diff --git a/Makefile b/Makefile index bafaaa6..2403747 100644 --- a/Makefile +++ b/Makefile @@ -10,13 +10,15 @@ install: cp android-config.h android-version.h $(DESTDIR)/$(INCLUDEDIR) cp android-headers.pc $(DESTDIR)/$(PKGCONFIGDIR) sed -i -e s:prefix=/usr:prefix=$(PREFIX):g $(DESTDIR)/$(PKGCONFIGDIR)/android-headers.pc + cp -r android $(DESTDIR)/$(INCLUDEDIR) + cp -r cutils $(DESTDIR)/$(INCLUDEDIR) cp -r hardware $(DESTDIR)/$(INCLUDEDIR) cp -r hardware_legacy $(DESTDIR)/$(INCLUDEDIR) - cp -r cutils $(DESTDIR)/$(INCLUDEDIR) - cp -r system $(DESTDIR)/$(INCLUDEDIR) - cp -r android $(DESTDIR)/$(INCLUDEDIR) cp -r linux $(DESTDIR)/$(INCLUDEDIR) - cp -r sync $(DESTDIR)/$(INCLUDEDIR) - cp -r libnfc-nxp $(DESTDIR)/$(INCLUDEDIR) - cp -r private $(DESTDIR)/$(INCLUDEDIR) cp -r log $(DESTDIR)/$(INCLUDEDIR) + cp -r nativebase $(DESTDIR)/$(INCLUDEDIR) + cp -r ndk $(DESTDIR)/$(INCLUDEDIR) + cp -r private $(DESTDIR)/$(INCLUDEDIR) + cp -r sync $(DESTDIR)/$(INCLUDEDIR) + cp -r system $(DESTDIR)/$(INCLUDEDIR) + cp -r vndk $(DESTDIR)/$(INCLUDEDIR) diff --git a/android-config.h b/android-config.h index d2cd9a1..235a224 100644 --- a/android-config.h +++ b/android-config.h @@ -4,7 +4,7 @@ /* When android is built for a specific device the build is modified by BoardConfig.mk and possibly other mechanisms. eg - device/samsung/i9305/BoardConfig.mk: + device/samsung/i9305/BoardConfig.mk: COMMON_GLOBAL_CFLAGS += -DCAMERA_WITH_CITYID_PARAM device/samsung/smdk4412-common/BoardCommonConfig.mk: COMMON_GLOBAL_CFLAGS += -DEXYNOS4_ENHANCEMENTS @@ -15,12 +15,10 @@ Typically it is generated at hardware adaptation time. - The CONFIG GOES HERE line can be used by automation to modify + The CONFIG GOES... line below can be used by automation to modify this file. */ #include -/* CONFIG GOES HERE */ - #endif diff --git a/android-headers.pc b/android-headers.pc index a1bb298..f6d6237 100644 --- a/android-headers.pc +++ b/android-headers.pc @@ -1,6 +1,6 @@ Name: Android header files Description: Header files needed to write applications for the Android platform -Version: 7.1.1 +Version: 9.0.0 prefix=/usr exec_prefix=${prefix} diff --git a/android-version.h b/android-version.h index 8e9af85..a350ea6 100644 --- a/android-version.h +++ b/android-version.h @@ -1,9 +1,9 @@ #ifndef ANDROID_VERSION_H_ #define ANDROID_VERSION_H_ -#define ANDROID_VERSION_MAJOR 7 -#define ANDROID_VERSION_MINOR 1 -#define ANDROID_VERSION_PATCH 1 +#define ANDROID_VERSION_MAJOR 9 +#define ANDROID_VERSION_MINOR 0 +#define ANDROID_VERSION_PATCH 0 #define ANDROID_VERSION_PATCH2 0 #define ANDROID_VERSION_PATCH3 0 diff --git a/android/api-level.h b/android/api-level.h new file mode 100644 index 0000000..7a909d7 --- /dev/null +++ b/android/api-level.h @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef ANDROID_API_LEVEL_H +#define ANDROID_API_LEVEL_H + +#include + +/* + * Magic version number for a current development build, which has + * not yet turned into an official release. + */ +#ifndef __ANDROID_API_FUTURE__ +#define __ANDROID_API_FUTURE__ 10000 +#endif + +#ifndef __ANDROID_API__ +#define __ANDROID_API__ __ANDROID_API_FUTURE__ +#else +#define __ANDROID_NDK__ 1 +#endif + +#define __ANDROID_API_G__ 9 +#define __ANDROID_API_I__ 14 +#define __ANDROID_API_J__ 16 +#define __ANDROID_API_J_MR1__ 17 +#define __ANDROID_API_J_MR2__ 18 +#define __ANDROID_API_K__ 19 +#define __ANDROID_API_L__ 21 +#define __ANDROID_API_L_MR1__ 22 +#define __ANDROID_API_M__ 23 +#define __ANDROID_API_N__ 24 +#define __ANDROID_API_N_MR1__ 25 +#define __ANDROID_API_O__ 26 +#define __ANDROID_API_O_MR1__ 27 +#define __ANDROID_API_P__ 28 + +#endif diff --git a/android/data_space.h b/android/data_space.h new file mode 100644 index 0000000..3ac1c58 --- /dev/null +++ b/android/data_space.h @@ -0,0 +1,108 @@ +/* + * Copyright 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file data_space.h + */ + +#ifndef ANDROID_DATA_SPACE_H +#define ANDROID_DATA_SPACE_H + +#include + +#include + +__BEGIN_DECLS + +/** + * ADataSpace. + */ +enum ADataSpace { + /** + * Default-assumption data space, when not explicitly specified. + * + * It is safest to assume the buffer is an image with sRGB primaries and + * encoding ranges, but the consumer and/or the producer of the data may + * simply be using defaults. No automatic gamma transform should be + * expected, except for a possible display gamma transform when drawn to a + * screen. + */ + ADATASPACE_UNKNOWN = 0, + + /** + * scRGB linear encoding: + * + * The red, green, and blue components are stored in extended sRGB space, + * but are linear, not gamma-encoded. + * The RGB primaries and the white point are the same as BT.709. + * + * The values are floating point. + * A pixel value of 1.0, 1.0, 1.0 corresponds to sRGB white (D65) at 80 nits. + * Values beyond the range [0.0 - 1.0] would correspond to other colors + * spaces and/or HDR content. + */ + ADATASPACE_SCRGB_LINEAR = 406913024, // STANDARD_BT709 | TRANSFER_LINEAR | RANGE_EXTENDED + + /** + * sRGB gamma encoding: + * + * The red, green and blue components are stored in sRGB space, and + * converted to linear space when read, using the SRGB transfer function + * for each of the R, G and B components. When written, the inverse + * transformation is performed. + * + * The alpha component, if present, is always stored in linear space and + * is left unmodified when read or written. + * + * Use full range and BT.709 standard. + */ + ADATASPACE_SRGB = 142671872, // STANDARD_BT709 | TRANSFER_SRGB | RANGE_FULL + + /** + * scRGB: + * + * The red, green, and blue components are stored in extended sRGB space, + * but are linear, not gamma-encoded. + * The RGB primaries and the white point are the same as BT.709. + * + * The values are floating point. + * A pixel value of 1.0, 1.0, 1.0 corresponds to sRGB white (D65) at 80 nits. + * Values beyond the range [0.0 - 1.0] would correspond to other colors + * spaces and/or HDR content. + */ + ADATASPACE_SCRGB = 411107328, // STANDARD_BT709 | TRANSFER_SRGB | RANGE_EXTENDED + + /** + * Display P3 + * + * Use same primaries and white-point as DCI-P3 + * but sRGB transfer function. + */ + ADATASPACE_DISPLAY_P3 = 143261696, // STANDARD_DCI_P3 | TRANSFER_SRGB | RANGE_FULL + + /** + * ITU-R Recommendation 2020 (BT.2020) + * + * Ultra High-definition television + * + * Use full range, SMPTE 2084 (PQ) transfer and BT2020 standard + */ + ADATASPACE_BT2020_PQ = 163971072, // STANDARD_BT2020 | TRANSFER_ST2084 | RANGE_FULL +}; + +__END_DECLS + +#endif // ANDROID_DATA_SPACE_H diff --git a/android/dlext.h b/android/dlext.h new file mode 100644 index 0000000..2b4169e --- /dev/null +++ b/android/dlext.h @@ -0,0 +1,182 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __ANDROID_DLEXT_H__ +#define __ANDROID_DLEXT_H__ + +#include +#include +#include +#include +#include /* for off64_t */ + +/** + * \file + * Advanced dynamic library opening support. Most users will want to use + * the standard [dlopen(3)](http://man7.org/linux/man-pages/man3/dlopen.3.html) + * functionality in `` instead. + */ + +__BEGIN_DECLS + +/** Bitfield definitions for `android_dlextinfo::flags`. */ +enum { + /** + * When set, the `reserved_addr` and `reserved_size` fields must point to an + * already-reserved region of address space which will be used to load the + * library if it fits. + * + * If the reserved region is not large enough, loading will fail. + */ + ANDROID_DLEXT_RESERVED_ADDRESS = 0x1, + + /** + * Like `ANDROID_DLEXT_RESERVED_ADDRESS`, but if the reserved region is not large enough, + * the linker will choose an available address instead. + */ + ANDROID_DLEXT_RESERVED_ADDRESS_HINT = 0x2, + + /** + * When set, write the GNU RELRO section of the mapped library to `relro_fd` + * after relocation has been performed, to allow it to be reused by another + * process loading the same library at the same address. This implies + * `ANDROID_DLEXT_USE_RELRO`. + * + * This is mainly useful for the system WebView implementation. + */ + ANDROID_DLEXT_WRITE_RELRO = 0x4, + + /** + * When set, compare the GNU RELRO section of the mapped library to `relro_fd` + * after relocation has been performed, and replace any relocated pages that + * are identical with a version mapped from the file. + * + * This is mainly useful for the system WebView implementation. + */ + ANDROID_DLEXT_USE_RELRO = 0x8, + + /** + * Use `library_fd` instead of opening the file by name. + * The filename parameter is still used to identify the library. + */ + ANDROID_DLEXT_USE_LIBRARY_FD = 0x10, + + /** + * If opening a library using `library_fd` read it starting at `library_fd_offset`. + * This is mainly useful for loading a library stored within another file (such as uncompressed + * inside a ZIP archive). + * This flag is only valid when `ANDROID_DLEXT_USE_LIBRARY_FD` is set. + */ + ANDROID_DLEXT_USE_LIBRARY_FD_OFFSET = 0x20, + + /** + * When set, do not use `stat(2)` to check if the library has already been loaded. + * + * This flag allows forced loading of the library in the case when for some + * reason multiple ELF files share the same filename (because the already-loaded + * library has been removed and overwritten, for example). + * + * Note that if the library has the same `DT_SONAME` as an old one and some other + * library has the soname in its `DT_NEEDED` list, the first one will be used to resolve any + * dependencies. + */ + ANDROID_DLEXT_FORCE_LOAD = 0x40, + + /** + * When set, if the minimum `p_vaddr` of the ELF file's `PT_LOAD` segments is non-zero, + * the dynamic linker will load it at that address. + * + * This flag is for ART internal use only. + */ + ANDROID_DLEXT_FORCE_FIXED_VADDR = 0x80, + + /** + * Instructs dlopen to load the library at the address specified by reserved_addr. + * + * The difference between `ANDROID_DLEXT_LOAD_AT_FIXED_ADDRESS` and + * `ANDROID_DLEXT_RESERVED_ADDRESS` is that for `ANDROID_DLEXT_LOAD_AT_FIXED_ADDRESS` the linker + * reserves memory at `reserved_addr` whereas for `ANDROID_DLEXT_RESERVED_ADDRESS` the linker + * relies on the caller to reserve the memory. + * + * This flag can be used with `ANDROID_DLEXT_FORCE_FIXED_VADDR`. When + * `ANDROID_DLEXT_FORCE_FIXED_VADDR` is set and `load_bias` is not 0 (`load_bias` is the + * minimum `p_vaddr` of all `PT_LOAD` segments) this flag is ignored because the linker has to + * pick one address over the other and this way is more convenient for ART. + * Note that `ANDROID_DLEXT_FORCE_FIXED_VADDR` does not generate an error when the minimum + * `p_vaddr` is 0. + * + * Cannot be used with `ANDROID_DLEXT_RESERVED_ADDRESS` or `ANDROID_DLEXT_RESERVED_ADDRESS_HINT`. + * + * This flag is for ART internal use only. + */ + ANDROID_DLEXT_LOAD_AT_FIXED_ADDRESS = 0x100, + + /** + * This flag used to load library in a different namespace. The namespace is + * specified in `library_namespace`. + * + * This flag is for internal use only (since there is no NDK API for namespaces). + */ + ANDROID_DLEXT_USE_NAMESPACE = 0x200, + + /** Mask of valid bits. */ + ANDROID_DLEXT_VALID_FLAG_BITS = ANDROID_DLEXT_RESERVED_ADDRESS | + ANDROID_DLEXT_RESERVED_ADDRESS_HINT | + ANDROID_DLEXT_WRITE_RELRO | + ANDROID_DLEXT_USE_RELRO | + ANDROID_DLEXT_USE_LIBRARY_FD | + ANDROID_DLEXT_USE_LIBRARY_FD_OFFSET | + ANDROID_DLEXT_FORCE_LOAD | + ANDROID_DLEXT_FORCE_FIXED_VADDR | + ANDROID_DLEXT_LOAD_AT_FIXED_ADDRESS | + ANDROID_DLEXT_USE_NAMESPACE, +}; + +struct android_namespace_t; + +/** Used to pass Android-specific arguments to `android_dlopen_ext`. */ +typedef struct { + /** A bitmask of `ANDROID_DLEXT_` enum values. */ + uint64_t flags; + + /** Used by `ANDROID_DLEXT_RESERVED_ADDRESS` and `ANDROID_DLEXT_RESERVED_ADDRESS_HINT`. */ + void* reserved_addr; + /** Used by `ANDROID_DLEXT_RESERVED_ADDRESS` and `ANDROID_DLEXT_RESERVED_ADDRESS_HINT`. */ + size_t reserved_size; + + /** Used by `ANDROID_DLEXT_WRITE_RELRO` and `ANDROID_DLEXT_USE_RELRO`. */ + int relro_fd; + + /** Used by `ANDROID_DLEXT_USE_LIBRARY_FD`. */ + int library_fd; + /** Used by `ANDROID_DLEXT_USE_LIBRARY_FD_OFFSET` */ + off64_t library_fd_offset; + + /** Used by `ANDROID_DLEXT_USE_NAMESPACE`. */ + struct android_namespace_t* library_namespace; +} android_dlextinfo; + +/** + * Opens the given library. The `__filename` and `__flags` arguments are + * the same as for [dlopen(3)](http://man7.org/linux/man-pages/man3/dlopen.3.html), + * with the Android-specific flags supplied via the `flags` member of `__info`. + */ +void* android_dlopen_ext(const char* __filename, int __flags, const android_dlextinfo* __info) + __INTRODUCED_IN(21); + +__END_DECLS + +#endif diff --git a/android/hardware_buffer.h b/android/hardware_buffer.h new file mode 100644 index 0000000..78cec41 --- /dev/null +++ b/android/hardware_buffer.h @@ -0,0 +1,307 @@ +/* + * Copyright 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file hardware_buffer.h + */ + +#ifndef ANDROID_HARDWARE_BUFFER_H +#define ANDROID_HARDWARE_BUFFER_H + +#include + +#include + +#include + +__BEGIN_DECLS + +/** + * Buffer pixel formats. + */ +enum { + /** + * Corresponding formats: + * Vulkan: VK_FORMAT_R8G8B8A8_UNORM + * OpenGL ES: GL_RGBA8 + */ + AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM = 1, + + /** + * 32 bits per pixel, 8 bits per channel format where alpha values are + * ignored (always opaque). + * Corresponding formats: + * Vulkan: VK_FORMAT_R8G8B8A8_UNORM + * OpenGL ES: GL_RGB8 + */ + AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM = 2, + + /** + * Corresponding formats: + * Vulkan: VK_FORMAT_R8G8B8_UNORM + * OpenGL ES: GL_RGB8 + */ + AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM = 3, + + /** + * Corresponding formats: + * Vulkan: VK_FORMAT_R5G6B5_UNORM_PACK16 + * OpenGL ES: GL_RGB565 + */ + AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM = 4, + + /** + * Corresponding formats: + * Vulkan: VK_FORMAT_R16G16B16A16_SFLOAT + * OpenGL ES: GL_RGBA16F + */ + AHARDWAREBUFFER_FORMAT_R16G16B16A16_FLOAT = 0x16, + + /** + * Corresponding formats: + * Vulkan: VK_FORMAT_A2B10G10R10_UNORM_PACK32 + * OpenGL ES: GL_RGB10_A2 + */ + AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM = 0x2b, + + /** + * An opaque binary blob format that must have height 1, with width equal to + * the buffer size in bytes. + */ + AHARDWAREBUFFER_FORMAT_BLOB = 0x21, + + /** + * Corresponding formats: + * Vulkan: VK_FORMAT_D16_UNORM + * OpenGL ES: GL_DEPTH_COMPONENT16 + */ + AHARDWAREBUFFER_FORMAT_D16_UNORM = 0x30, + + /** + * Corresponding formats: + * Vulkan: VK_FORMAT_X8_D24_UNORM_PACK32 + * OpenGL ES: GL_DEPTH_COMPONENT24 + */ + AHARDWAREBUFFER_FORMAT_D24_UNORM = 0x31, + + /** + * Corresponding formats: + * Vulkan: VK_FORMAT_D24_UNORM_S8_UINT + * OpenGL ES: GL_DEPTH24_STENCIL8 + */ + AHARDWAREBUFFER_FORMAT_D24_UNORM_S8_UINT = 0x32, + + /** + * Corresponding formats: + * Vulkan: VK_FORMAT_D32_SFLOAT + * OpenGL ES: GL_DEPTH_COMPONENT32F + */ + AHARDWAREBUFFER_FORMAT_D32_FLOAT = 0x33, + + /** + * Corresponding formats: + * Vulkan: VK_FORMAT_D32_SFLOAT_S8_UINT + * OpenGL ES: GL_DEPTH32F_STENCIL8 + */ + AHARDWAREBUFFER_FORMAT_D32_FLOAT_S8_UINT = 0x34, + + /** + * Corresponding formats: + * Vulkan: VK_FORMAT_S8_UINT + * OpenGL ES: GL_STENCIL_INDEX8 + */ + AHARDWAREBUFFER_FORMAT_S8_UINT = 0x35, +}; + +/** + * Buffer usage flags, specifying how the buffer will be accessed. + */ +enum { + /// The buffer will never be read by the CPU. + AHARDWAREBUFFER_USAGE_CPU_READ_NEVER = 0UL, + /// The buffer will sometimes be read by the CPU. + AHARDWAREBUFFER_USAGE_CPU_READ_RARELY = 2UL, + /// The buffer will often be read by the CPU. + AHARDWAREBUFFER_USAGE_CPU_READ_OFTEN = 3UL, + /// CPU read value mask. + AHARDWAREBUFFER_USAGE_CPU_READ_MASK = 0xFUL, + + /// The buffer will never be written by the CPU. + AHARDWAREBUFFER_USAGE_CPU_WRITE_NEVER = 0UL << 4, + /// The buffer will sometimes be written to by the CPU. + AHARDWAREBUFFER_USAGE_CPU_WRITE_RARELY = 2UL << 4, + /// The buffer will often be written to by the CPU. + AHARDWAREBUFFER_USAGE_CPU_WRITE_OFTEN = 3UL << 4, + /// CPU write value mask. + AHARDWAREBUFFER_USAGE_CPU_WRITE_MASK = 0xFUL << 4, + + /// The buffer will be read from by the GPU as a texture. + AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE = 1UL << 8, + /** + * The buffer will be written to by the GPU as a framebuffer attachment. + * Note that the name of this flag is somewhat misleading: it does not imply + * that the buffer contains a color format. A buffer with depth or stencil + * format that will be used as a framebuffer attachment should also have + * this flag. + */ + AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT = 1UL << 9, + /// The buffer must not be used outside of a protected hardware path. + AHARDWAREBUFFER_USAGE_PROTECTED_CONTENT = 1UL << 14, + /// The buffer will be read by a hardware video encoder. + AHARDWAREBUFFER_USAGE_VIDEO_ENCODE = 1UL << 16, + /// The buffer will be used for direct writes from sensors. + AHARDWAREBUFFER_USAGE_SENSOR_DIRECT_DATA = 1UL << 23, + /// The buffer will be used as a shader storage or uniform buffer object. + AHARDWAREBUFFER_USAGE_GPU_DATA_BUFFER = 1UL << 24, + /// The buffer will be used as a cube map texture. + AHARDWAREBUFFER_USAGE_GPU_CUBE_MAP = 1UL << 25, + /// The buffer contains a complete mipmap hierarchy. + AHARDWAREBUFFER_USAGE_GPU_MIPMAP_COMPLETE = 1UL << 26, + + AHARDWAREBUFFER_USAGE_VENDOR_0 = 1ULL << 28, + AHARDWAREBUFFER_USAGE_VENDOR_1 = 1ULL << 29, + AHARDWAREBUFFER_USAGE_VENDOR_2 = 1ULL << 30, + AHARDWAREBUFFER_USAGE_VENDOR_3 = 1ULL << 31, + AHARDWAREBUFFER_USAGE_VENDOR_4 = 1ULL << 48, + AHARDWAREBUFFER_USAGE_VENDOR_5 = 1ULL << 49, + AHARDWAREBUFFER_USAGE_VENDOR_6 = 1ULL << 50, + AHARDWAREBUFFER_USAGE_VENDOR_7 = 1ULL << 51, + AHARDWAREBUFFER_USAGE_VENDOR_8 = 1ULL << 52, + AHARDWAREBUFFER_USAGE_VENDOR_9 = 1ULL << 53, + AHARDWAREBUFFER_USAGE_VENDOR_10 = 1ULL << 54, + AHARDWAREBUFFER_USAGE_VENDOR_11 = 1ULL << 55, + AHARDWAREBUFFER_USAGE_VENDOR_12 = 1ULL << 56, + AHARDWAREBUFFER_USAGE_VENDOR_13 = 1ULL << 57, + AHARDWAREBUFFER_USAGE_VENDOR_14 = 1ULL << 58, + AHARDWAREBUFFER_USAGE_VENDOR_15 = 1ULL << 59, + AHARDWAREBUFFER_USAGE_VENDOR_16 = 1ULL << 60, + AHARDWAREBUFFER_USAGE_VENDOR_17 = 1ULL << 61, + AHARDWAREBUFFER_USAGE_VENDOR_18 = 1ULL << 62, + AHARDWAREBUFFER_USAGE_VENDOR_19 = 1ULL << 63, +}; + +/** + * Buffer description. Used for allocating new buffers and querying parameters + * of existing ones. + */ +typedef struct AHardwareBuffer_Desc { + uint32_t width; ///< Width in pixels. + uint32_t height; ///< Height in pixels. + uint32_t layers; ///< Number of images in an image array. + uint32_t format; ///< One of AHARDWAREBUFFER_FORMAT_* + uint64_t usage; ///< Combination of AHARDWAREBUFFER_USAGE_* + uint32_t stride; ///< Row stride in pixels, ignored for AHardwareBuffer_allocate() + uint32_t rfu0; ///< Initialize to zero, reserved for future use. + uint64_t rfu1; ///< Initialize to zero, reserved for future use. +} AHardwareBuffer_Desc; + +typedef struct AHardwareBuffer AHardwareBuffer; + +/** + * Allocates a buffer that backs an AHardwareBuffer using the passed + * AHardwareBuffer_Desc. + * + * \return 0 on success, or an error number of the allocation fails for + * any reason. The returned buffer has a reference count of 1. + */ +int AHardwareBuffer_allocate(const AHardwareBuffer_Desc* desc, + AHardwareBuffer** outBuffer); +/** + * Acquire a reference on the given AHardwareBuffer object. This prevents the + * object from being deleted until the last reference is removed. + */ +void AHardwareBuffer_acquire(AHardwareBuffer* buffer); + +/** + * Remove a reference that was previously acquired with + * AHardwareBuffer_acquire(). + */ +void AHardwareBuffer_release(AHardwareBuffer* buffer); + +/** + * Return a description of the AHardwareBuffer in the passed + * AHardwareBuffer_Desc struct. + */ +void AHardwareBuffer_describe(const AHardwareBuffer* buffer, + AHardwareBuffer_Desc* outDesc); + +/** + * Lock the AHardwareBuffer for reading or writing, depending on the usage flags + * passed. This call may block if the hardware needs to finish rendering or if + * CPU caches need to be synchronized, or possibly for other implementation- + * specific reasons. If fence is not negative, then it specifies a fence file + * descriptor that will be signaled when the buffer is locked, otherwise the + * caller will block until the buffer is available. + * + * If \a rect is not NULL, the caller promises to modify only data in the area + * specified by rect. If rect is NULL, the caller may modify the contents of the + * entire buffer. + * + * The content of the buffer outside of the specified rect is NOT modified + * by this call. + * + * The \a usage parameter may only specify AHARDWAREBUFFER_USAGE_CPU_*. If set, + * then outVirtualAddress is filled with the address of the buffer in virtual + * memory. + * + * THREADING CONSIDERATIONS: + * + * It is legal for several different threads to lock a buffer for read access; + * none of the threads are blocked. + * + * Locking a buffer simultaneously for write or read/write is undefined, but + * will neither terminate the process nor block the caller; AHardwareBuffer_lock + * may return an error or leave the buffer's content into an indeterminate + * state. + * + * \return 0 on success, -EINVAL if \a buffer is NULL or if the usage + * flags are not a combination of AHARDWAREBUFFER_USAGE_CPU_*, or an error + * number of the lock fails for any reason. + */ +int AHardwareBuffer_lock(AHardwareBuffer* buffer, uint64_t usage, + int32_t fence, const ARect* rect, void** outVirtualAddress); + +/** + * Unlock the AHardwareBuffer; must be called after all changes to the buffer + * are completed by the caller. If fence is not NULL then it will be set to a + * file descriptor that is signaled when all pending work on the buffer is + * completed. The caller is responsible for closing the fence when it is no + * longer needed. + * + * \return 0 on success, -EINVAL if \a buffer is NULL, or an error + * number if the unlock fails for any reason. + */ +int AHardwareBuffer_unlock(AHardwareBuffer* buffer, int32_t* fence); + +/** + * Send the AHardwareBuffer to an AF_UNIX socket. + * + * \return 0 on success, -EINVAL if \a buffer is NULL, or an error + * number if the operation fails for any reason. + */ +int AHardwareBuffer_sendHandleToUnixSocket(const AHardwareBuffer* buffer, int socketFd); + +/** + * Receive the AHardwareBuffer from an AF_UNIX socket. + * + * \return 0 on success, -EINVAL if \a outBuffer is NULL, or an error + * number if the operation fails for any reason. + */ +int AHardwareBuffer_recvHandleFromUnixSocket(int socketFd, AHardwareBuffer** outBuffer); + +__END_DECLS + +#endif // ANDROID_HARDWARE_BUFFER_H diff --git a/android/log.h b/android/log.h index a4973b2..28c87e4 100644 --- a/android/log.h +++ b/android/log.h @@ -34,9 +34,11 @@ * - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES */ -/* - * Support routines to send messages to the Android in-kernel log buffer, - * which can later be accessed through the 'logcat' utility. +/** + * \file + * + * Support routines to send messages to the Android log buffer, + * which can later be accessed through the `logcat` utility. * * Each log message must have * - a priority @@ -47,24 +49,22 @@ * and should be reasonably small. * * Log message text may be truncated to less than an implementation-specific - * limit (e.g. 1023 characters max). + * limit (1023 bytes). * * Note that a newline character ("\n") will be appended automatically to your - * log message, if not already there. It is not possible to send several messages - * and have them appear on a single line in logcat. + * log message, if not already there. It is not possible to send several + * messages and have them appear on a single line in logcat. * - * PLEASE USE LOGS WITH MODERATION: + * Please use logging in moderation: * * - Sending log messages eats CPU and slow down your application and the * system. * - * - The circular log buffer is pretty small (<64KB), sending many messages - * might push off other important log messages from the rest of the system. + * - The circular log buffer is pretty small, so sending many messages + * will hide other important log messages. * * - In release builds, only send log messages to account for exceptional * conditions. - * - * NOTE: These functions MUST be implemented by /system/lib/liblog.so */ #include @@ -73,72 +73,131 @@ extern "C" { #endif -/* - * Android log priority values, in ascending priority order. +/** + * Android log priority values, in increasing order of priority. */ typedef enum android_LogPriority { - ANDROID_LOG_UNKNOWN = 0, - ANDROID_LOG_DEFAULT, /* only for SetMinPriority() */ - ANDROID_LOG_VERBOSE, - ANDROID_LOG_DEBUG, - ANDROID_LOG_INFO, - ANDROID_LOG_WARN, - ANDROID_LOG_ERROR, - ANDROID_LOG_FATAL, - ANDROID_LOG_SILENT, /* only for SetMinPriority(); must be last */ + /** For internal use only. */ + ANDROID_LOG_UNKNOWN = 0, + /** The default priority, for internal use only. */ + ANDROID_LOG_DEFAULT, /* only for SetMinPriority() */ + /** Verbose logging. Should typically be disabled for a release apk. */ + ANDROID_LOG_VERBOSE, + /** Debug logging. Should typically be disabled for a release apk. */ + ANDROID_LOG_DEBUG, + /** Informational logging. Should typically be disabled for a release apk. */ + ANDROID_LOG_INFO, + /** Warning logging. For use with recoverable failures. */ + ANDROID_LOG_WARN, + /** Error logging. For use with unrecoverable failures. */ + ANDROID_LOG_ERROR, + /** Fatal logging. For use when aborting. */ + ANDROID_LOG_FATAL, + /** For internal use only. */ + ANDROID_LOG_SILENT, /* only for SetMinPriority(); must be last */ } android_LogPriority; -/* - * Release any logger resources (a new log write will immediately re-acquire) - */ -void __android_log_close(); - -/* - * Send a simple string to the log. +/** + * Writes the constant string `text` to the log, with priority `prio` and tag + * `tag`. */ -int __android_log_write(int prio, const char *tag, const char *text); +int __android_log_write(int prio, const char* tag, const char* text); -/* - * Send a formatted string to the log, used like printf(fmt,...) +/** + * Writes a formatted string to the log, with priority `prio` and tag `tag`. + * The details of formatting are the same as for + * [printf(3)](http://man7.org/linux/man-pages/man3/printf.3.html). */ -int __android_log_print(int prio, const char *tag, const char *fmt, ...) +int __android_log_print(int prio, const char* tag, const char* fmt, ...) #if defined(__GNUC__) #ifdef __USE_MINGW_ANSI_STDIO #if __USE_MINGW_ANSI_STDIO - __attribute__ ((format(gnu_printf, 3, 4))) + __attribute__((__format__(gnu_printf, 3, 4))) #else - __attribute__ ((format(printf, 3, 4))) + __attribute__((__format__(printf, 3, 4))) #endif #else - __attribute__ ((format(printf, 3, 4))) + __attribute__((__format__(printf, 3, 4))) #endif #endif ; -/* - * A variant of __android_log_print() that takes a va_list to list - * additional parameters. +/** + * Equivalent to `__android_log_print`, but taking a `va_list`. + * (If `__android_log_print` is like `printf`, this is like `vprintf`.) */ -int __android_log_vprint(int prio, const char *tag, - const char *fmt, va_list ap); +int __android_log_vprint(int prio, const char* tag, const char* fmt, va_list ap) +#if defined(__GNUC__) +#ifdef __USE_MINGW_ANSI_STDIO +#if __USE_MINGW_ANSI_STDIO + __attribute__((__format__(gnu_printf, 3, 0))) +#else + __attribute__((__format__(printf, 3, 0))) +#endif +#else + __attribute__((__format__(printf, 3, 0))) +#endif +#endif + ; -/* - * Log an assertion failure and abort the process to have a chance - * to inspect it if a debugger is attached. This uses the FATAL priority. +/** + * Writes an assertion failure to the log (as `ANDROID_LOG_FATAL`) and to + * stderr, before calling + * [abort(3)](http://man7.org/linux/man-pages/man3/abort.3.html). + * + * If `fmt` is non-null, `cond` is unused. If `fmt` is null, the string + * `Assertion failed: %s` is used with `cond` as the string argument. + * If both `fmt` and `cond` are null, a default string is provided. + * + * Most callers should use + * [assert(3)](http://man7.org/linux/man-pages/man3/assert.3.html) from + * `` instead, or the `__assert` and `__assert2` functions provided by + * bionic if more control is needed. They support automatically including the + * source filename and line number more conveniently than this function. */ -void __android_log_assert(const char *cond, const char *tag, - const char *fmt, ...) +void __android_log_assert(const char* cond, const char* tag, const char* fmt, + ...) #if defined(__GNUC__) - __attribute__ ((__noreturn__)) + __attribute__((__noreturn__)) #ifdef __USE_MINGW_ANSI_STDIO #if __USE_MINGW_ANSI_STDIO - __attribute__ ((format(gnu_printf, 3, 4))) + __attribute__((__format__(gnu_printf, 3, 4))) #else - __attribute__ ((format(printf, 3, 4))) + __attribute__((__format__(printf, 3, 4))) #endif #else - __attribute__ ((format(printf, 3, 4))) + __attribute__((__format__(printf, 3, 4))) +#endif +#endif + ; + +#ifndef log_id_t_defined +#define log_id_t_defined +typedef enum log_id { + LOG_ID_MIN = 0, + + LOG_ID_MAIN = 0, + LOG_ID_RADIO = 1, + LOG_ID_EVENTS = 2, + LOG_ID_SYSTEM = 3, + LOG_ID_CRASH = 4, + LOG_ID_STATS = 5, + LOG_ID_SECURITY = 6, + LOG_ID_KERNEL = 7, /* place last, third-parties can not use it */ + + LOG_ID_MAX +} log_id_t; #endif + +/* + * Send a simple string to the log. + */ +int __android_log_buf_write(int bufID, int prio, const char* tag, + const char* text); +int __android_log_buf_print(int bufID, int prio, const char* tag, + const char* fmt, ...) +#if defined(__GNUC__) + __attribute__((__format__(printf, 4, 5))) #endif ; diff --git a/android/native_window.h b/android/native_window.h new file mode 100644 index 0000000..d5e5e9d --- /dev/null +++ b/android/native_window.h @@ -0,0 +1,226 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup NativeActivity Native Activity + * @{ + */ + +/** + * @file native_window.h + * @brief API for accessing a native window. + */ + +#ifndef ANDROID_NATIVE_WINDOW_H +#define ANDROID_NATIVE_WINDOW_H + +#include + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Legacy window pixel format names, kept for backwards compatibility. + * New code and APIs should use AHARDWAREBUFFER_FORMAT_*. + */ +enum { + // NOTE: these values must match the values from graphics/common/x.x/types.hal + + /** Red: 8 bits, Green: 8 bits, Blue: 8 bits, Alpha: 8 bits. **/ + WINDOW_FORMAT_RGBA_8888 = AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM, + /** Red: 8 bits, Green: 8 bits, Blue: 8 bits, Unused: 8 bits. **/ + WINDOW_FORMAT_RGBX_8888 = AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM, + /** Red: 5 bits, Green: 6 bits, Blue: 5 bits. **/ + WINDOW_FORMAT_RGB_565 = AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM, +}; + +/** + * Transforms that can be applied to buffers as they are displayed to a window. + * + * Supported transforms are any combination of horizontal mirror, vertical + * mirror, and clockwise 90 degree rotation, in that order. Rotations of 180 + * and 270 degrees are made up of those basic transforms. + */ +enum ANativeWindowTransform { + ANATIVEWINDOW_TRANSFORM_IDENTITY = 0x00, + ANATIVEWINDOW_TRANSFORM_MIRROR_HORIZONTAL = 0x01, + ANATIVEWINDOW_TRANSFORM_MIRROR_VERTICAL = 0x02, + ANATIVEWINDOW_TRANSFORM_ROTATE_90 = 0x04, + + ANATIVEWINDOW_TRANSFORM_ROTATE_180 = ANATIVEWINDOW_TRANSFORM_MIRROR_HORIZONTAL | + ANATIVEWINDOW_TRANSFORM_MIRROR_VERTICAL, + ANATIVEWINDOW_TRANSFORM_ROTATE_270 = ANATIVEWINDOW_TRANSFORM_ROTATE_180 | + ANATIVEWINDOW_TRANSFORM_ROTATE_90, +}; + +struct ANativeWindow; +/** + * Opaque type that provides access to a native window. + * + * A pointer can be obtained using {@link ANativeWindow_fromSurface()}. + */ +typedef struct ANativeWindow ANativeWindow; + +/** + * Struct that represents a windows buffer. + * + * A pointer can be obtained using {@link ANativeWindow_lock()}. + */ +typedef struct ANativeWindow_Buffer { + /// The number of pixels that are shown horizontally. + int32_t width; + + /// The number of pixels that are shown vertically. + int32_t height; + + /// The number of *pixels* that a line in the buffer takes in + /// memory. This may be >= width. + int32_t stride; + + /// The format of the buffer. One of AHARDWAREBUFFER_FORMAT_* + int32_t format; + + /// The actual bits. + void* bits; + + /// Do not touch. + uint32_t reserved[6]; +} ANativeWindow_Buffer; + +/** + * Acquire a reference on the given {@link ANativeWindow} object. This prevents the object + * from being deleted until the reference is removed. + */ +void ANativeWindow_acquire(ANativeWindow* window); + +/** + * Remove a reference that was previously acquired with {@link ANativeWindow_acquire()}. + */ +void ANativeWindow_release(ANativeWindow* window); + +/** + * Return the current width in pixels of the window surface. + * + * \return negative value on error. + */ +int32_t ANativeWindow_getWidth(ANativeWindow* window); + +/** + * Return the current height in pixels of the window surface. + * + * \return a negative value on error. + */ +int32_t ANativeWindow_getHeight(ANativeWindow* window); + +/** + * Return the current pixel format (AHARDWAREBUFFER_FORMAT_*) of the window surface. + * + * \return a negative value on error. + */ +int32_t ANativeWindow_getFormat(ANativeWindow* window); + +/** + * Change the format and size of the window buffers. + * + * The width and height control the number of pixels in the buffers, not the + * dimensions of the window on screen. If these are different than the + * window's physical size, then its buffer will be scaled to match that size + * when compositing it to the screen. The width and height must be either both zero + * or both non-zero. + * + * For all of these parameters, if 0 is supplied then the window's base + * value will come back in force. + * + * \param width width of the buffers in pixels. + * \param height height of the buffers in pixels. + * \param format one of AHARDWAREBUFFER_FORMAT_* constants. + * \return 0 for success, or a negative value on error. + */ +int32_t ANativeWindow_setBuffersGeometry(ANativeWindow* window, + int32_t width, int32_t height, int32_t format); + +/** + * Lock the window's next drawing surface for writing. + * inOutDirtyBounds is used as an in/out parameter, upon entering the + * function, it contains the dirty region, that is, the region the caller + * intends to redraw. When the function returns, inOutDirtyBounds is updated + * with the actual area the caller needs to redraw -- this region is often + * extended by {@link ANativeWindow_lock}. + * + * \return 0 for success, or a negative value on error. + */ +int32_t ANativeWindow_lock(ANativeWindow* window, ANativeWindow_Buffer* outBuffer, + ARect* inOutDirtyBounds); + +/** + * Unlock the window's drawing surface after previously locking it, + * posting the new buffer to the display. + * + * \return 0 for success, or a negative value on error. + */ +int32_t ANativeWindow_unlockAndPost(ANativeWindow* window); + +#if __ANDROID_API__ >= __ANDROID_API_O__ + +/** + * Set a transform that will be applied to future buffers posted to the window. + * + * \param transform combination of {@link ANativeWindowTransform} flags + * \return 0 for success, or -EINVAL if \p transform is invalid + */ +int32_t ANativeWindow_setBuffersTransform(ANativeWindow* window, int32_t transform); + +#endif // __ANDROID_API__ >= __ANDROID_API_O__ + +#if __ANDROID_API__ >= __ANDROID_API_P__ + +/** + * All buffers queued after this call will be associated with the dataSpace + * parameter specified. + * + * dataSpace specifies additional information about the buffer. + * For example, it can be used to convey the color space of the image data in + * the buffer, or it can be used to indicate that the buffers contain depth + * measurement data instead of color images. The default dataSpace is 0, + * ADATASPACE_UNKNOWN, unless it has been overridden by the producer. + * + * \param dataSpace data space of all buffers queued after this call. + * \return 0 for success, -EINVAL if window is invalid or the dataspace is not + * supported. + */ +int32_t ANativeWindow_setBuffersDataSpace(ANativeWindow* window, int32_t dataSpace); + +/** + * Get the dataspace of the buffers in window. + * \return the dataspace of buffers in window, ADATASPACE_UNKNOWN is returned if + * dataspace is unknown, or -EINVAL if window is invalid. + */ +int32_t ANativeWindow_getBuffersDataSpace(ANativeWindow* window); + +#endif // __ANDROID_API__ >= __ANDROID_API_P__ + +#ifdef __cplusplus +}; +#endif + +#endif // ANDROID_NATIVE_WINDOW_H + +/** @} */ diff --git a/android/rect.h b/android/rect.h new file mode 100644 index 0000000..b36728e --- /dev/null +++ b/android/rect.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup NativeActivity Native Activity + * @{ + */ + +/** + * @file rect.h + */ + +#ifndef ANDROID_RECT_H +#define ANDROID_RECT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Rectangular window area. + * + * This is the NDK equivalent of the android.graphics.Rect class in Java. It is + * used with {@link ANativeActivityCallbacks::onContentRectChanged} event + * callback and the ANativeWindow_lock() function. + * + * In a valid ARect, left <= right and top <= bottom. ARect with left=0, top=10, + * right=1, bottom=11 contains only one pixel at x=0, y=10. + */ +typedef struct ARect { +#ifdef __cplusplus + typedef int32_t value_type; +#endif + /// Minimum X coordinate of the rectangle. + int32_t left; + /// Minimum Y coordinate of the rectangle. + int32_t top; + /// Maximum X coordinate of the rectangle. + int32_t right; + /// Maximum Y coordinate of the rectangle. + int32_t bottom; +} ARect; + +#ifdef __cplusplus +}; +#endif + +#endif // ANDROID_RECT_H + +/** @} */ diff --git a/android/set_abort_message.h b/android/set_abort_message.h new file mode 100644 index 0000000..3dde673 --- /dev/null +++ b/android/set_abort_message.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _SET_ABORT_MESSAGE_H +#define _SET_ABORT_MESSAGE_H + +#include + +__BEGIN_DECLS + +void android_set_abort_message(const char* __msg) __INTRODUCED_IN(21); + +__END_DECLS + +#endif diff --git a/cutils/android_filesystem_config.h b/cutils/android_filesystem_config.h new file mode 100644 index 0000000..5d17698 --- /dev/null +++ b/cutils/android_filesystem_config.h @@ -0,0 +1,202 @@ +/* + * Copyright (C) 2007 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * This file is consumed by build/tools/fs_config and is used + * for generating various files. Anything #define AID_ + * becomes the mapping for getpwnam/getpwuid, etc. The + * field is lowercased. + * For example: + * #define AID_FOO_BAR 6666 becomes a friendly name of "foo_bar" + * + * The above holds true with the exception of: + * mediacodec + * mediaex + * mediadrm + * Whose friendly names do not match the #define statements. + * + * Additionally, AID_OEM_RESERVED_START and AID_OEM_RESERVED_END + * can be used to define reserved OEM ranges used for sanity checks + * during the build process. The rules are, they must end with START/END + * The proper convention is incrementing a number like so: + * AID_OEM_RESERVED_START + * AID_OEM_RESERVED_1_START + * AID_OEM_RESERVED_2_START + * ... + * The same applies to the END. + * They are not required to be in order, but must not overlap each other and + * must define a START and END'ing range. START must be smaller than END. + */ + +#ifndef _ANDROID_FILESYSTEM_CONFIG_H_ +#define _ANDROID_FILESYSTEM_CONFIG_H_ + +#include + +#if !defined(__ANDROID_VNDK__) && !defined(EXCLUDE_FS_CONFIG_STRUCTURES) +#include +#endif + +/* This is the master Users and Groups config for the platform. + * DO NOT EVER RENUMBER + */ + +#define AID_ROOT 0 /* traditional unix root user */ +/* The following are for LTP and should only be used for testing */ +#define AID_DAEMON 1 /* traditional unix daemon owner */ +#define AID_BIN 2 /* traditional unix binaries owner */ + +#define AID_SYSTEM 1000 /* system server */ + +#define AID_RADIO 1001 /* telephony subsystem, RIL */ +#define AID_BLUETOOTH 1002 /* bluetooth subsystem */ +#define AID_GRAPHICS 1003 /* graphics devices */ +#define AID_INPUT 1004 /* input devices */ +#define AID_AUDIO 1005 /* audio devices */ +#define AID_CAMERA 1006 /* camera devices */ +#define AID_LOG 1007 /* log devices */ +#define AID_COMPASS 1008 /* compass device */ +#define AID_MOUNT 1009 /* mountd socket */ +#define AID_WIFI 1010 /* wifi subsystem */ +#define AID_ADB 1011 /* android debug bridge (adbd) */ +#define AID_INSTALL 1012 /* group for installing packages */ +#define AID_MEDIA 1013 /* mediaserver process */ +#define AID_DHCP 1014 /* dhcp client */ +#define AID_SDCARD_RW 1015 /* external storage write access */ +#define AID_VPN 1016 /* vpn system */ +#define AID_KEYSTORE 1017 /* keystore subsystem */ +#define AID_USB 1018 /* USB devices */ +#define AID_DRM 1019 /* DRM server */ +#define AID_MDNSR 1020 /* MulticastDNSResponder (service discovery) */ +#define AID_GPS 1021 /* GPS daemon */ +#define AID_UNUSED1 1022 /* deprecated, DO NOT USE */ +#define AID_MEDIA_RW 1023 /* internal media storage write access */ +#define AID_MTP 1024 /* MTP USB driver access */ +#define AID_UNUSED2 1025 /* deprecated, DO NOT USE */ +#define AID_DRMRPC 1026 /* group for drm rpc */ +#define AID_NFC 1027 /* nfc subsystem */ +#define AID_SDCARD_R 1028 /* external storage read access */ +#define AID_CLAT 1029 /* clat part of nat464 */ +#define AID_LOOP_RADIO 1030 /* loop radio devices */ +#define AID_MEDIA_DRM 1031 /* MediaDrm plugins */ +#define AID_PACKAGE_INFO 1032 /* access to installed package details */ +#define AID_SDCARD_PICS 1033 /* external storage photos access */ +#define AID_SDCARD_AV 1034 /* external storage audio/video access */ +#define AID_SDCARD_ALL 1035 /* access all users external storage */ +#define AID_LOGD 1036 /* log daemon */ +#define AID_SHARED_RELRO 1037 /* creator of shared GNU RELRO files */ +#define AID_DBUS 1038 /* dbus-daemon IPC broker process */ +#define AID_TLSDATE 1039 /* tlsdate unprivileged user */ +#define AID_MEDIA_EX 1040 /* mediaextractor process */ +#define AID_AUDIOSERVER 1041 /* audioserver process */ +#define AID_METRICS_COLL 1042 /* metrics_collector process */ +#define AID_METRICSD 1043 /* metricsd process */ +#define AID_WEBSERV 1044 /* webservd process */ +#define AID_DEBUGGERD 1045 /* debuggerd unprivileged user */ +#define AID_MEDIA_CODEC 1046 /* mediacodec process */ +#define AID_CAMERASERVER 1047 /* cameraserver process */ +#define AID_FIREWALL 1048 /* firewalld process */ +#define AID_TRUNKS 1049 /* trunksd process (TPM daemon) */ +#define AID_NVRAM 1050 /* Access-controlled NVRAM */ +#define AID_DNS 1051 /* DNS resolution daemon (system: netd) */ +#define AID_DNS_TETHER 1052 /* DNS resolution daemon (tether: dnsmasq) */ +#define AID_WEBVIEW_ZYGOTE 1053 /* WebView zygote process */ +#define AID_VEHICLE_NETWORK 1054 /* Vehicle network service */ +#define AID_MEDIA_AUDIO 1055 /* GID for audio files on internal media storage */ +#define AID_MEDIA_VIDEO 1056 /* GID for video files on internal media storage */ +#define AID_MEDIA_IMAGE 1057 /* GID for image files on internal media storage */ +#define AID_TOMBSTONED 1058 /* tombstoned user */ +#define AID_MEDIA_OBB 1059 /* GID for OBB files on internal media storage */ +#define AID_ESE 1060 /* embedded secure element (eSE) subsystem */ +#define AID_OTA_UPDATE 1061 /* resource tracking UID for OTA updates */ +#define AID_AUTOMOTIVE_EVS 1062 /* Automotive rear and surround view system */ +#define AID_LOWPAN 1063 /* LoWPAN subsystem */ +#define AID_HSM 1064 /* hardware security module subsystem */ +#define AID_RESERVED_DISK 1065 /* GID that has access to reserved disk space */ +#define AID_STATSD 1066 /* statsd daemon */ +#define AID_INCIDENTD 1067 /* incidentd daemon */ +#define AID_SECURE_ELEMENT 1068 /* secure element subsystem */ +/* Changes to this file must be made in AOSP, *not* in internal branches. */ + +#define AID_SHELL 2000 /* adb and debug shell user */ +#define AID_CACHE 2001 /* cache access */ +#define AID_DIAG 2002 /* access to diagnostic resources */ + +/* The range 2900-2999 is reserved for OEM, and must never be + * used here */ +#define AID_OEM_RESERVED_START 2900 +#define AID_OEM_RESERVED_END 2999 + +/* The 3000 series are intended for use as supplemental group id's only. + * They indicate special Android capabilities that the kernel is aware of. */ +#define AID_NET_BT_ADMIN 3001 /* bluetooth: create any socket */ +#define AID_NET_BT 3002 /* bluetooth: create sco, rfcomm or l2cap sockets */ +#define AID_INET 3003 /* can create AF_INET and AF_INET6 sockets */ +#define AID_NET_RAW 3004 /* can create raw INET sockets */ +#define AID_NET_ADMIN 3005 /* can configure interfaces and routing tables. */ +#define AID_NET_BW_STATS 3006 /* read bandwidth statistics */ +#define AID_NET_BW_ACCT 3007 /* change bandwidth statistics accounting */ +#define AID_READPROC 3009 /* Allow /proc read access */ +#define AID_WAKELOCK 3010 /* Allow system wakelock read/write access */ +#define AID_UHID 3011 /* Allow read/write to /dev/uhid node */ + +/* The range 5000-5999 is also reserved for OEM, and must never be used here. */ +#define AID_OEM_RESERVED_2_START 5000 +#define AID_OEM_RESERVED_2_END 5999 + +#define AID_EVERYBODY 9997 /* shared between all apps in the same profile */ +#define AID_MISC 9998 /* access to misc storage */ +#define AID_NOBODY 9999 + +#define AID_APP 10000 /* TODO: switch users over to AID_APP_START */ +#define AID_APP_START 10000 /* first app user */ +#define AID_APP_END 19999 /* last app user */ + +#define AID_CACHE_GID_START 20000 /* start of gids for apps to mark cached data */ +#define AID_CACHE_GID_END 29999 /* end of gids for apps to mark cached data */ + +#define AID_EXT_GID_START 30000 /* start of gids for apps to mark external data */ +#define AID_EXT_GID_END 39999 /* end of gids for apps to mark external data */ + +#define AID_EXT_CACHE_GID_START 40000 /* start of gids for apps to mark external cached data */ +#define AID_EXT_CACHE_GID_END 49999 /* end of gids for apps to mark external cached data */ + +#define AID_SHARED_GID_START 50000 /* start of gids for apps in each user to share */ +#define AID_SHARED_GID_END 59999 /* end of gids for apps in each user to share */ + +/* + * This is a magic number in the kernel and not something that was picked + * arbitrarily. This value is returned whenever a uid that has no mapping in the + * user namespace is returned to userspace: + * https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/highuid.h?h=v4.4#n40 + */ +#define AID_OVERFLOWUID 65534 /* unmapped user in the user namespace */ + +#define AID_ISOLATED_START 99000 /* start of uids for fully isolated sandboxed processes */ +#define AID_ISOLATED_END 99999 /* end of uids for fully isolated sandboxed processes */ + +#define AID_USER 100000 /* TODO: switch users over to AID_USER_OFFSET */ +#define AID_USER_OFFSET 100000 /* offset for uid ranges for each user */ + +/* + * android_ids has moved to pwd/grp functionality. + * If you need to add one, the structure is now + * auto-generated based on the AID_ constraints + * documented at the top of this header file. + * Also see build/tools/fs_config for more details. + */ + +#endif diff --git a/cutils/process_name.h b/cutils/android_get_control_file.h similarity index 57% rename from cutils/process_name.h rename to cutils/android_get_control_file.h index 1e72e5c..ed8fbf8 100644 --- a/cutils/process_name.h +++ b/cutils/android_get_control_file.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 The Android Open Source Project + * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,29 +14,24 @@ * limitations under the License. */ -/** - * Gives the current process a name. - */ +#ifndef __CUTILS_ANDROID_GET_CONTROL_FILE_H +#define __CUTILS_ANDROID_GET_CONTROL_FILE_H -#ifndef __PROCESS_NAME_H -#define __PROCESS_NAME_H +#define ANDROID_FILE_ENV_PREFIX "ANDROID_FILE_" #ifdef __cplusplus extern "C" { #endif -/** - * Sets the current process name. - * - * Warning: This leaks a string every time you call it. Use judiciously! +/* + * android_get_control_file - simple helper function to get the file + * descriptor of our init-managed file. `path' is the filename path as + * given in init.rc. Returns -1 on error. */ -void set_process_name(const char* process_name); - -/** Gets the current process name. */ -const char* get_process_name(void); +int android_get_control_file(const char* path); #ifdef __cplusplus } #endif -#endif /* __PROCESS_NAME_H */ +#endif /* __CUTILS_ANDROID_GET_CONTROL_FILE_H */ diff --git a/cutils/android_reboot.h b/cutils/android_reboot.h index a3861a0..99030ed 100644 --- a/cutils/android_reboot.h +++ b/cutils/android_reboot.h @@ -17,22 +17,28 @@ #ifndef __CUTILS_ANDROID_REBOOT_H__ #define __CUTILS_ANDROID_REBOOT_H__ -#include +#include __BEGIN_DECLS /* Commands */ -#define ANDROID_RB_RESTART 0xDEAD0001 +#define ANDROID_RB_RESTART 0xDEAD0001 /* deprecated. Use RESTART2. */ #define ANDROID_RB_POWEROFF 0xDEAD0002 #define ANDROID_RB_RESTART2 0xDEAD0003 +#define ANDROID_RB_THERMOFF 0xDEAD0004 /* Properties */ #define ANDROID_RB_PROPERTY "sys.powerctl" +/* Android reboot reason stored in this property */ +#define LAST_REBOOT_REASON_PROPERTY "persist.sys.boot.reason" + +/* Reboot or shutdown the system. + * This call uses ANDROID_RB_PROPERTY to request reboot to init process. + * Due to that, process calling this should have proper selinux permission + * to write to the property. Otherwise, the call will fail. + */ int android_reboot(int cmd, int flags, const char *arg); -int android_reboot_with_callback( - int cmd, int flags, const char *arg, - void (*cb_on_remount)(const struct mntent*)); __END_DECLS diff --git a/cutils/aref.h b/cutils/aref.h deleted file mode 100644 index 460ac02..0000000 --- a/cutils/aref.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _CUTILS_AREF_H_ -#define _CUTILS_AREF_H_ - -#include -#include - -#ifdef ANDROID_SMP -#include -#else -#include -#endif - -__BEGIN_DECLS - -#define AREF_TO_ITEM(aref, container, member) \ - (container *) (((char*) (aref)) - offsetof(container, member)) - -struct aref -{ - volatile int32_t count; -}; - -static inline void aref_init(struct aref *r) -{ - r->count = 1; -} - -static inline int32_t aref_count(struct aref *r) -{ - return r->count; -} - -static inline void aref_get(struct aref *r) -{ - android_atomic_inc(&r->count); -} - -static inline void aref_put(struct aref *r, void (*release)(struct aref *)) -{ - if (android_atomic_dec(&r->count) == 1) - release(r); -} - -__END_DECLS - -#endif // _CUTILS_AREF_H_ diff --git a/cutils/ashmem.h b/cutils/ashmem.h index 25b233e..d80caa6 100644 --- a/cutils/ashmem.h +++ b/cutils/ashmem.h @@ -12,10 +12,15 @@ #include +#if defined(__BIONIC__) +#include +#endif + #ifdef __cplusplus extern "C" { #endif +int ashmem_valid(int fd); int ashmem_create_region(const char *name, size_t size); int ashmem_set_prot_region(int fd, int prot); int ashmem_pin_region(int fd, size_t offset, size_t len); @@ -26,20 +31,4 @@ int ashmem_get_size_region(int fd); } #endif -#ifndef __ASHMEMIOC /* in case someone included too */ - -#define ASHMEM_NAME_LEN 256 - -#define ASHMEM_NAME_DEF "dev/ashmem" - -/* Return values from ASHMEM_PIN: Was the mapping purged while unpinned? */ -#define ASHMEM_NOT_PURGED 0 -#define ASHMEM_WAS_PURGED 1 - -/* Return values from ASHMEM_UNPIN: Is the mapping now pinned or unpinned? */ -#define ASHMEM_IS_UNPINNED 0 -#define ASHMEM_IS_PINNED 1 - -#endif /* ! __ASHMEMIOC */ - #endif /* _CUTILS_ASHMEM_H */ diff --git a/cutils/atomic-arm.h b/cutils/atomic-arm.h deleted file mode 100644 index 6b031b6..0000000 --- a/cutils/atomic-arm.h +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_CUTILS_ATOMIC_ARM_H -#define ANDROID_CUTILS_ATOMIC_ARM_H - -#include - -#ifndef ANDROID_ATOMIC_INLINE -#define ANDROID_ATOMIC_INLINE inline __attribute__((always_inline)) -#endif - -extern ANDROID_ATOMIC_INLINE void android_compiler_barrier() -{ - __asm__ __volatile__ ("" : : : "memory"); -} - -extern ANDROID_ATOMIC_INLINE void android_memory_barrier() -{ -#if ANDROID_SMP == 0 - android_compiler_barrier(); -#else - __asm__ __volatile__ ("dmb" : : : "memory"); -#endif -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_acquire_load(volatile const int32_t *ptr) -{ - int32_t value = *ptr; - android_memory_barrier(); - return value; -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_release_load(volatile const int32_t *ptr) -{ - android_memory_barrier(); - return *ptr; -} - -extern ANDROID_ATOMIC_INLINE -void android_atomic_acquire_store(int32_t value, volatile int32_t *ptr) -{ - *ptr = value; - android_memory_barrier(); -} - -extern ANDROID_ATOMIC_INLINE -void android_atomic_release_store(int32_t value, volatile int32_t *ptr) -{ - android_memory_barrier(); - *ptr = value; -} - -extern ANDROID_ATOMIC_INLINE -int android_atomic_cas(int32_t old_value, int32_t new_value, - volatile int32_t *ptr) -{ - int32_t prev, status; - do { - __asm__ __volatile__ ("ldrex %0, [%3]\n" - "mov %1, #0\n" - "teq %0, %4\n" -#ifdef __thumb2__ - "it eq\n" -#endif - "strexeq %1, %5, [%3]" - : "=&r" (prev), "=&r" (status), "+m"(*ptr) - : "r" (ptr), "Ir" (old_value), "r" (new_value) - : "cc"); - } while (__builtin_expect(status != 0, 0)); - return prev != old_value; -} - -extern ANDROID_ATOMIC_INLINE -int android_atomic_acquire_cas(int32_t old_value, int32_t new_value, - volatile int32_t *ptr) -{ - int status = android_atomic_cas(old_value, new_value, ptr); - android_memory_barrier(); - return status; -} - -extern ANDROID_ATOMIC_INLINE -int android_atomic_release_cas(int32_t old_value, int32_t new_value, - volatile int32_t *ptr) -{ - android_memory_barrier(); - return android_atomic_cas(old_value, new_value, ptr); -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_add(int32_t increment, volatile int32_t *ptr) -{ - int32_t prev, tmp, status; - android_memory_barrier(); - do { - __asm__ __volatile__ ("ldrex %0, [%4]\n" - "add %1, %0, %5\n" - "strex %2, %1, [%4]" - : "=&r" (prev), "=&r" (tmp), - "=&r" (status), "+m" (*ptr) - : "r" (ptr), "Ir" (increment) - : "cc"); - } while (__builtin_expect(status != 0, 0)); - return prev; -} - -extern ANDROID_ATOMIC_INLINE int32_t android_atomic_inc(volatile int32_t *addr) -{ - return android_atomic_add(1, addr); -} - -extern ANDROID_ATOMIC_INLINE int32_t android_atomic_dec(volatile int32_t *addr) -{ - return android_atomic_add(-1, addr); -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_and(int32_t value, volatile int32_t *ptr) -{ - int32_t prev, tmp, status; - android_memory_barrier(); - do { - __asm__ __volatile__ ("ldrex %0, [%4]\n" - "and %1, %0, %5\n" - "strex %2, %1, [%4]" - : "=&r" (prev), "=&r" (tmp), - "=&r" (status), "+m" (*ptr) - : "r" (ptr), "Ir" (value) - : "cc"); - } while (__builtin_expect(status != 0, 0)); - return prev; -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_or(int32_t value, volatile int32_t *ptr) -{ - int32_t prev, tmp, status; - android_memory_barrier(); - do { - __asm__ __volatile__ ("ldrex %0, [%4]\n" - "orr %1, %0, %5\n" - "strex %2, %1, [%4]" - : "=&r" (prev), "=&r" (tmp), - "=&r" (status), "+m" (*ptr) - : "r" (ptr), "Ir" (value) - : "cc"); - } while (__builtin_expect(status != 0, 0)); - return prev; -} - -#endif /* ANDROID_CUTILS_ATOMIC_ARM_H */ diff --git a/cutils/atomic-arm64.h b/cutils/atomic-arm64.h deleted file mode 100644 index 7ae47d7..0000000 --- a/cutils/atomic-arm64.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef ANDROID_CUTILS_ATOMIC_AARCH64_H -#define ANDROID_CUTILS_ATOMIC_AARCH64_H - -#include - -#ifndef ANDROID_ATOMIC_INLINE -#define ANDROID_ATOMIC_INLINE inline __attribute__((always_inline)) -#endif - -/* - TODOAArch64: Revisit the below functions and check for potential - optimizations using assembly code or otherwise. -*/ - -extern ANDROID_ATOMIC_INLINE -void android_compiler_barrier(void) -{ - __asm__ __volatile__ ("" : : : "memory"); -} - -extern ANDROID_ATOMIC_INLINE -void android_memory_barrier(void) -{ - __asm__ __volatile__ ("dmb ish" : : : "memory"); -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_acquire_load(volatile const int32_t *ptr) -{ - int32_t value = *ptr; - android_memory_barrier(); - return value; -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_release_load(volatile const int32_t *ptr) -{ - android_memory_barrier(); - return *ptr; -} - -extern ANDROID_ATOMIC_INLINE -void android_atomic_acquire_store(int32_t value, volatile int32_t *ptr) -{ - *ptr = value; - android_memory_barrier(); -} - -extern ANDROID_ATOMIC_INLINE -void android_atomic_release_store(int32_t value, volatile int32_t *ptr) -{ - android_memory_barrier(); - *ptr = value; -} - -extern ANDROID_ATOMIC_INLINE -int android_atomic_cas(int32_t old_value, int32_t new_value, - volatile int32_t *ptr) -{ - return __sync_val_compare_and_swap(ptr, old_value, new_value) != old_value; -} - -extern ANDROID_ATOMIC_INLINE -int android_atomic_acquire_cas(int32_t old_value, int32_t new_value, - volatile int32_t *ptr) -{ - int status = android_atomic_cas(old_value, new_value, ptr); - android_memory_barrier(); - return status; -} - -extern ANDROID_ATOMIC_INLINE -int android_atomic_release_cas(int32_t old_value, int32_t new_value, - volatile int32_t *ptr) -{ - android_memory_barrier(); - return android_atomic_cas(old_value, new_value, ptr); -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_add(int32_t increment, volatile int32_t *ptr) -{ - int32_t prev, status; - android_memory_barrier(); - do { - prev = *ptr; - status = android_atomic_cas(prev, prev + increment, ptr); - } while (__builtin_expect(status != 0, 0)); - return prev; -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_inc(volatile int32_t *addr) -{ - return android_atomic_add(1, addr); -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_dec(volatile int32_t *addr) -{ - return android_atomic_add(-1, addr); -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_and(int32_t value, volatile int32_t *ptr) -{ - int32_t prev, status; - android_memory_barrier(); - do { - prev = *ptr; - status = android_atomic_cas(prev, prev & value, ptr); - } while (__builtin_expect(status != 0, 0)); - return prev; -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_or(int32_t value, volatile int32_t *ptr) -{ - int32_t prev, status; - android_memory_barrier(); - do { - prev = *ptr; - status = android_atomic_cas(prev, prev | value, ptr); - } while (__builtin_expect(status != 0, 0)); - return prev; -} - -#endif /* ANDROID_CUTILS_ATOMIC_AARCH64_H */ diff --git a/cutils/atomic-inline.h b/cutils/atomic-inline.h deleted file mode 100644 index a31e913..0000000 --- a/cutils/atomic-inline.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_CUTILS_ATOMIC_INLINE_H -#define ANDROID_CUTILS_ATOMIC_INLINE_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Inline declarations and macros for some special-purpose atomic - * operations. These are intended for rare circumstances where a - * memory barrier needs to be issued inline rather than as a function - * call. - * - * Most code should not use these. - * - * Anything that does include this file must set ANDROID_SMP to either - * 0 or 1, indicating compilation for UP or SMP, respectively. - * - * Macros defined in this header: - * - * void ANDROID_MEMBAR_FULL(void) - * Full memory barrier. Provides a compiler reordering barrier, and - * on SMP systems emits an appropriate instruction. - */ - -#if !defined(ANDROID_SMP) -# error "Must define ANDROID_SMP before including atomic-inline.h" -#endif - -#if defined(__aarch64__) -#include -#elif defined(__arm__) -#include -#elif defined(__i386__) -#include -#elif defined(__x86_64__) -#include -#elif defined(__mips64) -#include -#elif defined(__mips__) -#include -#else -#error atomic operations are unsupported -#endif - -#if ANDROID_SMP == 0 -#define ANDROID_MEMBAR_FULL android_compiler_barrier -#else -#define ANDROID_MEMBAR_FULL android_memory_barrier -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* ANDROID_CUTILS_ATOMIC_INLINE_H */ diff --git a/cutils/atomic-mips.h b/cutils/atomic-mips.h deleted file mode 100644 index 5d4f097..0000000 --- a/cutils/atomic-mips.h +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_CUTILS_ATOMIC_MIPS_H -#define ANDROID_CUTILS_ATOMIC_MIPS_H - -#include - -#ifndef ANDROID_ATOMIC_INLINE -#define ANDROID_ATOMIC_INLINE inline __attribute__((always_inline)) -#endif - -extern ANDROID_ATOMIC_INLINE void android_compiler_barrier(void) -{ - __asm__ __volatile__ ("" : : : "memory"); -} - -#if ANDROID_SMP == 0 -extern ANDROID_ATOMIC_INLINE void android_memory_barrier(void) -{ - android_compiler_barrier(); -} -#else -extern ANDROID_ATOMIC_INLINE void android_memory_barrier(void) -{ - __asm__ __volatile__ ("sync" : : : "memory"); -} -#endif - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_acquire_load(volatile const int32_t *ptr) -{ - int32_t value = *ptr; - android_memory_barrier(); - return value; -} - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_release_load(volatile const int32_t *ptr) -{ - android_memory_barrier(); - return *ptr; -} - -extern ANDROID_ATOMIC_INLINE void -android_atomic_acquire_store(int32_t value, volatile int32_t *ptr) -{ - *ptr = value; - android_memory_barrier(); -} - -extern ANDROID_ATOMIC_INLINE void -android_atomic_release_store(int32_t value, volatile int32_t *ptr) -{ - android_memory_barrier(); - *ptr = value; -} - -extern ANDROID_ATOMIC_INLINE int -android_atomic_cas(int32_t old_value, int32_t new_value, volatile int32_t *ptr) -{ - int32_t prev, status; - do { - __asm__ __volatile__ ( - " ll %[prev], (%[ptr])\n" - " li %[status], 1\n" - " bne %[prev], %[old], 9f\n" - " move %[status], %[new_value]\n" - " sc %[status], (%[ptr])\n" - "9:\n" - : [prev] "=&r" (prev), [status] "=&r" (status) - : [ptr] "r" (ptr), [old] "r" (old_value), [new_value] "r" (new_value) - ); - } while (__builtin_expect(status == 0, 0)); - return prev != old_value; -} - -extern ANDROID_ATOMIC_INLINE int -android_atomic_acquire_cas(int32_t old_value, - int32_t new_value, - volatile int32_t *ptr) -{ - int status = android_atomic_cas(old_value, new_value, ptr); - android_memory_barrier(); - return status; -} - -extern ANDROID_ATOMIC_INLINE int -android_atomic_release_cas(int32_t old_value, - int32_t new_value, - volatile int32_t *ptr) -{ - android_memory_barrier(); - return android_atomic_cas(old_value, new_value, ptr); -} - - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_add(int32_t increment, volatile int32_t *ptr) -{ - int32_t prev, status; - android_memory_barrier(); - do { - __asm__ __volatile__ ( - " ll %[prev], (%[ptr])\n" - " addu %[status], %[prev], %[inc]\n" - " sc %[status], (%[ptr])\n" - : [status] "=&r" (status), [prev] "=&r" (prev) - : [ptr] "r" (ptr), [inc] "Ir" (increment) - ); - } while (__builtin_expect(status == 0, 0)); - return prev; -} - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_inc(volatile int32_t *addr) -{ - return android_atomic_add(1, addr); -} - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_dec(volatile int32_t *addr) -{ - return android_atomic_add(-1, addr); -} - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_and(int32_t value, volatile int32_t *ptr) -{ - int32_t prev, status; - android_memory_barrier(); - do { - __asm__ __volatile__ ( - " ll %[prev], (%[ptr])\n" - " and %[status], %[prev], %[value]\n" - " sc %[status], (%[ptr])\n" - : [prev] "=&r" (prev), [status] "=&r" (status) - : [ptr] "r" (ptr), [value] "Ir" (value) - ); - } while (__builtin_expect(status == 0, 0)); - return prev; -} - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_or(int32_t value, volatile int32_t *ptr) -{ - int32_t prev, status; - android_memory_barrier(); - do { - __asm__ __volatile__ ( - " ll %[prev], (%[ptr])\n" - " or %[status], %[prev], %[value]\n" - " sc %[status], (%[ptr])\n" - : [prev] "=&r" (prev), [status] "=&r" (status) - : [ptr] "r" (ptr), [value] "Ir" (value) - ); - } while (__builtin_expect(status == 0, 0)); - return prev; -} - -#endif /* ANDROID_CUTILS_ATOMIC_MIPS_H */ diff --git a/cutils/atomic-mips64.h b/cutils/atomic-mips64.h deleted file mode 100644 index 9d8f65e..0000000 --- a/cutils/atomic-mips64.h +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_CUTILS_ATOMIC_MIPS64_H -#define ANDROID_CUTILS_ATOMIC_MIPS64_H - -#include - -#ifndef ANDROID_ATOMIC_INLINE -#define ANDROID_ATOMIC_INLINE inline __attribute__((always_inline)) -#endif - -extern ANDROID_ATOMIC_INLINE void android_compiler_barrier(void) -{ - __asm__ __volatile__ ("" : : : "memory"); -} - -extern ANDROID_ATOMIC_INLINE void android_memory_barrier(void) -{ - __asm__ __volatile__ ("sync" : : : "memory"); -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_acquire_load(volatile const int32_t *ptr) -{ - int32_t value = *ptr; - android_memory_barrier(); - return value; -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_release_load(volatile const int32_t *ptr) -{ - android_memory_barrier(); - return *ptr; -} - -extern ANDROID_ATOMIC_INLINE -void android_atomic_acquire_store(int32_t value, volatile int32_t *ptr) -{ - *ptr = value; - android_memory_barrier(); -} - -extern ANDROID_ATOMIC_INLINE -void android_atomic_release_store(int32_t value, volatile int32_t *ptr) -{ - android_memory_barrier(); - *ptr = value; -} - -extern ANDROID_ATOMIC_INLINE -int android_atomic_cas(int32_t old_value, int32_t new_value, volatile int32_t *ptr) -{ - int32_t prev, status; - do { - __asm__ __volatile__ ( - " ll %[prev], (%[ptr])\n" - " li %[status], 1\n" - " bne %[prev], %[old], 9f\n" - " move %[status], %[new_value]\n" - " sc %[status], (%[ptr])\n" - "9:\n" - : [prev] "=&r" (prev), [status] "=&r" (status) - : [ptr] "r" (ptr), [old] "r" (old_value), [new_value] "r" (new_value) - ); - } while (__builtin_expect(status == 0, 0)); - return prev != old_value; -} - -extern ANDROID_ATOMIC_INLINE -int android_atomic_acquire_cas(int32_t old_value, - int32_t new_value, - volatile int32_t *ptr) -{ - int status = android_atomic_cas(old_value, new_value, ptr); - android_memory_barrier(); - return status; -} - -extern ANDROID_ATOMIC_INLINE -int android_atomic_release_cas(int32_t old_value, - int32_t new_value, - volatile int32_t *ptr) -{ - android_memory_barrier(); - return android_atomic_cas(old_value, new_value, ptr); -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_add(int32_t increment, volatile int32_t *ptr) -{ - int32_t prev, status; - android_memory_barrier(); - do { - __asm__ __volatile__ ( - " ll %[prev], (%[ptr])\n" - " addu %[status], %[prev], %[inc]\n" - " sc %[status], (%[ptr])\n" - : [status] "=&r" (status), [prev] "=&r" (prev) - : [ptr] "r" (ptr), [inc] "Ir" (increment) - ); - } while (__builtin_expect(status == 0, 0)); - return prev; -} - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_inc(volatile int32_t *addr) -{ - return android_atomic_add(1, addr); -} - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_dec(volatile int32_t *addr) -{ - return android_atomic_add(-1, addr); -} - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_and(int32_t value, volatile int32_t *ptr) -{ - int32_t prev, status; - android_memory_barrier(); - do { - __asm__ __volatile__ ( - " ll %[prev], (%[ptr])\n" - " and %[status], %[prev], %[value]\n" - " sc %[status], (%[ptr])\n" - : [prev] "=&r" (prev), [status] "=&r" (status) - : [ptr] "r" (ptr), [value] "Ir" (value) - ); - } while (__builtin_expect(status == 0, 0)); - return prev; -} - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_or(int32_t value, volatile int32_t *ptr) -{ - int32_t prev, status; - android_memory_barrier(); - do { - __asm__ __volatile__ ( - " ll %[prev], (%[ptr])\n" - " or %[status], %[prev], %[value]\n" - " sc %[status], (%[ptr])\n" - : [prev] "=&r" (prev), [status] "=&r" (status) - : [ptr] "r" (ptr), [value] "Ir" (value) - ); - } while (__builtin_expect(status == 0, 0)); - return prev; -} - -#endif /* ANDROID_CUTILS_ATOMIC_MIPS_H */ diff --git a/cutils/atomic-x86.h b/cutils/atomic-x86.h deleted file mode 100644 index 06bf1a3..0000000 --- a/cutils/atomic-x86.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_CUTILS_ATOMIC_X86_H -#define ANDROID_CUTILS_ATOMIC_X86_H - -#include - -#ifndef ANDROID_ATOMIC_INLINE -#define ANDROID_ATOMIC_INLINE inline __attribute__((always_inline)) -#endif - -extern ANDROID_ATOMIC_INLINE void android_compiler_barrier(void) -{ - __asm__ __volatile__ ("" : : : "memory"); -} - -#if ANDROID_SMP == 0 -extern ANDROID_ATOMIC_INLINE void android_memory_barrier(void) -{ - android_compiler_barrier(); -} -#else -extern ANDROID_ATOMIC_INLINE void android_memory_barrier(void) -{ - __asm__ __volatile__ ("mfence" : : : "memory"); -} -#endif - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_acquire_load(volatile const int32_t *ptr) -{ - int32_t value = *ptr; - android_compiler_barrier(); - return value; -} - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_release_load(volatile const int32_t *ptr) -{ - android_memory_barrier(); - return *ptr; -} - -extern ANDROID_ATOMIC_INLINE void -android_atomic_acquire_store(int32_t value, volatile int32_t *ptr) -{ - *ptr = value; - android_memory_barrier(); -} - -extern ANDROID_ATOMIC_INLINE void -android_atomic_release_store(int32_t value, volatile int32_t *ptr) -{ - android_compiler_barrier(); - *ptr = value; -} - -extern ANDROID_ATOMIC_INLINE int -android_atomic_cas(int32_t old_value, int32_t new_value, volatile int32_t *ptr) -{ - int32_t prev; - __asm__ __volatile__ ("lock; cmpxchgl %1, %2" - : "=a" (prev) - : "q" (new_value), "m" (*ptr), "0" (old_value) - : "memory"); - return prev != old_value; -} - -extern ANDROID_ATOMIC_INLINE int -android_atomic_acquire_cas(int32_t old_value, - int32_t new_value, - volatile int32_t *ptr) -{ - /* Loads are not reordered with other loads. */ - return android_atomic_cas(old_value, new_value, ptr); -} - -extern ANDROID_ATOMIC_INLINE int -android_atomic_release_cas(int32_t old_value, - int32_t new_value, - volatile int32_t *ptr) -{ - /* Stores are not reordered with other stores. */ - return android_atomic_cas(old_value, new_value, ptr); -} - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_add(int32_t increment, volatile int32_t *ptr) -{ - __asm__ __volatile__ ("lock; xaddl %0, %1" - : "+r" (increment), "+m" (*ptr) - : : "memory"); - /* increment now holds the old value of *ptr */ - return increment; -} - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_inc(volatile int32_t *addr) -{ - return android_atomic_add(1, addr); -} - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_dec(volatile int32_t *addr) -{ - return android_atomic_add(-1, addr); -} - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_and(int32_t value, volatile int32_t *ptr) -{ - int32_t prev, status; - do { - prev = *ptr; - status = android_atomic_cas(prev, prev & value, ptr); - } while (__builtin_expect(status != 0, 0)); - return prev; -} - -extern ANDROID_ATOMIC_INLINE int32_t -android_atomic_or(int32_t value, volatile int32_t *ptr) -{ - int32_t prev, status; - do { - prev = *ptr; - status = android_atomic_cas(prev, prev | value, ptr); - } while (__builtin_expect(status != 0, 0)); - return prev; -} - -#endif /* ANDROID_CUTILS_ATOMIC_X86_H */ diff --git a/cutils/atomic-x86_64.h b/cutils/atomic-x86_64.h deleted file mode 100644 index 99cb070..0000000 --- a/cutils/atomic-x86_64.h +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef ANDROID_CUTILS_ATOMIC_X86_64_H -#define ANDROID_CUTILS_ATOMIC_X86_64_H - -#include - -#ifndef ANDROID_ATOMIC_INLINE -#define ANDROID_ATOMIC_INLINE inline __attribute__((always_inline)) -#endif - -extern ANDROID_ATOMIC_INLINE -void android_compiler_barrier(void) -{ - __asm__ __volatile__ ("" : : : "memory"); -} - -extern ANDROID_ATOMIC_INLINE -void android_memory_barrier(void) -{ - __asm__ __volatile__ ("mfence" : : : "memory"); -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_acquire_load(volatile const int32_t *ptr) -{ - int32_t value = *ptr; - android_compiler_barrier(); - return value; -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_release_load(volatile const int32_t *ptr) -{ - android_memory_barrier(); - return *ptr; -} - -extern ANDROID_ATOMIC_INLINE -void android_atomic_acquire_store(int32_t value, volatile int32_t *ptr) -{ - *ptr = value; - android_memory_barrier(); -} - -extern ANDROID_ATOMIC_INLINE -void android_atomic_release_store(int32_t value, volatile int32_t *ptr) -{ - android_compiler_barrier(); - *ptr = value; -} - -extern ANDROID_ATOMIC_INLINE -int android_atomic_cas(int32_t old_value, int32_t new_value, - volatile int32_t *ptr) -{ - int32_t prev; - __asm__ __volatile__ ("lock; cmpxchgl %1, %2" - : "=a" (prev) - : "q" (new_value), "m" (*ptr), "0" (old_value) - : "memory"); - return prev != old_value; -} - -extern ANDROID_ATOMIC_INLINE -int android_atomic_acquire_cas(int32_t old_value, int32_t new_value, - volatile int32_t *ptr) -{ - /* Loads are not reordered with other loads. */ - return android_atomic_cas(old_value, new_value, ptr); -} - -extern ANDROID_ATOMIC_INLINE -int android_atomic_release_cas(int32_t old_value, int32_t new_value, - volatile int32_t *ptr) -{ - /* Stores are not reordered with other stores. */ - return android_atomic_cas(old_value, new_value, ptr); -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_add(int32_t increment, volatile int32_t *ptr) -{ - __asm__ __volatile__ ("lock; xaddl %0, %1" - : "+r" (increment), "+m" (*ptr) - : : "memory"); - /* increment now holds the old value of *ptr */ - return increment; -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_inc(volatile int32_t *addr) -{ - return android_atomic_add(1, addr); -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_dec(volatile int32_t *addr) -{ - return android_atomic_add(-1, addr); -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_and(int32_t value, volatile int32_t *ptr) -{ - int32_t prev, status; - do { - prev = *ptr; - status = android_atomic_cas(prev, prev & value, ptr); - } while (__builtin_expect(status != 0, 0)); - return prev; -} - -extern ANDROID_ATOMIC_INLINE -int32_t android_atomic_or(int32_t value, volatile int32_t *ptr) -{ - int32_t prev, status; - do { - prev = *ptr; - status = android_atomic_cas(prev, prev | value, ptr); - } while (__builtin_expect(status != 0, 0)); - return prev; -} - -#endif /* ANDROID_CUTILS_ATOMIC_X86_64_H */ diff --git a/cutils/atomic.h b/cutils/atomic.h index ded972a..0c88bfe 100644 --- a/cutils/atomic.h +++ b/cutils/atomic.h @@ -71,6 +71,15 @@ * If they are not, atomicity is not guaranteed. */ +ANDROID_ATOMIC_INLINE +volatile atomic_int_least32_t* to_atomic_int_least32_t(volatile const int32_t* addr) { +#ifdef __cplusplus + return reinterpret_cast(const_cast(addr)); +#else + return (volatile atomic_int_least32_t*)addr; +#endif +} + /* * Basic arithmetic and bitwise operations. These all provide a * barrier with "release" ordering, and return the previous value. @@ -81,7 +90,7 @@ ANDROID_ATOMIC_INLINE int32_t android_atomic_inc(volatile int32_t* addr) { - volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; + volatile atomic_int_least32_t* a = to_atomic_int_least32_t(addr); /* Int32_t, if it exists, is the same as int_least32_t. */ return atomic_fetch_add_explicit(a, 1, memory_order_release); } @@ -89,28 +98,28 @@ int32_t android_atomic_inc(volatile int32_t* addr) ANDROID_ATOMIC_INLINE int32_t android_atomic_dec(volatile int32_t* addr) { - volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; + volatile atomic_int_least32_t* a = to_atomic_int_least32_t(addr); return atomic_fetch_sub_explicit(a, 1, memory_order_release); } ANDROID_ATOMIC_INLINE int32_t android_atomic_add(int32_t value, volatile int32_t* addr) { - volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; + volatile atomic_int_least32_t* a = to_atomic_int_least32_t(addr); return atomic_fetch_add_explicit(a, value, memory_order_release); } ANDROID_ATOMIC_INLINE int32_t android_atomic_and(int32_t value, volatile int32_t* addr) { - volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; + volatile atomic_int_least32_t* a = to_atomic_int_least32_t(addr); return atomic_fetch_and_explicit(a, value, memory_order_release); } ANDROID_ATOMIC_INLINE int32_t android_atomic_or(int32_t value, volatile int32_t* addr) { - volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; + volatile atomic_int_least32_t* a = to_atomic_int_least32_t(addr); return atomic_fetch_or_explicit(a, value, memory_order_release); } @@ -131,14 +140,14 @@ int32_t android_atomic_or(int32_t value, volatile int32_t* addr) ANDROID_ATOMIC_INLINE int32_t android_atomic_acquire_load(volatile const int32_t* addr) { - volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; + volatile atomic_int_least32_t* a = to_atomic_int_least32_t(addr); return atomic_load_explicit(a, memory_order_acquire); } ANDROID_ATOMIC_INLINE int32_t android_atomic_release_load(volatile const int32_t* addr) { - volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; + volatile atomic_int_least32_t* a = to_atomic_int_least32_t(addr); atomic_thread_fence(memory_order_seq_cst); /* Any reasonable clients of this interface would probably prefer */ /* something weaker. But some remaining clients seem to be */ @@ -162,7 +171,7 @@ int32_t android_atomic_release_load(volatile const int32_t* addr) ANDROID_ATOMIC_INLINE void android_atomic_acquire_store(int32_t value, volatile int32_t* addr) { - volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; + volatile atomic_int_least32_t* a = to_atomic_int_least32_t(addr); atomic_store_explicit(a, value, memory_order_relaxed); atomic_thread_fence(memory_order_seq_cst); /* Again overly conservative to accomodate weird clients. */ @@ -171,7 +180,7 @@ void android_atomic_acquire_store(int32_t value, volatile int32_t* addr) ANDROID_ATOMIC_INLINE void android_atomic_release_store(int32_t value, volatile int32_t* addr) { - volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; + volatile atomic_int_least32_t* a = to_atomic_int_least32_t(addr); atomic_store_explicit(a, value, memory_order_release); } @@ -191,22 +200,22 @@ ANDROID_ATOMIC_INLINE int android_atomic_acquire_cas(int32_t oldvalue, int32_t newvalue, volatile int32_t* addr) { - volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; - return (int)(!atomic_compare_exchange_strong_explicit( + volatile atomic_int_least32_t* a = to_atomic_int_least32_t(addr); + return !atomic_compare_exchange_strong_explicit( a, &oldvalue, newvalue, memory_order_acquire, - memory_order_acquire)); + memory_order_acquire); } ANDROID_ATOMIC_INLINE int android_atomic_release_cas(int32_t oldvalue, int32_t newvalue, volatile int32_t* addr) { - volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; - return (int)(!atomic_compare_exchange_strong_explicit( + volatile atomic_int_least32_t* a = to_atomic_int_least32_t(addr); + return !atomic_compare_exchange_strong_explicit( a, &oldvalue, newvalue, memory_order_release, - memory_order_relaxed)); + memory_order_relaxed); } /* diff --git a/cutils/bitops.h b/cutils/bitops.h index 045830d..38d2840 100644 --- a/cutils/bitops.h +++ b/cutils/bitops.h @@ -24,94 +24,15 @@ __BEGIN_DECLS -/* - * Bitmask Operations - * - * Note this doesn't provide any locking/exclusion, and isn't atomic. - * Additionally no bounds checking is done on the bitmask array. - * - * Example: - * - * int num_resources; - * unsigned int resource_bits[BITS_TO_WORDS(num_resources)]; - * bitmask_init(resource_bits, num_resources); - * ... - * int bit = bitmask_ffz(resource_bits, num_resources); - * bitmask_set(resource_bits, bit); - * ... - * if (bitmask_test(resource_bits, bit)) { ... } - * ... - * bitmask_clear(resource_bits, bit); - * - */ - -#define BITS_PER_WORD (sizeof(unsigned int) * 8) -#define BITS_TO_WORDS(x) (((x) + BITS_PER_WORD - 1) / BITS_PER_WORD) -#define BIT_IN_WORD(x) ((x) % BITS_PER_WORD) -#define BIT_WORD(x) ((x) / BITS_PER_WORD) -#define BIT_MASK(x) (1 << BIT_IN_WORD(x)) - -static inline void bitmask_init(unsigned int *bitmask, int num_bits) -{ - memset(bitmask, 0, BITS_TO_WORDS(num_bits)*sizeof(unsigned int)); -} - -static inline int bitmask_ffz(unsigned int *bitmask, int num_bits) -{ - int bit, result; - size_t i; - - for (i = 0; i < BITS_TO_WORDS(num_bits); i++) { - bit = ffs(~bitmask[i]); - if (bit) { - // ffs is 1-indexed, return 0-indexed result - bit--; - result = BITS_PER_WORD * i + bit; - if (result >= num_bits) - return -1; - return result; - } - } - return -1; -} - -static inline int bitmask_weight(unsigned int *bitmask, int num_bits) -{ - size_t i; - int weight = 0; - - for (i = 0; i < BITS_TO_WORDS(num_bits); i++) - weight += __builtin_popcount(bitmask[i]); - return weight; -} - -static inline void bitmask_set(unsigned int *bitmask, int bit) -{ - bitmask[BIT_WORD(bit)] |= BIT_MASK(bit); -} - -static inline void bitmask_clear(unsigned int *bitmask, int bit) -{ - bitmask[BIT_WORD(bit)] &= ~BIT_MASK(bit); -} - -static inline bool bitmask_test(unsigned int *bitmask, int bit) -{ - return bitmask[BIT_WORD(bit)] & BIT_MASK(bit); -} - -static inline int popcount(unsigned int x) -{ +static inline int popcount(unsigned int x) { return __builtin_popcount(x); } -static inline int popcountl(unsigned long x) -{ +static inline int popcountl(unsigned long x) { return __builtin_popcountl(x); } -static inline int popcountll(unsigned long long x) -{ +static inline int popcountll(unsigned long long x) { return __builtin_popcountll(x); } diff --git a/cutils/debugger.h b/cutils/debugger.h deleted file mode 100644 index 285e1af..0000000 --- a/cutils/debugger.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __CUTILS_DEBUGGER_H -#define __CUTILS_DEBUGGER_H - -#include -#include - -__BEGIN_DECLS - -#define DEBUGGER_SOCKET_NAME "android:debuggerd" -#define DEBUGGER32_SOCKET_NAME "android:debuggerd32" -#define DEBUGGER64_SOCKET_NAME DEBUGGER_SOCKET_NAME - -typedef enum { - // dump a crash - DEBUGGER_ACTION_CRASH, - // dump a tombstone file - DEBUGGER_ACTION_DUMP_TOMBSTONE, - // dump a backtrace only back to the socket - DEBUGGER_ACTION_DUMP_BACKTRACE, -} debugger_action_t; - -// Make sure that all values have a fixed size so that this structure -// is the same for 32 bit and 64 bit processes. -// NOTE: Any changes to this structure must also be reflected in -// bionic/linker/debugger.cpp. -typedef struct __attribute__((packed)) { - int32_t action; - pid_t tid; - uint64_t abort_msg_address; - int32_t original_si_code; -} debugger_msg_t; - -/* Dumps a process backtrace, registers, and stack to a tombstone file (requires root). - * Stores the tombstone path in the provided buffer. - * Returns 0 on success, -1 on error. - */ -int dump_tombstone(pid_t tid, char* pathbuf, size_t pathlen); - -/* Dumps a process backtrace, registers, and stack to a tombstone file (requires root). - * Stores the tombstone path in the provided buffer. - * If reading debugger data from debuggerd ever takes longer than timeout_secs - * seconds, then stop and return an error. - * Returns 0 on success, -1 on error. - */ -int dump_tombstone_timeout(pid_t tid, char* pathbuf, size_t pathlen, int timeout_secs); - -/* Dumps a process backtrace only to the specified file (requires root). - * Returns 0 on success, -1 on error. - */ -int dump_backtrace_to_file(pid_t tid, int fd); - -/* Dumps a process backtrace only to the specified file (requires root). - * If reading debugger data from debuggerd ever takes longer than timeout_secs - * seconds, then stop and return an error. - * Returns 0 on success, -1 on error. - */ -int dump_backtrace_to_file_timeout(pid_t tid, int fd, int timeout_secs); - -__END_DECLS - -#endif /* __CUTILS_DEBUGGER_H */ diff --git a/cutils/iosched_policy.h b/cutils/iosched_policy.h index 25b87ba..07c5d1f 100644 --- a/cutils/iosched_policy.h +++ b/cutils/iosched_policy.h @@ -31,8 +31,6 @@ typedef enum { extern int android_set_ioprio(int pid, IoSchedClass clazz, int ioprio); extern int android_get_ioprio(int pid, IoSchedClass *clazz, int *ioprio); -extern int android_set_rt_ioprio(int pid, int rt); - #ifdef __cplusplus } #endif diff --git a/cutils/klog.h b/cutils/klog.h index 295d62b..5ae6216 100644 --- a/cutils/klog.h +++ b/cutils/klog.h @@ -23,10 +23,7 @@ __BEGIN_DECLS -void klog_init(void); -int klog_get_level(void); void klog_set_level(int level); -/* TODO: void klog_close(void); - and make klog_fd users thread safe. */ void klog_write(int level, const char *fmt, ...) __attribute__ ((format(printf, 2, 3))); @@ -46,6 +43,4 @@ __END_DECLS #define KLOG_INFO(tag,x...) klog_write(KLOG_INFO_LEVEL, "<6>" tag ": " x) #define KLOG_DEBUG(tag,x...) klog_write(KLOG_DEBUG_LEVEL, "<7>" tag ": " x) -#define KLOG_DEFAULT_LEVEL 3 /* messages <= this level are logged */ - #endif diff --git a/cutils/list.h b/cutils/list.h index 4ba2cfd..dfdc53b 100644 --- a/cutils/list.h +++ b/cutils/list.h @@ -34,20 +34,20 @@ struct listnode #define list_declare(name) \ struct listnode name = { \ - .next = &name, \ - .prev = &name, \ + .next = &(name), \ + .prev = &(name), \ } #define list_for_each(node, list) \ - for (node = (list)->next; node != (list); node = node->next) + for ((node) = (list)->next; (node) != (list); (node) = (node)->next) #define list_for_each_reverse(node, list) \ - for (node = (list)->prev; node != (list); node = node->prev) + for ((node) = (list)->prev; (node) != (list); (node) = (node)->prev) #define list_for_each_safe(node, n, list) \ - for (node = (list)->next, n = node->next; \ - node != (list); \ - node = n, n = node->next) + for ((node) = (list)->next, (n) = (node)->next; \ + (node) != (list); \ + (node) = (n), (n) = (node)->next) static inline void list_init(struct listnode *node) { diff --git a/cutils/multiuser.h b/cutils/multiuser.h index 7e7f815..9a2305c 100644 --- a/cutils/multiuser.h +++ b/cutils/multiuser.h @@ -23,19 +23,21 @@ extern "C" { #endif -// NOTE: keep in sync with android.os.UserId - -#define MULTIUSER_APP_PER_USER_RANGE 100000 -#define MULTIUSER_FIRST_SHARED_APPLICATION_GID 50000 -#define MULTIUSER_FIRST_APPLICATION_UID 10000 - typedef uid_t userid_t; typedef uid_t appid_t; extern userid_t multiuser_get_user_id(uid_t uid); extern appid_t multiuser_get_app_id(uid_t uid); -extern uid_t multiuser_get_uid(userid_t userId, appid_t appId); -extern appid_t multiuser_get_shared_app_gid(uid_t uid); + +extern uid_t multiuser_get_uid(userid_t user_id, appid_t app_id); + +extern gid_t multiuser_get_cache_gid(userid_t user_id, appid_t app_id); +extern gid_t multiuser_get_ext_gid(userid_t user_id, appid_t app_id); +extern gid_t multiuser_get_ext_cache_gid(userid_t user_id, appid_t app_id); +extern gid_t multiuser_get_shared_gid(userid_t user_id, appid_t app_id); + +/* TODO: switch callers over to multiuser_get_shared_gid() */ +extern gid_t multiuser_get_shared_app_gid(uid_t uid); #ifdef __cplusplus } diff --git a/cutils/native_handle.h b/cutils/native_handle.h index 268c5d3..f6cae36 100644 --- a/cutils/native_handle.h +++ b/cutils/native_handle.h @@ -17,18 +17,37 @@ #ifndef NATIVE_HANDLE_H_ #define NATIVE_HANDLE_H_ +#include + #ifdef __cplusplus extern "C" { #endif +#define NATIVE_HANDLE_MAX_FDS 1024 +#define NATIVE_HANDLE_MAX_INTS 1024 + +/* Declare a char array for use with native_handle_init */ +#define NATIVE_HANDLE_DECLARE_STORAGE(name, maxFds, maxInts) \ + alignas(native_handle_t) char (name)[ \ + sizeof(native_handle_t) + sizeof(int) * ((maxFds) + (maxInts))] + typedef struct native_handle { int version; /* sizeof(native_handle_t) */ int numFds; /* number of file-descriptors at &data[0] */ int numInts; /* number of ints at &data[numFds] */ +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wzero-length-array" +#endif int data[0]; /* numFds + numInts ints */ +#if defined(__clang__) +#pragma clang diagnostic pop +#endif } native_handle_t; +typedef const native_handle_t* buffer_handle_t; + /* * native_handle_close * @@ -39,6 +58,14 @@ typedef struct native_handle */ int native_handle_close(const native_handle_t* h); +/* + * native_handle_init + * + * Initializes a native_handle_t from storage. storage must be declared with + * NATIVE_HANDLE_DECLARE_STORAGE. numFds and numInts must not respectively + * exceed maxFds and maxInts used to declare the storage. + */ +native_handle_t* native_handle_init(char* storage, int numFds, int numInts); /* * native_handle_create @@ -49,6 +76,15 @@ int native_handle_close(const native_handle_t* h); */ native_handle_t* native_handle_create(int numFds, int numInts); +/* + * native_handle_clone + * + * creates a native_handle_t and initializes it from another native_handle_t. + * Must be destroyed with native_handle_delete(). + * + */ +native_handle_t* native_handle_clone(const native_handle_t* handle); + /* * native_handle_delete * diff --git a/cutils/partition_utils.h b/cutils/partition_utils.h index 72ca80d..7518559 100644 --- a/cutils/partition_utils.h +++ b/cutils/partition_utils.h @@ -17,6 +17,8 @@ #ifndef __CUTILS_PARTITION_WIPED_H__ #define __CUTILS_PARTITION_WIPED_H__ +#include + __BEGIN_DECLS int partition_wiped(char *source); diff --git a/cutils/properties.h b/cutils/properties.h index 24aa224..d2e0871 100644 --- a/cutils/properties.h +++ b/cutils/properties.h @@ -43,7 +43,7 @@ extern "C" { ** If the property read fails or returns an empty value, the default ** value is used (if nonnull). */ -int property_get(const char *key, char *value, const char *default_value); +int property_get(const char* key, char* value, const char* default_value); /* property_get_bool: returns the value of key coerced into a ** boolean. If the property is not set, then the default value is returned. @@ -106,14 +106,28 @@ int32_t property_get_int32(const char *key, int32_t default_value); /* property_set: returns 0 on success, < 0 on failure */ int property_set(const char *key, const char *value); - -int property_list(void (*propfn)(const char *key, const char *value, void *cookie), void *cookie); + +int property_list(void (*propfn)(const char *key, const char *value, void *cookie), void *cookie); #if defined(__BIONIC_FORTIFY) +#define __property_get_err_str "property_get() called with too small of a buffer" + +#if defined(__clang__) + +/* Some projects use -Weverything; diagnose_if is clang-specific. */ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgcc-compat" +int property_get(const char* key, char* value, const char* default_value) + __clang_error_if(__bos(value) != __BIONIC_FORTIFY_UNKNOWN_SIZE && + __bos(value) < PROPERTY_VALUE_MAX, + __property_get_err_str); +#pragma clang diagnostic pop + +#else /* defined(__clang__) */ extern int __property_get_real(const char *, char *, const char *) __asm__(__USER_LABEL_PREFIX__ "property_get"); -__errordecl(__property_get_too_small_error, "property_get() called with too small of a buffer"); +__errordecl(__property_get_too_small_error, __property_get_err_str); __BIONIC_FORTIFY_INLINE int property_get(const char *key, char *value, const char *default_value) { @@ -124,7 +138,10 @@ int property_get(const char *key, char *value, const char *default_value) { return __property_get_real(key, value, default_value); } -#endif +#endif /* defined(__clang__) */ + +#undef __property_get_err_str +#endif /* defined(__BIONIC_FORTIFY) */ #ifdef __cplusplus } diff --git a/cutils/qtaguid.h b/cutils/qtaguid.h index f8550fd..3f5e41f 100644 --- a/cutils/qtaguid.h +++ b/cutils/qtaguid.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 The Android Open Source Project + * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,7 @@ #ifndef __CUTILS_QTAGUID_H #define __CUTILS_QTAGUID_H -#include #include -#include #ifdef __cplusplus extern "C" { @@ -27,12 +25,12 @@ extern "C" { /* * Set tags (and owning UIDs) for network sockets. -*/ + */ extern int qtaguid_tagSocket(int sockfd, int tag, uid_t uid); /* * Untag a network socket before closing. -*/ + */ extern int qtaguid_untagSocket(int sockfd); /* @@ -44,8 +42,8 @@ extern int qtaguid_setCounterSet(int counterSetNum, uid_t uid); /* * Delete all tag info that relates to the given tag an uid. - * If the tag is 0, then ALL info about the uid is freeded. - * The delete data also affects active tagged socketd, which are + * If the tag is 0, then ALL info about the uid is freed. + * The delete data also affects active tagged sockets, which are * then untagged. * The calling process can only operate on its own tags. * Unless it is part of the happy AID_NET_BW_ACCT group. diff --git a/cutils/record_stream.h b/cutils/record_stream.h index bfac87a..bcfc80d 100644 --- a/cutils/record_stream.h +++ b/cutils/record_stream.h @@ -25,6 +25,7 @@ extern "C" { #endif +#include typedef struct RecordStream RecordStream; diff --git a/cutils/sched_policy.h b/cutils/sched_policy.h index 591bd44..cf91b76 100644 --- a/cutils/sched_policy.h +++ b/cutils/sched_policy.h @@ -17,21 +17,40 @@ #ifndef __CUTILS_SCHED_POLICY_H #define __CUTILS_SCHED_POLICY_H +#include + #ifdef __cplusplus extern "C" { #endif +/* + * Check if Linux kernel enables CPUSETS feature. + * + * Return value: 1 if Linux kernel CONFIG_CPUSETS=y; 0 otherwise. + */ +extern bool cpusets_enabled(); + +/* + * Check if Linux kernel enables SCHEDTUNE feature (only available in Android + * common kernel or Linaro LSK, not in mainline Linux as of v4.9) + * + * Return value: 1 if Linux kernel CONFIG_CGROUP_SCHEDTUNE=y; 0 otherwise. + */ +extern bool schedboost_enabled(); + /* Keep in sync with THREAD_GROUP_* in frameworks/base/core/java/android/os/Process.java */ typedef enum { - SP_DEFAULT = -1, + SP_DEFAULT = -1, SP_BACKGROUND = 0, SP_FOREGROUND = 1, - SP_SYSTEM = 2, // can't be used with set_sched_policy() - SP_AUDIO_APP = 3, - SP_AUDIO_SYS = 4, - SP_TOP_APP = 5, + SP_SYSTEM = 2, // can't be used with set_sched_policy() + SP_AUDIO_APP = 3, + SP_AUDIO_SYS = 4, + SP_TOP_APP = 5, + SP_RT_APP = 6, + SP_RESTRICTED = 7, SP_CNT, - SP_MAX = SP_CNT - 1, + SP_MAX = SP_CNT - 1, SP_SYSTEM_DEFAULT = SP_FOREGROUND, } SchedPolicy; diff --git a/cutils/sockets.h b/cutils/sockets.h index 783bd0b..b24468b 100644 --- a/cutils/sockets.h +++ b/cutils/sockets.h @@ -18,6 +18,7 @@ #define __CUTILS_SOCKETS_H #include +#include #include #include #include @@ -34,6 +35,7 @@ typedef SOCKET cutils_socket_t; #else #include +#include typedef int cutils_socket_t; #define INVALID_SOCKET (-1) @@ -51,28 +53,8 @@ extern "C" { * android_get_control_socket - simple helper function to get the file * descriptor of our init-managed Unix domain socket. `name' is the name of the * socket, as given in init.rc. Returns -1 on error. - * - * This is inline and not in libcutils proper because we want to use this in - * third-party daemons with minimal modification. */ -static inline int android_get_control_socket(const char* name) -{ - char key[64]; - snprintf(key, sizeof(key), ANDROID_SOCKET_ENV_PREFIX "%s", name); - - const char* val = getenv(key); - if (!val) { - return -1; - } - - errno = 0; - int fd = strtol(val, NULL, 10); - if (errno) { - return -1; - } - - return fd; -} +int android_get_control_socket(const char* name); /* * See also android.os.LocalSocketAddress.Namespace @@ -103,11 +85,9 @@ static inline int android_get_control_socket(const char* name) * * These functions return INVALID_SOCKET (-1) on failure for all platforms. */ -int socket_loopback_client(int port, int type); cutils_socket_t socket_network_client(const char* host, int port, int type); int socket_network_client_timeout(const char* host, int port, int type, int timeout, int* getaddrinfo_error); -int socket_loopback_server(int port, int type); int socket_local_server(const char* name, int namespaceId, int type); int socket_local_server_bind(int s, const char* name, int namespaceId); int socket_local_client_connect(int fd, const char *name, int namespaceId, diff --git a/cutils/trace.h b/cutils/trace.h index 19313af..bbb150d 100644 --- a/cutils/trace.h +++ b/cutils/trace.h @@ -71,7 +71,10 @@ __BEGIN_DECLS #define ATRACE_TAG_SYSTEM_SERVER (1<<19) #define ATRACE_TAG_DATABASE (1<<20) #define ATRACE_TAG_NETWORK (1<<21) -#define ATRACE_TAG_LAST ATRACE_TAG_NETWORK +#define ATRACE_TAG_ADB (1<<22) +#define ATRACE_TAG_VIBRATOR (1<<23) +#define ATRACE_TAG_AIDL (1<<24) +#define ATRACE_TAG_LAST ATRACE_TAG_AIDL // Reserved for initialization. #define ATRACE_TAG_NOT_READY (1ULL<<63) @@ -189,8 +192,8 @@ static inline void atrace_begin(uint64_t tag, const char* name) static inline void atrace_end(uint64_t tag) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { - char c = 'E'; - write(atrace_marker_fd, &c, 1); + void atrace_end_body(); + atrace_end_body(); } } diff --git a/hardware/audio.h b/hardware/audio.h index e5c20b7..10a8789 100644 --- a/hardware/audio.h +++ b/hardware/audio.h @@ -22,15 +22,13 @@ #include #include #include +#include #include #include #include #include -#ifdef AUDIO_LISTEN_ENABLED -#include -#endif __BEGIN_DECLS @@ -62,19 +60,6 @@ __BEGIN_DECLS /* Minimal audio HAL version supported by the audio framework */ #define AUDIO_DEVICE_API_VERSION_MIN AUDIO_DEVICE_API_VERSION_2_0 -/** - * List of known audio HAL modules. This is the base name of the audio HAL - * library composed of the "audio." prefix, one of the base names below and - * a suffix specific to the device. - * e.g: audio.primary.goldfish.so or audio.a2dp.default.so - */ - -#define AUDIO_HARDWARE_MODULE_ID_PRIMARY "primary" -#define AUDIO_HARDWARE_MODULE_ID_A2DP "a2dp" -#define AUDIO_HARDWARE_MODULE_ID_USB "usb" -#define AUDIO_HARDWARE_MODULE_ID_REMOTE_SUBMIX "r_submix" -#define AUDIO_HARDWARE_MODULE_ID_CODEC_OFFLOAD "codec_offload" - /**************************************/ /** @@ -85,11 +70,6 @@ __BEGIN_DECLS * audio device parameters */ -/* BT SCO Noise Reduction + Echo Cancellation parameters */ -#define AUDIO_PARAMETER_KEY_BT_NREC "bt_headset_nrec" -#define AUDIO_PARAMETER_VALUE_ON "on" -#define AUDIO_PARAMETER_VALUE_OFF "off" - /* TTY mode selection */ #define AUDIO_PARAMETER_KEY_TTY_MODE "tty_mode" #define AUDIO_PARAMETER_VALUE_TTY_OFF "tty_off" @@ -97,8 +77,7 @@ __BEGIN_DECLS #define AUDIO_PARAMETER_VALUE_TTY_HCO "tty_hco" #define AUDIO_PARAMETER_VALUE_TTY_FULL "tty_full" -/* Hearing Aid Compatibility - Telecoil (HAC-T) mode on/off - Strings must be in sync with CallFeaturesSetting.java */ +/* Hearing Aid Compatibility - Telecoil (HAC-T) mode on/off */ #define AUDIO_PARAMETER_KEY_HAC "HACSetting" #define AUDIO_PARAMETER_VALUE_HAC_ON "ON" #define AUDIO_PARAMETER_VALUE_HAC_OFF "OFF" @@ -109,67 +88,26 @@ __BEGIN_DECLS /* A2DP source address set by framework */ #define AUDIO_PARAMETER_A2DP_SOURCE_ADDRESS "a2dp_source_address" -/* Screen state */ -#define AUDIO_PARAMETER_KEY_SCREEN_STATE "screen_state" - /* Bluetooth SCO wideband */ #define AUDIO_PARAMETER_KEY_BT_SCO_WB "bt_wbs" +/* BT SCO headset name for debug */ +#define AUDIO_PARAMETER_KEY_BT_SCO_HEADSET_NAME "bt_headset_name" -/* Device state*/ -#define AUDIO_PARAMETER_KEY_DEV_SHUTDOWN "dev_shutdown" +/* BT SCO HFP control */ +#define AUDIO_PARAMETER_KEY_HFP_ENABLE "hfp_enable" +#define AUDIO_PARAMETER_KEY_HFP_SET_SAMPLING_RATE "hfp_set_sampling_rate" +#define AUDIO_PARAMETER_KEY_HFP_VOLUME "hfp_volume" -/* Get a new HW synchronization source identifier. - * Return a valid source (positive integer) or AUDIO_HW_SYNC_INVALID if an error occurs - * or no HW sync is available. */ -#define AUDIO_PARAMETER_HW_AV_SYNC "hw_av_sync" +/* Set screen orientation */ +#define AUDIO_PARAMETER_KEY_ROTATION "rotation" /** * audio stream parameters */ -#define AUDIO_PARAMETER_STREAM_ROUTING "routing" /* audio_devices_t */ -#define AUDIO_PARAMETER_STREAM_FORMAT "format" /* audio_format_t */ -#define AUDIO_PARAMETER_STREAM_CHANNELS "channels" /* audio_channel_mask_t */ -#define AUDIO_PARAMETER_STREAM_FRAME_COUNT "frame_count" /* size_t */ -#define AUDIO_PARAMETER_STREAM_INPUT_SOURCE "input_source" /* audio_source_t */ -#define AUDIO_PARAMETER_STREAM_SAMPLING_RATE "sampling_rate" /* uint32_t */ - -#define AUDIO_PARAMETER_DEVICE_CONNECT "connect" /* audio_devices_t */ -#define AUDIO_PARAMETER_DEVICE_DISCONNECT "disconnect" /* audio_devices_t */ - -/* Query supported formats. The response is a '|' separated list of strings from - * audio_format_t enum e.g: "sup_formats=AUDIO_FORMAT_PCM_16_BIT" */ -#define AUDIO_PARAMETER_STREAM_SUP_FORMATS "sup_formats" -/* Query supported channel masks. The response is a '|' separated list of strings from - * audio_channel_mask_t enum e.g: "sup_channels=AUDIO_CHANNEL_OUT_STEREO|AUDIO_CHANNEL_OUT_MONO" */ -#define AUDIO_PARAMETER_STREAM_SUP_CHANNELS "sup_channels" -/* Query supported sampling rates. The response is a '|' separated list of integer values e.g: - * "sup_sampling_rates=44100|48000" */ -#define AUDIO_PARAMETER_STREAM_SUP_SAMPLING_RATES "sup_sampling_rates" - -/* Set the HW synchronization source for an output stream. */ -#define AUDIO_PARAMETER_STREAM_HW_AV_SYNC "hw_av_sync" - -/* Enable mono audio playback if 1, else should be 0. */ -#define AUDIO_PARAMETER_MONO_OUTPUT "mono_output" - -/** - * audio codec parameters - */ - -#define AUDIO_OFFLOAD_CODEC_PARAMS "music_offload_codec_param" -#define AUDIO_OFFLOAD_CODEC_BIT_PER_SAMPLE "music_offload_bit_per_sample" -#define AUDIO_OFFLOAD_CODEC_BIT_RATE "music_offload_bit_rate" -#define AUDIO_OFFLOAD_CODEC_AVG_BIT_RATE "music_offload_avg_bit_rate" -#define AUDIO_OFFLOAD_CODEC_ID "music_offload_codec_id" -#define AUDIO_OFFLOAD_CODEC_BLOCK_ALIGN "music_offload_block_align" -#define AUDIO_OFFLOAD_CODEC_SAMPLE_RATE "music_offload_sample_rate" -#define AUDIO_OFFLOAD_CODEC_ENCODE_OPTION "music_offload_encode_option" -#define AUDIO_OFFLOAD_CODEC_NUM_CHANNEL "music_offload_num_channels" -#define AUDIO_OFFLOAD_CODEC_DOWN_SAMPLING "music_offload_down_sampling" -#define AUDIO_OFFLOAD_CODEC_DELAY_SAMPLES "delay_samples" -#define AUDIO_OFFLOAD_CODEC_PADDING_SAMPLES "padding_samples" +/* Enable AANC */ +#define AUDIO_PARAMETER_KEY_AANC "aanc_enabled" /**************************************/ @@ -274,13 +212,24 @@ typedef enum { give time for gapless track switch */ } audio_drain_type_t; +typedef struct source_metadata { + size_t track_count; + /** Array of metadata of each track connected to this source. */ + struct playback_track_metadata* tracks; +} source_metadata_t; + +typedef struct sink_metadata { + size_t track_count; + /** Array of metadata of each track connected to this sink. */ + struct record_track_metadata* tracks; +} sink_metadata_t; + /** * audio_stream_out is the abstraction interface for the audio output hardware. * * It provides information about various properties of the audio output * hardware driver. */ - struct audio_stream_out { /** * Common methods of the audio stream out. This *must* be the first member of audio_stream_out @@ -406,6 +355,72 @@ struct audio_stream_out { int (*get_presentation_position)(const struct audio_stream_out *stream, uint64_t *frames, struct timespec *timestamp); + /** + * Called by the framework to start a stream operating in mmap mode. + * create_mmap_buffer must be called before calling start() + * + * \note Function only implemented by streams operating in mmap mode. + * + * \param[in] stream the stream object. + * \return 0 in case of success. + * -ENOSYS if called out of sequence or on non mmap stream + */ + int (*start)(const struct audio_stream_out* stream); + + /** + * Called by the framework to stop a stream operating in mmap mode. + * Must be called after start() + * + * \note Function only implemented by streams operating in mmap mode. + * + * \param[in] stream the stream object. + * \return 0 in case of success. + * -ENOSYS if called out of sequence or on non mmap stream + */ + int (*stop)(const struct audio_stream_out* stream); + + /** + * Called by the framework to retrieve information on the mmap buffer used for audio + * samples transfer. + * + * \note Function only implemented by streams operating in mmap mode. + * + * \param[in] stream the stream object. + * \param[in] min_size_frames minimum buffer size requested. The actual buffer + * size returned in struct audio_mmap_buffer_info can be larger. + * \param[out] info address at which the mmap buffer information should be returned. + * + * \return 0 if the buffer was allocated. + * -ENODEV in case of initialization error + * -EINVAL if the requested buffer size is too large + * -ENOSYS if called out of sequence (e.g. buffer already allocated) + */ + int (*create_mmap_buffer)(const struct audio_stream_out *stream, + int32_t min_size_frames, + struct audio_mmap_buffer_info *info); + + /** + * Called by the framework to read current read/write position in the mmap buffer + * with associated time stamp. + * + * \note Function only implemented by streams operating in mmap mode. + * + * \param[in] stream the stream object. + * \param[out] position address at which the mmap read/write position should be returned. + * + * \return 0 if the position is successfully returned. + * -ENODATA if the position cannot be retrieved + * -ENOSYS if called before create_mmap_buffer() + */ + int (*get_mmap_position)(const struct audio_stream_out *stream, + struct audio_mmap_position *position); + + /** + * Called when the metadata of the stream's source has been changed. + * @param source_metadata Description of the audio that is played by the clients. + */ + void (*update_source_metadata)(struct audio_stream_out *stream, + const struct source_metadata* source_metadata); }; typedef struct audio_stream_out audio_stream_out_t; @@ -456,6 +471,90 @@ struct audio_stream_in { */ int (*get_capture_position)(const struct audio_stream_in *stream, int64_t *frames, int64_t *time); + + /** + * Called by the framework to start a stream operating in mmap mode. + * create_mmap_buffer must be called before calling start() + * + * \note Function only implemented by streams operating in mmap mode. + * + * \param[in] stream the stream object. + * \return 0 in case off success. + * -ENOSYS if called out of sequence or on non mmap stream + */ + int (*start)(const struct audio_stream_in* stream); + + /** + * Called by the framework to stop a stream operating in mmap mode. + * + * \note Function only implemented by streams operating in mmap mode. + * + * \param[in] stream the stream object. + * \return 0 in case of success. + * -ENOSYS if called out of sequence or on non mmap stream + */ + int (*stop)(const struct audio_stream_in* stream); + + /** + * Called by the framework to retrieve information on the mmap buffer used for audio + * samples transfer. + * + * \note Function only implemented by streams operating in mmap mode. + * + * \param[in] stream the stream object. + * \param[in] min_size_frames minimum buffer size requested. The actual buffer + * size returned in struct audio_mmap_buffer_info can be larger. + * \param[out] info address at which the mmap buffer information should be returned. + * + * \return 0 if the buffer was allocated. + * -ENODEV in case of initialization error + * -EINVAL if the requested buffer size is too large + * -ENOSYS if called out of sequence (e.g. buffer already allocated) + */ + int (*create_mmap_buffer)(const struct audio_stream_in *stream, + int32_t min_size_frames, + struct audio_mmap_buffer_info *info); + + /** + * Called by the framework to read current read/write position in the mmap buffer + * with associated time stamp. + * + * \note Function only implemented by streams operating in mmap mode. + * + * \param[in] stream the stream object. + * \param[out] position address at which the mmap read/write position should be returned. + * + * \return 0 if the position is successfully returned. + * -ENODATA if the position cannot be retreived + * -ENOSYS if called before mmap_read_position() + */ + int (*get_mmap_position)(const struct audio_stream_in *stream, + struct audio_mmap_position *position); + + /** + * Called by the framework to read active microphones + * + * \param[in] stream the stream object. + * \param[out] mic_array Pointer to first element on array with microphone info + * \param[out] mic_count When called, this holds the value of the max number of elements + * allowed in the mic_array. The actual number of elements written + * is returned here. + * if mic_count is passed as zero, mic_array will not be populated, + * and mic_count will return the actual number of active microphones. + * + * \return 0 if the microphone array is successfully filled. + * -ENOSYS if there is an error filling the data + */ + int (*get_active_microphones)(const struct audio_stream_in *stream, + struct audio_microphone_characteristic_t *mic_array, + size_t *mic_count); + + /** + * Called when the metadata of the stream's sink has been changed. + * @param sink_metadata Description of the audio that is recorded by the clients. + */ + void (*update_sink_metadata)(struct audio_stream_in *stream, + const struct sink_metadata* sink_metadata); }; typedef struct audio_stream_in audio_stream_in_t; @@ -628,6 +727,25 @@ struct audio_hw_device { void (*close_input_stream)(struct audio_hw_device *dev, struct audio_stream_in *stream_in); + /** + * Called by the framework to read available microphones characteristics. + * + * \param[in] dev the hw_device object. + * \param[out] mic_array Pointer to first element on array with microphone info + * \param[out] mic_count When called, this holds the value of the max number of elements + * allowed in the mic_array. The actual number of elements written + * is returned here. + * if mic_count is passed as zero, mic_array will not be populated, + * and mic_count will return the actual number of microphones in the + * system. + * + * \return 0 if the microphone array is successfully filled. + * -ENOSYS if there is an error filling the data + */ + int (*get_microphones)(const struct audio_hw_device *dev, + struct audio_microphone_characteristic_t *mic_array, + size_t *mic_count); + /** This method dumps the state of the audio hardware */ int (*dump)(const struct audio_hw_device *dev, int fd); @@ -677,28 +795,6 @@ struct audio_hw_device { int (*set_audio_port_config)(struct audio_hw_device *dev, const struct audio_port_config *config); -#ifdef AUDIO_LISTEN_ENABLED - /** This method creates the listen session and returns handle */ - int (*open_listen_session)(struct audio_hw_device *dev, - listen_open_params_t *params, - struct listen_session** handle); - - /** This method closes the listen session */ - int (*close_listen_session)(struct audio_hw_device *dev, - struct listen_session* handle); - - /** This method sets the mad observer callback */ - int (*set_mad_observer)(struct audio_hw_device *dev, - listen_callback_t cb_func); - - /** - * This method is used for setting listen hal specfic parameters. - * If multiple paramets are set in one call and setting any one of them - * fails it will return failure. - */ - int (*listen_set_parameters)(struct audio_hw_device *dev, - const char *kv_pairs); -#endif }; typedef struct audio_hw_device audio_hw_device_t; @@ -708,7 +804,7 @@ static inline int audio_hw_device_open(const struct hw_module_t* module, struct audio_hw_device** device) { return module->methods->open(module, AUDIO_HARDWARE_INTERFACE, - (struct hw_device_t**)device); + TO_HW_DEVICE_T_OPEN(device)); } static inline int audio_hw_device_close(struct audio_hw_device* device) diff --git a/hardware/audio_alsaops.h b/hardware/audio_alsaops.h index 0d266ff..6a17a35 100644 --- a/hardware/audio_alsaops.h +++ b/hardware/audio_alsaops.h @@ -22,7 +22,8 @@ #ifndef ANDROID_AUDIO_ALSAOPS_H #define ANDROID_AUDIO_ALSAOPS_H -#include +#include + #include #include @@ -37,7 +38,7 @@ __BEGIN_DECLS static inline enum pcm_format pcm_format_from_audio_format(audio_format_t format) { switch (format) { -#ifdef HAVE_BIG_ENDIAN +#if HAVE_BIG_ENDIAN case AUDIO_FORMAT_PCM_16_BIT: return PCM_FORMAT_S16_BE; case AUDIO_FORMAT_PCM_24_BIT_PACKED: @@ -72,7 +73,7 @@ static inline enum pcm_format pcm_format_from_audio_format(audio_format_t format static inline audio_format_t audio_format_from_pcm_format(enum pcm_format format) { switch (format) { -#ifdef HAVE_BIG_ENDIAN +#if HAVE_BIG_ENDIAN case PCM_FORMAT_S16_BE: return AUDIO_FORMAT_PCM_16_BIT; case PCM_FORMAT_S24_3BE: diff --git a/hardware/audio_amplifier.h b/hardware/audio_amplifier.h deleted file mode 100644 index e3477d5..0000000 --- a/hardware/audio_amplifier.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (C) 2015, The CyanogenMod Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef CM_AUDIO_AMPLIFIER_INTERFACE_H -#define CM_AUDIO_AMPLIFIER_INTERFACE_H - -#include -#include -#include - -#include -#include - -#include - -__BEGIN_DECLS - -#define AMPLIFIER_HARDWARE_MODULE_ID "audio_amplifier" - -#define AMPLIFIER_HARDWARE_INTERFACE "audio_amplifier_hw_if" - -#define AMPLIFIER_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) - -#define AMPLIFIER_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) -#define AMPLIFIER_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 0) -#define AMPLIFIER_DEVICE_API_VERSION_CURRENT AMPLIFIER_DEVICE_API_VERSION_2_0 - -struct str_parms; - -typedef struct amplifier_device { - /** - * Common methods of the amplifier device. This *must* be the first member - * of amplifier_device as users of this structure will cast a hw_device_t - * to amplifier_device pointer in contexts where it's known - * the hw_device_t references a amplifier_device. - */ - struct hw_device_t common; - - /** - * Notify amplifier device of current input devices - * - * This function should handle only input devices. - */ - int (*set_input_devices)(struct amplifier_device *device, uint32_t devices); - - /** - * Notify amplifier device of current output devices - * - * This function should handle only output devices. - */ - int (*set_output_devices)(struct amplifier_device *device, uint32_t devices); - - /** - * Notify amplifier device of output device enable/disable - * - * This function should handle only output devices. - */ - int (*enable_output_devices)(struct amplifier_device *device, - uint32_t devices, bool enable); - - /** - * Notify amplifier device of input device enable/disable - * - * This function should handle only input devices. - */ - int (*enable_input_devices)(struct amplifier_device *device, - uint32_t devices, bool enable); - - /** - * Notify amplifier device about current audio mode - */ - int (*set_mode)(struct amplifier_device *device, audio_mode_t mode); - - /** - * Notify amplifier device that an output stream has started - */ - int (*output_stream_start)(struct amplifier_device *device, - struct audio_stream_out *stream, bool offload); - - /** - * Notify amplifier device that an input stream has started - */ - int (*input_stream_start)(struct amplifier_device *device, - struct audio_stream_in *stream); - - /** - * Notify amplifier device that an output stream has stopped - */ - int (*output_stream_standby)(struct amplifier_device *device, - struct audio_stream_out *stream); - - /** - * Notify amplifier device that an input stream has stopped - */ - int (*input_stream_standby)(struct amplifier_device *device, - struct audio_stream_in *stream); - - /** - * set/get output audio device parameters. - */ - int (*set_parameters)(struct amplifier_device *device, - struct str_parms *parms); -} amplifier_device_t; - -typedef struct amplifier_module { - /** - * Common methods of the amplifier module. This *must* be the first member - * of amplifier_module as users of this structure will cast a hw_module_t - * to amplifier_module pointer in contexts where it's known - * the hw_module_t references a amplifier_module. - */ - struct hw_module_t common; -} amplifier_module_t; - -/** convenience API for opening and closing a supported device */ - -static inline int amplifier_device_open(const struct hw_module_t *module, - struct amplifier_device **device) -{ - return module->methods->open(module, AMPLIFIER_HARDWARE_INTERFACE, - (struct hw_device_t **) device); -} - -static inline int amplifier_device_close(struct amplifier_device *device) -{ - return device->common.close(&device->common); -} - -__END_DECLS - -#endif // CM_AUDIO_AMPLIFIER_INTERFACE_H diff --git a/hardware/audio_effect.h b/hardware/audio_effect.h index 8a88414..3366e17 100644 --- a/hardware/audio_effect.h +++ b/hardware/audio_effect.h @@ -26,7 +26,7 @@ #include -#include +#include __BEGIN_DECLS @@ -36,231 +36,11 @@ __BEGIN_DECLS // Common Definitions ///////////////////////////////////////////////// -// -//--- Effect descriptor structure effect_descriptor_t -// - -// Unique effect ID (can be generated from the following site: -// http://www.itu.int/ITU-T/asn1/uuid.html) -// This format is used for both "type" and "uuid" fields of the effect descriptor structure. -// - When used for effect type and the engine is implementing and effect corresponding to a standard -// OpenSL ES interface, this ID must be the one defined in OpenSLES_IID.h for that interface. -// - When used as uuid, it should be a unique UUID for this particular implementation. -typedef struct effect_uuid_s { - uint32_t timeLow; - uint16_t timeMid; - uint16_t timeHiAndVersion; - uint16_t clockSeq; - uint8_t node[6]; -} effect_uuid_t; - -// Maximum length of character strings in structures defines by this API. -#define EFFECT_STRING_LEN_MAX 64 - -// NULL UUID definition (matches SL_IID_NULL_) -#define EFFECT_UUID_INITIALIZER { 0xec7178ec, 0xe5e1, 0x4432, 0xa3f4, \ - { 0x46, 0x57, 0xe6, 0x79, 0x52, 0x10 } } -static const effect_uuid_t EFFECT_UUID_NULL_ = EFFECT_UUID_INITIALIZER; -static const effect_uuid_t * const EFFECT_UUID_NULL = &EFFECT_UUID_NULL_; -static const char * const EFFECT_UUID_NULL_STR = "ec7178ec-e5e1-4432-a3f4-4657e6795210"; - - -// The effect descriptor contains necessary information to facilitate the enumeration of the effect -// engines present in a library. -typedef struct effect_descriptor_s { - effect_uuid_t type; // UUID of to the OpenSL ES interface implemented by this effect - effect_uuid_t uuid; // UUID for this particular implementation - uint32_t apiVersion; // Version of the effect control API implemented - uint32_t flags; // effect engine capabilities/requirements flags (see below) - uint16_t cpuLoad; // CPU load indication (see below) - uint16_t memoryUsage; // Data Memory usage (see below) - char name[EFFECT_STRING_LEN_MAX]; // human readable effect name - char implementor[EFFECT_STRING_LEN_MAX]; // human readable effect implementor name -} effect_descriptor_t; - -// CPU load and memory usage indication: each effect implementation must provide an indication of -// its CPU and memory usage for the audio effect framework to limit the number of effects -// instantiated at a given time on a given platform. -// The CPU load is expressed in 0.1 MIPS units as estimated on an ARM9E core (ARMv5TE) with 0 WS. -// The memory usage is expressed in KB and includes only dynamically allocated memory - -// Definitions for flags field of effect descriptor. -// +---------------------------+-----------+----------------------------------- -// | description | bits | values -// +---------------------------+-----------+----------------------------------- -// | connection mode | 0..2 | 0 insert: after track process -// | | | 1 auxiliary: connect to track auxiliary -// | | | output and use send level -// | | | 2 replace: replaces track process function; -// | | | must implement SRC, volume and mono to stereo. -// | | | 3 pre processing: applied below audio HAL on input -// | | | 4 post processing: applied below audio HAL on output -// | | | 5 - 7 reserved -// +---------------------------+-----------+----------------------------------- -// | insertion preference | 3..5 | 0 none -// | | | 1 first of the chain -// | | | 2 last of the chain -// | | | 3 exclusive (only effect in the insert chain) -// | | | 4..7 reserved -// +---------------------------+-----------+----------------------------------- -// | Volume management | 6..8 | 0 none -// | | | 1 implements volume control -// | | | 2 requires volume indication -// | | | 4 reserved -// +---------------------------+-----------+----------------------------------- -// | Device indication | 9..11 | 0 none -// | | | 1 requires device updates -// | | | 2, 4 reserved -// +---------------------------+-----------+----------------------------------- -// | Sample input mode | 12..13 | 1 direct: process() function or EFFECT_CMD_SET_CONFIG -// | | | command must specify a buffer descriptor -// | | | 2 provider: process() function uses the -// | | | bufferProvider indicated by the -// | | | EFFECT_CMD_SET_CONFIG command to request input. -// | | | buffers. -// | | | 3 both: both input modes are supported -// +---------------------------+-----------+----------------------------------- -// | Sample output mode | 14..15 | 1 direct: process() function or EFFECT_CMD_SET_CONFIG -// | | | command must specify a buffer descriptor -// | | | 2 provider: process() function uses the -// | | | bufferProvider indicated by the -// | | | EFFECT_CMD_SET_CONFIG command to request output -// | | | buffers. -// | | | 3 both: both output modes are supported -// +---------------------------+-----------+----------------------------------- -// | Hardware acceleration | 16..17 | 0 No hardware acceleration -// | | | 1 non tunneled hw acceleration: the process() function -// | | | reads the samples, send them to HW accelerated -// | | | effect processor, reads back the processed samples -// | | | and returns them to the output buffer. -// | | | 2 tunneled hw acceleration: the process() function is -// | | | transparent. The effect interface is only used to -// | | | control the effect engine. This mode is relevant for -// | | | global effects actually applied by the audio -// | | | hardware on the output stream. -// +---------------------------+-----------+----------------------------------- -// | Audio Mode indication | 18..19 | 0 none -// | | | 1 requires audio mode updates -// | | | 2..3 reserved -// +---------------------------+-----------+----------------------------------- -// | Audio source indication | 20..21 | 0 none -// | | | 1 requires audio source updates -// | | | 2..3 reserved -// +---------------------------+-----------+----------------------------------- -// | Effect offload supported | 22 | 0 The effect cannot be offloaded to an audio DSP -// | | | 1 The effect can be offloaded to an audio DSP -// +---------------------------+-----------+----------------------------------- -// | Process function not | 23 | 0 The effect implements a process function. -// | implemented | | 1 The effect does not implement a process function: -// | | | enabling the effect has no impact on latency or -// | | | CPU load. -// | | | Effect implementations setting this flag do not have -// | | | to implement a process function. -// +---------------------------+-----------+----------------------------------- - -// Insert mode -#define EFFECT_FLAG_TYPE_SHIFT 0 -#define EFFECT_FLAG_TYPE_SIZE 3 -#define EFFECT_FLAG_TYPE_MASK (((1 << EFFECT_FLAG_TYPE_SIZE) -1) \ - << EFFECT_FLAG_TYPE_SHIFT) -#define EFFECT_FLAG_TYPE_INSERT (0 << EFFECT_FLAG_TYPE_SHIFT) -#define EFFECT_FLAG_TYPE_AUXILIARY (1 << EFFECT_FLAG_TYPE_SHIFT) -#define EFFECT_FLAG_TYPE_REPLACE (2 << EFFECT_FLAG_TYPE_SHIFT) -#define EFFECT_FLAG_TYPE_PRE_PROC (3 << EFFECT_FLAG_TYPE_SHIFT) -#define EFFECT_FLAG_TYPE_POST_PROC (4 << EFFECT_FLAG_TYPE_SHIFT) - -// Insert preference -#define EFFECT_FLAG_INSERT_SHIFT (EFFECT_FLAG_TYPE_SHIFT + EFFECT_FLAG_TYPE_SIZE) -#define EFFECT_FLAG_INSERT_SIZE 3 -#define EFFECT_FLAG_INSERT_MASK (((1 << EFFECT_FLAG_INSERT_SIZE) -1) \ - << EFFECT_FLAG_INSERT_SHIFT) -#define EFFECT_FLAG_INSERT_ANY (0 << EFFECT_FLAG_INSERT_SHIFT) -#define EFFECT_FLAG_INSERT_FIRST (1 << EFFECT_FLAG_INSERT_SHIFT) -#define EFFECT_FLAG_INSERT_LAST (2 << EFFECT_FLAG_INSERT_SHIFT) -#define EFFECT_FLAG_INSERT_EXCLUSIVE (3 << EFFECT_FLAG_INSERT_SHIFT) - - -// Volume control -#define EFFECT_FLAG_VOLUME_SHIFT (EFFECT_FLAG_INSERT_SHIFT + EFFECT_FLAG_INSERT_SIZE) -#define EFFECT_FLAG_VOLUME_SIZE 3 -#define EFFECT_FLAG_VOLUME_MASK (((1 << EFFECT_FLAG_VOLUME_SIZE) -1) \ - << EFFECT_FLAG_VOLUME_SHIFT) -#define EFFECT_FLAG_VOLUME_CTRL (1 << EFFECT_FLAG_VOLUME_SHIFT) -#define EFFECT_FLAG_VOLUME_IND (2 << EFFECT_FLAG_VOLUME_SHIFT) -#define EFFECT_FLAG_VOLUME_NONE (0 << EFFECT_FLAG_VOLUME_SHIFT) - -// Device indication -#define EFFECT_FLAG_DEVICE_SHIFT (EFFECT_FLAG_VOLUME_SHIFT + EFFECT_FLAG_VOLUME_SIZE) -#define EFFECT_FLAG_DEVICE_SIZE 3 -#define EFFECT_FLAG_DEVICE_MASK (((1 << EFFECT_FLAG_DEVICE_SIZE) -1) \ - << EFFECT_FLAG_DEVICE_SHIFT) -#define EFFECT_FLAG_DEVICE_IND (1 << EFFECT_FLAG_DEVICE_SHIFT) -#define EFFECT_FLAG_DEVICE_NONE (0 << EFFECT_FLAG_DEVICE_SHIFT) - -// Sample input modes -#define EFFECT_FLAG_INPUT_SHIFT (EFFECT_FLAG_DEVICE_SHIFT + EFFECT_FLAG_DEVICE_SIZE) -#define EFFECT_FLAG_INPUT_SIZE 2 -#define EFFECT_FLAG_INPUT_MASK (((1 << EFFECT_FLAG_INPUT_SIZE) -1) \ - << EFFECT_FLAG_INPUT_SHIFT) -#define EFFECT_FLAG_INPUT_DIRECT (1 << EFFECT_FLAG_INPUT_SHIFT) -#define EFFECT_FLAG_INPUT_PROVIDER (2 << EFFECT_FLAG_INPUT_SHIFT) -#define EFFECT_FLAG_INPUT_BOTH (3 << EFFECT_FLAG_INPUT_SHIFT) - -// Sample output modes -#define EFFECT_FLAG_OUTPUT_SHIFT (EFFECT_FLAG_INPUT_SHIFT + EFFECT_FLAG_INPUT_SIZE) -#define EFFECT_FLAG_OUTPUT_SIZE 2 -#define EFFECT_FLAG_OUTPUT_MASK (((1 << EFFECT_FLAG_OUTPUT_SIZE) -1) \ - << EFFECT_FLAG_OUTPUT_SHIFT) -#define EFFECT_FLAG_OUTPUT_DIRECT (1 << EFFECT_FLAG_OUTPUT_SHIFT) -#define EFFECT_FLAG_OUTPUT_PROVIDER (2 << EFFECT_FLAG_OUTPUT_SHIFT) -#define EFFECT_FLAG_OUTPUT_BOTH (3 << EFFECT_FLAG_OUTPUT_SHIFT) - -// Hardware acceleration mode -#define EFFECT_FLAG_HW_ACC_SHIFT (EFFECT_FLAG_OUTPUT_SHIFT + EFFECT_FLAG_OUTPUT_SIZE) -#define EFFECT_FLAG_HW_ACC_SIZE 2 -#define EFFECT_FLAG_HW_ACC_MASK (((1 << EFFECT_FLAG_HW_ACC_SIZE) -1) \ - << EFFECT_FLAG_HW_ACC_SHIFT) -#define EFFECT_FLAG_HW_ACC_SIMPLE (1 << EFFECT_FLAG_HW_ACC_SHIFT) -#define EFFECT_FLAG_HW_ACC_TUNNEL (2 << EFFECT_FLAG_HW_ACC_SHIFT) - -// Audio mode indication -#define EFFECT_FLAG_AUDIO_MODE_SHIFT (EFFECT_FLAG_HW_ACC_SHIFT + EFFECT_FLAG_HW_ACC_SIZE) -#define EFFECT_FLAG_AUDIO_MODE_SIZE 2 -#define EFFECT_FLAG_AUDIO_MODE_MASK (((1 << EFFECT_FLAG_AUDIO_MODE_SIZE) -1) \ - << EFFECT_FLAG_AUDIO_MODE_SHIFT) -#define EFFECT_FLAG_AUDIO_MODE_IND (1 << EFFECT_FLAG_AUDIO_MODE_SHIFT) -#define EFFECT_FLAG_AUDIO_MODE_NONE (0 << EFFECT_FLAG_AUDIO_MODE_SHIFT) - -// Audio source indication -#define EFFECT_FLAG_AUDIO_SOURCE_SHIFT (EFFECT_FLAG_AUDIO_MODE_SHIFT + EFFECT_FLAG_AUDIO_MODE_SIZE) -#define EFFECT_FLAG_AUDIO_SOURCE_SIZE 2 -#define EFFECT_FLAG_AUDIO_SOURCE_MASK (((1 << EFFECT_FLAG_AUDIO_SOURCE_SIZE) -1) \ - << EFFECT_FLAG_AUDIO_SOURCE_SHIFT) -#define EFFECT_FLAG_AUDIO_SOURCE_IND (1 << EFFECT_FLAG_AUDIO_SOURCE_SHIFT) -#define EFFECT_FLAG_AUDIO_SOURCE_NONE (0 << EFFECT_FLAG_AUDIO_SOURCE_SHIFT) - -// Effect offload indication -#define EFFECT_FLAG_OFFLOAD_SHIFT (EFFECT_FLAG_AUDIO_SOURCE_SHIFT + \ - EFFECT_FLAG_AUDIO_SOURCE_SIZE) -#define EFFECT_FLAG_OFFLOAD_SIZE 1 -#define EFFECT_FLAG_OFFLOAD_MASK (((1 << EFFECT_FLAG_OFFLOAD_SIZE) -1) \ - << EFFECT_FLAG_OFFLOAD_SHIFT) -#define EFFECT_FLAG_OFFLOAD_SUPPORTED (1 << EFFECT_FLAG_OFFLOAD_SHIFT) - -// Effect has no process indication -#define EFFECT_FLAG_NO_PROCESS_SHIFT (EFFECT_FLAG_OFFLOAD_SHIFT + \ - EFFECT_FLAG_OFFLOAD_SIZE) -#define EFFECT_FLAG_NO_PROCESS_SIZE 1 -#define EFFECT_FLAG_NO_PROCESS_MASK (((1 << EFFECT_FLAG_NO_PROCESS_SIZE) -1) \ - << EFFECT_FLAG_NO_PROCESS_SHIFT) -#define EFFECT_FLAG_NO_PROCESS (1 << EFFECT_FLAG_NO_PROCESS_SHIFT) - #define EFFECT_MAKE_API_VERSION(M, m) (((M)<<16) | ((m) & 0xFFFF)) #define EFFECT_API_VERSION_MAJOR(v) ((v)>>16) #define EFFECT_API_VERSION_MINOR(v) ((m) & 0xFFFF) - ///////////////////////////////////////////////// // Effect control interface ///////////////////////////////////////////////// @@ -288,15 +68,6 @@ typedef struct effect_descriptor_s { // type and return its address as effect_handle_t typedef struct effect_interface_s **effect_handle_t; - -// Forward definition of type audio_buffer_t -typedef struct audio_buffer_s audio_buffer_t; - - - - - - // Effect control interface definition struct effect_interface_s { //////////////////////////////////////////////////////////////////////////////// @@ -428,499 +199,6 @@ struct effect_interface_s { audio_buffer_t *outBuffer); }; - -// -//--- Standardized command codes for command() function -// -enum effect_command_e { - EFFECT_CMD_INIT, // initialize effect engine - EFFECT_CMD_SET_CONFIG, // configure effect engine (see effect_config_t) - EFFECT_CMD_RESET, // reset effect engine - EFFECT_CMD_ENABLE, // enable effect process - EFFECT_CMD_DISABLE, // disable effect process - EFFECT_CMD_SET_PARAM, // set parameter immediately (see effect_param_t) - EFFECT_CMD_SET_PARAM_DEFERRED, // set parameter deferred - EFFECT_CMD_SET_PARAM_COMMIT, // commit previous set parameter deferred - EFFECT_CMD_GET_PARAM, // get parameter - EFFECT_CMD_SET_DEVICE, // set audio device (see audio.h, audio_devices_t) - EFFECT_CMD_SET_VOLUME, // set volume - EFFECT_CMD_SET_AUDIO_MODE, // set the audio mode (normal, ring, ...) - EFFECT_CMD_SET_CONFIG_REVERSE, // configure effect engine reverse stream(see effect_config_t) - EFFECT_CMD_SET_INPUT_DEVICE, // set capture device (see audio.h, audio_devices_t) - EFFECT_CMD_GET_CONFIG, // read effect engine configuration - EFFECT_CMD_GET_CONFIG_REVERSE, // read configure effect engine reverse stream configuration - EFFECT_CMD_GET_FEATURE_SUPPORTED_CONFIGS,// get all supported configurations for a feature. - EFFECT_CMD_GET_FEATURE_CONFIG, // get current feature configuration - EFFECT_CMD_SET_FEATURE_CONFIG, // set current feature configuration - EFFECT_CMD_SET_AUDIO_SOURCE, // set the audio source (see audio.h, audio_source_t) - EFFECT_CMD_OFFLOAD, // set if effect thread is an offload one, - // send the ioHandle of the effect thread - EFFECT_CMD_FIRST_PROPRIETARY = 0x10000 // first proprietary command code -}; - -//================================================================================================== -// command: EFFECT_CMD_INIT -//-------------------------------------------------------------------------------------------------- -// description: -// Initialize effect engine: All configurations return to default -//-------------------------------------------------------------------------------------------------- -// command format: -// size: 0 -// data: N/A -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: sizeof(int) -// data: status -//================================================================================================== -// command: EFFECT_CMD_SET_CONFIG -//-------------------------------------------------------------------------------------------------- -// description: -// Apply new audio parameters configurations for input and output buffers -//-------------------------------------------------------------------------------------------------- -// command format: -// size: sizeof(effect_config_t) -// data: effect_config_t -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: sizeof(int) -// data: status -//================================================================================================== -// command: EFFECT_CMD_RESET -//-------------------------------------------------------------------------------------------------- -// description: -// Reset the effect engine. Keep configuration but resets state and buffer content -//-------------------------------------------------------------------------------------------------- -// command format: -// size: 0 -// data: N/A -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: 0 -// data: N/A -//================================================================================================== -// command: EFFECT_CMD_ENABLE -//-------------------------------------------------------------------------------------------------- -// description: -// Enable the process. Called by the framework before the first call to process() -//-------------------------------------------------------------------------------------------------- -// command format: -// size: 0 -// data: N/A -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: sizeof(int) -// data: status -//================================================================================================== -// command: EFFECT_CMD_DISABLE -//-------------------------------------------------------------------------------------------------- -// description: -// Disable the process. Called by the framework after the last call to process() -//-------------------------------------------------------------------------------------------------- -// command format: -// size: 0 -// data: N/A -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: sizeof(int) -// data: status -//================================================================================================== -// command: EFFECT_CMD_SET_PARAM -//-------------------------------------------------------------------------------------------------- -// description: -// Set a parameter and apply it immediately -//-------------------------------------------------------------------------------------------------- -// command format: -// size: sizeof(effect_param_t) + size of param and value -// data: effect_param_t + param + value. See effect_param_t definition below for value offset -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: sizeof(int) -// data: status -//================================================================================================== -// command: EFFECT_CMD_SET_PARAM_DEFERRED -//-------------------------------------------------------------------------------------------------- -// description: -// Set a parameter but apply it only when receiving EFFECT_CMD_SET_PARAM_COMMIT command -//-------------------------------------------------------------------------------------------------- -// command format: -// size: sizeof(effect_param_t) + size of param and value -// data: effect_param_t + param + value. See effect_param_t definition below for value offset -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: 0 -// data: N/A -//================================================================================================== -// command: EFFECT_CMD_SET_PARAM_COMMIT -//-------------------------------------------------------------------------------------------------- -// description: -// Apply all previously received EFFECT_CMD_SET_PARAM_DEFERRED commands -//-------------------------------------------------------------------------------------------------- -// command format: -// size: 0 -// data: N/A -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: sizeof(int) -// data: status -//================================================================================================== -// command: EFFECT_CMD_GET_PARAM -//-------------------------------------------------------------------------------------------------- -// description: -// Get a parameter value -//-------------------------------------------------------------------------------------------------- -// command format: -// size: sizeof(effect_param_t) + size of param -// data: effect_param_t + param -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: sizeof(effect_param_t) + size of param and value -// data: effect_param_t + param + value. See effect_param_t definition below for value offset -//================================================================================================== -// command: EFFECT_CMD_SET_DEVICE -//-------------------------------------------------------------------------------------------------- -// description: -// Set the rendering device the audio output path is connected to. See audio.h, audio_devices_t -// for device values. -// The effect implementation must set EFFECT_FLAG_DEVICE_IND flag in its descriptor to receive this -// command when the device changes -//-------------------------------------------------------------------------------------------------- -// command format: -// size: sizeof(uint32_t) -// data: uint32_t -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: 0 -// data: N/A -//================================================================================================== -// command: EFFECT_CMD_SET_VOLUME -//-------------------------------------------------------------------------------------------------- -// description: -// Set and get volume. Used by audio framework to delegate volume control to effect engine. -// The effect implementation must set EFFECT_FLAG_VOLUME_IND or EFFECT_FLAG_VOLUME_CTRL flag in -// its descriptor to receive this command before every call to process() function -// If EFFECT_FLAG_VOLUME_CTRL flag is set in the effect descriptor, the effect engine must return -// the volume that should be applied before the effect is processed. The overall volume (the volume -// actually applied by the effect engine multiplied by the returned value) should match the value -// indicated in the command. -//-------------------------------------------------------------------------------------------------- -// command format: -// size: n * sizeof(uint32_t) -// data: volume for each channel defined in effect_config_t for output buffer expressed in -// 8.24 fixed point format -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: n * sizeof(uint32_t) / 0 -// data: - if EFFECT_FLAG_VOLUME_CTRL is set in effect descriptor: -// volume for each channel defined in effect_config_t for output buffer expressed in -// 8.24 fixed point format -// - if EFFECT_FLAG_VOLUME_CTRL is not set in effect descriptor: -// N/A -// It is legal to receive a null pointer as pReplyData in which case the effect framework has -// delegated volume control to another effect -//================================================================================================== -// command: EFFECT_CMD_SET_AUDIO_MODE -//-------------------------------------------------------------------------------------------------- -// description: -// Set the audio mode. The effect implementation must set EFFECT_FLAG_AUDIO_MODE_IND flag in its -// descriptor to receive this command when the audio mode changes. -//-------------------------------------------------------------------------------------------------- -// command format: -// size: sizeof(uint32_t) -// data: audio_mode_t -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: 0 -// data: N/A -//================================================================================================== -// command: EFFECT_CMD_SET_CONFIG_REVERSE -//-------------------------------------------------------------------------------------------------- -// description: -// Apply new audio parameters configurations for input and output buffers of reverse stream. -// An example of reverse stream is the echo reference supplied to an Acoustic Echo Canceler. -//-------------------------------------------------------------------------------------------------- -// command format: -// size: sizeof(effect_config_t) -// data: effect_config_t -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: sizeof(int) -// data: status -//================================================================================================== -// command: EFFECT_CMD_SET_INPUT_DEVICE -//-------------------------------------------------------------------------------------------------- -// description: -// Set the capture device the audio input path is connected to. See audio.h, audio_devices_t -// for device values. -// The effect implementation must set EFFECT_FLAG_DEVICE_IND flag in its descriptor to receive this -// command when the device changes -//-------------------------------------------------------------------------------------------------- -// command format: -// size: sizeof(uint32_t) -// data: uint32_t -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: 0 -// data: N/A -//================================================================================================== -// command: EFFECT_CMD_GET_CONFIG -//-------------------------------------------------------------------------------------------------- -// description: -// Read audio parameters configurations for input and output buffers -//-------------------------------------------------------------------------------------------------- -// command format: -// size: 0 -// data: N/A -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: sizeof(effect_config_t) -// data: effect_config_t -//================================================================================================== -// command: EFFECT_CMD_GET_CONFIG_REVERSE -//-------------------------------------------------------------------------------------------------- -// description: -// Read audio parameters configurations for input and output buffers of reverse stream -//-------------------------------------------------------------------------------------------------- -// command format: -// size: 0 -// data: N/A -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: sizeof(effect_config_t) -// data: effect_config_t -//================================================================================================== -// command: EFFECT_CMD_GET_FEATURE_SUPPORTED_CONFIGS -//-------------------------------------------------------------------------------------------------- -// description: -// Queries for supported configurations for a particular feature (e.g. get the supported -// combinations of main and auxiliary channels for a noise suppressor). -// The command parameter is the feature identifier (See effect_feature_e for a list of defined -// features) followed by the maximum number of configuration descriptor to return. -// The reply is composed of: -// - status (uint32_t): -// - 0 if feature is supported -// - -ENOSYS if the feature is not supported, -// - -ENOMEM if the feature is supported but the total number of supported configurations -// exceeds the maximum number indicated by the caller. -// - total number of supported configurations (uint32_t) -// - an array of configuration descriptors. -// The actual number of descriptors returned must not exceed the maximum number indicated by -// the caller. -//-------------------------------------------------------------------------------------------------- -// command format: -// size: 2 x sizeof(uint32_t) -// data: effect_feature_e + maximum number of configurations to return -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: 2 x sizeof(uint32_t) + n x sizeof () -// data: status + total number of configurations supported + array of n config descriptors -//================================================================================================== -// command: EFFECT_CMD_GET_FEATURE_CONFIG -//-------------------------------------------------------------------------------------------------- -// description: -// Retrieves current configuration for a given feature. -// The reply status is: -// - 0 if feature is supported -// - -ENOSYS if the feature is not supported, -//-------------------------------------------------------------------------------------------------- -// command format: -// size: sizeof(uint32_t) -// data: effect_feature_e -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: sizeof(uint32_t) + sizeof () -// data: status + config descriptor -//================================================================================================== -// command: EFFECT_CMD_SET_FEATURE_CONFIG -//-------------------------------------------------------------------------------------------------- -// description: -// Sets current configuration for a given feature. -// The reply status is: -// - 0 if feature is supported -// - -ENOSYS if the feature is not supported, -// - -EINVAL if the configuration is invalid -//-------------------------------------------------------------------------------------------------- -// command format: -// size: sizeof(uint32_t) + sizeof () -// data: effect_feature_e + config descriptor -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: sizeof(uint32_t) -// data: status -//================================================================================================== -// command: EFFECT_CMD_SET_AUDIO_SOURCE -//-------------------------------------------------------------------------------------------------- -// description: -// Set the audio source the capture path is configured for (Camcorder, voice recognition...). -// See audio.h, audio_source_t for values. -//-------------------------------------------------------------------------------------------------- -// command format: -// size: sizeof(uint32_t) -// data: uint32_t -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: 0 -// data: N/A -//================================================================================================== -// command: EFFECT_CMD_OFFLOAD -//-------------------------------------------------------------------------------------------------- -// description: -// 1.indicate if the playback thread the effect is attached to is offloaded or not -// 2.update the io handle of the playback thread the effect is attached to -//-------------------------------------------------------------------------------------------------- -// command format: -// size: sizeof(effect_offload_param_t) -// data: effect_offload_param_t -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: sizeof(uint32_t) -// data: uint32_t -//-------------------------------------------------------------------------------------------------- -// command: EFFECT_CMD_FIRST_PROPRIETARY -//-------------------------------------------------------------------------------------------------- -// description: -// All proprietary effect commands must use command codes above this value. The size and format of -// command and response fields is free in this case -//================================================================================================== - - -// Audio buffer descriptor used by process(), bufferProvider() functions and buffer_config_t -// structure. Multi-channel audio is always interleaved. The channel order is from LSB to MSB with -// regard to the channel mask definition in audio.h, audio_channel_mask_t e.g : -// Stereo: left, right -// 5 point 1: front left, front right, front center, low frequency, back left, back right -// The buffer size is expressed in frame count, a frame being composed of samples for all -// channels at a given time. Frame size for unspecified format (AUDIO_FORMAT_OTHER) is 8 bit by -// definition -struct audio_buffer_s { - size_t frameCount; // number of frames in buffer - union { - void* raw; // raw pointer to start of buffer - int32_t* s32; // pointer to signed 32 bit data at start of buffer - int16_t* s16; // pointer to signed 16 bit data at start of buffer - uint8_t* u8; // pointer to unsigned 8 bit data at start of buffer - }; -}; - -// The buffer_provider_s structure contains functions that can be used -// by the effect engine process() function to query and release input -// or output audio buffer. -// The getBuffer() function is called to retrieve a buffer where data -// should read from or written to by process() function. -// The releaseBuffer() function MUST be called when the buffer retrieved -// with getBuffer() is not needed anymore. -// The process function should use the buffer provider mechanism to retrieve -// input or output buffer if the inBuffer or outBuffer passed as argument is NULL -// and the buffer configuration (buffer_config_t) given by the EFFECT_CMD_SET_CONFIG -// command did not specify an audio buffer. - -typedef int32_t (* buffer_function_t)(void *cookie, audio_buffer_t *buffer); - -typedef struct buffer_provider_s { - buffer_function_t getBuffer; // retrieve next buffer - buffer_function_t releaseBuffer; // release used buffer - void *cookie; // for use by client of buffer provider functions -} buffer_provider_t; - - -// The buffer_config_s structure specifies the input or output audio format -// to be used by the effect engine. It is part of the effect_config_t -// structure that defines both input and output buffer configurations and is -// passed by the EFFECT_CMD_SET_CONFIG or EFFECT_CMD_SET_CONFIG_REVERSE command. -typedef struct buffer_config_s { - audio_buffer_t buffer; // buffer for use by process() function if not passed explicitly - uint32_t samplingRate; // sampling rate - uint32_t channels; // channel mask (see audio_channel_mask_t in audio.h) - buffer_provider_t bufferProvider; // buffer provider - uint8_t format; // Audio format (see audio_format_t in audio.h) - uint8_t accessMode; // read/write or accumulate in buffer (effect_buffer_access_e) - uint16_t mask; // indicates which of the above fields is valid -} buffer_config_t; - -// Values for "accessMode" field of buffer_config_t: -// overwrite, read only, accumulate (read/modify/write) -enum effect_buffer_access_e { - EFFECT_BUFFER_ACCESS_WRITE, - EFFECT_BUFFER_ACCESS_READ, - EFFECT_BUFFER_ACCESS_ACCUMULATE - -}; - -// feature identifiers for EFFECT_CMD_GET_FEATURE_SUPPORTED_CONFIGS command -enum effect_feature_e { - EFFECT_FEATURE_AUX_CHANNELS, // supports auxiliary channels (e.g. dual mic noise suppressor) - EFFECT_FEATURE_CNT -}; - -// EFFECT_FEATURE_AUX_CHANNELS feature configuration descriptor. Describe a combination -// of main and auxiliary channels supported -typedef struct channel_config_s { - audio_channel_mask_t main_channels; // channel mask for main channels - audio_channel_mask_t aux_channels; // channel mask for auxiliary channels -} channel_config_t; - - -// Values for bit field "mask" in buffer_config_t. If a bit is set, the corresponding field -// in buffer_config_t must be taken into account when executing the EFFECT_CMD_SET_CONFIG command -#define EFFECT_CONFIG_BUFFER 0x0001 // buffer field must be taken into account -#define EFFECT_CONFIG_SMP_RATE 0x0002 // samplingRate field must be taken into account -#define EFFECT_CONFIG_CHANNELS 0x0004 // channels field must be taken into account -#define EFFECT_CONFIG_FORMAT 0x0008 // format field must be taken into account -#define EFFECT_CONFIG_ACC_MODE 0x0010 // accessMode field must be taken into account -#define EFFECT_CONFIG_PROVIDER 0x0020 // bufferProvider field must be taken into account -#define EFFECT_CONFIG_ALL (EFFECT_CONFIG_BUFFER | EFFECT_CONFIG_SMP_RATE | \ - EFFECT_CONFIG_CHANNELS | EFFECT_CONFIG_FORMAT | \ - EFFECT_CONFIG_ACC_MODE | EFFECT_CONFIG_PROVIDER) - - -// effect_config_s structure describes the format of the pCmdData argument of EFFECT_CMD_SET_CONFIG -// command to configure audio parameters and buffers for effect engine input and output. -typedef struct effect_config_s { - buffer_config_t inputCfg; - buffer_config_t outputCfg; -} effect_config_t; - - -// effect_param_s structure describes the format of the pCmdData argument of EFFECT_CMD_SET_PARAM -// command and pCmdData and pReplyData of EFFECT_CMD_GET_PARAM command. -// psize and vsize represent the actual size of parameter and value. -// -// NOTE: the start of value field inside the data field is always on a 32 bit boundary: -// -// +-----------+ -// | status | sizeof(int) -// +-----------+ -// | psize | sizeof(int) -// +-----------+ -// | vsize | sizeof(int) -// +-----------+ -// | | | | -// ~ parameter ~ > psize | -// | | | > ((psize - 1)/sizeof(int) + 1) * sizeof(int) -// +-----------+ | -// | padding | | -// +-----------+ -// | | | -// ~ value ~ > vsize -// | | | -// +-----------+ - -typedef struct effect_param_s { - int32_t status; // Transaction status (unused for command, used for reply) - uint32_t psize; // Parameter size - uint32_t vsize; // Value size - char data[]; // Start of Parameter + Value data -} effect_param_t; - -// Maximum effect_param_t size -#define EFFECT_PARAM_SIZE_MAX 65536 - -// structure used by EFFECT_CMD_OFFLOAD command -typedef struct effect_offload_param_s { - bool isOffload; // true if the playback thread the effect is attached to is offloaded - int ioHandle; // io handle of the playback thread the effect is attached to -} effect_offload_param_t; - - ///////////////////////////////////////////////// // Effect library interface ///////////////////////////////////////////////// diff --git a/hardware/bluetooth.h b/hardware/bluetooth.h index 5a03cf8..3bcbeed 100644 --- a/hardware/bluetooth.h +++ b/hardware/bluetooth.h @@ -22,20 +22,23 @@ #include #include -#include +#include +#include __BEGIN_DECLS -/** - * The Bluetooth Hardware Module ID - */ +/** +* The Bluetooth Hardware Module ID +*/ +#define BLUETOOTH_INTERFACE_STRING "bluetoothInterface" #define BT_HARDWARE_MODULE_ID "bluetooth" #define BT_STACK_MODULE_ID "bluetooth" #define BT_STACK_TEST_MODULE_ID "bluetooth_test" +#define bluetooth_module_t "bluetooth_test" -/* Bluetooth profile interface IDs */ +/** Bluetooth profile interface IDs */ #define BT_PROFILE_HANDSFREE_ID "handsfree" #define BT_PROFILE_HANDSFREE_CLIENT_ID "handsfree_client" @@ -44,6 +47,7 @@ __BEGIN_DECLS #define BT_PROFILE_HEALTH_ID "health" #define BT_PROFILE_SOCKETS_ID "socket" #define BT_PROFILE_HIDHOST_ID "hidhost" +#define BT_PROFILE_HIDDEV_ID "hiddev" #define BT_PROFILE_PAN_ID "pan" #define BT_PROFILE_MAP_CLIENT_ID "map_client" #define BT_PROFILE_SDP_CLIENT_ID "sdp" @@ -51,10 +55,8 @@ __BEGIN_DECLS #define BT_PROFILE_AV_RC_ID "avrcp" #define BT_PROFILE_AV_RC_CTRL_ID "avrcp_ctrl" -/** Bluetooth Address */ -typedef struct { - uint8_t address[6]; -} __attribute__((packed))bt_bdaddr_t; +/** Bluetooth test interface IDs */ +#define BT_TEST_INTERFACE_MCAP_ID "mcap_test" /** Bluetooth Device Name */ typedef struct { @@ -127,15 +129,10 @@ typedef enum { BT_ACL_STATE_DISCONNECTED } bt_acl_state_t; -/** Bluetooth 128-bit UUID */ -typedef struct { - uint8_t uu[16]; -} bt_uuid_t; - /** Bluetooth SDP service record */ typedef struct { - bt_uuid_t uuid; + bluetooth::Uuid uuid; uint16_t channel; char name[256]; // what's the maximum length } bt_service_record_t; @@ -162,98 +159,104 @@ typedef struct uint16_t total_trackable_advertisers; bool extended_scan_support; bool debug_logging_supported; + bool le_2m_phy_supported; + bool le_coded_phy_supported; + bool le_extended_advertising_supported; + bool le_periodic_advertising_supported; + uint16_t le_maximum_advertising_data_length; }bt_local_le_features_t; /* Bluetooth Adapter and Remote Device property types */ typedef enum { - /* Properties common to both adapter and remote device */ - /** - * Description - Bluetooth Device Name - * Access mode - Adapter name can be GET/SET. Remote device can be GET - * Data type - bt_bdname_t - */ - BT_PROPERTY_BDNAME = 0x1, - /** - * Description - Bluetooth Device Address - * Access mode - Only GET. - * Data type - bt_bdaddr_t - */ - BT_PROPERTY_BDADDR, - /** - * Description - Bluetooth Service 128-bit UUIDs - * Access mode - Only GET. - * Data type - Array of bt_uuid_t (Array size inferred from property length). - */ - BT_PROPERTY_UUIDS, - /** - * Description - Bluetooth Class of Device as found in Assigned Numbers - * Access mode - Only GET. - * Data type - uint32_t. - */ - BT_PROPERTY_CLASS_OF_DEVICE, - /** - * Description - Device Type - BREDR, BLE or DUAL Mode - * Access mode - Only GET. - * Data type - bt_device_type_t - */ - BT_PROPERTY_TYPE_OF_DEVICE, - /** - * Description - Bluetooth Service Record - * Access mode - Only GET. - * Data type - bt_service_record_t - */ - BT_PROPERTY_SERVICE_RECORD, - - /* Properties unique to adapter */ - /** - * Description - Bluetooth Adapter scan mode - * Access mode - GET and SET - * Data type - bt_scan_mode_t. - */ - BT_PROPERTY_ADAPTER_SCAN_MODE, - /** - * Description - List of bonded devices - * Access mode - Only GET. - * Data type - Array of bt_bdaddr_t of the bonded remote devices - * (Array size inferred from property length). - */ - BT_PROPERTY_ADAPTER_BONDED_DEVICES, - /** - * Description - Bluetooth Adapter Discovery timeout (in seconds) - * Access mode - GET and SET - * Data type - uint32_t - */ - BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT, - - /* Properties unique to remote device */ - /** - * Description - User defined friendly name of the remote device - * Access mode - GET and SET - * Data type - bt_bdname_t. - */ - BT_PROPERTY_REMOTE_FRIENDLY_NAME, - /** - * Description - RSSI value of the inquired remote device - * Access mode - Only GET. - * Data type - int32_t. - */ - BT_PROPERTY_REMOTE_RSSI, - /** - * Description - Remote version info - * Access mode - SET/GET. - * Data type - bt_remote_version_t. - */ - - BT_PROPERTY_REMOTE_VERSION_INFO, - - /** - * Description - Local LE features - * Access mode - GET. - * Data type - bt_local_le_features_t. - */ - BT_PROPERTY_LOCAL_LE_FEATURES, - - BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP = 0xFF, + /* Properties common to both adapter and remote device */ + /** + * Description - Bluetooth Device Name + * Access mode - Adapter name can be GET/SET. Remote device can be GET + * Data type - bt_bdname_t + */ + BT_PROPERTY_BDNAME = 0x1, + /** + * Description - Bluetooth Device Address + * Access mode - Only GET. + * Data type - RawAddress + */ + BT_PROPERTY_BDADDR, + /** + * Description - Bluetooth Service 128-bit UUIDs + * Access mode - Only GET. + * Data type - Array of bluetooth::Uuid (Array size inferred from property + * length). + */ + BT_PROPERTY_UUIDS, + /** + * Description - Bluetooth Class of Device as found in Assigned Numbers + * Access mode - Only GET. + * Data type - uint32_t. + */ + BT_PROPERTY_CLASS_OF_DEVICE, + /** + * Description - Device Type - BREDR, BLE or DUAL Mode + * Access mode - Only GET. + * Data type - bt_device_type_t + */ + BT_PROPERTY_TYPE_OF_DEVICE, + /** + * Description - Bluetooth Service Record + * Access mode - Only GET. + * Data type - bt_service_record_t + */ + BT_PROPERTY_SERVICE_RECORD, + + /* Properties unique to adapter */ + /** + * Description - Bluetooth Adapter scan mode + * Access mode - GET and SET + * Data type - bt_scan_mode_t. + */ + BT_PROPERTY_ADAPTER_SCAN_MODE, + /** + * Description - List of bonded devices + * Access mode - Only GET. + * Data type - Array of RawAddress of the bonded remote devices + * (Array size inferred from property length). + */ + BT_PROPERTY_ADAPTER_BONDED_DEVICES, + /** + * Description - Bluetooth Adapter Discovery timeout (in seconds) + * Access mode - GET and SET + * Data type - uint32_t + */ + BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT, + + /* Properties unique to remote device */ + /** + * Description - User defined friendly name of the remote device + * Access mode - GET and SET + * Data type - bt_bdname_t. + */ + BT_PROPERTY_REMOTE_FRIENDLY_NAME, + /** + * Description - RSSI value of the inquired remote device + * Access mode - Only GET. + * Data type - int32_t. + */ + BT_PROPERTY_REMOTE_RSSI, + /** + * Description - Remote version info + * Access mode - SET/GET. + * Data type - bt_remote_version_t. + */ + + BT_PROPERTY_REMOTE_VERSION_INFO, + + /** + * Description - Local LE features + * Access mode - GET. + * Data type - bt_local_le_features_t. + */ + BT_PROPERTY_LOCAL_LE_FEATURES, + + BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP = 0xFF, } bt_property_type_t; /** Bluetooth Adapter Property data structure */ @@ -267,12 +270,13 @@ typedef struct /** Bluetooth Out Of Band data for bonding */ typedef struct { + uint8_t le_bt_dev_addr[7]; /* LE Bluetooth Device Address */ uint8_t c192[16]; /* Simple Pairing Hash C-192 */ uint8_t r192[16]; /* Simple Pairing Randomizer R-192 */ uint8_t c256[16]; /* Simple Pairing Hash C-256 */ uint8_t r256[16]; /* Simple Pairing Randomizer R-256 */ uint8_t sm_tk[16]; /* Security Manager TK Value */ - uint8_t le_sc_c[16]; /* LE Secure Connections Random Value */ + uint8_t le_sc_c[16]; /* LE Secure Connections Confirmation Value */ uint8_t le_sc_r[16]; /* LE Secure Connections Random Value */ } bt_out_of_band_data_t; @@ -324,7 +328,7 @@ typedef void (*adapter_properties_callback)(bt_status_t status, * multiple properties - num_properties shall be 1 */ typedef void (*remote_device_properties_callback)(bt_status_t status, - bt_bdaddr_t *bd_addr, + RawAddress *bd_addr, int num_properties, bt_property_t *properties); @@ -338,7 +342,7 @@ typedef void (*device_found_callback)(int num_properties, typedef void (*discovery_state_changed_callback)(bt_discovery_state_t state); /** Bluetooth Legacy PinKey Request callback */ -typedef void (*pin_request_callback)(bt_bdaddr_t *remote_bd_addr, +typedef void (*pin_request_callback)(RawAddress *remote_bd_addr, bt_bdname_t *bd_name, uint32_t cod, bool min_16_digit); /** Bluetooth SSP Request callback - Just Works & Numeric Comparison*/ @@ -346,7 +350,7 @@ typedef void (*pin_request_callback)(bt_bdaddr_t *remote_bd_addr, * BT_SSP_PAIRING_PASSKEY_ENTRY */ /* TODO: Passkey request callback shall not be needed for devices with display * capability. We still need support this in the stack for completeness */ -typedef void (*ssp_request_callback)(bt_bdaddr_t *remote_bd_addr, +typedef void (*ssp_request_callback)(RawAddress *remote_bd_addr, bt_bdname_t *bd_name, uint32_t cod, bt_ssp_variant_t pairing_variant, @@ -355,11 +359,11 @@ typedef void (*ssp_request_callback)(bt_bdaddr_t *remote_bd_addr, /** Bluetooth Bond state changed callback */ /* Invoked in response to create_bond, cancel_bond or remove_bond */ typedef void (*bond_state_changed_callback)(bt_status_t status, - bt_bdaddr_t *remote_bd_addr, + RawAddress *remote_bd_addr, bt_bond_state_t state); /** Bluetooth ACL connection state changed callback */ -typedef void (*acl_state_changed_callback)(bt_status_t status, bt_bdaddr_t *remote_bd_addr, +typedef void (*acl_state_changed_callback)(bt_status_t status, RawAddress *remote_bd_addr, bt_acl_state_t state); typedef enum { @@ -376,10 +380,6 @@ typedef void (*callback_thread_event)(bt_cb_thread_evt evt); /* Receive any HCI event from controller. Must be in DUT Mode for this callback to be received */ typedef void (*dut_mode_recv_callback)(uint16_t opcode, uint8_t *buf, uint8_t len); -/** Bluetooth HCI event Callback */ -/* Receive any HCI event from controller for raw commands */ -typedef void (*hci_event_recv_callback)(uint8_t event_code, uint8_t *buf, uint8_t len); - /* LE Test mode callbacks * This callback shall be invoked whenever the le_tx_test, le_rx_test or le_test_end is invoked * The num_packets is valid only for le_test_end command */ @@ -417,7 +417,6 @@ typedef struct { dut_mode_recv_callback dut_mode_recv_cb; le_test_mode_callback le_test_mode_cb; energy_info_callback energy_info_cb; - hci_event_recv_callback hci_event_recv_cb; } bt_callbacks_t; typedef void (*alarm_cb)(void *data); @@ -484,27 +483,27 @@ typedef struct { /** Set Bluetooth Adapter property of 'type' */ /* Based on the type, val shall be one of - * bt_bdaddr_t or bt_bdname_t or bt_scanmode_t etc + * RawAddress or bt_bdname_t or bt_scanmode_t etc */ int (*set_adapter_property)(const bt_property_t *property); /** Get all Remote Device properties */ - int (*get_remote_device_properties)(bt_bdaddr_t *remote_addr); + int (*get_remote_device_properties)(RawAddress *remote_addr); /** Get Remote Device property of 'type' */ - int (*get_remote_device_property)(bt_bdaddr_t *remote_addr, + int (*get_remote_device_property)(RawAddress *remote_addr, bt_property_type_t type); /** Set Remote Device property of 'type' */ - int (*set_remote_device_property)(bt_bdaddr_t *remote_addr, + int (*set_remote_device_property)(RawAddress *remote_addr, const bt_property_t *property); /** Get Remote Device's service record for the given UUID */ - int (*get_remote_service_record)(bt_bdaddr_t *remote_addr, - bt_uuid_t *uuid); + int (*get_remote_service_record)(const RawAddress& remote_addr, + const bluetooth::Uuid& uuid); /** Start SDP to get remote services */ - int (*get_remote_services)(bt_bdaddr_t *remote_addr); + int (*get_remote_services)(RawAddress *remote_addr); /** Start Discovery */ int (*start_discovery)(void); @@ -513,28 +512,28 @@ typedef struct { int (*cancel_discovery)(void); /** Create Bluetooth Bonding */ - int (*create_bond)(const bt_bdaddr_t *bd_addr, int transport); + int (*create_bond)(const RawAddress *bd_addr, int transport); /** Create Bluetooth Bond using out of band data */ - int (*create_bond_out_of_band)(const bt_bdaddr_t *bd_addr, int transport, + int (*create_bond_out_of_band)(const RawAddress *bd_addr, int transport, const bt_out_of_band_data_t *oob_data); /** Remove Bond */ - int (*remove_bond)(const bt_bdaddr_t *bd_addr); + int (*remove_bond)(const RawAddress *bd_addr); /** Cancel Bond */ - int (*cancel_bond)(const bt_bdaddr_t *bd_addr); + int (*cancel_bond)(const RawAddress *bd_addr); /** * Get the connection status for a given remote device. * return value of 0 means the device is not connected, * non-zero return status indicates an active connection. */ - int (*get_connection_state)(const bt_bdaddr_t *bd_addr); + int (*get_connection_state)(const RawAddress *bd_addr); /** BT Legacy PinKey Reply */ /** If accept==FALSE, then pin_len and pin_code shall be 0x0 */ - int (*pin_reply)(const bt_bdaddr_t *bd_addr, uint8_t accept, + int (*pin_reply)(const RawAddress *bd_addr, uint8_t accept, uint8_t pin_len, bt_pin_code_t *pin_code); /** BT SSP Reply - Just Works, Numeric Comparison and Passkey @@ -542,7 +541,7 @@ typedef struct { * BT_SSP_VARIANT_CONSENT * For BT_SSP_VARIANT_PASSKEY_ENTRY, if accept==FALSE, then passkey * shall be zero */ - int (*ssp_reply)(const bt_bdaddr_t *bd_addr, bt_ssp_variant_t variant, + int (*ssp_reply)(const RawAddress *bd_addr, bt_ssp_variant_t variant, uint8_t accept, uint32_t passkey); /** Get Bluetooth profile interface */ @@ -554,17 +553,10 @@ typedef struct { /* Send any test HCI (vendor-specific) command to the controller. Must be in DUT Mode */ int (*dut_mode_send)(uint16_t opcode, uint8_t *buf, uint8_t len); - - /* Send any test HCI command to the controller. */ - int (*hci_cmd_send)(uint16_t opcode, uint8_t *buf, uint8_t len); - /** BLE Test Mode APIs */ /* opcode MUST be one of: LE_Receiver_Test, LE_Transmitter_Test, LE_Test_End */ int (*le_test_mode)(uint16_t opcode, uint8_t *buf, uint8_t len); - /* enable or disable bluetooth HCI snoop log */ - int (*config_hci_snoop_log)(uint8_t enable); - /** Sets the OS call-out functions that bluedroid needs for alarms and wake locks. * This should be called immediately after a successful |init|. */ @@ -598,23 +590,9 @@ typedef struct { * first |len| bytes of the its device address match |addr|. * NOTE: |feature| has to match an item defined in interop_feature_t (interop.h). */ - void (*interop_database_add)(uint16_t feature, const bt_bdaddr_t *addr, size_t len); - /** BT stack Test interface */ - const void* (*get_testapp_interface)(int test_app_profile); + void (*interop_database_add)(uint16_t feature, const RawAddress *addr, size_t len); } bt_interface_t; -/** TODO: Need to add APIs for Service Discovery, Service authorization and - * connection management. Also need to add APIs for configuring - * properties of remote bonded devices such as name, UUID etc. */ - -typedef struct { - struct hw_device_t common; - const bt_interface_t* (*get_bluetooth_interface)(); -} bluetooth_device_t; - -typedef bluetooth_device_t bluetooth_module_t; - - __END_DECLS #endif /* ANDROID_INCLUDE_BLUETOOTH_H */ diff --git a/hardware/bt_av.h b/hardware/bt_av.h deleted file mode 100644 index 5b72eb1..0000000 --- a/hardware/bt_av.h +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (C) 2013-2014, The Linux Foundation. All rights reserved. - * Not a Contribution. - * - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_INCLUDE_BT_AV_H -#define ANDROID_INCLUDE_BT_AV_H - -__BEGIN_DECLS - -/* Bluetooth AV connection states */ -typedef enum { - BTAV_CONNECTION_STATE_DISCONNECTED = 0, - BTAV_CONNECTION_STATE_CONNECTING, - BTAV_CONNECTION_STATE_CONNECTED, - BTAV_CONNECTION_STATE_DISCONNECTING -} btav_connection_state_t; - -/* Bluetooth AV datapath states */ -typedef enum { - BTAV_AUDIO_STATE_REMOTE_SUSPEND = 0, - BTAV_AUDIO_STATE_STOPPED, - BTAV_AUDIO_STATE_STARTED, -} btav_audio_state_t; - - -/** Callback for connection state change. - * state will have one of the values from btav_connection_state_t - */ -typedef void (* btav_connection_state_callback)(btav_connection_state_t state, - bt_bdaddr_t *bd_addr); - -/** Callback for audiopath state change. - * state will have one of the values from btav_audio_state_t - */ -typedef void (* btav_audio_state_callback)(btav_audio_state_t state, - bt_bdaddr_t *bd_addr); - -/** Callback for connection priority of device for incoming connection - * btav_connection_priority_t - */ -typedef void (* btav_connection_priority_callback)(bt_bdaddr_t *bd_addr); - -/** Callback for audio configuration change. - * Used only for the A2DP sink interface. - * state will have one of the values from btav_audio_state_t - * sample_rate: sample rate in Hz - * channel_count: number of channels (1 for mono, 2 for stereo) - */ -typedef void (* btav_audio_config_callback)(bt_bdaddr_t *bd_addr, - uint32_t sample_rate, - uint8_t channel_count); - -/** Callback for updating apps for A2dp multicast state. - */ - -typedef void (* btav_is_multicast_enabled_callback)(int state); - -/** Callback to notify reconfig a2dp when A2dp Soft Handoff is triggered -*/ -typedef void(* btav_reconfig_a2dp_trigger_callback)(int reason, bt_bdaddr_t *bd_addr); - -/** BT-AV callback structure. */ -typedef struct { - /** set to sizeof(btav_callbacks_t) */ - size_t size; - btav_connection_state_callback connection_state_cb; - btav_audio_state_callback audio_state_cb; - btav_audio_config_callback audio_config_cb; - btav_connection_priority_callback connection_priority_cb; - btav_is_multicast_enabled_callback multicast_state_cb; - btav_reconfig_a2dp_trigger_callback reconfig_a2dp_trigger_cb; -} btav_callbacks_t; - -/** - * NOTE: - * - * 1. AVRCP 1.0 shall be supported initially. AVRCP passthrough commands - * shall be handled internally via uinput - * - * 2. A2DP data path shall be handled via a socket pipe between the AudioFlinger - * android_audio_hw library and the Bluetooth stack. - * - */ -/** Represents the standard BT-AV interface. - * Used for both the A2DP source and sink interfaces. - */ -typedef struct { - - /** set to sizeof(btav_interface_t) */ - size_t size; - /** - * Register the BtAv callbacks - */ - bt_status_t (*init)( btav_callbacks_t* callbacks , int max_a2dp_connections, - int a2dp_multicast_state, const char *offload_cap); - - /** connect to headset */ - bt_status_t (*connect)( bt_bdaddr_t *bd_addr ); - - /** dis-connect from headset */ - bt_status_t (*disconnect)( bt_bdaddr_t *bd_addr ); - - /** Closes the interface. */ - void (*cleanup)( void ); - - /** Sends Audio Focus State. */ - void (*set_audio_focus_state)( int focus_state ); - - /** Sets the audio track gain. */ - void (*set_audio_track_gain)( float gain ); - - /** Send priority of device to stack*/ - void (*allow_connection)( int is_valid , bt_bdaddr_t *bd_addr); -} btav_interface_t; - -__END_DECLS - -#endif /* ANDROID_INCLUDE_BT_AV_H */ diff --git a/hardware/bt_common_types.h b/hardware/bt_common_types.h deleted file mode 100644 index 01b5256..0000000 --- a/hardware/bt_common_types.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/****************************************************************************** - * - * This file contains constants and definitions that can be used commonly between JNI and stack layer - * - ******************************************************************************/ -#ifndef ANDROID_INCLUDE_BT_COMMON_TYPES_H -#define ANDROID_INCLUDE_BT_COMMON_TYPES_H - -#include "bluetooth.h" - -typedef struct -{ - uint8_t client_if; - uint8_t filt_index; - uint8_t advertiser_state; - uint8_t advertiser_info_present; - uint8_t addr_type; - uint8_t tx_power; - int8_t rssi_value; - uint16_t time_stamp; - bt_bdaddr_t bd_addr; - uint8_t adv_pkt_len; - uint8_t *p_adv_pkt_data; - uint8_t scan_rsp_len; - uint8_t *p_scan_rsp_data; -} btgatt_track_adv_info_t; - -typedef enum -{ - BTGATT_DB_PRIMARY_SERVICE, - BTGATT_DB_SECONDARY_SERVICE, - BTGATT_DB_INCLUDED_SERVICE, - BTGATT_DB_CHARACTERISTIC, - BTGATT_DB_DESCRIPTOR, -} bt_gatt_db_attribute_type_t; - -typedef struct -{ - uint16_t id; - bt_uuid_t uuid; - bt_gatt_db_attribute_type_t type; - uint16_t attribute_handle; - - /* - * If |type| is |BTGATT_DB_PRIMARY_SERVICE|, or - * |BTGATT_DB_SECONDARY_SERVICE|, this contains the start and end attribute - * handles. - */ - uint16_t start_handle; - uint16_t end_handle; - - /* - * If |type| is |BTGATT_DB_CHARACTERISTIC|, this contains the properties of - * the characteristic. - */ - uint8_t properties; -} btgatt_db_element_t; - -#endif /* ANDROID_INCLUDE_BT_COMMON_TYPES_H */ diff --git a/hardware/bt_gatt.h b/hardware/bt_gatt.h deleted file mode 100644 index 42e14c2..0000000 --- a/hardware/bt_gatt.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef ANDROID_INCLUDE_BT_GATT_H -#define ANDROID_INCLUDE_BT_GATT_H - -#include -#include "bt_gatt_client.h" -#include "bt_gatt_server.h" - -__BEGIN_DECLS - -/** BT-GATT callbacks */ -typedef struct { - /** Set to sizeof(btgatt_callbacks_t) */ - size_t size; - - /** GATT Client callbacks */ - const btgatt_client_callbacks_t* client; - - /** GATT Server callbacks */ - const btgatt_server_callbacks_t* server; -} btgatt_callbacks_t; - -/** Represents the standard Bluetooth GATT interface. */ -typedef struct { - /** Set to sizeof(btgatt_interface_t) */ - size_t size; - - /** - * Initializes the interface and provides callback routines - */ - bt_status_t (*init)( const btgatt_callbacks_t* callbacks ); - - /** Closes the interface */ - void (*cleanup)( void ); - - /** Pointer to the GATT client interface methods.*/ - const btgatt_client_interface_t* client; - - /** Pointer to the GATT server interface methods.*/ - const btgatt_server_interface_t* server; -} btgatt_interface_t; - -__END_DECLS - -#endif /* ANDROID_INCLUDE_BT_GATT_H */ diff --git a/hardware/bt_gatt_client.h b/hardware/bt_gatt_client.h deleted file mode 100644 index e2c8a92..0000000 --- a/hardware/bt_gatt_client.h +++ /dev/null @@ -1,414 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef ANDROID_INCLUDE_BT_GATT_CLIENT_H -#define ANDROID_INCLUDE_BT_GATT_CLIENT_H - -#include -#include "bt_gatt_types.h" -#include "bt_common_types.h" - -__BEGIN_DECLS - -/** - * Buffer sizes for maximum attribute length and maximum read/write - * operation buffer size. - */ -#define BTGATT_MAX_ATTR_LEN 600 - -/** Buffer type for unformatted reads/writes */ -typedef struct -{ - uint8_t value[BTGATT_MAX_ATTR_LEN]; - uint16_t len; -} btgatt_unformatted_value_t; - -/** Parameters for GATT read operations */ -typedef struct -{ - uint16_t handle; - btgatt_unformatted_value_t value; - uint16_t value_type; - uint8_t status; -} btgatt_read_params_t; - -/** Parameters for GATT write operations */ -typedef struct -{ - btgatt_srvc_id_t srvc_id; - btgatt_gatt_id_t char_id; - btgatt_gatt_id_t descr_id; - uint8_t status; -} btgatt_write_params_t; - -/** Attribute change notification parameters */ -typedef struct -{ - uint8_t value[BTGATT_MAX_ATTR_LEN]; - bt_bdaddr_t bda; - uint16_t handle; - uint16_t len; - uint8_t is_notify; -} btgatt_notify_params_t; - -typedef struct -{ - uint8_t client_if; - uint8_t action; - uint8_t filt_index; - uint16_t feat_seln; - uint16_t list_logic_type; - uint8_t filt_logic_type; - uint8_t rssi_high_thres; - uint8_t rssi_low_thres; - uint8_t dely_mode; - uint16_t found_timeout; - uint16_t lost_timeout; - uint8_t found_timeout_cnt; - uint16_t num_of_tracking_entries; -} btgatt_filt_param_setup_t; - -typedef struct -{ - bt_bdaddr_t *bda1; - bt_uuid_t *uuid1; - uint16_t u1; - uint16_t u2; - uint16_t u3; - uint16_t u4; - uint16_t u5; -} btgatt_test_params_t; - -/* BT GATT client error codes */ -typedef enum -{ - BT_GATTC_COMMAND_SUCCESS = 0, /* 0 Command succeeded */ - BT_GATTC_COMMAND_STARTED, /* 1 Command started OK. */ - BT_GATTC_COMMAND_BUSY, /* 2 Device busy with another command */ - BT_GATTC_COMMAND_STORED, /* 3 request is stored in control block */ - BT_GATTC_NO_RESOURCES, /* 4 No resources to issue command */ - BT_GATTC_MODE_UNSUPPORTED, /* 5 Request for 1 or more unsupported modes */ - BT_GATTC_ILLEGAL_VALUE, /* 6 Illegal command /parameter value */ - BT_GATTC_INCORRECT_STATE, /* 7 Device in wrong state for request */ - BT_GATTC_UNKNOWN_ADDR, /* 8 Unknown remote BD address */ - BT_GATTC_DEVICE_TIMEOUT, /* 9 Device timeout */ - BT_GATTC_INVALID_CONTROLLER_OUTPUT,/* 10 An incorrect value was received from HCI */ - BT_GATTC_SECURITY_ERROR, /* 11 Authorization or security failure or not authorized */ - BT_GATTC_DELAYED_ENCRYPTION_CHECK, /*12 Delayed encryption check */ - BT_GATTC_ERR_PROCESSING /* 12 Generic error */ -} btgattc_error_t; - -/** BT-GATT Client callback structure. */ - -/** Callback invoked in response to register_client */ -typedef void (*register_client_callback)(int status, int client_if, - bt_uuid_t *app_uuid); - -/** Callback for scan results */ -typedef void (*scan_result_callback)(bt_bdaddr_t* bda, int rssi, uint8_t* adv_data); - -/** GATT open callback invoked in response to open */ -typedef void (*connect_callback)(int conn_id, int status, int client_if, bt_bdaddr_t* bda); - -/** Callback invoked in response to close */ -typedef void (*disconnect_callback)(int conn_id, int status, - int client_if, bt_bdaddr_t* bda); - -/** - * Invoked in response to search_service when the GATT service search - * has been completed. - */ -typedef void (*search_complete_callback)(int conn_id, int status); - -/** Callback invoked in response to [de]register_for_notification */ -typedef void (*register_for_notification_callback)(int conn_id, - int registered, int status, uint16_t handle); - -/** - * Remote device notification callback, invoked when a remote device sends - * a notification or indication that a client has registered for. - */ -typedef void (*notify_callback)(int conn_id, btgatt_notify_params_t *p_data); - -/** Reports result of a GATT read operation */ -typedef void (*read_characteristic_callback)(int conn_id, int status, - btgatt_read_params_t *p_data); - -/** GATT write characteristic operation callback */ -typedef void (*write_characteristic_callback)(int conn_id, int status, uint16_t handle); - -/** GATT execute prepared write callback */ -typedef void (*execute_write_callback)(int conn_id, int status); - -/** Callback invoked in response to read_descriptor */ -typedef void (*read_descriptor_callback)(int conn_id, int status, - btgatt_read_params_t *p_data); - -/** Callback invoked in response to write_descriptor */ -typedef void (*write_descriptor_callback)(int conn_id, int status, uint16_t handle); - -/** Callback triggered in response to read_remote_rssi */ -typedef void (*read_remote_rssi_callback)(int client_if, bt_bdaddr_t* bda, - int rssi, int status); - -/** - * Callback indicating the status of a listen() operation - */ -typedef void (*listen_callback)(int status, int server_if); - -/** Callback invoked when the MTU for a given connection changes */ -typedef void (*configure_mtu_callback)(int conn_id, int status, int mtu); - -/** Callback invoked when a scan filter configuration command has completed */ -typedef void (*scan_filter_cfg_callback)(int action, int client_if, int status, int filt_type, - int avbl_space); - -/** Callback invoked when scan param has been added, cleared, or deleted */ -typedef void (*scan_filter_param_callback)(int action, int client_if, int status, - int avbl_space); - -/** Callback invoked when a scan filter configuration command has completed */ -typedef void (*scan_filter_status_callback)(int enable, int client_if, int status); - -/** Callback invoked when multi-adv enable operation has completed */ -typedef void (*multi_adv_enable_callback)(int client_if, int status); - -/** Callback invoked when multi-adv param update operation has completed */ -typedef void (*multi_adv_update_callback)(int client_if, int status); - -/** Callback invoked when multi-adv instance data set operation has completed */ -typedef void (*multi_adv_data_callback)(int client_if, int status); - -/** Callback invoked when multi-adv disable operation has completed */ -typedef void (*multi_adv_disable_callback)(int client_if, int status); - -/** - * Callback notifying an application that a remote device connection is currently congested - * and cannot receive any more data. An application should avoid sending more data until - * a further callback is received indicating the congestion status has been cleared. - */ -typedef void (*congestion_callback)(int conn_id, bool congested); -/** Callback invoked when batchscan storage config operation has completed */ -typedef void (*batchscan_cfg_storage_callback)(int client_if, int status); - -/** Callback invoked when batchscan enable / disable operation has completed */ -typedef void (*batchscan_enable_disable_callback)(int action, int client_if, int status); - -/** Callback invoked when batchscan reports are obtained */ -typedef void (*batchscan_reports_callback)(int client_if, int status, int report_format, - int num_records, int data_len, uint8_t* rep_data); - -/** Callback invoked when batchscan storage threshold limit is crossed */ -typedef void (*batchscan_threshold_callback)(int client_if); - -/** Track ADV VSE callback invoked when tracked device is found or lost */ -typedef void (*track_adv_event_callback)(btgatt_track_adv_info_t *p_track_adv_info); - -/** Callback invoked when scan parameter setup has completed */ -typedef void (*scan_parameter_setup_completed_callback)(int client_if, - btgattc_error_t status); - -/** GATT get database callback */ -typedef void (*get_gatt_db_callback)(int conn_id, btgatt_db_element_t *db, int count); - -/** GATT services between start_handle and end_handle were removed */ -typedef void (*services_removed_callback)(int conn_id, uint16_t start_handle, uint16_t end_handle); - -/** GATT services were added */ -typedef void (*services_added_callback)(int conn_id, btgatt_db_element_t *added, int added_count); - -typedef struct { - register_client_callback register_client_cb; - scan_result_callback scan_result_cb; - connect_callback open_cb; - disconnect_callback close_cb; - search_complete_callback search_complete_cb; - register_for_notification_callback register_for_notification_cb; - notify_callback notify_cb; - read_characteristic_callback read_characteristic_cb; - write_characteristic_callback write_characteristic_cb; - read_descriptor_callback read_descriptor_cb; - write_descriptor_callback write_descriptor_cb; - execute_write_callback execute_write_cb; - read_remote_rssi_callback read_remote_rssi_cb; - listen_callback listen_cb; - configure_mtu_callback configure_mtu_cb; - scan_filter_cfg_callback scan_filter_cfg_cb; - scan_filter_param_callback scan_filter_param_cb; - scan_filter_status_callback scan_filter_status_cb; - multi_adv_enable_callback multi_adv_enable_cb; - multi_adv_update_callback multi_adv_update_cb; - multi_adv_data_callback multi_adv_data_cb; - multi_adv_disable_callback multi_adv_disable_cb; - congestion_callback congestion_cb; - batchscan_cfg_storage_callback batchscan_cfg_storage_cb; - batchscan_enable_disable_callback batchscan_enb_disable_cb; - batchscan_reports_callback batchscan_reports_cb; - batchscan_threshold_callback batchscan_threshold_cb; - track_adv_event_callback track_adv_event_cb; - scan_parameter_setup_completed_callback scan_parameter_setup_completed_cb; - get_gatt_db_callback get_gatt_db_cb; - services_removed_callback services_removed_cb; - services_added_callback services_added_cb; -} btgatt_client_callbacks_t; - -/** Represents the standard BT-GATT client interface. */ - -typedef struct { - /** Registers a GATT client application with the stack */ - bt_status_t (*register_client)( bt_uuid_t *uuid ); - - /** Unregister a client application from the stack */ - bt_status_t (*unregister_client)(int client_if ); - - /** Start or stop LE device scanning */ - bt_status_t (*scan)( bool start ); - - /** Create a connection to a remote LE or dual-mode device */ - bt_status_t (*connect)( int client_if, const bt_bdaddr_t *bd_addr, - bool is_direct, int transport ); - - /** Disconnect a remote device or cancel a pending connection */ - bt_status_t (*disconnect)( int client_if, const bt_bdaddr_t *bd_addr, - int conn_id); - - /** Start or stop advertisements to listen for incoming connections */ - bt_status_t (*listen)(int client_if, bool start); - - /** Clear the attribute cache for a given device */ - bt_status_t (*refresh)( int client_if, const bt_bdaddr_t *bd_addr ); - - /** - * Enumerate all GATT services on a connected device. - * Optionally, the results can be filtered for a given UUID. - */ - bt_status_t (*search_service)(int conn_id, bt_uuid_t *filter_uuid ); - - /** Read a characteristic on a remote device */ - bt_status_t (*read_characteristic)( int conn_id, uint16_t handle, - int auth_req ); - - /** Write a remote characteristic */ - bt_status_t (*write_characteristic)(int conn_id, uint16_t handle, - int write_type, int len, int auth_req, - char* p_value); - - /** Read the descriptor for a given characteristic */ - bt_status_t (*read_descriptor)(int conn_id, uint16_t handle, int auth_req); - - /** Write a remote descriptor for a given characteristic */ - bt_status_t (*write_descriptor)( int conn_id, uint16_t handle, - int write_type, int len, - int auth_req, char* p_value); - - /** Execute a prepared write operation */ - bt_status_t (*execute_write)(int conn_id, int execute); - - /** - * Register to receive notifications or indications for a given - * characteristic - */ - bt_status_t (*register_for_notification)( int client_if, - const bt_bdaddr_t *bd_addr, uint16_t handle); - - /** Deregister a previous request for notifications/indications */ - bt_status_t (*deregister_for_notification)( int client_if, - const bt_bdaddr_t *bd_addr, uint16_t handle); - - /** Request RSSI for a given remote device */ - bt_status_t (*read_remote_rssi)( int client_if, const bt_bdaddr_t *bd_addr); - - /** Setup scan filter params */ - bt_status_t (*scan_filter_param_setup)(btgatt_filt_param_setup_t filt_param); - - - /** Configure a scan filter condition */ - bt_status_t (*scan_filter_add_remove)(int client_if, int action, int filt_type, - int filt_index, int company_id, - int company_id_mask, const bt_uuid_t *p_uuid, - const bt_uuid_t *p_uuid_mask, const bt_bdaddr_t *bd_addr, - char addr_type, int data_len, char* p_data, int mask_len, - char* p_mask); - - /** Clear all scan filter conditions for specific filter index*/ - bt_status_t (*scan_filter_clear)(int client_if, int filt_index); - - /** Enable / disable scan filter feature*/ - bt_status_t (*scan_filter_enable)(int client_if, bool enable); - - /** Determine the type of the remote device (LE, BR/EDR, Dual-mode) */ - int (*get_device_type)( const bt_bdaddr_t *bd_addr ); - - /** Set the advertising data or scan response data */ - bt_status_t (*set_adv_data)(int client_if, bool set_scan_rsp, bool include_name, - bool include_txpower, int min_interval, int max_interval, int appearance, - uint16_t manufacturer_len, char* manufacturer_data, - uint16_t service_data_len, char* service_data, - uint16_t service_uuid_len, char* service_uuid); - - /** Configure the MTU for a given connection */ - bt_status_t (*configure_mtu)(int conn_id, int mtu); - - /** Request a connection parameter update */ - bt_status_t (*conn_parameter_update)(const bt_bdaddr_t *bd_addr, int min_interval, - int max_interval, int latency, int timeout); - - /** Sets the LE scan interval and window in units of N*0.625 msec */ - bt_status_t (*set_scan_parameters)(int client_if, int scan_interval, int scan_window); - - /* Setup the parameters as per spec, user manual specified values and enable multi ADV */ - bt_status_t (*multi_adv_enable)(int client_if, int min_interval,int max_interval,int adv_type, - int chnl_map, int tx_power, int timeout_s); - - /* Update the parameters as per spec, user manual specified values and restart multi ADV */ - bt_status_t (*multi_adv_update)(int client_if, int min_interval,int max_interval,int adv_type, - int chnl_map, int tx_power, int timeout_s); - - /* Setup the data for the specified instance */ - bt_status_t (*multi_adv_set_inst_data)(int client_if, bool set_scan_rsp, bool include_name, - bool incl_txpower, int appearance, int manufacturer_len, - char* manufacturer_data, int service_data_len, - char* service_data, int service_uuid_len, char* service_uuid); - - /* Disable the multi adv instance */ - bt_status_t (*multi_adv_disable)(int client_if); - - /* Configure the batchscan storage */ - bt_status_t (*batchscan_cfg_storage)(int client_if, int batch_scan_full_max, - int batch_scan_trunc_max, int batch_scan_notify_threshold); - - /* Enable batchscan */ - bt_status_t (*batchscan_enb_batch_scan)(int client_if, int scan_mode, - int scan_interval, int scan_window, int addr_type, int discard_rule); - - /* Disable batchscan */ - bt_status_t (*batchscan_dis_batch_scan)(int client_if); - - /* Read out batchscan reports */ - bt_status_t (*batchscan_read_reports)(int client_if, int scan_mode); - - /** Test mode interface */ - bt_status_t (*test_command)( int command, btgatt_test_params_t* params); - - /** Get gatt db content */ - bt_status_t (*get_gatt_db)( int conn_id); - -} btgatt_client_interface_t; - -__END_DECLS - -#endif /* ANDROID_INCLUDE_BT_GATT_CLIENT_H */ diff --git a/hardware/bt_gatt_server.h b/hardware/bt_gatt_server.h deleted file mode 100644 index 0d6cc1e..0000000 --- a/hardware/bt_gatt_server.h +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef ANDROID_INCLUDE_BT_GATT_SERVER_H -#define ANDROID_INCLUDE_BT_GATT_SERVER_H - -#include - -#include "bt_gatt_types.h" - -__BEGIN_DECLS - -/** GATT value type used in response to remote read requests */ -typedef struct -{ - uint8_t value[BTGATT_MAX_ATTR_LEN]; - uint16_t handle; - uint16_t offset; - uint16_t len; - uint8_t auth_req; -} btgatt_value_t; - -/** GATT remote read request response type */ -typedef union -{ - btgatt_value_t attr_value; - uint16_t handle; -} btgatt_response_t; - -/** BT-GATT Server callback structure. */ - -/** Callback invoked in response to register_server */ -typedef void (*register_server_callback)(int status, int server_if, - bt_uuid_t *app_uuid); - -/** Callback indicating that a remote device has connected or been disconnected */ -typedef void (*connection_callback)(int conn_id, int server_if, int connected, - bt_bdaddr_t *bda); - -/** Callback invoked in response to create_service */ -typedef void (*service_added_callback)(int status, int server_if, - btgatt_srvc_id_t *srvc_id, int srvc_handle); - -/** Callback indicating that an included service has been added to a service */ -typedef void (*included_service_added_callback)(int status, int server_if, - int srvc_handle, int incl_srvc_handle); - -/** Callback invoked when a characteristic has been added to a service */ -typedef void (*characteristic_added_callback)(int status, int server_if, - bt_uuid_t *uuid, int srvc_handle, int char_handle); - -/** Callback invoked when a descriptor has been added to a characteristic */ -typedef void (*descriptor_added_callback)(int status, int server_if, - bt_uuid_t *uuid, int srvc_handle, int descr_handle); - -/** Callback invoked in response to start_service */ -typedef void (*service_started_callback)(int status, int server_if, - int srvc_handle); - -/** Callback invoked in response to stop_service */ -typedef void (*service_stopped_callback)(int status, int server_if, - int srvc_handle); - -/** Callback triggered when a service has been deleted */ -typedef void (*service_deleted_callback)(int status, int server_if, - int srvc_handle); - -/** - * Callback invoked when a remote device has requested to read a characteristic - * or descriptor. The application must respond by calling send_response - */ -typedef void (*request_read_callback)(int conn_id, int trans_id, bt_bdaddr_t *bda, - int attr_handle, int offset, bool is_long); - -/** - * Callback invoked when a remote device has requested to write to a - * characteristic or descriptor. - */ -typedef void (*request_write_callback)(int conn_id, int trans_id, bt_bdaddr_t *bda, - int attr_handle, int offset, int length, - bool need_rsp, bool is_prep, uint8_t* value); - -/** Callback invoked when a previously prepared write is to be executed */ -typedef void (*request_exec_write_callback)(int conn_id, int trans_id, - bt_bdaddr_t *bda, int exec_write); - -/** - * Callback triggered in response to send_response if the remote device - * sends a confirmation. - */ -typedef void (*response_confirmation_callback)(int status, int handle); - -/** - * Callback confirming that a notification or indication has been sent - * to a remote device. - */ -typedef void (*indication_sent_callback)(int conn_id, int status); - -/** - * Callback notifying an application that a remote device connection is currently congested - * and cannot receive any more data. An application should avoid sending more data until - * a further callback is received indicating the congestion status has been cleared. - */ -typedef void (*congestion_callback)(int conn_id, bool congested); - -/** Callback invoked when the MTU for a given connection changes */ -typedef void (*mtu_changed_callback)(int conn_id, int mtu); - -typedef struct { - register_server_callback register_server_cb; - connection_callback connection_cb; - service_added_callback service_added_cb; - included_service_added_callback included_service_added_cb; - characteristic_added_callback characteristic_added_cb; - descriptor_added_callback descriptor_added_cb; - service_started_callback service_started_cb; - service_stopped_callback service_stopped_cb; - service_deleted_callback service_deleted_cb; - request_read_callback request_read_cb; - request_write_callback request_write_cb; - request_exec_write_callback request_exec_write_cb; - response_confirmation_callback response_confirmation_cb; - indication_sent_callback indication_sent_cb; - congestion_callback congestion_cb; - mtu_changed_callback mtu_changed_cb; -} btgatt_server_callbacks_t; - -/** Represents the standard BT-GATT server interface. */ -typedef struct { - /** Registers a GATT server application with the stack */ - bt_status_t (*register_server)( bt_uuid_t *uuid ); - - /** Unregister a server application from the stack */ - bt_status_t (*unregister_server)(int server_if ); - - /** Create a connection to a remote peripheral */ - bt_status_t (*connect)(int server_if, const bt_bdaddr_t *bd_addr, - bool is_direct, int transport); - - /** Disconnect an established connection or cancel a pending one */ - bt_status_t (*disconnect)(int server_if, const bt_bdaddr_t *bd_addr, - int conn_id ); - - /** Create a new service */ - bt_status_t (*add_service)( int server_if, btgatt_srvc_id_t *srvc_id, int num_handles); - - /** Assign an included service to it's parent service */ - bt_status_t (*add_included_service)( int server_if, int service_handle, int included_handle); - - /** Add a characteristic to a service */ - bt_status_t (*add_characteristic)( int server_if, - int service_handle, bt_uuid_t *uuid, - int properties, int permissions); - - /** Add a descriptor to a given service */ - bt_status_t (*add_descriptor)(int server_if, int service_handle, - bt_uuid_t *uuid, int permissions); - - /** Starts a local service */ - bt_status_t (*start_service)(int server_if, int service_handle, - int transport); - - /** Stops a local service */ - bt_status_t (*stop_service)(int server_if, int service_handle); - - /** Delete a local service */ - bt_status_t (*delete_service)(int server_if, int service_handle); - - /** Send value indication to a remote device */ - bt_status_t (*send_indication)(int server_if, int attribute_handle, - int conn_id, int len, int confirm, - char* p_value); - - /** Send a response to a read/write operation */ - bt_status_t (*send_response)(int conn_id, int trans_id, - int status, btgatt_response_t *response); - -} btgatt_server_interface_t; - -__END_DECLS - -#endif /* ANDROID_INCLUDE_BT_GATT_CLIENT_H */ diff --git a/hardware/bt_gatt_types.h b/hardware/bt_gatt_types.h deleted file mode 100644 index e037ddc..0000000 --- a/hardware/bt_gatt_types.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef ANDROID_INCLUDE_BT_GATT_TYPES_H -#define ANDROID_INCLUDE_BT_GATT_TYPES_H - -#include -#include - -__BEGIN_DECLS - -/** - * GATT Service types - */ -#define BTGATT_SERVICE_TYPE_PRIMARY 0 -#define BTGATT_SERVICE_TYPE_SECONDARY 1 - -/** GATT ID adding instance id tracking to the UUID */ -typedef struct -{ - bt_uuid_t uuid; - uint8_t inst_id; -} btgatt_gatt_id_t; - -/** GATT Service ID also identifies the service type (primary/secondary) */ -typedef struct -{ - btgatt_gatt_id_t id; - uint8_t is_primary; -} btgatt_srvc_id_t; - -/** Preferred physical Transport for GATT connection */ -typedef enum -{ - GATT_TRANSPORT_AUTO, - GATT_TRANSPORT_BREDR, - GATT_TRANSPORT_LE -} btgatt_transport_t; - -__END_DECLS - -#endif /* ANDROID_INCLUDE_BT_GATT_TYPES_H */ diff --git a/hardware/bt_hd.h b/hardware/bt_hd.h deleted file mode 100644 index 6ba5b09..0000000 --- a/hardware/bt_hd.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2013, The Linux Foundation. All rights reserved. - * Not a Contribution - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_INCLUDE_BT_HD_H -#define ANDROID_INCLUDE_BT_HD_H - -#include - -__BEGIN_DECLS - -typedef enum -{ - BTHD_REPORT_TYPE_OTHER = 0, - BTHD_REPORT_TYPE_INPUT, - BTHD_REPORT_TYPE_OUTPUT, - BTHD_REPORT_TYPE_FEATURE, - BTHD_REPORT_TYPE_INTRDATA // special value for reports to be sent on INTR (INPUT is assumed) -} bthd_report_type_t; - -typedef enum -{ - BTHD_APP_STATE_NOT_REGISTERED, - BTHD_APP_STATE_REGISTERED -} bthd_application_state_t; - -typedef enum -{ - BTHD_CONN_STATE_CONNECTED, - BTHD_CONN_STATE_CONNECTING, - BTHD_CONN_STATE_DISCONNECTED, - BTHD_CONN_STATE_DISCONNECTING, - BTHD_CONN_STATE_UNKNOWN -} bthd_connection_state_t; - -typedef struct -{ - const char *name; - const char *description; - const char *provider; - uint8_t subclass; - uint8_t *desc_list; - int desc_list_len; -} bthd_app_param_t; - -typedef struct -{ - uint8_t service_type; - uint32_t token_rate; - uint32_t token_bucket_size; - uint32_t peak_bandwidth; - uint32_t access_latency; - uint32_t delay_variation; -} bthd_qos_param_t; - -typedef void (* bthd_application_state_callback)(bt_bdaddr_t *bd_addr, bthd_application_state_t state); -typedef void (* bthd_connection_state_callback)(bt_bdaddr_t *bd_addr, bthd_connection_state_t state); -typedef void (* bthd_get_report_callback)(uint8_t type, uint8_t id, uint16_t buffer_size); -typedef void (* bthd_set_report_callback)(uint8_t type, uint8_t id, uint16_t len, uint8_t *p_data); -typedef void (* bthd_set_protocol_callback)(uint8_t protocol); -typedef void (* bthd_intr_data_callback)(uint8_t report_id, uint16_t len, uint8_t *p_data); -typedef void (* bthd_vc_unplug_callback)(void); - -/** BT-HD callbacks */ -typedef struct { - size_t size; - - bthd_application_state_callback application_state_cb; - bthd_connection_state_callback connection_state_cb; - bthd_get_report_callback get_report_cb; - bthd_set_report_callback set_report_cb; - bthd_set_protocol_callback set_protocol_cb; - bthd_intr_data_callback intr_data_cb; - bthd_vc_unplug_callback vc_unplug_cb; -} bthd_callbacks_t; - -/** BT-HD interface */ -typedef struct { - - size_t size; - - /** init interface and register callbacks */ - bt_status_t (*init)(bthd_callbacks_t* callbacks); - - /** close interface */ - void (*cleanup)(void); - - /** register application */ - bt_status_t (*register_app)(bthd_app_param_t *app_param, bthd_qos_param_t *in_qos, - bthd_qos_param_t *out_qos); - - /** unregister application */ - bt_status_t (*unregister_app)(void); - - /** connects to host with virtual cable */ - bt_status_t (*connect)(void); - - /** disconnects from currently connected host */ - bt_status_t (*disconnect)(void); - - /** send report */ - bt_status_t (*send_report)(bthd_report_type_t type, uint8_t id, uint16_t len, uint8_t *p_data); - - /** notifies error for invalid SET_REPORT */ - bt_status_t (*report_error)(uint8_t error); - - /** send Virtual Cable Unplug */ - bt_status_t (*virtual_cable_unplug)(void); - -} bthd_interface_t; - -__END_DECLS - -#endif /* ANDROID_INCLUDE_BT_HD_H */ - diff --git a/hardware/bt_hf.h b/hardware/bt_hf.h deleted file mode 100644 index 9d257b0..0000000 --- a/hardware/bt_hf.h +++ /dev/null @@ -1,347 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_INCLUDE_BT_HF_H -#define ANDROID_INCLUDE_BT_HF_H - -__BEGIN_DECLS - -/* AT response code - OK/Error */ -typedef enum { - BTHF_AT_RESPONSE_ERROR = 0, - BTHF_AT_RESPONSE_OK -} bthf_at_response_t; - -typedef enum { - BTHF_CONNECTION_STATE_DISCONNECTED = 0, - BTHF_CONNECTION_STATE_CONNECTING, - BTHF_CONNECTION_STATE_CONNECTED, - BTHF_CONNECTION_STATE_SLC_CONNECTED, - BTHF_CONNECTION_STATE_DISCONNECTING -} bthf_connection_state_t; - -typedef enum { - BTHF_AUDIO_STATE_DISCONNECTED = 0, - BTHF_AUDIO_STATE_CONNECTING, - BTHF_AUDIO_STATE_CONNECTED, - BTHF_AUDIO_STATE_DISCONNECTING -} bthf_audio_state_t; - -typedef enum { - BTHF_VR_STATE_STOPPED = 0, - BTHF_VR_STATE_STARTED -} bthf_vr_state_t; - -typedef enum { - BTHF_VOLUME_TYPE_SPK = 0, - BTHF_VOLUME_TYPE_MIC -} bthf_volume_type_t; - -/* Noise Reduction and Echo Cancellation */ -typedef enum -{ - BTHF_NREC_STOP, - BTHF_NREC_START -} bthf_nrec_t; - -/* WBS codec setting */ -typedef enum -{ - BTHF_WBS_NONE, - BTHF_WBS_NO, - BTHF_WBS_YES -}bthf_wbs_config_t; - -/* BIND type*/ -typedef enum -{ - BTHF_BIND_SET, - BTHF_BIND_READ, - BTHF_BIND_TEST -}bthf_bind_type_t; - - -/* CHLD - Call held handling */ -typedef enum -{ - BTHF_CHLD_TYPE_RELEASEHELD, // Terminate all held or set UDUB("busy") to a waiting call - BTHF_CHLD_TYPE_RELEASEACTIVE_ACCEPTHELD, // Terminate all active calls and accepts a waiting/held call - BTHF_CHLD_TYPE_HOLDACTIVE_ACCEPTHELD, // Hold all active calls and accepts a waiting/held call - BTHF_CHLD_TYPE_ADDHELDTOCONF, // Add all held calls to a conference -} bthf_chld_type_t; - -/** Callback for connection state change. - * state will have one of the values from BtHfConnectionState - */ -typedef void (* bthf_connection_state_callback)(bthf_connection_state_t state, bt_bdaddr_t *bd_addr); - -/** Callback for audio connection state change. - * state will have one of the values from BtHfAudioState - */ -typedef void (* bthf_audio_state_callback)(bthf_audio_state_t state, bt_bdaddr_t *bd_addr); - -/** Callback for VR connection state change. - * state will have one of the values from BtHfVRState - */ -typedef void (* bthf_vr_cmd_callback)(bthf_vr_state_t state, bt_bdaddr_t *bd_addr); - -/** Callback for answer incoming call (ATA) - */ -typedef void (* bthf_answer_call_cmd_callback)(bt_bdaddr_t *bd_addr); - -/** Callback for disconnect call (AT+CHUP) - */ -typedef void (* bthf_hangup_call_cmd_callback)(bt_bdaddr_t *bd_addr); - -/** Callback for disconnect call (AT+CHUP) - * type will denote Speaker/Mic gain (BtHfVolumeControl). - */ -typedef void (* bthf_volume_cmd_callback)(bthf_volume_type_t type, int volume, bt_bdaddr_t *bd_addr); - -/** Callback for dialing an outgoing call - * If number is NULL, redial - */ -typedef void (* bthf_dial_call_cmd_callback)(char *number, bt_bdaddr_t *bd_addr); - -/** Callback for sending DTMF tones - * tone contains the dtmf character to be sent - */ -typedef void (* bthf_dtmf_cmd_callback)(char tone, bt_bdaddr_t *bd_addr); - -/** Callback for enabling/disabling noise reduction/echo cancellation - * value will be 1 to enable, 0 to disable - */ -typedef void (* bthf_nrec_cmd_callback)(bthf_nrec_t nrec, bt_bdaddr_t *bd_addr); - -/** Callback for AT+BCS and event from BAC - * WBS enable, WBS disable - */ -typedef void (* bthf_wbs_callback)(bthf_wbs_config_t wbs, bt_bdaddr_t *bd_addr); - -/** Callback for call hold handling (AT+CHLD) - * value will contain the call hold command (0, 1, 2, 3) - */ -typedef void (* bthf_chld_cmd_callback)(bthf_chld_type_t chld, bt_bdaddr_t *bd_addr); - -/** Callback for CNUM (subscriber number) - */ -typedef void (* bthf_cnum_cmd_callback)(bt_bdaddr_t *bd_addr); - -/** Callback for indicators (CIND) - */ -typedef void (* bthf_cind_cmd_callback)(bt_bdaddr_t *bd_addr); - -/** Callback for operator selection (COPS) - */ -typedef void (* bthf_cops_cmd_callback)(bt_bdaddr_t *bd_addr); - -/** Callback for call list (AT+CLCC) - */ -typedef void (* bthf_clcc_cmd_callback) (bt_bdaddr_t *bd_addr); - -/** Callback for unknown AT command recd from HF - * at_string will contain the unparsed AT string - */ -typedef void (* bthf_unknown_at_cmd_callback)(char *at_string, bt_bdaddr_t *bd_addr); - -/** Callback for keypressed (HSP) event. - */ -typedef void (* bthf_key_pressed_cmd_callback)(bt_bdaddr_t *bd_addr); - -/** Callback for HF indicators (BIND) - */ -typedef void (* bthf_bind_cmd_callback)(char* hf_ind, bthf_bind_type_t type, bt_bdaddr_t *bd_addr); - -/** Callback for HF indicator value (BIEV) - */ -typedef void (* bthf_biev_cmd_callback)(char* hf_ind_val, bt_bdaddr_t *bd_addr); - -/** BT-HF callback structure. */ -typedef struct { - /** set to sizeof(BtHfCallbacks) */ - size_t size; - bthf_connection_state_callback connection_state_cb; - bthf_audio_state_callback audio_state_cb; - bthf_vr_cmd_callback vr_cmd_cb; - bthf_answer_call_cmd_callback answer_call_cmd_cb; - bthf_hangup_call_cmd_callback hangup_call_cmd_cb; - bthf_volume_cmd_callback volume_cmd_cb; - bthf_dial_call_cmd_callback dial_call_cmd_cb; - bthf_dtmf_cmd_callback dtmf_cmd_cb; - bthf_nrec_cmd_callback nrec_cmd_cb; - bthf_wbs_callback wbs_cb; - bthf_chld_cmd_callback chld_cmd_cb; - bthf_cnum_cmd_callback cnum_cmd_cb; - bthf_cind_cmd_callback cind_cmd_cb; - bthf_cops_cmd_callback cops_cmd_cb; - bthf_clcc_cmd_callback clcc_cmd_cb; - bthf_unknown_at_cmd_callback unknown_at_cmd_cb; - bthf_key_pressed_cmd_callback key_pressed_cmd_cb; - bthf_bind_cmd_callback bind_cmd_cb; - bthf_biev_cmd_callback biev_cmd_cb; -} bthf_callbacks_t; - -/** Network Status */ -typedef enum -{ - BTHF_NETWORK_STATE_NOT_AVAILABLE = 0, - BTHF_NETWORK_STATE_AVAILABLE -} bthf_network_state_t; - -/** Service type */ -typedef enum -{ - BTHF_SERVICE_TYPE_HOME = 0, - BTHF_SERVICE_TYPE_ROAMING -} bthf_service_type_t; - -typedef enum { - BTHF_CALL_STATE_ACTIVE = 0, - BTHF_CALL_STATE_HELD, - BTHF_CALL_STATE_DIALING, - BTHF_CALL_STATE_ALERTING, - BTHF_CALL_STATE_INCOMING, - BTHF_CALL_STATE_WAITING, - BTHF_CALL_STATE_IDLE -} bthf_call_state_t; - -typedef enum { - BTHF_CALL_DIRECTION_OUTGOING = 0, - BTHF_CALL_DIRECTION_INCOMING -} bthf_call_direction_t; - -typedef enum { - BTHF_CALL_TYPE_VOICE = 0, - BTHF_CALL_TYPE_DATA, - BTHF_CALL_TYPE_FAX -} bthf_call_mode_t; - -typedef enum { - BTHF_CALL_MPTY_TYPE_SINGLE = 0, - BTHF_CALL_MPTY_TYPE_MULTI -} bthf_call_mpty_type_t; - -typedef enum { - BTHF_HF_INDICATOR_STATE_DISABLED = 0, - BTHF_HF_INDICATOR_STATE_ENABLED -} bthf_hf_indicator_status_t; - -typedef enum { - BTHF_CALL_ADDRTYPE_UNKNOWN = 0x81, - BTHF_CALL_ADDRTYPE_INTERNATIONAL = 0x91 -} bthf_call_addrtype_t; - -typedef enum { - BTHF_VOIP_CALL_NETWORK_TYPE_MOBILE = 0, - BTHF_VOIP_CALL_NETWORK_TYPE_WIFI -} bthf_voip_call_network_type_t; - -typedef enum { - BTHF_VOIP_STATE_STOPPED = 0, - BTHF_VOIP_STATE_STARTED -} bthf_voip_state_t; - -/** Represents the standard BT-HF interface. */ -typedef struct { - - /** set to sizeof(BtHfInterface) */ - size_t size; - /** - * Register the BtHf callbacks - */ - bt_status_t (*init)( bthf_callbacks_t* callbacks, int max_hf_clients); - - /** connect to headset */ - bt_status_t (*connect)( bt_bdaddr_t *bd_addr ); - - /** dis-connect from headset */ - bt_status_t (*disconnect)( bt_bdaddr_t *bd_addr ); - - /** create an audio connection */ - bt_status_t (*connect_audio)( bt_bdaddr_t *bd_addr ); - - /** close the audio connection */ - bt_status_t (*disconnect_audio)( bt_bdaddr_t *bd_addr ); - - /** start voice recognition */ - bt_status_t (*start_voice_recognition)( bt_bdaddr_t *bd_addr ); - - /** stop voice recognition */ - bt_status_t (*stop_voice_recognition)( bt_bdaddr_t *bd_addr ); - - /** volume control */ - bt_status_t (*volume_control) (bthf_volume_type_t type, int volume, bt_bdaddr_t *bd_addr ); - - /** Combined device status change notification */ - bt_status_t (*device_status_notification)(bthf_network_state_t ntk_state, bthf_service_type_t svc_type, int signal, - int batt_chg); - - /** Response for COPS command */ - bt_status_t (*cops_response)(const char *cops, bt_bdaddr_t *bd_addr ); - - /** Response for CIND command */ - bt_status_t (*cind_response)(int svc, int num_active, int num_held, bthf_call_state_t call_setup_state, - int signal, int roam, int batt_chg, bt_bdaddr_t *bd_addr ); - - /** Pre-formatted AT response, typically in response to unknown AT cmd */ - bt_status_t (*formatted_at_response)(const char *rsp, bt_bdaddr_t *bd_addr ); - - /** ok/error response - * ERROR (0) - * OK (1) - */ - bt_status_t (*at_response) (bthf_at_response_t response_code, int error_code, bt_bdaddr_t *bd_addr ); - - /** response for CLCC command - * Can be iteratively called for each call index - * Call index of 0 will be treated as NULL termination (Completes response) - */ - bt_status_t (*clcc_response) (int index, bthf_call_direction_t dir, - bthf_call_state_t state, bthf_call_mode_t mode, - bthf_call_mpty_type_t mpty, const char *number, - bthf_call_addrtype_t type, bt_bdaddr_t *bd_addr ); - - /** notify of a call state change - * Each update notifies - * 1. Number of active/held/ringing calls - * 2. call_state: This denotes the state change that triggered this msg - * This will take one of the values from BtHfCallState - * 3. number & type: valid only for incoming & waiting call - */ - bt_status_t (*phone_state_change) (int num_active, int num_held, bthf_call_state_t call_setup_state, - const char *number, bthf_call_addrtype_t type); - - /** Closes the interface. */ - void (*cleanup)( void ); - - /** configureation for the SCO codec */ - bt_status_t (*configure_wbs)( bt_bdaddr_t *bd_addr ,bthf_wbs_config_t config ); - - /** Response for BIND READ command and activation/deactivation of HF indicator */ - bt_status_t (*bind_response) (int anum, bthf_hf_indicator_status_t status, - bt_bdaddr_t *bd_addr); - - /** Response for BIND TEST command */ - bt_status_t (*bind_string_response) (const char* result, bt_bdaddr_t *bd_addr); - - /** Sends connectivity network type used by Voip currently to stack */ - bt_status_t (*voip_network_type_wifi) (bthf_voip_state_t is_voip_started, - bthf_voip_call_network_type_t is_network_wifi); -} bthf_interface_t; - -__END_DECLS - -#endif /* ANDROID_INCLUDE_BT_HF_H */ diff --git a/hardware/bt_hf_client.h b/hardware/bt_hf_client.h deleted file mode 100644 index 0577e97..0000000 --- a/hardware/bt_hf_client.h +++ /dev/null @@ -1,375 +0,0 @@ -/* - * Copyright (C) 2012-2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_INCLUDE_BT_HF_CLIENT_H -#define ANDROID_INCLUDE_BT_HF_CLIENT_H - -__BEGIN_DECLS - -typedef enum { - BTHF_CLIENT_CONNECTION_STATE_DISCONNECTED = 0, - BTHF_CLIENT_CONNECTION_STATE_CONNECTING, - BTHF_CLIENT_CONNECTION_STATE_CONNECTED, - BTHF_CLIENT_CONNECTION_STATE_SLC_CONNECTED, - BTHF_CLIENT_CONNECTION_STATE_DISCONNECTING -} bthf_client_connection_state_t; - -typedef enum { - BTHF_CLIENT_AUDIO_STATE_DISCONNECTED = 0, - BTHF_CLIENT_AUDIO_STATE_CONNECTING, - BTHF_CLIENT_AUDIO_STATE_CONNECTED, - BTHF_CLIENT_AUDIO_STATE_CONNECTED_MSBC, -} bthf_client_audio_state_t; - -typedef enum { - BTHF_CLIENT_VR_STATE_STOPPED = 0, - BTHF_CLIENT_VR_STATE_STARTED -} bthf_client_vr_state_t; - -typedef enum { - BTHF_CLIENT_VOLUME_TYPE_SPK = 0, - BTHF_CLIENT_VOLUME_TYPE_MIC -} bthf_client_volume_type_t; - -typedef enum -{ - BTHF_CLIENT_NETWORK_STATE_NOT_AVAILABLE = 0, - BTHF_CLIENT_NETWORK_STATE_AVAILABLE -} bthf_client_network_state_t; - -typedef enum -{ - BTHF_CLIENT_SERVICE_TYPE_HOME = 0, - BTHF_CLIENT_SERVICE_TYPE_ROAMING -} bthf_client_service_type_t; - -typedef enum { - BTHF_CLIENT_CALL_STATE_ACTIVE = 0, - BTHF_CLIENT_CALL_STATE_HELD, - BTHF_CLIENT_CALL_STATE_DIALING, - BTHF_CLIENT_CALL_STATE_ALERTING, - BTHF_CLIENT_CALL_STATE_INCOMING, - BTHF_CLIENT_CALL_STATE_WAITING, - BTHF_CLIENT_CALL_STATE_HELD_BY_RESP_HOLD, -} bthf_client_call_state_t; - -typedef enum { - BTHF_CLIENT_CALL_NO_CALLS_IN_PROGRESS = 0, - BTHF_CLIENT_CALL_CALLS_IN_PROGRESS -} bthf_client_call_t; - -typedef enum { - BTHF_CLIENT_CALLSETUP_NONE = 0, - BTHF_CLIENT_CALLSETUP_INCOMING, - BTHF_CLIENT_CALLSETUP_OUTGOING, - BTHF_CLIENT_CALLSETUP_ALERTING - -} bthf_client_callsetup_t; - -typedef enum { - BTHF_CLIENT_CALLHELD_NONE = 0, - BTHF_CLIENT_CALLHELD_HOLD_AND_ACTIVE, - BTHF_CLIENT_CALLHELD_HOLD, -} bthf_client_callheld_t; - -typedef enum { - BTHF_CLIENT_RESP_AND_HOLD_HELD = 0, - BTRH_CLIENT_RESP_AND_HOLD_ACCEPT, - BTRH_CLIENT_RESP_AND_HOLD_REJECT, -} bthf_client_resp_and_hold_t; - -typedef enum { - BTHF_CLIENT_CALL_DIRECTION_OUTGOING = 0, - BTHF_CLIENT_CALL_DIRECTION_INCOMING -} bthf_client_call_direction_t; - -typedef enum { - BTHF_CLIENT_CALL_MPTY_TYPE_SINGLE = 0, - BTHF_CLIENT_CALL_MPTY_TYPE_MULTI -} bthf_client_call_mpty_type_t; - -typedef enum { - BTHF_CLIENT_CMD_COMPLETE_OK = 0, - BTHF_CLIENT_CMD_COMPLETE_ERROR, - BTHF_CLIENT_CMD_COMPLETE_ERROR_NO_CARRIER, - BTHF_CLIENT_CMD_COMPLETE_ERROR_BUSY, - BTHF_CLIENT_CMD_COMPLETE_ERROR_NO_ANSWER, - BTHF_CLIENT_CMD_COMPLETE_ERROR_DELAYED, - BTHF_CLIENT_CMD_COMPLETE_ERROR_BLACKLISTED, - BTHF_CLIENT_CMD_COMPLETE_ERROR_CME -} bthf_client_cmd_complete_t; - -typedef enum { - BTHF_CLIENT_CALL_ACTION_CHLD_0 = 0, - BTHF_CLIENT_CALL_ACTION_CHLD_1, - BTHF_CLIENT_CALL_ACTION_CHLD_2, - BTHF_CLIENT_CALL_ACTION_CHLD_3, - BTHF_CLIENT_CALL_ACTION_CHLD_4, - BTHF_CLIENT_CALL_ACTION_CHLD_1x, - BTHF_CLIENT_CALL_ACTION_CHLD_2x, - BTHF_CLIENT_CALL_ACTION_ATA, - BTHF_CLIENT_CALL_ACTION_CHUP, - BTHF_CLIENT_CALL_ACTION_BTRH_0, - BTHF_CLIENT_CALL_ACTION_BTRH_1, - BTHF_CLIENT_CALL_ACTION_BTRH_2, -} bthf_client_call_action_t; - -typedef enum { - BTHF_CLIENT_SERVICE_UNKNOWN = 0, - BTHF_CLIENT_SERVICE_VOICE, - BTHF_CLIENT_SERVICE_FAX -} bthf_client_subscriber_service_type_t; - -typedef enum { - BTHF_CLIENT_IN_BAND_RINGTONE_NOT_PROVIDED = 0, - BTHF_CLIENT_IN_BAND_RINGTONE_PROVIDED, -} bthf_client_in_band_ring_state_t; - -/* Peer features masks */ -#define BTHF_CLIENT_PEER_FEAT_3WAY 0x00000001 /* Three-way calling */ -#define BTHF_CLIENT_PEER_FEAT_ECNR 0x00000002 /* Echo cancellation and/or noise reduction */ -#define BTHF_CLIENT_PEER_FEAT_VREC 0x00000004 /* Voice recognition */ -#define BTHF_CLIENT_PEER_FEAT_INBAND 0x00000008 /* In-band ring tone */ -#define BTHF_CLIENT_PEER_FEAT_VTAG 0x00000010 /* Attach a phone number to a voice tag */ -#define BTHF_CLIENT_PEER_FEAT_REJECT 0x00000020 /* Ability to reject incoming call */ -#define BTHF_CLIENT_PEER_FEAT_ECS 0x00000040 /* Enhanced Call Status */ -#define BTHF_CLIENT_PEER_FEAT_ECC 0x00000080 /* Enhanced Call Control */ -#define BTHF_CLIENT_PEER_FEAT_EXTERR 0x00000100 /* Extended error codes */ -#define BTHF_CLIENT_PEER_FEAT_CODEC 0x00000200 /* Codec Negotiation */ - -/* Peer call handling features masks */ -#define BTHF_CLIENT_CHLD_FEAT_REL 0x00000001 /* 0 Release waiting call or held calls */ -#define BTHF_CLIENT_CHLD_FEAT_REL_ACC 0x00000002 /* 1 Release active calls and accept other - (waiting or held) cal */ -#define BTHF_CLIENT_CHLD_FEAT_REL_X 0x00000004 /* 1x Release specified active call only */ -#define BTHF_CLIENT_CHLD_FEAT_HOLD_ACC 0x00000008 /* 2 Active calls on hold and accept other - (waiting or held) call */ -#define BTHF_CLIENT_CHLD_FEAT_PRIV_X 0x00000010 /* 2x Request private mode with specified - call (put the rest on hold) */ -#define BTHF_CLIENT_CHLD_FEAT_MERGE 0x00000020 /* 3 Add held call to multiparty */ -#define BTHF_CLIENT_CHLD_FEAT_MERGE_DETACH 0x00000040 /* 4 Connect two calls and leave - (disconnect from) multiparty */ - -/** Callback for connection state change. - * state will have one of the values from BtHfConnectionState - * peer/chld_features are valid only for BTHF_CLIENT_CONNECTION_STATE_SLC_CONNECTED state - */ -typedef void (* bthf_client_connection_state_callback)(bthf_client_connection_state_t state, - unsigned int peer_feat, - unsigned int chld_feat, - bt_bdaddr_t *bd_addr); - -/** Callback for audio connection state change. - * state will have one of the values from BtHfAudioState - */ -typedef void (* bthf_client_audio_state_callback)(bthf_client_audio_state_t state, - bt_bdaddr_t *bd_addr); - -/** Callback for VR connection state change. - * state will have one of the values from BtHfVRState - */ -typedef void (* bthf_client_vr_cmd_callback)(bthf_client_vr_state_t state); - -/** Callback for network state change - */ -typedef void (* bthf_client_network_state_callback) (bthf_client_network_state_t state); - -/** Callback for network roaming status change - */ -typedef void (* bthf_client_network_roaming_callback) (bthf_client_service_type_t type); - -/** Callback for signal strength indication - */ -typedef void (* bthf_client_network_signal_callback) (int signal_strength); - -/** Callback for battery level indication - */ -typedef void (* bthf_client_battery_level_callback) (int battery_level); - -/** Callback for current operator name - */ -typedef void (* bthf_client_current_operator_callback) (const char *name); - -/** Callback for call indicator - */ -typedef void (* bthf_client_call_callback) (bthf_client_call_t call); - -/** Callback for callsetup indicator - */ -typedef void (* bthf_client_callsetup_callback) (bthf_client_callsetup_t callsetup); - -/** Callback for callheld indicator - */ -typedef void (* bthf_client_callheld_callback) (bthf_client_callheld_t callheld); - -/** Callback for response and hold - */ -typedef void (* bthf_client_resp_and_hold_callback) (bthf_client_resp_and_hold_t resp_and_hold); - -/** Callback for Calling Line Identification notification - * Will be called only when there is an incoming call and number is provided. - */ -typedef void (* bthf_client_clip_callback) (const char *number); - -/** - * Callback for Call Waiting notification - */ -typedef void (* bthf_client_call_waiting_callback) (const char *number); - -/** - * Callback for listing current calls. Can be called multiple time. - * If number is unknown NULL is passed. - */ -typedef void (*bthf_client_current_calls) (int index, bthf_client_call_direction_t dir, - bthf_client_call_state_t state, - bthf_client_call_mpty_type_t mpty, - const char *number); - -/** Callback for audio volume change - */ -typedef void (*bthf_client_volume_change_callback) (bthf_client_volume_type_t type, int volume); - -/** Callback for command complete event - * cme is valid only for BTHF_CLIENT_CMD_COMPLETE_ERROR_CME type - */ -typedef void (*bthf_client_cmd_complete_callback) (bthf_client_cmd_complete_t type, int cme); - -/** Callback for subscriber information - */ -typedef void (* bthf_client_subscriber_info_callback) (const char *name, - bthf_client_subscriber_service_type_t type); - -/** Callback for in-band ring tone settings - */ -typedef void (* bthf_client_in_band_ring_tone_callback) (bthf_client_in_band_ring_state_t state); - -/** - * Callback for requested number from AG - */ -typedef void (* bthf_client_last_voice_tag_number_callback) (const char *number); - -/** - * Callback for sending ring indication to app - */ -typedef void (* bthf_client_ring_indication_callback) (void); - -/** - * Callback for sending cgmi indication to app - */ -typedef void (* bthf_client_cgmi_indication_callback) (const char *str); - -/** - * Callback for sending cgmm indication to app - */ -typedef void (* bthf_client_cgmm_indication_callback) (const char *str); - -/** BT-HF callback structure. */ -typedef struct { - /** set to sizeof(BtHfClientCallbacks) */ - size_t size; - bthf_client_connection_state_callback connection_state_cb; - bthf_client_audio_state_callback audio_state_cb; - bthf_client_vr_cmd_callback vr_cmd_cb; - bthf_client_network_state_callback network_state_cb; - bthf_client_network_roaming_callback network_roaming_cb; - bthf_client_network_signal_callback network_signal_cb; - bthf_client_battery_level_callback battery_level_cb; - bthf_client_current_operator_callback current_operator_cb; - bthf_client_call_callback call_cb; - bthf_client_callsetup_callback callsetup_cb; - bthf_client_callheld_callback callheld_cb; - bthf_client_resp_and_hold_callback resp_and_hold_cb; - bthf_client_clip_callback clip_cb; - bthf_client_call_waiting_callback call_waiting_cb; - bthf_client_current_calls current_calls_cb; - bthf_client_volume_change_callback volume_change_cb; - bthf_client_cmd_complete_callback cmd_complete_cb; - bthf_client_subscriber_info_callback subscriber_info_cb; - bthf_client_in_band_ring_tone_callback in_band_ring_tone_cb; - bthf_client_last_voice_tag_number_callback last_voice_tag_number_callback; - bthf_client_ring_indication_callback ring_indication_cb; - bthf_client_cgmi_indication_callback cgmi_cb; - bthf_client_cgmm_indication_callback cgmm_cb; -} bthf_client_callbacks_t; - -/** Represents the standard BT-HF interface. */ -typedef struct { - - /** set to sizeof(BtHfClientInterface) */ - size_t size; - /** - * Register the BtHf callbacks - */ - bt_status_t (*init)(bthf_client_callbacks_t* callbacks); - - /** connect to audio gateway */ - bt_status_t (*connect)(bt_bdaddr_t *bd_addr); - - /** disconnect from audio gateway */ - bt_status_t (*disconnect)(bt_bdaddr_t *bd_addr); - - /** create an audio connection */ - bt_status_t (*connect_audio)(bt_bdaddr_t *bd_addr); - - /** close the audio connection */ - bt_status_t (*disconnect_audio)(bt_bdaddr_t *bd_addr); - - /** start voice recognition */ - bt_status_t (*start_voice_recognition)(void); - - /** stop voice recognition */ - bt_status_t (*stop_voice_recognition)(void); - - /** volume control */ - bt_status_t (*volume_control) (bthf_client_volume_type_t type, int volume); - - /** place a call with number a number - * if number is NULL last called number is called (aka re-dial)*/ - bt_status_t (*dial) (const char *number); - - /** place a call with number specified by location (speed dial) */ - bt_status_t (*dial_memory) (int location); - - /** perform specified call related action - * idx is limited only for enhanced call control related action - */ - bt_status_t (*handle_call_action) (bthf_client_call_action_t action, int idx); - - /** query list of current calls */ - bt_status_t (*query_current_calls) (void); - - /** query name of current selected operator */ - bt_status_t (*query_current_operator_name) (void); - - /** Retrieve subscriber information */ - bt_status_t (*retrieve_subscriber_info) (void); - - /** Send DTMF code*/ - bt_status_t (*send_dtmf) (char code); - - /** Request a phone number from AG corresponding to last voice tag recorded */ - bt_status_t (*request_last_voice_tag_number) (void); - - /** Closes the interface. */ - void (*cleanup)(void); - - /** Send AT Command. */ - bt_status_t (*send_at_cmd) (int cmd, int val1, int val2, const char *arg); -} bthf_client_interface_t; - -__END_DECLS - -#endif /* ANDROID_INCLUDE_BT_HF_CLIENT_H */ diff --git a/hardware/bt_hh.h b/hardware/bt_hh.h deleted file mode 100644 index ece3c11..0000000 --- a/hardware/bt_hh.h +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_INCLUDE_BT_HH_H -#define ANDROID_INCLUDE_BT_HH_H - -#include - -__BEGIN_DECLS - -#define BTHH_MAX_DSC_LEN 884 - -/* HH connection states */ -typedef enum -{ - BTHH_CONN_STATE_CONNECTED = 0, - BTHH_CONN_STATE_CONNECTING, - BTHH_CONN_STATE_DISCONNECTED, - BTHH_CONN_STATE_DISCONNECTING, - BTHH_CONN_STATE_FAILED_MOUSE_FROM_HOST, - BTHH_CONN_STATE_FAILED_KBD_FROM_HOST, - BTHH_CONN_STATE_FAILED_TOO_MANY_DEVICES, - BTHH_CONN_STATE_FAILED_NO_BTHID_DRIVER, - BTHH_CONN_STATE_FAILED_GENERIC, - BTHH_CONN_STATE_UNKNOWN -} bthh_connection_state_t; - -typedef enum -{ - BTHH_OK = 0, - BTHH_HS_HID_NOT_READY, /* handshake error : device not ready */ - BTHH_HS_INVALID_RPT_ID, /* handshake error : invalid report ID */ - BTHH_HS_TRANS_NOT_SPT, /* handshake error : transaction not spt */ - BTHH_HS_INVALID_PARAM, /* handshake error : invalid paremter */ - BTHH_HS_ERROR, /* handshake error : unspecified HS error */ - BTHH_ERR, /* general BTA HH error */ - BTHH_ERR_SDP, /* SDP error */ - BTHH_ERR_PROTO, /* SET_Protocol error, - only used in BTA_HH_OPEN_EVT callback */ - BTHH_ERR_DB_FULL, /* device database full error, used */ - BTHH_ERR_TOD_UNSPT, /* type of device not supported */ - BTHH_ERR_NO_RES, /* out of system resources */ - BTHH_ERR_AUTH_FAILED, /* authentication fail */ - BTHH_ERR_HDL -}bthh_status_t; - -/* Protocol modes */ -typedef enum { - BTHH_REPORT_MODE = 0x00, - BTHH_BOOT_MODE = 0x01, - BTHH_UNSUPPORTED_MODE = 0xff -}bthh_protocol_mode_t; - -/* Report types */ -typedef enum { - BTHH_INPUT_REPORT = 1, - BTHH_OUTPUT_REPORT, - BTHH_FEATURE_REPORT -}bthh_report_type_t; - -typedef struct -{ - int attr_mask; - uint8_t sub_class; - uint8_t app_id; - int vendor_id; - int product_id; - int version; - uint8_t ctry_code; - int dl_len; - uint8_t dsc_list[BTHH_MAX_DSC_LEN]; -} bthh_hid_info_t; - -/** Callback for connection state change. - * state will have one of the values from bthh_connection_state_t - */ -typedef void (* bthh_connection_state_callback)(bt_bdaddr_t *bd_addr, bthh_connection_state_t state); - -/** Callback for vitual unplug api. - * the status of the vitual unplug - */ -typedef void (* bthh_virtual_unplug_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status); - -/** Callback for get hid info - * hid_info will contain attr_mask, sub_class, app_id, vendor_id, product_id, version, ctry_code, len - */ -typedef void (* bthh_hid_info_callback)(bt_bdaddr_t *bd_addr, bthh_hid_info_t hid_info); - -/** Callback for get protocol api. - * the protocol mode is one of the value from bthh_protocol_mode_t - */ -typedef void (* bthh_protocol_mode_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status, bthh_protocol_mode_t mode); - -/** Callback for get/set_idle_time api. - */ -typedef void (* bthh_idle_time_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status, int idle_rate); - - -/** Callback for get report api. - * if staus is ok rpt_data contains the report data - */ -typedef void (* bthh_get_report_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status, uint8_t* rpt_data, int rpt_size); - -/** Callback for set_report/set_protocol api and if error - * occurs for get_report/get_protocol api. - */ -typedef void (* bthh_handshake_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status); - - -/** BT-HH callback structure. */ -typedef struct { - /** set to sizeof(BtHfCallbacks) */ - size_t size; - bthh_connection_state_callback connection_state_cb; - bthh_hid_info_callback hid_info_cb; - bthh_protocol_mode_callback protocol_mode_cb; - bthh_idle_time_callback idle_time_cb; - bthh_get_report_callback get_report_cb; - bthh_virtual_unplug_callback virtual_unplug_cb; - bthh_handshake_callback handshake_cb; - -} bthh_callbacks_t; - - - -/** Represents the standard BT-HH interface. */ -typedef struct { - - /** set to sizeof(BtHhInterface) */ - size_t size; - - /** - * Register the BtHh callbacks - */ - bt_status_t (*init)( bthh_callbacks_t* callbacks ); - - /** connect to hid device */ - bt_status_t (*connect)( bt_bdaddr_t *bd_addr); - - /** dis-connect from hid device */ - bt_status_t (*disconnect)( bt_bdaddr_t *bd_addr ); - - /** Virtual UnPlug (VUP) the specified HID device */ - bt_status_t (*virtual_unplug)(bt_bdaddr_t *bd_addr); - - /** Set the HID device descriptor for the specified HID device. */ - bt_status_t (*set_info)(bt_bdaddr_t *bd_addr, bthh_hid_info_t hid_info ); - - /** Get the HID proto mode. */ - bt_status_t (*get_protocol) (bt_bdaddr_t *bd_addr, bthh_protocol_mode_t protocolMode); - - /** Set the HID proto mode. */ - bt_status_t (*set_protocol)(bt_bdaddr_t *bd_addr, bthh_protocol_mode_t protocolMode); - - /** Get the HID Idle Time */ - bt_status_t (*get_idle_time)(bt_bdaddr_t *bd_addr); - - /** Set the HID Idle Time */ - bt_status_t (*set_idle_time)(bt_bdaddr_t *bd_addr, uint8_t idleTime); - - /** Send a GET_REPORT to HID device. */ - bt_status_t (*get_report)(bt_bdaddr_t *bd_addr, bthh_report_type_t reportType, uint8_t reportId, int bufferSize); - - /** Send a SET_REPORT to HID device. */ - bt_status_t (*set_report)(bt_bdaddr_t *bd_addr, bthh_report_type_t reportType, char* report); - - /** Send data to HID device. */ - bt_status_t (*send_data)(bt_bdaddr_t *bd_addr, char* data); - - /** Closes the interface. */ - void (*cleanup)( void ); - -} bthh_interface_t; -__END_DECLS - -#endif /* ANDROID_INCLUDE_BT_HH_H */ - - diff --git a/hardware/bt_hl.h b/hardware/bt_hl.h deleted file mode 100644 index bd29e3a..0000000 --- a/hardware/bt_hl.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_INCLUDE_BT_HL_H -#define ANDROID_INCLUDE_BT_HL_H - -__BEGIN_DECLS - -/* HL connection states */ - -typedef enum -{ - BTHL_MDEP_ROLE_SOURCE, - BTHL_MDEP_ROLE_SINK -} bthl_mdep_role_t; - -typedef enum { - BTHL_APP_REG_STATE_REG_SUCCESS, - BTHL_APP_REG_STATE_REG_FAILED, - BTHL_APP_REG_STATE_DEREG_SUCCESS, - BTHL_APP_REG_STATE_DEREG_FAILED -} bthl_app_reg_state_t; - -typedef enum -{ - BTHL_CHANNEL_TYPE_RELIABLE, - BTHL_CHANNEL_TYPE_STREAMING, - BTHL_CHANNEL_TYPE_ANY -} bthl_channel_type_t; - - -/* HL connection states */ -typedef enum { - BTHL_CONN_STATE_CONNECTING, - BTHL_CONN_STATE_CONNECTED, - BTHL_CONN_STATE_DISCONNECTING, - BTHL_CONN_STATE_DISCONNECTED, - BTHL_CONN_STATE_DESTROYED -} bthl_channel_state_t; - -typedef struct -{ - bthl_mdep_role_t mdep_role; - int data_type; - bthl_channel_type_t channel_type; - const char *mdep_description; /* MDEP description to be used in the SDP (optional); null terminated */ -} bthl_mdep_cfg_t; - -typedef struct -{ - const char *application_name; - const char *provider_name; /* provider name to be used in the SDP (optional); null terminated */ - const char *srv_name; /* service name to be used in the SDP (optional); null terminated*/ - const char *srv_desp; /* service description to be used in the SDP (optional); null terminated */ - int number_of_mdeps; - bthl_mdep_cfg_t *mdep_cfg; /* Dynamic array */ -} bthl_reg_param_t; - -/** Callback for application registration status. - * state will have one of the values from bthl_app_reg_state_t - */ -typedef void (* bthl_app_reg_state_callback)(int app_id, bthl_app_reg_state_t state); - -/** Callback for channel connection state change. - * state will have one of the values from - * bthl_connection_state_t and fd (file descriptor) - */ -typedef void (* bthl_channel_state_callback)(int app_id, bt_bdaddr_t *bd_addr, int mdep_cfg_index, int channel_id, bthl_channel_state_t state, int fd); - -/** BT-HL callback structure. */ -typedef struct { - /** set to sizeof(bthl_callbacks_t) */ - size_t size; - bthl_app_reg_state_callback app_reg_state_cb; - bthl_channel_state_callback channel_state_cb; -} bthl_callbacks_t; - - -/** Represents the standard BT-HL interface. */ -typedef struct { - - /** set to sizeof(bthl_interface_t) */ - size_t size; - - /** - * Register the Bthl callbacks - */ - bt_status_t (*init)( bthl_callbacks_t* callbacks ); - - /** Register HL application */ - bt_status_t (*register_application) ( bthl_reg_param_t *p_reg_param, int *app_id); - - /** Unregister HL application */ - bt_status_t (*unregister_application) (int app_id); - - /** connect channel */ - bt_status_t (*connect_channel)(int app_id, bt_bdaddr_t *bd_addr, int mdep_cfg_index, int *channel_id); - - /** destroy channel */ - bt_status_t (*destroy_channel)(int channel_id); - - /** Close the Bthl callback **/ - void (*cleanup)(void); - -} bthl_interface_t; -__END_DECLS - -#endif /* ANDROID_INCLUDE_BT_HL_H */ - - diff --git a/hardware/bt_mce.h b/hardware/bt_mce.h deleted file mode 100644 index 5d159b3..0000000 --- a/hardware/bt_mce.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_INCLUDE_BT_MCE_H -#define ANDROID_INCLUDE_BT_MCE_H - -__BEGIN_DECLS - -/** MAS instance description */ -typedef struct -{ - int id; - int scn; - int msg_types; - char *p_name; -} btmce_mas_instance_t; - -/** callback for get_remote_mas_instances */ -typedef void (*btmce_remote_mas_instances_callback)(bt_status_t status, bt_bdaddr_t *bd_addr, - int num_instances, btmce_mas_instance_t *instances); - -typedef struct { - /** set to sizeof(btmce_callbacks_t) */ - size_t size; - btmce_remote_mas_instances_callback remote_mas_instances_cb; -} btmce_callbacks_t; - -typedef struct { - /** set to size of this struct */ - size_t size; - - /** register BT MCE callbacks */ - bt_status_t (*init)(btmce_callbacks_t *callbacks); - - /** search for MAS instances on remote device */ - bt_status_t (*get_remote_mas_instances)(bt_bdaddr_t *bd_addr); -} btmce_interface_t; - -__END_DECLS - -#endif /* ANDROID_INCLUDE_BT_MCE_H */ diff --git a/hardware/bt_pan.h b/hardware/bt_pan.h deleted file mode 100644 index 83e7949..0000000 --- a/hardware/bt_pan.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_INCLUDE_BT_PAN_H -#define ANDROID_INCLUDE_BT_PAN_H - -__BEGIN_DECLS - -#define BTPAN_ROLE_NONE 0 -#define BTPAN_ROLE_PANNAP 1 -#define BTPAN_ROLE_PANU 2 - -typedef enum { - BTPAN_STATE_CONNECTED = 0, - BTPAN_STATE_CONNECTING = 1, - BTPAN_STATE_DISCONNECTED = 2, - BTPAN_STATE_DISCONNECTING = 3 -} btpan_connection_state_t; - -typedef enum { - BTPAN_STATE_ENABLED = 0, - BTPAN_STATE_DISABLED = 1 -} btpan_control_state_t; - -/** -* Callback for pan connection state -*/ -typedef void (*btpan_connection_state_callback)(btpan_connection_state_t state, bt_status_t error, - const bt_bdaddr_t *bd_addr, int local_role, int remote_role); -typedef void (*btpan_control_state_callback)(btpan_control_state_t state, int local_role, - bt_status_t error, const char* ifname); - -typedef struct { - size_t size; - btpan_control_state_callback control_state_cb; - btpan_connection_state_callback connection_state_cb; -} btpan_callbacks_t; -typedef struct { - /** set to size of this struct*/ - size_t size; - /** - * Initialize the pan interface and register the btpan callbacks - */ - bt_status_t (*init)(const btpan_callbacks_t* callbacks); - /* - * enable the pan service by specified role. The result state of - * enabl will be returned by btpan_control_state_callback. when pan-nap is enabled, - * the state of connecting panu device will be notified by btpan_connection_state_callback - */ - bt_status_t (*enable)(int local_role); - /* - * get current pan local role - */ - int (*get_local_role)(void); - /** - * start bluetooth pan connection to the remote device by specified pan role. The result state will be - * returned by btpan_connection_state_callback - */ - bt_status_t (*connect)(const bt_bdaddr_t *bd_addr, int local_role, int remote_role); - /** - * stop bluetooth pan connection. The result state will be returned by btpan_connection_state_callback - */ - bt_status_t (*disconnect)(const bt_bdaddr_t *bd_addr); - - /** - * Cleanup the pan interface - */ - void (*cleanup)(void); - -} btpan_interface_t; - -__END_DECLS - -#endif /* ANDROID_INCLUDE_BT_PAN_H */ diff --git a/hardware/bt_rc.h b/hardware/bt_rc.h deleted file mode 100644 index d0cf9c8..0000000 --- a/hardware/bt_rc.h +++ /dev/null @@ -1,545 +0,0 @@ -/* - * Copyright (C) 2013-2015, The Linux Foundation. All rights reserved. - * Not a Contribution. - * - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_INCLUDE_BT_RC_H -#define ANDROID_INCLUDE_BT_RC_H - -__BEGIN_DECLS - -/* Macros */ -#define BTRC_MAX_ATTR_STR_LEN 255 -#define BTRC_UID_SIZE 8 -#define BTRC_MAX_APP_SETTINGS 8 -#define BTRC_MAX_FOLDER_DEPTH 4 -#define BTRC_MAX_APP_ATTR_SIZE 16 -#define BTRC_MAX_ELEM_ATTR_SIZE 8 -#define BTRC_CHARSET_UTF8 0x006A -#define BTRC_BROWSE_PDU_HEADER 3 -#define BTRC_AVCTP_HEADER 3 -#define BTRC_BROWSE_PKT_3TO7OCT_LEN 5 -#define BTRC_FOLDER_ITEM_HEADER 14 -#define BTRC_ITEM_ATTRIBUTE_HEADER 8 -#define BTRC_ITEM_TYPE_N_LEN_OCT 3 - -typedef uint8_t btrc_uid_t[BTRC_UID_SIZE]; - -typedef enum { - BTRC_FEAT_NONE = 0x00, /* AVRCP 1.0 */ - BTRC_FEAT_METADATA = 0x01, /* AVRCP 1.3 */ - BTRC_FEAT_ABSOLUTE_VOLUME = 0x02, /* Supports TG role and volume sync */ - BTRC_FEAT_BROWSE = 0x04, /* AVRCP 1.4 and up, with Browsing support */ -} btrc_remote_features_t; - -typedef enum { - BTRC_PLAYSTATE_STOPPED = 0x00, /* Stopped */ - BTRC_PLAYSTATE_PLAYING = 0x01, /* Playing */ - BTRC_PLAYSTATE_PAUSED = 0x02, /* Paused */ - BTRC_PLAYSTATE_FWD_SEEK = 0x03, /* Fwd Seek*/ - BTRC_PLAYSTATE_REV_SEEK = 0x04, /* Rev Seek*/ - BTRC_PLAYSTATE_ERROR = 0xFF, /* Error */ -} btrc_play_status_t; - -typedef enum { - BTRC_EVT_PLAY_STATUS_CHANGED = 0x01, - BTRC_EVT_TRACK_CHANGE = 0x02, - BTRC_EVT_TRACK_REACHED_END = 0x03, - BTRC_EVT_TRACK_REACHED_START = 0x04, - BTRC_EVT_PLAY_POS_CHANGED = 0x05, - BTRC_EVT_APP_SETTINGS_CHANGED = 0x08, - BTRC_EVT_NOW_PLAYING_CONTENT_CHANGED = 0x09, - BTRC_EVT_AVAILABLE_PLAYERS_CHANGED = 0x0a, - BTRC_EVT_ADDRESSED_PLAYER_CHANGED = 0x0b, -} btrc_event_id_t; - -//used for Scope -typedef enum { - BTRC_EVT_MEDIA_PLAYLIST = 0, - BTRC_EVT_MEDIA_VIRTUALFILESYST = 1, - BTRC_EVT_SEARCH = 2, - BTRC_EVT_NOWPLAYING = 3, - BTRC_EVT_MAX_BROWSE = 4, -} btrc_browse_folderitem_t; - -typedef enum { - BTRC_NOTIFICATION_TYPE_INTERIM = 0, - BTRC_NOTIFICATION_TYPE_CHANGED = 1, - BTRC_NOTIFICATION_TYPE_REJECT = 2, -} btrc_notification_type_t; - -typedef enum { - BTRC_PLAYER_ATTR_EQUALIZER = 0x01, - BTRC_PLAYER_ATTR_REPEAT = 0x02, - BTRC_PLAYER_ATTR_SHUFFLE = 0x03, - BTRC_PLAYER_ATTR_SCAN = 0x04, -} btrc_player_attr_t; - -typedef enum { - BTRC_MEDIA_ATTR_TITLE = 0x01, - BTRC_MEDIA_ATTR_ARTIST = 0x02, - BTRC_MEDIA_ATTR_ALBUM = 0x03, - BTRC_MEDIA_ATTR_TRACK_NUM = 0x04, - BTRC_MEDIA_ATTR_NUM_TRACKS = 0x05, - BTRC_MEDIA_ATTR_GENRE = 0x06, - BTRC_MEDIA_ATTR_PLAYING_TIME = 0x07, - BTRC_MEDIA_ATTR_COVER_ART = 0x08, -} btrc_media_attr_t; - -typedef enum { - BTRC_PLAYER_VAL_OFF_REPEAT = 0x01, - BTRC_PLAYER_VAL_SINGLE_REPEAT = 0x02, - BTRC_PLAYER_VAL_ALL_REPEAT = 0x03, - BTRC_PLAYER_VAL_GROUP_REPEAT = 0x04 -} btrc_player_repeat_val_t; - -typedef enum { - BTRC_PLAYER_VAL_OFF_SHUFFLE = 0x01, - BTRC_PLAYER_VAL_ALL_SHUFFLE = 0x02, - BTRC_PLAYER_VAL_GROUP_SHUFFLE = 0x03 -} btrc_player_shuffle_val_t; - -typedef enum { - BTRC_STS_BAD_CMD = 0x00, /* Invalid command */ - BTRC_STS_BAD_PARAM = 0x01, /* Invalid parameter */ - BTRC_STS_NOT_FOUND = 0x02, /* Specified parameter is wrong or not found */ - BTRC_STS_INTERNAL_ERR = 0x03, /* Internal Error */ - BTRC_STS_NO_ERROR = 0x04 /* Operation Success */ -} btrc_status_t; - -typedef enum { - BTRC_TYPE_MEDIA_PLAYER = 0x01, - BTRC_TYPE_FOLDER = 0x02, - BTRC_TYPE_MEDIA_ELEMENT = 0x03 -} btrc_folder_list_item_type_t; - -typedef struct { - uint8_t num_attr; - uint8_t attr_ids[BTRC_MAX_APP_SETTINGS]; - uint8_t attr_values[BTRC_MAX_APP_SETTINGS]; -} btrc_player_settings_t; - -typedef struct { - uint8_t val; - uint16_t charset_id; - uint16_t str_len; - uint8_t *p_str; -} btrc_player_app_ext_attr_val_t; - -typedef struct { - uint8_t attr_id; - uint16_t charset_id; - uint16_t str_len; - uint8_t *p_str; - uint8_t num_val; - btrc_player_app_ext_attr_val_t ext_attr_val[BTRC_MAX_APP_ATTR_SIZE]; -} btrc_player_app_ext_attr_t; - -typedef struct { - uint8_t attr_id; - uint8_t num_val; - uint8_t attr_val[BTRC_MAX_APP_ATTR_SIZE]; -} btrc_player_app_attr_t; - -typedef struct { - uint32_t start_item; - uint32_t end_item; - uint32_t size; - uint32_t attrs[BTRC_MAX_ELEM_ATTR_SIZE]; - uint8_t attr_count; -} btrc_getfolderitem_t; - -typedef union -{ - btrc_play_status_t play_status; - btrc_uid_t track; /* queue position in NowPlaying */ - uint32_t song_pos; - btrc_player_settings_t player_setting; - uint16_t player_id; -} btrc_register_notification_t; - -typedef struct { - uint8_t id; /* can be attr_id or value_id */ - uint8_t text[BTRC_MAX_ATTR_STR_LEN]; -} btrc_player_setting_text_t; - -typedef struct { - uint32_t attr_id; - uint8_t text[BTRC_MAX_ATTR_STR_LEN]; -} btrc_element_attr_val_t; - -/** Callback for the controller's supported feautres */ -typedef void (* btrc_remote_features_callback)(bt_bdaddr_t *bd_addr, - btrc_remote_features_t features); -#define BTRC_FEATURE_MASK_SIZE 16 - -typedef uint8_t btrc_feature_mask_t[BTRC_FEATURE_MASK_SIZE]; - -typedef struct { - uint16_t charset_id; - uint16_t str_len; - uint8_t *p_str; -} btrc_player_full_name_t; - -typedef struct -{ - uint32_t sub_type; - uint16_t player_id; - uint8_t major_type; - uint8_t play_status; - btrc_feature_mask_t features; /* Supported feature bit mask*/ - btrc_player_full_name_t name; /* The player name, name length and character set id.*/ -} btrc_folder_list_item_player_t; - -typedef struct -{ - uint64_t uid; - uint8_t type; - uint8_t playable; - btrc_player_full_name_t name; -} btrc_folder_list_item_folder_t; - -typedef struct -{ - uint32_t attr_id; - btrc_player_full_name_t name; -} btrc_attr_entry_t; - -typedef struct -{ - uint64_t uid; - uint8_t type; - uint8_t attr_count; - btrc_player_full_name_t name; - btrc_attr_entry_t* p_attr_list; -} btrc_folder_list_item_media_t; - -typedef struct { - uint16_t str_len; - uint8_t *p_str; -} btrc_name_t; - -/* SetBrowsedPlayer */ -typedef struct -{ - uint32_t num_items; - uint16_t uid_counter; - uint16_t charset_id; - uint8_t status; - uint8_t folder_depth; - btrc_name_t *p_folders; -} btrc_set_browsed_player_rsp_t; - -typedef struct -{ - uint8_t item_type; - union - { - btrc_folder_list_item_player_t player; - btrc_folder_list_item_folder_t folder; - btrc_folder_list_item_media_t media; - } u; -} btrc_folder_list_item_t; - -/* GetFolderItems */ -typedef struct -{ - uint16_t uid_counter; - uint16_t item_count; - uint8_t status; - btrc_folder_list_item_t *p_item_list; -} btrc_folder_list_entries_t; - -/** Callback for play status request */ -typedef void (* btrc_get_play_status_callback)(bt_bdaddr_t *bd_addr); - -/** Callback for list player application attributes (Shuffle, Repeat,...) */ -typedef void (* btrc_list_player_app_attr_callback)(bt_bdaddr_t *bd_addr); - -/** Callback for list player application attributes (Shuffle, Repeat,...) */ -typedef void (* btrc_list_player_app_values_callback)(btrc_player_attr_t attr_id, - bt_bdaddr_t *bd_addr); - -/** Callback for getting the current player application settings value -** num_attr: specifies the number of attribute ids contained in p_attrs -*/ -typedef void (* btrc_get_player_app_value_callback) (uint8_t num_attr, btrc_player_attr_t *p_attrs, - bt_bdaddr_t *bd_addr); - -/** Callback for getting the player application settings attributes' text -** num_attr: specifies the number of attribute ids contained in p_attrs -*/ -typedef void (* btrc_get_player_app_attrs_text_callback) (uint8_t num_attr, - btrc_player_attr_t *p_attrs, bt_bdaddr_t *bd_addr); - -/** Callback for getting the player application settings values' text -** num_attr: specifies the number of value ids contained in p_vals -*/ -typedef void (* btrc_get_player_app_values_text_callback) (uint8_t attr_id, - uint8_t num_val, uint8_t *p_vals, bt_bdaddr_t *bd_addr); - -/** Callback for setting the player application settings values */ -typedef void (* btrc_set_player_app_value_callback) (btrc_player_settings_t *p_vals, - bt_bdaddr_t *bd_addr); - -/** Callback to fetch the get element attributes of the current song -** num_attr: specifies the number of attributes requested in p_attrs -*/ -typedef void (* btrc_get_element_attr_callback) (uint8_t num_attr, btrc_media_attr_t *p_attrs, - bt_bdaddr_t *bd_addr); - -/** Callback for register notification (Play state change/track change/...) -** param: Is only valid if event_id is BTRC_EVT_PLAY_POS_CHANGED -*/ -typedef void (* btrc_register_notification_callback) (btrc_event_id_t event_id, uint32_t param, - bt_bdaddr_t *bd_addr); - -/* AVRCP 1.4 Enhancements */ -/** Callback for volume change on CT -** volume: Current volume setting on the CT (0-127) -*/ -typedef void (* btrc_volume_change_callback) (uint8_t volume, uint8_t ctype, bt_bdaddr_t *bd_addr); - -/** Callback for passthrough commands */ -typedef void (* btrc_passthrough_cmd_callback) (int id, int key_state, bt_bdaddr_t *bd_addr); - -/** BT-RC Target callback structure. */ - -typedef void (* btrc_get_folder_items_callback) (btrc_browse_folderitem_t id, - btrc_getfolderitem_t *param, bt_bdaddr_t *bd_addr); - -typedef void (* btrc_set_addressed_player_callback) (uint32_t player_id, bt_bdaddr_t *bd_addr); - -typedef void (* btrc_set_browsed_player_callback) (uint32_t player_id, bt_bdaddr_t *bd_addr); - -typedef void (* btrc_change_path_callback) (uint8_t direction, uint64_t uid, bt_bdaddr_t *bd_addr); - -typedef void (* btrc_play_item_callback) (uint8_t scope, uint64_t uid, bt_bdaddr_t *bd_addr); - -typedef void (* btrc_get_item_attr_callback) (uint8_t scope, uint64_t uid, - uint8_t num_attr, btrc_media_attr_t *p_attrs, uint32_t size, bt_bdaddr_t *bd_addr); - -typedef void (* btrc_connection_state_callback) (bool state, bt_bdaddr_t *bd_addr); - -typedef void (* btrc_get_total_item_callback) (uint8_t scope, bt_bdaddr_t *bd_addr); - -typedef struct { - /** set to sizeof(BtRcCallbacks) */ - size_t size; - btrc_remote_features_callback remote_features_cb; - btrc_get_play_status_callback get_play_status_cb; - btrc_list_player_app_attr_callback list_player_app_attr_cb; - btrc_list_player_app_values_callback list_player_app_values_cb; - btrc_get_player_app_value_callback get_player_app_value_cb; - btrc_get_player_app_attrs_text_callback get_player_app_attrs_text_cb; - btrc_get_player_app_values_text_callback get_player_app_values_text_cb; - btrc_set_player_app_value_callback set_player_app_value_cb; - btrc_get_element_attr_callback get_element_attr_cb; - btrc_register_notification_callback register_notification_cb; - btrc_volume_change_callback volume_change_cb; - btrc_passthrough_cmd_callback passthrough_cmd_cb; - btrc_get_folder_items_callback get_folderitems_cb; - btrc_set_addressed_player_callback set_addrplayer_cb; - btrc_set_browsed_player_callback set_browsed_player_cb; - btrc_change_path_callback change_path_cb; - btrc_play_item_callback play_item_cb; - btrc_get_item_attr_callback get_item_attr_cb; - btrc_connection_state_callback connection_state_cb; - btrc_get_total_item_callback get_tot_item_cb; -} btrc_callbacks_t; - -/** Represents the standard BT-RC AVRCP Target interface. */ -typedef struct { - - /** set to sizeof(BtRcInterface) */ - size_t size; - /** - * Register the BtRc callbacks - */ - bt_status_t (*init)( btrc_callbacks_t* callbacks , int max_avrcp_connections); - - /** Respose to GetPlayStatus request. Contains the current - ** 1. Play status - ** 2. Song duration/length - ** 3. Song position - */ - bt_status_t (*get_play_status_rsp)( btrc_play_status_t play_status, uint32_t song_len, - uint32_t song_pos, bt_bdaddr_t *bd_addr); - - /** Lists the support player application attributes (Shuffle/Repeat/...) - ** num_attr: Specifies the number of attributes contained in the pointer p_attrs - */ - bt_status_t (*list_player_app_attr_rsp)( uint8_t num_attr, btrc_player_attr_t *p_attrs, - bt_bdaddr_t *bd_addr); - - /** Lists the support player application attributes (Shuffle Off/On/Group) - ** num_val: Specifies the number of values contained in the pointer p_vals - */ - bt_status_t (*list_player_app_value_rsp)( uint8_t num_val, uint8_t *p_vals, - bt_bdaddr_t *bd_addr); - - /** Returns the current application attribute values for each of the specified attr_id */ - bt_status_t (*get_player_app_value_rsp)( btrc_player_settings_t *p_vals, - bt_bdaddr_t *bd_addr); - - /** Returns the application attributes text ("Shuffle"/"Repeat"/...) - ** num_attr: Specifies the number of attributes' text contained in the pointer p_attrs - */ - bt_status_t (*get_player_app_attr_text_rsp)( int num_attr, btrc_player_setting_text_t *p_attrs, - bt_bdaddr_t *bd_addr); - - /** Returns the application attributes text ("Shuffle"/"Repeat"/...) - ** num_attr: Specifies the number of attribute values' text contained in the pointer p_vals - */ - bt_status_t (*get_player_app_value_text_rsp)( int num_val, btrc_player_setting_text_t *p_vals, - bt_bdaddr_t *bd_addr); - - /** Returns the current songs' element attributes text ("Title"/"Album"/"Artist") - ** num_attr: Specifies the number of attributes' text contained in the pointer p_attrs - */ - bt_status_t (*get_element_attr_rsp)( uint8_t num_attr, btrc_element_attr_val_t *p_attrs, - bt_bdaddr_t *bd_addr); - - /** Response to set player attribute request ("Shuffle"/"Repeat") - ** rsp_status: Status of setting the player attributes for the current media player - */ - bt_status_t (*set_player_app_value_rsp)(btrc_status_t rsp_status, bt_bdaddr_t *bd_addr); - - /* Response to the register notification request (Play state change/track change/...). - ** event_id: Refers to the event_id this notification change corresponds too - ** type: Response type - interim/changed - ** p_params: Based on the event_id, this parameter should be populated - */ - bt_status_t (*register_notification_rsp)(btrc_event_id_t event_id, - btrc_notification_type_t type, - btrc_register_notification_t *p_param, - bt_bdaddr_t *bd_addr); - - /* AVRCP 1.4 enhancements */ - - /**Send current volume setting to remote side. Support limited to SetAbsoluteVolume - ** This can be enhanced to support Relative Volume (AVRCP 1.0). - ** With RelateVolume, we will send VOLUME_UP/VOLUME_DOWN opposed to absolute volume level - ** volume: Should be in the range 0-127. bit7 is reseved and cannot be set - */ - bt_status_t (*set_volume)(uint8_t volume, bt_bdaddr_t *bd_addr); - bt_status_t (*get_folder_items_rsp) (btrc_folder_list_entries_t *p_param, bt_bdaddr_t *bd_addr); - - bt_status_t (*set_addressed_player_rsp) (btrc_status_t status_code, bt_bdaddr_t *bd_addr); - bt_status_t (*set_browsed_player_rsp) (btrc_set_browsed_player_rsp_t *p_param, - bt_bdaddr_t *bd_addr); - bt_status_t (*change_path_rsp) (uint8_t status_code, uint32_t item_count, - bt_bdaddr_t *bd_addr); - bt_status_t (*play_item_rsp) (uint8_t status_code, bt_bdaddr_t *bd_addr); - bt_status_t (*get_item_attr_rsp)( uint8_t num_attr, btrc_element_attr_val_t *p_attrs, - bt_bdaddr_t *bd_addr); - bt_status_t (*is_device_active_in_handoff) (bt_bdaddr_t *bd_addr); - bt_status_t (*get_total_items_rsp) (uint8_t status_code, uint32_t item_count, - uint16_t uid_counter, bt_bdaddr_t *bd_addr); - - /** Closes the interface. */ - void (*cleanup)( void ); -} btrc_interface_t; - - -typedef void (* btrc_passthrough_rsp_callback) (int id, int key_state); - -typedef void (* btrc_groupnavigation_rsp_callback) (int id, int key_state); - -typedef void (* btrc_connection_state_callback) (bool state, bt_bdaddr_t *bd_addr); - -typedef void (* btrc_ctrl_getrcfeatures_callback) (bt_bdaddr_t *bd_addr, int features); - -typedef void (* btrc_ctrl_setabsvol_cmd_callback) (bt_bdaddr_t *bd_addr, uint8_t abs_vol, uint8_t label); - -typedef void (* btrc_ctrl_registernotification_abs_vol_callback) (bt_bdaddr_t *bd_addr, uint8_t label); - -typedef void (* btrc_ctrl_setplayerapplicationsetting_rsp_callback) (bt_bdaddr_t *bd_addr, - uint8_t accepted); - -typedef void (* btrc_ctrl_playerapplicationsetting_callback)(bt_bdaddr_t *bd_addr, - uint8_t num_attr, - btrc_player_app_attr_t *app_attrs, - uint8_t num_ext_attr, - btrc_player_app_ext_attr_t *ext_attrs); - -typedef void (* btrc_ctrl_playerapplicationsetting_changed_callback)(bt_bdaddr_t *bd_addr, - btrc_player_settings_t *p_vals); - -typedef void (* btrc_ctrl_track_changed_callback)(bt_bdaddr_t *bd_addr, uint8_t num_attr, - btrc_element_attr_val_t *p_attrs); - -typedef void (* btrc_ctrl_play_position_changed_callback)(bt_bdaddr_t *bd_addr, - uint32_t song_len, uint32_t song_pos, btrc_play_status_t play_status); - -typedef void (* btrc_ctrl_play_status_changed_callback)(bt_bdaddr_t *bd_addr, - btrc_play_status_t play_status); - -/** BT-RC Controller callback structure. */ -typedef struct { - /** set to sizeof(BtRcCallbacks) */ - size_t size; - btrc_passthrough_rsp_callback passthrough_rsp_cb; - btrc_groupnavigation_rsp_callback groupnavigation_rsp_cb; - btrc_connection_state_callback connection_state_cb; - btrc_ctrl_getrcfeatures_callback getrcfeatures_cb; - btrc_ctrl_setplayerapplicationsetting_rsp_callback setplayerappsetting_rsp_cb; - btrc_ctrl_playerapplicationsetting_callback playerapplicationsetting_cb; - btrc_ctrl_playerapplicationsetting_changed_callback playerapplicationsetting_changed_cb; - btrc_ctrl_setabsvol_cmd_callback setabsvol_cmd_cb; - btrc_ctrl_registernotification_abs_vol_callback registernotification_absvol_cb; - btrc_ctrl_track_changed_callback track_changed_cb; - btrc_ctrl_play_position_changed_callback play_position_changed_cb; - btrc_ctrl_play_status_changed_callback play_status_changed_cb; -} btrc_ctrl_callbacks_t; - -/** Represents the standard BT-RC AVRCP Controller interface. */ -typedef struct { - - /** set to sizeof(BtRcInterface) */ - size_t size; - /** - * Register the BtRc callbacks - */ - bt_status_t (*init)( btrc_ctrl_callbacks_t* callbacks ); - - /** send pass through command to target */ - bt_status_t (*send_pass_through_cmd) (bt_bdaddr_t *bd_addr, uint8_t key_code, - uint8_t key_state ); - - /** send group navigation command to target */ - bt_status_t (*send_group_navigation_cmd) (bt_bdaddr_t *bd_addr, uint8_t key_code, - uint8_t key_state ); - - /** send command to set player applicaiton setting attributes to target */ - bt_status_t (*set_player_app_setting_cmd) (bt_bdaddr_t *bd_addr, uint8_t num_attrib, - uint8_t* attrib_ids, uint8_t* attrib_vals); - - /** send rsp to set_abs_vol received from target */ - bt_status_t (*set_volume_rsp) (bt_bdaddr_t *bd_addr, uint8_t abs_vol, uint8_t label); - - /** send notificaiton rsp for abs vol to target */ - bt_status_t (*register_abs_vol_rsp) (bt_bdaddr_t *bd_addr, btrc_notification_type_t rsp_type, - uint8_t abs_vol, uint8_t label); - - /** Closes the interface. */ - void (*cleanup)( void ); -} btrc_ctrl_interface_t; - -__END_DECLS - -#endif /* ANDROID_INCLUDE_BT_RC_H */ diff --git a/hardware/bt_sdp.h b/hardware/bt_sdp.h deleted file mode 100644 index 8f39bc5..0000000 --- a/hardware/bt_sdp.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "bluetooth.h" - -#define SDP_OPP_SUPPORTED_FORMATS_MAX_LENGTH 15 - -__BEGIN_DECLS - -/** - * These events are handled by the state machine - */ -typedef enum { - SDP_TYPE_RAW, // Used to carry raw SDP search data for unknown UUIDs - SDP_TYPE_MAP_MAS, // Message Access Profile - Server - SDP_TYPE_MAP_MNS, // Message Access Profile - Client (Notification Server) - SDP_TYPE_PBAP_PSE, // Phone Book Profile - Server - SDP_TYPE_PBAP_PCE, // Phone Book Profile - Client - SDP_TYPE_OPP_SERVER, // Object Push Profile - SDP_TYPE_SAP_SERVER // SIM Access Profile -} bluetooth_sdp_types; - -typedef struct _bluetooth_sdp_hdr { - bluetooth_sdp_types type; - bt_uuid_t uuid; - uint32_t service_name_length; - char *service_name; - int32_t rfcomm_channel_number; - int32_t l2cap_psm; - int32_t profile_version; -} bluetooth_sdp_hdr; - -/** - * Some signals need additional pointers, hence we introduce a - * generic way to handle these pointers. - */ -typedef struct _bluetooth_sdp_hdr_overlay { - bluetooth_sdp_types type; - bt_uuid_t uuid; - uint32_t service_name_length; - char *service_name; - int32_t rfcomm_channel_number; - int32_t l2cap_psm; - int32_t profile_version; - - // User pointers, only used for some signals - see bluetooth_sdp_ops_record - int user1_ptr_len; - uint8_t *user1_ptr; - int user2_ptr_len; - uint8_t *user2_ptr; -} bluetooth_sdp_hdr_overlay; - -typedef struct _bluetooth_sdp_mas_record { - bluetooth_sdp_hdr_overlay hdr; - uint32_t mas_instance_id; - uint32_t supported_features; - uint32_t supported_message_types; -} bluetooth_sdp_mas_record; - -typedef struct _bluetooth_sdp_mns_record { - bluetooth_sdp_hdr_overlay hdr; - uint32_t supported_features; -} bluetooth_sdp_mns_record; - -typedef struct _bluetooth_sdp_pse_record { - bluetooth_sdp_hdr_overlay hdr; - uint32_t supported_features; - uint32_t supported_repositories; -} bluetooth_sdp_pse_record; - -typedef struct _bluetooth_sdp_pce_record { - bluetooth_sdp_hdr_overlay hdr; -} bluetooth_sdp_pce_record; - -typedef struct _bluetooth_sdp_ops_record { - bluetooth_sdp_hdr_overlay hdr; - int supported_formats_list_len; - uint8_t supported_formats_list[SDP_OPP_SUPPORTED_FORMATS_MAX_LENGTH]; -} bluetooth_sdp_ops_record; - -typedef struct _bluetooth_sdp_sap_record { - bluetooth_sdp_hdr_overlay hdr; -} bluetooth_sdp_sap_record; - -typedef union { - bluetooth_sdp_hdr_overlay hdr; - bluetooth_sdp_mas_record mas; - bluetooth_sdp_mns_record mns; - bluetooth_sdp_pse_record pse; - bluetooth_sdp_pce_record pce; - bluetooth_sdp_ops_record ops; - bluetooth_sdp_sap_record sap; -} bluetooth_sdp_record; - - -/** Callback for SDP search */ -typedef void (*btsdp_search_callback)(bt_status_t status, bt_bdaddr_t *bd_addr, uint8_t* uuid, int num_records, bluetooth_sdp_record *records); - -typedef struct { - /** Set to sizeof(btsdp_callbacks_t) */ - size_t size; - btsdp_search_callback sdp_search_cb; -} btsdp_callbacks_t; - -typedef struct { - /** Set to size of this struct */ - size_t size; - - /** Register BT SDP search callbacks */ - bt_status_t (*init)(btsdp_callbacks_t *callbacks); - - /** Unregister BT SDP */ - bt_status_t (*deinit)(); - - /** Search for SDP records with specific uuid on remote device */ - bt_status_t (*sdp_search)(bt_bdaddr_t *bd_addr, const uint8_t* uuid); - - /** - * Use listen in the socket interface to create rfcomm and/or l2cap PSM channels, - * (without UUID and service_name and set the BTSOCK_FLAG_NO_SDP flag in flags). - * Then use createSdpRecord to create the SDP record associated with the rfcomm/l2cap channels. - * - * Returns a handle to the SDP record, which can be parsed to remove_sdp_record. - * - * record (in) The SDP record to create - * record_handle (out)The corresponding record handle will be written to this pointer. - */ - bt_status_t (*create_sdp_record)(bluetooth_sdp_record *record, int* record_handle); - - /** Remove a SDP record created by createSdpRecord */ - bt_status_t (*remove_sdp_record)(int sdp_handle); -} btsdp_interface_t; - -__END_DECLS - diff --git a/hardware/bt_sock.h b/hardware/bt_sock.h deleted file mode 100644 index 386dff7..0000000 --- a/hardware/bt_sock.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -__BEGIN_DECLS - -#define BTSOCK_FLAG_ENCRYPT 1 -#define BTSOCK_FLAG_AUTH (1 << 1) -#define BTSOCK_FLAG_NO_SDP (1 << 2) -#define BTSOCK_FLAG_AUTH_MITM (1 << 3) -#define BTSOCK_FLAG_AUTH_16_DIGIT (1 << 4) - -typedef enum { - BTSOCK_RFCOMM = 1, - BTSOCK_SCO = 2, - BTSOCK_L2CAP = 3 -} btsock_type_t; - -typedef enum { - BTSOCK_OPT_GET_MODEM_BITS = 1, - BTSOCK_OPT_SET_MODEM_BITS = 2, - BTSOCK_OPT_CLR_MODEM_BITS = 3, -} btsock_option_type_t; - -/** Represents the standard BT SOCKET interface. */ -typedef struct { - short size; - bt_bdaddr_t bd_addr; - int channel; - int status; - - // The writer must make writes using a buffer of this maximum size - // to avoid loosing data. (L2CAP only) - unsigned short max_tx_packet_size; - - // The reader must read using a buffer of at least this size to avoid - // loosing data. (L2CAP only) - unsigned short max_rx_packet_size; -} __attribute__((packed)) sock_connect_signal_t; - -typedef struct { - /** set to size of this struct*/ - size_t size; - - /** - * Listen to a RFCOMM UUID or channel. It returns the socket fd from which - * btsock_connect_signal can be read out when a remote device connected. - * If neither a UUID nor a channel is provided, a channel will be allocated - * and a service record can be created providing the channel number to - * create_sdp_record(...) in bt_sdp. - * The callingUid is the UID of the application which is requesting the socket. This is - * used for traffic accounting purposes. - */ - bt_status_t (*listen)(btsock_type_t type, const char* service_name, - const uint8_t* service_uuid, int channel, int* sock_fd, int flags, int callingUid); - - /** - * Connect to a RFCOMM UUID channel of remote device, It returns the socket fd from which - * the btsock_connect_signal and a new socket fd to be accepted can be read out when connected. - * The callingUid is the UID of the application which is requesting the socket. This is - * used for traffic accounting purposes. - */ - bt_status_t (*connect)(const bt_bdaddr_t *bd_addr, btsock_type_t type, const uint8_t* uuid, - int channel, int* sock_fd, int flags, int callingUid); - - /* - * get socket option of rfcomm channel socket. - */ - bt_status_t (*get_sock_opt)(btsock_type_t type, int channel, btsock_option_type_t option_name, - void *option_value, int *option_len); - /* - - * set socket option of rfcomm channel socket. - */ - bt_status_t (*set_sock_opt)(btsock_type_t type, int channel, btsock_option_type_t option_name, - void *option_value, int option_len); - -} btsock_interface_t; - -__END_DECLS - diff --git a/hardware/camera2.h b/hardware/camera2.h index 2b7add0..547a1d7 100644 --- a/hardware/camera2.h +++ b/hardware/camera2.h @@ -146,7 +146,7 @@ enum { typedef struct camera2_jpeg_blob { uint16_t jpeg_blob_id; uint32_t jpeg_size; -}; +} camera2_jpeg_blob_t; enum { CAMERA2_JPEG_BLOB_ID = 0x00FF diff --git a/hardware/camera3.h b/hardware/camera3.h index a7df0ee..c3ea0aa 100644 --- a/hardware/camera3.h +++ b/hardware/camera3.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 The Android Open Source Project + * Copyright (C) 2013-2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ #include "camera_common.h" /** - * Camera device HAL 3.4 [ CAMERA_DEVICE_API_VERSION_3_4 ] + * Camera device HAL 3.5[ CAMERA_DEVICE_API_VERSION_3_5 ] * * This is the current recommended version of the camera device HAL. * @@ -29,7 +29,7 @@ * android.hardware.camera2 API as LIMITED or above hardware level. * * Camera devices that support this version of the HAL must return - * CAMERA_DEVICE_API_VERSION_3_4 in camera_device_t.common.version and in + * CAMERA_DEVICE_API_VERSION_3_5 in camera_device_t.common.version and in * camera_info_t.device_version (from camera_module_t.get_camera_info). * * CAMERA_DEVICE_API_VERSION_3_3 and above: @@ -157,6 +157,32 @@ * - ANDROID_SENSOR_DYNAMIC_WHITE_LEVEL * - ANDROID_SENSOR_OPAQUE_RAW_SIZE * - ANDROID_SENSOR_OPTICAL_BLACK_REGIONS + * + * 3.5: Minor revisions to support session parameters and logical multi camera: + * + * - Add ANDROID_REQUEST_AVAILABLE_SESSION_KEYS static metadata, which is + * optional for implementations that want to support session parameters. If support is + * needed, then Hal should populate the list with all available capture request keys + * that can cause severe processing delays when modified by client. Typical examples + * include parameters that require time-consuming HW re-configuration or internal camera + * pipeline update. + * + * - Add a session parameter field to camera3_stream_configuration which can be populated + * by clients with initial values for the keys found in ANDROID_REQUEST_AVAILABLE_SESSION_KEYS. + * + * - Metadata additions for logical multi camera capability: + * - ANDROID_REQUEST_AVAILABLE_CAPABILITIES_LOGICAL_MULTI_CAMERA + * - ANDROID_LOGICAL_MULTI_CAMERA_PHYSICAL_IDS + * - ANDROID_LOGICAL_MULTI_CAMERA_SYNC_TYPE + * + * - Add physical camera id field in camera3_stream, so that for a logical + * multi camera, the application has the option to specify which physical camera + * a particular stream is configured on. + * + * - Add physical camera id and settings field in camera3_capture_request, so that + * for a logical multi camera, the application has the option to specify individual + * settings for a particular physical device. + * */ /** @@ -1479,6 +1505,13 @@ typedef enum camera3_stream_configuration_mode { * android.lens.opticalStabilizationMode (if it is supported) * android.scaler.cropRegion * android.statistics.faceDetectMode (if it is supported) + * 6. To reduce the amount of data passed across process boundaries at + * high frame rate, within one batch, camera framework only propagates + * the last shutter notify and the last capture results (including partial + * results and final result) to the app. The shutter notifies and capture + * results for the other requests in the batch are derived by + * the camera framework. As a result, the HAL can return empty metadata + * except for the last result in the batch. * * For more details about high speed stream requirements, see * android.control.availableHighSpeedVideoConfigurations and CONSTRAINED_HIGH_SPEED_VIDEO @@ -1597,6 +1630,13 @@ typedef struct camera3_stream { * value of this is 0. * For all streams passed via configure_streams(), the HAL must write * over this field with its usage flags. + * + * From Android O, the usage flag for an output stream may be bitwise + * combination of usage flags for multiple consumers, for the purpose of + * sharing one camera stream between those consumers. The HAL must fail + * configure_streams call with -EINVAL if the combined flags cannot be + * supported due to imcompatible buffer format, dataSpace, or other hardware + * limitations. */ uint32_t usage; @@ -1673,8 +1713,31 @@ typedef struct camera3_stream { */ int rotation; + /** + * The physical camera id this stream belongs to. + * + * <= CAMERA_DEVICE_API_VERISON_3_4: + * + * Not defined and must not be accessed. + * + * >= CAMERA_DEVICE_API_VERISON_3_5: + * + * Always set by camera service. If the camera device is not a logical + * multi camera, or if the camera is a logical multi camera but the stream + * is not a physical output stream, this field will point to a 0-length + * string. + * + * A logical multi camera is a camera device backed by multiple physical + * cameras that are also exposed to the application. And for a logical + * multi camera, a physical output stream is an output stream specifically + * requested on an underlying physical camera. + * + * For an input stream, this field is guaranteed to be a 0-length string. + */ + const char* physical_camera_id; + /* reserved for future use */ - void *reserved[7]; + void *reserved[6]; } camera3_stream_t; @@ -1720,6 +1783,18 @@ typedef struct camera3_stream_configuration { * */ uint32_t operation_mode; + + /** + * >= CAMERA_DEVICE_API_VERSION_3_5: + * + * The session metadata buffer contains the initial values of + * ANDROID_REQUEST_AVAILABLE_SESSION_KEYS. This field is optional + * and camera clients can choose to ignore it, in which case it will + * be set to NULL. If parameters are present, then Hal should examine + * the parameter values and configure its internal camera pipeline + * accordingly. + */ + const camera_metadata_t *session_parameters; } camera3_stream_configuration_t; /** @@ -2203,6 +2278,44 @@ typedef struct camera3_capture_request { */ const camera3_stream_buffer_t *output_buffers; + /** + * <= CAMERA_DEVICE_API_VERISON_3_4: + * + * Not defined and must not be accessed. + * + * >= CAMERA_DEVICE_API_VERSION_3_5: + * The number of physical camera settings to be applied. If 'num_physcam_settings' + * equals 0 or a physical device is not included, then Hal must decide the + * specific physical device settings based on the default 'settings'. + */ + uint32_t num_physcam_settings; + + /** + * <= CAMERA_DEVICE_API_VERISON_3_4: + * + * Not defined and must not be accessed. + * + * >= CAMERA_DEVICE_API_VERSION_3_5: + * The physical camera ids. The array will contain 'num_physcam_settings' + * camera id strings for all physical devices that have specific settings. + * In case some id is invalid, the process capture request must fail and return + * -EINVAL. + */ + const char **physcam_id; + + /** + * <= CAMERA_DEVICE_API_VERISON_3_4: + * + * Not defined and must not be accessed. + * + * >= CAMERA_DEVICE_API_VERSION_3_5: + * The capture settings for the physical cameras. The array will contain + * 'num_physcam_settings' settings for invididual physical devices. In + * case the settings at some particular index are empty, the process capture + * request must fail and return -EINVAL. + */ + const camera_metadata_t **physcam_settings; + } camera3_capture_request_t; /** @@ -2380,6 +2493,37 @@ typedef struct camera3_capture_result { */ uint32_t partial_result; + /** + * >= CAMERA_DEVICE_API_VERSION_3_5: + * + * Specifies the number of physical camera metadata this capture result + * contains. It must be equal to the number of physical cameras being + * requested from. + * + * If the current camera device is not a logical multi-camera, or the + * corresponding capture_request doesn't request on any physical camera, + * this field must be 0. + */ + uint32_t num_physcam_metadata; + + /** + * >= CAMERA_DEVICE_API_VERSION_3_5: + * + * An array of strings containing the physical camera ids for the returned + * physical camera metadata. The length of the array is + * num_physcam_metadata. + */ + const char **physcam_ids; + + /** + * >= CAMERA_DEVICE_API_VERSION_3_5: + * + * The array of physical camera metadata for the physical cameras being + * requested upon. This array should have a 1-to-1 mapping with the + * physcam_ids. The length of the array is num_physcam_metadata. + */ + const camera_metadata_t **physcam_metadata; + } camera3_capture_result_t; /********************************************************************** @@ -2912,7 +3056,8 @@ typedef struct camera3_device_ops { * 0: On a successful start to processing the capture request * * -EINVAL: If the input is malformed (the settings are NULL when not - * allowed, there are 0 output buffers, etc) and capture processing + * allowed, invalid physical camera settings, + * there are 0 output buffers, etc) and capture processing * cannot start. Failures during request processing should be * handled by calling camera3_callback_ops_t.notify(). In case of * this error, the framework will retain responsibility for the diff --git a/hardware/camera_common.h b/hardware/camera_common.h index c74d7bb..edd1ada 100644 --- a/hardware/camera_common.h +++ b/hardware/camera_common.h @@ -143,15 +143,16 @@ __BEGIN_DECLS #define CAMERA_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) // DEPRECATED #define CAMERA_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 0) // NO LONGER SUPPORTED #define CAMERA_DEVICE_API_VERSION_2_1 HARDWARE_DEVICE_API_VERSION(2, 1) // NO LONGER SUPPORTED -#define CAMERA_DEVICE_API_VERSION_3_0 HARDWARE_DEVICE_API_VERSION(3, 0) -#define CAMERA_DEVICE_API_VERSION_3_1 HARDWARE_DEVICE_API_VERSION(3, 1) +#define CAMERA_DEVICE_API_VERSION_3_0 HARDWARE_DEVICE_API_VERSION(3, 0) // NO LONGER SUPPORTED +#define CAMERA_DEVICE_API_VERSION_3_1 HARDWARE_DEVICE_API_VERSION(3, 1) // NO LONGER SUPPORTED #define CAMERA_DEVICE_API_VERSION_3_2 HARDWARE_DEVICE_API_VERSION(3, 2) #define CAMERA_DEVICE_API_VERSION_3_3 HARDWARE_DEVICE_API_VERSION(3, 3) #define CAMERA_DEVICE_API_VERSION_3_4 HARDWARE_DEVICE_API_VERSION(3, 4) +#define CAMERA_DEVICE_API_VERSION_3_5 HARDWARE_DEVICE_API_VERSION(3, 5) -// Device version 3.4 is current, older HAL camera device versions are not +// Device version 3.5 is current, older HAL camera device versions are not // recommended for new devices. -#define CAMERA_DEVICE_API_VERSION_CURRENT CAMERA_DEVICE_API_VERSION_3_4 +#define CAMERA_DEVICE_API_VERSION_CURRENT CAMERA_DEVICE_API_VERSION_3_5 /** * Defined in /system/media/camera/include/system/camera_metadata.h diff --git a/hardware/context_hub.h b/hardware/context_hub.h index 828f2dd..137cb3e 100644 --- a/hardware/context_hub.h +++ b/hardware/context_hub.h @@ -47,12 +47,13 @@ __BEGIN_DECLS /*****************************************************************************/ #define CONTEXT_HUB_HEADER_MAJOR_VERSION 1 -#define CONTEXT_HUB_HEADER_MINOR_VERSION 0 +#define CONTEXT_HUB_HEADER_MINOR_VERSION 1 #define CONTEXT_HUB_DEVICE_API_VERSION \ HARDWARE_DEVICE_API_VERSION(CONTEXT_HUB_HEADER_MAJOR_VERSION, \ CONTEXT_HUB_HEADER_MINOR_VERSION) #define CONTEXT_HUB_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) +#define CONTEXT_HUB_DEVICE_API_VERSION_1_1 HARDWARE_DEVICE_API_VERSION(1, 1) /** * The id of this module @@ -78,17 +79,17 @@ __BEGIN_DECLS #define NANOAPP_VENDOR_ALL_APPS 0x0000000000FFFFFFULL #define NANOAPP_VENDOR(name) \ - (((uint64_t)name[0] << 56) | \ - ((uint64_t)name[1] << 48) | \ - ((uint64_t)name[2] << 40) | \ - ((uint64_t)name[3] << 32) | \ - ((uint64_t)name[4] << 24)) + (((uint64_t)(name)[0] << 56) | \ + ((uint64_t)(name)[1] << 48) | \ + ((uint64_t)(name)[2] << 40) | \ + ((uint64_t)(name)[3] << 32) | \ + ((uint64_t)(name)[4] << 24)) /* * generates the NANOAPP ID from vendor id and app seq# id */ #define NANO_APP_ID(vendor, seq_id) \ - (((uint64_t)vendor & NANOAPP_VENDORS_ALL) | ((uint64_t)seq_id & NANOAPP_VENDOR_ALL_APPS)) + (((uint64_t)(vendor) & NANOAPP_VENDORS_ALL) | ((uint64_t)(seq_id) & NANOAPP_VENDOR_ALL_APPS)) struct hub_app_name_t { uint64_t id; @@ -131,9 +132,17 @@ struct nano_app_binary_t { uint32_t app_version; // Version of the app uint32_t flags; // Signed, encrypted uint64_t hw_hub_type; // which hub type is this compiled for - uint32_t reserved[2]; // Should be all zeroes - uint8_t custom_binary[0]; // start of custom binary data -}; + + // The version of the CHRE API that this nanoapp was compiled against. + // If these values are both set to 0, then they must be interpreted the same + // as if major version were set to 1, and minor 0 (the first valid CHRE API + // version). + uint8_t target_chre_api_major_version; + uint8_t target_chre_api_minor_version; + + uint8_t reserved[6]; // Should be all zeroes + uint8_t custom_binary[0]; // start of custom binary data +} __attribute__((packed)); struct hub_app_info { struct hub_app_name_t app_name; diff --git a/hardware/display_defs.h b/hardware/display_defs.h deleted file mode 100644 index 0ec356f..0000000 --- a/hardware/display_defs.h +++ /dev/null @@ -1,79 +0,0 @@ -/* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef ANDROID_INCLUDE_DISPLAY_DEFS_H -#define ANDROID_INCLUDE_DISPLAY_DEFS_H - -#include -#include - -#include - -__BEGIN_DECLS - -/* Will need to update below enums if hwcomposer_defs.h is updated */ - -/* Extended events for hwc_methods::eventControl() */ -enum { - HWC_EVENT_ORIENTATION = HWC_EVENT_VSYNC + 1 -}; - - -/* Extended hwc_layer_t::compositionType values */ -enum { - /* this layer will be handled in the HWC, using a blit engine */ - HWC_BLIT = 0xFF -}; - -/* Extended hwc_layer_t::flags values - * Flags are set by SurfaceFlinger and read by the HAL - */ -enum { - /* - * HWC_SCREENSHOT_ANIMATOR_LAYER is set by surfaceflinger to indicate - * that this layer is a screenshot animating layer. HWC uses this - * info to disable rotation animation on External Display - */ - HWC_SCREENSHOT_ANIMATOR_LAYER = 0x00000004 -}; - -/* This enum represents different types of 3D mode supported. This definition - * is maintained by HWC and exposed to its clients. - */ -enum { - HWC_S3DMODE_NONE = 0, - HWC_S3DMODE_LR, - HWC_S3DMODE_RL, - HWC_S3DMODE_TB, - HWC_S3DMODE_FP, - HWC_S3DMODE_MAX, -}; - -__END_DECLS - -#endif /* ANDROID_INCLUDE_DISPLAY_DEFS_H*/ diff --git a/hardware/fb.h b/hardware/fb.h index 9df9416..65720a3 100644 --- a/hardware/fb.h +++ b/hardware/fb.h @@ -160,7 +160,7 @@ typedef struct framebuffer_device_t { static inline int framebuffer_open(const struct hw_module_t* module, struct framebuffer_device_t** device) { return module->methods->open(module, - GRALLOC_HARDWARE_FB0, (struct hw_device_t**)device); + GRALLOC_HARDWARE_FB0, TO_HW_DEVICE_T_OPEN(device)); } static inline int framebuffer_close(struct framebuffer_device_t* device) { diff --git a/hardware/fingerprint.h b/hardware/fingerprint.h index 618ca7e..86ced9b 100644 --- a/hardware/fingerprint.h +++ b/hardware/fingerprint.h @@ -17,11 +17,13 @@ #ifndef ANDROID_INCLUDE_HARDWARE_FINGERPRINT_H #define ANDROID_INCLUDE_HARDWARE_FINGERPRINT_H +#include #include #define FINGERPRINT_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) #define FINGERPRINT_MODULE_API_VERSION_2_0 HARDWARE_MODULE_API_VERSION(2, 0) #define FINGERPRINT_MODULE_API_VERSION_2_1 HARDWARE_MODULE_API_VERSION(2, 1) +#define FINGERPRINT_MODULE_API_VERSION_3_0 HARDWARE_MODULE_API_VERSION(3, 0) #define FINGERPRINT_HARDWARE_MODULE_ID "fingerprint" typedef enum fingerprint_msg_type { @@ -50,6 +52,7 @@ typedef enum fingerprint_error { FINGERPRINT_ERROR_NO_SPACE = 4, /* No space available to store a template */ FINGERPRINT_ERROR_CANCELED = 5, /* The current operation can't proceed. See above. */ FINGERPRINT_ERROR_UNABLE_TO_REMOVE = 6, /* fingerprint with given id can't be removed */ + FINGERPRINT_ERROR_LOCKOUT = 7, /* the fingerprint hardware is in lockout due to too many attempts */ FINGERPRINT_ERROR_VENDOR_BASE = 1000 /* vendor-specific error messages start here */ } fingerprint_error_t; @@ -68,6 +71,8 @@ typedef enum fingerprint_acquired_info { FINGERPRINT_ACQUIRED_IMAGER_DIRTY = 3, /* sensor needs to be cleaned */ FINGERPRINT_ACQUIRED_TOO_SLOW = 4, /* mostly swipe-type sensors; not enough data collected */ FINGERPRINT_ACQUIRED_TOO_FAST = 5, /* for swipe and area sensors; tell user to slow down*/ + FINGERPRINT_ACQUIRED_DETECTED = 6, /* when the finger is first detected. Used to optimize wakeup. + Should be followed by one of the above messages */ FINGERPRINT_ACQUIRED_VENDOR_BASE = 1000 /* vendor-specific acquisition messages start here */ } fingerprint_acquired_info_t; @@ -84,14 +89,13 @@ typedef struct fingerprint_enroll { uint64_t msg; /* Vendor specific message. Used for user guidance */ } fingerprint_enroll_t; -typedef struct fingerprint_enumerated { +typedef struct fingerprint_iterator { fingerprint_finger_id_t finger; uint32_t remaining_templates; -} fingerprint_enumerated_t; +} fingerprint_iterator_t; -typedef struct fingerprint_removed { - fingerprint_finger_id_t finger; -} fingerprint_removed_t; +typedef fingerprint_iterator_t fingerprint_enumerated_t; +typedef fingerprint_iterator_t fingerprint_removed_t; typedef struct fingerprint_acquired { fingerprint_acquired_info_t acquired_info; /* information about the image */ @@ -206,12 +210,13 @@ typedef struct fingerprint_device { /* * Enumerate all the fingerprint templates found in the directory set by * set_active_group() - * For each template found notify() will be called with: + * For each template found a notify() will be called with: * fingerprint_msg.type == FINGERPRINT_TEMPLATE_ENUMERATED * fingerprint_msg.data.enumerated.finger indicating a template id * fingerprint_msg.data.enumerated.remaining_templates indicating how many more * enumeration messages to expect. - * + * Note: If there are no fingerprints, then this should return 0 and the first fingerprint + * enumerated should have fingerid=0 and remaining=0 * Function return: 0 if enumerate request is accepted * or a negative number in case of error, generally from the errno.h set. */ @@ -221,9 +226,14 @@ typedef struct fingerprint_device { * Fingerprint remove request: * Deletes a fingerprint template. * Works only within the path set by set_active_group(). - * notify() will be called with details on the template deleted. - * fingerprint_msg.type == FINGERPRINT_TEMPLATE_REMOVED and - * fingerprint_msg.data.removed.finger indicating the template id removed. + * The fid parameter can be used as a widcard: + * * fid == 0 -- delete all the templates in the group. + * * fid != 0 -- delete this specific template from the group. + * For each template found a notify() will be called with: + * fingerprint_msg.type == FINGERPRINT_TEMPLATE_REMOVED + * fingerprint_msg.data.removed.finger indicating a template id deleted + * fingerprint_msg.data.removed.remaining_templates indicating how many more + * templates will be deleted by this operation. * * Function return: 0 if fingerprint template(s) can be successfully deleted * or a negative number in case of error, generally from the errno.h set. diff --git a/hardware/fused_location.h b/hardware/fused_location.h index 73360a1..550e193 100644 --- a/hardware/fused_location.h +++ b/hardware/fused_location.h @@ -19,6 +19,7 @@ #include +#include "gnss-base.h" /** * This header file defines the interface of the Fused Location Provider. @@ -102,16 +103,6 @@ __BEGIN_DECLS */ #define FLP_STATUS_LOCATION_UNAVAILABLE 1 -/** - * This constant is used with the batched locations - * APIs. Batching is mandatory when FLP implementation - * is supported. If the flag is set, the hardware implementation - * will wake up the application processor when the FIFO is full, - * If the flag is not set, the hardware implementation will drop - * the oldest data when the FIFO is full. - */ -#define FLP_BATCH_WAKEUP_ON_FIFO_FULL 0x0000001 - /** * While batching, the implementation should not call the * flp_location_callback on every location fix. However, diff --git a/hardware/gnss-base.h b/hardware/gnss-base.h new file mode 100644 index 0000000..e56020d --- /dev/null +++ b/hardware/gnss-base.h @@ -0,0 +1,275 @@ +// This file is autogenerated by hidl-gen. Do not edit manually. +// Source: android.hardware.gnss@1.0 +// Root: android.hardware:hardware/interfaces + +#ifndef HIDL_GENERATED_ANDROID_HARDWARE_GNSS_V1_0_EXPORTED_CONSTANTS_H_ +#define HIDL_GENERATED_ANDROID_HARDWARE_GNSS_V1_0_EXPORTED_CONSTANTS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + GNSS_MAX_SVS_COUNT = 64u, // 64 +}; + +enum { + GNSS_CONSTELLATION_UNKNOWN = 0, + GNSS_CONSTELLATION_GPS = 1, + GNSS_CONSTELLATION_SBAS = 2, + GNSS_CONSTELLATION_GLONASS = 3, + GNSS_CONSTELLATION_QZSS = 4, + GNSS_CONSTELLATION_BEIDOU = 5, + GNSS_CONSTELLATION_GALILEO = 6, +}; + +enum { + GPS_LOCATION_HAS_LAT_LONG = 1, // 0x0001 + GPS_LOCATION_HAS_ALTITUDE = 2, // 0x0002 + GPS_LOCATION_HAS_SPEED = 4, // 0x0004 + GPS_LOCATION_HAS_BEARING = 8, // 0x0008 + GPS_LOCATION_HAS_HORIZONTAL_ACCURACY = 16, // 0x0010 + GPS_LOCATION_HAS_VERTICAL_ACCURACY = 32, // 0x0020 + GPS_LOCATION_HAS_SPEED_ACCURACY = 64, // 0x0040 + GPS_LOCATION_HAS_BEARING_ACCURACY = 128, // 0x0080 +}; + +enum { + APN_IP_INVALID = 0, + APN_IP_IPV4 = 1, + APN_IP_IPV6 = 2, + APN_IP_IPV4V6 = 3, +}; + +enum { + AGPS_TYPE_SUPL = 1, + AGPS_TYPE_C2K = 2, +}; + +enum { + GNSS_REQUEST_AGNSS_DATA_CONN = 1, + GNSS_RELEASE_AGNSS_DATA_CONN = 2, + GNSS_AGNSS_DATA_CONNECTED = 3, + GNSS_AGNSS_DATA_CONN_DONE = 4, + GNSS_AGNSS_DATA_CONN_FAILED = 5, +}; + +enum { + AGPS_SETID_TYPE_NONE = 0, + AGPS_SETID_TYPE_IMSI = 1, + AGPS_SETID_TYPE_MSISDM = 2, +}; + +enum { + AGPS_RIL_NETWORK_TYPE_MOBILE = 0, + AGPS_RIL_NETWORK_TYPE_WIFI = 1, + AGPS_RIL_NETWORK_TYPE_MMS = 2, + AGPS_RIL_NETWORK_TYPE_SUPL = 3, + AGPS_RIL_NETWORK_TYPE_DUN = 4, + AGPS_RIL_NETWORK_TYPE_HIPRI = 5, + AGPS_RIL_NETWORK_TYPE_WIMAX = 6, +}; + +enum { + AGPS_REF_LOCATION_TYPE_GSM_CELLID = 1, + AGPS_REF_LOCATION_TYPE_UMTS_CELLID = 2, + AGPS_REF_LOCATION_TYPE_LTE_CELLID = 4, +}; + +enum { + AGPS_RIL_REQUEST_SETID_IMSI = 1u, // (1 << 0L) + AGPS_RIL_REQUEST_SETID_MSISDN = 2u, // (1 << 1L) +}; + +enum { + GPS_POSITION_MODE_STANDALONE = 0, + GPS_POSITION_MODE_MS_BASED = 1, + GPS_POSITION_MODE_MS_ASSISTED = 2, +}; + +enum { + GPS_POSITION_RECURRENCE_PERIODIC = 0u, // 0 + GPS_POSITION_RECURRENCE_SINGLE = 1u, // 1 +}; + +enum { + GPS_DELETE_EPHEMERIS = 1, // 0x0001 + GPS_DELETE_ALMANAC = 2, // 0x0002 + GPS_DELETE_POSITION = 4, // 0x0004 + GPS_DELETE_TIME = 8, // 0x0008 + GPS_DELETE_IONO = 16, // 0x0010 + GPS_DELETE_UTC = 32, // 0x0020 + GPS_DELETE_HEALTH = 64, // 0x0040 + GPS_DELETE_SVDIR = 128, // 0x0080 + GPS_DELETE_SVSTEER = 256, // 0x0100 + GPS_DELETE_SADATA = 512, // 0x0200 + GPS_DELETE_RTI = 1024, // 0x0400 + GPS_DELETE_CELLDB_INFO = 32768, // 0x8000 + GPS_DELETE_ALL = 65535, // 0xFFFF +}; + +enum { + FLP_BATCH_WAKEUP_ON_FIFO_FULL = 1, // 0x01 +}; + +enum { + GPS_CAPABILITY_SCHEDULING = 1u, // (1 << 0) + GPS_CAPABILITY_MSB = 2u, // (1 << 1) + GPS_CAPABILITY_MSA = 4u, // (1 << 2) + GPS_CAPABILITY_SINGLE_SHOT = 8u, // (1 << 3) + GPS_CAPABILITY_ON_DEMAND_TIME = 16u, // (1 << 4) + GPS_CAPABILITY_GEOFENCING = 32u, // (1 << 5) + GPS_CAPABILITY_MEASUREMENTS = 64u, // (1 << 6) + GPS_CAPABILITY_NAV_MESSAGES = 128u, // (1 << 7) +}; + +enum { + GPS_STATUS_NONE = 0, + GPS_STATUS_SESSION_BEGIN = 1, + GPS_STATUS_SESSION_END = 2, + GPS_STATUS_ENGINE_ON = 3, + GPS_STATUS_ENGINE_OFF = 4, +}; + +enum { + GNSS_SV_FLAGS_NONE = 0, + GNSS_SV_FLAGS_HAS_EPHEMERIS_DATA = 1, // (1 << 0) + GNSS_SV_FLAGS_HAS_ALMANAC_DATA = 2, // (1 << 1) + GNSS_SV_FLAGS_USED_IN_FIX = 4, // (1 << 2) + GNSS_SV_FLAGS_HAS_CARRIER_FREQUENCY = 8, // (1 << 3) +}; + +enum { + GPS_GEOFENCE_ENTERED = 1, // (1 << 0L) + GPS_GEOFENCE_EXITED = 2, // (1 << 1L) + GPS_GEOFENCE_UNCERTAIN = 4, // (1 << 2L) +}; + +enum { + GPS_GEOFENCE_UNAVAILABLE = 1, // (1 << 0L) + GPS_GEOFENCE_AVAILABLE = 2, // (1 << 1L) +}; + +enum { + GPS_GEOFENCE_OPERATION_SUCCESS = 0, + GPS_GEOFENCE_ERROR_TOO_MANY_GEOFENCES = -100, // (-100) + GPS_GEOFENCE_ERROR_ID_EXISTS = -101, // (-101) + GPS_GEOFENCE_ERROR_ID_UNKNOWN = -102, // (-102) + GPS_GEOFENCE_ERROR_INVALID_TRANSITION = -103, // (-103) + GPS_GEOFENCE_ERROR_GENERIC = -149, // (-149) +}; + +enum { + GPS_MEASUREMENT_SUCCESS = 0, + GPS_MEASUREMENT_ERROR_ALREADY_INIT = -100, // (-100) + GPS_MEASUREMENT_ERROR_GENERIC = -101, // (-101) +}; + +enum { + GNSS_CLOCK_HAS_LEAP_SECOND = 1, // (1 << 0) + GNSS_CLOCK_HAS_TIME_UNCERTAINTY = 2, // (1 << 1) + GNSS_CLOCK_HAS_FULL_BIAS = 4, // (1 << 2) + GNSS_CLOCK_HAS_BIAS = 8, // (1 << 3) + GNSS_CLOCK_HAS_BIAS_UNCERTAINTY = 16, // (1 << 4) + GNSS_CLOCK_HAS_DRIFT = 32, // (1 << 5) + GNSS_CLOCK_HAS_DRIFT_UNCERTAINTY = 64, // (1 << 6) +}; + +enum { + GNSS_MEASUREMENT_HAS_SNR = 1u, // (1 << 0) + GNSS_MEASUREMENT_HAS_CARRIER_FREQUENCY = 512u, // (1 << 9) + GNSS_MEASUREMENT_HAS_CARRIER_CYCLES = 1024u, // (1 << 10) + GNSS_MEASUREMENT_HAS_CARRIER_PHASE = 2048u, // (1 << 11) + GNSS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY = 4096u, // (1 << 12) + GNSS_MEASUREMENT_HAS_AUTOMATIC_GAIN_CONTROL = 8192u, // (1 << 13) +}; + +enum { + GNSS_MULTIPATH_INDICATOR_UNKNOWN = 0, + GNSS_MULTIPATH_INDICATOR_PRESENT = 1, + GNSS_MULTIPATH_INDICATIOR_NOT_PRESENT = 2, +}; + +enum { + GNSS_MEASUREMENT_STATE_UNKNOWN = 0u, // 0 + GNSS_MEASUREMENT_STATE_CODE_LOCK = 1u, // (1 << 0) + GNSS_MEASUREMENT_STATE_BIT_SYNC = 2u, // (1 << 1) + GNSS_MEASUREMENT_STATE_SUBFRAME_SYNC = 4u, // (1 << 2) + GNSS_MEASUREMENT_STATE_TOW_DECODED = 8u, // (1 << 3) + GNSS_MEASUREMENT_STATE_MSEC_AMBIGUOUS = 16u, // (1 << 4) + GNSS_MEASUREMENT_STATE_SYMBOL_SYNC = 32u, // (1 << 5) + GNSS_MEASUREMENT_STATE_GLO_STRING_SYNC = 64u, // (1 << 6) + GNSS_MEASUREMENT_STATE_GLO_TOD_DECODED = 128u, // (1 << 7) + GNSS_MEASUREMENT_STATE_BDS_D2_BIT_SYNC = 256u, // (1 << 8) + GNSS_MEASUREMENT_STATE_BDS_D2_SUBFRAME_SYNC = 512u, // (1 << 9) + GNSS_MEASUREMENT_STATE_GAL_E1BC_CODE_LOCK = 1024u, // (1 << 10) + GNSS_MEASUREMENT_STATE_GAL_E1C_2ND_CODE_LOCK = 2048u, // (1 << 11) + GNSS_MEASUREMENT_STATE_GAL_E1B_PAGE_SYNC = 4096u, // (1 << 12) + GNSS_MEASUREMENT_STATE_SBAS_SYNC = 8192u, // (1 << 13) + GNSS_MEASUREMENT_STATE_TOW_KNOWN = 16384u, // (1 << 14) + GNSS_MEASUREMENT_STATE_GLO_TOD_KNOWN = 32768u, // (1 << 15) +}; + +enum { + GNSS_ADR_STATE_UNKNOWN = 0, + GNSS_ADR_STATE_VALID = 1, // (1 << 0) + GNSS_ADR_STATE_RESET = 2, // (1 << 1) + GNSS_ADR_STATE_CYCLE_SLIP = 4, // (1 << 2) +}; + +enum { + GPS_NAVIGATION_MESSAGE_SUCCESS = 0, + GPS_NAVIGATION_MESSAGE_ERROR_ALREADY_INIT = -100, // (-100) + GPS_NAVIGATION_MESSAGE_ERROR_GENERIC = -101, // (-101) +}; + +enum { + GNSS_NAVIGATION_MESSAGE_TYPE_UNKNOWN = 0, + GNSS_NAVIGATION_MESSAGE_TYPE_GNSS_L1CA = 257, // 0x0101 + GNSS_NAVIGATION_MESSAGE_TYPE_GNSS_L2CNAV = 258, // 0x0102 + GNSS_NAVIGATION_MESSAGE_TYPE_GNSS_L5CNAV = 259, // 0x0103 + GNSS_NAVIGATION_MESSAGE_TYPE_GNSS_CNAV2 = 260, // 0x0104 + GNSS_NAVIGATION_MESSAGE_TYPE_GLO_L1CA = 769, // 0x0301 + GNSS_NAVIGATION_MESSAGE_TYPE_BDS_D1 = 1281, // 0x0501 + GNSS_NAVIGATION_MESSAGE_TYPE_BDS_D2 = 1282, // 0x0502 + GNSS_NAVIGATION_MESSAGE_TYPE_GAL_I = 1537, // 0x0601 + GNSS_NAVIGATION_MESSAGE_TYPE_GAL_F = 1538, // 0x0602 +}; + +typedef enum { + NAV_MESSAGE_STATUS_PARITY_PASSED = 1, // (1 << 0) + NAV_MESSAGE_STATUS_PARITY_REBUILT = 2, // (1 << 1) + NAV_MESSAGE_STATUS_UNKNOWN = 0, +} navigation_message_status; + +enum { + GPS_NI_TYPE_VOICE = 1, + GPS_NI_TYPE_UMTS_SUPL = 2, + GPS_NI_TYPE_UMTS_CTRL_PLANE = 3, +}; + +enum { + GPS_NI_NEED_NOTIFY = 1u, // 0x0001 + GPS_NI_NEED_VERIFY = 2u, // 0x0002 + GPS_NI_PRIVACY_OVERRIDE = 4u, // 0x0004 +}; + +enum { + GPS_NI_RESPONSE_ACCEPT = 1, + GPS_NI_RESPONSE_DENY = 2, + GPS_NI_RESPONSE_NORESP = 3, +}; + +enum { + GPS_ENC_NONE = 0, + GPS_ENC_SUPL_GSM_DEFAULT = 1, + GPS_ENC_SUPL_UTF8 = 2, + GPS_ENC_SUPL_UCS2 = 3, + GPS_ENC_UNKNOWN = -1, // (-1) +}; + +#ifdef __cplusplus +} +#endif + +#endif // HIDL_GENERATED_ANDROID_HARDWARE_GNSS_V1_0_EXPORTED_CONSTANTS_H_ diff --git a/hardware/gps.h b/hardware/gps.h index acf601b..4e108b3 100644 --- a/hardware/gps.h +++ b/hardware/gps.h @@ -26,8 +26,42 @@ #include +#include "gnss-base.h" + __BEGIN_DECLS +/* + * Enums defined in HIDL in hardware/interfaces are auto-generated and present + * in gnss-base.h. + */ + +/* for compatibility */ + +/** Maximum number of SVs for gps_sv_status_callback(). */ +#define GNSS_MAX_SVS GNSS_MAX_SVS_COUNT +/** Maximum number of Measurements in gnss_measurement_callback(). */ +#define GNSS_MAX_MEASUREMENT GNSS_MAX_SVS_COUNT + +#define GPS_REQUEST_AGPS_DATA_CONN GNSS_REQUEST_AGNSS_DATA_CONN +#define GPS_RELEASE_AGPS_DATA_CONN GNSS_RELEASE_AGNSS_DATA_CONN +#define GPS_AGPS_DATA_CONNECTED GNSS_AGNSS_DATA_CONNECTED +#define GPS_AGPS_DATA_CONN_DONE GNSS_AGNSS_DATA_CONN_DONE +#define GPS_AGPS_DATA_CONN_FAILED GNSS_AGNSS_DATA_CONN_FAILED +#define AGPS_RIL_NETWORK_TYPE_MOBILE_MMS AGPS_RIL_NETWORK_TYPE_MMS +#define AGPS_RIL_NETWORK_TYPE_MOBILE_SUPL AGPS_RIL_NETWORK_TYPE_SUPL +#define AGPS_RIL_NETWORK_TTYPE_MOBILE_DUN AGPS_RIL_NETWORK_TYPE_DUN +#define AGPS_RIL_NETWORK_TTYPE_MOBILE_HIPRI AGPS_RIL_NETWORK_TYPE_HIPRI +#define AGPS_RIL_NETWORK_TTYPE_WIMAX AGPS_RIL_NETWORK_TYPE_WIMAX +#define GNSS_MULTIPATH_INDICATOR_NOT_PRESENT GNSS_MULTIPATH_INDICATIOR_NOT_PRESENT +#define AGPS_SETID_TYPE_MSISDN AGPS_SETID_TYPE_MSISDM +#define GPS_MEASUREMENT_OPERATION_SUCCESS GPS_MEASUREMENT_SUCCESS +#define GPS_NAVIGATION_MESSAGE_OPERATION_SUCCESS GPS_NAVIGATION_MESSAGE_SUCCESS +#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L1CA GNSS_NAVIGATION_MESSAGE_TYPE_GNSS_L1CA +#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L2CNAV GNSS_NAVIGATION_MESSAGE_TYPE_GNSS_L2CNAV +#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L5CNAV GNSS_NAVIGATION_MESSAGE_TYPE_GNSS_L5CNAV +#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_CNAV2 GNSS_NAVIGATION_MESSAGE_TYPE_GNSS_CNAV2 +#define GPS_LOCATION_HAS_ACCURACY GPS_LOCATION_HAS_HORIZONTAL_ACCURACY + /** * The id of this module */ @@ -39,127 +73,34 @@ typedef int64_t GpsUtcTime; /** Maximum number of SVs for gps_sv_status_callback(). */ #define GPS_MAX_SVS 32 -/** Maximum number of SVs for gps_sv_status_callback(). */ -#define GNSS_MAX_SVS 64 /** Maximum number of Measurements in gps_measurement_callback(). */ #define GPS_MAX_MEASUREMENT 32 -/** Maximum number of Measurements in gnss_measurement_callback(). */ -#define GNSS_MAX_MEASUREMENT 64 - /** Requested operational mode for GPS operation. */ typedef uint32_t GpsPositionMode; -/* IMPORTANT: Note that the following values must match - * constants in GpsLocationProvider.java. */ -/** Mode for running GPS standalone (no assistance). */ -#define GPS_POSITION_MODE_STANDALONE 0 -/** AGPS MS-Based mode. */ -#define GPS_POSITION_MODE_MS_BASED 1 -/** - * AGPS MS-Assisted mode. This mode is not maintained by the platform anymore. - * It is strongly recommended to use GPS_POSITION_MODE_MS_BASED instead. - */ -#define GPS_POSITION_MODE_MS_ASSISTED 2 /** Requested recurrence mode for GPS operation. */ typedef uint32_t GpsPositionRecurrence; -/* IMPORTANT: Note that the following values must match - * constants in GpsLocationProvider.java. */ -/** Receive GPS fixes on a recurring basis at a specified period. */ -#define GPS_POSITION_RECURRENCE_PERIODIC 0 -/** Request a single shot GPS fix. */ -#define GPS_POSITION_RECURRENCE_SINGLE 1 /** GPS status event values. */ typedef uint16_t GpsStatusValue; -/* IMPORTANT: Note that the following values must match - * constants in GpsLocationProvider.java. */ -/** GPS status unknown. */ -#define GPS_STATUS_NONE 0 -/** GPS has begun navigating. */ -#define GPS_STATUS_SESSION_BEGIN 1 -/** GPS has stopped navigating. */ -#define GPS_STATUS_SESSION_END 2 -/** GPS has powered on but is not navigating. */ -#define GPS_STATUS_ENGINE_ON 3 -/** GPS is powered off. */ -#define GPS_STATUS_ENGINE_OFF 4 /** Flags to indicate which values are valid in a GpsLocation. */ typedef uint16_t GpsLocationFlags; -/* IMPORTANT: Note that the following values must match - * constants in GpsLocationProvider.java. */ -/** GpsLocation has valid latitude and longitude. */ -#define GPS_LOCATION_HAS_LAT_LONG 0x0001 -/** GpsLocation has valid altitude. */ -#define GPS_LOCATION_HAS_ALTITUDE 0x0002 -/** GpsLocation has valid speed. */ -#define GPS_LOCATION_HAS_SPEED 0x0004 -/** GpsLocation has valid bearing. */ -#define GPS_LOCATION_HAS_BEARING 0x0008 -/** GpsLocation has valid accuracy. */ -#define GPS_LOCATION_HAS_ACCURACY 0x0010 - -/** Flags for the gps_set_capabilities callback. */ - -/** - * GPS HAL schedules fixes for GPS_POSITION_RECURRENCE_PERIODIC mode. If this is - * not set, then the framework will use 1000ms for min_interval and will start - * and call start() and stop() to schedule the GPS. - */ -#define GPS_CAPABILITY_SCHEDULING (1 << 0) -/** GPS supports MS-Based AGPS mode */ -#define GPS_CAPABILITY_MSB (1 << 1) -/** GPS supports MS-Assisted AGPS mode */ -#define GPS_CAPABILITY_MSA (1 << 2) -/** GPS supports single-shot fixes */ -#define GPS_CAPABILITY_SINGLE_SHOT (1 << 3) -/** GPS supports on demand time injection */ -#define GPS_CAPABILITY_ON_DEMAND_TIME (1 << 4) -/** GPS supports Geofencing */ -#define GPS_CAPABILITY_GEOFENCING (1 << 5) -/** GPS supports Measurements. */ -#define GPS_CAPABILITY_MEASUREMENTS (1 << 6) -/** GPS supports Navigation Messages */ -#define GPS_CAPABILITY_NAV_MESSAGES (1 << 7) /** * Flags used to specify which aiding data to delete when calling * delete_aiding_data(). */ typedef uint16_t GpsAidingData; -/* IMPORTANT: Note that the following values must match - * constants in GpsLocationProvider.java. */ -#define GPS_DELETE_EPHEMERIS 0x0001 -#define GPS_DELETE_ALMANAC 0x0002 -#define GPS_DELETE_POSITION 0x0004 -#define GPS_DELETE_TIME 0x0008 -#define GPS_DELETE_IONO 0x0010 -#define GPS_DELETE_UTC 0x0020 -#define GPS_DELETE_HEALTH 0x0040 -#define GPS_DELETE_SVDIR 0x0080 -#define GPS_DELETE_SVSTEER 0x0100 -#define GPS_DELETE_SADATA 0x0200 -#define GPS_DELETE_RTI 0x0400 -#define GPS_DELETE_CELLDB_INFO 0x8000 -#define GPS_DELETE_ALL 0xFFFF /** AGPS type */ typedef uint16_t AGpsType; -#define AGPS_TYPE_SUPL 1 -#define AGPS_TYPE_C2K 2 typedef uint16_t AGpsSetIDType; -#define AGPS_SETID_TYPE_NONE 0 -#define AGPS_SETID_TYPE_IMSI 1 -#define AGPS_SETID_TYPE_MSISDN 2 typedef uint16_t ApnIpType; -#define APN_IP_INVALID 0 -#define APN_IP_IPV4 1 -#define APN_IP_IPV6 2 -#define APN_IP_IPV4V6 3 /** * String length constants @@ -171,71 +112,31 @@ typedef uint16_t ApnIpType; * GpsNiType constants */ typedef uint32_t GpsNiType; -#define GPS_NI_TYPE_VOICE 1 -#define GPS_NI_TYPE_UMTS_SUPL 2 -#define GPS_NI_TYPE_UMTS_CTRL_PLANE 3 /** * GpsNiNotifyFlags constants */ typedef uint32_t GpsNiNotifyFlags; -/** NI requires notification */ -#define GPS_NI_NEED_NOTIFY 0x0001 -/** NI requires verification */ -#define GPS_NI_NEED_VERIFY 0x0002 -/** NI requires privacy override, no notification/minimal trace */ -#define GPS_NI_PRIVACY_OVERRIDE 0x0004 /** * GPS NI responses, used to define the response in * NI structures */ typedef int GpsUserResponseType; -#define GPS_NI_RESPONSE_ACCEPT 1 -#define GPS_NI_RESPONSE_DENY 2 -#define GPS_NI_RESPONSE_NORESP 3 /** * NI data encoding scheme */ typedef int GpsNiEncodingType; -#define GPS_ENC_NONE 0 -#define GPS_ENC_SUPL_GSM_DEFAULT 1 -#define GPS_ENC_SUPL_UTF8 2 -#define GPS_ENC_SUPL_UCS2 3 -#define GPS_ENC_UNKNOWN -1 /** AGPS status event values. */ typedef uint16_t AGpsStatusValue; -/** GPS requests data connection for AGPS. */ -#define GPS_REQUEST_AGPS_DATA_CONN 1 -/** GPS releases the AGPS data connection. */ -#define GPS_RELEASE_AGPS_DATA_CONN 2 -/** AGPS data connection initiated */ -#define GPS_AGPS_DATA_CONNECTED 3 -/** AGPS data connection completed */ -#define GPS_AGPS_DATA_CONN_DONE 4 -/** AGPS data connection failed */ -#define GPS_AGPS_DATA_CONN_FAILED 5 typedef uint16_t AGpsRefLocationType; -#define AGPS_REF_LOCATION_TYPE_GSM_CELLID 1 -#define AGPS_REF_LOCATION_TYPE_UMTS_CELLID 2 -#define AGPS_REF_LOCATION_TYPE_MAC 3 -#define AGPS_REF_LOCATION_TYPE_LTE_CELLID 4 /* Deprecated, to be removed in the next Android release. */ #define AGPS_REG_LOCATION_TYPE_MAC 3 -/** Network types for update_network_state "type" parameter */ -#define AGPS_RIL_NETWORK_TYPE_MOBILE 0 -#define AGPS_RIL_NETWORK_TYPE_WIFI 1 -#define AGPS_RIL_NETWORK_TYPE_MOBILE_MMS 2 -#define AGPS_RIL_NETWORK_TYPE_MOBILE_SUPL 3 -#define AGPS_RIL_NETWORK_TTYPE_MOBILE_DUN 4 -#define AGPS_RIL_NETWORK_TTYPE_MOBILE_HIPRI 5 -#define AGPS_RIL_NETWORK_TTYPE_WIMAX 6 - /* The following typedef together with its constants below are deprecated, and * will be removed in the next release. */ typedef uint16_t GpsClockFlags; @@ -251,20 +152,6 @@ typedef uint16_t GpsClockFlags; * Flags to indicate what fields in GnssClock are valid. */ typedef uint16_t GnssClockFlags; -/** A valid 'leap second' is stored in the data structure. */ -#define GNSS_CLOCK_HAS_LEAP_SECOND (1<<0) -/** A valid 'time uncertainty' is stored in the data structure. */ -#define GNSS_CLOCK_HAS_TIME_UNCERTAINTY (1<<1) -/** A valid 'full bias' is stored in the data structure. */ -#define GNSS_CLOCK_HAS_FULL_BIAS (1<<2) -/** A valid 'bias' is stored in the data structure. */ -#define GNSS_CLOCK_HAS_BIAS (1<<3) -/** A valid 'bias uncertainty' is stored in the data structure. */ -#define GNSS_CLOCK_HAS_BIAS_UNCERTAINTY (1<<4) -/** A valid 'drift' is stored in the data structure. */ -#define GNSS_CLOCK_HAS_DRIFT (1<<5) -/** A valid 'drift uncertainty' is stored in the data structure. */ -#define GNSS_CLOCK_HAS_DRIFT_UNCERTAINTY (1<<6) /* The following typedef together with its constants below are deprecated, and * will be removed in the next release. */ @@ -300,16 +187,6 @@ typedef uint32_t GpsMeasurementFlags; * Flags to indicate what fields in GnssMeasurement are valid. */ typedef uint32_t GnssMeasurementFlags; -/** A valid 'snr' is stored in the data structure. */ -#define GNSS_MEASUREMENT_HAS_SNR (1<<0) -/** A valid 'carrier frequency' is stored in the data structure. */ -#define GNSS_MEASUREMENT_HAS_CARRIER_FREQUENCY (1<<9) -/** A valid 'carrier cycles' is stored in the data structure. */ -#define GNSS_MEASUREMENT_HAS_CARRIER_CYCLES (1<<10) -/** A valid 'carrier phase' is stored in the data structure. */ -#define GNSS_MEASUREMENT_HAS_CARRIER_PHASE (1<<11) -/** A valid 'carrier phase uncertainty' is stored in the data structure. */ -#define GNSS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY (1<<12) /* The following typedef together with its constants below are deprecated, and * will be removed in the next release. */ @@ -331,12 +208,6 @@ typedef uint8_t GpsMultipathIndicator; * indicator. */ typedef uint8_t GnssMultipathIndicator; -/** The indicator is not available or unknown. */ -#define GNSS_MULTIPATH_INDICATOR_UNKNOWN 0 -/** The measurement is indicated to be affected by multipath. */ -#define GNSS_MULTIPATH_INDICATOR_PRESENT 1 -/** The measurement is indicated to be not affected by multipath. */ -#define GNSS_MULTIPATH_INDICATOR_NOT_PRESENT 2 /* The following typedef together with its constants below are deprecated, and * will be removed in the next release. */ @@ -363,21 +234,6 @@ typedef uint16_t GpsMeasurementState; * set to GNSS_MEASUREMENT_STATE_UNKNOWN(0). */ typedef uint32_t GnssMeasurementState; -#define GNSS_MEASUREMENT_STATE_UNKNOWN 0 -#define GNSS_MEASUREMENT_STATE_CODE_LOCK (1<<0) -#define GNSS_MEASUREMENT_STATE_BIT_SYNC (1<<1) -#define GNSS_MEASUREMENT_STATE_SUBFRAME_SYNC (1<<2) -#define GNSS_MEASUREMENT_STATE_TOW_DECODED (1<<3) -#define GNSS_MEASUREMENT_STATE_MSEC_AMBIGUOUS (1<<4) -#define GNSS_MEASUREMENT_STATE_SYMBOL_SYNC (1<<5) -#define GNSS_MEASUREMENT_STATE_GLO_STRING_SYNC (1<<6) -#define GNSS_MEASUREMENT_STATE_GLO_TOD_DECODED (1<<7) -#define GNSS_MEASUREMENT_STATE_BDS_D2_BIT_SYNC (1<<8) -#define GNSS_MEASUREMENT_STATE_BDS_D2_SUBFRAME_SYNC (1<<9) -#define GNSS_MEASUREMENT_STATE_GAL_E1BC_CODE_LOCK (1<<10) -#define GNSS_MEASUREMENT_STATE_GAL_E1C_2ND_CODE_LOCK (1<<11) -#define GNSS_MEASUREMENT_STATE_GAL_E1B_PAGE_SYNC (1<<12) -#define GNSS_MEASUREMENT_STATE_SBAS_SYNC (1<<13) /* The following typedef together with its constants below are deprecated, and * will be removed in the next release. */ @@ -391,10 +247,6 @@ typedef uint16_t GpsAccumulatedDeltaRangeState; * Flags indicating the Accumulated Delta Range's states. */ typedef uint16_t GnssAccumulatedDeltaRangeState; -#define GNSS_ADR_STATE_UNKNOWN 0 -#define GNSS_ADR_STATE_VALID (1<<0) -#define GNSS_ADR_STATE_RESET (1<<1) -#define GNSS_ADR_STATE_CYCLE_SLIP (1<<2) /* The following typedef together with its constants below are deprecated, and * will be removed in the next release. */ @@ -414,26 +266,6 @@ typedef uint8_t GpsNavigationMessageType; */ typedef int16_t GnssNavigationMessageType; -#define GNSS_NAVIGATION_MESSAGE_TYPE_UNKNOWN 0 -/** GPS L1 C/A message contained in the structure. */ -#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L1CA 0x0101 -/** GPS L2-CNAV message contained in the structure. */ -#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L2CNAV 0x0102 -/** GPS L5-CNAV message contained in the structure. */ -#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L5CNAV 0x0103 -/** GPS CNAV-2 message contained in the structure. */ -#define GNSS_NAVIGATION_MESSAGE_TYPE_GPS_CNAV2 0x0104 -/** Glonass L1 CA message contained in the structure. */ -#define GNSS_NAVIGATION_MESSAGE_TYPE_GLO_L1CA 0x0301 -/** Beidou D1 message contained in the structure. */ -#define GNSS_NAVIGATION_MESSAGE_TYPE_BDS_D1 0x0501 -/** Beidou D2 message contained in the structure. */ -#define GNSS_NAVIGATION_MESSAGE_TYPE_BDS_D2 0x0502 -/** Galileo I/NAV message contained in the structure. */ -#define GNSS_NAVIGATION_MESSAGE_TYPE_GAL_I 0x0601 -/** Galileo F/NAV message contained in the structure. */ -#define GNSS_NAVIGATION_MESSAGE_TYPE_GAL_F 0x0602 - /** * Status of Navigation Message * When a message is received properly without any parity error in its navigation words, the @@ -444,9 +276,6 @@ typedef int16_t GnssNavigationMessageType; * corrected. */ typedef uint16_t NavigationMessageStatus; -#define NAV_MESSAGE_STATUS_UNKNOWN 0 -#define NAV_MESSAGE_STATUS_PARITY_PASSED (1<<0) -#define NAV_MESSAGE_STATUS_PARITY_REBUILT (1<<1) /* This constant is deprecated, and will be removed in the next release. */ #define NAV_MESSAGE_STATUS_UNKONW 0 @@ -455,22 +284,11 @@ typedef uint16_t NavigationMessageStatus; * Flags that indicate information about the satellite */ typedef uint8_t GnssSvFlags; -#define GNSS_SV_FLAGS_NONE 0 -#define GNSS_SV_FLAGS_HAS_EPHEMERIS_DATA (1 << 0) -#define GNSS_SV_FLAGS_HAS_ALMANAC_DATA (1 << 1) -#define GNSS_SV_FLAGS_USED_IN_FIX (1 << 2) /** * Constellation type of GnssSvInfo */ typedef uint8_t GnssConstellationType; -#define GNSS_CONSTELLATION_UNKNOWN 0 -#define GNSS_CONSTELLATION_GPS 1 -#define GNSS_CONSTELLATION_SBAS 2 -#define GNSS_CONSTELLATION_GLONASS 3 -#define GNSS_CONSTELLATION_QZSS 4 -#define GNSS_CONSTELLATION_BEIDOU 5 -#define GNSS_CONSTELLATION_GALILEO 6 /** * Name for the GPS XTRA interface. @@ -522,7 +340,6 @@ typedef uint8_t GnssConstellationType; */ #define GNSS_CONFIGURATION_INTERFACE "gnss_configuration" - /** Represents a location. */ typedef struct { /** set to sizeof(GpsLocation) */ @@ -1126,9 +943,6 @@ struct gps_device_t { const GpsInterface* (*get_gps_interface)(struct gps_device_t* dev); }; -#define AGPS_RIL_REQUEST_SETID_IMSI (1<<0L) -#define AGPS_RIL_REQUEST_SETID_MSISDN (1<<1L) - #define AGPS_RIL_REQUEST_REFLOC_CELLID (1<<0L) #define AGPS_RIL_REQUEST_REFLOC_MAC (1<<1L) @@ -1251,19 +1065,6 @@ typedef struct { * subsystem knows about the Geofence. * */ -#define GPS_GEOFENCE_ENTERED (1<<0L) -#define GPS_GEOFENCE_EXITED (1<<1L) -#define GPS_GEOFENCE_UNCERTAIN (1<<2L) - -#define GPS_GEOFENCE_UNAVAILABLE (1<<0L) -#define GPS_GEOFENCE_AVAILABLE (1<<1L) - -#define GPS_GEOFENCE_OPERATION_SUCCESS 0 -#define GPS_GEOFENCE_ERROR_TOO_MANY_GEOFENCES -100 -#define GPS_GEOFENCE_ERROR_ID_EXISTS -101 -#define GPS_GEOFENCE_ERROR_ID_UNKNOWN -102 -#define GPS_GEOFENCE_ERROR_INVALID_TRANSITION -103 -#define GPS_GEOFENCE_ERROR_GENERIC -149 /** * The callback associated with the geofence. @@ -1972,10 +1773,6 @@ typedef struct { gnss_measurement_callback gnss_measurement_callback; } GpsMeasurementCallbacks; -#define GPS_MEASUREMENT_OPERATION_SUCCESS 0 -#define GPS_MEASUREMENT_ERROR_ALREADY_INIT -100 -#define GPS_MEASUREMENT_ERROR_GENERIC -101 - /** * Extended interface for GPS Measurements support. */ @@ -2147,10 +1944,6 @@ typedef struct { gnss_navigation_message_callback gnss_navigation_message_callback; } GpsNavigationMessageCallbacks; -#define GPS_NAVIGATION_MESSAGE_OPERATION_SUCCESS 0 -#define GPS_NAVIGATION_MESSAGE_ERROR_ALREADY_INIT -100 -#define GPS_NAVIGATION_MESSAGE_ERROR_GENERIC -101 - /** * Extended interface for GPS navigation message reporting support. */ diff --git a/hardware/gralloc.h b/hardware/gralloc.h index 0c87fb0..5dafea0 100644 --- a/hardware/gralloc.h +++ b/hardware/gralloc.h @@ -18,7 +18,6 @@ #ifndef ANDROID_GRALLOC_INTERFACE_H #define ANDROID_GRALLOC_INTERFACE_H -#include #include #include @@ -68,69 +67,69 @@ __BEGIN_DECLS enum { /* buffer is never read in software */ - GRALLOC_USAGE_SW_READ_NEVER = 0x00000000, + GRALLOC_USAGE_SW_READ_NEVER = 0x00000000U, /* buffer is rarely read in software */ - GRALLOC_USAGE_SW_READ_RARELY = 0x00000002, + GRALLOC_USAGE_SW_READ_RARELY = 0x00000002U, /* buffer is often read in software */ - GRALLOC_USAGE_SW_READ_OFTEN = 0x00000003, + GRALLOC_USAGE_SW_READ_OFTEN = 0x00000003U, /* mask for the software read values */ - GRALLOC_USAGE_SW_READ_MASK = 0x0000000F, + GRALLOC_USAGE_SW_READ_MASK = 0x0000000FU, /* buffer is never written in software */ - GRALLOC_USAGE_SW_WRITE_NEVER = 0x00000000, + GRALLOC_USAGE_SW_WRITE_NEVER = 0x00000000U, /* buffer is rarely written in software */ - GRALLOC_USAGE_SW_WRITE_RARELY = 0x00000020, + GRALLOC_USAGE_SW_WRITE_RARELY = 0x00000020U, /* buffer is often written in software */ - GRALLOC_USAGE_SW_WRITE_OFTEN = 0x00000030, + GRALLOC_USAGE_SW_WRITE_OFTEN = 0x00000030U, /* mask for the software write values */ - GRALLOC_USAGE_SW_WRITE_MASK = 0x000000F0, + GRALLOC_USAGE_SW_WRITE_MASK = 0x000000F0U, /* buffer will be used as an OpenGL ES texture */ - GRALLOC_USAGE_HW_TEXTURE = 0x00000100, + GRALLOC_USAGE_HW_TEXTURE = 0x00000100U, /* buffer will be used as an OpenGL ES render target */ - GRALLOC_USAGE_HW_RENDER = 0x00000200, + GRALLOC_USAGE_HW_RENDER = 0x00000200U, /* buffer will be used by the 2D hardware blitter */ - GRALLOC_USAGE_HW_2D = 0x00000400, + GRALLOC_USAGE_HW_2D = 0x00000400U, /* buffer will be used by the HWComposer HAL module */ - GRALLOC_USAGE_HW_COMPOSER = 0x00000800, + GRALLOC_USAGE_HW_COMPOSER = 0x00000800U, /* buffer will be used with the framebuffer device */ - GRALLOC_USAGE_HW_FB = 0x00001000, + GRALLOC_USAGE_HW_FB = 0x00001000U, /* buffer should be displayed full-screen on an external display when * possible */ - GRALLOC_USAGE_EXTERNAL_DISP = 0x00002000, + GRALLOC_USAGE_EXTERNAL_DISP = 0x00002000U, /* Must have a hardware-protected path to external display sink for * this buffer. If a hardware-protected path is not available, then * either don't composite only this buffer (preferred) to the * external sink, or (less desirable) do not route the entire * composition to the external sink. */ - GRALLOC_USAGE_PROTECTED = 0x00004000, + GRALLOC_USAGE_PROTECTED = 0x00004000U, /* buffer may be used as a cursor */ - GRALLOC_USAGE_CURSOR = 0x00008000, + GRALLOC_USAGE_CURSOR = 0x00008000U, /* buffer will be used with the HW video encoder */ - GRALLOC_USAGE_HW_VIDEO_ENCODER = 0x00010000, + GRALLOC_USAGE_HW_VIDEO_ENCODER = 0x00010000U, /* buffer will be written by the HW camera pipeline */ - GRALLOC_USAGE_HW_CAMERA_WRITE = 0x00020000, + GRALLOC_USAGE_HW_CAMERA_WRITE = 0x00020000U, /* buffer will be read by the HW camera pipeline */ - GRALLOC_USAGE_HW_CAMERA_READ = 0x00040000, + GRALLOC_USAGE_HW_CAMERA_READ = 0x00040000U, /* buffer will be used as part of zero-shutter-lag queue */ - GRALLOC_USAGE_HW_CAMERA_ZSL = 0x00060000, + GRALLOC_USAGE_HW_CAMERA_ZSL = 0x00060000U, /* mask for the camera access values */ - GRALLOC_USAGE_HW_CAMERA_MASK = 0x00060000, + GRALLOC_USAGE_HW_CAMERA_MASK = 0x00060000U, /* mask for the software usage bit-mask */ - GRALLOC_USAGE_HW_MASK = 0x00071F00, + GRALLOC_USAGE_HW_MASK = 0x00071F00U, /* buffer will be used as a RenderScript Allocation */ - GRALLOC_USAGE_RENDERSCRIPT = 0x00100000, + GRALLOC_USAGE_RENDERSCRIPT = 0x00100000U, /* Set by the consumer to indicate to the producer that they may attach a * buffer that they did not detach from the BufferQueue. Will be filtered * out by GRALLOC_USAGE_ALLOC_MASK, so gralloc modules will not need to * handle this flag. */ - GRALLOC_USAGE_FOREIGN_BUFFERS = 0x00200000, + GRALLOC_USAGE_FOREIGN_BUFFERS = 0x00200000U, /* Mask of all flags which could be passed to a gralloc module for buffer * allocation. Any flags not in this mask do not need to be handled by @@ -138,24 +137,11 @@ enum { GRALLOC_USAGE_ALLOC_MASK = ~(GRALLOC_USAGE_FOREIGN_BUFFERS), /* implementation-specific private usage flags */ - GRALLOC_USAGE_PRIVATE_0 = 0x10000000, - GRALLOC_USAGE_PRIVATE_1 = 0x20000000, - GRALLOC_USAGE_PRIVATE_2 = 0x40000000, - GRALLOC_USAGE_PRIVATE_3 = 0x80000000, - GRALLOC_USAGE_PRIVATE_MASK = 0xF0000000, - -#ifdef EXYNOS4_ENHANCEMENTS - /* SAMSUNG */ - GRALLOC_USAGE_PRIVATE_NONECACHE = 0x00800000, - - GRALLOC_USAGE_HW_FIMC1 = 0x01000000, - GRALLOC_USAGE_HW_ION = 0x02000000, - GRALLOC_USAGE_YUV_ADDR = 0x04000000, - GRALLOC_USAGE_CAMERA = 0x08000000, - - /* SEC Private usage , for Overlay path at HWC */ - GRALLOC_USAGE_HWC_HWOVERLAY = 0x20000000, -#endif + GRALLOC_USAGE_PRIVATE_0 = 0x10000000U, + GRALLOC_USAGE_PRIVATE_1 = 0x20000000U, + GRALLOC_USAGE_PRIVATE_2 = 0x40000000U, + GRALLOC_USAGE_PRIVATE_3 = 0x80000000U, + GRALLOC_USAGE_PRIVATE_MASK = 0xF0000000U, }; /*****************************************************************************/ @@ -250,10 +236,6 @@ typedef struct gralloc_module_t { int (*unlock)(struct gralloc_module_t const* module, buffer_handle_t handle); -#ifdef EXYNOS4_ENHANCEMENTS - int (*getphys) (struct gralloc_module_t const* module, - buffer_handle_t handle, void** paddr); -#endif /* reserved for future use */ int (*perform)(struct gralloc_module_t const* module, @@ -389,7 +371,7 @@ typedef struct alloc_device_t { static inline int gralloc_open(const struct hw_module_t* module, struct alloc_device_t** device) { return module->methods->open(module, - GRALLOC_HARDWARE_GPU0, (struct hw_device_t**)device); + GRALLOC_HARDWARE_GPU0, TO_HW_DEVICE_T_OPEN(device)); } static inline int gralloc_close(struct alloc_device_t* device) { diff --git a/hardware/gralloc1.h b/hardware/gralloc1.h index 82345e9..03e8432 100644 --- a/hardware/gralloc1.h +++ b/hardware/gralloc1.h @@ -18,7 +18,7 @@ #define ANDROID_HARDWARE_GRALLOC1_H #include -#include +#include __BEGIN_DECLS @@ -36,7 +36,19 @@ typedef enum { * allocate may be NULL, which instructs the device to report whether the * given allocation is possible or not. */ GRALLOC1_CAPABILITY_TEST_ALLOCATE = 1, - GRALLOC1_LAST_CAPABILITY = 1, + + /* If this capability is supported, then the implementation supports + * allocating buffers with more than one image layer. */ + GRALLOC1_CAPABILITY_LAYERED_BUFFERS = 2, + + /* If this capability is supported, then the implementation always closes + * and deletes a buffer handle whenever the last reference is removed. + * + * Supporting this capability is strongly recommended. It will become + * mandatory in future releases. */ + GRALLOC1_CAPABILITY_RELEASE_IMPLY_DELETE = 3, + + GRALLOC1_LAST_CAPABILITY = 3, } gralloc1_capability_t; typedef enum { @@ -71,7 +83,7 @@ typedef enum { GRALLOC1_CONSUMER_USAGE_FOREIGN_BUFFERS = 1ULL << 21, /* 1ULL << 22 */ - /* 1ULL << 23 */ + GRALLOC1_CONSUMER_USAGE_GPU_DATA_BUFFER = 1ULL << 23, /* 1ULL << 24 */ /* 1ULL << 25 */ /* 1ULL << 26 */ @@ -141,12 +153,12 @@ typedef enum { GRALLOC1_FUNCTION_LOCK = 18, GRALLOC1_FUNCTION_LOCK_FLEX = 19, GRALLOC1_FUNCTION_UNLOCK = 20, -#ifdef EXYNOS4_ENHANCEMENTS - GRALLOC1_FUNCTION_GETPHYS = 21, - GRALLOC1_LAST_FUNCTION = 21, -#else - GRALLOC1_LAST_FUNCTION = 20, -#endif + GRALLOC1_FUNCTION_SET_LAYER_COUNT = 21, + GRALLOC1_FUNCTION_GET_LAYER_COUNT = 22, + GRALLOC1_FUNCTION_VALIDATE_BUFFER_SIZE = 23, + GRALLOC1_FUNCTION_GET_TRANSPORT_SIZE = 24, + GRALLOC1_FUNCTION_IMPORT_BUFFER = 25, + GRALLOC1_LAST_FUNCTION = 25, } gralloc1_function_descriptor_t; typedef enum { @@ -193,7 +205,7 @@ typedef enum { /* 1ULL << 20 */ /* 1ULL << 21 */ GRALLOC1_PRODUCER_USAGE_VIDEO_DECODER = 1ULL << 22, - /* 1ULL << 23 */ + GRALLOC1_PRODUCER_USAGE_SENSOR_DIRECT_DATA = 1ULL << 23, /* 1ULL << 24 */ /* 1ULL << 25 */ /* 1ULL << 26 */ @@ -295,7 +307,7 @@ typedef struct gralloc1_device { static inline int gralloc1_open(const struct hw_module_t* module, gralloc1_device_t** device) { return module->methods->open(module, GRALLOC_HARDWARE_MODULE_ID, - (struct hw_device_t**) device); + TO_HW_DEVICE_T_OPEN(device)); } static inline int gralloc1_close(gralloc1_device_t* device) { @@ -445,6 +457,30 @@ typedef int32_t /*gralloc1_error_t*/ (*GRALLOC1_PFN_SET_FORMAT)( gralloc1_device_t* device, gralloc1_buffer_descriptor_t descriptor, int32_t /*android_pixel_format_t*/ format); +/* setLayerCount(..., layerCount) + * Function descriptor: GRALLOC1_FUNCTION_SET_LAYER_COUNT + * Must be provided by all gralloc1 devices that provide the + * GRALLOC1_CAPABILITY_LAYERED_BUFFERS capability. + * + * Sets the number of layers in the buffer. + * + * A buffer with multiple layers may be used as the backing store of an array + * texture. All layers of a buffer share the same characteristics (e.g., + * dimensions, format, usage). Devices that do not support + * GRALLOC1_CAPABILITY_LAYERED_BUFFERS must allocate only buffers with a single + * layer. + * + * Parameters: + * layerCount - the desired number of layers, must be non-zero + * + * Returns GRALLOC1_ERROR_NONE or one of the following errors: + * GRALLOC1_ERROR_BAD_DESCRIPTOR - the buffer descriptor is invalid + * GRALLOC1_ERROR_BAD_VALUE - the layer count is invalid + */ +typedef int32_t /*gralloc1_error_t*/ (*GRALLOC1_PFN_SET_LAYER_COUNT)( + gralloc1_device_t* device, gralloc1_buffer_descriptor_t descriptor, + uint32_t layerCount); + /* setProducerUsage(..., usage) * Function descriptor: GRALLOC1_FUNCTION_SET_PRODUCER_USAGE * Must be provided by all gralloc1 devices @@ -569,6 +605,28 @@ typedef int32_t /*gralloc1_error_t*/ (*GRALLOC1_PFN_GET_FORMAT)( gralloc1_device_t* device, buffer_handle_t descriptor, int32_t* outFormat); +/* getLayerCount(..., outLayerCount) + * Function descriptor: GRALLOC1_FUNCTION_GET_LAYER_COUNT + * Must be provided by all gralloc1 devices that provide the + * GRALLOC1_CAPABILITY_LAYERED_BUFFERS capability. + * + * Gets the number of layers of the buffer. + * + * See setLayerCount for more information about this value. + * + * Parameters: + * outLayerCount - the number of layers in the image, must be non-NULL + * + * Returns GRALLOC1_ERROR_NONE or one of the following errors: + * GRALLOC1_ERROR_BAD_HANDLE - the buffer handle is invalid + * GRALLOC1_ERROR_UNSUPPORTED - the device is unable to retrieve the + * layer count from the buffer; see note [1] in this section's header for + * more information + */ +typedef int32_t /*gralloc1_error_t*/ (*GRALLOC1_PFN_GET_LAYER_COUNT)( + gralloc1_device_t* device, buffer_handle_t buffer, + uint32_t* outLayerCount); + /* getProducerUsage(..., outUsage) * Function descriptor: GRALLOC1_FUNCTION_GET_PRODUCER_USAGE * Must be provided by all gralloc1 devices @@ -615,6 +673,65 @@ typedef int32_t /*gralloc1_error_t*/ (*GRALLOC1_PFN_GET_PRODUCER_USAGE)( typedef int32_t /*gralloc1_error_t*/ (*GRALLOC1_PFN_GET_STRIDE)( gralloc1_device_t* device, buffer_handle_t buffer, uint32_t* outStride); +/* getTransportSize(..., outNumFds, outNumInts) + * Function descriptor: GRALLOC1_FUNCTION_GET_TRANSPORT_SIZE + * This function is optional for all gralloc1 devices. + * + * Get the transport size of a buffer. An imported buffer handle is a raw + * buffer handle with the process-local runtime data appended. This + * function, for example, allows a caller to omit the process-local + * runtime data at the tail when serializing the imported buffer handle. + * + * Note that a client might or might not omit the process-local runtime + * data when sending an imported buffer handle. The mapper must support + * both cases on the receiving end. + * + * Parameters: + * outNumFds - the number of file descriptors needed for transport + * outNumInts - the number of integers needed for transport + * + * Returns GRALLOC1_ERROR_NONE or one of the following errors: + * GRALLOC1_ERROR_BAD_HANDLE - the buffer handle is invalid + * GRALLOC1_ERROR_UNSUPPORTED - the device is unable to retrieve the numFds + * and numInts; see note [1] in this section's header for more information + */ +typedef int32_t /*gralloc1_error_t*/ (*GRALLOC1_PFN_GET_TRANSPORT_SIZE)( + gralloc1_device_t* device, buffer_handle_t buffer, uint32_t *outNumFds, + uint32_t *outNumInts); + +typedef struct gralloc1_buffer_descriptor_info { + uint32_t width; + uint32_t height; + uint32_t layerCount; + int32_t /*android_pixel_format_t*/ format; + uint64_t producerUsage; + uint64_t consumerUsage; +} gralloc1_buffer_descriptor_info_t; + +/* validateBufferSize(..., ) + * Function descriptor: GRALLOC1_FUNCTION_VALIDATE_BUFFER_SIZE + * This function is optional for all gralloc1 devices. + * + * Validate that the buffer can be safely accessed by a caller who assumes + * the specified descriptorInfo and stride. This must at least validate + * that the buffer size is large enough. Validating the buffer against + * individual buffer attributes is optional. + * + * Parameters: + * descriptor - specifies the attributes of the buffer + * stride - the buffer stride returned by IAllocator::allocate + * + * Returns GRALLOC1_ERROR_NONE or one of the following errors: + * GRALLOC1_ERROR_BAD_HANDLE - the buffer handle is invalid + * GRALLOC1_ERROR_BAD_VALUE - when buffer cannot be safely accessed + * GRALLOC1_ERROR_UNSUPPORTED - the device is unable to validate the buffer + * size; see note [1] in this section's header for more information + */ +typedef int32_t /*gralloc1_error_t*/ (*GRALLOC1_PFN_VALIDATE_BUFFER_SIZE)( + gralloc1_device_t* device, buffer_handle_t buffer, + const gralloc1_buffer_descriptor_info_t* descriptorInfo, + uint32_t stride); + /* * Buffer management functions */ @@ -668,6 +785,37 @@ typedef int32_t /*gralloc1_error_t*/ (*GRALLOC1_PFN_ALLOCATE)( const gralloc1_buffer_descriptor_t* descriptors, buffer_handle_t* outBuffers); +/* importBuffer(..., rawHandle, outBuffer); + * Function descriptor: GRALLOC1_FUNCTION_IMPORT_BUFFER + * This function is optional for all gralloc1 devices. + * When supported, GRALLOC1_CAPABILITY_RELEASE_IMPLY_DELETE must also be + * supported. + * + * Explictly imports a buffer into a proccess. + * + * This function can be called in place of retain when a raw buffer handle is + * received by a remote process. Import producess a import handle that can + * be used to access the underlying graphic buffer. The new import handle has a + * ref count of 1. + * + * This function must at least validate the raw handle before creating the + * imported handle. It must also support importing the same raw handle + * multiple times to create multiple imported handles. The imported handle + * must be considered valid everywhere in the process. + * + * Parameters: + * rawHandle - the raw buffer handle to import + * outBuffer - a handle to the newly imported buffer + * + * Returns GRALLOC1_ERROR_NONE or one of the following errors: + * GRALLOC1_ERROR_BAD_HANDLE - the buffer handle is invalid + * GRALLOC1_ERROR_NO_RESOURCES - it is not possible to add a import to this + * buffer at this time + */ +typedef int32_t /*gralloc1_error_t*/ (*GRALLOC1_PFN_IMPORT_BUFFER)( + gralloc1_device_t* device, const buffer_handle_t rawHandle, + buffer_handle_t* outBuffer); + /* retain(..., buffer) * Function descriptor: GRALLOC1_FUNCTION_RETAIN * Must be provided by all gralloc1 devices @@ -701,6 +849,12 @@ typedef int32_t /*gralloc1_error_t*/ (*GRALLOC1_PFN_RETAIN)( * referring to a particular backing store is freed, that backing store should * also be freed. * + * When GRALLOC1_CAPABILITY_RELEASE_IMPLY_DELETE is supported, + * native_handle_close and native_handle_delete must always be called by the + * implementation whenever the last reference is removed. Otherwise, a call + * to release() will be followed by native_handle_close and native_handle_delete + * by the caller when the buffer is not allocated locally through allocate(). + * * Parameters: * buffer - the buffer from which a reference should be removed * @@ -887,12 +1041,6 @@ typedef int32_t /*gralloc1_error_t*/ (*GRALLOC1_PFN_UNLOCK)( gralloc1_device_t* device, buffer_handle_t buffer, int32_t* outReleaseFence); -#ifdef EXYNOS4_ENHANCEMENTS -typedef int32_t /*gralloc1_error_t*/ (*GRALLOC1_PFN_GETPHYS)( - gralloc1_device_t* device, buffer_handle_t buffer, - void **paddr); -#endif - __END_DECLS #endif diff --git a/hardware/hardware.h b/hardware/hardware.h index 74f57aa..bf076f6 100644 --- a/hardware/hardware.h +++ b/hardware/hardware.h @@ -201,6 +201,12 @@ typedef struct hw_device_t { } hw_device_t; +#ifdef __cplusplus +#define TO_HW_DEVICE_T_OPEN(x) reinterpret_cast(x) +#else +#define TO_HW_DEVICE_T_OPEN(x) (struct hw_device_t**)(x) +#endif + /** * Name of the hal_module_info */ diff --git a/hardware/hdmi_cec.h b/hardware/hdmi_cec.h index ab70f92..aa06384 100644 --- a/hardware/hdmi_cec.h +++ b/hardware/hdmi_cec.h @@ -417,7 +417,7 @@ typedef struct hdmi_cec_device { static inline int hdmi_cec_open(const struct hw_module_t* module, struct hdmi_cec_device** device) { return module->methods->open(module, - HDMI_CEC_HARDWARE_INTERFACE, (struct hw_device_t**)device); + HDMI_CEC_HARDWARE_INTERFACE, TO_HW_DEVICE_T_OPEN(device)); } static inline int hdmi_cec_close(struct hdmi_cec_device* device) { diff --git a/hardware/hw_auth_token.h b/hardware/hw_auth_token.h index f471d1a..3305f2c 100644 --- a/hardware/hw_auth_token.h +++ b/hardware/hw_auth_token.h @@ -23,7 +23,7 @@ extern "C" { #endif // __cplusplus -const uint8_t HW_AUTH_TOKEN_VERSION = 0; +#define HW_AUTH_TOKEN_VERSION 0 typedef enum { HW_AUTH_NONE = 0, diff --git a/hardware/hwcomposer.h b/hardware/hwcomposer.h index 28877e1..9eb1aaf 100644 --- a/hardware/hwcomposer.h +++ b/hardware/hwcomposer.h @@ -286,11 +286,6 @@ typedef struct hwc_layer_1 { * their origin is the top-left corner. */ hwc_region_t surfaceDamage; - -#ifdef QTI_BSP - /* Color for Dim Layer */ - hwc_color_t color; -#endif }; }; @@ -486,6 +481,7 @@ typedef struct hwc_module { struct hw_module_t common; } hwc_module_t; +#define HWC_ERROR (-1) typedef struct hwc_composer_device_1 { /** * Common methods of the hardware composer device. This *must* be the first member of @@ -719,9 +715,9 @@ typedef struct hwc_composer_device_1 { * (*getActiveConfig)() returns the index of the configuration that is * currently active on the connected display. The index is relative to * the list of configuration handles returned by getDisplayConfigs. If there - * is no active configuration, -1 shall be returned. + * is no active configuration, HWC_ERROR shall be returned. * - * Returns the configuration index on success or -1 on error. + * Returns the configuration index on success or HWC_ERROR on error. * * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_4 and later. * It shall be NULL for previous versions. @@ -788,7 +784,7 @@ typedef struct hwc_composer_device_1 { static inline int hwc_open_1(const struct hw_module_t* module, hwc_composer_device_1_t** device) { return module->methods->open(module, - HWC_HARDWARE_COMPOSER, (struct hw_device_t**)device); + HWC_HARDWARE_COMPOSER, TO_HW_DEVICE_T_OPEN(device)); } static inline int hwc_close_1(hwc_composer_device_1_t* device) { diff --git a/hardware/hwcomposer2.h b/hardware/hwcomposer2.h index 6973603..c9809ce 100644 --- a/hardware/hwcomposer2.h +++ b/hardware/hwcomposer2.h @@ -17,6 +17,8 @@ #ifndef ANDROID_HARDWARE_HWCOMPOSER2_H #define ANDROID_HARDWARE_HWCOMPOSER2_H +#include + #include #include "hwcomposer_defs.h" @@ -92,6 +94,27 @@ typedef enum { * the client. This will prevent the client from applying the color * transform during its composition step. */ HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM = 2, + + /* Specifies that the present fence must not be used as an accurate + * representation of the actual present time of a frame. + * This capability must never be set by HWC2 devices. + * This capability may be set for HWC1 devices that use the + * HWC2On1Adapter where emulation of the present fence using the retire + * fence is not feasible. + * In the future, CTS tests will require present time to be reliable. + */ + HWC2_CAPABILITY_PRESENT_FENCE_IS_NOT_RELIABLE = 3, + + /* Specifies that a device is able to skip the validateDisplay call before + * receiving a call to presentDisplay. The client will always skip + * validateDisplay and try to call presentDisplay regardless of the changes + * in the properties of the layers. If the device returns anything else than + * HWC2_ERROR_NONE, it will call validateDisplay then presentDisplay again. + * For this capability to be worthwhile the device implementation of + * presentDisplay should fail as fast as possible in the case a + * validateDisplay step is needed. + */ + HWC2_CAPABILITY_SKIP_VALIDATE = 4, } hwc2_capability_t; /* Possible composition types for a given layer */ @@ -239,6 +262,15 @@ typedef enum { HWC2_FUNCTION_SET_POWER_MODE, HWC2_FUNCTION_SET_VSYNC_ENABLED, HWC2_FUNCTION_VALIDATE_DISPLAY, + HWC2_FUNCTION_SET_LAYER_FLOAT_COLOR, + HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA, + HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS, + HWC2_FUNCTION_SET_READBACK_BUFFER, + HWC2_FUNCTION_GET_READBACK_BUFFER_ATTRIBUTES, + HWC2_FUNCTION_GET_READBACK_BUFFER_FENCE, + HWC2_FUNCTION_GET_RENDER_INTENTS, + HWC2_FUNCTION_SET_COLOR_MODE_WITH_RENDER_INTENT, + HWC2_FUNCTION_GET_DATASPACE_SATURATION_MATRIX } hwc2_function_descriptor_t; /* Layer requests returned from getDisplayRequests */ @@ -288,6 +320,33 @@ typedef enum { HWC2_VSYNC_DISABLE = 2, } hwc2_vsync_t; +/* MUST match HIDL's V2_2::IComposerClient::PerFrameMetadataKey */ +typedef enum { + /* SMPTE ST 2084:2014. + * Coordinates defined in CIE 1931 xy chromaticity space + */ + HWC2_DISPLAY_RED_PRIMARY_X = 0, + HWC2_DISPLAY_RED_PRIMARY_Y = 1, + HWC2_DISPLAY_GREEN_PRIMARY_X = 2, + HWC2_DISPLAY_GREEN_PRIMARY_Y = 3, + HWC2_DISPLAY_BLUE_PRIMARY_X = 4, + HWC2_DISPLAY_BLUE_PRIMARY_Y = 5, + HWC2_WHITE_POINT_X = 6, + HWC2_WHITE_POINT_Y = 7, + /* SMPTE ST 2084:2014. + * Units: nits + * max as defined by ST 2048: 10,000 nits + */ + HWC2_MAX_LUMINANCE = 8, + HWC2_MIN_LUMINANCE = 9, + + /* CTA 861.3 + * Units: nits + */ + HWC2_MAX_CONTENT_LIGHT_LEVEL = 10, + HWC2_MAX_FRAME_AVERAGE_LIGHT_LEVEL = 11, +} hwc2_per_frame_metadata_key_t; + /* * Stringification Functions */ @@ -333,6 +392,8 @@ static inline const char* getCapabilityName(hwc2_capability_t capability) { case HWC2_CAPABILITY_SIDEBAND_STREAM: return "SidebandStream"; case HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM: return "SkipClientColorTransform"; + case HWC2_CAPABILITY_PRESENT_FENCE_IS_NOT_RELIABLE: + return "PresentFenceIsNotReliable"; default: return "Unknown"; } } @@ -360,7 +421,7 @@ static inline const char* getConnectionName(hwc2_connection_t connection) { static inline const char* getDisplayRequestName( hwc2_display_request_t request) { - switch (request) { + switch (__BIONIC_CAST(static_cast, int, request)) { case 0: return "None"; case HWC2_DISPLAY_REQUEST_FLIP_CLIENT_TARGET: return "FlipClientTarget"; case HWC2_DISPLAY_REQUEST_WRITE_CLIENT_TARGET_TO_OUTPUT: @@ -454,12 +515,21 @@ static inline const char* getFunctionDescriptorName( case HWC2_FUNCTION_SET_POWER_MODE: return "SetPowerMode"; case HWC2_FUNCTION_SET_VSYNC_ENABLED: return "SetVsyncEnabled"; case HWC2_FUNCTION_VALIDATE_DISPLAY: return "ValidateDisplay"; + case HWC2_FUNCTION_SET_LAYER_FLOAT_COLOR: return "SetLayerFloatColor"; + case HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA: return "SetLayerPerFrameMetadata"; + case HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS: return "GetPerFrameMetadataKeys"; + case HWC2_FUNCTION_SET_READBACK_BUFFER: return "SetReadbackBuffer"; + case HWC2_FUNCTION_GET_READBACK_BUFFER_ATTRIBUTES: return "GetReadbackBufferAttributes"; + case HWC2_FUNCTION_GET_READBACK_BUFFER_FENCE: return "GetReadbackBufferFence"; + case HWC2_FUNCTION_GET_RENDER_INTENTS: return "GetRenderIntents"; + case HWC2_FUNCTION_SET_COLOR_MODE_WITH_RENDER_INTENT: return "SetColorModeWithRenderIntent"; + case HWC2_FUNCTION_GET_DATASPACE_SATURATION_MATRIX: return "GetDataspaceSaturationMatrix"; default: return "Unknown"; } } static inline const char* getLayerRequestName(hwc2_layer_request_t request) { - switch (request) { + switch (__BIONIC_CAST(static_cast, int, request)) { case 0: return "None"; case HWC2_LAYER_REQUEST_CLEAR_CLIENT_TARGET: return "ClearClientTarget"; default: return "Unknown"; @@ -477,7 +547,7 @@ static inline const char* getPowerModeName(hwc2_power_mode_t mode) { } static inline const char* getTransformName(hwc_transform_t transform) { - switch (transform) { + switch (__BIONIC_CAST(static_cast, int, transform)) { case 0: return "None"; case HWC_TRANSFORM_FLIP_H: return "FlipH"; case HWC_TRANSFORM_FLIP_V: return "FlipV"; @@ -549,6 +619,8 @@ enum class Capability : int32_t { Invalid = HWC2_CAPABILITY_INVALID, SidebandStream = HWC2_CAPABILITY_SIDEBAND_STREAM, SkipClientColorTransform = HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM, + PresentFenceIsNotReliable = HWC2_CAPABILITY_PRESENT_FENCE_IS_NOT_RELIABLE, + SkipValidate = HWC2_CAPABILITY_SKIP_VALIDATE, }; TO_STRING(hwc2_capability_t, Capability, getCapabilityName) @@ -641,6 +713,15 @@ enum class FunctionDescriptor : int32_t { SetPowerMode = HWC2_FUNCTION_SET_POWER_MODE, SetVsyncEnabled = HWC2_FUNCTION_SET_VSYNC_ENABLED, ValidateDisplay = HWC2_FUNCTION_VALIDATE_DISPLAY, + SetLayerFloatColor = HWC2_FUNCTION_SET_LAYER_FLOAT_COLOR, + SetLayerPerFrameMetadata = HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA, + GetPerFrameMetadataKeys = HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS, + SetReadbackBuffer = HWC2_FUNCTION_SET_READBACK_BUFFER, + GetReadbackBufferAttributes = HWC2_FUNCTION_GET_READBACK_BUFFER_ATTRIBUTES, + GetReadbackBufferFence = HWC2_FUNCTION_GET_READBACK_BUFFER_FENCE, + GetRenderIntents = HWC2_FUNCTION_GET_RENDER_INTENTS, + SetColorModeWithRenderIntent = HWC2_FUNCTION_SET_COLOR_MODE_WITH_RENDER_INTENT, + GetDataspaceSaturationMatrix = HWC2_FUNCTION_GET_DATASPACE_SATURATION_MATRIX, }; TO_STRING(hwc2_function_descriptor_t, FunctionDescriptor, getFunctionDescriptorName) @@ -738,7 +819,7 @@ typedef struct hwc2_device { static inline int hwc2_open(const struct hw_module_t* module, hwc2_device_t** device) { return module->methods->open(module, HWC_HARDWARE_COMPOSER, - (struct hw_device_t**) device); + TO_HW_DEVICE_T_OPEN(device)); } static inline int hwc2_close(hwc2_device_t* device) { @@ -942,6 +1023,27 @@ typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_REGISTER_CALLBACK)( int32_t /*hwc2_callback_descriptor_t*/ descriptor, hwc2_callback_data_t callbackData, hwc2_function_pointer_t pointer); +/* getDataspaceSaturationMatrix(..., dataspace, outMatrix) + * Descriptor: HWC2_FUNCTION_GET_DATASPACE_SATURATION_MATRIX + * Provided by HWC2 devices which don't return nullptr function pointer. + * + * Get the saturation matrix of the specified dataspace. The saturation matrix + * can be used to approximate the dataspace saturation operation performed by + * the HWC2 device when non-colorimetric mapping is allowed. It is to be + * applied on linear pixel values. + * + * Parameters: + * dataspace - the dataspace to query for + * outMatrix - a column-major 4x4 matrix (16 floats). It must be an identity + * matrix unless dataspace is HAL_DATASPACE_SRGB_LINEAR. + * + * Returns HWC2_ERROR_NONE or one of the following errors: + * HWC2_ERROR_BAD_PARAMETER - dataspace was invalid + */ +typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DATASPACE_SATURATION_MATRIX)( + hwc2_device_t* device, int32_t /*android_dataspace_t*/ dataspace, + float* outMatrix); + /* * Display Functions * @@ -1119,6 +1221,35 @@ typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_COLOR_MODES)( hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumModes, int32_t* /*android_color_mode_t*/ outModes); +/* getRenderIntents(..., mode, outNumIntents, outIntents) + * Descriptor: HWC2_FUNCTION_GET_RENDER_INTENTS + * Provided by HWC2 devices which don't return nullptr function pointer. + * + * Returns the render intents supported on this display. + * + * The valid render intents can be found in android_render_intent_v1_1_t in + * . All HWC2 devices must support at least + * HAL_RENDER_INTENT_COLORIMETRIC. + * + * outNumIntents may be NULL to retrieve the number of intents which will be + * returned. + * + * Parameters: + * mode - the color mode to query the render intents for + * outNumIntents - if outIntents was NULL, the number of intents which would + * have been returned; if outIntents was not NULL, the number of intents + * returned, which must not exceed the value stored in outNumIntents + * prior to the call; pointer will be non-NULL + * outIntents - an array of render intents + * + * Returns HWC2_ERROR_NONE or one of the following errors: + * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in + */ +typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_RENDER_INTENTS)( + hwc2_device_t* device, hwc2_display_t display, int32_t mode, + uint32_t* outNumIntents, + int32_t* /*android_render_intent_v1_1_t*/ outIntents); + /* getDisplayAttribute(..., config, attribute, outValue) * Descriptor: HWC2_FUNCTION_GET_DISPLAY_ATTRIBUTE * Must be provided by all HWC2 devices @@ -1443,8 +1574,8 @@ typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_CLIENT_TARGET)( * * Sets the color mode of the given display. * - * Upon returning from this function, the color mode change must have fully - * taken effect. + * This must be called outside of validateDisplay/presentDisplay, and it takes + * effect on next presentDisplay. * * The valid color modes can be found in android_color_mode_t in * . All HWC2 devices must support at least @@ -1463,6 +1594,34 @@ typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_COLOR_MODE)( hwc2_device_t* device, hwc2_display_t display, int32_t /*android_color_mode_t*/ mode); +/* setColorModeWithIntent(..., mode, intent) + * Descriptor: HWC2_FUNCTION_SET_COLOR_MODE_WITH_RENDER_INTENT + * Provided by HWC2 devices which don't return nullptr function pointer. + * + * This must be called outside of validateDisplay/presentDisplay, and it takes + * effect on next presentDisplay. + * + * The valid color modes and render intents can be found in + * android_color_mode_t and android_render_intent_v1_1_t in + * . All HWC2 devices must support at least + * HAL_COLOR_MODE_NATIVE and HAL_RENDER_INTENT_COLORIMETRIC, and displays are + * assumed to be in this mode and intent upon hotplug. + * + * Parameters: + * mode - the mode to set + * intent - the intent to set + * + * Returns HWC2_ERROR_NONE or one of the following errors: + * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in + * HWC2_ERROR_BAD_PARAMETER - mode/intent is not a valid color mode or + * render intent + * HWC2_ERROR_UNSUPPORTED - mode or intent is not supported on this display + */ +typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_COLOR_MODE_WITH_RENDER_INTENT)( + hwc2_device_t* device, hwc2_display_t display, + int32_t /*android_color_mode_t*/ mode, + int32_t /*android_render_intent_v1_1_t */ intent); + /* setColorTransform(..., matrix, hint) * Descriptor: HWC2_FUNCTION_SET_COLOR_TRANSFORM * Must be provided by all HWC2 devices @@ -1510,6 +1669,34 @@ typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_COLOR_TRANSFORM)( hwc2_device_t* device, hwc2_display_t display, const float* matrix, int32_t /*android_color_transform_t*/ hint); +/* getPerFrameMetadataKeys(..., outKeys) + * Descriptor: HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS + * Optional for HWC2 devices + * + * If supported (getFunction(HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS) is non-null), + * getPerFrameMetadataKeys returns the list of supported PerFrameMetadataKeys + * which are invariant with regard to the active configuration. + * + * Devices which are not HDR-capable, must return null when getFunction is called + * with HWC2_FUNCTION_GET_PER_FRAME_METADATA_KEYS. + * + * If outKeys is NULL, the required number of PerFrameMetadataKey keys + * must be returned in outNumKeys. + * + * Parameters: + * outNumKeys - if outKeys is NULL, the number of keys which would have + * been returned; if outKeys is not NULL, the number of keys stored in + * outKeys, which must not exceed the value stored in outNumKeys prior + * to the call; pointer will be non-NULL + * outKeys - an array of hwc2_per_frame_metadata_key_t keys + * + * Returns HWC2_ERROR_NONE or one of the following errors: + * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in + */ +typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_PER_FRAME_METADATA_KEYS)( + hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumKeys, + int32_t* /*hwc2_per_frame_metadata_key_t*/ outKeys); + /* setOutputBuffer(..., buffer, releaseFence) * Descriptor: HWC2_FUNCTION_SET_OUTPUT_BUFFER * Must be provided by all HWC2 devices @@ -1564,6 +1751,132 @@ typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_POWER_MODE)( hwc2_device_t* device, hwc2_display_t display, int32_t /*hwc2_power_mode_t*/ mode); +/* getReadbackBufferAttributes(..., outFormat, outDataspace) + * Optional for HWC2 devices + * + * Returns the format which should be used when allocating a buffer for use by + * device readback as well as the dataspace in which its contents should be + * interpreted. + * + * If readback is not supported by this HWC implementation, this call will also + * be able to return HWC2_ERROR_UNSUPPORTED so we can fall back to another method. + * Returning NULL to a getFunction request for this function will also indicate + * that readback is not supported. + * + * The width and height of this buffer will be those of the currently-active + * display configuration, and the usage flags will consist of the following: + * BufferUsage::CPU_READ | BufferUsage::GPU_TEXTURE | + * BufferUsage::COMPOSER_OUTPUT + * + * The format and dataspace provided must be sufficient such that if a + * correctly-configured buffer is passed into setReadbackBuffer, filled by + * the device, and then displayed by the client as a full-screen buffer, the + * output of the display remains the same (subject to the note about protected + * content in the description of setReadbackBuffer). + * + * If the active configuration or color mode of this display has changed since + * the previous call to this function, it will be called again prior to setting + * a readback buffer such that the returned format and dataspace can be updated + * accordingly. + * + * Parameters: + * outFormat - the format the client should use when allocating a device + * readback buffer; pointer will be non-NULL + * outDataspace - the dataspace the client will use when interpreting the + * contents of a device readback buffer; pointer will be non-NULL + * + * Returns HWC2_ERROR_NONE or one of the following errors: + * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in + * + * See also: + * setReadbackBuffer + * getReadbackBufferFence + */ +typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_READBACK_BUFFER_ATTRIBUTES)( + hwc2_device_t* device, hwc2_display_t display, + int32_t* /*android_pixel_format_t*/ outFormat, + int32_t* /*android_dataspace_t*/ outDataspace); + +/* getReadbackBufferFence(..., outFence) + * Optional for HWC2 devices + * + * Returns an acquire sync fence file descriptor which will signal when the + * buffer provided to setReadbackBuffer has been filled by the device and is + * safe for the client to read. + * + * If it is already safe to read from this buffer, -1 may be returned instead. + * The client takes ownership of this file descriptor and is responsible for + * closing it when it is no longer needed. + * + * This function will be called immediately after the composition cycle being + * captured into the readback buffer. The complete ordering of a readback buffer + * capture is as follows: + * + * getReadbackBufferAttributes + * // Readback buffer is allocated + * // Many frames may pass + * + * setReadbackBuffer + * validateDisplay + * presentDisplay + * getReadbackBufferFence + * // Implicitly wait on the acquire fence before accessing the buffer + * + * Parameters: + * outFence - a sync fence file descriptor as described above; pointer + * will be non-NULL + * + * Returns HWC2_ERROR_NONE or one of the following errors: + * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in + * HWC2_ERROR_NO_RESOURCES - the readback operation was successful, but + * resulted in a different validate result than would have occurred + * without readback + * HWC2_ERROR_UNSUPPORTED - the readback operation was unsuccessful because + * of resource constraints, the presence of protected content, or other + * reasons; -1 must be returned in outFence + */ +typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_READBACK_BUFFER_FENCE)( + hwc2_device_t* device, hwc2_display_t display, + int32_t* outFence); + +/* setReadbackBuffer(..., buffer, releaseFence) + * Optional for HWC2 devices + * + * Sets the readback buffer to be filled with the contents of the next + * composition performed for this display (i.e., the contents present at the + * time of the next validateDisplay/presentDisplay cycle). + * + * This buffer will have been allocated as described in + * getReadbackBufferAttributes and will be interpreted as being in the dataspace + * provided by the same. + * + * If there is hardware protected content on the display at the time of the next + * composition, the area of the readback buffer covered by such content must be + * completely black. Any areas of the buffer not covered by such content may + * optionally be black as well. + * + * The release fence file descriptor provided works identically to the one + * described for setOutputBuffer. + * + * This function will not be called between any call to validateDisplay and a + * subsequent call to presentDisplay. + * + * Parameters: + * buffer - the new readback buffer + * releaseFence - a sync fence file descriptor as described in setOutputBuffer + * + * Returns HWC2_ERROR_NONE or one of the following errors: + * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in + * HWC2_ERROR_BAD_PARAMETER - the new readback buffer handle was invalid + * + * See also: + * getReadbackBufferAttributes + * getReadbackBufferFence + */ +typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_READBACK_BUFFER)( + hwc2_device_t* device, hwc2_display_t display, + buffer_handle_t buffer, int32_t releaseFence); + /* setVsyncEnabled(..., enabled) * Descriptor: HWC2_FUNCTION_SET_VSYNC_ENABLED * Must be provided by all HWC2 devices @@ -1731,6 +2044,35 @@ typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_SURFACE_DAMAGE)( hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer, hwc_region_t damage); +/* setLayerPerFrameMetadata(..., numMetadata, metadata) + * Descriptor: HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA + * Optional for HWC2 devices + * + * If supported (getFunction(HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA) is + * non-null), sets the metadata for the given display for all following + * frames. + * + * Upon returning from this function, the metadata change must have + * fully taken effect. + * + * This function will only be called if getPerFrameMetadataKeys is non-NULL + * and returns at least one key. + * + * Parameters: + * numElements is the number of elements in each of the keys and metadata arrays + * keys is a pointer to the array of keys. + * outMetadata is a pointer to the corresponding array of metadata. + * + * Returns HWC2_ERROR_NONE or one of the following errors: + * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in + * HWC2_ERROR_BAD_PARAMETER - metadata is not valid + * HWC2_ERROR_UNSUPPORTED - metadata is not supported on this display + */ +typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_PER_FRAME_METADATA)( + hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer, + uint32_t numElements, const int32_t* /*hw2_per_frame_metadata_key_t*/ keys, + const float* metadata); + /* * Layer State Functions * @@ -1778,6 +2120,25 @@ typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_COLOR)( hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer, hwc_color_t color); +/* setLayerFloatColor(..., color) + * Descriptor: HWC2_FUNCTION_SET_LAYER_FLOAT_COLOR + * Provided by HWC2 devices which don't return nullptr function pointer. + * + * Sets the color of the given layer. If the composition type of the layer is + * not HWC2_COMPOSITION_SOLID_COLOR, this call must return HWC2_ERROR_NONE and + * have no other effect. + * + * Parameters: + * color - the new color in float type, rage is [0.0, 1.0], the colorspace is + * defined by the dataspace that gets set by calling setLayerDataspace. + * + * Returns HWC2_ERROR_NONE or one of the following errors: + * HWC2_ERROR_BAD_LAYER - an invalid layer handle was passed in + */ +typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_SET_LAYER_FLOAT_COLOR)( + hwc2_device_t* device, hwc2_display_t display, hwc2_layer_t layer, + hwc_float_color_t color); + /* setLayerCompositionType(..., type) * Descriptor: HWC2_FUNCTION_SET_LAYER_COMPOSITION_TYPE * Must be provided by all HWC2 devices diff --git a/hardware/hwcomposer_defs.h b/hardware/hwcomposer_defs.h index dc1eceb..9f22f86 100644 --- a/hardware/hwcomposer_defs.h +++ b/hardware/hwcomposer_defs.h @@ -58,6 +58,13 @@ typedef struct hwc_color { uint8_t a; } hwc_color_t; +typedef struct hwc_float_color { + float r; + float g; + float b; + float a; +} hwc_float_color_t; + typedef struct hwc_frect { float left; float top; @@ -136,9 +143,9 @@ enum { */ enum { /* - * HWC_SKIP_LAYER is set by SurfaceFlnger to indicate that the HAL + * HWC_SKIP_LAYER is set by SurfaceFlinger to indicate that the HAL * shall not consider this layer for composition as it will be handled - * by SurfaceFlinger (just as if compositionType was set to HWC_OVERLAY). + * by SurfaceFlinger (just as if compositionType was set to HWC_FRAMEBUFFER). */ HWC_SKIP_LAYER = 0x00000001, @@ -254,26 +261,24 @@ enum { enum { HWC_DISPLAY_PRIMARY = 0, HWC_DISPLAY_EXTERNAL = 1, // HDMI, DP, etc. -#ifdef QTI_BSP - HWC_DISPLAY_TERTIARY = 2, - HWC_DISPLAY_VIRTUAL = 3, - - HWC_NUM_PHYSICAL_DISPLAY_TYPES = 3, - HWC_NUM_DISPLAY_TYPES = 4, -#else - HWC_DISPLAY_VIRTUAL = 2, - - HWC_NUM_PHYSICAL_DISPLAY_TYPES = 2, - HWC_NUM_DISPLAY_TYPES = 3, -#endif + + HWC_DISPLAY_EXTERNAL_2 = 2, + HWC_DISPLAY_EXTERNAL_3 = 3, + HWC_DISPLAY_EXTERNAL_4 = 4, + + HWC_DISPLAY_BUILTIN_2 = 5, + HWC_DISPLAY_BUILTIN_3 = 6, + HWC_DISPLAY_BUILTIN_4 = 7, + + HWC_DISPLAY_VIRTUAL = 8, + + HWC_NUM_PHYSICAL_DISPLAY_TYPES = 8, + HWC_NUM_DISPLAY_TYPES = 9, }; enum { HWC_DISPLAY_PRIMARY_BIT = 1 << HWC_DISPLAY_PRIMARY, HWC_DISPLAY_EXTERNAL_BIT = 1 << HWC_DISPLAY_EXTERNAL, -#ifdef QTI_BSP - HWC_DISPLAY_TERTIARY_BIT = 1 << HWC_DISPLAY_TERTIARY, -#endif HWC_DISPLAY_VIRTUAL_BIT = 1 << HWC_DISPLAY_VIRTUAL, }; diff --git a/hardware/keymaster.h b/hardware/keymaster.h deleted file mode 100644 index 8c5ff14..0000000 --- a/hardware/keymaster.h +++ /dev/null @@ -1,296 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_HARDWARE_KEYMASTER_H -#define ANDROID_HARDWARE_KEYMASTER_H - -#include -#include -#include - -#include - -__BEGIN_DECLS - -/** - * The id of this module - */ -#define KEYSTORE_HARDWARE_MODULE_ID "keystore" - -#define KEYSTORE_KEYMASTER "keymaster" - -/** - * Settings for "module_api_version" and "hal_api_version" - * fields in the keymaster_module initialization. - */ -#define KEYMASTER_HEADER_VERSION 3 - -#define KEYMASTER_MODULE_API_VERSION_0_2 HARDWARE_MODULE_API_VERSION(0, 2) -#define KEYMASTER_DEVICE_API_VERSION_0_2 HARDWARE_DEVICE_API_VERSION_2(0, 2, KEYMASTER_HEADER_VERSION) - -#define KEYMASTER_MODULE_API_VERSION_0_3 HARDWARE_MODULE_API_VERSION(0, 3) -#define KEYMASTER_DEVICE_API_VERSION_0_3 HARDWARE_DEVICE_API_VERSION_2(0, 3, KEYMASTER_HEADER_VERSION) - -/** - * Flags for keymaster_device::flags - */ -enum { - /* - * Indicates this keymaster implementation does not have hardware that - * keeps private keys out of user space. - * - * This should not be implemented on anything other than the default - * implementation. - */ - KEYMASTER_SOFTWARE_ONLY = 1 << 0, - - /* - * This indicates that the key blobs returned via all the primitives - * are sufficient to operate on their own without the trusted OS - * querying userspace to retrieve some other data. Key blobs of - * this type are normally returned encrypted with a - * Key Encryption Key (KEK). - * - * This is currently used by "vold" to know whether the whole disk - * encryption secret can be unwrapped without having some external - * service started up beforehand since the "/data" partition will - * be unavailable at that point. - */ - KEYMASTER_BLOBS_ARE_STANDALONE = 1 << 1, - - /* - * Indicates that the keymaster module supports DSA keys. - */ - KEYMASTER_SUPPORTS_DSA = 1 << 2, - - /* - * Indicates that the keymaster module supports EC keys. - */ - KEYMASTER_SUPPORTS_EC = 1 << 3, -}; - -struct keystore_module { - /** - * Common methods of the keystore module. This *must* be the first member of - * keystore_module as users of this structure will cast a hw_module_t to - * keystore_module pointer in contexts where it's known the hw_module_t references a - * keystore_module. - */ - hw_module_t common; -}; - -/** - * Asymmetric key pair types. - */ -typedef enum { - TYPE_RSA = 1, - TYPE_DSA = 2, - TYPE_EC = 3, -} keymaster_keypair_t; - -/** - * Parameters needed to generate an RSA key. - */ -typedef struct { - uint32_t modulus_size; - uint64_t public_exponent; -} keymaster_rsa_keygen_params_t; - -/** - * Parameters needed to generate a DSA key. - */ -typedef struct { - uint32_t key_size; - uint32_t generator_len; - uint32_t prime_p_len; - uint32_t prime_q_len; - const uint8_t* generator; - const uint8_t* prime_p; - const uint8_t* prime_q; -} keymaster_dsa_keygen_params_t; - -/** - * Parameters needed to generate an EC key. - * - * Field size is the only parameter in version 2. The sizes correspond to these required curves: - * - * 192 = NIST P-192 - * 224 = NIST P-224 - * 256 = NIST P-256 - * 384 = NIST P-384 - * 521 = NIST P-521 - * - * The parameters for these curves are available at: http://www.nsa.gov/ia/_files/nist-routines.pdf - * in Chapter 4. - */ -typedef struct { - uint32_t field_size; -} keymaster_ec_keygen_params_t; - -/** - * Digest type. - */ -typedef enum { - DIGEST_NONE, -} keymaster_digest_t; - -/** - * Type of padding used for RSA operations. - */ -typedef enum { - PADDING_NONE, -} keymaster_rsa_padding_t; - - -typedef struct { - keymaster_digest_t digest_type; -} keymaster_dsa_sign_params_t; - -typedef struct { - keymaster_digest_t digest_type; -} keymaster_ec_sign_params_t; - -typedef struct { - keymaster_digest_t digest_type; - keymaster_rsa_padding_t padding_type; -} keymaster_rsa_sign_params_t; - -/** - * The parameters that can be set for a given keymaster implementation. - */ -struct keymaster_device { - /** - * Common methods of the keymaster device. This *must* be the first member of - * keymaster_device as users of this structure will cast a hw_device_t to - * keymaster_device pointer in contexts where it's known the hw_device_t references a - * keymaster_device. - */ - struct hw_device_t common; - - /** - * THIS IS DEPRECATED. Use the new "module_api_version" and "hal_api_version" - * fields in the keymaster_module initialization instead. - */ - uint32_t client_version; - - /** - * See flags defined for keymaster_device::flags above. - */ - uint32_t flags; - - void* context; - - /** - * Generates a public and private key. The key-blob returned is opaque - * and must subsequently provided for signing and verification. - * - * Returns: 0 on success or an error code less than 0. - */ - int (*generate_keypair)(const struct keymaster_device* dev, - const keymaster_keypair_t key_type, const void* key_params, - uint8_t** key_blob, size_t* key_blob_length); - - /** - * Imports a public and private key pair. The imported keys will be in - * PKCS#8 format with DER encoding (Java standard). The key-blob - * returned is opaque and will be subsequently provided for signing - * and verification. - * - * Returns: 0 on success or an error code less than 0. - */ - int (*import_keypair)(const struct keymaster_device* dev, - const uint8_t* key, const size_t key_length, - uint8_t** key_blob, size_t* key_blob_length); - - /** - * Gets the public key part of a key pair. The public key must be in - * X.509 format (Java standard) encoded byte array. - * - * Returns: 0 on success or an error code less than 0. - * On error, x509_data should not be allocated. - */ - int (*get_keypair_public)(const struct keymaster_device* dev, - const uint8_t* key_blob, const size_t key_blob_length, - uint8_t** x509_data, size_t* x509_data_length); - - /** - * Deletes the key pair associated with the key blob. - * - * This function is optional and should be set to NULL if it is not - * implemented. - * - * Returns 0 on success or an error code less than 0. - */ - int (*delete_keypair)(const struct keymaster_device* dev, - const uint8_t* key_blob, const size_t key_blob_length); - - /** - * Deletes all keys in the hardware keystore. Used when keystore is - * reset completely. - * - * This function is optional and should be set to NULL if it is not - * implemented. - * - * Returns 0 on success or an error code less than 0. - */ - int (*delete_all)(const struct keymaster_device* dev); - - /** - * Signs data using a key-blob generated before. This can use either - * an asymmetric key or a secret key. - * - * Returns: 0 on success or an error code less than 0. - */ - int (*sign_data)(const struct keymaster_device* dev, - const void* signing_params, - const uint8_t* key_blob, const size_t key_blob_length, - const uint8_t* data, const size_t data_length, - uint8_t** signed_data, size_t* signed_data_length); - - /** - * Verifies data signed with a key-blob. This can use either - * an asymmetric key or a secret key. - * - * Returns: 0 on successful verification or an error code less than 0. - */ - int (*verify_data)(const struct keymaster_device* dev, - const void* signing_params, - const uint8_t* key_blob, const size_t key_blob_length, - const uint8_t* signed_data, const size_t signed_data_length, - const uint8_t* signature, const size_t signature_length); -}; -typedef struct keymaster_device keymaster_device_t; - - -/* Convenience API for opening and closing keymaster devices */ - -static inline int keymaster_open(const struct hw_module_t* module, - keymaster_device_t** device) -{ - int rc = module->methods->open(module, KEYSTORE_KEYMASTER, - (struct hw_device_t**) device); - - return rc; -} - -static inline int keymaster_close(keymaster_device_t* device) -{ - return device->common.close(&device->common); -} - -__END_DECLS - -#endif // ANDROID_HARDWARE_KEYMASTER_H diff --git a/hardware/keymaster0.h b/hardware/keymaster0.h index f020e5b..52ac64b 100644 --- a/hardware/keymaster0.h +++ b/hardware/keymaster0.h @@ -134,7 +134,7 @@ static inline int keymaster0_open(const struct hw_module_t* module, keymaster0_device_t** device) { int rc = module->methods->open(module, KEYSTORE_KEYMASTER, - (struct hw_device_t**) device); + TO_HW_DEVICE_T_OPEN(device)); return rc; } diff --git a/hardware/keymaster1.h b/hardware/keymaster1.h index 079e5a0..9969380 100644 --- a/hardware/keymaster1.h +++ b/hardware/keymaster1.h @@ -530,62 +530,13 @@ struct keymaster1_device { */ keymaster_error_t (*abort)(const struct keymaster1_device* dev, keymaster_operation_handle_t operation_handle); - - /** - * Generates a pair of ATTK defined in SOTER. Save the private key into RPMB. - * Note that the ATTK generated will never be touched outside the keymaster. - * - * \param[in] dev The keymaster device structure. - * - * \param[in] copy_num The number of copies that will be saved in the RPMB. - */ - keymaster_error_t (*generate_attk_key_pair)(const struct keymaster1_device* dev, - const uint8_t copy_num); - - /** - * Verify the existance ATTK defined in SOTER. - * - * \param[in] dev The keymaster device structure. - * - * Returns: 0 if the ATTK exists. - */ - keymaster_error_t (*verify_attk_key_pair)(const struct keymaster1_device* dev); - - /** - * Export the public key of ATTK in PEM format. - * - * \param[in] dev The keymaster device structure. - * - * \param[out] pub_key_data The public key data in X.509v3 format PEM encoded - * - * \param[out] pub_key_data_length The length of the public key data. - */ - keymaster_error_t (*export_attk_public_key)(const struct keymaster1_device* dev, - const uint8_t* pub_key_data, - const size_t pub_key_data_length); - - /** - * Get Unique device ID. - * - * \param[in] dev The keymaster device structure. - * - * \param[out] device_id The unique id for each device, format as below: - * 1.bytes 0-3: Identify each silicon provider id. - * 2.bytes 4-7: SoC model ID, defined by each silicon provider - * 3.bytes 8-15: Public Chip Serial *Number of SoC, defined by each silicon provider - * - * \param[out] device_id_length The length of the device id. - */ - keymaster_error_t (*get_device_id)(const struct keymaster1_device* dev, - const uint8_t* device_id, - const size_t device_id_length); }; typedef struct keymaster1_device keymaster1_device_t; /* Convenience API for opening and closing keymaster devices */ static inline int keymaster1_open(const struct hw_module_t* module, keymaster1_device_t** device) { - return module->methods->open(module, KEYSTORE_KEYMASTER, (struct hw_device_t**)device); + return module->methods->open(module, KEYSTORE_KEYMASTER, TO_HW_DEVICE_T_OPEN(device)); } static inline int keymaster1_close(keymaster1_device_t* device) { diff --git a/hardware/keymaster2.h b/hardware/keymaster2.h index 565ad2e..f1993f8 100644 --- a/hardware/keymaster2.h +++ b/hardware/keymaster2.h @@ -420,7 +420,7 @@ typedef struct keymaster2_device keymaster2_device_t; /* Convenience API for opening and closing keymaster devices */ static inline int keymaster2_open(const struct hw_module_t* module, keymaster2_device_t** device) { - return module->methods->open(module, KEYSTORE_KEYMASTER, (struct hw_device_t**)device); + return module->methods->open(module, KEYSTORE_KEYMASTER, TO_HW_DEVICE_T_OPEN(device)); } static inline int keymaster2_close(keymaster2_device_t* device) { diff --git a/hardware/keymaster_defs.h b/hardware/keymaster_defs.h index 365fc4d..cec486e 100644 --- a/hardware/keymaster_defs.h +++ b/hardware/keymaster_defs.h @@ -112,6 +112,8 @@ typedef enum { KM_TAG_ALLOW_WHILE_ON_BODY = KM_BOOL | 506, /* Allow key to be used after authentication timeout * if device is still on-body (requires secure * on-body sensor. */ + KM_TAG_UNLOCKED_DEVICE_REQUIRED = KM_BOOL | 508, /* Require the device screen to be unlocked if the + * key is used. */ /* Application access control */ KM_TAG_ALL_APPLICATIONS = KM_BOOL | 600, /* Specified to indicate key is usable by all @@ -135,6 +137,26 @@ typedef enum { KM_TAG_OS_PATCHLEVEL = KM_UINT | 706, /* Patch level of system (keymaster2) */ KM_TAG_UNIQUE_ID = KM_BYTES | 707, /* Used to provide unique ID in attestation */ KM_TAG_ATTESTATION_CHALLENGE = KM_BYTES | 708, /* Used to provide challenge in attestation */ + KM_TAG_ATTESTATION_APPLICATION_ID = KM_BYTES | 709, /* Used to identify the set of possible + * applications of which one has initiated + * a key attestation */ + KM_TAG_ATTESTATION_ID_BRAND = KM_BYTES | 710, /* Used to provide the device's brand name to be + included in attestation */ + KM_TAG_ATTESTATION_ID_DEVICE = KM_BYTES | 711, /* Used to provide the device's device name to be + included in attestation */ + KM_TAG_ATTESTATION_ID_PRODUCT = KM_BYTES | 712, /* Used to provide the device's product name to + be included in attestation */ + KM_TAG_ATTESTATION_ID_SERIAL = KM_BYTES | 713, /* Used to provide the device's serial number to + be included in attestation */ + KM_TAG_ATTESTATION_ID_IMEI = KM_BYTES | 714, /* Used to provide the device's IMEI to be + included in attestation */ + KM_TAG_ATTESTATION_ID_MEID = KM_BYTES | 715, /* Used to provide the device's MEID to be + included in attestation */ + KM_TAG_ATTESTATION_ID_MANUFACTURER = KM_BYTES | 716, /* Used to provide the device's + manufacturer name to be included in + attestation */ + KM_TAG_ATTESTATION_ID_MODEL = KM_BYTES | 717, /* Used to provide the device's model name to be + included in attestation */ /* Tags used only to provide data to or receive data from operations */ KM_TAG_ASSOCIATED_DATA = KM_BYTES | 1000, /* Used to provide associated data for AEAD modes. */ @@ -148,15 +170,6 @@ typedef enum { KM_TAG_RESET_SINCE_ID_ROTATION = KM_BOOL | 1004, /* Whether the device has beeen factory reset since the last unique ID rotation. Used for key attestation. */ - KM_TAG_SOTER_IS_FROM_SOTER = KM_BOOL | 11000, - KM_TAG_SOTER_IS_AUTO_SIGNED_WITH_ATTK_WHEN_GET_PUBLIC_KEY = KM_BOOL | 11001, - KM_TAG_SOTER_IS_AUTO_SIGNED_WITH_COMMON_KEY_WHEN_GET_PUBLIC_KEY = KM_BOOL| 11002, - KM_TAG_SOTER_AUTO_SIGNED_COMMON_KEY_WHEN_GET_PUBLIC_KEY = KM_BYTES | 11003, - KM_TAG_SOTER_AUTO_ADD_COUNTER_WHEN_GET_PUBLIC_KEY = KM_BOOL | 11004, - KM_TAG_SOTER_IS_SECMSG_FID_COUNTER_SIGNED_WHEN_SIGN = KM_BOOL | 11005, - KM_TAG_SOTER_USE_NEXT_ATTK = KM_BOOL | 11006, - KM_TAG_SOTER_UID = KM_UINT | 11007, - KM_TAG_SOTER_AUTO_SIGNED_COMMON_KEY_WHEN_GET_PUBLIC_KEY_BLOB = KM_BYTES | 11008, } keymaster_tag_t; /** @@ -171,6 +184,7 @@ typedef enum { /* Block ciphers algorithms */ KM_ALGORITHM_AES = 32, + KM_ALGORITHM_TRIPLE_DES = 33, /* MAC algorithms */ KM_ALGORITHM_HMAC = 128, @@ -285,6 +299,8 @@ typedef enum { KM_PURPOSE_SIGN = 2, /* Usable with RSA, EC and HMAC keys. */ KM_PURPOSE_VERIFY = 3, /* Usable with RSA, EC and HMAC keys. */ KM_PURPOSE_DERIVE_KEY = 4, /* Usable with EC keys. */ + KM_PURPOSE_WRAP = 5, /* Usable with wrapped keys. */ + } keymaster_purpose_t; typedef struct { @@ -436,13 +452,14 @@ typedef enum { KM_ERROR_KEY_REQUIRES_UPGRADE = -62, KM_ERROR_ATTESTATION_CHALLENGE_MISSING = -63, KM_ERROR_KEYMASTER_NOT_CONFIGURED = -64, + KM_ERROR_ATTESTATION_APPLICATION_ID_MISSING = -65, + KM_ERROR_CANNOT_ATTEST_IDS = -66, + KM_ERROR_DEVICE_LOCKED = -72, KM_ERROR_UNIMPLEMENTED = -100, KM_ERROR_VERSION_MISMATCH = -101, KM_ERROR_UNKNOWN_ERROR = -1000, - - KM_ERROR_SOTER_ERROR = -10000, } keymaster_error_t; /* Convenience functions for manipulating keymaster tag types */ @@ -529,7 +546,7 @@ inline keymaster_key_param_t keymaster_param_date(keymaster_tag_t tag, uint64_t #define KEYMASTER_SIMPLE_COMPARE(a, b) (a < b) ? -1 : ((a > b) ? 1 : 0) inline int keymaster_param_compare(const keymaster_key_param_t* a, const keymaster_key_param_t* b) { - int retval = KEYMASTER_SIMPLE_COMPARE(a->tag, b->tag); + int retval = KEYMASTER_SIMPLE_COMPARE((uint32_t)a->tag, (uint32_t)b->tag); if (retval != 0) return retval; diff --git a/hardware/lights.h b/hardware/lights.h index 29d5e3c..b3d28b0 100644 --- a/hardware/lights.h +++ b/hardware/lights.h @@ -73,12 +73,6 @@ __BEGIN_DECLS #define LIGHT_ID_BLUETOOTH "bluetooth" #define LIGHT_ID_WIFI "wifi" -/* - * Additional hardware-specific lights - */ -#define LIGHT_ID_CAPS "caps" -#define LIGHT_ID_FUNC "func" - /* ************************************************************************ * Flash modes for the flashMode field of light_state_t. */ @@ -142,11 +136,6 @@ __BEGIN_DECLS */ #define BRIGHTNESS_MODE_LOW_PERSISTENCE 2 -/** - * Light mode allows multiple LEDs - */ -#define LIGHT_MODE_MULTIPLE_LEDS 0x01 - /** * The parameters that can be set for a given light. * @@ -167,9 +156,6 @@ struct light_state_t { * * The high byte should be ignored. Callers will set it to 0xff (which * would correspond to 255 alpha). - * - * CyanogenMod: The high byte value can be implemented to control the LEDs - * Brightness from the Lights settings. The value goes from 0x01 to 0xFF. */ unsigned int color; @@ -185,12 +171,6 @@ struct light_state_t { * Currently the values are BRIGHTNESS_MODE_USER and BRIGHTNESS_MODE_SENSOR. */ int brightnessMode; - - /** - * Define the LEDs modes (multiple, ...). - * See the LIGHTS_MODE_* mask constants. - */ - unsigned int ledsModes; }; struct light_device_t { diff --git a/hardware/local_time_hal.h b/hardware/local_time_hal.h index 946e799..1bbbf11 100644 --- a/hardware/local_time_hal.h +++ b/hardware/local_time_hal.h @@ -109,7 +109,7 @@ static inline int local_time_hw_device_open( struct local_time_hw_device** device) { return module->methods->open(module, LOCAL_TIME_HARDWARE_INTERFACE, - (struct hw_device_t**)device); + TO_HW_DEVICE_T_OPEN(device)); } static inline int local_time_hw_device_close(struct local_time_hw_device* device) diff --git a/hardware/nfc-base.h b/hardware/nfc-base.h new file mode 100644 index 0000000..6b63ad2 --- /dev/null +++ b/hardware/nfc-base.h @@ -0,0 +1,34 @@ +// This file is autogenerated by hidl-gen. Do not edit manually. +// Source: android.hardware.nfc@1.0 +// Root: android.hardware:hardware/interfaces + +#ifndef HIDL_GENERATED_ANDROID_HARDWARE_NFC_V1_0_EXPORTED_CONSTANTS_H_ +#define HIDL_GENERATED_ANDROID_HARDWARE_NFC_V1_0_EXPORTED_CONSTANTS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + HAL_NFC_OPEN_CPLT_EVT = 0u, // 0 + HAL_NFC_CLOSE_CPLT_EVT = 1u, // 1 + HAL_NFC_POST_INIT_CPLT_EVT = 2u, // 2 + HAL_NFC_PRE_DISCOVER_CPLT_EVT = 3u, // 3 + HAL_NFC_REQUEST_CONTROL_EVT = 4u, // 4 + HAL_NFC_RELEASE_CONTROL_EVT = 5u, // 5 + HAL_NFC_ERROR_EVT = 6u, // 6 +}; + +enum { + HAL_NFC_STATUS_OK = 0u, // 0 + HAL_NFC_STATUS_FAILED = 1u, // 1 + HAL_NFC_STATUS_ERR_TRANSPORT = 2u, // 2 + HAL_NFC_STATUS_ERR_CMD_TIMEOUT = 3u, // 3 + HAL_NFC_STATUS_REFUSED = 4u, // 4 +}; + +#ifdef __cplusplus +} +#endif + +#endif // HIDL_GENERATED_ANDROID_HARDWARE_NFC_V1_0_EXPORTED_CONSTANTS_H_ diff --git a/hardware/nfc.h b/hardware/nfc.h index 6002e34..fdd79a5 100644 --- a/hardware/nfc.h +++ b/hardware/nfc.h @@ -23,6 +23,7 @@ #include #include +#include "nfc-base.h" __BEGIN_DECLS @@ -54,7 +55,6 @@ __BEGIN_DECLS */ #define NFC_NCI_HARDWARE_MODULE_ID "nfc_nci" #define NFC_NCI_BCM2079X_HARDWARE_MODULE_ID "nfc_nci.bcm2079x" -#define NFC_NCI_NXP_PN54X_HARDWARE_MODULE_ID "nfc_nci.pn54x" #define NFC_NCI_CONTROLLER "nci" /* @@ -70,34 +70,9 @@ typedef struct nfc_nci_module_t { struct hw_module_t common; } nfc_nci_module_t; -/* - * HAL events that can be passed back to the stack - */ typedef uint8_t nfc_event_t; - -enum { - HAL_NFC_OPEN_CPLT_EVT = 0x00, - HAL_NFC_CLOSE_CPLT_EVT = 0x01, - HAL_NFC_POST_INIT_CPLT_EVT = 0x02, - HAL_NFC_PRE_DISCOVER_CPLT_EVT = 0x03, - HAL_NFC_REQUEST_CONTROL_EVT = 0x04, - HAL_NFC_RELEASE_CONTROL_EVT = 0x05, - HAL_NFC_ERROR_EVT = 0x06 -}; - -/* - * Allowed status return values for each of the HAL methods - */ typedef uint8_t nfc_status_t; -enum { - HAL_NFC_STATUS_OK = 0x00, - HAL_NFC_STATUS_FAILED = 0x01, - HAL_NFC_STATUS_ERR_TRANSPORT = 0x02, - HAL_NFC_STATUS_ERR_CMD_TIMEOUT = 0x03, - HAL_NFC_STATUS_REFUSED = 0x04 -}; - /* * The callback passed in from the NFC stack that the HAL * can use to pass events back to the stack. diff --git a/hardware/nvram.h b/hardware/nvram.h index a1868b5..0654afe 100644 --- a/hardware/nvram.h +++ b/hardware/nvram.h @@ -21,6 +21,7 @@ #include #include +#include __BEGIN_DECLS @@ -30,30 +31,7 @@ __BEGIN_DECLS /* The version of this module. */ #define NVRAM_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) -#define NVRAM_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION(0, 1) - -/* Values returned by nvram_device methods. */ -typedef uint32_t nvram_result_t; - -const nvram_result_t NV_RESULT_SUCCESS = 0; -const nvram_result_t NV_RESULT_INTERNAL_ERROR = 1; -const nvram_result_t NV_RESULT_ACCESS_DENIED = 2; -const nvram_result_t NV_RESULT_INVALID_PARAMETER = 3; -const nvram_result_t NV_RESULT_SPACE_DOES_NOT_EXIST = 4; -const nvram_result_t NV_RESULT_SPACE_ALREADY_EXISTS = 5; -const nvram_result_t NV_RESULT_OPERATION_DISABLED = 6; - -/* Values describing available access controls. */ -typedef uint32_t nvram_control_t; - -const nvram_control_t NV_CONTROL_PERSISTENT_WRITE_LOCK = 1; -const nvram_control_t NV_CONTROL_BOOT_WRITE_LOCK = 2; -const nvram_control_t NV_CONTROL_BOOT_READ_LOCK = 3; -const nvram_control_t NV_CONTROL_WRITE_AUTHORIZATION = 4; -const nvram_control_t NV_CONTROL_READ_AUTHORIZATION = 5; -const nvram_control_t NV_CONTROL_WRITE_EXTEND = 6; - -const uint32_t NV_UNLIMITED_SPACES = 0xFFFFFFFF; +#define NVRAM_DEVICE_API_VERSION_1_1 HARDWARE_DEVICE_API_VERSION(1, 1) struct nvram_module { /** @@ -98,6 +76,17 @@ struct nvram_device { nvram_result_t (*get_available_size_in_bytes)( const struct nvram_device* device, uint64_t* available_size); + /** + * Outputs the maximum number of bytes that can be allocated for a single + * space. This will always be at least 32. If an implementation does not + * limit the maximum size it may provide the total size. + * + * device - The nvram_device instance. + * max_space_size - Receives the output. Cannot be NULL. + */ + nvram_result_t (*get_max_space_size_in_bytes)( + const struct nvram_device* device, uint64_t* max_space_size); + /** * Outputs the maximum total number of spaces that may be allocated. * This will always be at least 8. Outputs NV_UNLIMITED_SPACES if any @@ -337,7 +326,7 @@ typedef struct nvram_device nvram_device_t; static inline int nvram_open(const struct hw_module_t* module, nvram_device_t** device) { return module->methods->open(module, NVRAM_HARDWARE_DEVICE_ID, - (struct hw_device_t**)device); + TO_HW_DEVICE_T_OPEN(device)); } static inline int nvram_close(nvram_device_t* device) { diff --git a/hardware/nvram_defs.h b/hardware/nvram_defs.h new file mode 100644 index 0000000..0256a3c --- /dev/null +++ b/hardware/nvram_defs.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * This file contains data type definitions and constants that are useful to + * code interacting with and implementing the NVRAM HAL, even though it doesn't + * use the actual NVRAM HAL module interface. Keeping this in a separate file + * simplifies inclusion in low-level code which can't easily include the heavier + * hardware.h due to lacking standard headers. + */ + +#ifndef ANDROID_HARDWARE_NVRAM_DEFS_H +#define ANDROID_HARDWARE_NVRAM_DEFS_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +/* Values returned by nvram_device methods. */ +typedef uint32_t nvram_result_t; + +const nvram_result_t NV_RESULT_SUCCESS = 0; +const nvram_result_t NV_RESULT_INTERNAL_ERROR = 1; +const nvram_result_t NV_RESULT_ACCESS_DENIED = 2; +const nvram_result_t NV_RESULT_INVALID_PARAMETER = 3; +const nvram_result_t NV_RESULT_SPACE_DOES_NOT_EXIST = 4; +const nvram_result_t NV_RESULT_SPACE_ALREADY_EXISTS = 5; +const nvram_result_t NV_RESULT_OPERATION_DISABLED = 6; + +/* Values describing available access controls. */ +typedef uint32_t nvram_control_t; + +const nvram_control_t NV_CONTROL_PERSISTENT_WRITE_LOCK = 1; +const nvram_control_t NV_CONTROL_BOOT_WRITE_LOCK = 2; +const nvram_control_t NV_CONTROL_BOOT_READ_LOCK = 3; +const nvram_control_t NV_CONTROL_WRITE_AUTHORIZATION = 4; +const nvram_control_t NV_CONTROL_READ_AUTHORIZATION = 5; +const nvram_control_t NV_CONTROL_WRITE_EXTEND = 6; + +const uint32_t NV_UNLIMITED_SPACES = 0xFFFFFFFF; + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus + +#endif // ANDROID_HARDWARE_NVRAM_DEFS_H diff --git a/hardware/power.h b/hardware/power.h index ddb5564..bd8216e 100644 --- a/hardware/power.h +++ b/hardware/power.h @@ -65,16 +65,11 @@ typedef enum { POWER_HINT_SUSTAINED_PERFORMANCE = 0x00000006, POWER_HINT_VR_MODE = 0x00000007, POWER_HINT_LAUNCH = 0x00000008, - POWER_HINT_DISABLE_TOUCH = 0x00000009, - - // CM hints - POWER_HINT_CPU_BOOST = 0x00000110, - POWER_HINT_SET_PROFILE = 0x00000111, + POWER_HINT_DISABLE_TOUCH = 0x00000009 } power_hint_t; typedef enum { - POWER_FEATURE_DOUBLE_TAP_TO_WAKE = 0x00000001, - POWER_FEATURE_SUPPORTED_PROFILES = 0x00001000 + POWER_FEATURE_DOUBLE_TAP_TO_WAKE = 0x00000001 } feature_t; /* @@ -162,15 +157,6 @@ typedef struct { power_state_voter_t *voters; } power_state_platform_sleep_state_t; -/** - * Process info, passed as an opaque handle when - * using POWER_HINT_LAUNCH_BOOST. - */ -typedef struct launch_boost_info { - pid_t pid; - const char* packageName; -} launch_boost_info_t; - /** * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM * and the fields of this data structure must begin with hw_module_t @@ -271,12 +257,6 @@ typedef struct power_module { * The data parameter is non-zero when touch could be disabled, and zero * when touch needs to be re-enabled. * - * POWER_HINT_CPU_BOOST - * - * An operation is happening where it would be ideal for the CPU to - * be boosted for a specific duration. The data parameter is an - * integer value of the boost duration in microseconds. - * * A particular platform may choose to ignore any hint. * * availability: version 0.2 @@ -299,12 +279,6 @@ typedef struct power_module { */ void (*setFeature)(struct power_module *module, feature_t feature, int state); - /* - * (*getFeature) is called to get the current value of a particular - * feature or capability from the hardware or PowerHAL - */ - int (*getFeature)(struct power_module *module, feature_t feature); - /* * Platform-level sleep state stats: * Report cumulative info on the statistics on platform-level sleep states since boot. @@ -363,6 +337,7 @@ typedef struct power_module { } power_module_t; + __END_DECLS #endif // ANDROID_INCLUDE_HARDWARE_POWER_H diff --git a/hardware/qemu_pipe.h b/hardware/qemu_pipe.h deleted file mode 100644 index 53aec97..0000000 --- a/hardware/qemu_pipe.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef ANDROID_INCLUDE_HARDWARE_QEMU_PIPE_H -#define ANDROID_INCLUDE_HARDWARE_QEMU_PIPE_H - -#include -#include -#include -#include -#include /* for pthread_once() */ -#include -#include -#include -#include - -#ifndef D -# define D(...) do{}while(0) -#endif - -/* Try to open a new Qemu fast-pipe. This function returns a file descriptor - * that can be used to communicate with a named service managed by the - * emulator. - * - * This file descriptor can be used as a standard pipe/socket descriptor. - * - * 'pipeName' is the name of the emulator service you want to connect to. - * E.g. 'opengles' or 'camera'. - * - * On success, return a valid file descriptor - * Returns -1 on error, and errno gives the error code, e.g.: - * - * EINVAL -> unknown/unsupported pipeName - * ENOSYS -> fast pipes not available in this system. - * - * ENOSYS should never happen, except if you're trying to run within a - * misconfigured emulator. - * - * You should be able to open several pipes to the same pipe service, - * except for a few special cases (e.g. GSM modem), where EBUSY will be - * returned if more than one client tries to connect to it. - */ -static __inline__ int -qemu_pipe_open(const char* pipeName) -{ - char buff[256]; - int buffLen; - int fd, ret; - - if (pipeName == NULL || pipeName[0] == '\0') { - errno = EINVAL; - return -1; - } - - snprintf(buff, sizeof buff, "pipe:%s", pipeName); - - fd = open("/dev/qemu_pipe", O_RDWR); - if (fd < 0 && errno == ENOENT) - fd = open("/dev/goldfish_pipe", O_RDWR); - if (fd < 0) { - D("%s: Could not open /dev/qemu_pipe: %s", __FUNCTION__, strerror(errno)); - //errno = ENOSYS; - return -1; - } - - buffLen = strlen(buff); - - ret = TEMP_FAILURE_RETRY(write(fd, buff, buffLen+1)); - if (ret != buffLen+1) { - D("%s: Could not connect to %s pipe service: %s", __FUNCTION__, pipeName, strerror(errno)); - if (ret == 0) { - errno = ECONNRESET; - } else if (ret > 0) { - errno = EINVAL; - } - return -1; - } - - return fd; -} - -#endif /* ANDROID_INCLUDE_HARDWARE_QEMUD_PIPE_H */ diff --git a/hardware/qemud.h b/hardware/qemud.h deleted file mode 100644 index 5c39f9c..0000000 --- a/hardware/qemud.h +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_INCLUDE_HARDWARE_QEMUD_H -#define ANDROID_INCLUDE_HARDWARE_QEMUD_H - -#include -#include "qemu_pipe.h" - -/* the following is helper code that is used by the QEMU-specific - * hardware HAL modules to communicate with the emulator program - * through the 'qemud' multiplexing daemon, or through the qemud - * pipe. - * - * see the documentation comments for details in - * development/emulator/qemud/qemud.c - * - * all definitions here are built into the HAL module to avoid - * having to write a tiny shared library for this. - */ - -/* we expect the D macro to be defined to a function macro - * that sends its formatted string argument(s) to the log. - * If not, ignore the traces. - */ -#ifndef D -# define D(...) ((void)0) -#endif - -static __inline__ int -qemud_fd_write(int fd, const void* buff, int len) -{ - int len2; - do { - len2 = write(fd, buff, len); - } while (len2 < 0 && errno == EINTR); - return len2; -} - -static __inline__ int -qemud_fd_read(int fd, void* buff, int len) -{ - int len2; - do { - len2 = read(fd, buff, len); - } while (len2 < 0 && errno == EINTR); - return len2; -} - -static __inline__ int -qemud_channel_open(const char* name) -{ - int fd; - int namelen = strlen(name); - char answer[2]; - char pipe_name[256]; - - /* First, try to connect to the pipe. */ - snprintf(pipe_name, sizeof(pipe_name), "qemud:%s", name); - fd = qemu_pipe_open(pipe_name); - if (fd < 0) { - D("QEMUD pipe is not available for %s: %s", name, strerror(errno)); - /* If pipe is not available, connect to qemud control socket */ - fd = socket_local_client( "qemud", - ANDROID_SOCKET_NAMESPACE_RESERVED, - SOCK_STREAM ); - if (fd < 0) { - D("no qemud control socket: %s", strerror(errno)); - return -1; - } - - /* send service name to connect */ - if (qemud_fd_write(fd, name, namelen) != namelen) { - D("can't send service name to qemud: %s", - strerror(errno)); - close(fd); - return -1; - } - - /* read answer from daemon */ - if (qemud_fd_read(fd, answer, 2) != 2 || - answer[0] != 'O' || answer[1] != 'K') { - D("cant' connect to %s service through qemud", name); - close(fd); - return -1; - } - } - return fd; -} - -static __inline__ int -qemud_channel_send(int fd, const void* msg, int msglen) -{ - char header[5]; - - if (msglen < 0) - msglen = strlen((const char*)msg); - - if (msglen == 0) - return 0; - - snprintf(header, sizeof header, "%04x", msglen); - if (qemud_fd_write(fd, header, 4) != 4) { - D("can't write qemud frame header: %s", strerror(errno)); - return -1; - } - - if (qemud_fd_write(fd, msg, msglen) != msglen) { - D("can4t write qemud frame payload: %s", strerror(errno)); - return -1; - } - return 0; -} - -static __inline__ int -qemud_channel_recv(int fd, void* msg, int msgsize) -{ - char header[5]; - int size, avail; - - if (qemud_fd_read(fd, header, 4) != 4) { - D("can't read qemud frame header: %s", strerror(errno)); - return -1; - } - header[4] = 0; - if (sscanf(header, "%04x", &size) != 1) { - D("malformed qemud frame header: '%.*s'", 4, header); - return -1; - } - if (size > msgsize) - return -1; - - if (qemud_fd_read(fd, msg, size) != size) { - D("can't read qemud frame payload: %s", strerror(errno)); - return -1; - } - return size; -} - -#endif /* ANDROID_INCLUDE_HARDWARE_QEMUD_H */ diff --git a/hardware/radio.h b/hardware/radio.h index 145deb5..413f413 100644 --- a/hardware/radio.h +++ b/hardware/radio.h @@ -285,7 +285,7 @@ static inline int radio_hw_device_open(const struct hw_module_t* module, struct radio_hw_device** device) { return module->methods->open(module, RADIO_HARDWARE_DEVICE, - (struct hw_device_t**)device); + TO_HW_DEVICE_T_OPEN(device)); } static inline int radio_hw_device_close(const struct radio_hw_device* device) diff --git a/hardware/sensors-base.h b/hardware/sensors-base.h new file mode 100644 index 0000000..b0f6223 --- /dev/null +++ b/hardware/sensors-base.h @@ -0,0 +1,137 @@ +// This file is autogenerated by hidl-gen. Do not edit manually. +// Source: android.hardware.sensors@1.0 +// Root: android.hardware:hardware/interfaces + +#ifndef HIDL_GENERATED_ANDROID_HARDWARE_SENSORS_V1_0_EXPORTED_CONSTANTS_H_ +#define HIDL_GENERATED_ANDROID_HARDWARE_SENSORS_V1_0_EXPORTED_CONSTANTS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + SENSOR_HAL_NORMAL_MODE = 0, + SENSOR_HAL_DATA_INJECTION_MODE = 1, +}; + +enum { + SENSOR_TYPE_META_DATA = 0, + SENSOR_TYPE_ACCELEROMETER = 1, + SENSOR_TYPE_MAGNETIC_FIELD = 2, + SENSOR_TYPE_ORIENTATION = 3, + SENSOR_TYPE_GYROSCOPE = 4, + SENSOR_TYPE_LIGHT = 5, + SENSOR_TYPE_PRESSURE = 6, + SENSOR_TYPE_TEMPERATURE = 7, + SENSOR_TYPE_PROXIMITY = 8, + SENSOR_TYPE_GRAVITY = 9, + SENSOR_TYPE_LINEAR_ACCELERATION = 10, + SENSOR_TYPE_ROTATION_VECTOR = 11, + SENSOR_TYPE_RELATIVE_HUMIDITY = 12, + SENSOR_TYPE_AMBIENT_TEMPERATURE = 13, + SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED = 14, + SENSOR_TYPE_GAME_ROTATION_VECTOR = 15, + SENSOR_TYPE_GYROSCOPE_UNCALIBRATED = 16, + SENSOR_TYPE_SIGNIFICANT_MOTION = 17, + SENSOR_TYPE_STEP_DETECTOR = 18, + SENSOR_TYPE_STEP_COUNTER = 19, + SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR = 20, + SENSOR_TYPE_HEART_RATE = 21, + SENSOR_TYPE_TILT_DETECTOR = 22, + SENSOR_TYPE_WAKE_GESTURE = 23, + SENSOR_TYPE_GLANCE_GESTURE = 24, + SENSOR_TYPE_PICK_UP_GESTURE = 25, + SENSOR_TYPE_WRIST_TILT_GESTURE = 26, + SENSOR_TYPE_DEVICE_ORIENTATION = 27, + SENSOR_TYPE_POSE_6DOF = 28, + SENSOR_TYPE_STATIONARY_DETECT = 29, + SENSOR_TYPE_MOTION_DETECT = 30, + SENSOR_TYPE_HEART_BEAT = 31, + SENSOR_TYPE_DYNAMIC_SENSOR_META = 32, + SENSOR_TYPE_ADDITIONAL_INFO = 33, + SENSOR_TYPE_LOW_LATENCY_OFFBODY_DETECT = 34, + SENSOR_TYPE_ACCELEROMETER_UNCALIBRATED = 35, + SENSOR_TYPE_DEVICE_PRIVATE_BASE = 65536, // 0x10000 +}; + +enum { + SENSOR_FLAG_WAKE_UP = 1u, // 1 + SENSOR_FLAG_CONTINUOUS_MODE = 0u, // 0 + SENSOR_FLAG_ON_CHANGE_MODE = 2u, // 2 + SENSOR_FLAG_ONE_SHOT_MODE = 4u, // 4 + SENSOR_FLAG_SPECIAL_REPORTING_MODE = 6u, // 6 + SENSOR_FLAG_DATA_INJECTION = 16u, // 0x10 + SENSOR_FLAG_DYNAMIC_SENSOR = 32u, // 0x20 + SENSOR_FLAG_ADDITIONAL_INFO = 64u, // 0x40 + SENSOR_FLAG_DIRECT_CHANNEL_ASHMEM = 1024u, // 0x400 + SENSOR_FLAG_DIRECT_CHANNEL_GRALLOC = 2048u, // 0x800 + SENSOR_FLAG_MASK_REPORTING_MODE = 14u, // 0xE + SENSOR_FLAG_MASK_DIRECT_REPORT = 896u, // 0x380 + SENSOR_FLAG_MASK_DIRECT_CHANNEL = 3072u, // 0xC00 +}; + +typedef enum { + SENSOR_FLAG_SHIFT_REPORTING_MODE = 1, + SENSOR_FLAG_SHIFT_DATA_INJECTION = 4, + SENSOR_FLAG_SHIFT_DYNAMIC_SENSOR = 5, + SENSOR_FLAG_SHIFT_ADDITIONAL_INFO = 6, + SENSOR_FLAG_SHIFT_DIRECT_REPORT = 7, + SENSOR_FLAG_SHIFT_DIRECT_CHANNEL = 10, +} sensor_flag_shift_t; + +enum { + SENSOR_STATUS_NO_CONTACT = -1, // (-1) + SENSOR_STATUS_UNRELIABLE = 0, + SENSOR_STATUS_ACCURACY_LOW = 1, + SENSOR_STATUS_ACCURACY_MEDIUM = 2, + SENSOR_STATUS_ACCURACY_HIGH = 3, +}; + +enum { + META_DATA_FLUSH_COMPLETE = 1u, // 1 +}; + +typedef enum { + AINFO_BEGIN = 0u, // 0 + AINFO_END = 1u, // 1 + AINFO_UNTRACKED_DELAY = 65536u, // 0x10000 + AINFO_INTERNAL_TEMPERATURE = 65537u, // 65537 + AINFO_VEC3_CALIBRATION = 65538u, // 65538 + AINFO_SENSOR_PLACEMENT = 65539u, // 65539 + AINFO_SAMPLING = 65540u, // 65540 + AINFO_CHANNEL_NOISE = 131072u, // 0x20000 + AINFO_CHANNEL_SAMPLER = 131073u, // 131073 + AINFO_CHANNEL_FILTER = 131074u, // 131074 + AINFO_CHANNEL_LINEAR_TRANSFORM = 131075u, // 131075 + AINFO_CHANNEL_NONLINEAR_MAP = 131076u, // 131076 + AINFO_CHANNEL_RESAMPLER = 131077u, // 131077 + AINFO_LOCAL_GEOMAGNETIC_FIELD = 196608u, // 0x30000 + AINFO_LOCAL_GRAVITY = 196609u, // 196609 + AINFO_DOCK_STATE = 196610u, // 196610 + AINFO_HIGH_PERFORMANCE_MODE = 196611u, // 196611 + AINFO_MAGNETIC_FIELD_CALIBRATION = 196612u, // 196612 + AINFO_CUSTOM_START = 268435456u, // 0x10000000 + AINFO_DEBUGGING_START = 1073741824u, // 0x40000000 +} additional_info_type_t; + +typedef enum { + SENSOR_DIRECT_RATE_STOP = 0, + SENSOR_DIRECT_RATE_NORMAL = 1, + SENSOR_DIRECT_RATE_FAST = 2, + SENSOR_DIRECT_RATE_VERY_FAST = 3, +} direct_rate_level_t; + +typedef enum { + SENSOR_DIRECT_MEM_TYPE_ASHMEM = 1, + SENSOR_DIRECT_MEM_TYPE_GRALLOC = 2, +} direct_mem_type_t; + +typedef enum { + SENSOR_DIRECT_FMT_SENSORS_EVENT = 1, +} direct_format_t; + +#ifdef __cplusplus +} +#endif + +#endif // HIDL_GENERATED_ANDROID_HARDWARE_SENSORS_V1_0_EXPORTED_CONSTANTS_H_ diff --git a/hardware/sensors.h b/hardware/sensors.h index 1d73c31..d058d3b 100644 --- a/hardware/sensors.h +++ b/hardware/sensors.h @@ -24,6 +24,8 @@ #include #include +#include "sensors-base.h" + __BEGIN_DECLS /*****************************************************************************/ @@ -54,14 +56,15 @@ __BEGIN_DECLS #define SENSORS_HARDWARE_POLL "poll" /** - * Handles must be higher than SENSORS_HANDLE_BASE and must be unique. - * A Handle identifies a given sensors. The handle is used to activate - * and/or deactivate sensors. - * In this version of the API there can only be 256 handles. + * Sensor handle is greater than 0 and less than INT32_MAX. + * + * **** Deprecated **** + * Defined values below are kept for code compatibility. Note sensor handle can be as large as + * INT32_MAX. */ #define SENSORS_HANDLE_BASE 0 -#define SENSORS_HANDLE_BITS 8 -#define SENSORS_HANDLE_COUNT (1< 35 degrees - * - * Large accelerations without a change in phone orientation should not trigger a tilt event. - * For example, a sharp turn or strong acceleration while driving a car should not trigger a tilt - * event, even though the angle of the average acceleration might vary by more than 35 degrees. - * - * Typically, this sensor is implemented with the help of only an accelerometer. Other sensors can - * be used as well if they do not increase the power consumption significantly. This is a low power - * sensor that should allow the AP to go into suspend mode. Do not emulate this sensor in the HAL. - * Like other wake up sensors, the driver is expected to a hold a wake_lock with a timeout of 200 ms - * while reporting this event. The only allowed return value is 1.0. - * - * Implement only the wake-up version of this sensor. - */ -#define SENSOR_TYPE_TILT_DETECTOR (22) -#define SENSOR_STRING_TYPE_TILT_DETECTOR "android.sensor.tilt_detector" - -/* - * SENSOR_TYPE_WAKE_GESTURE - * reporting-mode: one-shot - * - * A sensor enabling waking up the device based on a device specific motion. - * - * When this sensor triggers, the device behaves as if the power button was - * pressed, turning the screen on. This behavior (turning on the screen when - * this sensor triggers) might be deactivated by the user in the device - * settings. Changes in settings do not impact the behavior of the sensor: - * only whether the framework turns the screen on when it triggers. - * - * The actual gesture to be detected is not specified, and can be chosen by - * the manufacturer of the device. - * This sensor must be low power, as it is likely to be activated 24/7. - * The only allowed value to return is 1.0. - * - * Implement only the wake-up version of this sensor. - */ -#define SENSOR_TYPE_WAKE_GESTURE (23) -#define SENSOR_STRING_TYPE_WAKE_GESTURE "android.sensor.wake_gesture" - -/* - * SENSOR_TYPE_GLANCE_GESTURE - * reporting-mode: one-shot - * - * A sensor enabling briefly turning the screen on to enable the user to - * glance content on screen based on a specific motion. The device should - * turn the screen off after a few moments. - * - * When this sensor triggers, the device turns the screen on momentarily - * to allow the user to glance notifications or other content while the - * device remains locked in a non-interactive state (dozing). This behavior - * (briefly turning on the screen when this sensor triggers) might be deactivated - * by the user in the device settings. Changes in settings do not impact the - * behavior of the sensor: only whether the framework briefly turns the screen on - * when it triggers. - * - * The actual gesture to be detected is not specified, and can be chosen by - * the manufacturer of the device. - * This sensor must be low power, as it is likely to be activated 24/7. - * The only allowed value to return is 1.0. - * - * Implement only the wake-up version of this sensor. - */ -#define SENSOR_TYPE_GLANCE_GESTURE (24) -#define SENSOR_STRING_TYPE_GLANCE_GESTURE "android.sensor.glance_gesture" - -/** - * SENSOR_TYPE_PICK_UP_GESTURE - * reporting-mode: one-shot - * - * A sensor of this type triggers when the device is picked up regardless of wherever is was - * before (desk, pocket, bag). The only allowed return value is 1.0. - * This sensor de-activates itself immediately after it triggers. - * - * Implement only the wake-up version of this sensor. - */ -#define SENSOR_TYPE_PICK_UP_GESTURE (25) -#define SENSOR_STRING_TYPE_PICK_UP_GESTURE "android.sensor.pick_up_gesture" - -/* - * SENSOR_TYPE_WRIST_TILT_GESTURE - * trigger-mode: special - * wake-up sensor: yes - * - * A sensor of this type triggers an event each time a tilt of the wrist-worn - * device is detected. - * - * This sensor must be low power, as it is likely to be activated 24/7. - * The only allowed value to return is 1.0. - * - * Implement only the wake-up version of this sensor. - */ -#define SENSOR_TYPE_WRIST_TILT_GESTURE (26) -#define SENSOR_STRING_TYPE_WRIST_TILT_GESTURE "android.sensor.wrist_tilt_gesture" - -/* - * SENSOR_TYPE_DEVICE_ORIENTATION - * reporting-mode: on-change - * - * The current orientation of the device. The value should be reported in the - * first element of the 'data' member variable in sensors_event_t. The only - * values that can be reported are (please refer to Android Sensor Coordinate - * System to understand the X and Y axis direction with respect to default - * orientation): - * - 0: device is in default orientation (Y axis is vertical and points up) - * - 1: device is rotated 90 degrees counter-clockwise from default - * orientation (X axis is vertical and points up) - * - 2: device is rotated 180 degrees from default orientation (Y axis is - * vertical and points down) - * - 3: device is rotated 90 degrees clockwise from default orientation (X axis - * is vertical and points down) - * - * Moving the device to an orientation where the Z axis is vertical (either up - * or down) should not cause a new event to be reported. - * - * To improve the user experience of this sensor, it is recommended to implement - * some physical (i.e., rotation angle) and temporal (i.e., delay) hysteresis. - * In other words, minor or transient rotations should not cause a new event to - * be reported. - * - * This sensor should only be implemented with the help of an accelerometer. - * This is a low power sensor that should reduce the number of interrupts of the - * AP. Do not emulate this sensor in the HAL. - * - * Both wake-up and non wake-up versions are useful. - */ -#define SENSOR_TYPE_DEVICE_ORIENTATION (27) -#define SENSOR_STRING_TYPE_DEVICE_ORIENTATION "android.sensor.device_orientation" - -/* - * SENSOR_TYPE_POSE_6DOF - * trigger-mode: continuous - * - * A sensor of this type returns the pose of the device. - * Pose of the device is defined as the orientation of the device from a - * Earth Centered Earth Fixed frame and the translation from an arbitrary - * point at subscription. - * - * This sensor can be high power. It can use any and all of the following - * . Accelerometer - * . Gyroscope - * . Camera - * . Depth Camera - * - */ -#define SENSOR_TYPE_POSE_6DOF (28) -#define SENSOR_STRING_TYPE_POSE_6DOF "android.sensor.pose_6dof" - -/* - * SENSOR_TYPE_STATIONARY_DETECT - * trigger mode: one shot - * - * A sensor of this type returns an event if the device is still/stationary for - * a while. The period of time to monitor for statinarity should be greater than - * 5 seconds, and less than 10 seconds. - * - * Stationarity here refers to absolute stationarity. eg: device on desk. - * - * The only allowed value to return is 1.0. - */ -#define SENSOR_TYPE_STATIONARY_DETECT (29) +#define ADDITIONAL_INFO_SHIFT SENSOR_FLAG_SHIFT_ADDITIONAL_INFO +#define ADDITIONAL_INFO_MASK SENSOR_FLAG_ADDITIONAL_INFO + +/* + * Legacy alias of SENSOR_TYPE_MAGNETIC_FIELD. + * + * Previously, the type of a sensor measuring local magnetic field is named + * SENSOR_TYPE_GEOMAGNETIC_FIELD and SENSOR_TYPE_MAGNETIC_FIELD is its alias. + * SENSOR_TYPE_MAGNETIC_FIELD is redefined as primary name to avoid confusion. + * SENSOR_TYPE_GEOMAGNETIC_FIELD is the alias and is deprecating. New implementation must not use + * SENSOR_TYPE_GEOMAGNETIC_FIELD. + */ +#define SENSOR_TYPE_GEOMAGNETIC_FIELD SENSOR_TYPE_MAGNETIC_FIELD + +/* + * Sensor string types for Android defined sensor types. + * + * For Android defined sensor types, string type will be override in sensor service and thus no + * longer needed to be added to sensor_t data structure. + * + * These definitions are going to be removed soon. + */ +#define SENSOR_STRING_TYPE_ACCELEROMETER "android.sensor.accelerometer" +#define SENSOR_STRING_TYPE_MAGNETIC_FIELD "android.sensor.magnetic_field" +#define SENSOR_STRING_TYPE_ORIENTATION "android.sensor.orientation" +#define SENSOR_STRING_TYPE_GYROSCOPE "android.sensor.gyroscope" +#define SENSOR_STRING_TYPE_LIGHT "android.sensor.light" +#define SENSOR_STRING_TYPE_PRESSURE "android.sensor.pressure" +#define SENSOR_STRING_TYPE_TEMPERATURE "android.sensor.temperature" +#define SENSOR_STRING_TYPE_PROXIMITY "android.sensor.proximity" +#define SENSOR_STRING_TYPE_GRAVITY "android.sensor.gravity" +#define SENSOR_STRING_TYPE_LINEAR_ACCELERATION "android.sensor.linear_acceleration" +#define SENSOR_STRING_TYPE_ROTATION_VECTOR "android.sensor.rotation_vector" +#define SENSOR_STRING_TYPE_RELATIVE_HUMIDITY "android.sensor.relative_humidity" +#define SENSOR_STRING_TYPE_AMBIENT_TEMPERATURE "android.sensor.ambient_temperature" +#define SENSOR_STRING_TYPE_MAGNETIC_FIELD_UNCALIBRATED "android.sensor.magnetic_field_uncalibrated" +#define SENSOR_STRING_TYPE_GAME_ROTATION_VECTOR "android.sensor.game_rotation_vector" +#define SENSOR_STRING_TYPE_GYROSCOPE_UNCALIBRATED "android.sensor.gyroscope_uncalibrated" +#define SENSOR_STRING_TYPE_SIGNIFICANT_MOTION "android.sensor.significant_motion" +#define SENSOR_STRING_TYPE_STEP_DETECTOR "android.sensor.step_detector" +#define SENSOR_STRING_TYPE_STEP_COUNTER "android.sensor.step_counter" +#define SENSOR_STRING_TYPE_GEOMAGNETIC_ROTATION_VECTOR "android.sensor.geomagnetic_rotation_vector" +#define SENSOR_STRING_TYPE_HEART_RATE "android.sensor.heart_rate" +#define SENSOR_STRING_TYPE_TILT_DETECTOR "android.sensor.tilt_detector" +#define SENSOR_STRING_TYPE_WAKE_GESTURE "android.sensor.wake_gesture" +#define SENSOR_STRING_TYPE_GLANCE_GESTURE "android.sensor.glance_gesture" +#define SENSOR_STRING_TYPE_PICK_UP_GESTURE "android.sensor.pick_up_gesture" +#define SENSOR_STRING_TYPE_WRIST_TILT_GESTURE "android.sensor.wrist_tilt_gesture" +#define SENSOR_STRING_TYPE_DEVICE_ORIENTATION "android.sensor.device_orientation" +#define SENSOR_STRING_TYPE_POSE_6DOF "android.sensor.pose_6dof" #define SENSOR_STRING_TYPE_STATIONARY_DETECT "android.sensor.stationary_detect" - -/* - * SENSOR_TYPE_MOTION_DETECT - * trigger mode: one shot - * - * A sensor of this type returns an event if the device is not still for - * a while. The period of time to monitor for statinarity should be greater than - * 5 seconds, and less than 10 seconds. - * - * Motion here refers to any mechanism in which the device is causes to be - * moved in its inertial frame. eg: Pickin up the device and walking with it - * to a nearby room may trigger motion wherewas keeping the device on a table - * on a smooth train moving at constant velocity may not trigger motion. - * - * The only allowed value to return is 1.0. - */ -#define SENSOR_TYPE_MOTION_DETECT (30) #define SENSOR_STRING_TYPE_MOTION_DETECT "android.sensor.motion_detect" - -/* - * SENSOR_TYPE_HEART_BEAT - * trigger mode: continuous - * - * A sensor of this type returns an event everytime a hear beat peak is - * detected. - * - * Peak here ideally corresponds to the positive peak in the QRS complex of - * and ECG signal. - * - * The sensor is not expected to be optimized for latency. As a guide, a - * latency of up to 10 seconds is acceptable. However the timestamp attached - * to the event should be accurate and should correspond to the time the peak - * occured. - * - * The sensor event contains a parameter for the confidence in the detection - * of the peak where 0.0 represent no information at all, and 1.0 represents - * certainty. - */ -#define SENSOR_TYPE_HEART_BEAT (31) #define SENSOR_STRING_TYPE_HEART_BEAT "android.sensor.heart_beat" - -/** - * SENSOR_TYPE_DYNAMIC_SENSOR_META - * trigger-mode: special - * - * A sensor event of this type is received when a dynamic sensor is added to or removed from the - * system. At most one sensor of this type can be present in one sensor HAL implementation and - * presence of a sensor of this type in sensor HAL implementation indicates that this sensor HAL - * supports dynamic sensor feature. Operations, such as batch, activate and setDelay, to this - * special purpose sensor should be treated as no-op and return successful. - * - * A dynamic sensor connection indicates connection of a physical device or instantiation of a - * virtual sensor backed by algorithm; and a dynamic sensor disconnection indicates the the - * opposite. A sensor event of SENSOR_TYPE_DYNAMIC_SENSOR_META type should be delivered regardless - * of the activation status of the sensor in the event of dynamic sensor connection and - * disconnection. In the sensor event, besides the common data entries, "dynamic_sensor_meta", which - * includes fields for connection status, handle of the sensor involved, pointer to sensor_t - * structure and a uuid field, should be populated. - * - * At a dynamic sensor connection event, fields of sensor_t structure referenced by a pointer in - * dynamic_sensor_meta should be filled as if it was regular sensors. Sensor HAL is responsible for - * recovery of memory if the corresponding data is dynamicially allocated. However, the the pointer - * must be valid until the first activate call to the sensor reported in this connection event. At a - * dynamic sensor disconnection, the sensor_t pointer should be NULL. - * - * The sensor handle assigned to dynamic sensors should never be the same as that of any regular - * static sensors, and should be unique until next boot. In another word, if a handle h is used for - * a dynamic sensor A, that same number cannot be used for the same dynamic sensor A or another - * dynamic sensor B even after disconnection of A until reboot. - * - * The UUID field will be used for identifying the sensor in addition to name, vendor and version - * and type. For physical sensors of the same model, all sensors will have the same values in - * sensor_t, but the UUID should be unique and persistent for each individual unit. An all zero UUID - * indicates it is not possible to differentiate individual sensor unit. - * - */ -#define SENSOR_TYPE_DYNAMIC_SENSOR_META (32) -#define SENSOR_STRING_TYPE_DYNAMIC_SENSOR_META "android.sensor.dynamic_sensor_meta" - -/** - * SENSOR_TYPE_ADDITIONAL_INFO - * reporting-mode: N/A - * - * This sensor type is for delivering additional sensor information aside from sensor event data. - * Additional information may include sensor front-end group delay, internal calibration parameters, - * noise level metrics, device internal temperature, etc. - * - * This type will never bind to a sensor. In other words, no sensor in the sensor list should be of - * the type SENSOR_TYPE_ADDITIONAL_INFO. If a sensor HAL supports sensor additional information - * feature, it reports sensor_event_t with "sensor" field set to handle of the reporting sensor and - * "type" field set to SENSOR_TYPE_ADDITIONAL_INFO. Delivery of additional information events is - * triggered under two conditions: an enable activate() call or a flush() call to the corresponding - * sensor. - * - * A single additional information report consists of multiple frames. Sequences of these frames are - * ordered using timestamps, which means the timestamps of sequential frames have to be at least 1 - * nanosecond apart from each other. Each frame is a sensor_event_t delivered through the HAL - * interface, with related data stored in the "additional_info" field, which is of type - * additional_info_event_t. The "type" field of additional_info_event_t denotes the nature of the - * payload data (see additional_info_type_t). The "serial" field is used to keep the sequence of - * payload data that spans multiple frames. The first frame of the entire report is always of type - * AINFO_BEGIN, and the last frame is always AINFO_END. - * - * All additional information frames have to be delivered after flush complete event if flush() was - * triggering the report. - */ -#define SENSOR_TYPE_ADDITIONAL_INFO (33) -#define SENSOR_STRING_TYPE_ADDITIONAL_INFO "android.sensor.additional_info" +#define SENSOR_STRING_TYPE_DYNAMIC_SENSOR_META "android.sensor.dynamic_sensor_meta" +#define SENSOR_STRING_TYPE_ADDITIONAL_INFO "android.sensor.additional_info" +#define SENSOR_STRING_TYPE_LOW_LATENCY_OFFBODY_DETECT "android.sensor.low_latency_offbody_detect" +#define SENSOR_STRING_TYPE_ACCELEROMETER_UNCALIBRATED "android.sensor.accelerometer_uncalibrated" /** * Values returned by the accelerometer in various locations in the universe. @@ -876,16 +199,6 @@ enum { /** Minimum magnetic field on Earth's surface */ #define MAGNETIC_FIELD_EARTH_MIN (30.0f) -/** - * Possible values of the status field of sensor events. - */ -#define SENSOR_STATUS_NO_CONTACT -1 -#define SENSOR_STATUS_UNRELIABLE 0 -#define SENSOR_STATUS_ACCURACY_LOW 1 -#define SENSOR_STATUS_ACCURACY_MEDIUM 2 -#define SENSOR_STATUS_ACCURACY_HIGH 3 - - struct sensor_t; /** @@ -910,7 +223,7 @@ typedef struct { } sensors_vec_t; /** - * uncalibrated gyroscope and magnetometer event data + * uncalibrated accelerometer, gyroscope and magnetometer event data */ typedef struct { union { @@ -977,75 +290,6 @@ typedef struct { }; } additional_info_event_t; -typedef enum additional_info_type { - // - AINFO_BEGIN = 0x0, // Marks the beginning of additional information frames - AINFO_END = 0x1, // Marks the end of additional information frames - // Basic information - AINFO_UNTRACKED_DELAY = 0x10000, // Estimation of the delay that is not tracked by sensor - // timestamps. This includes delay introduced by - // sensor front-end filtering, data transport, etc. - // float[2]: delay in seconds - // standard deviation of estimated value - // - AINFO_INTERNAL_TEMPERATURE, // float: Celsius temperature. - // - AINFO_VEC3_CALIBRATION, // First three rows of a homogeneous matrix, which - // represents calibration to a three-element vector - // raw sensor reading. - // float[12]: 3x4 matrix in row major order - // - AINFO_SENSOR_PLACEMENT, // Location and orientation of sensor element in the - // device frame: origin is the geometric center of the - // mobile device screen surface; the axis definition - // corresponds to Android sensor definitions. - // float[12]: 3x4 matrix in row major order - // - AINFO_SAMPLING, // float[2]: raw sample period in seconds, - // standard deviation of sampling period - - // Sampling channel modeling information - AINFO_CHANNEL_NOISE = 0x20000, // int32_t: noise type - // float[n]: parameters - // - AINFO_CHANNEL_SAMPLER, // float[3]: sample period - // standard deviation of sample period, - // quantization unit - // - AINFO_CHANNEL_FILTER, // Represents a filter: - // \sum_j a_j y[n-j] == \sum_i b_i x[n-i] - // - // int32_t[3]: number of feedforward coefficients, M, - // number of feedback coefficients, N, for - // FIR filter, N=1. - // bit mask that represents which element to - // which the filter is applied, bit 0 == 1 - // means this filter applies to vector - // element 0. - // float[M+N]: filter coefficients (b0, b1, ..., BM-1), - // then (a0, a1, ..., aN-1), a0 is always 1. - // Multiple frames may be needed for higher - // number of taps. - // - AINFO_CHANNEL_LINEAR_TRANSFORM, // int32_t[2]: size in (row, column) ... 1st frame - // float[n]: matrix element values in row major order. - // - AINFO_CHANNEL_NONLINEAR_MAP, // int32_t[2]: extrapolate method - // interpolate method - // float[n]: mapping key points in pairs, (in, out)... - // (may be used to model saturation) - // - AINFO_CHANNEL_RESAMPLER, // int32_t: resample method (0-th order, 1st order...) - // float[1]: resample ratio (upsampling if < 1.0; - // downsampling if > 1.0). - // - - // Custom information - AINFO_CUSTOM_START = 0x10000000, // - // Debugging - AINFO_DEBUGGING_START = 0x40000000, // -} additional_info_type_t; - /** * Union of the various types of sensor data * that can be returned. @@ -1103,6 +347,9 @@ typedef struct sensors_event_t { /* uncalibrated magnetometer values are in micro-Teslas */ uncalibrated_event_t uncalibrated_magnetic; + /* uncalibrated accelerometer values are in meter per second per second (m/s^2) */ + uncalibrated_event_t uncalibrated_accelerometer; + /* heart rate data containing value in bpm and status */ heart_rate_event_t heart_rate; @@ -1151,7 +398,7 @@ struct sensors_module_t { /** * Enumerate all available sensors. The list is returned in "list". - * @return number of sensors in the list + * return number of sensors in the list */ int (*get_sensors_list)(struct sensors_module_t* module, struct sensor_t const** list); @@ -1162,7 +409,7 @@ struct sensors_module_t { * 0 - Normal operation. Default state of the module. * 1 - Loopback mode. Data is injected for the supported * sensors by the sensor service in this mode. - * @return 0 on success + * return 0 on success * -EINVAL if requested mode is not supported * -EPERM if operation is not allowed */ @@ -1225,13 +472,14 @@ struct sensor_t { */ uint32_t fifoMaxEventCount; - /* type of this sensor as a string. Set to corresponding - * SENSOR_STRING_TYPE_*. - * When defining an OEM specific sensor or sensor manufacturer specific - * sensor, use your reserve domain name as a prefix. - * ex: com.google.glass.onheaddetector - * For sensors of known type, the android framework might overwrite this - * string automatically. + /* type of this sensor as a string. + * + * If type is OEM specific or sensor manufacturer specific type + * (>=SENSOR_TYPE_DEVICE_PRIVATE_BASE), this string must be defined with reserved domain of + * vendor/OEM as a prefix, e.g. com.google.glass.onheaddetector + * + * For sensors of Android defined types, Android framework will override this value. It is ok to + * leave it pointing to an empty string. */ const char* stringType; @@ -1277,6 +525,23 @@ struct sensor_t { void* reserved[2]; }; +/** + * Shared memory information for a direct channel + */ +struct sensors_direct_mem_t { + int type; // enum SENSOR_DIRECT_MEM_... + int format; // enum SENSOR_DIRECT_FMT_... + size_t size; // size of the memory region, in bytes + const struct native_handle *handle; // shared memory handle, which is interpreted differently + // depending on type +}; + +/** + * Direct channel report configuration + */ +struct sensors_direct_cfg_t { + int rate_level; // enum SENSOR_DIRECT_RATE_... +}; /* * sensors_poll_device_t is used with SENSORS_DEVICE_API_VERSION_0_1 @@ -1308,11 +573,17 @@ typedef struct sensors_poll_device_1 { struct { struct hw_device_t common; - /* Activate/de-activate one sensor. Return 0 on success, negative + /* Activate/de-activate one sensor. * * sensor_handle is the handle of the sensor to change. * enabled set to 1 to enable, or 0 to disable the sensor. * + * Before sensor activation, existing sensor events that have not + * been picked up by poll() should be abandoned so that application + * upon new activation request will not get stale events. + * (events that are generated during latter activation or during + * data injection mode after sensor deactivation) + * * Return 0 on success, negative errno code otherwise. */ int (*activate)(struct sensors_poll_device_t *dev, @@ -1328,7 +599,13 @@ typedef struct sensors_poll_device_1 { int sensor_handle, int64_t sampling_period_ns); /** - * Returns an array of sensor data. + * Write an array of sensor_event_t to data. The size of the + * available buffer is specified by count. Returns number of + * valid sensor_event_t. + * + * This function should block if there is no sensor event + * available when being called. Thus, return value should always be + * positive. */ int (*poll)(struct sensors_poll_device_t *dev, sensors_event_t* data, int count); @@ -1367,13 +644,67 @@ typedef struct sensors_poll_device_1 { /* * Inject a single sensor sample to be to this device. * data points to the sensor event to be injected - * @return 0 on success + * return 0 on success * -EPERM if operation is not allowed * -EINVAL if sensor event cannot be injected */ int (*inject_sensor_data)(struct sensors_poll_device_1 *dev, const sensors_event_t *data); - void (*reserved_procs[7])(void); + /* + * Register/unregister direct report channel. + * + * A HAL declares support for direct report by setting non-NULL values for both + * register_direct_channel and config_direct_report. + * + * This function has two operation modes: + * + * Register: mem != NULL, register a channel using supplied shared memory information. By the + * time this function returns, sensors must finish initializing shared memory content + * (format dependent, see SENSOR_DIRECT_FMT_*). + * Parameters: + * mem points to a valid struct sensors_direct_mem_t. + * channel_handle is ignored. + * Return value: + * A handle of channel (>0, methods->open(module, - SENSORS_HARDWARE_POLL, (struct hw_device_t**)device); + SENSORS_HARDWARE_POLL, TO_HW_DEVICE_T_OPEN(device)); } static inline int sensors_close(struct sensors_poll_device_t* device) { @@ -1393,7 +724,7 @@ static inline int sensors_close(struct sensors_poll_device_t* device) { static inline int sensors_open_1(const struct hw_module_t* module, sensors_poll_device_1_t** device) { return module->methods->open(module, - SENSORS_HARDWARE_POLL, (struct hw_device_t**)device); + SENSORS_HARDWARE_POLL, TO_HW_DEVICE_T_OPEN(device)); } static inline int sensors_close_1(sensors_poll_device_1_t* device) { diff --git a/hardware/sound_trigger.h b/hardware/sound_trigger.h index e1abbc9..d7828ac 100644 --- a/hardware/sound_trigger.h +++ b/hardware/sound_trigger.h @@ -124,7 +124,7 @@ static inline int sound_trigger_hw_device_open(const struct hw_module_t* module, struct sound_trigger_hw_device** device) { return module->methods->open(module, SOUND_TRIGGER_HARDWARE_INTERFACE, - (struct hw_device_t**)device); + TO_HW_DEVICE_T_OPEN(device)); } static inline int sound_trigger_hw_device_close(struct sound_trigger_hw_device* device) diff --git a/hardware/thermal.h b/hardware/thermal.h index b5b6e1d..5db6ee0 100644 --- a/hardware/thermal.h +++ b/hardware/thermal.h @@ -19,6 +19,7 @@ #include #include +#include #include #include diff --git a/hardware/tv_input.h b/hardware/tv_input.h index ed3fafb..b421d43 100644 --- a/hardware/tv_input.h +++ b/hardware/tv_input.h @@ -23,7 +23,7 @@ #include #include -#include +#include __BEGIN_DECLS diff --git a/hardware/vehicle.h b/hardware/vehicle.h deleted file mode 100644 index a590fbd..0000000 --- a/hardware/vehicle.h +++ /dev/null @@ -1,1750 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_VEHICLE_INTERFACE_H -#define ANDROID_VEHICLE_INTERFACE_H - -#include -#include -#include -#include -#include - -#include -#include - -__BEGIN_DECLS - -/*****************************************************************************/ - -#define VEHICLE_HEADER_VERSION 1 -#define VEHICLE_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) -#define VEHICLE_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION_2(1, 0, VEHICLE_HEADER_VERSION) - -/** - * Vehicle HAL to provide interfaces to various Car related sensors. The HAL is - * designed in a property, value maping where each property has a value which - * can be "get", "set" and "(un)subscribed" to. Subscribing will require the - * user of this HAL to provide parameters such as sampling rate. - */ - - -/* - * The id of this module - */ -#define VEHICLE_HARDWARE_MODULE_ID "vehicle" - -/** - * Name of the vehicle device to open - */ -#define VEHICLE_HARDWARE_DEVICE "vehicle_hw_device" - -/** - * Each vehicle property is defined with various annotations to specify the type of information. - * Annotations will be used by scripts to run some type check or generate some boiler-plate codes. - * Also the annotations are the specification for each property, and each HAL implementation should - * follow what is specified as annotations. - * Here is the list of annotations with explanation on what it does: - * @value_type: Type of data for this property. One of the value from vehicle_value_type should be - * set here. - * @change_mode: How this property changes. Value set is from vehicle_prop_change_mode. Some - * properties can allow either on change or continuous mode and it is up to HAL - * implementation to choose which mode to use. - * @access: Define how this property can be accessed. read only, write only or R/W from - * vehicle_prop_access - * @data_member: Name of member from vehicle_value union to access this data. - * @data_enum: enum type that should be used for the data. - * @unit: Unit of data. Should be from vehicle_unit_type. - * @config_flags: Usage of config_flags in vehicle_prop_config - * @config_array: Usage of config_array in vehicle_prop_config. When this is specified, - * @config_flags will not be used. - * @config_string: Explains the usage of config_string in vehicle_prop_config. Property with - * this annotation is expected to have additional information in config_string - * for that property to work. - * @zone_type type of zoned used. defined for zoned property - * @range_start, @range_end : define range of specific property values. - * @allow_out_of_range_value : This property allows out of range value to deliver additional - * information. Check VEHICLE_*_OUT_OF_RANGE_* for applicable values. - */ -//===== Vehicle Information ==== - -/** - * Invalid property value used for argument where invalid property gives different result. - * @range_start - */ -#define VEHICLE_PROPERTY_INVALID (0x0) - -/** - * VIN of vehicle - * @value_type VEHICLE_VALUE_TYPE_STRING - * @change_mode VEHICLE_PROP_CHANGE_MODE_STATIC - * @access VEHICLE_PROP_ACCESS_READ - * @data_member info_vin - */ -#define VEHICLE_PROPERTY_INFO_VIN (0x00000100) - -/** - * Maker name of vehicle - * @value_type VEHICLE_VALUE_TYPE_STRING - * @change_mode VEHICLE_PROP_CHANGE_MODE_STATIC - * @access VEHICLE_PROP_ACCESS_READ - * @data_member info_make - */ -#define VEHICLE_PROPERTY_INFO_MAKE (0x00000101) - -/** - * Model of vehicle - * @value_type VEHICLE_VALUE_TYPE_STRING - * @change_mode VEHICLE_PROP_CHANGE_MODE_STATIC - * @access VEHICLE_PROP_ACCESS_READ - * @data_member info_model - */ -#define VEHICLE_PROPERTY_INFO_MODEL (0x00000102) - -/** - * Model year of vehicle. - * @value_type VEHICLE_VALUE_TYPE_INT32 - * @change_mode VEHICLE_PROP_CHANGE_MODE_STATIC - * @access VEHICLE_PROP_ACCESS_READ - * @data_member info_model_year - * @unit VEHICLE_UNIT_TYPE_YEAR - */ -#define VEHICLE_PROPERTY_INFO_MODEL_YEAR (0x00000103) - -/** - * Fuel capacity of the vehicle - * @value_type VEHICLE_VALUE_TYPE_FLOAT - * @change_mode VEHICLE_PROP_CHANGE_MODE_STATIC - * @access VEHICLE_PROP_ACCESS_READ - * @data_member info_fuel_capacity - * @unit VEHICLE_UNIT_TYPE_VEHICLE_UNIT_TYPE_MILLILITER - */ -#define VEHICLE_PROPERTY_INFO_FUEL_CAPACITY (0x00000104) - - -//==== Vehicle Performance Sensors ==== - -/** - * Current odometer value of the vehicle - * @value_type VEHICLE_VALUE_TYPE_FLOAT - * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE|VEHICLE_PROP_CHANGE_MODE_CONTINUOUS - * @access VEHICLE_PROP_ACCESS_READ - * @data_member odometer - * @unit VEHICLE_UNIT_TYPE_KILOMETER - */ -#define VEHICLE_PROPERTY_PERF_ODOMETER (0x00000204) - -/** - * Speed of the vehicle - * @value_type VEHICLE_VALUE_TYPE_FLOAT - * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE|VEHICLE_PROP_CHANGE_MODE_CONTINUOUS - * @access VEHICLE_PROP_ACCESS_READ - * @data_member vehicle_speed - * @unit VEHICLE_UNIT_TYPE_METER_PER_SEC - */ -#define VEHICLE_PROPERTY_PERF_VEHICLE_SPEED (0x00000207) - - -//==== Engine Sensors ==== - -/** - * Temperature of engine coolant - * @value_type VEHICLE_VALUE_TYPE_FLOAT - * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE|VEHICLE_PROP_CHANGE_MODE_CONTINUOUS - * @access VEHICLE_PROP_ACCESS_READ - * @data_member engine_coolant_temperature - * @unit VEHICLE_UNIT_TYPE_CELCIUS - */ -#define VEHICLE_PROPERTY_ENGINE_COOLANT_TEMP (0x00000301) - -/** - * Temperature of engine oil - * @value_type VEHICLE_VALUE_TYPE_FLOAT - * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE|VEHICLE_PROP_CHANGE_MODE_CONTINUOUS - * @access VEHICLE_PROP_ACCESS_READ - * @data_member engine_oil_temperature - * @unit VEHICLE_UNIT_TYPE_CELCIUS - */ -#define VEHICLE_PROPERTY_ENGINE_OIL_TEMP (0x00000304) -/** - * Engine rpm - * @value_type VEHICLE_VALUE_TYPE_FLOAT - * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE|VEHICLE_PROP_CHANGE_MODE_CONTINUOUS - * @access VEHICLE_PROP_ACCESS_READ - * @data_member engine_rpm - * @unit VEHICLE_UNIT_TYPE_RPM - */ -#define VEHICLE_PROPERTY_ENGINE_RPM (0x00000305) - -//==== Event Sensors ==== - -/** - * Currently selected gear - * @value_type VEHICLE_VALUE_TYPE_INT32 - * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE - * @access VEHICLE_PROP_ACCESS_READ - * @data_member gear_selection - * @data_enum vehicle_gear - */ -#define VEHICLE_PROPERTY_GEAR_SELECTION (0x00000400) - -/** - * Current gear. In non-manual case, selected gear does not necessarily match the current gear - * @value_type VEHICLE_VALUE_TYPE_INT32 - * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE - * @access VEHICLE_PROP_ACCESS_READ - * @data_member gear_current_gear - * @data_enum vehicle_gear - */ -#define VEHICLE_PROPERTY_CURRENT_GEAR (0x00000401) - -/** - * Parking brake state. - * @value_type VEHICLE_VALUE_TYPE_BOOLEAN - * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE - * @access VEHICLE_PROP_ACCESS_READ - * @data_member parking_brake - * @data_enum vehicle_boolean - */ -#define VEHICLE_PROPERTY_PARKING_BRAKE_ON (0x00000402) - -/** - * Driving status policy. - * @value_type VEHICLE_VALUE_TYPE_INT32 - * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE - * @access VEHICLE_PROP_ACCESS_READ - * @data_member driving_status - * @data_enum vehicle_driving_status - */ -#define VEHICLE_PROPERTY_DRIVING_STATUS (0x00000404) - -/** - * Warning for fuel low level. - * @value_type VEHICLE_VALUE_TYPE_BOOLEAN - * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE - * @access VEHICLE_PROP_ACCESS_READ - * @data_member is_fuel_level_low - * @data_enum vehicle_boolean - */ -#define VEHICLE_PROPERTY_FUEL_LEVEL_LOW (0x00000405) - -/** - * Night mode or not. - * @value_type VEHICLE_VALUE_TYPE_BOOLEAN - * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE - * @access VEHICLE_PROP_ACCESS_READ - * @data_member night_mode - * @data_enum vehicle_boolean - */ -#define VEHICLE_PROPERTY_NIGHT_MODE (0x00000407) - - - - //==== HVAC Properties ==== - -/** - * Fan speed setting - * @value_type VEHICLE_VALUE_TYPE_ZONED_INT32 - * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE - * @access VEHICLE_PROP_ACCESS_READ_WRITE - * @data_member hvac.fan_speed - * @zone_type VEHICLE_ZONE - * @data_enum TODO - * @allow_out_of_range_value : OFF - */ -#define VEHICLE_PROPERTY_HVAC_FAN_SPEED (0x00000500) - -/** - * Fan direction setting - * @value_type VEHICLE_VALUE_TYPE_ZONED_INT32 - * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE - * @access VEHICLE_PROP_ACCESS_READ_WRITE - * @data_member hvac.fan_direction - * @zone_type VEHICLE_ZONE - * @data_enum TODO - * @allow_out_of_range_value : OFF - */ -#define VEHICLE_PROPERTY_HVAC_FAN_DIRECTION (0x00000501) - -/* - * Bit flags for fan direction - */ -enum vehicle_hvac_fan_direction { - VEHICLE_HVAC_FAN_DIRECTION_FACE = 0x1, - VEHICLE_HVAC_FAN_DIRECTION_FLOOR = 0x2, - VEHICLE_HVAC_FAN_DIRECTION_FACE_AND_FLOOR = 0x3, - VEHICLE_HVAC_FAN_DIRECTION_DEFROST = 0x4, - VEHICLE_HVAC_FAN_DIRECTION_DEFROST_AND_FLOOR = 0x5 -}; - -/** - * HVAC current temperature. - * @value_type VEHICLE_VALUE_TYPE_ZONED_FLOAT - * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE|VEHICLE_PROP_CHANGE_MODE_CONTINUOUS - * @access VEHICLE_PROP_ACCESS_READ_WRITE - * @zone_type VEHICLE_ZONE - * @data_member hvac.temperature_current - */ -#define VEHICLE_PROPERTY_HVAC_TEMPERATURE_CURRENT (0x00000502) - -/** - * HVAC, target temperature set. - * @value_type VEHICLE_VALUE_TYPE_ZONED_FLOAT - * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE|VEHICLE_PROP_CHANGE_MODE_CONTINUOUS - * @access VEHICLE_PROP_ACCESS_READ_WRITE - * @zone_type VEHICLE_ZONE - * @data_member hvac.temperature_set - * @allow_out_of_range_value : MIN / MAX / OFF - */ -#define VEHICLE_PROPERTY_HVAC_TEMPERATURE_SET (0x00000503) - -/** - * On/off defrost - * @value_type VEHICLE_VALUE_TYPE_ZONED_BOOLEAN - * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE - * @access VEHICLE_PROP_ACCESS_READ_WRITE - * @zone_type VEHICLE_WINDOW - * @data_member hvac.defrost_on - */ -#define VEHICLE_PROPERTY_HVAC_DEFROSTER (0x00000504) - -/** - * On/off AC - * @value_type VEHICLE_VALUE_TYPE_ZONED_BOOLEAN - * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE - * @access VEHICLE_PROP_ACCESS_READ_WRITE - * @config_flags Supported zones - * @zone_type VEHICLE_ZONE - * @data_member hvac.ac_on - */ -#define VEHICLE_PROPERTY_HVAC_AC_ON (0x00000505) - -/** - * On/off max AC - * @value_type VEHICLE_VALUE_TYPE_ZONED_BOOLEAN - * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE - * @access VEHICLE_PROP_ACCESS_READ_WRITE - * @zone_type VEHICLE_ZONE - * @data_member hvac.max_ac_on - */ -#define VEHICLE_PROPERTY_HVAC_MAX_AC_ON (0x00000506) - -/** - * On/off max defrost - * @value_type VEHICLE_VALUE_TYPE_ZONED_BOOLEAN - * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE - * @access VEHICLE_PROP_ACCESS_READ_WRITE - * @zone_type VEHICLE_ZONE - * @data_member hvac.max_defrost_on - */ -#define VEHICLE_PROPERTY_HVAC_MAX_DEFROST_ON (0x00000507) - -/** - * On/off re-circulation - * @value_type VEHICLE_VALUE_TYPE_ZONED_BOOLEAN - * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE - * @access VEHICLE_PROP_ACCESS_READ_WRITE - * @zone_type VEHICLE_ZONE - * @data_member hvac.max_recirc_on - */ -#define VEHICLE_PROPERTY_HVAC_RECIRC_ON (0x00000508) - -/** - * On/off dual. This will be defined per each row. - * @value_type VEHICLE_VALUE_TYPE_ZONED_BOOLEAN - * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE - * @access VEHICLE_PROP_ACCESS_READ_WRITE - * @zone_type VEHICLE_ZONE - * @data_member hvac.dual_on - */ -#define VEHICLE_PROPERTY_HVAC_DUAL_ON (0x00000509) - -/** - * Represents power state for HVAC. Some HVAC properties will require matching power to be turned on - * to get out of OFF state. For non-zoned HVAC properties, VEHICLE_ALL_ZONE corresponds to - * global power state. - * - * @value_type VEHICLE_VALUE_TYPE_ZONED_BOOLEAN - * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE - * @access VEHICLE_PROP_ACCESS_READ_WRITE - * @config_string list of HVAC properties whose power is controlled by this property. Format is - * hexa-decimal number (0x...) separated by comma like "0x500,0x503". All zones - * defined in these affected properties should be available in the property. - * @zone_type VEHICLE_ZONE - * @data_member hvac.power_on - */ -#define VEHICLE_PROPERTY_HVAC_POWER_ON (0x00000510) - -/** - * Outside temperature - * @value_type VEHICLE_VALUE_TYPE_FLOAT - * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE|VEHICLE_PROP_CHANGE_MODE_CONTINUOUS - * @access VEHICLE_PROP_ACCESS_READ - * @data_member outside_temperature - * @unit VEHICLE_UNIT_TYPE_CELCIUS - */ - -#define VEHICLE_PROPERTY_ENV_OUTSIDE_TEMPERATURE (0x00000703) - - -/** - * Cabin temperature - * @value_type VEHICLE_VALUE_TYPE_FLOAT - * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE|VEHICLE_PROP_CHANGE_MODE_CONTINUOUS - * @access VEHICLE_PROP_ACCESS_READ - * @data_member cabin_temperature - * @unit VEHICLE_UNIT_TYPE_CELCIUS - */ -#define VEHICLE_PROPERTY_ENV_CABIN_TEMPERATURE (0x00000704) - - -/* - * Radio features. - */ -/** - * Radio presets stored on the Car radio module. The data type used is int32 - * array with the following fields: - *
    - *
  • int32_array[0]: Preset number
  • - *
  • int32_array[1]: Band type (see #RADIO_BAND_FM in - * system/core/include/system/radio.h). - *
  • int32_array[2]: Channel number
  • - *
  • int32_array[3]: Sub channel number
  • - *
- * - * NOTE: When getting a current preset config ONLY set preset number (i.e. - * int32_array[0]). For setting a preset other fields are required. - * - * @value_type VEHICLE_VALUE_TYPE_INT32_VEC4 - * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE - * @access VEHICLE_PROP_ACCESS_READ_WRITE - * @config_flags Number of presets supported - * @data_member int32_array - */ -#define VEHICLE_PROPERTY_RADIO_PRESET (0x0000801) - -/** - * Constants relevant to radio. - */ -enum vehicle_radio_consts { - /** Minimum value for the radio preset */ - VEHICLE_RADIO_PRESET_MIN_VALUE = 1, -}; - -/** - * Represents audio focus state of Android side. Note that car's audio module will own audio - * focus and grant audio focus to Android side when requested by Android side. The focus has both - * per stream characteristics and global characteristics. - * - * Focus request (get of this property) will take the following form in int32_vec4: - * int32_array[0]: vehicle_audio_focus_request type - * int32_array[1]: bit flags of streams requested by this focus request. There can be up to - * 32 streams. - * int32_array[2]: External focus state flags. For request, only flag like - * VEHICLE_AUDIO_EXT_FOCUS_CAR_PLAY_ONLY_FLAG or - * VEHICLE_AUDIO_EXT_FOCUS_CAR_MUTE_MEDIA_FLAG can be used. - * VEHICLE_AUDIO_EXT_FOCUS_CAR_PLAY_ONLY_FLAG is for case like radio where android - * side app still needs to hold focus but playback is done outside Android. - * VEHICLE_AUDIO_EXT_FOCUS_CAR_MUTE_MEDIA_FLAG is for muting media channel - * including radio. VEHICLE_AUDIO_EXT_FOCUS_CAR_MUTE_MEDIA_FLAG can be set even - * if android side releases focus (request type REQUEST_RELEASE). In that case, - * audio module should maintain mute state until user's explicit action to - * play some media. - * int32_array[3]: Currently active audio contexts. Use combination of flags from - * vehicle_audio_context_flag. - * This can be used as a hint to adjust audio policy or other policy decision. - * Note that there can be multiple context active at the same time. And android - * can send the same focus request type gain due to change in audio contexts. - * Note that each focus request can request multiple streams that is expected to be used for - * the current request. But focus request itself is global behavior as GAIN or GAIN_TRANSIENT - * expects all sounds played by car's audio module to stop. Note that stream already allocated to - * android before this focus request should not be affected by focus request. - * - * Focus response (set and subscription callback for this property) will take the following form: - * int32_array[0]: vehicle_audio_focus_state type - * int32_array[1]: bit flags of streams allowed. - * int32_array[2]: External focus state: bit flags of currently active audio focus in car - * side (outside Android). Active audio focus does not necessarily mean currently - * playing, but represents the state of having focus or waiting for focus - * (pause state). - * One or combination of flags from vehicle_audio_ext_focus_flag. - * 0 means no active audio focus holder outside Android. - * The state will have following values for each vehicle_audio_focus_state_type: - * GAIN: 0 or VEHICLE_AUDIO_EXT_FOCUS_CAR_PLAY_ONLY when radio is active in - * Android side. - * GAIN_TRANSIENT: 0. Can be VEHICLE_AUDIO_EXT_FOCUS_CAR_PERMANENT or - * VEHICLE_AUDIO_EXT_FOCUS_CAR_TRANSIENT if android side has requested - * GAIN_TRANSIENT_MAY_DUCK and car side is ducking. - * LOSS: 0 when no focus is audio is active in car side. - * VEHICLE_AUDIO_EXT_FOCUS_CAR_PERMANENT when car side is playing something - * permanent. - * LOSS_TRANSIENT: always should be VEHICLE_AUDIO_EXT_FOCUS_CAR_TRANSIENT - * int32_array[3]: should be zero. - * - * If car does not support VEHICLE_PROPERTY_AUDIO_FOCUS, focus is assumed to be granted always. - * - * @value_type VEHICLE_VALUE_TYPE_INT32_VEC4 - * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE - * @access VEHICLE_PROP_ACCESS_READ_WRITE - * @data_member int32_array - */ -#define VEHICLE_PROPERTY_AUDIO_FOCUS (0x00000900) - -enum vehicle_audio_focus_request { - VEHICLE_AUDIO_FOCUS_REQUEST_GAIN = 0x1, - VEHICLE_AUDIO_FOCUS_REQUEST_GAIN_TRANSIENT = 0x2, - VEHICLE_AUDIO_FOCUS_REQUEST_GAIN_TRANSIENT_MAY_DUCK = 0x3, - /** - * This is for the case where android side plays sound like UI feedback - * and car side does not need to duck existing playback as long as - * requested stream is available. - */ - VEHICLE_AUDIO_FOCUS_REQUEST_GAIN_TRANSIENT_NO_DUCK = 0x4, - VEHICLE_AUDIO_FOCUS_REQUEST_RELEASE = 0x5, -}; - -enum vehicle_audio_focus_state { - /** - * Android side has permanent focus and can play allowed streams. - */ - VEHICLE_AUDIO_FOCUS_STATE_GAIN = 0x1, - /** - * Android side has transient focus and can play allowed streams. - */ - VEHICLE_AUDIO_FOCUS_STATE_GAIN_TRANSIENT = 0x2, - /** - * Car audio module is playing guidance kind of sound outside Android. Android side can - * still play through allowed streams with ducking. - */ - VEHICLE_AUDIO_FOCUS_STATE_LOSS_TRANSIENT_CAN_DUCK = 0x3, - /** - * Car audio module is playing transient sound outside Android. Android side should stop - * playing any sounds. - */ - VEHICLE_AUDIO_FOCUS_STATE_LOSS_TRANSIENT = 0x4, - /** - * Android side has lost focus and cannot play any sound. - */ - VEHICLE_AUDIO_FOCUS_STATE_LOSS = 0x5, - /** - * car audio module is playing safety critical sound, and Android side cannot request focus - * until the current state is finished. car audio module should restore it to the previous - * state when it can allow Android to play. - */ - VEHICLE_AUDIO_FOCUS_STATE_LOSS_TRANSIENT_EXLCUSIVE = 0x6, -}; - -/** - * Flags to represent multiple streams by combining these. - */ -enum vehicle_audio_stream_flag { - VEHICLE_AUDIO_STREAM_STREAM0_FLAG = (0x1<<0), - VEHICLE_AUDIO_STREAM_STREAM1_FLAG = (0x1<<1), - VEHICLE_AUDIO_STREAM_STREAM2_FLAG = (0x1<<2), -}; - -/** - * Represents stream number (always 0 to N -1 where N is max number of streams). - * Can be used for audio related property expecting one stream. - */ -enum vehicle_audio_stream { - VEHICLE_AUDIO_STREAM0 = 0, - VEHICLE_AUDIO_STREAM1 = 1, -}; - -/** - * Flag to represent external focus state (outside Android). - */ -enum vehicle_audio_ext_focus_flag { - /** - * No external focus holder. - */ - VEHICLE_AUDIO_EXT_FOCUS_NONE_FLAG = 0x0, - /** - * Car side (outside Android) has component holding GAIN kind of focus state. - */ - VEHICLE_AUDIO_EXT_FOCUS_CAR_PERMANENT_FLAG = 0x1, - /** - * Car side (outside Android) has component holding GAIN_TRANSIENT kind of focus state. - */ - VEHICLE_AUDIO_EXT_FOCUS_CAR_TRANSIENT_FLAG = 0x2, - /** - * Car side is expected to play something while focus is held by Android side. One example - * can be radio attached in car side. But Android's radio app still should have focus, - * and Android side should be in GAIN state, but media stream will not be allocated to Android - * side and car side can play radio any time while this flag is active. - */ - VEHICLE_AUDIO_EXT_FOCUS_CAR_PLAY_ONLY_FLAG = 0x4, - /** - * Car side should mute any media including radio. This can be used with any focus request - * including GAIN* and RELEASE. - */ - VEHICLE_AUDIO_EXT_FOCUS_CAR_MUTE_MEDIA_FLAG = 0x8, -}; - -/** - * Index in int32_array for VEHICLE_PROPERTY_AUDIO_FOCUS property. - */ -enum vehicle_audio_focus_index { - VEHICLE_AUDIO_FOCUS_INDEX_FOCUS = 0, - VEHICLE_AUDIO_FOCUS_INDEX_STREAMS = 1, - VEHICLE_AUDIO_FOCUS_INDEX_EXTERNAL_FOCUS_STATE = 2, - VEHICLE_AUDIO_FOCUS_INDEX_AUDIO_CONTEXTS = 3, -}; - -/** - * Flags to tell the current audio context. - */ -enum vehicle_audio_context_flag { - /** Music playback is currently active. */ - VEHICLE_AUDIO_CONTEXT_MUSIC_FLAG = 0x1, - /** Navigation is currently running. */ - VEHICLE_AUDIO_CONTEXT_NAVIGATION_FLAG = 0x2, - /** Voice command session is currently running. */ - VEHICLE_AUDIO_CONTEXT_VOICE_COMMAND_FLAG = 0x4, - /** Voice call is currently active. */ - VEHICLE_AUDIO_CONTEXT_CALL_FLAG = 0x8, - /** Alarm is active. This may be only used in VEHICLE_PROPERTY_AUDIO_ROUTING_POLICY. */ - VEHICLE_AUDIO_CONTEXT_ALARM_FLAG = 0x10, - /** - * Notification sound is active. This may be only used in VEHICLE_PROPERTY_AUDIO_ROUTING_POLICY. - */ - VEHICLE_AUDIO_CONTEXT_NOTIFICATION_FLAG = 0x20, - /** - * Context unknown. Only used for VEHICLE_PROPERTY_AUDIO_ROUTING_POLICY to represent default - * stream for unknown contents. - */ - VEHICLE_AUDIO_CONTEXT_UNKNOWN_FLAG = 0x40, - /** Safety alert / warning is played. */ - VEHICLE_AUDIO_CONTEXT_SAFETY_ALERT_FLAG = 0x80, - /** CD / DVD kind of audio is played */ - VEHICLE_AUDIO_CONTEXT_CD_ROM_FLAG = 0x100, - /** Aux audio input is played */ - VEHICLE_AUDIO_CONTEXT_AUX_AUDIO_FLAG = 0x200, - /** system sound like UI feedback */ - VEHICLE_AUDIO_CONTEXT_SYSTEM_SOUND_FLAG = 0x400, - /** Radio is played */ - VEHICLE_AUDIO_CONTEXT_RADIO_FLAG = 0x800, -}; - -/** - * Property to control audio volume of each audio context. - * - * Data type looks like: - * int32_array[0] : stream context as defined in vehicle_audio_context_flag. - * int32_array[1] : volume level, valid range is 0 to int32_max_value defined in config. - * 0 will be mute state. int32_min_value in config should be always 0. - * int32_array[2] : One of vehicle_audio_volume_state. - * - * This property requires per stream based get. HAL implementation should check stream number - * in get call to return the right volume. - * - * @value_type VEHICLE_VALUE_TYPE_INT32_VEC3 - * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE - * @access VEHICLE_PROP_ACCESS_READ_WRITE - * @config_flags all audio contexts supported. - * @data_member int32_array - */ -#define VEHICLE_PROPERTY_AUDIO_VOLUME (0x00000901) - -/** - * enum to represent audio volume state. - */ -enum vehicle_audio_volume_state { - VEHICLE_AUDIO_VOLUME_STATE_OK = 0, - /** - * Audio volume has reached volume limit set in VEHICLE_PROPERTY_AUDIO_VOLUME_LIMIT - * and user's request to increase volume further is not allowed. - */ - VEHICLE_AUDIO_VOLUME_STATE_LIMIT_REACHED = 1, -}; - -/** - * Index in int32_array for VEHICLE_PROPERTY_AUDIO_VOLUME property. - */ -enum vehicle_audio_volume_index { - VEHICLE_AUDIO_VOLUME_INDEX_STREAM = 0, - VEHICLE_AUDIO_VOLUME_INDEX_VOLUME = 1, - VEHICLE_AUDIO_VOLUME_INDEX_STATE = 2, -}; - -/** - * Property for handling volume limit set by user. This limits maximum volume that can be set - * per each context. - * int32_array[0] : stream context as defined in vehicle_audio_context_flag. - * int32_array[1] : maximum volume set to the stream. If there is no restriction, this value - * will be bigger than VEHICLE_PROPERTY_AUDIO_VOLUME's max value. - * - * If car does not support this feature, this property should not be populated by HAL. - * This property requires per stream based get. HAL implementation should check stream number - * in get call to return the right volume. - * - * @value_type VEHICLE_VALUE_TYPE_INT32_VEC2 - * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE - * @access VEHICLE_PROP_ACCESS_READ_WRITE - * @config_flags all audio contexts supported. - * @data_member int32_array - */ -#define VEHICLE_PROPERTY_AUDIO_VOLUME_LIMIT (0x00000902) - -/** - * Index in int32_array for VEHICLE_PROPERTY_AUDIO_VOLUME_LIMIT property. - */ -enum vehicle_audio_volume_limit_index { - VEHICLE_AUDIO_VOLUME_LIMIT_INDEX_STREAM = 0, - VEHICLE_AUDIO_VOLUME_LIMIT_INDEX_MAX_VOLUME = 1, -}; - -/** - * Property to share audio routing policy of android side. This property is set at the beginning - * to pass audio policy in android side down to vehicle HAL and car audio module. - * This can be used as a hint to adjust audio policy or other policy decision. - * - * int32_array[0] : audio stream where the audio for the application context will be routed - * by default. Note that this is the default setting from system, but each app - * may still use different audio stream for whatever reason. - * int32_array[1] : All audio contexts that will be sent through the physical stream. Flag - * is defined in vehicle_audio_context_flag. - - * Setting of this property will be done for all available physical streams based on audio H/W - * variant information acquired from VEHICLE_PROPERTY_AUDIO_HW_VARIANT property. - * - * @value_type VEHICLE_VALUE_TYPE_INT32_VEC2 - * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE - * @access VEHICLE_PROP_ACCESS_WRITE - * @data_member int32_array - */ -#define VEHICLE_PROPERTY_AUDIO_ROUTING_POLICY (0x00000903) - -/** - * Index in int32_array for VEHICLE_PROPERTY_AUDIO_ROUTING_POLICY property. - */ -enum vehicle_audio_routing_policy_index { - VEHICLE_AUDIO_ROUTING_POLICY_INDEX_STREAM = 0, - VEHICLE_AUDIO_ROUTING_POLICY_INDEX_CONTEXTS = 1, -}; - -/** -* Property to return audio H/W variant type used in this car. This allows android side to -* support different audio policy based on H/W variant used. Note that other components like -* CarService may need overlay update to support additional variants. If this property does not -* exist, default audio policy will be used. -* -* @value_type VEHICLE_VALUE_TYPE_INT32 -* @change_mode VEHICLE_PROP_CHANGE_MODE_STATIC -* @access VEHICLE_PROP_ACCESS_READ -* @config_flags Additional info on audio H/W. Should use vehicle_audio_hw_variant_config_flag for -* this. -* @data_member int32_value -*/ -#define VEHICLE_PROPERTY_AUDIO_HW_VARIANT (0x00000904) - -/** - * Flag to be used in vehicle_prop_config.config_flags for VEHICLE_PROPERTY_AUDIO_HW_VARIANT. - */ -enum vehicle_audio_hw_variant_config_flag { - /** - * Flag to tell that radio is internal to android and radio should - * be treated like other android stream like media. - * When this flag is not set or AUDIO_HW_VARIANT does not exist, - * radio is treated as external module. This brins some delta in audio focus - * handling as well. - */ - VEHICLE_AUDIO_HW_VARIANT_FLAG_INTERNAL_RADIO_FLAG = 0x1, -}; - - -/** - * Property to control power state of application processor. - * - * It is assumed that AP's power state is controller by separate power controller. - * - * For configuration information, vehicle_prop_config.config_flags can have bit flag combining - * values in vehicle_ap_power_state_config_type. - * - * For get / notification, data type looks like this: - * int32_array[0] : vehicle_ap_power_state_type - * int32_array[1] : additional parameter relevant for each state. should be 0 if not used. - * For set, data type looks like this: - * int32_array[0] : vehicle_ap_power_state_set_type - * int32_array[1] : additional parameter relevant for each request. should be 0 if not used. - * - * @value_type VEHICLE_VALUE_TYPE_INT32_VEC2 - * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE - * @access VEHICLE_PROP_ACCESS_READ_WRITE - * @config_flags Additional info on power state. Should use vehicle_ap_power_state_config_flag. - * @data_member int32_array - */ -#define VEHICLE_PROPERTY_AP_POWER_STATE (0x00000A00) - -enum vehicle_ap_power_state_config_flag { - /** - * AP can enter deep sleep state. If not set, AP will always shutdown from - * VEHICLE_AP_POWER_STATE_SHUTDOWN_PREPARE power state. - */ - VEHICLE_AP_POWER_STATE_CONFIG_ENABLE_DEEP_SLEEP_FLAG = 0x1, - - /** - * The power controller can power on AP from off state after timeout specified in - * VEHICLE_AP_POWER_SET_SHUTDOWN_READY message. - */ - VEHICLE_AP_POWER_STATE_CONFIG_SUPPORT_TIMER_POWER_ON_FLAG = 0x2, -}; - -enum vehicle_ap_power_state { - /** vehicle HAL will never publish this state to AP */ - VEHICLE_AP_POWER_STATE_OFF = 0, - /** vehicle HAL will never publish this state to AP */ - VEHICLE_AP_POWER_STATE_DEEP_SLEEP = 1, - /** AP is on but display should be off. */ - VEHICLE_AP_POWER_STATE_ON_DISP_OFF = 2, - /** AP is on with display on. This state allows full user interaction. */ - VEHICLE_AP_POWER_STATE_ON_FULL = 3, - /** - * The power controller has requested AP to shutdown. AP can either enter sleep state or start - * full shutdown. AP can also request postponing shutdown by sending - * VEHICLE_AP_POWER_SET_SHUTDOWN_POSTPONE message. The power controller should change power - * state to this state to shutdown system. - * - * int32_array[1] : one of enum_vehicle_ap_power_state_shutdown_param_type - */ - VEHICLE_AP_POWER_STATE_SHUTDOWN_PREPARE = 4, -}; - -enum vehicle_ap_power_state_shutdown_param { - /** AP should shutdown immediately. Postponing is not allowed. */ - VEHICLE_AP_POWER_SHUTDOWN_PARAM_SHUTDOWN_IMMEDIATELY = 1, - /** AP can enter deep sleep instead of shutting down completely. */ - VEHICLE_AP_POWER_SHUTDOWN_PARAM_CAN_SLEEP = 2, - /** AP can only shutdown with postponing allowed. */ - VEHICLE_AP_POWER_SHUTDOWN_PARAM_SHUTDOWN_ONLY = 3, -}; - -enum vehicle_ap_power_set_state { - /** - * AP has finished boot up, and can start shutdown if requested by power controller. - */ - VEHICLE_AP_POWER_SET_BOOT_COMPLETE = 0x1, - /** - * AP is entering deep sleep state. How this state is implemented may vary depending on - * each H/W, but AP's power should be kept in this state. - */ - VEHICLE_AP_POWER_SET_DEEP_SLEEP_ENTRY = 0x2, - /** - * AP is exiting from deep sleep state, and is in VEHICLE_AP_POWER_STATE_SHUTDOWN_PREPARE state. - * The power controller may change state to other ON states based on the current state. - */ - VEHICLE_AP_POWER_SET_DEEP_SLEEP_EXIT = 0x3, - /** - * int32_array[1]: Time to postpone shutdown in ms. Maximum value can be 5000 ms. - * If AP needs more time, it will send another POSTPONE message before - * the previous one expires. - */ - VEHICLE_AP_POWER_SET_SHUTDOWN_POSTPONE = 0x4, - /** - * AP is starting shutting down. When system completes shutdown, everything will stop in AP - * as kernel will stop all other contexts. It is responsibility of vehicle HAL or lower level - * to synchronize that state with external power controller. As an example, some kind of ping - * with timeout in power controller can be a solution. - * - * int32_array[1]: Time to turn on AP in secs. Power controller may turn on AP after specified - * time so that AP can run tasks like update. If it is set to 0, there is no - * wake up, and power controller may not necessarily support wake-up. - * If power controller turns on AP due to timer, it should start with - * VEHICLE_AP_POWER_STATE_ON_DISP_OFF state, and after receiving - * VEHICLE_AP_POWER_SET_BOOT_COMPLETE, it shall do state transition to - * VEHICLE_AP_POWER_STATE_SHUTDOWN_PREPARE. - */ - VEHICLE_AP_POWER_SET_SHUTDOWN_START = 0x5, - /** - * User has requested to turn off headunit's display, which is detected in android side. - * The power controller may change the power state to VEHICLE_AP_POWER_STATE_ON_DISP_OFF. - */ - VEHICLE_AP_POWER_SET_DISPLAY_OFF = 0x6, - /** - * User has requested to turn on headunit's display, most probably from power key input which - * is attached to headunit. The power controller may change the power state to - * VEHICLE_AP_POWER_STATE_ON_FULL. - */ - VEHICLE_AP_POWER_SET_DISPLAY_ON = 0x7, -}; - -/** - * Property to represent brightness of the display. Some cars have single control for - * the brightness of all displays and this property is to share change in that control. - * - * If this is writable, android side can set this value when user changes display brightness - * from Settings. If this is read only, user may still change display brightness from Settings, - * but that will not be reflected to other displays. - * - * @value_type VEHICLE_VALUE_TYPE_INT32 - * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE - * @access VEHICLE_PROP_ACCESS_READ|VEHICLE_PROP_ACCESS_READ_WRITE - * @data_member int32 - */ -#define VEHICLE_PROPERTY_DISPLAY_BRIGHTNESS (0x00000A01) - - -/** - * Index in int32_array for VEHICLE_PROPERTY_AP_POWER_STATE property. - */ -enum vehicle_ap_power_state_index { - VEHICLE_AP_POWER_STATE_INDEX_STATE = 0, - VEHICLE_AP_POWER_STATE_INDEX_ADDITIONAL = 1, -}; - -/** -* Property to report bootup reason for the current power on. This is a static property that will -* not change for the whole duration until power off. For example, even if user presses power on -* button after automatic power on with door unlock, bootup reason should stay with -* VEHICLE_AP_POWER_BOOTUP_REASON_USER_UNLOCK. -* -* int32_value should be vehicle_ap_power_bootup_reason. -* -* @value_type VEHICLE_VALUE_TYPE_INT32 -* @change_mode VEHICLE_PROP_CHANGE_MODE_STATIC -* @access VEHICLE_PROP_ACCESS_READ -* @data_member int32_value -*/ -#define VEHICLE_PROPERTY_AP_POWER_BOOTUP_REASON (0x00000A02) - -/** - * Enum to represent bootup reason. - */ -enum vehicle_ap_power_bootup_reason { - /** - * Power on due to user's pressing of power key or rotating of ignition switch. - */ - VEHICLE_AP_POWER_BOOTUP_REASON_USER_POWER_ON = 0, - /** - * Automatic power on triggered by door unlock or any other kind of automatic user detection. - */ - VEHICLE_AP_POWER_BOOTUP_REASON_USER_UNLOCK = 1, - /** - * Automatic power on triggered by timer. This only happens when AP has asked wake-up after - * certain time through time specified in VEHICLE_AP_POWER_SET_SHUTDOWN_START. - */ - VEHICLE_AP_POWER_BOOTUP_REASON_TIMER = 2, -}; - - -/** - * Property to feed H/W input events to android - * - * int32_array[0] : action defined by vehicle_hw_key_input_action - * int32_array[1] : key code, should use standard android key code - * int32_array[2] : target display defined in vehicle_display. Events not tied - * to specific display should be sent to DISPLAY_MAIN. - * int32_array[3] : reserved for now. should be zero - * @value_type VEHICLE_VALUE_TYPE_INT32_VEC4 - * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE - * @access VEHICLE_PROP_ACCESS_READ - * @config_flags - * @data_member int32_array - */ -#define VEHICLE_PROPERTY_HW_KEY_INPUT (0x00000A10) - -enum vehicle_hw_key_input_action { - /** Key down */ - VEHICLE_HW_KEY_INPUT_ACTION_DOWN = 0, - /** Key up */ - VEHICLE_HW_KEY_INPUT_ACTION_UP = 1, -}; - -enum vehicle_display { - /** center console */ - VEHICLE_DISPLAY_MAIN = 0, - VEHICLE_DISPLAY_INSTRUMENT_CLUSTER = 1, -}; - -/** - * Property to define instrument cluster information. - * For CLUSTER_TYPE_EXTERNAL_DISPLAY: - * READ: - * int32_array[0] : The current screen mode index. Screen mode is defined - * as a configuration in car service and represents which - * area of screen is renderable. - * int32_array[1] : Android can render to instrument cluster (=1) or not(=0). When this is 0, - * instrument cluster may be rendering some information in the area - * allocated for android and android side rendering is invisible. * - * int32_array[2..3] : should be zero - * WRITE from android: - * int32_array[0] : Preferred mode for android side. Depending on the app rendering to instrument - * cluster, preferred mode can change. Instrument cluster still needs to send - * event with new mode to trigger actual mode change. - * int32_array[1] : The current app context relevant for instrument cluster. Use the same flag - * with vehicle_audio_context_flag but this context represents active apps, not - * active audio. Instrument cluster side may change mode depending on the - * currently active contexts. - * int32_array[2..3] : should be zero - * When system boots up, Android side will write {0, 0, 0, 0} when it is ready to render to - * instrument cluster. Before this message, rendering from android should not be visible in the - * cluster. - * @value_type VEHICLE_VALUE_TYPE_INT32_VEC4 - * @change_mode VEHICLE_PROP_CHANGE_MODE_ON_CHANGE - * @access VEHICLE_PROP_ACCESS_READ_WRITE - * @config_array 0:vehicle_instument_cluster_type 1:hw type - * @data_member int32_array - */ -#define VEHICLE_PROPERTY_INSTRUMENT_CLUSTER_INFO (0x00000A20) - -/** - * Represents instrument cluster type available in system - */ -enum vehicle_instument_cluster_type { - /** Android has no access to instument cluster */ - VEHICLE_INSTRUMENT_CLUSTER_TYPE_NONE = 0, - /** - * Instrument cluster can communicate through vehicle hal with additional - * properties to exchange meta-data - */ - VEHICLE_INSTRUMENT_CLUSTER_TYPE_HAL_INTERFACE = 1, - /** - * Instrument cluster is external display where android can render contents - */ - VEHICLE_INSTRUMENT_CLUSTER_TYPE_EXTERNAL_DISPLAY = 2, -}; - -/** - * H/W specific, non-standard property can be added as necessary. Such property should use - * property number in range of [VEHICLE_PROPERTY_CUSTOM_START, VEHICLE_PROPERTY_CUSTOM_END]. - * Definition of property in this range is completely up to each HAL implementation. - * For such property, it is recommended to fill vehicle_prop_config.config_string with some - * additional information to help debugging. For example, company XYZ's custom extension may - * include config_string of "com.XYZ.some_further_details". - * @range_start - */ -#define VEHICLE_PROPERTY_CUSTOM_START (0x70000000) -/** @range_end */ -#define VEHICLE_PROPERTY_CUSTOM_END (0x73ffffff) - -/** - * Property range allocated for system's internal usage like testing. HAL should never declare - * property in this range. - * @range_start - */ -#define VEHICLE_PROPERTY_INTERNAL_START (0x74000000) -/** - * @range_end - */ -#define VEHICLE_PROPERTY_INTERNAL_END (0x74ffffff) - -/** - * Value types for various properties. - */ -enum vehicle_value_type { - VEHICLE_VALUE_TYPE_SHOUD_NOT_USE = 0x00, // value_type should never set to 0. - VEHICLE_VALUE_TYPE_STRING = 0x01, - VEHICLE_VALUE_TYPE_BYTES = 0x02, - VEHICLE_VALUE_TYPE_BOOLEAN = 0x03, - VEHICLE_VALUE_TYPE_ZONED_BOOLEAN = 0x04, - VEHICLE_VALUE_TYPE_INT64 = 0x05, - VEHICLE_VALUE_TYPE_FLOAT = 0x10, - VEHICLE_VALUE_TYPE_FLOAT_VEC2 = 0x11, - VEHICLE_VALUE_TYPE_FLOAT_VEC3 = 0x12, - VEHICLE_VALUE_TYPE_FLOAT_VEC4 = 0x13, - VEHICLE_VALUE_TYPE_INT32 = 0x20, - VEHICLE_VALUE_TYPE_INT32_VEC2 = 0x21, - VEHICLE_VALUE_TYPE_INT32_VEC3 = 0x22, - VEHICLE_VALUE_TYPE_INT32_VEC4 = 0x23, - VEHICLE_VALUE_TYPE_ZONED_FLOAT = 0x30, - VEHICLE_VALUE_TYPE_ZONED_FLOAT_VEC2 = 0x31, - VEHICLE_VALUE_TYPE_ZONED_FLOAT_VEC3 = 0x32, - VEHICLE_VALUE_TYPE_ZONED_FLOAT_VEC4 = 0x33, - VEHICLE_VALUE_TYPE_ZONED_INT32 = 0x40, - VEHICLE_VALUE_TYPE_ZONED_INT32_VEC2 = 0x41, - VEHICLE_VALUE_TYPE_ZONED_INT32_VEC3 = 0x42, - VEHICLE_VALUE_TYPE_ZONED_INT32_VEC4 = 0x43, -}; - -/** - * Units used for int or float type with no attached enum types. - */ -enum vehicle_unit_type { - VEHICLE_UNIT_TYPE_SHOULD_NOT_USE = 0x00000000, - // speed related items - VEHICLE_UNIT_TYPE_METER_PER_SEC = 0x00000001, - VEHICLE_UNIT_TYPE_RPM = 0x00000002, - VEHICLE_UNIT_TYPE_HZ = 0x00000003, - // kind of ratio - VEHICLE_UNIT_TYPE_PERCENTILE = 0x00000010, - // length - VEHICLE_UNIT_TYPE_MILLIMETER = 0x00000020, - VEHICLE_UNIT_TYPE_METER = 0x00000021, - VEHICLE_UNIT_TYPE_KILOMETER = 0x00000023, - // temperature - VEHICLE_UNIT_TYPE_CELCIUS = 0x00000030, - // volume - VEHICLE_UNIT_TYPE_MILLILITER = 0x00000040, - // time - VEHICLE_UNIT_TYPE_NANO_SECS = 0x00000050, - VEHICLE_UNOT_TYPE_SECS = 0x00000053, - VEHICLE_UNIT_TYPE_YEAR = 0x00000059, -}; - -/** - * This describes how value of property can change. - */ -enum vehicle_prop_change_mode { - /** - * Property of this type will *never* change. This property will not support subscription, but - * will support get - */ - VEHICLE_PROP_CHANGE_MODE_STATIC = 0x00, - /** - * Property of this type will be reported when there is a change. get should return the - * current value. - */ - VEHICLE_PROP_CHANGE_MODE_ON_CHANGE = 0x01, - /** - * Property of this type change continuously and requires fixed rate of sampling to retrieve - * the data. - */ - VEHICLE_PROP_CHANGE_MODE_CONTINUOUS = 0x02, -}; - -/** - * Property config defines the capabilities of it. User of the API - * should first get the property config to understand the output from get() - * commands and also to ensure that set() or events commands are in sync with - * the expected output. - */ -enum vehicle_prop_access { - VEHICLE_PROP_ACCESS_READ = 0x01, - VEHICLE_PROP_ACCESS_WRITE = 0x02, - VEHICLE_PROP_ACCESS_READ_WRITE = 0x03 -}; - -/** - * These permissions define how the OEMs want to distribute their information and security they - * want to apply. On top of these restrictions, android will have additional - * 'app-level' permissions that the apps will need to ask the user before the apps have the - * information. - * This information should be kept in vehicle_prop_config.permission_model. - */ -enum vehicle_permission_model { - /** - * No special restriction, but each property can still require specific android app-level - * permission. - */ - VEHICLE_PERMISSION_NO_RESTRICTION = 0, - /** Signature only. Only APKs signed with OEM keys are allowed. */ - VEHICLE_PERMISSION_OEM_ONLY = 0x1, - /** System only. APKs built-in to system can access the property. */ - VEHICLE_PERMISSION_SYSTEM_APP_ONLY = 0x2, - /** Equivalent to “system|signature” */ - VEHICLE_PERMISSION_OEM_OR_SYSTEM_APP = 0x3 -}; - - -/** - * Special values for INT32/FLOAT (including ZONED types) - * These values represent special state, which is outside MIN/MAX range but can happen. - * For example, HVAC temperature may use out of range min / max to represent that - * it is working in full power although target temperature has separate min / max. - * OUT_OF_RANGE_OFF can represent a state where the property is powered off. - * Usually such property will have separate property to control power. - */ - -#define VEHICLE_INT_OUT_OF_RANGE_MAX (INT32_MAX) -#define VEHICLE_INT_OUT_OF_RANGE_MIN (INT32_MIN) -#define VEHICLE_INT_OUT_OF_RANGE_OFF (INT32_MIN + 1) - -#define VEHICLE_FLOAT_OUT_OF_RANGE_MAX (INFINITY) -#define VEHICLE_FLOAT_OUT_OF_RANGE_MIN (-INFINITY) -#define VEHICLE_FLOAT_OUT_OF_RANGE_OFF (NAN) - -/** - * Car states. - * - * The driving states determine what features of the UI will be accessible. - */ -enum vehicle_driving_status { - VEHICLE_DRIVING_STATUS_UNRESTRICTED = 0x00, - VEHICLE_DRIVING_STATUS_NO_VIDEO = 0x01, - VEHICLE_DRIVING_STATUS_NO_KEYBOARD_INPUT = 0x02, - VEHICLE_DRIVING_STATUS_NO_VOICE_INPUT = 0x04, - VEHICLE_DRIVING_STATUS_NO_CONFIG = 0x08, - VEHICLE_DRIVING_STATUS_LIMIT_MESSAGE_LEN = 0x10 -}; - -/** - * Various gears which can be selected by user and chosen in system. - */ -enum vehicle_gear { - // Gear selections present in both automatic and manual cars. - VEHICLE_GEAR_NEUTRAL = 0x0001, - VEHICLE_GEAR_REVERSE = 0x0002, - - // Gear selections (mostly) present only in automatic cars. - VEHICLE_GEAR_PARK = 0x0004, - VEHICLE_GEAR_DRIVE = 0x0008, - VEHICLE_GEAR_LOW = 0x0010, - - // Other possible gear selections (maybe present in manual or automatic - // cars). - VEHICLE_GEAR_1 = 0x0010, - VEHICLE_GEAR_2 = 0x0020, - VEHICLE_GEAR_3 = 0x0040, - VEHICLE_GEAR_4 = 0x0080, - VEHICLE_GEAR_5 = 0x0100, - VEHICLE_GEAR_6 = 0x0200, - VEHICLE_GEAR_7 = 0x0400, - VEHICLE_GEAR_8 = 0x0800, - VEHICLE_GEAR_9 = 0x1000 -}; - - -/** - * Various zones in the car. - * - * Zones are used for Air Conditioning purposes and divide the car into physical - * area zones. - */ -enum vehicle_zone { - VEHICLE_ZONE_ROW_1_LEFT = 0x00000001, - VEHICLE_ZONE_ROW_1_CENTER = 0x00000002, - VEHICLE_ZONE_ROW_1_RIGHT = 0x00000004, - VEHICLE_ZONE_ROW_1_ALL = 0x00000008, - VEHICLE_ZONE_ROW_2_LEFT = 0x00000010, - VEHICLE_ZONE_ROW_2_CENTER = 0x00000020, - VEHICLE_ZONE_ROW_2_RIGHT = 0x00000040, - VEHICLE_ZONE_ROW_2_ALL = 0x00000080, - VEHICLE_ZONE_ROW_3_LEFT = 0x00000100, - VEHICLE_ZONE_ROW_3_CENTER = 0x00000200, - VEHICLE_ZONE_ROW_3_RIGHT = 0x00000400, - VEHICLE_ZONE_ROW_3_ALL = 0x00000800, - VEHICLE_ZONE_ROW_4_LEFT = 0x00001000, - VEHICLE_ZONE_ROW_4_CENTER = 0x00002000, - VEHICLE_ZONE_ROW_4_RIGHT = 0x00004000, - VEHICLE_ZONE_ROW_4_ALL = 0x00008000, - VEHICLE_ZONE_ALL = 0x80000000, -}; - -/** - * Various Seats in the car. - */ -enum vehicle_seat { - VEHICLE_SEAT_DRIVER_LHD = 0x0001, - VEHICLE_SEAT_DRIVER_RHD = 0x0002, - VEHICLE_SEAT_ROW_1_PASSENGER_LEFT = 0x0010, - VEHICLE_SEAT_ROW_1_PASSENGER_CENTER = 0x0020, - VEHICLE_SEAT_ROW_1_PASSENGER_RIGHT = 0x0040, - VEHICLE_SEAT_ROW_2_PASSENGER_LEFT = 0x0100, - VEHICLE_SEAT_ROW_2_PASSENGER_CENTER = 0x0200, - VEHICLE_SEAT_ROW_2_PASSENGER_RIGHT = 0x0400, - VEHICLE_SEAT_ROW_3_PASSENGER_LEFT = 0x1000, - VEHICLE_SEAT_ROW_3_PASSENGER_CENTER = 0x2000, - VEHICLE_SEAT_ROW_3_PASSENGER_RIGHT = 0x4000 -}; - -/** - * Various windshields/windows in the car. - */ -enum vehicle_window { - VEHICLE_WINDOW_FRONT_WINDSHIELD = 0x0001, - VEHICLE_WINDOW_REAR_WINDSHIELD = 0x0002, - VEHICLE_WINDOW_ROOF_TOP = 0x0004, - VEHICLE_WINDOW_ROW_1_LEFT = 0x0010, - VEHICLE_WINDOW_ROW_1_RIGHT = 0x0020, - VEHICLE_WINDOW_ROW_2_LEFT = 0x0100, - VEHICLE_WINDOW_ROW_2_RIGHT = 0x0200, - VEHICLE_WINDOW_ROW_3_LEFT = 0x1000, - VEHICLE_WINDOW_ROW_3_RIGHT = 0x2000, -}; - -enum vehicle_door { - VEHICLE_DOOR_ROW_1_LEFT = 0x00000001, - VEHICLE_DOOR_ROW_1_RIGHT = 0x00000004, - VEHICLE_DOOR_ROW_2_LEFT = 0x00000010, - VEHICLE_DOOR_ROW_2_RIGHT = 0x00000040, - VEHICLE_DOOR_ROW_3_LEFT = 0x00000100, - VEHICLE_DOOR_ROW_3_RIGHT = 0x00000400, - VEHICLE_DOOR_HOOD = 0x10000000, - VEHICLE_DOOR_REAR = 0x20000000, -}; - -enum vehicle_mirror { - VEHICLE_MIRROR_DRIVER_LEFT = 0x00000001, - VEHICLE_MIRROR_DRIVER_RIGHT = 0x00000002, - VEHICLE_MIRROR_DRIVER_CENTER = 0x00000004, -}; -enum vehicle_turn_signal { - VEHICLE_SIGNAL_NONE = 0x00, - VEHICLE_SIGNAL_RIGHT = 0x01, - VEHICLE_SIGNAL_LEFT = 0x02, - VEHICLE_SIGNAL_EMERGENCY = 0x04 -}; - -/* - * Boolean type. - */ -enum vehicle_boolean { - VEHICLE_FALSE = 0x00, - VEHICLE_TRUE = 0x01 -}; - -typedef int32_t vehicle_boolean_t; - -/** - * Vehicle string. - * - * Defines a UTF8 encoded sequence of bytes that should be used for string - * representation throughout. - */ -typedef struct vehicle_str { - uint8_t* data; - int32_t len; -} vehicle_str_t; - -/** - * Vehicle byte array. - * This is for passing generic raw data. - */ -typedef vehicle_str_t vehicle_bytes_t; - -typedef struct vehicle_prop_config { - int32_t prop; - - /** - * Defines if the property is read or write. Value should be one of - * enum vehicle_prop_access. - */ - int32_t access; - - /** - * Defines if the property is continuous or on-change. Value should be one - * of enum vehicle_prop_change_mode. - */ - int32_t change_mode; - - /** - * Type of data used for this property. This type is fixed per each property. - * Check vehicle_value_type for allowed value. - */ - int32_t value_type; - - /** - * Define necessary permission model to access the data. - */ - int32_t permission_model; - - /** - * Some of the properties may have associated zones (such as hvac), in these - * cases the config should contain an ORed value for the associated zone. - */ - union { - /** - * The value is derived by ORing one or more of enum vehicle_zone members. - */ - int32_t vehicle_zone_flags; - /** The value is derived by ORing one or more of enum vehicle_seat members. */ - int32_t vehicle_seat_flags; - /** The value is derived by ORing one or more of enum vehicle_window members. */ - int32_t vehicle_window_flags; - }; - - /** - * Property specific configuration information. Usage of this will be defined per each property. - */ - union { - /** - * For generic configuration information - */ - int32_t config_flags; - /** The number of presets that are stored by the radio module. Pass 0 if - * there are no presets available. The range of presets is defined to be - * from 1 (see VEHICLE_RADIO_PRESET_MIN_VALUE) to vehicle_radio_num_presets. - */ - int32_t vehicle_radio_num_presets; - int32_t config_array[4]; - }; - - /** - * Some properties may require additional information passed over this string. Most properties - * do not need to set this and in that case, config_string.data should be NULL and - * config_string.len should be 0. - */ - vehicle_str_t config_string; - - /** - * Specify minimum allowed value for the property. This is necessary for property which does - * not have specified enum. - */ - union { - float float_min_value; - int32_t int32_min_value; - int64_t int64_min_value; - }; - - /** - * Specify maximum allowed value for the property. This is necessary for property which does - * not have specified enum. - */ - union { - float float_max_value; - int32_t int32_max_value; - int64_t int64_max_value; - }; - - /** - * Array of min values for zoned properties. Zoned property can specify min / max value in two - * different ways: - * 1. All zones having the same min / max value: *_min/max_value should be set and this - * array should be set to NULL. - * 2. All zones having separate min / max value: *_min/max_values array should be populated - * and its length should be the same as number of active zones specified by *_zone_flags. - * - * Should be NULL if each zone does not have separate max values. - */ - union { - float* float_min_values; - int32_t* int32_min_values; - int64_t* int64_min_values; - }; - - /** - * Array of max values for zoned properties. See above for its usage. - * Should be NULL if each zone does not have separate max values. - * If not NULL, length of array should match that of min_values. - */ - union { - float* float_max_values; - int32_t* int32_max_values; - int64_t* int64_max_values; - }; - - /** - * Min sample rate in Hz. Should be 0 for sensor type of VEHICLE_PROP_CHANGE_MODE_ON_CHANGE - */ - float min_sample_rate; - /** - * Max sample rate in Hz. Should be 0 for sensor type of VEHICLE_PROP_CHANGE_MODE_ON_CHANGE - */ - float max_sample_rate; - /** - * Place holder for putting HAL implementation specific data. Usage is wholly up to HAL - * implementation. - */ - void* hal_data; -} vehicle_prop_config_t; - -/** - * HVAC property fields. - * - * Defines various HVAC properties which are packed into vehicle_hvac_t (see - * below). We define these properties outside in global scope so that HAL - * implementation and HAL users (JNI) can typecast vehicle_hvac correctly. - */ -typedef struct vehicle_hvac { - /** - * Define one structure for each possible HVAC property. - * NOTES: - * a) Fan speed is a number from (0 - 6) where 6 is the highest speed. (TODO define enum) - * b) Temperature is a floating point Celcius scale. - * c) Direction is defined in enum vehicle_fan_direction. - * - * The HAL should create #entries number of vehicle_hvac_properties and - * assign it to "properties" variable below. - */ - union { - int32_t fan_speed; - int32_t fan_direction; - vehicle_boolean_t ac_on; - vehicle_boolean_t max_ac_on; - vehicle_boolean_t max_defrost_on; - vehicle_boolean_t recirc_on; - vehicle_boolean_t dual_on; - vehicle_boolean_t power_on; - - float temperature_current; - float temperature_set; - - vehicle_boolean_t defrost_on; - }; -} vehicle_hvac_t; - -/* - * Defines how the values for various properties are represented. - * - * There are two ways to populate and access the fields: - * a) Using the individual fields. Use this mechanism (see - * info_manufacture_date, fuel_capacity fields etc). - * b) Using the union accessors (see uint32_value, float_value etc). - * - * To add a new field make sure that it does not exceed the total union size - * (defined in int_array) and it is one of the vehicle_value_type. Then add the - * field name with its unit to union. If the field type is not yet defined (as - * of this draft, we don't use int64_t) then add that type to vehicle_value_type - * and have an accessor (so for int64_t it will be int64_t int64_value). - */ -typedef union vehicle_value { - /** Define the max size of this structure. */ - int32_t int32_array[4]; - float float_array[4]; - - // Easy accessors for union members (HAL implementation SHOULD NOT USE these - // fields while populating, use the property specific fields below instead). - int32_t int32_value; - int64_t int64_value; - float float_value; - vehicle_str_t str_value; - vehicle_bytes_t bytes_value; - vehicle_boolean_t boolean_value; - - // Vehicle Information. - vehicle_str_t info_vin; - vehicle_str_t info_make; - vehicle_str_t info_model; - int32_t info_model_year; - - // Represented in milliliters. - float info_fuel_capacity; - - float vehicle_speed; - float odometer; - - // Engine sensors. - - // Represented in milliliters. - //float engine_coolant_level; - // Represented in celcius. - float engine_coolant_temperature; - // Represented in a percentage value. - //float engine_oil_level; - // Represented in celcius. - float engine_oil_temperature; - float engine_rpm; - - // Event sensors. - // Value should be one of enum vehicle_gear_selection. - int32_t gear_selection; - // Value should be one of enum vehicle_gear. - int32_t gear_current_gear; - // Value should be one of enum vehicle_boolean. - int32_t parking_brake; - // If cruise_set_speed > 0 then cruise is ON otherwise cruise is OFF. - // Unit: meters / second (m/s). - //int32_t cruise_set_speed; - // Value should be one of enum vehicle_boolean. - int32_t is_fuel_level_low; - // Value should be one of enum vehicle_driving_status. - int32_t driving_status; - int32_t night_mode; - // Value should be one of emum vehicle_turn_signal. - int32_t turn_signals; - // Value should be one of enum vehicle_boolean. - //int32_t engine_on; - - // HVAC properties. - vehicle_hvac_t hvac; - - float outside_temperature; - float cabin_temperature; - -} vehicle_value_t; - -/* - * Encapsulates the property name and the associated value. It - * is used across various API calls to set values, get values or to register for - * events. - */ -typedef struct vehicle_prop_value { - /* property identifier */ - int32_t prop; - - /* value type of property for quick conversion from union to appropriate - * value. The value must be one of enum vehicle_value_type. - */ - int32_t value_type; - - /** time is elapsed nanoseconds since boot */ - int64_t timestamp; - - /** - * Zone information for zoned property. For non-zoned property, this should be ignored. - */ - union { - int32_t zone; - int32_t seat; - int32_t window; - }; - - vehicle_value_t value; -} vehicle_prop_value_t; - -/* - * Event callback happens whenever a variable that the API user has subscribed - * to needs to be reported. This may be based purely on threshold and frequency - * (a regular subscription, see subscribe call's arguments) or when the set() - * command is executed and the actual change needs to be reported. - * - * event_data is OWNED by the HAL and should be copied before the callback - * finishes. - */ -typedef int (*vehicle_event_callback_fn)(const vehicle_prop_value_t *event_data); - - -/** - * Represent the operation where the current error has happened. - */ -enum vehicle_property_operation { - /** Generic error to this property which is not tied to any operation. */ - VEHICLE_OPERATION_GENERIC = 0, - /** Error happened while handling property set. */ - VEHICLE_OPERATION_SET = 1, - /** Error happened while handling property get. */ - VEHICLE_OPERATION_GET = 2, - /** Error happened while handling property subscription. */ - VEHICLE_OPERATION_SUBSCRIBE = 3, -}; - -/* - * Suggests that an error condition has occurred. - * - * @param error_code Error code. error_code should be standard error code with - * negative value like -EINVAL. - * @parm property Note a property where error has happened. If this is generic error, property - * should be VEHICLE_PROPERTY_INVALID. - * @param operation Represent the operation where the error has happened. Should be one of - * vehicle_property_operation. - */ -typedef int (*vehicle_error_callback_fn)(int32_t error_code, int32_t property, int32_t operation); - -/************************************************************************************/ - -/* - * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM - * and the fields of this data structure must begin with hw_module_t - * followed by module specific information. - */ -typedef struct vehicle_module { - struct hw_module_t common; -} vehicle_module_t; - - -typedef struct vehicle_hw_device { - struct hw_device_t common; - - /** - * After calling open on device the user should register callbacks for event and error - * functions. - */ - int (*init)(struct vehicle_hw_device* device, - vehicle_event_callback_fn event_fn, vehicle_error_callback_fn err_fn); - /** - * Before calling close the user should destroy the registered callback - * functions. - * In case the unsubscribe() call is not called on all properties before - * release() then release() will unsubscribe the properties itself. - */ - int (*release)(struct vehicle_hw_device* device); - - /** - * Enumerate all available properties. The list is returned in "list". - * @param num_properties number of properties contained in the retuned array. - * @return array of property configs supported by this car. Note that returned data is const - * and caller cannot modify it. HAL implementation should keep this memory until HAL - * is released to avoid copying this again. - */ - vehicle_prop_config_t const *(*list_properties)(struct vehicle_hw_device* device, - int* num_properties); - - /** - * Get a vehicle property value immediately. data should be allocated - * properly. - * The caller of the API OWNS the data field. - * Caller will set data->prop, data->value_type, and optionally zone value for zoned property. - * But HAL implementation needs to fill all entries properly when returning. - * For pointer type, HAL implementation should allocate necessary memory and caller is - * responsible for calling release_memory_from_get, which allows HAL to release allocated - * memory. - * For VEHICLE_PROP_CHANGE_MODE_STATIC type of property, get should return the same value - * always. - * For VEHICLE_PROP_CHANGE_MODE_ON_CHANGE type of property, it should return the latest value. - * If there is no data available yet, which can happen during initial stage, this call should - * return immediately with error code of -EAGAIN. - */ - int (*get)(struct vehicle_hw_device* device, vehicle_prop_value_t *data); - - /** - * Release memory allocated to data in previous get call. get call for byte or string involves - * allocating necessary memory from vehicle hal. - * To be safe, memory allocated by vehicle hal should be released by vehicle hal and vehicle - * network service will call this when data from vehicle hal is no longer necessary. - * vehicle hal implementation should only release member of vehicle_prop_value_t like - * data->str_value.data or data->bytes_value.data but not data itself as data itself is - * allocated from vehicle network service. Once memory is freed, corresponding pointer should - * be set to NULL bu vehicle hal. - */ - void (*release_memory_from_get)(struct vehicle_hw_device* device, vehicle_prop_value_t *data); - - /** - * Set a vehicle property value. data should be allocated properly and not - * NULL. - * The caller of the API OWNS the data field. - * timestamp of data will be ignored for set operation. - * Setting some properties require having initial state available. Depending on the vehicle hal, - * such initial data may not be available for short time after init. In such case, set call - * can return -EAGAIN like get call. - * For a property with separate power control, set can fail if the property is not powered on. - * In such case, hal should return -ESHUTDOWN error. - */ - int (*set)(struct vehicle_hw_device* device, const vehicle_prop_value_t *data); - - /** - * Subscribe to events. - * Depending on output of list_properties if the property is: - * a) on-change: sample_rate should be set to 0. - * b) supports frequency: sample_rate should be set from min_sample_rate to - * max_sample_rate. - * For on-change type of properties, vehicle network service will make another get call to check - * the initial state. Due to this, vehicle hal implementation does not need to send initial - * state for on-change type of properties. - * @param device - * @param prop - * @param sample_rate - * @param zones All subscribed zones for zoned property. can be ignored for non-zoned property. - * 0 means all zones supported instead of no zone. - */ - int (*subscribe)(struct vehicle_hw_device* device, int32_t prop, float sample_rate, - int32_t zones); - - /** Cancel subscription on a property. */ - int (*unsubscribe)(struct vehicle_hw_device* device, int32_t prop); - - /** - * Print out debugging state for the vehicle hal. This will be called by - * the vehicle network service and will be included into the service' dump. - * - * The passed-in file descriptor can be used to write debugging text using - * dprintf() or write(). The text should be in ASCII encoding only. - * - * Performance requirements: - * - * This must be a non-blocking call. The HAL should return from this call - * in 1ms, must return from this call in 10ms. This call must avoid - * deadlocks, as it may be called at any point of operation. - * Any synchronization primitives used (such as mutex locks or semaphores) - * should be acquired with a timeout. - */ - int (*dump)(struct vehicle_hw_device* device, int fd); - -} vehicle_hw_device_t; - -__END_DECLS - -#endif // ANDROID_VEHICLE_INTERFACE_H diff --git a/hardware/vehicle_camera.h b/hardware/vehicle_camera.h deleted file mode 100644 index 8075aee..0000000 --- a/hardware/vehicle_camera.h +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ANDROID_VEHICLE_CAMERA_INTERFACE_H -#define ANDROID_VEHICLE_CAMERA_INTERFACE_H - -#include -#include -#include -#include - -#include -#include -#include - -__BEGIN_DECLS - -/*****************************************************************************/ - -#define VEHICLE_CAMERA_HEADER_VERSION 1 -#define VEHICLE_CAMERA_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) -#define VEHICLE_CAMERA_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION_2(1, 0, VEHICLE_CAMERA_HEADER_VERSION) - -/** - * Vehicle Camera to provide interfaces for controlling cameras - */ - -/** - * The id of this module - */ -#define VEHICLE_CAMERA_HARDWARE_MODULE_ID "vehicle_camera" - -/** - * Name of the vehicle device to open. Extend this list as - * more cameras are added. Each camera defined in vehicle_camera_type_t - * shall have a string defined for it. - */ -#define VEHICLE_CAMERA_RVC_DEVICE "vehicle_camera_rvc_device" - -/** - * Each camera on the car shall be enumerated - */ -typedef enum { - VEHICLE_CAMERA_RVC = 1, -} vehicle_camera_type_t; - -/** - * Describes the current state of camera device - */ -typedef struct { - uint32_t overlay_on; - uint32_t camera_on; -} vehicle_camera_state_t; - -/** - * Bitmask of features supported by a camera module - */ -enum { - VEHICLE_CAMERA_CONFIG_FLAG_ANDROID_OVERLAY_SUPPORT = 0x1, - VEHICLE_CAMERA_CONFIG_FLAG_CAMERA_CROP_SUPPORT = 0x2, - VEHICLE_CAMERA_CONFIG_FLAG_CAMERA_POSITIONING_SUPPORT = 0x4 -} vehicle_camera_config_flag; - -typedef struct { - uint32_t capabilites_flags; - uint32_t camera_width; - uint32_t camera_height; - uint32_t display_width; - uint32_t display_height; -} vehicle_camera_cap_t; - -/************************************************************************************/ - -/** - * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM - * and the fields of this data structure must begin with hw_module_t - * followed by module specific information. - */ -typedef struct { - struct hw_module_t common; - /** - * Queries the HW for the cameras installed on the vehicle - * @param num_cameras - number of camera devices available. If - * 0 is returned, an error has occurred and - * the return pointer shall be NULL. - * @return pointer to an array of vehicle_camera_type_t to - * denote which cameras are installed. This pointer is - * only valid while the vehicle hal is loaded. If the - * pointer is NULL, then an error has occurred and - * num_cameras shall be 0. - */ - const uint32_t * (*get_camera_device_list)(uint32_t *num_cameras); -} vehicle_camera_module_t; - - -typedef struct vehicle_camera_device_t { - struct hw_device_t common; - - const uint32_t camera_type; - - /** - * Returns the capabilities of this camera. - * @param device - device handle - * @param cap - pointer to capabilities flags being returned - * @return 0 on success - * -EPERM if device is invalid or not initialized - */ - int (*get_capabilities)(struct vehicle_camera_device_t *device, vehicle_camera_cap_t *cap); - - /** - * Gets the current camera crop settings. - * @param device - device handle - * @param rect - current camera crop settings - * @return 0 on success - * -EPERM if device is not initialized - * -errno on error - */ - int (*get_camera_crop)(struct vehicle_camera_device_t *device, android_native_rect_t *rect); - - /** - * Sets the camera crop. - * @param device - device handle - * @param rect - area of camera input to crop. Must fit within - * camera width and height from camera capabilities. - * @return 0 on success - * -EPERM if device is not initialized - * -errno on error - */ - int (*set_camera_crop)(struct vehicle_camera_device_t *device, const android_native_rect_t *rect); - - /** - * Gets position of the camera on the display. - * @param device - device handle - * @param rect - area of display the camera will appear when on - * @return 0 on success - * -EPERM if device is not initialized - * -errno on error - */ - int (*get_camera_position)(struct vehicle_camera_device_t *device, android_native_rect_t *rect); - - /** - * Sets position of the camera on the display. - * @param device - device handle - * @param rect - area of display the camera will appear when on. - * Must fit within display width and height from - * camera capabilities. - * @return 0 on success - * -EPERM if device is not initialized - * -errno on error - */ - int (*set_camera_position)(struct vehicle_camera_device_t *device, const android_native_rect_t *rect); - - /** - * Gets the current camera state. - * @param device - device handle - * @param state - last setting for the camera - * @return 0 on success - * -EPERM if device is not initialized - */ - int (*get_camera_state)(struct vehicle_camera_device_t *device, vehicle_camera_state_t *state); - - /** - * Sets the camera state. - * @param device - device handle - * @param state - desired setting for the camera - * @return 0 on success - * -EPERM if device is not initialized - * -errno on error - */ - int (*set_camera_state)(struct vehicle_camera_device_t *device, const vehicle_camera_state_t *state); -} vehicle_camera_device_t; - -__END_DECLS - -#endif // ANDROID_VEHICLE_CAMERA_INTERFACE_H diff --git a/hardware/vibrator.h b/hardware/vibrator.h index 200adf0..361085f 100644 --- a/hardware/vibrator.h +++ b/hardware/vibrator.h @@ -65,7 +65,7 @@ typedef struct vibrator_device { static inline int vibrator_open(const struct hw_module_t* module, vibrator_device_t** device) { - return module->methods->open(module, VIBRATOR_DEVICE_ID_MAIN, (struct hw_device_t**)device); + return module->methods->open(module, VIBRATOR_DEVICE_ID_MAIN, TO_HW_DEVICE_T_OPEN(device)); } __END_DECLS diff --git a/hardware/wipower.h b/hardware/wipower.h deleted file mode 100644 index ab6b3de..0000000 --- a/hardware/wipower.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef ANDROID_INCLUDE_WIPOWER_H -#define ANDROID_INCLUDE_WIPOWER_H - -#include -#include -#include -#include - -#include - -__BEGIN_DECLS - -typedef enum { - OFF =0, - ON -} wipower_state_t; - - -typedef struct { - -unsigned char optional; -unsigned short rect_voltage; -unsigned short rect_current; -unsigned short out_voltage; -unsigned short out_current; -unsigned char temp; -unsigned short rect_voltage_min; -unsigned short rect_voltage_set; -unsigned short rect_voltage_max; -unsigned char alert; -unsigned short rfu1; -unsigned char rfu2; - -}__attribute__((packed)) wipower_dyn_data_t; - -/** Bluetooth Enable/Disable Callback. */ -typedef void (*wipower_state_changed_callback)(wipower_state_t state); - - -typedef void (*wipower_alerts)(unsigned char alert); - - -typedef void (*wipower_dynamic_data)(wipower_dyn_data_t* alert_data); - - -typedef void (*wipower_power_apply)(unsigned char power_flag); - -/** Bluetooth DM callback structure. */ -typedef struct { - /** set to sizeof(wipower_callbacks_t) */ - size_t size; - wipower_state_changed_callback wipower_state_changed_cb; - wipower_alerts wipower_alert; - wipower_dynamic_data wipower_data; - wipower_power_apply wipower_power_event; -} wipower_callbacks_t; - - -/** Represents the standard Wipower interface. */ -typedef struct { - /** set to sizeof(wipower_interface_t) */ - size_t size; - - /** Initialize Wipower modules*/ - int (*init)(wipower_callbacks_t *wp_callbacks); - - /** Enable/Disable Wipower charging */ - int (*enable)(bool enable); - - int (*set_current_limit)(short value); - - unsigned char (*get_current_limit)(void); - - wipower_state_t (*get_state)(void); - - /** Enable/Disable Wipower charging */ - int (*enable_alerts)(bool enable); - - int (*enable_data_notify)(bool enable); - int (*enable_power_apply)(bool enable, bool on, bool time_flag); -} wipower_interface_t; - - -__END_DECLS - -#endif /* ANDROID_INCLUDE_WIPOWER_H */ diff --git a/hardware_legacy/vibrator.h b/hardware_legacy/vibrator.h deleted file mode 100644 index 7994f62..0000000 --- a/hardware_legacy/vibrator.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _HARDWARE_VIBRATOR_H -#define _HARDWARE_VIBRATOR_H - -#if __cplusplus -extern "C" { -#endif - -/** - * Return whether the device has a vibrator. - * - * @return 1 if a vibrator exists, 0 if it doesn't. - */ -int vibrator_exists(); - -/** - * Turn on vibrator - * - * @param timeout_ms number of milliseconds to vibrate - * - * @return 0 if successful, -1 if error - */ -int vibrator_on(int timeout_ms); - -/** - * Turn off vibrator - * - * @return 0 if successful, -1 if error - */ -int vibrator_off(); - -#if __cplusplus -} // extern "C" -#endif - -#endif // _HARDWARE_VIBRATOR_H diff --git a/hardware_legacy/wifi.h b/hardware_legacy/wifi.h index fbca81e..defff0a 100644 --- a/hardware_legacy/wifi.h +++ b/hardware_legacy/wifi.h @@ -1,11 +1,11 @@ /* - * Copyright (C) 2008 The Android Open Source Project + * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -14,12 +14,13 @@ * limitations under the License. */ -#ifndef _WIFI_H -#define _WIFI_H +#ifndef HARDWARE_LEGACY_WIFI_H +#define HARDWARE_LEGACY_WIFI_H -#if __cplusplus -extern "C" { -#endif +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ /** * Load the Wi-Fi driver. @@ -43,100 +44,12 @@ int wifi_unload_driver(); */ int is_wifi_driver_loaded(); - -/** - * Start supplicant. - * - * @return 0 on success, < 0 on failure. - */ -int wifi_start_supplicant(int p2pSupported); - -/** - * Stop supplicant. - * - * @return 0 on success, < 0 on failure. - */ -int wifi_stop_supplicant(int p2pSupported); - -/** - * Open a connection to supplicant - * - * @return 0 on success, < 0 on failure. - */ -int wifi_connect_to_supplicant(); - -/** - * Close connection to supplicant - * - * @return 0 on success, < 0 on failure. - */ -void wifi_close_supplicant_connection(); - -/** - * wifi_wait_for_event() performs a blocking call to - * get a Wi-Fi event and returns a string representing - * a Wi-Fi event when it occurs. - * - * @param buf is the buffer that receives the event - * @param len is the maximum length of the buffer - * - * @returns number of bytes in buffer, 0 if no - * event (for instance, no connection), and less than 0 - * if there is an error. - */ -int wifi_wait_for_event(char *buf, size_t len); - -/** - * wifi_command() issues a command to the Wi-Fi driver. - * - * Android extends the standard commands listed at - * /link http://hostap.epitest.fi/wpa_supplicant/devel/ctrl_iface_page.html - * to include support for sending commands to the driver: - * - * See wifi/java/android/net/wifi/WifiNative.java for the details of - * driver commands that are supported - * - * @param command is the string command (preallocated with 32 bytes) - * @param commandlen is command buffer length - * @param reply is a buffer to receive a reply string - * @param reply_len on entry, this is the maximum length of - * the reply buffer. On exit, the number of - * bytes in the reply buffer. - * - * @return 0 if successful, < 0 if an error. - */ -int wifi_command(const char *command, char *reply, size_t *reply_len); - -/** - * do_dhcp_request() issues a dhcp request and returns the acquired - * information. - * - * All IPV4 addresses/mask are in network byte order. - * - * @param ipaddr return the assigned IPV4 address - * @param gateway return the gateway being used - * @param mask return the IPV4 mask - * @param dns1 return the IPV4 address of a DNS server - * @param dns2 return the IPV4 address of a DNS server - * @param server return the IPV4 address of DHCP server - * @param lease return the length of lease in seconds. - * - * @return 0 if successful, < 0 if error. - */ -int do_dhcp_request(int *ipaddr, int *gateway, int *mask, - int *dns1, int *dns2, int *server, int *lease); - -/** - * Return the error string of the last do_dhcp_request(). - */ -const char *get_dhcp_error_string(); - /** * Return the path to requested firmware */ -#define WIFI_GET_FW_PATH_STA 0 -#define WIFI_GET_FW_PATH_AP 1 -#define WIFI_GET_FW_PATH_P2P 2 +#define WIFI_GET_FW_PATH_STA 0 +#define WIFI_GET_FW_PATH_AP 1 +#define WIFI_GET_FW_PATH_P2P 2 const char *wifi_get_fw_path(int fw_type); /** @@ -144,24 +57,8 @@ const char *wifi_get_fw_path(int fw_type); */ int wifi_change_fw_path(const char *fwpath); -/** - * Set the wifi mode (0 = normal, 1 = ap) - */ -int wifi_set_mode(int mode); - -/** - * Check and create if necessary initial entropy file - */ -#define WIFI_ENTROPY_FILE "/data/misc/wifi/entropy.bin" -int ensure_entropy_file_exists(); - -/** -* Check and create if necessary the desired configuration file -*/ -int ensure_config_file_exists(const char *config_file, const char *config_file_template); - -#if __cplusplus -}; // extern "C" -#endif +#ifdef __cplusplus +} +#endif /* __cplusplus */ -#endif // _WIFI_H +#endif /* HARDWARE_LEGACY_WIFI_H */ diff --git a/libnfc-nxp/nfc_custom_config_example.h b/libnfc-nxp/nfc_custom_config_example.h deleted file mode 100644 index d400bcc..0000000 --- a/libnfc-nxp/nfc_custom_config_example.h +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -/** -* \file nfc_custom_config.h -* \brief HAL Custom Configurations -* -* -* \note This is the configuration header file of the HAL 4.0. custom configurable -* parameters of the HAL 4.0 are provided in this file -* -* Project: NFC-FRI-1.1 / HAL4.0 -* -* $Date: Fri Jun 11 16:44:31 2010 $ -* $Author: ing04880 $ -* $Revision: 1.11 $ -* $Aliases: NFC_FRI1.1_WK1023_R35_1 $ -* -*/ - - -/*@{*/ -#ifndef NFC_CUSTOM_CONFIG_H -#define NFC_CUSTOM_CONFIG_H -/*@}*/ - - -/** -* \name Hal -* -* File: \ref nfc_custom_config.h -* -*/ - - -/* - ***************************************************************** - ********************** CUSTOM MACROS ************************** - ***************************************************************** - */ - -/**< Max number of remote devices supported*/ -#define MAX_REMOTE_DEVICES 0x10 - - -/**< Default Session ID for Initialisation */ -#define DEFAULT_SESSION "NXP-NFC2" - -/** Resolution value for the timer, here the - timer resolution is 100 milliseconds */ -#define TIMER_RESOLUTION 100U - -/**< Defines connection time out value for LLC timer, - 500 is in milliseconds */ -#define LINK_CONNECTION_TIMEOUT 500U - -/**< Defines guard time out value for LLC timer, - 250 is in milliseconds */ -#define LINK_GUARD_TIMEOUT 250U - -/**< Macro to Enable SMX Feature During - * Initialisation */ - - -/* PLEASE NOTE: This Macro should be only enabled if there is a SMART_MX - * Chip attached to the PN544. - */ -/* #define NXP_HAL_ENABLE_SMX */ - - - -/* PLEASE NOTE: Kindly change the DEFAULT_SESSION Macro for each of the - * configuration change done for the below Macros - */ - -/**< External Clock Request Configuration for the NFC Device, - 0x00U -> No Clock Request, - 0x01U -> Clock Request through CLKREQ pin (GPIO pin 2), - 0x02U -> Clock Request through NXP_EVT_CLK_REQUEST Event, - */ -#define NXP_DEFAULT_CLK_REQUEST 0x00U - -/**< External Input Clock Setting for the NFC Device, - 0x00U -> No Input Clock Required (Use the Xtal), - 0x01U -> 13 MHZ, - 0x02U -> 19.2 MHZ, - 0x03U -> 26 MHZ, - 0x04U -> 38.4 MHZ, - 0x05U -> Custom (Set the Custome Clock Registry), - */ -#define NXP_DEFAULT_INPUT_CLK 0x00U - - - -#define NFC_DEV_HWCONF_DEFAULT 0xBCU - -/**< TX LDO Configuration - 0x00 -> 00b 3.0 V, - 0x01 -> 01b 3.0 V, - 0x02 -> 10b 2.7 V, - 0x03 -> 11b 3.3 V, - - */ -#define NXP_DEFAULT_TX_LDO 0x00U - - -/**< External Clock Request Configuration for the NFC Device, - 0x00U -> No Power Request, - 0x01U -> Power Request through CLKREQ pin (GPIO pin 2), - 0x02U -> Power Request through PWR_REQUEST (GPIO Pin 3), - */ -#define NXP_UICC_PWR_REQUEST 0x00U - -/**< UICC Bit Rate Configuration - 0x02U -> 212Kbits/Sec - 0x04U -> 424Kbits/Sec - 0x08U -> 828Kbits/Sec - */ - -#define NXP_UICC_BIT_RATE 0x08U - -/**< Indicates PN544 Power Modes Configuration for the NFC Device, - 0x00U -> PN544 stays in active bat mode - (except when generating RF field) - 0x01U -> PN544 goes in standby when possible otherwise - stays in active bat mode - 0x02U -> PN544 goes in idle mode as soon as it can - (otherwise it is in active bat except when generating RF field) - 0x03U -> PN544 goes in standby when possible otherwise goes in idle mode - as soon as it can (otherwise it is in active bat except when - generating RF field) - */ - -#define NXP_SYSTEM_PWR_STATUS 0x01U - - -/**< System Event Notification - 0x01 Overcurrent - 0x02 PMUVCC Switch - 0x04 External RF Field - 0x08 Memory Violation - 0x10 Temperature Overheat - */ - -#define NXP_SYSTEM_EVT_INFO 0x10U - -/**< NFCIP Active Mode Configuration - 0x01 106 kbps - 0x02 212 kbps - 0x04 424 kbps - */ - -#define NXP_NFCIP_ACTIVE_DEFAULT 0x01U - - - -/* Reset the Default values of Host Link Timers */ -/* Macro to Enable the Host Side Link Timeout Configuration - * 0x00 ----> Default Pre-defined Configuration; - * 0x01 ----> Update only the Host Link Guard Timeout Configuration; - * 0x03 ----> Update Both the Host Link Guard Timeout - and ACK Timeout Configuration; - */ -#define HOST_LINK_TIMEOUT 0x00U - - -#define NXP_NFC_LINK_GRD_CFG_DEFAULT 0x0032U - - -#define NXP_NFC_LINK_ACK_CFG_DEFAULT 0x0005U - - -/* Macro to Enable the Interface Character Timeout Configuration - * 0x00 ----> Default Pre-defined Configuration; - * 0x01 ----> Update the IFC Timeout Default Configuration; - */ -#define NXP_NFC_IFC_TIMEOUT 0x00 - - -#define NXP_NFC_IFC_CONFIG_DEFAULT 0x203AU - - -#define NXP_NFCIP_PSL_BRS_DEFAULT 0x00U - - -#endif /* NFC_CUSTOM_CONFIG_H */ diff --git a/libnfc-nxp/nfc_osal_deferred_call.h b/libnfc-nxp/nfc_osal_deferred_call.h deleted file mode 100644 index 08396dc..0000000 --- a/libnfc-nxp/nfc_osal_deferred_call.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef __NFC_OSAL_DEFERRED_CALL_H_ -#define __NFC_OSAL_DEFERRED_CALL_H_ - -/** - * \ingroup grp_osal_nfc - *\brief Deferred call declaration. - * This type of API is called from ClientApplication ( main thread) to notify - * specific callback. - */ -typedef pphLibNfc_DeferredCallback_t nfc_osal_def_call_t; - -/** - * \ingroup grp_osal_nfc - *\brief Deferred message specific info declaration. - * This type information packed as WPARAM when \ref PHOSALNFC_MESSAGE_BASE type - *windows message is posted to main thread. - */ -typedef phLibNfc_DeferredCall_t nfc_osal_def_call_msg_t; - -/** - * \ingroup grp_osal_nfc - *\brief Deferred call declaration. - * This Deferred call post message of type \ref PH_OSALNFC_TIMER_MSG along with - * timer specific details.ain thread,which is responsible for timer callback notification - * consumes of this message and notifies respctive timer callback. - *\note: This API packs upper timer specific callback notification information and post - *ref\PHOSALNFC_MESSAGE_BASE to main thread via windows post messaging mechanism. - */ - -void nfc_osal_deferred_call(nfc_osal_def_call_t func, void *param); - -#endif \ No newline at end of file diff --git a/libnfc-nxp/phDal4Nfc.h b/libnfc-nxp/phDal4Nfc.h deleted file mode 100644 index 3cbb585..0000000 --- a/libnfc-nxp/phDal4Nfc.h +++ /dev/null @@ -1,619 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -/*! - -* \file phDal4Nfc.h -* \brief Common DAL for the upper layer. -* -* Project: NFC-FRI-1.1 -* -* $Date: Tue Nov 10 13:56:45 2009 $ -* $Author: ing07299 $ -* $Revision: 1.38 $ -* $Aliases: NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ -* -*/ - -#ifndef PHDAL4NFC_H -#define PHDAL4NFC_H - -/** -* \name DAl4 NFC -* -* File: \ref phDal4Nfc.h -* -*/ -/*@{*/ -#define PH_DAL4NFC_FILEREVISION "$Revision: 1.38 $" /**< \ingroup grp_file_attributes */ -#define PH_DAL4NFC_FILEALIASES "$Aliases: NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" - /**< \ingroup grp_file_attributes */ -/*@}*/ -/*************************** Includes *******************************/ -/** \defgroup grp_nfc_dal DAL Component - * - * - * - */ -#include -/**< Basic type definitions */ -#include -/**< Generic Interface Layer Function Definitions */ -#include -/*********************** End of includes ****************************/ - -/***************************** Macros *******************************/ - /**< Used for messaging by DAL as well as Upper Layers */ -#define PH_DAL4NFC_MESSAGE_BASE PH_LIBNFC_DEFERREDCALL_MSG - -/************************ End of macros *****************************/ - - -/********************* Structures and enums *************************/ - -/** - * \ingroup grp_nfc_dal - * - * DAL context : This contains the information of the upper layer callback - * and hardware reference. - */ -typedef struct phDal4Nfc_SContext -{ - phNfcIF_sCallBack_t cb_if; /**1.Exports DAL interfaces and DAL layer context to upper layer. - *Exported DAL interfaces are : - *

.phDal4Nfc_Shutdown - *

.phDal4Nfc_Write - *

.phDal4Nfc_Read - *

.phDal4Nfc_ReadWait - *

.phDal4Nfc_ReadWaitCancel - *

phDal4Nfc_Unregister - *

.Registeres upper layer callbacks and upper layer context with DAL layer. - *For details refer to \ref phNfcIF_sReference_t. - *Registration details are valid unless upper layer calls \ref phDal4Nfc_Unregister() - or \ref phDal4Nfc_Shutdown called. - - * \param[in,out] psRefer holds DAL exported interface references once registration - * sucessful.This also contains transmit and receive buffer - * references. - * - * \param[in] if_cb Contains upper layer callback reference details, which are used - * by DAL layer during callback notification. - * These callbacks gets registered with DAL layer. - * - - * \param[out] psIFConf Currently this parameter not used.This parameter to be other than NULL. - * - * - * \retval NFCSTATUS_SUCCESS Operation is successful. - * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. - * - *\msc - *ClientApp,UpperLayer,phDal4Nfc; - *ClientApp=>phDal4Nfc [label="phDal4Nfc_Config()",URL="\ref phDal4Nfc_Config"]; - *ClientApp<phDal4Nfc [label="phDal4Nfc_Register()",URL="\ref phDal4Nfc_Register"]; - *UpperLayer<phDal4Nfc [label="phDal4Nfc_Config()",URL="\ref phDal4Nfc_Config"]; - *ClientApp<phDal4Nfc [label="phDal4Nfc_Register()",URL="\ref phDal4Nfc_Register"]; - *UpperLayer<phDal4Nfc [label="phDal4Nfc_Unregister()",URL="\ref phDal4Nfc_Unregister"]; - *UpperLayer<
. Initialize parameters for HW Interface. - *

. Initializing read and writer threads. - *

. Initializing read and write task specific events and event specific configurations. - *

. Initializing DAL layer specific details. - * - * \param[in] pContext DAL context provided by the upper layer. - * The DAL context will be exported to the - * upper layer via upper layer registration interface. - * \param[in] pHwRef information of the hardware - * - * \retval NFCSTATUS_SUCCESS DAL initialization successful. - * \retval NFCSTATUS_INVALID_DEVICE The device is not enumerated or the - * Hardware Reference points to a device - * which does not exist. Alternatively, - * also already open devices produce this - * error. - * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function - * is invalid. - * - *\msc - *ClientApp,UpperLayer,phDal4Nfc; - *ClientApp=>phDal4Nfc [label="phDal4Nfc_Config()",URL="\ref phDal4Nfc_Config"]; - *ClientApp<phDal4Nfc [label="phDal4Nfc_Register()",URL="\ref phDal4Nfc_Register"]; - *UpperLayer<phDal4Nfc [label="phDal4Nfc_Init()",URL="\ref phDal4Nfc_Init"]; - *UpperLayer<
.Releases all the resources.( context,memory resources,read/write buffers). - *

.closes COMxx port which is used during DAL session. - *

.Terminates Reader and writer tasks. - * - * \param[in] pContext DAL context is provided by the upper layer. - * The DAL context earlier was given to the - * upper layer through the - * \ref \e phDal4Nfc_Register() function - * \param[in] pHwRef hardware reference context. - * - * \retval NFCSTATUS_SUCCESS DAL shutdown successful - * \retval NFCSTATUS_FAILED DAL shutdown failed(example.unable to - * suspend thread, close HW Interface etc.) - * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function - * is invalid. - * - *\msc - *ClientApp,UpperLayer,phDal4Nfc; - *ClientApp=>phDal4Nfc [label="phDal4Nfc_Config()",URL="\ref phDal4Nfc_Config"]; - *ClientApp<phDal4Nfc [label="phDal4Nfc_Register()",URL="\ref phDal4Nfc_Register"]; - *UpperLayer<phDal4Nfc [label="phDal4Nfc_Init()",URL="\ref phDal4Nfc_Init"]; - *UpperLayer<phDal4Nfc [label="phDal4Nfc_Shutdown()",URL="\ref phDal4Nfc_Shutdown"]; - *ClientApp<phDal4Nfc [label="phDal4Nfc_Write()",URL="\ref phDal4Nfc_Write()"]; - *UpperLayer<phDal4Nfc [label="phDal4Nfc_DeferredCall()",URL="\ref phDal4Nfc_DeferredCall()"]; - *ClientApp=>phDal4Nfc [label="phDal4Nfc_DeferredCb()",URL="\ref phDal4Nfc_DeferredCb()"]; - *phDal4Nfc=>UpperLayer [label="send_complete",URL="\ref phDal4Nfc_DeferredCb()"]; - *ClientApp<phDal4Nfc [label="phDal4Nfc_Write()",URL="\ref phDal4Nfc_Write()"]; - *UpperLayer<phDal4Nfc [label="phDal4Nfc_DeferredCall()",URL="\ref phDal4Nfc_DeferredCall()"]; - *ClientApp=>phDal4Nfc [label="phDal4Nfc_DeferredCb()",URL="\ref phDal4Nfc_DeferredCb()"]; - *phDal4Nfc=>UpperLayer [label="send_complete",URL="\ref phDal4Nfc_DeferredCb()"]; - *ClientApp<phDal4Nfc [label="phDal4Nfc_Read()",URL="\ref phDal4Nfc_Read()"]; - *UpperLayer<phDal4Nfc [label="phDal4Nfc_DeferredCall()",URL="\ref phDal4Nfc_DeferredCall()"]; - *ClientApp=>phDal4Nfc [label="phDal4Nfc_DeferredCb()",URL="\ref phDal4Nfc_DeferredCb()"]; - *phDal4Nfc=>UpperLayer [label="receive_complete",URL="\ref phDal4Nfc_DeferredCb()"]; - *ClientApp<phDal4Nfc [label="phDal4Nfc_Write()",URL="\ref phDal4Nfc_Write()"]; - *UpperLayer<phDal4Nfc [label="phDal4Nfc_DeferredCall()",URL="\ref phDal4Nfc_DeferredCall()"]; - *ClientApp=>phDal4Nfc [label="phDal4Nfc_DeferredCb()",URL="\ref phDal4Nfc_DeferredCb()"]; - *phDal4Nfc=>UpperLayer [label="send_complete",URL="\ref phDal4Nfc_DeferredCb()"]; - *ClientApp<phDal4Nfc [label="phDal4Nfc_ReadWait()",URL="\ref phDal4Nfc_ReadWait()"]; - *UpperLayer<phDal4Nfc [label="phDal4Nfc_DeferredCall()",URL="\ref phDal4Nfc_DeferredCall()"]; - *ClientApp=>phDal4Nfc [label="phDal4Nfc_DeferredCb()",URL="\ref phDal4Nfc_DeferredCb()"]; - *phDal4Nfc=>UpperLayer [label="receive_complete",URL="\ref phDal4Nfc_DeferredCb()"]; - *ClientApp<phDal4Nfc [label="phDal4Nfc_Write()",URL="\ref phDal4Nfc_Write()"]; - *UpperLayer<phDal4Nfc [label="phDal4Nfc_DeferredCall()",URL="\ref phDal4Nfc_DeferredCall()"]; - *ClientApp=>phDal4Nfc [label="phDal4Nfc_DeferredCb()",URL="\ref Call phDal4Nfc_DeferredCb()"]; - *phDal4Nfc=>UpperLayer [label="send_complete",URL="\ref phDal4Nfc_DeferredCb()"]; - *ClientApp<phDal4Nfc [label="phDal4Nfc_ReadWait()",URL="\ref phDal4Nfc_ReadWait()"]; - *UpperLayer<phDal4Nfc [label="phDal4Nfc_ReadWaitCancel()",URL="\ref phDal4Nfc_ReadWaitCancel()"]; - **UpperLayer<phDal4Nfc [label="phDal4Nfc_Config()",URL="\ref phDal4Nfc_Config"]; - *ClientApp<phDal4Nfc [label="phDal4Nfc_Config()",URL="\ref phDal4Nfc_Config"]; - *ClientApp<phDal4Nfc [label="phDal4Nfc_Register()",URL="\ref phDal4Nfc_Register"]; - *UpperLayer<phDal4Nfc [label="phDal4Nfc_Init()",URL="\ref phDal4Nfc_Init"]; - *UpperLayer<phDal4Nfc [label="phDal4Nfc_Shutdown()",URL="\ref phDal4Nfc_Shutdown"]; - *UpperLayer<phDal4Nfc [label="phDal4Nfc_ConfigRelease()",URL="\ref phDal4Nfc_ConfigRelease"]; - *ClientApp< -#else - -#ifdef _DAL_4_NFC_C -#define _ext_ -#else -#define _ext_ extern -#endif - -typedef pphLibNfc_DeferredCallback_t pphDal4Nfc_Deferred_Call_t; - -typedef phLibNfc_DeferredCall_t phDal4Nfc_DeferredCall_Msg_t; - -#ifndef WIN32 - -#ifdef USE_MQ_MESSAGE_QUEUE -#include -#define MQ_NAME_IDENTIFIER "/nfc_queue" - -_ext_ const struct mq_attr MQ_QUEUE_ATTRIBUTES -#ifdef _DAL_4_NFC_C - = { 0, /* flags */ - 10, /* max number of messages on queue */ - sizeof(phDal4Nfc_DeferredCall_Msg_t), /* max message size in bytes */ - 0 /* number of messages currently in the queue */ - } -#endif -; -#endif - -#endif - -void phDal4Nfc_DeferredCall(pphDal4Nfc_Deferred_Call_t func, void *param); -#endif -#endif - - diff --git a/libnfc-nxp/phDal4Nfc_messageQueueLib.h b/libnfc-nxp/phDal4Nfc_messageQueueLib.h deleted file mode 100644 index b13823b..0000000 --- a/libnfc-nxp/phDal4Nfc_messageQueueLib.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * \file phDalNfc_messageQueueLib.h - * \brief DAL independant message queue implementation for android (can be used under linux too) - * - * Project: Trusted NFC Linux Lignt - * - * $Date: 13 aug 2009 - * $Author: Jonathan roux - * $Revision: 1.0 $ - * - */ -#ifndef PHDAL4NFC_MESSAGEQUEUE_H -#define PHDAL4NFC_MESSAGEQUEUE_H - -#ifndef WIN32 -#ifdef ANDROID -#include -#else -#include -#endif - -typedef struct phDal4Nfc_Message_Wrapper -{ - long mtype; - phLibNfc_Message_t msg; -} phDal4Nfc_Message_Wrapper_t; - -intptr_t phDal4Nfc_msgget(key_t key, int msgflg); -int phDal4Nfc_msgctl(intptr_t msqid, int cmd, void *buf); -int phDal4Nfc_msgsnd(intptr_t msqid, void * msgp, size_t msgsz, int msgflg); -int phDal4Nfc_msgrcv(intptr_t msqid, void * msgp, size_t msgsz, long msgtyp, int msgflg); -#endif - -#endif /* PHDAL4NFC_MESSAGEQUEUE_H */ diff --git a/libnfc-nxp/phDbgTrace.h b/libnfc-nxp/phDbgTrace.h deleted file mode 100644 index b0890cb..0000000 --- a/libnfc-nxp/phDbgTrace.h +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -/** - * \file phDbgTrace.h - * Project: NFC-FRI-1.1 / HAL4.0 - * - * $Date: Tue Apr 28 11:48:33 2009 $ - * $Author: ing08203 $ - * $Revision: 1.17 $ - * $Aliases: NFC_FRI1.1_WK918_R24_1,NFC_FRI1.1_WK920_PREP1,NFC_FRI1.1_WK920_R25_1,NFC_FRI1.1_WK922_PREP1,NFC_FRI1.1_WK922_R26_1,NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ - * - */ - -/*@{*/ -#ifndef PHDBGTRACE_H -#define PHDBGTRACE_H -/*@}*/ - -#include - - -#ifdef PHDBG_TRACES -#define MAX_TRACE_BUFFER 300 - -#ifndef PHDBG_TRACES_LEVEL_0 -#ifndef PHDBG_TRACES_LEVEL_1 -#ifndef PHDBG_TRACES_LEVEL_2 -#define PHDBG_TRACES_LEVEL_0 -#endif -#endif -#endif - - extern char phOsalNfc_DbgTraceBuffer[]; - - #ifdef PHDBG_TRACES_LEVEL_0 - - /*indicates an error that causes a program to abort.*/ - #define PHDBG_FATAL_ERROR(Str) {\ - snprintf(phOsalNfc_DbgTraceBuffer,MAX_TRACE_BUFFER, \ - "FATAL ERROR in Module :%s\n",__FILE__);\ - phOsalNfc_DbgString(phOsalNfc_DbgTraceBuffer);\ - snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ - "In Function:%s\n",__FUNCTION__ ); \ - phOsalNfc_DbgString (phOsalNfc_DbgTraceBuffer);\ - } - - #define PHDBG_CRITICAL_ERROR(Str) {\ - snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ - "CRITICAL ERROR in Module :%s\n",__FILE__);\ - phOsalNfc_DbgString(phOsalNfc_DbgTraceBuffer);\ - snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ - "In Function:%s\n",__FUNCTION__ ); \ - phOsalNfc_DbgString (phOsalNfc_DbgTraceBuffer);\ - } - #define PHDBG_WARNING(Str) - #define PHDBG_INFO(Str) - #endif /*End of PHDBG_TRACES_LEVEL_0 */ - - #ifdef PHDBG_TRACES_LEVEL_1 - - /*indicates an error that causes a program to abort.*/ - #define PHDBG_FATAL_ERROR(Str) {\ - snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ - "FATAL ERROR in Module :%s\n",__FILE__);\ - phOsalNfc_DbgString(phOsalNfc_DbgTraceBuffer);\ - snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ - "In Function:%s\n",__FUNCTION__ ); \ - phOsalNfc_DbgString (phOsalNfc_DbgTraceBuffer);\ - } - - #define PHDBG_CRITICAL_ERROR(Str) {\ - snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ - "CRITICAL ERROR in Module :%s\n",__FILE__);\ - phOsalNfc_DbgString(phOsalNfc_DbgTraceBuffer);\ - snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ - "In Function:%s\n",__FUNCTION__ ); \ - phOsalNfc_DbgString (phOsalNfc_DbgTraceBuffer);\ - } - /*Normally this macro shall be used indicate system state that might cause problems in future.*/ - #define PHDBG_WARNING(Str) {\ - snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ - "WARNING :%s\n",__FILE__);\ - phOsalNfc_DbgString(phOsalNfc_DbgTraceBuffer);\ - phOsalNfc_DbgString (Str);\ - phOsalNfc_DbgString ("\n");\ - } - #define PHDBG_INFO(Str) - #endif /*End of PHDBG_TRACES_LEVEL_1 */ - - #ifdef PHDBG_TRACES_LEVEL_2 - - /*indicates an error that causes a program to abort.*/ - #define PHDBG_FATAL_ERROR(Str) {\ - snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ - "FATAL ERROR in Module :%s\n",__FILE__);\ - phOsalNfc_DbgString(phOsalNfc_DbgTraceBuffer);\ - snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ - "In Function:%s\n",__FUNCTION__ ); \ - phOsalNfc_DbgString (phOsalNfc_DbgTraceBuffer);\ - } - - #define PHDBG_CRITICAL_ERROR(Str) {\ - snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ - "CRITICAL ERROR in Module :%s\n",__FILE__);\ - phOsalNfc_DbgString(phOsalNfc_DbgTraceBuffer);\ - snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ - "In Function:%s\n",__FUNCTION__ ); \ - phOsalNfc_DbgString (phOsalNfc_DbgTraceBuffer);\ - } - /*Normally this macro shall be used indicate system state that might cause problems in future.*/ - #define PHDBG_WARNING(Str) {\ - snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ - "WARNING :%s\n",__FILE__);\ - phOsalNfc_DbgString(phOsalNfc_DbgTraceBuffer);\ - phOsalNfc_DbgString (Str);\ - phOsalNfc_DbgString ("\n");\ - } - - #define PHDBG_INFO(Str) {\ - snprintf(phOsalNfc_DbgTraceBuffer, MAX_TRACE_BUFFER, \ - "DBG INFO :%s\n",__FILE__);\ - phOsalNfc_DbgString(phOsalNfc_DbgTraceBuffer);\ - phOsalNfc_DbgString (Str);\ - phOsalNfc_DbgString ("\n");\ - } - - - -#endif /*End of PHDBG_TRACES_LEVEL_2 */ -#else -#define PHDBG_FATAL_ERROR(Str) -#define PHDBG_CRITICAL_ERROR(Str) -#define PHDBG_WARNING(Str) -#define PHDBG_INFO(Str) - - -#endif /*end of DEBUG trace*/ -#endif /* end of PHDBGTRACE_H */ diff --git a/libnfc-nxp/phDnldNfc.h b/libnfc-nxp/phDnldNfc.h deleted file mode 100644 index 7126413..0000000 --- a/libnfc-nxp/phDnldNfc.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! -* =========================================================================== * -* * -* * -* \file phDnldNfc.h * -* \brief Download Mgmt Header for the Generic Download Management. * -* * -* * -* Project: NFC-FRI-1.1 * -* * -* $Date: Thu Aug 26 15:39:56 2010 $ * -* $Author: ing04880 $ * -* $Revision: 1.7 $ * -* $Aliases: $ -* * -* =========================================================================== * -*/ - - -/*@{*/ - -#ifndef PHDNLDNFC_H -#define PHDNLDNFC_H - -/*@}*/ -/** - * \name Download Mgmt - * - * File: \ref phDnldNfc.h - * - */ -/*@{*/ -#define PH_DNLDNFC_FILEREVISION "$Revision: 1.7 $" /**< \ingroup grp_file_attributes */ -#define PH_DNLDNFC_FILEALIASES "$Aliases: $" /**< \ingroup grp_file_attributes */ -/*@}*/ - -/* -################################################################################ -***************************** Header File Inclusion **************************** -################################################################################ -*/ - -#include -#include - -/* -################################################################################ -****************************** Macro Definitions ******************************* -################################################################################ -*/ - - -/* -################################################################################ -******************** Enumeration and Structure Definition ********************** -################################################################################ -*/ - -#ifndef NXP_FW_PARAM -extern const uint8_t *nxp_nfc_fw; -#endif /* NXP_FW_PARAM */ - - - - -/* -################################################################################ -*********************** Function Prototype Declaration ************************* -################################################################################ -*/ - -/** - * \ingroup grp_hci_nfc - * - * The phDnldNfc_Upgrade function Upgrades the firmware of - * connected NFC Device with the data provided. - * - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] pHalNotify Upper layer Notification function - * pointer. - * \param[in] psContext psContext is the context of - * the Upper Layer. - * - * \retval NFCSTATUS_PENDING Upgrade of Download Layer is in Progress. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - - extern - NFCSTATUS - phDnldNfc_Upgrade ( - phHal_sHwReference_t *pHwRef, -#ifdef NXP_FW_PARAM - uint8_t *nxp_nfc_fw, - uint32_t fw_length, -#endif - pphNfcIF_Notification_CB_t upgrade_complete, - void *context - ); - - -#if !defined (NXP_FW_INTEGRITY_VERIFY) - -extern -NFCSTATUS -phDnldNfc_Run_Check( - phHal_sHwReference_t *pHwRef -#ifdef NXP_FW_PARAM - ,uint8_t *nxp_nfc_fw - uint32_t fw_length -#endif - ); -#endif /* #if !defined (NXP_FW_INTEGRITY_VERIFY) */ - - -#endif /* PHDNLDNFC_H */ - - diff --git a/libnfc-nxp/phFriNfc.h b/libnfc-nxp/phFriNfc.h deleted file mode 100644 index 3677405..0000000 --- a/libnfc-nxp/phFriNfc.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! - * \file phFriNfc.h - * \brief NFC FRI Main Header. - * - * Project: NFC-FRI - * - * $Date: Mon Dec 13 14:14:13 2010 $ - * $Author: ing02260 $ - * $Revision: 1.20 $ - * $Aliases: $ - * - */ - -#ifndef PHFRINFC_H /* */ -#define PHFRINFC_H /* */ -#include -#include - -#define PH_HAL4_ENABLE - -#ifdef PH_HAL4_ENABLE - #include - #define LOCK_BITS_CHECK_ENABLE -#endif - -#define FRINFC_READONLY_NDEF - -#ifdef DISABLE_MIFARE_MAPPING -#define PH_FRINFC_MAP_MIFAREUL_DISABLED -#define PH_FRINFC_MAP_MIFARESTD_DISABLED -#define PH_FRINFC_MAP_DESFIRE_DISABLED -#else -#define PH_NDEF_MIFARE_ULC -#endif - -#ifdef DISABLE_FELICA_MAPPING -#define PH_FRINFC_MAP_FELICA_DISABLED -#endif - -#ifdef DISABLE_JEWEL_MAPPING -#define PH_FRINFC_MAP_TOPAZ_DISABLED -#define PH_FRINFC_MAP_TOPAZ_DYNAMIC_DISABLED -#endif - -#ifdef DISABLE_ISO15693_MAPPING -#define PH_FRINFC_MAP_ISO15693_DISABLED -#endif - - -#ifdef DISABLE_FORMAT -#define PH_FRINFC_FMT_DESFIRE_DISABLED -#define PH_FRINFC_FMT_MIFAREUL_DISABLED -#define PH_FRINFC_FMT_MIFARESTD_DISABLED -#define PH_FRINFC_FMT_ISO15693_DISABLED -#endif /* #ifdef DISABLE_FORMAT */ - -#define PH_FRINFC_FMT_TOPAZ_DISABLED - -/*! - * \name NFC FRI Main Header - * - * File: \ref phFriNfc.h - * - */ -/*@{*/ - -#define PH_FRINFC_FILEREVISION "$Revision: 1.20 $" /**< \ingroup grp_file_attributes */ -#define PH_FRINFC_FILEALIASES "$Aliases: $" /**< \ingroup grp_file_attributes */ - -/*@}*/ - - -/*! - * \ingroup grp_fri_nfc_common - * - * \brief \copydoc page_cb Completion Routine - * - * NFC-FRI components that work in an overlapped style need to provide a function that is compatible - * to this definition.\n\n - * It is \b mandatory to define such a routine for components that interact with other components up or - * down the stack. Moreover, such components shall provide a function within their API to enable the - * setting of the \b Completion \b Routine address and parameters. - * - * \par First Parameter: Context - * Set to the address of the called instance (component instance context structure). For instance, - * a component that needs to give control to a component up the stack needs to call the completion - * routine of the \b upper component. The value to assign to this parameter is the \b address of - * the context structure instance of the called component. Such a structure usually contains all - * variables, data or state information a component member needs for operation. The address of the - * upper instance must be known by the lower (completing) instance. The mechanism to ensure that this - * information is present involves the structure \ref phFriNfc_CplRt_t . See its documentation for - * further information. - * - * \par Second Parameter: Status Value - * The lower layer hands over the completion status via this parameter. The completion - * routine that has been called needs to process the status in a way that is comparable to what - * a regular function return value would require. - * - * \note The prototype of the component's \b Process(ing) functions has to be compatible to this - * function pointer declaration for components interacting with others. In other cases, where - * there is no interaction or asynchronous processing the definition of the \b Process(ing) - * function can be arbitrary, if present at all. - */ - -typedef void (*pphFriNfc_Cr_t)(void*, NFCSTATUS); - - -/*! - * \ingroup grp_fri_nfc_common - * - * \brief Completion Routine structure - * - * This structure finds itself within each component that requires to report completion - * to an upper (calling) component.\n\n - * Depending on the actual implementation (static or dynamic completion information) the stack - * initialisation \b or the calling component needs to inform the initialised \b or called component - * about the completion path. This information is submitted via this structure. - * - */ -typedef struct phFriNfc_CplRt -{ - pphFriNfc_Cr_t CompletionRoutine; /*!< Address of the upper Layer's \b Process(ing) function to call upon completion. - * The stack initialiser (or depending on the implementation: the calling component) - * needs to set this member to the address of the function that needs to be within - * the completion path: A calling component would give its own processing function - * address to the lower layer. - */ - void *Context; /*!< Instance address (context) parameter. - * The stack initialiser (or depending on the implementation: the calling component) - * needs to set this member to the address of the component context structure instance - * within the completion path: A calling component would give its own instance address - * to the lower layer. - */ -} phFriNfc_CplRt_t; - - -#define NFCSTATUS_INVALID_DEVICE_REQUEST (0x10F5) - - -#endif /* __PHFRINFC_H__ */ diff --git a/libnfc-nxp/phFriNfc_DesfireFormat.h b/libnfc-nxp/phFriNfc_DesfireFormat.h deleted file mode 100644 index cabb9b0..0000000 --- a/libnfc-nxp/phFriNfc_DesfireFormat.h +++ /dev/null @@ -1,278 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! -* \file phFriNfc_DesfireFormat.h -* \brief Type4 Smart card formatting. -* -* Project: NFC-FRI -* -* $Date: Tue Jul 27 08:59:52 2010 $ -* $Author: ing02260 $ -* $Revision: 1.3 $ -* $Aliases: $ -* -*/ - -#ifndef PHFRINFC_DESFIREFORMAT_H -#define PHFRINFC_DESFIREFORMAT_H - - -/*! \ingroup grp_file_attributes -* \name NDEF Smart Card Foramting -* -* File: \ref phFriNfc_DesfireFormat.h -* -*/ -/*@{*/ - -/*@}*/ - - -/* Enum to represent the state variables*/ -enum{ - - PH_FRINFC_DESF_STATE_CREATE_AID = 0, - PH_FRINFC_DESF_STATE_SELECT_APP = 1, - PH_FRINFC_DESF_STATE_CREATE_CCFILE = 2, - PH_FRINFC_DESF_STATE_CREATE_NDEFFILE = 3, - PH_FRINFC_DESF_STATE_WRITE_CC_FILE = 4, - PH_FRINFC_DESF_STATE_WRITE_NDEF_FILE = 5, - PH_FRINFC_DESF_STATE_DISCON = 6, - PH_FRINFC_DESF_STATE_CON = 7, - PH_FRINFC_DESF_STATE_POLL = 8, - PH_FRINFC_DESF_STATE_GET_UID = 9, - PH_FRINFC_DESF_STATE_GET_SW_VERSION = 10, - PH_FRINFC_DESF_STATE_GET_HW_VERSION = 11, -#ifdef FRINFC_READONLY_NDEF - -#ifdef DESFIRE_FMT_EV1 - PH_FRINFC_DESF_STATE_RO_SELECT_APP_EV1 = 100, -#endif /* #ifdef DESFIRE_FMT_EV1 */ - - PH_FRINFC_DESF_STATE_RO_SELECT_APP = 101, - PH_FRINFC_DESF_STATE_RO_SELECT_CC_FILE = 102, - PH_FRINFC_DESF_STATE_RO_READ_CC_FILE = 103, - PH_FRINFC_DESF_STATE_RO_UPDATE_CC_FILE = 104, - -#endif /* #ifdef FRINFC_READONLY_NDEF */ - - /* following are used in the ISO wrapper commands*/ - PH_FRINFC_DESF_CREATEAPP_CMD = 0, - PH_FRINFC_DESF_SELECTAPP_CMD = 1, - PH_FRINFC_DESF_CREATECC_CMD = 2, - PH_FRINFC_DESF_CREATENDEF_CMD = 3, - PH_FRINFC_DESF_WRITECC_CMD = 4, -#ifdef FRINFC_READONLY_NDEF - PH_FRINFC_DESF_WRITECC_CMD_READ_ONLY = 20, -#endif /* #ifdef FRINFC_READONLY_NDEF */ - PH_FRINFC_DESF_WRITENDEF_CMD = 5, - PH_FRINFC_DESF_GET_HW_VERSION_CMD = 6, - PH_FRINFC_DESF_GET_SW_VERSION_CMD = 7, - PH_FRINFC_DESF_GET_UID_CMD = 8, - PH_FRINFC_DESF_WRITENDEF_CMD_SNLEN = 15, - PH_FRINFC_DESF_WRITECC_CMD_SNLEN = 28, - PH_FRINFC_DESF_CREATECCNDEF_CMD_SNLEN = 13, - PH_FRINFC_DESF_SELECTAPP_CMD_SNLEN = 9, - PH_FRINFC_DESF_CREATEAPP_CMD_SNLEN = 11, - PH_FRINFC_DESF_NATIVE_OFFSET_P1 = 0x00, - PH_FRINFC_DESF_NATIVE_OFFSET_P2 = 0x00, - PH_FRINFC_DESF_NATIVE_LE_BYTE = 0x00, - PH_FRINFC_DESF_NATIVE_CRAPP_WRDT_LEN = 5, - PH_FRINFC_DESF_NATIVE_SLAPP_WRDT_LEN = 3, - PH_FRINFC_DESF_NATIVE_CRCCNDEF_WRDT_LEN = 7, - PH_FRINFC_DESF_NATIVE_WRCC_WRDT_LEN = 22, - PH_FRINFC_DESF_NATIVE_WRNDEF_WRDT_LEN = 9 - -}; - - -/* CC File contents*/ - -#define PH_FRINFC_DESF_CCFILE_BYTES {0x00,0x0f,0x10,0x00,0x3B,0x00,0x34,0x04,0x06,0xE1,0x04,0x04,0x00,0x00,0x00 } -#define PH_FRINFC_DESF_NDEFFILE_BYTES {0x00,0x00} -#define PH_FRINFC_DESF_PICC_MASTER_KEY {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 } -#define PH_FRINFC_DESF_NFCFORUM_APP_KEY {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 } -#define PH_FRINFC_DESF_COMM_SETTINGS 0x00 -#define PH_FRINFC_DESF_CREATE_DATA_FILE_CMD 0xCD -#define PH_FRINFC_DESF_NATIVE_CLASS_BYTE 0x90 - -/* Constant defined to specify the NFC Forum Application ID : 0xEEEE10*/ -/* This is defined in order to support to N/W Byte order style : LSB : : MSB*/ -#define PH_FRINFC_DESF_FIRST_AID_BYTE 0x10 -#define PH_FRINFC_DESF_SEC_AID_BYTE 0xEE -#define PH_FRINFC_DESF_THIRD_AID_BYTE 0xEE - - -/* Create File command constants*/ -#define PH_FRINFC_DESF_CREATE_AID_CMD 0xCA - -/* Specifies the NFC Forum App Number of Keys*/ -#define PH_FRINFC_DESF_NFCFORUM_APP_NO_OF_KEYS 0x01 - -#define PH_FRINFC_DESF_SLECT_APP_CMD 0x5A - -#define PH_FRINFC_DESF_GET_VER_CMD 0x60 - - -#define PH_FRINFC_DESF_NATIVE_RESP_BYTE1 0x91 -#define PH_FRINFC_DESF_NATIVE_RESP_BYTE2 0x00 - -/* Create CC File Commands*/ -#define PH_FRINFC_DESF_CC_FILE_ID 0x03 -#define PH_FRINFC_DESF_CC_FILE_SIZE 0x0F -#define PH_FRINFC_DESF_FIRST_BYTE_CC_ACCESS_RIGHTS 0x00 -#define PH_FRINFC_DESF_SEC_BYTE_CC_ACCESS_RIGHTS 0xE0 - - -/* Create NDEF File Commands*/ -#define PH_FRINFC_DESF_NDEF_FILE_ID 0x04 -#define PH_FRINFC_DESF_NDEF_FILE_SIZE 0x04 -#define PH_FRINFC_DESF_FIRST_BYTE_NDEF_ACCESS_RIGHTS 0xE0 -#define PH_FRINFC_DESF_SEC_BYTE_NDEF_ACCESS_RIGHTS 0xEE - - -/* Write/Read Data commands/constants*/ -#define PH_FRINFC_DESF_WRITE_CMD 0x3D - -/* PICC additional frame response*/ -#define PH_FRINFC_DESF_PICC_ADDI_FRAME_RESP 0xAF - -/* Response for PICC native DESFire wrapper cmd*/ -#define PH_FRINFC_DESF_NAT_WRAP_FIRST_RESP_BYTE 0x91 -#define PH_FRINFC_DESF_NAT_WRAP_SEC_RESP_BYTE 0x00 - -/* DESFire4 Major/Minor versions*/ -#define PH_FRINFC_DESF4_MAJOR_VERSION 0x00 -#define PH_FRINFC_DESF4_MINOR_VERSION 0x06 - -/* DESFire4 memory size*/ -#define PH_FRINFC_DESF4_MEMORY_SIZE 0xEDE - -enum{ - PH_SMTCRDFMT_DESF_VAL0 = 0, - PH_SMTCRDFMT_DESF_VAL1 = 1, - PH_SMTCRDFMT_DESF_VAL2 = 2, - PH_SMTCRDFMT_DESF_VAL3 = 3, - PH_SMTCRDFMT_DESF_VAL4 = 4, - PH_SMTCRDFMT_DESF_VAL14 = 14, - PH_SMTCRDFMT_DESF_VAL15 = 15 -}; - - - -/*! -* \brief \copydoc page_reg Resets the component instance to the initial state and lets the component forget about -* the list of registered items. Moreover, the lower device is set. -* -* \param[in] NdefSmtCrdFmt Pointer to a valid or uninitialized instance of \ref phFriNfc_sNdefSmtCrdFmt_t. -* -* \note This function has to be called at the beginning, after creating an instance of -* \ref phFriNfc_sNdefSmtCrdFmt_t. Use this function to reset the instance of smart card -formatting context variables. -*/ -void phFriNfc_Desfire_Reset(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt); - -/*! -* \ingroup grp_fri_smart_card_formatting -* -* \brief Initiates the card formatting procedure for Remote Smart Card Type. -* -* \copydoc page_ovr The function initiates and formats the DESFire Card.After this -* operation,remote card would be properly initialized and -* Ndef Compliant.Depending upon the different card type, this -* function handles formatting procedure.This function also handles -* the different recovery procedures for different types of the cards. -* For both Format and Recovery Management same API is used. -* -* \param[in] phFriNfc_sNdefSmartCardFmt_t Pointer to a valid instance of the \ref phFriNfc_sNdefSmartCardFmt_t -* structure describing the component context. -* -* \retval NFCSTATUS_SUCCESS Card formatting has been successfully completed. -* \retval NFCSTATUS_PENDING The action has been successfully triggered. -* \retval NFCSTATUS_FORMAT_ERROR Error occured during the formatting procedure. -* \retval NFCSTATUS_INVALID_REMOTE_DEVICE Card Type is unsupported. -* \retval NFCSTATUS_INVALID_DEVICE_REQUEST Command or Operation types are mismatching. -* -*/ -NFCSTATUS phFriNfc_Desfire_Format(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt); - -/*! -* \brief \copydoc page_reg Resets the component instance to the initial state and lets the component forget about -* the list of registered items. Moreover, the lower device is set. -* -* \param[in] NdefSmtCrdFmt Pointer to a valid or uninitialized instance of \ref phFriNfc_sNdefSmtCrdFmt_t. -* -* \note This function has to be called at the beginning, after creating an instance of -* \ref phFriNfc_sNdefSmtCrdFmt_t. Use this function to reset the instance of smart card -formatting context variables. -*/ -void phFriNfc_Desfire_Reset(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt); - -#ifdef FRINFC_READONLY_NDEF -/*! - * \ingroup grp_fri_smart_card_formatting - * - * \brief Initiates the conversion of the already NDEF formatted tag to READ ONLY. - * - * \copydoc page_ovr The function initiates the conversion of the already NDEF formatted - * tag to READ ONLY. After this formation, remote card would be properly Ndef Compliant and READ ONLY. - * Depending upon the different card type, this function handles formatting procedure. - * - * \param[in] phFriNfc_sNdefSmartCardFmt_t Pointer to a valid instance of the \ref phFriNfc_sNdefSmartCardFmt_t - * structure describing the component context. - * - * \retval NFCSTATUS_SUCCESS Card formatting has been successfully completed. - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval NFCSTATUS_FORMAT_ERROR Error occured during the formatting procedure. - * \retval NFCSTATUS_INVALID_REMOTE_DEVICE Card Type is unsupported. - * \retval NFCSTATUS_INVALID_DEVICE_REQUEST Command or Operation types are mismatching. - * - */ -NFCSTATUS -phFriNfc_Desfire_ConvertToReadOnly ( - phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt); -#endif /* #ifdef FRINFC_READONLY_NDEF */ - -/** -*\ingroup grp_fri_smart_card_formatting -* -* \brief Smart card Formatting \b Completion \b Routine or \b Process function -* -* \copydoc page_ovr Completion Routine: This function is called by the lower layer (OVR HAL) -* when an I/O operation has finished. The internal state machine decides -* whether to call into the lower device again or to complete the process -* by calling into the upper layer's completion routine, stored within this -* component's context (\ref phFriNfc_sNdefSmtCrdFmt_t). -* -* The function call scheme is according to \ref grp_interact. No State reset is performed during -* operation. -* -* \param[in] Context The context of the current (not the lower/upper) instance, as set by the lower, -* calling layer, upon its completion. -* \param[in] Status The completion status of the lower layer (to be handled by the implementation of -* the state machine of this function like a regular return value of an internally -* called function). -* -* \note For general information about the completion routine interface please see \ref pphFriNfc_Cr_t . * The Different Status Values are as follows -* -*/ -void phFriNfc_Desf_Process(void *Context, - NFCSTATUS Status); - - -#endif - diff --git a/libnfc-nxp/phFriNfc_DesfireMap.h b/libnfc-nxp/phFriNfc_DesfireMap.h deleted file mode 100644 index 0432ab5..0000000 --- a/libnfc-nxp/phFriNfc_DesfireMap.h +++ /dev/null @@ -1,323 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * \file phFriNfc_Desfire.h - * \brief NFC Ndef Mapping For Desfire Smart Card. - * - * Project: NFC-FRI - * - * $Date: Tue Jul 27 08:58:21 2010 $ - * $Author: ing02260 $ - * $Revision: 1.5 $ - * $Aliases: $ - * - */ - -#ifndef PHFRINFC_DESFIREMAP_H -#define PHFRINFC_DESFIREMAP_H - -#include -#ifdef PH_HAL4_ENABLE -#include -#else -#include -#endif -#include -#include -#include - - - -/*! - * \name Desfire - Standard constants - * - */ -/*@{*/ -#define PH_FRINFC_NDEFMAP_DESF_READ_OP 2 /*!< Desfire Operation Flag is Read */ -#define PH_FRINFC_NDEFMAP_DESF_WRITE_OP 3 /*!< Desfire Operation Flag is Write */ -#define PH_FRINFC_NDEFMAP_DESF_NDEF_CHK_OP 4 /*!< Desfire Operation Flag is Check Ndef */ -#define PH_FRINFC_NDEFMAP_DESF_GET_LEN_OP 5 -#define PH_FRINFC_NDEFMAP_DESF_SET_LEN_OP 6 -#define PH_FRINFC_NDEFMAP_DESF_RESP_OFFSET 2 /*!< Two Status Flag at the end of the - Receive buffer*/ -#define PH_FRINFC_NDEFMAP_DESF_CAPDU_SMARTTAG_PKT_SIZE 12 /*!< Send Length for Smart Tag function*/ -#define PH_FRINFC_NDEFMAP_DESF_CAPDU_SELECT_FILE_PKT_SIZE 7 /*!< Send Length for Select File function */ -#define PH_FRINFC_NDEFMAP_DESF_CAPDU_READ_BIN_PKT_SIZE 5 /*!< Send Length for Reading a Packet */ - -/*! - * \name NDEF Mapping - states of the Finite State machine - * - */ -/*@{*/ -#ifdef DESFIRE_EV1 - #define PH_FRINFC_NDEFMAP_DESF_STATE_SELECT_SMART_TAG_EV1 4 /*!< Selection of Smart Tag is going on for Desfire EV1 */ -#endif /* #ifdef DESFIRE_EV1 */ -#define PH_FRINFC_NDEFMAP_DESF_STATE_SELECT_SMART_TAG 5 /*!< Selection of Smart Tag is going on */ -#define PH_FRINFC_NDEFMAP_DESF_STATE_SELECT_FILE 6 /*!< Selecting a file to read/write */ -#define PH_FRINFC_NDEFMAP_DESF_STATE_READ_CAP_CONT 7 /*!< Reading a capability container */ -#define PH_FRINFC_NDEFMAP_DESF_STATE_READ_BIN 8 /*!< Reading from the card */ -#define PH_FRINFC_NDEFMAP_DESF_STATE_UPDATE_BIN_BEGIN 60 /*!< Writing to the card */ -#define PH_FRINFC_NDEFMAP_DESF_STATE_UPDATE_BIN_END 61 /*!< Writing to the card */ - -#define PH_FRINFC_NDEFMAP_DESF_STATE_CHK_NDEF 10 /*!< Check Ndef is in progress */ -#define PH_FRINFC_NDEFMAP_DESF_TLV_INDEX 7 /*!< Specifies the index of TLV Structure */ -#define PH_FRINFC_NDEFMAP_DESF_NDEF_CNTRL_TLV 0x04 /*!< Specifies the NDEF File Cntrl TLV */ -#define PH_FRINFC_NDEFMAP_DESF_PROP_CNTRL_TLV 0x05 /*!< Specifies the Propreitary File Cntrl TLV */ - -/* Following Constants are used to navigate the Capability Container(CC)*/ - -/*!< Following two indexes represents the CCLEN in CC*/ -#define PH_FRINFC_NDEFMAP_DESF_CCLEN_BYTE_FIRST_INDEX 0 -#define PH_FRINFC_NDEFMAP_DESF_CCLEN_BYTE_SECOND_INDEX 1 - -/*!< Specifies the index of the Mapping Version in CC */ -#define PH_FRINFC_NDEFMAP_DESF_VER_INDEX 2 - -/*!< Following two indexes represents the MLe bytes in CC*/ -#define PH_FRINFC_NDEFMAP_DESF_MLE_BYTE_FIRST_INDEX 3 -#define PH_FRINFC_NDEFMAP_DESF_MLE_BYTE_SECOND_INDEX 4 - -/*!< Following two indexes represents the MLc bytes in CC*/ -#define PH_FRINFC_NDEFMAP_DESF_MLC_BYTE_FIRST_INDEX 5 -#define PH_FRINFC_NDEFMAP_DESF_MLC_BYTE_SECOND_INDEX 6 - -/*!< Specifies the index of the TLV in CC */ -#define PH_FRINFC_NDEFMAP_DESF_TLV_INDEX 7 - -/*!< Specifies the index of the TLV length in CC */ -#define PH_FRINFC_NDEFMAP_DESF_TLV_LEN_INDEX 8 - -/*!< Following two indexes represents the NDEF file identifier in CC*/ -#define PH_FRINFC_NDEFMAP_DESF_NDEF_FILEID_BYTE_FIRST_INDEX 9 -#define PH_FRINFC_NDEFMAP_DESF_NDEF_FILEID_BYTE_SECOND_INDEX 10 - -/*!< Following two indexes represents the NDEF file size in CC */ -#define PH_FRINFC_NDEFMAP_DESF_NDEF_FILESZ_BYTE_FIRST_INDEX 11 -#define PH_FRINFC_NDEFMAP_DESF_NDEF_FILESZ_BYTE_SECOND_INDEX 12 - -/*!< Specifies the index of the NDEF file READ access byte in CC */ -#define PH_FRINFC_NDEFMAP_DESF_NDEF_FILERD_ACCESS_INDEX 13 - -/*!< Specifies the index of the NDEF file WRITE access byte in CC */ -#define PH_FRINFC_NDEFMAP_DESF_NDEF_FILEWR_ACCESS_INDEX 14 - - -/* Macros to find Maximum NDEF File Size*/ -#define PH_NFCFRI_NDEFMAP_DESF_NDEF_FILE_SIZE (NdefMap->DesfireCapContainer.NdefFileSize - 2) -/* Specifies the size of the NLEN Bytes*/ -#define PH_FRINFC_NDEFMAP_DESF_NLEN_SIZE_IN_BYTES 2 - - -/* Following constants are used with buffer index's*/ -#define PH_FRINFC_NDEFMAP_DESF_SW1_INDEX 0 -#define PH_FRINFC_NDEFMAP_DESF_SW2_INDEX 1 - - -/* Following constants are used for SW1 SW2 status codes*/ -#define PH_FRINFC_NDEFMAP_DESF_RAPDU_SW1_BYTE 0x90 -#define PH_FRINFC_NDEFMAP_DESF_RAPDU_SW2_BYTE 0x00 - - -/* Following constatnts for shift bytes*/ -#define PH_FRINFC_NDEFMAP_DESF_SHL8 8 - - -#define PH_FRINFC_DESF_GET_VER_CMD 0x60 -#define PH_FRINFC_DESF_NATIVE_CLASS_BYTE 0x90 -#define PH_FRINFC_DESF_NATIVE_OFFSET_P1 0x00 -#define PH_FRINFC_DESF_NATIVE_OFFSET_P2 0x00 -#define PH_FRINFC_DESF_NATIVE_GETVER_RESP 0xAF -/*! -* \name NDEF Mapping - states of the Finite State machine -* -*/ -/*@{*/ - -typedef enum -{ - PH_FRINFC_DESF_STATE_GET_UID, - PH_FRINFC_DESF_STATE_GET_SW_VERSION, - PH_FRINFC_DESF_STATE_GET_HW_VERSION - -}phFriNfc_eMapDesfireState; - -typedef enum -{ - PH_FRINFC_DESF_IDX_0, - PH_FRINFC_DESF_IDX_1, - PH_FRINFC_DESF_IDX_2, - PH_FRINFC_DESF_IDX_3, - PH_FRINFC_DESF_IDX_4, - PH_FRINFC_DESF_IDX_5 - -}phFriNfc_eMapDesfireId; - -#define PH_FRINFC_DESF_ISO_NATIVE_WRAPPER() \ - do \ -{\ - NdefMap->SendRecvBuf[PH_FRINFC_DESF_IDX_0] = PH_FRINFC_DESF_NATIVE_CLASS_BYTE;\ - NdefMap->SendRecvBuf[PH_FRINFC_DESF_IDX_2] = PH_FRINFC_DESF_NATIVE_OFFSET_P1;\ - NdefMap->SendRecvBuf[PH_FRINFC_DESF_IDX_3] = PH_FRINFC_DESF_NATIVE_OFFSET_P2;\ - switch(NdefMap->State)\ -{\ - case PH_FRINFC_DESF_STATE_GET_HW_VERSION :\ - case PH_FRINFC_DESF_STATE_GET_SW_VERSION :\ - case PH_FRINFC_DESF_STATE_GET_UID :\ - if ( NdefMap->State == PH_FRINFC_DESF_STATE_GET_HW_VERSION )\ -{\ - NdefMap->SendRecvBuf[PH_FRINFC_DESF_IDX_1] = PH_FRINFC_DESF_GET_VER_CMD;\ -}\ - else\ -{\ - NdefMap->SendRecvBuf[PH_FRINFC_DESF_IDX_1] = 0xAF;\ -}\ - NdefMap->SendRecvBuf[PH_FRINFC_DESF_IDX_4] = 0x00;\ - NdefMap->SendLength = PH_FRINFC_DESF_IDX_5;\ - break;\ - default :\ - break;\ -}\ -} while(0)\ - - - - - -/*! - * \brief \copydoc page_ovr Initiates Reading of NDEF information from the Remote Device. - * - * The function initiates the reading of NDEF information from a Remote Device. - * It performs a reset of the state and starts the action (state machine). - * A periodic call of the \ref phFriNfc_NdefMap_Process has to be done once the action - * has been triggered. - * - * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing - * the component context. - * - * \param[in] PacketData Pointer to a location that receives the NDEF Packet. - * - * \param[in,out] PacketDataLength Pointer to a variable receiving the length of the NDEF packet. - * - * \param[in] Offset Indicates whether the read operation shall start from the begining of the - * file/card storage \b or continue from the last offset. The last Offset set is stored - * within a context variable (must not be modified by the integration). - * If the caller sets the value to \ref PH_FRINFC_NDEFMAP_SEEK_CUR, the component shall - * start reading from the last offset set (continue where it has stopped before). - * If set to \ref PH_FRINFC_NDEFMAP_SEEK_BEGIN, the component shall start reading - * from the begining of the card (restarted) - * - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval NFCSTATUS_INVALID_DEVICE_REQUEST If Previous Operation is Write Ndef and Offset - * is Current then this error is displayed. - * \retval NFCSTATUS_EOF_NDEF_CONTAINER_REACHED No Space in the File to read. - * \retval NFCSTATUS_MORE_INFORMATION There are more bytes to read in the card. - * \retval NFCSTATUS_SUCCESS Last Byte of the card read. - * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected - * meanwhile. - * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request. - * \retval NFCSTATUS_BUFFER_TOO_SMALL The buffer provided by the caller is too small. - * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period. - * - */ - -NFCSTATUS phFriNfc_Desfire_RdNdef( phFriNfc_NdefMap_t *NdefMap, - uint8_t *PacketData, - uint32_t *PacketDataLength, - uint8_t Offset); - -/*! - * \brief \copydoc page_ovr Initiates Writing of NDEF information to the Remote Device. - * - * The function initiates the writing of NDEF information to a Remote Device. - * It performs a reset of the state and starts the action (state machine). - * A periodic call of the \ref phFriNfc_NdefMap_Process has to be done once the action - * has been triggered. - * - * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing - * the component context. - * - * \param[in] PacketData Pointer to a location that holds the prepared NDEF Packet. - * - * \param[in,out] PacketDataLength Variable specifying the length of the prepared NDEF packet. - * - * \param[in] Offset Indicates whether the write operation shall start from the begining of the - * file/card storage \b or continue from the last offset. The last Offset set is stored - * within a context variable (must not be modified by the integration). - * If the caller sets the value to \ref PH_FRINFC_NDEFMAP_SEEK_CUR, the component shall - * start writing from the last offset set (continue where it has stopped before). - * If set to \ref PH_FRINFC_NDEFMAP_SEEK_BEGIN, the component shall start writing - * from the begining of the card (restarted) - * - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval NFCSTATUS_INVALID_DEVICE_REQUEST If Previous Operation is Write Ndef and Offset - * is Current then this error is displayed. - * \retval NFCSTATUS_EOF_NDEF_CONTAINER_REACHED Last byte is written to the card after this - * no further writing is possible. - * \retval NFCSTATUS_SUCCESS Buffer provided by the user is completely written - * into the card. - * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected - * meanwhile. - * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request. - * \retval NFCSTATUS_BUFFER_TOO_SMALL The buffer provided by the caller is too small. - * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period. - * - */ - -NFCSTATUS phFriNfc_Desfire_WrNdef( phFriNfc_NdefMap_t *NdefMap, - uint8_t *PacketData, - uint32_t *PacketDataLength, - uint8_t Offset); - -/*! - * \brief \copydoc page_ovr Check whether a particulat Remote Device is NDEF compliant. - * - * The function checks whether the peer device is NDEF compliant. - * - * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing - * the component context. - * - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. - * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected - * meanwhile. - * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request. - * \retval NFCSTATUS_BUFFER_TOO_SMALL The buffer provided by the caller is too small. - * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period. - * - */ - -NFCSTATUS phFriNfc_Desfire_ChkNdef( phFriNfc_NdefMap_t *NdefMap); - -/*! - * \brief \copydoc page_cb Completion Routine, Processing function, needed to avoid long blocking. - * - * The function call scheme is according to \ref grp_interact. No State reset is performed during operation. - * - * \copydoc pphFriNfc_Cr_t - * - * \note The lower (Overlapped HAL) layer must register a pointer to this function as a Completion - * Routine in order to be able to notify the component that an I/O has finished and data are - * ready to be processed. - * - */ - -void phFriNfc_Desfire_Process( void *Context, - NFCSTATUS Status); - - -#endif /* PHFRINFC_DESFIREMAP_H */ - diff --git a/libnfc-nxp/phFriNfc_FelicaMap.h b/libnfc-nxp/phFriNfc_FelicaMap.h deleted file mode 100644 index 298ffff..0000000 --- a/libnfc-nxp/phFriNfc_FelicaMap.h +++ /dev/null @@ -1,286 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! - * \file phFriNfc_FelicaMap.h - * \brief NFC Ndef Mapping For Felica Smart Card. - * - * Project: NFC-FRI - * - * $Date: Wed Apr 8 14:37:05 2009 $ - * $Author: ing02260 $ - * $Revision: 1.4 $ - * $Aliases: NFC_FRI1.1_WK914_R22_1,NFC_FRI1.1_WK914_R22_2,NFC_FRI1.1_WK916_R23_1,NFC_FRI1.1_WK918_R24_1,NFC_FRI1.1_WK920_PREP1,NFC_FRI1.1_WK920_R25_1,NFC_FRI1.1_WK922_PREP1,NFC_FRI1.1_WK922_R26_1,NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ - * - */ - -#ifndef PHFRINFC_FELICAMAP_H -#define PHFRINFC_FELICAMAP_H - -#include -#if !defined PH_HAL4_ENABLE -#include -#endif -#include -#include -#include - - -#ifndef PH_FRINFC_EXCLUDE_FROM_TESTFW /* */ - -#define PH_FRINFC_NDEFMAP_FELICAMAP_FILEREVISION "$Revision: 1.4 $" -#define PH_FRINFC_NDEFMAP_FELLICAMAP_FILEALIASES "$Aliases: NFC_FRI1.1_WK914_R22_1,NFC_FRI1.1_WK914_R22_2,NFC_FRI1.1_WK916_R23_1,NFC_FRI1.1_WK918_R24_1,NFC_FRI1.1_WK920_PREP1,NFC_FRI1.1_WK920_R25_1,NFC_FRI1.1_WK922_PREP1,NFC_FRI1.1_WK922_R26_1,NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" - -/* NDEF Mapping - states of the Finite State machine */ -#define PH_NFCFRI_NDEFMAP_FELI_STATE_SELECT_WILD_CARD 1 /* Select Wild Card State*/ -#define PH_NFCFRI_NDEFMAP_FELI_STATE_SELECT_NDEF_APP 2 /* Select NFC Forum Application State*/ -#define PH_FRINFC_NDEFMAP_FELI_STATE_CHK_NDEF 3 /* Ndef Complient State*/ -#define PH_NFCFRI_NDEFMAP_FELI_STATE_RD_ATTR 4 /* Read Attribute Information State*/ -#define PH_NFCFRI_NDEFMAP_FELI_STATE_RD_BLOCK 5 /* Read Data state*/ -#define PH_NFCFRI_NDEFMAP_FELI_STATE_WR_BLOCK 6 /* Write Data State*/ -#define PH_NFCFRI_NDEFMAP_FELI_STATE_ATTR_BLK_WR_BEGIN 7 /* Write Attrib Blk for write Begin*/ -#define PH_NFCFRI_NDEFMAP_FELI_STATE_ATTR_BLK_WR_END 8 /* Write Attrib Blk for write End*/ -#define PH_NFCFRI_NDEFMAP_FELI_STATE_WR_EMPTY_MSG 9 /* write Empty Ndef Msg*/ - - -#define PH_NFCFRI_NDEFMAP_FELI_WR_RESP_BYTE 0x09 /* Write Cmd Response Byte*/ -#define PH_NFCFRI_NDEFMAP_FELI_RD_RESP_BYTE 0x07 /* Read Cmd Response Byte*/ - -#define PH_NFCFRI_NDEFMAP_FELI_NMAXB 13 /* Nmaxb Identifier*/ -#define PH_NFCFRI_NDEFMAP_FELI_NBC 14 /* Nbc Identifier*/ - -#define PH_FRINFC_NDEFMAP_FELI_OP_NONE 15 /* To Read the attribute information*/ -#define PH_FRINFC_NDEFMAP_FELI_WR_ATTR_RD_OP 16 /* To Read the attribute info. while a WR Operationg*/ -#define PH_FRINFC_NDEFMAP_FELI_RD_ATTR_RD_OP 17 /* To Read the attribute info. while a RD Operationg*/ -#define PH_FRINFC_NDEFMAP_FELI_CHK_NDEF_OP 18 /* To Process the read attribute info. while a ChkNdef Operation*/ -#define PH_FRINFC_NDEFMAP_FELI_WR_EMPTY_MSG_OP 19 /* To Process the Empty NDEF Msg while erasing the NDEF data*/ - -#define PH_FRINFC_NDEFMAP_FELI_NUM_DEVICE_TO_DETECT 1 - -#define PH_NFCFRI_NDEFMAP_FELI_RESP_HEADER_LEN 13 /* To skip response code, IDm, status flgas and Nb*/ -#define PH_NFCFRI_NDEFMAP_FELI_VERSION_INDEX 13 /* Specifies Index of the version in Attribute Resp Buffer*/ -#define PH_NFCFRI_NDEFMAP_FELI_PKT_LEN_INDEX 0 /* Specifies Index of the Packet Length*/ - - -/* To Handle the EOF staus*/ -#ifndef TRUE -#define TRUE 1 -#endif /* #ifndef TRUE */ - -#ifndef FALSE -#define FALSE 0 -#endif /* #ifndef FALSE */ - - -/* NFC Device Major and Minor Version numbers*/ -/* !!CAUTION!! these needs to be updated periodically.Major and Minor version numbers - should be compatible to the version number of currently implemented mapping document. - Example : NFC Device version Number : 1.0 , specifies - Major VNo is 1, - Minor VNo is 0 */ -#define PH_NFCFRI_NDEFMAP_FELI_NFCDEV_MAJOR_VER_NUM 0x01 -#define PH_NFCFRI_NDEFMAP_FELI_NFCDEV_MINOR_VER_NUM 0x00 - -/* Macros to find major and minor T3T version numbers*/ -#define PH_NFCFRI_NDEFMAP_FELI_GET_MAJOR_T3T_VERNO(a)\ -do\ -{\ - (((a) & (0xf0))>>(4))\ -}while (0) - -#define PH_NFCFRI_NDEFMAP_FELI_GET_MINOR_T3T_VERNO(a)\ -do\ -{\ - ((a) & (0x0f))\ -}while (0) - - -/* Macro for LEN Byte Calculation*/ -#define PH_NFCFRI_NDEFMAP_FELI_CAL_LEN_BYTES(Byte1,Byte2,Byte3,DataLen)\ -do\ -{ \ - (DataLen) = (Byte1); \ - (DataLen) = (DataLen) << (16);\ - (DataLen) += (Byte2);\ - (DataLen) = (DataLen) << (8);\ - (DataLen) += (Byte3);\ -}while(0) - - - - -/* Enum for the data write operations*/ -typedef enum -{ - FELICA_WRITE_STARTED, - FELICA_WRITE_ENDED, - FELICA_EOF_REACHED_WR_WITH_BEGIN_OFFSET, - FELICA_EOF_REACHED_WR_WITH_CURR_OFFSET, - FELICA_RD_WR_EOF_CARD_REACHED, - FELICA_WRITE_EMPTY_MSG - -}phFriNfc_FelicaError_t; - - - -/*! - * \brief \copydoc page_ovr Initiates Reading of NDEF information from the Remote Device. - * - * The function initiates the reading of NDEF information from a Remote Device. - * It performs a reset of the state and starts the action (state machine). - * A periodic call of the \ref phFriNfc_NdefMap_Process has to be done once the action - * has been triggered. - * - * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing - * the component context. - * - * \param[in] PacketData Pointer to a location that receives the NDEF Packet. - * - * \param[in,out] PacketDataLength Pointer to a variable receiving the length of the NDEF packet. - * - * \param[in] Offset Indicates whether the read operation shall start from the begining of the - * file/card storage \b or continue from the last offset. The last Offset set is stored - * within a context variable (must not be modified by the integration). - * If the caller sets the value to \ref PH_FRINFC_NDEFMAP_SEEK_CUR, the component shall - * start reading from the last offset set (continue where it has stopped before). - * If set to \ref PH_FRINFC_NDEFMAP_SEEK_BEGIN, the component shall start reading - * from the begining of the card (restarted) - * - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval NFCSTATUS_INVALID_DEVICE_REQUEST If Previous Operation is Write Ndef and Offset - * is Current then this error is displayed. - * \retval NFCSTATUS_EOF_NDEF_CONTAINER_REACHED No Space in the File to read. - * \retval NFCSTATUS_SUCCESS Last Byte of the card read. - * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected - * meanwhile. - * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request. - * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period. - * - */ - -NFCSTATUS phFriNfc_Felica_RdNdef( phFriNfc_NdefMap_t *NdefMap, - uint8_t *PacketData, - uint32_t *PacketDataLength, - uint8_t Offset); - -/*! - * \brief \copydoc page_ovr Initiates Writing of NDEF information to the Remote Device. - * - * The function initiates the writing of NDEF information to a Remote Device. - * It performs a reset of the state and starts the action (state machine). - * A periodic call of the \ref phFriNfc_NdefMap_Process has to be done once the action - * has been triggered. - * - * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing - * the component context. - * - * \param[in] PacketData Pointer to a location that holds the prepared NDEF Packet. - * - * \param[in,out] PacketDataLength Variable specifying the length of the prepared NDEF packet. - * - * \param[in] Offset Indicates whether the write operation shall start from the begining of the - * file/card storage \b or continue from the last offset. The last Offset set is stored - * within a context variable (must not be modified by the integration). - * If the caller sets the value to \ref PH_FRINFC_NDEFMAP_SEEK_CUR, the component shall - * start writing from the last offset set (continue where it has stopped before). - * If set to \ref PH_FRINFC_NDEFMAP_SEEK_BEGIN, the component shall start writing - * from the begining of the card (restarted) - * - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval NFCSTATUS_INVALID_DEVICE_REQUEST If Previous Operation is Write Ndef and Offset - * is Current then this error is displayed. - * \retval NFCSTATUS_EOF_NDEF_CONTAINER_REACHED Last byte is written to the card after this - * no further writing is possible. - * \retval NFCSTATUS_SUCCESS Buffer provided by the user is completely written - * into the card. - * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected - * meanwhile. - * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request. - * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period. - * - */ - -NFCSTATUS phFriNfc_Felica_WrNdef( phFriNfc_NdefMap_t *NdefMap, - uint8_t *PacketData, - uint32_t *PacketDataLength, - uint8_t Offset); - -/*! - * \brief \copydoc page_ovr Initiates Writing of Empty NDEF information to the Remote Device. - * - * The function initiates the erasing of NDEF information to a Remote Device. - * It performs a reset of the state and starts the action (state machine). - * A periodic call of the \ref phFriNfc_NdefMap_Process has to be done once the action - * has been triggered. - * - * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing - * the component context. - * - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval NFCSTATUS_SUCCESS Empty msessage is completely written - * into the card. - * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected - * meanwhile. - * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request. - * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period. - * - */ - -NFCSTATUS phFriNfc_Felica_EraseNdef( phFriNfc_NdefMap_t *NdefMap); - - -/*! - * \brief \copydoc page_ovr Check whether a particulat Remote Device is NDEF compliant. - * - * The function checks whether the peer device is NDEF compliant. - * - * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing - * the component context. - * - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. - * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected - * meanwhile. - * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request. - * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period. - * - */ - -NFCSTATUS phFriNfc_Felica_ChkNdef( phFriNfc_NdefMap_t *NdefMap); - -/*! - * \brief \copydoc page_cb Completion Routine, Processing function, needed to avoid long blocking. - * - * The function call scheme is according to \ref grp_interact. No State reset is performed during operation. - * - * \copydoc pphFriNfc_Cr_t - * - * \note The lower (Overlapped HAL) layer must register a pointer to this function as a Completion - * Routine in order to be able to notify the component that an I/O has finished and data are - * ready to be processed. - * - */ - -void phFriNfc_Felica_Process(void *Context, - NFCSTATUS Status); - - -#endif /* PH_FRINFC_EXCLUDE_FROM_TESTFW */ - - -#endif /* PHFRINFC_FELICAMAP_H */ - - diff --git a/libnfc-nxp/phFriNfc_ISO15693Format.h b/libnfc-nxp/phFriNfc_ISO15693Format.h deleted file mode 100644 index 9dab3c1..0000000 --- a/libnfc-nxp/phFriNfc_ISO15693Format.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! -* \file phFriNfc_ISO15693Format.h -* \brief ISO-15693 Smart card formatting. -* -* Project: NFC-FRI -* -* $Date: $ -* $Author: ing02260 $ -* $Revision: 1.0 $ -* $Aliases: $ -* -*/ - -#ifndef PHFRINFC_ISO15693FORMAT_H -#define PHFRINFC_ISO15693FORMAT_H - -/****************************** Macro definitions start ********************************/ - -/****************************** Macro definitions end ********************************/ - -/****************************** Data structures start ********************************/ - -/****************************** Data structures end ********************************/ - -/*********************** External function declarations start ***********************/ -/*! -* \brief \copydoc page_reg Resets the component instance to the initial state and lets the component forget about -* the list of registered items. Moreover, the lower device is set. -* -* \param[in] NdefSmtCrdFmt Pointer to a valid or uninitialized instance of \ref phFriNfc_sNdefSmtCrdFmt_t. -* -* \note This function has to be called at the beginning, after creating an instance of -* \ref phFriNfc_sNdefSmtCrdFmt_t. Use this function to reset the instance of smart card -formatting context variables. -*/ -void -phFriNfc_ISO15693_FmtReset ( - phFriNfc_sNdefSmtCrdFmt_t *psNdefSmtCrdFmt); - -/*! -* \ingroup grp_fri_smart_card_formatting -* -* \brief Initiates the card formatting procedure for Remote Smart Card Type. -* -* \copydoc page_ovr The function initiates and formats the ISO-15693 Card.After this -* operation,remote card would be properly initialized and -* Ndef Compliant.Depending upon the different card type, this -* function handles formatting procedure.This function also handles -* the different recovery procedures for different types of the cards. -* For both Format and Recovery Management same API is used. -* -* \param[in] phFriNfc_sNdefSmartCardFmt_t Pointer to a valid instance of the \ref phFriNfc_sNdefSmartCardFmt_t -* structure describing the component context. -* -* \retval NFCSTATUS_SUCCESS Card formatting has been successfully completed. -* \retval NFCSTATUS_PENDING The action has been successfully triggered. -* \retval NFCSTATUS_FORMAT_ERROR Error occured during the formatting procedure. -* \retval NFCSTATUS_INVALID_REMOTE_DEVICE Card Type is unsupported. -* \retval NFCSTATUS_INVALID_DEVICE_REQUEST Command or Operation types are mismatching. -* -*/ -NFCSTATUS -phFriNfc_ISO15693_Format ( - phFriNfc_sNdefSmtCrdFmt_t *psNdefSmtCrdFmt); - -/** -*\ingroup grp_fri_smart_card_formatting -* -* \brief Smart card Formatting \b Completion \b Routine or \b Process function -* -* \copydoc page_ovr Completion Routine: This function is called by the lower layer (OVR HAL) -* when an I/O operation has finished. The internal state machine decides -* whether to call into the lower device again or to complete the process -* by calling into the upper layer's completion routine, stored within this -* component's context (\ref phFriNfc_sNdefSmtCrdFmt_t). -* -* The function call scheme is according to \ref grp_interact. No State reset is performed during -* operation. -* -* \param[in] Context The context of the current (not the lower/upper) instance, as set by the lower, -* calling layer, upon its completion. -* \param[in] Status The completion status of the lower layer (to be handled by the implementation of -* the state machine of this function like a regular return value of an internally -* called function). -* -* \note For general information about the completion routine interface please see \ref pphFriNfc_Cr_t . -* The Different Status Values are as follows -* -*/ -void -phFriNfc_ISO15693_FmtProcess ( - void *pContext, - NFCSTATUS Status); - -/*********************** External function declarations end ***********************/ - -#endif /* #define PHFRINFC_ISO15693FORMAT_H */ - - - diff --git a/libnfc-nxp/phFriNfc_ISO15693Map.h b/libnfc-nxp/phFriNfc_ISO15693Map.h deleted file mode 100644 index f4c0c08..0000000 --- a/libnfc-nxp/phFriNfc_ISO15693Map.h +++ /dev/null @@ -1,219 +0,0 @@ -/* - * - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * \file phFriNfc_ISO15693Map.h - * \brief NFC Ndef Mapping For ISO-15693 Smart Card. - * - * Project: NFC-FRI - * - * $Date: $ - * $Author: ing02260 $ - * $Revision: $ - * $Aliases: $ - * - */ - -#ifndef PHFRINFC_ISO15693MAP_H -#define PHFRINFC_ISO15693MAP_H - -/************************** START MACROS definition *********************/ -/* BYTES in a BLOCK */ -#define ISO15693_BYTES_PER_BLOCK 0x04U -/* BLOCKS per page */ -#define ISO15693_BLOCKS_PER_PAGE 0x04U -/* 3 BYTE value identifier for NDEF TLV */ -#define ISO15693_THREE_BYTE_LENGTH_ID 0xFFU - -/* Get the NDEF TLV VALUE field block and byte address */ -#define ISO15693_GET_VALUE_FIELD_BLOCK_NO(blk, byte_addr, ndef_size) \ - (((byte_addr + 1 + ((ndef_size >= ISO15693_THREE_BYTE_LENGTH_ID) ? 3 : 1)) > \ - (ISO15693_BYTES_PER_BLOCK - 1)) ? (blk + 1) : blk) - -#define ISO15693_GET_VALUE_FIELD_BYTE_NO(blk, byte_addr, ndef_size) \ - (((byte_addr + 1 + ((ndef_size >= ISO15693_THREE_BYTE_LENGTH_ID) ? 3 : 1)) % \ - ISO15693_BYTES_PER_BLOCK)) - -/************************** END MACROS definition *********************/ - -/************************** START Functions declaration *********************/ -/*! - * \brief \copydoc page_ovr Initiates Reading of NDEF information from the Remote Device. - * - * The function initiates the reading of NDEF information from a Remote Device. - * It performs a reset of the state and starts the action (state machine). - * A periodic call of the \ref phFriNfc_NdefMap_Process has to be done once the action - * has been triggered. - * - * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing - * the component context. - * - * \param[in] PacketData Pointer to a location that receives the NDEF Packet. - * - * \param[in,out] PacketDataLength Pointer to a variable receiving the length of the NDEF packet. - * - * \param[in] Offset Indicates whether the read operation shall start from the begining of the - * file/card storage \b or continue from the last offset. The last Offset set is stored - * within a context variable (must not be modified by the integration). - * If the caller sets the value to \ref PH_FRINFC_NDEFMAP_SEEK_CUR, the component shall - * start reading from the last offset set (continue where it has stopped before). - * If set to \ref PH_FRINFC_NDEFMAP_SEEK_BEGIN, the component shall start reading - * from the begining of the card (restarted) - * - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval NFCSTATUS_INVALID_DEVICE_REQUEST If Previous Operation is Write Ndef and Offset - * is Current then this error is displayed. - * \retval NFCSTATUS_EOF_NDEF_CONTAINER_REACHED No Space in the File to read. - * \retval NFCSTATUS_MORE_INFORMATION There are more bytes to read in the card. - * \retval NFCSTATUS_SUCCESS Last Byte of the card read. - * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected - * meanwhile. - * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request. - * \retval NFCSTATUS_BUFFER_TOO_SMALL The buffer provided by the caller is too small. - * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period. - * - */ - -NFCSTATUS -phFriNfc_ISO15693_RdNdef ( - phFriNfc_NdefMap_t *psNdefMap, - uint8_t *pPacketData, - uint32_t *pPacketDataLength, - uint8_t Offset); - -/*! - * \brief \copydoc page_ovr Initiates Writing of NDEF information to the Remote Device. - * - * The function initiates the writing of NDEF information to a Remote Device. - * It performs a reset of the state and starts the action (state machine). - * A periodic call of the \ref phFriNfc_NdefMap_Process has to be done once the action - * has been triggered. - * - * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing - * the component context. - * - * \param[in] PacketData Pointer to a location that holds the prepared NDEF Packet. - * - * \param[in,out] PacketDataLength Variable specifying the length of the prepared NDEF packet. - * - * \param[in] Offset Indicates whether the write operation shall start from the begining of the - * file/card storage \b or continue from the last offset. The last Offset set is stored - * within a context variable (must not be modified by the integration). - * If the caller sets the value to \ref PH_FRINFC_NDEFMAP_SEEK_CUR, the component shall - * start writing from the last offset set (continue where it has stopped before). - * If set to \ref PH_FRINFC_NDEFMAP_SEEK_BEGIN, the component shall start writing - * from the begining of the card (restarted) - * - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval NFCSTATUS_INVALID_DEVICE_REQUEST If Previous Operation is Write Ndef and Offset - * is Current then this error is displayed. - * \retval NFCSTATUS_EOF_NDEF_CONTAINER_REACHED Last byte is written to the card after this - * no further writing is possible. - * \retval NFCSTATUS_SUCCESS Buffer provided by the user is completely written - * into the card. - * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected - * meanwhile. - * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request. - * \retval NFCSTATUS_BUFFER_TOO_SMALL The buffer provided by the caller is too small. - * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period. - * - */ - -NFCSTATUS -phFriNfc_ISO15693_WrNdef ( - phFriNfc_NdefMap_t *psNdefMap, - uint8_t *pPacketData, - uint32_t *pPacketDataLength, - uint8_t Offset); - -/*! - * \brief \copydoc page_ovr Check whether a particulat Remote Device is NDEF compliant. - * - * The function checks whether the peer device is NDEF compliant. - * - * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing - * the component context. - * - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. - * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected - * meanwhile. - * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request. - * \retval NFCSTATUS_BUFFER_TOO_SMALL The buffer provided by the caller is too small. - * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period. - * - */ - -NFCSTATUS -phFriNfc_ISO15693_ChkNdef ( - phFriNfc_NdefMap_t *psNdefMap); - -/*! - * \brief \copydoc page_cb Completion Routine, Processing function, needed to avoid long blocking. - * - * The function call scheme is according to \ref grp_interact. No State reset is performed during operation. - * - * \copydoc pphFriNfc_Cr_t - * - * \note The lower (Overlapped HAL) layer must register a pointer to this function as a Completion - * Routine in order to be able to notify the component that an I/O has finished and data are - * ready to be processed. - * - */ - -void -phFriNfc_ISO15693_Process ( - void *pContext, - NFCSTATUS Status); - -#ifdef FRINFC_READONLY_NDEF - -/*! - * \brief \copydoc page_ovr Initiates Writing of NDEF information to the Remote Device. - * - * The function initiates the writing of NDEF information to a Remote Device. - * It performs a reset of the state and starts the action (state machine). - * A periodic call of the \ref phFriNfc_NdefMap_Process has to be done once the action - * has been triggered. - * - * \param[in] psNdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing - * the component context. - * - * - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval NFCSTATUS_INVALID_DEVICE_REQUEST If Previous Operation is Write Ndef and Offset - * is Current then this error is displayed. - * \retval NFCSTATUS_EOF_NDEF_CONTAINER_REACHED Last byte is written to the card after this - * no further writing is possible. - * \retval NFCSTATUS_SUCCESS Buffer provided by the user is completely written - * into the card. - * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected - * meanwhile. - * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request. - * \retval NFCSTATUS_BUFFER_TOO_SMALL The buffer provided by the caller is too small. - * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period. - * - */ -NFCSTATUS -phFriNfc_ISO15693_ConvertToReadOnly ( - phFriNfc_NdefMap_t *psNdefMap); - -#endif /* #ifdef FRINFC_READONLY_NDEF */ - -/************************** END Functions declaration *********************/ - -#endif /* #ifndef PHFRINFC_ISO15693MAP_H */ diff --git a/libnfc-nxp/phFriNfc_IntNdefMap.h b/libnfc-nxp/phFriNfc_IntNdefMap.h deleted file mode 100644 index 1951000..0000000 --- a/libnfc-nxp/phFriNfc_IntNdefMap.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * \file phFriNfc_IntNdefMap.h - * \brief NFC Internal Ndef Mapping File. - * - * Project: NFC-FRI - * - * $Date: Mon Sep 15 15:10:49 2008 $ - * $Author: ing08205 $ - * $Revision: 1.5 $ - * $Aliases: NFC_FRI1.1_WK838_R9_PREP2,NFC_FRI1.1_WK838_R9_1,NFC_FRI1.1_WK840_R10_PREP1,NFC_FRI1.1_WK840_R10_1,NFC_FRI1.1_WK842_R11_PREP1,NFC_FRI1.1_WK842_R11_PREP2,NFC_FRI1.1_WK842_R11_1,NFC_FRI1.1_WK844_PREP1,NFC_FRI1.1_WK844_R12_1,NFC_FRI1.1_WK846_PREP1,NFC_FRI1.1_WK846_R13_1,NFC_FRI1.1_WK848_PREP1,NFC_FRI1.1_WK848_R14_1,NFC_FRI1.1_WK850_PACK1,NFC_FRI1.1_WK851_PREP1,NFC_FRI1.1_WK850_R15_1,NFC_FRI1.1_WK902_PREP1,NFC_FRI1.1_WK902_R16_1,NFC_FRI1.1_WK904_PREP1,NFC_FRI1.1_WK904_R17_1,NFC_FRI1.1_WK906_R18_1,NFC_FRI1.1_WK908_PREP1,NFC_FRI1.1_WK908_R19_1,NFC_FRI1.1_WK910_PREP1,NFC_FRI1.1_WK910_R20_1,NFC_FRI1.1_WK912_PREP1,NFC_FRI1.1_WK912_R21_1,NFC_FRI1.1_WK914_PREP1,NFC_FRI1.1_WK914_R22_1,NFC_FRI1.1_WK914_R22_2,NFC_FRI1.1_WK916_R23_1,NFC_FRI1.1_WK918_R24_1,NFC_FRI1.1_WK920_PREP1,NFC_FRI1.1_WK920_R25_1,NFC_FRI1.1_WK922_PREP1,NFC_FRI1.1_WK922_R26_1,NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ - * - */ - -#ifndef PHFRINFC_INTNDEFMAP_H -#define PHFRINFC_INTNDEFMAP_H - -#include -#ifdef PH_HAL4_ENABLE - #include -#else - #include -#endif -#include -#include -#include - - - -/*! - * \name phFriNfc_IntNdefMap.h - * This file has functions which are used common across all the - typ1/type2/type3/type4 tags. - * - */ -/*@{*/ - -#define PH_FRINFC_NDEFMAP_TLVLEN_ZERO 0 - -/* NFC Device Major and Minor Version numbers*/ -/* !!CAUTION!! these needs to be updated periodically.Major and Minor version numbers - should be compatible to the version number of currently implemented mapping document. - Example : NFC Device version Number : 1.0 , specifies - Major VNo is 1, - Minor VNo is 0 */ -#define PH_NFCFRI_NDEFMAP_NFCDEV_MAJOR_VER_NUM 0x01 -#define PH_NFCFRI_NDEFMAP_NFCDEV_MINOR_VER_NUM 0x00 - -/* Macros to find major and minor TAG : Ex:Type1/Type2/Type3/Type4 version numbers*/ -#define PH_NFCFRI_NDEFMAP_GET_MAJOR_TAG_VERNO(a) (((a) & (0xf0))>>(4)) -#define PH_NFCFRI_NDEFMAP_GET_MINOR_TAG_VERNO(a) ((a) & (0x0f)) - - -/*! - * \name NDEF Mapping - states of the Finite State machine - * - */ -/*@{*/ - -NFCSTATUS phFriNfc_NdefMap_CheckSpecVersion(phFriNfc_NdefMap_t *NdefMap, - uint8_t VersionIndex); - -NFCSTATUS phFriNfc_NdefMap_SetCardState(phFriNfc_NdefMap_t *NdefMap, - uint16_t Length); - -#endif /* PHFRINFC_INTNDEFMAP_H */ diff --git a/libnfc-nxp/phFriNfc_Llcp.h b/libnfc-nxp/phFriNfc_Llcp.h deleted file mode 100644 index 728697f..0000000 --- a/libnfc-nxp/phFriNfc_Llcp.h +++ /dev/null @@ -1,463 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * \file phFriNfc_Llcp.h - * \brief NFC LLCP core - * - * Project: NFC-FRI - * - */ - -#ifndef PHFRINFC_LLCP_H -#define PHFRINFC_LLCP_H - -/*include files*/ -#include -#include -#include -#include - -#include - -/** - * \name NFC Forum Logical Link Control Protocol - * - * File: \ref phFriNfc_Llcp.h - * - */ - - -/** \defgroup grp_fri_nfc_llcp NFC Forum Logical Link Control Protocol Component - * - * TODO - * - */ - -/*=========== DEBUG MACROS ===========*/ - -/* LLCP TRACE Macros */ -#if defined(LLCP_TRACE) -#include -#include -extern char phOsalNfc_DbgTraceBuffer[]; -#define LLCP_MAX_TRACE_BUFFER 150 -#define LLCP_PRINT( str ) phOsalNfc_DbgString(str) -#define LLCP_DEBUG(str, arg) \ - { \ - snprintf(phOsalNfc_DbgTraceBuffer,LLCP_MAX_TRACE_BUFFER,str,arg); \ - phOsalNfc_DbgString(phOsalNfc_DbgTraceBuffer); \ - } -#define LLCP_PRINT_BUFFER(msg,buf,len) \ - { \ - snprintf(phOsalNfc_DbgTraceBuffer,LLCP_MAX_TRACE_BUFFER,"\n\t %s:",msg); \ - phOsalNfc_DbgString(phOsalNfc_DbgTraceBuffer); \ - phOsalNfc_DbgTrace(buf,len); \ - phOsalNfc_DbgString("\r"); \ - } -#else -#define LLCP_PRINT( str ) -#define LLCP_DEBUG(str, arg) -#define LLCP_PRINT_BUFFER(msg,buf,len) -#endif - - -/*=========== CONSTANTS ===========*/ - -/** - * \name LLCP local protocol version. - * - */ - /*@{*/ -#define PHFRINFC_LLCP_VERSION_MAJOR 0x01 /**< Major number of local LLCP version.*/ -#define PHFRINFC_LLCP_VERSION_MINOR 0x01 /**< Minor number of local LLCP version.*/ -#define PHFRINFC_LLCP_VERSION ((PHFRINFC_LLCP_VERSION_MAJOR << 4) | PHFRINFC_LLCP_VERSION_MINOR) /**< Local LLCP version.*/ -/*@}*/ - -/** - * \name LLCP packet types. - * - */ - /*@{*/ -#define PHFRINFC_LLCP_PTYPE_SYMM 0x00 /**< Symmetry.*/ -#define PHFRINFC_LLCP_PTYPE_PAX 0x01 /**< PArameter Exchange.*/ -#define PHFRINFC_LLCP_PTYPE_AGF 0x02 /**< AGgregated Frame.*/ -#define PHFRINFC_LLCP_PTYPE_UI 0x03 /**< Unnumbered Information.*/ -#define PHFRINFC_LLCP_PTYPE_CONNECT 0x04 /**< Connect.*/ -#define PHFRINFC_LLCP_PTYPE_DISC 0x05 /**< Disconnect.*/ -#define PHFRINFC_LLCP_PTYPE_CC 0x06 /**< Connection Complete.*/ -#define PHFRINFC_LLCP_PTYPE_DM 0x07 /**< Disconnected Mode.*/ -#define PHFRINFC_LLCP_PTYPE_FRMR 0x08 /**< FRaMe Reject.*/ -#define PHFRINFC_LLCP_PTYPE_SNL 0x09 /**< Service Name Lookup.*/ -#define PHFRINFC_LLCP_PTYPE_RESERVED1 0x0A /**< Reserved.*/ -#define PHFRINFC_LLCP_PTYPE_RESERVED2 0x0B /**< Reserved.*/ -#define PHFRINFC_LLCP_PTYPE_I 0x0C /**< Information.*/ -#define PHFRINFC_LLCP_PTYPE_RR 0x0D /**< Receive Ready.*/ -#define PHFRINFC_LLCP_PTYPE_RNR 0x0E /**< Receive Not Ready.*/ -#define PHFRINFC_LLCP_PTYPE_RESERVED3 0x0F /**< Reserved.*/ -/*@}*/ - -/** - * \name LLCP well-known SAPs. - * - */ - /*@{*/ -#define PHFRINFC_LLCP_SAP_LINK 0x00 /**< Link SAP.*/ -#define PHFRINFC_LLCP_SAP_SDP 0x01 /**< Service Discovery Protocol SAP.*/ -#define PHFRINFC_LLCP_SAP_WKS_FIRST 0x02 /**< Other Well-Known Services defined by the NFC Forum.*/ -#define PHFRINFC_LLCP_SAP_SDP_ADVERTISED_FIRST 0x10 /**< First SAP number from SDP-avertised SAP range.*/ -#define PHFRINFC_LLCP_SAP_SDP_UNADVERTISED_FIRST 0x20 /**< First SAP number from SDP-unavertised SAP range.*/ -#define PHFRINFC_LLCP_SAP_NUMBER 0x40 /**< Number of possible SAP values (also first invalid value).*/ -#define PHFRINFC_LLCP_SAP_DEFAULT 0xFF /**< Default number when a socket is created or reset */ -#define PHFRINFC_LLCP_SDP_ADVERTISED_NB 0x10 /**< Number of SDP advertised SAP slots */ -/*@}*/ - -/** - * \name LLCP well-known SAPs. - * - */ - /*@{*/ -#define PHFRINFC_LLCP_SERVICENAME_SDP "urn:nfc:sn:sdp" /**< Service Discovery Protocol name.*/ -/*@}*/ - -/** - * \name Length value for DM opCode - * - */ - /*@{*/ -#define PHFRINFC_LLCP_DM_LENGTH 0x01 /**< Length value for DM opCode */ -/*@}*/ - - -/** - * \internal - * \name Masks used with parameters value. - * - */ -/*@{*/ -#define PHFRINFC_LLCP_TLV_MIUX_MASK 0x07FF /**< \internal Mask to apply to MIUX TLV Value.*/ -#define PHFRINFC_LLCP_TLV_WKS_MASK 0x0001 /**< \internal Minimal bits to be set in WKS TLV Value.*/ -#define PHFRINFC_LLCP_TLV_RW_MASK 0x0F /**< \internal Mask to apply to RW TLV Value.*/ -#define PHFRINFC_LLCP_TLV_OPT_MASK 0x03 /**< \internal Mask to apply to OPT TLV Value.*/ -/*@}*/ - -/** - * \internal - * \name Type codes for parameters in TLV. - * - */ -/*@{*/ -#define PHFRINFC_LLCP_TLV_TYPE_VERSION 0x01 /**< \internal VERSION parameter Type code.*/ -#define PHFRINFC_LLCP_TLV_TYPE_MIUX 0x02 /**< \internal MIUX parameter Type code.*/ -#define PHFRINFC_LLCP_TLV_TYPE_WKS 0x03 /**< \internal WKS parameter Type code.*/ -#define PHFRINFC_LLCP_TLV_TYPE_LTO 0x04 /**< \internal LTO parameter Type code.*/ -#define PHFRINFC_LLCP_TLV_TYPE_RW 0x05 /**< \internal RW parameter Type code.*/ -#define PHFRINFC_LLCP_TLV_TYPE_SN 0x06 /**< \internal SN parameter Type code.*/ -#define PHFRINFC_LLCP_TLV_TYPE_OPT 0x07 /**< \internal OPT parameter Type code.*/ -#define PHFRINFC_LLCP_TLV_TYPE_SDREQ 0x08 /**< \internal SDREQ parameter Type code.*/ -#define PHFRINFC_LLCP_TLV_TYPE_SDRES 0x09 /**< \internal SDRES parameter Type code.*/ -/*@}*/ - -/** - * \internal - * \name Fixed Value length for parameters in TLV. - * - */ -/*@{*/ -#define PHFRINFC_LLCP_TLV_LENGTH_HEADER 2 /**< \internal Fixed length of Type and Length fields in TLV.*/ -#define PHFRINFC_LLCP_TLV_LENGTH_VERSION 1 /**< \internal Fixed length of VERSION parameter Value.*/ -#define PHFRINFC_LLCP_TLV_LENGTH_MIUX 2 /**< \internal Fixed length of MIUX parameter Value.*/ -#define PHFRINFC_LLCP_TLV_LENGTH_WKS 2 /**< \internal Fixed length of WKS parameter Value.*/ -#define PHFRINFC_LLCP_TLV_LENGTH_LTO 1 /**< \internal Fixed length of LTO parameter Value.*/ -#define PHFRINFC_LLCP_TLV_LENGTH_RW 1 /**< \internal Fixed length of RW parameter Value.*/ -#define PHFRINFC_LLCP_TLV_LENGTH_OPT 1 /**< \internal Fixed length of OPT parameter Value.*/ -/*@}*/ - -/** - * \name LLCP packet field sizes. - * - */ - /*@{*/ -#define PHFRINFC_LLCP_PACKET_HEADER_SIZE 2 /**< Size of the general packet header (DSAP+PTYPE+SSAP).*/ -#define PHFRINFC_LLCP_PACKET_SEQUENCE_SIZE 1 /**< Size of the sequence field, if present.*/ -#define PHFRINFC_LLCP_PACKET_MAX_SIZE (PHFRINFC_LLCP_PACKET_HEADER_SIZE + \ - PHFRINFC_LLCP_PACKET_SEQUENCE_SIZE + \ - PHFRINFC_LLCP_MIU_DEFAULT + \ - PHFRINFC_LLCP_TLV_MIUX_MASK) /**< Maximum size of a packet */ -/*@}*/ - -/*========== MACROS ===========*/ - -#define CHECK_SEND_RW(socket) ( (((socket)->socket_VS - (socket)->socket_VSA) % 16) < (socket)->remoteRW ) - -/*========== ENUMERATES ===========*/ - -typedef phFriNfc_LlcpMac_ePeerType_t phFriNfc_Llcp_eRole_t; - -typedef phFriNfc_LlcpMac_eLinkStatus_t phFriNfc_Llcp_eLinkStatus_t; - -/*========== CALLBACKS ===========*/ - -typedef void (*phFriNfc_Llcp_Check_CB_t) ( - void *pContext, - NFCSTATUS status -); - -typedef void (*phFriNfc_Llcp_LinkStatus_CB_t) ( - void *pContext, - phFriNfc_Llcp_eLinkStatus_t eLinkStatus -); - -typedef void (*phFriNfc_Llcp_LinkSend_CB_t) ( - void *pContext, - uint8_t socketIndex, - NFCSTATUS status -); - -typedef void (*phFriNfc_Llcp_Send_CB_t) ( - void *pContext, - NFCSTATUS status -); - -typedef void (*phFriNfc_Llcp_Recv_CB_t) ( - void *pContext, - phNfc_sData_t *psData, - NFCSTATUS status -); - -/*========== STRUCTURES ===========*/ - -typedef struct phFriNfc_Llcp_sPacketHeader -{ - /**< The destination service access point*/ - unsigned dsap : 6; - - /**< The packet type*/ - unsigned ptype : 4; - - /**< The source service access point*/ - unsigned ssap : 6; - -} phFriNfc_Llcp_sPacketHeader_t; - -typedef struct phFriNfc_Llcp_sPacketSequence -{ - /**< Sequence number for sending*/ - unsigned ns : 4; - - /**< Sequence number for reception*/ - unsigned nr : 4; - -} phFriNfc_Llcp_sPacketSequence_t; - -typedef struct phFriNfc_Llcp_sSendOperation -{ - /**< Sequence number for sending*/ - phFriNfc_Llcp_sPacketHeader_t *psHeader; - - /**< Sequence number for sending*/ - phFriNfc_Llcp_sPacketSequence_t *psSequence; - - /**< Sequence number for sending*/ - phNfc_sData_t *psInfo; - - /**< Sequence number for sending*/ - phFriNfc_Llcp_Send_CB_t pfSend_CB; - - /**< Sequence number for sending*/ - void *pContext; - -} phFriNfc_Llcp_sSendOperation_t; - -typedef struct phFriNfc_Llcp_sRecvOperation -{ - /**< Sequence number for sending*/ - uint8_t nSap; - - /**< Sequence number for sending*/ - phNfc_sData_t *psBuffer; - - /**< Sequence number for sending*/ - phFriNfc_Llcp_Recv_CB_t pfRecv_CB; - - /**< Sequence number for sending*/ - void *pContext; - -} phFriNfc_Llcp_sRecvOperation_t; - -typedef struct phFriNfc_Llcp -{ - /**< The current state*/ - uint8_t state; - - /**< MAC mapping instance*/ - phFriNfc_LlcpMac_t MAC; - - /**< Local LLC role*/ - phFriNfc_LlcpMac_ePeerType_t eRole; - - /**< Local link parameters*/ - phFriNfc_Llcp_sLinkParameters_t sLocalParams; - - /**< Remote link parameters*/ - phFriNfc_Llcp_sLinkParameters_t sRemoteParams; - - /**< Negociated protocol version (major number on MSB, minor on LSB)*/ - uint8_t version; - - /**< Internal reception buffer, its size may vary during time but not exceed nRxBufferSize*/ - phNfc_sData_t sRxBuffer; - - /**< Actual size of reception buffer*/ - uint16_t nRxBufferLength; - - /**< Internal emission buffer, its size may vary during time but not exceed nTxBufferSize*/ - phNfc_sData_t sTxBuffer; - - /**< Actual size of emission buffer*/ - uint16_t nTxBufferLength; - - /**< Callback function for link status notification*/ - phFriNfc_Llcp_LinkStatus_CB_t pfLink_CB; - - /**< Callback context for link status notification*/ - void *pLinkContext; - - /**< Callback function for compliance checking*/ - phFriNfc_Llcp_Check_CB_t pfChk_CB; - - /**< Callback context for compliance checking*/ - void *pChkContext; - - /**< Symmetry timer*/ - uint32_t hSymmTimer; - - /**< Control frames buffer*/ - uint8_t pCtrlTxBuffer[10]; - - /**< Control frames buffer size*/ - uint8_t pCtrlTxBufferLength; - - /**< DISC packet send pending flag*/ - bool_t bDiscPendingFlag; - - /**< FRMR packet send pending flag*/ - bool_t bFrmrPendingFlag; - - /**< Header of pending FRMR packet*/ - phFriNfc_Llcp_sPacketHeader_t sFrmrHeader; - - /**< Info field of pending FRMR packet*/ - uint8_t pFrmrInfo[4]; - - /**< Send callback*/ - phFriNfc_Llcp_Send_CB_t pfSendCB; - - /**< Send callback*/ - void *pSendContext; - - /**< Pending send header*/ - phFriNfc_Llcp_sPacketHeader_t *psSendHeader; - - /**< Pending send sequence*/ - phFriNfc_Llcp_sPacketSequence_t *psSendSequence; - - /**< Pending send info*/ - phNfc_sData_t *psSendInfo; - - /**< Receive callback*/ - phFriNfc_Llcp_Recv_CB_t pfRecvCB; - - /**< Receive callback*/ - void *pRecvContext; - -} phFriNfc_Llcp_t; - -/*========== UNIONS ===========*/ - - -/*========== FUNCTIONS ===========*/ - -/*! - * \brief TODO - */ -NFCSTATUS phFriNfc_Llcp_EncodeLinkParams( phNfc_sData_t *psRawBuffer, - phFriNfc_Llcp_sLinkParameters_t *psLinkParams, - uint8_t nVersion ); - - -/*! - * \brief TODO - */ -NFCSTATUS phFriNfc_Llcp_Reset( phFriNfc_Llcp_t *Llcp, - void *LowerDevice, - phFriNfc_Llcp_sLinkParameters_t *psLinkParams, - void *pRxBuffer, - uint16_t nRxBufferLength, - void *pTxBuffer, - uint16_t nTxBufferLength, - phFriNfc_Llcp_LinkStatus_CB_t pfLink_CB, - void *pContext ); - -/*! - * \brief TODO - */ -NFCSTATUS phFriNfc_Llcp_ChkLlcp( phFriNfc_Llcp_t *Llcp, - phHal_sRemoteDevInformation_t *psRemoteDevInfo, - phFriNfc_Llcp_Check_CB_t pfCheck_CB, - void *pContext ); - -/*! - * \brief TODO - */ -NFCSTATUS phFriNfc_Llcp_Activate( phFriNfc_Llcp_t *Llcp ); - -/*! - * \brief TODO - */ -NFCSTATUS phFriNfc_Llcp_Deactivate( phFriNfc_Llcp_t *Llcp ); - -/*! - * \brief TODO - */ -NFCSTATUS phFriNfc_Llcp_GetLocalInfo( phFriNfc_Llcp_t *Llcp, - phFriNfc_Llcp_sLinkParameters_t *pParams ); - -/*! - * \brief TODO - */ -NFCSTATUS phFriNfc_Llcp_GetRemoteInfo( phFriNfc_Llcp_t *Llcp, - phFriNfc_Llcp_sLinkParameters_t *pParams ); - -/*! - * \brief TODO - */ -NFCSTATUS phFriNfc_Llcp_Send( phFriNfc_Llcp_t *Llcp, - phFriNfc_Llcp_sPacketHeader_t *psHeader, - phFriNfc_Llcp_sPacketSequence_t *psSequence, - phNfc_sData_t *psInfo, - phFriNfc_Llcp_Send_CB_t pfSend_CB, - void *pContext ); - -/*! - * \brief TODO - */ -NFCSTATUS phFriNfc_Llcp_Recv( phFriNfc_Llcp_t *Llcp, - phFriNfc_Llcp_Recv_CB_t pfRecv_CB, - void *pContext ); - - -#endif /* PHFRINFC_LLCP_H */ diff --git a/libnfc-nxp/phFriNfc_LlcpMac.h b/libnfc-nxp/phFriNfc_LlcpMac.h deleted file mode 100644 index 8cd4373..0000000 --- a/libnfc-nxp/phFriNfc_LlcpMac.h +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -/** - * \file phFriNfc_LlcpMac.h - * \brief NFC LLCP MAC Mappings For Different RF Technologies. - * - * Project: NFC-FRI - * - */ - -#ifndef PHFRINFC_LLCPMAC_H -#define PHFRINFC_LLCPMAC_H - - -/*include files*/ -#include -#include -#include -#include - -#include - -/** - * \name LLCP MAC Mapping - * - * File: \ref phFriNfc_LlcpMac.h - * - */ - - -/** \defgroup grp_fri_nfc_llcp_mac LLCP MAC Mapping Component - * - * This component implements the different MAC mapping for a Logical Link Control Protocol communication, - * as defined by the NFC Forum LLCP specifications.\n - * The MAC component handles the mapping for the different technologies supported by LLCP - *..This component provides an API to the upper layer with the following features:\n\n - * - Reset the MAC mapping component - * - \ref phFriNfc_LlcpMac_ChkLlcp - * . - * - Check the LLCP Compliancy - * - \ref phFriNfc_LlcpMac_ChkLlcp - * . - * - Activate the LLCP link - * - \ref phFriNfc_LlcpMac_Activate - * . - * - Deactivate the LLCP link - * - \ref phFriNfc_LlcpMac_Deactivate - * . - * - Register the MAC component Interface with a specific technologie (NFCIP/ISO14443) - * - \ref phFriNfc_LlcpMac_Register - * . - * - Send packets through the LLCP link - * - \ref phFriNfc_LlcpMac_Send - * . - * - Receive packets through the LLCP link - * - \ref phFriNfc_LlcpMac_Receive - * - */ - -/** - * \ingroup grp_fri_nfc_llcp_mac - * \brief Declaration of a MAC type - */ -struct phFriNfc_LlcpMac; -typedef struct phFriNfc_LlcpMac phFriNfc_LlcpMac_t; - -/** - * \ingroup grp_fri_nfc_llcp_mac - * - */ -/*========== ENUMERATES ===========*/ - -/* Enum reperesents the different MAC mapping*/ -typedef enum phFriNfc_LlcpMac_eType -{ - phFriNfc_LlcpMac_eTypeNfcip, - phFriNfc_LlcpMac_eTypeIso14443 -}phFriNfc_LlcpMac_eType_t; - -/* Enum reperesents the different Peer type for a LLCP communication*/ -typedef enum phFriNfc_LlcpMac_ePeerType -{ - phFriNfc_LlcpMac_ePeerTypeInitiator, - phFriNfc_LlcpMac_ePeerTypeTarget -}phFriNfc_LlcpMac_ePeerType_t; - - - - - - -/*========== CALLBACKS ===========*/ - -typedef void (*phFriNfc_LlcpMac_Chk_CB_t) (void *pContext, - NFCSTATUS status); - -typedef void (*phFriNfc_LlcpMac_LinkStatus_CB_t) (void *pContext, - phFriNfc_LlcpMac_eLinkStatus_t eLinkStatus, - phNfc_sData_t *psData, - phFriNfc_LlcpMac_ePeerType_t PeerRemoteDevType); - -typedef void (*phFriNfc_LlcpMac_Send_CB_t) (void *pContext, - NFCSTATUS status); - - -typedef void (*phFriNfc_LlcpMac_Reveive_CB_t) (void *pContext, - NFCSTATUS status, - phNfc_sData_t *psData); - - -/*========== FUNCTIONS TYPES ===========*/ - -typedef NFCSTATUS (*pphFriNfcLlpcMac_Chk_t) ( phFriNfc_LlcpMac_t *LlcpMac, - phFriNfc_LlcpMac_Chk_CB_t ChkLlcpMac_Cb, - void *pContext); - -typedef NFCSTATUS (*pphFriNfcLlpcMac_Activate_t) (phFriNfc_LlcpMac_t *LlcpMac); - -typedef NFCSTATUS (*pphFriNfcLlpcMac_Deactivate_t) (phFriNfc_LlcpMac_t *LlcpMac); - -typedef NFCSTATUS (*pphFriNfcLlpcMac_Send_t) (phFriNfc_LlcpMac_t *LlcpMac, - phNfc_sData_t *psData, - phFriNfc_LlcpMac_Send_CB_t LlcpMacSend_Cb, - void *pContext); - -typedef NFCSTATUS (*pphFriNfcLlpcMac_Receive_t) (phFriNfc_LlcpMac_t *LlcpMac, - phNfc_sData_t *psData, - phFriNfc_LlcpMac_Reveive_CB_t LlcpMacReceive_Cb, - void *pContext); - -/*========== STRUCTURES ===========*/ - -/** - * \ingroup grp_fri_nfc_llcp_mac - * \brief Generic Interface structure with the Lower Layer - */ -typedef struct phFriNfc_LlcpMac_Interface -{ - pphFriNfcLlpcMac_Chk_t chk; - pphFriNfcLlpcMac_Activate_t activate; - pphFriNfcLlpcMac_Deactivate_t deactivate; - pphFriNfcLlpcMac_Send_t send; - pphFriNfcLlpcMac_Receive_t receive; -} phFriNfc_LlcpMac_Interface_t; - -/** - * \ingroup grp_fri_nfc_llcp_mac - * \brief Definition of the MAC type - */ -struct phFriNfc_LlcpMac -{ - phFriNfc_LlcpMac_eLinkStatus_t LinkState; - phHal_sRemoteDevInformation_t *psRemoteDevInfo; - phFriNfc_LlcpMac_LinkStatus_CB_t LinkStatus_Cb; - void *LinkStatus_Context; - phFriNfc_LlcpMac_Interface_t LlcpMacInterface; - phFriNfc_LlcpMac_ePeerType_t PeerRemoteDevType; - phFriNfc_LlcpMac_eType_t MacType; - - /**<\internal Holds the completion routine informations of the Map Layer*/ - phFriNfc_CplRt_t MacCompletionInfo; - void *LowerDevice; - phFriNfc_LlcpMac_Send_CB_t MacSend_Cb; - void *MacSend_Context; - phFriNfc_LlcpMac_Reveive_CB_t MacReceive_Cb; - void *MacReceive_Context; - phNfc_sData_t *psReceiveBuffer; - phNfc_sData_t *psSendBuffer; - phNfc_sData_t sConfigParam; - uint8_t RecvPending; - uint8_t SendPending; - uint8_t RecvStatus; - phHal_uCmdList_t Cmd; - phHal_sDepAdditionalInfo_t psDepAdditionalInfo; -} ; - - -/* -################################################################################ -********************** MAC Interface Function Prototype *********************** -################################################################################ -*/ - -/** - * \ingroup grp_fri_nfc_llcp_mac - * \brief - */ -NFCSTATUS phFriNfc_LlcpMac_Reset (phFriNfc_LlcpMac_t *LlcpMac, - void *LowerDevice, - phFriNfc_LlcpMac_LinkStatus_CB_t LinkStatus_Cb, - void *pContext); -/** - * \ingroup grp_fri_nfc_llcp_mac - * \brief - */ -NFCSTATUS phFriNfc_LlcpMac_ChkLlcp (phFriNfc_LlcpMac_t *LlcpMac, - phHal_sRemoteDevInformation_t *psRemoteDevInfo, - phFriNfc_LlcpMac_Chk_CB_t ChkLlcpMac_Cb, - void *pContext); - -/** - * \ingroup grp_fri_nfc_llcp_mac - * \brief - */ -NFCSTATUS phFriNfc_LlcpMac_Activate (phFriNfc_LlcpMac_t *LlcpMac); - -/** - * \ingroup grp_fri_nfc_llcp_mac - * \brief - */ -NFCSTATUS phFriNfc_LlcpMac_Deactivate (phFriNfc_LlcpMac_t *LlcpMac); - -/** - * \ingroup grp_fri_nfc_llcp_mac - * \brief - */ -NFCSTATUS phFriNfc_LlcpMac_Send (phFriNfc_LlcpMac_t *LlcpMac, - phNfc_sData_t *psData, - phFriNfc_LlcpMac_Send_CB_t LlcpMacSend_Cb, - void *pContext); - -/** - * \ingroup grp_fri_nfc_llcp_mac - * \brief - */ -NFCSTATUS phFriNfc_LlcpMac_Receive (phFriNfc_LlcpMac_t *LlcpMac, - phNfc_sData_t *psData, - phFriNfc_LlcpMac_Reveive_CB_t ReceiveLlcpMac_Cb, - void *pContext); - -#endif /* PHFRINFC_LLCPMAC_H */ diff --git a/libnfc-nxp/phFriNfc_LlcpTransport.h b/libnfc-nxp/phFriNfc_LlcpTransport.h deleted file mode 100644 index 2f83439..0000000 --- a/libnfc-nxp/phFriNfc_LlcpTransport.h +++ /dev/null @@ -1,794 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * \file phFriNfc_LlcpTransport.h - * \brief - * - * Project: NFC-FRI - * - */ - -#ifndef PHFRINFC_LLCP_TRANSPORT_H -#define PHFRINFC_LLCP_TRANSPORT_H -#include -#include -#include -#include -#include -#include -#ifdef ANDROID -#include -#include -#endif - - -typedef uint32_t phFriNfc_Socket_Handle; - -/** - * \ingroup grp_fri_nfc_llcp_mac - * \brief Declaration of a TRANSPORT type - */ -struct phFriNfc_LlcpTransport; -typedef struct phFriNfc_LlcpTransport phFriNfc_LlcpTransport_t; - -struct phFriNfc_LlcpTransport_Socket; -typedef struct phFriNfc_LlcpTransport_Socket phFriNfc_LlcpTransport_Socket_t; - -struct phFriNfc_Llcp_CachedServiceName; -typedef struct phFriNfc_Llcp_CachedServiceName phFriNfc_Llcp_CachedServiceName_t; - -/*========== ENUMERATES ===========*/ - -/* Enum reperesents the different LLCP Link status*/ -typedef enum phFriNfc_LlcpTransportSocket_eSocketState -{ - phFriNfc_LlcpTransportSocket_eSocketDefault, - phFriNfc_LlcpTransportSocket_eSocketCreated, - phFriNfc_LlcpTransportSocket_eSocketBound, - phFriNfc_LlcpTransportSocket_eSocketRegistered, - phFriNfc_LlcpTransportSocket_eSocketConnected, - phFriNfc_LlcpTransportSocket_eSocketConnecting, - phFriNfc_LlcpTransportSocket_eSocketAccepted, - phFriNfc_LlcpTransportSocket_eSocketDisconnected, - phFriNfc_LlcpTransportSocket_eSocketDisconnecting, - phFriNfc_LlcpTransportSocket_eSocketRejected, -}phFriNfc_LlcpTransportSocket_eSocketState_t; - - - -/*========== CALLBACKS ===========*/ - -/** -*\ingroup grp_fri_nfc -* -* \brief LLCP socket error notification callback definition -*/ -typedef void (*pphFriNfc_LlcpTransportSocketErrCb_t) ( void* pContext, - uint8_t nErrCode); - - -/** -*\ingroup grp_fri_nfc -* -* \brief LLCP socket listen callback definition -*/ -typedef void (*pphFriNfc_LlcpTransportSocketListenCb_t) (void* pContext, - phFriNfc_LlcpTransport_Socket_t *IncomingSocket); - -/** -*\ingroup grp_fri_nfc -* -* \brief LLCP socket connect callback definition -*/ -typedef void (*pphFriNfc_LlcpTransportSocketConnectCb_t) ( void* pContext, - uint8_t nErrCode, - NFCSTATUS status); - -/** -*\ingroup grp_fri_nfc -* -* \brief LLCP socket disconnect callback definition -*/ -typedef void (*pphFriNfc_LlcpTransportSocketDisconnectCb_t) (void* pContext, - NFCSTATUS status); - -/** -*\ingroup grp_fri_nfc -* -* \brief LLCP socket accept callback definition -*/ -typedef void (*pphFriNfc_LlcpTransportSocketAcceptCb_t) (void* pContext, - NFCSTATUS status); - -/** -*\ingroup grp_fri_nfc -* -* \brief LLCP socket reject callback definition -*/ -typedef void (*pphFriNfc_LlcpTransportSocketRejectCb_t) (void* pContext, - NFCSTATUS status); - -/** -*\ingroup grp_fri_nfc -* -* \brief LLCP socket reception callback definition -*/ -typedef void (*pphFriNfc_LlcpTransportSocketRecvCb_t) (void* pContext, - NFCSTATUS status); - -/** -*\ingroup grp_fri_nfc -* -* \brief LLCP socket reception with SSAP callback definition -*/ -typedef void (*pphFriNfc_LlcpTransportSocketRecvFromCb_t) (void* pContext, - uint8_t ssap, - NFCSTATUS status); - -/** -*\ingroup grp_fri_nfc -* -* \brief LLCP socket emission callback definition -*/ -typedef void (*pphFriNfc_LlcpTransportSocketSendCb_t) (void* pContext, - NFCSTATUS status); - - -/*========== STRUCTURES ===========*/ -/** - * \ingroup grp_fri_nfc_llcp_mac - * \brief Declaration of a SOCKET type - */ -struct phFriNfc_LlcpTransport_Socket -{ - phFriNfc_LlcpTransportSocket_eSocketState_t eSocket_State; - phFriNfc_LlcpTransport_eSocketType_t eSocket_Type; - phFriNfc_LlcpTransport_sSocketOptions_t sSocketOption; - pphFriNfc_LlcpTransportSocketErrCb_t pSocketErrCb; - - /* Remote and local socket info */ - uint8_t socket_sSap; - uint8_t socket_dSap; - // TODO: copy service name (could be deallocated by upper layer) - phNfc_sData_t sServiceName; - uint8_t remoteRW; - uint8_t localRW; - uint16_t remoteMIU; - uint16_t localMIUX; - uint8_t index; - - /* SDP related fields */ - uint8_t nTid; - - /* Information Flags */ - bool_t bSocketRecvPending; - bool_t bSocketSendPending; - bool_t bSocketListenPending; - bool_t bSocketDiscPending; - bool_t bSocketConnectPending; - bool_t bSocketAcceptPending; - bool_t bSocketRRPending; - bool_t bSocketRNRPending; - - /* Buffers */ - phNfc_sData_t sSocketSendBuffer; - phNfc_sData_t sSocketLinearBuffer; - phNfc_sData_t* sSocketRecvBuffer; - uint32_t *receivedLength; - uint32_t bufferLinearLength; - uint32_t bufferSendMaxLength; - uint32_t bufferRwMaxLength; - bool_t ReceiverBusyCondition; - bool_t RemoteBusyConditionInfo; - UTIL_FIFO_BUFFER sCyclicFifoBuffer; - uint32_t indexRwRead; - uint32_t indexRwWrite; - - /* Construction Frame */ - phFriNfc_Llcp_sPacketHeader_t sLlcpHeader; - phFriNfc_Llcp_sPacketSequence_t sSequence; - uint8_t socket_VS; - uint8_t socket_VSA; - uint8_t socket_VR; - uint8_t socket_VRA; - - /* Callbacks */ - pphFriNfc_LlcpTransportSocketAcceptCb_t pfSocketAccept_Cb; - pphFriNfc_LlcpTransportSocketSendCb_t pfSocketSend_Cb; - pphFriNfc_LlcpTransportSocketRecvFromCb_t pfSocketRecvFrom_Cb; - pphFriNfc_LlcpTransportSocketRecvCb_t pfSocketRecv_Cb; - pphFriNfc_LlcpTransportSocketListenCb_t pfSocketListen_Cb; - pphFriNfc_LlcpTransportSocketConnectCb_t pfSocketConnect_Cb; - pphFriNfc_LlcpTransportSocketDisconnectCb_t pfSocketDisconnect_Cb; - - /* Table of PHFRINFC_LLCP_RW_MAX Receive Windows Buffers */ - phNfc_sData_t sSocketRwBufferTable[PHFRINFC_LLCP_RW_MAX]; - - /* Pointer a the socket table */ - phFriNfc_LlcpTransport_t *psTransport; - /* Context */ - void *pListenContext; - void *pAcceptContext; - void *pRejectContext; - void *pConnectContext; - void *pDisconnectContext; - void *pSendContext; - void *pRecvContext; - void *pContext; -}; - -/** - * \ingroup grp_fri_nfc_llcp_mac - * \brief TODO - */ -struct phFriNfc_Llcp_CachedServiceName -{ - phNfc_sData_t sServiceName; - uint8_t nSap; -}; - - -/** - * \ingroup grp_fri_nfc_llcp_mac - * \brief Declaration of a TRANSPORT Type with a table of PHFRINFC_LLCP_NB_SOCKET_DEFAULT sockets - * and a pointer a Llcp layer - */ -struct phFriNfc_LlcpTransport -{ - phFriNfc_LlcpTransport_Socket_t pSocketTable[PHFRINFC_LLCP_NB_SOCKET_MAX]; - phFriNfc_Llcp_CachedServiceName_t pCachedServiceNames[PHFRINFC_LLCP_SDP_ADVERTISED_NB]; - phFriNfc_Llcp_t *pLlcp; - pthread_mutex_t mutex; - bool_t bSendPending; - bool_t bRecvPending; - bool_t bDmPending; - bool_t bFrmrPending; - - phFriNfc_Llcp_LinkSend_CB_t pfLinkSendCb; - void *pLinkSendContext; - - uint8_t socketIndex; - - /**< Info field of pending FRMR packet*/ - uint8_t FrmrInfoBuffer[4]; - phFriNfc_Llcp_sPacketHeader_t sLlcpHeader; - phFriNfc_Llcp_sPacketSequence_t sSequence; - - /**< Info field of pending DM packet*/ - phFriNfc_Llcp_sPacketHeader_t sDmHeader; - phNfc_sData_t sDmPayload; - uint8_t DmInfoBuffer[3]; - - uint8_t LinkStatusError; - - /**< Service discovery related infos */ - phNfc_sData_t *psDiscoveryServiceNameList; - uint8_t *pnDiscoverySapList; - uint8_t nDiscoveryListSize; - uint8_t nDiscoveryReqOffset; - uint8_t nDiscoveryResOffset; - - uint8_t nDiscoveryResTidList[PHFRINFC_LLCP_SNL_RESPONSE_MAX]; - uint8_t nDiscoveryResSapList[PHFRINFC_LLCP_SNL_RESPONSE_MAX]; - uint8_t nDiscoveryResListSize; - - uint8_t pDiscoveryBuffer[PHFRINFC_LLCP_MIU_DEFAULT]; - pphFriNfc_Cr_t pfDiscover_Cb; - void *pDiscoverContext; - -}; - -/* -################################################################################ -********************** TRANSPORT Interface Function Prototype ***************** -################################################################################ -*/ - -bool_t testAndSetSendPending(phFriNfc_LlcpTransport_t* transport); - -void clearSendPending(phFriNfc_LlcpTransport_t* transport); - - /** -* \ingroup grp_fri_nfc -* \brief Create a socket on a LLCP-connected device. -* -*/ -NFCSTATUS phFriNfc_LlcpTransport_Reset (phFriNfc_LlcpTransport_t *pLlcpSocketTable, - phFriNfc_Llcp_t *pLlcp); - - -/** -* \ingroup grp_fri_nfc -* \brief Close all existing sockets. -* -*/ -NFCSTATUS phFriNfc_LlcpTransport_CloseAll (phFriNfc_LlcpTransport_t *pLlcpSocketTable); - - -/** -* \ingroup grp_fri_nfc -* \brief Used by transport layers to request a send on link layer. -* -*/ -NFCSTATUS phFriNfc_LlcpTransport_LinkSend( phFriNfc_LlcpTransport_t *LlcpTransport, - phFriNfc_Llcp_sPacketHeader_t *psHeader, - phFriNfc_Llcp_sPacketSequence_t *psSequence, - phNfc_sData_t *psInfo, - phFriNfc_Llcp_LinkSend_CB_t pfSend_CB, - uint8_t socketIndex, - void *pContext ); - - -/** -* \ingroup grp_fri_nfc -* \brief Used by transport layers to send a DM frame. -* -* This function is only used when the DM is not related to a DISC on a socket. -*/ -NFCSTATUS phFriNfc_LlcpTransport_SendDisconnectMode(phFriNfc_LlcpTransport_t* psTransport, - uint8_t dsap, - uint8_t ssap, - uint8_t dmOpCode); - -/** -* \ingroup grp_fri_nfc -* \brief Used by transport layers to send a FRMR frame. -* -*/ -NFCSTATUS phFriNfc_LlcpTransport_SendFrameReject(phFriNfc_LlcpTransport_t *psTransport, - uint8_t dsap, - uint8_t rejectedPTYPE, - uint8_t ssap, - phFriNfc_Llcp_sPacketSequence_t* sLlcpSequence, - uint8_t WFlag, - uint8_t IFlag, - uint8_t RFlag, - uint8_t SFlag, - uint8_t vs, - uint8_t vsa, - uint8_t vr, - uint8_t vra); - -/*! -* \ingroup grp_fri_nfc -* \brief Discover remote services SAP using SDP protocol. - */ -NFCSTATUS phFriNfc_LlcpTransport_DiscoverServices( phFriNfc_LlcpTransport_t *pLlcpTransport, - phNfc_sData_t *psServiceNameList, - uint8_t *pnSapList, - uint8_t nListSize, - pphFriNfc_Cr_t pDiscover_Cb, - void *pContext ); - -/** -* \ingroup grp_lib_nfc -* \brief Get the local options of a socket. -* -* This function returns the local options (maximum packet size and receive window size) used -* for a given connection-oriented socket. This function shall not be used with connectionless -* sockets. -* -* \param[out] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. -* \param[in] psLocalOptions A pointer to be filled with the local options of the socket. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of -* a valid type to perform the requsted operation. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -NFCSTATUS phFriNfc_LlcpTransport_SocketGetLocalOptions(phFriNfc_LlcpTransport_Socket_t *pLlcpSocket, - phLibNfc_Llcp_sSocketOptions_t *psLocalOptions); - - -/** -* \ingroup grp_lib_nfc -* \brief Get the local options of a socket. -* -* This function returns the remote options (maximum packet size and receive window size) used -* for a given connection-oriented socket. This function shall not be used with connectionless -* sockets. -* -* \param[out] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. -* \param[in] psRemoteOptions A pointer to be filled with the remote options of the socket. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of -* a valid type to perform the requsted operation. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -NFCSTATUS phFriNfc_LlcpTransport_SocketGetRemoteOptions(phFriNfc_LlcpTransport_Socket_t* pLlcpSocket, - phLibNfc_Llcp_sSocketOptions_t* psRemoteOptions); - - - /** -* \ingroup grp_fri_nfc -* \brief Create a socket on a LLCP-connected device. -* -* This function creates a socket for a given LLCP link. Sockets can be of two types : -* connection-oriented and connectionless. If the socket is connection-oriented, the caller -* must provide a working buffer to the socket in order to handle incoming data. This buffer -* must be large enough to fit the receive window (RW * MIU), the remaining space being -* used as a linear buffer to store incoming data as a stream. Data will be readable later -* using the phLibNfc_LlcpTransport_Recv function. -* The options and working buffer are not required if the socket is used as a listening socket, -* since it cannot be directly used for communication. -* -* \param[in] pLlcpSocketTable A pointer to a table of PHFRINFC_LLCP_NB_SOCKET_DEFAULT sockets. -* \param[in] eType The socket type. -* \param[in] psOptions The options to be used with the socket. -* \param[in] psWorkingBuffer A working buffer to be used by the library. -* \param[out] pLlcpSocket A pointer to a socket pointer to be filled with a - socket found on the socket table. -* \param[in] pErr_Cb The callback to be called each time the socket -* is in error. -* \param[in] pContext Upper layer context to be returned in the callback. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_BUFFER_TOO_SMALL The working buffer is too small for the MIU and RW -* declared in the options. -* \retval NFCSTATUS_INSUFFICIENT_RESOURCES No more socket handle available. -* \retval NFCSTATUS_FAILED Operation failed. -* */ -NFCSTATUS phFriNfc_LlcpTransport_Socket(phFriNfc_LlcpTransport_t *pLlcpSocketTable, - phFriNfc_LlcpTransport_eSocketType_t eType, - phFriNfc_LlcpTransport_sSocketOptions_t* psOptions, - phNfc_sData_t* psWorkingBuffer, - phFriNfc_LlcpTransport_Socket_t **pLlcpSocket, - pphFriNfc_LlcpTransportSocketErrCb_t pErr_Cb, - void* pContext); - -/** -* \ingroup grp_fri_nfc -* \brief Close a socket on a LLCP-connected device. -* -* This function closes a LLCP socket previously created using phFriNfc_LlcpTransport_Socket. -* If the socket was connected, it is first disconnected, and then closed. -* -* \param[in] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. - -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -NFCSTATUS phFriNfc_LlcpTransport_Close(phFriNfc_LlcpTransport_Socket_t* pLlcpSocket); - - -/** -* \ingroup grp_fri_nfc -* \brief Bind a socket to a local SAP. -* -* This function binds the socket to a local Service Access Point. -* -* \param[out] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. -* \param[in] pConfigInfo A port number for a specific socket -* \param TODO -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of -* a valid type to perform the requsted operation. -* \retval NFCSTATUS_ALREADY_REGISTERED The selected SAP is already bound to another - socket. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -NFCSTATUS phFriNfc_LlcpTransport_Bind(phFriNfc_LlcpTransport_Socket_t *pLlcpSocket, - uint8_t nSap, - phNfc_sData_t *psServiceName); - -/** -* \ingroup grp_fri_nfc -* \brief Listen for incoming connection requests on a socket. -* -* This function switches a socket into a listening state and registers a callback on -* incoming connection requests. In this state, the socket is not able to communicate -* directly. The listening state is only available for connection-oriented sockets -* which are still not connected. The socket keeps listening until it is closed, and -* thus can trigger several times the pListen_Cb callback. -* -* -* \param[in] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. -* \param[in] pListen_Cb The callback to be called each time the -* socket receive a connection request. -* \param[in] pContext Upper layer context to be returned in -* the callback. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state to switch -* to listening state. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -NFCSTATUS phFriNfc_LlcpTransport_Listen(phFriNfc_LlcpTransport_Socket_t* pLlcpSocket, - pphFriNfc_LlcpTransportSocketListenCb_t pListen_Cb, - void* pContext); - -/** -* \ingroup grp_fri_nfc -* \brief Accept an incoming connection request for a socket. -* -* This functions allows the client to accept an incoming connection request. -* It must be used with the socket provided within the listen callback. The socket -* is implicitly switched to the connected state when the function is called. -* -* \param[in] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. -* \param[in] psOptions The options to be used with the socket. -* \param[in] psWorkingBuffer A working buffer to be used by the library. -* \param[in] pErr_Cb The callback to be called each time the accepted socket -* is in error. -* \param[in] pAccept_RspCb The callback to be called when the Accept operation is completed -* \param[in] pContext Upper layer context to be returned in the callback. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_BUFFER_TOO_SMALL The working buffer is too small for the MIU and RW -* declared in the options. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -NFCSTATUS phFriNfc_LlcpTransport_Accept(phFriNfc_LlcpTransport_Socket_t* pLlcpSocket, - phFriNfc_LlcpTransport_sSocketOptions_t* psOptions, - phNfc_sData_t* psWorkingBuffer, - pphFriNfc_LlcpTransportSocketErrCb_t pErr_Cb, - pphFriNfc_LlcpTransportSocketAcceptCb_t pAccept_RspCb, - void* pContext); - - /** -* \ingroup grp_fri_nfc -* \brief Reject an incoming connection request for a socket. -* -* This functions allows the client to reject an incoming connection request. -* It must be used with the socket provided within the listen callback. The socket -* is implicitly closed when the function is called. -* -* \param[in] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. -* \param[in] pReject_RspCb The callback to be called when the Reject operation is completed -* \param[in] pContext Upper layer context to be returned in the callback. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -NFCSTATUS phFriNfc_LlcpTransport_Reject( phFriNfc_LlcpTransport_Socket_t* pLlcpSocket, - pphFriNfc_LlcpTransportSocketRejectCb_t pReject_RspCb, - void *pContext); -/** -* \ingroup grp_fri_nfc -* \brief Try to establish connection with a socket on a remote SAP. -* -* This function tries to connect to a given SAP on the remote peer. If the -* socket is not bound to a local SAP, it is implicitly bound to a free SAP. -* -* \param[in] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. -* \param[in] nSap The destination SAP to connect to. -* \param[in] pConnect_RspCb The callback to be called when the connection -* operation is completed. -* \param[in] pContext Upper layer context to be returned in -* the callback. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_PENDING Connection operation is in progress, -* pConnect_RspCb will be called upon completion. -* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of -* a valid type to perform the requsted operation. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -NFCSTATUS phFriNfc_LlcpTransport_Connect( phFriNfc_LlcpTransport_Socket_t* pLlcpSocket, - uint8_t nSap, - pphFriNfc_LlcpTransportSocketConnectCb_t pConnect_RspCb, - void* pContext); - -/** -* \ingroup grp_fri_nfc -* \brief Try to establish connection with a socket on a remote service, given its URI. -* -* This function tries to connect to a SAP designated by an URI. If the -* socket is not bound to a local SAP, it is implicitly bound to a free SAP. -* -* \param[in] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. -* \param[in] psUri The URI corresponding to the destination SAP to connect to. -* \param[in] pConnect_RspCb The callback to be called when the connection -* operation is completed. -* \param[in] pContext Upper layer context to be returned in -* the callback. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_PENDING Connection operation is in progress, -* pConnect_RspCb will be called upon completion. -* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of -* a valid type to perform the requsted operation. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -NFCSTATUS phFriNfc_LlcpTransport_ConnectByUri(phFriNfc_LlcpTransport_Socket_t* pLlcpSocket, - phNfc_sData_t* psUri, - pphFriNfc_LlcpTransportSocketConnectCb_t pConnect_RspCb, - void* pContext); - -/** -* \ingroup grp_lib_nfc -* \brief Disconnect a currently connected socket. -* -* This function initiates the disconnection of a previously connected socket. -* -* \param[in] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. -* \param[in] pDisconnect_RspCb The callback to be called when the -* operation is completed. -* \param[in] pContext Upper layer context to be returned in -* the callback. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_PENDING Disconnection operation is in progress, -* pDisconnect_RspCb will be called upon completion. -* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of -* a valid type to perform the requsted operation. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -NFCSTATUS phFriNfc_LlcpTransport_Disconnect(phFriNfc_LlcpTransport_Socket_t* pLlcpSocket, - pphLibNfc_LlcpSocketDisconnectCb_t pDisconnect_RspCb, - void* pContext); - -/** -* \ingroup grp_fri_nfc -* \brief Send data on a socket. -* -* This function is used to write data on a socket. This function -* can only be called on a connection-oriented socket which is already -* in a connected state. -* -* -* \param[in] hSocket Socket handle obtained during socket creation. -* \param[in] psBuffer The buffer containing the data to send. -* \param[in] pSend_RspCb The callback to be called when the -* operation is completed. -* \param[in] pContext Upper layer context to be returned in -* the callback. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_PENDING Reception operation is in progress, -* pSend_RspCb will be called upon completion. -* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of -* a valid type to perform the requsted operation. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -NFCSTATUS phFriNfc_LlcpTransport_Send(phFriNfc_LlcpTransport_Socket_t* pLlcpSocket, - phNfc_sData_t* psBuffer, - pphFriNfc_LlcpTransportSocketSendCb_t pSend_RspCb, - void* pContext); - -/** -* \ingroup grp_fri_nfc -* \brief Read data on a socket. -* -* This function is used to read data from a socket. It reads at most the -* size of the reception buffer, but can also return less bytes if less bytes -* are available. If no data is available, the function will be pending until -* more data comes, and the response will be sent by the callback. This function -* can only be called on a connection-oriented socket. -* -* -* \param[in] hSocket Socket handle obtained during socket creation. -* \param[in] psBuffer The buffer receiving the data. -* \param[in] pRecv_RspCb The callback to be called when the -* operation is completed. -* \param[in] pContext Upper layer context to be returned in -* the callback. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_PENDING Reception operation is in progress, -* pRecv_RspCb will be called upon completion. -* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of -* a valid type to perform the requsted operation. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -NFCSTATUS phFriNfc_LlcpTransport_Recv( phFriNfc_LlcpTransport_Socket_t* pLlcpSocket, - phNfc_sData_t* psBuffer, - pphFriNfc_LlcpTransportSocketRecvCb_t pRecv_RspCb, - void* pContext); - - - - /** -* \ingroup grp_lib_nfc -* \brief Read data on a socket and get the source SAP. -* -* This function is the same as phLibNfc_Llcp_Recv, except that the callback includes -* the source SAP. This functions can only be called on a connectionless socket. -* -* -* \param[in] pLlcpSocket A pointer to a LlcpSocket created. -* \param[in] psBuffer The buffer receiving the data. -* \param[in] pRecv_RspCb The callback to be called when the -* operation is completed. -* \param[in] pContext Upper layer context to be returned in -* the callback. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_PENDING Reception operation is in progress, -* pRecv_RspCb will be called upon completion. -* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of -* a valid type to perform the requsted operation. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -NFCSTATUS phFriNfc_LlcpTransport_RecvFrom( phFriNfc_LlcpTransport_Socket_t *pLlcpSocket, - phNfc_sData_t* psBuffer, - pphFriNfc_LlcpTransportSocketRecvFromCb_t pRecv_Cb, - void *pContext); - -/** -* \ingroup grp_fri_nfc -* \brief Send data on a socket to a given destination SAP. -* -* This function is used to write data on a socket to a given destination SAP. -* This function can only be called on a connectionless socket. -* -* -* \param[in] pLlcpSocket A pointer to a LlcpSocket created. -* \param[in] nSap The destination SAP. -* \param[in] psBuffer The buffer containing the data to send. -* \param[in] pSend_RspCb The callback to be called when the -* operation is completed. -* \param[in] pContext Upper layer context to be returned in -* the callback. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_PENDING Reception operation is in progress, -* pSend_RspCb will be called upon completion. -* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of -* a valid type to perform the requsted operation. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -NFCSTATUS phFriNfc_LlcpTransport_SendTo( phFriNfc_LlcpTransport_Socket_t *pLlcpSocket, - uint8_t nSap, - phNfc_sData_t* psBuffer, - pphFriNfc_LlcpTransportSocketSendCb_t pSend_RspCb, - void* pContext); -#endif /* PHFRINFC_LLCP_TRANSPORT_H */ diff --git a/libnfc-nxp/phFriNfc_LlcpTransport_Connection.h b/libnfc-nxp/phFriNfc_LlcpTransport_Connection.h deleted file mode 100644 index 07ec1fb..0000000 --- a/libnfc-nxp/phFriNfc_LlcpTransport_Connection.h +++ /dev/null @@ -1,302 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * \file phFriNfc_LlcpTransport_Connection.h - * \brief - * - * Project: NFC-FRI - * - */ -#ifndef PHFRINFC_LLCP_TRANSPORT_CONNECTION_H -#define PHFRINFC_LLCP_TRANSPORT_CONNECTION_H -/*include files*/ -#include -#include -#include - -#include - -void Handle_ConnectionOriented_IncommingFrame(phFriNfc_LlcpTransport_t *pLlcpTransport, - phNfc_sData_t *psData, - uint8_t dsap, - uint8_t ptype, - uint8_t ssap); - -NFCSTATUS phFriNfc_LlcpTransport_ConnectionOriented_HandlePendingOperations(phFriNfc_LlcpTransport_Socket_t *pSocket); - -/** -* \ingroup grp_lib_nfc -* \brief Get the local options of a socket. -* -* This function returns the local options (maximum packet size and receive window size) used -* for a given connection-oriented socket. This function shall not be used with connectionless -* sockets. -* -* \param[out] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. -* \param[in] psLocalOptions A pointer to be filled with the local options of the socket. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of -* a valid type to perform the requsted operation. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -NFCSTATUS phFriNfc_LlcpTransport_ConnectionOriented_SocketGetLocalOptions(phFriNfc_LlcpTransport_Socket_t *pLlcpSocket, - phLibNfc_Llcp_sSocketOptions_t *psLocalOptions); - -/** -* \ingroup grp_lib_nfc -* \brief Get the local options of a socket. -* -* This function returns the remote options (maximum packet size and receive window size) used -* for a given connection-oriented socket. This function shall not be used with connectionless -* sockets. -* -* \param[out] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. -* \param[in] psRemoteOptions A pointer to be filled with the remote options of the socket. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of -* a valid type to perform the requsted operation. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -NFCSTATUS phFriNfc_LlcpTransport_ConnectionOriented_SocketGetRemoteOptions(phFriNfc_LlcpTransport_Socket_t* pLlcpSocket, - phLibNfc_Llcp_sSocketOptions_t* psRemoteOptions); - -/** -* \ingroup grp_fri_nfc -* \brief Close a socket on a LLCP-connected device. -* -* This function closes a LLCP socket previously created using phFriNfc_LlcpTransport_Socket. -* If the socket was connected, it is first disconnected, and then closed. -* -* \param[in] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. - -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -NFCSTATUS phFriNfc_LlcpTransport_ConnectionOriented_Close(phFriNfc_LlcpTransport_Socket_t* pLlcpSocket); - -/** -* \ingroup grp_fri_nfc -* \brief Listen for incoming connection requests on a socket. -* -* This function switches a socket into a listening state and registers a callback on -* incoming connection requests. In this state, the socket is not able to communicate -* directly. The listening state is only available for connection-oriented sockets -* which are still not connected. The socket keeps listening until it is closed, and -* thus can trigger several times the pListen_Cb callback. -* -* -* \param[in] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. -* \param[in] pListen_Cb The callback to be called each time the -* socket receive a connection request. -* \param[in] pContext Upper layer context to be returned in -* the callback. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state to switch -* to listening state. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -NFCSTATUS phFriNfc_LlcpTransport_ConnectionOriented_Listen(phFriNfc_LlcpTransport_Socket_t* pLlcpSocket, - pphFriNfc_LlcpTransportSocketListenCb_t pListen_Cb, - void* pContext); - - -/** -* \ingroup grp_fri_nfc -* \brief Accept an incoming connection request for a socket. -* -* This functions allows the client to accept an incoming connection request. -* It must be used with the socket provided within the listen callback. The socket -* is implicitly switched to the connected state when the function is called. -* -* \param[in] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. -* \param[in] psOptions The options to be used with the socket. -* \param[in] psWorkingBuffer A working buffer to be used by the library. -* \param[in] pErr_Cb The callback to be called each time the accepted socket -* is in error. -* \param[in] pAccept_RspCb The callback to be called when the Accept operation is completed -* \param[in] pContext Upper layer context to be returned in the callback. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_BUFFER_TOO_SMALL The working buffer is too small for the MIU and RW -* declared in the options. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -NFCSTATUS phFriNfc_LlcpTransport_ConnectionOriented_Accept(phFriNfc_LlcpTransport_Socket_t* pLlcpSocket, - phFriNfc_LlcpTransport_sSocketOptions_t* psOptions, - phNfc_sData_t* psWorkingBuffer, - pphFriNfc_LlcpTransportSocketErrCb_t pErr_Cb, - pphFriNfc_LlcpTransportSocketAcceptCb_t pAccept_RspCb, - void* pContext); - - - /** -* \ingroup grp_fri_nfc -* \brief Reject an incoming connection request for a socket. -* -* This functions allows the client to reject an incoming connection request. -* It must be used with the socket provided within the listen callback. The socket -* is implicitly closed when the function is called. -* -* \param[in] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. -* \param[in] pReject_RspCb The callback to be called when the Reject operation is completed -* \param[in] pContext Upper layer context to be returned in the callback. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -NFCSTATUS phLibNfc_LlcpTransport_ConnectionOriented_Reject( phFriNfc_LlcpTransport_Socket_t* pLlcpSocket, - pphFriNfc_LlcpTransportSocketRejectCb_t pReject_RspCb, - void *pContext); - -/** -* \ingroup grp_fri_nfc -* \brief Try to establish connection with a socket on a remote SAP. -* -* This function tries to connect to a given SAP on the remote peer. If the -* socket is not bound to a local SAP, it is implicitly bound to a free SAP. -* -* \param[in] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. -* \param[in] nSap The destination SAP to connect to. -* \param[in] psUri The URI corresponding to the destination SAP to connect to. -* \param[in] pConnect_RspCb The callback to be called when the connection -* operation is completed. -* \param[in] pContext Upper layer context to be returned in -* the callback. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_PENDING Connection operation is in progress, -* pConnect_RspCb will be called upon completion. -* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of -* a valid type to perform the requsted operation. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -NFCSTATUS phFriNfc_LlcpTransport_ConnectionOriented_Connect( phFriNfc_LlcpTransport_Socket_t* pLlcpSocket, - uint8_t nSap, - phNfc_sData_t* psUri, - pphFriNfc_LlcpTransportSocketConnectCb_t pConnect_RspCb, - void* pContext); - -/** -* \ingroup grp_lib_nfc -* \brief Disconnect a currently connected socket. -* -* This function initiates the disconnection of a previously connected socket. -* -* \param[in] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. -* \param[in] pDisconnect_RspCb The callback to be called when the -* operation is completed. -* \param[in] pContext Upper layer context to be returned in -* the callback. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_PENDING Disconnection operation is in progress, -* pDisconnect_RspCb will be called upon completion. -* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of -* a valid type to perform the requsted operation. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -NFCSTATUS phLibNfc_LlcpTransport_ConnectionOriented_Disconnect(phFriNfc_LlcpTransport_Socket_t* pLlcpSocket, - pphLibNfc_LlcpSocketDisconnectCb_t pDisconnect_RspCb, - void* pContext); - -/** -* \ingroup grp_fri_nfc -* \brief Send data on a socket. -* -* This function is used to write data on a socket. This function -* can only be called on a connection-oriented socket which is already -* in a connected state. -* -* -* \param[in] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. -* \param[in] psBuffer The buffer containing the data to send. -* \param[in] pSend_RspCb The callback to be called when the -* operation is completed. -* \param[in] pContext Upper layer context to be returned in -* the callback. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_PENDING Reception operation is in progress, -* pSend_RspCb will be called upon completion. -* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of -* a valid type to perform the requsted operation. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -NFCSTATUS phFriNfc_LlcpTransport_ConnectionOriented_Send(phFriNfc_LlcpTransport_Socket_t* pLlcpSocket, - phNfc_sData_t* psBuffer, - pphFriNfc_LlcpTransportSocketSendCb_t pSend_RspCb, - void* pContext); - - /** -* \ingroup grp_fri_nfc -* \brief Read data on a socket. -* -* This function is used to read data from a socket. It reads at most the -* size of the reception buffer, but can also return less bytes if less bytes -* are available. If no data is available, the function will be pending until -* more data comes, and the response will be sent by the callback. This function -* can only be called on a connection-oriented socket. -* -* -* \param[in] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. -* \param[in] psBuffer The buffer receiving the data. -* \param[in] pRecv_RspCb The callback to be called when the -* operation is completed. -* \param[in] pContext Upper layer context to be returned in -* the callback. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_PENDING Reception operation is in progress, -* pRecv_RspCb will be called upon completion. -* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of -* a valid type to perform the requsted operation. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -NFCSTATUS phFriNfc_LlcpTransport_ConnectionOriented_Recv( phFriNfc_LlcpTransport_Socket_t* pLlcpSocket, - phNfc_sData_t* psBuffer, - pphFriNfc_LlcpTransportSocketRecvCb_t pRecv_RspCb, - void* pContext); -#endif /* PHFRINFC_LLCP_TRANSPORT_CONNECTION_H */ diff --git a/libnfc-nxp/phFriNfc_LlcpTransport_Connectionless.h b/libnfc-nxp/phFriNfc_LlcpTransport_Connectionless.h deleted file mode 100644 index 2fa263e..0000000 --- a/libnfc-nxp/phFriNfc_LlcpTransport_Connectionless.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * \file phFriNfc_LlcpTransport_Connectionless.h - * \brief - * - * Project: NFC-FRI - * - */ -#ifndef PHFRINFC_LLCP_TRANSPORT_CONNECTIONLESS_H -#define PHFRINFC_LLCP_TRANSPORT_CONNECTIONLESS_H -/*include files*/ -#include -#include -#include - -#include - - -void Handle_Connectionless_IncommingFrame(phFriNfc_LlcpTransport_t *pLlcpTransport, - phNfc_sData_t *psData, - uint8_t dsap, - uint8_t ssap); - -NFCSTATUS phFriNfc_LlcpTransport_Connectionless_HandlePendingOperations(phFriNfc_LlcpTransport_Socket_t *pSocket); - -/** -* \ingroup grp_fri_nfc -* \brief Close a socket on a LLCP-connectionless device. -* -* This function closes a LLCP socket previously created using phFriNfc_LlcpTransport_Socket. -* -* \param[in] pLlcpSocket A pointer to a phFriNfc_LlcpTransport_Socket_t. - -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -NFCSTATUS phFriNfc_LlcpTransport_Connectionless_Close(phFriNfc_LlcpTransport_Socket_t* pLlcpSocket); - -/** -* \ingroup grp_fri_nfc -* \brief Send data on a socket to a given destination SAP. -* -* This function is used to write data on a socket to a given destination SAP. -* This function can only be called on a connectionless socket. -* -* -* \param[in] pLlcpSocket A pointer to a LlcpSocket created. -* \param[in] nSap The destination SAP. -* \param[in] psBuffer The buffer containing the data to send. -* \param[in] pSend_RspCb The callback to be called when the -* operation is completed. -* \param[in] pContext Upper layer context to be returned in -* the callback. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_PENDING Reception operation is in progress, -* pSend_RspCb will be called upon completion. -* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of -* a valid type to perform the requsted operation. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -NFCSTATUS phFriNfc_LlcpTransport_Connectionless_SendTo(phFriNfc_LlcpTransport_Socket_t *pLlcpSocket, - uint8_t nSap, - phNfc_sData_t* psBuffer, - pphFriNfc_LlcpTransportSocketSendCb_t pSend_RspCb, - void* pContext); - - /** -* \ingroup grp_lib_nfc -* \brief Read data on a socket and get the source SAP. -* -* This function is the same as phLibNfc_Llcp_Recv, except that the callback includes -* the source SAP. This functions can only be called on a connectionless socket. -* -* -* \param[in] pLlcpSocket A pointer to a LlcpSocket created. -* \param[in] psBuffer The buffer receiving the data. -* \param[in] pRecv_RspCb The callback to be called when the -* operation is completed. -* \param[in] pContext Upper layer context to be returned in -* the callback. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_PENDING Reception operation is in progress, -* pRecv_RspCb will be called upon completion. -* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of -* a valid type to perform the requsted operation. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -NFCSTATUS phLibNfc_LlcpTransport_Connectionless_RecvFrom(phFriNfc_LlcpTransport_Socket_t *pLlcpSocket, - phNfc_sData_t* psBuffer, - pphFriNfc_LlcpTransportSocketRecvFromCb_t pRecv_Cb, - void* pContext); - -#endif /* PHFRINFC_LLCP_TRANSPORT_CONNECTIONLESS_H */ diff --git a/libnfc-nxp/phFriNfc_LlcpUtils.h b/libnfc-nxp/phFriNfc_LlcpUtils.h deleted file mode 100644 index 9dcb95a..0000000 --- a/libnfc-nxp/phFriNfc_LlcpUtils.h +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * \file phFriNfc_LlcpUtils.h - * \brief NFC LLCP utils - * - * Project: NFC-FRI - * - */ - -#ifndef PHFRINFC_LLCPUTILS_H -#define PHFRINFC_LLCPUTILS_H - -/*include files*/ -#include -#include -#include -#include -#include - -/** - * \name NFC Forum Logical Link Control Protocol Utils - * - * File: \ref phFriNfc_LlcpUtils.h - * - */ - -/** - * UTIL_FIFO_BUFFER - A Cyclic FIFO buffer - * If pIn == pOut the buffer is empty. - */ -typedef struct UTIL_FIFO_BUFFER -{ - uint8_t *pBuffStart; /* Points to first valid location in buffer */ - uint8_t *pBuffEnd; /* Points to last valid location in buffer */ - volatile uint8_t *pIn; /* Points to 1 before where the next TU1 will enter buffer */ - volatile uint8_t *pOut; /* Points to 1 before where the next TU1 will leave buffer */ - volatile bool_t bFull; /* TRUE if buffer is full */ -}UTIL_FIFO_BUFFER, *P_UTIL_FIFO_BUFFER; - - -/** \defgroup grp_fri_nfc_llcp NFC Forum Logical Link Control Protocol Component - * - * TODO - * - */ - -NFCSTATUS phFriNfc_Llcp_DecodeTLV( phNfc_sData_t *psRawData, - uint32_t *pOffset, - uint8_t *pType, - phNfc_sData_t *psValueBuffer ); - -NFCSTATUS phFriNfc_Llcp_EncodeTLV( phNfc_sData_t *psValueBuffer, - uint32_t *pOffset, - uint8_t type, - uint8_t length, - uint8_t *pValue); - -NFCSTATUS phFriNfc_Llcp_AppendTLV( phNfc_sData_t *psValueBuffer, - uint32_t nTlvOffset, - uint32_t *pCurrentOffset, - uint8_t length, - uint8_t *pValue); - -void phFriNfc_Llcp_EncodeMIUX(uint16_t pMiux, - uint8_t* pMiuxEncoded); - -void phFriNfc_Llcp_EncodeRW(uint8_t *pRw); - -/** - * Initializes a Fifo Cyclic Buffer to point to some allocated memory. - */ -void phFriNfc_Llcp_CyclicFifoInit(P_UTIL_FIFO_BUFFER sUtilFifo, - const uint8_t *pBuffStart, - uint32_t buffLength); - -/** - * Clears the Fifo Cyclic Buffer - loosing any data that was in it. - */ -void phFriNfc_Llcp_CyclicFifoClear(P_UTIL_FIFO_BUFFER sUtilFifo); - - -/** - * Attempts to write dataLength bytes to the specified Fifo Cyclic Buffer. - */ -uint32_t phFriNfc_Llcp_CyclicFifoWrite(P_UTIL_FIFO_BUFFER sUtilFifo, - uint8_t *pData, - uint32_t dataLength); - -/** - * Attempts to read dataLength bytes from the specified Fifo Cyclic Buffer. - */ -uint32_t phFriNfc_Llcp_CyclicFifoFifoRead(P_UTIL_FIFO_BUFFER sUtilFifo, - uint8_t *pBuffer, - uint32_t dataLength); - -/** - * Returns the number of bytes currently stored in Fifo Cyclic Buffer. - */ -uint32_t phFriNfc_Llcp_CyclicFifoUsage(P_UTIL_FIFO_BUFFER sUtilFifo); - -/** - * Returns the available room for writing in Fifo Cyclic Buffer. - */ -uint32_t phFriNfc_Llcp_CyclicFifoAvailable(P_UTIL_FIFO_BUFFER sUtilFifo); - -uint32_t phFriNfc_Llcp_Header2Buffer( phFriNfc_Llcp_sPacketHeader_t *psHeader, - uint8_t *pBuffer, - uint32_t nOffset ); - -uint32_t phFriNfc_Llcp_Sequence2Buffer( phFriNfc_Llcp_sPacketSequence_t *psSequence, - uint8_t *pBuffer, - uint32_t nOffset ); - -uint32_t phFriNfc_Llcp_Buffer2Header( uint8_t *pBuffer, - uint32_t nOffset, - phFriNfc_Llcp_sPacketHeader_t *psHeader ); - -uint32_t phFriNfc_Llcp_Buffer2Sequence( uint8_t *pBuffer, - uint32_t nOffset, - phFriNfc_Llcp_sPacketSequence_t *psSequence ); - - -#endif /* PHFRINFC_LLCPUTILS_H */ diff --git a/libnfc-nxp/phFriNfc_MapTools.h b/libnfc-nxp/phFriNfc_MapTools.h deleted file mode 100644 index e9eda20..0000000 --- a/libnfc-nxp/phFriNfc_MapTools.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * \file phFriNfc_MapTools.h - * \brief NFC Internal Ndef Mapping File. - * - * Project: NFC-FRI - * - * $Date: Fri Oct 15 13:50:54 2010 $ - * $Author: ing02260 $ - * $Revision: 1.6 $ - * $Aliases: $ - * - */ - -#ifndef PHFRINFC_MAPTOOLS_H -#define PHFRINFC_MAPTOOLS_H - -#include -#ifdef PH_HAL4_ENABLE -#include -#else -#include -#endif -#include -#include -#include - -/*! - * \name phFriNfc_MapTools.h - * This file has functions which are used common across all the - typ1/type2/type3/type4 tags. - * - */ -/*@{*/ - -#define PH_FRINFC_NDEFMAP_TLVLEN_ZERO 0 - -/* NFC Device Major and Minor Version numbers*/ -/* !!CAUTION!! these needs to be updated periodically.Major and Minor version numbers - should be compatible to the version number of currently implemented mapping document. - Example : NFC Device version Number : 1.0 , specifies - Major VNo is 1, - Minor VNo is 0 */ -#define PH_NFCFRI_NDEFMAP_NFCDEV_MAJOR_VER_NUM 0x01 -#ifdef DESFIRE_EV1 -#define PH_NFCFRI_NDEFMAP_NFCDEV_MAJOR_VER_NUM_2 0x02 -#endif /* */ -#define PH_NFCFRI_NDEFMAP_NFCDEV_MINOR_VER_NUM 0x00 - -/* Macros to find major and minor TAG : Ex:Type1/Type2/Type3/Type4 version numbers*/ -#define PH_NFCFRI_NDEFMAP_GET_MAJOR_TAG_VERNO(a) (((a) & (0xf0))>>(4)) -#define PH_NFCFRI_NDEFMAP_GET_MINOR_TAG_VERNO(a) ((a) & (0x0f)) - -/* NFC Device Major and Minor Version numbers*/ -/* !!CAUTION!! these needs to be updated periodically.Major and Minor version numbers - should be compatible to the version number of currently implemented mapping document. - Example : NFC Device version Number : 1.0 , specifies - Major VNo is 1, - Minor VNo is 0 */ -#define PH_NFCFRI_MFSTDMAP_NFCDEV_MAJOR_VER_NUM 0x40 -#define PH_NFCFRI_MFSTDMAP_NFCDEV_MINOR_VER_NUM 0x00 - -/* Macros to find major and minor TAG : Ex:Type1/Type2/Type3/Type4 version numbers*/ -#define PH_NFCFRI_MFSTDMAP_GET_MAJOR_TAG_VERNO(a) ((a) & (0x40)) // must be 0xC0 -#define PH_NFCFRI_MFSTDMAP_GET_MINOR_TAG_VERNO(a) ((a) & (0x30)) - -/*! - * \name NDEF Mapping - states of the Finite State machine - * - */ -/*@{*/ - - -NFCSTATUS phFriNfc_MapTool_ChkSpcVer( const phFriNfc_NdefMap_t *NdefMap, - uint8_t VersionIndex); - -NFCSTATUS phFriNfc_MapTool_SetCardState(phFriNfc_NdefMap_t *NdefMap, - uint32_t Length); - -#endif //PHFRINFC_MAPTOOLS_H diff --git a/libnfc-nxp/phFriNfc_MifStdFormat.h b/libnfc-nxp/phFriNfc_MifStdFormat.h deleted file mode 100644 index 648ec38..0000000 --- a/libnfc-nxp/phFriNfc_MifStdFormat.h +++ /dev/null @@ -1,461 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * \file phFriNfc_MifStdFormat.h - * \brief NFC Ndef Formatting For Mifare standard card. - * - * Project: NFC-FRI - * - * $Date: Fri Sep 25 15:24:17 2009 $ - * $Author: ing07299 $ - * $Revision: 1.4 $ - * $Aliases: NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ - * - */ - -#ifndef PHFRINFC_MIFSTDFORMAT_H -#define PHFRINFC_MIFSTDFORMAT_H - -#include -#ifdef PH_HAL4_ENABLE - #include -#else - #include -#endif /* #ifdef PH_HAL4_ENABLE */ -#include -#include -#include - -#define PH_FRINFC_MIFSTD_FORMAT_FILEREVISION "$Revision: 1.4 $" -#define PH_FRINFC_MIFSTD_FORMAT_FILEALIASES "$Aliases: NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" - - -/*! - * \name Mifare standard - constants for the state - * - */ -/*@{*/ -#define PH_FRINFC_MFSTD_FMT_RESET_INIT 0 /*!< Reset state */ -#define PH_FRINFC_MFSTD_FMT_AUTH_SECT 1 /*!< Sector authentication is in progress */ -#define PH_FRINFC_MFSTD_FMT_DIS_CON 2 /*!< Disconnect is in progress */ -#define PH_FRINFC_MFSTD_FMT_CON 3 /*!< Connect is in progress */ -#define PH_FRINFC_MFSTD_FMT_POLL 4 /*!< Poll is in progress */ -#define PH_FRINFC_MFSTD_FMT_RD_SECT_TR 5 /*!< Read sector trailer is in progress */ -#define PH_FRINFC_MFSTD_FMT_WR_SECT_TR 6 /*!< Write sector trailer is in progress */ -#define PH_FRINFC_MFSTD_FMT_WR_TLV 7 /*!< Write sector trailer is in progress */ -#define PH_FRINFC_MFSTD_FMT_WR_MAD_BLK 8 /*!< Write MAD is in progress */ -#define PH_FRINFC_MFSTD_FMT_UPD_MAD_BLK 9 /*!< Write MAD is in progress */ -/*@}*/ - -/*! -* \name Mifare standard - Authenticate states -* -*/ -/*@{*/ -#define PH_FRINFC_MFSTD_FMT_AUTH_DEF_KEY 0 /*!< Trying to authenticate with the default key */ -#define PH_FRINFC_MFSTD_FMT_AUTH_NFC_KEY 1 /*!< Trying to authenticate with the MAD key */ -#define PH_FRINFC_MFSTD_FMT_AUTH_MAD_KEY 2 /*!< Trying to authenticate with the NFC forum key */ -#define PH_FRINFC_MFSTD_FMT_AUTH_KEYB 3 /*!< Trying to authenticate with key B */ -#define PH_FRINFC_MFSTD_FMT_AUTH_SCRT_KEYB 4 /*!< Trying to authenticate with secret key B */ - -/*@}*/ - -/*! -* \name Mifare standard - Update MAD block flag -* -*/ -/*@{*/ -#define PH_FRINFC_MFSTD_FMT_NOT_A_MAD_BLK 0 /*!< Not a MAD block */ -#define PH_FRINFC_MFSTD_FMT_MAD_BLK_1 1 /*!< MAD block number 1 */ -#define PH_FRINFC_MFSTD_FMT_MAD_BLK_2 2 /*!< MAD block number 2 */ -#define PH_FRINFC_MFSTD_FMT_MAD_BLK_64 64 /*!< MAD block number 64 (only used for Mifare 4k card) */ -#define PH_FRINFC_MFSTD_FMT_MAD_BLK_65 65 /*!< MAD block number 65 (only used for Mifare 4k card) */ -#define PH_FRINFC_MFSTD_FMT_MAD_BLK_66 66 /*!< MAD block number 66 (only used for Mifare 4k card) */ - -/*@}*/ - -/*! -* \name Mifare standard - Update MAD block flag -* -*/ -/*@{*/ -#define PH_FRINFC_SMTCRDFMT_MSTD_MADSECT_KEYA_ACS_BIT_1K {0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0x78,0x77,0x88,0xC1} -#define PH_FRINFC_SMTCRDFMT_MSTD_MADSECT_KEYA_ACS_BIT_4K {0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0x78,0x77,0x88,0xC2} -#define PH_FRINFC_SMTCRDFMT_NFCFORUMSECT_KEYA_ACS_BIT {0xD3,0xF7,0xD3,0xF7,0xD3,0xF7,0x7F,0x07,0x88,0x40} - -/*@}*/ -/*! - * \name Mifare standard - Key and access bit constants - * - */ -/*@{*/ -#define PH_FRINFC_MFSTD_FMT_NFC_SECT_KEYA0 0xD3 /*!< NFC forum sector key A */ -#define PH_FRINFC_MFSTD_FMT_NFC_SECT_KEYA1 0xF7 /*!< NFC forum sector key A */ - -#define PH_FRINFC_MFSTD_FMT_MAD_SECT_KEYA0 0xA0 /*!< MAD sector key A */ -#define PH_FRINFC_MFSTD_FMT_MAD_SECT_KEYA1 0xA1 /*!< MAD sector key A */ -#define PH_FRINFC_MFSTD_FMT_MAD_SECT_KEYA2 0xA2 /*!< MAD sector key A */ -#define PH_FRINFC_MFSTD_FMT_MAD_SECT_KEYA3 0xA3 /*!< MAD sector key A */ -#define PH_FRINFC_MFSTD_FMT_MAD_SECT_KEYA4 0xA4 /*!< MAD sector key A */ -#define PH_FRINFC_MFSTD_FMT_MAD_SECT_KEYA5 0xA5 /*!< MAD sector key A */ - -#define PH_FRINFC_MFSTD_FMT_DEFAULT_KEY 0xFF /*!< Default key A or B */ - -#define PH_FRINFC_MFSTD_FMT_MAD_SECT_ACS6 0x78 /*!< MAD sector access bits 6 */ -#define PH_FRINFC_MFSTD_FMT_MAD_SECT_ACS7 0x77 /*!< MAD sector access bits 7 */ -#define PH_FRINFC_MFSTD_FMT_MAD_SECT_ACS8 0x88 /*!< MAD sector access bits 8 */ -#define PH_FRINFC_MFSTD_FMT_MAD_SECT_GPB 0xC1 /*!< MAD sector GPB */ - -#define PH_FRINFC_MFSTD_FMT_NFC_SECT_ACS_RW6 0x7F /*!< NFC forum sector access bits 6 for read write */ -#define PH_FRINFC_MFSTD_FMT_NFC_SECT_ACS_RW7 0x07 /*!< NFC forum sector access bits 7 for read write */ -#define PH_FRINFC_MFSTD_FMT_NFC_SECT_ACS_RW8 0x88 /*!< NFC forum sector access bits 8 for read write */ -#define PH_FRINFC_MFSTD_FMT_NFC_SECT_GPB_RW 0x40 /*!< NFC forum sector GPB for read write */ - -#define PH_FRINFC_MFSTD_FMT_NFC_SECT_ACS_RO6 0x07 /*!< NFC forum sector access bits 6 for read only */ -#define PH_FRINFC_MFSTD_FMT_NFC_SECT_ACS_RO7 0x8F /*!< NFC forum sector access bits 7 for read only */ -#define PH_FRINFC_MFSTD_FMT_NFC_SECT_ACS_RO8 0x0F /*!< NFC forum sector access bits 8 for read only */ -#define PH_FRINFC_MFSTD_FMT_NFC_SECT_GPB_R0 0x43 /*!< NFC forum sector GPB for read only */ - -/*@}*/ - -/*! - * \name Mifare standard - enums the values - * - */ -/*@{*/ -typedef enum{ -PH_FRINFC_MFSTD_FMT_VAL_0, -PH_FRINFC_MFSTD_FMT_VAL_1, -PH_FRINFC_MFSTD_FMT_VAL_2, -PH_FRINFC_MFSTD_FMT_VAL_3, -PH_FRINFC_MFSTD_FMT_VAL_4, -PH_FRINFC_MFSTD_FMT_VAL_5, -PH_FRINFC_MFSTD_FMT_VAL_6, -PH_FRINFC_MFSTD_FMT_VAL_7, -PH_FRINFC_MFSTD_FMT_VAL_8, -PH_FRINFC_MFSTD_FMT_VAL_9, -PH_FRINFC_MFSTD_FMT_VAL_10, -PH_FRINFC_MFSTD_FMT_VAL_11 -}phFriNfc_MfStdVal; -/*@}*/ - -/*! - * \name Mifare standard - NDEF information constants - * - */ -/*@{*/ -#define PH_FRINFC_MFSTD_FMT_NON_NDEF_COMPL 0 /*!< Sector is not ndef compliant */ -#define PH_FRINFC_MFSTD_FMT_NDEF_COMPL 1 /*!< Sector is ndef compliant */ -#define PH_FRINFC_MFSTD_FMT_NDEF_INFO1 0x03 /*!< If sector is ndef compliant, then one of the MAD - sector byte is 0x03 */ -#define PH_FRINFC_MFSTD_FMT_NDEF_INFO2 0xE1 /*!< If sector is ndef compliant, then one of the MAD - sector byte is 0xE1 */ -/*@}*/ - -/*! - * \name Mifare standard - constants - * - */ -/*@{*/ -#define PH_FRINFC_MFSTD_FMT_MAX_RECV_LENGTH 252 /*!< Maximum receive length */ -#define PH_FRINFC_MFSTD_FMT_WR_SEND_LENGTH 17 /*!< Send length for write */ -#define PH_FRINFC_MFSTD_FMT_MAX_SECT_IND_1K 16 /*!< Maximum sector index for Mifare 1k = 16 */ -#define PH_FRINFC_MFSTD_FMT_MAX_SECT_IND_4K 40 /*!< Maximum sector index for Mifare 4k = 40 */ -#define PH_FRINFC_MFSTD_FMT_MAX_BLOCKS_1K 64 /*!< Maximum sector index for Mifare 1k = 16 */ -#define PH_FRINFC_MFSTD_FMT_MAX_BLOCKS_4K 256 /*!< Maximum sector index for Mifare 4k = 40 */ -/*@}*/ - -/*! - * \name Mifare standard - constants for filling send buffer, calculating the block number, - * checking the authenticate state - * - */ -/*@{*/ -/* Copy default keyA to send buffer */ -#ifdef PH_HAL4_ENABLE - -#define PH_FRINFC_MFSTD_FMT_AUTH_SEND_BUF_DEF(mem)\ -do \ -{\ - (void)memset(&NdefSmtCrdFmt->SendRecvBuf[PH_FRINFC_MFSTD_FMT_VAL_1],\ - PH_FRINFC_MFSTD_FMT_DEFAULT_KEY,\ - PH_FRINFC_MFSTD_FMT_VAL_6);\ - NdefSmtCrdFmt->Cmd.MfCmd = ((NdefSmtCrdFmt->AddInfo.MfStdInfo.AuthState == \ - PH_FRINFC_MFSTD_FMT_AUTH_DEF_KEY)? \ - phHal_eMifareAuthentA: \ - phHal_eMifareAuthentB); \ - NdefSmtCrdFmt->SendLength = PH_FRINFC_MFSTD_FMT_VAL_7; \ -}while(0) - -/* Copy NFC forum sector keyA to send buffer */ -#define PH_FRINFC_MFSTD_FMT_AUTH_SEND_BUF_NFCSECT_KEYA(mem)\ -do \ -{\ - (void)memcpy(&NdefSmtCrdFmt->SendRecvBuf[PH_FRINFC_MFSTD_FMT_VAL_1],\ - NdefSmtCrdFmt->AddInfo.MfStdInfo.NFCForumSect_KeyA,\ - PH_FRINFC_MFSTD_FMT_VAL_6);\ - NdefSmtCrdFmt->Cmd.MfCmd = phHal_eMifareAuthentA;\ - NdefSmtCrdFmt->SendLength = PH_FRINFC_MFSTD_FMT_VAL_7;\ -} while(0) - -/* Copy MAD sector keyA to send buffer */ -#define PH_FRINFC_MFSTD_FMT_AUTH_SEND_BUF_MADSECT_KEYA(mem)\ -do \ -{\ - (void)memcpy(&NdefSmtCrdFmt->SendRecvBuf[PH_FRINFC_MFSTD_FMT_VAL_1],\ - NdefSmtCrdFmt->AddInfo.MfStdInfo.MADSect_KeyA,\ - PH_FRINFC_MFSTD_FMT_VAL_6);\ - NdefSmtCrdFmt->Cmd.MfCmd = phHal_eMifareAuthentA;\ - NdefSmtCrdFmt->SendLength = PH_FRINFC_MFSTD_FMT_VAL_7;\ -} while(0) - -#define PH_FRINFC_MFSTD_FMT_AUTH_SEND_BUF_SCRT_KEY(mem) \ -do \ -{\ - (void)memcpy(&NdefSmtCrdFmt->SendRecvBuf[PH_FRINFC_MFSTD_FMT_VAL_1],\ - NdefSmtCrdFmt->AddInfo.MfStdInfo.ScrtKeyB,\ - PH_FRINFC_MFSTD_FMT_VAL_6);\ - NdefSmtCrdFmt->Cmd.MfCmd = phHal_eMifareAuthentB;\ - NdefSmtCrdFmt->SendLength = PH_FRINFC_MFSTD_FMT_VAL_7;\ -} while(0) - -#else - -#define PH_FRINFC_MFSTD_FMT_AUTH_SEND_BUF_DEF(mem)\ -do \ -{\ - (void)memset(&NdefSmtCrdFmt->SendRecvBuf[PH_FRINFC_MFSTD_FMT_VAL_1],\ - PH_FRINFC_MFSTD_FMT_DEFAULT_KEY,\ - PH_FRINFC_MFSTD_FMT_VAL_6);\ - NdefSmtCrdFmt->Cmd.MfCmd = ((NdefSmtCrdFmt->AddInfo.MfStdInfo.AuthState == \ - PH_FRINFC_MFSTD_FMT_AUTH_DEF_KEY)? \ - phHal_eMifareCmdListMifareAuthentA: \ - phHal_eMifareCmdListMifareAuthentB); \ - NdefSmtCrdFmt->SendLength = PH_FRINFC_MFSTD_FMT_VAL_7; \ -}while(0) - -/* Copy NFC forum sector keyA to send buffer */ -#define PH_FRINFC_MFSTD_FMT_AUTH_SEND_BUF_NFCSECT_KEYA(mem)\ -do \ -{\ - (void)memcpy(&NdefSmtCrdFmt->SendRecvBuf[PH_FRINFC_MFSTD_FMT_VAL_1],\ - NdefSmtCrdFmt->AddInfo.MfStdInfo.NFCForumSect_KeyA,\ - PH_FRINFC_MFSTD_FMT_VAL_6);\ - NdefSmtCrdFmt->Cmd.MfCmd = phHal_eMifareCmdListMifareAuthentA;\ - NdefSmtCrdFmt->SendLength = PH_FRINFC_MFSTD_FMT_VAL_7;\ -} while(0) - -/* Copy MAD sector keyA to send buffer */ -#define PH_FRINFC_MFSTD_FMT_AUTH_SEND_BUF_MADSECT_KEYA(mem)\ -do \ -{\ - (void)memcpy(&NdefSmtCrdFmt->SendRecvBuf[PH_FRINFC_MFSTD_FMT_VAL_1],\ - NdefSmtCrdFmt->AddInfo.MfStdInfo.MADSect_KeyA,\ - PH_FRINFC_MFSTD_FMT_VAL_6);\ - NdefSmtCrdFmt->Cmd.MfCmd = phHal_eMifareCmdListMifareAuthentA;\ - NdefSmtCrdFmt->SendLength = PH_FRINFC_MFSTD_FMT_VAL_7;\ -} while(0) - -#define PH_FRINFC_MFSTD_FMT_AUTH_SEND_BUF_SCRT_KEY(mem) \ -do \ -{\ - (void)memcpy(&NdefSmtCrdFmt->SendRecvBuf[PH_FRINFC_MFSTD_FMT_VAL_1],\ - NdefSmtCrdFmt->AddInfo.MfStdInfo.ScrtKeyB,\ - PH_FRINFC_MFSTD_FMT_VAL_6);\ - NdefSmtCrdFmt->Cmd.MfCmd = phHal_eMifareCmdListMifareAuthentB;\ - NdefSmtCrdFmt->SendLength = PH_FRINFC_MFSTD_FMT_VAL_7;\ -} while(0) - -#endif /* #ifdef PH_HAL4_ENABLE */ - - -/* Get the next block */ -#define PH_FRINFC_MFSTD_FMT_CUR_BLK_INC() \ - NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock += \ - ((NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock >= 127)?\ - 16:4) - -/* Get the sector index */ -#define PH_FRINFC_MFSTD_FMT_SECT_INDEX_CALC \ - ((NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock >= 128)?\ - (32 + ((NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock - 128)/16)):\ - (NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock/4)) - -#define PH_FRINFC_MFSTD_FMT_CUR_BLK_CHK\ - ((NdefSmtCrdFmt->CardType == PH_FRINFC_SMTCRDFMT_MFSTD_1K_CRD) && \ - (NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock >= \ - PH_FRINFC_MFSTD_FMT_MAX_BLOCKS_1K)) || \ - ((NdefSmtCrdFmt->CardType == PH_FRINFC_SMTCRDFMT_MFSTD_4K_CRD) && \ - (NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock >= \ - PH_FRINFC_MFSTD_FMT_MAX_BLOCKS_4K)) - -/* Get the next authenticate state */ -#define PH_FRINFC_MFSTD_FMT_NXT_AUTH_STATE() \ -do \ -{\ - switch(NdefSmtCrdFmt->AddInfo.MfStdInfo.AuthState)\ - {\ - case PH_FRINFC_MFSTD_FMT_AUTH_DEF_KEY:\ - {\ - NdefSmtCrdFmt->AddInfo.MfStdInfo.AuthState = (uint8_t) \ - ((((NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock <= 3) || \ - ((NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock > 63) && \ - (NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock < 67))))? \ - PH_FRINFC_MFSTD_FMT_AUTH_MAD_KEY: \ - PH_FRINFC_MFSTD_FMT_AUTH_NFC_KEY);\ - }\ - break;\ - case PH_FRINFC_MFSTD_FMT_AUTH_NFC_KEY:\ - {\ - NdefSmtCrdFmt->AddInfo.MfStdInfo.AuthState = \ - PH_FRINFC_MFSTD_FMT_AUTH_KEYB;\ - }\ - break;\ - case PH_FRINFC_MFSTD_FMT_AUTH_MAD_KEY:\ - {\ - NdefSmtCrdFmt->AddInfo.MfStdInfo.AuthState = \ - PH_FRINFC_MFSTD_FMT_AUTH_NFC_KEY;\ - }\ - break;\ - case PH_FRINFC_MFSTD_FMT_AUTH_KEYB:\ - { \ - NdefSmtCrdFmt->AddInfo.MfStdInfo.AuthState = \ - PH_FRINFC_MFSTD_FMT_AUTH_SCRT_KEYB;\ - } \ - break;\ - case PH_FRINFC_MFSTD_FMT_AUTH_SCRT_KEYB:\ - default:\ - { \ - NdefSmtCrdFmt->AddInfo.MfStdInfo.AuthState = \ - PH_FRINFC_MFSTD_FMT_AUTH_DEF_KEY;\ - }\ - break;\ - }\ -} while(0) - - -/* Increment the sector index */ -#define PH_FRINFC_MFSTD_FMT_INCR_SECT \ -do \ -{\ - SectIndex++;\ - SectIndex = (uint8_t)((SectIndex == 16)?\ - (SectIndex + PH_FRINFC_MFSTD_FMT_VAL_1):\ - SectIndex);\ -} while(0) - - -/* Increment the sector index */ -#define PH_FRINFC_MFSTD_FMT_CHK_SECT_ARRAY \ -do \ -{\ - while ((index < PH_FRINFC_MFSTD_FMT_MAX_SECT_IND_4K) && \ - (memcompare != PH_FRINFC_MFSTD_FMT_VAL_0))\ - {\ - /* Compare any one among the sectors is NDEF COMPLIANT */\ - memcompare = (uint32_t)phFriNfc_MfStd_MemCompare(&Buffer[PH_FRINFC_MFSTD_FMT_VAL_0], \ - &NdefSmtCrdFmt->AddInfo.MfStdInfo.SectCompl[index],\ - PH_FRINFC_MFSTD_FMT_VAL_1);\ - /* increment the index */\ - index += (uint8_t)((index == (PH_FRINFC_MFSTD_FMT_MAX_SECT_IND_1K - \ - PH_FRINFC_MFSTD_FMT_VAL_1))?\ - PH_FRINFC_MFSTD_FMT_VAL_2:\ - PH_FRINFC_MFSTD_FMT_VAL_1);\ - }\ -} while(0) - -#define PH_FRINFC_MFSTD_FMT_CHK_END_OF_CARD() \ -do \ -{ \ - phFriNfc_MfStd_H_NdefComplSect(NdefSmtCrdFmt->CardType, \ - NdefSmtCrdFmt->AddInfo.MfStdInfo.SectCompl); \ - PH_FRINFC_MFSTD_FMT_CHK_SECT_ARRAY; \ - if(memcompare == PH_FRINFC_MFSTD_FMT_VAL_0) \ - { \ - phFriNfc_MfStd_H_StrNdefData(NdefSmtCrdFmt); \ - NdefSmtCrdFmt->AddInfo.MfStdInfo.CurrentBlock = \ - PH_FRINFC_MFSTD_FMT_VAL_1; \ - NdefSmtCrdFmt->AddInfo.MfStdInfo.UpdMADBlk = \ - PH_FRINFC_MFSTD_FMT_MAD_BLK_1; \ - NdefSmtCrdFmt->AddInfo.MfStdInfo.AuthState = \ - PH_FRINFC_MFSTD_FMT_AUTH_SCRT_KEYB; \ - NdefSmtCrdFmt->State = PH_FRINFC_MFSTD_FMT_AUTH_SECT; \ - Result = phFriNfc_MfStd_H_WrRdAuth(NdefSmtCrdFmt); \ - } \ - else \ - { \ - Result = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT, \ - NFCSTATUS_FORMAT_ERROR); \ - } \ -} while(0) -/*@}*/ - - -/** - * \ingroup grp_fri_smart_card_formatting - * \brief Smart Card Formatting \b Reset function - * - * \copydoc page_reg Resets the component instance to the initial state and initializes the - * internal variables. - */ -void phFriNfc_MfStd_Reset(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt); - -/*! - * \ingroup grp_fri_smart_card_formatting - * - * \brief Initiates the card formatting procedure for Remote Smart Card Type. - * - * \copydoc page_ovr The function initiates and formats the Smart Card.After this formation, remote - * card would be properly initialized and Ndef Compliant. - * Depending upon the different card type, this function handles formatting procedure. - * This function also handles the different recovery procedures for different types of the cards. For both - * Format and Recovery Management same API is used. - * - * \param[in] phFriNfc_sNdefSmartCardFmt_t Pointer to a valid instance of the \ref phFriNfc_sNdefSmartCardFmt_t - * structure describing the component context. - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval Other values An error has occurred. - * - */ -NFCSTATUS phFriNfc_MfStd_Format(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt, const uint8_t *ScrtKeyB); - -/** - *\ingroup grp_fri_smart_card_formatting - * - * \brief Smart card Formatting \b Completion \b Routine or \b Process function - * - * \copydoc page_ovr Completion Routine: This function is called by the lower layer (OVR HAL) - * when an I/O operation has finished. The internal state machine decides - * whether to call into the lower device again or to complete the process - * by calling into the upper layer's completion routine, stored within this - * component's context (\ref phFriNfc_sNdefSmtCrdFmt_t). - * - * The function call scheme is according to \ref grp_interact. No State reset is performed during - * operation. - * - * \param[in] Context The context of the current (not the lower/upper) instance, as set by the lower, - * calling layer, upon its completion. - * \param[in] Status The completion status of the lower layer (to be handled by the implementation of - * the state machine of this function like a regular return value of an internally - * called function). - * - * \note For general information about the completion routine interface please see \ref pphFriNfc_Cr_t . * The Different Status Values are as follows - * - */ -void phFriNfc_MfStd_Process(void *Context, - NFCSTATUS Status); -#endif /* PHFRINFC_MIFSTDFMT_H */ diff --git a/libnfc-nxp/phFriNfc_MifULFormat.h b/libnfc-nxp/phFriNfc_MifULFormat.h deleted file mode 100644 index 5238014..0000000 --- a/libnfc-nxp/phFriNfc_MifULFormat.h +++ /dev/null @@ -1,225 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * \file phFriNfc_MifULFormat.h - * \brief NFC Ndef Formatting For Mifare standard card. - * - * Project: NFC-FRI - * - * $Date: Mon Dec 13 14:14:12 2010 $ - * $Author: ing02260 $ - * $Revision: 1.5 $ - * $Aliases: $ - * - */ - -#ifndef PHFRINFC_MIFULFORMAT_H -#define PHFRINFC_MIFULFORMAT_H - -#include -#ifdef PH_HAL4_ENABLE - #include -#else - #include -#endif -#include -#include -#include - -#ifdef PH_NDEF_MIFARE_ULC -#include -#endif /* #ifdef PH_NDEF_MIFARE_ULC */ - -#define PH_FRINFC_MIFUL_FORMAT_FILEREVISION "$Revision: 1.5 $" -#define PH_FRINFC_MIFUL_FORMAT_FILEALIASES "$Aliases: $" - - -/*! - * \name Mifare UL - constants for the state - * - */ -/*@{*/ -#define PH_FRINFC_MFUL_FMT_RESET_INIT 0 /*!< Reset state */ -#define PH_FRINFC_MFUL_FMT_RD_16BYTES 1 /*!< Read 16 bytes */ -#define PH_FRINFC_MFUL_FMT_WR_OTPBYTES 2 /*!< Write OTP bytes */ -#define PH_FRINFC_MFUL_FMT_WR_TLV 3 /*!< Write TLV */ -#ifdef PH_NDEF_MIFARE_ULC -#define PH_FRINFC_MFUL_FMT_WR_TLV1 4 /*!< Write TLV (second part) */ -#endif /* #ifdef PH_NDEF_MIFARE_ULC */ -#ifdef FRINFC_READONLY_NDEF -#define PH_FRINFC_MFUL_FMT_RO_RD_16BYTES 5 /*!< Read only the tag */ -#define PH_FRINFC_MFUL_FMT_RO_WR_LOCK_BYTES 6 /*!< Write lock bytes to make the tag Read only */ -#define PH_FRINFC_MFUL_FMT_RO_WR_OTP_BYTES 7 /*!< Write OTP bytes to make the tag Read only */ - -#ifdef PH_NDEF_MIFARE_ULC -#define PH_FRINFC_MFUL_FMT_RO_RD_DYN_LOCK_BYTES 8 /*!< Read default dynamic lock bytes address */ -#define PH_FRINFC_MFUL_FMT_RO_WR_DYN_LOCK_BYTES 9 /*!< Write default dynamic lock bytes address */ -#define PH_FRINFC_MFUL_FMT_RO_PARSE_NDEF 10 /*!< Write default dynamic lock bytes address */ -#define PH_FRINFC_MFUL_FMT_RO_NDEF_PARSE_RD_BYTES 12 /*!< Read bytes from the card for parsing NDEF */ -#endif /* #ifdef PH_NDEF_MIFARE_ULC */ - -#endif /* #ifdef FRINFC_READONLY_NDEF */ - -/*@}*/ - - -/*! -* \name Mifare standard - Block numbers -* -*/ -/*@{*/ -#define PH_FRINFC_MFUL_FMT_LOCK_BITS_VAL 0x00 /*!< Lock bits block is 2 */ - -/*@}*/ - -/*! - * \name Mifare UL - OTP bytes - * - */ -/*@{*/ -#ifdef PH_NDEF_MIFARE_ULC -#define PH_FRINFC_MFULC_FMT_OTP_BYTES {0xE1, 0x10, 0x12, 0x00} /*!< OTP bytes macro */ -#endif /* #ifdef PH_NDEF_MIFARE_ULC */ -#define PH_FRINFC_MFUL_FMT_OTP_BYTES {0xE1, 0x10, 0x06, 0x00} /*!< OTP bytes macro */ - -/*@}*/ - -/*! - * \name Mifare UL - enums the values - * - */ -/*@{*/ -enum{ -PH_FRINFC_MFUL_FMT_VAL_0, -PH_FRINFC_MFUL_FMT_VAL_1, -PH_FRINFC_MFUL_FMT_VAL_2, -PH_FRINFC_MFUL_FMT_VAL_3, -PH_FRINFC_MFUL_FMT_VAL_4, -PH_FRINFC_MFUL_FMT_VAL_5, -PH_FRINFC_MFUL_FMT_VAL_6, -PH_FRINFC_MFUL_FMT_VAL_7 -}; -/*@}*/ - -/*! - * \name Mifare UL - constants - * - */ -/*@{*/ -#define PH_FRINFC_MFUL_FMT_NON_NDEF_COMPL 0 /*!< Card is not ndef compliant */ -#define PH_FRINFC_MFUL_FMT_NDEF_COMPL 1 /*!< Card is ndef compliant */ -/*@}*/ - -/*! - * \name Mifare UL - constants - * - */ -/*@{*/ -#define PH_FRINFC_MFUL_FMT_MAX_RECV_LENGTH 252 /*!< Maximum receive length */ -#define PH_FRINFC_MFUL_FMT_WR_SEND_LENGTH 5 /*!< Send length for write */ -#define PH_FRINFC_MFUL_FMT_MAX_BLK 16 /*!< Maximum blocks */ - -/*@}*/ - -/*! - * \name Mifare UL - constants for filling send buffer, calculating the block number, - * checking the authenticate state - * - */ -/*@{*/ - -/*@}*/ - - -/** - * \ingroup grp_fri_smart_card_formatting - * \brief Smart Card Formatting \b Reset function - * - * \copydoc page_reg Resets the component instance to the initial state and initializes the - * internal variables. - */ -void phFriNfc_MfUL_Reset(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt); - -/*! - * \ingroup grp_fri_smart_card_formatting - * - * \brief Initiates the card formatting procedure for Remote Smart Card Type. - * - * \copydoc page_ovr The function initiates and formats the Smart Card.After this formation, remote - * card would be properly initialized and Ndef Compliant. - * Depending upon the different card type, this function handles formatting procedure. - * This function also handles the different recovery procedures for different types of the cards. For both - * Format and Recovery Management same API is used. - * - * \param[in] phFriNfc_sNdefSmartCardFmt_t Pointer to a valid instance of the \ref phFriNfc_sNdefSmartCardFmt_t - * structure describing the component context. - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval Other values An error has occurred. - * - */ -NFCSTATUS phFriNfc_MfUL_Format(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt); - -#ifdef FRINFC_READONLY_NDEF - -/*! - * \ingroup grp_fri_smart_card_formatting - * - * \brief Initiates the conversion of the already NDEF formatted tag to READ ONLY. - * - * \copydoc page_ovr The function initiates the conversion of the already NDEF formatted - * tag to READ ONLY.After this formation, remote card would be properly Ndef Compliant and READ ONLY. - * Depending upon the different card type, this function handles formatting procedure. - * - * \param[in] phFriNfc_sNdefSmartCardFmt_t Pointer to a valid instance of the \ref phFriNfc_sNdefSmartCardFmt_t - * structure describing the component context. - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval Other values An error has occurred. - * - */ -NFCSTATUS -phFriNfc_MfUL_ConvertToReadOnly ( - phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt); - -#endif /* #ifdef FRINFC_READONLY_NDEF */ - -/** - *\ingroup grp_fri_smart_card_formatting - * - * \brief Smart card Formatting \b Completion \b Routine or \b Process function - * - * \copydoc page_ovr Completion Routine: This function is called by the lower layer (OVR HAL) - * when an I/O operation has finished. The internal state machine decides - * whether to call into the lower device again or to complete the process - * by calling into the upper layer's completion routine, stored within this - * component's context (\ref phFriNfc_sNdefSmtCrdFmt_t). - * - * The function call scheme is according to \ref grp_interact. No State reset is performed during - * operation. - * - * \param[in] Context The context of the current (not the lower/upper) instance, as set by the lower, - * calling layer, upon its completion. - * \param[in] Status The completion status of the lower layer (to be handled by the implementation of - * the state machine of this function like a regular return value of an internally - * called function). - * - * \note For general information about the completion routine interface please see \ref pphFriNfc_Cr_t . * The Different Status Values are as follows - * - */ -void phFriNfc_MfUL_Process(void *Context, - NFCSTATUS Status); -#endif /* PHFRINFC_MIFULFORMAT_H */ - diff --git a/libnfc-nxp/phFriNfc_MifareStdMap.h b/libnfc-nxp/phFriNfc_MifareStdMap.h deleted file mode 100644 index aeea7e7..0000000 --- a/libnfc-nxp/phFriNfc_MifareStdMap.h +++ /dev/null @@ -1,397 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! - * \file phFriNfc_MifareStdMap.h - * \brief NFC Ndef Mapping For Remote Devices. - * - * Project: NFC-FRI - * - * $Date: Tue May 19 10:30:01 2009 $ - * $Author: ing07336 $ - * $Revision: 1.7 $ - * $Aliases: NFC_FRI1.1_WK922_PREP1,NFC_FRI1.1_WK920_R25_1,NFC_FRI1.1_WK922_R26_1,NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ - * - */ - -#ifndef PHFRINFC_MIFARESTDMAP_H -#define PHFRINFC_MIFARESTDMAP_H - -#include -#ifdef PH_HAL4_ENABLE -#include -#else -#include -#endif -/** Fix: [NFC-FRI * * * CCB * * * 0000429]: - phFriNfc_MifareMap : Error during compilation **/ -#include -#include - -#ifndef PH_HAL4_ENABLE -#include -#endif - -#include -#include - -/*! \ingroup grp_file_attributes - * \name NDEF Mapping - * - * File: \ref phFriNfc_NdefMap.h - * - */ -/*@{*/ -#define PH_FRINFC_MIFARESTDMAP_FILEREVISION "$Revision: 1.7 $" -#define PH_FRINFC_MIFARESTDMAP_FILEALIASES "$Aliases: NFC_FRI1.1_WK922_PREP1,NFC_FRI1.1_WK920_R25_1,NFC_FRI1.1_WK922_R26_1,NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" -/*@}*/ - - -/*! \defgroup grp_fri_nfc_ndef_map NDEF Mapping for Remote Devices - * - * This component encapsulates Ndef Registration and Listening data and functionality. - */ -/*@{*/ - -/*! - * \name NDEF Mapping - states of the Finite State machine - * - */ -/*@{*/ -#define PH_FRINFC_NDEFMAP_STATE_INIT 0 /*!< Init state. The start-up state */ -#define PH_FRINFC_NDEFMAP_STATE_READ 1 /*!< Read State */ -#define PH_FRINFC_NDEFMAP_STATE_WRITE 2 /*!< Write is going on*/ -#define PH_FRINFC_NDEFMAP_STATE_AUTH 3 /*!< Authenticate is going on*/ -#define PH_FRINFC_NDEFMAP_STATE_CHK_NDEF_COMP 4 /*!< Check Ndef is going on */ -#define PH_FRINFC_NDEFMAP_STATE_RD_ACS_BIT 5 /*!< Read access bit is in progress */ -#define PH_FRINFC_NDEFMAP_STATE_WR_NDEF_LEN 6 /*!< Write NDEF TLV LEngth*/ -#define PH_FRINFC_NDEFMAP_STATE_RD_TO_WR_NDEF_LEN 7 /*!< read to write the Ndef TLV*/ -#define PH_FRINFC_NDEFMAP_STATE_GET_ACT_CARDSIZE 8 /*!< Get the card size */ -#define PH_FRINFC_NDEFMAP_STATE_RD_BEF_WR 9 /*!< Read the NDEF TLV block before starting write */ -#define PH_FRINFC_NDEFMAP_STATE_WR_TLV 10 /*!< Read the NDEF TLV block before starting write */ -#define PH_FRINFC_NDEFMAP_STATE_RD_TLV 11 /*!< Read the NDEF TLV block */ -#define PH_FRINFC_NDEFMAP_STATE_TERM_TLV 12 /*!< Write terminator TLV block */ -#define PH_FRINFC_NDEFMAP_STATE_POLL 13 /*!< Poll in progress */ -#define PH_FRINFC_NDEFMAP_STATE_DISCONNECT 14 /*!< Disconnect in progress */ -#define PH_FRINFC_NDEFMAP_STATE_CONNECT 15 /*!< Connect in progress */ - -#define PH_FRINFC_NDEFMAP_STATE_RD_SEC_ACS_BIT 16 /*!< Convert to ReadOnly in progress */ -#define PH_FRINFC_NDEFMAP_STATE_WRITE_SEC 17 /*!< Convert to ReadOnly in progress */ - - -/*@}*/ - -/*! - * \name Mifare Standard - NDEF Compliant Flags - * - */ -/*@{*/ -#define PH_FRINFC_MIFARESTD_NDEF_COMP 0 /*!< Sector is NDEF Compliant */ -#define PH_FRINFC_MIFARESTD_NON_NDEF_COMP 1 /*!< Sector is not NDEF Compliant */ -/*@}*/ - -/*! - * \name Mifare Standard - NDEF Compliant Flags - * - */ -/*@{*/ -#define PH_FRINFC_MIFARESTD_PROP_1ST_CONFIG 0 /*!< No proprietary forum sector found */ -#define PH_FRINFC_MIFARESTD_PROP_2ND_CONFIG 1 /*!< Here the proprietary - forum sector exists after NFC forum - sector */ -#define PH_FRINFC_MIFARESTD_PROP_3RD_CONFIG 2 /*!< Here the proprietary - forum sector exists before NFC forum - sector */ -/*@}*/ - -/*! - * \name Mifare Standard - NDEF Compliant Flags - * - */ -/*@{*/ -#define PH_FRINFC_MIFARESTD_MADSECT_ACS_BYTE6 0x78 /*!< Access Bit for Byte 6 in - MAD sector trailer */ -#define PH_FRINFC_MIFARESTD_MADSECT_ACS_BYTE7 0x77 /*!< Access Bit for Byte 7 in - MAD sector trailer */ -#define PH_FRINFC_MIFARESTD_NFCSECT_ACS_BYTE6 0x7F /*!< Access Bit for Byte 6 in - NFC forum sector trailer */ -#define PH_FRINFC_MIFARESTD_NFCSECT_ACS_BYTE7 0x07 /*!< Access Bit for Byte 7 in - NFC forum sector trailer */ -#define PH_FRINFC_MIFARESTD_ACS_BYTE8 0x88 /*!< Access Bit for Byte 8 in - all sector trailer */ -#define PH_FRINFC_MIFARESTD_NFCSECT_RDACS_BYTE6 0x07 /*!< Access Bit for Byte 6 in - NFC forum sector trailer for - Read Only State */ -#define PH_FRINFC_MIFARESTD_NFCSECT_RDACS_BYTE7 0x8F /*!< Access Bit for Byte 7 in - NFC forum sector trailer - Read Only State */ -#define PH_FRINFC_MIFARESTD_NFCSECT_RDACS_BYTE8 0x0F /*!< Access Bit for Byte 8 in - NFC forum sector trailer - Read Only State */ -/*@}*/ - -/*! - * \name Mifare Standard - Mifare Standard constants - * - */ -/*@{*/ -#define MIFARE_MAX_SEND_BUF_TO_READ 1 /*!< Send Length for Reading a Block */ -#define MIFARE_MAX_SEND_BUF_TO_WRITE 17 /*!< Send Length for writing a Block */ -#define MIFARE_AUTHENTICATE_CMD_LENGTH 7 /*!< Send Length for authenticating a Block */ -/*@}*/ - -/*! - * \name Mifare standard - Constants - * - */ -/*@{*/ -#define PH_FRINFC_MIFARESTD_MAD_BLK0 0 /*!< Block number 0 */ -#define PH_FRINFC_MIFARESTD_MAD_BLK1 1 /*!< Block number 1 */ -#define PH_FRINFC_MIFARESTD_MAD_BLK2 2 /*!< Block number 2 */ -#define PH_FRINFC_MIFARESTD_MAD_BLK3 3 /*!< Block number 3 */ -#define PH_FRINFC_MIFARESTD_BLK4 4 /*!< Block number 4 */ -#define PH_FRINFC_MIFARESTD_BLK5 5 /*!< Block number 5 */ -#define PH_FRINFC_MIFARESTD_BLK6 6 /*!< Block number 6 */ -#define PH_FRINFC_MIFARESTD_BLK7 7 /*!< Block number 7 */ -#define PH_FRINFC_MIFARESTD_BLK8 8 /*!< Block number 8 */ -#define PH_FRINFC_MIFARESTD_BLK9 9 /*!< Block number 9 */ -#define PH_FRINFC_MIFARESTD_BLK10 10 /*!< Block number 10 */ -#define PH_FRINFC_MIFARESTD_BLK11 11 /*!< Block number 11 */ -#define PH_FRINFC_MIFARESTD_BLK12 12 /*!< Block number 12 */ -#define PH_FRINFC_MIFARESTD_BLK13 13 /*!< Block number 13 */ -#define PH_FRINFC_MIFARESTD_BLK14 14 /*!< Block number 14 */ -#define PH_FRINFC_MIFARESTD_BLK15 15 /*!< Block number 15 */ -#define PH_FRINFC_MIFARESTD_MAD_BLK16 16 /*!< Block number 16 */ -#define PH_FRINFC_MIFARESTD_MAD_BLK63 63 /*!< Block number 63 */ -#define PH_FRINFC_MIFARESTD_MAD_BLK64 64 /*!< Block number 64 */ -#define PH_FRINFC_MIFARESTD_MAD_BLK65 65 /*!< Block number 65 */ -#define PH_FRINFC_MIFARESTD_MAD_BLK66 66 /*!< Block number 66 */ -#define PH_FRINFC_MIFARESTD_MAD_BLK67 67 /*!< Block number 67 */ -#define PH_FRINFC_MIFARESTD4K_BLK128 128 /*!< Block number 128 for Mifare 4k */ -#define PH_FRINFC_MIFARESTD_SECTOR_NO0 0 /*!< Sector 0 */ -#define PH_FRINFC_MIFARESTD_SECTOR_NO1 1 /*!< Sector 1 */ -#define PH_FRINFC_MIFARESTD_SECTOR_NO16 16 /*!< Sector 16 */ -#define PH_FRINFC_MIFARESTD_SECTOR_NO39 39 /*!< Sector 39 */ -#define PH_FRINFC_MIFARESTD_SECTOR_NO32 32 /*!< Sector 32 */ -#define PH_FRINFC_MIFARESTD4K_TOTAL_SECTOR 40 /*!< Sector 40 */ -#define PH_FRINFC_MIFARESTD1K_TOTAL_SECTOR 16 /*!< Sector 40 */ -#define PH_FRINFC_MIFARESTD_BYTES_READ 16 /*!< Bytes read */ -#define PH_FRINFC_MIFARESTD_BLOCK_BYTES 16 /*!< Bytes per block */ -#define PH_FRINFC_MIFARESTD_SECTOR_BLOCKS 16 /*!< Blocks per sector */ -#define PH_FRINFC_MIFARESTD_WR_A_BLK 17 /*!< 17 bytes (including current block) - are given to transfer */ -#define PH_FRINFC_MIFARESTD4K_MAX_BLOCKS 210 /*!< Maximum number of Mifare 4k Blocks - excluding sector trailer */ -#define PH_FRINFC_MIFARESTD1K_MAX_BLK 63 /*!< Maximum number of Mifare 1k blocks - including the sector trailer*/ -#define PH_FRINFC_MIFARESTD4K_MAX_BLK 254 /*!< Maximum number of Mifare 4k blocks - including the sector trailer*/ -#define PH_FRINFC_MIFARESTD_FLAG1 1 /*!< Flag to set 1 */ -#define PH_FRINFC_MIFARESTD_FLAG0 0 /*!< Flag to set 0 */ -#define PH_FRINFC_MIFARESTD_INC_1 1 /*!< increment by 1 */ -#define PH_FRINFC_MIFARESTD_INC_2 2 /*!< increment by 2 */ -#define PH_FRINFC_MIFARESTD_INC_3 3 /*!< increment by 3 */ -#define PH_FRINFC_MIFARESTD_INC_4 4 /*!< increment by 4 */ -#define PH_FRINFC_MIFARESTD_VAL0 0 /*!< Value initialised to 0 */ -#define PH_FRINFC_MIFARESTD_VAL1 1 /*!< Value initialised to 1 */ -#define PH_FRINFC_MIFARESTD_VAL2 2 /*!< Value initialised to 2 */ -#define PH_FRINFC_MIFARESTD_VAL3 3 /*!< Value initialised to 3 */ -#define PH_FRINFC_MIFARESTD_VAL4 4 /*!< Value initialised to 4 */ -#define PH_FRINFC_MIFARESTD_VAL5 5 /*!< Value initialised to 5 */ -#define PH_FRINFC_MIFARESTD_VAL6 6 /*!< Value initialised to 6 */ -#define PH_FRINFC_MIFARESTD_VAL7 7 /*!< Value initialised to 7 */ -#define PH_FRINFC_MIFARESTD_VAL8 8 /*!< Value initialised to 8 */ -#define PH_FRINFC_MIFARESTD_VAL9 9 /*!< Value initialised to 9 */ -#define PH_FRINFC_MIFARESTD_VAL10 10 /*!< Value initialised to 10 */ -#define PH_FRINFC_MIFARESTD_VAL11 11 /*!< Value initialised to 11 */ -#define PH_FRINFC_MIFARESTD_VAL12 12 /*!< Value initialised to 12 */ -#define PH_FRINFC_MIFARESTD_VAL13 13 /*!< Value initialised to 13 */ -#define PH_FRINFC_MIFARESTD_VAL14 14 /*!< Value initialised to 14 */ -#define PH_FRINFC_MIFARESTD_VAL15 15 /*!< Value initialised to 15 */ -#define PH_FRINFC_MIFARESTD_VAL16 16 /*!< Value initialised to 16 */ -#define PH_FRINFC_MIFARESTD_NDEFTLV_L 0xFF /*!< Length of the TLV */ -#define PH_FRINFC_MIFARESTD_NDEFTLV_T 0x03 /*!< Length of the TLV */ -#define PH_FRINFC_MIFARESTD_NDEFTLV_L0 0x00 /*!< Length of the TLV */ -#define PH_FRINFC_MIFARESTD_NDEFTLV_LBYTES0 0 /*!< Number of bytes taken by length (L) of the TLV */ -#define PH_FRINFC_MIFARESTD_NDEFTLV_LBYTES1 1 /*!< Number of bytes taken by length (L) of the TLV */ -#define PH_FRINFC_MIFARESTD_NDEFTLV_LBYTES2 2 /*!< Number of bytes taken by length (L) of the TLV */ -#define PH_FRINFC_MIFARESTD_NDEFTLV_LBYTES3 3 /*!< Number of bytes taken by length (L) of the TLV */ -#define PH_FRINFC_MIFARESTD_PROPTLV_T 0xFD /*!< Type of Proprietary TLV */ -#define PH_FRINFC_MIFARESTD_TERMTLV_T 0xFE /*!< Type of Terminator TLV */ -#define PH_FRINFC_MIFARESTD_NULLTLV_T 0x00 /*!< Type of NULL TLV */ -#define PH_FRINFC_MIFARESTD_LEFTSHIFT8 8 /*!< Left shift by 8 */ -#define PH_FRINFC_MIFARESTD_RIGHTSHIFT8 8 /*!< Right shift by 8 */ -#define PH_FRINFC_MIFARESTD_MASK_FF 0xFF /*!< Mask 0xFF */ -#define PH_FRINFC_MIFARESTD_MASK_GPB_WR 0x03 /*!< Mask 0x03 for GPB byte */ -#define PH_FRINFC_MIFARESTD_MASK_GPB_RD 0x0C /*!< Mask 0xOC for GPB byte */ -#define PH_FRINFC_MIFARESTD_GPB_RD_WR_VAL 0x00 /*!< GPB Read Write value */ -#define PH_FRINFC_MIFARESTD_KEY_LEN 0x06 /*!< MIFARE Std key length */ - -/*@}*/ - - -/*! - * \brief \copydoc page_reg Resets the component instance to the initial state and lets the component forget about - * the list of registered items. Moreover, the lower device is set. - * - * \param[in] NdefMap Pointer to a valid or uninitialised instance of \ref phFriNfc_NdefMap_t . - * - * \note This function has to be called at the beginning, after creating an instance of - * \ref phFriNfc_NdefMap_t . Use this function to reset the instance and/or switch - * to a different underlying device (different NFC device or device mode, or different - * Remote Device). - */ -NFCSTATUS phFriNfc_MifareStdMap_H_Reset( phFriNfc_NdefMap_t *NdefMap); - - - -/*! - * \brief \copydoc page_ovr Initiates Reading of NDEF information from the Remote Device. - * - * The function initiates the reading of NDEF information from a Remote Device. - * It performs a reset of the state and starts the action (state machine). - * A periodic call of the \ref phFriNfc_NdefMap_Process has to be done once the action - * has been triggered. - * - * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing - * the component context. - * - * \param[in] PacketData Pointer to a location that receives the NDEF Packet. - * - * \param[in,out] PacketDataLength Pointer to a variable receiving the length of the NDEF packet. - * - * \param[in] Offset Indicates whether the read operation shall start from the begining of the - * file/card storage \b or continue from the last offset. The last Offset set is stored - * within a context variable (must not be modified by the integration). - * If the caller sets the value to \ref PH_FRINFC_NDEFMAP_SEEK_CUR, the component shall - * start reading from the last offset set (continue where it has stopped before). - * If set to \ref PH_FRINFC_NDEFMAP_SEEK_BEGIN, the component shall start reading - * from the begining of the card (restarted) - * - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval NFCSTATUS_INVALID_DEVICE_REQUEST If Previous Operation is Write Ndef and Offset - * is Current then this error is displayed. - * \retval NFCSTATUS_EOF_NDEF_CONTAINER_REACHED No Space in the File to read. - * \retval NFCSTATUS_MORE_INFORMATION There are more bytes to read in the card. - * \retval NFCSTATUS_SUCCESS Last Byte of the card read. - * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected - * meanwhile. - * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request. - * \retval NFCSTATUS_BUFFER_TOO_SMALL The buffer provided by the caller is too small. - * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period. - * - */ -NFCSTATUS phFriNfc_MifareStdMap_RdNdef( phFriNfc_NdefMap_t *NdefMap, - uint8_t *PacketData, - uint32_t *PacketDataLength, - uint8_t Offset); - - -/*! - * \brief \copydoc page_ovr Initiates Writing of NDEF information to the Remote Device. - * - * The function initiates the writing of NDEF information to a Remote Device. - * It performs a reset of the state and starts the action (state machine). - * A periodic call of the \ref phFriNfc_NdefMap_Process has to be done once the action - * has been triggered. - * - * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing - * the component context. - * - * \param[in] PacketData Pointer to a location that holds the prepared NDEF Packet. - * - * \param[in,out] PacketDataLength Variable specifying the length of the prepared NDEF packet. - * - * \param[in] Offset Indicates whether the write operation shall start from the begining of the - * file/card storage \b or continue from the last offset. The last Offset set is stored - * within a context variable (must not be modified by the integration). - * If the caller sets the value to \ref PH_FRINFC_NDEFMAP_SEEK_CUR, the component shall - * start writing from the last offset set (continue where it has stopped before). - * If set to \ref PH_FRINFC_NDEFMAP_SEEK_BEGIN, the component shall start writing - * from the begining of the card (restarted) - * - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval NFCSTATUS_INVALID_DEVICE_REQUEST If Previous Operation is Write Ndef and Offset - * is Current then this error is displayed. - * \retval NFCSTATUS_EOF_NDEF_CONTAINER_REACHED Last byte is written to the card after this - * no further writing is possible. - * \retval NFCSTATUS_SUCCESS Buffer provided by the user is completely written - * into the card. - * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected - * meanwhile. - * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request. - * \retval NFCSTATUS_BUFFER_TOO_SMALL The buffer provided by the caller is too small. - * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period. - * - */ - -NFCSTATUS phFriNfc_MifareStdMap_WrNdef( phFriNfc_NdefMap_t *NdefMap, - uint8_t *PacketData, - uint32_t *PacketDataLength, - uint8_t Offset); - - -/*! - * \brief \copydoc page_ovr Check whether a particulat Remote Device is NDEF compliant. - * - * The function checks whether the peer device is NDEF compliant. - * - * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing - * the component context. - * - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. - * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected - * meanwhile. - * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request. - * \retval NFCSTATUS_BUFFER_TOO_SMALL The buffer provided by the caller is too small. - * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period. - * - */ -NFCSTATUS phFriNfc_MifareStdMap_ChkNdef(phFriNfc_NdefMap_t *NdefMap); - -/*! - * \brief \copydoc page_cb Completion Routine, Processing function, needed to avoid long blocking. - * - * The function call scheme is according to \ref grp_interact. No State reset is performed during operation. - * - * \copydoc pphFriNfc_Cr_t - * - * \note The lower (Overlapped HAL) layer must register a pointer to this function as a Completion - * Routine in order to be able to notify the component that an I/O has finished and data are - * ready to be processed. - * - */ -void phFriNfc_MifareStdMap_Process( void *Context, - NFCSTATUS Status); - -/*! - * - * The function Convert the Mifare card to ReadOnly. - * - * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing - * the component context. - * - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. - * \retval NFCSTATUS_INVALID_STATE The mifare card should be in read_write state to convert card to - * readonly.If any other state the function return NFCSTATUS_INVALID_STATE - *\retval NFCSTATUS_NOT_ALLOWED If card is already in read_only state or initialized state - * - */ -NFCSTATUS phFriNfc_MifareStdMap_ConvertToReadOnly(phFriNfc_NdefMap_t *NdefMap, const uint8_t *ScrtKeyB); - -#endif /* PHFRINFC_MIFARESTDMAP_H */ diff --git a/libnfc-nxp/phFriNfc_MifareULMap.h b/libnfc-nxp/phFriNfc_MifareULMap.h deleted file mode 100644 index abdf135..0000000 --- a/libnfc-nxp/phFriNfc_MifareULMap.h +++ /dev/null @@ -1,290 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * \file phFriNfc_MifareULMap.h - * \brief NFC Ndef Mapping For Mifare UL Card. - * - * Project: NFC-FRI - * - * $Date: Fri Aug 7 13:06:49 2009 $ - * $Author: ing07336 $ - * $Revision: 1.9 $ - * $Aliases: NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ - * - */ - -#ifndef PHFRINFC_MIFAREULMAP_H -#define PHFRINFC_MIFAREULMAP_H - -#include -#if !defined PH_HAL4_ENABLE -#include -#endif -#include -#include -#include - -#define PH_FRINFC_NDEFMAP_MIFAREMAP_FILEREVISION "$Revision: 1.9 $" -#define PH_FRINFC_NDEFMAP_MIFAREMAP_FILEALIASES "$Aliases: NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" - - -/*! - * \name Mifare UL - states of the Finite State machine - * - */ -/*@{*/ -#define PH_FRINFC_NDEFMAP_MFUL_STATE_READ 1 /*!< Read State */ -#define PH_FRINFC_NDEFMAP_MFUL_STATE_WRITE 2 /*!< Write is going on*/ -#define PH_FRINFC_NDEFMAP_MFUL_STATE_CHK_NDEF_COMP 3 /*!< Check Ndef is going on */ -#define PH_FRINFC_NDEFMAP_MFUL_STATE_FND_NDEF_COMP 4 /*!< to find the NDEF TLV */ -#define PH_FRINFC_NDEFMAP_MFUL_STATE_TERM_TLV 5 /*!< to write the terminator TLV */ -#define PH_FRINFC_NDEFMAP_MFUL_STATE_WR_LEN_TLV 6 /*!< Write L value of TLV */ -#define PH_FRINFC_NDEFMAP_MFUL_STATE_SELECT_SECTOR_CHK_1 7 /*!< to send sector select command 1 */ -#define PH_FRINFC_NDEFMAP_MFUL_STATE_SELECT_SECTOR_CHK_2 8 /*!< to send sector select command 2 */ -#define PH_FRINFC_NDEFMAP_MFUL_STATE_SELECT_SECTOR_RESET_1 9 /*!< to send sector select command 1 for resetting sector 0 */ -#define PH_FRINFC_NDEFMAP_MFUL_STATE_SELECT_SECTOR_RESET_2 10 /*!< to send sector select command 2 for resetting sector 0 */ -#define PH_FRINFC_NDEFMAP_MFUL_STATE_SELECT_SECTOR_READ_1 11 /*!< to send sector select command 1 for resetting sector 0 */ -#define PH_FRINFC_NDEFMAP_MFUL_STATE_SELECT_SECTOR_READ_2 12 /*!< to send sector select command 2 for resetting sector 0 */ -#define PH_FRINFC_NDEFMAP_MFUL_STATE_SELECT_SECTOR_WRITE_1 13 /*!< to send sector select command 1 for resetting sector 0 */ -#define PH_FRINFC_NDEFMAP_MFUL_STATE_SELECT_SECTOR_WRITE_2 14 /*!< to send sector select command 2 for resetting sector 0 */ -#define PH_FRINFC_NDEFMAP_MFUL_STATE_SELECT_SECTOR_RW_1 15 /*!< to send sector select command 1 for resetting sector 0 */ -#define PH_FRINFC_NDEFMAP_MFUL_STATE_SELECT_SECTOR_RW_2 16 /*!< to send sector select command 2 for resetting sector 0 */ -#define PH_FRINFC_NDEFMAP_MFUL_STATE_SELECT_SECTOR_WRITE_INIT_1 17 /*!< to send sector select command 1 for resetting sector 0 */ -#define PH_FRINFC_NDEFMAP_MFUL_STATE_SELECT_SECTOR_WRITE_INIT_2 18 /*!< to send sector select command 2 for resetting sector 0 */ - - -/*@}*/ - -/*! - * \name Mifare - constants for the capability container - * - */ -/*@{*/ -#define PH_FRINFC_NDEFMAP_MFUL_CC_BYTE0 0xE1 /*!< Capability container byte 0 = 0xE1 */ -#define PH_FRINFC_NDEFMAP_MFUL_CC_BYTE1 0x10 /*!< Capability container byte 1 = 0x10 */ -#define PH_FRINFC_NDEFMAP_MFUL_CC_BYTE2 0x06 /*!< Capability container byte 2 = 0x06 */ -#define PH_FRINFC_NDEFMAP_MFUL_CC_BYTE3_RW 0x00 /*!< Capability container byte 3 = 0x00 for - READ WRITE/INITIALISED card state*/ -#define PH_FRINFC_NDEFMAP_MFUL_CC_BYTE3_RO 0x0F /*!< Capability container byte 3 = 0x0F for - READ only card state*/ -/*@}*/ - -/*! - * \name Mifare - constants for Flags - * - */ -/*@{*/ -#define PH_FRINFC_NDEFMAP_MFUL_FLAG0 0 /*!< Flag value = 0 */ -#define PH_FRINFC_NDEFMAP_MFUL_FLAG1 1 /*!< Flag value = 1 */ -/*@}*/ - -/*! - * \name Mifare - constants for left shift - * - */ -/*@{*/ -#define PH_FRINFC_NDEFMAP_MFUL_SHIFT8 8 /*!< Flag value = 0 */ -/*@}*/ - -/*! - * \name Mifare - TLV related constants - * - */ -/*@{*/ -#define PH_FRINFC_NDEFMAP_MFUL_NDEFTLV_T 0x03 /*!< Type value of TLV = 0x03 */ -#define PH_FRINFC_NDEFMAP_MFUL_NDEFTLV_L 0x00 /*!< Length value of TLV = 0x00 */ -#define PH_FRINFC_NDEFMAP_MFUL_NDEFTLV_LFF 0xFF /*!< Length value of TLV = 0xFF */ -#define PH_FRINFC_NDEFMAP_MFUL_TERMTLV 0xFE /*!< Terminator TLV value = 0xFE */ -#define PH_FRINFC_NDEFMAP_MFUL_NULLTLV 0x00 /*!< Null TLV value = 0x00 */ -#define PH_FRINFC_NDEFMAP_MFUL_LOCK_CTRL_TLV 0x01 /*!< Lock Control TLV value = 0x01 */ -#define PH_FRINFC_NDEFMAP_MFUL_MEM_CTRL_TLV 0x02 /*!< Memory Control TVL value = 0x02 */ -#define PH_FRINFC_NDEFMAP_MFUL_PROPRIETRY_TLV 0xFD /*!< Proprietry TVL value = 0xFD */ - - -/*@}*/ - - -/*! - * \name Mifare - Standard constants - * - */ -/*@{*/ -#define PH_FRINFC_NDEFMAP_MFUL_WR_A_BLK 0x05 /*!< Send Length for Write Ndef */ -#define PH_FRINFC_NDEFMAP_MFUL_MAX_SEND_BUF_TO_READ 0x01 /*!< Send Length for Read Ndef */ -#define PH_FRINFC_NDEFMAP_MFUL_CHECK_RESP 0x04 /*!< Value of the Sense Response for Mifare UL */ -#define PH_FRINFC_NDEFMAP_MFUL_OTP_OFFSET 3 /*!< To initialise the Offset */ -#define PH_FRINFC_NDEFMAP_MFUL_MUL8 8 /*!< Multiply by 8 */ -#define PH_FRINFC_NDEFMAP_MFUL_VAL0 0 /*!< Value 0 */ -#define PH_FRINFC_NDEFMAP_MFUL_VAL1 1 /*!< Value 1 */ -#define PH_FRINFC_NDEFMAP_MFUL_VAL2 2 /*!< Value 2 */ -#define PH_FRINFC_NDEFMAP_MFUL_VAL3 3 /*!< Value 3 */ -#define PH_FRINFC_NDEFMAP_MFUL_VAL4 4 /*!< Value 4 */ -#define PH_FRINFC_NDEFMAP_MFUL_VAL5 5 /*!< Value 5 */ -#define PH_FRINFC_NDEFMAP_MFUL_VAL64 64 /*!< Value 64 */ -#define PH_FRINFC_NDEFMAP_MFUL_BYTE0 0x00 /*!< Byte number 0 */ -#define PH_FRINFC_NDEFMAP_MFUL_BYTE1 0x01 /*!< Byte number 1 */ -#define PH_FRINFC_NDEFMAP_MFUL_BYTE2 0x02 /*!< Byte number 2 */ -#define PH_FRINFC_NDEFMAP_MFUL_BYTE3 0x03 /*!< Byte number 3 */ -#define PH_FRINFC_NDEFMAP_MFUL_BYTE4 0x04 /*!< Byte number 4 */ -#define PH_FRINFC_NDEFMAP_MFUL_BLOCK0 0x00 /*!< Block number 0 */ -#define PH_FRINFC_NDEFMAP_MFUL_BLOCK1 0x01 /*!< Block number 1 */ -#define PH_FRINFC_NDEFMAP_MFUL_BLOCK2 0x02 /*!< Block number 2 */ -#define PH_FRINFC_NDEFMAP_MFUL_BLOCK3 0x03 /*!< Block number 3 */ -#define PH_FRINFC_NDEFMAP_MFUL_BLOCK4 0x04 /*!< Block number 4 */ -#define PH_FRINFC_NDEFMAP_MFUL_BLOCK5 0x05 /*!< Block number 5 */ - -#define PH_FRINFC_NDEFMAP_MFUL_RDBYTES_16 0x10 /*!< Read Bytes 16 */ -#define PH_FRINFC_NDEFMAP_STMFUL_MAX_CARD_SZ 48 /*!< For static maximum memory size is 48 bytes */ -#define PH_FRINFC_NDEFMAP_MFUL_WR_BUF_STR 0x04 /*!< To store the block of data written to the card */ -/*@}*/ - -/*! - * \brief \copydoc page_reg Resets the component instance to the initial state and lets the component forget about - * the list of registered items. Moreover, the lower device is set. - * - * \param[in] NdefMap Pointer to a valid or uninitialised instance of \ref phFriNfc_NdefMap_t . - * - * \note This function has to be called at the beginning, after creating an instance of - * \ref phFriNfc_NdefMap_t . Use this function to reset the instance and/or switch - * to a different underlying device (different NFC device or device mode, or different - * Remote Device). - */ -NFCSTATUS phFriNfc_MifareUL_H_Reset( phFriNfc_NdefMap_t *NdefMap); - -/*! - * \brief \copydoc page_ovr Initiates Reading of NDEF information from the Remote Device. - * - * The function initiates the reading of NDEF information from a Remote Device. - * It performs a reset of the state and starts the action (state machine). - * A periodic call of the \ref phFriNfc_NdefMap_Process has to be done once the action - * has been triggered. - * - * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing - * the component context. - * - * \param[in] PacketData Pointer to a location that receives the NDEF Packet. - * - * \param[in,out] PacketDataLength Pointer to a variable receiving the length of the NDEF packet. - * - * \param[in] Offset Indicates whether the read operation shall start from the begining of the - * file/card storage \b or continue from the last offset. The last Offset set is stored - * within a context variable (must not be modified by the integration). - * If the caller sets the value to \ref PH_FRINFC_NDEFMAP_SEEK_CUR, the component shall - * start reading from the last offset set (continue where it has stopped before). - * If set to \ref PH_FRINFC_NDEFMAP_SEEK_BEGIN, the component shall start reading - * from the begining of the card (restarted) - * - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval NFCSTATUS_INVALID_DEVICE_REQUEST If Previous Operation is Write Ndef and Offset - * is Current then this error is displayed. - * \retval NFCSTATUS_EOF_NDEF_CONTAINER_REACHED No Space in the File to read. - * \retval NFCSTATUS_MORE_INFORMATION There are more bytes to read in the card. - * \retval NFCSTATUS_SUCCESS Last Byte of the card read. - * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected - * meanwhile. - * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request. - * \retval NFCSTATUS_BUFFER_TOO_SMALL The buffer provided by the caller is too small. - * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period. - * - */ - -NFCSTATUS phFriNfc_MifareUL_RdNdef( phFriNfc_NdefMap_t *NdefMap, - uint8_t *PacketData, - uint32_t *PacketDataLength, - uint8_t Offset); - -/*! - * \brief \copydoc page_ovr Initiates Writing of NDEF information to the Remote Device. - * - * The function initiates the writing of NDEF information to a Remote Device. - * It performs a reset of the state and starts the action (state machine). - * A periodic call of the \ref phFriNfc_NdefMap_Process has to be done once the action - * has been triggered. - * - * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing - * the component context. - * - * \param[in] PacketData Pointer to a location that holds the prepared NDEF Packet. - * - * \param[in,out] PacketDataLength Variable specifying the length of the prepared NDEF packet. - * - * \param[in] Offset Indicates whether the write operation shall start from the begining of the - * file/card storage \b or continue from the last offset. The last Offset set is stored - * within a context variable (must not be modified by the integration). - * If the caller sets the value to \ref PH_FRINFC_NDEFMAP_SEEK_CUR, the component shall - * start writing from the last offset set (continue where it has stopped before). - * If set to \ref PH_FRINFC_NDEFMAP_SEEK_BEGIN, the component shall start writing - * from the begining of the card (restarted) - * - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval NFCSTATUS_INVALID_DEVICE_REQUEST If Previous Operation is Write Ndef and Offset - * is Current then this error is displayed. - * \retval NFCSTATUS_EOF_NDEF_CONTAINER_REACHED Last byte is written to the card after this - * no further writing is possible. - * \retval NFCSTATUS_SUCCESS Buffer provided by the user is completely written - * into the card. - * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected - * meanwhile. - * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request. - * \retval NFCSTATUS_BUFFER_TOO_SMALL The buffer provided by the caller is too small. - * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period. - * - */ - -NFCSTATUS phFriNfc_MifareUL_WrNdef( phFriNfc_NdefMap_t *NdefMap, - uint8_t *PacketData, - uint32_t *PacketDataLength, - uint8_t Offset); - -/*! - * \brief \copydoc page_ovr Check whether a particulat Remote Device is NDEF compliant. - * - * The function checks whether the peer device is NDEF compliant. - * - * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing - * the component context. - * - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. - * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected - * meanwhile. - * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request. - * \retval NFCSTATUS_BUFFER_TOO_SMALL The buffer provided by the caller is too small. - * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period. - * - */ - -NFCSTATUS phFriNfc_MifareUL_ChkNdef( phFriNfc_NdefMap_t *NdefMap); - -/*! - * \brief \copydoc page_cb Completion Routine, Processing function, needed to avoid long blocking. - * - * The function call scheme is according to \ref grp_interact. No State reset is performed during operation. - * - * \copydoc pphFriNfc_Cr_t - * - * \note The lower (Overlapped HAL) layer must register a pointer to this function as a Completion - * Routine in order to be able to notify the component that an I/O has finished and data are - * ready to be processed. - * - */ - -void phFriNfc_MifareUL_Process( void *Context, - NFCSTATUS Status); - - -#endif /* PHFRINFC_MIFAREULMAP_H */ diff --git a/libnfc-nxp/phFriNfc_NdefMap.h b/libnfc-nxp/phFriNfc_NdefMap.h deleted file mode 100644 index 4c4ab45..0000000 --- a/libnfc-nxp/phFriNfc_NdefMap.h +++ /dev/null @@ -1,1336 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * \file phFriNfc_NdefMap.h - * \brief NFC Ndef Mapping For Different Smart Cards. - * - * Project: NFC-FRI - * - * $Date: Mon Dec 13 14:14:14 2010 $ - * $Author: ing02260 $ - * $Revision: 1.25 $ - * $Aliases: $ - * - */ - -#ifndef PHFRINFC_NDEFMAP_H -#define PHFRINFC_NDEFMAP_H - - -/*include files*/ -#include -#include -#include -#ifdef PH_HAL4_ENABLE - #include -#else - #include -#endif - - -#include - -#ifndef PH_FRINFC_EXCLUDE_FROM_TESTFW /* */ - -/** - * \name NDEF Mapping - * - * File: \ref phFriNfc_NdefMap.h - * - */ -/*@{*/ -#define PH_FRINFC_NDEFMAP_FILEREVISION "$Revision: 1.25 $" /**< \ingroup grp_file_attributes */ -#define PH_FRINFC_NDEFMAP_FILEALIASES "$Aliases: $" /**< \ingroup grp_file_attributes */ -/*@}*/ - -#endif /* PH_FRINFC_EXCLUDE_FROM_TESTFW */ - - -/** \defgroup grp_fri_nfc_ndef_map NDEF Mapping Component - * - * This component implements the read/write/check NDEF functions for remote devices. - * NDEF data, as defined by the NFC Forum NDEF specification are written to or read from - * a remote device that can be a smart- or memory card. \n\n - * Please notice that the NDEF mapping command sequence must - * be \b contiguous (after correct initialisation): \n - * \b Examples: - * - Checking and Reading - * - \ref phFriNfc_NdefMap_ChkNdef - * - \ref phFriNfc_NdefMap_RdNdef - * . - * - Checking and Writing - * - \ref phFriNfc_NdefMap_ChkNdef - * - \ref phFriNfc_NdefMap_WrNdef - * . - * - Checking, Reading and Writing - * - \ref phFriNfc_NdefMap_ChkNdef - * - \ref phFriNfc_NdefMap_RdNdef - * - \ref phFriNfc_NdefMap_WrNdef - * . - * . - * There must be \b no \b other FRI or HAL call between these mapping commands. Exceptions to this - * rule are specific to the NDEF mapping of certain card / remote device types and separately noted, - * typically for true multi-activation capable devices. - * - */ - -/** - * \name NDEF Mapping - specifies the different card types - * These are the only recognised card types in this version. - * - */ -/*@{*/ - -#define DESFIRE_EV1 - -#define PH_FRINFC_NDEFMAP_MIFARE_UL_CARD 1 /**< \internal Mifare UL */ -#define PH_FRINFC_NDEFMAP_ISO14443_4A_CARD 2 /**< \internal Iso 14443-4A */ -#define PH_FRINFC_NDEFMAP_MIFARE_STD_1K_CARD 3 /**< \internal Mifare Standard */ -#define PH_FRINFC_NDEFMAP_MIFARE_STD_4K_CARD 4 /**< \internal Mifare Standard */ -#define PH_FRINFC_NDEFMAP_FELICA_SMART_CARD 5 /**< \internal Felica Smart Tag */ -#define PH_FRINFC_NDEFMAP_TOPAZ_CARD 7 /**< \internal Felica Smart Tag */ -#define PH_FRINFC_NDEFMAP_TOPAZ_DYNAMIC_CARD 8 /**< \internal Felica Smart Tag */ -#ifdef DESFIRE_EV1 -#define PH_FRINFC_NDEFMAP_ISO14443_4A_CARD_EV1 9 /**< \internal Iso 14443-4A EV1 */ -#endif /* #ifdef DESFIRE_EV1 */ - -#define PH_FRINFC_NDEFMAP_ISO15693_CARD 10 /**< \internal ISO 15693 */ - - -#ifdef PH_NDEF_MIFARE_ULC -#define PH_FRINFC_NDEFMAP_MIFARE_ULC_CARD 8 /**< \internal Mifare UL */ -#endif /* #ifdef PH_NDEF_MIFARE_ULC */ - -#define PH_FRINFC_NDEFMAP_EMPTY_NDEF_MSG {0xD0, 0x00, 0x00} /**< \internal Empty ndef message */ - - -#ifdef PHFRINFC_OVRHAL_MOCKUP /* */ -#define PH_FRINFC_NDEFMAP_MOCKUP_CARD 6 /**< \internal Mocup*/ -#endif /* PHFRINFC_OVRHAL_MOCKUP */ - - - -/* Enum reperesents the different card state*/ -typedef enum -{ - PH_NDEFMAP_CARD_STATE_INITIALIZED, - PH_NDEFMAP_CARD_STATE_READ_ONLY, - PH_NDEFMAP_CARD_STATE_READ_WRITE, - PH_NDEFMAP_CARD_STATE_INVALID -}phNDEF_CARD_STATE; - - -/*@}*/ - - -#ifndef PH_FRINFC_MAP_MIFARESTD_DISABLED -/** - * \name NDEF Mapping - specifies the Compliant Blocks in the Mifare 1k and 4k card types - * - */ -/*@{*/ -#define PH_FRINFC_NDEFMAP_MIFARESTD_1KNDEF_COMPBLOCK 45 /**< \internal Total Ndef Compliant blocks Mifare 1k */ -#define PH_FRINFC_NDEFMAP_MIFARESTD_4KNDEF_COMPBLOCK 210 /**< \internal Total Ndef Compliant blocks Mifare 4k */ -#define PH_FRINFC_NDEFMAP_MIFARESTD_RDWR_SIZE 16 /**< \internal Bytes read/write for one read/write operation*/ -#define PH_FRINFC_NDEFMAP_MIFARESTD_TOTALNO_BLK 40 /**< \internal Total number of sectors in Mifare 4k */ -#define PH_FRINFC_NDEFMAP_MIFARESTD_ST15_BYTES 15 /**< \internal To store 15 bytes after reading a block */ -/*@}*/ -#endif /* PH_FRINFC_MAP_MIFARESTD_DISABLED */ - -#ifndef PH_FRINFC_MAP_TOPAZ_DISABLED -/** - * \name NDEF Mapping - specifies the Compliant Blocks in the Mifare 1k and 4k card types - * - */ -/*@{*/ -#define PH_FRINFC_NDEFMAP_TOPAZ_MAX_SIZE 256 /**< \internal Total Memory size = 96 bytes (newer version have mode) */ -#define PH_FRINFC_NDEFMAP_TOPAZ_UID_SIZE 0x04 /**< \internal UID size returned by READID command = 4 bytes */ -/*@}*/ -#endif /* PH_FRINFC_MAP_TOPAZ_DISABLED */ - -#ifndef PH_FRINFC_MAP_FELICA_DISABLED -/* Felica Mapping - Constants */ -#define PH_FRINFC_NDEFMAP_FELICA_BLOCK_SIZE 16 -#define PH_FRINFC_NDEFMAP_FELICA_ATTR_NDEF_DATA_LEN 3 -#define PH_FRINFC_NDEFMAP_FELICA_MANUF_ID_DATA_LEN 8 -#endif /* PH_FRINFC_MAP_FELICA_DISABLED */ - -/* MifareUL/Type2 specific constants*/ -#ifndef PH_FRINFC_MAP_MIFAREUL_DISABLED - -#ifdef PH_NDEF_MIFARE_ULC -#define PH_FRINFC_NDEFMAP_MFUL_64BYTES_BUF 2048 /**< \internal To store 2048 bytes after reading entire card */ -#else -#define PH_FRINFC_NDEFMAP_MFUL_64BYTES_BUF 64 /**< \internal To store 64 bytes after reading entire card */ -#endif /*#ifdef PH_NDEF_MIFARE_ULC */ - -#define PH_FRINFC_NDEFMAP_MFUL_4BYTES_BUF 4 /**< \internal To store 4 bytes after write */ - -#endif /*#ifndef PH_FRINFC_MAP_MIFAREUL_DISABLED*/ - -#ifdef PHFRINFC_OVRHAL_MOCKUP /* */ - -#define PH_FRINFC_NDEFMAP_MOCKUP_4096BYTES_BUF 4096 /**< \internal To store 4 bytes after write */ - -#endif /*#ifndef PH_FRINFC_MAP_MOCKUP_DISABLED*/ - -/** - * \name Completion Routine Indices - * - * These are the indices of the completion routine pointers within the component context. - * Completion routines belong to upper components. - * - */ -/*@{*/ -/** \ingroup grp_fri_nfc_ndef_map - * Completion Routine Index for \ref phFriNfc_NdefMap_ChkNdef */ -#define PH_FRINFC_NDEFMAP_CR_CHK_NDEF 0 /* */ -/** \ingroup grp_fri_nfc_ndef_map - * Completion Routine Index for \ref phFriNfc_NdefMap_RdNdef */ -#define PH_FRINFC_NDEFMAP_CR_RD_NDEF 1 /* */ -/** \ingroup grp_fri_nfc_ndef_map - * Completion Routine Index for \ref phFriNfc_NdefMap_WrNdef */ -#define PH_FRINFC_NDEFMAP_CR_WR_NDEF 2 /* */ -/** \ingroup grp_fri_nfc_ndef_map - * Completion Routine Index for \ref phFriNfc_NdefMap_EraseNdef */ -#define PH_FRINFC_NDEFMAP_CR_ERASE_NDEF 3 /* */ -/** \ingroup grp_fri_nfc_ndef_map Completion - * Routine Index for Unknown States/Operations */ -#define PH_FRINFC_NDEFMAP_CR_INVALID_OPE 4 /* */ -/** \ingroup grp_fri_nfc_ndef_map - * Number of completion routines that have to be initialised */ -#define PH_FRINFC_NDEFMAP_CR 5 /* */ -/*@}*/ - -/** - * \name File Offset Attributes - * - * Following values are used to determine the offset value for Read/Write. This specifies whether - * the Read/Write operation needs to be restarted/continued from the last offset set. - * - */ -/*@{*/ -/** \ingroup grp_fri_nfc_ndef_map - * Read/Write operation shall start from the last offset set */ -#define PH_FRINFC_NDEFMAP_SEEK_CUR 0 /* */ -/** \ingroup grp_fri_nfc_ndef_map - * Read/Write operation shall start from the begining of the file/card */ -#define PH_FRINFC_NDEFMAP_SEEK_BEGIN 1 /* */ -/*@}*/ - - -/** - * \name Buffer Size Definitions - * - */ -/*@{*/ -/** \ingroup grp_fri_nfc_ndef_map Minimum size of the TRX buffer required */ -#define PH_FRINFC_NDEFMAP_MAX_SEND_RECV_BUF_SIZE 252 /* */ -/** \internal The size of s MIFARE block */ -#define PH_FRINFC_NDEFMAP_MF_READ_BLOCK_SIZE 16 /* */ - - -#ifndef PH_FRINFC_EXCLUDE_FROM_TESTFW /* */ - - -#ifndef PH_FRINFC_MAP_ISO15693_DISABLED - -#define ISO15693_MAX_DATA_TO_STORE 0x04U - -typedef struct phFriNfc_ISO15693Cont -{ - /**< \internal block number that is executed */ - uint16_t current_block; - /**< \internal The state of the operation */ - uint8_t state; - /**< \internal Completion routine index */ - uint8_t cr_index; - /**< \internal Execution sequence */ - uint8_t ndef_seq; - /**< \internal NDEF TLV size */ - uint16_t actual_ndef_size; - /**< \internal NDEF TLV size */ - uint16_t max_data_size; - /**< \internal NDEF TLV TYPE block number */ - uint16_t ndef_tlv_type_blk; - /**< \internal NDEF TLV TYPE byte number in the - "ndef_tlv_type_blk" */ - uint8_t ndef_tlv_type_byte; - /**< \internal Store the remaining bytes that can be used for - READ with continue option */ - uint8_t store_read_data[ISO15693_MAX_DATA_TO_STORE]; - uint8_t store_length; - /**< \internal Remaining size that can be read */ - uint16_t remaining_size_to_read; - uint8_t read_capabilities; - - -}phFriNfc_ISO15693Cont_t; - -#endif /* #ifndef PH_FRINFC_MAP_ISO15693_DISABLED */ - - - -#ifndef PH_FRINFC_MAP_FELICA_DISABLED -/** - * \ingroup grp_fri_nfc_ndef_map - * \brief Felica Basic structure which details the different vaiables - * used for Reading/writing. - * - */ -typedef struct phFriNfc_Felica -{ - /**< Current block being read or written*/ - uint8_t CurBlockNo; - - /**< No. Of Written*/ - uint8_t NoBlocksWritten; - - /**< Following are different variables used for write operation*/ - uint8_t Wr_BytesRemained; /* No of bytes to pad*/ - - /**< Buffer to store odd number of block data */ - uint8_t Wr_RemainedBytesBuff[PH_FRINFC_NDEFMAP_FELICA_BLOCK_SIZE]; - - /**< Following are different variables used for read operation*/ - uint8_t Rd_NoBytesToCopy; /*specifies the extra number of read bytes */ - - /**< stores extra read data bytes*/ - uint8_t Rd_BytesToCopyBuff[PH_FRINFC_NDEFMAP_FELICA_BLOCK_SIZE]; - - /**< Flag determines Intermediate Copy Operation*/ - uint8_t IntermediateCpyFlag; - - /**< Stores Intermediate Copy data len*/ - uint8_t IntermediateCpyLen; - - /**< Flag specifies Pad Byte Information*/ - uint8_t PadByteFlag; - - /**< Flag specifies Intermediate WR Information*/ - uint8_t IntermediateWrFlag; - - /**< Flag specifies Intermediate Rd Information*/ - uint8_t IntermediateRdFlag; - - /**< Flag specifies Last Block Reached Information*/ - uint8_t LastBlkReachedFlag; - - /**< Specifies how many bytes read from the card*/ - uint16_t CurrBytesRead; - - /**< Flag specifies EOF card reached Information*/ - uint8_t EofCardReachedFlag; - - /**< Flag specifies different Operation Types*/ - uint8_t OpFlag; - - /**< Specifies Offset*/ - uint8_t Offset; - - /**< Specifies TrxLen Information*/ - uint16_t TrxLen; - -}phFriNfc_Felica_t; - -/** - * \ingroup grp_fri_nfc_ndef_map - * \brief Felica structure which details the different vaiables - * used to store the poll related information. - * - */ -typedef struct phFriNfc_Felica_PollDetails -{ - phHal_sDevInputParam_t *DevInputParam; -#ifndef PH_HAL4_ENABLE - phHal_eOpModes_t *OpMode; -#endif - /**< Temporary place holder to the Remote Device - Information, required to store the Felica - session opened information. */ - phHal_sRemoteDevInformation_t psTempRemoteDevInfo; -}phFriNfc_Felica_PollDetails_t; - -/** - * \ingroup grp_fri_nfc_ndef_map - * \brief Felica structure which details the attribute related information. - * - */ -typedef struct phFriNfc_Felica_AttrInfo -{ - /** Version of the Ndefmap document*/ - uint8_t Version; - /** Nbr for check cmd*/ - uint8_t Nbr; - /** Nbw for update cmd*/ - uint8_t Nbw; - /** Maximum number of blocks to store Ndef data*/ - uint16_t Nmaxb; - /** Flag to indicate the status of the write operation*/ - uint8_t WriteFlag; - /** Flag to indicate the status of the read/write operation*/ - uint8_t RdWrFlag; - /** Represents the length of Ndef data : 3 bytes*/ - uint8_t LenBytes[PH_FRINFC_NDEFMAP_FELICA_ATTR_NDEF_DATA_LEN]; - /** Specifies the ERASE NDEF Message Operation */ - uint8_t EraseMsgFlag; - -}phFriNfc_Felica_AttrInfo_t; - -/** - * \ingroup grp_fri_nfc_ndef_map - * \brief Felica structure which details the different vaiables - * used to store the Card Manufacturer details. - */ -typedef struct phFriNfc_Felica_ManufDetails -{ - /** Manufacture identifier*/ - uint8_t ManufID[PH_FRINFC_NDEFMAP_FELICA_MANUF_ID_DATA_LEN]; - /** Manufacture Parameters*/ - uint8_t ManufParameter[PH_FRINFC_NDEFMAP_FELICA_MANUF_ID_DATA_LEN]; -}phFriNfc_Felica_ManufDetails_t; -#endif /* PH_FRINFC_MAP_FELICA_DISABLED */ - -#ifndef PH_FRINFC_MAP_MIFARESTD_DISABLED -typedef struct phFriNfc_MifareStdCont -{ - /** Device input parameter for poll and connect after failed authentication */ - phHal_sDevInputParam_t *DevInputParam; - /** to store bytes that will be used in the - next write/read operation, if any */ - uint8_t internalBuf[PH_FRINFC_NDEFMAP_MIFARESTD_ST15_BYTES]; - /** to Store the length of the internalBuf */ - uint16_t internalLength; - /** holds the block number which is presently been used */ - uint8_t currentBlock; - /** the number of Ndef Compliant blocks written/read */ - uint8_t NdefBlocks; - /** Total Number of Ndef Complaint Blocks */ - uint16_t NoOfNdefCompBlocks; - /** used in write ndef, to know that internal bytes - are accessed */ - uint8_t internalBufFlag; - /** used in write ndef, to know that last 16 bytes - are used to write*/ - uint8_t RemainingBufFlag; - /** indicates that Read has reached the end of the - card */ - uint8_t ReadWriteCompleteFlag; - /** indicates that Read has reached the end of the - card */ - uint8_t ReadCompleteFlag; - /** indicates that Write is possible or not */ - uint8_t WriteFlag; - /** indicates that Write is possible or not */ - uint8_t ReadFlag; - /** indicates that Write is possible or not */ - uint8_t RdBeforeWrFlag; - /** Authentication Flag indicating that a particular - sector is authenticated or not */ - uint8_t AuthDone; - /** to store the last Sector ID in Check Ndef */ - uint8_t SectorIndex; - /** to read the access bits of each sector */ - uint8_t ReadAcsBitFlag; - /** Flag to check if Acs bit was written in this call */ - uint8_t WriteAcsBitFlag; - /** Buffer to store 16 bytes */ - uint8_t Buffer[PH_FRINFC_NDEFMAP_MIFARESTD_RDWR_SIZE]; - /** to store the AIDs of Mifare 1k or 4k */ - uint8_t aid[PH_FRINFC_NDEFMAP_MIFARESTD_TOTALNO_BLK]; - /** flag to write with offset begin */ - uint8_t WrNdefFlag; - /** flag to read with offset begin */ - uint8_t ReadNdefFlag; - /** flag to check with offset begin */ - uint8_t ChkNdefFlag; - /** To store the remaining size of the Mifare 1k or 4k card */ - uint16_t remainingSize; - /** To update the remaining size when writing to the Mifare 1k or 4k card */ - uint8_t remSizeUpdFlag; - /** The flag is to know that there is a different AID apart from - NFC forum sector AID */ - uint16_t aidCompleteFlag; - /** The flag is to know that there is a a NFC forum sector exists - in the card */ - uint16_t NFCforumSectFlag; - /** The flag is to know that the particular sector is a proprietary - NFC forum sector */ - uint16_t ProprforumSectFlag; - /** The flag is set after reading the MAD sectors */ - uint16_t ChkNdefCompleteFlag; - /** Flag to store the current block */ - uint8_t TempBlockNo; - /** Completion routine index */ - uint8_t CRIndex; - /** Bytes remaining to write for one write procedure */ - uint16_t WrLength; - /** Flag to read after write */ - uint8_t RdAfterWrFlag; - /** Flag to say that poll is required before write ndef (authentication) */ - uint8_t PollFlag; - /** Flag is to know that this is first time the read has been called. This - is required when read is called after write (especially for the card formatted - with the 2nd configuration) */ - uint8_t FirstReadFlag; - /** Flag is to know that this is first time the write has been called. This - is required when the card formatted with the 3rd configuration */ - uint8_t FirstWriteFlag; - /** Indicates the sector trailor id for which the convert - to read only is currently in progress*/ - uint8_t ReadOnlySectorIndex; - /** Indicates the total number of sectors on the card */ - uint8_t TotalNoSectors; - /** Indicates the block number of the sector trailor on the card */ - uint8_t SectorTrailerBlockNo; - /** Secret key B to given by the application */ - uint8_t UserScrtKeyB[6]; -}phFriNfc_MifareStdCont_t; -/*@}*/ -#endif /* PH_FRINFC_MAP_MIFARESTD_DISABLED */ - -#ifndef PH_FRINFC_MAP_DESFIRE_DISABLED -/** - * \ingroup grp_fri_nfc_ndef_map - * \brief Capability Container. - * - * The Capability Container structure required for smart card operations. - * - */ -typedef struct phFriNfc_DesfireCapCont -{ - uint16_t DesfVersion; /**< \internal Desfire Version . */ - uint16_t NdefMsgFid; /**< \internal Ndef Message file pointer*/ - uint16_t NdefFileSize; /**< \internal Holds Desfire File Size */ - uint8_t ReadAccess; /**< \internal Read Access Information. */ - uint8_t WriteAccess; /**< \internal Write Access Information. */ - uint16_t MaxRespSize; /**< \internal Maximum expected response size. */ - uint16_t MaxCmdSize; /**< \internal Maximum command size. */ - uint16_t NdefDataLen; /**< \internal Holds actual NDEF Data Len.*/ - uint8_t IsNlenPresentFlag; /**< \internal specifies NLEN presence .*/ - uint8_t SkipNlenBytesFlag; /**< \internal sets on presence of NLEN.*/ -} phFriNfc_DesfireCapCont_t; -#endif /* PH_FRINFC_MAP_DESFIRE_DISABLED */ - -#ifndef PH_FRINFC_MAP_MIFAREUL_DISABLED -/** - * \ingroup grp_fri_nfc_ndef_map - * \brief Mifare UL Basic structure which details the different vaiables - * used for Reading/writing. - * - */ -typedef struct phFriNfc_MifareULCont -{ - /** to store bytes that will be used in the - next write/read operation, if any */ - uint8_t InternalBuf[PH_FRINFC_NDEFMAP_MFUL_4BYTES_BUF]; - /** to Store the length of the internalBuf */ - uint16_t InternalLength; - /** holds the sector number which is presently been used */ - uint8_t CurrentSector; - /** holds the block number which is presently been used */ - uint8_t CurrentBlock; - /** to know the completion routine */ - uint8_t CRindex; - /** This stores the free memory size left in the card */ - uint16_t RemainingSize; - /** Copy all the data(including non NDEF TLVs) from the card */ - uint8_t ReadBuf[PH_FRINFC_NDEFMAP_MFUL_64BYTES_BUF]; - /** index of the above buffer */ - uint16_t ReadBufIndex; - /** This variable stores the index of the "ReadBuf" from which actual - data has to be copied into the user buffer */ - uint16_t ByteNumber; - /** indicates that read/write has reached the end of the - card */ - uint8_t ReadWriteCompleteFlag; - /** Buffer to store 4 bytes of data which is written to a block */ - uint8_t Buffer[PH_FRINFC_NDEFMAP_MFUL_4BYTES_BUF]; -}phFriNfc_MifareULCont_t; -#endif /* PH_FRINFC_MAP_MIFAREUL_DISABLED */ - -#ifdef PHFRINFC_OVRHAL_MOCKUP /* */ -/** - * \ingroup grp_fri_nfc_ndef_map - * \brief Mifare UL Basic structure which details the different vaiables - * used for Reading/writing. - * - */ -typedef struct phFriNfc_MockupCont -{ - /** to store bytes that will be used in the - next write/read operation, if any */ - uint8_t *NdefData; - /** to Store the length of the internalBuf */ - uint32_t NdefActualSize; - /** to Store the length of the internalBuf */ - uint32_t NdefMaxSize; - /** to Store the length of the internalBuf */ - uint32_t CardSize; - /** holds the block number which is presently been used */ - uint32_t CurrentBlock; -} phFriNfc_MockupCont_t; -#endif /* PHFRINFC_OVRHAL_MOCKUP */ - -#endif /* PH_FRINFC_EXCLUDE_FROM_TESTFW */ - -/** - * \ingroup grp_fri_nfc_ndef_map - * \brief NDEF TLV structure which details the different vaiables - * used for TLV. - * - */ -typedef struct phFriNfc_NDEFTLVCont -{ - /** Flag is to know that the TLV Type Found */ - uint8_t NdefTLVFoundFlag; - /** Sector number of the next/present available TLV */ - uint8_t NdefTLVSector; - /** Following two variables are used to store the - T byte and the Block number in which the T is - found in Tag */ - /** Byte number of the next/present available TLV */ - uint16_t NdefTLVByte; - /** Block number of the next/present available TLV */ - uint8_t NdefTLVBlock; - /** Authentication flag for NDEF TLV Block */ - uint8_t NdefTLVAuthFlag; - /** if the 16th byte of the last read is type (T) of TLV - and next read contains length (L) bytes of TLV. This flag - is set when the type (T) of TLV is found in the last read */ - uint8_t TcheckedinTLVFlag; - /** if the 16th byte of the last read is Length (L) of TLV - and next read contains length (L) bytes of TLV. This flag - is set when the Length (L) of TLV is found in the last read */ - uint8_t LcheckedinTLVFlag; - /** This flag is set, if Terminator TLV is already written - and next read contains value (V) bytes of TLV. This flag - is set when the value (V) of TLV is found in the last read */ - uint8_t SetTermTLVFlag; - /** To know the number of Length (L) field is present in the - next block */ - uint8_t NoLbytesinTLV; - /** The value of 3 bytes length(L) field in TLV. In 3 bytes - length field, 2 bytes are in one block and other 1 byte - is in the next block. To store the former block length - field value, this variable is used */ - uint16_t prevLenByteValue; - /** The value of length(L) field in TLV. */ - uint16_t BytesRemainLinTLV; - /** Actual size to read and write. This will be always equal to the - length (L) of TLV as there is only one NDEF TLV . */ - uint16_t ActualSize; - /** Flag is to write the length (L) field of the TLV */ - uint8_t WrLenFlag; - /** Flag is to write the length (L) field of the TLV */ - uint16_t NULLTLVCount; - /** Buffer to store 4 bytes of data which is written to a block */ - uint8_t NdefTLVBuffer[PH_FRINFC_NDEFMAP_MFUL_4BYTES_BUF]; - /** Buffer to store 4 bytes of data which is written to a next block */ - uint8_t NdefTLVBuffer1[PH_FRINFC_NDEFMAP_MFUL_4BYTES_BUF]; -}phFriNfc_NDEFTLVCont_t; - -/** - * \ingroup grp_fri_nfc_ndef_map - * \brief Lock Control TLV structure which stores the Position, - * Size and PageCntrl details. - */ - -typedef struct phFriNfc_LockCntrlTLVCont -{ - /** Specifies the Byte Position of the lock cntrl tlv - in the card memory*/ - uint16_t ByteAddr; - - /** Specifies the Size of the lock area in terms of - bits/bytes*/ - uint16_t Size; - - /** Specifies the Bytes per Page*/ - uint8_t BytesPerPage; - - /** Specifies the BytesLockedPerLockBit */ - uint8_t BytesLockedPerLockBit; - - /** Specifies the index of Lock cntrl TLV*/ - uint8_t LockTlvBuffIdx; - - /** Store the content of Lock cntrl TLV*/ - uint8_t LockTlvBuff[8]; - - /** Specifies the Block number Lock cntrl TLV*/ - uint16_t BlkNum; - - /** Specifies the Byte Number position of Lock cntrl TLV*/ - uint16_t ByteNum; - - -}phFriNfc_LockCntrlTLVCont_t; - - -/** - * \ingroup grp_fri_nfc_ndef_map - * \brief Memeory Control TLV structure which stores the Position, - * Size and PageCntrl details of the reserved byte area. - */ - -typedef struct phFriNfc_ResMemCntrlTLVCont -{ - /** Specifies the Byte Position of the lock cntrl tlv - in the card memory*/ - uint16_t ByteAddr; - - /** Specifies the Size of the lock area in terms of - bits/bytes*/ - uint16_t Size; - - /** Store the content of Memory cntrl TLV*/ - uint8_t MemCntrlTlvBuff[8]; - - /** Specifies the Bytes per Page*/ - uint8_t BytesPerPage; - - /** Specifies the index of Mem cntrl TLV*/ - uint8_t MemTlvBuffIdx; - - /** Specifies the Block number Lock cntrl TLV*/ - uint16_t BlkNum; - - /** Specifies the Byte Number position of Lock cntrl TLV*/ - uint16_t ByteNum; - - - -}phFriNfc_ResMemCntrlTLVCont_t; - -#if !(defined(PH_FRINFC_MAP_TOPAZ_DISABLED ) || defined (PH_FRINFC_MAP_TOPAZ_DYNAMIC_DISABLED )) - -/** - * \ingroup grp_fri_nfc_ndef_map - * \brief Topaz container structure which details the different vaiables - * used for Topaz card mapping. - * - */ -typedef struct phFriNfc_TopazCont -{ - /** This stores the free memory size left in the card. In case of topaz, - this is updated only during check ndef */ - uint16_t RemainingSize; - /** Stores the current block number */ - uint8_t CurrentBlock; - /** Stores the current block number */ - uint8_t ByteNumber; - /** To know the completion routine call */ - uint8_t CRIndex; - - uint8_t ReadWriteCompleteFlag; - /** This state is used for write */ - uint8_t InternalState; - /** This state is used for write */ - uint8_t SkipLockBlkFlag; - /** To store the UID */ - uint8_t UID[PH_FRINFC_NDEFMAP_TOPAZ_UID_SIZE]; - /** To CC bytes length */ - uint8_t CCByteBuf[4]; - /** Store the Buffer Index */ - uint16_t Cur_RW_Index; - - /* No of bytes read or write*/ - uint16_t ByteRWFrmCard; - - /* Cuurent Segment */ - uint8_t CurrentSeg; - - /** Store the read bytes */ - uint8_t ReadBuffer[PH_FRINFC_NDEFMAP_TOPAZ_MAX_SIZE]; - - /** Size to know the exact data filled in the ReadBuffer. Useful, when the - offset = PH_FRINFC_NDEFMAP_SEEK_CUR */ - uint8_t ReadBufferSize; - - /** NDEF TLV byte address, This stores the byte address of - TYPE field of the TLV */ - uint16_t NdefTLVByteAddress; - - /** Expected sequence */ - uint8_t ExpectedSeq; - - /** Write sequence */ - uint8_t WriteSeq; - - /** Actual NDEF message size */ - uint16_t ActualNDEFMsgSize; - - /** NDEF Read Write size in the card, this excludes lock and reserved bytes, - mentioned in the LOCK and MEMORY control TLVs */ - uint16_t NDEFRWSize; - - /** Remaining read size in the card, after reading the card. - User has asked for the data less than " ActualNDEFMsgSize ", - then remaining read bytes are stored in this variable. - If the next read is with offset = PH_FRINFC_NDEFMAP_SEEK_CUR, - then this variable is used. - */ - uint16_t RemainingReadSize; -#ifdef FRINFC_READONLY_NDEF - uint8_t read_only_seq; - uint8_t lock_bytes_written; -#endif /* #ifdef FRINFC_READONLY_NDEF */ - -}phFriNfc_TopazCont_t; - -#endif /* PH_FRINFC_MAP_TOPAZ_DISABLED */ -/** - * \ingroup grp_fri_nfc_ndef_map - * \brief NFC NDEF Mapping Component Context Structure - * - * This structure is used to store the current context information of the instance. - * - */ -typedef struct phFriNfc_NdefMap -{ - /**< \internal The state of the operation. */ - uint8_t State; - - /**< \internal Completion Routine Context. */ - phFriNfc_CplRt_t CompletionRoutine[PH_FRINFC_NDEFMAP_CR]; - - /**< \internal Pointer to the lower (HAL) instance. */ - void *LowerDevice; - - /**<\internal Holds the device additional informations*/ - phHal_sDepAdditionalInfo_t psDepAdditionalInfo; - - /**<\internal Holds the completion routine informations of the Map Layer*/ - phFriNfc_CplRt_t MapCompletionInfo; - - /**< \internal Pointer to the Remote Device Information */ - phHal_sRemoteDevInformation_t *psRemoteDevInfo; - - /**<\internal Holds the Command Type(read/write)*/ - phHal_uCmdList_t Cmd; - - /**< \internal Pointer to a temporary buffer. Could be - used for read/write purposes */ - uint8_t *ApduBuffer; - - /**< \internal Size allocated to the ApduBuffer. */ - uint32_t ApduBufferSize; - - /**< \internal Index to the APDU Buffer. Used for internal calculations */ - uint16_t ApduBuffIndex; - - /**< \internal Pointer to the user-provided Data Size to be written trough WrNdef function. */ - uint32_t *WrNdefPacketLength; - - - /**< \internal Holds the length of the received data. */ - uint16_t *SendRecvLength; - - /**<\internal Holds the ack of some intial commands*/ - uint8_t *SendRecvBuf; - - /**< \internal Holds the length of the data to be sent. */ - uint16_t SendLength; - - /**< \internal Data Byte Count, which gives the offset to the integration.*/ - uint16_t *DataCount; - - /**< \ internal Holds the previous operation on the card*/ - uint8_t PrevOperation; - - /**< \ internal Holds the previous state on the card*/ - uint8_t PrevState; - - /**< \internal Stores the type of the smart card. */ - uint8_t CardType; - - /**< \internal Stores the card state. */ - uint8_t CardState; - - /**< \internal Stores the memory size of the card */ - uint16_t CardMemSize; - - /**<\internal to Store the page offset on the mifare ul card*/ - uint8_t Offset; - - /** \internal specifies the desfire operation to be performed*/ - uint8_t DespOpFlag; - - /** \internal Used to remeber how many bytes were written, to update - the dataCount and the BufferIndex */ - uint16_t NumOfBytesWritten; - - /**\internal used to remember number of L byte Remaining to be written */ - uint16_t NumOfLReminWrite; - - /** \internal Pointer Used to remeber and return how many bytes were read, - to update the PacketDataLength in case of Read operation */ - /* Fix for 0000238: [gk] MAP: Number of bytes actually read out is - not returned. */ - uint32_t *NumOfBytesRead; - - /** \internal Flag used to tell the process function that WRITE has - requested for an internal READ.*/ - uint8_t ReadingForWriteOperation; - - /** \internal Buffer of 5 bytes used for the write operation for the - Mifare UL card.*/ - uint8_t BufferForWriteOp[5]; - - /** \internal Temporary Receive Length to update the Receive Length - when every time the Overlapped HAL is called. */ - uint16_t TempReceiveLength; - - uint8_t NoOfDevices ; - - /** \internal stores operating mode type of the felica smart tag */ - /* phHal_eOpModes_t OpModeType[2]; */ - - /** \internal stores the type of the TLV found */ - uint8_t TLVFoundFlag; - - /** \internal stores the TLV structure related informations */ - phFriNfc_NDEFTLVCont_t TLVStruct; - - - /** \internal stores the Lock Contrl Tlv related informations */ - phFriNfc_LockCntrlTLVCont_t LockTlv; - - /** \internal stores the Mem Contrl Tlv related informations */ - phFriNfc_ResMemCntrlTLVCont_t MemTlv; - - - - /** Capabilitity Containers: */ - #ifndef PH_FRINFC_EXCLUDE_FROM_TESTFW /* */ - /** \internal Desfire capability Container Structure. */ -#ifndef PH_FRINFC_MAP_DESFIRE_DISABLED - phFriNfc_DesfireCapCont_t DesfireCapContainer; -#endif /* PH_FRINFC_MAP_DESFIRE_DISABLED */ - -#ifndef PH_FRINFC_MAP_MIFARESTD_DISABLED - /** \internal Pointer to the Mifare Standard capability Container Structure. */ - phFriNfc_MifareStdCont_t StdMifareContainer; -#endif /* PH_FRINFC_MAP_MIFARESTD_DISABLED */ - -#ifndef PH_FRINFC_MAP_FELICA_DISABLED - /** \internal Following are the Felica Smart tag related strucutre & variables */ - phFriNfc_Felica_t Felica; - - /** \internal Struture Stores the dev i/p , opmode informations of smart tag */ - phFriNfc_Felica_PollDetails_t FelicaPollDetails; - - /** \internal Struture Stores the different attribute informations of smart tag */ - phFriNfc_Felica_AttrInfo_t FelicaAttrInfo; - - /** \internal Struture Stores the PMm,IDm informations of smart tag */ - phFriNfc_Felica_ManufDetails_t FelicaManufDetails; -#endif /* PH_FRINFC_MAP_FELICA_DISABLED */ -#ifndef PH_FRINFC_MAP_MIFAREUL_DISABLED - /** \internal Mifare UL capability container structure. */ - phFriNfc_MifareULCont_t MifareULContainer; -#endif /* PH_FRINFC_MAP_MIFAREUL_DISABLED */ -#ifndef PH_FRINFC_MAP_TOPAZ_DISABLED - /** \internal Mifare UL capability container structure. */ - phFriNfc_TopazCont_t TopazContainer; -#endif /* PH_FRINFC_MAP_TOPAZ_DISABLED */ - -#ifndef PH_FRINFC_MAP_ISO15693_DISABLED - phFriNfc_ISO15693Cont_t ISO15693Container; -#endif /* #ifndef PH_FRINFC_MAP_ISO15693_DISABLED */ - -#ifdef PHFRINFC_OVRHAL_MOCKUP - phFriNfc_MockupCont_t MochupContainer; -#endif /* PHFRINFC_OVRHAL_MOCKUP */ - - #endif /* PH_FRINFC_EXCLUDE_FROM_TESTFW */ - -} phFriNfc_NdefMap_t; - - -#ifndef PH_FRINFC_EXCLUDE_FROM_TESTFW /* */ - -/** - * \ingroup grp_fri_nfc_ndef_map - * - * \brief Ndef Mapping \b Reset function - * - * \copydoc page_reg Resets the component instance to the initial state and initialises the - * internal variables. - * - * \param[in] NdefMap is a Pointer to a valid and initialised or uninitialised instance - * of \ref phFriNfc_NdefMap_t . - * \param[in] LowerDevice Overlapped HAL reference, pointing at a valid instance of this - * underlying component. - * \param[in] psRemoteDevInfo Points to the Remote Device Information structure encapsulating - * the information about the device (Smart card, NFC device) to access. - * \param[in] psDevInputParam The Device input parameter, as used for the HAL POLL function. - * This parameter is needed by the component in special cases, when an internal call - * to POLL is required again, such as for FeliCa. The storage of the structure behind - * the pointer must be retained by the calling software. The component itself only - * keeps the reference. No change is applied to the structure's content. - * \param[in] TrxBuffer Pointer to an internally used buffer. The buffer has to be allocated by - * the integrating software (not done by the component). The purpose of - * this storage is to serve as an intermediate buffer for data frame - * composition and analysis. - * The size shall be at least \ref PH_FRINFC_NDEFMAP_MAX_SEND_RECV_BUF_SIZE . - * \param[in] TrxBufferSize The size of TrxBuffer: - * The size shall be at least \ref PH_FRINFC_NDEFMAP_MAX_SEND_RECV_BUF_SIZE . - * \param[in] ReceiveBuffer Pointer to a buffer that the component uses internally use to - * store the data received from the lower component. - * The size shall be at least \ref PH_FRINFC_NDEFMAP_MAX_SEND_RECV_BUF_SIZE . - * \param[in] ReceiveLength The size of ReceiveBuffer. This specifies the actual length - * of the data received from the lower component. - * The size shall be at least \ref PH_FRINFC_NDEFMAP_MAX_SEND_RECV_BUF_SIZE . - * \param[in] DataCount Specifies the offset count during read/write operations. This can be - * used by the integrating software to know about the total number of bytes read/written - * from/to the card. The caller shall set the value behind the pointer to zero - * before calling this function. - * - * \retval NFCSTATUS_SUCCESS Operation successful. - * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. - * - * \note The DataCount variable is internally updated by the module and must not be changed by the - * embedding software. - * \note This function has to be called at the beginning, after creating an instance of - * \ref phFriNfc_NdefMap_t . Use this function to reset the instance and/or to switch - * to a different underlying device (different NFC device or device mode). - */ -NFCSTATUS phFriNfc_NdefMap_Reset(phFriNfc_NdefMap_t *NdefMap, - void *LowerDevice, - phHal_sRemoteDevInformation_t *psRemoteDevInfo, - phHal_sDevInputParam_t *psDevInputParam, - uint8_t *TrxBuffer, - uint16_t TrxBufferSize, - uint8_t *ReceiveBuffer, - uint16_t *ReceiveLength, - uint16_t *DataCount); - - -/** - * \ingroup grp_fri_nfc_ndef_map - * - * \brief Ndef Mapping \b Set \b Completion \b Routine function - * - * \copydoc page_reg Setting of the Completion Routine. - * - * This function sets the Completion Routine for the specified function ID:\n - * The completion routine is a function of an upper layer in the stack that needs to be notified - * when the current instance has completed an I/O operation and data and/or an I/O status value - * is available. The list of valid function IDs can be found under the section - * "Completion Routine Indices", like e.g. \ref PH_FRINFC_NDEFMAP_CR_CHK_NDEF. - * - * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure - * serving as the component context. - * \param[in] FunctionID ID of the component API function to set a with a completion routine for. - * A valid routine has to be assigned for each function ID. - * Use the "Completion Routine Indices", such as \ref PH_FRINFC_NDEFMAP_CR_CHK_NDEF . - * \param[in] CompletionRoutine Pointer to a completion routine (part of a component of the upper layer) - * to be called when the non-blocking opertaion has finished. - * \param[in] CompletionRoutineContext Pointer to the context of the (upper) component where the - * particular completion routine is located. - * - * \retval NFCSTATUS_SUCCESS Operation successful. - * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. - * - * \note This function has to be called after \ref phFriNfc_NdefMap_Reset . - */ -NFCSTATUS phFriNfc_NdefMap_SetCompletionRoutine(phFriNfc_NdefMap_t *NdefMap, - uint8_t FunctionID, - pphFriNfc_Cr_t CompletionRoutine, - void *CompletionRoutineContext); - - -/** - * \ingroup grp_fri_nfc_ndef_map - * - * \brief Ndef Mapping \b Read \b Ndef function - * - * \copydoc page_ovr Initiates Reading of NDEF information from the Remote Device. - * - * The function initiates the reading of NDEF information from a Remote Device. - * It performs a reset of the state and restarts the state machine. - * - * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t - * component context structure. - * \param[in,out] PacketData Pointer to a location that shall receive the NDEF Packet. - * \param[in,out] PacketDataLength Pointer to a variable that shall receive the length of the NDEF packet. - * The caller has to provide the maximum length, the function fills - * in the actual number of bytes received. - * \param[in] Offset Indicates whether the read operation shall start from the begining of the - * file/card storage \b or continue from the last offset. The last Offset set is stored - * within a context (Data Count) variable (must not be modified by the integration). - * If the caller sets the value to \ref PH_FRINFC_NDEFMAP_SEEK_CUR, the component shall - * start reading from the last offset set (continue where it has stopped before). - * If set to \ref PH_FRINFC_NDEFMAP_SEEK_BEGIN, the component shall start reading - * from the begining of the card (restarted) - * - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval NFCSTATUS_SUCCESS Operation Successful. - * - * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. - * \retval NFCSTATUS_INVALID_REMOTE_DEVICE Card Type is unsupported. - * \retval NFCSTATUS_EOF_CARD_REACHED No Space in the File to read. - * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected - * meanwhile. - * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request. - * \retval NFCSTATUS_BUFFER_TOO_SMALL The buffer provided by the caller is too small. - * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period. - * - */ -NFCSTATUS phFriNfc_NdefMap_RdNdef(phFriNfc_NdefMap_t *NdefMap, - uint8_t *PacketData, - uint32_t *PacketDataLength, - uint8_t Offset); - - -/** - * \ingroup grp_fri_nfc_ndef_map - * - * \brief Ndef Mapping \b Check \b Ndef function - * - * \copydoc page_ovr Initiates Writing of NDEF information to the Remote Device. - * - * The function initiates the writing of NDEF information to a Remote Device. - * It performs a reset of the state and starts the action (state machine). - * A periodic call of the \ref phFriNfc_NdefMap_Process has to be done once the action - * has been triggered. - * - * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t - * component context structure. - * \param[in] PacketData Pointer to a location that holds the prepared NDEF Packet. - * \param[in,out] PacketDataLength Pointer to a variable that shall specify the length of the prepared NDEF packet. - * The caller has to provide the length, the function fills - * in the actual number of bytes received. - * \param[in] Offset Indicates whether the write operation shall start from the begining of the - * file/card storage \b or continue from the last offset. The last Offset set is stored - * within a context (Data Count) variable (must not be modified by the integration). - * If the caller sets the value to \ref PH_FRINFC_NDEFMAP_SEEK_CUR, the component shall - * start writing from the last offset set (continue where it has stopped before). - * If set to \ref PH_FRINFC_NDEFMAP_SEEK_BEGIN, the component shall start writing - * from the begining of the card (restarted) - * - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval NFCSTATUS_SUCCESS Operation Successful. - * - * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. - * \retval NFCSTATUS_INVALID_REMOTE_DEVICE Card Type is unsupported. - * \retval NFCSTATUS_EOF_CARD_REACHED No Space in the File to write. - * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected - * meanwhile. - * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request. - * \retval NFCSTATUS_BUFFER_TOO_SMALL The buffer provided by the caller is too small. - * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period. - * - */ - -extern NFCSTATUS phFriNfc_NdefMap_WrNdef(phFriNfc_NdefMap_t *NdefMap, - uint8_t *PacketData, - uint32_t *PacketDataLength, - uint8_t Offset); - - -/** - * \ingroup grp_fri_nfc_ndef_map - * - * \brief Ndef Mapping \b Check \b NDEF function - * - * \copydoc page_ovr Check whether a particular Remote Device is NDEF compliant. - * - * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t - * component context structure. - * - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. - * \retval NFCSTATUS_INVALID_REMOTE_DEVICE Card Type is unsupported. - * \retval NFCSTATUS_INVALID_PARAMETER Completion Routine is NULL. - * \retval NFCSTATUS_INVALID_REMOTE_DEVICE OpModes invalid. - * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected - * meanwhile. - * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request. - * \retval NFCSTATUS_BUFFER_TOO_SMALL The buffer provided by the caller is too small. - * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period. - * - */ -NFCSTATUS phFriNfc_NdefMap_ChkNdef(phFriNfc_NdefMap_t *NdefMap); - -#ifdef FRINFC_READONLY_NDEF -/*! - * \ingroup grp_fri_smart_card_formatting - * - * \brief Initiates the conversion of the already NDEF formatted tag to READ ONLY. - * - * \copydoc page_ovr The function initiates the conversion of the already NDEF formatted - * tag to READ ONLY.After this formation, remote card would be properly Ndef Compliant and READ ONLY. - * Depending upon the different card type, this function handles formatting procedure. - * This function supports only for the TOPAZ tags. - * - * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing - * the component context. - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval Other values An error has occurred. - * - */ -NFCSTATUS -phFriNfc_NdefMap_ConvertToReadOnly ( - phFriNfc_NdefMap_t *NdefMap); - -#endif /* #ifdef FRINFC_READONLY_NDEF */ - -/** - * \ingroup grp_fri_nfc_ndef_map - * - * \brief Ndef Mapping \b Erase \b NDEF function - * - * \copydoc page_ovr find the position of the existing NDEF TLV and overwrite with \b empty NDEF - * message \b at that position. - * - * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t - * component context structure. - * - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. - * \retval NFCSTATUS_INVALID_REMOTE_DEVICE Card Type is unsupported. - * \retval NFCSTATUS_INVALID_PARAMETER Completion Routine is NULL. - * \retval NFCSTATUS_INVALID_REMOTE_DEVICE OpModes invalid. - * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected - * meanwhile. - * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request. - * \retval NFCSTATUS_BUFFER_TOO_SMALL The buffer provided by the caller is too small. - * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period. - * - */ -NFCSTATUS phFriNfc_NdefMap_EraseNdef(phFriNfc_NdefMap_t *NdefMap); - -/** - * \ingroup grp_fri_nfc_ndef_map - * - * \brief Ndef Mapping \b Get Container size function - * - * \copydoc page_ovr Returns the size of the NDEF data that the card can hold to the caller. - * - * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t - * component context structure. - * - * \param[out] size Pointer to a uint32_t variable, which receives the size of the NDEF data - * - * \retval NFCSTATUS_SUCCESS The size has been successfully calculated. - * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. - * \retval NFCSTATUS_INVALID_REMOTE_DEVICE Card Type is unsupported. - * - */ - -NFCSTATUS phFriNfc_NdefMap_GetContainerSize(const phFriNfc_NdefMap_t *NdefMap,uint32_t *maxSize, uint32_t *actualSize); - -/** - * \ingroup grp_fri_nfc_ndef_map - * - * \brief Ndef Mapping \b Completion \b Routine or \b Process function - * - * \copydoc page_cb Completion Routine: This function is called by the lower layer (OVR HAL) - * when an I/O operation has finished. The internal state machine decides - * whether to call into the lower device again or to complete the process - * by calling into the upper layer's completion routine, stored within this - * component's context (\ref phFriNfc_NdefMap_t). - * - * The function call scheme is according to \ref grp_interact. No State reset is performed during - * operation. - * - * \param[in] Context The context of the current (not the lower/upper) instance, as set by the lower, - * calling layer, upon its completion. - * \param[in] Status The completion status of the lower layer (to be handled by the implementation of - * the state machine of this function like a regular return value of an internally - * called function). - * - * \note For general information about the completion routine interface please see \ref pphFriNfc_Cr_t . * The Different Status Values are as follows - * - */ -void phFriNfc_NdefMap_Process(void *Context, - NFCSTATUS Status); - - - -/** - * \ingroup grp_fri_nfc_ndef_map - * - * \brief Ndef Mapping \b Check And Parse TLV Structure \b NDEF function - * - * \copydoc page_ovr Checks the presence of a valid TLV's(NDEF/Propritery). - * - * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t - * component context structure. - * - * \retval NFCSTATUS_INVALID_FORMAT No valid TLV Found. - * \retval NFCSTATUS_SUCCESS Operation Successful. - * - */ -NFCSTATUS phFriNfc_ChkAndParseTLV(phFriNfc_NdefMap_t *NdefMap); - - -#ifdef PHFRINFC_OVRHAL_MOCKUP /* */ - -/** - * \ingroup grp_fri_nfc_ndef_map - * - * \brief Set data NDEF in mockup mode - * - * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t component context structure. - * \param[in] NdefData Pointer to card mockup data - * \param[in] NdefActualSize The actual data length - * \param[in] NdefMaxSize The max data length - * \param[in] NdefCardSize The total card size - * - * \retval NFCSTATUS_SUCCESS The operation is ok. - * - */ -NFCSTATUS phFriNfc_NdefMap_MockupCardSetter(phFriNfc_NdefMap_t *NdefMap, uint8_t *NdefData, uint32_t NdefActualSize, uint32_t NdefMaxSize, uint32_t CardSize); -NFCSTATUS phFriNfc_NdefMap_MockupNDefModeEn(uint8_t *pNdefCompliancy, uint8_t *pCardType, uint8_t Enable); -#endif /*#ifndef PH_FRINFC_MAP_MOCKUP_DISABLED*/ - - -/** - * \internal - * \name States of the FSM. - * - */ -/*@{*/ -#define PH_FRINFC_NDEFMAP_STATE_RESET_INIT 0 /**< \internal Initial state */ -#define PH_FRINFC_NDEFMAP_STATE_CR_REGISTERED 1 /**< \internal CR has been registered */ -#define PH_FRINFC_NDEFMAP_STATE_EOF_CARD 2 /**< \internal EOF card reached */ -/*@}*/ - -/* Following values specify the previous operation on the card. This value is assigned to - the context structure variable: PrevOperation. */ - -/**< Previous operation is check*/ -#define PH_FRINFC_NDEFMAP_CHECK_OPE 1 -/**< Previous operation is read*/ -#define PH_FRINFC_NDEFMAP_READ_OPE 2 -/**< Previous operation is write */ -#define PH_FRINFC_NDEFMAP_WRITE_OPE 3 -/**< Previous operation is Actual size */ -#define PH_FRINFC_NDEFMAP_GET_ACTSIZE_OPE 4 - -/* This flag is set when there is a need of write operation on the odd positions - ex: 35,5 etc. This is used with MfUlOp Flag */ -#define PH_FRINFC_MFUL_INTERNAL_READ 3 /**< \internal Read/Write control*/ - - -#endif /* PH_FRINFC_EXCLUDE_FROM_TESTFW */ - -#endif /* PHFRINFC_NDEFMAP_H */ diff --git a/libnfc-nxp/phFriNfc_NdefRecord.h b/libnfc-nxp/phFriNfc_NdefRecord.h deleted file mode 100644 index b537c41..0000000 --- a/libnfc-nxp/phFriNfc_NdefRecord.h +++ /dev/null @@ -1,513 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * \file phFriNfc_NdefRecord.h - * \brief NFC Ndef Record component header file. - * - * Project: NFC-FRI - * - * $Date: Wed Jun 17 14:17:53 2009 $ - * $Author: ing01697 $ - * $Revision: 1.6 $ - * $Aliases: NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ - * - */ - -#ifndef PHFRINFC_NDEFRECORD_H -#define PHFRINFC_NDEFRECORD_H - -#ifndef PH_FRINFC_EXCLUDE_FROM_TESTFW /* */ - -/** - * \name NDEF Record Tools Header - * - * File: \ref phFriNfc_NdefRecord.h - * - */ -/*@{*/ -#define PHFRINFC_NDEFRECORD_FILEREVISION "$Revision: 1.6 $" /**< \ingroup grp_file_attributes */ -#define PHFRINFC_NDEFRECORD_FILEALIASES "$Aliases: NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ -/*@}*/ - -#endif /* PH_FRINFC_EXCLUDE_FROM_TESTFW */ - -#include -#include -/* Mantis 0000214 - Platform and language dependency found in some files */ -/* To Fix: 0000358: phFriNfc_NdefRecord.h: includes should be moved */ -/* stdlib.h and string.h - header file inclusion removed */ - -/** - * This component implements Ndef Message composing and processing routines. - * - * The Ndef Record is a data structure used by NFC Forum compliant devices for data transfer. - * \n\n - * The capabilities of this module are: - * \li Interprete a given buffer by listing the embedded NDEF records - * \li Extract a Ndef record from a given buffer - * \li Compose a NDEF record and optionally append it to an existing buffer/message - * - */ -/*@{*/ - -/** - * \brief The TNF specifies the structure of the NDEF Record TYPE field. - * - * \name NDEF Record Type Name Format - * - */ -/*@{*/ -#define PH_FRINFC_NDEFRECORD_TNF_EMPTY ((uint8_t)0x00) /**< Empty Record, no type, ID or payload present. */ -#define PH_FRINFC_NDEFRECORD_TNF_NFCWELLKNOWN ((uint8_t)0x01) /**< NFC well-known type (RTD). */ -#define PH_FRINFC_NDEFRECORD_TNF_MEDIATYPE ((uint8_t)0x02) /**< Media Type. */ -#define PH_FRINFC_NDEFRECORD_TNF_ABSURI ((uint8_t)0x03) /**< Absolute URI. */ -#define PH_FRINFC_NDEFRECORD_TNF_NFCEXT ((uint8_t)0x04) /**< Nfc Extenal Type (following the RTD format). */ -#define PH_FRINFC_NDEFRECORD_TNF_UNKNOWN ((uint8_t)0x05) /**< Unknown type; Contains no Type information. */ -#define PH_FRINFC_NDEFRECORD_TNF_UNCHANGED ((uint8_t)0x06) /**< Unchanged: Used for Chunked Records. */ -#define PH_FRINFC_NDEFRECORD_TNF_RESERVED ((uint8_t)0x07) /**< RFU, must not be used. */ -/*@}*/ - - -/** - * \brief These are the flags specifying the content, structure or purpose of a NDEF Record. - * \name NDEF Record Header Flags - * - * Flags of the first record byte, as defined by the NDEF specification. - * - */ -/*@{*/ -#define PH_FRINFC_NDEFRECORD_FLAGS_MB ((uint8_t)0x80) /**< This marks the begin of a NDEF Message. */ -#define PH_FRINFC_NDEFRECORD_FLAGS_ME ((uint8_t)0x40) /**< Set if the record is at the Message End. */ -#define PH_FRINFC_NDEFRECORD_FLAGS_CF ((uint8_t)0x20) /**< Chunk Flag: The record is a record chunk only. */ -#define PH_FRINFC_NDEFRECORD_FLAGS_SR ((uint8_t)0x10) /**< Short Record: Payload Length is encoded in ONE byte only. */ -#define PH_FRINFC_NDEFRECORD_FLAGS_IL ((uint8_t)0x08) /**< The ID Length Field is present. */ -/*@}*/ - -/* Internal: - * NDEF Record #defines for constant value - */ -#define PHFRINFCNDEFRECORD_CHUNKBIT_SET 1 /** \internal Chunk Bit is set. */ -#define PHFRINFCNDEFRECORD_CHUNKBIT_SET_ZERO 0 /** \internal Chunk Bit is not set. */ -#define PHNFCSTSHL16 16 /** \internal Shift 16 bits(left or right). */ -#define PHNFCSTSHL24 24 /** \internal Shift 24 bits(left or right). */ -#define PHFRINFCNDEFRECORD_NORMAL_RECORD_BYTE 4 /** \internal Normal record. */ -#define PH_FRINFC_NDEFRECORD_TNFBYTE_MASK ((uint8_t)0x07) /** \internal For masking */ -#define PH_FRINFC_NDEFRECORD_BUF_INC1 1 /** \internal Increment Buffer Address by 1 */ -#define PH_FRINFC_NDEFRECORD_BUF_INC2 2 /** \internal Increment Buffer Address by 2 */ -#define PH_FRINFC_NDEFRECORD_BUF_INC3 3 /** \internal Increment Buffer Address by 3 */ -#define PH_FRINFC_NDEFRECORD_BUF_INC4 4 /** \internal Increment Buffer Address by 4 */ -#define PH_FRINFC_NDEFRECORD_BUF_INC5 5 /** \internal Increment Buffer Address by 5 */ -#define PH_FRINFC_NDEFRECORD_BUF_TNF_VALUE ((uint8_t)0x00) /** \internal If TNF = Empty, Unknown and Unchanged, the id, type and payload length is ZERO */ -#define PH_FRINFC_NDEFRECORD_FLAG_MASK ((uint8_t)0xF8) /** \internal To Mask the Flag Byte */ - - - -/** - *\ingroup grp_lib_nfc - *\brief NFC NDEF Record structure definition. - * - *The NDEF Record Compound used for: - *\li \b Extraction: The calling function(-ality) receives the NDEF data of an extracted - * record in this structure. - *\li \b Composition The caller is required to specify the data to write within this structure - * in order to have it serialized into a new NDEF record. - * The structure offers a user-friendly way to accomplish this. - */ -typedef struct phFriNfc_NdefRecord -{ - /** - * The flags control (or inform about) the structure of a record. - * - * \li \b Extraction: The component fills in the flags, extracted from the NDEF record. - * \li \b Composition: The caller has to specify the proper flags (OR'ing of the individual - * flag definitions (such as \ref PH_FRINFC_NDEFRECORD_FLAGS_MB). This - * information goes into the generated (composed) record. The caller - * is responsible for applying the correct flags in order to mark the - * begin or end of a message or other conditions. - */ - uint8_t Flags; - - /** - * The Type Name Format, according to the NDEF specification, e.g. \ref PH_FRINFC_NDEFRECORD_TNF_NFCWELLKNOWN . - * - * \li \b Extraction: The component fills the TNF value, extracted from the NDEF record. - * \li \b Composition: The caller needs to specify the TNF according to the definitions in the - * NDEF specification. - */ - uint8_t Tnf; - - /** - * The length of the Type field. See \ref phFriNfc_NdefRecord_t::Tnf and - * \ref phFriNfc_NdefRecord_t::Type . - * - * \li \b Extraction: If the TNF indicates that a type field is present this - * member contains its length. Otherwise the length is set - * to zero by the library. - * \li \b Composition: If the caller specifies via TNF that a Type field is present - * the length of the Type has to be specified in this member. - * Otherwise, this member is ignored by the library. - */ - uint8_t TypeLength; - - /** - * Contained record type: This is a buffer holding the Type - * as defined in the NDEF specification of the NFC Forum. - * No zero-termination is present, the length is determined by - * \ref phFriNfc_NdefRecord_t::TypeLength . - * - * \li \b Extraction: If the record holds a type (see TNF) the function sets the pointer to the - * beginning of the Type field of the record. Otherwise, if no type is present - * this member is set to NULL by the library. - * \li \b Composition: The caller has to specify a pointer to a buffer holding the record type. If the - * caller specifies that the record is without type (TNF) this member is ignored - * by the library. - */ - uint8_t *Type; - - /** - * The length of the ID field. See \ref phFriNfc_NdefRecord_t::Flags . - * - * \li \b Extraction: If the IL flag indicates that an ID field is present this - * member contains its length. Otherwise the length is set - * to zero by the library. - * \li \b Composition: If the caller specifies via IL that an ID field is present - * the length of the ID has to be specified in this member. - * Otherwise, this member is ignored by the library. - */ - uint8_t IdLength; - - /** - * Record ID: This is a buffer holding the ID - * as written in the NDEF specification of the NFC Forum. - * No zero-termination is present, the length is determined by - * \ref phFriNfc_NdefRecord_t::IdLength . - * - * \li \b Extraction: If the record holds an ID (IL Flag) the function sets the pointer to the - * beginning of the ID field of the record. Otherwise, if no ID is present - * this member is set to NULL by the library. - * \li \b Composition: The caller has to specify a pointer to a buffer holding the record ID. If the - * caller specifies that the record is without ID (IL Flag) this member is ignored - * by the library. - */ - uint8_t *Id; - - - /** - * The length of the Payload, in bytes. The maximum length is 2^32 - 1. - * - * \li \b Extraction: The value is set by the function. In case that the extraction encounters - * an error, this member is set to zero. - * \li \b Composition: The value must be different from ZERO and and less than 2^32 and has to be - * provided by the caller. - */ - uint32_t PayloadLength; - - /** - * Payload Data, pointer to a buffer containing the payload data. - * - * \li \b Extraction: The pointer is set to the beginning of the payload. - * No pre-set is required before the extraction function call. - * \li \b Composition: The referenced data is copied to buffer where the library composes the record. - * The pointer is provided by the caller and must not be NULL and valid. - */ - uint8_t *PayloadData; - -} phFriNfc_NdefRecord_t; - - -#ifndef PH_FRINFC_EXCLUDE_FROM_TESTFW /* */ - - - /** - *\ingroup grp_lib_nfc - *\brief NDEF Record \b Get \b Records function. - * - * - * Get a list of NDEF records from the raw data as provided by the caller. This data is a - * buffer holding one or more NDEF records within a NDEF message (received from a NFC peer - * device, for example). The function returns the NumberOfRawRecords present in the message - * with pointers to the records stored in the array RawRecords. The function also tells - * whether a record is chunked. - * - * \param[in] Buffer The data buffer holding the NDEF Message, as provided - * by the caller. - * \param[in] BufferLength The data length, as provided by the caller. - * \param[in,out] RawRecords Array of pointers, receiving the references to the found - * Ndef Records in the given Message. The caller has to provide the - * array of pointers. The array is filled with valid pointers - * up to the number of records found or the array size if the - * number of found records exceeds the size.\n - * If this parameter is set to NULL by the caller it is ignored. - * \param[in,out] IsChunked This array of booleans indicates whether a record has the - * CHUNKED flag set (is a partial record). - * The number of caller-provided array positions has to be the same - * as "NumberOfRawRecords". - * If the caller sets this parameter to NULL it is ignored. - * \param[in,out] NumberOfRawRecords Length of the RawRecords array and IsChunked list. - * The value is set by the extracting function to the actual number - * of records found in the data. If the user specifies 0 (zero) - * the function only yields the number of records without filling - * in pointers.\n The value NULL is invalid. - * - * \retval NFCSTATUS_SUCCESS Operation successful. - * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. - * \retval NFCSTATUS_INVALID_FORMAT This error is returned in the following scenarios - * - *
1. There is no Message Begin (MB) Bit in the Message. - *
2. Type Name Format (TNF) Bits are set to 0x07 (Reserved) - * which is reserved and has not to be used. - *
3. MB Bit is set to 1 and TNF bits are set to 0x06 (unchanged). - *
4. MB Bit is set to 1 and TNF bits are not set to 0x05 or 0x00 (unknown or Empty). However,Type Length equals 0. - *
5. Message End Bit is set to 1 and Chunked Flag(CF)is set to 1 in the same record. - *
6. Not a First Record, either the MB Bit OR the CF bit is set to 1. IDLength (IL) Bit is set to 1 and TNF bits are set to 0x06 (Unchanged). - *
7. Not a First Record, the CF Bit of previous record is set to 1 and TNF bits are not set to 0x06 (unchanged) OR\n The CF Bit of the previous record is not set to 1 and TNF bits are not set to 0x06 (unchanged). - *
8. Check for Last Chunk, CF Bit of previous record is set to 1 and CF Bit of present record is set to 0, but Type Length or ID Length is not equal to zero. - *
9. Inconsistency between the calculated length of the message and the length provided by the caller.or if TNF bits are set to 0x00 or 0x05 or 0x06 (Empty,Unknown and Unchanged), but Type Length is not equal to zero - *
10.TNF bits are set to 0x00 (Empty), but Payload Length is not equal to zero. - *
11.TNF bits are set to 0x00 (Empty),but ID Length is not equal to zero. - * - * \note The correct number of found records is returned by the function also in case that: - * - The "RawRecords" array is too short to hold all values: It is filled up to the allowed maximum. - * - The "RawRecords" array is NULL: Only the number is returned. - * - The "NumberOfRawRecords" parameter is zero: The array is not filled, just the number is returned. - * . - * This can be used for targeted memory allocation: Specify NULL for "RawRecords" and/or - * zero for "NumberOfRawRecords" and the function just yields the correct array size to allocate - * for a second call. - * \note \b Security: This function verifies the given NDEF message buffer integrity. Its purpose is to - * initially check incoming data and taking this effort away from \ref phFriNfc_NdefRecord_Parse. - * It is a strong requirement for \ref phFriNfc_NdefRecord_GetRecords to be called to check incoming data - * before it is handed over to further processing stages. - * - *\msc - *LibNfcClient,LibNfc; - *--- [label="Tag discovered and tag found to be NDEF compliant "]; - *LibNfcClient=>LibNfc [label="phLibNfc_Ndef_Read()",URL="\ref phLibNfc_Ndef_Read"]; - *LibNfcClient<LibNfc [label="phFriNfc_NdefRecord_GetRecords(pBuffer,BufferLength,NULL,)",URL="\ref phFriNfc_NdefRecord_GetRecords"]; - *LibNfcClient<LibNfc [label="phFriNfc_NdefRecord_GetRecords()",URL="\ref phFriNfc_NdefRecord_GetRecords"]; - *LibNfcClient<NDEF Record \b Parse function - * - * - * Extract a specific NDEF record from the data, provided by the caller. The data is a buffer holding - * at least the entire NDEF record (received via the NFC link, for example). - * - * \param[out] Record The NDEF record structure. The storage for the structure has to - * be provided by the caller matching the requirements for \b Extraction, - * as described in the compound documentation. It is important to note - * that all the pointers inside the extracted record structure direct - * to the \b original buffer and not to a copy (see notes) after extraction. - * \param[in] RawRecord The Pointer to the record location, selected out of the records array, - * returned by the \ref phFriNfc_NdefRecord_GetRecords function. - * - * \retval NFCSTATUS_SUCCESS Operation successful. - * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. - * \retval NFCSTATUS_INVALID_FORMAT This error is returned in the following scenarios - *
1. Type Name Format (TNF) Bits are set to 0x07 (Reserved) which is reserved and has not to be used. - *
2. TNF bits are set to 0x00 or 0x05 or 0x06 (Empty,Unknown and Unchanged), but Type Length is not - * equal to 0. - *
3. TNF bits are set to 0x00 (Empty),but Payload Length is not equal to 0. - *
4. TNF bits are set to 0x00 (Empty),but ID Length is not equal to 0. - * - * \note There are some caveats: - * \li The "RawRecord" Data buffer must exist at least as long as the function execution time - * plus the time needed by the caller to evaluate the extracted information. No copying of - * the contained data is done internally. - * \li \b Security: It is not allowed to feed an unchecked NDEF message into the RawRecord - * parameter of the function in an attempt to extract just the first record. The - * rule is always to use \ref phFriNfc_NdefRecord_GetRecords in order to retrieve the - * verified pointers to the individual records within a raw message. A violation of this - * rule leads to the loss of buffer boundary overflow protection. - * - *\msc - *LibNfcClient,LibNfc; - *--- [label="Tag discovered and tag found to be NDEF compliant "]; - *LibNfcClient=>LibNfc [label="phLibNfc_Ndef_Read()",URL="\ref phLibNfc_Ndef_Read"]; - *LibNfcClient<LibNfc [label="phFriNfc_NdefRecord_GetRecords(pBuffer,BufferLength,NULL,)",URL="\ref phFriNfc_NdefRecord_GetRecords "]; - *LibNfcClient<LibNfc [label="phFriNfc_NdefRecord_GetRecords()",URL="\ref phFriNfc_NdefRecord_GetRecords "]; - *LibNfcClient<LibNfc [label="phFriNfc_NdefRecord_Parse(pRawRecords[i],pRawRecord)",URL="\ref phFriNfc_NdefRecord_Parse "]; - *LibNfcClient<NDEF Record \b Generate function - * - * The function writes one NDEF record to a specified memory location. Called within a loop, it is - * possible to write more records into a contiguous buffer, in each cycle advancing by the number - * of bytes written for each record. - * - * \param[in] Record The NDEF record structure to append. The structure - * has to be initialized by the caller matching the requirements for - * \b Composition, as described in the documentation of - * the \ref phFriNfc_NdefRecord_t "NDEF Record" structure. - * \param[in] Buffer The pointer to the buffer to which the record shall be written. - * \param[in] MaxBufferSize The data buffer's (remaining) maximum size, provided by the caller. - * This must be the \b actual number of bytes that can be written into - * the buffer. The user must update this value for each call. - * \param[out] BytesWritten The actual number of bytes written to the buffer during the recent call. - * This can be used by the caller to serialize more than one record - * into the same buffer (composing a NDEF message). - * - * \retval NFCSTATUS_SUCCESS Operation successful. - * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. - * \retval NFCSTATUS_BUFFER_TOO_SMALL The data buffer, provided by the caller is to small to - * hold the composed NDEF record. The existing content is - * not changed, no data have been written. - * - * \note The Caller of this function must take care that, with each call, the parameters are - * updated correctly: - * \li MaxBufferSize must decreased by the previous call number of \b BytesWritten - * \li Pointer to Buffer is advanced by the previous call number of \b BytesWritten. - * - *\msc - *LibNfcClient,LibNfc; - *--- [label="Tag discovered and tag found to be NDEF compliant "]; - *--- [label="Create NDEF raw buffer based of NDEF record details"]; - *LibNfcClient=>LibNfc [label="phFriNfc_NdefRecord_Generate()",URL="\ref phFriNfc_NdefRecord_Generate "]; - *LibNfcClient<LibNfc [label="phLibNfc_Ndef_Write()",URL="\ref phLibNfc_Ndef_Write "]; - *LibNfcClient<This is not a user API. This should not be exposed in the SDK. - */ -uint32_t phFriNfc_NdefRecord_GetLength(phFriNfc_NdefRecord_t* pRecord); - -/** \internal - * - * This is a sub function to the Generate Function. This function will get bit fields of the Flags Byte - * and returns the Status Flag. No Error Checks done here. - * - * \note This is not a user API. This should not be exposed in the SDK. - */ - static uint8_t phFriNfc_NdefRecord_NdefFlag(uint8_t Flags,uint8_t Mask); - -/** \internal - * - * This is a sub function to the Parse Function. This function will get only flag bits in a Packet - * and omit the Type Name Format bits. No Error Checks done here. - * - * \note This is not a user API. This should not be exposed in the SDK. - */ - static uint8_t phFriNfc_NdefRecord_RecordFlag ( uint8_t* pRecord); - -/** \internal - * - * This is a sub function to the Parse Function. This function will get only Type Name Format bits in a Packet - * and omit the other Flags bits. No Error Checks done here. - * - * \note This is not a user API. This should not be exposed in the SDK. - */ - static uint8_t phFriNfc_NdefRecord_TypeNameFormat ( uint8_t* pRecord); - -/** \internal - * - * This function is a sub function of both Get Records and Parse function. This function extracts the - * Type Length, Payload Length and ID Length for the respective Type, Payload and ID Data. - * - * \param[in] Record The data buffer holding the NDEF Message, as provided by the caller. - * \param[out] TypeLength Length of the Type Data. - * \param[out] TypeLengthByte Number of Bytes required to store Type Length. - * \param[out] PayloadLengthByte Number of Bytes required to store Payload Length depends on Short and - * Normal Record. - * \param[out] PayloadLength Length of the Payload Data. - * \param[out] IDLengthByte Number of Bytes required to store ID Length. - * \param[out] IDLength Length of the ID Data. - * - * \note This is not a user API. This should not be exposed in the SDK. - * - */ -static NFCSTATUS phFriNfc_NdefRecord_RecordIDCheck (uint8_t* pRecord, - uint8_t* pTypeLength, - uint8_t* pTypeLengthByte, - uint8_t* pPayloadLengthByte, - uint32_t* pPayloadLength, - uint8_t* pIDLengthByte, - uint8_t* pIDLength - ); -/** \internal - * - * This is a sub function to the Parse Function. This function will get only Type Name Format bits in a Packet - * and omit the other Flags bits. No Error Checks done here. - * - * \note This is not a user API. This should not be exposed in the SDK. - * \param[in] s1 String to compare. - * \param[out] s2 String to compare. - * \param[out] count Number of characters to compare. - */ - -int16_t phFriNfc_NdefReg_Strnicmp(const int8_t *s1, const int8_t *s2, uint32_t count); - -/*@}*/ /* defgroup */ - -#endif /* PH_FRINFC_EXCLUDE_FROM_TESTFW */ - -#endif /* PHFRINFC_NDEFRECORD_H */ - diff --git a/libnfc-nxp/phFriNfc_NdefReg.h b/libnfc-nxp/phFriNfc_NdefReg.h deleted file mode 100644 index 5a4b86d..0000000 --- a/libnfc-nxp/phFriNfc_NdefReg.h +++ /dev/null @@ -1,456 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * \file phFriNfc_NdefReg.h - * \brief NFC Ndef Registration / Listening. - * - * Project: NFC-FRI - * - * $Date: Fri Oct 5 10:10:07 2007 $ - * $Author: frq05303 $ - * $Revision: 1.1 $ - * $Aliases: NFC_FRI1.1_WK826_PREP1,NFC_FRI1.1_WK826_R1,NFC_FRI1.1_WK826_R2,NFC_FRI1.1_WK830_PREP1,NFC_FRI1.1_WK830_PREP2,NFC_FRI1.1_WK830_R5_1,NFC_FRI1.1_WK830_R5_2,NFC_FRI1.1_WK830_R5_3,NFC_FRI1.1_WK832_PREP1,NFC_FRI1.1_WK832_PRE2,NFC_FRI1.1_WK832_PREP2,NFC_FRI1.1_WK832_PREP3,NFC_FRI1.1_WK832_R5_1,NFC_FRI1.1_WK832_R6_1,NFC_FRI1.1_WK834_PREP1,NFC_FRI1.1_WK834_PREP2,NFC_FRI1.1_WK834_R7_1,NFC_FRI1.1_WK836_PREP1,NFC_FRI1.1_WK836_R8_1,NFC_FRI1.1_WK838_PREP1,NFC_FRI1.1_WK838_R9_PREP2,NFC_FRI1.1_WK838_R9_1,NFC_FRI1.1_WK840_R10_PREP1,NFC_FRI1.1_WK840_R10_1,NFC_FRI1.1_WK842_R11_PREP1,NFC_FRI1.1_WK842_R11_PREP2,NFC_FRI1.1_WK842_R11_1,NFC_FRI1.1_WK844_PREP1,NFC_FRI1.1_WK844_R12_1,NFC_FRI1.1_WK846_PREP1,NFC_FRI1.1_WK846_R13_1,NFC_FRI1.1_WK848_PREP1,NFC_FRI1.1_WK848_R14_1,NFC_FRI1.1_WK850_PACK1,NFC_FRI1.1_WK851_PREP1,NFC_FRI1.1_WK850_R15_1,NFC_FRI1.1_WK902_PREP1,NFC_FRI1.1_WK902_R16_1,NFC_FRI1.1_WK904_PREP1,NFC_FRI1.1_WK904_R17_1,NFC_FRI1.1_WK906_R18_1,NFC_FRI1.1_WK908_PREP1,NFC_FRI1.1_WK908_R19_1,NFC_FRI1.1_WK910_PREP1,NFC_FRI1.1_WK910_R20_1,NFC_FRI1.1_WK912_PREP1,NFC_FRI1.1_WK912_R21_1,NFC_FRI1.1_WK914_PREP1,NFC_FRI1.1_WK914_R22_1,NFC_FRI1.1_WK914_R22_2,NFC_FRI1.1_WK916_R23_1,NFC_FRI1.1_WK918_R24_1,NFC_FRI1.1_WK920_PREP1,NFC_FRI1.1_WK920_R25_1,NFC_FRI1.1_WK922_PREP1,NFC_FRI1.1_WK922_R26_1,NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ - * - */ - -#ifndef PHFRINFC_NDEFREG_H -#define PHFRINFC_NDEFREG_H - -#ifndef PH_FRINFC_EXCLUDE_FROM_TESTFW /* */ - -/** - * \name NDEF Registry and Listening - * - */ -/*@{*/ -#define PH_FRINFC_NDEFREG_FILEREVISION "$Revision: 1.1 $" /** \ingroup grp_file_attributes */ -#define PH_FRINFC_NDEFREG_FILEALIASES "$Aliases: NFC_FRI1.1_WK826_PREP1,NFC_FRI1.1_WK826_R1,NFC_FRI1.1_WK826_R2,NFC_FRI1.1_WK830_PREP1,NFC_FRI1.1_WK830_PREP2,NFC_FRI1.1_WK830_R5_1,NFC_FRI1.1_WK830_R5_2,NFC_FRI1.1_WK830_R5_3,NFC_FRI1.1_WK832_PREP1,NFC_FRI1.1_WK832_PRE2,NFC_FRI1.1_WK832_PREP2,NFC_FRI1.1_WK832_PREP3,NFC_FRI1.1_WK832_R5_1,NFC_FRI1.1_WK832_R6_1,NFC_FRI1.1_WK834_PREP1,NFC_FRI1.1_WK834_PREP2,NFC_FRI1.1_WK834_R7_1,NFC_FRI1.1_WK836_PREP1,NFC_FRI1.1_WK836_R8_1,NFC_FRI1.1_WK838_PREP1,NFC_FRI1.1_WK838_R9_PREP2,NFC_FRI1.1_WK838_R9_1,NFC_FRI1.1_WK840_R10_PREP1,NFC_FRI1.1_WK840_R10_1,NFC_FRI1.1_WK842_R11_PREP1,NFC_FRI1.1_WK842_R11_PREP2,NFC_FRI1.1_WK842_R11_1,NFC_FRI1.1_WK844_PREP1,NFC_FRI1.1_WK844_R12_1,NFC_FRI1.1_WK846_PREP1,NFC_FRI1.1_WK846_R13_1,NFC_FRI1.1_WK848_PREP1,NFC_FRI1.1_WK848_R14_1,NFC_FRI1.1_WK850_PACK1,NFC_FRI1.1_WK851_PREP1,NFC_FRI1.1_WK850_R15_1,NFC_FRI1.1_WK902_PREP1,NFC_FRI1.1_WK902_R16_1,NFC_FRI1.1_WK904_PREP1,NFC_FRI1.1_WK904_R17_1,NFC_FRI1.1_WK906_R18_1,NFC_FRI1.1_WK908_PREP1,NFC_FRI1.1_WK908_R19_1,NFC_FRI1.1_WK910_PREP1,NFC_FRI1.1_WK910_R20_1,NFC_FRI1.1_WK912_PREP1,NFC_FRI1.1_WK912_R21_1,NFC_FRI1.1_WK914_PREP1,NFC_FRI1.1_WK914_R22_1,NFC_FRI1.1_WK914_R22_2,NFC_FRI1.1_WK916_R23_1,NFC_FRI1.1_WK918_R24_1,NFC_FRI1.1_WK920_PREP1,NFC_FRI1.1_WK920_R25_1,NFC_FRI1.1_WK922_PREP1,NFC_FRI1.1_WK922_R26_1,NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /** \ingroup grp_file_attributes */ -/*@}*/ -#include - -#endif /* Exclude from test fw */ - -/* - * NDEF Registration And Listening - States of the Finite State machine - * - */ -#define PH_FRINFC_NDEFREG_STATE_INIT 0 /**< \internal Init state. The start-up state */ -#define PH_FRINFC_NDEFREG_STATE_DIS_PKT 1 /**< \internal Dispatch Packet is in progress */ -#define PH_FRINFC_NDEFREG_STATE_DIS_RCD 2 /**< \internal Dispatch Record is in progress */ - -/* - * NDEF Registration And Listening internal definitions - */ -#define PH_FRINFC_NDEFRECORD_TNF_MASK 0x07 /**< \internal */ -#define PH_FRINFC_NDEFREG_CH_FLG_ARR_INDEX 50 /**< \internal */ - - - - -/** \defgroup grp_fri_nfc_ndef_reg NDEF Registry - * - * This component implements the NDEF Registration and Listening functionality. - */ -/*@{*/ - -/* - * \name NDEF Registration And Listening callback and node definitions - * - * \ref PH_FRINFC_NDEFREG_MAX_RTD_REGISTERED is the maximum number of RTDs - * that can be registered in a node.\n - * \ref PH_FRINFC_NDEFREG_MAX_RTD is the maximum number of Records that can - * be present in a single callback function. - */ -/*@{*/ -#define PH_FRINFC_NDEFREG_MAX_RTD_REGISTERED 64 /**< Maximum number of RTDs per node */ -#define PH_FRINFC_NDEFREG_MAX_RTD 8 /**< Maximum number of RTDs per callback function. */ -/*@}*/ - -/** - * \brief NDEF Callback - * - * \copydoc page_reg - * - * Upon reception of a NDEF record the component calls into the function registered as a listener - * for a NDEF type. The function must be compatible to the declaration of the pointer described in - * this section. - * - * \par Parameter - * The underlying type of the callback parameter (void pointer) is \ref phFriNfc_NdefReg_CbParam_t . - * - * \note On systems, requiring non-blocking operation, the user-defined callback function must not block, - * but just deliver the data and return immediately. In this case the CB must make a copy of the - * parameter structure (\ref phFriNfc_NdefReg_CbParam_t) and store it within the environment of the - * registered listener. A copy is needed because once the CB returns the values behind the parameter - * pointer become invalid. We observe the following rules: - * - This component does not rely on lower layers (e.g. HAL), therefore it doesn't need to handle - * completion routines. - * - This library gets a NDEF message and extracts the records using the NDEF Record (Tools) Library. - * - Alternatively, this component can process pre-extracted NDEF records. - * - This library only handles TOP level records, cascaded content is ignored. - * - Functions do not block: The \ref phFriNfc_NdefReg_Process "Process" function needs to be called - * periodically until completion. - * . - */ -typedef void(*pphFriNfc_NdefReg_Cb_t)(void*); - - -/** - * \brief Callback Parameter. This parameter is provided to the CB function that serves - * as the notifier for services/applicatioon/software components registered for a specific - * NDEF Type. - * - * All information required to perform the \ref pphFriNfc_Cr_t "callback" operation is contained - * within the structure. The members of the structure may only be read, changing them is not allowed. - * - * - */ -typedef struct phFriNfc_NdefReg_CbParam -{ - /** - * Number of array Positions. Each array position carries data from a NDEF Record. The maximum - * number is \ref PH_FRINFC_NDEFREG_MAX_RTD . - */ - uint8_t Count; - - /** - * The records that matched with the registred RTDs for this callback. - * The number of records here will be equal to the first parameter Count. - */ - phFriNfc_NdefRecord_t Records[PH_FRINFC_NDEFREG_MAX_RTD]; - - /** Indicates whether a record is chunked or not. */ - uint8_t Chunked[PH_FRINFC_NDEFREG_MAX_RTD]; - - /** Pointer to the raw record. */ - uint8_t *RawRecord[PH_FRINFC_NDEFREG_MAX_RTD]; - - /** Size of the raw record */ - uint32_t RawRecordSize[PH_FRINFC_NDEFREG_MAX_RTD]; - - /** Pointer for usage by the registering entity. The software component that registers for - a specific RTD can specify this \b context pointer. With the help of the pointer - the component is able to resolve its own address, context or object, respectively.\n - \b Example: \ref grp_fri_nfc_ndef_reg "This SW component" is embedded into a C++ system - that has one object registered for a certain RTD. \ref grp_fri_nfc_ndef_reg "This library" - itself is written in C and therefore it requires a pure "C" callback that can be provided by - C++ through a \b static member function. The registering C++ object will consequently set the - \ref phFriNfc_NdefReg_CbParam_t::CbContext pointer to its \c this pointer. When the static - member function of the C++ class is called it immediately knows the instance and can - call into one of the C++ instance members again (\ref phFriNfc_NdefReg_CbParam_t::CbContext - needs to be casted back to the original C++ class type). - */ - void *CbContext; -} phFriNfc_NdefReg_CbParam_t; - - - -/** - * \brief Registration of a Callback - Parameter Structure - * - * This structure is used by the registering software. The registering listener has to \b initialise - * \b all \b members of the structure that are \b not \b internal. Members for \b internal use \b must - * \b not be set by the registering entity. Used by \ref phFriNfc_NdefReg_CbParam_t . - * - */ -typedef struct phFriNfc_NdefReg_Cb -{ - /** - * Number of array Positions. Each array position carries data specifying a RTD. The maximum number - * is \ref PH_FRINFC_NDEFREG_MAX_RTD . - * - * \li Needs to be set by the registering entity. - */ - uint8_t NumberOfRTDs; - /** - * The Type Name Format, according to the NDEF specification, see the NDEF Record (Tools) component. - * - * \li Needs to be set by the registering entity. - */ - uint8_t Tnf[PH_FRINFC_NDEFREG_MAX_RTD_REGISTERED]; - - /** - * Array of pointers to the individual RTD buffers. - * - * \li Needs to be set by the registering entity. - */ - uint8_t *NdefType[PH_FRINFC_NDEFREG_MAX_RTD_REGISTERED]; - - /** - * Array of length indicators of the RTD buffers. - * - * \li Needs to be set by the registering entity. - */ - uint8_t NdeftypeLength[PH_FRINFC_NDEFREG_MAX_RTD_REGISTERED]; - - /** - * Function pointer to the C-style function within the registering entity. - * - * \li Needs to be set by the registering entity. - */ - pphFriNfc_NdefReg_Cb_t NdefCallback; - - /** - * Context pointer of the registering entity (see \ref phFriNfc_NdefReg_CbParam_t). - * - * \li Needs to be set by the registering entity. - */ - void *CbContext; - - /** \internal - * This member is required by the library to link to the previous registered item. In case of the - * first item this member is NULL. - */ - struct phFriNfc_NdefReg_Cb *Previous; - /** \internal - * This member is required by the library to link to the next registered item. In case of the - * last item this member is NULL. - */ - struct phFriNfc_NdefReg_Cb *Next; -} phFriNfc_NdefReg_Cb_t; - - -/** - * \brief NFC NDEF Registry Compound - * - * The NDEF Registry Compound. This is the context structure of the NDEF Registry and - * Listener. - * - */ -typedef struct phFriNfc_NdefReg -{ - phFriNfc_NdefReg_Cb_t *NdefTypeList; /**< \internal List of Callback Structures (Listeners). */ - uint8_t *NdefData; /**< \internal Data to process. */ - uint32_t NdefDataLength; /**< \internal Length of the NDEF data. */ - uint8_t State; /**< \internal The state of the library. */ - uint8_t **NdefTypes; /**< \internal */ - - phFriNfc_NdefRecord_t *RecordsExtracted; /**< \internal */ - - phFriNfc_NdefReg_CbParam_t *CbParam; /**< \internal */ - - /* Harsha: Fix for 0000252: [JF] Buffer overshoot in phFriNfc_NdefRecord_GetRecords */ - uint8_t *IsChunked; /**< \internal Array of chunked flags */ - - /* Harsha: Fix for 0000252: [JF] Buffer overshoot - in phFriNfc_NdefRecord_GetRecords */ - uint32_t NumberOfRecords; /**< \internal Space available in NdefTypes - and IsChunked arrays */ - - /* Harsha: Fix for 0000243: [JF] phFriNfc_NdefReg_Process - won't parse correctly chunked records */ - /* Used to remember the last valid TNF */ - uint8_t validPreviousTnf; /**< \internal The last valid TNF that we had. */ - - uint32_t NumberOfNdefTypes;/**< \internal */ - - uint32_t RecordIndex; /**< \internal */ - - uint32_t RtdIndex; /**< \internal */ - - /* This flag is used to remember whether we have found a - TNF which matches with the Registered RTD */ - uint8_t MainTnfFound; /**< \internal */ - - /* This flag is used to tell whether the present record - being processed is newly extracted */ - uint8_t newRecordextracted;/**< \internal */ - -}phFriNfc_NdefReg_t; - - -#ifndef PH_FRINFC_EXCLUDE_FROM_TESTFW /* */ - -/** - * \brief Ndef Registry \b Reset function - * - * \copydoc page_reg - * - * Resets the component instance to the initial state and lets the component forget about - * the list of registered items. Does basic initialisation. - * - * \param[in] NdefReg Pointer to a valid or uninitialised instance of \ref phFriNfc_NdefReg_t . - * - * \param[in] NdefTypesarray Array of pointers to individual NDEF Types. Later used to store - * the NdefTypes - * - * \param[in] RecordsExtracted Pointer to an uninitialised instance of the NDEF Record structure - * that is later used to retrieve the record information. - * - * \param[in] CbParam Pointer to an un-initialised instance of \ref phFriNfc_NdefReg_CbParam_t - * structure, which is later used to store the callback parameters. - * - * \param[in] ChunkedRecordsarray Pointer to an array of bytes. Later used to store the - * Chunked record flags. - * - * \param[in] NumberOfRecords The number of members in the arrays NdefTypesarray and ChunkedRecordsarray. - * - * \retval NFCSTATUS_SUCCESS The operation has been successful. - * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. - * - * \note This function has to be called at the beginning, after creating an instance of - * \ref phFriNfc_NdefReg_t . - */ -NFCSTATUS phFriNfc_NdefReg_Reset(phFriNfc_NdefReg_t *NdefReg, - uint8_t **NdefTypesarray, - phFriNfc_NdefRecord_t *RecordsExtracted, - phFriNfc_NdefReg_CbParam_t *CbParam, - uint8_t *ChunkedRecordsarray, - uint32_t NumberOfRecords); - - -/** - * \brief Ndef Registry \b Add \b Callback function - * - * \copydoc page_reg - * - * Adds an NDEF type listener to the (internal) list of listeners: - * The registering caller or embedding SW must create an instance of \ref phFriNfc_NdefReg_Cb_t and - * hand the reference over to this function. The library does no allocation of memory. - * - * \param[in] NdefReg Pointer to an initialised instance of \ref phFriNfc_NdefReg_t that holds the - * context of the current component instance. - * - * \param[in] NdefCb Pointer to a caller-initialised structure describing the context of a Listener - * that requests its registration. - * - * \retval NFCSTATUS_SUCCESS The operation has been successful. - * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function - * is invalid. or Number of RTDs in NdefCb - * Structure is greater than - * PH_FRINFC_NDEFREG_MAX_RTD_REGISTERED - * - * \note This function returns once the listener is registered successfully or an error occurs. - */ -NFCSTATUS phFriNfc_NdefReg_AddCb(phFriNfc_NdefReg_t *NdefReg, - phFriNfc_NdefReg_Cb_t *NdefCb); - - -/** - * \brief NDEF Registry \b Remove \b Callback function - * - * \copydoc page_reg - * - * Removes a specific listener from the list: The element to remove is specified by its address. - * As the library does no de-allocation the caller of this function needs to take care of the - * correct disposal of the removed \ref phFriNfc_NdefReg_Cb_t instance once this function returns - * successfully. - * - * \param[in] NdefReg Pointer to an initialised instance of \ref phFriNfc_NdefReg_t that holds the - * context of this component. - * - * \param[in] NdefCb Pointer to a caller-initialised structure describing the context of a Listener - * that requests its un-registration. - * - * \retval NFCSTATUS_SUCCESS The operation has been successful. - * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. - * \retval NFCSTATUS_NODE_NOT_FOUND If the internal list is NULL or a list node is not found. - * - * \note This function returns once the listener is removed successfully or an error occurs. - */ -NFCSTATUS phFriNfc_NdefReg_RmCb(phFriNfc_NdefReg_t *NdefReg, - phFriNfc_NdefReg_Cb_t *NdefCb); - - - -/** - * \brief NDEF Registry \b Dispatch \b Packet function - * - * \copydoc page_reg - * - * The entry point for NDEF \b PACKETS retrieved from the Peer (Remote) Device: - * The function performs a reset of the state. It starts the action (state machine). For actual - * processing a periodic call of \ref phFriNfc_NdefReg_Process has to be done. This - * function parses the Message, isolates the record, looks for a match with the registered - * RTDs and if a match is found, it calls the related callback. This procedure is done for each - * record in the Message - * - * \param[in] NdefReg Pointer to an initialised instance of \ref phFriNfc_NdefReg_t that holds the - * context of this component. - * - * \param[in] PacketData Pointer to a NDEF Packet that has been received. - * - * \param[in] PacketDataLength Length of the NDEF packet to process. - * - * \retval NFCSTATUS_SUCCESS The operation has been successfully initiated. - * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. - * - * \note This function returns once the operation is initiated or an error occurs. - * - */ -NFCSTATUS phFriNfc_NdefReg_DispatchPacket(phFriNfc_NdefReg_t *NdefReg, - uint8_t *PacketData, - uint16_t PacketDataLength); - - -/** - * \brief NDEF Registry \b Dispatch \b Record function - * - * \copydoc page_reg - * - * The entry point for NDEF \b RECORDS retrieved from the Peer (Remote) Device: - * The function performs a reset of the state. It starts the action (state machine). For actual - * processing a periodic call of \ref phFriNfc_NdefReg_Process has to be done. This - * function compares the given record with the registered RTDs and if a match is found it calls - * the related callback. - * - * \param[in] NdefReg Pointer to an initialised instance of \ref phFriNfc_NdefReg_t that holds the - * context of this component. - * - * \param[in] RecordsExtracted Pointer to a NDEF Record that has been received. - * - * \retval NFCSTATUS_SUCCESS The operation has been successfully initiated. - * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. - * - * \note This function returns once the process is initiated or an error occurs. - */ -NFCSTATUS phFriNfc_NdefReg_DispatchRecord(phFriNfc_NdefReg_t *NdefReg, - phFriNfc_NdefRecord_t *RecordsExtracted); - - -/** - * \brief NDEF Registry \b Process function - * - * \copydoc page_reg - * - * Processing function, needed to avoid long blocking and to give control to other parts of the software - * between the internal dispatching of data. - * The function needs to be called during processing, within a message loop or a simple loop until its - * return value tells that it has finished. No State reset is performed during operation. - * - * \param NdefReg Pointer to a valid instance of the \ref phFriNfc_NdefReg_t structure describing - * the component context. - * - * \param Status Pointer to a variable receiving the final result of the NDEF data processing operation. - * There are the following values: - * \li NFCSTATUS_SUCCESS The operation has been successful. - * \li NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. - * \li NFCSTATUS_NODE_NOT_FOUND If the List is NULL or Node is not found. - * \li NFCSTATUS_INVALID_DEVICE_REQUEST State other than the specified in the File. - * - * \retval FALSE Processing has finished, no more function call is needed. - * \retval TRUE Processing is ongoing, the function must be called again. - */ -uint8_t phFriNfc_NdefReg_Process(phFriNfc_NdefReg_t *NdefReg, - NFCSTATUS *Status); - -/*@}*/ /* defgroup */ - -#endif /* PH_FRINFC_EXCLUDE_FROM_TESTFW */ - -#endif /* PHFRINFCNDEFREG_H */ - diff --git a/libnfc-nxp/phFriNfc_OvrHal.h b/libnfc-nxp/phFriNfc_OvrHal.h deleted file mode 100644 index 2b9fdfc..0000000 --- a/libnfc-nxp/phFriNfc_OvrHal.h +++ /dev/null @@ -1,351 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * \file phFriNfc_OvrHal.h - * \brief Overlapped HAL - * - * Project: NFC-FRI - * Creator: Gerald Kersch - * - * $Date: Tue May 19 10:30:18 2009 $ - * Changed by: $Author: ing07336 $ - * $Revision: 1.13 $ - * $Aliases: NFC_FRI1.1_WK922_PREP1,NFC_FRI1.1_WK920_R25_1,NFC_FRI1.1_WK922_R26_1,NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ - * - */ - -#ifndef PHFRINFC_OVRHAL_H -#define PHFRINFC_OVRHAL_H - -#include -#ifdef PH_HAL4_ENABLE -#include -#else -#include -#endif -#include -#include - - -/** - * \name Overlapped HAL - * - * File: \ref phFriNfc_OvrHal.h - * - */ -/*@{*/ -#define PH_FRINFC_OVRHAL_FILEREVISION "$Revision: 1.13 $" /** \ingroup grp_file_attributes */ -#define PH_FRINFC_OVRHAL_FILEALIASES "$Aliases: NFC_FRI1.1_WK922_PREP1,NFC_FRI1.1_WK920_R25_1,NFC_FRI1.1_WK922_R26_1,NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /** \ingroup grp_file_attributes */ -/*@}*/ - - -/** \defgroup grp_fri_nfc_ovr_hal Overlapped HAL - * - * This component encapsulates the HAL functions, suited for the NFC-FRI overlapped way of operation. The HAL itself - * is used as it is, wrapped by this component. The purpose of the wrapper is to de-couple a blocking I/O, as used by - * the HAL, from the overlapped I/O operation mode the FRI is using. - * - * \par Device Based Functions - * NFC Device Based Functions are used to address the NFC device (local device) directly. - * These are all functions that use no Remote Device Information. - * - * \par Connection Based Functions - * Connection Based Functions use the Remote Device Information to describe a connection - * to a certain Remote Device. - * - * \par Component Instance Sharing - * FRI components accessing one NFC device share one instance of the Overlapped HAL. Therefore - * each calling FRI component must specify - together with the call - where to deliver the - * response of the overlapped operation. - * - * \par Lowest Layer - * The Overlapped HAL represents the NFC Device, the lowest layer of the FRI components. - * - * \par Completion Forced - * The \b HAL \b functions (and underlying functions) of this library must complete before a new call can - * be issued. No HAL operation must be pending. - * - */ -/*@{*/ - -/** - * \name OVR HAL Constants - */ -/*@{*/ -#define PH_FRINFC_OVRHAL_MAX_NUM_MOCKUP_PARAM 255 /**< Number of mockup indices that are are prepared. */ -/* Harsha: changed from 48 to 128, to work with the Mifare 4k TCs */ -#define PH_FRINFC_OVRHAL_MAX_NUM_MOCKUP_RDI 4 /**< Max. number of mockup RDIs. */ -#define PH_FRINFC_OVRHAL_MAX_TEST_DELAY 1000 /**< Max. test delay in OVR HAL. */ -#define PH_FRINFC_OVRHAL_POLL_PAYLOAD_LEN 5 /**< Length of the POLL payload. */ /* @GK/5.6.06 */ -/*@}*/ -/*@}*/ /* defgroup... */ - -/** \defgroup grp_ovr_hal_cmd Overlapped HAL Command List - * \ingroup grp_fri_nfc_ovr_hal - * These are the command definitions for the Overlapped HAL. They are used internally by the - * implementation of the component. - */ -/*@{*/ -#define PH_FRINFC_OVRHAL_NUL (0) /**< \brief We're in NO command */ - -#define PH_FRINFC_OVRHAL_ENU (1) /**< \brief Enumerate */ -#define PH_FRINFC_OVRHAL_OPE (2) /**< \brief Open */ -#define PH_FRINFC_OVRHAL_CLO (3) /**< \brief Close */ -#define PH_FRINFC_OVRHAL_GDC (4) /**< \brief Get Dev Caps */ -#define PH_FRINFC_OVRHAL_POL (5) /**< \brief Poll */ -#define PH_FRINFC_OVRHAL_CON (6) /**< \brief Connect */ -#define PH_FRINFC_OVRHAL_DIS (7) /**< \brief Disconnect */ -#define PH_FRINFC_OVRHAL_TRX (8) /**< \brief Transceive */ -#define PH_FRINFC_OVRHAL_STM (9) /**< \brief Start Target Mode */ -#define PH_FRINFC_OVRHAL_SND (10) /**< \brief Send */ -#define PH_FRINFC_OVRHAL_RCV (11) /**< \brief Receive */ -#define PH_FRINFC_OVRHAL_IOC (12) /**< \brief IOCTL */ - -#define PH_FRINFC_OVRHAL_TST (255) /**< \brief OVR HAL test-related command */ - -/** \ingroup grp_fri_nfc_ovr_hal - * \brief Post Message Function for Overlapped HAL - * - * \copydoc page_reg - * - * This is required by the Overlapped HAL in order to call the blocking (original HAL) in another - * thread. This function is required in addition to \ref pphFriNfc_OvrHalPresetParm to be - * implemented in the integrating software. - * - * \par First Parameter: Context of the Integration - * Set to the value, the Integration has provided when initialising this component. - */ -typedef void (*pphFriNfc_OvrHalPostMsg_t)(void*); - -/** \ingroup grp_fri_nfc_ovr_hal - * \brief Abort Function (to be defined/implemented by the Integration) - * - * \copydoc page_reg - * - * This is required by the Overlapped HAL in order abort a pending Overlapped HAL operation. This funtion will be - * internally called by the \ref phFriNfc_OvrHal_Abort function. - * - * \par First Parameter: Context of the Integration - * Set to the value, the Integration has provided when initialising this component. - * - * \par Return value: - * As defined by the integration - */ -typedef NFCSTATUS (*pphFriNfc_OvrHalAbort_t)(void*); - - -typedef void (*pphOvrHal_CB_t) (phHal_sRemoteDevInformation_t *RemoteDevHandle, - NFCSTATUS status, - phNfc_sData_t *pRecvdata, - void *context); - -/** \ingroup grp_fri_nfc_ovr_hal - * \brief Preset Function to prepare the parameters in the HAL - * - * \copydoc page_reg - * - * This function (pointer) is called by the Overlapped HAL to prepare the function call parameters - * in the HAL before posting the start message. As we have an asynchronously running FRI, but a - * synchronous HAL, the calls need to be "decoupled". This means, the HAL needs to run under - * a different time-base (or thread/task etc.). The consequence is that the data exchange between - * FRI and HAL must be done as required by the integration/system itself. The declaration - * of the function pointer allows for the integrating software to implement whatever functionality - * is required to convey the data. - * - * - * \par First Parameter - * Context of the Integration Set to the value, the Integration has provided when initialising - * this component. - * - * \par Second Parameter: - * \b HAL \b Command, as defined in the module \ref grp_ovr_hal_cmd. - * - * \par Third Parameter: - * \b Pointers to a specific structure containing the parameters of the HAL functions to be - * called. - * - * \par Forth parameter: - * Immediate Operation result (not the result of the HAL operation). Usually this is - * \ref NFCSTATUS_PENDING (for a successfully triggered HAL I/O or an error value that is - * returned by the HAL immediately, such as \ref NFCSTATUS_INVALID_PARAMETER. - * - * \par Return value: - * A boolean (\ref grp_special_conventions) value. The integration implementation must ensure - * that, if the function \b succeeds, the return value is \b TRUE, otherwise false. - */ -typedef uint8_t (*pphFriNfc_OvrHalPresetParm)(void*, uint16_t, void*, NFCSTATUS*); - -/** \ingroup grp_fri_nfc_ovr_hal - * \brief Overlapped HAL Context - * - * The Overlapped HAL structure. This structure contains the HAL "context" that - * is required by the FRI on a connection basis. Please note that the Overlapped HAL is - * a shared component, requiring a special completion notification mechanism. - * Read more in the description of this component. - * - */ -typedef struct phFriNfc_OvrHal -{ - /** Currently active operation of the component. If no operation is pending, the content of this member is - * \ref PH_FRINFC_OVRHAL_NUL . The component refuses a new call if the contenet is different, namely one - * of the other values defined in \ref grp_ovr_hal_cmd . - */ - uint8_t Operation; - - /** The \b temporary pointer to the completion routine information. The HAL needs - for each call - to be told about the - * completion routine of the upper (calling) component. This major difference to other components is because - * some functions of the HAL are connection-based and some are not. Moreover it is because the HAL is shared - * among the FRI components. So, with a variety of potential callers it is required for each caller to instruct - * the HAL about the "delivery" address of the response for each individual call. - */ - phFriNfc_CplRt_t TemporaryCompletionInfo; - phFriNfc_CplRt_t TemporaryRcvCompletionInfo; - phFriNfc_CplRt_t TemporarySndCompletionInfo; - - /** Points to a function within the Integration that presets the parameters for the actual - * HAL call. - */ - pphFriNfc_OvrHalPresetParm Presetparameters; - - /** Posts a message to the actual HAL integration, starting a NFC HAL I/O with the pre-set - * parameters. - */ - pphFriNfc_OvrHalPostMsg_t PostMsg; - - /** The context of the Integration (the SW around this component). This is needed to let - * the Overlapped HAL access the Integration's functionality to post a message to another - * thread. - */ - void *IntegrationContext; - - /** Device reference returned during enumeration: This has to be filled in by the integrating software after - a call to the HAL Enumerate function (not contained in the overlapped HAl API). */ - phHal_sHwReference_t *psHwReference; - - /** This flag is set by the ABORT function. The OVR HAL then does no I/O to the real HAL - * or to the mockup any more but just completed with the ABORTED status. - */ - uint8_t OperationAborted; - - /** Abort function to be implemented by the integration. This parameter can be (optionally) initialized - * via the call of \ref phFriNfc_OvrHal_Reset_Abort function. - * If it is not NULL, the function pointed by \ref will be internally called by the \ref phFriNfc_OvrHal_Abort function. - */ - pphFriNfc_OvrHalAbort_t AbortIntegrationFunction; - - /** Integration-defined Context passed as a parameter of the \ref AbortIntegrationFunction. - */ - void* AbortIntegrationContext; - - void* OvrCompletion; - - phHal_sTransceiveInfo_t TranceiveInfo; - - /** TODO - */ - phNfc_sData_t sReceiveData; - - /** TODO - */ - phNfc_sData_t sSendData; - - /** TODO - */ - phHal4Nfc_TransactInfo_t TransactInfo; - - uint16_t *pndef_recv_length; -} phFriNfc_OvrHal_t; - -/** - * \ingroup grp_fri_nfc_ovr_hal - * - * \brief Transceive Data to/from a Remote Device - * - * \copydoc page_ovr - * - * \param[in] OvrHal Component Context. - * \param[in] CompletionInfo \copydoc phFriNfc_OvrHal_t::TemporaryCompletionInfo - * \param[in,out] RemoteDevInfo Remote Device Information. - * \param[in] Cmd Command to perform. - * \param[out] DepAdditionalInfo Protocol Information. - * \param[in] SendBuf Pointer to the data to send. - * \param[in] SendLength Length, in bytes, of the Send Buffer. - * \param[out] RecvBuf Pointer to the buffer that receives the data. - * \param[in,out] RecvLength Length, in bytes, of the received data. - * - * \retval NFCSTATUS_PENDING The operation is pending. - * \retval NFCSTATUS_INVALID_DEVICE_REQUEST \copydoc phFriNfc_OvrHal_t::Operation - * \retval NFCSTATUS_SUCCESS Success. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters could not be - * properly interpreted. - * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected - * meanwhile. - * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request. - * \retval NFCSTATUS_BUFFER_TOO_SMALL The buffer provided by the caller is too small. - * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period. - * - * \note Please refer to HAL Transceive for a detailed description of the - * underlying function and the propagated parameters. - * - */ - -NFCSTATUS phFriNfc_OvrHal_Transceive(phFriNfc_OvrHal_t *OvrHal, - phFriNfc_CplRt_t *CompletionInfo, - phHal_sRemoteDevInformation_t *RemoteDevInfo, - phHal_uCmdList_t Cmd, - phHal_sDepAdditionalInfo_t *DepAdditionalInfo, - uint8_t *SendBuf, - uint16_t SendLength, - uint8_t *RecvBuf, - uint16_t *RecvLength); - -/** - * \ingroup grp_fri_nfc_ovr_hal - * - * \brief TODO - * - */ -NFCSTATUS phFriNfc_OvrHal_Receive(phFriNfc_OvrHal_t *OvrHal, - phFriNfc_CplRt_t *CompletionInfo, - phHal_sRemoteDevInformation_t *RemoteDevInfo, - uint8_t *RecvBuf, - uint16_t *RecvLength); - -/** - * \ingroup grp_fri_nfc_ovr_hal - * - * \brief TODO - * - */ -NFCSTATUS phFriNfc_OvrHal_Send(phFriNfc_OvrHal_t *OvrHal, - phFriNfc_CplRt_t *CompletionInfo, - phHal_sRemoteDevInformation_t *RemoteDevInfo, - uint8_t *SendBuf, - uint16_t SendLength); - - -NFCSTATUS phFriNfc_OvrHal_Reconnect(phFriNfc_OvrHal_t *OvrHal, - phFriNfc_CplRt_t *CompletionInfo, - phHal_sRemoteDevInformation_t *RemoteDevInfo); - - -NFCSTATUS phFriNfc_OvrHal_Connect(phFriNfc_OvrHal_t *OvrHal, - phFriNfc_CplRt_t *CompletionInfo, - phHal_sRemoteDevInformation_t *RemoteDevInfo, - phHal_sDevInputParam_t *DevInputParam); - -#endif diff --git a/libnfc-nxp/phFriNfc_OvrHalCmd.h b/libnfc-nxp/phFriNfc_OvrHalCmd.h deleted file mode 100644 index 52e126c..0000000 --- a/libnfc-nxp/phFriNfc_OvrHalCmd.h +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * \file phFriNfc_OvrHalCmd.h - * \brief Overlapped HAL - * - * Project: NFC-FRI - * - * $Date: Fri Oct 5 10:09:57 2007 $ - * $Author: frq05303 $ - * $Revision: 1.1 $ - * $Aliases: NFC_FRI1.1_WK826_PREP1,NFC_FRI1.1_WK826_R1,NFC_FRI1.1_WK826_R2,NFC_FRI1.1_WK830_PREP1,NFC_FRI1.1_WK830_PREP2,NFC_FRI1.1_WK830_R5_1,NFC_FRI1.1_WK830_R5_2,NFC_FRI1.1_WK830_R5_3,NFC_FRI1.1_WK832_PREP1,NFC_FRI1.1_WK832_PRE2,NFC_FRI1.1_WK832_PREP2,NFC_FRI1.1_WK832_PREP3,NFC_FRI1.1_WK832_R5_1,NFC_FRI1.1_WK832_R6_1,NFC_FRI1.1_WK834_PREP1,NFC_FRI1.1_WK834_PREP2,NFC_FRI1.1_WK834_R7_1,NFC_FRI1.1_WK836_PREP1,NFC_FRI1.1_WK836_R8_1,NFC_FRI1.1_WK838_PREP1,NFC_FRI1.1_WK838_R9_PREP2,NFC_FRI1.1_WK838_R9_1,NFC_FRI1.1_WK840_R10_PREP1,NFC_FRI1.1_WK840_R10_1,NFC_FRI1.1_WK842_R11_PREP1,NFC_FRI1.1_WK842_R11_PREP2,NFC_FRI1.1_WK842_R11_1,NFC_FRI1.1_WK844_PREP1,NFC_FRI1.1_WK844_R12_1,NFC_FRI1.1_WK846_PREP1,NFC_FRI1.1_WK846_R13_1,NFC_FRI1.1_WK848_PREP1,NFC_FRI1.1_WK848_R14_1,NFC_FRI1.1_WK850_PACK1,NFC_FRI1.1_WK851_PREP1,NFC_FRI1.1_WK850_R15_1,NFC_FRI1.1_WK902_PREP1,NFC_FRI1.1_WK902_R16_1,NFC_FRI1.1_WK904_PREP1,NFC_FRI1.1_WK904_R17_1,NFC_FRI1.1_WK906_R18_1,NFC_FRI1.1_WK908_PREP1,NFC_FRI1.1_WK908_R19_1,NFC_FRI1.1_WK910_PREP1,NFC_FRI1.1_WK910_R20_1,NFC_FRI1.1_WK912_PREP1,NFC_FRI1.1_WK912_R21_1,NFC_FRI1.1_WK914_PREP1,NFC_FRI1.1_WK914_R22_1,NFC_FRI1.1_WK914_R22_2,NFC_FRI1.1_WK916_R23_1,NFC_FRI1.1_WK918_R24_1,NFC_FRI1.1_WK920_PREP1,NFC_FRI1.1_WK920_R25_1,NFC_FRI1.1_WK922_PREP1,NFC_FRI1.1_WK922_R26_1,NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1 $ - * - */ - -#ifndef PHFRINFC_OVRHALCMD_H -#define PHFRINFC_OVRHALCMD_H - -#include - -/** - * \name Overlapped HAL - * - * File: \ref phFriNfc_OvrHalCmd.h - * - */ -/*@{*/ -#define PH_FRINFC_OVRHALCMD_FILEREVISION "$Revision: 1.1 $" /** \ingroup grp_file_attributes */ -#define PH_FRINFC_OVRHALCMD_FILEALIASES "$Aliases: NFC_FRI1.1_WK826_PREP1,NFC_FRI1.1_WK826_R1,NFC_FRI1.1_WK826_R2,NFC_FRI1.1_WK830_PREP1,NFC_FRI1.1_WK830_PREP2,NFC_FRI1.1_WK830_R5_1,NFC_FRI1.1_WK830_R5_2,NFC_FRI1.1_WK830_R5_3,NFC_FRI1.1_WK832_PREP1,NFC_FRI1.1_WK832_PRE2,NFC_FRI1.1_WK832_PREP2,NFC_FRI1.1_WK832_PREP3,NFC_FRI1.1_WK832_R5_1,NFC_FRI1.1_WK832_R6_1,NFC_FRI1.1_WK834_PREP1,NFC_FRI1.1_WK834_PREP2,NFC_FRI1.1_WK834_R7_1,NFC_FRI1.1_WK836_PREP1,NFC_FRI1.1_WK836_R8_1,NFC_FRI1.1_WK838_PREP1,NFC_FRI1.1_WK838_R9_PREP2,NFC_FRI1.1_WK838_R9_1,NFC_FRI1.1_WK840_R10_PREP1,NFC_FRI1.1_WK840_R10_1,NFC_FRI1.1_WK842_R11_PREP1,NFC_FRI1.1_WK842_R11_PREP2,NFC_FRI1.1_WK842_R11_1,NFC_FRI1.1_WK844_PREP1,NFC_FRI1.1_WK844_R12_1,NFC_FRI1.1_WK846_PREP1,NFC_FRI1.1_WK846_R13_1,NFC_FRI1.1_WK848_PREP1,NFC_FRI1.1_WK848_R14_1,NFC_FRI1.1_WK850_PACK1,NFC_FRI1.1_WK851_PREP1,NFC_FRI1.1_WK850_R15_1,NFC_FRI1.1_WK902_PREP1,NFC_FRI1.1_WK902_R16_1,NFC_FRI1.1_WK904_PREP1,NFC_FRI1.1_WK904_R17_1,NFC_FRI1.1_WK906_R18_1,NFC_FRI1.1_WK908_PREP1,NFC_FRI1.1_WK908_R19_1,NFC_FRI1.1_WK910_PREP1,NFC_FRI1.1_WK910_R20_1,NFC_FRI1.1_WK912_PREP1,NFC_FRI1.1_WK912_R21_1,NFC_FRI1.1_WK914_PREP1,NFC_FRI1.1_WK914_R22_1,NFC_FRI1.1_WK914_R22_2,NFC_FRI1.1_WK916_R23_1,NFC_FRI1.1_WK918_R24_1,NFC_FRI1.1_WK920_PREP1,NFC_FRI1.1_WK920_R25_1,NFC_FRI1.1_WK922_PREP1,NFC_FRI1.1_WK922_R26_1,NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1 $" /** \ingroup grp_file_attributes */ -/*@}*/ - -/** \defgroup grp_ovr_hal_cmd Overlapped HAL Command List - * \ingroup grp_fri_nfc_ovr_hal - * These are the command definitions for the Overlapped HAL. They are used internally by the - * implementation of the component. - */ -/*@{*/ -#define PH_FRINFC_OVRHALCMD_NUL (0) /**< \brief We're in NO command */ - -#define PH_FRINFC_OVRHALCMD_ENU (1) /**< \brief Enumerate */ -#define PH_FRINFC_OVRHALCMD_OPE (2) /**< \brief Open */ -#define PH_FRINFC_OVRHALCMD_CLO (3) /**< \brief Close */ -#define PH_FRINFC_OVRHALCMD_GDC (4) /**< \brief Get Dev Caps */ -#define PH_FRINFC_OVRHALCMD_POL (5) /**< \brief Poll */ -#define PH_FRINFC_OVRHALCMD_CON (6) /**< \brief Connect */ -#define PH_FRINFC_OVRHALCMD_DIS (7) /**< \brief Disconnect */ -#define PH_FRINFC_OVRHALCMD_TRX (8) /**< \brief Transceive */ -#define PH_FRINFC_OVRHALCMD_STM (9) /**< \brief Start Target Mode */ -#define PH_FRINFC_OVRHALCMD_SND (10) /**< \brief Send */ -#define PH_FRINFC_OVRHALCMD_RCV (11) /**< \brief Receive */ -#define PH_FRINFC_OVRHALCMD_IOC (12) /**< \brief IOCTL */ - -#define PH_FRINFC_OVRHALCMD_TST (255) /**< \brief OVR HAL test-related command */ - - -/** \brief Parameter compound internally used for testing purpose - * - */ -typedef struct phFriNfc_OvrHalCmdVoid -{ - void *Div; - NFCSTATUS Status; - uint32_t Delay; -} phFriNfc_OvrHalCmdVoid_t; - -/** \brief Parameter compound internally used by \ref phFriNfc_OvrHal_Enumerate - * - */ -typedef struct phFriNfc_OvrHalCmdEnu -{ - phHal_sHwReference_t *HwReference; - uint8_t *pNbrOfDevDetected; -} phFriNfc_OvrHalCmdEnu_t; - -/** \brief Parameter compound internally used by \ref phFriNfc_OvrHal_Open - * - */ -typedef struct phFriNfc_OvrHalCmdOpe -{ - phHal_sHwReference_t *psHwReference; -} phFriNfc_OvrHalCmdOpe_t; - -/** \brief Parameter compound internally used by \ref phFriNfc_OvrHal_Close - * - */ -typedef struct phFriNfc_OvrHalCmdClo -{ - phHal_sHwReference_t *psHwReference; -} phFriNfc_OvrHalCmdClo_t; - -/** \brief Parameter compound internally used by \ref phFriNfc_OvrHal_GetDeviceCapabilities - * - */ -typedef struct phFriNfc_OvrHalCmdGdc -{ - phHal_sHwReference_t *psHwReference; - phHal_sDeviceCapabilities_t *psDevCapabilities; -} phFriNfc_OvrHalCmdGdc_t; - -/** \brief Parameter compound internally used by \ref phFriNfc_OvrHal_Poll - * - */ -typedef struct phFriNfc_OvrHalCmdPol -{ - phHal_sHwReference_t *psHwReference; - phHal_eOpModes_t *OpModes; - phHal_sRemoteDevInformation_t *psRemoteDevInfoList; - uint8_t *NbrOfRemoteDev; - phHal_sDevInputParam_t *psDevInputParam; -} phFriNfc_OvrHalCmdPol_t; - -/** \brief Parameter compound internally used by \ref phFriNfc_OvrHal_Connect - * - */ -typedef struct phFriNfc_OvrHalCmdCon -{ - phHal_sHwReference_t *psHwReference; - phHal_eOpModes_t OpMode; - phHal_sRemoteDevInformation_t *psRemoteDevInfo; - phHal_sDevInputParam_t *psDevInputParam; -} phFriNfc_OvrHalCmdCon_t; - -/** \brief Parameter compound internally used by \ref phFriNfc_OvrHal_Disconnect - * - */ -typedef struct phFriNfc_OvrHalCmdDis -{ - phHal_sHwReference_t *psHwReference; - phHal_sRemoteDevInformation_t *psRemoteDevInfo; -} phFriNfc_OvrHalCmdDis_t; - -/** \brief Parameter compound internally used by \ref phFriNfc_OvrHal_Transceive - * - */ -typedef struct phFriNfc_OvrHalCmdTrx -{ - phHal_sHwReference_t *psHwReference; - phHal_sRemoteDevInformation_t *psRemoteDevInfo; - phHal_uCmdList_t Cmd; - phHal_sDepAdditionalInfo_t *psDepAdditionalInfo; - uint8_t *pSendBuf; - uint16_t SendLength; - uint8_t *pRecvBuf; - uint16_t *pRecvLength; -} phFriNfc_OvrHalCmdTrx_t; - -/** \brief Parameter compound internally used by \ref phFriNfc_OvrHal_StartTargetMode - * - */ -typedef struct phFriNfc_OvrHalCmdStm -{ - phHal_sHwReference_t *psHwReference; - phHal_sTargetInfo_t *pTgInfo; - phHal_eOpModes_t *OpModes; - uint8_t *pConnectionReq; - uint8_t *pConnectionReqBufLength; -} phFriNfc_OvrHalCmdStm_t; - -/** \brief Parameter compound internally used by \ref phFriNfc_OvrHal_Receive - * - */ -typedef struct phFriNfc_OvrHalCmdRcv -{ - phHal_sHwReference_t *psHwReference; - phHal_sDepAdditionalInfo_t *psDepAdditionalInfo; - uint8_t *pRecvBuf; - uint16_t *pRecvLength; -} phFriNfc_OvrHalCmdRcv_t; - -/** \brief Parameter compound internally used by \ref phFriNfc_OvrHal_Send - * - */ -typedef struct phFriNfc_OvrHalCmdSnd -{ - phHal_sHwReference_t *psHwReference; - phHal_sDepAdditionalInfo_t *psDepAdditionalInfo; - uint8_t *pSendBuf; - uint16_t SendLength; -} phFriNfc_OvrHalCmdSnd_t; - -/** \brief Parameter compound internally used by \ref phFriNfc_OvrHal_Ioctl - * - */ -typedef struct phFriNfc_OvrHalCmdIoc -{ - phHal_sHwReference_t *psHwReference; - uint16_t IoctlCode; - uint8_t *pInBuf; - uint16_t InLength; - uint8_t *pOutBuf; - uint16_t *pOutLength; -} phFriNfc_OvrHalCmdIoc_t; - -/** \brief Parameter compound internally used by \ref phFriNfc_OvrHal_Test - * - */ -typedef struct phFriNfc_OvrHalCmdTst -{ - phHal_sHwReference_t *psHwReference; - void *pTestParam; -} phFriNfc_OvrHalCmdTst_t; - - -#ifdef PHFRINFC_OVRHAL_MOCKUP /* */ -/** \brief Parameter compound internally used by \ref phFriNfc_OvrHalCmdMockup_t - * - */ -typedef struct phFriNfc_OvrHalCmdMockup -{ - phHal_sHwReference_t *psHwReference; - uint16_t IoctlCode; - uint8_t *pInBuf; - uint16_t InLength; - uint8_t *pOutBuf; - uint16_t *pOutLength; -} phFriNfc_OvrHalCmdMockup_t; -#endif /* PHFRINFC_OVRHAL_MOCKUP */ - -/** \brief Placeholder for all parameter structures - * - */ -typedef union phFriNfc_OvrHalCmd -{ - phFriNfc_OvrHalCmdVoid_t CmdVoid; - - phFriNfc_OvrHalCmdEnu_t CmdEnu; - phFriNfc_OvrHalCmdOpe_t CmdOpe; - phFriNfc_OvrHalCmdClo_t CmdClo; - phFriNfc_OvrHalCmdGdc_t CmdGdc; - phFriNfc_OvrHalCmdPol_t CmdPol; - phFriNfc_OvrHalCmdCon_t CmdCon; - phFriNfc_OvrHalCmdDis_t CmdDis; - phFriNfc_OvrHalCmdTrx_t CmdTrx; - phFriNfc_OvrHalCmdIoc_t CmdIoc; - phFriNfc_OvrHalCmdStm_t CmdStm; - phFriNfc_OvrHalCmdSnd_t CmdSnd; - phFriNfc_OvrHalCmdRcv_t CmdRcv; - phFriNfc_OvrHalCmdTst_t CmdTst; -} phFriNfc_OvrHalCmd_t; - - -/*@}*/ -#endif /* PHFRINFC_OVRHALCMD_H */ diff --git a/libnfc-nxp/phFriNfc_SmtCrdFmt.h b/libnfc-nxp/phFriNfc_SmtCrdFmt.h deleted file mode 100644 index 4800c41..0000000 --- a/libnfc-nxp/phFriNfc_SmtCrdFmt.h +++ /dev/null @@ -1,501 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! - * \file phFriNfc_SmtCrdFmt.h - * \brief NFC-FRI Smart Card Formatting. - * - * Project: NFC-FRI - * - * $Date: Mon Dec 13 14:14:11 2010 $ - * $Author: ing02260 $ - * $Revision: 1.5 $ - * $Aliases: $ - * - */ - -#ifndef PHFRINFC_SMTCRDFMT_H -#define PHFRINFC_SMTCRDFMT_H - -/** - * \name Smart Card Formatting - * - * File: \ref phFri_CardFormatFunctions.h - * - */ -/*@{*/ -#define PHFRINFC_SMTCRDFMT_FILEREVISION "$Revision: 1.5 $" -#define PHFRINFC_SMTCRDFMT_FILEALIASES "$Aliases: $" -/*@}*/ - -/*! \defgroup grp_fri_smart_card_formatting NFC FRI Smart Card Formatting - * - * Smart Card Formatting functionality enables automatic formatting of any type of smart cards. - * This initializes the smart cards and makes them NDEF Compliant. - * Single API is provided to handle format/recovery management of different types cards. - * Following are different Types of cards supported by this module, currently. - * - Type1 ( Topaz) - * - Type2 ( Mifare UL) - * - Type4 ( Desfire) - * - Mifare Std. - */ -/*@{*/ -/** - * \ingroup grp_fri_smart_card_formatting - * \brief Macro definitions. - * \note - On requirement basis, new constants will be defined - during the implementation phase. -*/ - -#define DESFIRE_FMT_EV1 - - -#define PH_FRI_NFC_SMTCRDFMT_NFCSTATUS_FORMAT_ERROR 9 -#define PH_FRINFC_SMTCRDFMT_MSTD_DEFAULT_KEYA_OR_KEYB {0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF} -#define PH_FRINFC_SMTCRDFMT_MSTD_MADSECT_KEYA {0xA0, 0xA1,0xA2,0xA3,0xA4,0xA5} -#define PH_FRINFC_SMTCRDFMT_NFCFORUMSECT_KEYA {0xD3, 0xF7,0xD3,0xF7,0xD3,0xF7} -#define PH_FRINFC_SMTCRDFMT_MSTD_MADSECT_ACCESSBITS {0x78,0x77,0x88} -#define PH_FRINFC_SMTCRDFMT_MSTD_NFCFORUM_ACCESSBITS {0x7F,0x07,0x88} -#define PH_FRINFC_SMTCRDFMT_MAX_TLV_TYPE_SUPPORTED 1 - -#define PH_FRINFC_SMTCRDFMT_MAX_SEND_RECV_BUF_SIZE 252 - -#define PH_FRINFC_SMTCRDFMT_STATE_RESET_INIT 1 - -enum -{ - PH_FRINFC_SMTCRDFMT_MIFARE_UL_CARD, - PH_FRINFC_SMTCRDFMT_ISO14443_4A_CARD, - PH_FRINFC_SMTCRDFMT_MFSTD_1K_CRD, - PH_FRINFC_SMTCRDFMT_MFSTD_4K_CRD, - PH_FRINFC_SMTCRDFMT_TOPAZ_CARD -}; - -/** - * \name Completion Routine Indices - * - * These are the indices of the completion routine pointers within the component context. - * Completion routines belong to upper components. - * - */ -/*@{*/ -/** \ingroup grp_fri_nfc_ndef_map -* Completion Routine Index for \ref phFriNfc_SmtCrd_Format */ -#define PH_FRINFC_SMTCRDFMT_CR_FORMAT 0 /* */ -/** \ingroup grp_fri_nfc_ndef_map Completion - * Routine Index for Unknown States/Operations */ -#define PH_FRINFC_SMTCRDFMT_CR_INVALID_OPE 1 /* */ -/** \ingroup grp_fri_nfc_ndef_map - * Number of completion routines that have to be initialised */ -#define PH_FRINFC_SMTCRDFMT_CR 2 -/*@}*/ - - -/*@}*/ - -/* - * \ingroup grp_fri_smart_card_formatting - * - * \brief NFC Smart Card Formatting Component Type1 Additional Information Structure - * - * This structure is used to specify additional information required to format the Type1 card. - * \note - * On requirement basis,structure will be filled/modified with other parameters - * during the implementation phase. - * - */ -typedef struct phFriNfc_Type1_AddInfo -{ - /* Stores the CC byte values. For Ex: 0xE1, 0x10 , 0x0C, 0x00*/ - uint8_t CCBytes[5]; - uint8_t UID[4]; - uint8_t CCByteIndex; - -} phFriNfc_Type1_AddInfo_t; - -/* - * - * \ingroup grp_fri_smart_card_formatting - * \brief NFC Smart Card Formatting Component Type2 Additional Information Structure - * - * This structure is used to specify additional information required to format the Type2 card. - * \note - * On requirement basis,structure will be filled/modified with other parametes - * during the implementation phase. - * - */ -typedef struct phFriNfc_Type2_AddInfo -{ - /* Stores the CC byte values. For Ex: 0xE1, 0x10 , 0x10, 0x00*/ - uint8_t OTPBytes[4]; -#ifdef FRINFC_READONLY_NDEF - uint8_t LockBytes[4]; - -#ifdef PH_NDEF_MIFARE_ULC - uint8_t ReadData[16]; - uint8_t ReadDataIndex; - uint8_t DynLockBytes[4]; - uint8_t BytesLockedPerLockBit; - uint8_t LockBytesPerPage; - uint8_t LockByteNumber; - uint8_t LockBlockNumber; - uint8_t NoOfLockBits; - uint8_t DefaultLockBytesFlag; - uint8_t LockBitsWritten; -#endif /* #ifdef PH_NDEF_MIFARE_ULC */ - -#endif /* #ifdef FRINFC_READONLY_NDEF */ - /* Current Block Address*/ - uint8_t CurrentBlock; -} phFriNfc_Type2_AddInfo_t; - -/* - * \ingroup grp_fri_smart_card_formatting - * \brief NFC Smart Card Formatting Component Type4 Additional Information Structure - * - * This structure is used to specify additional information required to format the type4 card. - * \note - * On requirement basis,structure will be filled/modified with other parametes - * during the implementation phase. - * - */ - -typedef struct phFriNfc_Type4_AddInfo -{ - /* Specifies Keys related to PICC/NFCForum Master Key settings*/ - /* Stores the PICC Master Key/NFC Forum MasterKey*/ - uint8_t PICCMasterKey[16]; - uint8_t NFCForumMasterkey[16]; - - /* To create the files follwoiing attributes are required*/ - uint8_t PrevState; - uint16_t FileAccessRights; - uint32_t CardSize; - uint16_t MajorVersion; - uint16_t MinorVersion; - -} phFriNfc_Type4_AddInfo_t; - -/* - * \ingroup grp_fri_smart_card_formatting - * \brief NFC Smart Card Formatting Component Mifare Std Additional Information Structure - * - * This structure is used to specify additional information required to format the Mifare Std card. - * \note - * On requirement basis,structure will be filled/modified with other parametes - * during the implementation phase. - * - */ - typedef struct phFriNfc_MfStd_AddInfo -{ - /** Device input parameter for poll and connect after failed authentication */ - phHal_sDevInputParam_t *DevInputParam; - - /* Stores the Default KeyA and KeyB values*/ - uint8_t Default_KeyA_OR_B[6]; - - /* Key A of MAD sector*/ - uint8_t MADSect_KeyA[6]; - - /* Key A of NFC Forum Sector sector*/ - uint8_t NFCForumSect_KeyA[6]; - - /* Access Bits of MAD sector*/ - uint8_t MADSect_AccessBits[3]; - - /* Access Bits of NFC Forum sector*/ - uint8_t NFCForumSect_AccessBits[3]; - - /* Secret key B to given by the application */ - uint8_t ScrtKeyB[6]; - - /* Specifies the status of the different authentication handled in - formatting procedure*/ - uint8_t AuthState; - - /* Stores the current block */ - uint16_t CurrentBlock; - - /* Stores the current block */ - uint8_t NoOfDevices; - - /* Store the compliant sectors */ - uint8_t SectCompl[40]; - - /* Flag to know that MAD sector */ - uint8_t WrMADBlkFlag; - - /* Fill the MAD sector blocks */ - uint8_t MADSectBlk[80]; - - /* Fill the MAD sector blocks */ - uint8_t UpdMADBlk; -} phFriNfc_MfStd_AddInfo_t; - - - /* - * \ingroup grp_fri_smart_card_formatting - * \brief NFC Smart Card Formatting Component ISO-15693 Additional Information Structure - * - * This structure is used to specify additional information required to format the ISO-15693 card. - * \note - * On requirement basis,structure will be filled/modified with other parametes - * during the implementation phase. - * - */ - typedef struct phFriNfc_ISO15693_AddInfo - { - /* Stores the current block executed */ - uint16_t current_block; - /* Sequence executed */ - uint8_t format_seq; - /* Maximum data size in the card */ - uint16_t max_data_size; - }phFriNfc_ISO15693_AddInfo_t; - -/** - * \ingroup grp_fri_smart_card_formatting - * - * \brief NFC Smart Card Formatting Component Additional Information Structure - * - * This structure is composed to have additional information of different type of tags - * Ex: Type1/Type2/Type4/Mifare 1k/4k - * - * \note - * On requirement basis, structure will be filled/modified with other parameters - * during the implementation phase. - */ -typedef struct phFriNfc_sNdefSmtCrdFmt_AddInfo -{ - phFriNfc_Type1_AddInfo_t Type1Info; - phFriNfc_Type2_AddInfo_t Type2Info; - phFriNfc_Type4_AddInfo_t Type4Info; - phFriNfc_MfStd_AddInfo_t MfStdInfo; - phFriNfc_ISO15693_AddInfo_t s_iso15693_info; - -}phFriNfc_sNdefSmtCrdFmt_AddInfo_t; - -/** - * \ingroup grp_fri_smart_card_formatting - * \brief NFC Smart Card Formatting Component Context Structure - * - * This structure is used to store the current context information of the instance. - * - * \note On requirement basis,structure will be filled/modified with other parameters - * during the implementation phase - * - */ -typedef struct phFriNfc_sNdefSmtCrdFmt -{ - /** Pointer to the lower (HAL) instance.*/ - void *LowerDevice; - - /** Holds the device additional informations*/ - phHal_sDepAdditionalInfo_t psDepAdditionalInfo; - - /** Pointer to the Remote Device Information */ - phHal_sRemoteDevInformation_t *psRemoteDevInfo; - - /** Stores the type of the smart card. */ - uint8_t CardType; - - /** Stores operating mode type of the MifareStd. */ - /* phHal_eOpModes_t OpModeType[2]; */ - - /**< \internal The state of the operation. */ - uint8_t State; - - /**< \internal Stores the card state Ex: Blank/Formatted etc. */ - uint8_t CardState; - - /**< \internal Completion Routine Context. */ - phFriNfc_CplRt_t CompletionRoutine[PH_FRINFC_SMTCRDFMT_CR]; - - /**<\internal Holds the completion routine informations of the Smart Card Formatting Layer*/ - phFriNfc_CplRt_t SmtCrdFmtCompletionInfo; - - /**<\internal Holds the Command Type(read/write)*/ - phHal_uCmdList_t Cmd; - - /**< \internal Holds the length of the received data. */ - uint16_t *SendRecvLength; - - /**<\internal Holds the ack of some intial commands*/ - uint8_t *SendRecvBuf; - - /**< \internal Holds the length of the data to be sent. */ - uint16_t SendLength; - - /**< \internal Stores the output/result of the format procedure. Ex: Formatted Successfully, - Format Error etc */ - NFCSTATUS FmtProcStatus; - - /** Stores Additional Information needed to format the different types of tags*/ - phFriNfc_sNdefSmtCrdFmt_AddInfo_t AddInfo; - - /* Stores NDEF message TLV*/ - /* This stores the different TLV messages for the different card types*/ - uint8_t TLVMsg[PH_FRINFC_SMTCRDFMT_MAX_TLV_TYPE_SUPPORTED][8]; - - -} phFriNfc_sNdefSmtCrdFmt_t; - -/** - * \ingroup grp_fri_smart_card_formatting - * \brief Smart Card Formatting \b Reset function - * - * \copydoc page_reg Resets the component instance to the initial state and initializes the - * internal variables. - * - * \param[in] NdefSmtCrdFmt is a Pointer to a valid and initialized or uninitialised instance - * of \ref phFriNfc_sNdefSmtCrdFmt_t . - * \param[in] LowerDevice Overlapped HAL reference, pointing at a valid instance of this - * underlying component. - * \param[in] psRemoteDevInfo Points to the Remote Device Information structure encapsulating - * the information about the device (Smart card, NFC device) to access. - * \param[in] psDevInputParam The Device input parameter, as used for the HAL POLL function. - * This parameter is needed by the component in special cases, when an internal call - * to POLL is required again, such as for FeliCa. The storage of the structure behind - * the pointer must be retained by the calling software. The component itself only - * keeps the reference. No change is applied to the structure's content. - * \param[in] ReceiveBuffer Pointer to a buffer that the component uses internally use to - * store the data received from the lower component. - * The size shall be at least \ref PH_FRINFC_SMTCRDFMT_MAX_SEND_RECV_BUF_SIZE . - * \param[in] ReceiveLength The size of ReceiveBuffer. This specifies the actual length - * of the data received from the lower component. - * The size shall be at least \ref PH_FRINFC_SMTCRDFMT_MAX_SEND_RECV_BUF_SIZE . - * - * \retval NFCSTATUS_SUCCESS Operation successful. - * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. - * - * \note This function has to be called at the beginning, after creating an instance of - * \ref phFriNfc_sNdefSmtCrdFmt_t . Use this function to reset the instance and/or to switch - * to a different underlying card types. - */ -NFCSTATUS phFriNfc_NdefSmtCrd_Reset(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt, - void *LowerDevice, - phHal_sRemoteDevInformation_t *psRemoteDevInfo, - phHal_sDevInputParam_t *psDevInputParam, - uint8_t *SendRecvBuffer, - uint16_t *SendRecvBuffLen); - - - -/*! - * \ingroup grp_fri_smart_card_formatting - * - * \brief Setting of the Completion Routine. - * - * \copydoc page_ovr This function allows the caller to set a Completion Routine (notifier). - * - * \param[in] NdefSmtCrdFmt Pointer to a valid instance of the \ref phFriNfc_sNdefSmtCrdFmt_t structure describing - * the component context. - * - * \param CompletionRoutine Pointer to a valid completion routine being called when the non-blocking - * operation has finished. - * - * \param CompletionRoutineParam Pointer to a location with user-defined information that is submitted - * to the Completion Routine once it is called. - - * \retval NFCSTATUS_SUCCESS Operation successful. - * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. - * - */ -NFCSTATUS phFriNfc_NdefSmtCrd_SetCR(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt, - uint8_t FunctionID, - pphFriNfc_Cr_t CompletionRoutine, - void *CompletionRoutineContext); - - -/*! - * \ingroup grp_fri_smart_card_formatting - * - * \brief Initiates the card formatting procedure for Remote Smart Card Type. - * - * \copydoc page_ovr The function initiates and formats the Smart Card.After this formation, remote - * card would be properly initialized and Ndef Compliant. - * Depending upon the different card type, this function handles formatting procedure. - * This function also handles the different recovery procedures for different types of the cards. For both - * Format and Recovery Management same API is used. - * - * \param[in] phFriNfc_sNdefSmtCrdFmt_t Pointer to a valid instance of the \ref phFriNfc_sNdefSmartCardFmt_t - * structure describing the component context. - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval Other values An error has occurred. - * - */ -NFCSTATUS phFriNfc_NdefSmtCrd_Format(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt, const uint8_t *ScrtKeyB); - - -#ifdef FRINFC_READONLY_NDEF -/*! - * \ingroup grp_fri_smart_card_formatting - * - * \brief Initiates the conversion of the already NDEF formatted tag to READ ONLY. - * - * \copydoc page_ovr The function initiates the conversion of the already NDEF formatted - * tag to READ ONLY.After this formation, remote card would be properly Ndef Compliant and READ ONLY. - * Depending upon the different card type, this function handles formatting procedure. - * This function supports only for the DESFIRE, MIFARE UL and TOPAZ tags. - * - * \param[in] phFriNfc_sNdefSmtCrdFmt_t Pointer to a valid instance of the \ref phFriNfc_sNdefSmartCardFmt_t - * structure describing the component context. - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval Other values An error has occurred. - * - */ -NFCSTATUS -phFriNfc_NdefSmtCrd_ConvertToReadOnly ( - phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt); - -#endif /* #ifdef FRINFC_READONLY_NDEF */ - - -/** - *\ingroup grp_fri_smart_card_formatting - * - * \brief Smart card Formatting \b Completion \b Routine or \b Process function - * - * \copydoc page_ovr Completion Routine: This function is called by the lower layer (OVR HAL) - * when an I/O operation has finished. The internal state machine decides - * whether to call into the lower device again or to complete the process - * by calling into the upper layer's completion routine, stored within this - * component's context (\ref phFriNfc_sNdefSmtCrdFmt_t). - * - * The function call scheme is according to \ref grp_interact. No State reset is performed during - * operation. - * - * \param[in] Context The context of the current (not the lower/upper) instance, as set by the lower, - * calling layer, upon its completion. - * \param[in] Status The completion status of the lower layer (to be handled by the implementation of - * the state machine of this function like a regular return value of an internally - * called function). - * - * \note For general information about the completion routine interface please see \ref pphFriNfc_Cr_t . * The Different Status Values are as follows - * - */ -void phFriNfc_NdefSmtCrd_Process(void *Context, - NFCSTATUS Status); - -void phFriNfc_SmtCrdFmt_HCrHandler(phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt, - NFCSTATUS Status); - -/*@}*/ - -#endif /* PHFRINFC_SMTCRDFMT_H */ - - diff --git a/libnfc-nxp/phFriNfc_TopazMap.h b/libnfc-nxp/phFriNfc_TopazMap.h deleted file mode 100644 index eb503f8..0000000 --- a/libnfc-nxp/phFriNfc_TopazMap.h +++ /dev/null @@ -1,636 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * \file phFriNfc_TopazMap.h - * \brief NFC Ndef Mapping For Mifare UL Card. - * - * Project: NFC-FRI - * - * $Date: Mon Dec 13 14:14:14 2010 $ - * $Author: ing02260 $ - * $Revision: 1.26 $ - * $Aliases: $ - * - */ - -#ifndef PHFRINFC_TOPAZMAP_H -#define PHFRINFC_TOPAZMAP_H - -#include -#ifdef PH_HAL4_ENABLE -#include -#else -#include -#endif -#include -#include -#include - - -#define PH_FRINFC_NDEFMAP_TOPAZMAP_FILEREVISION "$Revision: 1.26 $" -#define PH_FRINFC_NDEFMAP_TOPAZMAP_FILEALIASES "$Aliases: $" - -#if !defined (ES_HW_VER) - - #define ES_HW_VER (32U) - -#endif /* #if !defined (ES_HW_VER) */ - -#if (ES_HW_VER >= 32) - - /* This macro is used for the new 3.2 chip,as the JEWEL_READ and - JEWEL_WRITE for this chip is removed from the firmware. And for the - new FW, only JEWEL_RAW shall be used */ - #define TOPAZ_RAW_SUPPORT - -#endif /* #if (ES_HW_VER == 32) */ - -#define TOPAZ_UID_LENGTH_FOR_READ_WRITE 0x04U - -/*! - * \name Topaz - states of the Finite State machine - * - */ -/*@{*/ -#define PH_FRINFC_TOPAZ_STATE_READ 1 /*!< Read State */ -#define PH_FRINFC_TOPAZ_STATE_WRITE 2 /*!< Write is going on*/ -#define PH_FRINFC_TOPAZ_STATE_CHK_NDEF 3 /*!< Check Ndef is going on */ -#define PH_FRINFC_TOPAZ_STATE_READID 4 /*!< Read Id under progress */ -#define PH_FRINFC_TOPAZ_STATE_READALL 5 /*!< Read all under progress */ -#define PH_FRINFC_TOPAZ_STATE_WRITE_NMN 6 /*!< Write ndef magic number */ -#define PH_FRINFC_TOPAZ_STATE_WRITE_L_TLV 7 /*!< Write length field of TLV */ -#define PH_FRINFC_TOPAZ_STATE_WR_CC_OR_TLV 8 /*!< Write CC or NDEF TLV */ - -#ifdef FRINFC_READONLY_NDEF - - #define PH_FRINFC_TOPAZ_STATE_WR_CC_BYTE 9 /*!< READ ONLY state */ - #define PH_FRINFC_TOPAZ_STATE_RD_LOCK0_BYTE 10 /*!< read Lock byte 0 state */ - #define PH_FRINFC_TOPAZ_STATE_WR_LOCK0_BYTE 11 /*!< write Lock byte 0 state */ - #define PH_FRINFC_TOPAZ_STATE_RD_LOCK1_BYTE 12 /*!< read Lock byte 1 state */ - #define PH_FRINFC_TOPAZ_STATE_WR_LOCK1_BYTE 13 /*!< write Lock byte 1 state */ - -#endif /* #ifdef FRINFC_READONLY_NDEF */ -/*@}*/ - -/*! - * \name Topaz - constants for the capability container - * - */ -/*@{*/ -#define PH_FRINFC_TOPAZ_CC_BYTE0 0xE1 /*!< Capability container byte 0 = 0xE1 (NMN) */ -#define PH_FRINFC_TOPAZ_CC_BYTE1 0x10 /*!< Capability container byte 1 = 0x10 (version number) */ -#define PH_FRINFC_TOPAZ_CC_BYTE2_MAX 0x0E /*!< Capability container byte 2 = 0x0E (Total free space - in the card) */ -#define PH_FRINFC_TOPAZ_CC_BYTE3_RW 0x00 /*!< Capability container byte 3 = 0x00 for - READ WRITE/INITIALISED card state */ -#define PH_FRINFC_TOPAZ_CC_BYTE3_RO 0x0F /*!< Capability container byte 3 = 0x0F for - READ only card state */ - -/*@}*/ - -/*! - * \name Topaz - constants for Flags - * - */ -/*@{*/ -#define PH_FRINFC_TOPAZ_FLAG0 0 /*!< Flag value = 0 */ -#define PH_FRINFC_TOPAZ_FLAG1 1 /*!< Flag value = 1 */ -/*@}*/ - -/*! - * \name Topaz - constants for left shift - * - */ -/*@{*/ -#define PH_FRINFC_TOPAZ_SHIFT3 3 /*!< Shift by 3 bits */ -/*@}*/ - -/*! - * \name Topaz - internal state for write - * - */ -/*@{*/ -enum -{ - PH_FRINFC_TOPAZ_WR_CC_BYTE0, /*!< CC Byte 0 = 0xE1 ndef magic number */ - PH_FRINFC_TOPAZ_WR_CC_BYTE1, /*!< CC Byte 1 = 0x10 version number */ - PH_FRINFC_TOPAZ_WR_CC_BYTE2, /*!< CC Byte 2 = 0x0C space in the data area */ - PH_FRINFC_TOPAZ_WR_CC_BYTE3, /*!< CC Byte 3 = 0x00 read write access */ - PH_FRINFC_TOPAZ_WR_T_OF_TLV, /*!< CC Byte 3 = 0x00 read write access */ - PH_FRINFC_TOPAZ_WR_NMN_0, /*!< NMN = 0x00 */ - PH_FRINFC_TOPAZ_WR_NMN_E1, /*!< NMN = 0xE1 */ - PH_FRINFC_TOPAZ_WR_L_TLV_0, /*!< L field of TLV = 0 */ - PH_FRINFC_TOPAZ_WR_L_TLV, /*!< To update the L field */ - PH_FRINFC_TOPAZ_DYNAMIC_INIT_CHK_NDEF, /*!< Internal state to represent the parsing of card to locate Ndef TLV*/ - PH_FRINFC_TOPAZ_DYNAMIC_INIT_FIND_NDEF_TLV - - -}; -/*@}*/ - -/*! - * \name Topaz - TLV related constants - * - */ -/*@{*/ -#define PH_FRINFC_TOPAZ_NULL_T 0x00 /*!< Null TLV value = 0x00 */ -#define PH_FRINFC_TOPAZ_LOCK_CTRL_T 0x01 /*!< Lock TLV = 0x01 */ -#define PH_FRINFC_TOPAZ_MEM_CTRL_T 0x02 /*!< Memory TLV = 0x02 */ -#define PH_FRINFC_TOPAZ_NDEF_T 0x03 /*!< NDEF TLV = 0x03 */ -#define PH_FRINFC_TOPAZ_PROP_T 0xFD /*!< NDEF TLV = 0xFD */ -#define PH_FRINFC_TOPAZ_TERM_T 0xFE /*!< Terminator TLV value = 0xFE */ - -#define PH_FRINFC_TOPAZ_NDEFTLV_L 0x00 /*!< Length value of TLV = 0x00 */ -#define PH_FRINFC_TOPAZ_NDEFTLV_LFF 0xFF /*!< Length value of TLV = 0xFF */ -#define PH_FRINFC_TOPAZ_MAX_CARD_SZ 0x60 /*!< Send Length for Read Ndef */ -/*@}*/ - - -/*! - * \name Topaz - Standard constants - * - */ -/*@{*/ -#define PH_FRINFC_TOPAZ_WR_A_BYTE 0x02 /*!< Send Length for Write Ndef */ -#define PH_FRINFC_TOPAZ_SEND_BUF_READ 0x01 /*!< Send Length for Read Ndef */ -#define PH_FRINFC_TOPAZ_HEADROM0_CHK 0xFF /*!< To check the header rom byte 0 */ -#define PH_FRINFC_TOPAZ_HEADROM0_VAL 0x11 /*!< Header rom byte 0 value of static card */ -#define PH_FRINFC_TOPAZ_READALL_RESP 0x7A /*!< Response of the read all command 122 bytes */ -#define PH_FRINFC_TOPAZ_TOTAL_RWBYTES 0x60 /*!< Total number of raw Bytes that can - be read or written to the card 96 bytes */ -#define PH_FRINFC_TOPAZ_TOTAL_RWBYTES1 0x5A /*!< Total number of bytes that can be read - or written 90 bytes */ -#define PH_FRINFC_TOPAZ_BYTE3_MSB 0xF0 /*!< most significant nibble of byte 3(RWA) shall be - 0 */ -#define PH_FRINFC_TOPAZ_LOCKBIT_BYTE114 0x01 /*!< lock bits value of byte 104 */ -#define PH_FRINFC_TOPAZ_LOCKBIT_BYTE115_1 0x60 /*!< lock bits value of byte 105 */ -#define PH_FRINFC_TOPAZ_LOCKBIT_BYTE115_2 0xE0 /*!< lock bits value of byte 105 */ -#define PH_FRINFC_TOPAZ_LOCKBIT_BYTENO_0 114 /*!< lock bits byte number 104 */ -#define PH_FRINFC_TOPAZ_LOCKBIT_BYTENO_1 115 /*!< lock bits byte number 105 */ -#define PH_FRINFC_TOPAZ_CC_BYTENO_3 13 /*! Lock status according to CC bytes */ -#define PH_FRINFC_TOPAZ_CC_READWRITE 0x00 /*! Lock status according to CC bytes */ -#define PH_FRINFC_TOPAZ_CC_READONLY 0x0F /*! Lock status according to CC bytes */ - -/**Topaz static commands*/ -#define PH_FRINFC_TOPAZ_CMD_READID 0x78U -#define PH_FRINFC_TOPAZ_CMD_READALL 0x00U -#define PH_FRINFC_TOPAZ_CMD_READ 0x01U -#define PH_FRINFC_TOPAZ_CMD_WRITE_1E 0x53U -#define PH_FRINFC_TOPAZ_CMD_WRITE_1NE 0x1AU - -/**Topaz Dynamic commands*/ -#define PH_FRINFC_TOPAZ_CMD_RSEG 0x10U -#define PH_FRINFC_TOPAZ_CMD_READ8 0x02U -#define PH_FRINFC_TOPAZ_CMD_WRITE_E8 0x54U -#define PH_FRINFC_TOPAZ_CMD_WRITE_NE8 0x1BU - -enum -{ - PH_FRINFC_TOPAZ_VAL0, - PH_FRINFC_TOPAZ_VAL1, - PH_FRINFC_TOPAZ_VAL2, - PH_FRINFC_TOPAZ_VAL3, - PH_FRINFC_TOPAZ_VAL4, - PH_FRINFC_TOPAZ_VAL5, - PH_FRINFC_TOPAZ_VAL6, - PH_FRINFC_TOPAZ_VAL7, - PH_FRINFC_TOPAZ_VAL8, - PH_FRINFC_TOPAZ_VAL9, - PH_FRINFC_TOPAZ_VAL10, - PH_FRINFC_TOPAZ_VAL11, - PH_FRINFC_TOPAZ_VAL12, - PH_FRINFC_TOPAZ_VAL13, - PH_FRINFC_TOPAZ_VAL14, - PH_FRINFC_TOPAZ_VAL15, - PH_FRINFC_TOPAZ_VAL16, - PH_FRINFC_TOPAZ_VAL17, - PH_FRINFC_TOPAZ_VAL18 -}; - - -/*@}*/ - -/*! - * \brief \copydoc page_reg Resets the component instance to the initial state and lets the component forget about - * the list of registered items. Moreover, the lower device is set. - * - * \param[in] NdefMap Pointer to a valid or uninitialised instance of \ref phFriNfc_NdefMap_t . - * - * \note This function has to be called at the beginning, after creating an instance of - * \ref phFriNfc_NdefMap_t . Use this function to reset the instance and/or switch - * to a different underlying device (different NFC device or device mode, or different - * Remote Device). - */ -void phFriNfc_TopazMap_H_Reset( phFriNfc_NdefMap_t *NdefMap); - -#ifdef FRINFC_READONLY_NDEF - -/*! - * \ingroup grp_fri_smart_card_formatting - * - * \brief Initiates the conversion of the already NDEF formatted tag to READ ONLY. - * - * \copydoc page_ovr The function initiates the conversion of the already NDEF formatted - * tag to READ ONLY.After this formation, remote card would be properly Ndef Compliant and READ ONLY. - * Depending upon the different card type, this function handles formatting procedure. - * This function supports only for the TOPAZ tags. - * - * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing - * the component context. - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval Other values An error has occurred. - * - */ -NFCSTATUS -phFriNfc_TopazMap_ConvertToReadOnly ( - phFriNfc_NdefMap_t *NdefMap); - -#endif /* #ifdef FRINFC_READONLY_NDEF */ - -/*! - * \brief \copydoc page_ovr Initiates Reading of NDEF information from the Remote Device. - * - * The function initiates the reading of NDEF information from a Remote Device. - * It performs a reset of the state and starts the action (state machine). - * A periodic call of the \ref phFriNfc_NdefMap_Process has to be done once the action - * has been triggered. - * - * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing - * the component context. - * - * \param[in] PacketData Pointer to a location that receives the NDEF Packet. - * - * \param[in,out] PacketDataLength Pointer to a variable receiving the length of the NDEF packet. - * - * \param[in] Offset Indicates whether the read operation shall start from the begining of the - * file/card storage \b or continue from the last offset. The last Offset set is stored - * within a context variable (must not be modified by the integration). - * If the caller sets the value to \ref PH_FRINFC_NDEFMAP_SEEK_CUR, the component shall - * start reading from the last offset set (continue where it has stopped before). - * If set to \ref PH_FRINFC_NDEFMAP_SEEK_BEGIN, the component shall start reading - * from the begining of the card (restarted) - * - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval NFCSTATUS_INVALID_DEVICE_REQUEST If Previous Operation is Write Ndef and Offset - * is Current then this error is displayed. - * \retval NFCSTATUS_EOF_NDEF_CONTAINER_REACHED No Space in the File to read. - * \retval NFCSTATUS_MORE_INFORMATION There are more bytes to read in the card. - * \retval NFCSTATUS_SUCCESS Last Byte of the card read. - * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected - * meanwhile. - * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request. - * \retval NFCSTATUS_BUFFER_TOO_SMALL The buffer provided by the caller is too small. - * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period. - * - */ - -NFCSTATUS phFriNfc_TopazMap_RdNdef( phFriNfc_NdefMap_t *NdefMap, - uint8_t *PacketData, - uint32_t *PacketDataLength, - uint8_t Offset); - - - -/*! - * \brief \copydoc page_ovr Initiates Writing of NDEF information to the Remote Device. - * - * The function initiates the writing of NDEF information to a Remote Device. - * It performs a reset of the state and starts the action (state machine). - * A periodic call of the \ref phFriNfc_NdefMap_Process has to be done once the action - * has been triggered. - * - * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing - * the component context. - * - * \param[in] PacketData Pointer to a location that holds the prepared NDEF Packet. - * - * \param[in,out] PacketDataLength Variable specifying the length of the prepared NDEF packet. - * - * \param[in] Offset Indicates whether the write operation shall start from the begining of the - * file/card storage \b or continue from the last offset. The last Offset set is stored - * within a context variable (must not be modified by the integration). - * If the caller sets the value to \ref PH_FRINFC_NDEFMAP_SEEK_CUR, the component shall - * start writing from the last offset set (continue where it has stopped before). - * If set to \ref PH_FRINFC_NDEFMAP_SEEK_BEGIN, the component shall start writing - * from the begining of the card (restarted) - * - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval NFCSTATUS_INVALID_DEVICE_REQUEST If Previous Operation is Write Ndef and Offset - * is Current then this error is displayed. - * \retval NFCSTATUS_EOF_NDEF_CONTAINER_REACHED Last byte is written to the card after this - * no further writing is possible. - * \retval NFCSTATUS_SUCCESS Buffer provided by the user is completely written - * into the card. - * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected - * meanwhile. - * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request. - * \retval NFCSTATUS_BUFFER_TOO_SMALL The buffer provided by the caller is too small. - * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period. - * - */ - -NFCSTATUS phFriNfc_TopazMap_WrNdef( phFriNfc_NdefMap_t *NdefMap, - uint8_t *PacketData, - uint32_t *PacketDataLength, - uint8_t Offset); - -/*! - * \brief \copydoc page_ovr Check whether a particulat Remote Device is NDEF compliant. - * - * The function checks whether the peer device is NDEF compliant. - * - * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing - * the component context. - * - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. - * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected - * meanwhile. - * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request. - * \retval NFCSTATUS_BUFFER_TOO_SMALL The buffer provided by the caller is too small. - * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period. - * - */ - -NFCSTATUS phFriNfc_TopazMap_ChkNdef( phFriNfc_NdefMap_t *NdefMap); - -extern NFCSTATUS phFriNfc_Tpz_H_ChkSpcVer( phFriNfc_NdefMap_t *NdefMap, - uint8_t VersionNo); - - -/*! - * \brief \copydoc page_cb Completion Routine, Processing function, needed to avoid long blocking. - * - * The function call scheme is according to \ref grp_interact. No State reset is performed during operation. - * - * \copydoc pphFriNfc_Cr_t - * - * \note The lower (Overlapped HAL) layer must register a pointer to this function as a Completion - * Routine in order to be able to notify the component that an I/O has finished and data are - * ready to be processed. - * - */ - -void phFriNfc_TopazMap_Process( void *Context, - NFCSTATUS Status); - - -/*! - * \name TopazDynamicMap - Following section describes constans, functions, variables used in - * Topaz Dyanmic card mapping. Ex : Topaz-512 - * - */ -/*@{*/ -/*! - * \brief \copydoc Dynamic Card supported definitions. - * \note State Mechine Delcations. - */ - -#define PH_FRINFC_TOPAZ_DYNAMIC_STATE_WRITE_COMPLETE 11 /*!< Write Operation Complete */ -#define PH_FRINFC_TOPAZ_DYNAMIC_STATE_NXP_READ 12 -#define PH_FRINFC_TOPAZ_DYNAMIC_STATE_RD_CCBLK 13 -#define PH_FRINFC_TOPAZ_DYNAMIC_STATE_INIT_RD_CCBLK 14 -#define PH_FRINFC_TOPAZ_DYNAMIC_STATE_INIT_WR 15 -#define PH_FRINFC_TOPAZ_DYNAMIC_STATE_WRITE_LEN 16 -#define PH_FRINFC_TOPAZ_DYNAMIC_STATE_FIND_NDEF_TLV 17 -#define PH_FRINFC_TOPAZ_DYNAMI_FOUND_RESERV_AREA 18 -#define PH_FRINFC_TOPAZ_DYNAMIC_NOT_FOUND_RESERV_AREA 19 -#define PH_FRINFC_TOPAZ_DYNAMIC_PROCESS_CHK_NDEF 20 -#define PH_FRINFC_TOPAZ_DYNAMIC_FIND_NDEF_TLV 21 -#define PH_FRINFC_TOPAZ_DYNAMIC_INIT_RD_NDEF 22 -#define PH_FRINFC_TOPAZ_DYNAMIC_STATE_WR_MEM_TLV 23 -#define PH_FRINFC_TOPAZ_DYNAMIC_STATE_WR_LOCK_TLV 24 - -/*! - * \brief \copydoc Dynamic Card : Capability Container bytes. - * \note State Mechine Delcations. - */ - -#define PH_FRINFC_TOPAZ_DYNAMIC_CC_BYTE2_MMSIZE 0x3F /*!< Capability container byte 2 = 0x3F (Total free space - in the card) */ -#define PH_FRINFC_TOPAZ_DYNAMIC_HEADROM0_VAL 0x12 /*!< Header rom byte 0 value of dynamic card */ - -#define PH_FRINFC_TOPAZ_DYNAMIC_TOTAL_RWBYTES 0x1CC /*!< Total number of raw Bytes that can - be read or written to the card 460 bytes - 460 = 512 - 6 bloks * 8(48)( this includes 2 bytes of null byte in 02 block) - - 4 bytes ( NDEF TLV )*/ -#define PH_FRINFC_TOPAZ_DYNAMIC_MAX_CARD_SZ 0x1E0 /*!< Card size */ -#define PH_FRINFC_TOPAZ_DYNAMIC_MX_ONEBYTE_TLV_SIZE 0xFF /*!< MAX size supported in one byte length TLV*/ -#define PH_FRINFC_TOPAZ_DYNAMIC_MAX_DATA_SIZE_TO_WRITE 0xE6 /*!< MAX size supported by HAL if the data size > 255*/ - -#define PH_FRINFC_TOPAZ_DYNAMIC_LOCKBYTE_0 0x00 /*!< lock bits value of byte 104 */ -#define PH_FRINFC_TOPAZ_DYNAMIC_LOCKBYTE_1 0x00 /*!< lock bits value of byte 105 */ -#define PH_FRINFC_TOPAZ_DYNAMIC_LOCKBYTE_2TO7 0x00 /*!< lock bits value of byte 105 */ - -#define PH_FRINFC_TOPAZ_DYNAMIC_LOCKBIT_BYTENO_0 112 /*!< lock bits byte number 104:Blk0-7 */ -#define PH_FRINFC_TOPAZ_DYNAMIC_LOCKBIT_BYTENO_1 113 /*!< lock bits byte number 105:Blk08-F */ -#define PH_FRINFC_TOPAZ_DYNAMIC_LOCKBIT_BYTENO_2 122 /*!< lock bits byte number 124:Blk10-17 */ -#define PH_FRINFC_TOPAZ_DYNAMIC_LOCKBIT_BYTENO_3 123 /*!< lock bits byte number 125:Blk18-1F */ -#define PH_FRINFC_TOPAZ_DYNAMIC_LOCKBIT_BYTENO_4 124 /*!< lock bits byte number 126:Blk20-27*/ -#define PH_FRINFC_TOPAZ_DYNAMIC_LOCKBIT_BYTENO_5 125 /*!< lock bits byte number 127:Blk28-2F*/ -#define PH_FRINFC_TOPAZ_DYNAMIC_LOCKBIT_BYTENO_6 126 /*!< lock bits byte number 128:Blk30-37*/ -#define PH_FRINFC_TOPAZ_DYNAMIC_LOCKBIT_BYTENO_7 127 /*!< lock bits byte number 128:Blk30-37*/ -#define PH_FRINFC_TOPAZ_DYNAMIC_CC_BYTENO_3 11 /*! Lock status according to CC bytes */ - -#define PH_FRINFC_TOPAZ_DYNAMIC_SEGMENT0 0x00 /*!< 00000000 : 0th segment */ -#define PH_FRINFC_TOPAZ_DYNAMIC_READSEG_RESP 0x80 - -#define PH_FRINFC_TOPAZ_DYNAMIC_MAX_BYTES_TO_READ_IN_ONEB_LTLV_FSEG 78 -#define PH_FRINFC_TOPAZ_DYNAMIC_MAX_BYTES_TO_READ_IN_THREEB_LTLV_FSEG 76 - -#define PH_FRINFC_TOPAZ_DYNAMIC_MAX_DATA_SIZE PHHAL_MAX_DATASIZE -#define PH_FRINFC_TOPAZ_DYNAMIC_FSEG_BYTE_COUNT 104 -#define PH_FRINFC_TOPAZ_DYNAMIC_SEG_BYTE_COUNT 128 -#define PH_FRINFC_TOPAZ_DYNAMIC_CC_BLK_SIZE 18 -#define PH_FRINFC_TOPAZ_DYNAMIC_CC_BLK_ADDRESS 8 -#define PH_FRINFC_TOPAZ_DYNAMIC_UID_BLK_ADDRESS 0 -#define PH_FRINFC_TOPAZ_DYNAMIC_LOCK_BYTE_SIZE 24 -#define PH_FRINFC_TOPAZ_DYNAMIC_FSEG_TOT_DATA_BYTES 120 - -#define PH_FRINFC_TOPAZ_DYNAMIC_DATA_BYTE_COUNT_OF_FSEG_IN_ONEB_LTLV_FSEG 26 -#define PH_FRINFC_TOPAZ_DYNAMIC_DATA_BYTE_COUNT_OF_FSEG_IN_THREEB_LTLV_FSEG 28 - - -enum -{ - - NULL_TLV, - LOCK_TLV, - MEM_TLV, - NDEF_TLV, - PROP_TLV, - TERM_TLV, - INVALID_TLV, - VALID_TLV, - TLV_NOT_FOUND - -}; - -/*! - * \brief \copydoc page_ovr Initiates Reading of NDEF information from the Remote Device. - * - * The function initiates the reading of NDEF information from a Remote Device. - * It performs a reset of the state and starts the action (state machine). - * A periodic call of the \ref phFriNfc_NdefMap_Process has to be done once the action - * has been triggered. - * - * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing - * the component context. - * - * \param[in] PacketData Pointer to a location that receives the NDEF Packet. - * - * \param[in,out] PacketDataLength Pointer to a variable receiving the length of the NDEF packet. - * - * \param[in] Offset Indicates whether the read operation shall start from the begining of the - * file/card storage \b or continue from the last offset. The last Offset set is stored - * within a context variable (must not be modified by the integration). - * If the caller sets the value to \ref PH_FRINFC_NDEFMAP_SEEK_CUR, the component shall - * start reading from the last offset set (continue where it has stopped before). - * If set to \ref PH_FRINFC_NDEFMAP_SEEK_BEGIN, the component shall start reading - * from the begining of the card (restarted) - * - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval NFCSTATUS_INVALID_DEVICE_REQUEST If Previous Operation is Write Ndef and Offset - * is Current then this error is displayed. - * \retval NFCSTATUS_EOF_NDEF_CONTAINER_REACHED No Space in the File to read. - * \retval NFCSTATUS_MORE_INFORMATION There are more bytes to read in the card. - * \retval NFCSTATUS_SUCCESS Last Byte of the card read. - * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected - * meanwhile. - * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request. - * \retval NFCSTATUS_BUFFER_TOO_SMALL The buffer provided by the caller is too small. - * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period. - * - */ - -NFCSTATUS phFriNfc_TopazDynamicMap_RdNdef( phFriNfc_NdefMap_t *NdefMap, - uint8_t *PacketData, - uint32_t *PacketDataLength, - uint8_t Offset); - -/*! - * \brief \copydoc page_ovr Initiates Writing of NDEF information to the Remote Device. - * - * The function initiates the writing of NDEF information to a Remote Device. - * It performs a reset of the state and starts the action (state machine). - * A periodic call of the \ref phFriNfc_NdefMap_Process has to be done once the action - * has been triggered. - * - * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing - * the component context. - * - * \param[in] PacketData Pointer to a location that holds the prepared NDEF Packet. - * - * \param[in,out] PacketDataLength Variable specifying the length of the prepared NDEF packet. - * - * \param[in] Offset Indicates whether the write operation shall start from the begining of the - * file/card storage \b or continue from the last offset. The last Offset set is stored - * within a context variable (must not be modified by the integration). - * If the caller sets the value to \ref PH_FRINFC_NDEFMAP_SEEK_CUR, the component shall - * start writing from the last offset set (continue where it has stopped before). - * If set to \ref PH_FRINFC_NDEFMAP_SEEK_BEGIN, the component shall start writing - * from the begining of the card (restarted) - * - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval NFCSTATUS_INVALID_DEVICE_REQUEST If Previous Operation is Write Ndef and Offset - * is Current then this error is displayed. - * \retval NFCSTATUS_EOF_NDEF_CONTAINER_REACHED Last byte is written to the card after this - * no further writing is possible. - * \retval NFCSTATUS_SUCCESS Buffer provided by the user is completely written - * into the card. - * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected - * meanwhile. - * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request. - * \retval NFCSTATUS_BUFFER_TOO_SMALL The buffer provided by the caller is too small. - * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period. - * - */ -NFCSTATUS phFriNfc_TopazDynamicMap_WrNdef( phFriNfc_NdefMap_t *NdefMap, - uint8_t *PacketData, - uint32_t *PacketDataLength, - uint8_t Offset); - -/*! - * \brief \copydoc page_ovr Check whether a particulat Remote Device is NDEF compliant. - * - * The function checks whether the peer device is NDEF compliant. - * - * \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing - * the component context. - * - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. - * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected - * meanwhile. - * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request. - * \retval NFCSTATUS_BUFFER_TOO_SMALL The buffer provided by the caller is too small. - * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period. - * - */ -NFCSTATUS phFriNfc_TopazDynamicMap_ChkNdef( phFriNfc_NdefMap_t *NdefMap); - -/*! - * \brief \copydoc page_cb Completion Routine, Processing function, needed to avoid long blocking. - * - * The function call scheme is according to \ref grp_interact. No State reset is performed during operation. - * - * \copydoc pphFriNfc_Cr_t - * - * \note The lower (Overlapped HAL) layer must register a pointer to this function as a Completion - * Routine in order to be able to notify the component that an I/O has finished and data are - * ready to be processed. - * - */ -void phFriNfc_TopazDynamicMap_Process( void *Context, - NFCSTATUS Status); - -#ifdef FRINFC_READONLY_NDEF -/*! - * \brief \copydoc page_ovr Initiates Writing of NDEF information to the Remote Device. - * - * The function initiates the writing of NDEF information to a Remote Device. - * It performs a reset of the state and starts the action (state machine). - * A periodic call of the \ref phFriNfc_NdefMap_Process has to be done once the action - * has been triggered. - * - * \param[in] psNdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing - * the component context. - * - * - * \retval NFCSTATUS_PENDING The action has been successfully triggered. - * \retval NFCSTATUS_INVALID_DEVICE_REQUEST If Previous Operation is Write Ndef and Offset - * is Current then this error is displayed. - * \retval NFCSTATUS_EOF_NDEF_CONTAINER_REACHED Last byte is written to the card after this - * no further writing is possible. - * \retval NFCSTATUS_SUCCESS Buffer provided by the user is completely written - * into the card. - * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected - * meanwhile. - * \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request. - * \retval NFCSTATUS_BUFFER_TOO_SMALL The buffer provided by the caller is too small. - * \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period. - * - */ -NFCSTATUS -phFriNfc_TopazDynamicMap_ConvertToReadOnly ( - phFriNfc_NdefMap_t *psNdefMap); -#endif /* #ifdef FRINFC_READONLY_NDEF */ - - - -#endif /* PHFRINFC_TOPAZMAP_H */ - diff --git a/libnfc-nxp/phHal4Nfc.h b/libnfc-nxp/phHal4Nfc.h deleted file mode 100644 index 47e3136..0000000 --- a/libnfc-nxp/phHal4Nfc.h +++ /dev/null @@ -1,1169 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -/** - * \file phHal4Nfc.h - * \brief HAL Function Prototypes - * The HAL4.0 API provides the user to have a interface for PN544(PN54x)/PN65N - * NFC device.The API is a non-blocking API, asynchronous API. This means that - * when ever an API function call results in waiting for a response from the - * NFC device, the API function will return immediately with status 'PENDING' - * and the actual result will be returned through specific callback functions - * on receiving the response from the NFC device - * - * \note This is the representative header file of the HAL 4.0. The release - * TAG or label is representing the release TAG (alias) of the entire - * library.A mechanism (see documentation \ref hal_release_label near - * the include guards of this file) is used to propagate the alias to - * the main documentation page. - * - * Project: NFC-FRI-1.1 / HAL4.0 - * - * $Date: Mon Jun 14 11:36:12 2010 $ - * $Author: ing07385 $ - * $Revision: 1.171 $ - * $Aliases: NFC_FRI1.1_WK1023_R35_2,NFC_FRI1.1_WK1023_R35_1 $ - * - */ - -/** page hal_release_label HAL 4.0 Release Label - * SDK_HAL_4.0 v 0.1 Draft - * \note This is the TAG (label, alias) of the HAL. If the string is empty,the - * current documentation has not been generated from an official release. - */ -/*@{*/ -#ifndef PHHAL4NFC_H -#define PHHAL4NFC_H -/*@}*/ - - -/** - * \name HAL4 - * - * File: \ref phHal4Nfc.h - *\def hal - */ - -/*@{*/ -#define PH_HAL4NFC_FILEREVISION "$Revision: 1.171 $" /**< \ingroup grp_file_attributes */ -#define PH_HAL4NFC_FILEALIASES "$Aliases: NFC_FRI1.1_WK1023_R35_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ -/*@}*/ - -/* -----------------Include files ---------------------------------------*/ -#include -#include -#include -#include -#include -#include -#include -#ifdef ANDROID -#include -#endif - -/*************************** Includes *******************************/ -/** \defgroup grp_mw_external_hal_funcs NFC HAL4.0 -* -* -* -*/ -/* ---------------- Macros ----------------------------------------------*/ - -/** HAL Implementation Version Macros : Updated for every feature release of - HAL functionality */ -#define PH_HAL4NFC_VERSION 8 -#define PH_HAL4NFC_REVISION 21 -#define PH_HAL4NFC_PATCH 1 -#define PH_HAL4NFC_BUILD 0 - -/** HAL Interface Version Macros : Updated for every external release of - HAL Interface */ -#define PH_HAL4NFC_INTERFACE_VERSION 0 -#define PH_HAL4NFC_INTERFACE_REVISION 6 -#define PH_HAL4NFC_INTERFACE_PATCH 0 -#define PH_HAL4NFC_INTERAFECE_BUILD 0 - -/**Maximum length of receive buffer maintained by HAL*/ -#define PH_HAL4NFC_MAX_RECEIVE_BUFFER 4096U - -/**Send length used for Transceive*/ -#define PH_HAL4NFC_MAX_SEND_LEN PHHAL_MAX_DATASIZE - -/* -----------------Structures and Enumerations -------------------------*/ - -/** - * \ingroup grp_mw_external_hal_funcs - * - * Structure containing information about discovered remote device, like - * the number of remote devices found, device specific information - * like type of device (eg: ISO14443-4A/4B, NFCIP1 target etc) and - * the type sepcific information (eg: UID, SAK etc). This structure is - * returned as part of the disocvery notification. For more info refer - * \ref phHal4Nfc_ConfigureDiscovery, - * \ref phHal4Nfc_RegisterNotification, - * \ref pphHal4Nfc_Notification_t, - * phHal4Nfc_NotificationInfo_t - * - * - */ -typedef struct phHal4Nfc_DiscoveryInfo -{ - uint32_t NumberOfDevices;/**< Number of devices found */ - phHal_sRemoteDevInformation_t **ppRemoteDevInfo;/**< Pointer to Remote - device info list*/ -}phHal4Nfc_DiscoveryInfo_t; - -/** - * \ingroup grp_mw_external_hal_funcs - * - * This is a union returned as part of the \ref pphHal4Nfc_Notification_t - * callback. It contains either discovery information or other event - * information for which the client has registered using the - * \ref phHal4Nfc_RegisterNotification. - */ -typedef union -{ - phHal4Nfc_DiscoveryInfo_t *psDiscoveryInfo; - phHal_sEventInfo_t *psEventInfo; -}phHal4Nfc_NotificationInfo_t; - - - -/** -* \ingroup grp_mw_external_hal_funcs -* -* Prototype for Generic callback type provided by upper layer. This is used -* to return the success or failure status an asynchronous API function which -* does not have any other additional information to be returned. Refer -* specific function for applicable status codes. -*/ -typedef void (*pphHal4Nfc_GenCallback_t)( - void *context, - NFCSTATUS status - ); - -/** -* \ingroup grp_mw_external_hal_funcs -* -* Disconnect callback type provided by upper layer to called on completion -* of disconnect call \ref phHal4Nfc_Disconnect. -* -*/ -typedef void (*pphHal4Nfc_DiscntCallback_t)( - void *context, - phHal_sRemoteDevInformation_t *psDisconnectDevInfo, - NFCSTATUS status - ); - -/** -* \ingroup grp_mw_external_hal_funcs -* -* Notification callback type used by HAL to provide a Discovery or -* Event notification to the upper layer. -* -*/ -typedef void (*pphHal4Nfc_Notification_t) ( - void *context, - phHal_eNotificationType_t type, - phHal4Nfc_NotificationInfo_t info, - NFCSTATUS status - ); - - -/** -* \ingroup grp_mw_external_hal_funcs -* -* Callback type used to provide a Connect Success or Failure indication to -* the upper layer as a result of \ref phHal4Nfc_Connect call used to connect -* to discovered remote device. -* -*/ -typedef void (*pphHal4Nfc_ConnectCallback_t)( - void *context, - phHal_sRemoteDevInformation_t *psRemoteDevInfo, - NFCSTATUS status - ); - -/** -* \ingroup grp_mw_external_hal_funcs -* -* This callback type is used to provide received data and it's size to the -* upper layer in \ref phNfc_sData_t format ,when the upper layer has performed -* a Transceive operation on a tag or when the Device acts as an Initiator in a -* P2P transaction. -* -* -*/ -typedef void (*pphHal4Nfc_TransceiveCallback_t) ( - void *context, - phHal_sRemoteDevInformation_t *ConnectedDevice, - phNfc_sData_t *pRecvdata, - NFCSTATUS status - ); - -/** -* \ingroup grp_mw_external_hal_funcs -* -* This callback type is used to provide received data and it's size to the -* upper layer in \ref phNfc_sData_t structure, when the upper layer when the -* Device acts as a Target in a P2P transaction. -* -* -*/ -typedef void (*pphHal4Nfc_ReceiveCallback_t) ( - void *context, - phNfc_sData_t *pDataInfo, - NFCSTATUS status - ); - -/** -* \ingroup grp_mw_external_hal_funcs -* -* Callback type to inform success or failure of the Ioctl calls -* made by upper layer. It may optionally contain response data -* depending on the Ioctl command issued. -* -*/ -typedef void (*pphHal4Nfc_IoctlCallback_t) (void *context, - phNfc_sData_t *pOutData, - NFCSTATUS status ); - -/** -* \ingroup grp_mw_external_hal_funcs -*\if hal -* \sa \ref pphHal4Nfc_GenCallback_t -* \endif -* -*/ - -/** Same as general callback type, used to inform the completion of -* \ref phHal4Nfc_Send call done by when in NFCIP1 Target mode -*/ -typedef pphHal4Nfc_GenCallback_t pphHal4Nfc_SendCallback_t; - -/** -* \ingroup grp_mw_external_hal_funcs -* -* Enum type to distinguish between normal init and test mode init -* to be done as part of phHal4Nfc_Open -* In test mode init only minimal initialization of the NFC Device -* sufficient to run the self test is performed. -* -* \note Note: No functional features can be accessed when -* phHal4Nfc_Open is called with TestModeOn -* \ref phHal4Nfc_Open -* -*/ -typedef enum{ - eInitDefault = 0x00, /** - * pOpenCallback is called. It uses a Hardware Reference - * \ref phHal_sHwReference, allocated by the upper layer and the p_board_driver - * member initialized with the dal_instance (handle to the communication driver) - * and other members initialized to zero or NULL. - * - * \note - * - The device is in initialized state after the command has completed - * successfully. - * - * - * \param[in,out] psHwReference Hardware Reference, pre-initialized by upper - * layer. Members of this structure are made valid if - * this function is successful. \n - * - * \param[in] InitType Initialization type, used to differentiate between - * test mode limited initialization and normal init. - * - * \param[in] pOpenCallback The open callback function called by the HAL - * when open (initialization) sequence is completed or if there - * is an error in initialization. \n - * - * \param[in] pContext Upper layer context which will be included in the - * call back when request is completed. \n - * - * \retval NFCSTATUS_PENDING Open sequence has been successfully - * started and result will be conveyed - * via the pOpenCallback function. - * \retval NFCSTATUS_ALREADY_INITIALISED Device initialization already in - * progress. - * \retval NFCSTATUS_INVALID_PARAMETER The parameter could not be properly - * interpreted (structure uninitialized?). - * \retval NFCSTATUS_INSUFFICIENT_RESOURCES Insufficient resources for - * completing the request. - * \retval Others Errors related to the lower layers. - * - * \if hal - * \sa \ref phHal4Nfc_Close, - * \endif - */ -extern NFCSTATUS phHal4Nfc_Open( - phHal_sHwReference_t *psHwReference, - phHal4Nfc_InitType_t InitType, - pphHal4Nfc_GenCallback_t pOpenCallback, - void *pContext - ); - - - -/** - * \if hal - * \ingroup grp_hal_common - * \else - * \ingroup grp_mw_external_hal_funcs - * \endif - * - * Retrieves the capabilities of the device represented by the Hardware - * Reference parameter.The HW, FW versions,model-id and other capability - * information are located inside the pDevCapabilities parameter. - * - * \param[in] psHwReference Hardware Reference, pre-initialized - * by upper layer. \n - * \param[out] psDevCapabilities Pointer to the device capabilities structure - * where all relevant capabilities of the - * peripheral are stored. \n - * \param[in] pContext Upper layer context which will be included in - * the call back when request is completed. \n - * - * \retval NFCSTATUS_SUCCESS Success and the psDevCapabilities is - * updated with info. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be properly interpreted. - * \retval NFCSTATUS_NOT_INITIALISED Hal is not yet initialized. - * \retval Others Errors related to the lower layers. - * - */ -extern NFCSTATUS phHal4Nfc_GetDeviceCapabilities( - phHal_sHwReference_t *psHwReference, - phHal_sDeviceCapabilities_t *psDevCapabilities, - void *pContext - ); - - -/** -* \if hal -* \ingroup grp_hal_common -* \else -* \ingroup grp_mw_external_hal_funcs -* \endif -* -* This function is used to Configure discovery wheel (and start if -* required) based on the discovery configuration passed. -* This includes enabling/disabling of the Reader phases (A, B, F), -* NFCIP1 Initiator Speed and duration of the Emulation phase. -* Additional optional parameters for each of the features i.e. Reader, -* Emulation and Peer2Peer can be set using the -* \ref phHal4Nfc_ConfigParameters function -* -* \param[in] psHwReference Hardware Reference, pre-initialized by -* upper layer. \n -* -* \param[in] discoveryMode Discovery Mode allows to choose between: -* discovery configuration and start, stop -* discovery and start discovery (with last -* set configuration). -* \ref phHal_eDiscoveryConfigMode_t -* \note Note: Presently only NFC_DISCOVERY_CONFIG is supported, other values -* are for future use. When in Reader/Initiator mode it mandatory -* to call phHal4Nfc_Connect before any transaction can be performed -* with the discovered device. -* -* \param[in] discoveryCfg Discovery configuration parameters. -* Reader A/Reader B, Felica 212, Felica 424, -* NFCIP1 Speed, Emulation Enable and Duration. -* -* -* \param[in] pConfigCallback This callback has to be called once Hal -* completes the Configuration. -* -* \param[in] pContext Upper layer context to be returned in the -* callback. -* -* \retval NFCSTATUS_INVALID_PARAMETER Wrong Parameter values. -* -* \retval NFCSTATUS_NOT_INITIALISED Hal is not initialized. -* -* \retval NFCSTATUS_BUSY Cannot Configure Hal in -* Current state. -* -* \retval NFCSTATUS_INSUFFICIENT_RESOURCES System Resources insufficient. -* -* \retval NFCSTATUS_PENDING Configuration request accepted -* and Configuration is in progress. -* -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied -* parameters could not be properly -* interpreted. -* \retval Others Errors related to the lower layers -* -* \note Note: When in Reader/Initiator mode it mandatory -* to call phHal4Nfc_Connect before any transaction can be performed -* with the discovered device. Even if the HAL client is not -* interested in using any of the discovered phHal4Nfc_Connect and -* phHal4Nfc_Disconnect should be called to restart the Discovery -* wheel -* -* \ref phHal4Nfc_Connect, phHal4Nfc_Disconnect -* -*/ -extern NFCSTATUS phHal4Nfc_ConfigureDiscovery( - phHal_sHwReference_t *psHwReference, - phHal_eDiscoveryConfigMode_t discoveryMode, - phHal_sADD_Cfg_t *discoveryCfg, - pphHal4Nfc_GenCallback_t pConfigCallback, - void *pContext - ); -/** -* \if hal -* \ingroup grp_hal_common -* \else -* \ingroup grp_mw_external_hal_funcs -* \endif -* -* This function is used to set parameters of various features of the Hal, -* based on the CfgType parameter. Presently following configuration -* types are supported :- -* \n 1. NFC_RF_READER_CONFIG (optional)-> Configure parameters for Reader A -* or Reader B based on the configuration passed -* \n 2. NFC_P2P_CONFIG (optional)-> Congfigure P2P parameters like -* 'General bytes', 'PSL Request' etc. -* \n 3. NFC_EMULATION_CONFIG -> Enable and configure the emulation mode -* parameters for either NFC Target, SmartMX, UICC and -* \n Card Emulation from Host (A, B, F) -* All the configuration modes can be called independent of each other. The -* setting will typically take effect for the next cycle of the relevant -* phase of discovery. For optional configuration internal defaults will be -* used in case the configuration is not set. -* \note Card emulation from Host and Card Emulation from UICC are mutually -* exclusive modes, i.e: only one can be enabled at a time. Using -* this function to enable one of the emulation modes implicitly disables the -* the other. eg. Setting Type A (or Type B) Emulation from Host disables -* card emulation from UICC and vice versa. -* -* \param[in] psHwReference Hardware Reference, pre-initialized by -* upper layer. \n -* -* \param[in] eCfgType Configuration type which can take one of the -* enum values of \ref phHal_eConfigType_t. Each -* config type is associated with its corresponding -* information which is passed using the uCfg structure. -* -* -* \param[in] uCfg Union containing configuration information, -* which will be interpreted based on eCfgType -* parameter. -* -* -* \param[in] pConfigCallback This callback has to be called once Hal -* completes the Configuration. -* -* \param[in] pContext Upper layer context to be returned in the -* callback. -* -* \retval NFCSTATUS_INVALID_PARAMETER Wrong Parameter values. -* -* \retval NFCSTATUS_NOT_INITIALISED Hal is not initialized. -* -* \retval NFCSTATUS_BUSY Cannot Configure Hal in -* Current state. -* -* \retval NFCSTATUS_INSUFFICIENT_RESOURCES System Resources insufficient. -* -* \retval NFCSTATUS_PENDING Configuration request accepted -* and Configuration is in progress. -* -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied -* parameters could not be properly -* interpreted. -* \retval Others Errors related to the lower layers -*/ - -extern NFCSTATUS phHal4Nfc_ConfigParameters( - phHal_sHwReference_t *psHwReference, - phHal_eConfigType_t eCfgType, - phHal_uConfig_t *uCfg, - pphHal4Nfc_GenCallback_t pConfigCallback, - void *pContext - ); - -/** - * \if hal - * \ingroup grp_hal_nfci - * \else - * \ingroup grp_mw_external_hal_funcs - * \endif - * - * This function is called to connect to a one (out of many if multiple - * devices are discovered) already discovered Remote Device notified - * through register notification. The Remote Device Information structure is - * already pre-initialized with data (e.g. from Discovery Notificaiton - * Callback) A new session is started after the connect function returns - * successfully. The session ends with a successful disconnect - * (see \ref phHal4Nfc_Disconnect). - * - * \param[in] psHwReference Hardware Reference, pre-initialized by - * upper layer. \n - * - * \param[in,out] psRemoteDevInfo Points to the Remote Device Information - * structure. The members of it can be - * re-used from a previous session. - * - * \param[in] pNotifyConnectCb Upper layer callback to be called for - * notifying Connect Success/Failure - * - * \param[in] pContext Upper layer context to be returned in - * pNotifyConnectCb. - * - * \retval NFCSTATUS_PENDING Request initiated, result will - * be informed through the callback. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied - * parameters could not be - * properly interpreted. - * \retval NFCSTATUS_FAILED More than one phHal4Nfc_Connect - * is not allowed during a session - * on the same remote device. The - * session has to be closed before - * (see\ref phHal4Nfc_Disconnect). - * \retval NFCSTATUS_NOT_INITIALIZED Hal is not initialized. - * \retval NFCSTATUS_FEATURE_NOT_SUPPORTED Reactivation is not supported for - * NfcIp target and Jewel/Topaz - * remote device types. - * \retval NFCSTATUS_INVALID_REMOTE_DEVICE The Remote Device Identifier is - * not valid. - * \retval Others Errors related to the lower layers. - * - * \if hal - * \sa \ref phHal4Nfc_Disconnect - * \endif - */ -extern NFCSTATUS phHal4Nfc_Connect( - phHal_sHwReference_t *psHwReference, - phHal_sRemoteDevInformation_t *psRemoteDevInfo, - pphHal4Nfc_ConnectCallback_t pNotifyConnectCb, - void *pContext - ); - - -/** - * \if hal - * \ingroup grp_hal_nfci - * \else - * \ingroup grp_mw_external_hal_funcs - * \endif - * - * The phHal4Nfc_Transceive function allows to send data to and receive data - * from the Remote Device selected by the caller.It is also used by the - * NFCIP1 Initiator while performing a transaction with the NFCIP1 target. - * The caller has to provide the Remote Device Information structure and the - * command in order to communicate with the selected remote device.For P2P - * transactions the command type will not be used. - * - * - * \note the RecvData should be valid until the pTrcvCallback has been called. - * - * - * \param[in] psHwReference Hardware Reference, pre-initialized by - * upper layer. \n - * - * \param[in,out] psTransceiveInfo Information required by transceive is - * concealed in this structure.It contains - * the send,receive buffers and their - * lengths. - * - * \param[in] psRemoteDevInfo Points to the Remote Device Information - * structure which identifies the selected - * Remote Device. - * - * \param[in] pTrcvCallback Callback function for returning the - * received response or error. - * - * \param[in] pContext Upper layer context to be returned in - * the callback. - * - * \retval NFCSTATUS_PENDING Transceive initiated.pTrcvCallback - * will return the response or error. - * \retval NFCSTATUS_NOT_INITIALIZED Hal is not initialized. - * \retval NFCSTATUS_SUCCESS This status is used when send data - * length is zero and HAL contains - * previously more bytes from previous - * receive. \n - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied - * parameters could not be properly - * interpreted or are invalid. - * \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or - * has been disconnected meanwhile. - * \retval NFCSTATUS_FEATURE_NOT_SUPPORTED Transaction on this Device type is - * not supported. - * \retval NFCSTATUS_BUSY Previous transaction is not - * completed. - * \retval NFCSTATUS_INSUFFICIENT_RESOURCES System resources are insufficient - * to complete the request at that - * point in time. - * \retval NFCSTATUS_MORE_INFORMATION Received number of bytes is greater - * than receive buffer provided by the - * upper layer.Extra bytes will be - * retained by Hal and returned on next - * call to transceive. - * \retval Others Errors related to the lower layers. - * - */ -extern NFCSTATUS phHal4Nfc_Transceive( - phHal_sHwReference_t *psHwReference, - phHal_sTransceiveInfo_t *psTransceiveInfo, - phHal_sRemoteDevInformation_t *psRemoteDevInfo, - pphHal4Nfc_TransceiveCallback_t pTrcvCallback, - void *pContext - ); - - - - -/** - * \if hal - * \ingroup grp_hal_nfci - * \else - * \ingroup grp_mw_external_hal_funcs - * \endif - * - * The function allows to disconnect from a specific Remote Device. This - * function closes the session opened with \ref phHal4Nfc_Connect "Connect".It - * is also used to switch from wired to virtual mode in case the discovered - * device is SmartMX in wired mode. The status of discovery wheel after - * disconnection is determined by the ReleaseType parameter. - * - * - * - * \param[in] psHwReference Hardware Reference, pre-initialized by - * upper layer. \n - * \param[in,out] psRemoteDevInfo Points to the valid (connected) Remote - * Device Information structure. - * - * \param[in] ReleaseType Defines various modes of releasing an acquired - * target or tag - * - * \param[in] pDscntCallback Callback function to notify - * disconnect success/error. - * - * \param[in] pContext Upper layer context to be returned in - * the callback. - * - * - * \retval NFCSTATUS_PENDING Disconnect initiated.pDscntCallback - * will return the response or error. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied - * parameters could not be properly - * interpreted. - * \retval NFCSTATUS_INVALID_REMOTE_DEVICE The device has not been opened - * before or has already been closed. - * \retval NFCSTATUS_NOT_INITIALIZED Hal is not initialized. - * \retval Others Errors related to the lower layers. - * - * \if hal - * \sa \ref phHal4Nfc_Connect - * \endif - */ -extern NFCSTATUS phHal4Nfc_Disconnect( - phHal_sHwReference_t *psHwReference, - phHal_sRemoteDevInformation_t *psRemoteDevInfo, - phHal_eReleaseType_t ReleaseType, - pphHal4Nfc_DiscntCallback_t pDscntCallback, - void *pContext - ); - -/** -* \if hal -* \ingroup grp_hal_common -* \else -* \ingroup grp_mw_external_hal_funcs -* \endif -* -* The function allows to do a one time check on whether the connected target -* is still present in the field of the Reader. The call back returns the -* result of the presence check sequence indicating whether it is still present -* or moved out of the reader field. -* -* \param[in] psHwReference Hardware Reference, pre-initialized by -* upper layer. \n -* -* \param[in] pPresenceChkCb Callback function called on completion of the -* presence check sequence or in case an error -* has occurred.. -* -* \param[in] context Upper layer context to be returned in the -* callback. -* -* \retval NFCSTATUS_PENDING Call successfully issued to lower layer. -* Status will be returned in pPresenceChkCb. -* -* \retval NFCSTATUS_NOT_INITIALISED The device has not been opened or has -* been disconnected meanwhile. -* -* \retval NFCSTATUS_BUSY Previous presence check callback has not -* been received -* -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* -* \retval NFCSTATUS_RELEASED P2P target has been released by Initiator. -* \retval Others Errors related to the lower layers -* -*/ -extern NFCSTATUS phHal4Nfc_PresenceCheck( - phHal_sHwReference_t *psHwReference, - pphHal4Nfc_GenCallback_t pPresenceChkCb, - void *context - ); - - -/** - * \if hal - * \ingroup grp_hal_common - * \else - * \ingroup grp_mw_external_hal_funcs - * \endif - * - * The I/O Control function allows the caller to use (vendor-) specific - * functionality provided by the lower layer or by the hardware. Each feature - * is accessible via a specific IOCTL Code and has to be documented by the - * provider of the driver and the hardware. - * See "IOCTL Codes" for the definition of a standard command set.\n - * - * - * \param[in] psHwReference Hardware Reference, pre-initialized by - * upper layer. \n - * \param[in] IoctlCode Control code for the operation. - * This value identifies the specific - * operation to be performed and are defined - * in \ref phNfcIoctlCode.h - * - * \param[in] pInParam Pointer to any input data structure - * containing data which is interpreted - * based on Ioctl code and the length of - * the data. - * - * \param[in] pOutParam Pointer to output data structure - * containing data which is returned as a - * result of the Ioctl operation and the - * length of the data. - * - * \param[in] pIoctlCallback callback function called in case an - * error has occurred while performing - * requested operation,or on successful - * completion of the request - * - * \param[in] pContext Upper layer context to be returned in - * the callback. - * - * \retval NFCSTATUS_SUCCESS Success. - * \retval NFCSTATUS_PENDING Call issued to lower layer.Status will - * be notified in pIoctlCallback. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be properly interpreted. - * \retval NFCSTATUS_NOT_INITIALIZED Hal is not initialized. - * \retval Others Errors related to the lower layers. - * - */ -extern NFCSTATUS phHal4Nfc_Ioctl( - phHal_sHwReference_t *psHwReference, - uint32_t IoctlCode, - phNfc_sData_t *pInParam, - phNfc_sData_t *pOutParam, - pphHal4Nfc_IoctlCallback_t pIoctlCallback, - void *pContext - ); - - - -/** - * \if hal - * \ingroup grp_hal_common - * \else - * \ingroup grp_mw_external_hal_funcs - * \endif - * - * Closes the link to the NFC device. All configurations/setups - * done until now are invalidated.To restart communication, phHal4Nfc_Open - * needs to be called. The pClosecallback is called when all steps - * in the close sequence are completed. - * - * - * \param[in] psHwReference Hardware Reference, pre-initialized by - * upper layer. \n - * - * \param[in] pCloseCallback Callback function called on completion of - * the close sequence or in case an error - * has occurred.. - * - * \param[in] pContext Upper layer context to be returned - * in the callback. - * - * \retval NFCSTATUS_SUCCESS Closing successful. - * \retval NFCSTATUS_NOT_INITIALIZED The device has not been opened or has - * been disconnected meanwhile. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be properly interpreted. - * \retval NFCSTATUS_BUSY Configuration is in progress.Shutdown - * is not allowed until configure complete. - * \retval Others Errors related to the lower layers. - * - * \if hal - * \sa \ref phHal4Nfc_Open - * \endif - */ -extern NFCSTATUS phHal4Nfc_Close( - phHal_sHwReference_t *psHwReference, - pphHal4Nfc_GenCallback_t pCloseCallback, - void *pContext - ); - - -/** - * \if hal - * \ingroup grp_hal_common - * \else - * \ingroup grp_mw_external_hal_funcs - * \endif - * - * Forcibly shutdown the HAl.This API makes a call to forcibly shutdown the - * lower layer and frees all resources in use by Hal before shutting down.The - * API always succeeds.It does not however reset the target. - * - * \param[in] psHwReference Hardware Reference, pre-initialized by - * upper layer. \n - * - * \param[in] pConfig Reserved for future use. - * - * - */ -extern void phHal4Nfc_Hal4Reset( - phHal_sHwReference_t *psHwReference, - void *pConfig - ); - - -/** -* \if hal -* \ingroup grp_hal_common -* \else -* \ingroup grp_mw_external_hal_funcs -* \endif -* -* The function is used by the NFCIP1 Target to respond to packect received -* from NFCIP1 initiator. pSendCallback() -* is called , when all steps in the send sequence are completed. -* -* \param[in] psHwReference Hardware Reference, pre-initialized by -* upper layer. \n -* -* \param[in] psTransactInfo information required for transferring -* the data -* -* \param[in] sTransferData Data and the length of the data to be -* transferred -* -* \param[in] pSendCallback Callback function called on completion -* of the NfcIP sequence or in case an -* error has occurred. -* -* \param[in] pContext Upper layer context to be returned in -* the callback. -* -* \retval NFCSTATUS_PENDING Send is in progress. -* \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has -* been disconnected meanwhile. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_NOT_INITIALIZED Hal is not initialized. -* \retval Others Errors related to the lower layers. -* -* -*/ -extern -NFCSTATUS -phHal4Nfc_Send( - phHal_sHwReference_t *psHwReference, - phHal4Nfc_TransactInfo_t *psTransactInfo, - phNfc_sData_t sTransferData, - pphHal4Nfc_SendCallback_t pSendCallback, - void *pContext - ); - -/** -* \if hal -* \ingroup grp_hal_common -* \else -* \ingroup grp_mw_external_hal_funcs -* \endif -* -* This function is called by the NfcIP Peer to wait for receiving data from -* the other peer.It is used only by the NfcIP Target. -* \note NOTE: After this function is called, its mandatory to wait for the -* pphHal4Nfc_ReceiveCallback_t callback, before calling any other function. -* Only functions allowed are phHal4Nfc_Close() and phHal4Nfc_Hal4Reset(). -* -* -* \param[in] psHwReference Hardware Reference, pre-initialized by -* upper layer. \n -* -* \param[in] psTransactInfo information required for transferring the -* data -* -* \param[in] pReceiveCallback Callback function called after receiving -* the data or in case an error has -* has occurred. -* -* \param[in] pContext Upper layer context to be returned -* in the callback. -* -* \retval NFCSTATUS_PENDING Receive is in progress. -* \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has -* been disconnected meanwhile. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_NOT_INITIALIZED Hal is not initialized. -* \retval Others Errors related to the lower layers -* -*/ -extern -NFCSTATUS -phHal4Nfc_Receive( - phHal_sHwReference_t *psHwReference, - phHal4Nfc_TransactInfo_t *psTransactInfo, - pphHal4Nfc_ReceiveCallback_t pReceiveCallback, - void *pContext - ); - - -/** -* \if hal -* \ingroup grp_hal_common -* \else -* \ingroup grp_mw_external_hal_funcs -* \endif -* -* This API is a synchronous call used to register a listener for either tag -* discovery, Secure element notification or P2P Notification or a general -* notification handler for all the three. -* -* -* \param[in] psHwRef Hardware Reference, pre-initialized by -* upper layer. \n -* -* \param[in] eRegisterType Type of Notification registered.Informs -* whether upper layer is interested in Tag -* Discovery,secure element or P2P notification. -* -* \param[in] pNotificationHandler Notification callback.If this parameter is -* NULL,any notification from Hci will be -* ignored and upper layer will not be notified -* of the event. -* -* \param[in] Context Upper layer context. -* -* \retval NFCSTATUS_SUCCESS Notification unregister successful. -* -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_NOT_INITIALIZED Hal is not initialized. -* -*/ -extern NFCSTATUS phHal4Nfc_RegisterNotification( - phHal_sHwReference_t *psHwRef, - phHal4Nfc_RegisterType_t eRegisterType, - pphHal4Nfc_Notification_t pNotificationHandler, - void *Context - ); - -/** -* \if hal -* \ingroup grp_hal_common -* \else -* \ingroup grp_mw_external_hal_funcs -* \endif -* -* This API is a synchronous call used to unregister a listener for either tag -* discovery, Secure element notification or P2P Notification, previously -* registered using \ref phHal4Nfc_RegisterNotification. -* -* \param[in] psHwReference Hardware Reference, pre-initialized by -* upper layer. \n -* -* \param[in] eRegisterType Type of registration ,tells whether upper -* layer is interested in unregistering for -* Tag Discovery,Secure element or P2P. \n -* -* \param[in] Context Upper layer context. -* -* \retval NFCSTATUS_SUCCESS Notification unregister successful. -* -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* -* \retval NFCSTATUS_NOT_INITIALIZED Hal is not initialized. -* -* -*/ -extern NFCSTATUS phHal4Nfc_UnregisterNotification( - phHal_sHwReference_t *psHwReference, - phHal4Nfc_RegisterType_t eRegisterType, - void *Context - ); - - -/** -* \if hal -* \ingroup grp_hal_common -* \else -* \ingroup grp_mw_external_hal_funcs -* \endif -* -* This function is called to switch the SmartMX to Wired Mode. After switching -* to Wired mode the SmartMX can be discovered through Tag Discovery like a normal -* tag and used in the same manner as a tag. SmartMx returns to previous mode -* (Virtual or Off) when the tag is relased by phHal4Nfc_Disconnect -* -* -* \param[in] psHwReference Hardware Reference, pre-initialized by -* upper layer. \n -* -* \param[in] smx_mode Mode to which the switch should be made. -* -* \param[in] pSwitchModecb Callback for Switch mode complete -* with success/error notification. -* -* \param[in] pContext Upper layer context. -* -* \retval NFCSTATUS_PENDING Switch in progress.Status will be -* returned in pSwitchModecb. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied -* parameters could not be properly -* interpreted. -* \retval NFCSTATUS_NOT_INITIALIZED Hal is not initialized. -* \retval NFCSTATUS_BUSY Configuration in Progress or -* remote device is connected. -* \retval NFCSTATUS_INSUFFICIENT_RESOURCES System resources are insufficient -* to complete the request at that -* point in time. -* \retval NFCSTATUS_FAILED No listener has been registered -* by the upper layer for Emulation -* before making this call. -* \retval Others Errors related to the lower -* layers. -*/ -extern NFCSTATUS phHal4Nfc_Switch_SMX_Mode( - phHal_sHwReference_t *psHwReference, - phHal_eSmartMX_Mode_t smx_mode, - pphHal4Nfc_GenCallback_t pSwitchModecb, - void *pContext - ); - - -/** -* \if hal -* \ingroup grp_hal_common -* \else -* \ingroup grp_mw_external_hal_funcs -* \endif -* -* This function is called to switch the UICC on or Off. -* -* -* \param[in] psHwReference Hardware Reference, pre-initialized by -* upper layer. \n -* -* \param[in] smx_mode Mode to which the switch should be made. -* -* \param[in] pSwitchModecb Callback for Switch mode complete -* with success/error notification. -* -* \param[in] pContext Upper layer context. -* -* \retval NFCSTATUS_PENDING Switch in progress.Status will be -* returned in pSwitchModecb. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied -* parameters could not be properly -* interpreted. -* \retval NFCSTATUS_NOT_INITIALIZED Hal is not initialized. -* \retval NFCSTATUS_BUSY Configuration in Progress or -* remote device is connected. -* \retval NFCSTATUS_INSUFFICIENT_RESOURCES System resources are insufficient -* to complete the request at that -* point in time. -* \retval NFCSTATUS_FAILED No listener has been registered -* by the upper layer for Emulation -* before making this call. -* \retval Others Errors related to the lower -* layers. -*/ -extern NFCSTATUS phHal4Nfc_Switch_Swp_Mode( - phHal_sHwReference_t *psHwReference, - phHal_eSWP_Mode_t swp_mode, - pphHal4Nfc_GenCallback_t pSwitchModecb, - void *pContext - ); - -#endif /* end of PHHAL4NFC_H */ - - diff --git a/libnfc-nxp/phHal4Nfc_Internal.h b/libnfc-nxp/phHal4Nfc_Internal.h deleted file mode 100644 index 50f4ea1..0000000 --- a/libnfc-nxp/phHal4Nfc_Internal.h +++ /dev/null @@ -1,314 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -/** -* \file phHal4Nfc_Internal.h -* \brief HAL callback Function Prototypes -* -* The HAL4.0 Internal header file -* -* Project: NFC-FRI-1.1 / HAL4.0 -* -* $Date: Mon May 31 11:43:42 2010 $ -* $Author: ing07385 $ -* $Revision: 1.40 $ -* $Aliases: NFC_FRI1.1_WK1023_R35_1 $ -* -*/ - -/*@{*/ -#ifndef PHHAL4NFC_INTERNAL_H -#define PHHAL4NFC_INTERNAL_H -/*@}*/ - -#include - -/** -* \name HAL4 -* -* File: \ref phHal4Nfc_Internal.h -* -*/ - -/*@{*/ -#define PH_HAL4NFC_INTERNAL_FILEREVISION "$Revision: 1.40 $" /**< \ingroup grp_file_attributes */ -#define PH_HAL4NFC_INTERNAL_FILEALIASES "$Aliases: NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ -/*@}*/ - -/* -----------------Include files ---------------------------------------*/ - -/* ---------------- Macros ----------------------------------------------*/ -#define LLCP_DISCON_CHANGES -#define PH_HAL4NFC_TRANSCEIVE_TIMEOUT 30000 /** -#include -#ifdef ANDROID -#include -#endif - -/* -################################################################################ -****************************** Macro Definitions ******************************* -################################################################################ -*/ - - -/* -################################################################################ -******************** Enumeration and Structure Definition ********************** -################################################################################ -*/ - -typedef enum phHciNfc_Init -{ - HCI_SESSION = 0x00, - HCI_NFC_DEVICE_TEST, - HCI_CUSTOM_INIT, - HCI_SELF_TEST -}phHciNfc_Init_t; - -/** \ingroup grp_hal_hci - * - * \if hal - * \brief HCI Tag Exchange Information - * \else - * \brief HCI-Specific - * \endif - * - * The Tag Exchange Info Structure holds the exchange information to - * the connected tag . - * - * \note All members of this structure are in parameters [in]. - * - */ - -typedef struct phHciNfc_Tag_XchgInfo -{ - /** \internal RF Reader Command Type */ - uint8_t cmd_type; - /** \internal Address Field required for only Mifare - * Family Proprietary Cards. - * The Address Size is Valid only upto 255 Blocks limit - * i:e for Mifare 4K - */ - uint8_t addr; -}phHciNfc_Tag_XchgInfo_t; - -/** \ingroup grp_hal_hci - * - * \if hal - * \brief HCI NFC-IP Exchange Information - * \else - * \brief HCI-Specific - * \endif - * - * The NFC-IP Exchange Info Structure holds the exchange information to - * the connected NFC-IP target . - * - * \note All members of this structure are in parameters [in]. - * - */ - -typedef struct phHciNfc_NfcIP_XchgInfo -{ - /** \internal NFC-IP DEP Meta Chining Information */ - uint8_t more_info; - -}phHciNfc_NfcIP_XchgInfo_t; - -/** \ingroup grp_hal_hci - * - * \if hal - * \brief HCI Target Exchange Information - * \else - * \brief HCI-Specific - * \endif - * - * The Target Exchange Info Structure holds all the exchange information to - * the connected target . - * - * \note All members of this structure are in parameters [in]. - * - */ - - -typedef struct phHciNfc_XchgInfo -{ - /** \internal Exchange Data/NFC-IP DEP - * Exchange Buffer */ - uint8_t *tx_buffer; - /** \internal Exchange Data/NFC-IP DEP - * Exchange Buffer Length*/ - uint16_t tx_length; - - union - { - phHciNfc_Tag_XchgInfo_t tag_info; - phHciNfc_NfcIP_XchgInfo_t nfc_info; - }params; - -}phHciNfc_XchgInfo_t; - - - -/* -################################################################################ -*********************** Function Prototype Declaration ************************* -################################################################################ -*/ - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Initialise function initialises the HCI context and all other - * resources used in the HCI Layer for the corresponding interface link. - * - * \param[in,out] psHciHandle psHciHandle is the handle or the context - * of the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] init_mode init_mode specifies the kind of the - * Initialisation for the HCI layer . - * \param[in] pHwConfig pHwConfig is the Information required - * to configure the parameters of the - * NFC Device . - * \param[in] pHalNotify Upper layer Notification function - * pointer. - * \param[in] psContext psContext is the context of - * the Upper Layer. - * \param[in] psHciLayerCfg Pointer to the HCI Layer configuration - * Structure. - * - * \retval NFCSTATUS_PENDING Initialisation of HCI Layer is in Progress. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - - extern - NFCSTATUS - phHciNfc_Initialise ( - void *psHciHandle, - void *pHwRef, - phHciNfc_Init_t init_mode, - phHal_sHwConfig_t *pHwConfig, - pphNfcIF_Notification_CB_t pHalNotify, - void *psContext, - phNfcLayer_sCfg_t *psHciLayerCfg - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Release function releases all the resources used in the HCI - * Layer for the corresponding interface link, described by the HCI handle. - * - * \param[in] psHciHandle psHciHandle is the handle or the context - * of the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] pHalReleaseCB Upper layer release callback function - * pointer . - * \param[in] psContext psContext is the context of - * the Upper Layer. - * - * \retval NFCSTATUS_PENDING Releasing of HCI Resources are in Progress. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - - extern - NFCSTATUS - phHciNfc_Release ( - void *psHciHandle, - void *pHwRef, - pphNfcIF_Notification_CB_t pHalReleaseCB, - void *psContext - ); - - -extern -NFCSTATUS -phHciNfc_Config_Discovery ( - void *psHciHandle, - void *pHwRef, - phHal_sADD_Cfg_t *pPollConfig - ); - - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Restart_Discovery function restarts the Polling Wheel. - * - * \param[in] psHciHandle psHciHandle is the handle or the context - * of the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] discovery_type If True: Start re-polling of the target - * after the Target Device is de-activated - * or else - continue discovery with next - * technology. - * \retval NFCSTATUS_PENDING The Discovery Wheel retarted. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - - extern - NFCSTATUS - phHciNfc_Restart_Discovery ( - void *psHciHandle, - void *pHwRef, - uint8_t discovery_type - ); - - - /** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Start_Discovery function Starts the Polling Wheel. - * - * \param[in] psHciHandle psHciHandle is the handle or the context - * of the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \retval NFCSTATUS_PENDING The Discovery Wheel Started. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - - extern - NFCSTATUS - phHciNfc_Start_Discovery ( - void *psHciHandle, - void *pHwRef - ); - - - /** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Stop_Discovery function Stops the Polling Wheel. - * - * \param[in] psHciHandle psHciHandle is the handle or the context - * of the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \retval NFCSTATUS_PENDING The Discovery Wheel Stopped. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - - extern - NFCSTATUS - phHciNfc_Stop_Discovery ( - void *psHciHandle, - void *pHwRef - ); - - - /** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Configure function Configures Configures the Polling Wheel to - * select the kind of Tags to be polled. This also allows to enable/disable - * the Tag Emulation. This also configures the Secure elements the UICC, WI and - * Target to Emulate the Tag or Target. - * - * - * \param[in] psHciHandle psHciHandle is the handle or the context - * of the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] config_type config_type specifies the type of the - * Parameter configuration. - * \param[in] pConfig pConfig is the Information for - * Configuring the Device. - * \retval NFCSTATUS_PENDING The Emulation configuration pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - - extern - NFCSTATUS - phHciNfc_Configure ( - void *psHciHandle, - void *pHwRef, - phHal_eConfigType_t config_type, - phHal_uConfig_t *pConfig - ); - - /** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Switch_SmxMode function Switches the WI(S2C) interface - * from Wired/Virtual to vice versa. - * - * - * \param[in] psHciHandle psHciHandle is the handle or the context - * of the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] smx_mode smx_mode specifies the type of the switch - * configuration. - * \param[in] pPollConfig pPollConfig is the Information for - * polling the SmartMX Device. - * \retval NFCSTATUS_PENDING The SmartMX Mode Switch pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - - NFCSTATUS - phHciNfc_Switch_SmxMode ( - void *psHciHandle, - void *pHwRef, - phHal_eSmartMX_Mode_t smx_mode, - phHal_sADD_Cfg_t *pPollConfig - ); - - - /** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Switch_SwpMode function Switches the SWP Link - * from On/Off to vice versa. - * - * - * \param[in] psHciHandle psHciHandle is the handle or the context - * of the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] swp_mode swp_mode specifies to switch on/off the - * SWP Link. - * \retval NFCSTATUS_PENDING The SWP Mode Switch pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - - NFCSTATUS - phHciNfc_Switch_SwpMode ( - void *psHciHandle, - void *pHwRef, - phHal_eSWP_Mode_t swp_mode /* , - void *pSwpCfg */ - ); - - - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Connect function selects the discovered target to - * perform the transactions on it. - * - * - * \param[in] psHciHandle psHciHandle is the handle or the context - * of the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] p_remote_dev_info p_remote_dev_info is the information - * of the Target Device to be connected . - * \retval NFCSTATUS_PENDING To select the remote target pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - - extern - NFCSTATUS - phHciNfc_Connect ( - void *psHciHandle, - void *pHwRef, - phHal_sRemoteDevInformation_t *p_remote_dev_info - ); - - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Reactiavte function reactivates the discovered target to - * and selects that target perform the transactions on it. - * - * - * \param[in] psHciHandle psHciHandle is the handle or the context - * of the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] p_remote_dev_info p_remote_dev_info is the information - * of the Target Device to be reactivated . - * \retval NFCSTATUS_PENDING To reactivate the remote target pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - - - extern - NFCSTATUS - phHciNfc_Reactivate ( - void *psHciHandle, - void *pHwRef, - phHal_sRemoteDevInformation_t *p_target_info - ); - - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Disconnect function de-selects the selected target and - * any ongoing transactions . - * - * - * \param[in] psHciHandle psHciHandle is the handle or the context - * of the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] discovery_type If NFC_RF_DISCOVERY_REPOLL: Start re-polling of - * the target after the Target Device is - * de-activatedor if NFC_RF_DISCOVERY_CONTINUE - - * continue discovery with next technology or - * stop the discovery wheel. - * - * \retval NFCSTATUS_PENDING To De-select the remote target pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - - extern - NFCSTATUS - phHciNfc_Disconnect ( - void *psHciHandle, - void *pHwRef, - uint8_t discovery_type - ); - - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Presence_Check function checks for the presence of the target - * selected in the vicinity of the Reader's RF Field . - * - * - * \param[in] psHciHandle psHciHandle is the handle or the context - * of the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \retval NFCSTATUS_PENDING Presence Check of the remote target - * pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - -extern -NFCSTATUS -phHciNfc_Presence_Check ( - void *psHciHandle, - void *pHwRef - ); - - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Select_Next_Target function selects and activates the - * next target present in the the Reader's RF Field . - * - * - * \param[in] psHciHandle psHciHandle is the handle or the - * context of the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \retval NFCSTATUS_PENDING selection and activation of the next - * remote target pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - -extern -NFCSTATUS -phHciNfc_Select_Next_Target ( - void *psHciHandle, - void *pHwRef - ); - - - /** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Exchange_Data function exchanges the data - * to/from the selected remote target device. - * - * - * \param[in] psHciHandle psHciHandle is the handle or the context - * of the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] p_remote_dev_info p_remote_dev_info is the information of the - * selected target to which data - * should be sent. - * \param[in] p_xchg_info The exchange info contains the command type, - * addr and data to be sent to the connected - * remote target device. - * \retval NFCSTATUS_PENDING Data to remote target pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - - extern - NFCSTATUS - phHciNfc_Exchange_Data ( - void *psHciHandle, - void *pHwRef, - phHal_sRemoteDevInformation_t *p_remote_dev_info, - phHciNfc_XchgInfo_t *p_xchg_info - ); - - /** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Send_Data function Sends the data provided - * to the appropriate remote target device. - * - * - * \param[in] psHciHandle psHciHandle is the handle or the context - * of the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] p_remote_dev_info p_remote_dev_info is the information - * of the selected target to which data - * should be sent. - * \param[in] p_send_param The send param contains the - * data to be sent to the - * remote device. - * \retval NFCSTATUS_PENDING Data to remote device pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - - extern - NFCSTATUS - phHciNfc_Send_Data ( - void *psHciHandle, - void *pHwRef, - phHal_sRemoteDevInformation_t *p_remote_dev_info, - phHciNfc_XchgInfo_t *p_send_param - ); - - /** - * \ingroup grp_hci_nfc - * - * The phHciNfc_System_Test function performs the System Management Tests - * provided by the NFC Peripheral device. - * - * \param[in] psContext psContext is the pointer to HCI Layer - * context Structure. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] test_type test_type is the type of the Self Test - * that needs to be performed on the device. - * \param[in] test_param test_param is the parameter for the Self Test - * that needs to be performed on the device. - * - * - * \retval NFCSTATUS_PENDING System Test on the System Management - * is pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - -extern -NFCSTATUS -phHciNfc_System_Test( - void *psContext, - void *pHwRef, - uint32_t test_type, - phNfc_sData_t *test_param - ); - - /** - * \ingroup grp_hci_nfc - * - * The phHciNfc_System_Configure function performs the System Management - * Configuration with the value provided. - * - * \param[in] psContext psContext is the pointer to HCI Layer - * context Structure. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] config_type config_type is the type of the configuration - * that needs to be performed on the device. - * \param[in] config_value config_value is the value for the configuring - * that needs to be performed on the device. - * - * - * \retval NFCSTATUS_PENDING Configuration of the provided information to - * the is pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ -extern -NFCSTATUS -phHciNfc_System_Configure ( - void *psHciHandle, - void *pHwRef, - uint32_t config_type, - uint8_t config_value - ); - - /** - * \ingroup grp_hci_nfc - * - * The phHciNfc_System_Get_Info function obtains the System Management - * information from the address provided. - * - * \param[in] psContext psContext is the pointer to HCI Layer - * context Structure. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] info_type info_type is the type of the Information - * that needs to be obtained from the device. - * \param[in,out] p_val p_val is the pointer to which the - * information need to be updated. - * - * - * \retval NFCSTATUS_PENDING Get information from the NFC Device - * is pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ -extern -NFCSTATUS -phHciNfc_System_Get_Info( - void *psHciHandle, - void *pHwRef, - uint32_t info_type, - uint8_t *p_val - ); - -extern -NFCSTATUS -phHciNfc_PRBS_Test ( - void *psHciHandle, - void *pHwRef, - uint32_t test_type, - phNfc_sData_t *test_param - ); - -#if 0 - extern - NFCSTATUS - phHciNfc_Receive_Data ( - void *psHciHandle, - void *pHwRef, - uint8_t *p_data, - uint8_t length - ); - -#endif - - -#endif - diff --git a/libnfc-nxp/phHciNfc_AdminMgmt.h b/libnfc-nxp/phHciNfc_AdminMgmt.h deleted file mode 100644 index cf1ac3a..0000000 --- a/libnfc-nxp/phHciNfc_AdminMgmt.h +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! -* =========================================================================== * -* * -* * -* \file phHciNfc_AdminMgmt.h * -* \brief HCI Header for the Admin Gate Management. * -* * -* * -* Project: NFC-FRI-1.1 * -* * -* $Date: Mon Mar 29 17:34:48 2010 $ * -* $Author: ing04880 $ * -* $Revision: 1.7 $ * -* $Aliases: NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ * -* * -* =========================================================================== * -*/ - - -#ifndef PHHCINFC_ADMINMGMT_H -#define PHHCINFC_ADMINMGMT_H - -/*@}*/ - - -/** - * \name HCI - * - * File: \ref phHciNfc_AdminMgmt.h - * - */ -/*@{*/ -#define PHHCINFC_ADMINMGMT_FILEREVISION "$Revision: 1.7 $" /**< \ingroup grp_file_attributes */ -#define PHHCINFC_ADMINMGMT_FILEALIASES "$Aliases: NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ -/*@}*/ - -/* -***************************** Header File Inclusion **************************** -*/ - -#include - -/* -****************************** Macro Definitions ******************************* -*/ - -#define EVT_HOT_PLUG 0x03 - -/* -******************** Enumeration and Structure Definition ********************** -*/ - -/** \defgroup grp_hci_nfc HCI Component - * - * - */ - - -/* -*********************** Function Prototype Declaration ************************* -*/ - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Admin_Initialise function Initialises the AdminGate and opens the - * Admin Gate pipe - * - * \param[in] psHciContext psHciContext is the pointer to HCI Layer - * context Structure. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * - * \retval NFCSTATUS_PENDING AdminGate Initialisation is pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - -extern -NFCSTATUS -phHciNfc_Admin_Initialise( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Admin_Release function closes the opened pipes between - * the Host Controller Device and the NFC Device. - * - * \param[in] psHciContext psHciContext is the pointer to HCI Layer - * context Structure. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] host_type host_type is the type of the host - * to be released. - * - * \retval NFCSTATUS_PENDING Release of the Admingate resources are - * pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - -extern -NFCSTATUS -phHciNfc_Admin_Release( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - phHciNfc_HostID_t host_type - ); - - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Send_Admin_Cmd function Sends the Particular AdminGate - * command to the Host Controller Device. - * - * \param[in] psHciContext psHciContext is the pointer to HCI Layer - * context Structure. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] cmd cmd to be sent to the Admin gate of the - * Host controller. - * \param[in] length Size of the data sent in the parameter. - * \param[in,out] params params contains the parameters that are - * required by the particular HCI command. - * - * \retval None - * - */ - -extern -NFCSTATUS -phHciNfc_Send_Admin_Cmd ( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - uint8_t cmd, - uint8_t length, - void *params - ); - - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Send_Admin_Cmd function Sends the Particular AdminGate - * command to the Host Controller Device. - * - * \param[in] psHciContext psHciContext is the pointer to HCI Layer - * context Structure. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] Event Event to be sent to the Admin gate of the - * Host controller. - * \param[in] length Size of the data sent in the parameter. - * \param[in,out] params params contains the parameters that are - * required by the particular HCI command. - * - * \retval None - * - */ - -extern -NFCSTATUS -phHciNfc_Send_Admin_Event ( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - uint8_t event, - uint8_t length, - void *params - ); - -extern -NFCSTATUS -phHciNfc_Admin_CE_Init( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - phHciNfc_GateID_t ce_gate - ); - - -#endif - diff --git a/libnfc-nxp/phHciNfc_CE_A.h b/libnfc-nxp/phHciNfc_CE_A.h deleted file mode 100644 index aab5b24..0000000 --- a/libnfc-nxp/phHciNfc_CE_A.h +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! -* =========================================================================== * -* * -* * -* \file phHciNfc_CE_A.h * -* \brief HCI card emulation management routines. * -* * -* * -* Project: NFC-FRI-1.1 * -* * -* $Date: Fri Aug 14 17:01:27 2009 $ * -* $Author: ing04880 $ * -* $Revision: 1.5 $ * -* $Aliases: NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ * -* * -* =========================================================================== * -*/ - - -#ifndef PHHCINFC_CE_A_H -#define PHHCINFC_CE_A_H - -/*@}*/ - - -/** -* \name HCI -* -* File: \ref phHciNfc_CE_A.h -* -*/ -/*@{*/ -#define PHHCINFC_CE_A_FILEREVISION "$Revision: 1.5 $" /**< \ingroup grp_file_attributes */ -#define PHHCINFC_CE_A_FILEALIASES "$Aliases: NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ -/*@}*/ - -/* -***************************** Header File Inclusion **************************** -*/ - -#include - -/* -****************************** Macro Definitions ******************************* -*/ - -#define HOST_CE_A_MODE_INDEX (0x01U) -#define HOST_CE_A_UID_REG_INDEX (0x02U) -#define HOST_CE_A_SAK_INDEX (0x03U) -#define HOST_CE_A_ATQA_INDEX (0x04U) -#define HOST_CE_A_APP_DATA_INDEX (0x05U) -#define HOST_CE_A_FWI_SFGT_INDEX (0x06U) -#define HOST_CE_A_CID_INDEX (0x07U) -#define HOST_CE_A_CLT_INDEX (0x08U) -#define HOST_CE_A_DATA_RATE_INDEX (0x09U) - - -/* -******************** Enumeration and Structure Definition ********************** -*/ - -/* Sequence list */ -typedef enum phHciNfc_CE_A_Seq{ - HOST_CE_A_INVALID_SEQ, - HOST_CE_A_PIPE_OPEN, - HOST_CE_A_SAK_SEQ, - HOST_CE_A_ATQA_SEQ, - HOST_CE_A_ENABLE_SEQ, - HOST_CE_A_DISABLE_SEQ, - HOST_CE_A_PIPE_CLOSE, - HOST_CE_A_PIPE_DELETE -}phHciNfc_CE_A_Seq_t; - -/* Information structure for the card emulation A Gate */ -typedef struct phHciNfc_CE_A_Info{ - - phHciNfc_CE_A_Seq_t current_seq; - phHciNfc_CE_A_Seq_t next_seq; - /* Pointer to the card emulation A pipe information */ - phHciNfc_Pipe_Info_t *p_pipe_info; - uint8_t pipe_id; - -} phHciNfc_CE_A_Info_t; - -/* -*********************** Function Prototype Declaration ************************* -*/ - -/*! - * \brief Allocates the resources of card emulation A management gate. - * - * This function Allocates the resources of the card emulation A management - * gate Information Structure. - * - */ -extern -NFCSTATUS -phHciNfc_CE_A_Init_Resources( - phHciNfc_sContext_t *psHciContext - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_CE_A_Get_PipeID function gives the pipe id of the card -* emulation A gate -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_CE_A_Get_PipeID( - phHciNfc_sContext_t *psHciContext, - uint8_t *ppipe_id - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_CE_A_Update_PipeInfo function updates the pipe_id of the card -* emulation A gate management Structure. -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pipeID pipeID of the card emulation A gate -* \param[in] pPipeInfo Update the pipe Information of the reader -* A gate -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ - -extern -NFCSTATUS -phHciNfc_CE_A_Update_PipeInfo( - phHciNfc_sContext_t *psHciContext, - uint8_t pipeID, - phHciNfc_Pipe_Info_t *pPipeInfo - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_CE_A_SendData_Event function sends data to the lo -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* \param[in] pipeID pipeID of the card emulation A gate -* \param[in] pPipeInfo Update the pipe Information of the reader -* A gate -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -#ifdef CE_A_SEND_EVENT -extern -NFCSTATUS -phHciNfc_CE_A_SendData_Event( - void *psContext, - void *pHwRef, - uint8_t *pEvent, - uint8_t length - ); -#endif /* #ifdef CE_A_SEND_EVENT */ - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_CE_A_Mode function sends data to the set the card emulation mode -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* \param[in] enable_type type to enable -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_CE_A_Mode( - void *psHciHandle, - void *pHwRef, - uint8_t enable_type - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_CE_A_Initialise function opens the CE A and set all the -* required parameters for CE A -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_CE_A_Initialise( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_CE_A_Initialise function close the CE A and reset all the -* required parameters to default value of CE A -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_CE_A_Release( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_CE_A_Update_Seq function to update CE A sequence depending on the -* specified \ref seq_type -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] seq_type sequence type specified in -* \ref phHciNfc_eSeqType_t -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_CE_A_Update_Seq( - phHciNfc_sContext_t *psHciContext, - phHciNfc_eSeqType_t seq_type - ); -#endif /* PHHCINFC_CE_A_H */ - - diff --git a/libnfc-nxp/phHciNfc_CE_B.h b/libnfc-nxp/phHciNfc_CE_B.h deleted file mode 100644 index e34e2db..0000000 --- a/libnfc-nxp/phHciNfc_CE_B.h +++ /dev/null @@ -1,284 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! -* =========================================================================== * -* * -* * -* \file phHciNfc_CE_B.h * -* \brief HCI card emulation management routines. * -* * -* * -* Project: NFC-FRI-1.1 * -* * -* $Date: Fri Aug 14 17:01:26 2009 $ * -* $Author: ing04880 $ * -* $Revision: 1.4 $ * -* $Aliases: NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ * -* * -* =========================================================================== * -*/ - - -#ifndef PHHCINFC_CE_B_H -#define PHHCINFC_CE_B_H - -/*@}*/ - - -/** -* \name HCI -* -* File: \ref phHciNfc_CE_B.h -* -*/ -/*@{*/ -#define PHHCINFC_CE_B_FILEREVISION "$Revision: 1.4 $" /**< \ingroup grp_file_attributes */ -#define PHHCINFC_CE_B_FILEALIASES "$Aliases: NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ -/*@}*/ - -/* -***************************** Header File Inclusion **************************** -*/ - -#include - -/* -****************************** Macro Definitions ******************************* -*/ -#define HOST_CE_B_MODE_INDEX (0x01U) -#define HOST_CE_B_PUPI_INDEX (0x02U) -#define HOST_CE_B_AFI_INDEX (0x03U) -#define HOST_CE_B_ATQB_INDEX (0x04U) -#define HOST_CE_B_HIGH_LAYER_RESP_INDEX (0x05U) -#define HOST_CE_B_DATA_RATE_MAX_INDEX (0x05U) - -/* -******************** Enumeration and Structure Definition ********************** -*/ - -/* Sequence list */ -typedef enum phHciNfc_CE_B_Seq{ - HOST_CE_B_INVALID_SEQ, - HOST_CE_B_PIPE_OPEN, - HOST_CE_B_PUPI_SEQ, - HOST_CE_B_ATQB_SEQ, - HOST_CE_B_ENABLE_SEQ, - HOST_CE_B_DISABLE_SEQ, - HOST_CE_B_PIPE_CLOSE, - HOST_CE_B_PIPE_DELETE -}phHciNfc_CE_B_Seq_t; - -/* Information structure for the card emulation B gate */ -typedef struct phHciNfc_CE_B_Info{ - phHciNfc_CE_B_Seq_t current_seq; - phHciNfc_CE_B_Seq_t next_seq; - /* Pointer to the card emulation B pipe information */ - phHciNfc_Pipe_Info_t *p_pipe_info; - uint8_t pipe_id; - -} phHciNfc_CE_B_Info_t; - -/* -*********************** Function Prototype Declaration ************************* -*/ - -/*! - * \brief Allocates the resources of card emulation B management gate. - * - * This function Allocates the resources of the card emulation B management - * gate Information Structure. - * - */ -extern -NFCSTATUS -phHciNfc_CE_B_Init_Resources( - phHciNfc_sContext_t *psHciContext - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_CE_B_Get_PipeID function gives the pipe id of the card -* emulation B gate -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_CE_B_Get_PipeID( - phHciNfc_sContext_t *psHciContext, - uint8_t *ppipe_id - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_CE_B_Update_PipeInfo function updates the pipe_id of the card -* emulation B gate management Structure. -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pipeID pipeID of the card emulation A gate -* \param[in] pPipeInfo Update the pipe Information of the reader -* A gate -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ - -extern -NFCSTATUS -phHciNfc_CE_B_Update_PipeInfo( - phHciNfc_sContext_t *psHciContext, - uint8_t pipeID, - phHciNfc_Pipe_Info_t *pPipeInfo - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_CE_B_SendData_Event function sends data to the PN544 -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* \param[in] pipeID pipeID of the card emulation B gate -* \param[in] pPipeInfo Update the pipe Information of the card -* emulation B gate -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -#ifdef CE_B_SEND_EVENT -extern -NFCSTATUS -phHciNfc_CE_B_SendData_Event( - void *psContext, - void *pHwRef, - uint8_t *pEvent, - uint8_t length - ); -#endif /* #ifdef CE_B_SEND_EVENT */ - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_CE_B_Mode function sends data to the set the card emulation mode -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* \param[in] enable_type type to enable -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -NFCSTATUS -phHciNfc_CE_B_Mode( - void *psHciHandle, - void *pHwRef, - uint8_t enable_type - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_CE_B_Initialise function opens the CE B and set all the -* required parameters for CE B -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_CE_B_Initialise( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_CE_B_Initialise function close the CE B and reset all the -* required parameters to default value of CE B -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_CE_B_Release( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_CE_B_Update_Seq function to update CE B sequence depending on the -* specified \ref seq_type -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] seq_type sequence type specified in -* \ref phHciNfc_eSeqType_t -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_CE_B_Update_Seq( - phHciNfc_sContext_t *psHciContext, - phHciNfc_eSeqType_t seq_type - ); - -#endif /* PHHCINFC_CE_B_H */ - - diff --git a/libnfc-nxp/phHciNfc_DevMgmt.h b/libnfc-nxp/phHciNfc_DevMgmt.h deleted file mode 100644 index e886013..0000000 --- a/libnfc-nxp/phHciNfc_DevMgmt.h +++ /dev/null @@ -1,334 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! -* =========================================================================== * -* * -* * -* \file phHciNfc_DevMgmt.h * -* \brief HCI Header for the PN544 Device Management Gate. * -* * -* * -* Project: NFC-FRI-1.1 * -* * -* $Date: Tue Jun 8 09:30:49 2010 $ * -* $Author: ing04880 $ * -* $Revision: 1.15 $ * -* $Aliases: NFC_FRI1.1_WK1023_R35_1 $ -* * -* =========================================================================== * -*/ - - -#ifndef PHHCINFC_DEVMGMT_H -#define PHHCINFC_DEVMGMT_H - -/*@}*/ - - -/** - * \name HCI - * - * File: \ref phHciNfc_DevMgmt.h - * - */ -/*@{*/ -#define PHHCINFC_DEVICE_MGMT_FILEREVISION "$Revision: 1.15 $" /**< \ingroup grp_file_attributes */ -#define PHHCINFC_DEVICE_MGMT_FILEALIASES "$Aliases: NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ -/*@}*/ - -/* -***************************** Header File Inclusion **************************** -*/ - -#include - -/* -****************************** Macro Definitions ******************************* -*/ - -#define DEVICE_PWR_STATUS_INDEX 0x01U -#define DEVICE_INFO_EVT_INDEX 0x02U -#define DEVICE_INFO_EEPROM_INDEX 0x03U - -#define NXP_DOWNLOAD_GPIO 0x04U - -/* GPIO PIN Mask Macro */ -#define NXP_NFC_GPIO_MASK(n) ((uint8_t)(1U << (n))) - -/* Address Definitions for GPIO Register Configuration */ -#define NFC_ADDRESS_GPIO_PDIR 0xF821U -#define NFC_ADDRESS_GPIO_PEN 0xF829U - - -/* Address Definitions for SWP Configuration */ -#define NFC_ADDRESS_SWP_BITRATE 0x9C01U -#define NFC_ADDRESS_SWP_PWR_REQ 0x9EB4U - -/* Address Definitions for UICC Host Configuration */ -#define NFC_ADDRESS_UICC_RD_A_ACCESS 0x9ED9U -#define NFC_ADDRESS_UICC_RD_B_ACCESS 0x9EDAU -#define NFC_ADDRESS_UICC_CE_A_ACCESS 0x9EDBU -#define NFC_ADDRESS_UICC_CE_B_ACCESS 0x9EDCU -#define NFC_ADDRESS_UICC_CE_BP_ACCESS 0x9EDDU -#define NFC_ADDRESS_UICC_CE_F_ACCESS 0x9EDEU - -/* Address Definitions for SE Configuration */ - -/* Address Definitions for HW Configuration */ -#define NFC_ADDRESS_CLK_REQ 0x9E71U -#define NFC_ADDRESS_CLK_INPUT 0x9809U -#define NFC_ADDRESS_HW_CONF 0x9810U -#define NFC_ADDRESS_PWR_STATUS 0x9EAAU - -/* Address Definitions for RF Configuration */ - - -/* Address Definitions for Interframe Character Timeout Configuration */ -#define NFC_ADDRESS_IFC_TO_RX_H 0x9C0CU -#define NFC_ADDRESS_IFC_TO_RX_L 0x9C0DU -#define NFC_ADDRESS_IFC_TO_TX_H 0x9C12U -#define NFC_ADDRESS_IFC_TO_TX_L 0x9C13U - - -/* Address Definitions for LLC Configuration */ -#define NFC_ADDRESS_LLC_ACK_TO_H 0x9C27U -#define NFC_ADDRESS_LLC_ACK_TO_L 0x9C28U -#define NFC_ADDRESS_LLC_GRD_TO_H 0x9C31U -#define NFC_ADDRESS_LLC_GRD_TO_L 0x9C32U - -#define NFC_ADDRESS_ACT_GRD_TO 0x9916U - -/* The Address Definition for the TYPE B Tuning */ - -#ifdef SW_TYPE_RF_TUNING_BF -#define NFC_ADDRESS_ANAIRQ_CONF 0x9801U -#define NFC_ADDRESS_PMOS_MOD 0x997AU -#endif - -#define NFC_FELICA_RC_ADDR 0x9F9AU - -/* The Address Definition for the Enabling the EVT_HOT_PLUG */ -#define NFC_ADDRESS_HOTPLUG_EVT 0x9FF0U - - -/* -******************** Enumeration and Structure Definition ********************** -*/ - - - -/* -*********************** Function Prototype Declaration ************************* -*/ - -/************************ Function Prototype Declaration *************************/ - -/*! - * \brief Allocates the resources required for PN544 Device management gate. - * - * This function Allocates necessary resources as requiered by PN544 Device - * gate management - * - * \param[in] psHciContext psHciContext is the pointer to HCI Layer - * - * \retval NFCSTATUS_SUCCESS Function execution is successful - * - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the given inputs are not valid - */ - -extern -NFCSTATUS -phHciNfc_DevMgmt_Init_Resources(phHciNfc_sContext_t *psHciContext); - - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_DevMgmt_Get_PipeID function gives the pipe id of the PN544 Device -* management gate -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* \param[in] ppipe_id ppipe_id of the Device management Gate -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ - -extern -NFCSTATUS -phHciNfc_DevMgmt_Get_PipeID( - phHciNfc_sContext_t *psHciContext, - uint8_t *ppipe_id - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_DevMgmt_Initialise function creates and the opens the pipe - * PN544 Device Management Gate in the NFC Device - * - * \param[in] psHciContext psHciContext is the pointer to HCI Layer - * context Structure. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * - * \retval NFCSTATUS_PENDING Device Mgmt Gate Initialisation is pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - -extern -NFCSTATUS -phHciNfc_DevMgmt_Initialise( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_DevMgmt_Test function performs the System Management Tests - * provided by the NFC Peripheral device. - * - * \param[in] psHciContext psHciContext is the pointer to HCI Layer - * context Structure. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] test_type test_type is the type of the Self Test - * that needs to be performed on the device. - * \param[in] test_param test_param is the parameter for the Self Test - * that needs to be performed on the device. - * - * - * \retval NFCSTATUS_PENDING Self Test on the Device Management gate - * is pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - -extern -NFCSTATUS -phHciNfc_DevMgmt_Test( - void *psContext, - void *pHwRef, - uint8_t test_type, - phNfc_sData_t *test_param - ); - -extern -NFCSTATUS -phHciNfc_DevMgmt_Get_Info ( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - uint16_t address, - uint8_t *p_val - ); - -extern -NFCSTATUS -phHciNfc_DevMgmt_Configure ( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - uint16_t address, - uint8_t value - ); - -extern -NFCSTATUS -phHciNfc_DevMgmt_Get_Test_Result( - phHciNfc_sContext_t *psHciContext, - phNfc_sData_t *test_result - ); - - -/** -* \ingroup grp_hci_nfc -* -* \brief Allocates the resources required for PN544 Device -* management gate -* This function Allocates necessary resources as requiered by PN544 -* Device management gate -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* \param[in] pipeID pipeID of the Device management Gate -* \param[in] pPipeInfo Update the pipe Information of the Device -* Management Gate. -* -* \retval NFCSTATUS_SUCCESS Function execution is successful -* -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the given inputs are not valid -*/ -extern -NFCSTATUS -phHciNfc_DevMgmt_Update_PipeInfo( - phHciNfc_sContext_t *psHciContext, - uint8_t pipeID, - phHciNfc_Pipe_Info_t *pPipeInfo - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_DevMgmt_Release function closes the opened pipes between - * the Device Management Gate in the Host Controller Device - * and the NFC Device. - * - * \param[in] psHciContext psHciContext is the pointer to HCI Layer - * context Structure. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * - * \retval NFCSTATUS_PENDING Release of the Device Management gate - * resources are pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ -extern -NFCSTATUS -phHciNfc_DevMgmt_Release( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - -extern -NFCSTATUS -phHciNfc_DevMgmt_Update_Sequence( - phHciNfc_sContext_t *psHciContext, - phHciNfc_eSeqType_t DevMgmt_seq - ); - -extern -NFCSTATUS -phHciNfc_DevMgmt_Set_Test_Result( - phHciNfc_sContext_t *psHciContext, - uint8_t test_status - ) -; - -#endif - diff --git a/libnfc-nxp/phHciNfc_Emulation.h b/libnfc-nxp/phHciNfc_Emulation.h deleted file mode 100644 index b4669f3..0000000 --- a/libnfc-nxp/phHciNfc_Emulation.h +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! -* =========================================================================== * -* * -* * -* \file phHciNfc_Emulation.h * -* \brief HCI emulation management routines. * -* * -* * -* Project: NFC-FRI-1.1 * -* * -* $Date: Fri Aug 14 17:01:26 2009 $ * -* $Author: ing04880 $ * -* $Revision: 1.10 $ * -* $Aliases: NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ * -* * -* =========================================================================== * -*/ - - -#ifndef PHHCINFC_EMULATION_H -#define PHHCINFC_EMULATION_H - -/*@}*/ - - -/** -* \name HCI -* -* File: \ref phHciNfc_Emulation.h -* -*/ -/*@{*/ -#define PHHCINFC_EMULATION_FILEREVISION "$Revision: 1.10 $" /**< \ingroup grp_file_attributes */ -#define PHHCINFC_EMULATION_FILEALIASES "$Aliases: NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ -/*@}*/ - -/* -***************************** Header File Inclusion **************************** -*/ - -#include - -/* -****************************** Macro Definitions ******************************* -*/ -/* Connectivity Gate Command Support */ -#define PRO_HOST_REQUEST (0x10U) - -/* Connectivity Gate Event Support */ -#define EVT_CONNECTIVITY (0x10U) -#define EVT_END_OF_TRANSACTION (0x11U) -#define EVT_TRANSACTION (0x12U) -#define EVT_OPERATION_ENDED (0x13U) - -#define TRANSACTION_MIN_LEN (0x03U) -#define TRANSACTION_AID (0x81U) -#define TRANSACTION_PARAM (0x82U) - -#define HOST_CE_MODE_ENABLE (0x02U) -#define HOST_CE_MODE_DISABLE (0xFFU) - -#define NXP_PIPE_CONNECTIVITY (0x60U) - - -/* Card Emulation Gate Events */ -#define CE_EVT_NFC_SEND_DATA (0x10U) -#define CE_EVT_NFC_FIELD_ON (0x11U) -#define CE_EVT_NFC_DEACTIVATED (0x12U) -#define CE_EVT_NFC_ACTIVATED (0x13U) -#define CE_EVT_NFC_FIELD_OFF (0x14U) - -/* -******************** Enumeration and Structure Definition ********************** -*/ - - - -/* -*********************** Function Prototype Declaration ************************* -*/ - -extern -NFCSTATUS -phHciNfc_Uicc_Update_PipeInfo( - phHciNfc_sContext_t *psHciContext, - uint8_t pipe_id, - phHciNfc_Pipe_Info_t *pPipeInfo - ); - -extern -NFCSTATUS -phHciNfc_EmuMgmt_Update_Seq( - phHciNfc_sContext_t *psHciContext, - phHciNfc_eSeqType_t seq_type - ); - -extern -NFCSTATUS -phHciNfc_EmuMgmt_Initialise( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - -extern -NFCSTATUS -phHciNfc_EmuMgmt_Release( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - - -extern -NFCSTATUS -phHciNfc_Emulation_Cfg ( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - phHciNfc_eConfigType_t cfg_type - ); - -extern -NFCSTATUS -phHciNfc_Uicc_Get_PipeID( - phHciNfc_sContext_t *psHciContext, - uint8_t *ppipe_id - ); - -extern -NFCSTATUS -phHciNfc_Uicc_Connect_Status( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - -extern -void -phHciNfc_Uicc_Connectivity( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - - -#endif /* PHHCINFC_EMULATION_H */ diff --git a/libnfc-nxp/phHciNfc_Felica.h b/libnfc-nxp/phHciNfc_Felica.h deleted file mode 100644 index f399417..0000000 --- a/libnfc-nxp/phHciNfc_Felica.h +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! -* =========================================================================== * -* * -* * -* \file phHciNfc_Felica.h * -* \brief HCI Felica Management Routines. * -* * -* * -* Project: NFC-FRI-1.1 * -* * -* $Date: Fri Jun 5 12:10:53 2009 $ * -* $Author: ing02260 $ * -* $Revision: 1.3 $ * -* $Aliases: NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK926_R28_2,NFC_FRI1.1_WK926_R28_3,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ * -* * -* =========================================================================== * -*/ - -#ifndef PHHCINFC_FELICA_H -#define PHHCINFC_FELICA_H - -/*@}*/ - - -/** -* \name HCI -* -* File: \ref phHciNfc_Felica.h -* -*/ -/*@{*/ -#define PHHCINFC_FELICA_FILEREVISION "$Revision: 1.3 $" /**< \ingroup grp_file_attributes */ -#define PHHCINFC_FELICA_FILEALIASES "$Aliases: NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK926_R28_2,NFC_FRI1.1_WK926_R28_3,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ -/*@}*/ - -/* -***************************** Header File Inclusion **************************** -*/ - -#include - -/* -****************************** Macro Definitions ******************************* -*/ - -/* Commands exposed to the upper layer */ - -/* Enable the Felica */ -#define HCI_FELICA_ENABLE 0x01U -#define HCI_FELICA_INFO_SEQ 0x02U - -/* Felica read write commands */ -#define NXP_FELICA_RAW 0x20U -#define NXP_FELICA_CMD 0x21U - -/* -******************** Enumeration and Structure Definition ********************** -*/ -typedef enum phHciNfc_Felica_Seq{ - FELICA_SYSTEMCODE, - FELICA_CURRENTIDM, - FELICA_CURRENTPMM, - FELICA_END_SEQUENCE, - FELICA_INVALID_SEQ -} phHciNfc_Felica_Seq_t; - -/* Information structure for the Felica Gate */ -typedef struct phHciNfc_Felica_Info{ - /* Current running Sequence of the Felica Management */ - phHciNfc_Felica_Seq_t current_seq; - /* Next running Sequence of the Felica Management */ - phHciNfc_Felica_Seq_t next_seq; - /* Pointer to the Felica pipe information */ - phHciNfc_Pipe_Info_t *p_pipe_info; - uint8_t pipe_id; - /* Flag to say about the multiple targets */ - uint8_t multiple_tgts_found; - /* Felica information */ - phHal_sRemoteDevInformation_t felica_info; - /* Enable or disable reader gate */ - uint8_t enable_felica_gate; - /* UICC re-activation status */ - uint8_t uicc_activation; -} phHciNfc_Felica_Info_t; - -/* -*********************** Function Prototype Declaration ************************* -*/ - -/*! -* \brief Allocates the resources of Felica management gate. -* -* This function Allocates the resources of the Felica management -* gate Information Structure. -* -*/ -extern -NFCSTATUS -phHciNfc_Felica_Init_Resources( - phHciNfc_sContext_t *psHciContext - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_Felica_Get_PipeID function gives the pipe id of the Felica -* gate -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_Felica_Get_PipeID( - phHciNfc_sContext_t *psHciContext, - uint8_t *ppipe_id - ); - - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_Felica_Update_PipeInfo function updates the pipe_id of the Felica -* gate management Structure. -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pipeID pipeID of the Felica gate -* \param[in] pPipeInfo Update the pipe Information of the reader -* A gate -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ - -extern -NFCSTATUS -phHciNfc_Felica_Update_PipeInfo( - phHciNfc_sContext_t *psHciContext, - uint8_t pipeID, - phHciNfc_Pipe_Info_t *pPipeInfo - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_ReaderA_Update_Info function updated the felica gate info. -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] infotype To enable the felica gate -* \param[in] fel_info felica gate info -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -*/ -extern -NFCSTATUS -phHciNfc_Felica_Update_Info( - phHciNfc_sContext_t *psHciContext, - uint8_t infotype, - void *fel_info - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_Felica_Info_Sequence function executes the sequence of operations, to -* get the SYSTEM CODE, IDM, PPM. -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_Felica_Info_Sequence ( - void *psHciHandle, - void *pHwRef - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_Felica_Request_Mode function is to know about the felica tag is -* in the field or not -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_Felica_Request_Mode( - phHciNfc_sContext_t *psHciContext, - void *pHwRef); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_Send_Felica_Command function executes the command sent by the -* upper layer, depending on the commands defined. -* -* \param[in] psContext psContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* \param[in] pipe_id pipeID of the Felica gate -* \param[in] cmd command that needs to be sent to the device -* \param[in] length information length sent by the caller -* \param[in] params information related to the command -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -*/ -extern -NFCSTATUS -phHciNfc_Send_Felica_Command( - phHciNfc_sContext_t *psContext, - void *pHwRef, - uint8_t pipe_id, - uint8_t cmd - ); - -#endif /* #ifndef PHHCINFC_FELICA_H */ - - diff --git a/libnfc-nxp/phHciNfc_Generic.h b/libnfc-nxp/phHciNfc_Generic.h deleted file mode 100644 index de4bbfd..0000000 --- a/libnfc-nxp/phHciNfc_Generic.h +++ /dev/null @@ -1,1231 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! -* =========================================================================== * -* * -* * -* \file phHciNfc_Generic.h * -* \brief Common HCI Header for the Generic HCI Management. * -* * -* * -* Project: NFC-FRI-1.1 * -* * -* $Date: Mon Mar 29 17:34:47 2010 $ * -* $Author: ing04880 $ * -* $Revision: 1.73 $ * -* $Aliases: NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ -* * -* =========================================================================== * -*/ - -/*@{*/ -#ifndef PHHCINFC_GENERIC_H -#define PHHCINFC_GENERIC_H - -/*@}*/ - - -/** - * \name HCI - * - * File: \ref phHciNfc_Generic.h - * - */ -/*@{*/ -#define PHHCINFC_GENERIC_FILEREVISION "$Revision: 1.73 $" /**< \ingroup grp_file_attributes */ -#define PHHCINFC_GENERIC_FILEALIASES "$Aliases: NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ -/*@}*/ -/* - -################################################################################ -***************************** Header File Inclusion **************************** -################################################################################ -*/ -#define LOG_TAG "NFC-HCI" -#include -#include -#include -#include -/* -################################################################################ -****************************** Macro Definitions ******************************* -################################################################################ -*/ - -#define Trace_buffer phOsalNfc_DbgTraceBuffer - -/* HCI TRACE Macros */ -#if defined(HCI_TRACE)&& !defined(SILENT_HCI) -#include -#include -extern char phOsalNfc_DbgTraceBuffer[]; -#define MAX_TRACE_BUFFER 150 -/* #define HCI_PRINT( str ) phOsalNfc_DbgTrace(str) */ -#define HCI_PRINT( str ) phOsalNfc_DbgString(str) -#define HCI_DEBUG(...) ALOGD(__VA_ARGS__) - - - - -#define HCI_PRINT_BUFFER(msg,buf,len) \ - { \ - snprintf(Trace_buffer,MAX_TRACE_BUFFER,"\t %s:",msg); \ - phOsalNfc_DbgString(Trace_buffer); \ - phOsalNfc_DbgTrace(buf,len); \ - phOsalNfc_DbgString("\r"); \ - \ - } -#else -#include -#if defined(PHDBG_TRACES) && !defined(HCI_TRACE) -#define HCI_PRINT( str ) PHDBG_INFO(str) -#define HCI_DEBUG(str, arg) -#define HCI_PRINT_BUFFER(msg,buf,len) -#else -#define HCI_PRINT( str ) -#define HCI_DEBUG(...) -#define HCI_PRINT_BUFFER(msg,buf,len) -#endif /* #if defined(PHDBG_TRACES) */ -/* #if defined(PHDBG_INFO) && defined (PHDBG_CRITICAL_ERROR) */ - -#endif /* #if defined(HCI_TRACE) */ - -#define ZERO 0x00U - - -#ifdef MASK_BITS -#define BYTE_SIZE 0x08U - -/* HCI GET and SET BITS Macros */ -#define MASK_BITS8(p,l) \ - ( ( (((uint8_t)(p))+((uint8_t)(l)))<=BYTE_SIZE )? \ - (~(0xFFU<<((p)+(l))) & (0xFFU<<(p))):(0U) ) -#ifdef MASK_BITS -#define GET_BITS8(num,p,l) \ - ( ((((uint8_t)(p))+((uint8_t)(l)))<=BYTE_SIZE)? \ - (((num)& (MASK_BITS8(p,l)))>>(p)):(0U) ) -#else -#define GET_BITS8(num,p,l) \ - ( ((((p)+(l))<=BYTE_SIZE))? \ - (((num)>>(p))& (~(0xFFU<<(l)))):(0U) ) -#endif -#define SET_BITS8(num,p,l,val) \ - ( ((((uint8_t)(p))+((uint8_t)(l)))<=BYTE_SIZE)? \ - (((num)& (~MASK_BITS8(p,l)))|((val)<<(p))):(0U)) - -#endif - -/** \ingroup grp_hci_retval - The Corresponding HCI Gate Not Supported. - */ -#define NFCSTATUS_HCI_GATE_NOT_SUPPORTED (0x71U) - -/** \ingroup grp_hci_retval - Invalid Command from the HCI Layer - */ -#define NFCSTATUS_INVALID_HCI_COMMAND (0x72U) - -/** \ingroup grp_hci_retval - HCI Command not supported . */ -#define NFCSTATUS_COMMAND_NOT_SUPPORTED (0x73U) - -/** \ingroup grp_hci_retval - Invalide Response from the HCI Layer - */ -#define NFCSTATUS_INVALID_HCI_RESPONSE (0x74U) - -/** \ingroup grp_hci_retval - The Invalid Instruction type (Neither Command/Response nor Event ). - */ -#define NFCSTATUS_INVALID_HCI_INSTRUCTION (0x75U) - -/** \ingroup grp_hci_retval - The Invalid Instruction type (Neither Command/Response nor Event ). - */ -#define NFCSTATUS_INVALID_HCI_INFORMATION (0x76U) - -/** \ingroup grp_hci_retval - The Invalid HCI Sequence. - */ -#define NFCSTATUS_INVALID_HCI_SEQUENCE (0x78U) - - -/** \ingroup grp_hci_retval - The HCI Error Response with Response code. - */ -#define NFCSTATUS_HCI_RESPONSE(code) (code) - - -/* Length of the HCP and the HCP Message Header in Bytes */ -#define HCP_HEADER_LEN 0x02U - -/* Length of the HCP Message Header in Bytes */ -#define HCP_MESSAGE_LEN 0x01U - -/* HCP Header Chaining Bit Offset */ -#define HCP_CHAINBIT_OFFSET 0x07U -/* HCP Header Chaining Bit Length */ -#define HCP_CHAINBIT_LEN 0x01U - -/* Chaining Bit Values */ -#define HCP_CHAINBIT_DEFAULT 0x01U -#define HCP_CHAINBIT_BEGIN 0x00U -#define HCP_CHAINBIT_END HCP_CHAINBIT_DEFAULT - -/* HCP Header Pipe ID Offset */ -#define HCP_PIPEID_OFFSET 0x00U -/* HCP Header Pipe ID Length */ -#define HCP_PIPEID_LEN 0x07U - -/* HCP Message Header Type Offset */ -#define HCP_MSG_TYPE_OFFSET 0x06U -/* HCP Message Header Type Length */ -#define HCP_MSG_TYPE_LEN 0x02U - -/* HCP Message Type Values */ -#define HCP_MSG_TYPE_COMMAND 0x00U -#define HCP_MSG_TYPE_EVENT 0x01U -#define HCP_MSG_TYPE_RESPONSE 0x02U -#define HCP_MSG_TYPE_RESERVED 0x03U - -/* HCP Message Header Instruction Offset */ -#define HCP_MSG_INSTRUCTION_OFFSET 0x00U -/* HCP Message Header Instruction Length */ -#define HCP_MSG_INSTRUCTION_LEN 0x06U -/* HCP Invalid Message Instruction */ -#define HCP_MSG_INSTRUCTION_INVALID 0x3FU - - -/* HCP Packet Zero Length */ -#define HCP_ZERO_LEN 0x00U - - - - /** \internal Generic HCI Commands for all the Gates */ -#define ANY_SET_PARAMETER 0x01U -#define ANY_GET_PARAMETER 0x02U -#define ANY_OPEN_PIPE 0x03U -#define ANY_CLOSE_PIPE 0x04U -#define ANY_GENERIC_CMD_RFU_B 0x05U -#define ANY_GENERIC_CMD_RFU_E 0x0FU - -/* - * 0x05-0x0F is Reserved for Future Use - */ - -/** \internal HCI Administration Com mands for the Management of the Host Network */ - -#define ADM_CREATE_PIPE 0x10U -#define ADM_DELETE_PIPE 0x11U -#define ADM_NOTIFY_PIPE_CREATED 0x12U -#define ADM_NOTIFY_PIPE_DELETED 0x13U -#define ADM_CLEAR_ALL_PIPE 0x14U -#define ADM_NOTIFY_ALL_PIPE_CLEARED 0x15U -#define ADM_CMD_RFU_B 0x16U -#define ADM_CMD_RFU_E 0x3FU - -#define MSG_INSTRUCTION_UNKNWON 0x3FU - - /* - * 0x16-0x3F is Reserved for Future Use - */ - - -/** \internal HCI Generic Responses from the Gates */ -#define ANY_OK 0x00U -#define ANY_E_NOT_CONNECTED 0x01U -#define ANY_E_CMD_PAR_UNKNOWN 0x02U -#define ANY_E_NOK 0x03U -#define ANY_E_PIPES_FULL 0x04U -#define ANY_E_REG_PAR_UNKNOWN 0x05U -#define ANY_E_PIPE_NOT_OPENED 0x06U -#define ANY_E_CMD_NOT_SUPPORTED 0x07U -#define ANY_E_INHIBITED 0x08U -#define ANY_E_TIMEOUT 0x09U -#define ANY_E_REG_ACCESS_DENIED 0x0AU -#define ANY_E_PIPE_ACCESS_DENIED 0x0BU - -/* Response Error Code for RF Reader Gate */ -#define WR_RF_ERROR 0x10U - -/* -* 0x08, 0x0B-0x3F is Reserved for Future Use -*/ - - -/** \internal HCI Generic Events from the Gates */ -#define EVT_HCI_END_OF_OPERATION 0x01 -#define EVT_POST_DATA 0x02 -#define EVT_HOT_PLUG 0x03 - - -/* Maximum Buffer Size for the HCI Data */ -#define PHHCINFC_MAX_BUFFERSIZE (PHHAL_MAX_DATASIZE + 0x50U) - -#define PHHCINFC_MAX_OPENPIPE 0x6FU -#define PHHCINFC_MAX_PIPE 0x6FU -#define PHHCINFC_MIN_PIPE 0x02U - - -/* Maximum Payload Length of HCI. */ -#define PHHCINFC_MAX_PACKET_DATA 0x1CU -#define PHHCINFC_MAX_HCP_LEN PHHCINFC_MAX_PACKET_DATA + 1 - - - -/* Maximum Payload Length of HCI. */ - - -/* -################################################################################ -******************** Enumeration and Structure Definition ********************** -################################################################################ -*/ -#if 1 -typedef NFCSTATUS (*pphHciNfc_Pipe_Receive_t) ( - void *pContext, - void *pHwRef, - uint8_t *data, -#ifdef ONE_BYTE_LEN - uint8_t length -#else - uint16_t length -#endif - ); -#else - -typedef pphNfcIF_Transact_t pphHciNfc_Pipe_Receive_t; - -#endif - -/** \defgroup grp_hci_nfc HCI Component - * - * - */ - -typedef enum phHciNfc_HostID { - phHciNfc_HostControllerID = 0x00U, - phHciNfc_TerminalHostID = 0x01U, - phHciNfc_UICCHostID = 0x02U -/* - phHciNfc_HostID_RFU_B = 0x03U, - phHciNfc_HostID_RFU_E = 0xBFU, - phHciNfc_HostIDProprietary_B = 0xC0U, - phHciNfc_HostIDProprietary_E = 0xFFU -*/ -}phHciNfc_HostID_t; - - -typedef enum phHciNfc_GateID{ - phHciNfc_AdminGate = 0x00U, -/* - phHciNfc_evGateIDProprietary_B = 0x01U, - phHciNfc_evGateIDProprietary_E = 0x03U, -*/ - phHciNfc_LoopBackGate = 0x04U, - phHciNfc_IdentityMgmtGate = 0x05U, - phHciNfc_LinkMgmtGate = 0x06U, -/* - phHciNfc_GateID_RFU_B = 0x07U, - phHciNfc_GateID_RFU_E = 0x0FU, -*/ - -/* TODO: Fillin Other Gate Information */ - /* ETSI HCI Specific RF Reader Gates */ - phHciNfc_RFReaderAGate = 0x13, - phHciNfc_RFReaderBGate = 0x11, - - /* Proprietary Reader Gate */ - phHciNfc_ISO15693Gate = 0x12, - phHciNfc_RFReaderFGate = 0x14, - phHciNfc_JewelReaderGate = 0x15, - - /* ETSI HCI Card RF Gates */ - phHciNfc_CETypeBGate = 0x21, - phHciNfc_CETypeBPrimeGate = 0x22, - phHciNfc_CETypeAGate = 0x23, - phHciNfc_CETypeFGate = 0x24, - - /* NFC-IP1 Gates */ - phHciNfc_NFCIP1InitRFGate = 0x30, - phHciNfc_NFCIP1TargetRFGate = 0x31, - - /* ETSI HCI Connectivity Gate */ - phHciNfc_ConnectivityGate = 0x41, - - - /* Device Configuration Gates */ - phHciNfc_PN544MgmtGate = 0x90, - phHciNfc_HostCommGate = 0x91, - phHciNfc_GPIOGate = 0x92, - phHciNfc_RFMgmtGate = 0x93, - phHciNfc_PollingLoopGate = 0x94, - phHciNfc_DownloadMgmtGate = 0x95, - - /* Card Emulation Managment Gates */ - phHciNfc_SwpMgmtGate = 0xA0, - phHciNfc_NfcWIMgmtGate = 0xA1, - phHciNfc_UnknownGate = 0xFF - -}phHciNfc_GateID_t; - - -typedef enum phHciNfc_PipeID{ - HCI_LINKMGMT_PIPE_ID = 0x00U, - HCI_ADMIN_PIPE_ID = 0x01U, - HCI_DYNAMIC_PIPE_ID = 0x02U, - HCI_RESERVED_PIPE_ID = 0x70U, - HCI_UNKNOWN_PIPE_ID = PHHCINFC_MAX_PIPE -/* - phHciNfc_evOtherGatePipeID_B = 0x02U, - phHciNfc_evOtherGatePipeID_E = 0x6FU, - phHciNfc_evGatePipeID_RFU_B = 0x70U, - phHciNfc_evGatePipeID_RFU_E = 0x7FU, -*/ -}phHciNfc_PipeID_t; - - -typedef enum phHciNfc_eState { - hciState_Reset = 0x00U, - hciState_Initialise, - hciState_Test, - hciState_Config, - hciState_IO, - hciState_Select, - hciState_Listen, - hciState_Activate, - hciState_Reactivate, - hciState_Connect, - hciState_Transact, - hciState_Disconnect, - hciState_Presence, - hciState_Release, - hciState_Unknown -}phHciNfc_eState_t; - -typedef enum phHciNfc_eMode { - hciMode_Reset = 0x00U, - hciMode_Session, - hciMode_Override, - hciMode_Test, - hciMode_Unknown -}phHciNfc_eMode_t; - - -typedef enum phHciNfc_eSeq{ - /* HCI Admin Sequence */ - ADMIN_INIT_SEQ = 0x00U, - ADMIN_SESSION_SEQ, - ADMIN_CE_SEQ, - ADMIN_REL_SEQ, - ADMIN_EVT_HOTPLUG_SEQ, - - /* HCI Link Management Sequence */ - LINK_MGMT_INIT_SEQ, - LINK_MGMT_REL_SEQ, - - /* HCI Identity Management Sequence */ - IDENTITY_INIT_SEQ, - IDENTITY_INFO_SEQ, - IDENTITY_REL_SEQ, - - /* HCI Polling Loop Sequence */ - PL_INIT_SEQ, - PL_DURATION_SEQ, - PL_CONFIG_PHASE_SEQ, - PL_TGT_DISABLE_SEQ, - PL_RESTART_SEQ, - PL_STOP_SEQ, - PL_REL_SEQ, - - /* HCI Device Management Sequence */ - DEV_INIT_SEQ, - DEV_HAL_INFO_SEQ, - DEV_CONFIG_SEQ, - DEV_REL_SEQ, - - /* HCI Reader Management Sequence */ - READER_MGMT_INIT_SEQ, - READER_ENABLE_SEQ, - READER_SELECT_SEQ, - READER_REACTIVATE_SEQ, - READER_SW_AUTO_SEQ, - READER_PRESENCE_CHK_SEQ, - READER_UICC_DISPATCH_SEQ, - READER_DESELECT_SEQ, - READER_RESELECT_SEQ, - READER_DISABLE_SEQ, - READER_MGMT_REL_SEQ, - - /* HCI NFC-IP1 Sequence */ - NFCIP1_INIT_SEQ, - INITIATOR_SPEED_SEQ, - INITIATOR_GENERAL_SEQ, - TARGET_GENERAL_SEQ, - TARGET_SPEED_SEQ, - NFCIP1_REL_SEQ, - - /* HCI Emulation Management Sequence */ - EMULATION_INIT_SEQ, - EMULATION_SWP_SEQ, - EMULATION_CONFIG_SEQ, - EMULATION_REL_SEQ, - - HCI_END_SEQ, - HCI_INVALID_SEQ -} phHciNfc_eSeq_t; - - - -typedef enum phHciNfc_eSeqType{ - RESET_SEQ = 0x00U, - INIT_SEQ, - UPDATE_SEQ, - INFO_SEQ, - CONFIG_SEQ, - REL_SEQ, - END_SEQ -} phHciNfc_eSeqType_t; - - -typedef enum phHciNfc_eConfigType{ - INVALID_CFG = 0x00U, - POLL_LOOP_CFG, - SMX_WI_CFG, - SMX_WI_MODE, - UICC_SWP_CFG, - SWP_EVT_CFG, - SWP_PROTECT_CFG, - NFC_GENERAL_CFG, - NFC_TARGET_CFG, - NFC_CE_A_CFG, - NFC_CE_B_CFG -} phHciNfc_eConfigType_t; - - -typedef struct phHciNfc_HCP_Message{ - /** \internal Identifies the Type and Kind of Instruction */ - uint8_t msg_header; - /** \internal Host Controller Protocol (HCP) Packet Message Payload */ - uint8_t payload[PHHCINFC_MAX_PACKET_DATA - 1]; -}phHciNfc_HCP_Message_t; - - -typedef struct phHciNfc_HCP_Packet{ - /** \internal Chaining Information and Pipe Identifier */ - uint8_t hcp_header; - /** \internal Host Controller Protocol (HCP) Packet Message or Payload */ - union - { - /** \internal Host Controller Protocol (HCP) Packet Message */ - phHciNfc_HCP_Message_t message; - /** \internal Host Controller Protocol (HCP) Packet Payload */ - uint8_t payload[PHHCINFC_MAX_PACKET_DATA]; - }msg; -}phHciNfc_HCP_Packet_t; - - - -typedef struct phHciNfc_Gate_Info{ - /** \internal HCI Host Identifier */ - uint8_t host_id; - /** \internal HCI Gate Identifier */ - uint8_t gate_id; -}phHciNfc_Gate_Info_t; - - -typedef struct phHciNfc_Pipe_Params{ - /** \internal HCI Source Gate Information for the pipe */ - phHciNfc_Gate_Info_t source; - /** \internal HCI Destination Gate Information for the pipe */ - phHciNfc_Gate_Info_t dest; - /** \internal HCI Pipe Identifier */ - uint8_t pipe_id; -}phHciNfc_Pipe_Params_t; - - -typedef struct phHciNfc_Pipe_Info{ - /** \internal Structure containing the created dynamic pipe information */ - phHciNfc_Pipe_Params_t pipe; - /** \internal Status of the previous command sent to this pipe */ - NFCSTATUS prev_status; - /** \internal previous message type Sent to this pipe */ - uint8_t sent_msg_type; - /** \internal Message type Received in this pipe */ - uint8_t recv_msg_type; - /** \internal previous message sent to this pipe */ - uint8_t prev_msg; - /** \internal Index of the previous Set/Get Parameter command - * sent to this pipe */ - uint8_t reg_index; - /** \internal length of Parameter of the Set/Get Parameter - * command sent to this pipe */ - uint16_t param_length; - /** \internal Parameter of the Set/Get Parameter command - * sent to this pipe */ - void *param_info; - /** \internal Pointer to a Pipe specific Receive Response function */ - pphHciNfc_Pipe_Receive_t recv_resp; - /** \internal Pointer to a Pipe specific Receive Event function */ - pphHciNfc_Pipe_Receive_t recv_event; - /** \internal Pointer to a Pipe specific Receive Command function */ - pphHciNfc_Pipe_Receive_t recv_cmd; -}phHciNfc_Pipe_Info_t; - - -typedef struct phHciNfc_sContext{ - /** \internal HCI Layer Pointer from the upper layer for - lower layer function registration */ - phNfcLayer_sCfg_t *p_hci_layer; - /** \internal Pointer to the upper layer context */ - void *p_upper_context; - /** \internal Pointer to the Hardware Reference Sturcture */ - phHal_sHwReference_t *p_hw_ref; - /** \internal Pointer to the upper layer notification callback function */ - pphNfcIF_Notification_CB_t p_upper_notify; - /** \internal Structure to store the lower interface operations */ - phNfc_sLowerIF_t lower_interface; - /** \internal Execution Sequence using the HCI Context */ - volatile phHciNfc_eSeq_t hci_seq; - - /** \internal State of the HCI Context */ - volatile phNfc_sState_t hci_state; - - /** \internal Mode of HCI Initialisation */ - phHciNfc_Init_t init_mode; - - /** \internal Memory Information for HCI Initialisation */ - uint8_t hal_mem_info[NXP_HAL_MEM_INFO_SIZE]; - - /** \internal HCI Configuration Type */ - phHciNfc_eConfigType_t config_type; - /** \internal HCI SmartMX Mode Configuration */ - phHal_eSmartMX_Mode_t smx_mode; - /** \internal HCI Configuration Information */ - void *p_config_params; - - /** \internal Current RF Reader/Emulation Gate in Use */ - phHal_eRFDevType_t host_rf_type; - - /** \internal Connected Target Information */ - phHal_sRemoteDevInformation_t *p_target_info; - - /** \internal Information of all the pipes created and opened */ - phHciNfc_Pipe_Info_t *p_pipe_list[PHHCINFC_MAX_PIPE+1]; - - /** \internal Tag */ - phHciNfc_XchgInfo_t *p_xchg_info; - - /** \internal Information of the HCI Gates */ - /** \internal HCI Admin Management Gate Information */ - void *p_admin_info; - /** \internal HCI Link Management Gate Information */ - void *p_link_mgmt_info; - /** \internal HCI Identity Management Gate Information */ - void *p_identity_info; - /** \internal HCI Polling Loop Gate Information */ - void *p_poll_loop_info; - /** \internal HCI NFC Device Management Information */ - void *p_device_mgmt_info; - /** \internal HCI RF Reader Gates Management Information */ - void *p_reader_mgmt_info; - /** \internal HCI Card Application Gates and Emulation - Information */ - void *p_emulation_mgmt_info; - /** \internal HCI RF Reader A Gate Information */ - void *p_reader_a_info; -#ifdef TYPE_B - /** \internal HCI RF Reader B Gate Information */ - void *p_reader_b_info; -#endif -#ifdef TYPE_FELICA - /** \internal HCI Felica Reader Gate Information */ - void *p_felica_info; -#endif -#ifdef TYPE_JEWEL - /** \internal HCI Jewel Reader Gate Information */ - void *p_jewel_info; -#endif -#ifdef TYPE_ISO15693 - /** \internal HCI ISO15693 Reader Gate Information */ - void *p_iso_15693_info; -#endif - -#ifdef ENABLE_P2P - /** \internal HCI NFC-IP1 Peer to Peer Information */ - void *p_nfcip_info; -#endif - /** \internal HCI Secure Element Management Information */ - void *p_wi_info; - /** \internal HCI UICC Information */ - void *p_uicc_info; - /** \internal HCI SWP Information */ - void *p_swp_info; -#ifdef HOST_EMULATION - /** \internal HCI Card Emulation A Gate Information */ - void *p_ce_a_info; - /** \internal HCI Card Emulation B Gate Information */ - void *p_ce_b_info; -#endif - - /** \internal HCI Packet Data to be sent to the lower layer */ - phHciNfc_HCP_Packet_t tx_packet; - /** \internal HCI Packet Data to be received from the lower layer */ - phHciNfc_HCP_Packet_t rx_packet; - - /** \internal Previous Status (To Store the Error Status ) */ - NFCSTATUS error_status; - - /** \internal Pointer to HCI Send Buffer */ - uint8_t send_buffer[PHHCINFC_MAX_BUFFERSIZE]; - /** \internal Pointer to HCI Receive Buffer */ - uint8_t recv_buffer[PHHCINFC_MAX_BUFFERSIZE]; - - /** \internal Total Number of bytes to be Sent */ - volatile uint16_t tx_total; - /** \internal Number of bytes Remaining to be Sent */ - volatile uint16_t tx_remain; - /** \internal Number of bytes sent */ - volatile uint16_t tx_sent; - - volatile uint16_t rx_index; - - /** \internal Total Number of bytes received */ - volatile uint16_t rx_total; - /** \internal Number of bytes received */ - volatile uint16_t rx_recvd; - /** \internal Index of the received data in the - * response packet - */ - - /** \internal Send HCP Chaining Information */ - volatile uint8_t tx_hcp_chaining; - /** \internal Send HCP Fragment Index */ - volatile uint16_t tx_hcp_frgmnt_index; - - /** \internal Receive HCP Chaining Information */ - volatile uint8_t rx_hcp_chaining; - /** \internal Receive HCP Fragment Index */ - volatile uint16_t rx_hcp_frgmnt_index; - - /** \internal The Device under Test */ - volatile uint8_t hci_mode; - /** \internal Wait for Response if Response is Pending */ - volatile uint8_t response_pending; - /** \internal Notify the Event if Notifcation is Pending */ - volatile uint8_t event_pending; - - /** \internal Pending Release of the detected Target */ - uint8_t target_release; - -}phHciNfc_sContext_t; - -/* -################################################################################ -*********************** Function Prototype Declaration ************************* -################################################################################ -*/ - - -/** - * - * \ingroup grp_hci_nfc - * - * The phHciNfc_Receive function receives the HCI Events or Response from the - * corresponding peripheral device, described by the HCI Context Structure. - * - * \param[in] psContext psContext is the context of - * the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[out] pdata Pointer to the response buffer that - * receives the response read. - * \param[in] length Variable that receives - * the number of bytes read. - * - * \retval NFCSTATUS_PENDING Data successfully read. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Other related errors - * - */ - -extern -NFCSTATUS -phHciNfc_Receive( - void *psContext, - void *pHwRef, - uint8_t *pdata, -#ifdef ONE_BYTE_LEN - uint8_t length -#else - uint16_t length -#endif - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Send_Complete function acknowledges the completion of the HCI - * Commands sent to the device. - * - * \param[in] psContext psContext is the context of - * the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] pInfo Transaction information like - * status and length after the - * completion of the send. - * - * \retval NONE. - * - */ - -extern -void -phHciNfc_Send_Complete ( - void *psContext, - void *pHwRef, - phNfc_sTransactionInfo_t *pInfo - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Receive_Complete function acknowledges the completion of the HCI - * Event Information or Response received from the device. - * - * \param[in] psContext psContext is the context of - * the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] pInfo Transaction information like status - * data and length after the completely - * receiving the response . - * \retval NONE. - * - * - */ - -extern -void -phHciNfc_Receive_Complete ( - void *psContext, - void *pHwRef, - phNfc_sTransactionInfo_t *pInfo - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Notify_Event function notifies the occurence of the HCI - * Event from the device. - * - * \param[in] psContext psContext is the context of - * the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] type reason returned for the notification to - * the HCI. - * \param[in] pInfo Notification information like status - * data,length etc from the lower layer - * to the HCI Layer. - * \retval NONE. - * - */ - -extern -void -phHciNfc_Notify_Event( - void *psContext, - void *pHwRef, - uint8_t type, - void *pInfo - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Tag_Notify function notifies the the upper layer - * with the Tag Specific Notifications . - * - * \param[in] psContext psContext is the context of - * the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] type reason returned for the notification to - * the HCI. - * \param[in] pInfo Notification information like status - * data,length etc from the lower layer - * to the HCI Layer. - * \retval NONE. - * - */ -extern -void -phHciNfc_Tag_Notify( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - uint8_t type, - void *pInfo - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Tag_Notify function notifies the the upper layer - * with the Tag Specific Notifications . - * - * \param[in] psContext psContext is the context of - * the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] type reason returned for the notification to - * the HCI. - * \param[in] pInfo Notification information like status - * data,length etc from the lower layer - * to the HCI Layer. - * \retval NONE. - * - */ - -extern -void -phHciNfc_Target_Select_Notify( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - uint8_t type, - void *pInfo - ); - - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Transceive_Notify function notifies the the upper layer - * with the after the transceive operation. - * - * \param[in] psContext psContext is the context of - * the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] type reason returned for the notification to - * the HCI. - * \param[in] pInfo Notification information like status - * data,length etc from the lower layer - * to the HCI Layer. - * \retval NONE. - * - */ -extern -void -phHciNfc_Transceive_Notify( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - uint8_t type, - void *pInfo - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Notify function calls the upper layer notification callback. - * - * \param[in] pUpperNotify pUpperNotify is the notification - * callback of the upper HAL Layer. - * \param[in] pUpperContext pUpperContext is the context of - * the upper HAL Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] type type of the notification to - * the upper HAL layer. - * \param[in] pInfo completion information returned - * to the Upper HAL Layer. - * NFCSTATUS_SUCCESS Notification successfully completed . - * NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * Other errors Errors related to the HCI or lower layers - * - * \retval NONE. - * - */ - -extern -void -phHciNfc_Notify( - pphNfcIF_Notification_CB_t p_upper_notify, - void *p_upper_context, - void *pHwRef, - uint8_t type, - void *pInfo - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Release_Notify function Releases HCI and notifies - * the upper layer. - * - * \param[in] psHciContext psHciContext is the context of - * the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] type reason returned for the notification to - * the HCI. - * \param[in] pInfo Notification information like status - * data,length etc from the lower layer - * to the HCI Layer. - * \retval NONE. - * - */ -extern -void -phHciNfc_Release_Notify( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - uint8_t type, - void *pInfo - ); - - - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Send_Generic_Cmd function sends the HCI Generic Commands - * to the device. - * - * \param[in] psHciContext psHciContext is the context of - * the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] pipe_id The pipe to which the command - * is being sent. - * \param[in] cmd The HCI Generic command sent to a - * particular pipe . - * - * \retval NFCSTATUS_PENDING HCI Generic Command send in progress . - * \retval - * NFCSTATUS_INSUFFICIENT_RESOURCES The memory could not be allocated - * as required amount of memory - * is not sufficient. - * - */ - -extern -NFCSTATUS -phHciNfc_Send_Generic_Cmd ( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - uint8_t pipe_id, - uint8_t cmd - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Set_Param function configures the Gate specific register - * with the provided value. - * - * \param[in] psHciContext psHciContext is the context of - * the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] p_pipe_info Pointer to pipe specific information. - * \param[in] reg_index Index of the register to be - * configured . - * \param[in] p_param Value to the configured in - * particular register. - * \param[in] param_length Length of the parameter provided - * for the configuration. - * - * \retval NFCSTATUS_PENDING HCI Set parameter in progress . - * \retval - * NFCSTATUS_INVALID_HCI_INFORMATION The Information like p_pipe_info, - * p_param or param_length is invalid - * - */ - -extern -NFCSTATUS -phHciNfc_Set_Param ( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - phHciNfc_Pipe_Info_t *p_pipe_info, - uint8_t reg_index, - void *p_param, - uint16_t param_length - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Send_HCP function sends the HCI Host Control Packet - * Frames to the device. - * - * \param[in] psHciContext psHciContext is the context of - * the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * - * \retval NFCSTATUS_PENDING HCP Frame send pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Other related errors - * - * - */ - -extern -NFCSTATUS -phHciNfc_Send_HCP ( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Build_HCPFrame function initially builds the HCP Packet Frame - * with the values passed in the arguments . - * - * \param[in] hcp_packet hcp_packet is the frame packet structure - * in which the frame is populated with the - * appropriate fields. - * \param[in] chainbit chainbit specifies whether the following - * HCP frames are chained or the frame is a - * normal frame. - * \param[in] pipe_id pipe_id of the pipe to which the frame has - * to be sent. - * \param[in] msg_type type of message sent to the pipe. - * \param[in] instruction type of message instruction send to the pipe. - * - * \retval NONE. - * - */ - - -extern -void -phHciNfc_Build_HCPFrame ( - phHciNfc_HCP_Packet_t *hcp_packet, - uint8_t chainbit, - uint8_t pipe_id, - uint8_t msg_type, - uint8_t instruction - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Append_HCPFrame function Appends the HCP Packet Frame - * with the values passed in the arguments . - * - * \param[in] hcp_data hcp_data is the pointer to the HCP - * payload to which the data is to be - * appended. - * \param[in] hcp_index hcp_index is the index from which - * the data source needs to be appended. - * \param[in] src_data src_data that is to be appended to the - * HCP packet. - * \param[in] src_len The length of the data source that is - * to be appended. - * \retval NONE. - * - */ - -extern -void - phHciNfc_Append_HCPFrame ( - uint8_t *hcp_data, - uint16_t hcp_index, - uint8_t *src_data, - uint16_t src_len - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Allocate_Resource function allocates and initialises the - * resource memory for the HCI layer. - * - * \param[in] ppBuffer ppBuffer is the pointer to which the - * resource memory is allocated. - * \param[in] size Variable that specifies the size of - * the memory that needs to be created. - * - * \retval NFCSTATUS_SUCCESS The Resource Memory was allocated - * successfully . - * \retval - * NFCSTATUS_INSUFFICIENT_RESOURCES The memory could not be allocated - * as required amount of memory - * is not suffient. - * - */ - -extern -NFCSTATUS - phHciNfc_Allocate_Resource ( - void **ppBuffer, - uint16_t size - ); -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Release_Resources function releases all the resources - * allocated in the HCI Layer. - * - * \param[in] psHciContext psHciContext is the context of - * the HCI Layer. - * - * \retval NONE. - * - */ - -extern - void - phHciNfc_Release_Resources ( - phHciNfc_sContext_t **ppsHciContext - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Release_Lower function initiates the release of the - * lower layers. - * - * \param[in] psHciContext psHciContext is the context of - * the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * - * \retval NONE. - * - */ - -extern -void -phHciNfc_Release_Lower( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - - - -#endif - diff --git a/libnfc-nxp/phHciNfc_IDMgmt.h b/libnfc-nxp/phHciNfc_IDMgmt.h deleted file mode 100644 index 5e1e7c6..0000000 --- a/libnfc-nxp/phHciNfc_IDMgmt.h +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! -* =========================================================================== * -* * -* * -* \file phHciNfc_IDMgmt.h * -* \brief HCI Header for the Identity Management Gate. * -* * -* * -* Project: NFC-FRI-1.1 * -* * -* $Date: Fri Aug 14 17:01:26 2009 $ * -* $Author: ing04880 $ * -* $Revision: 1.5 $ * -* $Aliases: NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ * -* * -* =========================================================================== * -*/ - - -#ifndef PHHCINFC_IDMGMT_H -#define PHHCINFC_IDMGMT_H - -/*@}*/ - - -/** - * \name HCI - * - * File: \ref phHciNfc_IDMgmt.h - * - */ -/*@{*/ -#define PHHCINFC_IDMGMT_FILEREVISION "$Revision: 1.5 $" /**< \ingroup grp_file_attributes */ -#define PHHCINFC_IDMGMT_FILEALIASES "$Aliases: NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ -/*@}*/ - -/* -***************************** Header File Inclusion **************************** -*/ - -#include - -/* -****************************** Macro Definitions ******************************* -*/ - -/* -******************** Enumeration and Structure Definition ********************** -*/ - - - -/* -*********************** Function Prototype Declaration ************************* -*/ - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_IDMgmt_Initialise function creates and the opens Identity - * Management Gate - * - * \param[in] psHciContext psHciContext is the pointer to HCI Layer - * context Structure. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * - * \retval NFCSTATUS_PENDING Identity Mgmt Gate Initialisation is pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ -extern -NFCSTATUS -phHciNfc_IDMgmt_Initialise( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_IDMgmt_Info_Sequence function obtains the information - * from the Identity Management Gate - * - * \param[in] psHciContext psHciContext is the pointer to HCI Layer - * context Structure. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * - * \retval NFCSTATUS_PENDING Identity Mgmt Gate Information is pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ -extern -NFCSTATUS -phHciNfc_IDMgmt_Info_Sequence( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_IDMgmt_Release function closes the opened pipes between - * the Host Controller Device and the NFC Device. - * - * \param[in] psHciContext psHciContext is the pointer to HCI Layer - * context Structure. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * - * \retval NFCSTATUS_PENDING Release of the Identity Management gate - * resources are pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ -extern -NFCSTATUS -phHciNfc_IDMgmt_Release( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_IDMgmt_Update_PipeInfo function updates the pipe_id of the Idetity - * Gate Managment Struction. - * - * \param[in] psHciContext psHciContext is the pointer to HCI Layer - * context Structure. - * \param[in] pipeID pipeID of the Identity management Gate - * \param[in] pPipeInfo Update the pipe Information of the Identity - * Management Gate. - * - * \retval NFCSTATUS_SUCCESS AdminGate Response received Successfully. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * - */ - -extern -NFCSTATUS -phHciNfc_IDMgmt_Update_PipeInfo( - phHciNfc_sContext_t *psHciContext, - uint8_t pipeID, - phHciNfc_Pipe_Info_t *pPipeInfo - ); - - -/*! - * \brief Updates the Sequence of Identity Managment Gate. - * - * This function Updates the Sequence of the Identity Management - * gate Information Structure. - * - */ -extern -NFCSTATUS -phHciNfc_IDMgmt_Update_Sequence( - phHciNfc_sContext_t *psHciContext, - phHciNfc_eSeqType_t reader_seq - ); - -/*! - * \brief Allocates the resources of Identity Managment Gate. - * - * This function Allocates the resources of the Identity Management - * gate Information Structure. - * - */ -extern -NFCSTATUS -phHciNfc_IDMgmt_Init_Resources( - phHciNfc_sContext_t *psHciContext - ); - - -/*! - * \brief Get the pipe_id of Identity Managment Gate. - * - * This function Get the pipe_id of Identity Managment Gate. - * - */ - -extern -NFCSTATUS -phHciNfc_IDMgmt_Get_PipeID( - phHciNfc_sContext_t *psHciContext, - uint8_t *ppipe_id - ); - - - -#endif - diff --git a/libnfc-nxp/phHciNfc_ISO15693.h b/libnfc-nxp/phHciNfc_ISO15693.h deleted file mode 100644 index d6fb849..0000000 --- a/libnfc-nxp/phHciNfc_ISO15693.h +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! -* =========================================================================== * -* * -* * -* \file phHciNfc_NfcIPMgmt.h * -* \brief HCI NFCIP-1 Management Routines. * -* * -* * -* Project: NFC-FRI-1.1 * -* * -* $Date: Tue Jun 30 17:09:29 2009 $ * -* $Author: ing04880 $ * -* $Revision: 1.1 $ * -* $Aliases: NFC_FRI1.1_WK926_R28_2,NFC_FRI1.1_WK926_R28_3,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ * -* * -* =========================================================================== * -*/ - -#ifndef PHHCINFC_ISO15693_H -#define PHHCINFC_ISO15693_H - -/*@}*/ - - -/** -* \name HCI -* -* File: \ref phHciNfc_ISO15693.h -* -*/ -/*@{*/ -#define PHHCINFC_ISO15693_FILEREVISION "$Revision: 1.1 $" /**< \ingroup grp_file_attributes */ -#define PHHCINFC_ISO15693_FILEALIASES "$Aliases: NFC_FRI1.1_WK926_R28_2,NFC_FRI1.1_WK926_R28_3,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ -/*@}*/ - -/* -***************************** Header File Inclusion **************************** -*/ - -#include - -/* -****************************** Macro Definitions ******************************* -*/ -/* Enable the ISO 15693 */ -#define HCI_ISO_15693_ENABLE 0x01U -#define HCI_ISO_15693_INFO_SEQ 0x02U - -#define NXP_ISO15693_CMD 0x20U - - -/* -******************** Enumeration and Structure Definition ********************** -*/ - -typedef enum phHciNfc_ISO15693_Seq{ - ISO15693_INVENTORY, - ISO15693_AFI, - ISO15693_END_SEQUENCE, - ISO15693_INVALID_SEQ -} phHciNfc_ISO15693_Seq_t; - -typedef struct phHciNfc_ISO15693_Info{ - phHciNfc_ISO15693_Seq_t current_seq; - phHciNfc_ISO15693_Seq_t next_seq; - phHciNfc_Pipe_Info_t *ps_15693_pipe_info; - uint8_t pipe_id; - uint8_t multiple_tgts_found; - phHal_sRemoteDevInformation_t iso15693_info; - uint8_t enable_iso_15693_gate; -}phHciNfc_ISO15693_Info_t; - - -/* -*********************** Function Prototype Declaration ************************* -*/ - -/*! -* \brief Allocates the resources of ISO15693 management gate. -* -* This function Allocates the resources of the ISO15693 management -* gate Information Structure. -* -*/ -extern -NFCSTATUS -phHciNfc_ISO15693_Init_Resources( - phHciNfc_sContext_t *psHciContext - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_ISO15693_Get_PipeID function gives the pipe id of the ISO15693 -* gate -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_ISO15693_Get_PipeID( - phHciNfc_sContext_t *psHciContext, - uint8_t *ppipe_id - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_ISO15693_Update_PipeInfo function updates the pipe_id of the ISO15693 -* gate management Structure. -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pipeID pipeID of the ISO15693 gate -* \param[in] pPipeInfo Update the pipe Information of the ISO15693 -* gate -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ - -extern -NFCSTATUS -phHciNfc_ISO15693_Update_PipeInfo( - phHciNfc_sContext_t *psHciContext, - uint8_t pipeID, - phHciNfc_Pipe_Info_t *pPipeInfo - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_ISO15693_Update_Info function stores the data sent by the -* upper layer. -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] infotype To enable the ISO 15693 gate -* \param[in] iso_15693_info ISO 15693 gate info -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_ISO15693_Update_Info( - phHciNfc_sContext_t *psHciContext, - uint8_t infotype, - void *iso_15693_info - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_ISO15693_Sequence function executes the sequence of operations, to -* get the NXP_ISO15693_INVENTORY, NXP_ISO15693_AFI. -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_ISO15693_Info_Sequence ( - void *psHciHandle, - void *pHwRef - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_Send_ISO15693_Command function executes the command sent by the -* upper layer, depending on the commands defined. -* -* \param[in] psContext psContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* \param[in] pipe_id pipeID of the ISO 15693 gate -* \param[in] cmd command that needs to be sent to the device -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_Send_ISO15693_Command( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - uint8_t pipe_id, - uint8_t cmd - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_ISO15693_Set_AFI function updates the AFI value -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pipeID pipeID of the ISO 15693 gate -* \param[in] pPipeInfo Update the pipe Information of the ISO -* 15693 gate -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_ISO15693_Set_AFI( - void *psContext, - void *pHwRef, - uint8_t afi_value - ); - -#endif /* #ifndef PHHCINFC_ISO15693_H */ - - diff --git a/libnfc-nxp/phHciNfc_Jewel.h b/libnfc-nxp/phHciNfc_Jewel.h deleted file mode 100644 index e184d27..0000000 --- a/libnfc-nxp/phHciNfc_Jewel.h +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! -* =========================================================================== * -* * -* * -* \file phHciNfc_Jewel.h * -* \brief HCI Jewel Management Routines. * -* * -* * -* Project: NFC-FRI-1.1 * -* * -* $Date: Mon Mar 29 17:34:50 2010 $ * -* $Author: ing04880 $ * -* $Revision: 1.3 $ * -* $Aliases: NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ * -* * -* =========================================================================== * -*/ - -#ifndef PHHCINFC_JEWEL_H -#define PHHCINFC_JEWEL_H - -/*@}*/ - - -/** -* \name HCI -* -* File: \ref phHciNfc_Jewel.h -* -*/ -/*@{*/ -#define PHHCINFC_JEWEL_FILEREVISION "$Revision: 1.3 $" /**< \ingroup grp_file_attributes */ -#define PHHCINFC_JEWEL_FILEALIASES "$Aliases: NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ -/*@}*/ - -/* -***************************** Header File Inclusion **************************** -*/ - -#include - -/* -****************************** Macro Definitions ******************************* -*/ - -/* Commands exposed to the upper layer */ - -/* Enable the Jewel */ -#define HCI_JEWEL_ENABLE 0x01U -#define HCI_JEWEL_INFO_SEQ 0x02U - -/* Jewel read write commands */ -#define NXP_JEWEL_RAW 0x23U - -/* -******************** Enumeration and Structure Definition ********************** -*/ -typedef enum phHciNfc_Jewel_Seq{ - JEWEL_READID_SEQUENCE, - JEWEL_END_SEQUENCE, - JEWEL_INVALID_SEQ -} phHciNfc_Jewel_Seq_t; - -/* Information structure for the Jewel Gate */ -typedef struct phHciNfc_Jewel_Info{ - /* Current running Sequence of the Jewel Management */ - phHciNfc_Jewel_Seq_t current_seq; - /* Next running Sequence of the Jewel Management */ - phHciNfc_Jewel_Seq_t next_seq; - /* Pointer to the Jewel pipe information */ - phHciNfc_Pipe_Info_t *p_pipe_info; - uint8_t pipe_id; - /* Flag to say about the multiple targets */ - uint8_t multiple_tgts_found; - /* Jewel information */ - phHal_sRemoteDevInformation_t s_jewel_info; - /* Enable or disable reader gate */ - uint8_t enable_jewel_gate; - /* UICC re-activation status */ - uint8_t uicc_activation; -} phHciNfc_Jewel_Info_t; - -/* -*********************** Function Prototype Declaration ************************* -*/ - -/*! -* \brief Allocates the resources of Jewel management gate. -* -* This function Allocates the resources of the Jewel management -* gate Information Structure. -* -*/ -extern -NFCSTATUS -phHciNfc_Jewel_Init_Resources( - phHciNfc_sContext_t *psHciContext - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_Jewel_Get_PipeID function gives the pipe id of the Jewel -* gate -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_Jewel_Get_PipeID( - phHciNfc_sContext_t *psHciContext, - uint8_t *ppipe_id - ); - - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_Jewel_Update_PipeInfo function updates the pipe_id of the Jewel -* gate management Structure. -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pipeID pipeID of the Jewel gate -* \param[in] pPipeInfo Update the pipe Information of the reader -* A gate -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ - -extern -NFCSTATUS -phHciNfc_Jewel_Update_PipeInfo( - phHciNfc_sContext_t *psHciContext, - uint8_t pipeID, - phHciNfc_Pipe_Info_t *pPipeInfo - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_Jewel_Update_Info function updated the jewel gate info. -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] infotype To enable the jewel gate -* \param[in] jewel_info Jewel gate info -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -*/ -extern -NFCSTATUS -phHciNfc_Jewel_Update_Info( - phHciNfc_sContext_t *psHciContext, - uint8_t infotype, - void *jewel_info - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_Jewel_Info_Sequence function executes the sequence of operations, to -* get the ID. -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_Jewel_Info_Sequence ( - void *psHciHandle, - void *pHwRef - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_Send_Jewel_Command function executes the command sent by the -* upper layer, depending on the commands defined. -* -* \param[in] psContext psContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* \param[in] pipe_id pipeID of the jewel gate -* \param[in] cmd command that needs to be sent to the device -* \param[in] length information length sent by the caller -* \param[in] params information related to the command -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -*/ -extern -NFCSTATUS -phHciNfc_Send_Jewel_Command( - phHciNfc_sContext_t *psContext, - void *pHwRef, - uint8_t pipe_id, - uint8_t cmd - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_Jewel_GetRID function executes the command to read the ID -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -*/ -extern -NFCSTATUS -phHciNfc_Jewel_GetRID( - phHciNfc_sContext_t *psHciContext, - void *pHwRef); - -#endif /* #ifndef PHHCINFC_JEWEL_H */ - - diff --git a/libnfc-nxp/phHciNfc_LinkMgmt.h b/libnfc-nxp/phHciNfc_LinkMgmt.h deleted file mode 100644 index 54df378..0000000 --- a/libnfc-nxp/phHciNfc_LinkMgmt.h +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! -* =========================================================================== * -* * -* * -* \file phHciNfc_LinkMgmt.h * -* \brief HCI Header for the Link Management Gate. * -* * -* * -* Project: NFC-FRI-1.1 * -* * -* $Date: Tue Mar 30 09:32:13 2010 $ * -* $Author: ing04880 $ * -* $Revision: 1.5 $ * -* $Aliases: NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ -* * -* =========================================================================== * -*/ - - -#ifndef PHHCINFC_LINKMGMT_H -#define PHHCINFC_LINKMGMT_H - -/*@}*/ - - -/** - * \name HCI - * - * File: \ref phHciNfc_LinkMgmt.h - * - */ -/*@{*/ -#define PHHCINFC_LINK_MGMT_FILEREVISION "$Revision: 1.5 $" /**< \ingroup grp_file_attributes */ -#define PHHCINFC_LINK_MGMT_FILEALIASES "$Aliases: NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ -/*@}*/ - -/* -***************************** Header File Inclusion **************************** -*/ - -#include - -/* -****************************** Macro Definitions ******************************* -*/ - -/* -******************** Enumeration and Structure Definition ********************** -*/ - - - -/* -*********************** Function Prototype Declaration ************************* -*/ - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_LinkMgmt_Initialise function creates and the opens Link - * Management Gate - * - * \param[in] psHciContext psHciContext is the pointer to HCI Layer - * context Structure. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * - * \retval NFCSTATUS_PENDING Link Mgmt Gate Initialisation is pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ -extern -NFCSTATUS -phHciNfc_LinkMgmt_Initialise( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_LinkMgmt_Release function closes the opened pipes between - * the Host Controller Device and the NFC Device. - * - * \param[in] psHciContext psHciContext is the pointer to HCI Layer - * context Structure. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * - * \retval NFCSTATUS_PENDING Release of the Link Management gate - * resources are pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ -extern -NFCSTATUS -phHciNfc_LinkMgmt_Release( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_LinkMgmt_Open function opens Link - * Management Gate - * - * \param[in] psHciContext psHciContext is the pointer to HCI Layer - * context Structure. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * - * \retval NFCSTATUS_PENDING Link Mgmt Gate open is pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - -extern -NFCSTATUS -phHciNfc_LinkMgmt_Open( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - - -#endif - diff --git a/libnfc-nxp/phHciNfc_NfcIPMgmt.h b/libnfc-nxp/phHciNfc_NfcIPMgmt.h deleted file mode 100644 index 00e4b7b..0000000 --- a/libnfc-nxp/phHciNfc_NfcIPMgmt.h +++ /dev/null @@ -1,699 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! -* =========================================================================== * -* * -* * -* \file phHciNfc_NfcIPMgmt.h * -* \brief HCI NFCIP-1 Management Routines. * -* * -* * -* Project: NFC-FRI-1.1 * -* * -* $Date: Thu Jun 11 18:45:00 2009 $ * -* $Author: ing02260 $ * -* $Revision: 1.14 $ * -* $Aliases: NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK926_R28_2,NFC_FRI1.1_WK926_R28_3,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ * -* * -* =========================================================================== * -*/ - -#ifndef PHHCINFC_NFCIPMGMT_H -#define PHHCINFC_NFCIPMGMT_H - -/*@}*/ - - -/** -* \name HCI -* -* File: \ref phHciNfc_NfcIPMgmt.h -* -*/ -/*@{*/ -#define PHHCINFC_NFCIP1MGMT_FILEREVISION "$Revision: 1.14 $" /**< \ingroup grp_file_attributes */ -#define PHHCINFC_NFCIP1MGMT_FILEALIASES "$Aliases: NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK926_R28_2,NFC_FRI1.1_WK926_R28_3,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ -/*@}*/ - -/* -***************************** Header File Inclusion **************************** -*/ - -#include - -/* -****************************** Macro Definitions ******************************* -*/ - -/* Commands exposed to the upper layer */ - - -/* -******************** Enumeration and Structure Definition ********************** -*/ -/* LENGTH definition */ -#define NFCIP_ATR_MAX_LENGTH PHHAL_MAX_ATR_LENGTH -#define NFCIP_NFCID_LENGTH PHHAL_MAX_UID_LENGTH -#define NFCIP_MAX_DEP_REQ_HDR_LEN 0x05 - -typedef enum phHciNfc_eNfcIPType{ - NFCIP_INVALID = 0x00U, - NFCIP_INITIATOR, - NFCIP_TARGET -}phHciNfc_eNfcIPType_t; - -typedef enum phHciNfc_NfcIP_Seq{ - NFCIP_INVALID_SEQUENCE = 0x00U, - NFCIP_ATR_INFO, - NFCIP_STATUS, - NFCIP_NFCID3I, - NFCIP_NFCID3T, - NFCIP_PARAM, - NFCIP_END_SEQUENCE -} phHciNfc_NfcIP_Seq_t; - -typedef enum phHciNfc_eP2PSpeed{ - NFCIP_SPEED_106 = 0x00U, - NFCIP_SPEED_212, - NFCIP_SPEED_424, - NFCIP_SPEED_848, - NFCIP_SPEED_1696, - NFCIP_SPEED_3392, - NFCIP_SPEED_6784, - NFCIP_SPEED_RFU -}phHciNfc_eP2PSpeed_t; - -typedef enum phHciNfc_eNfcIPMode{ - NFCIP_MODE_PAS_106 = 0x01U, - NFCIP_MODE_PAS_212 = 0x02U, - NFCIP_MODE_PAS_424 = 0x04U, - NFCIP_MODE_ACT_106 = 0x08U, - NFCIP_MODE_ACT_212 = 0x10U, - NFCIP_MODE_ACT_424 = 0x20U, - NFCIP_MODE_ALL = 0x3FU -}phHciNfc_eNfcIPMode_t; - -typedef struct phHciNfc_NfcIP_Info -{ - phHciNfc_NfcIP_Seq_t current_seq; - phHciNfc_NfcIP_Seq_t next_seq; - phHciNfc_eNfcIPType_t nfcip_type; - phHciNfc_Pipe_Info_t *p_init_pipe_info; - phHciNfc_Pipe_Info_t *p_tgt_pipe_info; - phHal_sRemoteDevInformation_t rem_nfcip_tgt_info; - /* ATR_RES = General bytes length, Max length = 48 bytes for - host = target */ - uint8_t atr_res_info[NFCIP_ATR_MAX_LENGTH]; - uint8_t atr_res_length; - /* ATR_REQ = General bytes length, Max length = 48 bytes for - host = initiator */ - uint8_t atr_req_info[NFCIP_ATR_MAX_LENGTH]; - uint8_t atr_req_length; - /* Contains the current status of the NFCIP-1 link - when communication has been set. - 0x00 -> data is expected from the host - 0x01 -> data is expected from the RF side */ - uint8_t linkstatus; - /* Contains the random NFCID3I conveyed with the ATR_REQ. - always 10 bytes length */ - uint8_t nfcid3i_length; - uint8_t nfcid3i[NFCIP_NFCID_LENGTH]; - /* Contains the random NFCID3T conveyed with the ATR_RES. - always 10 bytes length */ - uint8_t nfcid3t_length; - uint8_t nfcid3t[NFCIP_NFCID_LENGTH]; - /* Contains the current parameters of the NFCIP-1 link when - communication has been set. - - bits 0 to 2: data rate target to initiator - - bits 3 to 5: data rate initiator to target - 0 -> Divisor equal to 1 - 1 -> Divisor equal to 2 - 2 -> Divisor equal to 4 - 3 -> Divisor equal to 8 - 4 -> Divisor equal to 16 - 5 -> Divisor equal to 32 - 6 -> Divisor equal to 64 - 7 -> RFU - - bits 6 to 7: maximum frame length - 0 -> 64 bytes - 1 -> 128 bytes - 2 -> 192 bytes - 3 -> 256 bytes */ - phHciNfc_eP2PSpeed_t initiator_speed; - phHciNfc_eP2PSpeed_t target_speed; - uint16_t max_frame_len; - /* Supported modes */ - uint8_t nfcip_mode; - uint8_t psl1; - uint8_t psl2; - uint8_t nad; - uint8_t did; - uint8_t options; - uint8_t activation_mode; -}phHciNfc_NfcIP_Info_t; - - -/* -*********************** Function Prototype Declaration ************************* -*/ -/*! -* \brief Allocates the resources of NFCIP-1 initiator management gate. -* -* This function Allocates the resources of the NFCIP-1 initiator management -* gate Information Structure. -* -*/ -extern -NFCSTATUS -phHciNfc_Initiator_Init_Resources( - phHciNfc_sContext_t *psHciContext - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_Initiator_Get_PipeID function gives the pipe id of the NFCIP-1 -* initiator gate -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_Initiator_Get_PipeID( - phHciNfc_sContext_t *psHciContext, - uint8_t *ppipe_id - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_Initiator_Update_PipeInfo function updates the pipe_id of the NFCIP-1 -* initiator gate management Structure. -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pipeID pipeID of the NFCIP-1 initiator gate -* \param[in] pPipeInfo Update the pipe Information of the NFCIP-1 -* initiator gate -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ - -extern -NFCSTATUS -phHciNfc_Initiator_Update_PipeInfo( - phHciNfc_sContext_t *psHciContext, - uint8_t pipeID, - phHciNfc_Pipe_Info_t *pPipeInfo - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_Send_Initiator_Command function executes the command sent by the -* upper layer, depending on the commands defined. -* -* \param[in] psContext psContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_NfcIP_Presence_Check( - phHciNfc_sContext_t *psContext, - void *pHwRef - ); - -/*! -* \brief Allocates the resources of NFCIP-1 target management gate. -* -* This function Allocates the resources of the NFCIP-1 target management -* gate Information Structure. -* -*/ -extern -NFCSTATUS -phHciNfc_Target_Init_Resources( - phHciNfc_sContext_t *psHciContext - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_Target_Get_PipeID function gives the pipe id of the NFCIP-1 -* target gate -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_Target_Get_PipeID( - phHciNfc_sContext_t *psHciContext, - uint8_t *ppipe_id - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_Target_Update_PipeInfo function updates the pipe_id of the NFCIP-1 -* target gate management Structure. -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pipeID pipeID of the NFCIP-1 target gate -* \param[in] pPipeInfo Update the pipe Information of the NFCIP-1 -* target gate -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ - -extern -NFCSTATUS -phHciNfc_Target_Update_PipeInfo( - phHciNfc_sContext_t *psHciContext, - uint8_t pipeID, - phHciNfc_Pipe_Info_t *pPipeInfo - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_NfcIP_Info_Sequence function executes the sequence of operations, to -* get ATR_RES, NFCID3I, NFCID3T, PARAMS etc. -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* \param[in] notify_reqd if TRUE continue till END_SEQUENCE, else -* stop the sequence -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_NfcIP_Info_Sequence ( - phHciNfc_sContext_t *psHciContext, - void *pHwRef -#ifdef NOTIFY_REQD - , - uint8_t notify_reqd -#endif /* #ifdef NOTIFY_REQD */ - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_NfcIP_SetMode function sets the value for NFCIP-1 modes -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* \param[in] nfciptype Specifies initiator or target -* \param[in] nfcip_mode nfcip_mode is the supported mode -* information -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_NfcIP_SetMode( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - phHciNfc_eNfcIPType_t nfciptype, - uint8_t nfcip_mode - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_NfcIP_SetNAD function sets the NAD value -* -* \param[in] psHciContext pContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* \param[in] nfciptype Specifies initiator or target -* \param[in] nad Node address, this will be used as -* logical address of the initiator (b4 to b7) -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_NfcIP_SetNAD( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - phHciNfc_eNfcIPType_t nfciptype, - uint8_t nad - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_NfcIP_SetDID function sets the DID value for the initiator -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* \param[in] did Device ID -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_NfcIP_SetDID( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - uint8_t did - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_NfcIP_SetOptions function sets the different options depending on -* the host type (initiator or target) like PSL, NAD and DID -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* \param[in] nfciptype Specifies initiator or target -* \param[in] nfcip_options specifies enabled options PSL, NAD and DID -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_NfcIP_SetOptions( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - phHciNfc_eNfcIPType_t nfciptype, - uint8_t nfcip_options - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_NfcIP_SetATRInfo function sets the general byte information -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* \param[in] nfciptype Specifies initiator or target -* \param[in] atr_info contains the general bytes of the ATR_REQ -* (initiator) or ATR_RES (target) (max size = -* 48 bytes) -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_NfcIP_SetATRInfo( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - phHciNfc_eNfcIPType_t nfciptype, - phHal_sNfcIPCfg_t *atr_info - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_NfcIP_SetPSL1 function sets the BRS byte of PSL_REQ -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* \param[in] psl1 specifies the BRS byte of PSL_REQ -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_NfcIP_SetPSL1( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - uint8_t psl1 - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_NfcIP_SetPSL2 function sets the BRS byte of PSL_REQ -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* \param[in] psl2 specifies the FSL byte of PSL_REQ -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_NfcIP_SetPSL2( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - uint8_t psl2 - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_NfcIP_GetStatus function receives the present status of the -* NFCIP-1 link, when communication has been set. -* If 0x00 is the status, then it means data is expected from the host -* If 0x01 is the status, then it means data is expected from the RF side -* Other status values are error -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* \param[in] nfciptype Specifies initiator or target -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_NfcIP_GetStatus( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - phHciNfc_eNfcIPType_t nfciptype - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_NfcIP_GetStatus function receives the current parameters of the -* NFCIP-1 link, when communication has been set. -* - bits 0 to 2: data rate target to initiator -* - bits 3 to 5: data rate initiator to target -* 0 -> Divisor equal to 1 -* 1 -> Divisor equal to 2 -* 2 -> Divisor equal to 4 -* 3 -> Divisor equal to 8 -* 4 -> Divisor equal to 16 -* 5 -> Divisor equal to 32 -* 6 -> Divisor equal to 64 -* 7 -> RFU -* - bits 6 to 7: maximum frame length -* 0 -> 64 bytes -* 1 -> 128 bytes -* 2 -> 192 bytes -* 3 -> 256 bytes -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* \param[in] nfciptype Specifies initiator or target -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_NfcIP_GetParam( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - phHciNfc_eNfcIPType_t nfciptype - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_NfcIP_Send_Data function sends data using the SEND_DATA event -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* \param[in] sData Data to be sent to the lower layer -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_NfcIP_Send_Data ( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - phHciNfc_XchgInfo_t *sData - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_Initiator_Cont_Activate function to activate the NFCIP initiator -* -* \param[in] pContext pContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_Initiator_Cont_Activate ( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_NfcIP_GetATRInfo function is to get ATR information -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* \param[in] nfciptype Specifies initiator or target -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_NfcIP_GetATRInfo ( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - phHciNfc_eNfcIPType_t nfciptype - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_NfcIP_SetMergeSak function is to indicate, if the NFCIP-1 -* target feature must be merged with Type A RF card feature in order to -* present only one type A target (set of the related bit in SAK to -* reflect the ISO18092 compliancy). -* 0x00 -> disabled -* 0x01 -> enabled -* Others values are RFU : error code returned as NFCSTATUS_INVALID_PARAMETER -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* \param[in] sak_value Specifies initiator or target -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_NfcIP_SetMergeSak( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - uint8_t sak_value - ); -#endif /* #ifndef PHHCINFC_NFCIPMGMT_H */ - - diff --git a/libnfc-nxp/phHciNfc_Pipe.h b/libnfc-nxp/phHciNfc_Pipe.h deleted file mode 100644 index e011824..0000000 --- a/libnfc-nxp/phHciNfc_Pipe.h +++ /dev/null @@ -1,273 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! -* =========================================================================== * -* * -* * -* \file phHciNfc_Pipe.h * -* \brief HCI Header for the Pipe Management. * -* * -* * -* Project: NFC-FRI-1.1 * -* * -* $Date: Fri Aug 14 17:01:27 2009 $ * -* $Author: ing04880 $ * -* $Revision: 1.17 $ * -* $Aliases: NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ -* * -* =========================================================================== * -*/ - -/*@{*/ - -#ifndef PHHCINFC_PIPE_H -#define PHHCINFC_PIPE_H - -/*@}*/ - - -/** - * \name HCI - * - * File: \ref phHciNfc_Pipe.h - * - */ -/*@{*/ -#define PHHCINFC_PIPE_FILEREVISION "$Revision: 1.17 $" /**< \ingroup grp_file_attributes */ -#define PHHCINFC_PIPE_FILEALIASES "$Aliases: NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ -/*@}*/ - -/* -***************************** Header File Inclusion **************************** -*/ - -#include -#include - -/* -****************************** Macro Definitions ******************************* -*/ - -#define PIPEINFO_SIZE 0x04U -#define PIPEID_LEN 0x01U - -#define RESPONSE_GATEID_OFFSET 0x03U -#define RESPONSE_PIPEID_OFFSET 0x04U - - -#define PIPETYPE_STATIC_LINK 0x00U -#define PIPETYPE_STATIC_ADMIN 0x01U -#define PIPETYPE_DYNAMIC 0x02U - -/* -******************** Enumeration and Structure Definition ********************** -*/ - -typedef enum phHciNfc_PipeMgmt_Seq{ - /* Pipe for Identitiy Management */ - PIPE_IDMGMT_CREATE = 0x00U, - /* Pipe for Configuring PN544 Nfc Device */ - PIPE_PN544MGMT_CREATE, - /* Pipe for Configuring Polling Wheel */ - PIPE_POLLINGLOOP_CREATE, - /* Pipes for Configuring the RF Readers */ - PIPE_READER_A_CREATE, - PIPE_READER_B_CREATE, - PIPE_READER_F_CREATE, - PIPE_READER_JWL_CREATE, - PIPE_READER_ISO15693_CREATE, - /* Pipes for configuring the Card Emulation */ - PIPE_CARD_A_CREATE, - PIPE_CARD_A_DELETE, - PIPE_CARD_B_CREATE, - PIPE_CARD_B_DELETE, - PIPE_CARD_F_CREATE, - PIPE_CARD_F_DELETE, - /* Pipes for Peer to Peer Communication */ - PIPE_NFC_INITIATOR_CREATE, - PIPE_NFC_TARGET_CREATE, - /* Secure Element Commands */ - PIPE_WI_CREATE, - PIPE_SWP_CREATE, - /* Connectiviy Gate Pipe */ - PIPE_CONNECTIVITY, - - /* Clearing all the created Pipes */ - PIPE_DELETE_ALL, - PIPE_MGMT_END -} phHciNfc_PipeMgmt_Seq_t; - -/** \defgroup grp_hci_nfc HCI Component - * - * - */ - -/* -*********************** Function Prototype Declaration ************************* -*/ - -/*! - * \brief Creates the Pipes of all the Supported Gates . - * - * This function Creates the pipes for all the supported gates - */ - -extern -NFCSTATUS -phHciNfc_Create_All_Pipes( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - phHciNfc_PipeMgmt_Seq_t *p_pipe_seq - ); - -/*! - * \brief Deletes the Pipes of all the Supported Gates . - * - * This function Deletes the pipes for all the supported gates - */ -extern -NFCSTATUS -phHciNfc_Delete_All_Pipes( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - phHciNfc_PipeMgmt_Seq_t pipeSeq - ); - -/*! - * \brief Updates the Information of Pipes of all the Supported Gates . - * - * This function Updates the pipe information for all the supported gates - */ - -extern -NFCSTATUS -phHciNfc_Update_PipeInfo( - phHciNfc_sContext_t *psHciContext, - phHciNfc_PipeMgmt_Seq_t *pPipeSeq, - uint8_t pipe_id, - phHciNfc_Pipe_Info_t *pPipeInfo - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Open_Pipe function opens - * . - * - * \param[in] psContext psContext is pointer to the context - * Structure of the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] pPipeHandle pPipeHandle is the handle used to open - * the Static or Dynamically Created Pipe. - * - * \retval NFCSTATUS_PENDING Pipe Open is pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the lower layers - * - */ - - extern - NFCSTATUS - phHciNfc_Open_Pipe ( - phHciNfc_sContext_t *psContext, - void *pHwRef, - phHciNfc_Pipe_Info_t *pPipeHandle - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Close_Pipe function closes - * . - * - * \param[in] psContext psContext is pointer to the context - * Structure of the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] pPipeHandle pPipeHandle is the handle used to closes - * the Static or Dynamically Created Pipe. - * - * \retval NFCSTATUS_PENDING Pipe close is pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the lower layers - * - */ - - extern - NFCSTATUS - phHciNfc_Close_Pipe ( - phHciNfc_sContext_t *psContext, - void *pHwRef, - phHciNfc_Pipe_Info_t *pPipeHandle - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Delete_Pipe function deletes the dynamically created pipe - * using the supplied pipe handle. - * - * \param[in] psContext psContext is pointer to the context - * Structure of the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] pPipeHandle pPipeHandle is the handle used to delete - * the Dynamically Created Pipe. - * - * \retval NFCSTATUS_PENDING Pipe Deletion is pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * - */ - -extern -NFCSTATUS -phHciNfc_Delete_Pipe( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - phHciNfc_Pipe_Info_t *pPipeHandle - ); - -/*! - * \brief Creates and Update the Pipes during the Session - * - * This function Creates and Update the Pipes of all the Supported Gates - * for the already initialised session. - */ - -extern -NFCSTATUS -phHciNfc_Update_Pipe( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - phHciNfc_PipeMgmt_Seq_t *p_pipe_seq - ); - - -extern -NFCSTATUS -phHciNfc_CE_Pipes_OP( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - phHciNfc_PipeMgmt_Seq_t *p_pipe_seq - ); - -#endif - diff --git a/libnfc-nxp/phHciNfc_PollingLoop.h b/libnfc-nxp/phHciNfc_PollingLoop.h deleted file mode 100644 index 6e251e8..0000000 --- a/libnfc-nxp/phHciNfc_PollingLoop.h +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! -* =========================================================================== * -* * -* * -* \file phHciNfc_PollingLoop.h * -* \brief HCI Header for the Polling loop Management. * -* * -* * -* Project: NFC-FRI-1.1 * -* * -* $Date: Mon Mar 29 17:34:49 2010 $ * -* $Author: ing04880 $ * -* $Revision: 1.6 $ * -* $Aliases: NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ * -* * -* =========================================================================== * -*/ - - -#ifndef PHHCINFC_POLLINGLOOP_H -#define PHHCINFC_POLLINGLOOP_H - -/*@}*/ - - -/** - * \name HCI - * - * File: \ref phHciNfc_PollingLoop.h - * - */ -/*@{*/ -#define PHHCINFC_POLLINGLOOP_FILEREVISION "$Revision: 1.6 $" /**< \ingroup grp_file_attributes */ -#define PHHCINFC_POLLINGLOOP_FILEALIASES "$Aliases: NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ -/*@}*/ - -/* -***************************** Header File Inclusion **************************** -*/ - -#include - -/* -****************************** Macro Definitions ******************************* -*/ -#define PL_DURATION 0x00U -#define PL_RD_PHASES 0x01U -#define PL_DISABLE_TARGET 0x02U - - - -#define PL_RD_PHASES_DISABLE 0x80U - -/* -******************** Enumeration and Structure Definition ********************** -*/ - -/** \defgroup grp_hci_nfc HCI Component - * - * - */ - - -/* -*********************** Function Prototype Declaration ************************* -*/ - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_PollLoop_Initialise function Initialises the polling loop and opens the - * polling loop pipe - * - * \param[in] psHciContext psHciContext is the pointer to HCI Layer - * context Structure. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * - * \retval NFCSTATUS_PENDING Polling loop gate Initialisation is pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - -extern -NFCSTATUS -phHciNfc_PollLoop_Initialise( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_PollLoop_Release function closes the polling loop gate pipe - * between the Host Controller Device and the NFC Device. - * - * \param[in] psHciContext psHciContext is the pointer to HCI Layer - * context Structure. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * - * \retval NFCSTATUS_PENDING Release of the Polling loop gate resources are - * pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - -extern -NFCSTATUS -phHciNfc_PollLoop_Release( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_PollLoop_Update_PipeInfo function updates the pipe_id of the polling - * loop gate Managment Struction. - * - * \param[in] psHciContext psHciContext is the pointer to HCI Layer - * context Structure. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link - * \param[in] cfg_type Poll configuration type - * - * \param[in] pcfg_info Poll configuration info. - * - * \retval NFCSTATUS_SUCCESS Polling loop gate Response received Successfully. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * - */ -extern -NFCSTATUS -phHciNfc_PollLoop_Cfg ( - void *psHciHandle, - void *pHwRef, - uint8_t cfg_type, - void *pcfg_info - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_PollLoop_Update_PipeInfo function updates the pipe_id of the polling - * loop gate management structure. This function is used by the pipe management to - * update the pipe id - * - * \param[in] psHciContext psHciContext is the pointer to HCI Layer - * context Structure. - * \param[in] pipeID pipeID of the polling loop gate - * \param[in] pPipeInfo Update the pipe Information of the polling loop - * gate. - * - * \retval NFCSTATUS_SUCCESS Polling loop gate Response received Successfully. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * - */ - -extern -NFCSTATUS -phHciNfc_PollLoop_Update_PipeInfo( - phHciNfc_sContext_t *psHciContext, - uint8_t pipeID, - phHciNfc_Pipe_Info_t *pPipeInfo - ); - - -/*! - * \brief Allocates the resources of Polling loop Managment Gate. - * - * This function Allocates the resources of the Polling loop management - * gate Information Structure. - * - */ -extern -NFCSTATUS -phHciNfc_PollLoop_Init_Resources( - phHciNfc_sContext_t *psHciContext - ); - - -/*! - * \brief Get the pipe_id of Polling loop managment Gate. - * - * This function Get the pipe_id of Polling loop managment Gate. - * - */ - -extern -NFCSTATUS -phHciNfc_PollLoop_Get_PipeID( - phHciNfc_sContext_t *psHciContext, - uint8_t *ppipe_id - ); - -#endif /* PHHCINFC_POLLINGLOOP_H */ - - diff --git a/libnfc-nxp/phHciNfc_RFReader.h b/libnfc-nxp/phHciNfc_RFReader.h deleted file mode 100644 index 751fbbb..0000000 --- a/libnfc-nxp/phHciNfc_RFReader.h +++ /dev/null @@ -1,558 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! -* =========================================================================== * -* * -* * -* \file phHciNfc_RFReader.h * -* \brief HCI Header for the RF Reader Management Gate. * -* * -* * -* Project: NFC-FRI-1.1 * -* * -* $Date: Fri Aug 14 17:01:28 2009 $ * -* $Author: ing04880 $ * -* $Revision: 1.17 $ * -* $Aliases: NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ * -* * -* =========================================================================== * -*/ - - -#ifndef PHHCINFC_RFREADER_H -#define PHHCINFC_RFREADER_H - -/*@}*/ - - -/** - * \name HCI - * - * File: \ref phHciNfc_RFReader.h - * - */ -/*@{*/ -#define PHHCINFC_RF_READER_FILEREVISION "$Revision: 1.17 $" /**< \ingroup grp_file_attributes */ -#define PHHCINFC_RF_READER_FILEALIASES "$Aliases: NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ -/*@}*/ - -/* -***************************** Header File Inclusion **************************** -*/ - -#include - -/* -****************************** Macro Definitions ******************************* -*/ -/* Events Requested by the Reader Application Gates */ -#define EVT_READER_REQUESTED 0x10U -#define EVT_END_OPERATION 0x11U - -/* Events Triggered by the Reader RF Gates */ -#define EVT_TARGET_DISCOVERED 0x10U - -/* Commands from ETSI HCI Specification */ -#define WR_XCHGDATA 0x10U - -/* NXP Additional Commands apart from ETSI HCI Specification */ -/* Command to Check the presence of the card */ -#define NXP_WR_PRESCHECK 0x30U - -/* Command to Activate the next card present in the field */ -#define NXP_WR_ACTIVATE_NEXT 0x31U - -/* Command to Activate a card with its UID */ -#define NXP_WR_ACTIVATE_ID 0x32U - -/* Command to Dispatch the card to UICC */ -#define NXP_WR_DISPATCH_TO_UICC 0x33U - -/* NXP Additional Events apart from ETSI HCI Specification */ -/* Event to Release the Target and Restart The Wheel */ -#define NXP_EVT_RELEASE_TARGET 0x35U - - -/* Type Macro to Update the RF Reader Information */ - -#define HCI_RDR_ENABLE_TYPE 0x01U - -#define UICC_CARD_ACTIVATION_SUCCESS 0x00U -#define UICC_CARD_ACTIVATION_ERROR 0x01U -#define UICC_RDR_NOT_INTERESTED 0x02U - - -/* -******************** Enumeration and Structure Definition ********************** -*/ - - - -/* -*********************** Function Prototype Declaration ************************* -*/ - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_ReaderMgmt_Initialise function creates and the opens RF Reader - * Management Gate - * - * \param[in] psHciContext psHciContext is the pointer to HCI Layer - * context Structure. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * - * \retval NFCSTATUS_PENDING Reader RF Mgmt Gate Initialisation is pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ -extern -NFCSTATUS -phHciNfc_ReaderMgmt_Initialise( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_ReaderMgmt_Release function closes the opened RF Reader pipes - * between the Host Controller Device and the NFC Device. - * - * \param[in] psHciContext psHciContext is the pointer to HCI Layer - * context Structure. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * - * \retval NFCSTATUS_PENDING Release of the Reader RF Management gate - * resources are pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ -extern -NFCSTATUS -phHciNfc_ReaderMgmt_Release( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_ReaderMgmt_Update_Sequence function Resets/Updates the sequence - * to the Specified RF Reader Sequence . - * - * \param[in] psHciContext psHciContext is the pointer to HCI Layer - * context Structure. - * \param[in] reader_seq reader_seq is the Type of sequence update - * required to reset . - * - * \retval NFCSTATUS_SUCCESS Updates/Resets the Sequence of the Reader - * RF Management gate Successsfully. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval - * NFCSTATUS_INVALID_HCI_INFORMATION The RF Reader Management information is - * invalid. - * - */ - -extern -NFCSTATUS -phHciNfc_ReaderMgmt_Update_Sequence( - phHciNfc_sContext_t *psHciContext, - phHciNfc_eSeqType_t reader_seq - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_ReaderMgmt_Enable_Discovery function Enables the RF Reader - * Gates to discover the corresponding PICC Tags . - * - * \param[in] psHciContext psHciContext is the pointer to HCI Layer - * context Structure. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * - * \retval NFCSTATUS_PENDING Enable of the Reader RF Management gate - * Discovery is pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - -extern -NFCSTATUS -phHciNfc_ReaderMgmt_Enable_Discovery( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_ReaderMgmt_Discovery function Enables/Disables/Restart/Continue - * the RF Reader Gates to discover the corresponding PICC Tags . - * - * \param[in] psHciContext psHciContext is the pointer to HCI Layer - * context Structure. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * - * \retval NFCSTATUS_PENDING Enable of the Reader RF Management gate - * Discovery is pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_ReaderMgmt_Disable_Discovery function Disables the RF Reader - * Gates discovery . - * - * \param[in] psHciContext psHciContext is the pointer to HCI Layer - * context Structure. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * - * \retval NFCSTATUS_PENDING Disable of the Reader RF Management gate - * Discovery is pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - -extern -NFCSTATUS -phHciNfc_ReaderMgmt_Disable_Discovery( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_ReaderMgmt_Info_Sequence function Gets the information - * of the Tag discovered . - * - * \param[in] psHciContext psHciContext is the pointer to HCI Layer - * context Structure. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * - * \retval NFCSTATUS_PENDING Reception the information of the discoverd - * tag is ongoing. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - -extern -NFCSTATUS -phHciNfc_ReaderMgmt_Info_Sequence( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_ReaderMgmt_Select function connects the - * the selected tag by performing certain operation. - * - * \param[in] psHciContext psHciContext is the pointer to HCI Layer - * context Structure. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] target_type target_type is the type of the - * Target Device to be connected . - * - * \retval NFCSTATUS_PENDING The selected tag initialisation for - * transaction ongoing. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - -extern -NFCSTATUS -phHciNfc_ReaderMgmt_Select( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - phHal_eRemDevType_t target_type - ); - - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_ReaderMgmt_Reactivate function reactivates the - * the tag by performing reactivate operation. - * - * \param[in] psHciContext psHciContext is the pointer to HCI Layer - * context Structure. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] target_type target_type is the type of the - * Target Device to be reactivated . - * - * \retval NFCSTATUS_PENDING The tag reactivation ongoing. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - - -extern -NFCSTATUS -phHciNfc_ReaderMgmt_Reactivate( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - phHal_eRemDevType_t target_type - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_ReaderMgmt_Presence_Check function performs presence on ISO -* cards. -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link . -* -* \retval NFCSTATUS_PENDING The presence check for tag is ongoing. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* \retval Other errors Errors related to the other layers -* -*/ - -extern -NFCSTATUS -phHciNfc_ReaderMgmt_Presence_Check( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_ReaderMgmt_Activate_Next function activates and selects next -* tag or target present in the RF Field . -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link . -* -* \retval NFCSTATUS_PENDING The activation of the next tag is ongoing. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* \retval Other errors Errors related to the other layers -* -*/ - -extern -NFCSTATUS -phHciNfc_ReaderMgmt_Activate_Next( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_ReaderMgmt_UICC_Dispatch function de-activates the - * the selected tag by de-selecting the tag and dispatch the Card to UICC. - * - * \param[in] psHciContext psHciContext is the pointer to HCI Layer - * context Structure. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] target_type target_type is the type of the - * Target Device to be de-selected . - * \param[in] re_poll If True: Start re-polling of the target - * after the Target Device is de-activated - * or else - continue discovery with next - * technology. - * - * - * \retval NFCSTATUS_PENDING Dispatching the selected tag to UICC - * is ongoing. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - -extern -NFCSTATUS -phHciNfc_ReaderMgmt_UICC_Dispatch( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - phHal_eRemDevType_t target_type - ); - - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_ReaderMgmt_Deselect function de-activates the - * the selected tag by de-selecting the tag and restarting the discovery. - * - * \param[in] psHciContext psHciContext is the pointer to HCI Layer - * context Structure. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] target_type target_type is the type of the - * Target Device to be de-selected . - * - * \retval NFCSTATUS_PENDING Terminating the operations between selected - * tag is ongoing. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - -extern -NFCSTATUS -phHciNfc_ReaderMgmt_Deselect( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - phHal_eRemDevType_t target_type, - uint8_t re_poll - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_ReaderMgmt_Exchange_Data function exchanges the - * data to/from the selected tag . - * - * \param[in] psHciContext psHciContext is the pointer to HCI Layer - * context Structure. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] p_xchg_info The tag exchange info contains the command type, - * addr and data to be sent to the connected - * remote target device. - * - * \retval NFCSTATUS_PENDING Exchange of the data between the selected - * tag is ongoing. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - -extern -NFCSTATUS -phHciNfc_ReaderMgmt_Exchange_Data( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - phHciNfc_XchgInfo_t *p_xchg_info - ); - - - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Send_RFReader_Command function sends the HCI Reader Gate - * Specific Commands to the HCI Controller device. - * - * \param[in] psHciContext psHciContext is the context of - * the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] pipe_id The Reader pipe to which the - * command is being sent. - * \param[in] cmd The HCI Reader Gate specific command - * sent to a Reader pipe . - * - * - * \retval NFCSTATUS_PENDING ETSI HCI RF Reader gate Command - * to be sent is pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - -extern -NFCSTATUS - phHciNfc_Send_RFReader_Command ( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - uint8_t pipe_id, - uint8_t cmd - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Send_RFReader_Event function sends the HCI Reader Gate - * Specific Events to the HCI Controller device. - * - * \param[in] psHciContext psHciContext is the context of - * the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] pipe_id The Reader pipe to which the - * command is being sent. - * \param[in] event The HCI Reader Gate specific event - * sent to a Reader pipe . - * - * - * \retval NFCSTATUS_PENDING ETSI HCI RF Reader gate Event - * to be sent is pending. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Errors related to the other layers - * - */ - -extern -NFCSTATUS - phHciNfc_Send_RFReader_Event ( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - uint8_t pipe_id, - uint8_t event - ); - -#endif /* PHHCINFC_RFREADER_H */ - diff --git a/libnfc-nxp/phHciNfc_RFReaderA.h b/libnfc-nxp/phHciNfc_RFReaderA.h deleted file mode 100644 index 7743186..0000000 --- a/libnfc-nxp/phHciNfc_RFReaderA.h +++ /dev/null @@ -1,373 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! -* =========================================================================== * -* * -* * -* \file phHciNfc_RFReaderA.h * -* \brief HCI Reader A Management Routines. * -* * -* * -* Project: NFC-FRI-1.1 * -* * -* $Date: Fri Aug 14 17:01:27 2009 $ * -* $Author: ing04880 $ * -* $Revision: 1.17 $ * -* $Aliases: NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ * -* * -* =========================================================================== * -*/ - - -#ifndef PHHCINFC_RFREADERA_H -#define PHHCINFC_RFREADERA_H - -/*@}*/ - - -/** - * \name HCI - * - * File: \ref phHciNfc_ReaderA.h - * - */ -/*@{*/ -#define PHHCINFC_RFREADERA_FILEREVISION "$Revision: 1.17 $" /**< \ingroup grp_file_attributes */ -#define PHHCINFC_RFREADERA_FILEALIASES "$Aliases: NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ -/*@}*/ - -/* -***************************** Header File Inclusion **************************** -*/ - -#include - -/* -****************************** Macro Definitions ******************************* -*/ - -/* Commands exposed to the upper layer */ -#define NXP_WRA_CONTINUE_ACTIVATION 0x12U -#define NXP_MIFARE_RAW 0x20U -#define NXP_MIFARE_CMD 0x21U -#define DATA_RATE_MAX_DEFAULT_VALUE 0x00U - -/* Enable the reader A */ -#define HCI_READER_A_ENABLE 0x01U -#define HCI_READER_A_INFO_SEQ 0x02U - -#define RDR_A_TIMEOUT_MIN 0x00U -#define RDR_A_TIMEOUT_MAX 0x15U -/* -******************** Enumeration and Structure Definition ********************** -*/ -typedef enum phHciNfc_ReaderA_Seq{ - RDR_A_DATA_RATE_MAX, - RDR_A_UID, - RDR_A_SAK, - RDR_A_ATQA, - RDR_A_APP_DATA, - RDR_A_FWI_SFGT, - RDR_A_END_SEQUENCE, - RDR_A_INVALID_SEQ -} phHciNfc_ReaderA_Seq_t; - -/* Information structure for the polling loop Gate */ -typedef struct phHciNfc_ReaderA_Info{ - /* Current running Sequence of the reader A Management */ - phHciNfc_ReaderA_Seq_t current_seq; - /* Next running Sequence of the reader A Management */ - phHciNfc_ReaderA_Seq_t next_seq; - /* Pointer to the reader A pipe information */ - phHciNfc_Pipe_Info_t *p_pipe_info; - uint8_t pipe_id; - /* Flag to say about the multiple targets */ - uint8_t multiple_tgts_found; - /* Reader A information */ - phHal_sRemoteDevInformation_t reader_a_info; - /* Enable or disable reader gate */ - uint8_t enable_rdr_a_gate; - /* UICC re-activation status */ - uint8_t uicc_activation; -} phHciNfc_ReaderA_Info_t; - -/* -*********************** Function Prototype Declaration ************************* -*/ - -/*! - * \brief Allocates the resources of reader A management gate. - * - * This function Allocates the resources of the reader A management - * gate Information Structure. - * - */ -extern -NFCSTATUS -phHciNfc_ReaderA_Init_Resources( - phHciNfc_sContext_t *psHciContext - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_ReaderA_Get_PipeID function gives the pipe id of the reader A -* gate -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_ReaderA_Get_PipeID( - phHciNfc_sContext_t *psHciContext, - uint8_t *ppipe_id - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_ReaderA_Sequence function executes the sequence of operations, to -* get the UID, SAK, ATQA etc. -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_ReaderA_Info_Sequence ( - void *psHciHandle, - void *pHwRef - ); - - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_ReaderA_App_Data function is to get the application data information. -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_ReaderA_App_Data ( - void *psHciHandle, - void *pHwRef - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_ReaderA_Fwi_Sfgt function is to get the frame waiting time -* information. -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_ReaderA_Fwi_Sfgt ( - void *psHciHandle, - void *pHwRef - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_ReaderA_Update_PipeInfo function updates the pipe_id of the reader A -* gate management Structure. -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pipeID pipeID of the reader A gate -* \param[in] pPipeInfo Update the pipe Information of the reader -* A gate -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ - -extern -NFCSTATUS -phHciNfc_ReaderA_Update_PipeInfo( - phHciNfc_sContext_t *psHciContext, - uint8_t pipeID, - phHciNfc_Pipe_Info_t *pPipeInfo - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_Send_ReaderA_Command function executes the command sent by the -* upper layer, depending on the commands defined. -* -* \param[in] psContext psContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* \param[in] pipe_id pipeID of the reader A gate -* \param[in] cmd command that needs to be sent to the device -* \param[in] length information length sent by the caller -* \param[in] params information related to the command -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_Send_ReaderA_Command( - phHciNfc_sContext_t *psContext, - void *pHwRef, - uint8_t pipe_id, - uint8_t cmd - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_ReaderA_Auto_Activate function updates auto activate register -* -* \param[in] psContext psContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* \param[in] activate_enable to enable or disable auto activation -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_ReaderA_Auto_Activate( - void *psContext, - void *pHwRef, - uint8_t activate_enable - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_Send_ReaderA_Command function executes the command sent by the -* upper layer, depending on the commands defined. -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] infotype To enable the reader A gate -* \param[in] rdr_a_info reader A gate info -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_ReaderA_Update_Info( - phHciNfc_sContext_t *psHciContext, - uint8_t infotype, - void *rdr_a_info - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_ReaderA_Cont_Active function executes NXP_WRA_CONTINUE_ACTIVATION -* command to inform the CLF Controller after having received the event -* EVT_TARGET_DISCOVERED to continue activation in case activation has -* been stopped after successful SAK response. The response to this command, sent -* as soon as the activation is finished, indicates the result of the -* activation procedure -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* \param[in] pipeID pipeID of the reader A gate -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_ReaderA_Cont_Activate ( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_ReaderA_Set_DataRateMax function updates the data rate max value -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pipeID pipeID of the reader A gate -* \param[in] pPipeInfo Update the pipe Information of the reader -* A gate -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_ReaderA_Set_DataRateMax( - void *psContext, - void *pHwRef, - uint8_t data_rate_value - ); - -#endif /* #ifndef PHHCINFC_RFREADERA_H */ - diff --git a/libnfc-nxp/phHciNfc_RFReaderB.h b/libnfc-nxp/phHciNfc_RFReaderB.h deleted file mode 100644 index 4b97da8..0000000 --- a/libnfc-nxp/phHciNfc_RFReaderB.h +++ /dev/null @@ -1,262 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! -* =========================================================================== * -* * -* * -* \file phHciNfc_RFReaderB.h * -* \brief HCI Reader B Management Routines. * -* * -* * -* Project: NFC-FRI-1.1 * -* * -* $Date: Fri Aug 14 17:01:26 2009 $ * -* $Author: ing04880 $ * -* $Revision: 1.5 $ * -* $Aliases: NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ * -* * -* =========================================================================== * -*/ - -#ifndef PHHCINFC_RFREADERB_H -#define PHHCINFC_RFREADERB_H - -/*@}*/ - - -/** -* \name HCI -* -* File: \ref phHciNfc_ReaderB.h -* -*/ -/*@{*/ -#define PHHCINFC_RFREADERB_FILEREVISION "$Revision: 1.5 $" /**< \ingroup grp_file_attributes */ -#define PHHCINFC_RFREADERB_FILEALIASES "$Aliases: NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ -/*@}*/ - -/* -***************************** Header File Inclusion **************************** -*/ - -#include - -/* -****************************** Macro Definitions ******************************* -*/ - -/* Enable the reader B */ -#define HCI_READER_B_ENABLE 0x01U -#define HCI_READER_B_INFO_SEQ 0x02U - -/* -******************** Enumeration and Structure Definition ********************** -*/ -typedef enum phHciNfc_ReaderB_Seq{ - RDR_B_PUPI, - RDR_B_APP_DATA, - RDR_B_AFI, - RDR_B_HIGHER_LAYER_RESP, - RDR_B_HIGHER_LAYER_DATA, - RDR_B_END_SEQUENCE, - RDR_B_INVALID_SEQ -} phHciNfc_ReaderB_Seq_t; - -/* Information structure for the reader B Gate */ -typedef struct phHciNfc_ReaderB_Info{ - /* Current running Sequence of the reader B Management */ - phHciNfc_ReaderB_Seq_t current_seq; - /* Next running Sequence of the reader B Management */ - phHciNfc_ReaderB_Seq_t next_seq; - /* Pointer to the reader B pipe information */ - phHciNfc_Pipe_Info_t *p_pipe_info; - uint8_t pipe_id; - /* Flag to say about the multiple targets */ - uint8_t multiple_tgts_found; - /* Reader B information */ - phHal_sRemoteDevInformation_t reader_b_info; - /* Enable or disable reader gate */ - uint8_t enable_rdr_b_gate; - /* UICC re-activation status */ - uint8_t uicc_activation; -} phHciNfc_ReaderB_Info_t; - -/* -*********************** Function Prototype Declaration ************************* -*/ - -/*! -* \brief Allocates the resources of reader B management gate. -* -* This function Allocates the resources of the reader B management -* gate Information Structure. -* -*/ -extern -NFCSTATUS -phHciNfc_ReaderB_Init_Resources( - phHciNfc_sContext_t *psHciContext - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_ReaderB_Get_PipeID function gives the pipe id of the reader B -* gate -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_ReaderB_Get_PipeID( - phHciNfc_sContext_t *psHciContext, - uint8_t *ppipe_id - ); - - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_ReaderB_Update_PipeInfo function updates the pipe_id of the reader B -* gate management Structure. -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pipeID pipeID of the reader B gate -* \param[in] pPipeInfo Update the pipe Information of the reader -* A gate -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ - -extern -NFCSTATUS -phHciNfc_ReaderB_Update_PipeInfo( - phHciNfc_sContext_t *psHciContext, - uint8_t pipeID, - phHciNfc_Pipe_Info_t *pPipeInfo - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_ReaderB_Info_Sequence function executes the sequence of operations, to -* get the PUPI, AFI, APPLICATION_DATA etc. -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_ReaderB_Info_Sequence ( - void *psHciHandle, - void *pHwRef - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_ReaderB_Update_Info function updates the reader B information. -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* context Structure. -* \param[in] infotype To enable the reader B gate -* \param[in] rdr_b_info reader B gate info -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_ReaderB_Update_Info( - phHciNfc_sContext_t *psHciContext, - uint8_t infotype, - void *rdr_b_info - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_ReaderB_Set_LayerData function updates higher layer data -* registry -* -* \param[in] psContext psContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* \param[in] layer_data_info layer data information -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_ReaderB_Set_LayerData( - void *psContext, - void *pHwRef, - phNfc_sData_t *layer_data_info - ); - -/** -* \ingroup grp_hci_nfc -* -* The phHciNfc_ReaderB_Set_AFI function updates application family -* identifier registry -* -* \param[in] psContext psContext is the pointer to HCI Layer -* context Structure. -* \param[in] pHwRef pHwRef is the Information of -* the Device Interface Link -* \param[in] afi_value to afi value update -* -* \retval NFCSTATUS_SUCCESS Function execution is successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be interpreted properly. -* -*/ -extern -NFCSTATUS -phHciNfc_ReaderB_Set_AFI( - void *psContext, - void *pHwRef, - uint8_t afi_value - ); -#endif /* #ifndef PHHCINFC_RFREADERB_H */ - - diff --git a/libnfc-nxp/phHciNfc_SWP.h b/libnfc-nxp/phHciNfc_SWP.h deleted file mode 100644 index e397e36..0000000 --- a/libnfc-nxp/phHciNfc_SWP.h +++ /dev/null @@ -1,355 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! -* =========================================================================== * -* * -* * -* \file phHciNfc_SWP .h * -* \brief HCI wired interface gate Management Routines. * -* * -* * -* Project: NFC-FRI-1.1 * -* * -* $Date: Fri Aug 14 17:01:28 2009 $ * -* $Author: ing04880 $ * -* $Revision: 1.15 $ * -* $Aliases: NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ * -* * -* =========================================================================== * -*/ -#ifndef PHHCINFC_SWP_H -#define PHHCINFC_SWP_H -/*@}*/ -/** - * \name HCI - * - * File: \ref phHciNfc_SWP.h - * - */ -/*@{*/ -#define PHHCINFC_SWPRED_FILEREVISION "$Revision: 1.15 $" /**< \ingroup grp_file_attributes */ -#define PHHCINFC_SWPREDINTERFACE_FILEALIASES "$Aliases: NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ -/*@}*/ - -/****************************** Header File Inclusion *****************************/ -#include - -/******************************* Macro Definitions ********************************/ - -/* Kb/sec */ -#define UICC_REF_BITRATE (106U) -#define UICC_MAX_CONNECT_RETRY (0x02U) - -/* SWP switch mode event parameters */ -#define UICC_SWITCH_MODE_OFF (0x00U) -#define UICC_SWITCH_MODE_DEFAULT (0x01U) -#define UICC_SWITCH_MODE_ON (0x02U) - -/******************** Enumeration and Structure Definition ***********************/ - -typedef enum phHciNfc_SWP_Seq{ - SWP_INVALID_SEQUENCE = 0x00U, - SWP_MODE_SEQ, - SWP_STATUS_SEQ, - SWP_END_SEQ -}phHciNfc_SWP_Seq_t; - -typedef enum phHciNfc_SWP_Status{ - UICC_NOT_CONNECTED = 0x00U, - UICC_CONNECTION_ONGOING, - UICC_CONNECTED, - UICC_CONNECTION_LOST, - UICC_DISCONNECTION_ONGOING, - UICC_CONNECTION_FAILED -}phHciNfc_SWP_Status_t; - - -/* Information structure for SWP Gate */ -typedef struct phHciNfc_SWP_Info{ - - /* Pointer to SWP gate pipe information */ - phHciNfc_Pipe_Info_t *p_pipe_info; - /* SWP gate pipe Identified */ - uint8_t pipe_id; - /*Current internal Sequence type */ - phHciNfc_SWP_Seq_t current_seq; - /*Current next Sequence ID */ - phHciNfc_SWP_Seq_t next_seq; - - phHciNfc_SWP_Status_t uicc_status; - - uint8_t uicc_bitrate; - -} phHciNfc_SWP_Info_t; - -/************************ Function Prototype Declaration *************************/ -/*! - * \brief Allocates the resources required for SWP gate management. - * - * This function Allocates necessary resources as requiered by SWP gate management - * - * \param[in] psHciContext psHciContext is the pointer to HCI Layer - * - * \retval NFCSTATUS_SUCCESS Function execution is successful - * - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the given inputs are not valid - */ -extern -NFCSTATUS -phHciNfc_SWP_Init_Resources(phHciNfc_sContext_t *psHciContext); - -/** -* \ingroup grp_hci_nfc -* -* \brief Allocates the resources required for SWP gate management. -* -* This function Allocates necessary resources as requiered by SWP gate management -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* -* \retval NFCSTATUS_SUCCESS Function execution is successful -* -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the given inputs are not valid -*/ - -extern -NFCSTATUS -phHciNfc_SWPMgmt_Initialise( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - -/** -* \ingroup grp_hci_nfc -* -* \brief updates SWP gate specific pipe information . -* -* This function intialises gate specific informations like pipe id, -* event handler and response handler etc. -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* \param[in] pipeID pipeID of the SWP management Gate -* \param[in] pPipeInfo Update the pipe Information of the SWP -* Management Gate. -* -* \retval NFCSTATUS_SUCCESS Function execution is successful -* -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the given inputs are not valid -*/ -extern -NFCSTATUS -phHciNfc_SWP_Update_PipeInfo( - phHciNfc_sContext_t *psHciContext, - uint8_t pipeID, - phHciNfc_Pipe_Info_t *pPipeInfo - ); -/** -* \ingroup grp_hci_nfc -* -* \brief updates SWP gate specific pipe information . -* -* This function intialises gate specific informations like pipe id, -* event handler and response handler etc. -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* -* \retval NFCSTATUS_SUCCESS Function execution is successful -* -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the given inputs are not valid -*/ - -extern -NFCSTATUS -phHciNfc_SWP_Get_PipeID( - phHciNfc_sContext_t *psHciContext, - uint8_t *ppipe_id - ); - -/** -* \ingroup grp_hci_nfc -* -* \brief Enables /disables SWP mode . -* -* This function enables/disables SWP link associated with UICC. -* -* -* \param[in] psHciContext psHciContext is pointer to HCI Layer -* -* \param[in] pHwRef pHwRef is underlying Hardware context. -* -* \param[in] enable_type 0 means disable ,1 means enable SWP link. -* \retval NFCSTATUS_SUCCESS Function execution is successful -* -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the given inputs are not valid -*/ -extern -NFCSTATUS -phHciNfc_SWP_Configure_Default( - void *psHciHandle, - void *pHwRef, - uint8_t enable_type - ); - -/** -* \ingroup grp_hci_nfc -* -* \brief Enables /disables SWP mode . -* -* This function enables/disables SWP link associated with UICC. -* -* -* \param[in] psHciContext psHciContext is pointer to HCI Layer -* -* \param[in] pHwRef pHwRef is underlying Hardware context. -* -* \param[in] mode TRUE Enable Protection. -* \retval NFCSTATUS_SUCCESS Function execution is successful -* -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the given inputs are not valid -*/ -extern -NFCSTATUS -phHciNfc_SWP_Protection( - void *psHciHandle, - void *pHwRef, - uint8_t mode - ); - - -/** -* \ingroup grp_hci_nfc -* -* \brief To send the switch mode event -* -* This function send an event to change the switch mode. -* -* -* \param[in] psHciContext psHciContext is pointer to HCI Layer -* -* \param[in] pHwRef pHwRef is underlying Hardware context. -* -* \param[in] uicc_mode UICC_SWITCH_MODE_OFF -* UICC_SWITCH_MODE_DEFAULT -* UICC_SWITCH_MODE_ON -* \retval NFCSTATUS_SUCCESS Function execution is successful -* -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the given inputs are not valid -*/ -extern -NFCSTATUS -phHciNfc_SWP_Configure_Mode( - void *psHciHandle, - void *pHwRef, - uint8_t uicc_mode - ); - -/** -* \ingroup grp_hci_nfc -* -* \brief To get the status of the UICC -* -* This function reads the status of the UICC. The status value can be any -* of the values present in the \ref phHciNfc_SWP_Status_t -* -* -* \param[in] psHciContext psHciContext is pointer to HCI Layer -* -* \param[in] pHwRef pHwRef is underlying Hardware context. -* \retval NFCSTATUS_SUCCESS Function execution is successful -* -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the given inputs are not valid -*/ -extern -NFCSTATUS -phHciNfc_SWP_Get_Status( - void *psHciHandle, - void *pHwRef - ); - -/** -* \ingroup grp_hci_nfc -* -* \brief To get the bitrate -* -* This function reads the bitrate -* -* -* \param[in] psHciContext psHciContext is pointer to HCI Layer -* -* \param[in] pHwRef pHwRef is underlying Hardware context. -* \retval NFCSTATUS_SUCCESS Function execution is successful -* -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the given inputs are not valid -*/ -extern -NFCSTATUS -phHciNfc_SWP_Get_Bitrate( - void *psHciHandle, - void *pHwRef - ); - -/** -* \ingroup grp_hci_nfc -* -* \brief To update the sequence -* -* This function reads the bitrate -* -* -* \param[in] psHciContext psHciContext is pointer to HCI Layer -* -* \param[in] SWP_seq SWP sequence. -* -* \retval NFCSTATUS_SUCCESS Function execution is successful -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the given inputs are not valid -*/ -extern -NFCSTATUS -phHciNfc_SWP_Update_Sequence( - phHciNfc_sContext_t *psHciContext, - phHciNfc_eSeqType_t SWP_seq - ); - -/** -* \ingroup grp_hci_nfc -* -* \brief To configure default mode and the default status. -* -* This function configures default status and default mode. -* -* -* \param[in] psHciContext psHciContext is pointer to HCI Layer -* \param[in] pHwRef pHwRef is underlying Hardware context. -* \param[in] ps_emulation_cfg emulation configuration info. -* -* -* \retval NFCSTATUS_SUCCESS Function execution is successful -* -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the given inputs are not valid -*/ -extern -NFCSTATUS -phHciNfc_SWP_Config_Sequence( - phHciNfc_sContext_t *psHciContext, - void *pHwRef, - phHal_sEmulationCfg_t *ps_emulation_cfg - ); - - -#endif /* #ifndef PHHCINFC_SWP_H */ - - diff --git a/libnfc-nxp/phHciNfc_Sequence.h b/libnfc-nxp/phHciNfc_Sequence.h deleted file mode 100644 index e3c714f..0000000 --- a/libnfc-nxp/phHciNfc_Sequence.h +++ /dev/null @@ -1,421 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -/*! -* =========================================================================== * -* * -* * -* \file phHciNfc_Sequence.h * -* \brief State Machine Management for the HCI and the Function Sequence * -* for a particular State. * -* * -* * -* Project: NFC-FRI-1.1 * -* * -* $Date: Fri Aug 14 17:01:28 2009 $ * -* $Author: ing04880 $ * -* $Revision: 1.12 $ * -* $Aliases: NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ -* * -* =========================================================================== * -*/ - -/*@{*/ -#ifndef PHHCINFC_SEQUENCE_H -#define PHHCINFC_SEQUENCE_H - -/*@}*/ - - -/** - * \name HCI - * - * File: \ref phHciNfc_Sequence.h - * - */ - -/*@{*/ -#define PHHCINFC_SEQUENCE_FILEREVISION "$Revision: 1.12 $" /**< \ingroup grp_file_attributes */ -#define PHHCINFC_SEQUENCE_FILEALIASES "$Aliases: NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ -/*@}*/ - - -/* -################################################################################ -***************************** Header File Inclusion **************************** -################################################################################ -*/ - -#include - -/* -################################################################################ -****************************** Macro Definitions ******************************* -################################################################################ -*/ - -/* -################################################################################ -************************* Function Prototype Declaration *********************** -################################################################################ -*/ - - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_FSM_Update function Validates the HCI State to - * the next operation ongoing. - * - * \param[in] psHciContext psHciContext is the context of - * the HCI Layer. - * \param[in] state state is the state to which the - * current HCI Layer state is validated. - * \param[in] validate_type validate the state by the type of the - * validation required. - * - * \retval NFCSTATUS_SUCCESS FSM Validated successfully . - * \retval NFCSTATUS_INVALID_STATE The supplied state parameter is invalid. - * - */ - -extern -NFCSTATUS -phHciNfc_FSM_Validate( - phHciNfc_sContext_t *psHciContext, - phHciNfc_eState_t state, - uint8_t validate_type - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_FSM_Update function Checks and Updates the HCI State to - * the next valid State. - * - * \param[in] psHciContext psHciContext is the context of - * the HCI Layer. - * \param[in] next_state next_state is the state to which - * we the HCI Layer. - * \param[in] transition transiton of the state whether - * ongoing or complete . - * - * \retval NFCSTATUS_SUCCESS FSM Updated successfully . - * \retval NFCSTATUS_INVALID_STATE The supplied state parameter is invalid. - * - */ - -extern -NFCSTATUS -phHciNfc_FSM_Update( - phHciNfc_sContext_t *psHciContext, - phHciNfc_eState_t next_state - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_FSM_Complete function completes the ongoing state transition - * from the current state to the next state. - * - * \param[in] psHciContext psHciContext is the context of - * the HCI Layer. - * - * \retval NFCSTATUS_SUCCESS FSM Updated successfully . - * \retval NFCSTATUS_INVALID_STATE The supplied state parameter is invalid. - * - */ - -extern -NFCSTATUS -phHciNfc_FSM_Complete( - phHciNfc_sContext_t *psHciContext - ); - - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_FSM_Rollback function rolls back to previous valid state - * and abort the ongoing state transition. - * - * \param[in] psHciContext psHciContext is the context of - * the HCI Layer. - * - * \retval NONE. - * - */ - -extern -void -phHciNfc_FSM_Rollback( - phHciNfc_sContext_t *psHciContext - ); - - - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Initialise_Sequence function sequence initialises the - * HCI layer and the remote device by performing the operations required - * setup the reader and discovery functionality. - * - * \param[in] psHciContext psHciContext is the context of - * the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * - * \retval NFCSTATUS_SUCCESS HCI current initialise sequence successful. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Other related errors - * - */ - - -extern -NFCSTATUS -phHciNfc_Initialise_Sequence( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_PollLoop_Sequence function sequence starts the - * discovery sequence of device. - * - * \param[in] psHciContext psHciContext is the context of - * the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * - * \retval NFCSTATUS_SUCCESS HCI Discovery Configuration sequence successful. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Other related errors - * - */ - -extern -NFCSTATUS -phHciNfc_PollLoop_Sequence( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_EmulationCfg_Sequence function sequence configures the - * device for different types of emulation supported. - * - * \param[in] psHciContext psHciContext is the context of - * the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * - * \retval NFCSTATUS_SUCCESS HCI Emulation Configuration - * sequence successful. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Other related errors - * - */ - -extern -NFCSTATUS -phHciNfc_EmulationCfg_Sequence( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_SmartMx_Mode_Sequence function sequence configures the - * SmartMx device for different modes by enabling and disabling polling. - * - * \param[in] psHciContext psHciContext is the context of - * the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * - * \retval NFCSTATUS_SUCCESS HCI SmartMX Mode Configuration - * sequence successful. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Other related errors - * - */ - -extern -NFCSTATUS -phHciNfc_SmartMx_Mode_Sequence( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Connect_Sequence function sequence selects the - * discovered target for performing the transaction. - * - * \param[in] psHciContext psHciContext is the context of - * the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * - * \retval NFCSTATUS_SUCCESS HCI target selection sequence successful. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Other related errors - * - */ - -extern -NFCSTATUS -phHciNfc_Connect_Sequence( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Disconnect_Sequence function sequence de-selects the - * selected target . - * - * \param[in] psHciContext psHciContext is the context of - * the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * - * \retval NFCSTATUS_SUCCESS HCI target de-selection sequence successful. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Other related errors - * - */ - -extern -NFCSTATUS -phHciNfc_Disconnect_Sequence( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Error_Sequence function sequence notifies the - * error in the HCI sequence to the upper layer . - * - * \param[in] psHciContext psHciContext is the context of - * the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * \param[in] status Notify status information from the - * HCI layer to the Upper Layer. - * - * - * \retval NFCSTATUS_SUCCESS HCI Error sequence Notification successful. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Other related errors - * - */ -extern -void -phHciNfc_Error_Sequence( - void *psContext, - void *pHwRef, - NFCSTATUS error_status, - void *pdata, - uint8_t length - ); - - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Resume_Sequence function sequence resumes the - * previous pending sequence of HCI . - * - * \param[in] psHciContext psHciContext is the context of - * the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * - * \retval NFCSTATUS_SUCCESS HCI sequence resume successful. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Other related errors - * - */ - -extern -NFCSTATUS -phHciNfc_Resume_Sequence( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - - -/** - * \ingroup grp_hci_nfc - * - * The phHciNfc_Release_Sequence function sequence releases the - * HCI layer and the remote device by performing the operations required - * release the reader and discovery functionality. - * - * \param[in] psHciContext psHciContext is the context of - * the HCI Layer. - * \param[in] pHwRef pHwRef is the Information of - * the Device Interface Link . - * - * \retval NFCSTATUS_SUCCESS HCI current release sequence successful. - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters - * could not be interpreted properly. - * \retval Other errors Other related errors - * - */ - - -extern -NFCSTATUS -phHciNfc_Release_Sequence( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); - - -/* -################################################################################ -***************************** Function Definitions ***************************** -################################################################################ -*/ - -#endif - diff --git a/libnfc-nxp/phHciNfc_WI.h b/libnfc-nxp/phHciNfc_WI.h deleted file mode 100644 index 6ab2f5c..0000000 --- a/libnfc-nxp/phHciNfc_WI.h +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! -* =========================================================================== * -* * -* * -* \file phHciNfc_WI .h * -* \brief HCI wired interface gate Management Routines. * -* * -* * -* Project: NFC-FRI-1.1 * -* * -* $Date: Fri Jan 16 10:33:47 2009 $ * -* $Author: ravindrau $ * -* $Revision: 1.11 $ * -* $Aliases: NFC_FRI1.1_WK904_PREP1,NFC_FRI1.1_WK904_R17_1,NFC_FRI1.1_WK906_R18_1,NFC_FRI1.1_WK908_PREP1,NFC_FRI1.1_WK908_R19_1,NFC_FRI1.1_WK910_PREP1,NFC_FRI1.1_WK910_R20_1,NFC_FRI1.1_WK912_PREP1,NFC_FRI1.1_WK912_R21_1,NFC_FRI1.1_WK914_PREP1,NFC_FRI1.1_WK914_R22_1,NFC_FRI1.1_WK914_R22_2,NFC_FRI1.1_WK916_R23_1,NFC_FRI1.1_WK918_R24_1,NFC_FRI1.1_WK920_PREP1,NFC_FRI1.1_WK920_R25_1,NFC_FRI1.1_WK922_PREP1,NFC_FRI1.1_WK922_R26_1,NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK926_R28_2,NFC_FRI1.1_WK926_R28_3,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ * -* * -* =========================================================================== * -*/ -#ifndef PHHCINFC_WI_H -#define PHHCINFC_WI_H -/*@}*/ -/** - * \name HCI - * - * File: \ref phHciNfc_WI.h - * - */ -/*@{*/ -#define PHHCINFC_WIRED_FILEREVISION "$Revision: 1.11 $" /**< \ingroup grp_file_attributes */ -#define PHHCINFC_WIREDINTERFACE_FILEALIASES "$Aliases: NFC_FRI1.1_WK904_PREP1,NFC_FRI1.1_WK904_R17_1,NFC_FRI1.1_WK906_R18_1,NFC_FRI1.1_WK908_PREP1,NFC_FRI1.1_WK908_R19_1,NFC_FRI1.1_WK910_PREP1,NFC_FRI1.1_WK910_R20_1,NFC_FRI1.1_WK912_PREP1,NFC_FRI1.1_WK912_R21_1,NFC_FRI1.1_WK914_PREP1,NFC_FRI1.1_WK914_R22_1,NFC_FRI1.1_WK914_R22_2,NFC_FRI1.1_WK916_R23_1,NFC_FRI1.1_WK918_R24_1,NFC_FRI1.1_WK920_PREP1,NFC_FRI1.1_WK920_R25_1,NFC_FRI1.1_WK922_PREP1,NFC_FRI1.1_WK922_R26_1,NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK926_R28_2,NFC_FRI1.1_WK926_R28_3,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ -/*@}*/ - -/****************************** Header File Inclusion *****************************/ -#include -#include - -/******************************* Macro Definitions ********************************/ - -/******************** Enumeration and Structure Definition ***********************/ - - -/* enable /disable notifications */ -typedef enum phHciNfc_WI_Events{ - eDisableEvents, - eEnableEvents -} phHciNfc_WI_Events_t; - -typedef enum phHciNfc_WI_Seq{ - eWI_PipeOpen = 0x00U, - eWI_SetDefaultMode, - eWI_PipeClose -} phHciNfc_WI_Seq_t; - -/* Information structure for WI Gate */ -typedef struct phHciNfc_WI_Info{ - - /* Pointer to WI gate pipe information */ - phHciNfc_Pipe_Info_t *p_pipe_info; - /* WI gate pipe Identifier */ - uint8_t pipe_id; - /* Application ID of the Transaction performed */ - uint8_t aid[MAX_AID_LEN]; - /* Default info */ - uint8_t default_type; - /* Current WI gate Internal Sequence type */ - phHciNfc_WI_Seq_t current_seq; - /*Current WI gate next Sequence ID */ - phHciNfc_WI_Seq_t next_seq; - -} phHciNfc_WI_Info_t; - -/************************ Function Prototype Declaration *************************/ -/*! - * \brief Allocates the resources required for WI gate management. - * - * This function Allocates necessary resources as requiered by WI gate management - * - * \param[in] psHciContext psHciContext is the pointer to HCI Layer - * - * \retval NFCSTATUS_SUCCESS Function execution is successful - * - * \retval NFCSTATUS_INVALID_PARAMETER One or more of the given inputs are not valid - */ -extern -NFCSTATUS -phHciNfc_WI_Init_Resources(phHciNfc_sContext_t *psHciContext); - -/** -* \ingroup grp_hci_nfc -* -* \brief Allocates the resources required for WI gate management. -* -* This function Allocates necessary resources as requiered by WI gate management -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* -* \retval NFCSTATUS_SUCCESS Function execution is successful -* -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the given inputs are not valid -*/ - -extern -NFCSTATUS -phHciNfc_WIMgmt_Initialise( - phHciNfc_sContext_t *psHciContext, - void *pHwRef - ); -/** -* \ingroup grp_hci_nfc -* -* \brief Allocates the resources required for WI gate management. -* -* This function Allocates necessary resources as requiered by WI gate management -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* -* \retval NFCSTATUS_SUCCESS Function execution is successful -* -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the given inputs are not valid -*/ -extern -NFCSTATUS -phHciNfc_WI_Update_PipeInfo( - phHciNfc_sContext_t *psHciContext, - uint8_t pipeID, - phHciNfc_Pipe_Info_t *pPipeInfo - ); - -/** -* \ingroup grp_hci_nfc -* -* \brief Allocates the resources required for WI gate management. -* -* This function Allocates necessary resources as requiered by WI gate management -* -* \param[in] psHciContext psHciContext is the pointer to HCI Layer -* -* \retval NFCSTATUS_SUCCESS Function execution is successful -* -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the given inputs are not valid -*/ -extern -NFCSTATUS -phHciNfc_WI_Configure_Mode( - void *psHciHandle, - void *pHwRef, - phHal_eSmartMX_Mode_t cfg_Mode - ); - -extern -NFCSTATUS -phHciNfc_WI_Configure_Notifications( - void *psHciHandle, - void *pHwRef, - phHciNfc_WI_Events_t eNotification - ); - -extern -NFCSTATUS -phHciNfc_WI_Get_PipeID( - phHciNfc_sContext_t *psHciContext, - uint8_t *ppipe_id - ); - -extern -NFCSTATUS -phHciNfc_WI_Configure_Default( - void *psHciHandle, - void *pHwRef, - uint8_t enable_type - ); - -extern -NFCSTATUS -phHciNfc_WI_Get_Default( - void *psHciHandle, - void *pHwRef - ); - - -#endif /* #ifndef PHHCINFC_WI_H */ - diff --git a/libnfc-nxp/phLibNfc.h b/libnfc-nxp/phLibNfc.h deleted file mode 100644 index ddce262..0000000 --- a/libnfc-nxp/phLibNfc.h +++ /dev/null @@ -1,3152 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! -*\file phLibNfc_1.1.h -*\brief Contains FRI1.1 API details. -*Project: NFC-FRI 1.1 -* $Workfile:: phLibNfc_1.1.h $ -* $Modtime:: $ -* $Author: ing07385 $ -* $Revision: 1.80 $ -* $Aliases: NFC_FRI1.1_WK1014_SDK,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1019_SDK,NFC_FRI1.1_WK1024_SDK $ -*\defgroup grp_lib_nfc LIBNFC Component -*/ -/* \page LibNfc_release_label FRI1.1 API Release Label -* $Aliases: NFC_FRI1.1_WK1014_SDK,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1019_SDK,NFC_FRI1.1_WK1024_SDK $ -*\note This is the TAG (label, alias) of the FRI1.1. -*If the string is empty, the current documentation -* has not been generated for official release. -*/ -#ifndef PHLIBNFC_H -#define PHLIBNFC_H -#include -#include -#include -#include -#include -#ifdef ANDROID -#include -#endif - -/*! -*\def PHLIBNFC_MAXNO_OF_SE -*Defines maximum no of secured elements supported by PN544. -*/ -#define LIBNFC_READONLY_NDEF -#define PHLIBNFC_MAXNO_OF_SE (0x02) - -typedef uintptr_t phLibNfc_Handle; - -extern const unsigned char *nxp_nfc_full_version; - - -/** -*\ingroup grp_lib_nfc -* -*\brief Defines Testmode Init configuration values -*/ - -typedef enum -{ - phLibNfc_TstMode_Off = 0x00, /**< Test mode is off */ - phLibNfc_TstMode_On /**< Testmode is on */ - -} phLibNfc_Cfg_Testmode_t; - - -/** -*\ingroup grp_lib_nfc -* -*\brief Defines Secure Element configurable states -*/ - -typedef enum -{ - phLibNfc_SE_Active = 0x00, /**< state of the SE is active */ - phLibNfc_SE_Inactive= 0x01 /**< state of the SE is In active*/ - -} phLibNfc_SE_State_t; - -/** -*\ingroup grp_lib_nfc -* -*\brief Defines Secure Element types. -*/ -typedef enum -{ - phLibNfc_SE_Type_Invalid=0x00,/**< Indicates SE type is Invalid */ - phLibNfc_SE_Type_SmartMX=0x01,/**< Indicates SE type is SmartMX */ - phLibNfc_SE_Type_UICC =0x02,/**LibNfc[label="phLibNfc_Mgt_ConfigureDriver()",URL="\ref phLibNfc_Mgt_ConfigureDriver"]; -*LibNfcClient<LibNfc [label="phLibNfc_Mgt_ConfigureDriver()",URL="\ref phLibNfc_Mgt_ConfigureDriver"]; - *LibNfcClient<LibNfc [label="phLibNfc_Mgt_Initialize()",URL="\ref phLibNfc_Mgt_Initialize"]; - *LibNfcClient<LibNfc [label="phLibNfc_Mgt_DeInitialize()",URL="\ref phLibNfc_Mgt_DeInitialize"]; - *LibNfcClient<LibNfc [label="phLibNfc_Mgt_UnConfigureDriver()",URL="\ref phLibNfc_Mgt_UnConfigureDriver"]; - *LibNfcClient< timeout value, (256*16/13.56*10^6) * 2^value -// [0] -> 0.0003s -// .. -// [14] -> 4.9s -// [15] -> not allowed -// bit [4] => timeout enable -// bit [5..7] => unused -NFCSTATUS phLibNfc_SetIsoXchgTimeout(uint8_t timeout); -int phLibNfc_GetIsoXchgTimeout(); - -NFCSTATUS phLibNfc_SetHciTimeout(uint32_t timeout_in_ms); -int phLibNfc_GetHciTimeout(); - -// Felica timeout -// [0] -> timeout disabled -// [1..255] -> timeout in ms -NFCSTATUS phLibNfc_SetFelicaTimeout(uint8_t timeout_in_ms); -int phLibNfc_GetFelicaTimeout(); - -// MIFARE RAW timeout (ISO14443-3A / NfcA timeout) -// timeout is 8 bits -// bits [0..3] => timeout value, (256*16/13.56*10^6) * 2^value -// [0] -> 0.0003s -// .. -// [14] -> 4.9s -// [15] -> not allowed -// bits [4..7] => 0 -NFCSTATUS phLibNfc_SetMifareRawTimeout(uint8_t timeout); -int phLibNfc_GetMifareRawTimeout(); - -/** -* \ingroup grp_lib_nfc -* -* \brief Initializes the NFC library . -* -* -*\brief This function initializes NFC library and its underlying layers. -* As part of this interface underlying modules gets initialized. -* A session with NFC hardware will be established. -* Once initialization is successful ,NFC library ready for use. -*\note It is must to initialize prior usage of the stack . -* -* \param[in] pDriverHandle Driver Handle currently application is using. -* \param[in] pInitCb The init callback is called by the LibNfc when init is -* completed or there is an error in initialization. -* -* \param[in] pContext Client context which will be included in -* callback when the request is completed. -* -* \retval NFCSTATUS_ALREADY_INITIALISED Stack is already initialized. -* \retval NFCSTATUS_PENDING Init sequence has been successfully -* started and result will be conveyed via -* callback notification. -* \retval NFCSTATUS_INVALID_PARAMETER The parameter could not be properly -* interpreted. -*\retval NFCSTATUS_INSUFFICIENT_RESOURCES Insufficient resource.(Ex: insufficient memory) -* -*\msc -*LibNfcClient,LibNfc; -*--- [label="Before initializing Nfc LIB,Configure Driver layer"]; -*LibNfcClient=>LibNfc[label="phLibNfc_Mgt_ConfigureDriver()",URL="\ref phLibNfc_Mgt_ConfigureDriver"]; -*LibNfcClient<LibNfc [label="phLibNfc_Mgt_Initialize()",URL="\ref phLibNfc_Mgt_Initialize"]; -*LibNfcClient<LibNfc [label="phLibNfc_Mgt_Initialize()",URL="\ref phLibNfc_Mgt_Initialize"]; -*LibNfcClient<LibNfc [label="phLibNfc_Mgt_DeInitialize()",URL="\ref phLibNfc_Mgt_DeInitialize"]; -*LibNfcClient<LibNfc [label="phLibNfc_Mgt_Initialize()",URL="\ref phLibNfc_Mgt_Initialize"]; -*LibNfcClient<LibNfc [label="phLibNfc_Mgt_Initialize()",URL="\ref phLibNfc_Mgt_Initialize"]; -*LibNfcClient<LibNfc [label="phLibNfc_SE_GetSecureElementList()",URL="\ref phLibNfc_SE_GetSecureElementList"]; -*LibNfcClient<LibNfc [label="phLibNfc_SE_SetMode(hSE_Handle,)",URL="\ref phLibNfc_SE_SetMode"]; -*LibNfcClient<LibNfc [label="phLibNfc_Mgt_Initialize()",URL="\ref phLibNfc_Mgt_Initialize"]; -*LibNfcClient<LibNfc [label="phLibNfc_SE_NtfRegister()",URL="\ref phLibNfc_SE_NtfRegister"]; -LibNfcClient<LibNfc [label="phLibNfc_Mgt_Initialize()",URL="\ref phLibNfc_Mgt_Initialize"]; -*LibNfcClient<LibNfc [label="phLibNfc_SE_NtfRegister()",URL="\ref phLibNfc_SE_NtfRegister"]; -LibNfcClient<LibNfc [label="phLibNfc_SE_NtfUnregister()",URL="\ref phLibNfc_SE_NtfUnregister"]; -*LibNfcClient<LibNfc [label="phLibNfc_Mgt_IoCtl(pDriverHandle,)",URL="\ref phLibNfc_Mgt_IoCtl"]; -*LibNfcClient<LibNfc [label="phLibNfc_Mgt_Initialize()",URL="\ref phLibNfc_Mgt_Initialize"]; -*LibNfcClient<-LibNfc [label="pInitCb()",URL="\ref pphLibNfc_RspCb_t()"]; -*--- [label="Register for technology type.Ex: MIFARE UL"]; -*LibNfcClient=>LibNfc [label="phLibNfc_RemoteDev_NtfRegister()",URL="\ref phLibNfc_RemoteDev_NtfRegister"]; -*LibNfcClient<
a)Enabling/disabling of Reader phases for A,B and F technologies. -*
b)Configuring NFC-IP1 Initiator Speed and duration of the Emulation phase . -* -*Discovery wheel configuration based on discovery mode selected is as below. -*

1.If discovery Mode is set as \ref NFC_DISCOVERY_CONFIG then previous configurations -* over written by new configurations passed in \ref phLibNfc_sADD_Cfg_t and Discovery wheel -*restarts with new configurations. -*

2.If discovery Mode is set as \ref NFC_DISCOVERY_START or \ref NFC_DISCOVERY_STOP then -* discovery parameters passed in \ref phLibNfc_sADD_Cfg_t will not be considered and previous -*configurations still holds good. -*

3.If discovery Mode is set as \ref NFC_DISCOVERY_RESUME discovery mode starts the discovery -*wheel from where it is stopped previously. -* -*\b Note: Config types \b NFC_DISCOVERY_START, \b NFC_DISCOVERY_STOP and \b NFC_DISCOVERY_RESUME -* are not supported currently. It is for future use. -* -* \param[in] DiscoveryMode Discovery Mode allows to choose between: -* discovery configuration and start, stop -* discovery and start discovery (with last -* set configuration).For mode details refer to -\ref phNfc_eDiscoveryConfigMode_t. -* \param[in] sADDSetup Includes Enable/Disable discovery for -* each protocol A,B and F. -* Details refer to \ref phNfc_sADD_Cfg_t. -* \param[in] pConfigDiscovery_RspCb is called once the discovery wheel -* configuration is complete. -* \param[in] pContext Client context which will be included in -* callback when the request is completed. -* -* -*\retval NFCSTATUS_PENDING Discovery request is in progress and result -* will be notified via callback later. -*\retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -*\retval NFCSTATUS_NOT_INITIALISED Indicates stack is not initialized. -*\retval NFCSTATUS_INSUFFICIENT_RESOURCES Insufficient resource.(Ex: insufficient memory) -*\retval NFCSTATUS_BUSY already discovery in progress -* or it is already discovered Target and -* connected. -*\retval NFSCSTATUS_SHUTDOWN Shutdown in progress. -*\retval NFCSTATUS_FAILED Request failed. - -* -* \note : During Reader/Initiator mode it is mandatory -* to call \ref phLibNfc_RemoteDev_Connect before any transaction can be performed -* with the discovered target. Even if the LibNfc client is not -* interested in using any of the discovered targets \ref phLibNfc_RemoteDev_Connect -* and \ref phLibNfc_RemoteDev_Disconnect should be called to restart the Discovery -* wheel. -* \sa \ref phLibNfc_RemoteDev_Connect, phLibNfc_RemoteDev_Disconnect. - -*\msc -*LibNfcClient,LibNfc; -*LibNfcClient=>LibNfc [label="phLibNfc_Mgt_Initialize()",URL="\ref phLibNfc_Mgt_Initialize"]; -*LibNfcClient<-LibNfc [label="pInitCb()",URL="\ref pphLibNfc_RspCb_t()"]; -*LibNfcClient=>LibNfc [label="phLibNfc_RemoteDev_NtfRegister()",URL="\ref -phLibNfc_RemoteDev_NtfRegister"]; -*LibNfcClient<LibNfc [label="phLibNfc_Mgt_ConfigureDiscovery()",URL="\ref phLibNfc_Mgt_ConfigureDiscovery"]; -*LibNfcClient<-LibNfc [label="pConfigDiscovery_RspCb",URL="\ref pphLibNfc_RspCb_t"]; -*--- [label="Now discovery wheel configured as requested"]; -* -*\endmsc -* -*\note Response callback parameters details for this interface are as listed below. -* -* \param[in] pContext LibNfc client context passed in the corresponding request before. -* \param[in] status Status of the response callback. -* -* \param NFCSTATUS_SUCCESS Discovery Configuration successful. -* \param NFCSTATUS_SHUTDOWN Shutdown in progress. -* \param NFCSTATUS_FAILED Request failed. -*/ - -NFCSTATUS phLibNfc_Mgt_ConfigureDiscovery (phLibNfc_eDiscoveryConfigMode_t DiscoveryMode, - phLibNfc_sADD_Cfg_t sADDSetup, - pphLibNfc_RspCb_t pConfigDiscovery_RspCb, - void* pContext - ); - - -/** -* \ingroup grp_lib_nfc -* \brief This function is used to to connect to a single Remote Device. -* -* This function is called to connect to discovered target. -* Once notification handler notified sucessfully discovered targets will be available in -* \ref phLibNfc_RemoteDevList_t .Remote device list contains valid handles for discovered -* targets .Using this interface LibNfc client can connect to one out of 'n' discovered targets. -* A new session is started after connect operation is successful.The session ends with a -* successful disconnect operation.Connect operation on an already connected tag Reactivates -* the Tag.This Feature is not Valid for Jewel/Topaz Tags ,and hence a second connect if issued -* without disconnecting a Jewel/Topaz tag always Fails. -* -* \note :In case multiple targets discovered LibNfc client can connect to only one target. -* -* \param[in] hRemoteDevice Handle of the target device obtained during discovery process. -* -* \param[in] pNotifyConnect_RspCb Client response callback to be to be -* notified to indicate status of the request. -* -* \param[in] pContext Client context which will be included in -* callback when the request is completed. -* -*\retval NFCSTATUS_PENDING Request initiated, result will be informed via -* callback. -*\retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -*\retval NFCSTATUS_TARGET_LOST Indicates target is lost. -*\retval NFSCSTATUS_SHUTDOWN shutdown in progress. -*\retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -*\retval NFCSTATUS_INVALID_HANDLE Target handle is invalid. -* -*\retval NFCSTATUS_FAILED Request failed. -* -* -*\msc -*LibNfcClient,LibNfc; -*LibNfcClient=>LibNfc [label="phLibNfc_Mgt_Initialize()",URL="\ref phLibNfc_Mgt_Initialize"]; -*LibNfcClient<-LibNfc [label="pInitCb()",URL="\ref pphLibNfc_RspCb_t()"]; -*LibNfcClient=>LibNfc [label="phLibNfc_RemoteDev_NtfRegister()",URL="\ref phLibNfc_RemoteDev_NtfRegister"]; -*LibNfcClient<LibNfc [label="phLibNfc_Mgt_configureDiscovery()",URL="\ref phLibNfc_Mgt_ConfigureDiscovery"]; -*LibNfcClient<-LibNfc [label="pConfigDiscovery_RspCb",URL="\ref pphLibNfc_RspCb_t"]; -*--- [label="Now Present Tag to be discovered"]; -*LibNfcClient<-LibNfc [label="pNotificationHandler",URL="\ref phLibNfc_NtfRegister_RspCb_t"]; -*LibNfcClient=>LibNfc [label="phLibNfc_RemoteDev_Connect()",URL="\ref phLibNfc_RemoteDev_Connect"]; -*LibNfcClient<-LibNfc [label="pNotifyConnect_RspCb",URL="\ref pphLibNfc_ConnectCallback_t"]; -* -*\endmsc -*/ - -NFCSTATUS phLibNfc_RemoteDev_Connect(phLibNfc_Handle hRemoteDevice, - pphLibNfc_ConnectCallback_t pNotifyConnect_RspCb, - void* pContext - ); - -#ifdef RECONNECT_SUPPORT - -/** -* \ingroup grp_lib_nfc -* \brief This function is used to to connect to NEXT Remote Device. -* -* This function is called only if there are more than one remote device is detected. -* Once notification handler notified sucessfully discovered targets will be available in -* \ref phLibNfc_RemoteDevList_t .Remote device list contains valid handles for discovered -* targets .Using this interface LibNfc client can connect to one out of 'n' discovered targets. -* A new session is started after connect operation is successful. -* Similarly, if the user wants to connect to another handle. Libnfc client can select the handle and -* the previously connected device is replaced by present handle. The session ends with a -* successful disconnect operation. -* Re-Connect operation on an already connected tag Reactivates the Tag. This Feature is not -* Valid for Jewel/Topaz Tags ,and hence a second re-connect if issued -* without disconnecting a Jewel/Topaz tag always Fails. -* -* \note :In case multiple targets discovered LibNfc client can re-connect to only one target. -* -* \param[in] hRemoteDevice Handle of the target device obtained during discovery process. -* -* \param[in] pNotifyReConnect_RspCb Client response callback to be to be -* notified to indicate status of the request. -* -* \param[in] pContext Client context which will be included in -* callback when the request is completed. -* -*\retval NFCSTATUS_PENDING Request initiated, result will be informed via -* callback. -*\retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -*\retval NFCSTATUS_TARGET_LOST Indicates target is lost. -*\retval NFSCSTATUS_SHUTDOWN shutdown in progress. -*\retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -*\retval NFCSTATUS_INVALID_HANDLE Target handle is invalid. -* -*\retval NFCSTATUS_FAILED Request failed. -* -* -*\msc -*LibNfcClient,LibNfc; -*LibNfcClient=>LibNfc [label="phLibNfc_Mgt_Initialize()",URL="\ref phLibNfc_Mgt_Initialize"]; -*LibNfcClient<-LibNfc [label="pInitCb()",URL="\ref pphLibNfc_RspCb_t()"]; -*LibNfcClient=>LibNfc [label="phLibNfc_RemoteDev_NtfRegister()",URL="\ref phLibNfc_RemoteDev_NtfRegister"]; -*LibNfcClient<LibNfc [label="phLibNfc_Mgt_configureDiscovery()",URL="\ref phLibNfc_Mgt_ConfigureDiscovery"]; -*LibNfcClient<-LibNfc [label="pConfigDiscovery_RspCb",URL="\ref pphLibNfc_RspCb_t"]; -*--- [label="Now Present multiple protocol Tag to be discovered"]; -*LibNfcClient<-LibNfc [label="pNotificationHandler",URL="\ref phLibNfc_NtfRegister_RspCb_t"]; -*--- [label="TWO remote device information is received, So connect with one handle"]; -*LibNfcClient=>LibNfc [label="phLibNfc_RemoteDev_Connect()",URL="\ref phLibNfc_RemoteDev_Connect"]; -*LibNfcClient<-LibNfc [label="pNotifyConnect_RspCb",URL="\ref pphLibNfc_ConnectCallback_t"]; -*--- [label="Connect is successful, so transact using this handle. Now if user wants to switch to another handle then call Reconnect "]; -*LibNfcClient=>LibNfc [label="phLibNfc_RemoteDev_ReConnect()",URL="\ref phLibNfc_RemoteDev_ReConnect"]; -*LibNfcClient<-LibNfc [label="pNotifyReConnect_RspCb",URL="\ref pphLibNfc_ConnectCallback_t"]; -* -*\endmsc -*/ -NFCSTATUS -phLibNfc_RemoteDev_ReConnect ( - phLibNfc_Handle hRemoteDevice, - pphLibNfc_ConnectCallback_t pNotifyReConnect_RspCb, - void *pContext); - -#endif /* #ifdef RECONNECT_SUPPORT */ - -/** -* \ingroup grp_lib_nfc -* \brief This interface allows to perform Read/write operation on remote device. -* -* This function allows to send data to and receive data -* from the target selected by libNfc client.It is also used by the -* NFCIP1 Initiator while performing a transaction with the NFCIP1 target. -* The LibNfc client has to provide the handle of the target and the -* command in order to communicate with the selected remote device. -* -* -*\param[in] hRemoteDevice handle of the remote device.This handle to be -* same as as handle obtained for specific remote device -* during device discovery. -* \param[in] psTransceiveInfo Information required by transceive is concealed in -* this structure.It contains send,receive buffers -* and command specific details. -* -* -* \param[in] pTransceive_RspCb Callback function for returning the received response -* or error. -* \param[in] pContext Client context which will be included in -* callback when the request is completed. -* -* \retval NFCSTATUS_PENDING Request initiated, result will be informed through -* the callback. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters could -* not be properly interpreted or invalid. -* \retval NFCSTATUS_COMMAND_NOT_SUPPORTED The command is not supported. -* \retval NFSCSTATUS_SHUTDOWN shutdown in progress. -* \retval NFCSTATUS_TARGET_LOST Indicates target is lost. -* \retval NFCSTATUS_TARGET_NOT_CONNECTED The Remote Device is not connected. -* \retval NFCSTATUS_INVALID_HANDLE Target handle is invalid -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_REJECTED Indicates invalid request. -* \retval NFCSTATUS_FAILED Request failed. -* -*\msc -*LibNfcClient,LibNfc; -*LibNfcClient=>LibNfc [label="phLibNfc_Mgt_Initialize()",URL="\ref phLibNfc_Mgt_Initialize"]; -*LibNfcClient<-LibNfc [label="pInitCb()",URL="\ref pphLibNfc_RspCb_t()"]; -*LibNfcClient=>LibNfc [label="phLibNfc_RemoteDev_NtfRegister()",URL="\ref phLibNfc_RemoteDev_NtfRegister"]; -*LibNfcClient<LibNfc [label="phLibNfc_Mgt_configureDiscovery()",URL="\ref phLibNfc_Mgt_ConfigureDiscovery"]; -*LibNfcClient<-LibNfc [label="pConfigDiscovery_RspCb",URL="\ref pphLibNfc_RspCb_t"]; -*--- [label="Now Present Tag to be discovered"]; -*LibNfcClient<-LibNfc [label="pNotificationHandler",URL="\ref phLibNfc_NtfRegister_RspCb_t"]; -*LibNfcClient=>LibNfc [label="phLibNfc_RemoteDev_Connect()",URL="\ref phLibNfc_RemoteDev_Connect"]; -*LibNfcClient<-LibNfc [label="pNotifyConnect_RspCb",URL="\ref pphLibNfc_ConnectCallback_t"]; -*--- [label="Now perform transceive operation"]; -*LibNfcClient=>LibNfc [label="phLibNfc_RemoteDev_Transceive()",URL="\ref phLibNfc_RemoteDev_Transceive "]; -*LibNfcClient<-LibNfc [label="pTransceive_RspCb",URL="\ref pphLibNfc_TransceiveCallback_t"]; -* -*\endmsc -*/ - -NFCSTATUS phLibNfc_RemoteDev_Transceive(phLibNfc_Handle hRemoteDevice, - phLibNfc_sTransceiveInfo_t* psTransceiveInfo, - pphLibNfc_TransceiveCallback_t pTransceive_RspCb, - void* pContext - ); - -/** -*\ingroup grp_lib_nfc -*\brief Allows to disconnect from already connected target. -* -* The function allows to disconnect from from already connected target. This -* function closes the session opened during connect operation.The status of discovery -* wheel after disconnection is determined by the \ref phLibNfc_eReleaseType_t parameter. -* it is also used to switch from wired to virtual mode in case the discovered -* device is SmartMX in wired mode. -* -*\param[in] hRemoteDevice handle of the target device.This handle to be -* same as as handle obtained for specific remote device -* during device discovery. -* \param[in] ReleaseType Release mode to be used while -* disconnecting from target.Refer \ref phLibNfc_eReleaseType_t -* for possible release types. -*\param[in] pDscntCallback Client response callback to be to be notified -to indicate status of the request. -* \param[in] pContext Client context which will be included in -* callback when the request is completed. - -*\retval NFCSTATUS_PENDING Request initiated, result will be informed through -the callback. -*\retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters could not be -* properly interpreted. -*\retval NFCSTATUS_TARGET_NOT_CONNECTED The Remote Device is not connected. -*\retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_INVALID_HANDLE Target handle is invalid. -*\retval NFSCSTATUS_SHUTDOWN Shutdown in progress. -*\retval NFCSTATUS_REJECTED Indicates previous disconnect in progress. -* \retval NFCSTATUS_BUSY Indicates can not disconnect due to outstanding transaction in progress. -* \retval NFCSTATUS_FAILED Request failed. - -* -* -* -*\msc -*LibNfcClient,LibNfc; -*LibNfcClient=>LibNfc [label="phLibNfc_Mgt_Initialize()",URL="\ref phLibNfc_Mgt_Initialize"]; -*LibNfcClient<-LibNfc [label="pInitCb()",URL="\ref pphLibNfc_RspCb_t()"]; -*LibNfcClient=>LibNfc [label="phLibNfc_RemoteDev_NtfRegister()",URL="\ref phLibNfc_RemoteDev_NtfRegister"]; -*LibNfcClient<LibNfc [label="phLibNfc_Mgt_configureDiscovery()",URL="\ref phLibNfc_Mgt_ConfigureDiscovery"]; -*LibNfcClient<-LibNfc [label="pConfigDiscovery_RspCb",URL="\ref pphLibNfc_RspCb_t"]; -*--- [label="Now Present Tag to be discovered"]; -*LibNfcClient<-LibNfc [label="pNotificationHandler",URL="\ref phLibNfc_NtfRegister_RspCb_t"]; -*LibNfcClient=>LibNfc [label="phLibNfc_RemoteDev_Connect()",URL="\ref phLibNfc_RemoteDev_Connect"]; -*LibNfcClient<-LibNfc [label="pNotifyConnect_RspCb",URL="\ref pphLibNfc_ConnectCallback_t"]; -*LibNfcClient=>LibNfc [label="phLibNfc_RemoteDev_Transceive()",URL="\ref phLibNfc_RemoteDev_Transceive"]; -*LibNfcClient<-LibNfc [label="pTransceive_RspCb",URL="\ref pphLibNfc_TransceiveCallback_t"]; -*--- [label="Once transceive is completed Now disconnect"]; -*LibNfcClient=>LibNfc [label="phLibNfc_RemoteDev_Disconnect()",URL="\ref phLibNfc_RemoteDev_Disconnect"]; -*LibNfcClient<-LibNfc [label="pDscntCallback",URL="\ref pphLibNfc_RspCb_t"]; -* -*\endmsc -*/ -NFCSTATUS phLibNfc_RemoteDev_Disconnect( phLibNfc_Handle hRemoteDevice, - phLibNfc_eReleaseType_t ReleaseType, - pphLibNfc_DisconnectCallback_t pDscntCallback, - void* pContext - ); - - - -/** -* \ingroup grp_lib_nfc -*\brief This interface unregisters notification handler for target discovery. -* -* This function unregisters the listener which has been registered with -* phLibNfc_RemoteDev_NtfUnregister() before. After this call the callback -* function won't be called anymore. If nothing is registered the -* function still succeeds -* \retval NFCSTATUS_SUCCESS callback unregistered. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -*\retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* -*\msc -*LibNfcClient,LibNfc; -*LibNfcClient=>LibNfc [label="phLibNfc_Mgt_Initialize()",URL="\ref phLibNfc_Mgt_Initialize"]; -*LibNfcClient<-LibNfc [label="pInitCb()",URL="\ref pphLibNfc_RspCb_t()"]; -*LibNfcClient=>LibNfc [label="phLibNfc_RemoteDev_NtfRegister()",URL="\ref phLibNfc_RemoteDev_NtfRegister"]; -*LibNfcClient<LibNfc [label="phLibNfc_RemoteDev_NtfUnregister()",URL="\ref phLibNfc_RemoteDev_NtfUnregister"]; -* -*\endmsc -*/ - -NFCSTATUS phLibNfc_RemoteDev_NtfUnregister(void); - -/** -* \ingroup grp_lib_nfc -* \brief Check for target presence. -* This function checks ,given target is present in RF filed or not. -* Client can make use of this API to check periodically discovered -* tag is present in RF field or not. -* -* -*\param[in] hRemoteDevice handle of the target device.This handle to be -* same as as handle obtained for specific remote device -* during device discovery. -* \param[in] pPresenceChk_RspCb callback function called on completion of the -* presence check or in case an error has occurred. -* \param[in] pContext Client context which will be included in -* callback when the request is completed. -* -* \retval NFCSTATUS_PENDING presence check started. Status will be notified -* via callback. -* -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not initialized. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters could -* not be properly interpreted. -* \retval NFCSTATUS_TARGET_NOT_CONNECTED The Remote Device is not connected. -* \retval NFCSTATUS_INVALID_HANDLE Target handle is invalid -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Request failed. -* -* -*\msc -*LibNfcClient,LibNfc; -*LibNfcClient=>LibNfc [label="phLibNfc_Mgt_Initialize()",URL="\ref phLibNfc_Mgt_Initialize"]; -*LibNfcClient<-LibNfc [label="pInitCb()",URL="\ref pphLibNfc_RspCb_t()"]; -*LibNfcClient=>LibNfc [label="phLibNfc_RemoteDev_NtfRegister()",URL="\ref phLibNfc_RemoteDev_NtfRegister"]; -*LibNfcClient<LibNfc [label="phLibNfc_Mgt_configureDiscovery()",URL="\ref phLibNfc_Mgt_ConfigureDiscovery"]; -*LibNfcClient<-LibNfc [label="pConfigDiscovery_RspCb",URL="\ref pphLibNfc_RspCb_t"]; -*--- [label="Now Present Tag to be discovered"]; -*LibNfcClient<-LibNfc [label="pNotificationHandler",URL="\ref phLibNfc_NtfRegister_RspCb_t"]; -*LibNfcClient=>LibNfc [label="phLibNfc_RemoteDev_Connect()",URL="\ref phLibNfc_RemoteDev_Connect"]; -*LibNfcClient<-LibNfc [label="pNotifyConnect_RspCb",URL="\ref pphLibNfc_RspCb_t"]; -*LibNfcClient=>LibNfc [label="phLibNfc_RemoteDev_CheckPresence()",URL="\ref phLibNfc_RemoteDev_CheckPresence"]; -*LibNfcClient<-LibNfc [label="pPresenceChk_RspCb",URL="\ref pphLibNfc_RspCb_t"]; -* -*\endmsc -* -*\note Response callback parameters details for this interface are as listed below. -* -* \param[in] pContext LibNfc client context passed in the corresponding request before. -* \param[in] status Status of the response callback. -* -* \param NFCSTATUS_SUCCESS Successful,indicates tag is present in RF field. -* \param NFCSTATUS_TARGET_LOST Indicates target is lost. -* \param NFCSTATUS_SHUTDOWN Shutdown in progress. -* \param NFCSTATUS_FAILED Request failed. -* -*/ -NFCSTATUS phLibNfc_RemoteDev_CheckPresence( phLibNfc_Handle hRemoteDevice, - pphLibNfc_RspCb_t pPresenceChk_RspCb, - void* pContext - ); - -/** -* \ingroup grp_lib_nfc -*\brief Allows to check connected tag is NDEF compliant or not. -* This function allows to validate connected tag is NDEF compliant or not. -* -*\param[in] hRemoteDevice handle of the remote device.This handle to be -* same as as handle obtained for specific remote device -* during device discovery. -*\param[in] pCheckNdef_RspCb Response callback defined by the caller. -*\param[in] pContext Client context which will be included in -* callback when the request is completed. -* -* \retval NFCSTATUS_PENDING The action has been successfully triggered. -* \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function -* is invalid. -* \retval NFCSTATUS_TARGET_LOST Indicates target is lost -* \retval NFCSTATUS_TARGET_NOT_CONNECTED The Remote Device is not connected. -* \retval NFCSTATUS_INVALID_HANDLE Target handle is invalid -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Request failed. -* -* -*\msc -*LibNfcClient,LibNfc; -*LibNfcClient=>LibNfc [label="phLibNfc_Mgt_Initialize()",URL="\ref phLibNfc_Mgt_Initialize"]; -*LibNfcClient<-LibNfc [label="pInitCb()",URL="\ref pphLibNfc_RspCb_t()"]; -*LibNfcClient=>LibNfc [label="phLibNfc_RemoteDev_NtfRegister()",URL="\ref phLibNfc_RemoteDev_NtfRegister"]; -*LibNfcClient<LibNfc [label="phLibNfc_Mgt_configureDiscovery()",URL="\ref phLibNfc_Mgt_ConfigureDiscovery"]; -*LibNfcClient<-LibNfc [label="pConfigDiscovery_RspCb",URL="\ref pphLibNfc_RspCb_t"]; -*--- [label="Now Present NDEF complaint Tag Type"]; -*LibNfcClient<-LibNfc [label="pNotificationHandler",URL="\ref phLibNfc_NtfRegister_RspCb_t"]; -*LibNfcClient=>LibNfc [label="phLibNfc_RemoteDev_Connect()",URL="\ref phLibNfc_RemoteDev_Connect"]; -*LibNfcClient<-LibNfc [label="pNotifyConnect_RspCb",URL="\ref pphLibNfc_RspCb_t"]; -*LibNfcClient=>LibNfc [label="phLibNfc_Ndef_CheckNdef()",URL="\ref phLibNfc_Ndef_CheckNdef "]; -*LibNfcClient<-LibNfc [label="pCheckNdef_RspCb",URL="\ref pphLibNfc_RspCb_t"]; -* -*\endmsc -* -*\note Response callback parameters details for this interface are as listed below. -* -* \param[in] pContext LibNfc client context passed in the corresponding request before. -* \param[in] status Status of the response callback. -* -* \param NFCSTATUS_SUCCESS Successful and tag is NDEF compliant . -* \param NFCSTATUS_TARGET_LOST NDEF check operation is failed because of target is ** lost. -* \param NFCSTATUS_SHUTDOWN Shutdown in progress. -* \param NFCSTATUS_ABORTED Aborted due to disconnect operation in between. -* \param NFCSTATUS_FAILED Request failed. -*/ - -NFCSTATUS phLibNfc_Ndef_CheckNdef(phLibNfc_Handle hRemoteDevice, - pphLibNfc_ChkNdefRspCb_t pCheckNdef_RspCb, - void* pContext); - -/** -* \ingroup grp_lib_nfc -* \brief Read NDEF message from a Tag. -* This function reads an NDEF message from already connected tag. -* the NDEF message is read starting after the position of the last read operation -* of the same tag during current session. -* If it's FALSE the NDEF message is read from starting of the NDEF message. -* If the call returns with NFCSTATUS_PENDING , a response callback pNdefRead_RspCb is -* called ,when the read operation is complete. -* -*\note Before issuing NDEF read operation LibNfc client should perform NDEF check operation -* using \ref phLibNfc_Ndef_CheckNdef interface. -* If the call back error code is NFCSTATUS_FAILED then the LIBNFC client has to do the -* phLibNfc_RemoteDev_CheckPresence to find , its communication error or target lost. -* -*\param[in] hRemoteDevice handle of the remote device.This handle to be -* same as as handle obtained for specific remote device -* during device discovery. -* \param[in] psRd Pointer to the read buffer info. -* \param[in] Offset Reading Offset : phLibNfc_Ndef_EBegin means from the -* beginning, phLibNfc_Ndef_ECurrent means from the -* current offset. -* \param[in] pNdefRead_RspCb Response callback defined by the caller. -* \param[in] pContext Client context which will be included in -* callback when the request is completed. -* -* \retval NFCSTATUS_SUCCESS NDEF read operation successful. -* \retval NFCSTATUS_PENDING Request accepted and started -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress -* \retval NFCSTATUS_INVALID_HANDLE Target handle is invalid -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters could not -* be properly interpreted. -* \retval NFCSTATUS_TARGET_NOT_CONNECTED The Remote Device is not connected. -* \retval NFCSTATUS_FAILED Read operation failed since tag does not contain NDEF data. -* \retval NFCSTATUS_NON_NDEF_COMPLIANT Tag is not Ndef Compliant. -* \param NFCSTATUS_REJECTED Rejected due to NDEF read issued on non -* ,or Ndef check has not been performed -* before the readNDEF tag. -* -*\msc -*LibNfcClient,LibNfc; -*LibNfcClient=>LibNfc [label="phLibNfc_Mgt_Initialize()",URL="\ref phLibNfc_Mgt_Initialize"]; -*LibNfcClient<-LibNfc [label="pInitCb()",URL="\ref pphLibNfc_RspCb_t()"]; -*LibNfcClient=>LibNfc [label="phLibNfc_RemoteDev_NtfRegister()",URL="\ref phLibNfc_RemoteDev_NtfRegister"]; -*LibNfcClient<LibNfc [label="phLibNfc_Mgt_configureDiscovery()",URL="\ref phLibNfc_Mgt_ConfigureDiscovery"]; -*LibNfcClient<-LibNfc [label="pConfigDiscovery_RspCb",URL="\ref pphLibNfc_RspCb_t"]; -*--- [label="Now Present NDEF complaint Tag Type"]; -*LibNfcClient<-LibNfc [label="pNotificationHandler",URL="\ref phLibNfc_NtfRegister_RspCb_t"]; -*LibNfcClient=>LibNfc [label="phLibNfc_RemoteDev_Connect()",URL="\ref phLibNfc_RemoteDev_Connect"]; -*LibNfcClient<-LibNfc [label="pNotifyConnect_RspCb",URL="\ref pphLibNfc_RspCb_t"]; -*LibNfcClient=>LibNfc [label="phLibNfc_Ndef_CheckNdef()",URL="\ref phLibNfc_Ndef_CheckNdef "]; -*LibNfcClient<-LibNfc [label="pCheckNdef_RspCb",URL="\ref pphLibNfc_RspCb_t"]; -*LibNfcClient=>LibNfc [label="phLibNfc_Ndef_Read()",URL="\ref phLibNfc_Ndef_Read "]; -*LibNfcClient<-LibNfc [label="pNdefRead_RspCb",URL="\ref pphLibNfc_RspCb_t"]; -* -*\endmsc -* -*\note Response callback parameters details for this interface are as listed below. -* -* \param[in] pContext LibNfc client context passed in the corresponding request before. -* \param[in] status Status of the response callback. -* -* \param NFCSTATUS_SUCCESS NDEF read operation successful. -* \param NFCSTATUS_SHUTDOWN Shutdown in progress. -* \param NFCSTATUS_ABORTED Aborted due to disconnect operation in between. -* \param NFCSTATUS_FAILED Request failed. -*/ -NFCSTATUS phLibNfc_Ndef_Read(phLibNfc_Handle hRemoteDevice, - phNfc_sData_t* psRd, - phLibNfc_Ndef_EOffset_t Offset, - pphLibNfc_RspCb_t pNdefRead_RspCb, - void* pContext - ); -/** -** \ingroup grp_lib_nfc -* -* \brief Write NDEF data to NFC tag. -* -* This function allows the client to write a NDEF data to already connected NFC tag. -* Function writes a complete NDEF message to a tag. If a NDEF message already -* exists in the tag, it will be overwritten. When the transaction is complete, -* a notification callback is notified. -* -*\note Before issuing NDEF write operation LibNfc client should perform NDEF check operation -* using \ref phLibNfc_Ndef_CheckNdef interface. -* -*\param[in] hRemoteDevice handle of the remote device.This handle to be -* same as as handle obtained for specific remote device -* during device discovery. -*\param[in] psWr Ndef Buffer to write. If NdefMessageLen is set to 0 -* and pNdefMessage = NULL, the NFC library will erase -* tag internally. -*\param[in] pNdefWrite_RspCb Response callback defined by the caller. -*\param[in] pContext Client context which will be included in -* callback when the request is completed. -* -*\note If \ref phNfc_sData_t.NdefMessageLen is 0 bytes, this function will erase all -*current NDEF data present in the tag. Any non-zero length buffer size -*will attempt to write NEDF data onto the tag. -* If the call back error code is NFCSTATUS_FAILED then the LIBNFC client has to do the -* phLibNfc_RemoteDev_CheckPresence to find , its communication error or target lost. -* -* -* \retval NFCSTATUS_PENDING Request accepted and started. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_INVALID_HANDLE Target handle is invalid. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters could not -* be properly interpreted. -* \retval NFCSTATUS_NON_NDEF_COMPLIANT Tag is not Ndef Compliant. -* \retval NFCSTATUS_TARGET_NOT_CONNECTED The Remote Device is not connected. -* \retval NFCSTATUS_REJECTED Rejected due to NDEF write issued without -* performing a CheckNdef(). -* \retval NFCSTATUS_FAILED operation failed. -* -*\msc -*LibNfcClient,LibNfc; -*LibNfcClient=>LibNfc [label="phLibNfc_Mgt_Initialize()",URL="\ref phLibNfc_Mgt_Initialize"]; -*LibNfcClient<-LibNfc [label="pInitCb()",URL="\ref pphLibNfc_RspCb_t()"]; -*LibNfcClient=>LibNfc [label="phLibNfc_RemoteDev_NtfRegister()",URL="\ref phLibNfc_RemoteDev_NtfRegister"]; -*LibNfcClient<LibNfc [label="phLibNfc_Mgt_configureDiscovery()",URL="\ref phLibNfc_Mgt_ConfigureDiscovery"]; -*LibNfcClient<-LibNfc [label="pConfigDiscovery_RspCb",URL="\ref pphLibNfc_RspCb_t"]; -*--- [label="Now Present NDEF Tag "]; -*LibNfcClient<-LibNfc [label="pNotificationHandler",URL="\ref phLibNfc_NtfRegister_RspCb_t"]; -*LibNfcClient=>LibNfc [label="phLibNfc_RemoteDev_Connect()",URL="\ref phLibNfc_RemoteDev_Connect"]; -*LibNfcClient<-LibNfc [label="pNotifyConnect_RspCb",URL="\ref pphLibNfc_RspCb_t"]; -*LibNfcClient=>LibNfc [label="phLibNfc_Ndef_CheckNdef()",URL="\ref phLibNfc_Ndef_CheckNdef "]; -*LibNfcClient<-LibNfc [label="pCheckNdef_RspCb",URL="\ref pphLibNfc_RspCb_t"]; -*LibNfcClient=>LibNfc [label="phLibNfc_Ndef_Write()",URL="\ref phLibNfc_Ndef_Write "]; -*LibNfcClient<-LibNfc [label="pNdefWrite_RspCb",URL="\ref pphLibNfc_RspCb_t"]; -* -*\endmsc -* -*\note Response callback parameters details for this interface are as listed below. -* -* \param[in] pContext LibNfc client context passed in the corresponding request before. -* \param[in] status Status of the response callback. -* -* \param NFCSTATUS_SUCCESS NDEF write operation is successful. -* \param NFCSTATUS_SHUTDOWN Shutdown in progress. -* \param NFCSTATUS_ABORTED, Aborted due to disconnect operation in between. -* \param NFCSTATUS_NOT_ENOUGH_MEMORY Requested no of bytes to be writen exceeds size of the memory available on the tag. -* \param NFCSTATUS_FAILED Request failed. -*/ - -NFCSTATUS phLibNfc_Ndef_Write (phLibNfc_Handle hRemoteDevice, - phNfc_sData_t* psWr, - pphLibNfc_RspCb_t pNdefWrite_RspCb, - void* pContext - ); - - - -/** -* \ingroup grp_lib_nfc -* -* \brief Format target. -* -* This function allows the LibNfc client to perform NDEF formating operation on discovered target. -This function formats given target -* -*\note -*
1. Prior to formating it is recommended to perform NDEF check using \ref phLibNfc_Ndef_CheckNdef interface. -*
2. formatting feature supported only for MIFARE Std,MIFARE UL and Desfire tag types. -* If the call back error code is NFCSTATUS_FAILED then the LIBNFC client has to do the -* phLibNfc_RemoteDev_CheckPresence to find , its communication error or target lost. -* -*\param[in] hRemoteDevice handle of the remote device.This handle to be -* same as as handle obtained for specific remote device -* during device discovery. -*\param[in] pScrtKey info containing the secret key data -* and Secret key buffer length. -* -*\param[in] pNdefformat_RspCb Response callback defined by the caller. -*\param[in] pContext Client context which will be included in -* callback when the request is completed. -* -* -* \retval NFCSTATUS_PENDING Request accepted and started. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_INVALID_HANDLE Target handle is invalid. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters could not -* be properly interpreted. -* \retval NFCSTATUS_TARGET_NOT_CONNECTED The Remote Device is not connected. -* \retval NFCSTATUS_FAILED operation failed. -* \retval NFCSTATUS_REJECTED Tag is already formatted one. -* -*\msc -*LibNfcClient,LibNfc; -*LibNfcClient=>LibNfc [label="phLibNfc_Mgt_Initialize()",URL="\ref phLibNfc_Mgt_Initialize"]; -*LibNfcClient<-LibNfc [label="pInitCb()",URL="\ref pphLibNfc_RspCb_t()"]; -*LibNfcClient=>LibNfc [label="phLibNfc_RemoteDev_NtfRegister()",URL="\ref phLibNfc_RemoteDev_NtfRegister"]; -*LibNfcClient<LibNfc [label="phLibNfc_Mgt_configureDiscovery()",URL="\ref phLibNfc_Mgt_ConfigureDiscovery"]; -*LibNfcClient<-LibNfc [label="pConfigDiscovery_RspCb",URL="\ref pphLibNfc_RspCb_t"]; -*--- [label="Now Present non NDEF Tag "]; -*LibNfcClient<-LibNfc [label="pNotificationHandler",URL="\ref phLibNfc_NtfRegister_RspCb_t"]; -*LibNfcClient=>LibNfc [label="phLibNfc_RemoteDev_Connect()",URL="\ref phLibNfc_RemoteDev_Connect"]; -*LibNfcClient<-LibNfc [label="pNotifyConnect_RspCb",URL="\ref pphLibNfc_RspCb_t"]; -*LibNfcClient=>LibNfc [label="phLibNfc_Ndef_CheckNdef()",URL="\ref phLibNfc_Ndef_CheckNdef "]; -*LibNfcClient<-LibNfc [label="pCheckNdef_RspCb",URL="\ref pphLibNfc_RspCb_t"]; -*--- [label="Tag found to be non NDEF compliant ,now format it"]; -*LibNfcClient=>LibNfc [label="phLibNfc_RemoteDev_FormatNdef()",URL="\ref phLibNfc_RemoteDev_FormatNdef "]; -*LibNfcClient<-LibNfc [label="pNdefformat_RspCb",URL="\ref pphLibNfc_RspCb_t"]; -* -*\endmsc -* -*\note Response callback parameters details for this interface are as listed below. -* -* \param[in] pContext LibNfc client context passed in the corresponding request before. -* \param[in] status Status of the response callback. -* -* \param NFCSTATUS_SUCCESS NDEF formatting operation is successful. -* \param NFCSTATUS_SHUTDOWN Shutdown in progress. -* \param NFCSTATUS_ABORTED, Aborted due to disconnect operation in between. -* \param NFCSTATUS_FAILED Request failed. -*/ - -NFCSTATUS phLibNfc_RemoteDev_FormatNdef(phLibNfc_Handle hRemoteDevice, - phNfc_sData_t* pScrtKey, - pphLibNfc_RspCb_t pNdefformat_RspCb, - void* pContext - ); - -#ifdef LIBNFC_READONLY_NDEF -/** -* \ingroup grp_lib_nfc -* -* \brief To convert a already formatted NDEF READ WRITE tag to READ ONLY. -* -* This function allows the LibNfc client to convert a already formatted NDEF READ WRITE -* tag to READ ONLY on discovered target. -* -*\note -*
1. Prior to formating it is recommended to perform NDEF check using \ref phLibNfc_Ndef_CheckNdef interface. -*
2. READ ONLY feature supported only for MIFARE UL and Desfire tag types. -* If the call back error code is NFCSTATUS_FAILED then the LIBNFC client has to do the -* phLibNfc_RemoteDev_CheckPresence to find, its communication error or target lost. -* -*\param[in] hRemoteDevice handle of the remote device.This handle to be -* same as as handle obtained for specific remote device -* during device discovery. -*\param[in] pScrtKey Key to be used for making Mifare read only. This parameter is -* unused in case of readonly for other cards. -*\param[in] pNdefReadOnly_RspCb Response callback defined by the caller. -*\param[in] pContext Client context which will be included in -* callback when the request is completed. -* -* -* \retval NFCSTATUS_PENDING Request accepted and started. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_INVALID_HANDLE Target handle is invalid. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters could not -* be properly interpreted. -* \retval NFCSTATUS_TARGET_NOT_CONNECTED The Remote Device is not connected. -* \retval NFCSTATUS_FAILED operation failed. -* \retval NFCSTATUS_REJECTED Tag is already formatted one. -* -*\msc -*LibNfcClient,LibNfc; -*LibNfcClient=>LibNfc [label="phLibNfc_Mgt_Initialize()",URL="\ref phLibNfc_Mgt_Initialize"]; -*LibNfcClient<-LibNfc [label="pInitCb()",URL="\ref pphLibNfc_RspCb_t()"]; -*LibNfcClient=>LibNfc [label="phLibNfc_RemoteDev_NtfRegister()",URL="\ref phLibNfc_RemoteDev_NtfRegister"]; -*LibNfcClient<LibNfc [label="phLibNfc_Mgt_configureDiscovery()",URL="\ref phLibNfc_Mgt_ConfigureDiscovery"]; -*LibNfcClient<-LibNfc [label="pConfigDiscovery_RspCb",URL="\ref pphLibNfc_RspCb_t"]; -*--- [label="Now Present NDEF Tag "]; -*LibNfcClient<-LibNfc [label="pNotificationHandler",URL="\ref phLibNfc_NtfRegister_RspCb_t"]; -*LibNfcClient=>LibNfc [label="phLibNfc_RemoteDev_Connect()",URL="\ref phLibNfc_RemoteDev_Connect"]; -*LibNfcClient<-LibNfc [label="pNotifyConnect_RspCb",URL="\ref pphLibNfc_RspCb_t"]; -*LibNfcClient=>LibNfc [label="phLibNfc_Ndef_CheckNdef()",URL="\ref phLibNfc_Ndef_CheckNdef "]; -*LibNfcClient<-LibNfc [label="pCheckNdef_RspCb",URL="\ref pphLibNfc_RspCb_t"]; -*--- [label="Tag found to be NDEF compliant ,now convert the tag to read only"]; -*LibNfcClient=>LibNfc [label="phLibNfc_ConvertToReadOnlyNdef()",URL="\ref phLibNfc_ConvertToReadOnlyNdef "]; -*LibNfcClient<-LibNfc [label="pNdefReadOnly_RspCb",URL="\ref pphLibNfc_RspCb_t"]; -* -*\endmsc -* -*\note Response callback parameters details for this interface are as listed below. -* -* \param[in] pContext LibNfc client context passed in the corresponding request before. -* \param[in] status Status of the response callback. -* -* \param NFCSTATUS_SUCCESS Converting the tag to READ ONLY NDEF is successful. -* \param NFCSTATUS_SHUTDOWN Shutdown in progress. -* \param NFCSTATUS_ABORTED, Aborted due to disconnect operation in between. -* \param NFCSTATUS_FAILED Request failed. -*/ - -NFCSTATUS phLibNfc_ConvertToReadOnlyNdef (phLibNfc_Handle hRemoteDevice, - phNfc_sData_t* pScrtKey, - pphLibNfc_RspCb_t pNdefReadOnly_RspCb, - void* pContext - ); -#endif /* #ifdef LIBNFC_READONLY_NDEF */ - -/** -* \ingroup grp_lib_nfc -* \brief Search for NDEF Record type. -* -* This function allows LibNfc client to search NDEF content based on TNF value and type \n -* -*This API allows to find NDEF records based on RTD (Record Type Descriptor) info. -*LibNfc internally parses NDEF content based registration type registered. -*In case there is match LibNfc notifies LibNfc client with NDEF information details. -*LibNfc client can search a new NDEF registration type once the previous call is handled. -* -*\param[in] hRemoteDevice Handle of the remote device.This handle to be -* same as as handle obtained for specific remote device -* during device discovery. -*\param[in] psSrchTypeList List of NDEF records to be looked in based on TNF value and type. -* For NDEF search type refer to \ref phLibNfc_Ndef_SrchType. -* If this set to NULL then it means that libNfc client interested in -* all possible NDEF records. -* -*\param[in] uNoSrchRecords Indicates no of NDEF records in requested list as mentioned -* in psSrchTypeList. -*\param[in] pNdefNtfRspCb Response callback defined by the caller. -*\param[in] pContext Client context which will be included in -* callback when callback is notified. -* -* -* \retval NFCSTATUS_SUCCESS Indicates NDEF notification registration successful. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_INVALID_HANDLE Target handle is invalid. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters could not -* be properly interpreted. -* \retval NFCSTATUS_TARGET_NOT_CONNECTED The Remote Device is not connected. -* \retval NFCSTATUS_FAILED operation failed. -* \retval NFCSTATUS_BUSY Previous request in progress can not accept new request. -* -* \retval NFCSTATUS_ABORTED Aborted due to disconnect request in between. -*\msc -*LibNfcClient,LibNfc; -*LibNfcClient=>LibNfc [label="phLibNfc_Mgt_Initialize()",URL="\ref phLibNfc_Mgt_Initialize"]; -*LibNfcClient<-LibNfc [label="pInitCb()",URL="\ref pphLibNfc_RspCb_t()"]; -*LibNfcClient=>LibNfc [label="phLibNfc_RemoteDev_NtfRegister()",URL="\ref phLibNfc_RemoteDev_NtfRegister"]; -*LibNfcClient<LibNfc [label="phLibNfc_Mgt_configureDiscovery()",URL="\ref phLibNfc_Mgt_ConfigureDiscovery"]; -*LibNfcClient<-LibNfc [label="pConfigDiscovery_RspCb",URL="\ref pphLibNfc_RspCb_t"]; -*--- [label="Now Present NDEF Tag "]; -*LibNfcClient<-LibNfc [label="pNotificationHandler",URL="\ref phLibNfc_NtfRegister_RspCb_t"]; -*LibNfcClient=>LibNfc [label="phLibNfc_RemoteDev_Connect()",URL="\ref phLibNfc_RemoteDev_Connect"]; -*LibNfcClient<-LibNfc [label="pNotifyConnect_RspCb",URL="\ref pphLibNfc_RspCb_t"]; -*LibNfcClient=>LibNfc [label="phLibNfc_Ndef_CheckNdef()",URL="\ref phLibNfc_Ndef_CheckNdef "]; -*LibNfcClient<-LibNfc [label="pCheckNdef_RspCb",URL="\ref pphLibNfc_RspCb_t"]; -*LibNfcClient=>LibNfc [label="phLibNfc_Ndef_SearchNdefContent()",URL="\ref phLibNfc_Ndef_SearchNdefContent"]; -*LibNfcClient<-LibNfc [label="pNdefNtfRspCb",URL="\ref pphLibNfc_Ndef_Search_RspCb_t()"]; -*\endmsc -* -*\note Response callback parameters details for this interface are as listed below. -* -* \param[in] pContext LibNfc client context passed in the corresponding request before. -* \param[in] status Status of the response callback. -* -*/ -NFCSTATUS phLibNfc_Ndef_SearchNdefContent( - phLibNfc_Handle hRemoteDevice, - phLibNfc_Ndef_SrchType_t* psSrchTypeList, - uint8_t uNoSrchRecords, - pphLibNfc_Ndef_Search_RspCb_t pNdefNtfRspCb, - void * pContext - ); - - - - -/** -* \ingroup grp_lib_nfc -* \brief Interface used to receive data from initiator at target side during P2P communication. -* -*This function Allows the NFC-IP1 target to retrieve data/commands coming from the -*Initiator.Once this function is called by LibNfc client on target side it waits for -*receiving data from initiator.It is used by libNfc client which acts as target during P2P -*communication. -* -*\note : Once this API is called,its mandatory to wait for receive -*\ref pphLibNfc_Receive_RspCb_t callback notification,before calling any other -*API.Only function allowed is \ref phLibNfc_Mgt_DeInitialize. -* -* \param[in] hRemoteDevice Peer handle obtained during device discovery process. -* -* \param[in] pReceiveRspCb Callback function called after receiving -* the data or in case an error has -* has occurred. -* -* \param[in] pContext Upper layer context to be returned -* in the callback. -* -* \retval NFCSTATUS_PENDING Receive operation is in progress. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_INVALID_DEVICE The device has been disconnected meanwhile. -* \retval NFCSTATUS_DESELECTED Receive operation is not possible due to -* initiator issued disconnect or intiator -* physically removed from the RF field. -* -*\retval NFCSTATUS_REJECTED Indicates invalid request. -*\retval NFCSTATUS_FAILED Request failed. -* -*\msc -*P2PInitiatorClient,InitiatorLibNfc,P2PTargetLibNfc,P2PTargetClient; -*--- [label="stack is intialised and P2P notification handler registered alredy"]; -*P2PTargetClient=>P2PTargetLibNfc [label="phLibNfc_Mgt_SetP2P_ConfigParams()",URL="\ref phLibNfc_Mgt_SetP2P_ConfigParams"]; -*P2PTargetClient<InitiatorLibNfc [label="phLibNfc_Mgt_SetP2P_ConfigParams()",URL="\ref phLibNfc_Mgt_SetP2P_ConfigParams"]; -*P2PInitiatorClient<P2PTargetLibNfc [label="phLibNfc_Mgt_ConfigureDiscovery()",URL="\ref phLibNfc_Mgt_ConfigureDiscovery"]; -*P2PTargetClient<InitiatorLibNfc [label="phLibNfc_Mgt_ConfigureDiscovery()",URL="\ref phLibNfc_Mgt_ConfigureDiscovery"]; -*P2PInitiatorClient<InitiatorLibNfc [label="phLibNfc_RemoteDev_Connect()",URL="\ref phLibNfc_RemoteDev_Connect"]; -*P2PInitiatorClient<P2PTargetLibNfc [label="phLibNfc_RemoteDev_Receive()",URL="\ref phLibNfc_RemoteDev_Receive"]; -*--- [label="Now target waits to receive data from intiator"]; -*--- [label="Send data from initiator now"]; -*P2PInitiatorClient=>InitiatorLibNfc [label="phLibNfc_RemoteDev_Transceive()",URL="\ref phLibNfc_RemoteDev_Transceive "]; -*P2PInitiatorClient<-InitiatorLibNfc [label="pTransceive_RspCb",URL="\ref pphLibNfc_TransceiveCallback_t"]; -*--- [label="Now data arrived at target side"]; -*P2PTargetClient<-P2PTargetLibNfc [label="pReceiveRspCb",URL="\ref pphLibNfc_Receive_RspCb_t"]; -\endmsc -*\note Response callback parameters details for this interface are as listed below. -* -* \param[in] pContext LibNfc client context passed in the corresponding request before. -* \param[in] status Status of the response callback. -* -* \param NFCSTATUS_SUCCESS Receive operation successful. -* \param NFCSTATUS_SHUTDOWN Receive operation failed because Shutdown in progress. -* \param NFCSTATUS_ABORTED Aborted due to initiator issued disconnect request. -* or intiator removed physically from the RF field. -* This status code reported,to indicate P2P session -* closed and send and receive requests not allowed -* any more unless new session is started. -* \param NFCSTATUS_DESELECTED Receive operation is not possible due to -* initiator issued disconnect or intiator -* physically removed from the RF field. -*/ -extern -NFCSTATUS -phLibNfc_RemoteDev_Receive( phLibNfc_Handle hRemoteDevice, - pphLibNfc_Receive_RspCb_t pReceiveRspCb, - void* pContext - ); - - - - - -/** -* \ingroup grp_lib_nfc -* \brief Interface used to send data from target to initiator during P2P communication. -* -*This function Allows the NFC-IP1 target to send data to Initiator,in response to packet received -*from initiator during P2P communication.It is must prior to send request target has received -*data from initiator using \ref phLibNfc_RemoteDev_Receive interface. -* -* -* \param[in] hRemoteDevice Peer handle obtained during device discovery process. -* -* \param[in] pTransferData Data and the length of the data to be -* transferred. -* \param[in] pSendRspCb Callback function called on completion -* of the NfcIP sequence or in case an -* error has occurred. -* -* \param[in] pContext Upper layer context to be returned in -* the callback. -* -** \retval NFCSTATUS_PENDING Send operation is in progress. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_INVALID_DEVICE The device has been disconnected meanwhile. -* \retval NFCSTATUS_BUSY Previous request in progress can not accept new request. -* \retval NFCSTATUS_DESELECTED Receive operation is not possible due to -* initiator issued disconnect or intiator -* physically removed from the RF field. -*\retval NFCSTATUS_REJECTED Indicates invalid request. -*\retval NFCSTATUS_FAILED Request failed. -* -*\msc -*P2PInitiatorClient,InitiatorLibNfc,P2PTargetLibNfc,P2PTargetClient; -*--- [label="stack is intialised and P2P notification handler registered alredy"]; -*P2PTargetClient=>P2PTargetLibNfc [label="phLibNfc_Mgt_SetP2P_ConfigParams()",URL="\ref phLibNfc_Mgt_SetP2P_ConfigParams"]; -*P2PTargetClient<InitiatorLibNfc [label="phLibNfc_Mgt_SetP2P_ConfigParams()",URL="\ref phLibNfc_Mgt_SetP2P_ConfigParams"]; -*P2PInitiatorClient<P2PTargetLibNfc [label="phLibNfc_Mgt_ConfigureDiscovery()",URL="\ref phLibNfc_Mgt_ConfigureDiscovery"]; -*P2PTargetClient<InitiatorLibNfc [label="phLibNfc_Mgt_ConfigureDiscovery()",URL="\ref phLibNfc_Mgt_ConfigureDiscovery"]; -*P2PInitiatorClient<InitiatorLibNfc [label="phLibNfc_RemoteDev_Connect()",URL="\ref phLibNfc_RemoteDev_Connect"]; -*P2PInitiatorClient<P2PTargetLibNfc [label="phLibNfc_RemoteDev_Receive()",URL="\ref phLibNfc_RemoteDev_Receive"]; -*--- [label="Now target waits to receive data from intiator"]; -*--- [label="Send data from initiator now"]; -*P2PInitiatorClient=>InitiatorLibNfc [label="phLibNfc_RemoteDev_Transceive()",URL="\ref phLibNfc_RemoteDev_Transceive "]; -*--- [label="Now data arrived at target side"]; -*P2PTargetClient<-P2PTargetLibNfc [label="pReceiveRspCb",URL="\ref pphLibNfc_Receive_RspCb_t"]; -*--- [label="Now send data from target"]; -*P2PTargetClient=>P2PTargetLibNfc [label="phLibNfc_RemoteDev_Send()",URL="\ref phLibNfc_RemoteDev_Send"]; -*P2PInitiatorClient<-InitiatorLibNfc [label="pTransceive_RspCb",URL="\ref pphLibNfc_TransceiveCallback_t"]; -*P2PTargetClient<-P2PTargetLibNfc [label="pSendRspCb",URL="\ref pphLibNfc_RspCb_t"]; -*\endmsc -* -*\note Response callback parameters details for this interface are as listed below. -* -* \param[in] pContext LibNfc client context passed in the corresponding request before. -* \param[in] status Status of the response callback. -* -* \param NFCSTATUS_SUCCESS Send operation successful. -* \param NFCSTATUS_SHUTDOWN Send operation failed because Shutdown in progress. -* \param NFCSTATUS_ABORTED Aborted due to initiator issued disconnect request. -* or intiator removed physically from the RF field. -* This status code reported,to indicate P2P session -* closed and send and receive requests not allowed -* any more unless new session is started. -* \param NFCSTATUS_DESELECTED Receive operation is not possible due to -* initiator issued disconnect or intiator -* physically removed from the RF field. -* -* -*/ -extern -NFCSTATUS -phLibNfc_RemoteDev_Send(phLibNfc_Handle hRemoteDevice, - phNfc_sData_t* pTransferData, - pphLibNfc_RspCb_t pSendRspCb, - void* pContext - ); - -/** -* \ingroup grp_lib_nfc -* \brief Interface to configure P2P and intiator mode configurations. -* The setting will be typically take effect for the next cycle of the relevant -* phase of discovery. For optional configuration internal defaults will be -* used in case the configuration is not set. -* -*\note Currently general bytes configuration supported. -* -* \param[in] pConfigInfo Union containing P2P configuration details as -* in \ref phLibNfc_sNfcIPCfg_t. -* -* \param[in] pConfigRspCb This callback has to be called once LibNfc -* completes the Configuration. -* -* \param[in] pContext Upper layer context to be returned in -* the callback. -* -* -* \retval NFCSTATUS_PENDING Config operation is in progress. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_BUSY Previous request in progress can not accept new request. -* -*\msc -*P2PInitiatorClient,InitiatorLibNfc,P2PTargetLibNfc,P2PTargetClient; -*--- [label="stack is intialised and P2P notification handler registered alredy"]; -*P2PTargetClient=>P2PTargetLibNfc [label="phLibNfc_Mgt_SetP2P_ConfigParams()",URL="\ref phLibNfc_Mgt_SetP2P_ConfigParams"]; -*P2PTargetClient<InitiatorLibNfc [label="phLibNfc_Mgt_SetP2P_ConfigParams()",URL="\ref phLibNfc_Mgt_SetP2P_ConfigParams"]; -*P2PInitiatorClient<P2PTargetLibNfc [label="phLibNfc_Mgt_ConfigureDiscovery()",URL="\ref phLibNfc_Mgt_ConfigureDiscovery"]; -*P2PTargetClient<InitiatorLibNfc [label="phLibNfc_Mgt_ConfigureDiscovery()",URL="\ref phLibNfc_Mgt_ConfigureDiscovery"]; -*P2PInitiatorClient<InitiatorLibNfc [label="phLibNfc_RemoteDev_Connect()",URL="\ref phLibNfc_RemoteDev_Connect"]; -*P2PInitiatorClient<Interface to stack capabilities. -* -* LibNfc client can query to retrieve stack capabilities.Stack capabilities contains -*

a).Device capabilities which contains details like protocols supported, -* Hardware,Firmware and model-id version details .For details refer to \ref phNfc_sDeviceCapabilities_t. -*

b).NDEF mapping related info. This info helps in identifying supported tags for NDEF mapping feature. -*

c).NDEF formatting related info. This info helps in identifying supported tags for NDEF formatting feature. -* -* \param[in] phLibNfc_StackCapabilities Contains device capabilities and NDEF mapping and formatting feature - support for different tag types. -* -* \param[in] pContext Upper layer context to be returned in -* the callback. -* -* -* \retval NFCSTATUS_SUCCESS Indicates Get stack Capabilities operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED operation failed. -* \retval NFCSTATUS_BUSY Previous request in progress can not accept new request. -* -* -*\msc -*LibNfcClient,LibNfc; -*LibNfcClient=>LibNfc [label="phLibNfc_Mgt_Initialize()",URL="\ref phLibNfc_Mgt_Initialize"]; -*LibNfcClient<-LibNfc [label="pInitCb()",URL="\ref pphLibNfc_RspCb_t()"]; -*LibNfcClient=>LibNfc [label="phLibNfc_RemoteDev_NtfRegister()",URL="\ref phLibNfc_RemoteDev_NtfRegister"]; -*LibNfcClient<LibNfc [label="phLibNfc_Mgt_GetstackCapabilities()",URL="\ref phLibNfc_Mgt_GetstackCapabilities"]; -*LibNfcClient<Interface to configure local LLCP peer. -* -* This function configures the parameters of the local LLCP peer. This function must be called -* before any other LLCP-related function from this API. -* -* \param[in] pConfigInfo Contains local LLCP link parameters to be applied -* \param[in] pConfigRspCb This callback has to be called once LibNfc -* completes the Configuration. -* \param[in] pContext Upper layer context to be returned in -* the callback. -* -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_PENDING Configuration operation is in progress, - pConfigRspCb will be called upon completion. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Operation failed. -* \retval NFCSTATUS_BUSY Previous request in progress can not accept new request. -*/ -extern NFCSTATUS phLibNfc_Mgt_SetLlcp_ConfigParams( phLibNfc_Llcp_sLinkParameters_t* pConfigInfo, - pphLibNfc_RspCb_t pConfigRspCb, - void* pContext - ); - - -/** -* \ingroup grp_lib_nfc -* \brief Checks if a remote peer is LLCP compliant. -* -* This functions allows to check if a previously detected tag is compliant with the -* LLCP protocol. This step is needed before calling any other LLCP-related function on -* this remote peer, except local LLCP peer configurationn, which is more general. Once -* this checking is done, the caller will be able to receive link status notifications -* until the peer is disconnected. -* -* \param[in] hRemoteDevice Peer handle obtained during device discovery process. -* \param[in] pCheckLlcp_RspCb The callback to be called once LibNfc -* completes the LLCP compliancy check. -* \param[in] pLink_Cb The callback to be called each time the -* LLCP link status changes. -* \param[in] pContext Upper layer context to be returned in -* the callbacks. -* -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_PENDING Check operation is in progress, pCheckLlcp_RspCb will -* be called upon completion. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Operation failed. -* \retval NFCSTATUS_BUSY Previous request in progress can not accept new request. -*/ -extern NFCSTATUS phLibNfc_Llcp_CheckLlcp( phLibNfc_Handle hRemoteDevice, - pphLibNfc_ChkLlcpRspCb_t pCheckLlcp_RspCb, - pphLibNfc_LlcpLinkStatusCb_t pLink_Cb, - void* pContext - ); - - -/** -* \ingroup grp_lib_nfc -* \brief Activates a LLCP link with a remote device . -* -* This function launches the link activation process on a remote LLCP-compliant peer. The link status -* notification will be sent by the corresponding callback given in the phLibNfc_Llcp_CheckLlcp function. -* If the activation fails, the deactivated status will be notified, even if the link is already in a -* deactivated state. -* -* \param[in] hRemoteDevice Peer handle obtained during device discovery process. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_PENDING Activation operation is in progress, - pLink_Cb will be called upon completion. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Operation failed. -* \retval NFCSTATUS_BUSY Previous request in progress can not accept new request. -*/ -extern NFCSTATUS phLibNfc_Llcp_Activate( phLibNfc_Handle hRemoteDevice ); - - -/** -* \ingroup grp_lib_nfc -* \brief Deactivate a previously activated LLCP link with a remote device. -* -* This function launches the link deactivation process on a remote LLCP-compliant peer. The link status -* notification will be sent by the corresponding callback given in the phLibNfc_Llcp_CheckLlcp function. -* -* \param[in] hRemoteDevice Peer handle obtained during device discovery process. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_PENDING Deactivation operation is in progress, - pLink_Cb will be called upon completion. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Operation failed. -* \retval NFCSTATUS_BUSY Previous request in progress can not accept new request. -*/ -extern NFCSTATUS phLibNfc_Llcp_Deactivate( phLibNfc_Handle hRemoteDevice ); - - -/** -* \ingroup grp_lib_nfc -* \brief Get information on the local LLCP peer. -* -* This function returns the LLCP link parameters of the local peer that were used -* during the link activation. -* -* \param[in] hRemoteDevice Peer handle obtained during device discovery process. -* \param[out] pConfigInfo Pointer on the variable to be filled with the configuration - parameters used during activation. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Operation failed. -* \retval NFCSTATUS_BUSY Previous request in progress can not accept new request. -*/ -extern NFCSTATUS phLibNfc_Llcp_GetLocalInfo( phLibNfc_Handle hRemoteDevice, - phLibNfc_Llcp_sLinkParameters_t* pConfigInfo - ); - - -/** -* \ingroup grp_lib_nfc -* \brief Get information on the remote LLCP peer. -* -* This function returns the LLCP link parameters of the remote peer that were received -* during the link activation. -* -* \param[in] hRemoteDevice Peer handle obtained during device discovery process. -* \param[out] pConfigInfo Pointer on the variable to be filled with the configuration - parameters used during activation. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Operation failed. -* \retval NFCSTATUS_BUSY Previous request in progress can not accept new request. -*/ -extern NFCSTATUS phLibNfc_Llcp_GetRemoteInfo( phLibNfc_Handle hRemoteDevice, - phLibNfc_Llcp_sLinkParameters_t* pConfigInfo - ); - - -/** -* \ingroup grp_lib_nfc -* \brief Create a socket on a LLCP-connected device. -* -* This function creates a socket for a given LLCP link. Sockets can be of two types : -* connection-oriented and connectionless. If the socket is connection-oriented, the caller -* must provide a working buffer to the socket in order to handle incoming data. This buffer -* must be large enough to fit the receive window (RW * MIU), the remaining space being -* used as a linear buffer to store incoming data as a stream. Data will be readable later -* using the phLibNfc_Llcp_Recv function. If the socket is connectionless, the caller may -* provide a working buffer to the socket in order to bufferize as many packets as the buffer -* can contain (each packet needs MIU + 1 bytes). -* The options and working buffer are not required if the socket is used as a listening socket, -* since it cannot be directly used for communication. -* -* \param[in] eType The socket type. -* \param[in] psOptions The options to be used with the socket. -* \param[in] psWorkingBuffer A working buffer to be used by the library. -* \param[out] phSocket A pointer on the variable to be filled with the handle -* on the created socket. -* \param[in] pErr_Cb The callback to be called each time the socket -* is in error. -* \param[in] pContext Upper layer context to be returned in the callback. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_BUFFER_TOO_SMALL The working buffer is too small for the MIU and RW -* declared in the options. -* \retval NFCSTATUS_INSUFFICIENT_RESOURCES No more socket handle available. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -extern NFCSTATUS phLibNfc_Llcp_Socket( phLibNfc_Llcp_eSocketType_t eType, - phLibNfc_Llcp_sSocketOptions_t* psOptions, - phNfc_sData_t* psWorkingBuffer, - phLibNfc_Handle* phSocket, - pphLibNfc_LlcpSocketErrCb_t pErr_Cb, - void* pContext - ); - - -/** -* \ingroup grp_lib_nfc -* \brief Get SAP of remote services using their names. -* -* This function sends SDP queries to the remote peer to get the SAP to address for a given -* service name. The queries are aggregated as much as possible for efficiency, but if all -* the queries cannot fit in a single packet, they will be splitted in multiple packets. -* The callback will be called only when all of the requested services names SAP will be -* gathered. As mentionned in LLCP specification, a SAP of 0 means that the service name -* as not been found. -* -* This feature is available only since LLCP v1.1, both devices must be at least v1.1 in -* order to be able to use this function. -* -* \param[in] hRemoteDevice Peer handle obtained during device discovery process. -* \param[in] psServiceNameList The list of the service names to discover. -* \param[out] pnSapList The list of the corresponding SAP numbers, in the same -* order than the service names list. -* \param[in] nListSize The size of both service names and SAP list. -* \param[in] pDiscover_Cb The callback to be called once LibNfc matched SAP for -* all of the provided service names. -* \param[in] pContext Upper layer context to be returned in the callback. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Operation failed. -* \retval NFCSTATUS_FEATURE_NOT_SUPPORTED Remote peer does not support this feature (e.g.: is v1.0). -* \retval NFCSTATUS_BUSY Previous request in progress can not accept new request. -*/ -extern NFCSTATUS phLibNfc_Llcp_DiscoverServices( phLibNfc_Handle hRemoteDevice, - phNfc_sData_t *psServiceNameList, - uint8_t *pnSapList, - uint8_t nListSize, - pphLibNfc_RspCb_t pDiscover_Cb, - void *pContext - ); - - -/** -* \ingroup grp_lib_nfc -* \brief Close a socket on a LLCP-connected device. -* -* This function closes a LLCP socket previously created using phLibNfc_Llcp_Socket. -* If the socket was connected, it is first disconnected, and then closed. -* -* \param[in] hSocket Socket handle obtained during socket creation. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -extern NFCSTATUS phLibNfc_Llcp_Close( phLibNfc_Handle hSocket ); - - -/** -* \ingroup grp_lib_nfc -* \brief Get the local options of a socket. -* -* This function returns the local options (maximum packet size and receive window size) used -* for a given connection-oriented socket. This function shall not be used with connectionless -* sockets. -* -* \param[in] hSocket Socket handle obtained during socket creation. -* \param[in] psLocalOptions A pointer to be filled with the local options of the socket. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of -* a valid type to perform the requsted operation. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -extern NFCSTATUS phLibNfc_Llcp_SocketGetLocalOptions( phLibNfc_Handle hSocket, - phLibNfc_Llcp_sSocketOptions_t* psLocalOptions - ); - - -/** -* \ingroup grp_lib_nfc -* \brief Get the local options of a socket. -* -* This function returns the remote options (maximum packet size and receive window size) used -* for a given connection-oriented socket. This function shall not be used with connectionless -* sockets. -* -* \param[in] hSocket Socket handle obtained during socket creation. -* \param[in] psRemoteOptions A pointer to be filled with the remote options of the socket. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of -* a valid type to perform the requsted operation. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -extern NFCSTATUS phLibNfc_Llcp_SocketGetRemoteOptions( phLibNfc_Handle hRemoteDevice, - phLibNfc_Handle hSocket, - phLibNfc_Llcp_sSocketOptions_t* psRemoteOptions - ); - - -/** -* \ingroup grp_lib_nfc -* \brief Bind a socket to a local SAP. -* -* This function binds the socket to a local Service Access Point. -* -* \param[in] hSocket Peer handle obtained during device discovery process. -* \param TODO (nSap + sn) - -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of -* a valid type to perform the requsted operation. -* \retval NFCSTATUS_ALREADY_REGISTERED The selected SAP is already bound to another - socket. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -extern NFCSTATUS phLibNfc_Llcp_Bind( phLibNfc_Handle hSocket, - uint8_t nSap, - phNfc_sData_t * psServiceName - ); - - -/** -* \ingroup grp_lib_nfc -* \brief Listen for incoming connection requests on a socket. -* -* This function switches a socket into a listening state and registers a callback on -* incoming connection requests. In this state, the socket is not able to communicate -* directly. The listening state is only available for connection-oriented sockets -* which are still not connected. The socket keeps listening until it is closed, and -* thus can trigger several times the pListen_Cb callback. The caller can adverise the -* service through SDP by providing a service name. -* -* -* \param[in] hSocket Socket handle obtained during socket creation. -* \param[in] pListen_Cb The callback to be called each time the -* socket receive a connection request. -* \param[in] pContext Upper layer context to be returned in -* the callback. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state to switch -* to listening state. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -extern NFCSTATUS phLibNfc_Llcp_Listen( phLibNfc_Handle hSocket, - pphLibNfc_LlcpSocketListenCb_t pListen_Cb, - void* pContext - ); - - -/** -* \ingroup grp_lib_nfc -* \brief Accept an incoming connection request for a socket. -* -* This functions allows the client to accept an incoming connection request. -* It must be used with the socket provided within the listen callback. The socket -* is implicitly switched to the connected state when the function is called. -* -* \param[in] hSocket Socket handle obtained in the listening callback. -* \param[in] psOptions The options to be used with the socket. -* \param[in] psWorkingBuffer A working buffer to be used by the library. -* \param[in] pErr_Cb The callback to be called each time the accepted socket -* is in error. -* \param[in] pAccept_RspCb The callback to be called when the Accept operation -* is completed. -* \param[in] pContext Upper layer context to be returned in the callback. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_BUFFER_TOO_SMALL The working buffer is too small for the MIU and RW -* declared in the options. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -extern NFCSTATUS phLibNfc_Llcp_Accept( phLibNfc_Handle hSocket, - phLibNfc_Llcp_sSocketOptions_t* psOptions, - phNfc_sData_t* psWorkingBuffer, - pphLibNfc_LlcpSocketErrCb_t pErr_Cb, - pphLibNfc_LlcpSocketAcceptCb_t pAccept_RspCb, - void* pContext - ); - - -/** -* \ingroup grp_lib_nfc -* \brief Reject an incoming connection request for a socket. -* -* This functions allows the client to reject an incoming connection request. -* It must be used with the socket provided within the listen callback. The socket -* is implicitly closed when the function is called. -* -* \param[in] hSocket Socket handle obtained in the listening callback. -* \param[in] pReject_RspCb The callback to be called when the Reject operation -* is completed. -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -extern NFCSTATUS phLibNfc_Llcp_Reject( phLibNfc_Handle hRemoteDevice, - phLibNfc_Handle hSocket, - pphLibNfc_LlcpSocketAcceptCb_t pReject_RspCb, - void* pContext); - - -/** -* \ingroup grp_lib_nfc -* \brief Try to establish connection with a socket on a remote SAP. -* -* This function tries to connect to a given SAP on the remote peer. If the -* socket is not bound to a local SAP, it is implicitly bound to a free SAP. -* -* \param[in] hSocket Socket handle obtained during socket creation. -* \param[in] nSap The destination SAP to connect to. -* \param[in] pConnect_RspCb The callback to be called when the connection -* operation is completed. -* \param[in] pContext Upper layer context to be returned in -* the callback. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_PENDING Connection operation is in progress, -* pConnect_RspCb will be called upon completion. -* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of -* a valid type to perform the requsted operation. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -extern NFCSTATUS phLibNfc_Llcp_Connect( phLibNfc_Handle hRemoteDevice, - phLibNfc_Handle hSocket, - uint8_t nSap, - pphLibNfc_LlcpSocketConnectCb_t pConnect_RspCb, - void* pContext - ); - - -/** -* \ingroup grp_lib_nfc -* \brief Try to establish connection with a socket on a remote service, given its URI. -* -* This function tries to connect to a SAP designated by an URI. If the -* socket is not bound to a local SAP, it is implicitly bound to a free SAP. -* -* \param[in] hSocket Socket handle obtained during socket creation. -* \param[in] psUri The URI corresponding to the destination SAP to connect to. -* \param[in] pConnect_RspCb The callback to be called when the connection -* operation is completed. -* \param[in] pContext Upper layer context to be returned in -* the callback. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_PENDING Connection operation is in progress, -* pConnect_RspCb will be called upon completion. -* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of -* a valid type to perform the requsted operation. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -extern NFCSTATUS phLibNfc_Llcp_ConnectByUri( phLibNfc_Handle hRemoteDevice, - phLibNfc_Handle hSocket, - phNfc_sData_t* psUri, - pphLibNfc_LlcpSocketConnectCb_t pConnect_RspCb, - void* pContext - ); - - -/** -* \ingroup grp_lib_nfc -* \brief Disconnect a currently connected socket. -* -* This function initiates the disconnection of a previously connected socket. -* -* \param[in] hSocket Socket handle obtained during socket creation. -* \param[in] pDisconnect_RspCb The callback to be called when the -* operation is completed. -* \param[in] pContext Upper layer context to be returned in -* the callback. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_PENDING Disconnection operation is in progress, -* pDisconnect_RspCb will be called upon completion. -* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of -* a valid type to perform the requsted operation. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -extern NFCSTATUS phLibNfc_Llcp_Disconnect( phLibNfc_Handle hRemoteDevice, - phLibNfc_Handle hSocket, - pphLibNfc_LlcpSocketDisconnectCb_t pDisconnect_RspCb, - void* pContext - ); - - -/** -* \ingroup grp_lib_nfc -* \brief Read data on a socket. -* -* This function is used to read data from a socket. It reads at most the -* size of the reception buffer, but can also return less bytes if less bytes -* are available. If no data is available, the function will be pending until -* more data comes, and the response will be sent by the callback. This function -* can only be called on a connection-oriented socket. -* -* -* \param[in] hSocket Socket handle obtained during socket creation. -* \param[in] psBuffer The buffer receiving the data. -* \param[in] pRecv_RspCb The callback to be called when the -* operation is completed. -* \param[in] pContext Upper layer context to be returned in -* the callback. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_PENDING Reception operation is in progress, -* pRecv_RspCb will be called upon completion. -* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of -* a valid type to perform the requsted operation. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -extern NFCSTATUS phLibNfc_Llcp_Recv( phLibNfc_Handle hRemoteDevice, - phLibNfc_Handle hSocket, - phNfc_sData_t* psBuffer, - pphLibNfc_LlcpSocketRecvCb_t pRecv_RspCb, - void* pContext - ); - - -/** -* \ingroup grp_lib_nfc -* \brief Read data on a socket and get the source SAP. -* -* This function is the same as phLibNfc_Llcp_Recv, except that the callback includes -* the source SAP. This functions can only be called on a connectionless socket. -* -* -* \param[in] hSocket Socket handle obtained during socket creation. -* \param[in] psBuffer The buffer receiving the data. -* \param[in] pRecv_RspCb The callback to be called when the -* operation is completed. -* \param[in] pContext Upper layer context to be returned in -* the callback. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_PENDING Reception operation is in progress, -* pRecv_RspCb will be called upon completion. -* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of -* a valid type to perform the requsted operation. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -extern NFCSTATUS phLibNfc_Llcp_RecvFrom( phLibNfc_Handle hRemoteDevice, - phLibNfc_Handle hSocket, - phNfc_sData_t* psBuffer, - pphLibNfc_LlcpSocketRecvFromCb_t pRecv_Cb, - void* pContext - ); - - -/** -* \ingroup grp_lib_nfc -* \brief Send data on a socket. -* -* This function is used to write data on a socket. This function -* can only be called on a connection-oriented socket which is already -* in a connected state. -* -* -* \param[in] hSocket Socket handle obtained during socket creation. -* \param[in] psBuffer The buffer containing the data to send. -* \param[in] pSend_RspCb The callback to be called when the -* operation is completed. -* \param[in] pContext Upper layer context to be returned in -* the callback. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_PENDING Reception operation is in progress, -* pSend_RspCb will be called upon completion. -* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of -* a valid type to perform the requsted operation. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -extern NFCSTATUS phLibNfc_Llcp_Send( phLibNfc_Handle hRemoteDevice, - phLibNfc_Handle hSocket, - phNfc_sData_t* psBuffer, - pphLibNfc_LlcpSocketSendCb_t pSend_RspCb, - void* pContext - ); - - -/** -* \ingroup grp_lib_nfc -* \brief Send data on a socket to a given destination SAP. -* -* This function is used to write data on a socket to a given destination SAP. -* This function can only be called on a connectionless socket. -* -* -* \param[in] hSocket Socket handle obtained during socket creation. -* \param[in] nSap The destination SAP. -* \param[in] psBuffer The buffer containing the data to send. -* \param[in] pSend_RspCb The callback to be called when the -* operation is completed. -* \param[in] pContext Upper layer context to be returned in -* the callback. -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_PENDING Reception operation is in progress, -* pSend_RspCb will be called upon completion. -* \retval NFCSTATUS_INVALID_STATE The socket is not in a valid state, or not of -* a valid type to perform the requsted operation. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -* \retval NFCSTATUS_FAILED Operation failed. -*/ -extern NFCSTATUS phLibNfc_Llcp_SendTo( phLibNfc_Handle hRemoteDevice, - phLibNfc_Handle hSocket, - uint8_t nSap, - phNfc_sData_t* psBuffer, - pphLibNfc_LlcpSocketSendCb_t pSend_RspCb, - void* pContext - ); - - -/** -* \ingroup grp_lib_nfc -* -* \brief Initializes \ DeInitialize the NFC library for testmode. -* -* -*\brief This function initializes / DeInitialize NFC library and its underlying layers -* in test mode. As part of this interface underlying layers gets configured. -* Once phLibNfc_TstMode_On is successful ,NFC library ready in testmode using IOCTL. -* After using test IOCTLs ,Test mode should be DeInit using phLibNfc_TstMode_Off. -*\note This API should be used only for test IOCTL codes. -* -* \param[in] pDriverHandle Driver Handle currently application is using. -* \param[in] pTestModeCb The init callback is called by the LibNfc when -* Configure test mode completed or there is an error -* in initialization. -* -* \param[in] pContext Client context which will be included in -* callback when the request is completed. -* -* \retval NFCSTATUS_ALREADY_INITIALISED Stack is already initialized. -* \retval NFCSTATUS_PENDING Init sequence has been successfully -* started and result will be conveyed via -* callback notification. -* \retval NFCSTATUS_INVALID_PARAMETER The parameter could not be properly -* interpreted. -*\retval NFCSTATUS_INSUFFICIENT_RESOURCES Insufficient resource.(Ex: insufficient memory) -* -*\msc -*LibNfcClient,LibNfc; -*--- [label="Before initializing Nfc LIB,Setup Driver layer"]; -*LibNfcClient=>LibNfc [label="phLibNfc_Mgt_ConfigureDriver()",URL="\ref phLibNfc_Mgt_ConfigureDriver"]; -*LibNfcClient<LibNfc [label="phLibNfc_Mgt_ConfigureTestMode()",URL="\ref phLibNfc_Mgt_ConfigureTestMode"]; -*LibNfcClient<Interface to LibNfc Reset. -* -* LibNfc client can reset the stack. -* -* \param[in] pContext Upper layer context to be returned in -* the callback. -* -* -* \retval NFCSTATUS_SUCCESS Indicates Get stack Capabilities operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER One or more of the supplied parameters -* could not be properly interpreted. -* \retval NFCSTATUS_NOT_INITIALISED Indicates stack is not yet initialized. -* \retval NFCSTATUS_SHUTDOWN Shutdown in progress. -*/ - -NFCSTATUS phLibNfc_Mgt_Reset(void *pContext); - -#endif /* PHLIBNFC_H */ - diff --git a/libnfc-nxp/phLibNfcStatus.h b/libnfc-nxp/phLibNfcStatus.h deleted file mode 100644 index c4deb8f..0000000 --- a/libnfc-nxp/phLibNfcStatus.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * \file phLibNfcStatus.h - * \brief NFC Status Values - Function Return Codes - * - * Project: NFC MW / HAL - * - * $Date: Thu Feb 25 19:16:41 2010 $ - * $Author: ing07385 $ - * $Revision: 1.24 $ - * $Aliases: NFC_FRI1.1_WK1008_SDK,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1007_SDK,NFC_FRI1.1_WK1014_SDK,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1019_SDK,NFC_FRI1.1_WK1024_SDK $ - * - */ -#ifndef PHLIBNFCSTATUS_H /* */ -#define PHLIBNFCSTATUS_H/* */ - -#include - -#define LLCP_CHANGES -#define LLCP_TRANSACT_CHANGES - -#ifdef LLCP_TRANSACT_CHANGES -/* These two macros are defined due to non availibity of the below macros in header files -#define PHFRINFC_LLCP_STATE_RESET_INIT 0 // \internal Initial state -#define PHFRINFC_LLCP_STATE_CHECKED 1 // \internal The tag has been checked for LLCP compliance -*/ -#define LLCP_STATE_RESET_INIT 0x00U -#define LLCP_STATE_CHECKED 0x01U - - -#endif /* #ifdef LLCP_TRANSACT_CHANGES */ -#define LIB_NFC_VERSION_SET(v,major,minor,patch,build) ((v) = \ - ( ((major) << 24) & 0xFF000000 ) | \ - ( ((minor) << 16) & 0x00FF0000 ) | \ - ( ((patch) << 8) & 0x0000FF00 ) | \ - ( (build) & 0x000000FF ) ) - -#define NFCSTATUS_SHUTDOWN (0x0091) -#define NFCSTATUS_TARGET_LOST (0x0092) -#define NFCSTATUS_REJECTED (0x0093) -#define NFCSTATUS_TARGET_NOT_CONNECTED (0x0094) -#define NFCSTATUS_INVALID_HANDLE (0x0095) -#define NFCSTATUS_ABORTED (0x0096) -#define NFCSTATUS_COMMAND_NOT_SUPPORTED (0x0097) -#define NFCSTATUS_NON_NDEF_COMPLIANT (0x0098) -#define NFCSTATUS_OK (0x0000) - -#ifndef NFCSTATUS_NOT_ENOUGH_MEMORY -#define NFCSTATUS_NOT_ENOUGH_MEMORY (0x001F) -#endif - - -#endif /* PHNFCSTATUS_H */ - - - diff --git a/libnfc-nxp/phLibNfc_Internal.h b/libnfc-nxp/phLibNfc_Internal.h deleted file mode 100644 index 368c6c9..0000000 --- a/libnfc-nxp/phLibNfc_Internal.h +++ /dev/null @@ -1,278 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! - * \file phLibNfc_Internal.h - * - * Project: NFC-FRI 1.1 - * - * $Workfile:: phLibNfc_Internal.h $ - * $Modtime:: $ - * $Author: ing07385 $ - * $Revision: 1.26 $ - * - */ -#ifndef PHLIBNFC_IN_H -#define PHLIBNFC_IN_H -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/**Maximum number of Records.Presently set to a realistic value of 128 - Configurable upto 1K*/ -#define MAX_NO_OF_RECORDS 128U -#define CHK_NDEF_NOT_DONE 0x02U - -typedef struct phLibNfc_status -{ - unsigned RlsCb_status : 1; - unsigned DiscEnbl_status : 1; - unsigned Connect_status : 1; - unsigned TransProg_status : 1; - unsigned RelsProg_status : 1; - unsigned GenCb_pending_status : 1; - unsigned Shutdown_pending_status : 1; - unsigned Discovery_pending_status : 1; - -}Status_t; -typedef enum phLibNfc_State{ - eLibNfcHalStateShutdown = 0x00, /**< closed*/ - eLibNfcHalInitInProgress, - eLibNfcHalInited, - eLibNfcHalShutdownInProgress, - eLibNfcHalStateInitandIdle, - eLibNfcHalStateConfigReady , - eLibNfcHalStateConnect, - eLibNfcHalStateTransaction, - eLibNfcHalStatePresenceChk, - eLibNfcHalStateRelease, - eLibNfcHalStateInvalid -} phLibNfc_State_t; - - - - -typedef struct phLibNfc_Hal_CB_Info -{ - /*Init call back & its context*/ - pphLibNfc_RspCb_t pClientInitCb; - void *pClientInitCntx; - /*Shutdown call back & its context*/ - pphLibNfc_RspCb_t pClientShutdownCb; - void *pClientShtdwnCntx; - /*Connect call back & its context*/ - pphLibNfc_ConnectCallback_t pClientConnectCb; - void *pClientConCntx; - /*DisConnect call back & its context*/ - pphLibNfc_DisconnectCallback_t pClientDisConnectCb; - void *pClientDConCntx; - - /*Transceive Call back & it's context*/ - pphLibNfc_TransceiveCallback_t pClientTransceiveCb; - void *pClientTranseCntx; - /*Check Ndef Call back & it's context*/ - pphLibNfc_ChkNdefRspCb_t pClientCkNdefCb; - void *pClientCkNdefCntx; - /*Read Ndef Call back & it's context*/ - pphLibNfc_RspCb_t pClientRdNdefCb; - void *pClientRdNdefCntx; - /*Write Ndef Call back & it's context*/ - pphLibNfc_RspCb_t pClientWrNdefCb; - void *pClientWrNdefCntx; - - - /*Discover Call back & it's context*/ - pphLibNfc_RspCb_t pClientDisConfigCb; - void *pClientDisCfgCntx; - - /*Presence check Call back & it's context*/ - pphLibNfc_RspCb_t pClientPresChkCb; - void *pClientPresChkCntx; - - /*Register notification Call back & it's context*/ - phLibNfc_NtfRegister_RspCb_t pClientNtfRegRespCB; - void *pClientNtfRegRespCntx; - - /*Ndef Notification CB*/ - pphLibNfc_Ndef_Search_RspCb_t pClientNdefNtfRespCb; - void *pClientNdefNtfRespCntx; - - /*LLCP Check CB*/ - pphLibNfc_ChkLlcpRspCb_t pClientLlcpCheckRespCb; - void *pClientLlcpCheckRespCntx; - - /*LLCP Link CB*/ - pphLibNfc_LlcpLinkStatusCb_t pClientLlcpLinkCb; - void *pClientLlcpLinkCntx; - - /*LLCP service discovery*/ - pphLibNfc_RspCb_t pClientLlcpDiscoveryCb; - void *pClientLlcpDiscoveryCntx; - -}phLibNfc_Hal_CB_Info_t; - -typedef struct phLibNfc_NdefInfo -{ - bool_t NdefContinueRead; - uint32_t NdefActualSize, - AppWrLength; - phFriNfc_NdefMap_t *psNdefMap; - uint16_t NdefSendRecvLen; - uint16_t NdefDataCount; - phNfc_sData_t *psUpperNdefMsg; - uint32_t NdefReadTimerId, - NdefLength; - uint8_t is_ndef ; - phFriNfc_sNdefSmtCrdFmt_t *ndef_fmt ; - phLibNfc_Last_Call_t eLast_Call; - uint32_t Chk_Ndef_Timer_Id; - - - /*Format Ndef Call back & it's context*/ - pphLibNfc_RspCb_t pClientNdefFmtCb; - void *pClientNdefFmtCntx; - phLibNfc_Ndef_SrchType_t *pNdef_NtfSrch_Type; - -}phLibNfc_NdefInfo_t; - -typedef struct phLibNfc_NdefRecInfo -{ - phFriNfc_NdefReg_CbParam_t CbParam; - phFriNfc_NdefReg_t NdefReg; - uint8_t *NdefTypes_array[100]; - phFriNfc_NdefRecord_t RecordsExtracted; - uint8_t ChunkedRecordsarray[MAX_NO_OF_RECORDS]; - uint32_t NumberOfRecords; - uint8_t IsChunked[MAX_NO_OF_RECORDS]; - uint32_t NumberOfRawRecords; - uint8_t *RawRecords[MAX_NO_OF_RECORDS]; - phFriNfc_NdefReg_Cb_t *NdefCb; - phNfc_sData_t ndef_message; -}phLibNfc_NdefRecInfo_t; - -typedef struct phLibNfc_LlcpInfo -{ - /* Local parameters for LLC, given upon config - * and used upon detection. - */ - phLibNfc_Llcp_sLinkParameters_t sLocalParams; - - /* LLCP compliance flag */ - bool_t bIsLlcp; - - /* Monitor structure for LLCP Transport */ - phFriNfc_LlcpTransport_t sLlcpTransportContext; - - /* Monitor structure for LLCP LLC */ - phFriNfc_Llcp_t sLlcpContext; - - /* LLC Rx buffer */ - uint8_t pRxBuffer[PHFRINFC_LLCP_PDU_HEADER_MAX + PHFRINFC_LLCP_MIU_DEFAULT + PHFRINFC_LLCP_MIUX_MAX]; - - /* LLC Tx buffer */ - uint8_t pTxBuffer[PHFRINFC_LLCP_PDU_HEADER_MAX + PHFRINFC_LLCP_MIU_DEFAULT + PHFRINFC_LLCP_MIUX_MAX]; - -} phLibNfc_LlcpInfo_t; - -typedef struct phLibNfc_LibContext -{ - phHal_sHwReference_t *psHwReference; - Status_t status; - phHal_sEmulationCfg_t sCardEmulCfg; - phLibNfc_SeCtxt_t sSeContext; - phNfc_sState_t LibNfcState; - - phHal_sDevInputParam_t *psDevInputParam; - - phLibNfc_NdefInfo_t ndef_cntx; - phLibNfc_NfcIpInfo_t sNfcIp_Context; - - phFriNfc_OvrHal_t *psOverHalCtxt; - phLibNfc_Registry_Info_t RegNtfType; - uint8_t dev_cnt; - - /*To re configure the discovery wheel*/ - phLibNfc_sADD_Cfg_t sADDconfig; - uintptr_t Connected_handle, - Discov_handle[MAX_REMOTE_DEVICES]; - - /* To store the previous connected handle in case of Multiple protocol tags */ - uintptr_t Prev_Connected_handle; - - /*Call back function pointers */ - - phLibNfc_eDiscoveryConfigMode_t eLibNfcCfgMode; - - phHal4Nfc_DiscoveryInfo_t *psDiscInfo; - - phLibNfc_eReleaseType_t ReleaseType; - /**Transaction Related Info */ - phLibNfc_sTransceiveInfo_t *psTransInfo; - phLibNfc_sTransceiveInfo_t *psBufferedAuth; - uint8_t LastTrancvSuccess; - phLibNfc_RemoteDevList_t psRemoteDevList[MAX_REMOTE_DEVICES]; - /*To Call back function pointers & Client context*/ - phLibNfc_Hal_CB_Info_t CBInfo; - - /*Ndef RTD search Info*/ - phLibNfc_NdefRecInfo_t phLib_NdefRecCntx; - - /*LLCP Info*/ - phLibNfc_LlcpInfo_t llcp_cntx; - - /* Pointer to Lib context */ -} phLibNfc_LibContext_t,*pphLibNfc_LibContext_t; - -extern void phLibNfc_Pending_Shutdown(void); -extern pphLibNfc_LibContext_t gpphLibContext; -extern NFCSTATUS -phLibNfc_UpdateNextState( - pphLibNfc_LibContext_t psNfcHalCtxt, - phLibNfc_State_t next_state - ); - -extern void -phLibNfc_UpdateCurState( - NFCSTATUS status, - pphLibNfc_LibContext_t psNfcHalCtxt - ); - -extern void -phLibNfc_Reconnect_Mifare_Cb ( - void *pContext, - phHal_sRemoteDevInformation_t *psRemoteDevInfo, - NFCSTATUS status); - - -#endif - - diff --git a/libnfc-nxp/phLibNfc_SE.h b/libnfc-nxp/phLibNfc_SE.h deleted file mode 100644 index 99e3ffe..0000000 --- a/libnfc-nxp/phLibNfc_SE.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! - * \file phLibNfc_SE.h - * - * Project: NFC-FRI 1.1 - * - * $Workfile:: phLibNfc_1.1.h $ - * $Modtime:: $ - * $Author: ing07299 $ - * $Revision: 1.14 $ - * - */ -#ifndef PHLIBNFC_SE_H -#define PHLIBNFC_SE_H - -#define LIBNFC_SE_INVALID_HANDLE 0 -#define LIBNFC_SE_SUPPORTED 2 -#define LIBNFC_SE_BASE_HANDLE 0xABCDEF - -#define LIBNFC_SE_SMARTMX_INDEX 0 -#define LIBNFC_SE_UICC_INDEX 1 - -#define PAUSE_PHASE 0x0824 /*Indicates the Pause phase duration*/ -#define EMULATION_PHASE 0x5161 /*Indicates the Emulation phase duration*/ - -typedef struct phLibNfc_SeCallbackInfo -{ - /* SE set mode callback and its context */ - pphLibNfc_SE_SetModeRspCb_t pSEsetModeCb; - void *pSEsetModeCtxt; - /* Store SE discovery notification callback and its context */ - pphLibNfc_SE_NotificationCb_t pSeListenerNtfCb; - void *pSeListenerCtxt; - -}phLibNfc_SECallbackInfo_t; - -/*SE State */ -typedef enum { - phLibNfc_eSeInvalid = 0x00, - phLibNfc_eSeInit, - phLibNfc_eSeReady, - phLibNfc_eSeVirtual, - phLibNfc_eSeWired -}phLibNfc_SeState_t; - - -/* Context for secured element */ -typedef struct phLibNfc_SeCtxt -{ - - /* UICC Status in Virtual Mode */ - uint8_t uUiccActivate; - - /* SMX Status in Virtual Mode */ - uint8_t uSmxActivate; - - /* Count of the Secure Elements Present */ - uint8_t uSeCount; - - /* Se Temp handle */ - phLibNfc_Handle hSetemp; - - /*Current SE state*/ - phLibNfc_SeState_t eSE_State; - - /*Current SE Mode */ - - phLibNfc_eSE_ActivationMode eActivatedMode; - - /* SE callback information */ - phLibNfc_SECallbackInfo_t sSeCallabackInfo; - -}phLibNfc_SeCtxt_t; - -extern phLibNfc_SE_List_t sSecuredElementInfo[PHLIBNFC_MAXNO_OF_SE]; - - - -#endif - - diff --git a/libnfc-nxp/phLibNfc_initiator.h b/libnfc-nxp/phLibNfc_initiator.h deleted file mode 100644 index 66d7d2a..0000000 --- a/libnfc-nxp/phLibNfc_initiator.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! - * \file phLibNfc_initiator.h - * - * Project: NFC-FRI 1.1 - * - * $Workfile:: phLibNfc_1.1.h $ - * $Modtime:: $ - * $Author: ing07299 $ - * $Revision: 1.13 $ - * - */ -#ifndef PHLIBNFC_INITIATOR_H -#define PHLIBNFC_INITIATOR_H - -typedef struct phLibNfc_NfcIpInfo -{ - phNfc_sData_t *p_recv_data; - uint32_t recv_index; - /*NFC-IP Call back & it's context*/ - pphLibNfc_RspCb_t pClientNfcIpCfgCb; - void *pClientNfcIpCfgCntx; - /*NFC-IP send callback and its context*/ - pphLibNfc_RspCb_t pClientNfcIpTxCb; - void *pClientNfcIpTxCntx; - - /*NFC-IP receive callback and its context*/ - pphLibNfc_Receive_RspCb_t pClientNfcIpRxCb; - void *pClientNfcIpRxCntx; - /*Store the role of remote device*/ - phHal4Nfc_TransactInfo_t TransactInfoRole; - - /*NFC IP remote initator handle */ - uint32_t Rem_Initiator_Handle; - -}phLibNfc_NfcIpInfo_t; - - -#endif - - diff --git a/libnfc-nxp/phLibNfc_ioctl.h b/libnfc-nxp/phLibNfc_ioctl.h deleted file mode 100644 index 61e312f..0000000 --- a/libnfc-nxp/phLibNfc_ioctl.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! -*\file phLibNfc_ioctl.h -*\brief Contains LibNfc IOCTL details. -*Project: NFC-FRI 1.1 -* $Workfile:: phLibNfc_ioctl.h $ -* $Modtime:: $ -* $Author: ing07299 $ -* $Revision: 1.9 $ -* $Aliases: NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK949_SDK_INT,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK1003_SDK,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1008_SDK,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1007_SDK,NFC_FRI1.1_WK1014_SDK,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1019_SDK,NFC_FRI1.1_WK1024_SDK $ -*\defgroup grp_lib_ioctl IOCTL code details -*/ - - -#ifndef PHLIBNFCIOCTL_H /* */ -#define PHLIBNFCIOCTL_H /* */ - -#include -#include - -/** -* \ingroup grp_lib_ioctl -* \brief Allows to initiate firmware download to connected PN544 -* -*/ -#define PHLIBNFC_FW_DOWNLOAD NFC_FW_DOWNLOAD -/** -* \ingroup grp_lib_ioctl -* \brief Allows to read memory from connected PN544 . -* -*/ -#define PHLIBNFC_MEM_READ NFC_MEM_READ - -/** -* \ingroup grp_lib_ioctl -* \brief Allows to write PN544 memory. -* -*/ -#define PHLIBNFC_MEM_WRITE NFC_MEM_WRITE - -/** -* \ingroup grp_lib_ioctl -* \brief Allows to do Antenna test. -* -*/ -#define PHLIBNFC_ANTENNA_TEST DEVMGMT_ANTENNA_TEST -/** -* \ingroup grp_lib_ioctl -* \brief Allows to do SWP test. -* -*/ -#define PHLIBNFC_SWP_TEST DEVMGMT_SWP_TEST -/** -* \ingroup grp_lib_ioctl -* \brief Allows to do PRBS test. -* -*/ -#define PHLIBNFC_PRBS_TEST DEVMGMT_PRBS_TEST - -/** -* \ingroup grp_lib_ioctl -* \brief Allows to switch UICC mode. -* -*/ -#define PHLIBNFC_SWITCH_SWP_MODE NFC_SWITCH_SWP_MODE - -typedef struct -{ - void *pCliCntx; - pphLibNfc_IoctlCallback_t CliRspCb; - phHal_sHwReference_t *psHwReference; - phNfc_sData_t* pOutParam; - uint16_t IoctlCode; -}phLibNfc_Ioctl_Cntx_t; - -#endif /* PHLIBNFCIOCTL_H */ - - - - diff --git a/libnfc-nxp/phLibNfc_ndef_raw.h b/libnfc-nxp/phLibNfc_ndef_raw.h deleted file mode 100644 index 036803c..0000000 --- a/libnfc-nxp/phLibNfc_ndef_raw.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! - * \file phLibNfc_ndef_raw.h - * - * Project: NFC-FRI 1.1 - * - * $Workfile:: phLibNfc_1.1.h $ - * $Modtime:: $ - * $Author: ing07299 $ - * $Revision: 1.15 $ - * - */ -#ifndef PHLIBNFC_NDEF_RAW_H -#define PHLIBNFC_NDEF_RAW_H - -/*Check for type of NDEF Calls*/ -typedef enum phLibNfc_Last_Call{ - ChkNdef = 0x00, - NdefRd, - NdefWr, - NdefFmt, -#ifdef LIBNFC_READONLY_NDEF - NdefReadOnly, -#endif /* #ifdef LIBNFC_READONLY_NDEF */ - RawTrans -} phLibNfc_Last_Call_t; - -#define TAG_MIFARE 0x01 -#define TAG_FELICA 0x02 -#define TAG_JEWEL 0x04 -#define TAG_ISO14443_4A 0x08 -#define TAG_ISO14443_4B 0x10 -#define TAG_NFC_IP1 0x20 - -#define NDEF_READ_TIMER_TIMEOUT 60U -#define CHK_NDEF_TIMER_TIMEOUT 60U -#define NDEF_SENDRCV_BUF_LEN 252U -#define NDEF_TEMP_RECV_LEN 256U -#define NDEF_MIFARE_UL_LEN 46U -#define NDEF_FELICA_LEN 0U/*len to be set when supported*/ -#define NDEF_JEWEL_TOPAZ_LEN 0U -#define NDEF_ISO14443_4A_LEN 4096U -#define NDEF_ISO14443_4B_LEN 0U -#define NDEF_MIFARE_4K_LEN 3356U -#define NDEF_MIFARE_1K_LEN 716U -#define MIFARE_STD_DEFAULT_KEY {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF} -#define MIFARE_STD_KEY_LEN 6 -#define ISO_SAK_VALUE 0x20U - - -#define UNKNOWN_BLOCK_ADDRESS 0xFF /***/ -#define SESSION_OPEN 0x01 - - -extern void phLibNfc_Ndef_Init(void); -extern void phLibNfc_Ndef_DeInit(void); -extern phLibNfc_Ndef_Info_t NdefInfo; -extern phFriNfc_NdefRecord_t *pNdefRecord; - -#endif - diff --git a/libnfc-nxp/phLlcNfc.h b/libnfc-nxp/phLlcNfc.h deleted file mode 100644 index 552ec38..0000000 --- a/libnfc-nxp/phLlcNfc.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! -* \file phLlcNfc.h -* \brief Common LLC for the upper layer. -* -* Project: NFC-FRI-1.1 -* -* $Date: Thu Sep 11 12:18:52 2008 $ -* $Author: ing02260 $ -* $Revision: 1.7 $ -* $Aliases: NFC_FRI1.1_WK838_PREP1,NFC_FRI1.1_WK838_R9_PREP2,NFC_FRI1.1_WK838_R9_1,NFC_FRI1.1_WK840_R10_PREP1,NFC_FRI1.1_WK840_R10_1,NFC_FRI1.1_WK842_R11_PREP1,NFC_FRI1.1_WK842_R11_PREP2,NFC_FRI1.1_WK842_R11_1,NFC_FRI1.1_WK844_PREP1,NFC_FRI1.1_WK844_R12_1,NFC_FRI1.1_WK846_PREP1,NFC_FRI1.1_WK846_R13_1,NFC_FRI1.1_WK848_PREP1,NFC_FRI1.1_WK848_R14_1,NFC_FRI1.1_WK849_PACK1_PREP1,NFC_FRI1.1_WK850_PACK1,NFC_FRI1.1_WK851_PREP1,NFC_FRI1.1_WK850_R15_1,NFC_FRI1.1_WK902_PREP1,NFC_FRI1.1_WK902_R16_1,NFC_FRI1.1_WK904_PREP1,NFC_FRI1.1_WK904_R17_1,NFC_FRI1.1_WK906_R18_1,NFC_FRI1.1_WK908_PREP1,NFC_FRI1.1_WK908_R19_1,NFC_FRI1.1_WK910_PREP1,NFC_FRI1.1_WK910_R20_1,NFC_FRI1.1_WK912_PREP1,NFC_FRI1.1_WK912_R21_1,NFC_FRI1.1_WK914_PREP1,NFC_FRI1.1_WK914_R22_1,NFC_FRI1.1_WK914_R22_2,NFC_FRI1.1_WK916_R23_1,NFC_FRI1.1_WK918_R24_1,NFC_FRI1.1_WK920_PREP1,NFC_FRI1.1_WK920_R25_1,NFC_FRI1.1_WK922_PREP1,NFC_FRI1.1_WK922_R26_1,NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK926_R28_2,NFC_FRI1.1_WK926_R28_3,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ -* -*/ - -#ifndef PHLLCNFC_H -#define PHLLCNFC_H - -#ifdef ANDROID -#include -#endif - -/** -* \name LLC NFC -* -* File: \ref phLlcNfc.h -* -*/ -/*@{*/ -#define PH_LLCNFC_FILEREVISION "$Revision: 1.7 $" /**< \ingroup grp_file_attributes */ -#define PH_LLCNFC_FILEALIASES "$Aliases: NFC_FRI1.1_WK838_PREP1,NFC_FRI1.1_WK838_R9_PREP2,NFC_FRI1.1_WK838_R9_1,NFC_FRI1.1_WK840_R10_PREP1,NFC_FRI1.1_WK840_R10_1,NFC_FRI1.1_WK842_R11_PREP1,NFC_FRI1.1_WK842_R11_PREP2,NFC_FRI1.1_WK842_R11_1,NFC_FRI1.1_WK844_PREP1,NFC_FRI1.1_WK844_R12_1,NFC_FRI1.1_WK846_PREP1,NFC_FRI1.1_WK846_R13_1,NFC_FRI1.1_WK848_PREP1,NFC_FRI1.1_WK848_R14_1,NFC_FRI1.1_WK849_PACK1_PREP1,NFC_FRI1.1_WK850_PACK1,NFC_FRI1.1_WK851_PREP1,NFC_FRI1.1_WK850_R15_1,NFC_FRI1.1_WK902_PREP1,NFC_FRI1.1_WK902_R16_1,NFC_FRI1.1_WK904_PREP1,NFC_FRI1.1_WK904_R17_1,NFC_FRI1.1_WK906_R18_1,NFC_FRI1.1_WK908_PREP1,NFC_FRI1.1_WK908_R19_1,NFC_FRI1.1_WK910_PREP1,NFC_FRI1.1_WK910_R20_1,NFC_FRI1.1_WK912_PREP1,NFC_FRI1.1_WK912_R21_1,NFC_FRI1.1_WK914_PREP1,NFC_FRI1.1_WK914_R22_1,NFC_FRI1.1_WK914_R22_2,NFC_FRI1.1_WK916_R23_1,NFC_FRI1.1_WK918_R24_1,NFC_FRI1.1_WK920_PREP1,NFC_FRI1.1_WK920_R25_1,NFC_FRI1.1_WK922_PREP1,NFC_FRI1.1_WK922_R26_1,NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK926_R28_2,NFC_FRI1.1_WK926_R28_3,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ -/*@}*/ -/*************************** Includes *******************************/ - -/*********************** End of includes ****************************/ -/** \defgroup grp_hal_nfc_llc LLC Component - * - * - * - */ - -/***************************** Macros *******************************/ - -/************************ End of macros *****************************/ - -/********************** Callback functions **************************/ - -/******************* End of Callback functions **********************/ - -/********************* Structures and enums *************************/ - - -/****************** End of structures and enums *********************/ - - -/******************** Function declarations *************************/ -/** -* \ingroup grp_hal_nfc_llc -* -* \brief \b Register function -* -* \copydoc page_reg Provides the callback to the LLC layer and register -* the calling functions to the upper layer (Synchronous function). -* -* \param[out] psReference Structure is used to give the LLC calling functions -* and also LLC context information to the upper layer -* \param[in] if_callback Callback information provided by the upper layer -* \param[in] psIFConfig This gives the information of the next register call -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. -* \retval Other errors Errors related to the lower layers -* -*/ - -NFCSTATUS -phLlcNfc_Register ( - phNfcIF_sReference_t *psReference, - phNfcIF_sCallBack_t if_callback, - void *psIFConfig -); - - - -/****************** End of function declarations ********************/ -#endif /* PHLLCNFC_H */ diff --git a/libnfc-nxp/phLlcNfc_DataTypes.h b/libnfc-nxp/phLlcNfc_DataTypes.h deleted file mode 100644 index b84cd3e..0000000 --- a/libnfc-nxp/phLlcNfc_DataTypes.h +++ /dev/null @@ -1,646 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* -* \file phLlcNfc_DataTypes.h -* \brief Contains the structure information. -* -* Project: NFC-FRI-1.1 -* -* $Date: Fri Apr 30 10:03:36 2010 $ -* $Author: ing02260 $ -* $Revision: 1.43 $ -* $Aliases: NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ -* -*/ - -#ifndef PHLLCNFC_DATATYPES_H -#define PHLLCNFC_DATATYPES_H - -/** -* \name LLC NFC frame creation, deletion and processing -* -* File: \ref phLlcNfc_DataTypes.h -* -*/ -/*@{*/ -#define PH_LLCNFC_DATATYPES_FILEREVISION "$Revision: 1.43 $" /**< \ingroup grp_hal_nfc_llc */ -#define PH_LLCNFC_DATATYPES_FILEALIASES "$Aliases: NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_hal_nfc_llc */ -/*@}*/ -/*************************** Includes *******************************/ -#include -/*********************** End of includes ****************************/ -/***************************** Macros *******************************/ - -/* Trace buffer declaration */ -#if defined (LLC_TRACE) - #include - #include - - extern char phOsalNfc_DbgTraceBuffer[]; - #define trace_buffer phOsalNfc_DbgTraceBuffer - - #define MAX_TRACE_BUFFER 150 - #define PH_LLCNFC_PRINT( str ) phOsalNfc_DbgString(str) - #define PH_LLCNFC_PRINT_DATA(buf,len) - #define PH_LLCNFC_STRING( str ) - #define PH_LLCNFC_DEBUG(str, arg) \ - { \ - snprintf(trace_buffer,MAX_TRACE_BUFFER,str,arg); \ - phOsalNfc_DbgString(trace_buffer); \ - } - #define PH_LLCNFC_PRINT_BUFFER(buf,len) \ - { \ - /* uint16_t i = 0; \ - char trace_buffer[MAX_TRACE_BUFFER]; \ - snprintf(trace_buffer,MAX_TRACE_BUFFER,"\n\t %s:",msg); \ - phOsalNfc_DbgString(trace); */\ - phOsalNfc_DbgTrace(buf,len); \ - phOsalNfc_DbgString("\r"); \ - } -#endif /* #if defined (LLC_TRACE) */ - - -#if (!defined (LLC_TRACE) && defined (LLC_DATA_BYTES)) - #include - - extern char phOsalNfc_DbgTraceBuffer[]; - #define trace_buffer phOsalNfc_DbgTraceBuffer - - #define PH_LLCNFC_PRINT( str ) - #define PH_LLCNFC_PRINT_BUFFER(buf, len) - #define PH_LLCNFC_DEBUG(str, arg1) - #define PH_LLCNFC_STRING( str ) phOsalNfc_DbgString(str) - #define PH_LLCNFC_PRINT_DATA(buf,len) \ - { \ - /* uint16_t i = 0; \ - char trace_buffer[MAX_TRACE_BUFFER]; \ - snprintf(trace_buffer,MAX_TRACE_BUFFER,"\n\t %s:",msg); \ - phOsalNfc_DbgString(trace_buffer); */\ - phOsalNfc_DbgTrace(buf,len); \ - } -#endif /* #if (!defined (LLC_TRACE) && defined (LLC_DATA_BYTES)) */ - - -#if (!defined (LLC_TRACE) && !defined (LLC_DATA_BYTES)) - /** To disable prints */ - #define PH_LLCNFC_PRINT(str) - #define PH_LLCNFC_PRINT_BUFFER(buf, len) - #define PH_LLCNFC_DEBUG(str, arg1) - #define PH_LLCNFC_PRINT_DATA(buf,len) - #define PH_LLCNFC_STRING( str ) -#endif /* #if (!defined (LLC_TRACE) && !defined (LLC_DATA_BYTES)) */ - - -/* If the below MACRO (RECV_NR_CHECK_ENABLE) is -DEFINED : then check for the NR frame received from PN544 in the I frame is - added. This shall be greater than sent NS from the HOST. - This is used to stop the timer -COMMENTED : dont check the N(R) frame received from the PN544 -*/ -/* #define RECV_NR_CHECK_ENABLE */ - -/* If the below MACRO (LLC_UPP_LAYER_NTFY_WRITE_RSP_CB) is -DEFINED : then if an I frame is received and the - upper layer response callback (before another READ is pended) is called - only after sending S frame and wait for the callback and then notify the - upper layer -COMMENTED : then if an I frame is received and the - upper layer response callback (before another READ is pended) is called - immediately after sending S frame (not waiting for the sent S frame - callback) -*/ -/* #define LLC_UPP_LAYER_NTFY_WRITE_RSP_CB */ - -/* PN544 continuously sends an incorrect I frames to the HOST, - even after the REJ frame from HOST to PN544 -If the below MACRO (LLC_RR_INSTEAD_OF_REJ) is -DEFINED : then if the received NS = (expected NR - 1) then instead of REJ - RR frame is sent -COMMENTED : then REJ frame is sent -*/ -// #define LLC_RR_INSTEAD_OF_REJ - -#define SEND_UFRAME - -/* If the below MACRO (CTRL_WIN_SIZE_COUNT) is -DEFINED : then window size will be maximum -COMMENTED : then window size is 1 -*/ -#define CTRL_WIN_SIZE_COUNT - -/* -If the below MACRO (LLC_URSET_NO_DELAY) is -DEFINED : then after receiving the UA frame, then immediately this will be - notified or further operation will be carried on. -COMMENTED : then after receiving the UA frame, then a timer is started, to - delay the notifiation or to carry on the next operation -*/ -#define LLC_URSET_NO_DELAY - - /* - If the below MACRO (LLC_RELEASE_FLAG) is -DEFINED : then whenever LLC release is called the g_release_flag variable - will be made TRUE. Also, NO notification is allowed to the - upper layer. -COMMENTED : g_release_flag is not declared and not used - */ - #define LLC_RELEASE_FLAG - - - /* - Actually, there is a send and receive error count, if either of them reaches - limit, then exception is raised. - If the below MACRO (LLC_RSET_INSTEAD_OF_EXCEPTION) is -DEFINED : then exception is not raised, instead a U RSET command is sent. -COMMENTED : then exception is raised - */ -/* #define LLC_RSET_INSTEAD_OF_EXCEPTION */ - -#ifndef LLC_UPP_LAYER_NTFY_WRITE_RSP_CB - /* - If the below MACRO (PIGGY_BACK) is - DEFINED : After receiving I frame, wait till the ACK timer to expire to send an ACK to PN544. - COMMENTED : immediately ACK the received I frame - */ - #define PIGGY_BACK - -#endif /* LLC_UPP_LAYER_NTFY_WRITE_RSP_CB */ - -#define LLC_SEND_ERROR_COUNT - -#define RECV_ERROR_FRAME_COUNT (0x50U) -#define SENT_ERROR_FRAME_COUNT (0x50U) - -/** Initial bytes to read */ -#define PH_LLCNFC_BYTES_INIT_READ (1) -/** Maximum buffer that I frame can send */ -#define PH_LLCNFC_MAX_IFRAME_BUFLEN (29) -#define PH_LLCNFC_MAX_UFRAME_BUFLEN (4) -#define PH_LLCNFC_CRC_LENGTH (2) -#define PH_LLCNFC_MAX_LLC_PAYLOAD ((PH_LLCNFC_MAX_IFRAME_BUFLEN) + (4)) -/** Maximum timer used in the Llc */ -#define PH_LLCNFC_MAX_TIMER_USED (3) -/** Maximum timer used in the Llc */ -#define PH_LLCNFC_MAX_ACK_GUARD_TIMER (4) -/** Maximum I frame that can be stored */ -#define PH_LLCNFC_MAX_I_FRAME_STORE (8) - -/** Read pending for one byte */ -#define PH_LLCNFC_READPEND_ONE_BYTE (0x01U) - /** Read pending for remaining byte */ -#define PH_LLCNFC_READPEND_REMAIN_BYTE (0x02U) -/** Read pending not done */ -#define PH_LLCNFC_READPEND_FLAG_OFF FALSE -#define PH_LLCNFC_MAX_REJ_RETRY_COUNT (200) - - -/**** Macros for state machine ****/ - -typedef enum phLlcNfc_State -{ - /** This specifies that LLC is in uninitialise state */ - phLlcNfc_Uninitialise_State = 0x00, - /** This specifies that LLC initialise is in progress */ - phLlcNfc_Initialising_State = 0x01, - /** This specifies that LLC is in initialise is complete */ - phLlcNfc_Initialised_State = 0x02, - /** This specifies that LLC is send with the - lower layer */ - phLlcNfc_Sending_State = 0x03, - /** This specifies that LLC is receive with the - lower layer */ - phLlcNfc_Receiving_State = 0x04, - /** This specifies that LLC is receive wait with the - lower layer */ - phLlcNfc_ReceiveWait_State = 0x05, - /** This specifies that LLC is resending the I frames */ - phLlcNfc_Resend_State = 0x06 -}phLlcNfc_State_t; -/**** Macros for state machine end ****/ - -/************************ End of macros *****************************/ - -/********************** Callback functions **************************/ - -/******************* End of Callback functions **********************/ - -/********************* Structures and enums *************************/ -/** -* \ingroup grp_hal_nfc_llc -* \brief Enum to get the baud rate -* -* This enum contains the baud rate information. -* -*/ -/*@{*/ -typedef enum phLlcNfc_LlcBaudRate -{ - /** Baud rate = 9600 */ - phLlcNfc_e_9600 = 0x00, - /** Baud rate = 19200 */ - phLlcNfc_e_19200 = 0x01, - /** Baud rate = 28800 */ - phLlcNfc_e_28800 = 0x02, - /** Baud rate = 38400 */ - phLlcNfc_e_38400 = 0x03, - /** Baud rate = 57600 */ - phLlcNfc_e_57600 = 0x04, - /** Baud rate = 115200 */ - phLlcNfc_e_115200 = 0x05, - /** Baud rate = 23400 */ - phLlcNfc_e_234000 = 0x06, - /** Baud rate = 46800 */ - phLlcNfc_e_460800 = 0x07, - /** Baud rate = 921600 */ - phLlcNfc_e_921600 = 0x08, - /** Baud rate = 1228000 */ - phLlcNfc_e_1228000 = 0x09, - /** Baud rate error */ - phLlcNfc_e_bdrate_err = 0xFF -}phLlcNfc_LlcBaudRate_t; -/*@}*/ - -/** -* \ingroup grp_hal_nfc_llc -* \brief Enum to select the U or I or S frame -* -* This enum is to set the frames. -* -*/ -/*@{*/ -typedef enum phLlcNfc_LlcCmd -{ - /** This command is for I frame (no command) */ - phLlcNfc_e_no_cmd = 0xFF, - /** This command is for U frame */ - phLlcNfc_e_rset = 0x19, - /** This command is for U frame */ - phLlcNfc_e_ua = 0x06, - /** This is RR command for S frame */ - phLlcNfc_e_rr = 0x00, - /** This is REJ command for S frame */ - phLlcNfc_e_rej = 0x08, - /** This is RNR command for S frame */ - phLlcNfc_e_rnr = 0x10, - /** This is SREJ command for S frame */ - phLlcNfc_e_srej = 0x18, - /** Error command */ - phLlcNfc_e_error = 0xFE -}phLlcNfc_LlcCmd_t; -/*@}*/ - -/** -* \ingroup grp_hal_nfc_llc -* \brief Enum to select the U or I or S frame -* -* This enum is to set the frames. -* -*/ -/*@{*/ -typedef enum phLlcNfc_FrameType -{ - /** U frame type */ - phLlcNfc_eU_frame = 0x00, - /** I frame type */ - phLlcNfc_eI_frame = 0x01, - /** S frame type */ - phLlcNfc_eS_frame = 0x02, - /** Error frame type */ - phLlcNfc_eErr_frame = 0x03 -}phLlcNfc_FrameType_t; -/*@}*/ - -/** -* \ingroup grp_hal_nfc_llc -* \brief LLC sent frame type -* -* This enum values defines what are the frames sent to the PN544 -* -*/ -/*@{*/ - -typedef enum phLlcNfc_eSentFrameType -{ - invalid_frame, - /* During initialisation the U RSET is sent to PN544 */ - init_u_rset_frame, - /* During initialisation the UA is sent to PN544 */ - init_u_a_frame, - /* After unsuccessful retries of sending I frame to PN544, - URSET is sent */ - u_rset_frame, - /* If PN544 sends the URSET frame in between any transaction, then - the UA response shall be sent */ - u_a_frame, - /* S frame is sent to PN544, this will be sent only if an I frame - is received from PN544 */ - s_frame, - /* User has sent an I frame, for that a write response callback - shall be called */ - user_i_frame, - /* LLC, internally (means stored non acknowledged frames) has sent - an I frame as it doesnt get a proper acknowledgement */ - resend_i_frame, - /* LLC, internally (means stored non acknowledged frames) has sent - an I frame as it doesnt get a reject as acknowledgement */ - rejected_i_frame, - /* LLC has received a I frame for the re-sent I frames, so an S - frame is sent */ - resend_s_frame, - /* LLC has received a I frame for the re-sent I frames, so an S - frame is sent */ - resend_rej_s_frame, - /* PN544 has sent an I frame, which is wrong, so send a reject S - frame */ - reject_s_frame, -#ifdef LLC_RR_INSTEAD_OF_REJ - - /* RR is sent instead of REJECT */ - rej_rr_s_frame, - -#endif /* #ifdef LLC_RR_INSTEAD_OF_REJ */ - /* For any of the above sent frames, the response shall be received */ - write_resp_received -}phLlcNfc_eSentFrameType_t; - -/*@}*/ - -/** -* \ingroup grp_hal_nfc_llc -* \brief LLC payload -* -* This structure contains both the header information and -* the exact length of the buffer. -* -*/ -/*@{*/ -typedef struct phLlcNfc_Payload -{ - /** Llc header information */ - uint8_t llcheader; - - /** User or received buffer */ - uint8_t llcpayload[PH_LLCNFC_MAX_LLC_PAYLOAD]; -}phLlcNfc_Payload_t; -/*@}*/ - -/** -* \ingroup grp_hal_nfc_llc -* \brief Llc buffer -* -* This structure contains the information of the LLC length byte -* and payload. -* -*/ -/*@{*/ -typedef struct phLlcNfc_Buffer -{ - /** Llc length */ - uint8_t llc_length_byte; - - /** LLC data including the LLC header and CRC */ - phLlcNfc_Payload_t sllcpayload; -}phLlcNfc_Buffer_t; -/*@}*/ - -/** -* \ingroup grp_hal_nfc_llc -* \brief Packet information -* -* This structure contains the length and buffer of the packet. -* -*/ -/*@{*/ -typedef struct phLlcNfc_LlcPacket -{ - /** Complete LLC buffer */ - phLlcNfc_Buffer_t s_llcbuf; - - /** LLC buffer length */ - uint8_t llcbuf_len; - - /** Stored frame needs completion callback, to be sent to HCI */ - phLlcNfc_eSentFrameType_t frame_to_send; - -}phLlcNfc_LlcPacket_t; -/*@}*/ - -/** -* \ingroup grp_hal_nfc_llc_helper -* \brief I frame details -* -* This structure stores the information of the I frame -* (to support sliding window). -* -*/ -/*@{*/ -typedef struct phLlcNfc_StoreIFrame -{ - /** Complete LLC packet */ - phLlcNfc_LlcPacket_t s_llcpacket[PH_LLCNFC_MAX_I_FRAME_STORE]; - - /** Window size count */ - uint8_t winsize_cnt; - - /** Start position */ - uint8_t start_pos; - -}phLlcNfc_StoreIFrame_t; -/*@}*/ - -/** -* \ingroup grp_hal_nfc_llc -* \brief LLC timer information -* -* This structure contains the timer related information -* -*/ -/*@{*/ -typedef struct phLlcNfc_Timerinfo -{ - /** Store the timer id for each timer create */ - uint32_t timer_id[PH_LLCNFC_MAX_TIMER_USED]; - - /** This will store the connection time out value */ - uint16_t con_to_value; - - /** This will store the guard time out values */ - uint16_t guard_to_value[PH_LLCNFC_MAX_ACK_GUARD_TIMER]; - - /** This will store the guard time out values */ - uint16_t iframe_send_count[PH_LLCNFC_MAX_ACK_GUARD_TIMER]; - - /** This will store ns value for the sent N(S) */ - uint8_t timer_ns_value[PH_LLCNFC_MAX_ACK_GUARD_TIMER]; - - /** Each frame stored needs to be */ - uint8_t frame_type[PH_LLCNFC_MAX_ACK_GUARD_TIMER]; - - /** Index to re-send */ - uint8_t index_to_send; - - /** This is a count for gaurd time out */ - uint8_t guard_to_count; - -#ifdef PIGGY_BACK - /** This will store the ack time out values */ - uint16_t ack_to_value; -#endif /* #ifdef PIGGY_BACK */ - - /** This is a timer flag - Bit 0 = 1 means connection time out started else stopped - Bit 1 = 1 means guard time out started else stopped - Bit 2 = 1 means ack time out started else stopped - */ - uint8_t timer_flag; -}phLlcNfc_Timerinfo_t; -/*@}*/ - -/** -* \ingroup grp_hal_nfc_llc -* \brief LLC frame information -* -* This structure contains the information of the LLC frame. -* -*/ -/*@{*/ -typedef struct phLlcNfc_Frame -{ - /** N(S) - Number of information frame */ - uint8_t n_s; - - /** N(R) - Number of next information frame to receive */ - uint8_t n_r; - - /** Store the window size */ - uint8_t window_size; - - /** SREJ is optional, so store the flag whether it is set or not */ - uint8_t srej_on_off; - - /** Store the baud rate */ - uint8_t baud_rate; - - /** Flag to find the rset_recvd */ - uint8_t rset_recvd; - - /** Complete LLC packet information */ - phLlcNfc_LlcPacket_t s_llcpacket; - - /** Store the I frames, that has been sent, Storage will be till - the window size */ - phLlcNfc_StoreIFrame_t s_send_store; - -#ifdef PIGGY_BACK - /** Store the I frames, that has been received, Storage will be - till the window size */ - phLlcNfc_StoreIFrame_t s_recv_store; - - /** Response received count to send the ACK once it reaches the window size */ - uint8_t resp_recvd_count; -#endif /* #ifdef PIGGY_BACK */ - - /** To receive the packet sent by below layer */ - phLlcNfc_LlcPacket_t s_recvpacket; - - /** Number of window I frames has to be sent again */ - uint8_t rejected_ns; - - /** To store the count received error frames like - wrong CRC, REJ and RNR frames */ - uint8_t recv_error_count; - - /** Sending error frames like REJ frames to the PN544 */ - uint8_t send_error_count; - - /** Send U frame count */ - uint8_t retry_cnt; - - /** Read pending flag, to know that read is already pended - or not. Use the below macros to ON and OFF the flag - PH_LLCNFC_READPEND_FLAG_OFF - PH_LLCNFC_READPEND_ONE_BYTE - PH_LLCNFC_READPEND_REMAIN_BYTE - */ - uint8_t read_pending; - - /** Write pending */ - uint8_t write_pending; - - /** Sent frame type */ - phLlcNfc_eSentFrameType_t sent_frame_type; - - /** upper receive called */ - uint8_t upper_recv_call; - - /** Status returned during DAL write */ - NFCSTATUS write_status; - - /** Depending on the "write_status", write call has to be called */ - phLlcNfc_eSentFrameType_t write_wait_call; -}phLlcNfc_Frame_t; -/*@}*/ - -/** -* \ingroup grp_hal_nfc_llc -* \brief LLC Component Context Structure -* -* This structure is used to store the current context information -* of the instance. -* -*/ -/*@{*/ -typedef struct phLlcNfc_Context -{ - /** Information regarding all the LLC frame */ - phLlcNfc_Frame_t s_frameinfo; - - /** Local send and receive */ - phNfc_sLowerIF_t lower_if; - - /** Register attention, send and receive callback from the - register functions of the upper layer */ - phNfcIF_sCallBack_t cb_for_if; - - /** Store the length, which shall be sent later through the - "send complete" callback */ - uint32_t send_cb_len; - - /** Receive buffer provided by the upper layer */ - uint8_t precv_buf[PH_LLCNFC_MAX_LLC_PAYLOAD]; - - /** Receive length provided by the upper layer */ - uint32_t recvbuf_length; - - /** Llc state */ - phLlcNfc_State_t state; - - /** Hardware information */ - void *phwinfo; - - /** Timer information */ - phLlcNfc_Timerinfo_t s_timerinfo; -}phLlcNfc_Context_t; -/*@}*/ -/****************** End of structures and enums *********************/ - -/******************** Function declarations *************************/ - -/******************** Function declarations *************************/ -#endif /* PHLLCNFC_DATATYPES_H */ - - diff --git a/libnfc-nxp/phLlcNfc_Frame.h b/libnfc-nxp/phLlcNfc_Frame.h deleted file mode 100644 index e76e017..0000000 --- a/libnfc-nxp/phLlcNfc_Frame.h +++ /dev/null @@ -1,471 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! -* \file phLlcNfc_Frame.h -* \brief To append and delete the I or S or U frames. -* -* Project: NFC-FRI-1.1 -* -* $Date: Fri Apr 30 10:03:36 2010 $ -* $Author: ing02260 $ -* $Revision: 1.19 $ -* $Aliases: NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ -* -*/ - -#ifndef PHLLCNFC_FRAME_H -#define PHLLCNFC_FRAME_H - -/** -* \name LLC NFC frame creation and deletion -* -* File: \ref phLlcNfc_Frame.h -* -*/ -/*@{*/ -#define PHLLCNFCFRAME_FILEREVISION "$Revision: 1.19 $" /**< \ingroup grp_hal_nfc_llc */ -#define PHLLCNFCFRAME_FILEALIASES "$Aliases: NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_hal_nfc_llc */ -/*@}*/ - -/*************************** Includes *******************************/ - -/*********************** End of includes ****************************/ - -/** \defgroup grp_hal_nfc_llc_helper LLC helper functions - * - * - * - */ - -/***************************** Macros *******************************/ -/** Maximum buffer that LLC can send and receive */ -#define PH_LLCNFC_MAX_BUFLEN_RECV_SEND (33) -/** Maximum buffer that LLC can send and receive */ -#define PH_LLCNFC_MIN_BUFLEN_RECVD (1) -/** Modulo to calculate the N(S) and N(R), when it extends 7, because - N(S) and N(R) can have the value maximum up to 7 */ -#define PH_LLCNFC_MOD_NS_NR (8) -/** When the entire LLC buffer is created or received, the header byte - will be the first byte (not the 0th byte which is the LLC length) - of the buffer */ -#define PH_LLCNFC_HEADER_BYTE_IN_BUFFER (1) -/** Maximum windows size, which is obtained by sending or - receiving the U - frame */ -#define PH_LLCNFC_U_FRAME_MAX_WIN_SIZE (4) -/** Minimum windows size, which is obtained by sending or - receiving the U - frame */ -#define PH_LLCNFC_U_FRAME_MIN_WIN_SIZE (2) -/** Start position of the U frame */ -#define PH_LLCNFC_U_FRAME_START_POS (0) -/** No of position to set the U frame */ -#define PH_LLCNFC_U_FRAME_NO_OF_POS (5) -/** This mask is to find the frame type ( S or U) */ -#define PH_LLCNFC_LLC_HEADER_MASK (0xE0) -/** This mask is to find the frame type (I, S or U) */ -#define PH_LLCNFC_I_FRM_HEADER_MASK (0x80) -/** If S frame is received or to be sent, the maximum length that - can be sent or received is 4 */ -#define PH_LLCNFC_MAX_S_FRAME_LEN (4) -/** If S frame is received, to know the command type like RR, RNR, - REJ or SREJ */ -#define PH_LLCNFC_S_FRAME_TYPE_MASK (0x18) -/** Maximum value of N(S) or N(R) */ -#define PH_LLCNFC_I_S_FRAME_MAX_NR (0x07) -/** If U frame is received or to be sent, the maximum length that - can be sent or received is 7 */ -#define PH_LLCNFC_U_FRAME_LEN (7) -/** If S frame is received, to know the command type like RSET or UA */ -#define PH_LLCNFC_U_FRAME_MODIFIER_MASK (0x1F) -/** Extra length to be append to the user buffer Length to create the - LLC buffer */ -#define PH_LLCNFC_LEN_APPEND (0x04) -/** U frame header without modifier */ -#define PH_LLCNFC_U_HEADER_INIT (0xE0) -/** I frame header without N(S) and N(R) */ -#define PH_LLCNFC_I_HEADER_INIT (0x80) -/** S frame header without type and N(R) */ -#define PH_LLCNFC_S_HEADER_INIT (0xC0) -/** N(S) start bit position */ -#define PH_LLCNFC_NS_START_BIT_POS (0x03) -/** N(R) start bit position */ -#define PH_LLCNFC_NR_START_BIT_POS (0x00) -/** Number of bits N(R) and N(S) */ -#define PH_LLCNFC_NR_NS_NO_OF_BITS (0x03) -/** S frame type start bit position */ -#define PH_LLCNFC_S_FRAME_TYPE_POS (0x03) -/** Number of bits (Type in S frame) */ -#define PH_LLCNFC_SFRAME_TYPE_NOOFBITS (0x02) -/** SREJ command */ -#define PH_LLCNFC_SREJ_BYTE_VALUE (0x00) -/** Number of CRC bytes in a LLC packet */ -#define PH_LLCNFC_NUM_OF_CRC_BYTES (0x02) - -/* This macro is used as the input for the function "phLlcNfc_H_IFrameList_Peek" - and "phLlcNfc_H_SendTimedOutIFrame" functions. This values means, take the starting - position as the reference */ -#define DEFAULT_PACKET_INPUT (0xFFU) -#define MAX_NS_NR_VALUE (0x07U) - -/************************ End of macros *****************************/ - -/********************** Callback functions **************************/ - -/******************* End of Callback functions **********************/ - -/********************* Structures and enums *************************/ - -/****************** End of structures and enums *********************/ - -/******************** Function declarations *************************/ -/** -* \ingroup grp_hal_nfc_llc_helper -* -* \brief LLC helper functions \b Frame Init function -* -* \copydoc page_reg Gets the LLC main context and stores it. -* -* \param[in] psLlcCtxt Llc main structure information -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. -* -*/ -void phLlcNfc_H_Frame_Init ( - phLlcNfc_Context_t *psLlcCtxt -); - -/** -* \ingroup grp_hal_nfc_llc_helper -* -* \brief LLC helper functions \b DeInit function -* -* \copydoc page_reg -* -* \param[in] psFrameInfo Frame structure information -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. -* -*/ -void -phLlcNfc_H_Frame_DeInit ( - phLlcNfc_Frame_t *psFrameInfo -); - -/** -* \ingroup grp_hal_nfc_llc_helper -* -* \brief LLC helper functions \b List append function -* -* \copydoc page_reg Append the new I frame information at the beginning of the list -* -* \param[in/out] psList List inofrmation to know where shall the packet should be stored -* \param[in] packetInfo Llc packet information -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. -* -*/ -NFCSTATUS -phLlcNfc_H_StoreIFrame ( - phLlcNfc_StoreIFrame_t *psList, - phLlcNfc_LlcPacket_t sPacketInfo - -); - - -/** -* \ingroup grp_hal_nfc_llc_helper -* -* \brief LLC helper functions Create S frame function -* -* \copydoc page_reg This function creates a S frame -* -* \param[in/out] pllcSFrmBuf Required buffer to create the S frame -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. -* -*/ -void -phLlcNfc_H_Create_S_Frame( - uint8_t *pllcSFrmBuf -); - -/** -* \ingroup grp_hal_nfc_llc_helper -* -* \brief LLC helper functions Compute CRC function -* -* \copydoc page_reg This function is used to compute CRC for the llc data -* -* \param[in] pData Llc data for which the CRC needs to be calculated -* \param[in] length Length is the value till the CRC needs to be -* calculated for the Llc data -* \param[in] pCrc1 1st CRC byte -* \param[in] pCrc2 2nd CRC byte -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. -* -*/ -void -phLlcNfc_H_ComputeCrc( - uint8_t *pData, - uint8_t length, - uint8_t *pCrc1, - uint8_t *pCrc2 -); - -/** -* \ingroup grp_hal_nfc_llc_helper -* -* \brief LLC helper functions Create U frame payload function -* -* \copydoc page_reg This function is used to create a LLC packet with U frame -* -* \param[in/out] psLlcCtxt Llc main structure information -* \param[in/out] psLlcPacket Llc packet sent by the upper layer -* \param[in/out] pLlcPacketLength Length of the llc packet -* \param[in] cmdType U frame has RSET/UA commands -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. -* -*/ -NFCSTATUS -phLlcNfc_H_CreateUFramePayload ( - phLlcNfc_Context_t *psLlcCtxt, - phLlcNfc_LlcPacket_t *psLlcPacket, - uint8_t *pLlcPacketLength, - phLlcNfc_LlcCmd_t cmdType -); - -/** -* \ingroup grp_hal_nfc_llc_helper -* -* \brief LLC helper functions Create I frame payload function -* -* \copydoc page_reg This function is used to create a LLC packet with I frame -* -* \param[in/out] psFrameInfo Information related to LLC frames are stored -* in this structure -* \param[in/out] psLlcPacket Llc packet sent by the upper layer -* \param[in] pLlcBuf User given buffer or the buffer which needs LLC framing -* \param[in] llcBufLength Length of the parameter "pLlcBuf" -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. -* -*/ -NFCSTATUS -phLlcNfc_H_CreateIFramePayload ( - phLlcNfc_Frame_t *psFrameInfo, - phLlcNfc_LlcPacket_t *psLlcPacket, - uint8_t *pLlcBuf, - uint8_t llcBufLength -); - -/** - * \ingroup grp_hal_nfc_llc_helper - * - * \brief LLC helper functions Process received frame function - * - * \copydoc page_reg This function process the received data - * - * \param[in] pLlcCtxt Llc main context - * - * \retval NFCSTATUS_SUCCESS Operation successful. - * \retval NFCSTATUS_INVALID_FORMAT If any error in the frame - */ -NFCSTATUS -phLlcNfc_H_ProRecvFrame ( - phLlcNfc_Context_t *psLlcCtxt -); - -/** -* \ingroup grp_hal_nfc_llc_helper -* -* \brief LLC component resend the I frame function -* -* \copydoc page_reg This is a helper function which, sends back the timed out -* I frame to the PN544. This is due to the reason that ACK is not received -* from PN544 within the guard time-out value -* -* \param[in] psLlcCtxt Llc main structure information -* \param[in/out] psListInfo List of I frame information -* \param[in] ns_frame_no Frame number to send (to send the first stored -* frame send DEFAULT_PACKET_INPUT) -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. -* -*/ -extern -NFCSTATUS -phLlcNfc_H_SendTimedOutIFrame ( - phLlcNfc_Context_t *psLlcCtxt, - phLlcNfc_StoreIFrame_t *psListInfo, - uint8_t ns_frame_no -); - -/** -* \ingroup grp_hal_nfc_llc_helper -* -* \brief LLC state machine functions \b Change state function -* -* \copydoc page_reg changes the state if possible else returns error -* -* \param[in, out] psLlcCtxt Llc main structure information -* \param[in] changeStateTo Next state to change -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. -* -*/ -extern -NFCSTATUS -phLlcNfc_H_ChangeState( - phLlcNfc_Context_t *psLlcCtxt, - phLlcNfc_State_t changeStateTo - ); - -#ifdef CRC_ERROR_REJ -/** -* \ingroup grp_hal_nfc_llc_helper -* -* \brief LLC send reject command function -* -* \copydoc page_reg Sends reject command, when CRC error is recieved -* -* \param[in, out] psLlcCtxt Llc main structure information -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. -* -*/ -extern -NFCSTATUS -phLlcNfc_H_SendRejectFrame( - phLlcNfc_Context_t *psLlcCtxt - ); -#endif /* #ifdef CRC_ERROR_REJ */ - -/** -* \ingroup grp_hal_nfc_llc_helper -* -* \brief LLC Write wait call function -* -* \copydoc page_reg Write that has been ignored earlier will be called in this function -* -* \param[in, out] psLlcCtxt Llc main structure information -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_BUSY Write is pended, so wait till it completes. -* \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. -* -*/ -extern -NFCSTATUS -phLlcNfc_H_WriteWaitCall ( - phLlcNfc_Context_t *psLlcCtxt - ); - -/** -* \ingroup grp_hal_nfc_llc_helper -* -* \brief LLC Send user frame function -* -* \copydoc page_reg Sends the stored user frame, that are not sent. -* -* \param[in, out] psLlcCtxt Llc main structure information -* \param[in] psListInfo Stored list of packets -* -* No return value -* -*/ -NFCSTATUS -phLlcNfc_H_SendUserIFrame ( - phLlcNfc_Context_t *psLlcCtxt, - phLlcNfc_StoreIFrame_t *psListInfo - ); - -/** -* \ingroup grp_hal_nfc_llc_helper -* -* \brief LLC Send rejected frame function -* -* \copydoc page_reg Sends the stored rejected frame from PN544. -* -* \param[in, out] psLlcCtxt Llc main structure information -* \param[in] psListInfo Stored list of packets -* \param[in] ns_rejected N(S) that was rejected -* -* No return value -* -*/ -NFCSTATUS -phLlcNfc_H_SendRejectedIFrame ( - phLlcNfc_Context_t *psLlcCtxt, - phLlcNfc_StoreIFrame_t *psListInfo, - uint8_t ns_rejected - ); - -/** -* \ingroup grp_hal_nfc_llc_helper -* -* \brief LLC component Create S frame function -* -* \copydoc page_reg This is a helper function which, creates the S frame -* -* \param[in/out] psFrameInfo Generic frame information -* \param[in/out] psLlcPacket Llc packet sent by the upper layer -* \param[in/out] cmdType Command type of S frame -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. -* -*/ -NFCSTATUS -phLlcNfc_H_CreateSFramePayload ( - phLlcNfc_Frame_t *psFrameInfo, - phLlcNfc_LlcPacket_t *psLlcPacket, - phLlcNfc_LlcCmd_t cmdType -); - -/** -* \ingroup grp_hal_nfc_llc_helper -* -* \brief LLC Send upper layer information function -* -* \copydoc page_reg Sends received information to the upper layer frame. -* -* \param[in, out] psLlcCtxt Llc main structure information -* -* No return value -* -*/ -void -phLlcNfc_H_SendInfo( - phLlcNfc_Context_t *psLlcCtxt - ); - - -/******************** Function declarations *************************/ -#endif /* #ifndef PHLLCNFC_FRAME_H */ - - diff --git a/libnfc-nxp/phLlcNfc_Interface.h b/libnfc-nxp/phLlcNfc_Interface.h deleted file mode 100644 index 45bf703..0000000 --- a/libnfc-nxp/phLlcNfc_Interface.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! -* \file phLlcNfc_Interface.h -* \brief Interface for both LLC and transport layer -* -* Project: NFC-FRI-1.1 -* -* $Date: Thu Sep 11 12:19:29 2008 $ -* $Author: ing02260 $ -* $Revision: 1.9 $ -* $Aliases: NFC_FRI1.1_WK838_PREP1,NFC_FRI1.1_WK838_R9_PREP2,NFC_FRI1.1_WK838_R9_1,NFC_FRI1.1_WK840_R10_PREP1,NFC_FRI1.1_WK840_R10_1,NFC_FRI1.1_WK842_R11_PREP1,NFC_FRI1.1_WK842_R11_PREP2,NFC_FRI1.1_WK842_R11_1,NFC_FRI1.1_WK844_PREP1,NFC_FRI1.1_WK844_R12_1,NFC_FRI1.1_WK846_PREP1,NFC_FRI1.1_WK846_R13_1,NFC_FRI1.1_WK848_PREP1,NFC_FRI1.1_WK848_R14_1,NFC_FRI1.1_WK849_PACK1_PREP1,NFC_FRI1.1_WK850_PACK1,NFC_FRI1.1_WK851_PREP1,NFC_FRI1.1_WK850_R15_1,NFC_FRI1.1_WK902_PREP1,NFC_FRI1.1_WK902_R16_1,NFC_FRI1.1_WK904_PREP1,NFC_FRI1.1_WK904_R17_1,NFC_FRI1.1_WK906_R18_1,NFC_FRI1.1_WK908_PREP1,NFC_FRI1.1_WK908_R19_1,NFC_FRI1.1_WK910_PREP1,NFC_FRI1.1_WK910_R20_1,NFC_FRI1.1_WK912_PREP1,NFC_FRI1.1_WK912_R21_1,NFC_FRI1.1_WK914_PREP1,NFC_FRI1.1_WK914_R22_1,NFC_FRI1.1_WK914_R22_2,NFC_FRI1.1_WK916_R23_1,NFC_FRI1.1_WK918_R24_1,NFC_FRI1.1_WK920_PREP1,NFC_FRI1.1_WK920_R25_1,NFC_FRI1.1_WK922_PREP1,NFC_FRI1.1_WK922_R26_1,NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK926_R28_2,NFC_FRI1.1_WK926_R28_3,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ -* -*/ - -#ifndef PHLLCNFC_INTERFACE_H -#define PHLLCNFC_INTERFACE_H - -/** -* \name LLC TL NFC interface -* -* File: \ref phLlcTlNfc_Interface.h -* -*/ -/*@{*/ -#define PH_LLCNFC_INTERFACE_FILEREVISION "$Revision: 1.9 $" /**< \ingroup grp_hal_nfc_llc */ -#define PH_LLCNFC_INTERFACE_FILEALIASES "$Aliases: NFC_FRI1.1_WK838_PREP1,NFC_FRI1.1_WK838_R9_PREP2,NFC_FRI1.1_WK838_R9_1,NFC_FRI1.1_WK840_R10_PREP1,NFC_FRI1.1_WK840_R10_1,NFC_FRI1.1_WK842_R11_PREP1,NFC_FRI1.1_WK842_R11_PREP2,NFC_FRI1.1_WK842_R11_1,NFC_FRI1.1_WK844_PREP1,NFC_FRI1.1_WK844_R12_1,NFC_FRI1.1_WK846_PREP1,NFC_FRI1.1_WK846_R13_1,NFC_FRI1.1_WK848_PREP1,NFC_FRI1.1_WK848_R14_1,NFC_FRI1.1_WK849_PACK1_PREP1,NFC_FRI1.1_WK850_PACK1,NFC_FRI1.1_WK851_PREP1,NFC_FRI1.1_WK850_R15_1,NFC_FRI1.1_WK902_PREP1,NFC_FRI1.1_WK902_R16_1,NFC_FRI1.1_WK904_PREP1,NFC_FRI1.1_WK904_R17_1,NFC_FRI1.1_WK906_R18_1,NFC_FRI1.1_WK908_PREP1,NFC_FRI1.1_WK908_R19_1,NFC_FRI1.1_WK910_PREP1,NFC_FRI1.1_WK910_R20_1,NFC_FRI1.1_WK912_PREP1,NFC_FRI1.1_WK912_R21_1,NFC_FRI1.1_WK914_PREP1,NFC_FRI1.1_WK914_R22_1,NFC_FRI1.1_WK914_R22_2,NFC_FRI1.1_WK916_R23_1,NFC_FRI1.1_WK918_R24_1,NFC_FRI1.1_WK920_PREP1,NFC_FRI1.1_WK920_R25_1,NFC_FRI1.1_WK922_PREP1,NFC_FRI1.1_WK922_R26_1,NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK926_R28_2,NFC_FRI1.1_WK926_R28_3,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_hal_nfc_llc */ -/*@}*/ -/*************************** Includes *******************************/ - -/*********************** End of includes ****************************/ - -/***************************** Macros *******************************/ -#define PH_LLCNFC_READWAIT_OFF 0 -#define PH_LLCNFC_READWAIT_ON 1 - -/************************ End of macros *****************************/ - -/********************** Callback functions **************************/ - -/******************* End of Callback functions **********************/ - -/********************* Structures and enums *************************/ - -/****************** End of structures and enums *********************/ - -/******************** Function declarations *************************/ - -NFCSTATUS -phLlcNfc_Interface_Register( - phLlcNfc_Context_t *psLlcCtxt, - phNfcLayer_sCfg_t *psIFConfig -); - -NFCSTATUS -phLlcNfc_Interface_Init( - phLlcNfc_Context_t *psLlcCtxt -); - -NFCSTATUS -phLlcNfc_Interface_Read( - phLlcNfc_Context_t *psLlcCtxt, - uint8_t readWaitOn, - uint8_t *pLlcBuffer, - uint32_t llcBufferLength -); - -NFCSTATUS -phLlcNfc_Interface_Write( - phLlcNfc_Context_t *psLlcCtxt, - uint8_t *pLlcBuffer, - uint32_t llcBufferLength -); - -/** -* \ingroup grp_hal_nfc_llc -* -* \brief \b Release function -* -* \copydoc page_reg Release all the variables of the LLC component, that has been -* initialised in \b phLlcNfc_Init function (Synchronous function). -* -* \param[in] pContext LLC context is provided by the upper layer. The LLC -* context earlier was given to the upper layer through the -* \ref phLlcNfc_Register function -* \param[in] pLinkInfo Link information of the hardware -* -* \retval NFCSTATUS_PENDING If the command is yet to be processed. -* \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. -* \retval Other errors Errors related to the lower layers -* -*/ -extern -NFCSTATUS -phLlcNfc_Release( - void *pContext, - void *pLinkInfo - ); -/****************** End of Function declarations ********************/ -#endif /* PHLLCTLNFC_INTERFACE_H */ diff --git a/libnfc-nxp/phLlcNfc_Timer.h b/libnfc-nxp/phLlcNfc_Timer.h deleted file mode 100644 index f212a32..0000000 --- a/libnfc-nxp/phLlcNfc_Timer.h +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*! -* \file phLlcNfc_Timer.h -* \brief To create, start, stop and destroy timer. -* -* Project: NFC-FRI-1.1 -* -* $Date: Thu Jun 10 17:26:41 2010 $ -* $Author: ing02260 $ -* $Revision: 1.14 $ -* $Aliases: NFC_FRI1.1_WK1023_R35_1 $ -* -*/ - -#ifndef PHLLCNFC_TIMER_H -#define PHLLCNFC_TIMER_H - -/** -* \name LLC NFC state machine handling -* -* File: \ref phLlcNfc_StateMachine.h -* -*/ -/*@{*/ -#define PH_LLCNFC_TIMER_FILEREVISION "$Revision: 1.14 $" /**< \ingroup grp_hal_nfc_llc_helper */ -#define PH_LLCNFC_TIMER_FILEALIASES "$Aliases: NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_hal_nfc_llc_helper */ -/*@}*/ -/*************************** Includes *******************************/ - -/*********************** End of includes ****************************/ - -/***************************** Macros *******************************/ -#define PH_LLCNFC_CONNECTIONTIMER (0x00) /**< Timer for connection time out */ -#define PH_LLCNFC_GUARDTIMER (0x01) /**< Timer for guard time out */ -#define PH_LLCNFC_ACKTIMER (0x02) /**< Timer for ack time out */ -#define PH_LLCNFC_MAX_RETRY_COUNT (0x03) /**< Retries */ -/** Resolution value for the timer */ -#define PH_LLCNFC_RESOLUTION TIMER_RESOLUTION -/**< 0x05 Timer for connection time out value */ -#define PH_LLCNFC_CONNECTION_TO_VALUE LINK_CONNECTION_TIMEOUT -/**< 0x05 Timer for guard time out value */ -#define PH_LLCNFC_GUARD_TO_VALUE LINK_GUARD_TIMEOUT - -#ifdef PIGGY_BACK - -#define PH_LLCNFC_ACK_TO_VALUE LINK_ACK_TIMEOUT - -#endif /* #ifdef PIGGY_BACK */ - -#ifdef LLC_RESET_DELAY - #define LLC_URSET_DELAY_TIME_OUT LLC_RESET_DELAY -#else - #define LLC_URSET_DELAY_TIME_OUT 50 -#endif /* */ - - - -/************************ End of macros *****************************/ - -/********************** Callback functions **************************/ - -/******************* End of Callback functions **********************/ - -/********************* Structures and enums *************************/ - -/****************** End of structures and enums *********************/ - -/******************** Function declarations *************************/ -/** -* \ingroup grp_hal_nfc_llc_helper -* -* \brief LLC timer functions \b Timer Init function -* -* \copydoc page_reg This is to store LLCs main context structure -* -* \param[in, out] psLlcCtxt Llc main structure information -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. -* -*/ -NFCSTATUS -phLlcNfc_TimerInit ( - phLlcNfc_Context_t *psLlcCtxt -); - -/** -* \ingroup grp_hal_nfc_llc_helper -* -* \brief LLC timer functions \b Timer UnInit function -* -* \copydoc page_reg This is to uninitialise all timer related information -* -* \param[in, out] psLlcCtxt Llc main structure information -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. -* -*/ -void -phLlcNfc_TimerUnInit ( - phLlcNfc_Context_t *psLlcCtxt -); - -/** -* \ingroup grp_hal_nfc_llc_helper -* -* \brief LLC timer functions \b Create timer function -* -* \copydoc page_reg creates all the timers in the LLC context -* -* -*/ -void -phLlcNfc_CreateTimers (void); - -/** -* \ingroup grp_hal_nfc_llc_helper -* -* \brief LLC timer functions \b Start timer function -* -* \copydoc page_reg starts the timer type given by the user -* -* \param[in] TimerType Timer type to start -* \param[in] ns_value Value of N(S) for which the timer is started -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. -* \retval Others Errors related to OsalNfc. -* -*/ -NFCSTATUS -phLlcNfc_StartTimers ( - uint8_t TimerType, - uint8_t ns_value -); - -/** -* \ingroup grp_hal_nfc_llc_helper -* -* \brief LLC timer functions \b Stop timer function -* -* \copydoc page_reg stop the timer type given by the user -* -* \param[in] TimerType Timer type to start -* \param[in] no_of_gaurd_to_del Guard time-out count shall be decreased as and when -* frame is removed -* -* -*/ -void -phLlcNfc_StopTimers ( - uint8_t TimerType, - uint8_t no_of_guard_to_del -); - -/** -* \ingroup grp_hal_nfc_llc_helper -* -* \brief LLC timer functions \b Stop timer function -* -* \copydoc page_reg stop the timer type given by the user -* -* -* -* -*/ -void -phLlcNfc_StopAllTimers (void); - - -/** -* \ingroup grp_hal_nfc_llc_helper -* -* \brief LLC timer functions \b Delete timer function -* -* \copydoc page_reg deletes all the timers in the LLC context -* -* \retval NFCSTATUS_SUCCESS Operation successful. -* \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. -* \retval Others Errors related to OsalNfc. -* -*/ -void -phLlcNfc_DeleteTimer (void); - -#ifdef LLC_URSET_NO_DELAY - - /* NO definition required */ - -#else /* #ifdef LLC_URSET_NO_DELAY */ - -void -phLlcNfc_URSET_Delay_Notify ( - - uint32_t delay_id); - - - -#endif /* #ifdef LLC_URSET_NO_DELAY */ - -/****************** End of Function declarations ********************/ -#endif /* PHLLCNFC_TIMER_H */ diff --git a/libnfc-nxp/phNfcCompId.h b/libnfc-nxp/phNfcCompId.h deleted file mode 100644 index 4cb95af..0000000 --- a/libnfc-nxp/phNfcCompId.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * \file phNfcCompId.h - * \brief NFC Component ID Values - Used for Function Return Codes - * - * Project: NFC MW / HAL - * - * $Date: Thu Mar 12 12:00:30 2009 $ - * $Author: ing04880 $ - * $Revision: 1.6 $ - * $Aliases: NFC_FRI1.1_WK912_PREP1,NFC_FRI1.1_WK912_R21_1,NFC_FRI1.1_WK914_PREP1,NFC_FRI1.1_WK914_R22_1,NFC_FRI1.1_WK914_R22_2,NFC_FRI1.1_WK916_R23_1,NFC_FRI1.1_WK918_R24_1,NFC_FRI1.1_WK920_PREP1,NFC_FRI1.1_WK920_R25_1,NFC_FRI1.1_WK922_PREP1,NFC_FRI1.1_WK922_R26_1,NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ - * - */ - -#ifndef PHNFCCOMPID_H /* */ -#define PHNFCCOMPID_H /* */ - -#ifndef PH_FRINFC_EXCLUDE_FROM_TESTFW /* */ - -/** - * \name NFC Comp. ID - * - * File: \ref phNfcCompId.h - * - */ -/*@{*/ -#define PHNFCCOMPID_FILEREVISION "$Revision: 1.6 $" /**< \ingroup grp_file_attributes */ -#define PHNFCCOMPID_FILEALIASES "$Aliases: NFC_FRI1.1_WK912_PREP1,NFC_FRI1.1_WK912_R21_1,NFC_FRI1.1_WK914_PREP1,NFC_FRI1.1_WK914_R22_1,NFC_FRI1.1_WK914_R22_2,NFC_FRI1.1_WK916_R23_1,NFC_FRI1.1_WK918_R24_1,NFC_FRI1.1_WK920_PREP1,NFC_FRI1.1_WK920_R25_1,NFC_FRI1.1_WK922_PREP1,NFC_FRI1.1_WK922_R26_1,NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ -/*@}*/ - -#endif /* PH_FRINFC_EXCLUDE_FROM_TESTFW */ - -/** - * \ingroup grp_comp_id - * - * \name Component IDs - * - * IDs for all NFC components. Combined with the Status Code they build the value (status) - * returned by each function. - * - * ID Number Spaces: - * - 01..1F: HAL - * - 20..3F: NFC-MW (Local Device) - * - 40..5F: NFC-MW (Remote Device) - * . - * - * \note The value \ref CID_NFC_NONE does not exist for Component IDs. Do not use this value except - * for \ref NFCSTATUS_SUCCESS. The enumeration function uses \ref CID_NFC_NONE - * to mark unassigned \ref phHal_sHwReference_t "Hardware References". - * - * \if hal - * \sa \ref phHalNfc_Enumerate - * \endif - */ -/*@{*/ -#define CID_NFC_NONE 0x00 /**< \ingroup grp_comp_id - Unassigned or doesn't apply (see \ref NFCSTATUS_SUCCESS). */ -#define CID_NFC_DAL 0x01 /**< \ingroup grp_comp_id - Driver Abstraction Layer - \if hal (\ref grp_subcomponents) \endif . */ -#define CID_NFC_LLC 0x07 /**< \ingroup grp_comp_id - Logical Link Control Layer - \if hal (\ref grp_subcomponents) \endif . */ -#define CID_NFC_HCI 0x08 /**< \ingroup grp_comp_id - Host Control Interface Layer - \if hal (\ref grp_subcomponents) \endif . */ -#define CID_NFC_DNLD 0x09 /**< \ingroup grp_comp_id - Firmware Download Management Layer - \if hal (\ref grp_subcomponents) \endif . */ -#define CID_NFC_HAL 0x10 /**< \ingroup grp_comp_id - Hardware Abstraction Layer \if hal (\ref grp_hal_common) \endif . */ -#define CID_FRI_NFC_OVR_HAL 0x20 /**< \ingroup grp_comp_id - NFC-Device, HAL-based. */ -#define CID_FRI_NFC_NDEF_RECORD 0x22 /**< \ingroup grp_comp_id - NDEF Record Tools Library. */ -#define CID_FRI_NFC_NDEF_MAP 0x23 /**< \ingroup grp_comp_id - NDEF Mapping. */ -#define CID_FRI_NFC_NDEF_REGISTRY 0x24 /**< \ingroup grp_comp_id - NDEF_REGISTRY. */ -#define CID_FRI_NFC_AUTO_DEV_DIS 0x25 /**< \ingroup grp_comp_id - Automatic Device Discovery. */ -#define CID_FRI_NFC_NDEF_SMTCRDFMT 0x26 /**< \ingroup grp_comp_id - Smart Card Formatting */ -#define CID_FRI_NFC_LLCP 0x27 /**< \ingroup grp_comp_id - LLCP Core. */ -#define CID_FRI_NFC_LLCP_MAC 0x28 /**< \ingroup grp_comp_id - LLCP Mac Mappings. */ -#define CID_FRI_NFC_LLCP_TRANSPORT 0x29 /**< \ingroup grp_comp_id - LLCP Transport. */ -#define CID_NFC_LIB 0x30 /**< \ingroup grp_comp_id - NFC Library Layer \if hal (\ref grp_hal_common) \endif . */ -#define CID_MAX_VALUE 0xF0 /**< \ingroup grp_comp_id - The maximum CID value that is defined. */ - -/*@}*/ - -#endif /* PHNFCCOMPID_H */ diff --git a/libnfc-nxp/phNfcConfig.h b/libnfc-nxp/phNfcConfig.h deleted file mode 100644 index 955c26b..0000000 --- a/libnfc-nxp/phNfcConfig.h +++ /dev/null @@ -1,543 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -/** -* \file phNfcConfig.h -* \brief HAL Configurations -* -* -* \note This is the configuration header file of the HAL 4.0.All configurable parameters of the HAL 4.0 -* are provided in this file -* -* Project: NFC-FRI-1.1 / HAL4.0 -* -* $Date: Thu Sep 9 14:56:35 2010 $ -* $Author: ing04880 $ -* $Revision: 1.39 $ -* $Aliases: $ -* -*/ - - -/*@{*/ -#ifndef PHNFC_CONFIG_H -#define PHNFC_CONFIG_H -/*@}*/ - - -/** -* \name Hal -* -* File: \ref phNfcConfig.h -* -*/ - -/*@{*/ -#define PH_NFC_CONFIG_FILEREVISION "$Revision: 1.39 $" /**< \ingroup grp_file_attributes */ -#define PH_NFC_CONFIG_FILEALIASES "$Aliases: $" /**< \ingroup grp_file_attributes */ -/*@}*/ - - -/* -----------------Include files ---------------------------------------*/ - -#ifdef NFC_CUSTOM_CONFIG_INCLUDE -#include -#endif - -/* ---------------- Macros ----------------------------------------------*/ - - - -/* - ***************************************************************** - ********************** DEFAULT MACROS ************************** - ***************************************************************** - */ - - -/**< External Clock Request Configuration for the NFC Device, - 0x00U No Clock Request, - 0x01U Clock Request through CLKREQ pin (GPIO pin 2), - 0x02U Clock Request through NXP_EVT_CLK_REQUEST Event, - */ -#ifndef NXP_DEFAULT_CLK_REQUEST -#define NXP_DEFAULT_CLK_REQUEST 0x00U -#endif - -/**< External Input Clock Setting for the NFC Device, - 0x00U No Input Clock Required (Use the Xtal), - 0x01U 13 MHZ, - 0x02U 19.2 MHZ, - 0x03U 26 MHZ, - 0x04U 38.4 MHZ, - 0x05U Custom (Set the Custome Clock Registry), - */ - -#ifndef NXP_DEFAULT_INPUT_CLK -#define NXP_DEFAULT_INPUT_CLK 0x00U -#endif - -/**< UICC Power Request configuration for the NFC Device, - 0x00U No Power Request, - 0x01U Power Request through CLKREQ pin (GPIO pin 2), - 0x02U Power Request through PWR_REQUEST (GPIO Pin 3), - */ - -#ifndef NXP_UICC_PWR_REQUEST -#define NXP_UICC_PWR_REQUEST 0x00U -#endif - -/**< TX LDO Configuration - 0x00 00b 3.0 V, - 0x01 01b 3.0 V, - 0x02 10b 2.7 V, - 0x03 11b 3.3 V, - */ - -#ifndef NXP_DEFAULT_TX_LDO -#define NXP_DEFAULT_TX_LDO 0x00U -#endif - -/**< UICC Bit Rate Configuration - 0x02 212Kbits/Sec - 0x04 424Kbits/Sec - 0x08 828Kbits/Sec - */ - -#ifndef NXP_UICC_BIT_RATE -#define NXP_UICC_BIT_RATE 0x08U -#endif - - -/**< Indicates PN544 Power Modes Configuration for the NFC Device, - 0x00U -> PN544 stays in active bat mode - (except when generating RF field) - 0x01U -> PN544 goes in standby when possible otherwise - stays in active bat mode - 0x02U -> PN544 goes in idle mode as soon as it can - (otherwise it is in active bat except when generating RF field) - 0x03U -> PN544 goes in standby when possible otherwise goes in idle mode - as soon as it can (otherwise it is in active bat except when - generating RF field) - */ - -#ifndef NXP_SYSTEM_PWR_STATUS -#define NXP_SYSTEM_PWR_STATUS 0x01U -#endif - -/**< Default Session ID for Initialisation */ -#ifndef DEFAULT_SESSION -#define DEFAULT_SESSION "android8" -#endif - - -/* The Other Integration Configuration Values */ - -/**< Max number of remote devices supported */ - -#ifndef MAX_REMOTE_DEVICES -#define MAX_REMOTE_DEVICES 0x0A -#endif - -/**< System Event Notification - 0x01 Overcurrent - 0x02 PMUVCC Switch - 0x04 External RF Field - 0x08 Memory Violation - 0x10 Temperature Overheat - */ - -#ifndef NXP_SYSTEM_EVT_INFO -#define NXP_SYSTEM_EVT_INFO 0x3DU -#endif - - -#ifndef NFC_DEV_HWCONF_DEFAULT -#define NFC_DEV_HWCONF_DEFAULT 0xBCU -#endif - - -#ifndef NXP_ISO_XCHG_TIMEOUT -#define NXP_ISO_XCHG_TIMEOUT 0x1BU -#endif - -#ifndef NXP_MIFARE_XCHG_TIMEOUT -#define NXP_MIFARE_XCHG_TIMEOUT 0x0BU -#endif - -#ifndef NXP_FELICA_XCHG_TIMEOUT -#define NXP_FELICA_XCHG_TIMEOUT 0xFFU -#endif - - -#ifndef NXP_NFCIP_PSL_BRS_DEFAULT -#define NXP_NFCIP_PSL_BRS_DEFAULT 0x00U -#endif - - - -/**< ID For Invalid Timer */ -#ifndef NXP_INVALID_TIMER_ID -#define NXP_INVALID_TIMER_ID 0xFFFFFFFFU -#endif - -/**< Presence check interval in milliseconds */ -#ifndef PRESENCE_CHECK_INTERVAL -#define PRESENCE_CHECK_INTERVAL 500U -#endif - -/** Resolution value for the timer, here the - timer resolution is 500 milliseconds */ -#ifndef TIMER_RESOLUTION -#define TIMER_RESOLUTION 500U -#endif - -/* Kindly note that the below Timeout values should be - * in Multiples of the value provided to TIMER_RESOLUTION - */ - -/**< Defines guard time out value for LLC timer, - 1000 is in milliseconds */ -#ifndef LINK_GUARD_TIMEOUT -#define LINK_GUARD_TIMEOUT 1000U -#endif - - -/**< Defines connection time out value for LLC timer, - 1000 is in milliseconds */ -#ifndef LINK_CONNECTION_TIMEOUT -#define LINK_CONNECTION_TIMEOUT 1000U -#endif - -/**< Defines ACK time out value for LLC timer, - 150 is in milliseconds */ -#ifndef LINK_ACK_TIMEOUT -#define LINK_ACK_TIMEOUT 1U -#endif - - -/**< Defines Firmware Download Completion Timeout value , - 120000 is in milliseconds */ - - -#ifndef NXP_DNLD_COMPLETE_TIMEOUT -#define NXP_DNLD_COMPLETE_TIMEOUT 60000U -#endif - - -/**< Define to configure the Active Mode Polling Guard Time-out - */ - -#ifndef DEV_MGMT_ACT_GRD_TO_DEFAULT -#define DEV_MGMT_ACT_GRD_TO_DEFAULT 0x20U -#endif - -/**< NFCIP Active Mode Default Configuration (when acting as Target) - 0x01 106 kbps - 0x02 212 kbps - 0x04 424 kbps - */ - -#ifndef NXP_NFCIP_ACTIVE_DEFAULT -#define NXP_NFCIP_ACTIVE_DEFAULT 0x01U -#endif - - - - -#ifndef NXP_NFC_HCI_TIMER -#define NXP_NFC_HCI_TIMER 1 -#define NXP_NFC_HCI_TIMEOUT 6000 -#endif - - -/* - ***************************************************************** - DO NOT MODIFY THE BELOW MACROS UNLESS OTHERWISE MENTIONED - ***************************************************************** - */ - - - -#ifndef HOST_CE_A_SAK_DEFAULT -#define HOST_CE_A_SAK_DEFAULT 0x20U -#endif - -#ifndef NXP_CE_A_ATQA_HIGH -#define NXP_CE_A_ATQA_HIGH 0x00U -#endif - -#ifndef NXP_CE_A_ATQA_LOW -#define NXP_CE_A_ATQA_LOW 0x04U -#endif - - -#ifndef NXP_UICC_CE_RIGHTS -#define NXP_UICC_CE_RIGHTS 0x0FU -#endif - -#ifndef NXP_UICC_RD_RIGHTS -#define NXP_UICC_RD_RIGHTS 0x00U -#endif - - -/* - ***************************************************************** - DO NOT DISABLE/ENABLE BELOW MACROS UNLESS OTHERWISE MENTIONED - ***************************************************************** - */ - -#define ES_HW_VER 32 - -/* - ***************************************************************** - *************** FEATURE SPECIFIC MACROS ************************* - ***************************************************************** - */ - - - -/**< Macro to Enable SMX Feature During - * Initialisation */ - -#if !defined(NXP_SMX) -#define NXP_SMX 1 -#endif - -#if (NXP_SMX == 1) -#define NXP_HAL_ENABLE_SMX -#endif - -/**< Macro to Enable the Host Session - * Initialisation */ -#define ESTABLISH_SESSION - -/**< Macro to Enable the Peer to Peer Feature */ -#define ENABLE_P2P - -#define DEFAULT_NFCIP_INITIATOR_MODE_SUPPORT 0x3FU -#define DEFAULT_NFCIP_TARGET_MODE_SUPPORT 0x0FU - -/**< Macro to Enable the ISO14443-B Feature */ -#define TYPE_B - -/**< Macro to Enable the Felica Feature */ -#define TYPE_FELICA - -/**< Macro to Enable the JEWEL Feature */ -#define TYPE_JEWEL - -/**< Macro to Enable the ISO15693 Feature */ -#define TYPE_ISO15693 - -/*< Macro to Verify the Poll Parameters Set */ -/* #define ENABLE_VERIFY_PARAM */ - -/**< Macro to Enable ISO 18092 Protocol compliancy - * SAK to be merged with the TYPE A Card RF Feature :3.1*/ -#define TGT_MERGE_SAK - - -/**< Macro to Configure the default power status - * to allow the PN544 to enter into the Standby */ -#define CFG_PWR_STATUS - - -/**< Macro to Enable the SWP Protocol - * to detect UICC During Initialisation */ -#define ENABLE_UICC - -/**< Macro to Enable the RAW Mode of Transaction - * for the ISO-14443-3A Compliant Targets */ -#define ENABLE_MIFARE_RAW - -/**< Macro to Enable the HOST List - * to allow the UICC Communication */ -#define HOST_WHITELIST - -/**< Support reconnecting to a different handle on the same tag */ -#define RECONNECT_SUPPORT - -/**< Macro to Enable the Card Emulation Feature */ -/* #define HOST_EMULATION */ - -#define NXP_HAL_VERIFY_EEPROM_CRC 0x01U - -/**< Macro to Enable the Download Mode Feature */ -#define FW_DOWNLOAD - -/**< Macro to Enable the Firmware Download Timer */ -/* 0x01U to use overall timeout */ -/* 0x02U to use per frame timeout */ -#define FW_DOWNLOAD_TIMER 0x02U - -/**< Macro to Verify the Firmware Download */ -/* #define FW_DOWNLOAD_VERIFY */ - -#ifndef FW_DOWNLOAD_VERIFY -#define NXP_FW_INTEGRITY_CHK 1 -#endif - -/* To specify the Maximum TX/RX Len */ -#define NXP_FW_MAX_TX_RX_LEN 0x200 - -#define UICC_CONNECTIVITY_PATCH - -/* Work around to Delay the initiator activation */ -/* #define NXP_NFCIP_ACTIVATE_DELAY */ - -/* Work around to Release the Discovered Target */ -#define SW_RELEASE_TARGET - -/* Macro to Allow the HCI Release in any state */ -#define NXP_HCI_SHUTDOWN_OVERRIDE - - -/* Macro to Enable The P2P Transaction Timers */ -#define P2P_TGT_TRANSACT_TIMER - -#if (ES_HW_VER == 32) -/* Macro to Configure the Target Disable Register */ -#define NFCIP_TGT_DISABLE_CFG - -#endif - -/*< Macro to Disable the Felica Mapping */ -/* #define DISABLE_FELICA_MAPPING */ - -/*< Macro to Disable the Felica Mapping */ -/* #define DISABLE_JEWEL_MAPPING */ - -/**< Macro to enable LLC timer */ -#define LLC_TIMER_ENABLE - -/**< Macro to enable HCI Response timer */ -#define NXP_NFC_HCI_TIMER 1 - -/* A Workaround to Delay and obtain the UICC Status Information */ -/* #define UICC_STATUS_DELAY */ - -#ifdef UICC_STATUS_DELAY -#define UICC_STATUS_DELAY_COUNT 0x00100000 -#endif - -/**< Macro to delay the LLC RESET response callback, - Value is in milli-seconds */ -#define LLC_RESET_DELAY 10 - -/* Macro to Enable the workaround for Tuning of - * RF for TYPE B and F - */ -/* #define SW_TYPE_RF_TUNING_BF */ - -/* Workaround to update the Active Guard Timeout */ -/* #define MAX_ACTIVATE_TIMEOUT */ - -/* #define ONE_BYTE_LEN */ - -#define NFC_RF_NOISE_SW - -/**< Define to configure the PMOS Modulation Index value - */ - -#ifndef NFC_DEV_PMOS_MOD_DEFAULT -/* 0x3F -> 6%, 0x3A -> 10%, 0x3C -> 10%, 0x35 -> 15.8%, 0x28 -> 25.8% */ -#define NFC_DEV_PMOS_MOD_DEFAULT 0x3CU -#endif - - -#ifndef SW_TYPE_RF_TUNING_BF -#define SW_TYPE_RF_TUNING_BF 0x80U -#endif - - -/* Reset the Default values of Host Link Timers */ -/* Macro to Enable the Host Side Link Timeout Configuration - * 0x00 ----> Default Pre-defined Configuration; - * 0x01 ----> Update only the Host Link Guard Timeout Configuration; - * 0x03 ----> Update Both the Host Link Guard Timeout - and ACK Timeout Configuration; - */ - -#ifndef HOST_LINK_TIMEOUT -#define HOST_LINK_TIMEOUT 0x00U -#endif - - -#ifndef NXP_NFC_LINK_GRD_CFG_DEFAULT -#define NXP_NFC_LINK_GRD_CFG_DEFAULT 0x0032U -#endif - -#ifndef NXP_NFC_LINK_ACK_CFG_DEFAULT -#define NXP_NFC_LINK_ACK_CFG_DEFAULT 0x0005U -#endif - -/* Macro to Enable the Interface Character Timeout Configuration - * 0x00 ----> Default Pre-defined Configuration; - * 0x01 ----> Update the IFC Timeout Default Configuration; - */ - -#ifndef NXP_NFC_IFC_TIMEOUT -#define NXP_NFC_IFC_TIMEOUT 0x00 -#endif - - -#ifndef NXP_NFC_IFC_CONFIG_DEFAULT -#define NXP_NFC_IFC_CONFIG_DEFAULT 0x203AU -#endif - -#ifndef NFC_ISO_15693_MULTIPLE_TAGS_SUPPORT -#define NFC_ISO_15693_MULTIPLE_TAGS_SUPPORT 0x00 -#endif - -/* - ***************************************************************** - *********** MACROS ENABLE EEPROM REGISTER WRITE **************** - ***************************************************************** - */ - - -/* Enable this to Disable the WI Notification */ -/* #define DISABLE_WI_NOTIFICATION */ - -/* Macro to Enable the Configuration of Initiator - * speed during Discovery configuration - */ -#define INITIATOR_SPEED -#define TARGET_SPEED - - -/**/ -/* #define UICC_SESSION_RESET */ - -/* Macro to Enable the Configuration of UICC - * Timer and Bitrate during Initialisation - */ - - - - -/* -----------------Structures and Enumerations -------------------------*/ - - - - -/* -----------------Exported Functions----------------------------------*/ - - -#endif /*PHNFC_CONFIG_H*/ - diff --git a/libnfc-nxp/phNfcHalTypes.h b/libnfc-nxp/phNfcHalTypes.h deleted file mode 100644 index 522df6d..0000000 --- a/libnfc-nxp/phNfcHalTypes.h +++ /dev/null @@ -1,1349 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * \file phNfcHalTypes.h - * \brief Structure declarations/type definitions belonging to the HAL subsystem. - * - * Project: NFC MW / HAL - * - * $Date: Thu Apr 8 17:11:39 2010 $ - * $Author: ing04880 $ - * $Revision: 1.106 $ - * $Aliases: NFC_FRI1.1_WK1007_SDK,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ - * - */ - - -#ifndef PHNFCHALTYPES_H /* */ -#define PHNFCHALTYPES_H /* */ - -/** - * \name HAL Types - * - * File: \ref phNfcHalTypes.h - * - */ - -/*@{*/ -#define PHNFCHALTYPES_FILEREVISION "$Revision: 1.106 $" /**< \ingroup grp_file_attributes */ -#define PHNFCHALTYPES_FILEALIASES "$Aliases: NFC_FRI1.1_WK1007_SDK,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ -/*@}*/ - -#include -#include -#include - -#ifndef NXP_HAL_MEM_INFO_SIZE -#define NXP_HAL_MEM_INFO_SIZE 0x01U -#endif - -#if (NXP_HAL_MEM_INFO_SIZE > 0x01) -#define NXP_FW_UPLOAD_PROGRESS 0x965AU -#define NXP_FW_UPLOAD_SUCCESS 0x0000U -#else -#define NXP_FW_UPLOAD_PROGRESS 0x5AU -#define NXP_FW_UPLOAD_SUCCESS 0x00U -#endif - - -typedef struct phHal_sMemInfo -{ - uint16_t fw_magic; - uint16_t fw_rfu; - uint32_t hal_version; -}phHal_sMemInfo_t; - - -/** \ingroup grp_hal_common - * - * \if hal - * \brief Protocol Support Information - * \else - * \brief HAL-Specific - * \endif - * - * The Supported Protocols Structure holds all protocol supported by the current NFC - * device. - * - * \note All members of this structure are output parameters [out]. - * - */ -typedef phNfc_sSupProtocol_t phHal_sSupProtocol_t; - - -/** \ingroup grp_hal_common - * - * - * \if hal - * \brief Information related to the NFC Device - * \else - * \brief HAL-Specific - * \endif - * - * The Device Information Structure holds information - * related to the NFC IC read during initialization time. - * It allows the caller firware, hardware version, the model id, - * HCI verison supported and vendor name. Refer to the NFC Device - * User Manual on how to interpret each of the values. In addition - * it also contains capabilities of the NFC Device such as the - * protocols supported in Reader and emulation mode - * - */ - -typedef phNfc_sDeviceCapabilities_t phHal_sDeviceCapabilities_t; - - -/** - * \ingroup grp_hal_common - * - * \if hal - * \brief Hardware Reference - The Peripheral Representation - * \else - * \brief HAL-Specific - * \endif - * - * The Hardware Reference structure is filled as part of the open function and - * contains information regarding connected peripheral NFC device. It also - * stores the refernce to the communication driver passed by the HAL client - * for usage during communication with the NFC Device - * - * \note The caller can consider this structure atomic, no interpretation is required - * for HAL operation. - * - * \sa phHal4Nfc_Open . - * - */ - -/** - * \ingroup grp_hal_common - * - * \brief Hardware Reference - The Peripheral Representation - * - * The Hardware Reference structure is filled as part of the open function and - * contains information regarding connected peripheral NFC device. It also - * stores the refernce to the communication driver passed by the HAL client - * for usage during communication with the NFC Device - * - * \note The caller can consider this structure atomic, no interpretation is required - * for HAL operation. - * - */ -typedef struct phHal_sHwReference -{ - /**< Will be usable/valid after the Open function. */ - void *p_board_driver; - /**< Session Identifier for the established session */ - uint8_t session_id[SESSIONID_SIZE]; - /**< SMX Connected TRUE/FALSE */ - uint8_t smx_connected; - /**< UICC Connected TRUE/FALSE */ - uint8_t uicc_connected; - /**< UICC Reader Mode is Active TRUE/FALSE */ - uint8_t uicc_rdr_active; - /**< Device information. */ - phNfc_sDeviceCapabilities_t device_info; - /**< Context of the HAL Layer */ - void *hal_context; - /**< Context of the DAL Layer */ - void *dal_context; -} phHal_sHwReference_t; - - -/** \ingroup grp_hal_common - * - * \if hal - * \brief Hardware configuration - Configuration Parameters for the NFC Device - * \else - * \brief HAL-Specific - * \endif - * - * The parameters used to configure the device during the initialisation. - * This structure is used internally by the HAL implementation and is filled - * up based on various configuration parameters from the config file - * \note None. - * - */ - -typedef struct phHal_sHwConfig -{ - - uint8_t session_id[SESSIONID_SIZE]; /**< Session Identifier for - the established session */ - - uint8_t clk_req; /**< Clock Request Setting */ - - uint8_t input_clk; /**< Input Clock Setting */ - -} phHal_sHwConfig_t; - - - -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ - -/* This data structure is not used anymore and will be removed in subsequent - release */ -typedef struct phHal_sDepFlags -{ - unsigned int MetaChaining : 1; - unsigned int NADPresent : 1; -} phHal_sDepFlags_t; - -/* This data structure is not used anymore and will be removed in subsequent - release */ - -typedef struct phHal_sDepAdditionalInfo -{ - phHal_sDepFlags_t DepFlags; - uint8_t NAD; -} phHal_sDepAdditionalInfo_t; - - -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ - - - -/** \ingroup grp_hal_common - * - * \if hal - * \brief Enumerated MIFARE Commands - * \else - * \brief HAL-Specific - * \endif - * - * The Mifare Command List Enumerator lists all available Mifare native commands. - * - * \note None. - * - */ - -typedef phNfc_eMifareCmdList_t phHal_eMifareCmdList_t; - -#define phHal_eMifareRaw phNfc_eMifareRaw -#define phHal_eMifareAuthentA phNfc_eMifareAuthentA -#define phHal_eMifareAuthentB phNfc_eMifareAuthentB -#define phHal_eMifareRead16 phNfc_eMifareRead16 -#define phHal_eMifareRead phNfc_eMifareRead -#define phHal_eMifareWrite16 phNfc_eMifareWrite16 -#define phHal_eMifareWrite4 phNfc_eMifareWrite4 -#define phHal_eMifareInc phNfc_eMifareInc -#define phHal_eMifareDec phNfc_eMifareDec -#define phHal_eMifareTransfer phNfc_eMifareTransfer -#define phHal_eMifareRestore phNfc_eMifareRestore -#define phHal_eMifareReadSector phNfc_eMifareReadSector -#define phHal_eMifareWriteSector phNfc_eMifareWriteSector -#define phHal_eMifareInvalidCmd phNfc_eMifareInvalidCmd - - -/** \ingroup grp_hal_common - * - * The T=Cl Command List Enumerator lists all available T=Cl Commands. - * - * \note None. - * - */ -typedef phNfc_eIso14443_4_CmdList_t phHal_eIso14443_4_CmdList_t; - -#define phHal_eIso14443_4_Raw phNfc_eIso14443_4_Raw - - -/** \ingroup grp_hal_common - * - * The NFCIP1 Command List Enumerator lists all available NFCIP1 Commands. - * - * \note None. - * - */ -typedef phNfc_eNfcIP1CmdList_t phHal_eNfcIP1CmdList_t; - -#define phHal_eNfcIP1_Raw phNfc_eNfcIP1_Raw - - -/** \ingroup grp_hal_common - * - * The ISO15693 Command List Enumerator lists all available ISO15693 Commands. - * - * \note None. - * - */ - -typedef phNfc_eIso15693_CmdList_t phHal_eIso15693_CmdList_t; - -#if 0 -#define phHal_eIso15693_Raw phNfc_eIso15693_Raw -#endif -#define phHal_eIso15693_Cmd phNfc_eIso15693_Cmd -#define phHal_eIso15693_Invalid phNfc_eIso15693_Invalid - -/** \ingroup grp_hal_common - * - * The Felica Command List Enumerator lists all available Felica Commands. - * - * \note None. - * - */ - -typedef enum phHal_eFelicaCmdList -{ - phHal_eFelica_Raw = 0xF0U, /**< Felica Raw command:\n - - This command sends the data buffer directly - to the remote device */ - phHal_eFelica_Check = 0x00, /**< Felica Check command:\n - - This command checks the data from the Felica - remote device */ - phHal_eFelica_Update = 0x01, /**< Felica Update command:\n - - This command updates the data onto the Felica - remote device */ - phHal_eFelica_Invalid = 0xFFU /**< Invalid Command */ -} phHal_eFelicaCmdList_t; - - -typedef enum phHal_eJewelCmdList -{ - phHal_eJewel_Raw = 0x00U, /**< Jewel command:\n - - This command sends the data buffer directly - to the remote device */ - phHal_eJewel_Invalid = 0xFFU /**< Invalid jewel command */ -}phHal_eJewelCmdList_t; - - - -/** \ingroup grp_hal_nfci -* -* \if hal -* \brief Remote Device Reader A RF Gate Information Container -* \else -* \brief HAL-Specific -* \endif -* -* The Reader A structure includes the available information -* related to the discovered ISO14443A remote device. This information -* is updated for every device discovery. -* \note None. -* -*/ -typedef phNfc_sIso14443AInfo_t phHal_sIso14443AInfo_t; - -/** \ingroup grp_hal_nfci -* -* \if hal -* \brief Remote Device Reader B RF Gate Information Container -* \else -* \brief HAL-Specific -* \endif -* -* The Reader B structure includes the available information -* related to the discovered ISO14443B remote device. This information -* is updated for every device discovery. -* \note None. -* -*/ - -typedef phNfc_sIso14443BInfo_t phHal_sIso14443BInfo_t; - -typedef phNfc_sIso14443BPrimeInfo_t phHal_sIso14443BPrimeInfo; - - -/** \ingroup grp_hal_nfci -* -* \if hal -* \brief Remote Device Jewel Reader RF Gate Information Container -* \else -* \brief HAL-Specific -* \endif -* -* The Jewel Reader structure includes the available information -* related to the discovered Jewel remote device. This information -* is updated for every device discovery. -* \note None. -* -*/ - - -typedef phNfc_sJewelInfo_t phHal_sJewelInfo_t; - -/** \ingroup grp_hal_nfci -* -* \if hal -* \brief Remote Device Felica Reader RF Gate Information Container -* \else -* \brief HAL-Specific -* \endif -* -* The Felica Reader structure includes the available information -* related to the discovered Felica remote device. This information -* is updated for every device discovery. -* \note None. -* -*/ - -typedef phNfc_sFelicaInfo_t phHal_sFelicaInfo_t; - - -/** \ingroup grp_hal_nfci -* -* \if hal -* \brief Remote Device Reader 15693 RF Gate Information Container -* \else -* \brief HAL-Specific -* \endif -* -* The Reader A structure includes the available information -* related to the discovered ISO15693 remote device. This information -* is updated for every device discovery. -* \note None. -* -*/ - -typedef phNfc_sIso15693Info_t phHal_sIso15693Info_t; - - -/** \ingroup grp_hal_nfci -* -* \if hal -* \brief NFC Data Rate Supported between the Reader and the Target -* \else -* \brief HAL-Specific -* \endif -* -* The \ref phHalNfc_eDataRate enum lists all the Data Rate -* values to be used to determine the rate at which the data is transmitted -* to the target. -* -* \note None. -*/ - - -typedef phNfc_eDataRate_t phHalNfc_eDataRate_t; - - -/** \ingroup grp_hal_nfci -* -* \if hal -* \brief NFCIP1 Gate Information Container -* \else -* \brief HAL-Specific -* \endif -* -* The NFCIP1 structure includes the available information -* related to the discovered NFCIP1 remote device. This information -* is updated for every device discovery. -* \note None. -* -*/ - -typedef phNfc_sNfcIPInfo_t phHal_sNfcIPInfo_t; - - -/** \ingroup grp_hal_nfci -* -* \if hal -* \brief Remote Device Specific Information Container -* \else -* \brief HAL-Specific -* \endif -* -* The Remote Device Information Union includes the available Remote Device Information -* structures. Following the device detected, the corresponding data structure is used. -* -* \note None. -* -*/ - -typedef phNfc_uRemoteDevInfo_t phHal_uRemoteDevInfo_t; - -/** \ingroup grp_hal_nfci -* -* \if hal -* \brief RF Device Type Listing -* \else -* \brief HAL-Specific -* \endif -* -* The RF Device Type List is used to identify the type of -* remote device that is discovered/connected. There seperate -* types to identify a Remote Reader (denoted by _PCD) and -* Remote Tag (denoted by _PICC) -* \note None. -* -*/ - -typedef phNfc_eRFDevType_t phHal_eRFDevType_t; - -#define phHal_eUnknown_DevType phNfc_eUnknown_DevType - - /* Specific PCD Devices */ -#define phHal_eISO14443_A_PCD phNfc_eISO14443_A_PCD -#define phHal_eISO14443_B_PCD phNfc_eISO14443_B_PCD -#define phHal_eISO14443_BPrime_PCD phNfc_eISO14443_BPrime_PCD -#define phHal_eFelica_PCD phNfc_eFelica_PCD -#define phHal_eJewel_PCD phNfc_eJewel_PCD -#define phHal_eISO15693_PCD phNfc_eISO15693_PCD - /* Generic PCD Type */ -#define phHal_ePCD_DevType phNfc_ePCD_DevType - - /* Generic PICC Type */ -#define phHal_ePICC_DevType phNfc_ePICC_DevType - /* Specific PICC Devices */ -#define phHal_eISO14443_A_PICC phNfc_eISO14443_A_PICC -#define phHal_eISO14443_4A_PICC phNfc_eISO14443_4A_PICC -#define phHal_eISO14443_3A_PICC phNfc_eISO14443_3A_PICC -#define phHal_eMifare_PICC phNfc_eMifare_PICC -#define phHal_eISO14443_B_PICC phNfc_eISO14443_B_PICC -#define phHal_eISO14443_4B_PICC phNfc_eISO14443_4B_PICC -#define phHal_eISO14443_BPrime_PICC phNfc_eISO14443_BPrime_PICC -#define phHal_eFelica_PICC phNfc_eFelica_PICC -#define phHal_eJewel_PICC phNfc_eJewel_PICC -#define phHal_eISO15693_PICC phNfc_eISO15693_PICC - - /* NFC-IP1 Device Types */ -#define phHal_eNfcIP1_Target phNfc_eNfcIP1_Target -#define phHal_eNfcIP1_Initiator phNfc_eNfcIP1_Initiator - - /* Other Sources */ -#define phHal_eInvalid_DevType phNfc_eInvalid_DevType - -/** \ingroup grp_hal_nfci -* -* \if hal -* \brief Remote Device Type Listing -* \else -* \brief HAL-Specific -* \endif -* -* The Remote Device Type List is used to identify the type of -* remote device that is discovered/connected -* \note This is same as RF Device Type List. -* -*/ -typedef phNfc_eRemDevType_t phHal_eRemDevType_t; - -/** \ingroup grp_hal_common - * - * - * \if hal - * \brief Common Command Attribute - * \else - * \brief HAL-Specific - * \endif - * - * The Hal Command Union includes each available type of Commands. - * - * \note None. - * - */ - -typedef phNfc_uCmdList_t phHal_uCmdList_t; - - -/** \ingroup grp_hal_nfci - * - * \if hal - * \brief Remote Device Information Structure - * \else - * \brief HAL-Specific - * \endif - * - * The Remote Device Information Structure holds information about one single Remote - * Device detected by the polling function .\n - * It lists parameters common to all supported remote devices. - * - * \note - * - * \if hal - * \sa \ref phHal4Nfc_ConfigureDiscovery and \ref phHal4Nfc_Connect - * \else - * \sa - * \endif - * - */ - -typedef phNfc_sRemoteDevInformation_t phHal_sRemoteDevInformation_t; - - - -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ - -/* This data structure is not used anymore and will be removed in subsequent - release */ - -typedef struct phHal_sDevInputParam -{ - uint8_t FelicaPollPayload[5]; - - - uint8_t NfcPollPayload[5]; - - - uint8_t NFCIDAuto; - - - uint8_t NFCID3i[PHHAL_NFCID_LENGTH]; - - - - uint8_t DIDiUsed; - - uint8_t CIDiUsed; - - uint8_t NfcNADiUsed; - - /*+ MantisId : 31 - JP - 09-01-2006 */ - /*uint8_t TClNADiUsed; */ - - /*- MantisId : 31 - JP - 09-01-2006 */ - uint8_t GeneralByte[48]; - - - uint8_t GeneralByteLength; - - - uint8_t ISO14443_4B_AFI; - -} phHal_sDevInputParam_t; - - - - -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ - - -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* TARGET STRUCTURES */ - - -/** \ingroup grp_hal_common - * - * \if hal - * \brief Transceive Information Data Structure for sending commands/response - * to the remote device - * \else - * \brief HAL-Specific - * \endif - * - * The Transceive Information Data Structure is used to pass the - * Command, Address (only required for MIFARE) and the send and receive data - * data structure (buffer and length) for communication with remote device - * - * - */ - -typedef phNfc_sTransceiveInfo_t phHal_sTransceiveInfo_t; - - -/** \ingroup grp_hal_nfci -* -* \if hal -* \brief Input information for the Type A tags -* \else -* \brief HAL-Specific -* \endif -* -* The \ref phHal_sIso14443ACfg structure holds the information -* required for the NFC device to be used during ISO14443A target discovery -* -* \note None. -*/ -typedef struct phHal_sIso14443ACfg -{ - uint8_t Auto_Activation; /**< Enable Auto Activation for - Technology A \n - If set to 0, the activation procedure will stop - after Select (SAK has been received). - The host could evaluate SAK value and then decide: - - to start communicating with the remote card - using proprietary commands (see NXP_MIFARE_RAW - and NXP_MIFARE_CMD) - or - - to activate the remote card up to ISO14443-4 - level (RATS and PPS) using - CONTINUE ACTIVATION command - If set to 1, activation follows the flow described in - ETSI HCI specification (restrict detection to - ISO14443-4 compliant cards). - */ -}phHal_sIso14443ACfg_t; - - -/** \ingroup grp_hal_nfci -* -* \if hal -* \brief Input information for the Type B tags -* \else -* \brief HAL-Specific -* \endif -* -* The \ref phHal_sIso14443BCfg structure holds the information -* required for the NFC device to be used during ISO14443B target discovery -* -* \note None. -*/ -typedef struct phHal_sIso14443BCfg -{ - uint8_t AppFamily_ID; /**< Application Family Identifier for - Technology B, 0x00 means all application */ -}phHal_sIso14443BCfg_t; - -/** \ingroup grp_hal_nfci -* -* \if hal -* \brief Input information for the Felica tags -* \else -* \brief HAL-Specific -* \endif -* -* The \ref phHal_sFelicaCfg_t structure holds the information -* required for the NFC device to be used during Felica target discovery -* -* \note None. -*/ - -typedef struct phHal_sFelicaCfg -{ - uint8_t SystemCode[PHHAL_FEL_SYS_CODE_LEN]; /**< System code for Felica tags */ - -}phHal_sFelicaCfg_t; - - -/** \ingroup grp_hal_nfci -* -* \if hal -* \brief Poll Device Information for conifiguring the discovery wheel - Reader and Card Emulation Phases -* \else -* \brief HAL-Specific -* \endif -* -* The \ref phHal_sPollDevInfo_t enum is used to enable/disable -* phases of the discovery wheel related to specific reader types and -* card emulation phase -* \note Enabling specific Reader technology when NFCIP1 speed is set in the -* phNfc_sADD_Cfg_t is implicitly done in HAL. Use this structure to only -* enable/disable Card Reader Functionality -*/ -typedef phNfc_sPollDevInfo_t phHal_sPollDevInfo_t; - - -/** \ingroup grp_hal_common -* -* \if hal -* \brief Identifies Type of Host -* \else -* \brief HAL-Specific -* \endif -* -* This enumeration is used to identify the type of the host providing the -* information or the notification to the Terminal host. -* \note None. -*/ - -typedef enum phHal_HostType { - /* - * This type identifies the host controller - * in the NFC device - */ - phHal_eHostController = 0x00U, - /* - * This type identifies the Host Device - * controlling the NFC device. - */ - phHal_eTerminalHost = 0x01U, - /* - * This type identifies the uicc host - * connnected to the NFC device - */ - phHal_eUICCHost = 0x02U, - /* Host type is unknown */ - phHal_eUnknownHost = 0xFFU -}phHal_HostType_t; - - -/** \ingroup grp_hal_nfci -* -* \if hal -* \brief P2P speed for the Initiator -* \else -* \brief HAL-Specific -* \endif -* -* The \ref phHal_eP2PMode enum lists all the NFCIP1 speeds -* to be used for configuring the NFCIP1 discovery -* -* \note None. -*/ - -#define phHal_eDefaultP2PMode phNfc_eDefaultP2PMode -#define phHal_ePassive106 phNfc_ePassive106 -#define phHal_ePassive212 phNfc_ePassive212 -#define phHal_ePassive424 phNfc_ePassive424 -#define phHal_eActive phNfc_eActive -#define phHal_eP2P_ALL phNfc_eP2P_ALL -#define phHal_eInvalidP2PMode phNfc_eInvalidP2PMode - - -/** \ingroup grp_hal_common -* -* \if hal -* \brief Identities the type of Notification -* \else -* \brief HAL-Specific -* \endif -* -* This enumeration is used to specify the type of notification notified -* to the upper layer. This classifies the notification into two types -* one for the discovery notifications and the other for all the remaining -* event notifications -* \note None. -*/ - - -typedef phNfc_eNotificationType_t phHal_eNotificationType_t; - - -/** \ingroup grp_hal_common -* -* \if hal -* \brief Identifies the type of event notification -* \else -* \brief HAL-Specific -* \endif -* -* This enumeration is used to identify the type of the event notified -* to the Terminal host. -* \note None. -*/ - -typedef enum phHal_Event { - - - /* Transaction Events */ - NFC_EVT_END_OF_TRANSACTION = 0x11U , - NFC_EVT_TRANSACTION = 0x12U , - NFC_EVT_START_OF_TRANSACTION = 0x20U , - - /* Field Events */ - NFC_EVT_FIELD_ON = 0x31U, - NFC_EVT_FIELD_OFF = 0x34U, - - /* Card/Target Activation Events */ - NFC_EVT_ACTIVATED = 0x33U, - NFC_EVT_DEACTIVATED = 0x32U, - - NFC_EVT_PROTECTED = 0x24U , - - /* Reader Phases configuration request by UICC */ - NFC_UICC_RDPHASES_ACTIVATE_REQ = 0x43U, - NFC_UICC_RDPHASES_DEACTIVATE_REQ = 0x44U, - - /* Connectivity and Triggering Events - Future Use */ - NFC_EVT_CONNECTIVITY = 0x10U , - NFC_EVT_OPERATION_ENDED = 0x13U , - - /* NXP Specific System Information Events */ - NFC_INFO_TXLDO_OVERCUR = 0x71U, - NFC_INFO_MEM_VIOLATION = 0x73U, - NFC_INFO_TEMP_OVERHEAT = 0x74U, - NFC_INFO_LLC_ERROR = 0x75U, - - /* NXP EVENTS */ - NFC_EVT_MIFARE_ACCESS = 0x35, - NFC_EVT_APDU_RECEIVED = 0x36, - NFC_EVT_EMV_CARD_REMOVAL = 0x37 - -}phHal_Event_t; - -typedef phNfc_sUiccInfo_t phHal_sUiccInfo_t; - -/** \ingroup grp_hal_common -* -* \if hal -* \brief Event notification Information -* \else -* \brief HAL-Specific -* \endif -* -* This structure provides the information about the event notified -* to the terminal host. -* \note None. -*/ - -typedef struct phHal_sEventInfo -{ - /* Type of the host issuing the event */ - phHal_HostType_t eventHost; - /* Type of the source issuing the event */ - phHal_eRFDevType_t eventSource; - /* Type of the source issuing the event */ - phHal_Event_t eventType; - union uEventInfo - { - /* Parameter information Information is obtained if the eventType is - * NFC_EVT_TRANSACTION for UICC. - */ - phHal_sUiccInfo_t uicc_info; - /* AID Information is obtained if the eventType is - * NFC_EVT_TRANSACTION. - */ - phNfc_sData_t aid; - /* Overheat Status Information is obtained if the eventType is - * NFC_INFO_TEMP_OVERHEAT. - */ - uint8_t overheat_status; - /* rd_phases Information is obtained if the eventType is - * NFC_UICC_RDPHASES_ACTIVATE_REQ. - */ - uint8_t rd_phases; - /* Remote Device Information is obtained if the eventType is - * NFC_EVT_ACTIVATED. - */ - phHal_sRemoteDevInformation_t *pRemoteDevInfo; - }eventInfo; -}phHal_sEventInfo_t; - - -/** \ingroup grp_hal_common -* -* \if hal -* \brief Information for the Host/Uicc Emulation Support -* \else -* \brief HAL-Specific -* \endif -* -* The \ref phHal_sEmuSupport structure holds the type -* of the target emulation supported. -* -* \note None. -*/ - -typedef struct phHal_sEmuSupport -{ - unsigned int TypeA:1; - unsigned int TypeB:1; - unsigned int TypeBPrime:1; - unsigned int TypeFelica:1; - unsigned int TypeMifare:1; - unsigned int TypeNfcIP1:1; - unsigned int RFU:2; - -}phHal_sEmuSupport_t; - - -/** \ingroup grp_hal_nfci -* -* \if hal -* \brief P2P Information for the Initiator -* \else -* \brief HAL-Specific -* \endif -* -* The \ref phHal_sNfcIPCfg holds the P2P related information -* use by the NFC Device during P2P Discovery and connection -* -* \note None. -*/ - -typedef phNfc_sNfcIPCfg_t phHal_sNfcIPCfg_t; - -/** \ingroup grp_hal_common -* -* \if hal -* \brief Enumeration used to choose which type of parameters -* are to be configured -* \else -* \brief HAL-Specific -* \endif -* -* -* \note None. -*/ -typedef enum phHal_eConfigType -{ - NFC_INVALID_CONFIG = 0x00U, /**< Invalid Configuration */ - NFC_RF_READER_CONFIG, /**< Reader Parmaeters */ - NFC_P2P_CONFIG, /**< NFCIP1 Parameters */ - NFC_SE_PROTECTION_CONFIG, /**< Secure Element - Protection Cofiguration */ - NFC_EMULATION_CONFIG /**< Emulation Parameters */ -}phHal_eConfigType_t; - -/** \ingroup grp_hal_common -* -* \if hal -* \brief Discovery Configuration Mode -* \else -* \brief HAL-Specific -* \endif -* -* This enumeration is used to choose the Discovery Configuration -* Mode :- Configure and Start, Stop or Start with last set -* configuration -* \note None. -*/ - -typedef phNfc_eDiscoveryConfigMode_t phHal_eDiscoveryConfigMode_t; - - -/** \ingroup grp_hal_common -* -* \if hal -* \brief Target or Tag Release Mode -* \else -* \brief HAL-Specific -* \endif -* -* This enumeration defines various modes of releasing an acquired target -* or tag. -* \note None. -*/ -typedef phNfc_eReleaseType_t phHal_eReleaseType_t; - - -/** \ingroup grp_hal_common -* -* \if hal -* \brief Configuration of specific Emulation Feature -* \else -* \brief HAL-Specific -* \endif -* -* This enumeration is used to choose configuration for a specific -* emulation feature. -* \note None. -*/ - -typedef enum phHal_eEmulationType -{ - NFC_UNKNOWN_EMULATION = 0x00U, /**< Invalid Configuration */ - NFC_HOST_CE_A_EMULATION = 0x01U, /**< Configure parameters for Type A - card emulation from host */ - NFC_HOST_CE_B_EMULATION = 0x02U, /**< Configure parameters for Type B - card emulation from host */ - NFC_B_PRIME_EMULATION = 0x03U, /**< Configure parameters for Type B' - card emulation from host */ - NFC_FELICA_EMULATION = 0x04U, /**< Configure parameters for Type F - card emulation from host */ - NFC_MIFARE_EMULATION = 0x06U, /**< Configure parameters for MIFARE - card emulation - For Future Use */ - NFC_SMARTMX_EMULATION = 0x07U, /**< Configure parameters for SmartMX - */ - NFC_UICC_EMULATION = 0x08U /**< Configure parameters for UICC - emulation */ -}phHal_eEmulationType_t; - -#if 0 -/** \ingroup grp_hal_nfct - * - * \if hal - * \brief Information for Target Mode Start-Up - * \else - * \brief HAL-Specific - * \endif - * - * The Target Information Structure required to start Target mode. - * It contains all the information for the Target mode. - * - * \note None. - * - */ - -typedef struct phHal_sTargetInfo -{ - uint8_t enableEmulation; - phHal_sNfcIPCfg_t targetConfig; -} phHal_sTargetInfo_t; -#endif - - -/** \ingroup grp_hal_common -* -* \if hal -* \brief Mode of operation for SmartMX -* \else -* \brief HAL-Specific -* \endif -* -* This enumeration is used to choose the mode of operation for the SmartMx Module. -* Default static configuration at initialization time. -* \note None. -*/ - -typedef enum phHal_eSmartMX_Mode{ - eSmartMx_Wired = 0x00U, /* SmartMX is in Wired Mode */ - eSmartMx_Default, /* SmartMX is in Default Configuration Mode */ - eSmartMx_Virtual, /* SmartMx in the Virutal Mode */ - eSmartMx_Off /* SmartMx Feature is Switched off */ -} phHal_eSmartMX_Mode_t; - - -/** \ingroup grp_hal_common -* -* \if hal -* \brief Mode of operation for SWP -* \else -* \brief HAL-Specific -* \endif -* -* This enumeration is used to choose the mode of operation for the SWP Link -* for UICC Module. Default static configuration at initialization time. -* \note None. -*/ - -typedef enum phHal_eSWP_Mode{ - eSWP_Switch_Off = 0x00U, /* SWP Link is Switched off */ - eSWP_Switch_Default, /* SWP is in Default Configuration Mode */ - eSWP_Switch_On /* SWP Link is Switched on */ -} phHal_eSWP_Mode_t; - - -/** \ingroup grp_hal_common -* -* \if hal -* \brief Information for the Configuring the SmartMX -* \else -* \brief HAL-Specific -* \endif -* -* The \ref phHal_sSmartMX_Cfg structure holds the information -* to configure the SmartMX Module in the NFC Device. -* -* \note None. -*/ - - -typedef struct phHal_sSmartMX_Cfg -{ - uint8_t enableEmulation; - uint8_t lowPowerMode; - phHal_eSmartMX_Mode_t smxMode; -}phHal_sSmartMX_Cfg_t; - - -/** \ingroup grp_hal_common -* -* \if hal -* \brief Information for the Configuring the UICC -* \else -* \brief HAL-Specific -* \endif -* -* The \ref phHal_sUiccEmuCfg structure holds the information -* to configure the UICC Host. -* -* \note None. -*/ - - -typedef struct phHal_sUiccEmuCfg -{ - uint8_t enableUicc; - uint8_t uiccEmuSupport; - uint8_t uiccReaderSupport; - uint8_t lowPowerMode; - /* TODO: This will be updated later */ -}phHal_sUiccEmuCfg_t; - -/** \ingroup grp_hal_common -* -* \if hal -* \brief Information for the Configuring the Type A Host Emulation Feature -* \else -* \brief HAL-Specific -* \endif -* -* The \ref phHal_sHostEmuCfg_A structure holds the information -* to configure the Host Emulation for Type A. -* -* \note None. -*/ - -typedef struct phHal_sHostEmuCfg_A -{ - uint8_t enableEmulation; - phNfc_sIso14443AInfo_t hostEmuCfgInfo; - uint8_t enableCID; -}phHal_sHostEmuCfg_A_t; - - -/** \ingroup grp_hal_common -* -* \if hal -* \brief Information for the Configuring the Type B Host Emulation Feature -* \else -* \brief HAL-Specific -* \endif -* -* The \ref phHal_sHostEmuCfg_B structure holds the information -* to configure the Host Emulation for Type B. -* -* \note None. -*/ - -typedef struct phHal_sHostEmuCfg_B -{ - uint8_t enableEmulation; - phNfc_sIso14443BInfo_t hostEmuCfgInfo; -}phHal_sHostEmuCfg_B_t; - -/** \ingroup grp_hal_common -* -* \if hal -* \brief Information for the Configuring the Felica Host Emulation Feature -* \else -* \brief HAL-Specific -* \endif -* -* The \ref phHal_sHostEmuCfg_F structure holds the information -* to configure the Felica Host Emulation. -* -* \note None. -*/ - - -typedef struct phHal_sHostEmuCfg_F -{ - uint8_t enableEmulation; -}phHal_sHostEmuCfg_F_t; - - -/** \ingroup grp_hal_common -* -* \if hal -* \brief Information for the Configuring the Emulation -* \else -* \brief HAL-Specific -* \endif -* -* The \ref phHal_sEmulationCfg structure holds the information -* required for the device to act as a Tag or NFCIP1 Target. -* -* \note phHal_sHostEmuCfg_F_t Type F emulation is not presently supported -* is reserved for future use. -*/ - -typedef struct phHal_sEmulationCfg -{ - phHal_HostType_t hostType; - phHal_eEmulationType_t emuType; - union phHal_uEmuConfig - { - phHal_sSmartMX_Cfg_t smartMxCfg; - phHal_sHostEmuCfg_A_t hostEmuCfg_A; - phHal_sHostEmuCfg_B_t hostEmuCfg_B; - phHal_sHostEmuCfg_F_t hostEmuCfg_F; - phHal_sUiccEmuCfg_t uiccEmuCfg; - }config; -}phHal_sEmulationCfg_t; - -/** \ingroup grp_hal_common -* -* \if hal -* \brief Information for the Configuring the Reader parameters -* \else -* \brief HAL-Specific -* \endif -* -* The \ref phHal_sReaderCfg structure holds the information -* to configure the Reader A or Reader B parameters. -* -* \note None. -*/ - -typedef struct phHal_sReaderCfg -{ - phHal_eRFDevType_t readerType; - union phHal_uReaderCfg - { - phHal_sIso14443ACfg_t Iso14443ACfg; - phHal_sIso14443BCfg_t Iso14443BCfg; - }config; -}phHal_sReaderCfg_t; - - -/** \ingroup grp_hal_common -* -* \if hal -* \brief Information for Configuring the Protected Mode for -* the Secure Elements. -* \else -* \brief HAL-Specific -* \endif -* -* The \ref phHal_sSEProtectionCfg structure holds the -* information to configure the Secure Element Protection configuration. -* -* \note None. -*/ - -typedef struct phHal_sSEProtectionCfg -{ - uint8_t mode; -}phHal_sSEProtectionCfg_t; - - -/** \ingroup grp_hal_common -* -* \if hal -* \brief Poll configuration structure -* \else -* \brief HAL-Specific -* \endif -* -* The Poll configuration structure holds information about the -* enabling the the type of discovery required by the application. This -* structure is the input parameter for the discovery call -* -* \note All members of this structure are input parameters [out]. -* -* \if hal -* \sa \ref phHal4Nfc_Connect, \ref phHal4Nfc_ConfigParameters, -* \ref phHal_eP2PMode_t and \ref phHal4Nfc_Disconnect. -* \endif -* -*/ - -typedef phNfc_sADD_Cfg_t phHal_sADD_Cfg_t; - - -/** \ingroup grp_hal_common -* -* \if hal -* \brief Configuration information. -* \else -* \brief HAL-Specific -* \endif -* -* The \ref phHal_uConfig structure holds the information -* required for Configuring the Device. -* -* \note None. -*/ - - -typedef union phHal_uConfig -{ - phHal_sEmulationCfg_t emuConfig; - phHal_sNfcIPCfg_t nfcIPConfig; /**< Gives the information about - * the General Bytes for NFC-IP - * Communication. - */ - phHal_sReaderCfg_t readerConfig; - phHal_sSEProtectionCfg_t protectionConfig; -}phHal_uConfig_t; - - -#endif - -/* EOF */ diff --git a/libnfc-nxp/phNfcInterface.h b/libnfc-nxp/phNfcInterface.h deleted file mode 100644 index fdae2ed..0000000 --- a/libnfc-nxp/phNfcInterface.h +++ /dev/null @@ -1,422 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -/*! -* ============================================================================= -* \file phNfcInterface.h -* \brief Generic Interface Layer Function Definitions. -* -* Project: NFC-FRI-1.1 -* -* $Date: Thu Feb 11 19:01:36 2010 $ -* $Author: ing04880 $ -* $Revision: 1.42 $ -* $Aliases: NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ -* -* ============================================================================= -*/ - -#ifndef PHNFCINTERFACE_H /* */ -#define PHNFCINTERFACE_H /* */ - -/** -* \name NFC Inteface -* -* File: \ref phNfcInterface.h -* -*/ - -/*@{*/ -#define PHNFCINTERFACE_FILEREVISION "$Revision: 1.42 $" /**< \ingroup grp_file_attributes */ -#define PHNFCINTERFACE_FILEALIASES "$Aliases: NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ -/*@}*/ - -/* -################################################################################ -***************************** Header File Inclusion **************************** -################################################################################ -*/ - -#include -#include - - -/* -################################################################################ -****************************** Macro Definitions ******************************* -################################################################################ -*/ - -#define NFC_FSM_IN_PROGRESS 0x01U -#define NFC_FSM_COMPLETE 0x00U - -#define NFC_FSM_CURRENT 0x00U -#define NFC_FSM_NEXT 0x01U - -/* NFC Notification Types */ - -#define NFC_NOTIFY_INIT_COMPLETED 0x01 -#define NFC_NOTIFY_INIT_FAILED 0xF1 - -#define NFC_NOTIFY_DEINIT_COMPLETED 0x02 -#define NFC_NOTIFY_DEINIT_FAILED 0xF2 - -#define NFC_NOTIFY_EVENT 0x70 - -#define NFC_NOTIFY_DEVICE_ACTIVATED 0x82 -#define NFC_NOTIFY_DEVICE_DEACTIVATED 0x83 - -#define NFC_NOTIFY_SEND_COMPLETED 0x03 -#define NFC_NOTIFY_SEND_ERROR 0xF3 - -#define NFC_NOTIFY_RECV_COMPLETED 0x04 -#define NFC_NOTIFY_RECV_ERROR 0xF4 -#define NFC_NOTIFY_RECV_EVENT 0x74 -#define NFC_NOTIFY_RECV_CANCELLED 0x34 - -#define NFC_NOTIFY_TRANSCEIVE_COMPLETED 0x05 -#define NFC_NOTIFY_TRANSCEIVE_ERROR 0xF5 - -#define NFC_NOTIFY_POLL_ENABLED 0x06 -#define NFC_NOTIFY_POLL_RESTARTED 0x16 -#define NFC_NOTIFY_POLL_DISABLED 0x26 -#define NFC_NOTIFY_CONFIG_SUCCESS 0x36 -#define NFC_NOTIFY_CONFIG_ERROR 0xF6 - -#define NFC_NOTIFY_TARGET_DISCOVERED 0x10 -#define NFC_NOTIFY_DISCOVERY_ERROR 0xFA -#define NFC_NOTIFY_TARGET_RELEASED 0x11 -#define NFC_NOTIFY_TARGET_CONNECTED 0x12 -#define NFC_NOTIFY_TARGET_PRESENT 0x13 -#define NFC_NOTIFY_TARGET_REACTIVATED 0x14 -#define NFC_NOTIFY_CONNECT_FAILED 0xFC -#define NFC_NOTIFY_TARGET_DISCONNECTED 0x15 -#define NFC_NOTIFY_DISCONNECT_FAILED 0xFD - -#define NFC_NOTIFY_TRANSACTION 0x07 - -#define NFC_NOTIFY_RESULT 0x08 - -#define NFC_NOTIFY_DEVICE_ERROR 0xFEU -#define NFC_NOTIFY_ERROR 0xFFU - - -#define BYTE_SIZE 0x08U -#define BYTE_MASK 0xFFU -/* HCI GET and SET BITS Macros */ -#define MASK_BITS8(p,l) \ - ( ( (((uint8_t)(p))+((uint8_t)(l)))<=BYTE_SIZE )? \ - (~(0xFFU<<((p)+(l))) & (0xFFU<<(p))):(0U) ) -#ifdef MASK_BITS -#define GET_BITS8(num,p,l) \ - ( ((((uint8_t)(p))+((uint8_t)(l)))<=BYTE_SIZE)? \ - (((num)& (MASK_BITS8(p,l)))>>(p)):(0U) ) -#else -#define GET_BITS8(num,p,l) \ - ( ((((p)+(l))<=BYTE_SIZE))? \ - (((num)>>(p))& (~(0xFFU<<(l)))):(0U) ) -#endif -#define SET_BITS8(num,p,l,val) \ - ( ((((uint8_t)(p))+((uint8_t)(l)))<=BYTE_SIZE)? \ - (((num)& (~MASK_BITS8(p,l)))|((val)<<(p))):(0U)) - -/* -################################################################################ -******************** Enumeration and Structure Definition ********************** -################################################################################ -*/ - - -enum phNfcIF_eExecution{ - NFC_EXEC_NORMAL = 0x00, /**< Normal Execution Sequence */ - NFC_EXEC_CALLBACK = 0x01, /**< Callback Execution Sequence */ - NFC_EXEC_UNKNOWN = 0xFF /**< Callback Execution Sequence */ -}; - - -typedef enum phNfc_eModeType{ - MODE_ON = 0x00U, /**< Switches the particular feature ON*/ - MODE_OFF /**< Switches the particular feature OFF*/ -}phNfc_eModeType_t; - -/** - * State Structure to hold the State Information - * - * This structure holds the state Information of a specified - * Layer . - * - */ - -typedef struct phNfc_sState -{ - uint8_t cur_state; - uint8_t transition; - uint8_t next_state; - /* uint8_t event; */ - -}phNfc_sState_t; - - - -/** - * Transaction Completion Information Structure - * - * This structure holds the completion callback information of the - * transaction passed from the lower layer to the upper layer - * along with the completion callback. - */ - -typedef struct phNfc_sTransactionInfo -{ - /* Returns the status of the Transaction Completion routine */ - NFCSTATUS status; - /* Indicates the Type of the Transaction */ - uint8_t type; - /* To contain more Transaction Notification specific info */ - void *info; - /* The data response from the Transaction */ - uint8_t *buffer; - /* The size of the data response from the Transaction */ - uint16_t length; -}phNfc_sTransactionInfo_t; - -/** - * Notification Information Structure - * - * This structure holds the notification callback information passed from - * the lower layer to the upper layer along with the notification callback. - */ - -typedef struct phNfc_sCompletionInfo -{ - /* Returns the status of the completion routine */ - NFCSTATUS status; - - /* Indicates the Type of the Information - * associated with the completion - */ - uint8_t type; - - /* To contain more completion specific info */ - void *info; - -}phNfc_sCompletionInfo_t; - - -/** - * Notification Information - * - */ -typedef struct phNfc_sNotificationInfo -{ - /* Returns the status of the Notification routine */ - NFCSTATUS status; - /* Indicates the Type of the Notification */ - phHal_eNotificationType_t type; - /* To contain more Notification specific info */ - void *info; - -}phNfc_sNotificationInfo_t; - - -/* -################################################################################ -********************* Callback Function Type Definition ************************ -################################################################################ -*/ - -/** -* Interface Notification Callback -* -* This callback notifies the occurrance of an event in the Lower Interface. -* -* \param [in] pContext Context for the Callback Function -* \param [in] pHwRef Pointer to the Hardware Reference -* \param [in] type Type of the Notification sent -* \param [out] pInfo Pointer to the Transaction Information Structure -* which contains the Status of the operation, data -* obtained or sent and size of the data sent or received -*/ - -typedef void (*pphNfcIF_Notification_CB_t) ( - void *pContext, - void *pHwRef, - uint8_t type, - void *pInfo - ); - -/** -* asynchronous Interface Transaction Completion callback -* -* This callback signals the completion of the asynchronous send or receive -* operation. The number of bytes sent or recieved is returned back. -* -* \param [in] pContext Context for the Callback Function -* \param [in] pHwRef Pointer to the Hardware Reference -* \param [out] pInfo Pointer to the Transaction Information Structure -* which contains the Status of the operation, data -* obtained or sent and size of the data sent or received -*/ - -typedef void (*pphNfcIF_Transact_Completion_CB_t) ( - void *pContext, - void *pHwRef, - phNfc_sTransactionInfo_t *pInfo - ); - -/* -################################################################################ -********************** Generic Interface Function Prototype ******************** -################################################################################ -*/ - -/** - * Generic NFC Interface Function Type . - * - * \param [in] pContext Context pointer for the Generic Interface. - * \param [in] pHwRef pointer for the device interface link information. - */ - -typedef NFCSTATUS (*pphNfcIF_Interface_t) ( - void *pContext, - void *pHwRef - ); -/** - * Data Transaction between the lower layer interface - * - * Sends or Receives the given amount of data to the lower layer. - * The call returns immediately and the registered callback is - * called when all data has been written. - *

- * - * @note If the interface is not initialized the function does nothing. - * - * \param [in] pContext Context pointer for sending the data. - * \param [in] pHwRef pointer for the device interface link information. - * \param[in] data pointer to data buffer containing the data to be sent or - * to be received. The data pointer is valid at least until - * the registered callback is called. - * \param[in] length length of the data to be sent or to be received. - */ - -typedef NFCSTATUS (*pphNfcIF_Transact_t) ( - void *pContext, - void *pHwRef, - uint8_t *data, - uint16_t length - ); - - -/** - * Generic Interface structure with the Lower Layer - * - * This structure holds the context and function pointers of all functions - * required to interface with the Lower Layers. - */ - -typedef struct phNfc_sLowerIF -{ - void *pcontext; - pphNfcIF_Interface_t init; - pphNfcIF_Interface_t release; - pphNfcIF_Transact_t send; - pphNfcIF_Transact_t receive; - pphNfcIF_Transact_t receive_wait; - pphNfcIF_Interface_t transact_abort; - pphNfcIF_Interface_t unregister; -} phNfc_sLowerIF_t,*pphNfc_sLowerIF_t; - - -/** - * Generic Callback interface structure for the Lower layer. - * - * This structure holds the callback function pointers of the functions that - * performs the completion of a particular operation. These functions are used - * by the Lower Layer interface to convey the completion of an operation. - */ - -typedef struct phNfcIF_sCallBack -{ - /** -#include - -/*=========== CONSTANTS ===========*/ - -/** - * \name LLCP default parameters. - * - * Definitions for use when wanting to use default LLCP parameter values. - * - */ - /*@{*/ -#define PHFRINFC_LLCP_MIU_DEFAULT 128 /**< Default MIU value (in bytes).*/ -#define PHFRINFC_LLCP_WKS_DEFAULT 1 /**< Default WKS value (bitfield).*/ -#define PHFRINFC_LLCP_LTO_DEFAULT 10 /**< Default LTO value (in step of 10ms).*/ -#define PHFRINFC_LLCP_RW_DEFAULT 1 /**< Default RW value (in frames).*/ -#define PHFRINFC_LLCP_OPTION_DEFAULT 0 /**< Default OPTION value (in frames).*/ -#define PHFRINFC_LLCP_MIUX_DEFAULT 0 /**< Default MIUX value (in bytes) */ -#define PHFRINFC_LLCP_MIUX_MAX 0x7FF /**< Max MIUX value (in bytes) */ -#define PHFRINFC_LLCP_PDU_HEADER_MAX 3 /**< Max size of PDU header (in bytes) */ -#define PHFRINFC_LLCP_SN_MAX_LENGTH 255 /**< Max length value for the Service Name */ -#define PHFRINFC_LLCP_RW_MAX 15 /**< Max RW value (in frames).*/ -/*@}*/ - -/** - * \name LLCP config parameters. - * - * Definitions used for internal LLCP configuration. - * - */ - /*@{*/ -#define PHFRINFC_LLCP_NB_SOCKET_MAX 10 /**< Max.number of simultaneous sockets */ -#define PHFRINFC_LLCP_SNL_RESPONSE_MAX 256 /**< Max.number of simultaneous discovery requests */ -/*@}*/ - -/** - * \internal - * \name Fixed value for ERROR op code. - * - */ -/*@{*/ -#define PHFRINFC_LLCP_ERR_DISCONNECTED 0x00 -#define PHFRINFC_LLCP_ERR_FRAME_REJECTED 0x01 -#define PHFRINFC_LLCP_ERR_BUSY_CONDITION 0x02 -#define PHFRINFC_LLCP_ERR_NOT_BUSY_CONDITION 0x03 - -/** - * \internal - * \name Fixed value for DM op code. - * - */ -/*@{*/ -#define PHFRINFC_LLCP_DM_OPCODE_DISCONNECTED 0x00 -#define PHFRINFC_LLCP_DM_OPCODE_SAP_NOT_ACTIVE 0x01 -#define PHFRINFC_LLCP_DM_OPCODE_SAP_NOT_FOUND 0x02 -#define PHFRINFC_LLCP_DM_OPCODE_CONNECT_REJECTED 0x03 -#define PHFRINFC_LLCP_DM_OPCODE_CONNECT_NOT_ACCEPTED 0x20 -#define PHFRINFC_LLCP_DM_OPCODE_SOCKET_NOT_AVAILABLE 0x21 - - -/*========== ENUMERATES ===========*/ - -/* Enum reperesents the different LLCP Link status*/ -typedef enum phFriNfc_LlcpMac_eLinkStatus -{ - phFriNfc_LlcpMac_eLinkDefault, - phFriNfc_LlcpMac_eLinkActivated, - phFriNfc_LlcpMac_eLinkDeactivated -}phFriNfc_LlcpMac_eLinkStatus_t; - -/* Enum represents the different Socket types */ -typedef enum phFriNfc_LlcpTransport_eSocketType -{ - phFriNfc_LlcpTransport_eDefaultType, - phFriNfc_LlcpTransport_eConnectionOriented, - phFriNfc_LlcpTransport_eConnectionLess -}phFriNfc_LlcpTransport_eSocketType_t; - - -/*========== STRUCTURES ===========*/ - -typedef struct phFriNfc_LlcpTransport_sSocketOptions -{ - /** The remote Maximum Information Unit Extension (NOTE: this is MIUX, not MIU !)*/ - uint16_t miu; - - /** The Receive Window size (4 bits)*/ - uint8_t rw; - -}phFriNfc_LlcpTransport_sSocketOptions_t; - -typedef struct phFriNfc_Llcp_sLinkParameters -{ - /** The remote Maximum Information Unit (NOTE: this is MIU, not MIUX !)*/ - uint16_t miu; - - /** The remote Well-Known Services*/ - uint16_t wks; - - /** The remote Link TimeOut (in 1/100s)*/ - uint8_t lto; - - /** The remote options*/ - uint8_t option; - -} phFriNfc_Llcp_sLinkParameters_t; - -#endif - -/* EOF */ diff --git a/libnfc-nxp/phNfcStatus.h b/libnfc-nxp/phNfcStatus.h deleted file mode 100644 index 01f48fb..0000000 --- a/libnfc-nxp/phNfcStatus.h +++ /dev/null @@ -1,343 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * \file phNfcStatus.h - * \brief NFC Status Values - Function Return Codes - * - * Project: NFC MW / HAL - * - * $Date: Wed Apr 29 16:28:21 2009 $ - * $Author: ing04880 $ - * $Revision: 1.31 $ - * $Aliases: NFC_FRI1.1_WK918_R24_1,NFC_FRI1.1_WK920_PREP1,NFC_FRI1.1_WK920_R25_1,NFC_FRI1.1_WK922_PREP1,NFC_FRI1.1_WK922_R26_1,NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ - * - */ - -#ifndef PHNFCSTATUS_H /* */ -#define PHNFCSTATUS_H/* */ - -#ifndef PH_FRINFC_EXCLUDE_FROM_TESTFW /* */ - -/** - * \name NFC Status - * - * File: \ref phNfcStatus.h - * - *\defgroup grp_retval ERROR Status Codes - */ -/*@{*/ -#define PHNFCSTATUS_FILEREVISION "$Revision: 1.31 $" /**< \ingroup grp_file_attributes */ -#define PHNFCSTATUS_FILEALIASES "$Aliases: NFC_FRI1.1_WK918_R24_1,NFC_FRI1.1_WK920_PREP1,NFC_FRI1.1_WK920_R25_1,NFC_FRI1.1_WK922_PREP1,NFC_FRI1.1_WK922_R26_1,NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ -/*@}*/ - -#endif /* PH_FRINFC_EXCLUDE_FROM_TESTFW */ - -#include - -/* Internally required by \ref PHNFCSTVAL. */ -#define PHNFCSTSHL8 (8U) -/* Required by \ref PHNFCSTVAL. */ -#define PHNFCSTBLOWER ((NFCSTATUS)(0x00FFU)) - -/** - * \name NFC Status Composition Macro - * - * This is the macro which must be used to compose status values. - * - * \param[in] phNfcCompID Component ID, as defined in \ref phNfcCompId.h . - * \param[in] phNfcStatus Status values, as defined in \ref phNfcStatus.h . - * - * \note The macro is not required for the \ref NFCSTATUS_SUCCESS value. This is the only - * return value to be used directly. - * For all other values it shall be used in assigment and conditional statements e.g.: - * - NFCSTATUS status = PHNFCSTVAL(phNfcCompID, phNfcStatus); ... - * - if (status == PHNFCSTVAL(phNfcCompID, phNfcStatus)) ... - * - */ -#define PHNFCSTVAL(phNfcCompID, phNfcStatus) \ - ( ((phNfcStatus) == (NFCSTATUS_SUCCESS)) ? (NFCSTATUS_SUCCESS) : \ - ( (((NFCSTATUS)(phNfcStatus)) & (PHNFCSTBLOWER)) | \ - (((uint16_t)(phNfcCompID)) << (PHNFCSTSHL8)) ) ) /**< \ingroup grp_retval - Use this macro for return value composition. */ -#define PHNFCSTATUS(phNfcStatus) ((phNfcStatus) & 0x00FFU) -#define PHNFCCID(phNfcStatus) (((phNfcStatus) & 0xFF00U)>>8) - -/** - * \name Status Codes - * - * Generic Status codes for the NFC components. Combined with the Component ID - * they build the value (status) returned by each - * function. Some Specific E.g.:\n - *

    - *
  • \ref grp_comp_id "Component ID" - e.g. 0x10, plus
  • - *
  • status code as listed in this file - e.g. 0x03
  • - *
- * result in a status value of 0x0003. - * - * \note The \ref grp_comp_id "Component ID" used for return codes - must not be \ref CID_NFC_NONE - * except for the value \ref NFCSTATUS_SUCCESS. - */ -/*@{*/ - -/** \ingroup grp_retval - The function indicates successful completion. */ -#define NFCSTATUS_SUCCESS (0x0000) - -/** \ingroup grp_retval - At least one paramter could not be properly interpreted. */ -#define NFCSTATUS_INVALID_PARAMETER (0x0001) - -/** \ingroup grp_retval - The buffer provided by the caller is too small. */ -#define NFCSTATUS_BUFFER_TOO_SMALL (0x0003) - -/** \ingroup grp_retval - Device specifier/handle value is invalid for the operation. */ -#define NFCSTATUS_INVALID_DEVICE (0x0006) - -/** \ingroup grp_retval - The function executed successfully but could have returned - more information than space provided by the caller. */ -#define NFCSTATUS_MORE_INFORMATION (0x0008) - -/** \ingroup grp_retval - No response from the remote device received: Time-out.*/ -#define NFCSTATUS_RF_TIMEOUT (0x0009) - -/** \ingroup grp_retval - RF Error during data transaction with the remote device.*/ -#define NFCSTATUS_RF_ERROR (0x000A) - -/** \ingroup grp_retval - Not enough resources (e.g. allocation failed.). */ -#define NFCSTATUS_INSUFFICIENT_RESOURCES (0x000C) - -/** \ingroup grp_retval - A non-blocking function returns this immediately to indicate - that an internal operation is in progress. */ -#define NFCSTATUS_PENDING (0x000D) - -/** \ingroup grp_retval - A board communication error occurred - (e.g. configuration went wrong). */ -#define NFCSTATUS_BOARD_COMMUNICATION_ERROR (0x000F) - -/** \ingroup grp_retval - Invalid State of the particular state machine - */ -#define NFCSTATUS_INVALID_STATE (0x0011) - - -/** \ingroup grp_retval - This Layer is Not initialised, hence initialisation required. - */ -#define NFCSTATUS_NOT_INITIALISED (0x0031) - - -/** \ingroup grp_retval - The Layer is already initialised, hence initialisation repeated. - */ -#define NFCSTATUS_ALREADY_INITIALISED (0x0032) - - -/** \ingroup grp_retval - Feature not supported . */ -#define NFCSTATUS_FEATURE_NOT_SUPPORTED (0x0033) - -/** \ingroup grp_retval - The Unregistration command has failed because the user wants to unregister on - an element for which he was not registered*/ -#define NFCSTATUS_NOT_REGISTERED (0x0034) - - -/** \ingroup grp_retval - The Registration command has failed because the user wants to register on - an element for which he is already registered*/ -#define NFCSTATUS_ALREADY_REGISTERED (0x0035) - -/** \ingroup grp_retval - Single Tag with Multiple - Protocol support detected. */ -#define NFCSTATUS_MULTIPLE_PROTOCOLS (0x0036) - -/** \ingroup grp_retval - Feature not supported . */ -#define NFCSTATUS_MULTIPLE_TAGS (0x0037) - -/** \ingroup grp_retval - A DESELECT event has occurred. */ -#define NFCSTATUS_DESELECTED (0x0038) - -/** \ingroup grp_retval - A RELEASE event has occurred. */ -#define NFCSTATUS_RELEASED (0x0039) - -/** \ingroup grp_retval - The operation is currently not possible or not allowed */ -#define NFCSTATUS_NOT_ALLOWED (0x003A) - -/** \ingroup grp_retval - The sytem is busy with the previous operation. -*/ -#define NFCSTATUS_BUSY (0x006F) - - -/* NDEF Mapping error codes */ - -/** \ingroup grp_retval - The remote device (type) is not valid for this request. */ -#define NFCSTATUS_INVALID_REMOTE_DEVICE (0x001D) - -/** \ingroup grp_retval - Smart tag functionality not supported */ -#define NFCSTATUS_SMART_TAG_FUNC_NOT_SUPPORTED (0x0013) - -/** \ingroup grp_retval - Read operation failed */ -#define NFCSTATUS_READ_FAILED (0x0014) - -/** \ingroup grp_retval - Write operation failed */ -#define NFCSTATUS_WRITE_FAILED (0x0015) - -/** \ingroup grp_retval - Non Ndef Compliant */ -#define NFCSTATUS_NO_NDEF_SUPPORT (0x0016) - -/** \ingroup grp_retval - Could not proceed further with the write operation: reached card EOF*/ -#define NFCSTATUS_EOF_NDEF_CONTAINER_REACHED (0x001A) - -/** \ingroup grp_retval - Incorrect number of bytes received from the card*/ -#define NFCSTATUS_INVALID_RECEIVE_LENGTH (0x001B) - -/** \ingroup grp_retval - The data format/composition is not understood/correct. */ -#define NFCSTATUS_INVALID_FORMAT (0x001C) - - -/** \ingroup grp_retval - There is not sufficient storage available. */ -#define NFCSTATUS_INSUFFICIENT_STORAGE (0x001F) - -/** \ingroup grp_retval - The Ndef Format procedure has failed. */ -#define NFCSTATUS_FORMAT_ERROR (0x0023) - - -/* - * Macros Required for FRI Stack -NFCSTATUS_INVALID_PARAMETER -NFCSTATUS_CMD_ABORTED -NFCSTATUS_FORMAT_STATUS -NFSTATUS_SUCCESS -NFCSTATUS_INVALID_REMOTE_DEVICE -NFCSTATUS_PENDING -NFCSTATUS_EOF_NDEF_CONTAINED_REACHED -NFCSTATUS_NO_NDEF_SUPPORT -NFCSTATUS_SMART_TAG_FUNC_NOT_SUPPORTED -NFCSTATUS_READ_FAILED -NFCSTATUS_WRITE_FAILED -NFCSTATUS_INVALID_RECEIVE_LENGTH -NFCSTATUS_BUFFER_TOO_SMALL -NFCSTATUS_NODE_NOT_FOUND -*/ - - -/* 0x70 to 0xCF Values are Component Specific Error Values */ - - -/** \ingroup grp_retval - Max number of Status Codes*/ -#define NFCSTATUS_FAILED (0x00FF) - -/*@}*/ - -#ifdef RFU_STATUS_CODES /* To Be Removed later */ - -/** \ingroup grp_retval - The function/command has been aborted. */ -#define NFCSTATUS_CMD_ABORTED (0x0002) - -/** \ingroup grp_retval - * Repeated call of the connecting function is not allowed. - * \if hal - * \sa \ref phHalNfc_Connect - * \endif */ -#define NFCSTATUS_ALREADY_CONNECTED (0x0004) - -/** \ingroup grp_retval - * Calling the polling function is not allowed when remote device - * are allready connected. - * \if hal - * \sa \ref phHalNfc_Poll - * \endif */ -#define NFCSTATUS_MULTI_POLL_NOT_SUPPORTED (0x0005) - - -/** \ingroup grp_retval - No target found after poll.*/ -#define NFCSTATUS_NO_DEVICE_FOUND (0x000A) - -/** \ingroup grp_retval - No target found after poll.*/ -#define NFCSTATUS_NO_TARGET_FOUND (0x000A) - -/** \ingroup grp_retval - Attempt to disconnect a not connected remote device. */ -#define NFCSTATUS_NO_DEVICE_CONNECTED (0x000B) - -/** \ingroup grp_retval - External RF field detected. */ -#define NFCSTATUS_EXTERNAL_RF_DETECTED (0x000E) - -/** \ingroup grp_retval - Message is not allowed by the state machine - (e.g. configuration went wrong). */ -#define NFCSTATUS_MSG_NOT_ALLOWED_BY_FSM (0x0010) - -/** \ingroup grp_retval - No access has been granted. */ -#define NFCSTATUS_ACCESS_DENIED (0x001E) - -/** \ingroup grp_retval - No registry node matches the specified input data. */ -#define NFCSTATUS_NODE_NOT_FOUND (0x0017) - -/** \ingroup grp_retval - The current module is busy ; one might retry later */ -#define NFCSTATUS_SMX_BAD_STATE (0x00F0) - - -/** \ingroup grp_retval - The Abort mechanism has failed for unexpected reason: user can try again*/ -#define NFCSTATUS_ABORT_FAILED (0x00F2) - - -/** \ingroup grp_retval - The Registration command has failed because the user wants to register as target - on a operating mode not supported*/ -#define NFCSTATUS_REG_OPMODE_NOT_SUPPORTED (0x00F5) - - -#endif - - -#endif /* PHNFCSTATUS_H */ - diff --git a/libnfc-nxp/phNfcTypes.h b/libnfc-nxp/phNfcTypes.h deleted file mode 100644 index 79d12aa..0000000 --- a/libnfc-nxp/phNfcTypes.h +++ /dev/null @@ -1,1109 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * \file phNfcTypes.h - * \brief Basic type definitions. - * - * Project: NFC MW / HAL - * - * $Date: Thu Jun 25 21:24:53 2009 $ - * $Author: ing04880 $ - * $Revision: 1.13 $ - * $Aliases: NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ - * - */ - -#ifndef PHNFCTYPES /* */ -#define PHNFCTYPES /* */ - -/** - * \name NFC Types - * - * File: \ref phNfcTypes.h - * - */ -/*@{*/ -#define PHNFCTYPES_FILEREVISION "$Revision: 1.13 $" /**< \ingroup grp_file_attributes */ -#define PHNFCTYPES_FILEALIASES "$Aliases: NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /**< \ingroup grp_file_attributes */ -/*@}*/ - -#ifndef _WIN32 -#include -#else -#include -#include -#define snprintf _snprintf - -#ifndef linux -/** - * \name Basic Type Definitions - * - * Constant-length-type definition ('C99). - * - */ -/*@{*/ -#ifndef __int8_t_defined /* */ -#define __int8_t_defined /* */ -typedef signed char int8_t; /**< \ingroup grp_nfc_common - 8 bit signed integer */ -#endif - -#ifndef __int16_t_defined /* */ -#define __int16_t_defined /* */ -typedef signed short int16_t; /**< \ingroup grp_nfc_common - 16 bit signed integer */ -#endif - -#ifndef __stdint_h -#ifndef __int32_t_defined /* */ -#define __int32_t_defined /* */ -typedef signed long int32_t; /**< \ingroup grp_nfc_common - 32 bit signed integer */ -#endif -#endif - -#ifndef __uint8_t_defined /* */ -#define __uint8_t_defined /* */ -typedef unsigned char uint8_t; /**< \ingroup grp_nfc_common - 8 bit unsigned integer */ -#endif - -#ifndef __uint16_t_defined /* */ -#define __uint16_t_defined /* */ -typedef unsigned short uint16_t; /**< \ingroup grp_nfc_common - 16 bit unsigned integer */ -#endif - -#ifndef __stdint_h -#ifndef __uint32_t_defined /* */ -#define __uint32_t_defined /* */ -typedef unsigned long uint32_t; /**< \ingroup grp_nfc_common - 32 bit unsigned integer */ -#endif -#endif - -#endif /* linux */ - -#endif /* _WIN32 */ - -#ifndef TRUE -#define TRUE (0x01) /**< \ingroup grp_nfc_common - Logical True Value */ -#endif - -#ifndef FALSE -#define FALSE (0x00) /**< \ingroup grp_nfc_common - Logical False Value */ -#endif - -typedef uint8_t utf8_t; /**< \ingroup grp_nfc_common - UTF8 Character String */ - -typedef uint8_t bool_t; /**< \ingroup grp_nfc_common - boolean data type */ - -typedef uint16_t NFCSTATUS; /**< \ingroup grp_nfc_common - NFC return values - \ref phNfcStatus.h for different status - values */ - -#ifndef NULL -#define NULL ((void *)0) -#endif - -/* This Macro to be used to resolve Unused and unreference - * compiler warnings. - */ - -#define PHNFC_UNUSED_VARIABLE(x) for((x)=(x);(x)!=(x);) - -/*@}*/ - -/** - * - * \name HAL Overall Definitions - * - * Definitions applicable to a variety of purposes and functions/features. - * - */ - /*@{*/ - -#define PHHAL_COMMON_MAX_STRING_LENGTH 0x40U /**< \ingroup grp_hal_common - Maximum vendor name length in bytes. */ -#define PHHAL_UNKNOWN_DEVICE_TYPE 0x00U /**< \ingroup grp_hal_common - Unknown device type. */ -#define PHHAL_SERIAL_DEVICE 0x01U /**< \ingroup grp_hal_common - Serial device type. */ -#define PHHAL_USB_DEVICE 0x02U /**< \ingroup grp_hal_common - USB device type. */ -#define PHHAL_I2C_DEVICE 0x03U /**< \ingroup grp_hal_common - I2C device type. */ -#define PHHAL_SPI_DEVICE 0x04U /**< \ingroup grp_hal_common - SPI device type. */ -#define PHHAL_PARALLEL_DEVICE 0x05U /**< \ingroup grp_hal_common - Parallel device type. */ -#define PHHAL_NFCID_LENGTH 0x0AU /**< \ingroup grp_hal_common - Maximum length of NFCID 1..3. */ - -#define PHHAL_MAX_DATASIZE 0xFBU /* 256 * Maximum Data size sent - * by the HAL - */ - -#define PHHAL_ATQA_LENGTH 0x02U /**< ATQA length */ -#define PHHAL_MAX_UID_LENGTH 0x0AU /**< Maximum UID length expected */ -#define PHHAL_MAX_ATR_LENGTH 0x30U /**< Maximum ATR_RES (General Bytes) - * length expected */ - -#define PHHAL_ATQB_LENGTH 0x0BU /**< ATQB length */ - -#define PHHAL_PUPI_LENGTH 0x04U /**< PUPI length */ -#define PHHAL_APP_DATA_B_LENGTH 0x04U /**< Application Data length for Type B */ -#define PHHAL_PROT_INFO_B_LENGTH 0x03U /**< Protocol info length for Type B */ -#define PHHAL_FEL_SYS_CODE_LEN 0x02U /**< Felica System Code Length */ -#define PHHAL_FEL_ID_LEN 0x08U /**< Felica current ID Length */ -#define PHHAL_FEL_PM_LEN 0x08U /**< Felica current PM Length */ -#define PHHAL_15693_UID_LENGTH 0x08U /**< Length of the Inventory bytes for - ISO15693 Tag */ - -#define VENDOR_NAME_LEN 0x14U -#define MAX_TRANSFER_UNIT 0x21U -#define SESSIONID_SIZE 0x08U -#define MAX_AID_LEN 0x10U -#define MAX_UICC_PARAM_LEN 0xFFU - -#define MIFARE_BITMASK 0x08U -#define ISO_14443_BITMASK 0x20U -#define ISO_14443_DETECTED 0x20U -#define NFCIP_BITMASK 0x40U -#define NFCIP_DETECTED 0x40U - -#define MAX_TARGET_SUPPORTED MAX_REMOTE_DEVICES - -#define NFC_HW_PN65N 0x10U - -#define NXP_NFCIP_NFCID2_ID 0x01FEU - -#define NXP_FULL_VERSION_LEN 0x0BU - - -/*@}*/ - - -/** - * \name NFC specific Type Definitions - * - */ -/*@{*/ - -/** - * Data Buffer Structure to hold the Data Buffer - * - * This structure holds the Data in the Buffer of the specified - * size. - * - */ -typedef struct phNfc_sData_t -{ - uint8_t *buffer; - uint32_t length; -} phNfc_sData_t; - -/** - * \brief Possible Hardware Configuration exposed to upper layer. - * Typically this should be at least the communication link (Ex:"COM1","COM2") - * the controller is connected to. - */ -typedef struct phLibNfc_sConfig_t -{ - /** Device node of the controller */ - const char* deviceNode; - /** The client ID (thread ID or message queue ID) */ - intptr_t nClientId; -} phLibNfc_sConfig_t, *pphLibNfc_sConfig_t; - - -/*! - * NFC Message structure contains message specific details like - * message type, message specific data block details, etc. - */ -typedef struct phLibNfc_Message_t -{ - uint32_t eMsgType;/**< Type of the message to be posted*/ - void * pMsgData;/**< Pointer to message specific data block in case any*/ - uint32_t Size;/**< Size of the datablock*/ -} phLibNfc_Message_t,*pphLibNfc_Message_t; - - -#ifdef WIN32 -#define PH_LIBNFC_MESSAGE_BASE (WM_USER+0x3FF) -#endif -/** - * Deferred message. This message type will be posted to the client application thread - * to notify that a deferred call must be invoked. - */ -#define PH_LIBNFC_DEFERREDCALL_MSG (0x311) - -/** - *\brief Deferred call declaration. - * This type of API is called from ClientApplication ( main thread) to notify - * specific callback. - */ -typedef void (*pphLibNfc_DeferredCallback_t) (void*); -/** - *\brief Deferred parameter declaration. - * This type of data is passed as parameter from ClientApplication (main thread) to the - * callback. - */ -typedef void *pphLibNfc_DeferredParameter_t; -/** - *\brief Deferred message specific info declaration. - * This type of information is packed as message data when \ref PH_LIBNFC_DEFERREDCALL_MSG - * type message is posted to message handler thread. - */ -typedef struct phLibNfc_DeferredCall_t -{ - pphLibNfc_DeferredCallback_t pCallback;/**< pointer to Deferred callback */ - pphLibNfc_DeferredParameter_t pParameter;/**< pointer to Deferred parameter */ -} phLibNfc_DeferredCall_t; - - -/** \ingroup grp_hal_common - * - * \brief Protocol Support Information - * - * The Supported Protocols Structure holds all protocol supported by the current NFC - * device. - * - * \note All members of this structure are output parameters [out]. - * - */ -typedef struct phNfc_sSupProtocol_t -{ - unsigned int MifareUL : 1; /**< Protocol Mifare Ultra Light or - any NFC Forum Type-2 tags */ - unsigned int MifareStd : 1; /**< Protocol Mifare Standard. */ - unsigned int ISO14443_4A : 1; /**< Protocol ISO14443-4 Type A. */ - unsigned int ISO14443_4B : 1; /**< Protocol ISO14443-4 Type B. */ - unsigned int ISO15693 : 1; /**< Protocol ISO15693 HiTag. */ - unsigned int Felica : 1; /**< Protocol Felica. */ - unsigned int NFC : 1; /**< Protocol NFC. */ - unsigned int Jewel : 1; /**< Protocol Innovision Jewel Tag. */ - /*** TODO: Add SWP, ETSI HCI to this list **/ -} phNfc_sSupProtocol_t; - - -/** \ingroup grp_hal_common - * - * - * \brief Information related to the NFC Device - * - * The Device Information Structure holds information - * related to the NFC IC read during initialization time. - * It allows the caller firware, hardware version, the model id, - * HCI verison supported and vendor name. Refer to the NFC Device - * User Manual on how to interpret each of the values. In addition - * it also contains capabilities of the NFC Device such as the - * protocols supported in Reader and emulation mode - * - */ -typedef struct phNfc_sDeviceCapabilities_t -{ - /* */ - uint32_t hal_version; /**< \ingroup grp_hal_common - HAL 4.0 Version Information. */ - uint32_t fw_version; /**< \ingroup grp_hal_common - Firmware Version Info. */ - uint32_t hw_version; /**< \ingroup grp_hal_common - Hardware Version Info. */ - uint8_t model_id; /**< \ingroup grp_hal_common - IC Variant . */ - uint8_t hci_version; /**< \ingroup grp_hal_common - ETSI HCI Version Supported */ - utf8_t vendor_name[VENDOR_NAME_LEN]; /**< \ingroup grp_hal_common - Vendor name (Null terminated string)*/ - uint8_t full_version[NXP_FULL_VERSION_LEN]; - - phNfc_sSupProtocol_t ReaderSupProtocol; /**< Supported protocols - (Bitmapped) in Reader mode. */ - phNfc_sSupProtocol_t EmulationSupProtocol; /**< Supported protocols - (Bitmapped) in Emulation - mode. */ - char firmware_update_info; /** */ -} phNfc_sDeviceCapabilities_t; - - -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ - - -/** \ingroup grp_hal_common - * - * \brief Enumerated MIFARE Commands - * - * The Mifare Command List Enumerator lists all available Mifare native commands. - * - * \note None. - * - */ -typedef enum phNfc_eMifareCmdList_t -{ - phNfc_eMifareRaw = 0x00U, /**< This command performs raw transcations . - Format of the phLibNfc_sTransceiveInfo_t - content in this case shall be as below: - � cmd: filed shall set to phHal_eMifareRaw . - � addr : doesn't carry any significance. - � sSendData : Shall contain formatted raw buffer - based on MIFARE commands type used. - Formatted buffer shall follow below - formating scheme. - - CmdType+ Block No + CommandSpecific data + 2 byte CRC - Ex: With Write 4 byte command on block 8 looks as - " 0xA2,0x08,0x01,0x02,0x03,0x04,CRC1,CRC2 - Note : For MIFARE Std card we recommend use MIFARE - commands directly. - */ - phNfc_eMifareAuthentA = 0x60U, /**< Mifare Standard:\n - This command performs an authentication with KEY A for a sector.\n - Format of the phLibNfc_sTransceiveInfo_t content in this case is : - � cmd: field shall set to phHal_eMifareAuthentA . - � addr : indicates MIFARE block address. - Ex: 0x08 indicates block 8 needs to be authenticated. - � sSendData : Shall contain authentication key values. - sSendData ,buffer shall contain authentication - key values 01 02 03 04 05 06 authenticates - block 08 with the key 0x01[..]06. If this - command fails, then user needs to reactivate - the remote Mifare card. - */ - phNfc_eMifareAuthentB = 0x61U, /**< Mifare Standard:\n - This command performs an authentication with KEY B for a sector.\n - Format of the phLibNfc_sTransceiveInfo_t content in this case is : - � cmd: field shall set to phHal_eMifareAuthentB . - � addr : indicates MIFARE block address. - Ex: 0x08 indicates block 8 needs to be authenticated. - � sSendData : Shall contain authentication key values. - sSendData ,buffer shall contain authentication - key values 01 02 03 04 05 06 authenticates - block 08 with the key 0x01[..]06. If this - command fails, then user needs to reactivate - the remote Mifare card. - */ - phNfc_eMifareRead16 = 0x30U, /**< Mifare Standard and Ultra Light:\n - Read 16 Bytes from a Mifare Standard block or 4 Mifare Ultra Light pages.\n - Format of the phLibNfc_sTransceiveInfo_t content in this case is : - � cmd: field shall set to phHal_eMifareRead16 . - � addr : memory adress to read. - � sRecvData : Shall contain buffer of size 16 - to read the data into. - - If this command fails, the user needs to reactivate the - the remote Mifare card - */ - phNfc_eMifareRead = 0x30U, - phNfc_eMifareWrite16 = 0xA0U, /**< Mifare Standard and Ultra Light:\n - Write 16 Bytes to a Mifare Standard block or 4 Mifare Ultra Light pages.\n - Format of the phLibNfc_sTransceiveInfo_t content in this case is : - � cmd: field shall set to phHal_eMifareWrite16 . - � addr : starting memory adress to write from. - � sSendData : Shall contain buffer of size 16 containing - the data bytes to be written. - - If this command fails, the user needs to reactivate the - the remote Mifare card - */ - phNfc_eMifareWrite4 = 0xA2U, /**< Mifare Ultra Light:\n - Write 4 bytes.\n - Format of the phLibNfc_sTransceiveInfo_t content in this case is : - � cmd: field shall set to phHal_eMifareWrite4 . - � addr : starting memory adress to write from. - � sSendData : Shall contain buffer of size 4 containing - the data bytes to be written. - - If this command fails, the user needs to reactivate the - the remote Mifare card - */ - phNfc_eMifareInc = 0xC1U, /**< Increment. */ - phNfc_eMifareDec = 0xC0U, /**< Decrement. */ - phNfc_eMifareTransfer = 0xB0U, /**< Tranfer. */ - phNfc_eMifareRestore = 0xC2U, /**< Restore. */ - phNfc_eMifareReadSector = 0x38U, /**< Read Sector. */ - phNfc_eMifareWriteSector= 0xA8U, /**< Write Sector. */ - phNfc_eMifareInvalidCmd = 0xFFU /**< Invalid Command */ -} phNfc_eMifareCmdList_t; - - -/** \ingroup grp_hal_common - * - * The T=Cl Command List Enumerator lists all available T=Cl Commands. - * - * \note None. - * - */ -typedef enum phNfc_eIso14443_4_CmdList_t -{ - phNfc_eIso14443_4_Raw = 0x00U /**< ISO 14443-4 Exchange command:\n - - This command sends the data buffer directly - to the remote device */ - -} phNfc_eIso14443_4_CmdList_t; - - -/** \ingroup grp_hal_common - * - * The NFCIP1 Command List Enumerator lists all available NFCIP1 Commands. - * - * \note None. - * - */ -typedef enum phNfc_eNfcIP1CmdList_t -{ - phNfc_eNfcIP1_Raw = 0x00U /**< NfcIP Exchange command:\n - - This command sends the data buffer directly - to the remote device */ -}phNfc_eNfcIP1CmdList_t; - - -/** \ingroup grp_hal_common - * - * The ISO15693 Command List Enumerator lists all available ISO15693 Commands. - * - * \note None. - * - */ -typedef enum phNfc_eIso15693_CmdList_t -{ -#if 0 - phNfc_eIso15693_Raw = 0x00U, /**< ISO 15693 Exchange Raw command:\n - - This command sends the data buffer directly - to the remote device */ -#endif - phNfc_eIso15693_Cmd = 0x20U, /**< ISO 15693 Exchange command:\n - - This command is used to access the card - to the remote device */ - phNfc_eIso15693_Invalid = 0xFFU /**< Invalid Command */ -} phNfc_eIso15693_CmdList_t; - - -/** \ingroup grp_hal_common - * - * The Felica Command List Enumerator lists all available Felica Commands. - * - * \note None. - * - */ -typedef enum phNfc_eFelicaCmdList_t -{ - phNfc_eFelica_Raw = 0xF0U, /**< Felica Raw command:\n - - This command sends the data buffer directly - to the remote device */ - phNfc_eFelica_Check = 0x00, /**< Felica Check command:\n - - This command checks the data from the Felica - remote device */ - phNfc_eFelica_Update = 0x01, /**< Felica Update command:\n - - This command updates the data onto the Felica - remote device */ - phNfc_eFelica_Invalid = 0xFFU /**< Invalid Command */ -} phNfc_eFelicaCmdList_t; - - -/** \ingroup grp_hal_common - * - * The Jewel Command List Enumerator lists all available Jewel Commands. - * - * \note None. - * - */ -typedef enum phNfc_eJewelCmdList_t -{ - phNfc_eJewel_Raw = 0x00U, /**< Jewel command:\n - - This command sends the data buffer directly - to the remote device */ - phNfc_eJewel_Invalid = 0xFFU /**< Invalid jewel command */ -}phNfc_eJewelCmdList_t; - - -/** \ingroup grp_hal_nfci -* -* \brief Remote Device Reader A RF Gate Information Container -* -* The Reader A structure includes the available information -* related to the discovered ISO14443A remote device. This information -* is updated for every device discovery. -* \note None. -* -*/ -typedef struct phNfc_sIso14443AInfo_t -{ - uint8_t Uid[PHHAL_MAX_UID_LENGTH]; /**< UID information of the TYPE A - Tag Discovered */ - uint8_t UidLength; /**< UID information length, shall not be greater - than PHHAL_MAX_UID_LENGTH i.e., 10 */ - uint8_t AppData[PHHAL_MAX_ATR_LENGTH]; /**< Application data information of the - tag discovered (= Historical bytes for - type A) */ - uint8_t AppDataLength; /**< Application data length */ - uint8_t Sak; /**< SAK informationof the TYPE A - Tag Discovered */ - uint8_t AtqA[PHHAL_ATQA_LENGTH]; /**< ATQA informationof the TYPE A - Tag Discovered */ - uint8_t MaxDataRate; /**< Maximum data rate supported by the TYPE A - Tag Discovered */ - uint8_t Fwi_Sfgt; /**< Frame waiting time and start up frame guard - time as defined in ISO/IEC 14443-4[7] for - type A */ -} phNfc_sIso14443AInfo_t; - - -/** \ingroup grp_hal_nfci -* -* \brief Remote Device Reader B RF Gate Information Container -* -* The Reader B structure includes the available information -* related to the discovered ISO14443B remote device. This information -* is updated for every device discovery. -* \note None. -* -*/ -typedef struct phNfc_sIso14443BInfo_t -{ - union phNfc_uAtqBInfo - { - struct phNfc_sAtqBInfo - { - uint8_t Pupi[PHHAL_PUPI_LENGTH]; /**< PUPI information of the TYPE B - Tag Discovered */ - uint8_t AppData[PHHAL_APP_DATA_B_LENGTH]; /**< Application Data of the TYPE B - Tag Discovered */ - uint8_t ProtInfo[PHHAL_PROT_INFO_B_LENGTH]; /**< Protocol Information of the TYPE B - Tag Discovered */ - } AtqResInfo; - uint8_t AtqRes[PHHAL_ATQB_LENGTH]; /**< ATQB Response Information of TYPE B - Tag Discovered */ - } AtqB; - uint8_t HiLayerResp[PHHAL_MAX_ATR_LENGTH]; /**< Higher Layer Response information - in answer to ATRRIB Command for Type B */ - uint8_t HiLayerRespLength; /**< Higher Layer Response length */ - uint8_t Afi; /**< Application Family Identifier of TYPE B - Tag Discovered */ - uint8_t MaxDataRate; /**< Maximum data rate supported by the TYPE B - Tag Discovered */ -} phNfc_sIso14443BInfo_t; - - -/** \ingroup grp_hal_nfci -* -* \brief Remote Device Reader B prime RF Gate Information Container -* -*/ -typedef struct phNfc_sIso14443BPrimeInfo_t -{ - /* TODO: This will be updated later */ - void *BPrimeCtxt; -} phNfc_sIso14443BPrimeInfo_t; - - -/** \ingroup grp_hal_nfci -* -* \brief Remote Device Jewel Reader RF Gate Information Container -* -* The Jewel Reader structure includes the available information -* related to the discovered Jewel remote device. This information -* is updated for every device discovery. -* \note None. -* -*/ -typedef struct phNfc_sJewelInfo_t -{ - uint8_t Uid[PHHAL_MAX_UID_LENGTH]; /**< UID information of the TYPE A - Tag Discovered */ - uint8_t UidLength; /**< UID information length, shall not be greater - than PHHAL_MAX_UID_LENGTH i.e., 10 */ - uint8_t HeaderRom0; /**< Header Rom byte zero */ - uint8_t HeaderRom1; /**< Header Rom byte one */ - -} phNfc_sJewelInfo_t; - - -/** \ingroup grp_hal_nfci -* -* \brief Remote Device Felica Reader RF Gate Information Container -* -* The Felica Reader structure includes the available information -* related to the discovered Felica remote device. This information -* is updated for every device discovery. -* \note None. -* -*/ -typedef struct phNfc_sFelicaInfo_t -{ - uint8_t IDm[(PHHAL_FEL_ID_LEN + 2)]; /**< Current ID of Felica tag */ - uint8_t IDmLength; /**< IDm length, shall not be greater - than PHHAL_FEL_ID_LEN i.e., 8 */ - uint8_t PMm[PHHAL_FEL_PM_LEN]; /**< Current PM of Felica tag */ - uint8_t SystemCode[PHHAL_FEL_SYS_CODE_LEN]; /**< System code of Felica tag */ -} phNfc_sFelicaInfo_t; - - -/** \ingroup grp_hal_nfci -* -* \brief Remote Device Reader 15693 RF Gate Information Container -* -* The Reader A structure includes the available information -* related to the discovered ISO15693 remote device. This information -* is updated for every device discovery. -* \note None. -* -*/ - -typedef struct phNfc_sIso15693Info_t -{ - uint8_t Uid[PHHAL_15693_UID_LENGTH]; /**< UID information of the 15693 - Tag Discovered */ - uint8_t UidLength; /**< UID information length, shall not be greater - than PHHAL_15693_UID_LENGTH i.e., 8 */ - uint8_t Dsfid; /**< DSF information of the 15693 - Tag Discovered */ - uint8_t Flags; /**< Information about the Flags - in the 15693 Tag Discovered */ - uint8_t Afi; /**< Application Family Identifier of - 15693 Tag Discovered */ -} phNfc_sIso15693Info_t; - - -/** \ingroup grp_hal_nfci -* -* \brief NFC Data Rate Supported between the Reader and the Target -* -* The \ref phHalNfc_eDataRate enum lists all the Data Rate -* values to be used to determine the rate at which the data is transmitted -* to the target. -* -* \note None. -*/ - - -/** \ingroup grp_hal_nfci -* -* \brief NFCIP1 Data rates -* -*/ -typedef enum phNfc_eDataRate_t{ - phNfc_eDataRate_106 = 0x00U, - phNfc_eDataRate_212, - phNfc_eDataRate_424, - /* phNfc_eDataRate_848, - phNfc_eDataRate_1696, - phNfc_eDataRate_3392, - phNfc_eDataRate_6784,*/ - phNfc_eDataRate_RFU -} phNfc_eDataRate_t; - - -/** \ingroup grp_hal_nfci -* -* \brief NFCIP1 Gate Information Container -* -* The NFCIP1 structure includes the available information -* related to the discovered NFCIP1 remote device. This information -* is updated for every device discovery. -* \note None. -* -*/ -typedef struct phNfc_sNfcIPInfo_t -{ - /* Contains the random NFCID3I conveyed with the ATR_REQ. - always 10 bytes length - or contains the random NFCID3T conveyed with the ATR_RES. - always 10 bytes length */ - uint8_t NFCID[PHHAL_MAX_UID_LENGTH]; - uint8_t NFCID_Length; - /* ATR_RES = General bytes length, Max length = 48 bytes */ - uint8_t ATRInfo[PHHAL_MAX_ATR_LENGTH]; - uint8_t ATRInfo_Length; - /**< SAK information of the tag discovered */ - uint8_t SelRes; - /**< ATQA information of the tag discovered */ - uint8_t SenseRes[PHHAL_ATQA_LENGTH]; - /**< Is Detection Mode of the NFCIP Target Active */ - uint8_t Nfcip_Active; - /**< Maximum frame length supported by the NFCIP device */ - uint16_t MaxFrameLength; - /**< Data rate supported by the NFCIP device */ - phNfc_eDataRate_t Nfcip_Datarate; - -} phNfc_sNfcIPInfo_t; - - -/** \ingroup grp_hal_nfci -* -* \brief Remote Device Specific Information Container -* -* The Remote Device Information Union includes the available Remote Device Information -* structures. Following the device detected, the corresponding data structure is used. -* -* \note None. -* -*/ -typedef union phNfc_uRemoteDevInfo_t -{ - phNfc_sIso14443AInfo_t Iso14443A_Info; - phNfc_sIso14443BInfo_t Iso14443B_Info; - phNfc_sIso14443BPrimeInfo_t Iso14443BPrime_Info; - phNfc_sNfcIPInfo_t NfcIP_Info; - phNfc_sFelicaInfo_t Felica_Info; - phNfc_sJewelInfo_t Jewel_Info; - phNfc_sIso15693Info_t Iso15693_Info; -} phNfc_uRemoteDevInfo_t; - - -/** \ingroup grp_hal_nfci -* -* \brief RF Device Type Listing -* -* The RF Device Type List is used to identify the type of -* remote device that is discovered/connected. There seperate -* types to identify a Remote Reader (denoted by _PCD) and -* Remote Tag (denoted by _PICC) -* \note None. -* -*/ -typedef enum phNfc_eRFDevType_t -{ - phNfc_eUnknown_DevType = 0x00U, - - /* Specific PCD Devices */ - phNfc_eISO14443_A_PCD, - phNfc_eISO14443_B_PCD, - phNfc_eISO14443_BPrime_PCD, - phNfc_eFelica_PCD, - phNfc_eJewel_PCD, - phNfc_eISO15693_PCD, - /* Generic PCD Type */ - phNfc_ePCD_DevType, - - /* Generic PICC Type */ - phNfc_ePICC_DevType, - /* Specific PICC Devices */ - phNfc_eISO14443_A_PICC, - phNfc_eISO14443_4A_PICC, - phNfc_eISO14443_3A_PICC, - phNfc_eMifare_PICC, - phNfc_eISO14443_B_PICC, - phNfc_eISO14443_4B_PICC, - phNfc_eISO14443_BPrime_PICC, - phNfc_eFelica_PICC, - phNfc_eJewel_PICC, - phNfc_eISO15693_PICC, - - /* NFC-IP1 Device Types */ - phNfc_eNfcIP1_Target, - phNfc_eNfcIP1_Initiator, - - /* Other Sources */ - phNfc_eInvalid_DevType - -} phNfc_eRFDevType_t; - - -/** \ingroup grp_hal_nfci -* -* \brief Remote Device Type Listing -* -* The Remote Device Type List is used to identify the type of -* remote device that is discovered/connected -* \note This is same as RF Device Type List. -* -*/ -typedef phNfc_eRFDevType_t phNfc_eRemDevType_t; - - -/** \ingroup grp_hal_common - * - * - * \brief Common Command Attribute - * - * The Hal Command Union includes each available type of Commands. - * - * \note None. - * - */ -typedef union phNfc_uCommand_t -{ - phNfc_eMifareCmdList_t MfCmd; /**< Mifare command structure. */ - phNfc_eIso14443_4_CmdList_t Iso144434Cmd; /**< ISO 14443-4 command structure. */ - phNfc_eFelicaCmdList_t FelCmd; /**< Felica command structure. */ - phNfc_eJewelCmdList_t JewelCmd; /**< Jewel command structure. */ - phNfc_eIso15693_CmdList_t Iso15693Cmd; /**< ISO 15693 command structure. */ - phNfc_eNfcIP1CmdList_t NfcIP1Cmd; /**< ISO 18092 (NFCIP1) command structure */ -} phNfc_uCmdList_t; - - -/** \ingroup grp_hal_nfci - * - * \brief Remote Device Information Structure - * - * The Remote Device Information Structure holds information about one single Remote - * Device detected by the polling function .\n - * It lists parameters common to all supported remote devices. - * - * \note - * - * \sa \ref phHal4Nfc_ConfigureDiscovery and \ref phHal4Nfc_Connect - * - */ -typedef struct phNfc_sRemoteDevInformation_t -{ - uint8_t SessionOpened; /**< [out] Boolean - * Flag indicating the validity of - * the handle of the remote device. */ - phNfc_eRemDevType_t RemDevType; /**< [out] Remote device type which says that remote - is Reader A or Reader B or NFCIP or Felica or - Reader B Prime or Jewel*/ - phNfc_uRemoteDevInfo_t RemoteDevInfo; /**< Union of available Remote Device. - * \ref phNfc_uRemoteDevInfo_t Information. */ -} phNfc_sRemoteDevInformation_t; - - -/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* TARGET STRUCTURES */ - - -/** \ingroup grp_hal_common - * - * \brief Transceive Information Data Structure for sending commands/response - * to the remote device - * - * The Transceive Information Data Structure is used to pass the - * Command, Address (only required for MIFARE) and the send and receive data - * data structure (buffer and length) for communication with remote device - * - * - */ -typedef struct phNfc_sTransceiveInfo_t -{ - phNfc_uCmdList_t cmd; - - /** \internal Address Field required for only Mifare - * Family Proprietary Cards. - * The Address Size is Valid only upto 255 Blocks limit - * i:e for Mifare 4K - */ - uint8_t addr; - phNfc_sData_t sSendData; - phNfc_sData_t sRecvData; -} phNfc_sTransceiveInfo_t; - - -/** \ingroup grp_hal_nfci -* -* \brief Poll Device Information for conifiguring the discovery wheel - Reader and Card Emulation Phases -* -* The \ref phNfc_sPollDevInfo_t enum is used to enable/disable -* phases of the discovery wheel related to specific reader types and -* card emulation phase -* \note Enabling specific Reader technology when NFCIP1 speed is set in the -* phNfc_sADD_Cfg_t is implicitly done in HAL. Use this structure to only -* enable/disable Card Reader Functionality -*/ -typedef struct phNfc_sPollDevInfo_t -{ - unsigned EnableIso14443A : 1; /**< Flag to enable - Reader A discovery */ - unsigned EnableIso14443B : 1; /**< Flag to enable - Reader B discovery */ - unsigned EnableFelica212 : 1; /**< Flag to enable - Felica 212 discovery */ - unsigned EnableFelica424 : 1; /**< Flag to enable - Felica 424 discovery */ - unsigned EnableIso15693 : 1; /**< Flag to enable - ISO 15693 discovery */ - unsigned EnableNfcActive : 1; /**< Flag to enable - Active Mode of NFC-IP discovery. - This is updated internally - based on the NFC-IP speed. - */ - unsigned RFU : 1; /**< Reserved for future use */ - unsigned DisableCardEmulation : 1; /**< Flag to - disable the card emulation */ -} phNfc_sPollDevInfo_t; - - -/** \ingroup grp_hal_nfci -* -* \brief P2P speed for the Initiator -* -* The \ref phNfc_eP2PMode_t enum lists all the NFCIP1 speeds -* to be used for configuring the NFCIP1 discovery -* -* \note None. -*/ -typedef enum phNfc_eP2PMode_t -{ - phNfc_eDefaultP2PMode = 0x00U, - phNfc_ePassive106 = 0x01U, - phNfc_ePassive212 = 0x02U, - phNfc_ePassive424 = 0x04U, - phNfc_eActive106 = 0x08U, - phNfc_eActive212 = 0x10U, - phNfc_eActive424 = 0x20U, - phNfc_eP2P_ALL = 0x27U, /* All Passive and 424 Active */ - phNfc_eInvalidP2PMode = 0xFFU -} phNfc_eP2PMode_t; - - -/** \ingroup grp_hal_common -* -* \brief Identities the type of Notification -* -* This enumeration is used to specify the type of notification notified -* to the upper layer. This classifies the notification into two types -* one for the discovery notifications and the other for all the remaining -* event notifications -* \note None. -*/ -typedef enum phNfc_eNotificationType_t -{ - INVALID_NFC_NOTIFICATION = 0x00U, /* Invalid Notification */ - NFC_DISCOVERY_NOTIFICATION, /* Remote Device Discovery Notification */ - NFC_EVENT_NOTIFICATION /* Event Notification from the other hosts */ -} phNfc_eNotificationType_t; - - -/** \ingroup grp_hal_common -* -* \brief -* -* \note None. -*/ -typedef struct phNfc_sUiccInfo_t -{ - /* AID and Parameter Information is obtained if the - * eventType is NFC_EVT_TRANSACTION. - */ - phNfc_sData_t aid; - phNfc_sData_t param; - -} phNfc_sUiccInfo_t; - - -/** \ingroup grp_hal_nfci -* -* \brief P2P Information for the Initiator -* -* The \ref phNfc_sNfcIPCfg_t holds the P2P related information -* use by the NFC Device during P2P Discovery and connection -* -* \note None. -*/ -typedef struct phNfc_sNfcIPCfg_t -{ - /* ATR_RES = General bytes length, Max length = 48 bytes */ - uint8_t generalBytesLength; - uint8_t generalBytes[PHHAL_MAX_ATR_LENGTH]; - - /* TODO: This will be updated later for any additional params*/ -} phNfc_sNfcIPCfg_t; - - -/** \ingroup grp_hal_common -* -* \brief Discovery Configuration Mode -* -* This enumeration is used to choose the Discovery Configuration -* Mode :- Configure and Start, Stop or Start with last set -* configuration -* \note None. -*/ -typedef enum phNfc_eDiscoveryConfigMode_t -{ - NFC_DISCOVERY_CONFIG = 0x00U,/**< Configure discovery with values - in phNfc_sADD_Cfg_t and start - discovery */ - NFC_DISCOVERY_START, /**< Start Discovery with previously set - configuration */ - NFC_DISCOVERY_STOP, /**< Stop the Discovery */ - NFC_DISCOVERY_RESUME /**< Resume the Discovery with previously - * set configuration. - * This is valid only when the Target - * is not connected. - */ -}phNfc_eDiscoveryConfigMode_t; - -/** \ingroup grp_hal_common -* -* \brief Target or Tag Release Mode -* -* This enumeration defines various modes of releasing an acquired target -* or tag. -* \note None. -*/ -typedef enum phNfc_eReleaseType_t -{ - NFC_INVALID_RELEASE_TYPE =0x00U,/** Poll configuration structure holds information about the -* enabling the the type of discovery required by the application. This -* structure is the input parameter for the discovery call -* -* \note All members of this structure are input parameters [out]. -* -* \sa \ref phNfc_eP2PMode_t -* -*/ -typedef struct phNfc_sADD_Cfg_t -{ - union - { - phNfc_sPollDevInfo_t PollCfgInfo; /**< Enable/Disable Specific - Reader Functionality and - Card Emulation */ - unsigned PollEnabled; /** Can be used to set polling 'Off' - by setting PollEnabled to zero */ - - } PollDevInfo; - uint32_t Duration; /**< Duration of virtual or idle - period in microseconds in the step size - of 48 microseconds.If duration is set less - than 48 microseconds then default value is - used.For more details please refer PN 544 - user manual*/ - uint8_t NfcIP_Mode ; /**< Select the P2P - speeds using phNfc_eP2PMode_t type. - This is used to enable NFC-IP Discovery - The related Reader Type will be implicitly - selected */ - uint8_t NfcIP_Target_Mode ; - uint8_t NfcIP_Tgt_Disable; /**< Flag to - disable the NFCIP1 TARGET */ -} phNfc_sADD_Cfg_t; - -/*@}*/ - -#endif /* PHNFCTYPES */ - diff --git a/libnfc-nxp/phOsalNfc.h b/libnfc-nxp/phOsalNfc.h deleted file mode 100644 index e522263..0000000 --- a/libnfc-nxp/phOsalNfc.h +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright (C) 2010 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * \file phOsalNfc.h - * \brief OSAL Implementation. - * - * Project: NFC-FRI 1.1 - * $Date: Fri Jun 26 14:41:31 2009 $ - * $Author: ing04880 $ - * $Revision: 1.21 $ - * $Aliases: NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ - * - */ -#ifndef PHOSALNFC_H -#define PHOSALNFC_H - - -/** \defgroup grp_osal_nfc OSAL Component - * - *\note: API listed here encompasses Operating System Abstraction Layer interfaces required to be mapped to underlying OS platforms. - * - */ -#include - -#ifdef PH_NFC_CUSTOMINTEGRATION -#include -#else -#include - -/**< OSAL Message Type */ -#ifdef WIN32 -//#define PH_OSALNFC_MESSAGE_BASE (WM_USER+0x3FF) -#define PH_OSALNFC_MESSAGE_BASE PH_LIBNFC_MESSAGE_BASE -#endif - -/*! - * \ingroup grp_osal_nfc - * - * OSAL Message structure contains message specific details like - * message type, message specific data block details, etc. - */ -//typedef struct phOsalNfc_Message -//{ -// uint32_t eMsgType;/**< Type of the message to be posted*/ -// void * pMsgData;/**< Pointer to message specific data block in case any*/ -// uint16_t Size;/**< Size of the datablock*/ -//} phOsalNfc_Message_t,*pphOsalNfc_Message_t; -typedef phLibNfc_Message_t phOsalNfc_Message_t; -typedef pphLibNfc_Message_t pphOsalNfc_Message_t; - -/*! - * \ingroup grp_osal_nfc - * - * Enum definition contains supported exception types - */ -typedef enum -{ - phOsalNfc_e_NoMemory, /** -#ifdef PH_NFC_CUSTOMINTEGRATION -#include -#else -#ifdef NXP_MESSAGING -#include -#endif - -#ifdef NXP_MESSAGING -/** - * \ingroup grp_osal_nfc - *\brief Deferred message specific info declaration. - * This type information packed as WPARAM when \ref PH_OSALNFC_MESSAGE_BASE type windows message - * is posted to message handler thread. - */ -//typedef struct phOsalNfc_DeferedCalldInfo -//{ -// nfc_osal_def_call_t pDeferedCall;/**< pointer to Deferred callback */ -// void *pParam;/**< contains timer message specific details*/ -//}phOsalNfc_DeferedCalldInfo_t; -typedef phLibNfc_DeferredCall_t phOsalNfc_DeferedCalldInfo_t; -#endif - -/* ---------------- Macros ----------------------------------------------*/ -/** -*\ingroup grp_osal_nfc -* OSAL timer message .This message type will be posted to calling application thread. -*/ -//#define PH_OSALNFC_TIMER_MSG (0x315) -#define PH_OSALNFC_TIMER_MSG PH_LIBNFC_DEFERREDCALL_MSG - -/** - * \ingroup grp_osal_nfc - * Invalid timer ID type.This ID used indicate timer creation is failed. - */ -#define PH_OSALNFC_INVALID_TIMER_ID (0xFFFF) - -/*! - * \ingroup grp_osal_nfc - * \brief Timer callback interface which will be called once registered timer - * timeout expires. - * \param[in] TimerId Timer Id for which callback is called. - * \retval None - */ -typedef void (*ppCallBck_t)(uint32_t TimerId, void *pContext); - -/* -----------------Structures and Enumerations -------------------------*/ -/** - * \ingroup grp_osal_nfc - **\brief Timer message structure definition. - * Timer Message Structure contains timer specific informations like timer identifier - * and timer callback. - * - */ -typedef struct phOsalNfc_TimerMsg -{ - uint32_t TimerId;/**< Timer ID*/ - ppCallBck_t pCallBck;/**< pointer to Timer Callback*/ - void* pContext; /**< Timer Callback context*/ -}phOsalNfc_Timer_Msg_t,*pphOsalNfc_TimerMsg_t; - -/* -----------------Exported Functions----------------------------------*/ -/** - * \ingroup grp_osal_nfc - * \brief Allows to create new timer. - * - * This API creates a cyclic timer. In case a valid timer is created returned - * timer ID will be other than \ref PH_OSALNFC_INVALID_TIMER_ID. In case returned - * timer id is \ref PH_OSALNFC_INVALID_TIMER_ID, this indicates timer creation - * has failed. - * - * When a timer is created, it is not started by default. The application has to - * explicitly start it using \ref phOsalNfc_Timer_Start(). - * - * \param[in] void - * \retval Created timer ID. - * \note If timer ID value is PH_OSALNFC_INVALID_TIMER_ID, it indicates - * an error occured during timer creation. - * - * \msc - * Application,phOsalNfc; - * Application=>phOsalNfc [label="phOsalNfc_Timer_Create()",URL="\ref phOsalNfc_Timer_Create"]; - * Application<phOsalNfc [label="phOsalNfc_Timer_Create()", URL="\ref phOsalNfc_Timer_Create"]; - * Application<phOsalNfc [label="phOsalNfc_Timer_Start(TIMERID, TIMEOUT, CB)", URL="\ref phOsalNfc_Timer_Start"]; - * --- [label=" : On timer time out expired "]; - * phOsalNfc=>phOsalNfc [label="CB()"]; - * Application<-phOsalNfc[label="PH_OSALNFC_TIMER_MSG"]; - * \endmsc - */ -void phOsalNfc_Timer_Start(uint32_t TimerId, - uint32_t RegTimeCnt, - ppCallBck_t Application_callback, - void *pContext); - -/** - * \ingroup grp_osal_nfc - * \brief Stop an already started timer. - * - * This API allows to stop running timers. In case the timer is stopped, its callback will not be - * notified any more. - * - * \param[in] TimerId valid timer ID obtained suring timer creation. - * \param[in] Application_callback Application Callback interface to be called when timer expires. - * - * \msc - * Application,phOsalNfc; - * Application=>phOsalNfc [label="phOsalNfc_Timer_Create()",URL="\ref phOsalNfc_Timer_Create"]; - * Application<phOsalNfc [label="phOsalNfc_Timer_Start(TIMERID, TIMEOUT, CB)",URL="\ref phOsalNfc_Timer_Start"]; - * --- [label=" : On timer time out expired "]; - * phOsalNfc=>phOsalNfc [label="CB()"]; - * Application=>phOsalNfc [label="phOsalNfc_Timer_Stop(TIMERID)",URL="\ref phOsalNfc_Timer_Stop"]; - \endmsc - */ -void phOsalNfc_Timer_Stop(uint32_t TimerId); - -/** - * \ingroup grp_osal_nfc - * \brief Allows to delete the timer which is already created. - * - * This API allows to delete a timer. Incase timer is running - * it is stopped first and then deleted. if the given timer ID is invalid, this - * function doesn't return any error. Application has to explicitly ensure - * timer ID sent is valid. - * - * \param[in] TimerId timer identieir to delete the timer. - */ -void phOsalNfc_Timer_Delete(uint32_t TimerId); - -#endif -#endif /* PHOSALNFC_TIMER_H */ diff --git a/linux/android_alarm.h b/linux/android_alarm.h deleted file mode 100644 index 9f2de28..0000000 --- a/linux/android_alarm.h +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** - **************************************************************************** - *** - *** This header was automatically generated from a Linux kernel header - *** of the same name, to make information necessary for userspace to - *** call into the kernel available to libc. It contains only constants, - *** structures, and macros generated from the original header, and thus, - *** contains no copyrightable information. - *** - *** To edit the content of this header, modify the corresponding - *** source file (e.g. under external/kernel-headers/original/) then - *** run bionic/libc/kernel/tools/update_all.py - *** - *** Any manual change here will be lost the next time this script will - *** be run. You've been warned! - *** - **************************************************************************** - ****************************************************************************/ -#ifndef _UAPI_LINUX_ANDROID_ALARM_H -#define _UAPI_LINUX_ANDROID_ALARM_H -#include -#include -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ -enum android_alarm_type { - ANDROID_ALARM_RTC_WAKEUP, - ANDROID_ALARM_RTC, - ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP, -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ - ANDROID_ALARM_ELAPSED_REALTIME, - ANDROID_ALARM_SYSTEMTIME, - ANDROID_ALARM_RTC_POWEROFF_WAKEUP, - ANDROID_ALARM_TYPE_COUNT, -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ -}; -enum android_alarm_return_flags { - ANDROID_ALARM_RTC_WAKEUP_MASK = 1U << ANDROID_ALARM_RTC_WAKEUP, - ANDROID_ALARM_RTC_MASK = 1U << ANDROID_ALARM_RTC, -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ - ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP_MASK = 1U << ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP, - ANDROID_ALARM_ELAPSED_REALTIME_MASK = 1U << ANDROID_ALARM_ELAPSED_REALTIME, - ANDROID_ALARM_SYSTEMTIME_MASK = 1U << ANDROID_ALARM_SYSTEMTIME, - ANDROID_ALARM_RTC_POWEROFF_WAKEUP_MASK = 1U << ANDROID_ALARM_RTC_POWEROFF_WAKEUP, -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ - ANDROID_ALARM_TIME_CHANGE_MASK = 1U << 16 -}; -#define ANDROID_ALARM_CLEAR(type) _IO('a', 0 | ((type) << 4)) -#define ANDROID_ALARM_WAIT _IO('a', 1) -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ -#define ALARM_IOW(c,type,size) _IOW('a', (c) | ((type) << 4), size) -#define ANDROID_ALARM_SET(type) ALARM_IOW(2, type, struct timespec) -#define ANDROID_ALARM_SET_AND_WAIT(type) ALARM_IOW(3, type, struct timespec) -#define ANDROID_ALARM_GET_TIME(type) ALARM_IOW(4, type, struct timespec) -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ -#define ANDROID_ALARM_SET_RTC _IOW('a', 5, struct timespec) -#define ANDROID_ALARM_BASE_CMD(cmd) (cmd & ~(_IOC(0, 0, 0xf0, 0))) -#define ANDROID_ALARM_IOCTL_TO_TYPE(cmd) (_IOC_NR(cmd) >> 4) -#endif -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ diff --git a/linux/binder.h b/linux/binder.h deleted file mode 100644 index af3cea9..0000000 --- a/linux/binder.h +++ /dev/null @@ -1,190 +0,0 @@ -/**************************************************************************** - **************************************************************************** - *** - *** This header was automatically generated from a Linux kernel header - *** of the same name, to make information necessary for userspace to - *** call into the kernel available to libc. It contains only constants, - *** structures, and macros generated from the original header, and thus, - *** contains no copyrightable information. - *** - *** To edit the content of this header, modify the corresponding - *** source file (e.g. under external/kernel-headers/original/) then - *** run bionic/libc/kernel/tools/update_all.py - *** - *** Any manual change here will be lost the next time this script will - *** be run. You've been warned! - *** - **************************************************************************** - ****************************************************************************/ -#ifndef _UAPI_LINUX_BINDER_H -#define _UAPI_LINUX_BINDER_H -#include -#define B_PACK_CHARS(c1,c2,c3,c4) ((((c1) << 24)) | (((c2) << 16)) | (((c3) << 8)) | (c4)) -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ -#define B_TYPE_LARGE 0x85 -enum { - BINDER_TYPE_BINDER = B_PACK_CHARS('s', 'b', '*', B_TYPE_LARGE), - BINDER_TYPE_WEAK_BINDER = B_PACK_CHARS('w', 'b', '*', B_TYPE_LARGE), -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ - BINDER_TYPE_HANDLE = B_PACK_CHARS('s', 'h', '*', B_TYPE_LARGE), - BINDER_TYPE_WEAK_HANDLE = B_PACK_CHARS('w', 'h', '*', B_TYPE_LARGE), - BINDER_TYPE_FD = B_PACK_CHARS('f', 'd', '*', B_TYPE_LARGE), -}; -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ -enum { - FLAT_BINDER_FLAG_PRIORITY_MASK = 0xff, - FLAT_BINDER_FLAG_ACCEPTS_FDS = 0x100, -}; -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ -#ifdef BINDER_IPC_32BIT -typedef __u32 binder_size_t; -typedef __u32 binder_uintptr_t; -#else -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ -typedef __u64 binder_size_t; -typedef __u64 binder_uintptr_t; -#endif -struct flat_binder_object { -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ - __u32 type; - __u32 flags; - union { - binder_uintptr_t binder; -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ - __u32 handle; - }; - binder_uintptr_t cookie; -}; -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ -struct binder_write_read { - binder_size_t write_size; - binder_size_t write_consumed; - binder_uintptr_t write_buffer; -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ - binder_size_t read_size; - binder_size_t read_consumed; - binder_uintptr_t read_buffer; -}; -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ -struct binder_version { - __s32 protocol_version; -}; -#ifdef BINDER_IPC_32BIT -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ -#define BINDER_CURRENT_PROTOCOL_VERSION 7 -#else -#define BINDER_CURRENT_PROTOCOL_VERSION 8 -#endif -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ -#define BINDER_WRITE_READ _IOWR('b', 1, struct binder_write_read) -#define BINDER_SET_IDLE_TIMEOUT _IOW('b', 3, __s64) -#define BINDER_SET_MAX_THREADS _IOW('b', 5, __u32) -#define BINDER_SET_IDLE_PRIORITY _IOW('b', 6, __s32) -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ -#define BINDER_SET_CONTEXT_MGR _IOW('b', 7, __s32) -#define BINDER_THREAD_EXIT _IOW('b', 8, __s32) -#define BINDER_VERSION _IOWR('b', 9, struct binder_version) -enum transaction_flags { -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ - TF_ONE_WAY = 0x01, - TF_ROOT_OBJECT = 0x04, - TF_STATUS_CODE = 0x08, - TF_ACCEPT_FDS = 0x10, -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ -}; -struct binder_transaction_data { - union { - __u32 handle; -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ - binder_uintptr_t ptr; - } target; - binder_uintptr_t cookie; - __u32 code; -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ - __u32 flags; - pid_t sender_pid; - uid_t sender_euid; - binder_size_t data_size; -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ - binder_size_t offsets_size; - union { - struct { - binder_uintptr_t buffer; -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ - binder_uintptr_t offsets; - } ptr; - __u8 buf[8]; - } data; -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ -}; -struct binder_ptr_cookie { - binder_uintptr_t ptr; - binder_uintptr_t cookie; -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ -}; -struct binder_handle_cookie { - __u32 handle; - binder_uintptr_t cookie; -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ -} __packed; -struct binder_pri_desc { - __s32 priority; - __u32 desc; -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ -}; -struct binder_pri_ptr_cookie { - __s32 priority; - binder_uintptr_t ptr; -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ - binder_uintptr_t cookie; -}; -enum binder_driver_return_protocol { - BR_ERROR = _IOR('r', 0, __s32), -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ - BR_OK = _IO('r', 1), - BR_TRANSACTION = _IOR('r', 2, struct binder_transaction_data), - BR_REPLY = _IOR('r', 3, struct binder_transaction_data), - BR_ACQUIRE_RESULT = _IOR('r', 4, __s32), -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ - BR_DEAD_REPLY = _IO('r', 5), - BR_TRANSACTION_COMPLETE = _IO('r', 6), - BR_INCREFS = _IOR('r', 7, struct binder_ptr_cookie), - BR_ACQUIRE = _IOR('r', 8, struct binder_ptr_cookie), -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ - BR_RELEASE = _IOR('r', 9, struct binder_ptr_cookie), - BR_DECREFS = _IOR('r', 10, struct binder_ptr_cookie), - BR_ATTEMPT_ACQUIRE = _IOR('r', 11, struct binder_pri_ptr_cookie), - BR_NOOP = _IO('r', 12), -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ - BR_SPAWN_LOOPER = _IO('r', 13), - BR_FINISHED = _IO('r', 14), - BR_DEAD_BINDER = _IOR('r', 15, binder_uintptr_t), - BR_CLEAR_DEATH_NOTIFICATION_DONE = _IOR('r', 16, binder_uintptr_t), -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ - BR_FAILED_REPLY = _IO('r', 17), -}; -enum binder_driver_command_protocol { - BC_TRANSACTION = _IOW('c', 0, struct binder_transaction_data), -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ - BC_REPLY = _IOW('c', 1, struct binder_transaction_data), - BC_ACQUIRE_RESULT = _IOW('c', 2, __s32), - BC_FREE_BUFFER = _IOW('c', 3, binder_uintptr_t), - BC_INCREFS = _IOW('c', 4, __u32), -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ - BC_ACQUIRE = _IOW('c', 5, __u32), - BC_RELEASE = _IOW('c', 6, __u32), - BC_DECREFS = _IOW('c', 7, __u32), - BC_INCREFS_DONE = _IOW('c', 8, struct binder_ptr_cookie), -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ - BC_ACQUIRE_DONE = _IOW('c', 9, struct binder_ptr_cookie), - BC_ATTEMPT_ACQUIRE = _IOW('c', 10, struct binder_pri_desc), - BC_REGISTER_LOOPER = _IO('c', 11), - BC_ENTER_LOOPER = _IO('c', 12), -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ - BC_EXIT_LOOPER = _IO('c', 13), - BC_REQUEST_DEATH_NOTIFICATION = _IOW('c', 14, struct binder_handle_cookie), - BC_CLEAR_DEATH_NOTIFICATION = _IOW('c', 15, struct binder_handle_cookie), - BC_DEAD_BINDER_DONE = _IOW('c', 16, binder_uintptr_t), -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ -}; -#endif diff --git a/linux/sync.h b/linux/sync.h deleted file mode 100644 index bbf6641..0000000 --- a/linux/sync.h +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** - **************************************************************************** - *** - *** This header was automatically generated from a Linux kernel header - *** of the same name, to make information necessary for userspace to - *** call into the kernel available to libc. It contains only constants, - *** structures, and macros generated from the original header, and thus, - *** contains no copyrightable information. - *** - *** To edit the content of this header, modify the corresponding - *** source file (e.g. under external/kernel-headers/original/) then - *** run bionic/libc/kernel/tools/update_all.py - *** - *** Any manual change here will be lost the next time this script will - *** be run. You've been warned! - *** - **************************************************************************** - ****************************************************************************/ -#ifndef _UAPI_LINUX_SYNC_H -#define _UAPI_LINUX_SYNC_H -#include -#include -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ -struct sync_merge_data { - __s32 fd2; - char name[32]; - __s32 fence; -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ -}; -struct sync_pt_info { - __u32 len; - char obj_name[32]; -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ - char driver_name[32]; - __s32 status; - __u64 timestamp_ns; - __u8 driver_data[0]; -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ -}; -struct sync_fence_info_data { - __u32 len; - char name[32]; -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ - __s32 status; - __u8 pt_info[0]; -}; -#define SYNC_IOC_MAGIC '>' -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ -#define SYNC_IOC_WAIT _IOW(SYNC_IOC_MAGIC, 0, __s32) -#define SYNC_IOC_MERGE _IOWR(SYNC_IOC_MAGIC, 1, struct sync_merge_data) -#define SYNC_IOC_FENCE_INFO _IOWR(SYNC_IOC_MAGIC, 2, struct sync_fence_info_data) -#endif -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ diff --git a/linux/sw_sync.h b/linux/sync_file.h similarity index 64% rename from linux/sw_sync.h rename to linux/sync_file.h index ac50000..497300e 100644 --- a/linux/sw_sync.h +++ b/linux/sync_file.h @@ -16,18 +16,33 @@ *** **************************************************************************** ****************************************************************************/ -#ifndef _UAPI_LINUX_SW_SYNC_H -#define _UAPI_LINUX_SW_SYNC_H +#ifndef _UAPI_LINUX_SYNC_H +#define _UAPI_LINUX_SYNC_H +#include #include -struct sw_sync_create_fence_data { -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ - __u32 value; +struct sync_merge_data { char name[32]; + __s32 fd2; __s32 fence; + __u32 flags; + __u32 pad; }; -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ -#define SW_SYNC_IOC_MAGIC 'W' -#define SW_SYNC_IOC_CREATE_FENCE _IOWR(SW_SYNC_IOC_MAGIC, 0, struct sw_sync_create_fence_data) -#define SW_SYNC_IOC_INC _IOW(SW_SYNC_IOC_MAGIC, 1, __u32) +struct sync_fence_info { + char obj_name[32]; + char driver_name[32]; + __s32 status; + __u32 flags; + __u64 timestamp_ns; +}; +struct sync_file_info { + char name[32]; + __s32 status; + __u32 flags; + __u32 num_fences; + __u32 pad; + __u64 sync_fence_info; +}; +#define SYNC_IOC_MAGIC '>' +#define SYNC_IOC_MERGE _IOWR(SYNC_IOC_MAGIC, 3, struct sync_merge_data) +#define SYNC_IOC_FILE_INFO _IOWR(SYNC_IOC_MAGIC, 4, struct sync_file_info) #endif -/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ diff --git a/log/event_tag_map.h b/log/event_tag_map.h index 1653c61..8dd9157 100644 --- a/log/event_tag_map.h +++ b/log/event_tag_map.h @@ -21,7 +21,7 @@ extern "C" { #endif -#define EVENT_TAG_MAP_FILE "/system/etc/event-log-tags" +#define EVENT_TAG_MAP_FILE "/system/etc/event-log-tags" struct EventTagMap; typedef struct EventTagMap EventTagMap; @@ -41,7 +41,30 @@ void android_closeEventTagMap(EventTagMap* map); /* * Look up a tag by index. Returns the tag string, or NULL if not found. */ -const char* android_lookupEventTag(const EventTagMap* map, int tag); +const char* android_lookupEventTag(const EventTagMap* map, unsigned int tag) + __attribute__(( + deprecated("use android_lookupEventTag_len() instead to minimize " + "MAP_PRIVATE copy-on-write memory impact"))); + +/* + * Look up a tag by index. Returns the tag string & string length, or NULL if + * not found. Returned string is not guaranteed to be nul terminated. + */ +const char* android_lookupEventTag_len(const EventTagMap* map, size_t* len, + unsigned int tag); + +/* + * Look up a format by index. Returns the format string & string length, + * or NULL if not found. Returned string is not guaranteed to be nul terminated. + */ +const char* android_lookupEventFormat_len(const EventTagMap* map, size_t* len, + unsigned int tag); + +/* + * Look up tagname, generate one if necessary, and return a tag + */ +int android_lookupEventTagNum(EventTagMap* map, const char* tagname, + const char* format, int prio); #ifdef __cplusplus } diff --git a/log/log.h b/log/log.h index e606a84..3813e6e 100644 --- a/log/log.h +++ b/log/log.h @@ -14,683 +14,232 @@ * limitations under the License. */ -// -// C/C++ logging functions. See the logging documentation for API details. -// -// We'd like these to be available from C code (in case we import some from -// somewhere), so this has a C interface. -// -// The output will be correct when the log file is shared between multiple -// threads and/or multiple processes so long as the operating system -// supports O_APPEND. These calls have mutex-protected data structures -// and so are NOT reentrant. Do not use LOG in a signal handler. -// #ifndef _LIBS_LOG_LOG_H #define _LIBS_LOG_LOG_H -#include +/* Too many in the ecosystem assume these are included */ +#if !defined(_WIN32) +#include +#endif +#include /* uint16_t, int32_t */ #include #include #include #include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* helper to define iovec for portability */ #ifdef __cplusplus extern "C" { #endif -// --------------------------------------------------------------------- - -/* - * Normally we strip ALOGV (VERBOSE messages) from release builds. - * You can modify this (for example with "#define LOG_NDEBUG 0" - * at the top of your source file) to change that behavior. - */ -#ifndef LOG_NDEBUG -#ifdef NDEBUG -#define LOG_NDEBUG 1 -#else -#define LOG_NDEBUG 0 -#endif -#endif - /* - * This is the local tag used for the following simplified + * LOG_TAG is the local tag used for the following simplified * logging macros. You can change this preprocessor definition * before using the other macros to change the tag. */ + #ifndef LOG_TAG #define LOG_TAG NULL #endif -// --------------------------------------------------------------------- - -#ifndef __predict_false -#define __predict_false(exp) __builtin_expect((exp) != 0, 0) -#endif - /* - * -DLINT_RLOG in sources that you want to enforce that all logging - * goes to the radio log buffer. If any logging goes to any of the other - * log buffers, there will be a compile or link error to highlight the - * problem. This is not a replacement for a full audit of the code since - * this only catches compiled code, not ifdef'd debug code. Options to - * defining this, either temporarily to do a spot check, or permanently - * to enforce, in all the communications trees; We have hopes to ensure - * that by supplying just the radio log buffer that the communications - * teams will have their one-stop shop for triaging issues. + * Normally we strip the effects of ALOGV (VERBOSE messages), + * LOG_FATAL and LOG_FATAL_IF (FATAL assert messages) from the + * release builds be defining NDEBUG. You can modify this (for + * example with "#define LOG_NDEBUG 0" at the top of your source + * file) to change that behavior. */ -#ifndef LINT_RLOG -/* - * Simplified macro to send a verbose log message using the current LOG_TAG. - */ -#ifndef ALOGV -#define __ALOGV(...) ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) -#if LOG_NDEBUG -#define ALOGV(...) do { if (0) { __ALOGV(__VA_ARGS__); } } while (0) +#ifndef LOG_NDEBUG +#ifdef NDEBUG +#define LOG_NDEBUG 1 #else -#define ALOGV(...) __ALOGV(__VA_ARGS__) +#define LOG_NDEBUG 0 #endif #endif -#ifndef ALOGV_IF -#if LOG_NDEBUG -#define ALOGV_IF(cond, ...) ((void)0) -#else -#define ALOGV_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif -#endif +/* --------------------------------------------------------------------- */ /* - * Simplified macro to send a debug log message using the current LOG_TAG. + * This file uses ", ## __VA_ARGS__" zero-argument token pasting to + * work around issues with debug-only syntax errors in assertions + * that are missing format strings. See commit + * 19299904343daf191267564fe32e6cd5c165cd42 */ -#ifndef ALOGD -#define ALOGD(...) ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)) +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments" #endif -#ifndef ALOGD_IF -#define ALOGD_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif +/* --------------------------------------------------------------------- */ /* - * Simplified macro to send an info log message using the current LOG_TAG. + * Event logging. */ -#ifndef ALOGI -#define ALOGI(...) ((void)ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef ALOGI_IF -#define ALOGI_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif /* - * Simplified macro to send a warning log message using the current LOG_TAG. + * The following should not be used directly. */ -#ifndef ALOGW -#define ALOGW(...) ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__)) -#endif -#ifndef ALOGW_IF -#define ALOGW_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - -/* - * Simplified macro to send an error log message using the current LOG_TAG. - */ -#ifndef ALOGE -#define ALOGE(...) ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__)) -#endif +int __android_log_bwrite(int32_t tag, const void* payload, size_t len); +int __android_log_btwrite(int32_t tag, char type, const void* payload, + size_t len); +int __android_log_bswrite(int32_t tag, const char* payload); -#ifndef ALOGE_IF -#define ALOGE_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif +int __android_log_stats_bwrite(int32_t tag, const void* payload, size_t len); -// --------------------------------------------------------------------- +#define android_bWriteLog(tag, payload, len) \ + __android_log_bwrite(tag, payload, len) +#define android_btWriteLog(tag, type, payload, len) \ + __android_log_btwrite(tag, type, payload, len) /* - * Conditional based on whether the current LOG_TAG is enabled at - * verbose priority. + * Event log entry types. */ -#ifndef IF_ALOGV -#if LOG_NDEBUG -#define IF_ALOGV() if (false) -#else -#define IF_ALOGV() IF_ALOG(LOG_VERBOSE, LOG_TAG) -#endif +#ifndef __AndroidEventLogType_defined +#define __AndroidEventLogType_defined +typedef enum { + /* Special markers for android_log_list_element type */ + EVENT_TYPE_LIST_STOP = '\n', /* declare end of list */ + EVENT_TYPE_UNKNOWN = '?', /* protocol error */ + + /* must match with declaration in java/android/android/util/EventLog.java */ + EVENT_TYPE_INT = 0, /* int32_t */ + EVENT_TYPE_LONG = 1, /* int64_t */ + EVENT_TYPE_STRING = 2, + EVENT_TYPE_LIST = 3, + EVENT_TYPE_FLOAT = 4, +} AndroidEventLogType; #endif +#define sizeof_AndroidEventLogType sizeof(typeof_AndroidEventLogType) +#define typeof_AndroidEventLogType unsigned char -/* - * Conditional based on whether the current LOG_TAG is enabled at - * debug priority. - */ -#ifndef IF_ALOGD -#define IF_ALOGD() IF_ALOG(LOG_DEBUG, LOG_TAG) +#ifndef LOG_EVENT_INT +#define LOG_EVENT_INT(_tag, _value) \ + { \ + int intBuf = _value; \ + (void)android_btWriteLog(_tag, EVENT_TYPE_INT, &intBuf, sizeof(intBuf)); \ + } #endif - -/* - * Conditional based on whether the current LOG_TAG is enabled at - * info priority. - */ -#ifndef IF_ALOGI -#define IF_ALOGI() IF_ALOG(LOG_INFO, LOG_TAG) +#ifndef LOG_EVENT_LONG +#define LOG_EVENT_LONG(_tag, _value) \ + { \ + long long longBuf = _value; \ + (void)android_btWriteLog(_tag, EVENT_TYPE_LONG, &longBuf, sizeof(longBuf)); \ + } #endif - -/* - * Conditional based on whether the current LOG_TAG is enabled at - * warn priority. - */ -#ifndef IF_ALOGW -#define IF_ALOGW() IF_ALOG(LOG_WARN, LOG_TAG) +#ifndef LOG_EVENT_FLOAT +#define LOG_EVENT_FLOAT(_tag, _value) \ + { \ + float floatBuf = _value; \ + (void)android_btWriteLog(_tag, EVENT_TYPE_FLOAT, &floatBuf, \ + sizeof(floatBuf)); \ + } #endif - -/* - * Conditional based on whether the current LOG_TAG is enabled at - * error priority. - */ -#ifndef IF_ALOGE -#define IF_ALOGE() IF_ALOG(LOG_ERROR, LOG_TAG) +#ifndef LOG_EVENT_STRING +#define LOG_EVENT_STRING(_tag, _value) \ + (void)__android_log_bswrite(_tag, _value); #endif +#ifdef __linux__ -// --------------------------------------------------------------------- - -/* - * Simplified macro to send a verbose system log message using the current LOG_TAG. - */ -#ifndef SLOGV -#define __SLOGV(...) \ - ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) -#if LOG_NDEBUG -#define SLOGV(...) do { if (0) { __SLOGV(__VA_ARGS__); } } while (0) -#else -#define SLOGV(...) __SLOGV(__VA_ARGS__) -#endif -#endif - -#ifndef SLOGV_IF -#if LOG_NDEBUG -#define SLOGV_IF(cond, ...) ((void)0) +#ifndef __ANDROID_USE_LIBLOG_CLOCK_INTERFACE +#ifndef __ANDROID_API__ +#define __ANDROID_USE_LIBLOG_CLOCK_INTERFACE 1 +#elif __ANDROID_API__ > 22 /* > Lollipop */ +#define __ANDROID_USE_LIBLOG_CLOCK_INTERFACE 1 #else -#define SLOGV_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif -#endif - -/* - * Simplified macro to send a debug system log message using the current LOG_TAG. - */ -#ifndef SLOGD -#define SLOGD(...) \ - ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef SLOGD_IF -#define SLOGD_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - -/* - * Simplified macro to send an info system log message using the current LOG_TAG. - */ -#ifndef SLOGI -#define SLOGI(...) \ - ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef SLOGI_IF -#define SLOGI_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - -/* - * Simplified macro to send a warning system log message using the current LOG_TAG. - */ -#ifndef SLOGW -#define SLOGW(...) \ - ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) +#define __ANDROID_USE_LIBLOG_CLOCK_INTERFACE 0 #endif - -#ifndef SLOGW_IF -#define SLOGW_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) #endif -/* - * Simplified macro to send an error system log message using the current LOG_TAG. - */ -#ifndef SLOGE -#define SLOGE(...) \ - ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) +#if __ANDROID_USE_LIBLOG_CLOCK_INTERFACE +clockid_t android_log_clockid(void); #endif -#ifndef SLOGE_IF -#define SLOGE_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - -#endif /* !LINT_RLOG */ - -// --------------------------------------------------------------------- +#endif /* __linux__ */ -/* - * Simplified macro to send a verbose radio log message using the current LOG_TAG. - */ -#ifndef RLOGV -#define __RLOGV(...) \ - ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) -#if LOG_NDEBUG -#define RLOGV(...) do { if (0) { __RLOGV(__VA_ARGS__); } } while (0) -#else -#define RLOGV(...) __RLOGV(__VA_ARGS__) -#endif -#endif +/* --------------------------------------------------------------------- */ -#ifndef RLOGV_IF -#if LOG_NDEBUG -#define RLOGV_IF(cond, ...) ((void)0) +#ifndef __ANDROID_USE_LIBLOG_CLOSE_INTERFACE +#ifndef __ANDROID_API__ +#define __ANDROID_USE_LIBLOG_CLOSE_INTERFACE 1 +#elif __ANDROID_API__ > 18 /* > JellyBean */ +#define __ANDROID_USE_LIBLOG_CLOSE_INTERFACE 1 #else -#define RLOGV_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif -#endif - -/* - * Simplified macro to send a debug radio log message using the current LOG_TAG. - */ -#ifndef RLOGD -#define RLOGD(...) \ - ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef RLOGD_IF -#define RLOGD_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - -/* - * Simplified macro to send an info radio log message using the current LOG_TAG. - */ -#ifndef RLOGI -#define RLOGI(...) \ - ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef RLOGI_IF -#define RLOGI_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - -/* - * Simplified macro to send a warning radio log message using the current LOG_TAG. - */ -#ifndef RLOGW -#define RLOGW(...) \ - ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef RLOGW_IF -#define RLOGW_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - -/* - * Simplified macro to send an error radio log message using the current LOG_TAG. - */ -#ifndef RLOGE -#define RLOGE(...) \ - ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef RLOGE_IF -#define RLOGE_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - - -// --------------------------------------------------------------------- - -/* - * Log a fatal error. If the given condition fails, this stops program - * execution like a normal assertion, but also generating the given message. - * It is NOT stripped from release builds. Note that the condition test - * is -inverted- from the normal assert() semantics. - */ -#ifndef LOG_ALWAYS_FATAL_IF -#define LOG_ALWAYS_FATAL_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)android_printAssert(#cond, LOG_TAG, ## __VA_ARGS__)) \ - : (void)0 ) +#define __ANDROID_USE_LIBLOG_CLOSE_INTERFACE 0 #endif - -#ifndef LOG_ALWAYS_FATAL -#define LOG_ALWAYS_FATAL(...) \ - ( ((void)android_printAssert(NULL, LOG_TAG, ## __VA_ARGS__)) ) #endif +#if __ANDROID_USE_LIBLOG_CLOSE_INTERFACE /* - * Versions of LOG_ALWAYS_FATAL_IF and LOG_ALWAYS_FATAL that - * are stripped out of release builds. + * Release any logger resources (a new log write will immediately re-acquire) + * + * May be used to clean up File descriptors after a Fork, the resources are + * all O_CLOEXEC so wil self clean on exec(). */ -#if LOG_NDEBUG - -#ifndef LOG_FATAL_IF -#define LOG_FATAL_IF(cond, ...) ((void)0) -#endif -#ifndef LOG_FATAL -#define LOG_FATAL(...) ((void)0) +void __android_log_close(void); #endif +#ifndef __ANDROID_USE_LIBLOG_RATELIMIT_INTERFACE +#ifndef __ANDROID_API__ +#define __ANDROID_USE_LIBLOG_RATELIMIT_INTERFACE 1 +#elif __ANDROID_API__ > 25 /* > OC */ +#define __ANDROID_USE_LIBLOG_RATELIMIT_INTERFACE 1 #else - -#ifndef LOG_FATAL_IF -#define LOG_FATAL_IF(cond, ...) LOG_ALWAYS_FATAL_IF(cond, ## __VA_ARGS__) -#endif -#ifndef LOG_FATAL -#define LOG_FATAL(...) LOG_ALWAYS_FATAL(__VA_ARGS__) +#define __ANDROID_USE_LIBLOG_RATELIMIT_INTERFACE 0 #endif - #endif -/* - * Assertion that generates a log message when the assertion fails. - * Stripped out of release builds. Uses the current LOG_TAG. - */ -#ifndef ALOG_ASSERT -#define ALOG_ASSERT(cond, ...) LOG_FATAL_IF(!(cond), ## __VA_ARGS__) -//#define ALOG_ASSERT(cond) LOG_FATAL_IF(!(cond), "Assertion failed: " #cond) -#endif - -// --------------------------------------------------------------------- +#if __ANDROID_USE_LIBLOG_RATELIMIT_INTERFACE /* - * Basic log message macro. - * - * Example: - * ALOG(LOG_WARN, NULL, "Failed with error %d", errno); + * if last is NULL, caller _must_ provide a consistent value for seconds. * - * The second argument may be NULL or "" to indicate the "global" tag. - */ -#ifndef ALOG -#define ALOG(priority, tag, ...) \ - LOG_PRI(ANDROID_##priority, tag, __VA_ARGS__) -#endif - -/* - * Log macro that allows you to specify a number for the priority. - */ -#ifndef LOG_PRI -#define LOG_PRI(priority, tag, ...) \ - android_printLog(priority, tag, __VA_ARGS__) -#endif - -/* - * Log macro that allows you to pass in a varargs ("args" is a va_list). - */ -#ifndef LOG_PRI_VA -#define LOG_PRI_VA(priority, tag, fmt, args) \ - android_vprintLog(priority, NULL, tag, fmt, args) -#endif - -/* - * Conditional given a desired logging priority and tag. - */ -#ifndef IF_ALOG -#define IF_ALOG(priority, tag) \ - if (android_testLog(ANDROID_##priority, tag)) -#endif - -// --------------------------------------------------------------------- - -/* - * Event logging. - */ - -/* - * Event log entry types. - */ -typedef enum { - /* Special markers for android_log_list_element type */ - EVENT_TYPE_LIST_STOP = '\n', /* declare end of list */ - EVENT_TYPE_UNKNOWN = '?', /* protocol error */ - - /* must match with declaration in java/android/android/util/EventLog.java */ - EVENT_TYPE_INT = 0, /* uint32_t */ - EVENT_TYPE_LONG = 1, /* uint64_t */ - EVENT_TYPE_STRING = 2, - EVENT_TYPE_LIST = 3, - EVENT_TYPE_FLOAT = 4, -} AndroidEventLogType; -#define sizeof_AndroidEventLogType sizeof(typeof_AndroidEventLogType) -#define typeof_AndroidEventLogType unsigned char - -#ifndef LOG_EVENT_INT -#define LOG_EVENT_INT(_tag, _value) { \ - int intBuf = _value; \ - (void) android_btWriteLog(_tag, EVENT_TYPE_INT, &intBuf, \ - sizeof(intBuf)); \ - } -#endif -#ifndef LOG_EVENT_LONG -#define LOG_EVENT_LONG(_tag, _value) { \ - long long longBuf = _value; \ - (void) android_btWriteLog(_tag, EVENT_TYPE_LONG, &longBuf, \ - sizeof(longBuf)); \ - } -#endif -#ifndef LOG_EVENT_FLOAT -#define LOG_EVENT_FLOAT(_tag, _value) { \ - float floatBuf = _value; \ - (void) android_btWriteLog(_tag, EVENT_TYPE_FLOAT, &floatBuf, \ - sizeof(floatBuf)); \ - } -#endif -#ifndef LOG_EVENT_STRING -#define LOG_EVENT_STRING(_tag, _value) \ - (void) __android_log_bswrite(_tag, _value); -#endif - -typedef enum log_id { - LOG_ID_MIN = 0, - -#ifndef LINT_RLOG - LOG_ID_MAIN = 0, -#endif - LOG_ID_RADIO = 1, -#ifndef LINT_RLOG - LOG_ID_EVENTS = 2, - LOG_ID_SYSTEM = 3, - LOG_ID_CRASH = 4, - LOG_ID_SECURITY = 5, - LOG_ID_KERNEL = 6, /* place last, third-parties can not use it */ -#endif - - LOG_ID_MAX -} log_id_t; -#define sizeof_log_id_t sizeof(typeof_log_id_t) -#define typeof_log_id_t unsigned char - -/* For manipulating lists of events. */ - -#define ANDROID_MAX_LIST_NEST_DEPTH 8 - -/* - * The opaque context used to manipulate lists of events. - */ -typedef struct android_log_context_internal *android_log_context; - -/* - * Elements returned when reading a list of events. - */ -typedef struct { - AndroidEventLogType type; - uint16_t complete; - uint16_t len; - union { - int32_t int32; - int64_t int64; - char *string; - float float32; - } data; -} android_log_list_element; - -/* - * Creates a context associated with an event tag to write elements to - * the list of events. - */ -android_log_context create_android_logger(uint32_t tag); - -/* All lists must be braced by a begin and end call */ -/* - * NB: If the first level braces are missing when specifying multiple - * elements, we will manufacturer a list to embrace it for your API - * convenience. For a single element, it will remain solitary. - */ -int android_log_write_list_begin(android_log_context ctx); -int android_log_write_list_end(android_log_context ctx); - -int android_log_write_int32(android_log_context ctx, int32_t value); -int android_log_write_int64(android_log_context ctx, int64_t value); -int android_log_write_string8(android_log_context ctx, const char *value); -int android_log_write_string8_len(android_log_context ctx, - const char *value, size_t maxlen); -int android_log_write_float32(android_log_context ctx, float value); - -/* Submit the composed list context to the specified logger id */ -/* NB: LOG_ID_EVENTS and LOG_ID_SECURITY only valid binary buffers */ -int android_log_write_list(android_log_context ctx, log_id_t id); - -/* - * Creates a context from a raw buffer representing a list of events to be read. + * Return -1 if we can not acquire a lock, which below will permit the logging, + * error on allowing a log message through. */ -android_log_context create_android_log_parser(const char *msg, size_t len); - -android_log_list_element android_log_read_next(android_log_context ctx); -android_log_list_element android_log_peek_next(android_log_context ctx); - -/* Finished with reader or writer context */ -int android_log_destroy(android_log_context *ctx); +int __android_log_ratelimit(time_t seconds, time_t* last); /* - * =========================================================================== + * Usage: * - * The stuff in the rest of this file should not be used directly. - */ - -#define android_printLog(prio, tag, fmt...) \ - __android_log_print(prio, tag, fmt) - -#define android_vprintLog(prio, cond, tag, fmt...) \ - __android_log_vprint(prio, tag, fmt) - -/* XXX Macros to work around syntax errors in places where format string - * arg is not passed to ALOG_ASSERT, LOG_ALWAYS_FATAL or LOG_ALWAYS_FATAL_IF - * (happens only in debug builds). - */ - -/* Returns 2nd arg. Used to substitute default value if caller's vararg list - * is empty. - */ -#define __android_second(dummy, second, ...) second - -/* If passed multiple args, returns ',' followed by all but 1st arg, otherwise - * returns nothing. + * // Global default and state + * IF_ALOG_RATELIMIT() { + * ALOG*(...); + * } + * + * // local state, 10 seconds ratelimit + * static time_t local_state; + * IF_ALOG_RATELIMIT_LOCAL(10, &local_state) { + * ALOG*(...); + * } */ -#define __android_rest(first, ...) , ## __VA_ARGS__ - -#define android_printAssert(cond, tag, fmt...) \ - __android_log_assert(cond, tag, \ - __android_second(0, ## fmt, NULL) __android_rest(fmt)) -#define android_writeLog(prio, tag, text) \ - __android_log_write(prio, tag, text) +#define IF_ALOG_RATELIMIT() if (__android_log_ratelimit(0, NULL) > 0) +#define IF_ALOG_RATELIMIT_LOCAL(seconds, state) \ + if (__android_log_ratelimit(seconds, state) > 0) -#define android_bWriteLog(tag, payload, len) \ - __android_log_bwrite(tag, payload, len) -#define android_btWriteLog(tag, type, payload, len) \ - __android_log_btwrite(tag, type, payload, len) - -#define android_errorWriteLog(tag, subTag) \ - __android_log_error_write(tag, subTag, -1, NULL, 0) - -#define android_errorWriteWithInfoLog(tag, subTag, uid, data, dataLen) \ - __android_log_error_write(tag, subTag, uid, data, dataLen) - -/* - * IF_ALOG uses android_testLog, but IF_ALOG can be overridden. - * android_testLog will remain constant in its purpose as a wrapper - * for Android logging filter policy, and can be subject to - * change. It can be reused by the developers that override - * IF_ALOG as a convenient means to reimplement their policy - * over Android. - */ -#if LOG_NDEBUG /* Production */ -#define android_testLog(prio, tag) \ - (__android_log_is_loggable(prio, tag, ANDROID_LOG_DEBUG) != 0) #else -#define android_testLog(prio, tag) \ - (__android_log_is_loggable(prio, tag, ANDROID_LOG_VERBOSE) != 0) -#endif - -/* - * Use the per-tag properties "log.tag." to generate a runtime - * result of non-zero to expose a log. prio is ANDROID_LOG_VERBOSE to - * ANDROID_LOG_FATAL. default_prio if no property. Undefined behavior if - * any other value. - */ -int __android_log_is_loggable(int prio, const char *tag, int default_prio); -int __android_log_security(); /* Device Owner is present */ +/* No ratelimiting as API unsupported */ +#define IF_ALOG_RATELIMIT() if (1) +#define IF_ALOG_RATELIMIT_LOCAL(...) if (1) -int __android_log_error_write(int tag, const char *subTag, int32_t uid, const char *data, - uint32_t dataLen); +#endif -/* - * Send a simple string to the log. - */ -int __android_log_buf_write(int bufID, int prio, const char *tag, const char *text); -int __android_log_buf_print(int bufID, int prio, const char *tag, const char *fmt, ...) -#if defined(__GNUC__) - __attribute__((__format__(printf, 4, 5))) +#if defined(__clang__) +#pragma clang diagnostic pop #endif - ; #ifdef __cplusplus } diff --git a/log/log_event_list.h b/log/log_event_list.h new file mode 100644 index 0000000..bb1ce34 --- /dev/null +++ b/log/log_event_list.h @@ -0,0 +1,316 @@ +/* + * Copyright (C) 2005-2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _LIBS_LOG_EVENT_LIST_H +#define _LIBS_LOG_EVENT_LIST_H + +#include +#include + +#if (defined(__cplusplus) && defined(_USING_LIBCXX)) +extern "C++" { +#include +} +#endif + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __ANDROID_USE_LIBLOG_EVENT_INTERFACE +#ifndef __ANDROID_API__ +#define __ANDROID_USE_LIBLOG_EVENT_INTERFACE 1 +#elif __ANDROID_API__ > 23 /* > Marshmallow */ +#define __ANDROID_USE_LIBLOG_EVENT_INTERFACE 1 +#else +#define __ANDROID_USE_LIBLOG_EVENT_INTERFACE 0 +#endif +#endif + +#if __ANDROID_USE_LIBLOG_EVENT_INTERFACE + +/* For manipulating lists of events. */ + +#define ANDROID_MAX_LIST_NEST_DEPTH 8 + +/* + * The opaque context used to manipulate lists of events. + */ +#ifndef __android_log_context_defined +#define __android_log_context_defined +typedef struct android_log_context_internal* android_log_context; +#endif + +/* + * Elements returned when reading a list of events. + */ +#ifndef __android_log_list_element_defined +#define __android_log_list_element_defined +typedef struct { + AndroidEventLogType type; + uint16_t complete; + uint16_t len; + union { + int32_t int32; + int64_t int64; + char* string; + float float32; + } data; +} android_log_list_element; +#endif + +/* + * Creates a context associated with an event tag to write elements to + * the list of events. + */ +android_log_context create_android_logger(uint32_t tag); + +/* All lists must be braced by a begin and end call */ +/* + * NB: If the first level braces are missing when specifying multiple + * elements, we will manufacturer a list to embrace it for your API + * convenience. For a single element, it will remain solitary. + */ +int android_log_write_list_begin(android_log_context ctx); +int android_log_write_list_end(android_log_context ctx); + +int android_log_write_int32(android_log_context ctx, int32_t value); +int android_log_write_int64(android_log_context ctx, int64_t value); +int android_log_write_string8(android_log_context ctx, const char* value); +int android_log_write_string8_len(android_log_context ctx, const char* value, + size_t maxlen); +int android_log_write_float32(android_log_context ctx, float value); + +/* Submit the composed list context to the specified logger id */ +/* NB: LOG_ID_EVENTS and LOG_ID_SECURITY only valid binary buffers */ +int android_log_write_list(android_log_context ctx, log_id_t id); + +/* + * Creates a context from a raw buffer representing a list of events to be read. + */ +android_log_context create_android_log_parser(const char* msg, size_t len); + +android_log_list_element android_log_read_next(android_log_context ctx); +android_log_list_element android_log_peek_next(android_log_context ctx); + +/* Finished with reader or writer context */ +int android_log_destroy(android_log_context* ctx); + +#ifdef __cplusplus +#ifndef __class_android_log_event_list_defined +#define __class_android_log_event_list_defined +/* android_log_list C++ helpers */ +extern "C++" { +class android_log_event_list { + friend class __android_log_event_list; + + private: + android_log_context ctx; + int ret; + + android_log_event_list(const android_log_event_list&) = delete; + void operator=(const android_log_event_list&) = delete; + + public: + explicit android_log_event_list(int tag) : ret(0) { + ctx = create_android_logger(static_cast(tag)); + } + explicit android_log_event_list(log_msg& log_msg) : ret(0) { + ctx = create_android_log_parser(log_msg.msg() + sizeof(uint32_t), + log_msg.entry.len - sizeof(uint32_t)); + } + ~android_log_event_list() { + android_log_destroy(&ctx); + } + + int close() { + int retval = android_log_destroy(&ctx); + if (retval < 0) ret = retval; + return retval; + } + + /* To allow above C calls to use this class as parameter */ + operator android_log_context() const { + return ctx; + } + + /* return errors or transmit status */ + int status() const { + return ret; + } + + int begin() { + int retval = android_log_write_list_begin(ctx); + if (retval < 0) ret = retval; + return ret; + } + int end() { + int retval = android_log_write_list_end(ctx); + if (retval < 0) ret = retval; + return ret; + } + + android_log_event_list& operator<<(int32_t value) { + int retval = android_log_write_int32(ctx, value); + if (retval < 0) ret = retval; + return *this; + } + + android_log_event_list& operator<<(uint32_t value) { + int retval = android_log_write_int32(ctx, static_cast(value)); + if (retval < 0) ret = retval; + return *this; + } + + android_log_event_list& operator<<(bool value) { + int retval = android_log_write_int32(ctx, value ? 1 : 0); + if (retval < 0) ret = retval; + return *this; + } + + android_log_event_list& operator<<(int64_t value) { + int retval = android_log_write_int64(ctx, value); + if (retval < 0) ret = retval; + return *this; + } + + android_log_event_list& operator<<(uint64_t value) { + int retval = android_log_write_int64(ctx, static_cast(value)); + if (retval < 0) ret = retval; + return *this; + } + + android_log_event_list& operator<<(const char* value) { + int retval = android_log_write_string8(ctx, value); + if (retval < 0) ret = retval; + return *this; + } + +#if defined(_USING_LIBCXX) + android_log_event_list& operator<<(const std::string& value) { + int retval = + android_log_write_string8_len(ctx, value.data(), value.length()); + if (retval < 0) ret = retval; + return *this; + } +#endif + + android_log_event_list& operator<<(float value) { + int retval = android_log_write_float32(ctx, value); + if (retval < 0) ret = retval; + return *this; + } + + int write(log_id_t id = LOG_ID_EVENTS) { + /* facilitate -EBUSY retry */ + if ((ret == -EBUSY) || (ret > 0)) ret = 0; + int retval = android_log_write_list(ctx, id); + /* existing errors trump transmission errors */ + if (!ret) ret = retval; + return ret; + } + + int operator<<(log_id_t id) { + write(id); + android_log_destroy(&ctx); + return ret; + } + + /* + * Append methods removes any integer promotion + * confusion, and adds access to string with length. + * Append methods are also added for all types for + * convenience. + */ + + bool AppendInt(int32_t value) { + int retval = android_log_write_int32(ctx, value); + if (retval < 0) ret = retval; + return ret >= 0; + } + + bool AppendLong(int64_t value) { + int retval = android_log_write_int64(ctx, value); + if (retval < 0) ret = retval; + return ret >= 0; + } + + bool AppendString(const char* value) { + int retval = android_log_write_string8(ctx, value); + if (retval < 0) ret = retval; + return ret >= 0; + } + + bool AppendString(const char* value, size_t len) { + int retval = android_log_write_string8_len(ctx, value, len); + if (retval < 0) ret = retval; + return ret >= 0; + } + +#if defined(_USING_LIBCXX) + bool AppendString(const std::string& value) { + int retval = + android_log_write_string8_len(ctx, value.data(), value.length()); + if (retval < 0) ret = retval; + return ret; + } + + bool Append(const std::string& value) { + int retval = + android_log_write_string8_len(ctx, value.data(), value.length()); + if (retval < 0) ret = retval; + return ret; + } +#endif + + bool AppendFloat(float value) { + int retval = android_log_write_float32(ctx, value); + if (retval < 0) ret = retval; + return ret >= 0; + } + + template + bool Append(Tvalue value) { + *this << value; + return ret >= 0; + } + + bool Append(const char* value, size_t len) { + int retval = android_log_write_string8_len(ctx, value, len); + if (retval < 0) ret = retval; + return ret >= 0; + } + + android_log_list_element read() { + return android_log_read_next(ctx); + } + android_log_list_element peek() { + return android_log_peek_next(ctx); + } +}; +} +#endif +#endif + +#endif /* __ANDROID_USE_LIBLOG_EVENT_INTERFACE */ + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBS_LOG_EVENT_LIST_H */ diff --git a/log/log_id.h b/log/log_id.h new file mode 100644 index 0000000..c44f5a2 --- /dev/null +++ b/log/log_id.h @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2005-2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _LIBS_LOG_LOG_ID_H +#define _LIBS_LOG_LOG_ID_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef log_id_t_defined +#define log_id_t_defined +typedef enum log_id { + LOG_ID_MIN = 0, + + LOG_ID_MAIN = 0, + LOG_ID_RADIO = 1, + LOG_ID_EVENTS = 2, + LOG_ID_SYSTEM = 3, + LOG_ID_CRASH = 4, + LOG_ID_STATS = 5, + LOG_ID_SECURITY = 6, + LOG_ID_KERNEL = 7, /* place last, third-parties can not use it */ + + LOG_ID_MAX +} log_id_t; +#endif +#define sizeof_log_id_t sizeof(typeof_log_id_t) +#define typeof_log_id_t unsigned char + +/* + * Send a simple string to the log. + */ +int __android_log_buf_write(int bufID, int prio, const char* tag, + const char* text); +int __android_log_buf_print(int bufID, int prio, const char* tag, + const char* fmt, ...) +#if defined(__GNUC__) + __attribute__((__format__(printf, 4, 5))) +#endif + ; + +/* + * log_id_t helpers + */ +log_id_t android_name_to_log_id(const char* logName); +const char* android_log_id_to_name(log_id_t log_id); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBS_LOG_LOG_ID_H */ diff --git a/log/log_main.h b/log/log_main.h new file mode 100644 index 0000000..21fc7cc --- /dev/null +++ b/log/log_main.h @@ -0,0 +1,391 @@ +/* + * Copyright (C) 2005-2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _LIBS_LOG_LOG_MAIN_H +#define _LIBS_LOG_LOG_MAIN_H + +#include + +#include +#include + +__BEGIN_DECLS + +/* + * Normally we strip the effects of ALOGV (VERBOSE messages), + * LOG_FATAL and LOG_FATAL_IF (FATAL assert messages) from the + * release builds be defining NDEBUG. You can modify this (for + * example with "#define LOG_NDEBUG 0" at the top of your source + * file) to change that behavior. + */ + +#ifndef LOG_NDEBUG +#ifdef NDEBUG +#define LOG_NDEBUG 1 +#else +#define LOG_NDEBUG 0 +#endif +#endif + +/* --------------------------------------------------------------------- */ + +/* + * This file uses ", ## __VA_ARGS__" zero-argument token pasting to + * work around issues with debug-only syntax errors in assertions + * that are missing format strings. See commit + * 19299904343daf191267564fe32e6cd5c165cd42 + */ +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments" +#endif + +#ifndef __predict_false +#define __predict_false(exp) __builtin_expect((exp) != 0, 0) +#endif + +#define android_writeLog(prio, tag, text) __android_log_write(prio, tag, text) + +#define android_printLog(prio, tag, ...) \ + __android_log_print(prio, tag, __VA_ARGS__) + +#define android_vprintLog(prio, cond, tag, ...) \ + __android_log_vprint(prio, tag, __VA_ARGS__) + +/* + * Log macro that allows you to specify a number for the priority. + */ +#ifndef LOG_PRI +#define LOG_PRI(priority, tag, ...) android_printLog(priority, tag, __VA_ARGS__) +#endif + +/* + * Log macro that allows you to pass in a varargs ("args" is a va_list). + */ +#ifndef LOG_PRI_VA +#define LOG_PRI_VA(priority, tag, fmt, args) \ + android_vprintLog(priority, NULL, tag, fmt, args) +#endif + +/* --------------------------------------------------------------------- */ + +/* XXX Macros to work around syntax errors in places where format string + * arg is not passed to ALOG_ASSERT, LOG_ALWAYS_FATAL or LOG_ALWAYS_FATAL_IF + * (happens only in debug builds). + */ + +/* Returns 2nd arg. Used to substitute default value if caller's vararg list + * is empty. + */ +#define __android_second(dummy, second, ...) second + +/* If passed multiple args, returns ',' followed by all but 1st arg, otherwise + * returns nothing. + */ +#define __android_rest(first, ...) , ##__VA_ARGS__ + +#define android_printAssert(cond, tag, ...) \ + __android_log_assert(cond, tag, \ + __android_second(0, ##__VA_ARGS__, NULL) \ + __android_rest(__VA_ARGS__)) + +/* + * Log a fatal error. If the given condition fails, this stops program + * execution like a normal assertion, but also generating the given message. + * It is NOT stripped from release builds. Note that the condition test + * is -inverted- from the normal assert() semantics. + */ +#ifndef LOG_ALWAYS_FATAL_IF +#define LOG_ALWAYS_FATAL_IF(cond, ...) \ + ((__predict_false(cond)) \ + ? ((void)android_printAssert(#cond, LOG_TAG, ##__VA_ARGS__)) \ + : (void)0) +#endif + +#ifndef LOG_ALWAYS_FATAL +#define LOG_ALWAYS_FATAL(...) \ + (((void)android_printAssert(NULL, LOG_TAG, ##__VA_ARGS__))) +#endif + +/* + * Versions of LOG_ALWAYS_FATAL_IF and LOG_ALWAYS_FATAL that + * are stripped out of release builds. + */ + +#if LOG_NDEBUG + +#ifndef LOG_FATAL_IF +#define LOG_FATAL_IF(cond, ...) ((void)0) +#endif +#ifndef LOG_FATAL +#define LOG_FATAL(...) ((void)0) +#endif + +#else + +#ifndef LOG_FATAL_IF +#define LOG_FATAL_IF(cond, ...) LOG_ALWAYS_FATAL_IF(cond, ##__VA_ARGS__) +#endif +#ifndef LOG_FATAL +#define LOG_FATAL(...) LOG_ALWAYS_FATAL(__VA_ARGS__) +#endif + +#endif + +/* + * Assertion that generates a log message when the assertion fails. + * Stripped out of release builds. Uses the current LOG_TAG. + */ +#ifndef ALOG_ASSERT +#define ALOG_ASSERT(cond, ...) LOG_FATAL_IF(!(cond), ##__VA_ARGS__) +#endif + +/* --------------------------------------------------------------------- */ + +/* + * C/C++ logging functions. See the logging documentation for API details. + * + * We'd like these to be available from C code (in case we import some from + * somewhere), so this has a C interface. + * + * The output will be correct when the log file is shared between multiple + * threads and/or multiple processes so long as the operating system + * supports O_APPEND. These calls have mutex-protected data structures + * and so are NOT reentrant. Do not use LOG in a signal handler. + */ + +/* --------------------------------------------------------------------- */ + +/* + * Simplified macro to send a verbose log message using the current LOG_TAG. + */ +#ifndef ALOGV +#define __ALOGV(...) ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) +#if LOG_NDEBUG +#define ALOGV(...) \ + do { \ + if (false) { \ + __ALOGV(__VA_ARGS__); \ + } \ + } while (false) +#else +#define ALOGV(...) __ALOGV(__VA_ARGS__) +#endif +#endif + +#ifndef ALOGV_IF +#if LOG_NDEBUG +#define ALOGV_IF(cond, ...) ((void)0) +#else +#define ALOGV_IF(cond, ...) \ + ((__predict_false(cond)) ? ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \ + : (void)0) +#endif +#endif + +/* + * Simplified macro to send a debug log message using the current LOG_TAG. + */ +#ifndef ALOGD +#define ALOGD(...) ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)) +#endif + +#ifndef ALOGD_IF +#define ALOGD_IF(cond, ...) \ + ((__predict_false(cond)) ? ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \ + : (void)0) +#endif + +/* + * Simplified macro to send an info log message using the current LOG_TAG. + */ +#ifndef ALOGI +#define ALOGI(...) ((void)ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__)) +#endif + +#ifndef ALOGI_IF +#define ALOGI_IF(cond, ...) \ + ((__predict_false(cond)) ? ((void)ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__)) \ + : (void)0) +#endif + +/* + * Simplified macro to send a warning log message using the current LOG_TAG. + */ +#ifndef ALOGW +#define ALOGW(...) ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__)) +#endif + +#ifndef ALOGW_IF +#define ALOGW_IF(cond, ...) \ + ((__predict_false(cond)) ? ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__)) \ + : (void)0) +#endif + +/* + * Simplified macro to send an error log message using the current LOG_TAG. + */ +#ifndef ALOGE +#define ALOGE(...) ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__)) +#endif + +#ifndef ALOGE_IF +#define ALOGE_IF(cond, ...) \ + ((__predict_false(cond)) ? ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__)) \ + : (void)0) +#endif + +/* --------------------------------------------------------------------- */ + +/* + * Conditional based on whether the current LOG_TAG is enabled at + * verbose priority. + */ +#ifndef IF_ALOGV +#if LOG_NDEBUG +#define IF_ALOGV() if (false) +#else +#define IF_ALOGV() IF_ALOG(LOG_VERBOSE, LOG_TAG) +#endif +#endif + +/* + * Conditional based on whether the current LOG_TAG is enabled at + * debug priority. + */ +#ifndef IF_ALOGD +#define IF_ALOGD() IF_ALOG(LOG_DEBUG, LOG_TAG) +#endif + +/* + * Conditional based on whether the current LOG_TAG is enabled at + * info priority. + */ +#ifndef IF_ALOGI +#define IF_ALOGI() IF_ALOG(LOG_INFO, LOG_TAG) +#endif + +/* + * Conditional based on whether the current LOG_TAG is enabled at + * warn priority. + */ +#ifndef IF_ALOGW +#define IF_ALOGW() IF_ALOG(LOG_WARN, LOG_TAG) +#endif + +/* + * Conditional based on whether the current LOG_TAG is enabled at + * error priority. + */ +#ifndef IF_ALOGE +#define IF_ALOGE() IF_ALOG(LOG_ERROR, LOG_TAG) +#endif + +/* --------------------------------------------------------------------- */ + +/* + * Basic log message macro. + * + * Example: + * ALOG(LOG_WARN, NULL, "Failed with error %d", errno); + * + * The second argument may be NULL or "" to indicate the "global" tag. + */ +#ifndef ALOG +#define ALOG(priority, tag, ...) LOG_PRI(ANDROID_##priority, tag, __VA_ARGS__) +#endif + +/* + * Conditional given a desired logging priority and tag. + */ +#ifndef IF_ALOG +#define IF_ALOG(priority, tag) if (android_testLog(ANDROID_##priority, tag)) +#endif + +/* --------------------------------------------------------------------- */ + +/* + * IF_ALOG uses android_testLog, but IF_ALOG can be overridden. + * android_testLog will remain constant in its purpose as a wrapper + * for Android logging filter policy, and can be subject to + * change. It can be reused by the developers that override + * IF_ALOG as a convenient means to reimplement their policy + * over Android. + */ + +#ifndef __ANDROID_USE_LIBLOG_LOGGABLE_INTERFACE +#ifndef __ANDROID_API__ +#define __ANDROID_USE_LIBLOG_LOGGABLE_INTERFACE 2 +#elif __ANDROID_API__ > 24 /* > Nougat */ +#define __ANDROID_USE_LIBLOG_LOGGABLE_INTERFACE 2 +#elif __ANDROID_API__ > 22 /* > Lollipop */ +#define __ANDROID_USE_LIBLOG_LOGGABLE_INTERFACE 1 +#else +#define __ANDROID_USE_LIBLOG_LOGGABLE_INTERFACE 0 +#endif +#endif + +#if __ANDROID_USE_LIBLOG_LOGGABLE_INTERFACE + +/* + * Use the per-tag properties "log.tag." to generate a runtime + * result of non-zero to expose a log. prio is ANDROID_LOG_VERBOSE to + * ANDROID_LOG_FATAL. default_prio if no property. Undefined behavior if + * any other value. + */ +int __android_log_is_loggable(int prio, const char* tag, int default_prio); + +#if __ANDROID_USE_LIBLOG_LOGGABLE_INTERFACE > 1 +#include + +int __android_log_is_loggable_len(int prio, const char* tag, size_t len, + int default_prio); + +#if LOG_NDEBUG /* Production */ +#define android_testLog(prio, tag) \ + (__android_log_is_loggable_len(prio, tag, ((tag) && *(tag)) ? strlen(tag) : 0, \ + ANDROID_LOG_DEBUG) != 0) +#else +#define android_testLog(prio, tag) \ + (__android_log_is_loggable_len(prio, tag, ((tag) && *(tag)) ? strlen(tag) : 0, \ + ANDROID_LOG_VERBOSE) != 0) +#endif + +#else + +#if LOG_NDEBUG /* Production */ +#define android_testLog(prio, tag) \ + (__android_log_is_loggable(prio, tag, ANDROID_LOG_DEBUG) != 0) +#else +#define android_testLog(prio, tag) \ + (__android_log_is_loggable(prio, tag, ANDROID_LOG_VERBOSE) != 0) +#endif + +#endif + +#else /* __ANDROID_USE_LIBLOG_LOGGABLE_INTERFACE */ + +#define android_testLog(prio, tag) (1) + +#endif /* !__ANDROID_USE_LIBLOG_LOGGABLE_INTERFACE */ + +#if defined(__clang__) +#pragma clang diagnostic pop +#endif + +__END_DECLS + +#endif /* _LIBS_LOG_LOG_MAIN_H */ diff --git a/log/log_properties.h b/log/log_properties.h new file mode 100644 index 0000000..7d398a6 --- /dev/null +++ b/log/log_properties.h @@ -0,0 +1,35 @@ +/* +** +** Copyright 2017, The Android Open Source Project +** +** This file is dual licensed. It may be redistributed and/or modified +** under the terms of the Apache 2.0 License OR version 2 of the GNU +** General Public License. +*/ + +#ifndef _LIBS_LOG_PROPERTIES_H +#define _LIBS_LOG_PROPERTIES_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __ANDROID_USE_LIBLOG_IS_DEBUGGABLE_INTERFACE +#ifndef __ANDROID_API__ +#define __ANDROID_USE_LIBLOG_IS_DEBUGGABLE_INTERFACE 1 +#elif __ANDROID_API__ > 24 /* > Nougat */ +#define __ANDROID_USE_LIBLOG_IS_DEBUGGABLE_INTERFACE 1 +#else +#define __ANDROID_USE_LIBLOG_IS_DEBUGGABLE_INTERFACE 0 +#endif +#endif + +#if __ANDROID_USE_LIBLOG_IS_DEBUGGABLE_INTERFACE +int __android_log_is_debuggable(); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBS_LOG_PROPERTIES_H */ diff --git a/log/log_radio.h b/log/log_radio.h new file mode 100644 index 0000000..bd629fe --- /dev/null +++ b/log/log_radio.h @@ -0,0 +1,144 @@ +/* + * Copyright (C) 2005-2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _LIBS_LOG_LOG_RADIO_H +#define _LIBS_LOG_LOG_RADIO_H + +#include +#include + +/* + * Normally we strip the effects of ALOGV (VERBOSE messages), + * LOG_FATAL and LOG_FATAL_IF (FATAL assert messages) from the + * release builds be defining NDEBUG. You can modify this (for + * example with "#define LOG_NDEBUG 0" at the top of your source + * file) to change that behavior. + */ + +#ifndef LOG_NDEBUG +#ifdef NDEBUG +#define LOG_NDEBUG 1 +#else +#define LOG_NDEBUG 0 +#endif +#endif + +/* --------------------------------------------------------------------- */ + +#ifndef __predict_false +#define __predict_false(exp) __builtin_expect((exp) != 0, 0) +#endif + +/* + * Simplified macro to send a verbose radio log message using current LOG_TAG. + */ +#ifndef RLOGV +#define __RLOGV(...) \ + ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, LOG_TAG, \ + __VA_ARGS__)) +#if LOG_NDEBUG +#define RLOGV(...) \ + do { \ + if (0) { \ + __RLOGV(__VA_ARGS__); \ + } \ + } while (0) +#else +#define RLOGV(...) __RLOGV(__VA_ARGS__) +#endif +#endif + +#ifndef RLOGV_IF +#if LOG_NDEBUG +#define RLOGV_IF(cond, ...) ((void)0) +#else +#define RLOGV_IF(cond, ...) \ + ((__predict_false(cond)) \ + ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, \ + LOG_TAG, __VA_ARGS__)) \ + : (void)0) +#endif +#endif + +/* + * Simplified macro to send a debug radio log message using current LOG_TAG. + */ +#ifndef RLOGD +#define RLOGD(...) \ + ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_DEBUG, LOG_TAG, \ + __VA_ARGS__)) +#endif + +#ifndef RLOGD_IF +#define RLOGD_IF(cond, ...) \ + ((__predict_false(cond)) \ + ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_DEBUG, \ + LOG_TAG, __VA_ARGS__)) \ + : (void)0) +#endif + +/* + * Simplified macro to send an info radio log message using current LOG_TAG. + */ +#ifndef RLOGI +#define RLOGI(...) \ + ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, LOG_TAG, \ + __VA_ARGS__)) +#endif + +#ifndef RLOGI_IF +#define RLOGI_IF(cond, ...) \ + ((__predict_false(cond)) \ + ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, \ + LOG_TAG, __VA_ARGS__)) \ + : (void)0) +#endif + +/* + * Simplified macro to send a warning radio log message using current LOG_TAG. + */ +#ifndef RLOGW +#define RLOGW(...) \ + ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_WARN, LOG_TAG, \ + __VA_ARGS__)) +#endif + +#ifndef RLOGW_IF +#define RLOGW_IF(cond, ...) \ + ((__predict_false(cond)) \ + ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_WARN, \ + LOG_TAG, __VA_ARGS__)) \ + : (void)0) +#endif + +/* + * Simplified macro to send an error radio log message using current LOG_TAG. + */ +#ifndef RLOGE +#define RLOGE(...) \ + ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, LOG_TAG, \ + __VA_ARGS__)) +#endif + +#ifndef RLOGE_IF +#define RLOGE_IF(cond, ...) \ + ((__predict_false(cond)) \ + ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, \ + LOG_TAG, __VA_ARGS__)) \ + : (void)0) +#endif + +#endif /* _LIBS_LOG_LOG_RADIO_H */ diff --git a/log/log_read.h b/log/log_read.h index 1b70aff..d118563 100644 --- a/log/log_read.h +++ b/log/log_read.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013-2014 The Android Open Source Project + * Copyright (C) 2005-2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,154 +17,261 @@ #ifndef _LIBS_LOG_LOG_READ_H #define _LIBS_LOG_LOG_READ_H +/* deal with possible sys/cdefs.h conflict with fcntl.h */ +#ifdef __unused +#define __unused_defined __unused +#undef __unused +#endif + +#include /* Pick up O_* macros */ + +/* restore definitions from above */ +#ifdef __unused_defined +#define __unused __attribute__((__unused__)) +#endif + #include -#include -/* struct log_time is a wire-format variant of struct timespec */ -#define NS_PER_SEC 1000000000ULL +#include +#include #ifdef __cplusplus +extern "C" { +#endif -// NB: do NOT define a copy constructor. This will result in structure -// no longer being compatible with pass-by-value which is desired -// efficient behavior. Also, pass-by-reference breaks C/C++ ABI. -struct log_time { -public: - uint32_t tv_sec; // good to Feb 5 2106 - uint32_t tv_nsec; - - static const uint32_t tv_sec_max = 0xFFFFFFFFUL; - static const uint32_t tv_nsec_max = 999999999UL; - - log_time(const timespec &T) - { - tv_sec = T.tv_sec; - tv_nsec = T.tv_nsec; - } - log_time(uint32_t sec, uint32_t nsec) - { - tv_sec = sec; - tv_nsec = nsec; - } - static const timespec EPOCH; - log_time() - { - } - log_time(clockid_t id) - { - timespec T; - clock_gettime(id, &T); - tv_sec = T.tv_sec; - tv_nsec = T.tv_nsec; - } - log_time(const char *T) - { - const uint8_t *c = (const uint8_t *) T; - tv_sec = c[0] | (c[1] << 8) | (c[2] << 16) | (c[3] << 24); - tv_nsec = c[4] | (c[5] << 8) | (c[6] << 16) | (c[7] << 24); - } +/* + * Native log reading interface section. See logcat for sample code. + * + * The preferred API is an exec of logcat. Likely uses of this interface + * are if native code suffers from exec or filtration being too costly, + * access to raw information, or parsing is an issue. + */ - // timespec - bool operator== (const timespec &T) const - { - return (tv_sec == static_cast(T.tv_sec)) - && (tv_nsec == static_cast(T.tv_nsec)); - } - bool operator!= (const timespec &T) const - { - return !(*this == T); - } - bool operator< (const timespec &T) const - { - return (tv_sec < static_cast(T.tv_sec)) - || ((tv_sec == static_cast(T.tv_sec)) - && (tv_nsec < static_cast(T.tv_nsec))); - } - bool operator>= (const timespec &T) const - { - return !(*this < T); - } - bool operator> (const timespec &T) const - { - return (tv_sec > static_cast(T.tv_sec)) - || ((tv_sec == static_cast(T.tv_sec)) - && (tv_nsec > static_cast(T.tv_nsec))); - } - bool operator<= (const timespec &T) const - { - return !(*this > T); - } - log_time operator-= (const timespec &T); - log_time operator- (const timespec &T) const - { - log_time local(*this); - return local -= T; - } - log_time operator+= (const timespec &T); - log_time operator+ (const timespec &T) const - { - log_time local(*this); - return local += T; - } +/* + * The userspace structure for version 1 of the logger_entry ABI. + */ +#ifndef __struct_logger_entry_defined +#define __struct_logger_entry_defined +struct logger_entry { + uint16_t len; /* length of the payload */ + uint16_t __pad; /* no matter what, we get 2 bytes of padding */ + int32_t pid; /* generating process's pid */ + int32_t tid; /* generating process's tid */ + int32_t sec; /* seconds since Epoch */ + int32_t nsec; /* nanoseconds */ +#ifndef __cplusplus + char msg[0]; /* the entry's payload */ +#endif +}; +#endif - // log_time - bool operator== (const log_time &T) const - { - return (tv_sec == T.tv_sec) && (tv_nsec == T.tv_nsec); - } - bool operator!= (const log_time &T) const - { - return !(*this == T); - } - bool operator< (const log_time &T) const - { - return (tv_sec < T.tv_sec) - || ((tv_sec == T.tv_sec) && (tv_nsec < T.tv_nsec)); - } - bool operator>= (const log_time &T) const - { - return !(*this < T); - } - bool operator> (const log_time &T) const - { - return (tv_sec > T.tv_sec) - || ((tv_sec == T.tv_sec) && (tv_nsec > T.tv_nsec)); - } - bool operator<= (const log_time &T) const - { - return !(*this > T); - } - log_time operator-= (const log_time &T); - log_time operator- (const log_time &T) const - { - log_time local(*this); - return local -= T; +/* + * The userspace structure for version 2 of the logger_entry ABI. + */ +#ifndef __struct_logger_entry_v2_defined +#define __struct_logger_entry_v2_defined +struct logger_entry_v2 { + uint16_t len; /* length of the payload */ + uint16_t hdr_size; /* sizeof(struct logger_entry_v2) */ + int32_t pid; /* generating process's pid */ + int32_t tid; /* generating process's tid */ + int32_t sec; /* seconds since Epoch */ + int32_t nsec; /* nanoseconds */ + uint32_t euid; /* effective UID of logger */ +#ifndef __cplusplus + char msg[0]; /* the entry's payload */ +#endif +} __attribute__((__packed__)); +#endif + +/* + * The userspace structure for version 3 of the logger_entry ABI. + */ +#ifndef __struct_logger_entry_v3_defined +#define __struct_logger_entry_v3_defined +struct logger_entry_v3 { + uint16_t len; /* length of the payload */ + uint16_t hdr_size; /* sizeof(struct logger_entry_v3) */ + int32_t pid; /* generating process's pid */ + int32_t tid; /* generating process's tid */ + int32_t sec; /* seconds since Epoch */ + int32_t nsec; /* nanoseconds */ + uint32_t lid; /* log id of the payload */ +#ifndef __cplusplus + char msg[0]; /* the entry's payload */ +#endif +} __attribute__((__packed__)); +#endif + +/* + * The userspace structure for version 4 of the logger_entry ABI. + */ +#ifndef __struct_logger_entry_v4_defined +#define __struct_logger_entry_v4_defined +struct logger_entry_v4 { + uint16_t len; /* length of the payload */ + uint16_t hdr_size; /* sizeof(struct logger_entry_v4) */ + int32_t pid; /* generating process's pid */ + uint32_t tid; /* generating process's tid */ + uint32_t sec; /* seconds since Epoch */ + uint32_t nsec; /* nanoseconds */ + uint32_t lid; /* log id of the payload, bottom 4 bits currently */ + uint32_t uid; /* generating process's uid */ +#ifndef __cplusplus + char msg[0]; /* the entry's payload */ +#endif +}; +#endif + +/* + * The maximum size of the log entry payload that can be + * written to the logger. An attempt to write more than + * this amount will result in a truncated log entry. + */ +#define LOGGER_ENTRY_MAX_PAYLOAD 4068 + +/* + * The maximum size of a log entry which can be read. + * An attempt to read less than this amount may result + * in read() returning EINVAL. + */ +#define LOGGER_ENTRY_MAX_LEN (5 * 1024) + +#ifndef __struct_log_msg_defined +#define __struct_log_msg_defined +struct log_msg { + union { + unsigned char buf[LOGGER_ENTRY_MAX_LEN + 1]; + struct logger_entry_v4 entry; + struct logger_entry_v4 entry_v4; + struct logger_entry_v3 entry_v3; + struct logger_entry_v2 entry_v2; + struct logger_entry entry_v1; + } __attribute__((aligned(4))); +#ifdef __cplusplus + /* Matching log_time operators */ + bool operator==(const log_msg& T) const { + return (entry.sec == T.entry.sec) && (entry.nsec == T.entry.nsec); + } + bool operator!=(const log_msg& T) const { + return !(*this == T); + } + bool operator<(const log_msg& T) const { + return (entry.sec < T.entry.sec) || + ((entry.sec == T.entry.sec) && (entry.nsec < T.entry.nsec)); + } + bool operator>=(const log_msg& T) const { + return !(*this < T); + } + bool operator>(const log_msg& T) const { + return (entry.sec > T.entry.sec) || + ((entry.sec == T.entry.sec) && (entry.nsec > T.entry.nsec)); + } + bool operator<=(const log_msg& T) const { + return !(*this > T); + } + uint64_t nsec() const { + return static_cast(entry.sec) * NS_PER_SEC + entry.nsec; + } + + /* packet methods */ + log_id_t id() { + return static_cast(entry.lid); + } + char* msg() { + unsigned short hdr_size = entry.hdr_size; + if (!hdr_size) { + hdr_size = sizeof(entry_v1); } - log_time operator+= (const log_time &T); - log_time operator+ (const log_time &T) const - { - log_time local(*this); - return local += T; + if ((hdr_size < sizeof(entry_v1)) || (hdr_size > sizeof(entry))) { + return NULL; } + return reinterpret_cast(buf) + hdr_size; + } + unsigned int len() { + return (entry.hdr_size ? entry.hdr_size + : static_cast(sizeof(entry_v1))) + + entry.len; + } +#endif +}; +#endif - uint64_t nsec() const - { - return static_cast(tv_sec) * NS_PER_SEC + tv_nsec; - } +#ifndef __ANDROID_USE_LIBLOG_READER_INTERFACE +#ifndef __ANDROID_API__ +#define __ANDROID_USE_LIBLOG_READER_INTERFACE 3 +#elif __ANDROID_API__ > 23 /* > Marshmallow */ +#define __ANDROID_USE_LIBLOG_READER_INTERFACE 3 +#elif __ANDROID_API__ > 22 /* > Lollipop */ +#define __ANDROID_USE_LIBLOG_READER_INTERFACE 2 +#elif __ANDROID_API__ > 19 /* > KitKat */ +#define __ANDROID_USE_LIBLOG_READER_INTERFACE 1 +#else +#define __ANDROID_USE_LIBLOG_READER_INTERFACE 0 +#endif +#endif - static const char default_format[]; +#if __ANDROID_USE_LIBLOG_READER_INTERFACE - // Add %#q for the fraction of a second to the standard library functions - char *strptime(const char *s, const char *format = default_format); -} __attribute__((__packed__)); +struct logger; + +log_id_t android_logger_get_id(struct logger* logger); + +int android_logger_clear(struct logger* logger); +long android_logger_get_log_size(struct logger* logger); +int android_logger_set_log_size(struct logger* logger, unsigned long size); +long android_logger_get_log_readable_size(struct logger* logger); +int android_logger_get_log_version(struct logger* logger); +struct logger_list; + +#if __ANDROID_USE_LIBLOG_READER_INTERFACE > 1 +ssize_t android_logger_get_statistics(struct logger_list* logger_list, + char* buf, size_t len); +ssize_t android_logger_get_prune_list(struct logger_list* logger_list, + char* buf, size_t len); +int android_logger_set_prune_list(struct logger_list* logger_list, char* buf, + size_t len); +#endif + +#define ANDROID_LOG_RDONLY O_RDONLY +#define ANDROID_LOG_WRONLY O_WRONLY +#define ANDROID_LOG_RDWR O_RDWR +#define ANDROID_LOG_ACCMODE O_ACCMODE +#ifndef O_NONBLOCK +#define ANDROID_LOG_NONBLOCK 0x00000800 #else +#define ANDROID_LOG_NONBLOCK O_NONBLOCK +#endif +#if __ANDROID_USE_LIBLOG_READER_INTERFACE > 2 +#define ANDROID_LOG_WRAP 0x40000000 /* Block until buffer about to wrap */ +#define ANDROID_LOG_WRAP_DEFAULT_TIMEOUT 7200 /* 2 hour default */ +#endif +#if __ANDROID_USE_LIBLOG_READER_INTERFACE > 1 +#define ANDROID_LOG_PSTORE 0x80000000 +#endif + +struct logger_list* android_logger_list_alloc(int mode, unsigned int tail, + pid_t pid); +struct logger_list* android_logger_list_alloc_time(int mode, log_time start, + pid_t pid); +void android_logger_list_free(struct logger_list* logger_list); +/* In the purest sense, the following two are orthogonal interfaces */ +int android_logger_list_read(struct logger_list* logger_list, + struct log_msg* log_msg); -typedef struct log_time { - uint32_t tv_sec; - uint32_t tv_nsec; -} __attribute__((__packed__)) log_time; +/* Multiple log_id_t opens */ +struct logger* android_logger_open(struct logger_list* logger_list, log_id_t id); +#define android_logger_close android_logger_free +/* Single log_id_t open */ +struct logger_list* android_logger_list_open(log_id_t id, int mode, + unsigned int tail, pid_t pid); +#define android_logger_list_close android_logger_list_free +#endif /* __ANDROID_USE_LIBLOG_READER_INTERFACE */ + +#ifdef __cplusplus +} #endif -#endif /* define _LIBS_LOG_LOG_READ_H */ +#endif /* _LIBS_LOG_LOG_H */ diff --git a/log/log_safetynet.h b/log/log_safetynet.h new file mode 100644 index 0000000..07e8c8a --- /dev/null +++ b/log/log_safetynet.h @@ -0,0 +1,46 @@ +/* +** +** Copyright 2017, The Android Open Source Project +** +** This file is dual licensed. It may be redistributed and/or modified +** under the terms of the Apache 2.0 License OR version 2 of the GNU +** General Public License. +*/ + +#ifndef _LIBS_LOG_SAFETYNET_H +#define _LIBS_LOG_SAFETYNET_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ANDROID_USE_LIBLOG_SAFETYNET_INTERFACE +#ifndef __ANDROID_API__ +#define __ANDROID_USE_LIBLOG_SAFETYNET_INTERFACE 1 +#elif __ANDROID_API__ > 22 /* > Lollipop */ +#define __ANDROID_USE_LIBLOG_SAFETYNET_INTERFACE 1 +#else +#define __ANDROID_USE_LIBLOG_SAFETYNET_INTERFACE 0 +#endif +#endif + +#if __ANDROID_USE_LIBLOG_SAFETYNET_INTERFACE + +#define android_errorWriteLog(tag, subTag) \ + __android_log_error_write(tag, subTag, -1, NULL, 0) + +#define android_errorWriteWithInfoLog(tag, subTag, uid, data, dataLen) \ + __android_log_error_write(tag, subTag, uid, data, dataLen) + +int __android_log_error_write(int tag, const char* subTag, int32_t uid, + const char* data, uint32_t dataLen); + +#endif /* __ANDROID_USE_LIBLOG_SAFETYNET_INTERFACE */ + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBS_LOG_SAFETYNET_H */ diff --git a/log/log_system.h b/log/log_system.h new file mode 100644 index 0000000..3b5ae22 --- /dev/null +++ b/log/log_system.h @@ -0,0 +1,142 @@ +/* + * Copyright (C) 2005-2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _LIBS_LOG_LOG_SYSTEM_H +#define _LIBS_LOG_LOG_SYSTEM_H + +#include +#include + +/* + * Normally we strip the effects of ALOGV (VERBOSE messages), + * LOG_FATAL and LOG_FATAL_IF (FATAL assert messages) from the + * release builds be defining NDEBUG. You can modify this (for + * example with "#define LOG_NDEBUG 0" at the top of your source + * file) to change that behavior. + */ + +#ifndef LOG_NDEBUG +#ifdef NDEBUG +#define LOG_NDEBUG 1 +#else +#define LOG_NDEBUG 0 +#endif +#endif + +#ifndef __predict_false +#define __predict_false(exp) __builtin_expect((exp) != 0, 0) +#endif + +/* + * Simplified macro to send a verbose system log message using current LOG_TAG. + */ +#ifndef SLOGV +#define __SLOGV(...) \ + ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, \ + __VA_ARGS__)) +#if LOG_NDEBUG +#define SLOGV(...) \ + do { \ + if (0) { \ + __SLOGV(__VA_ARGS__); \ + } \ + } while (0) +#else +#define SLOGV(...) __SLOGV(__VA_ARGS__) +#endif +#endif + +#ifndef SLOGV_IF +#if LOG_NDEBUG +#define SLOGV_IF(cond, ...) ((void)0) +#else +#define SLOGV_IF(cond, ...) \ + ((__predict_false(cond)) \ + ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, \ + LOG_TAG, __VA_ARGS__)) \ + : (void)0) +#endif +#endif + +/* + * Simplified macro to send a debug system log message using current LOG_TAG. + */ +#ifndef SLOGD +#define SLOGD(...) \ + ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, \ + __VA_ARGS__)) +#endif + +#ifndef SLOGD_IF +#define SLOGD_IF(cond, ...) \ + ((__predict_false(cond)) \ + ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, \ + LOG_TAG, __VA_ARGS__)) \ + : (void)0) +#endif + +/* + * Simplified macro to send an info system log message using current LOG_TAG. + */ +#ifndef SLOGI +#define SLOGI(...) \ + ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, \ + __VA_ARGS__)) +#endif + +#ifndef SLOGI_IF +#define SLOGI_IF(cond, ...) \ + ((__predict_false(cond)) \ + ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, \ + LOG_TAG, __VA_ARGS__)) \ + : (void)0) +#endif + +/* + * Simplified macro to send a warning system log message using current LOG_TAG. + */ +#ifndef SLOGW +#define SLOGW(...) \ + ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, \ + __VA_ARGS__)) +#endif + +#ifndef SLOGW_IF +#define SLOGW_IF(cond, ...) \ + ((__predict_false(cond)) \ + ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, \ + LOG_TAG, __VA_ARGS__)) \ + : (void)0) +#endif + +/* + * Simplified macro to send an error system log message using current LOG_TAG. + */ +#ifndef SLOGE +#define SLOGE(...) \ + ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, \ + __VA_ARGS__)) +#endif + +#ifndef SLOGE_IF +#define SLOGE_IF(cond, ...) \ + ((__predict_false(cond)) \ + ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, \ + LOG_TAG, __VA_ARGS__)) \ + : (void)0) +#endif + +#endif /* _LIBS_LOG_LOG_SYSTEM_H */ diff --git a/log/log_time.h b/log/log_time.h new file mode 100644 index 0000000..309f5d1 --- /dev/null +++ b/log/log_time.h @@ -0,0 +1,185 @@ +/* + * Copyright (C) 2005-2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _LIBS_LOG_LOG_TIME_H +#define _LIBS_LOG_LOG_TIME_H + +#include +#include + +/* struct log_time is a wire-format variant of struct timespec */ +#define NS_PER_SEC 1000000000ULL +#define US_PER_SEC 1000000ULL +#define MS_PER_SEC 1000ULL + +#ifndef __struct_log_time_defined +#define __struct_log_time_defined + +#define LOG_TIME_SEC(t) ((t)->tv_sec) +/* next power of two after NS_PER_SEC */ +#define LOG_TIME_NSEC(t) ((t)->tv_nsec & (UINT32_MAX >> 2)) + +#ifdef __cplusplus + +/* + * NB: we did NOT define a copy constructor. This will result in structure + * no longer being compatible with pass-by-value which is desired + * efficient behavior. Also, pass-by-reference breaks C/C++ ABI. + */ +struct log_time { + public: + uint32_t tv_sec; /* good to Feb 5 2106 */ + uint32_t tv_nsec; + + static const uint32_t tv_sec_max = 0xFFFFFFFFUL; + static const uint32_t tv_nsec_max = 999999999UL; + + log_time(const timespec& T) + : tv_sec(static_cast(T.tv_sec)), + tv_nsec(static_cast(T.tv_nsec)) { + } + explicit log_time(uint32_t sec, uint32_t nsec = 0) + : tv_sec(sec), tv_nsec(nsec) { + } +#ifdef _SYSTEM_CORE_INCLUDE_PRIVATE_ANDROID_LOGGER_H_ +#define __struct_log_time_private_defined + static const timespec EPOCH; +#endif + log_time() { + } +#ifdef __linux__ + explicit log_time(clockid_t id) { + timespec T; + clock_gettime(id, &T); + tv_sec = static_cast(T.tv_sec); + tv_nsec = static_cast(T.tv_nsec); + } +#endif + explicit log_time(const char* T) { + const uint8_t* c = reinterpret_cast(T); + tv_sec = c[0] | (static_cast(c[1]) << 8) | + (static_cast(c[2]) << 16) | + (static_cast(c[3]) << 24); + tv_nsec = c[4] | (static_cast(c[5]) << 8) | + (static_cast(c[6]) << 16) | + (static_cast(c[7]) << 24); + } + + /* timespec */ + bool operator==(const timespec& T) const { + return (tv_sec == static_cast(T.tv_sec)) && + (tv_nsec == static_cast(T.tv_nsec)); + } + bool operator!=(const timespec& T) const { + return !(*this == T); + } + bool operator<(const timespec& T) const { + return (tv_sec < static_cast(T.tv_sec)) || + ((tv_sec == static_cast(T.tv_sec)) && + (tv_nsec < static_cast(T.tv_nsec))); + } + bool operator>=(const timespec& T) const { + return !(*this < T); + } + bool operator>(const timespec& T) const { + return (tv_sec > static_cast(T.tv_sec)) || + ((tv_sec == static_cast(T.tv_sec)) && + (tv_nsec > static_cast(T.tv_nsec))); + } + bool operator<=(const timespec& T) const { + return !(*this > T); + } + +#ifdef _SYSTEM_CORE_INCLUDE_PRIVATE_ANDROID_LOGGER_H_ + log_time operator-=(const timespec& T); + log_time operator-(const timespec& T) const { + log_time local(*this); + return local -= T; + } + log_time operator+=(const timespec& T); + log_time operator+(const timespec& T) const { + log_time local(*this); + return local += T; + } +#endif + + /* log_time */ + bool operator==(const log_time& T) const { + return (tv_sec == T.tv_sec) && (tv_nsec == T.tv_nsec); + } + bool operator!=(const log_time& T) const { + return !(*this == T); + } + bool operator<(const log_time& T) const { + return (tv_sec < T.tv_sec) || + ((tv_sec == T.tv_sec) && (tv_nsec < T.tv_nsec)); + } + bool operator>=(const log_time& T) const { + return !(*this < T); + } + bool operator>(const log_time& T) const { + return (tv_sec > T.tv_sec) || + ((tv_sec == T.tv_sec) && (tv_nsec > T.tv_nsec)); + } + bool operator<=(const log_time& T) const { + return !(*this > T); + } + +#ifdef _SYSTEM_CORE_INCLUDE_PRIVATE_ANDROID_LOGGER_H_ + log_time operator-=(const log_time& T); + log_time operator-(const log_time& T) const { + log_time local(*this); + return local -= T; + } + log_time operator+=(const log_time& T); + log_time operator+(const log_time& T) const { + log_time local(*this); + return local += T; + } +#endif + + uint64_t nsec() const { + return static_cast(tv_sec) * NS_PER_SEC + tv_nsec; + } + uint64_t usec() const { + return static_cast(tv_sec) * US_PER_SEC + + tv_nsec / (NS_PER_SEC / US_PER_SEC); + } + uint64_t msec() const { + return static_cast(tv_sec) * MS_PER_SEC + + tv_nsec / (NS_PER_SEC / MS_PER_SEC); + } + +#ifdef _SYSTEM_CORE_INCLUDE_PRIVATE_ANDROID_LOGGER_H_ + static const char default_format[]; + + /* Add %#q for the fraction of a second to the standard library functions */ + char* strptime(const char* s, const char* format = default_format); +#endif +} __attribute__((__packed__)); + +#else /* __cplusplus */ + +typedef struct log_time { + uint32_t tv_sec; + uint32_t tv_nsec; +} __attribute__((__packed__)) log_time; + +#endif /* __cplusplus */ + +#endif /* __struct_log_time_defined */ + +#endif /* _LIBS_LOG_LOG_TIME_H */ diff --git a/log/log_transport.h b/log/log_transport.h new file mode 100644 index 0000000..80b30db --- /dev/null +++ b/log/log_transport.h @@ -0,0 +1,37 @@ +/* +** +** Copyright 2017, The Android Open Source Project +** +** This file is dual licensed. It may be redistributed and/or modified +** under the terms of the Apache 2.0 License OR version 2 of the GNU +** General Public License. +*/ + +#ifndef _LIBS_LOG_TRANSPORT_H +#define _LIBS_LOG_TRANSPORT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Logging transports, bit mask to select features. Function returns selection. + */ +/* clang-format off */ +#define LOGGER_DEFAULT 0x00 +#define LOGGER_LOGD 0x01 +#define LOGGER_KERNEL 0x02 /* Reserved/Deprecated */ +#define LOGGER_NULL 0x04 /* Does not release resources of other selections */ +#define LOGGER_LOCAL 0x08 /* logs sent to local memory */ +#define LOGGER_STDERR 0x10 /* logs sent to stderr */ +/* clang-format on */ + +/* Both return the selected transport flag mask, or negative errno */ +int android_set_log_transport(int transport_flag); +int android_get_log_transport(); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBS_LOG_TRANSPORT_H */ diff --git a/log/logd.h b/log/logd.h index b271602..77400ca 100644 --- a/log/logd.h +++ b/log/logd.h @@ -1,54 +1,5 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _ANDROID_CUTILS_LOGD_H -#define _ANDROID_CUTILS_LOGD_H - -/* the stable/frozen log-related definitions have been - * moved to this header, which is exposed by the NDK - */ -#include - -/* the rest is only used internally by the system */ -#if !defined(_WIN32) -#include -#endif -#include -#include -#include -#include -#include -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -int __android_log_bwrite(int32_t tag, const void *payload, size_t len); -int __android_log_btwrite(int32_t tag, char type, const void *payload, - size_t len); -int __android_log_bswrite(int32_t tag, const char *payload); - -int __android_log_security_bwrite(int32_t tag, const void *payload, size_t len); -int __android_log_security_bswrite(int32_t tag, const char *payload); - -#ifdef __cplusplus -} -#endif - -#endif /* _LOGD_H */ +#ifndef _LIBS_LOG_LOGD_H +#define _LIBS_LOG_LOGD_H +#include +#warning "Deprecated: do not include log/logd.h, use log/log.h instead" +#endif /*_LIBS_LOG_LOGD_H*/ diff --git a/log/logger.h b/log/logger.h index 60d47a2..1bf2d17 100644 --- a/log/logger.h +++ b/log/logger.h @@ -1,219 +1,5 @@ -/* -** -** Copyright 2007-2014, The Android Open Source Project -** -** This file is dual licensed. It may be redistributed and/or modified -** under the terms of the Apache 2.0 License OR version 2 of the GNU -** General Public License. -*/ - #ifndef _LIBS_LOG_LOGGER_H #define _LIBS_LOG_LOGGER_H - -#include -#ifdef __linux__ -#include /* clockid_t definition */ -#endif - #include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * The userspace structure for version 1 of the logger_entry ABI. - * This structure is returned to userspace by the kernel logger - * driver unless an upgrade to a newer ABI version is requested. - */ -struct logger_entry { - uint16_t len; /* length of the payload */ - uint16_t __pad; /* no matter what, we get 2 bytes of padding */ - int32_t pid; /* generating process's pid */ - int32_t tid; /* generating process's tid */ - int32_t sec; /* seconds since Epoch */ - int32_t nsec; /* nanoseconds */ - char msg[0]; /* the entry's payload */ -} __attribute__((__packed__)); - -/* - * The userspace structure for version 2 of the logger_entry ABI. - * This structure is returned to userspace if ioctl(LOGGER_SET_VERSION) - * is called with version==2; or used with the user space log daemon. - */ -struct logger_entry_v2 { - uint16_t len; /* length of the payload */ - uint16_t hdr_size; /* sizeof(struct logger_entry_v2) */ - int32_t pid; /* generating process's pid */ - int32_t tid; /* generating process's tid */ - int32_t sec; /* seconds since Epoch */ - int32_t nsec; /* nanoseconds */ - uint32_t euid; /* effective UID of logger */ - char msg[0]; /* the entry's payload */ -} __attribute__((__packed__)); - -struct logger_entry_v3 { - uint16_t len; /* length of the payload */ - uint16_t hdr_size; /* sizeof(struct logger_entry_v3) */ - int32_t pid; /* generating process's pid */ - int32_t tid; /* generating process's tid */ - int32_t sec; /* seconds since Epoch */ - int32_t nsec; /* nanoseconds */ - uint32_t lid; /* log id of the payload */ - char msg[0]; /* the entry's payload */ -} __attribute__((__packed__)); - -struct logger_entry_v4 { - uint16_t len; /* length of the payload */ - uint16_t hdr_size; /* sizeof(struct logger_entry_v4) */ - int32_t pid; /* generating process's pid */ - uint32_t tid; /* generating process's tid */ - uint32_t sec; /* seconds since Epoch */ - uint32_t nsec; /* nanoseconds */ - uint32_t lid; /* log id of the payload, bottom 4 bits currently */ - uint32_t uid; /* generating process's uid */ - char msg[0]; /* the entry's payload */ -} __attribute__((__packed__)); - -/* - * The maximum size of the log entry payload that can be - * written to the logger. An attempt to write more than - * this amount will result in a truncated log entry. - */ -#define LOGGER_ENTRY_MAX_PAYLOAD 4068 - -/* - * The maximum size of a log entry which can be read from the - * kernel logger driver. An attempt to read less than this amount - * may result in read() returning EINVAL. - */ -#define LOGGER_ENTRY_MAX_LEN (5*1024) - -#define NS_PER_SEC 1000000000ULL - -struct log_msg { - union { - unsigned char buf[LOGGER_ENTRY_MAX_LEN + 1]; - struct logger_entry_v4 entry; - struct logger_entry_v4 entry_v4; - struct logger_entry_v3 entry_v3; - struct logger_entry_v2 entry_v2; - struct logger_entry entry_v1; - } __attribute__((aligned(4))); -#ifdef __cplusplus - /* Matching log_time operators */ - bool operator== (const log_msg &T) const - { - return (entry.sec == T.entry.sec) && (entry.nsec == T.entry.nsec); - } - bool operator!= (const log_msg &T) const - { - return !(*this == T); - } - bool operator< (const log_msg &T) const - { - return (entry.sec < T.entry.sec) - || ((entry.sec == T.entry.sec) - && (entry.nsec < T.entry.nsec)); - } - bool operator>= (const log_msg &T) const - { - return !(*this < T); - } - bool operator> (const log_msg &T) const - { - return (entry.sec > T.entry.sec) - || ((entry.sec == T.entry.sec) - && (entry.nsec > T.entry.nsec)); - } - bool operator<= (const log_msg &T) const - { - return !(*this > T); - } - uint64_t nsec() const - { - return static_cast(entry.sec) * NS_PER_SEC + entry.nsec; - } - - /* packet methods */ - log_id_t id() - { - return (log_id_t) entry.lid; - } - char *msg() - { - return entry.hdr_size ? (char *) buf + entry.hdr_size : entry_v1.msg; - } - unsigned int len() - { - return (entry.hdr_size ? entry.hdr_size : sizeof(entry_v1)) + entry.len; - } -#endif -}; - -struct logger; - -log_id_t android_logger_get_id(struct logger *logger); - -int android_logger_clear(struct logger *logger); -long android_logger_get_log_size(struct logger *logger); -int android_logger_set_log_size(struct logger *logger, unsigned long size); -long android_logger_get_log_readable_size(struct logger *logger); -int android_logger_get_log_version(struct logger *logger); - -struct logger_list; - -ssize_t android_logger_get_statistics(struct logger_list *logger_list, - char *buf, size_t len); -ssize_t android_logger_get_prune_list(struct logger_list *logger_list, - char *buf, size_t len); -int android_logger_set_prune_list(struct logger_list *logger_list, - char *buf, size_t len); - -#define ANDROID_LOG_RDONLY O_RDONLY -#define ANDROID_LOG_WRONLY O_WRONLY -#define ANDROID_LOG_RDWR O_RDWR -#define ANDROID_LOG_ACCMODE O_ACCMODE -#define ANDROID_LOG_NONBLOCK O_NONBLOCK -#define ANDROID_LOG_WRAP 0x40000000 /* Block until buffer about to wrap */ -#define ANDROID_LOG_WRAP_DEFAULT_TIMEOUT 7200 /* 2 hour default */ -#define ANDROID_LOG_PSTORE 0x80000000 - -struct logger_list *android_logger_list_alloc(int mode, - unsigned int tail, - pid_t pid); -struct logger_list *android_logger_list_alloc_time(int mode, - log_time start, - pid_t pid); -void android_logger_list_free(struct logger_list *logger_list); -/* In the purest sense, the following two are orthogonal interfaces */ -int android_logger_list_read(struct logger_list *logger_list, - struct log_msg *log_msg); - -/* Multiple log_id_t opens */ -struct logger *android_logger_open(struct logger_list *logger_list, - log_id_t id); -#define android_logger_close android_logger_free -/* Single log_id_t open */ -struct logger_list *android_logger_list_open(log_id_t id, - int mode, - unsigned int tail, - pid_t pid); -#define android_logger_list_close android_logger_list_free - -#ifdef __linux__ -clockid_t android_log_clockid(); -#endif - -/* - * log_id_t helpers - */ -log_id_t android_name_to_log_id(const char *logName); -const char *android_log_id_to_name(log_id_t log_id); - -#ifdef __cplusplus -} -#endif - -#endif /* _LIBS_LOG_LOGGER_H */ +#warning "Deprecated: do not include log/logger.h, use log/log.h instead" +#endif /*_LIBS_LOG_LOGGER_H*/ diff --git a/log/logprint.h b/log/logprint.h index 539d1dc..ca58bc7 100644 --- a/log/logprint.h +++ b/log/logprint.h @@ -17,62 +17,67 @@ #ifndef _LOGPRINT_H #define _LOGPRINT_H -#include -#include -#include #include +#include +#include + #ifdef __cplusplus extern "C" { #endif typedef enum { - FORMAT_OFF = 0, - FORMAT_BRIEF, - FORMAT_PROCESS, - FORMAT_TAG, - FORMAT_THREAD, - FORMAT_RAW, - FORMAT_TIME, - FORMAT_THREADTIME, - FORMAT_LONG, - /* The following are modifiers to above formats */ - FORMAT_MODIFIER_COLOR, /* converts priority to color */ - FORMAT_MODIFIER_TIME_USEC, /* switches from msec to usec time precision */ - FORMAT_MODIFIER_PRINTABLE, /* converts non-printable to printable escapes */ - FORMAT_MODIFIER_YEAR, /* Adds year to date */ - FORMAT_MODIFIER_ZONE, /* Adds zone to date */ - FORMAT_MODIFIER_EPOCH, /* Print time as seconds since Jan 1 1970 */ - FORMAT_MODIFIER_MONOTONIC, /* Print cpu time as seconds since start */ - FORMAT_MODIFIER_UID, /* Adds uid */ + /* Verbs */ + FORMAT_OFF = 0, + FORMAT_BRIEF, + FORMAT_PROCESS, + FORMAT_TAG, + FORMAT_THREAD, + FORMAT_RAW, + FORMAT_TIME, + FORMAT_THREADTIME, + FORMAT_LONG, + /* Adverbs. The following are modifiers to above format verbs */ + FORMAT_MODIFIER_COLOR, /* converts priority to color */ + FORMAT_MODIFIER_TIME_USEC, /* switches from msec to usec time precision */ + FORMAT_MODIFIER_PRINTABLE, /* converts non-printable to printable escapes */ + FORMAT_MODIFIER_YEAR, /* Adds year to date */ + FORMAT_MODIFIER_ZONE, /* Adds zone to date, + UTC */ + FORMAT_MODIFIER_EPOCH, /* Print time as seconds since Jan 1 1970 */ + FORMAT_MODIFIER_MONOTONIC, /* Print cpu time as seconds since start */ + FORMAT_MODIFIER_UID, /* Adds uid */ + FORMAT_MODIFIER_DESCRIPT, /* Adds descriptive */ + /* private, undocumented */ + FORMAT_MODIFIER_TIME_NSEC, /* switches from msec to nsec time precision */ } AndroidLogPrintFormat; typedef struct AndroidLogFormat_t AndroidLogFormat; typedef struct AndroidLogEntry_t { - time_t tv_sec; - long tv_nsec; - android_LogPriority priority; - int32_t uid; - int32_t pid; - int32_t tid; - const char * tag; - size_t messageLen; - const char * message; + time_t tv_sec; + long tv_nsec; + android_LogPriority priority; + int32_t uid; + int32_t pid; + int32_t tid; + const char* tag; + size_t tagLen; + size_t messageLen; + const char* message; } AndroidLogEntry; -AndroidLogFormat *android_log_format_new(); +AndroidLogFormat* android_log_format_new(); -void android_log_format_free(AndroidLogFormat *p_format); +void android_log_format_free(AndroidLogFormat* p_format); /* currently returns 0 if format is a modifier, 1 if not */ -int android_log_setPrintFormat(AndroidLogFormat *p_format, - AndroidLogPrintFormat format); +int android_log_setPrintFormat(AndroidLogFormat* p_format, + AndroidLogPrintFormat format); /** * Returns FORMAT_OFF on invalid string */ -AndroidLogPrintFormat android_log_formatFromString(const char *s); +AndroidLogPrintFormat android_log_formatFromString(const char* s); /** * filterExpression: a single filter expression @@ -84,9 +89,8 @@ AndroidLogPrintFormat android_log_formatFromString(const char *s); * */ -int android_log_addFilterRule(AndroidLogFormat *p_format, - const char *filterExpression); - +int android_log_addFilterRule(AndroidLogFormat* p_format, + const char* filterExpression); /** * filterString: a whitespace-separated set of filter expressions @@ -98,17 +102,15 @@ int android_log_addFilterRule(AndroidLogFormat *p_format, * */ -int android_log_addFilterString(AndroidLogFormat *p_format, - const char *filterString); - +int android_log_addFilterString(AndroidLogFormat* p_format, + const char* filterString); /** * returns 1 if this log line should be printed based on its priority * and tag, and 0 if it should not */ -int android_log_shouldPrintLine ( - AndroidLogFormat *p_format, const char *tag, android_LogPriority pri); - +int android_log_shouldPrintLine(AndroidLogFormat* p_format, const char* tag, + android_LogPriority pri); /** * Splits a wire-format buffer into an AndroidLogEntry @@ -117,8 +119,8 @@ int android_log_shouldPrintLine ( * Returns 0 on success and -1 on invalid wire format (entry will be * in unspecified state) */ -int android_log_processLogBuffer(struct logger_entry *buf, - AndroidLogEntry *entry); +int android_log_processLogBuffer(struct logger_entry* buf, + AndroidLogEntry* entry); /** * Like android_log_processLogBuffer, but for binary logs. @@ -126,10 +128,10 @@ int android_log_processLogBuffer(struct logger_entry *buf, * If "map" is non-NULL, it will be used to convert the log tag number * into a string. */ -int android_log_processBinaryLogBuffer(struct logger_entry *buf, - AndroidLogEntry *entry, const EventTagMap* map, char* messageBuf, - int messageBufLen); - +int android_log_processBinaryLogBuffer(struct logger_entry* buf, + AndroidLogEntry* entry, + const EventTagMap* map, char* messageBuf, + int messageBufLen); /** * Formats a log message into a buffer @@ -139,13 +141,10 @@ int android_log_processBinaryLogBuffer(struct logger_entry *buf, * Returns NULL on malloc error */ -char *android_log_formatLogLine ( - AndroidLogFormat *p_format, - char *defaultBuffer, - size_t defaultBufferSize, - const AndroidLogEntry *p_line, - size_t *p_outLength); - +char* android_log_formatLogLine(AndroidLogFormat* p_format, char* defaultBuffer, + size_t defaultBufferSize, + const AndroidLogEntry* p_line, + size_t* p_outLength); /** * Either print or do not print log line, based on filter @@ -153,15 +152,11 @@ char *android_log_formatLogLine ( * Assumes single threaded execution * */ -int android_log_printLogLine( - AndroidLogFormat *p_format, - int fd, - const AndroidLogEntry *entry); - +int android_log_printLogLine(AndroidLogFormat* p_format, int fd, + const AndroidLogEntry* entry); #ifdef __cplusplus } #endif - #endif /*_LOGPRINT_H*/ diff --git a/log/uio.h b/log/uio.h index 7059da5..a492bae 100644 --- a/log/uio.h +++ b/log/uio.h @@ -34,12 +34,12 @@ extern "C" { #include struct iovec { - void* iov_base; - size_t iov_len; + void* iov_base; + size_t iov_len; }; -extern int readv( int fd, struct iovec* vecs, int count ); -extern int writev( int fd, const struct iovec* vecs, int count ); +extern int readv(int fd, struct iovec* vecs, int count); +extern int writev(int fd, const struct iovec* vecs, int count); #ifdef __cplusplus } @@ -48,4 +48,3 @@ extern int writev( int fd, const struct iovec* vecs, int count ); #endif #endif /* _LIBS_UTILS_UIO_H */ - diff --git a/nativebase/nativebase.h b/nativebase/nativebase.h new file mode 100644 index 0000000..7ecdfbd --- /dev/null +++ b/nativebase/nativebase.h @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +__BEGIN_DECLS + +#ifdef __cplusplus +#define ANDROID_NATIVE_UNSIGNED_CAST(x) static_cast(x) +#else +#define ANDROID_NATIVE_UNSIGNED_CAST(x) ((unsigned int)(x)) +#endif + +#define ANDROID_NATIVE_MAKE_CONSTANT(a,b,c,d) \ + ((ANDROID_NATIVE_UNSIGNED_CAST(a) << 24) | \ + (ANDROID_NATIVE_UNSIGNED_CAST(b) << 16) | \ + (ANDROID_NATIVE_UNSIGNED_CAST(c) << 8) | \ + (ANDROID_NATIVE_UNSIGNED_CAST(d))) + +#define ANDROID_NATIVE_BUFFER_MAGIC ANDROID_NATIVE_MAKE_CONSTANT('_','b','f','r') + + +typedef struct android_native_base_t +{ + /* a magic value defined by the actual EGL native type */ + int magic; + + /* the sizeof() of the actual EGL native type */ + int version; + + void* reserved[4]; + + /* reference-counting interface */ + void (*incRef)(struct android_native_base_t* base); + void (*decRef)(struct android_native_base_t* base); +} android_native_base_t; + +typedef struct android_native_rect_t +{ + int32_t left; + int32_t top; + int32_t right; + int32_t bottom; +} android_native_rect_t; + +typedef struct ANativeWindowBuffer +{ +#ifdef __cplusplus + ANativeWindowBuffer() { + common.magic = ANDROID_NATIVE_BUFFER_MAGIC; + common.version = sizeof(ANativeWindowBuffer); + memset(common.reserved, 0, sizeof(common.reserved)); + } + + // Implement the methods that sp expects so that it + // can be used to automatically refcount ANativeWindowBuffer's. + void incStrong(const void* /*id*/) const { + common.incRef(const_cast(&common)); + } + void decStrong(const void* /*id*/) const { + common.decRef(const_cast(&common)); + } +#endif + + struct android_native_base_t common; + + int width; + int height; + int stride; + int format; + int usage_deprecated; + uintptr_t layerCount; + + void* reserved[1]; + + const native_handle_t* handle; + uint64_t usage; + + // we needed extra space for storing the 64-bits usage flags + // the number of slots to use from reserved_proc depends on the + // architecture. + void* reserved_proc[8 - (sizeof(uint64_t) / sizeof(void*))]; +} ANativeWindowBuffer_t; + +typedef struct ANativeWindowBuffer ANativeWindowBuffer; + +// Old typedef for backwards compatibility. +typedef ANativeWindowBuffer_t android_native_buffer_t; + +__END_DECLS diff --git a/ndk/sync.h b/ndk/sync.h new file mode 100644 index 0000000..3c55783 --- /dev/null +++ b/ndk/sync.h @@ -0,0 +1,88 @@ +/* + * Copyright 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_SYNC_H +#define ANDROID_SYNC_H + +#include + +#include + +__BEGIN_DECLS + +#if __ANDROID_API__ >= __ANDROID_API_O__ + +/* Fences indicate the status of an asynchronous task. They are initially + * in unsignaled state (0), and make a one-time transition to either signaled + * (1) or error (< 0) state. A sync file is a collection of one or more fences; + * the sync file's status is error if any of its fences are in error state, + * signaled if all of the child fences are signaled, or unsignaled otherwise. + * + * Sync files are created by various device APIs in response to submitting + * tasks to the device. Standard file descriptor lifetime syscalls like dup() + * and close() are used to manage sync file lifetime. + * + * The poll(), ppoll(), or select() syscalls can be used to wait for the sync + * file to change status, or (with a timeout of zero) to check its status. + * + * The functions below provide a few additional sync-specific operations. + */ + +/** + * Merge two sync files. + * + * This produces a new sync file with the given name which has the union of the + * two original sync file's fences; redundant fences may be removed. + * + * If one of the input sync files is signaled or invalid, then this function + * may behave like dup(): the new file descriptor refers to the valid/unsignaled + * sync file with its original name, rather than a new sync file. + * + * The original fences remain valid, and the caller is responsible for closing + * them. + */ +int32_t sync_merge(const char *name, int32_t fd1, int32_t fd2); + +/** + * Retrieve detailed information about a sync file and its fences. + * + * The returned sync_file_info must be freed by calling sync_file_info_free(). + */ +struct sync_file_info *sync_file_info(int32_t fd); + +/** + * Get the array of fence infos from the sync file's info. + * + * The returned array is owned by the parent sync file info, and has + * info->num_fences entries. + */ +static inline struct sync_fence_info* sync_get_fence_info(const struct sync_file_info* info) { +// This header should compile in C, but some C++ projects enable +// warnings-as-error for C-style casts. +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wold-style-cast" + return (struct sync_fence_info *)(uintptr_t)(info->sync_fence_info); +#pragma GCC diagnostic pop +} + +/** Free a struct sync_file_info structure */ +void sync_file_info_free(struct sync_file_info *info); + +#endif // __ANDROID_API__ >= __ANDROID_API_O__ + +__END_DECLS + +#endif /* ANDROID_SYNC_H */ diff --git a/private/CFIShadow.h b/private/CFIShadow.h new file mode 100644 index 0000000..1423d86 --- /dev/null +++ b/private/CFIShadow.h @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CFI_SHADOW_H +#define CFI_SHADOW_H + +#include + +#include "private/bionic_page.h" +#include "private/bionic_macros.h" + +constexpr unsigned kLibraryAlignmentBits = 18; +constexpr size_t kLibraryAlignment = 1UL << kLibraryAlignmentBits; + +// This class defines format of the shadow region for Control Flow Integrity support. +// See documentation in http://clang.llvm.org/docs/ControlFlowIntegrityDesign.html#shared-library-support. +// +// CFI shadow is effectively a very fast and specialized implementation of dladdr: given an address that +// belongs to a shared library or an executable, it can find the address of a specific export in that +// library (a function called "__cfi_check"). This is only guaranteed to work for +// addresses of possible CFI targets inside a library: indirectly called functions and virtual +// tables. A random address inside a library may not work in the future (but it does in the current +// implementation). +// +// Implementation is a sparse array of uint16_t where each element describes the location of +// __cfi_check for a 2**kShadowGranularity range of memory. Array elements (called "shadow values" +// below) are interpreted as follows. +// +// For an address P and corresponding shadow value V, the address of __cfi_check is calculated as +// align_up(P, 2**kShadowGranularity) - (V - 2) * (2 ** kCfiCheckGranularity) +// +// Special shadow values: +// 0 = kInvalidShadow, this memory range has no valid CFI targets. +// 1 = kUncheckedShadow, any address is this memory range is a valid CFI target +// +// Loader requirement: each aligned 2**kShadowGranularity region of address space may contain at +// most one DSO. +// Compiler requirement: __cfi_check is aligned at kCfiCheckGranularity. +// Compiler requirement: __cfi_check for a given DSO is located below any CFI target for that DSO. +class CFIShadow { + public: + static constexpr uintptr_t kShadowGranularity = kLibraryAlignmentBits; + static constexpr uintptr_t kCfiCheckGranularity = 12; + + // Each uint16_t element of the shadow corresponds to this much application memory. + static constexpr uintptr_t kShadowAlign = 1UL << kShadowGranularity; + + // Alignment of __cfi_check. + static constexpr uintptr_t kCfiCheckAlign = 1UL << kCfiCheckGranularity; // 4K + +#if defined (__LP64__) + static constexpr uintptr_t kMaxTargetAddr = 0xffffffffffff; +#else + static constexpr uintptr_t kMaxTargetAddr = 0xffffffff; +#endif + + // Shadow is 2 -> 2**kShadowGranularity. + static constexpr uintptr_t kShadowSize = + align_up((kMaxTargetAddr >> (kShadowGranularity - 1)), PAGE_SIZE); + + // Returns offset inside the shadow region for an address. + static constexpr uintptr_t MemToShadowOffset(uintptr_t x) { + return (x >> kShadowGranularity) << 1; + } + + typedef int (*CFICheckFn)(uint64_t, void *, void *); + + public: + enum ShadowValues : uint16_t { + kInvalidShadow = 0, // Not a valid CFI target. + kUncheckedShadow = 1, // Unchecked, valid CFI target. + kRegularShadowMin = 2 // This and all higher values encode a negative offset to __cfi_check in + // the units of kCfiCheckGranularity, starting with 0 at + // kRegularShadowMin. + }; +}; + +#endif // CFI_SHADOW_H diff --git a/private/CachedProperty.h b/private/CachedProperty.h new file mode 100644 index 0000000..bd67d74 --- /dev/null +++ b/private/CachedProperty.h @@ -0,0 +1,107 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#pragma once + +#include + +#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_ +#include + +// Cached system property lookup. For code that needs to read the same property multiple times, +// this class helps optimize those lookups. +class CachedProperty { + public: + // The lifetime of `property_name` must be greater than that of this CachedProperty. + explicit CachedProperty(const char* property_name) + : property_name_(property_name), + prop_info_(nullptr), + cached_area_serial_(0), + cached_property_serial_(0), + is_read_only_(strncmp(property_name, "ro.", 3) == 0), + read_only_property_(nullptr) { + cached_value_[0] = '\0'; + } + + // Returns true if the property has been updated (based on the serial rather than the value) + // since the last call to Get. + bool DidChange() { + uint32_t initial_property_serial_ = cached_property_serial_; + Get(); + return (cached_property_serial_ != initial_property_serial_); + } + + // Returns the current value of the underlying system property as cheaply as possible. + // The returned pointer is valid until the next call to Get. It is the caller's responsibility + // to provide a lock for thread-safety. + const char* Get() { + // Do we have a `struct prop_info` yet? + if (prop_info_ == nullptr) { + // `__system_property_find` is expensive, so only retry if a property + // has been created since last time we checked. + uint32_t property_area_serial = __system_property_area_serial(); + if (property_area_serial != cached_area_serial_) { + prop_info_ = __system_property_find(property_name_); + cached_area_serial_ = property_area_serial; + } + } + + if (prop_info_ != nullptr) { + // Only bother re-reading the property if it's actually changed since last time. + uint32_t property_serial = __system_property_serial(prop_info_); + if (property_serial != cached_property_serial_) { + __system_property_read_callback(prop_info_, &CachedProperty::Callback, this); + } + } + if (is_read_only_ && read_only_property_ != nullptr) { + return read_only_property_; + } + return cached_value_; + } + + private: + const char* property_name_; + const prop_info* prop_info_; + uint32_t cached_area_serial_; + uint32_t cached_property_serial_; + char cached_value_[PROP_VALUE_MAX]; + bool is_read_only_; + const char* read_only_property_; + + static void Callback(void* data, const char*, const char* value, uint32_t serial) { + CachedProperty* instance = reinterpret_cast(data); + instance->cached_property_serial_ = serial; + // Read only properties can be larger than PROP_VALUE_MAX, but also never change value or + // location, thus we return the pointer from the shared memory directly. + if (instance->is_read_only_) { + instance->read_only_property_ = value; + } else { + strlcpy(instance->cached_value_, value, PROP_VALUE_MAX); + } + } +}; diff --git a/libnfc-nxp/phOsalNfc_Msg.h b/private/ErrnoRestorer.h similarity index 54% rename from libnfc-nxp/phOsalNfc_Msg.h rename to private/ErrnoRestorer.h index d295068..f467393 100644 --- a/libnfc-nxp/phOsalNfc_Msg.h +++ b/private/ErrnoRestorer.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 NXP Semiconductors + * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,28 +14,30 @@ * limitations under the License. */ -/*! - * \file phOsalNfc_Msg.h - * - * Project: NFC FRI / OSAL - * - * $Workfile:: phOsalNfc.h $ - * $Modtime:: $ - * $Author: frq09147 $ - * $Revision: 1.1 $ - * - */ +#ifndef ERRNO_RESTORER_H +#define ERRNO_RESTORER_H + +#include + +#include "bionic_macros.h" + +class ErrnoRestorer { + public: + explicit ErrnoRestorer() : saved_errno_(errno) { + } + + ~ErrnoRestorer() { + errno = saved_errno_; + } + + void override(int new_errno) { + saved_errno_ = new_errno; + } + + private: + int saved_errno_; + + DISALLOW_COPY_AND_ASSIGN(ErrnoRestorer); +}; -#ifndef PHOSALNFC_MSG_H -#define PHOSALNFC_MSG_H -#ifdef _WIN32 -#include -#else -#ifdef __linux__ -#include -#else -#include -#endif -#endif - -#endif /* PHOSALNFC_MSG_H */ +#endif // ERRNO_RESTORER_H diff --git a/cutils/dir_hash.h b/private/FdPath.h similarity index 58% rename from cutils/dir_hash.h rename to private/FdPath.h index fbb4d02..4a6a2d5 100644 --- a/cutils/dir_hash.h +++ b/private/FdPath.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007 The Android Open Source Project + * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,13 +14,18 @@ * limitations under the License. */ -typedef enum { - SHA_1, -} HashAlgorithm; +#pragma once -int get_file_hash(HashAlgorithm algorithm, const char *path, - char *output_string, size_t max_output_string); +class FdPath { + public: + explicit FdPath(int fd) { + snprintf(buf, sizeof(buf), "/proc/self/fd/%d", fd); + } -int get_recursive_hash_manifest(HashAlgorithm algorithm, - const char *directory_path, - char **output_string); + const char* c_str() { + return buf; + } + + private: + char buf[40]; +}; diff --git a/private/KernelArgumentBlock.h b/private/KernelArgumentBlock.h new file mode 100644 index 0000000..747186c --- /dev/null +++ b/private/KernelArgumentBlock.h @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef KERNEL_ARGUMENT_BLOCK_H +#define KERNEL_ARGUMENT_BLOCK_H + +#include +#include +#include +#include + +#include "private/bionic_macros.h" + +struct abort_msg_t; + +// When the kernel starts the dynamic linker, it passes a pointer to a block +// of memory containing argc, the argv array, the environment variable array, +// and the array of ELF aux vectors. This class breaks that block up into its +// constituents for easy access. +class KernelArgumentBlock { + public: + explicit KernelArgumentBlock(void* raw_args) { + uintptr_t* args = reinterpret_cast(raw_args); + argc = static_cast(*args); + argv = reinterpret_cast(args + 1); + envp = argv + argc + 1; + + // Skip over all environment variable definitions to find the aux vector. + // The end of the environment block is marked by a NULL pointer. + char** p = envp; + while (*p != NULL) { + ++p; + } + ++p; // Skip the NULL itself. + + auxv = reinterpret_cast(p); + } + + // Similar to ::getauxval but doesn't require the libc global variables to be set up, + // so it's safe to call this really early on. + unsigned long getauxval(unsigned long type) { + for (ElfW(auxv_t)* v = auxv; v->a_type != AT_NULL; ++v) { + if (v->a_type == type) { + return v->a_un.a_val; + } + } + return 0; + } + + int argc; + char** argv; + char** envp; + ElfW(auxv_t)* auxv; + + abort_msg_t** abort_message_ptr; + + private: + DISALLOW_COPY_AND_ASSIGN(KernelArgumentBlock); +}; + +#endif // KERNEL_ARGUMENT_BLOCK_H diff --git a/private/NetdClientDispatch.h b/private/NetdClientDispatch.h new file mode 100644 index 0000000..8d8947d --- /dev/null +++ b/private/NetdClientDispatch.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef PRIVATE_NETD_CLIENT_DISPATCH_H +#define PRIVATE_NETD_CLIENT_DISPATCH_H + +#include +#include + +__BEGIN_DECLS + +struct NetdClientDispatch { + int (*accept4)(int, struct sockaddr*, socklen_t*, int); + int (*connect)(int, const struct sockaddr*, socklen_t); + int (*socket)(int, int, int); + unsigned (*netIdForResolv)(unsigned); +}; + +extern __LIBC_HIDDEN__ struct NetdClientDispatch __netdClientDispatch; + +__END_DECLS + +#endif // PRIVATE_NETD_CLIENT_DISPATCH_H diff --git a/private/ScopedPthreadMutexLocker.h b/private/ScopedPthreadMutexLocker.h new file mode 100644 index 0000000..58462e3 --- /dev/null +++ b/private/ScopedPthreadMutexLocker.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SCOPED_PTHREAD_MUTEX_LOCKER_H +#define SCOPED_PTHREAD_MUTEX_LOCKER_H + +#include + +#include "bionic_macros.h" + +class ScopedPthreadMutexLocker { + public: + explicit ScopedPthreadMutexLocker(pthread_mutex_t* mu) : mu_(mu) { + pthread_mutex_lock(mu_); + } + + ~ScopedPthreadMutexLocker() { + pthread_mutex_unlock(mu_); + } + + private: + pthread_mutex_t* mu_; + + DISALLOW_IMPLICIT_CONSTRUCTORS(ScopedPthreadMutexLocker); +}; + +#endif // SCOPED_PTHREAD_MUTEX_LOCKER_H diff --git a/libnfc-nxp/phFriNfc_LlcpMacNfcip.h b/private/ScopedReaddir.h similarity index 51% rename from libnfc-nxp/phFriNfc_LlcpMacNfcip.h rename to private/ScopedReaddir.h index 945ddc9..3d77a40 100644 --- a/libnfc-nxp/phFriNfc_LlcpMacNfcip.h +++ b/private/ScopedReaddir.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 NXP Semiconductors + * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,37 +14,40 @@ * limitations under the License. */ -/** - * \file phFriNfc_LlcpMacNfcip.h - * \brief NFC LLCP MAC Mapping for NFCIP. - * - * Project: NFC-FRI - * - */ +#ifndef SCOPED_READDIR_H +#define SCOPED_READDIR_H -#ifndef PHFRINFC_LLCPMACNFCIP_H -#define PHFRINFC_LLCPMACNFCIP_H +#include +#include "private/bionic_macros.h" -/*include files*/ -#include -#include -#include -#include - -/** - * \name MAC Mapping for NFCIP - * - * File: \ref phFriNfc_LlcpMacNfcip.h - * - */ +class ScopedReaddir { + public: + ScopedReaddir(const char* path) : ScopedReaddir(opendir(path)) { + } + ScopedReaddir(DIR* dir) { + dir_ = dir; + } -/** \defgroup grp_fri_nfc_llcp_macnfcip NFCIP MAC Mapping - * - * TODO - * - */ -NFCSTATUS phFriNfc_LlcpMac_Nfcip_Register (phFriNfc_LlcpMac_t *LlcpMac); + ~ScopedReaddir() { + if (dir_ != NULL) { + closedir(dir_); + } + } + + bool IsBad() { + return dir_ == NULL; + } + + dirent* ReadEntry() { + return readdir(dir_); + } + + private: + DIR* dir_; + + DISALLOW_COPY_AND_ASSIGN(ScopedReaddir); +}; -#endif /* PHFRINFC_LLCPMACNFCIP_H */ +#endif // SCOPED_READDIR_H diff --git a/private/ScopedSignalBlocker.h b/private/ScopedSignalBlocker.h new file mode 100644 index 0000000..7582068 --- /dev/null +++ b/private/ScopedSignalBlocker.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SCOPED_SIGNAL_BLOCKER_H +#define SCOPED_SIGNAL_BLOCKER_H + +#include + +#include "bionic_macros.h" + +class ScopedSignalBlocker { + public: + explicit ScopedSignalBlocker() { + sigset64_t set; + sigfillset64(&set); + sigprocmask64(SIG_SETMASK, &set, &old_set_); + } + + ~ScopedSignalBlocker() { + reset(); + } + + void reset() { + sigprocmask64(SIG_SETMASK, &old_set_, nullptr); + } + + private: + sigset64_t old_set_; + + DISALLOW_COPY_AND_ASSIGN(ScopedSignalBlocker); +}; + +#endif diff --git a/private/SigSetConverter.h b/private/SigSetConverter.h new file mode 100644 index 0000000..7d0b215 --- /dev/null +++ b/private/SigSetConverter.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#pragma once + +union SigSetConverter { + int bsd; + sigset_t sigset; + sigset64_t sigset64; +}; diff --git a/private/WriteProtected.h b/private/WriteProtected.h new file mode 100644 index 0000000..20afdec --- /dev/null +++ b/private/WriteProtected.h @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _PRIVATE_WRITEPROTECTED_H +#define _PRIVATE_WRITEPROTECTED_H + +#include +#include +#include +#include +#include + +#include + +#include "private/bionic_macros.h" +#include "private/bionic_prctl.h" + +template +union WriteProtectedContents { + T value; + char padding[PAGE_SIZE]; + + WriteProtectedContents() = default; + DISALLOW_COPY_AND_ASSIGN(WriteProtectedContents); +} __attribute__((aligned(PAGE_SIZE))); + +// Write protected wrapper class that aligns its contents to a page boundary, +// and sets the memory protection to be non-writable, except when being modified +// explicitly. +template +class WriteProtected { + static_assert(sizeof(T) < PAGE_SIZE, + "WriteProtected only supports contents up to PAGE_SIZE"); + static_assert(__is_pod(T), "WriteProtected only supports POD contents"); + + WriteProtectedContents contents; + + public: + WriteProtected() = default; + DISALLOW_COPY_AND_ASSIGN(WriteProtected); + + void initialize() { + // Not strictly necessary, but this will hopefully segfault if we initialize + // multiple times by accident. + memset(&contents, 0, sizeof(contents)); + + if (mprotect(&contents, PAGE_SIZE, PROT_READ)) { + async_safe_fatal("failed to make WriteProtected nonwritable in initialize"); + } + } + + const T* operator->() { + return &contents.value; + } + + const T& operator*() { + return contents.value; + } + + template + void mutate(Mutator mutator) { + if (mprotect(&contents, PAGE_SIZE, PROT_READ | PROT_WRITE) != 0) { + async_safe_fatal("failed to make WriteProtected writable in mutate: %s", + strerror(errno)); + } + mutator(&contents.value); + if (mprotect(&contents, PAGE_SIZE, PROT_READ) != 0) { + async_safe_fatal("failed to make WriteProtected nonwritable in mutate: %s", + strerror(errno)); + } + } +}; + +#endif diff --git a/private/__get_tls.h b/private/__get_tls.h new file mode 100644 index 0000000..9f37b01 --- /dev/null +++ b/private/__get_tls.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef __BIONIC_PRIVATE_GET_TLS_H_ +#define __BIONIC_PRIVATE_GET_TLS_H_ + +#ifdef __cplusplus +extern "C" { +#endif +void **__get_tls(void); +void **__get_tls_hooks(void); +#ifdef __cplusplus +} +#endif + +#include "__get_tls_internal.h" + +//#define __get_tls __get_tls_hooks + +#endif /* __BIONIC_PRIVATE_GET_TLS_H_ */ diff --git a/private/__get_tls_internal.h b/private/__get_tls_internal.h new file mode 100644 index 0000000..4a8fa5f --- /dev/null +++ b/private/__get_tls_internal.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef __BIONIC_PRIVATE_GET_TLS_INTERNAL_H_ +#define __BIONIC_PRIVATE_GET_TLS_INTERNAL_H_ + +#if defined(__aarch64__) +# define __get_tls_internal() ({ void** __val; __asm__("mrs %0, tpidr_el0" : "=r"(__val)); __val; }) +#elif defined(__arm__) +# define __get_tls_internal() ({ void** __val; __asm__("mrc p15, 0, %0, c13, c0, 3" : "=r"(__val)); __val; }) +#elif defined(__mips__) +# define __get_tls_internal() \ + /* On mips32r1, this goes via a kernel illegal instruction trap that's optimized for v1. */ \ + ({ register void** __val asm("v1"); \ + __asm__(".set push\n" \ + ".set mips32r2\n" \ + "rdhwr %0,$29\n" \ + ".set pop\n" : "=r"(__val)); \ + __val; }) +#elif defined(__i386__) +# define __get_tls_internal() ({ void** __val; __asm__("movl %%gs:0, %0" : "=r"(__val)); __val; }) +#elif defined(__x86_64__) +# define __get_tls_internal() ({ void** __val; __asm__("mov %%fs:0, %0" : "=r"(__val)); __val; }) +#else +#error unsupported architecture +#endif + +#endif /* __BIONIC_PRIVATE_GET_TLS_INTERNAL_H_ */ + diff --git a/private/android_filesystem_config.h b/private/android_filesystem_config.h index f03346e..5d17698 100644 --- a/private/android_filesystem_config.h +++ b/private/android_filesystem_config.h @@ -14,270 +14,189 @@ * limitations under the License. */ -/* This file is used to define the properties of the filesystem -** images generated by build tools (mkbootfs and mkyaffs2image) and -** by the device side of adb. -*/ +/* + * This file is consumed by build/tools/fs_config and is used + * for generating various files. Anything #define AID_ + * becomes the mapping for getpwnam/getpwuid, etc. The + * field is lowercased. + * For example: + * #define AID_FOO_BAR 6666 becomes a friendly name of "foo_bar" + * + * The above holds true with the exception of: + * mediacodec + * mediaex + * mediadrm + * Whose friendly names do not match the #define statements. + * + * Additionally, AID_OEM_RESERVED_START and AID_OEM_RESERVED_END + * can be used to define reserved OEM ranges used for sanity checks + * during the build process. The rules are, they must end with START/END + * The proper convention is incrementing a number like so: + * AID_OEM_RESERVED_START + * AID_OEM_RESERVED_1_START + * AID_OEM_RESERVED_2_START + * ... + * The same applies to the END. + * They are not required to be in order, but must not overlap each other and + * must define a START and END'ing range. START must be smaller than END. + */ #ifndef _ANDROID_FILESYSTEM_CONFIG_H_ #define _ANDROID_FILESYSTEM_CONFIG_H_ -#include #include -#include -#if defined(__ANDROID__) -#include -#else -#include "android_filesystem_capability.h" +#if !defined(__ANDROID_VNDK__) && !defined(EXCLUDE_FS_CONFIG_STRUCTURES) +#include #endif -#define CAP_MASK_LONG(cap_name) (1ULL << (cap_name)) - /* This is the master Users and Groups config for the platform. * DO NOT EVER RENUMBER */ -#define AID_ROOT 0 /* traditional unix root user */ - -#define AID_SYSTEM 1000 /* system server */ - -#define AID_RADIO 1001 /* telephony subsystem, RIL */ -#define AID_BLUETOOTH 1002 /* bluetooth subsystem */ -#define AID_GRAPHICS 1003 /* graphics devices */ -#define AID_INPUT 1004 /* input devices */ -#define AID_AUDIO 1005 /* audio devices */ -#define AID_CAMERA 1006 /* camera devices */ -#define AID_LOG 1007 /* log devices */ -#define AID_COMPASS 1008 /* compass device */ -#define AID_MOUNT 1009 /* mountd socket */ -#define AID_WIFI 1010 /* wifi subsystem */ -#define AID_ADB 1011 /* android debug bridge (adbd) */ -#define AID_INSTALL 1012 /* group for installing packages */ -#define AID_MEDIA 1013 /* mediaserver process */ -#define AID_DHCP 1014 /* dhcp client */ -#define AID_SDCARD_RW 1015 /* external storage write access */ -#define AID_VPN 1016 /* vpn system */ -#define AID_KEYSTORE 1017 /* keystore subsystem */ -#define AID_USB 1018 /* USB devices */ -#define AID_DRM 1019 /* DRM server */ -#define AID_MDNSR 1020 /* MulticastDNSResponder (service discovery) */ -#define AID_GPS 1021 /* GPS daemon */ -#define AID_UNUSED1 1022 /* deprecated, DO NOT USE */ -#define AID_MEDIA_RW 1023 /* internal media storage write access */ -#define AID_MTP 1024 /* MTP USB driver access */ -#define AID_UNUSED2 1025 /* deprecated, DO NOT USE */ -#define AID_DRMRPC 1026 /* group for drm rpc */ -#define AID_NFC 1027 /* nfc subsystem */ -#define AID_SDCARD_R 1028 /* external storage read access */ -#define AID_CLAT 1029 /* clat part of nat464 */ -#define AID_LOOP_RADIO 1030 /* loop radio devices */ -#define AID_MEDIA_DRM 1031 /* MediaDrm plugins */ -#define AID_PACKAGE_INFO 1032 /* access to installed package details */ -#define AID_SDCARD_PICS 1033 /* external storage photos access */ -#define AID_SDCARD_AV 1034 /* external storage audio/video access */ -#define AID_SDCARD_ALL 1035 /* access all users external storage */ -#define AID_LOGD 1036 /* log daemon */ -#define AID_SHARED_RELRO 1037 /* creator of shared GNU RELRO files */ -#define AID_DBUS 1038 /* dbus-daemon IPC broker process */ -#define AID_TLSDATE 1039 /* tlsdate unprivileged user */ -#define AID_MEDIA_EX 1040 /* mediaextractor process */ -#define AID_AUDIOSERVER 1041 /* audioserver process */ -#define AID_METRICS_COLL 1042 /* metrics_collector process */ -#define AID_METRICSD 1043 /* metricsd process */ -#define AID_WEBSERV 1044 /* webservd process */ -#define AID_DEBUGGERD 1045 /* debuggerd unprivileged user */ -#define AID_MEDIA_CODEC 1046 /* mediacodec process */ -#define AID_CAMERASERVER 1047 /* cameraserver process */ -#define AID_FIREWALL 1048 /* firewalld process */ -#define AID_TRUNKS 1049 /* trunksd process (TPM daemon) */ -#define AID_NVRAM 1050 /* Access-controlled NVRAM */ -#define AID_DNS 1051 /* DNS resolution daemon (system: netd) */ -#define AID_DNS_TETHER 1052 /* DNS resolution daemon (tether: dnsmasq) */ +#define AID_ROOT 0 /* traditional unix root user */ +/* The following are for LTP and should only be used for testing */ +#define AID_DAEMON 1 /* traditional unix daemon owner */ +#define AID_BIN 2 /* traditional unix binaries owner */ + +#define AID_SYSTEM 1000 /* system server */ + +#define AID_RADIO 1001 /* telephony subsystem, RIL */ +#define AID_BLUETOOTH 1002 /* bluetooth subsystem */ +#define AID_GRAPHICS 1003 /* graphics devices */ +#define AID_INPUT 1004 /* input devices */ +#define AID_AUDIO 1005 /* audio devices */ +#define AID_CAMERA 1006 /* camera devices */ +#define AID_LOG 1007 /* log devices */ +#define AID_COMPASS 1008 /* compass device */ +#define AID_MOUNT 1009 /* mountd socket */ +#define AID_WIFI 1010 /* wifi subsystem */ +#define AID_ADB 1011 /* android debug bridge (adbd) */ +#define AID_INSTALL 1012 /* group for installing packages */ +#define AID_MEDIA 1013 /* mediaserver process */ +#define AID_DHCP 1014 /* dhcp client */ +#define AID_SDCARD_RW 1015 /* external storage write access */ +#define AID_VPN 1016 /* vpn system */ +#define AID_KEYSTORE 1017 /* keystore subsystem */ +#define AID_USB 1018 /* USB devices */ +#define AID_DRM 1019 /* DRM server */ +#define AID_MDNSR 1020 /* MulticastDNSResponder (service discovery) */ +#define AID_GPS 1021 /* GPS daemon */ +#define AID_UNUSED1 1022 /* deprecated, DO NOT USE */ +#define AID_MEDIA_RW 1023 /* internal media storage write access */ +#define AID_MTP 1024 /* MTP USB driver access */ +#define AID_UNUSED2 1025 /* deprecated, DO NOT USE */ +#define AID_DRMRPC 1026 /* group for drm rpc */ +#define AID_NFC 1027 /* nfc subsystem */ +#define AID_SDCARD_R 1028 /* external storage read access */ +#define AID_CLAT 1029 /* clat part of nat464 */ +#define AID_LOOP_RADIO 1030 /* loop radio devices */ +#define AID_MEDIA_DRM 1031 /* MediaDrm plugins */ +#define AID_PACKAGE_INFO 1032 /* access to installed package details */ +#define AID_SDCARD_PICS 1033 /* external storage photos access */ +#define AID_SDCARD_AV 1034 /* external storage audio/video access */ +#define AID_SDCARD_ALL 1035 /* access all users external storage */ +#define AID_LOGD 1036 /* log daemon */ +#define AID_SHARED_RELRO 1037 /* creator of shared GNU RELRO files */ +#define AID_DBUS 1038 /* dbus-daemon IPC broker process */ +#define AID_TLSDATE 1039 /* tlsdate unprivileged user */ +#define AID_MEDIA_EX 1040 /* mediaextractor process */ +#define AID_AUDIOSERVER 1041 /* audioserver process */ +#define AID_METRICS_COLL 1042 /* metrics_collector process */ +#define AID_METRICSD 1043 /* metricsd process */ +#define AID_WEBSERV 1044 /* webservd process */ +#define AID_DEBUGGERD 1045 /* debuggerd unprivileged user */ +#define AID_MEDIA_CODEC 1046 /* mediacodec process */ +#define AID_CAMERASERVER 1047 /* cameraserver process */ +#define AID_FIREWALL 1048 /* firewalld process */ +#define AID_TRUNKS 1049 /* trunksd process (TPM daemon) */ +#define AID_NVRAM 1050 /* Access-controlled NVRAM */ +#define AID_DNS 1051 /* DNS resolution daemon (system: netd) */ +#define AID_DNS_TETHER 1052 /* DNS resolution daemon (tether: dnsmasq) */ +#define AID_WEBVIEW_ZYGOTE 1053 /* WebView zygote process */ +#define AID_VEHICLE_NETWORK 1054 /* Vehicle network service */ +#define AID_MEDIA_AUDIO 1055 /* GID for audio files on internal media storage */ +#define AID_MEDIA_VIDEO 1056 /* GID for video files on internal media storage */ +#define AID_MEDIA_IMAGE 1057 /* GID for image files on internal media storage */ +#define AID_TOMBSTONED 1058 /* tombstoned user */ +#define AID_MEDIA_OBB 1059 /* GID for OBB files on internal media storage */ +#define AID_ESE 1060 /* embedded secure element (eSE) subsystem */ +#define AID_OTA_UPDATE 1061 /* resource tracking UID for OTA updates */ +#define AID_AUTOMOTIVE_EVS 1062 /* Automotive rear and surround view system */ +#define AID_LOWPAN 1063 /* LoWPAN subsystem */ +#define AID_HSM 1064 /* hardware security module subsystem */ +#define AID_RESERVED_DISK 1065 /* GID that has access to reserved disk space */ +#define AID_STATSD 1066 /* statsd daemon */ +#define AID_INCIDENTD 1067 /* incidentd daemon */ +#define AID_SECURE_ELEMENT 1068 /* secure element subsystem */ /* Changes to this file must be made in AOSP, *not* in internal branches. */ -#define AID_SHELL 2000 /* adb and debug shell user */ -#define AID_CACHE 2001 /* cache access */ -#define AID_DIAG 2002 /* access to diagnostic resources */ +#define AID_SHELL 2000 /* adb and debug shell user */ +#define AID_CACHE 2001 /* cache access */ +#define AID_DIAG 2002 /* access to diagnostic resources */ /* The range 2900-2999 is reserved for OEM, and must never be * used here */ #define AID_OEM_RESERVED_START 2900 - -#define AID_QCOM_DIAG 2950 /* access to QTI diagnostic resources */ -#define AID_RFS 2951 /* Remote Filesystem for peripheral processors */ -#define AID_RFS_SHARED 2952 /* Shared files for Remote Filesystem for peripheral processors */ - -#define AID_OEM_RESERVED_END 2999 +#define AID_OEM_RESERVED_END 2999 /* The 3000 series are intended for use as supplemental group id's only. * They indicate special Android capabilities that the kernel is aware of. */ -#define AID_NET_BT_ADMIN 3001 /* bluetooth: create any socket */ -#define AID_NET_BT 3002 /* bluetooth: create sco, rfcomm or l2cap sockets */ -#define AID_INET 3003 /* can create AF_INET and AF_INET6 sockets */ -#define AID_NET_RAW 3004 /* can create raw INET sockets */ -#define AID_NET_ADMIN 3005 /* can configure interfaces and routing tables. */ -#define AID_NET_BW_STATS 3006 /* read bandwidth statistics */ -#define AID_NET_BW_ACCT 3007 /* change bandwidth statistics accounting */ -#define AID_NET_BT_STACK 3008 /* bluetooth: access config files */ -#define AID_READPROC 3009 /* Allow /proc read access */ -#define AID_WAKELOCK 3010 /* Allow system wakelock read/write access */ - -#define AID_RFS_OLD 3012 /* DEPRECATED OLD ID FOR RFS, DO NOT USE */ -#define AID_RFS_SHARED_OLD 3013 /* DEPRECATED OLD ID FOR RFS-SHARED */ +#define AID_NET_BT_ADMIN 3001 /* bluetooth: create any socket */ +#define AID_NET_BT 3002 /* bluetooth: create sco, rfcomm or l2cap sockets */ +#define AID_INET 3003 /* can create AF_INET and AF_INET6 sockets */ +#define AID_NET_RAW 3004 /* can create raw INET sockets */ +#define AID_NET_ADMIN 3005 /* can configure interfaces and routing tables. */ +#define AID_NET_BW_STATS 3006 /* read bandwidth statistics */ +#define AID_NET_BW_ACCT 3007 /* change bandwidth statistics accounting */ +#define AID_READPROC 3009 /* Allow /proc read access */ +#define AID_WAKELOCK 3010 /* Allow system wakelock read/write access */ +#define AID_UHID 3011 /* Allow read/write to /dev/uhid node */ /* The range 5000-5999 is also reserved for OEM, and must never be used here. */ #define AID_OEM_RESERVED_2_START 5000 -#define AID_OEM_RESERVED_2_END 5999 -#define AID_SENSORS 3011 /* access to /dev/socket/sensor_ctl_socket & QCCI/QCSI */ +#define AID_OEM_RESERVED_2_END 5999 +#define AID_EVERYBODY 9997 /* shared between all apps in the same profile */ +#define AID_MISC 9998 /* access to misc storage */ +#define AID_NOBODY 9999 -#define AID_EVERYBODY 9997 /* shared between all apps in the same profile */ -#define AID_MISC 9998 /* access to misc storage */ -#define AID_NOBODY 9999 +#define AID_APP 10000 /* TODO: switch users over to AID_APP_START */ +#define AID_APP_START 10000 /* first app user */ +#define AID_APP_END 19999 /* last app user */ -#define AID_APP 10000 /* first app user */ +#define AID_CACHE_GID_START 20000 /* start of gids for apps to mark cached data */ +#define AID_CACHE_GID_END 29999 /* end of gids for apps to mark cached data */ -#define AID_ISOLATED_START 99000 /* start of uids for fully isolated sandboxed processes */ -#define AID_ISOLATED_END 99999 /* end of uids for fully isolated sandboxed processes */ +#define AID_EXT_GID_START 30000 /* start of gids for apps to mark external data */ +#define AID_EXT_GID_END 39999 /* end of gids for apps to mark external data */ -#define AID_USER 100000 /* offset for uid ranges for each user */ +#define AID_EXT_CACHE_GID_START 40000 /* start of gids for apps to mark external cached data */ +#define AID_EXT_CACHE_GID_END 49999 /* end of gids for apps to mark external cached data */ #define AID_SHARED_GID_START 50000 /* start of gids for apps in each user to share */ -#define AID_SHARED_GID_END 59999 /* start of gids for apps in each user to share */ +#define AID_SHARED_GID_END 59999 /* end of gids for apps in each user to share */ -#if !defined(EXCLUDE_FS_CONFIG_STRUCTURES) /* - * Used in: - * bionic/libc/bionic/stubs.cpp - * external/libselinux/src/android.c - * system/core/logd/LogStatistics.cpp - * system/core/init/ueventd.cpp - * system/core/init/util.cpp + * This is a magic number in the kernel and not something that was picked + * arbitrarily. This value is returned whenever a uid that has no mapping in the + * user namespace is returned to userspace: + * https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/highuid.h?h=v4.4#n40 */ -struct android_id_info { - const char *name; - unsigned aid; -}; - -static const struct android_id_info android_ids[] = { - { "root", AID_ROOT, }, - - { "system", AID_SYSTEM, }, +#define AID_OVERFLOWUID 65534 /* unmapped user in the user namespace */ - { "radio", AID_RADIO, }, - { "bluetooth", AID_BLUETOOTH, }, - { "graphics", AID_GRAPHICS, }, - { "input", AID_INPUT, }, - { "audio", AID_AUDIO, }, - { "camera", AID_CAMERA, }, - { "log", AID_LOG, }, - { "compass", AID_COMPASS, }, - { "mount", AID_MOUNT, }, - { "wifi", AID_WIFI, }, - { "adb", AID_ADB, }, - { "install", AID_INSTALL, }, - { "media", AID_MEDIA, }, - { "dhcp", AID_DHCP, }, - { "sdcard_rw", AID_SDCARD_RW, }, - { "vpn", AID_VPN, }, - { "keystore", AID_KEYSTORE, }, - { "usb", AID_USB, }, - { "drm", AID_DRM, }, - { "mdnsr", AID_MDNSR, }, - { "gps", AID_GPS, }, - // AID_UNUSED1 - { "media_rw", AID_MEDIA_RW, }, - { "mtp", AID_MTP, }, - // AID_UNUSED2 - { "drmrpc", AID_DRMRPC, }, - { "nfc", AID_NFC, }, - { "sdcard_r", AID_SDCARD_R, }, - { "clat", AID_CLAT, }, - { "loop_radio", AID_LOOP_RADIO, }, - { "mediadrm", AID_MEDIA_DRM, }, - { "package_info", AID_PACKAGE_INFO, }, - { "sdcard_pics", AID_SDCARD_PICS, }, - { "sdcard_av", AID_SDCARD_AV, }, - { "sdcard_all", AID_SDCARD_ALL, }, - { "logd", AID_LOGD, }, - { "shared_relro", AID_SHARED_RELRO, }, - { "dbus", AID_DBUS, }, - { "tlsdate", AID_TLSDATE, }, - { "mediaex", AID_MEDIA_EX, }, - { "audioserver", AID_AUDIOSERVER, }, - { "metrics_coll", AID_METRICS_COLL }, - { "metricsd", AID_METRICSD }, - { "webserv", AID_WEBSERV }, - { "debuggerd", AID_DEBUGGERD, }, - { "mediacodec", AID_MEDIA_CODEC, }, - { "cameraserver", AID_CAMERASERVER, }, - { "firewall", AID_FIREWALL, }, - { "trunks", AID_TRUNKS, }, - { "nvram", AID_NVRAM, }, - { "dns", AID_DNS, }, - { "dns_tether", AID_DNS_TETHER, }, - - { "shell", AID_SHELL, }, - { "cache", AID_CACHE, }, - { "diag", AID_DIAG, }, - - { "qcom_diag", AID_QCOM_DIAG, }, - - { "rfs", AID_RFS, }, - { "rfs_shared", AID_RFS_SHARED, }, - - { "net_bt_admin", AID_NET_BT_ADMIN, }, - { "net_bt", AID_NET_BT, }, - { "inet", AID_INET, }, - { "net_raw", AID_NET_RAW, }, - { "net_admin", AID_NET_ADMIN, }, - { "net_bw_stats", AID_NET_BW_STATS, }, - { "net_bw_acct", AID_NET_BW_ACCT, }, - { "net_bt_stack", AID_NET_BT_STACK, }, - { "readproc", AID_READPROC, }, - { "wakelock", AID_WAKELOCK, }, - { "sensors", AID_SENSORS, }, - - { "rfs_old", AID_RFS_OLD, }, - { "rfs_shared_old", AID_RFS_SHARED_OLD, }, - - { "everybody", AID_EVERYBODY, }, - { "misc", AID_MISC, }, - { "nobody", AID_NOBODY, }, -}; - -#define android_id_count \ - (sizeof(android_ids) / sizeof(android_ids[0])) - -struct fs_path_config { - unsigned mode; - unsigned uid; - unsigned gid; - uint64_t capabilities; - const char *prefix; -}; - -/* Rules for directories and files has moved to system/code/libcutils/fs_config.c */ +#define AID_ISOLATED_START 99000 /* start of uids for fully isolated sandboxed processes */ +#define AID_ISOLATED_END 99999 /* end of uids for fully isolated sandboxed processes */ -__BEGIN_DECLS +#define AID_USER 100000 /* TODO: switch users over to AID_USER_OFFSET */ +#define AID_USER_OFFSET 100000 /* offset for uid ranges for each user */ /* - * Used in: - * build/tools/fs_config/fs_config.c - * build/tools/fs_get_stats/fs_get_stats.c - * system/extras/ext4_utils/make_ext4fs_main.c - * external/squashfs-tools/squashfs-tools/android.c - * system/core/cpio/mkbootfs.c - * system/core/adb/file_sync_service.cpp - * system/extras/ext4_utils/canned_fs_config.c + * android_ids has moved to pwd/grp functionality. + * If you need to add one, the structure is now + * auto-generated based on the AID_ constraints + * documented at the top of this header file. + * Also see build/tools/fs_config for more details. */ -void fs_config(const char *path, int dir, const char *target_out_path, - unsigned *uid, unsigned *gid, unsigned *mode, uint64_t *capabilities); -ssize_t fs_config_generate(char *buffer, size_t length, const struct fs_path_config *pc); - -__END_DECLS - -#endif #endif diff --git a/private/bionic_arc4random.h b/private/bionic_arc4random.h new file mode 100644 index 0000000..0e9376e --- /dev/null +++ b/private/bionic_arc4random.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _PRIVATE_BIONIC_ARC4RANDOM_H_ +#define _PRIVATE_BIONIC_ARC4RANDOM_H_ + +#include + +#include "private/KernelArgumentBlock.h" + +// arc4random(3) aborts if it's unable to fetch entropy, which is always +// the case for init on devices. GCE kernels have a workaround to ensure +// sufficient entropy during early boot, but no device kernels do. This +// wrapper falls back to AT_RANDOM if the kernel doesn't have enough +// entropy for getrandom(2) or /dev/urandom. +void __libc_safe_arc4random_buf(void* buf, size_t n, KernelArgumentBlock& args); + +#endif diff --git a/private/bionic_asm.h b/private/bionic_asm.h new file mode 100644 index 0000000..30842f4 --- /dev/null +++ b/private/bionic_asm.h @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _PRIVATE_BIONIC_ASM_H_ +#define _PRIVATE_BIONIC_ASM_H_ + +#include /* For system call numbers. */ +#define MAX_ERRNO 4095 /* For recognizing system call error returns. */ + +#define __bionic_asm_custom_entry(f) +#define __bionic_asm_custom_end(f) +#define __bionic_asm_function_type @function + +#if defined(__aarch64__) +#include +#elif defined(__arm__) +#include +#elif defined(__i386__) +#include +#elif defined(__mips__) +#include +#elif defined(__x86_64__) +#include +#endif + +#define ENTRY_NO_DWARF(f) \ + .text; \ + .globl f; \ + .balign __bionic_asm_align; \ + .type f, __bionic_asm_function_type; \ + f: \ + __bionic_asm_custom_entry(f); \ + +#define ENTRY(f) \ + ENTRY_NO_DWARF(f) \ + .cfi_startproc \ + +#define END_NO_DWARF(f) \ + .size f, .-f; \ + __bionic_asm_custom_end(f) \ + +#define END(f) \ + .cfi_endproc; \ + END_NO_DWARF(f) \ + +/* Like ENTRY, but with hidden visibility. */ +#define ENTRY_PRIVATE(f) \ + ENTRY(f); \ + .hidden f \ + +/* Like ENTRY_NO_DWARF, but with hidden visibility. */ +#define ENTRY_PRIVATE_NO_DWARF(f) \ + ENTRY_NO_DWARF(f); \ + .hidden f \ + +#define __BIONIC_WEAK_ASM_FOR_NATIVE_BRIDGE(f) \ + .weak f; \ + +#define ALIAS_SYMBOL(alias, original) \ + .globl alias; \ + .equ alias, original + +#endif diff --git a/private/bionic_asm_arm.h b/private/bionic_asm_arm.h new file mode 100644 index 0000000..d8381d3 --- /dev/null +++ b/private/bionic_asm_arm.h @@ -0,0 +1,48 @@ +/* $OpenBSD: asm.h,v 1.1 2004/02/01 05:09:49 drahn Exp $ */ +/* $NetBSD: asm.h,v 1.4 2001/07/16 05:43:32 matt Exp $ */ + +/* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)asm.h 5.5 (Berkeley) 5/7/91 + */ + +#pragma once + +#define __bionic_asm_align 0 + +#undef __bionic_asm_custom_entry +#undef __bionic_asm_custom_end +#define __bionic_asm_custom_entry(f) .fnstart +#define __bionic_asm_custom_end(f) .fnend + +#undef __bionic_asm_function_type +#define __bionic_asm_function_type #function diff --git a/private/bionic_asm_arm64.h b/private/bionic_asm_arm64.h new file mode 100644 index 0000000..43ecaf3 --- /dev/null +++ b/private/bionic_asm_arm64.h @@ -0,0 +1,43 @@ +/* $OpenBSD: asm.h,v 1.1 2004/02/01 05:09:49 drahn Exp $ */ +/* $NetBSD: asm.h,v 1.4 2001/07/16 05:43:32 matt Exp $ */ + +/* + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)asm.h 5.5 (Berkeley) 5/7/91 + */ + +#pragma once + +#define __bionic_asm_align 0 + +#undef __bionic_asm_function_type +#define __bionic_asm_function_type %function diff --git a/private/bionic_asm_mips.h b/private/bionic_asm_mips.h new file mode 100644 index 0000000..99dcfb1 --- /dev/null +++ b/private/bionic_asm_mips.h @@ -0,0 +1,187 @@ +/* $OpenBSD: asm.h,v 1.7 2004/10/20 12:49:15 pefo Exp $ */ + +/* + * Copyright (c) 2001-2002 Opsycon AB (www.opsycon.se / www.opsycon.com) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#pragma once + +#define __bionic_asm_align 16 + +#undef __bionic_asm_custom_entry +#undef __bionic_asm_custom_end +#define __bionic_asm_custom_entry(f) .ent f +#define __bionic_asm_custom_end(f) .end f + +#define _MIPS_ISA_MIPS1 1 /* R2000/R3000 */ +#define _MIPS_ISA_MIPS2 2 /* R4000/R6000 */ +#define _MIPS_ISA_MIPS3 3 /* R4000 */ +#define _MIPS_ISA_MIPS4 4 /* TFP (R1x000) */ +#define _MIPS_ISA_MIPS5 5 +#define _MIPS_ISA_MIPS32 6 +#define _MIPS_ISA_MIPS64 7 + +#if !defined(ABICALLS) && !defined(_NO_ABICALLS) +#define ABICALLS .abicalls +#endif + +#if defined(ABICALLS) && !defined(_KERNEL) + ABICALLS +#endif + +/* + * Define how to access unaligned data word + */ +#define LWLO lwl +#define LWHI lwr +#define SWLO swl +#define SWHI swr +#define LDLO ldl +#define LDHI ldr +#define SDLO sdl +#define SDHI sdr + +/* + * Define programming environment for ABI. + */ +#if defined(ABICALLS) && !defined(_KERNEL) && !defined(_STANDALONE) + +#if (_MIPS_SIM == _ABIO32) || (_MIPS_SIM == _ABI32) +#define NARGSAVE 4 + +#define SETUP_GP \ + .set noreorder; \ + .cpload $t9; \ + .set reorder; + +#define SAVE_GP(x) \ + .cprestore x + +#define SETUP_GP64(gpoff, name) +#define RESTORE_GP64 +#endif + +#if (_MIPS_SIM == _ABI64) || (_MIPS_SIM == _ABIN32) +#define NARGSAVE 0 + +#define SETUP_GP +#define SAVE_GP(x) +#define SETUP_GP64(gpoff, name) \ + .cpsetup $t9, gpoff, name +#define RESTORE_GP64 \ + .cpreturn +#endif + +#define MKFSIZ(narg,locals) (((narg+locals)*REGSZ+31)&(~31)) + +#else /* defined(ABICALLS) && !defined(_KERNEL) */ + +#define NARGSAVE 4 +#define SETUP_GP +#define SAVE_GP(x) + +#define ALIGNSZ 16 /* Stack layout alignment */ +#define FRAMESZ(sz) (((sz) + (ALIGNSZ-1)) & ~(ALIGNSZ-1)) + +#endif + +/* + * Basic register operations based on selected ISA + */ +#if (_MIPS_ISA == _MIPS_ISA_MIPS1 || _MIPS_ISA == _MIPS_ISA_MIPS2 || _MIPS_ISA == _MIPS_ISA_MIPS32) +#define REGSZ 4 /* 32 bit mode register size */ +#define LOGREGSZ 2 /* log rsize */ +#define REG_S sw +#define REG_L lw +#define CF_SZ 24 /* Call frame size */ +#define CF_ARGSZ 16 /* Call frame arg size */ +#define CF_RA_OFFS 20 /* Call ra save offset */ +#endif + +#if (_MIPS_ISA == _MIPS_ISA_MIPS3 || _MIPS_ISA == _MIPS_ISA_MIPS4 || _MIPS_ISA == _MIPS_ISA_MIPS64) +#define REGSZ 8 /* 64 bit mode register size */ +#define LOGREGSZ 3 /* log rsize */ +#define REG_S sd +#define REG_L ld +#define CF_SZ 48 /* Call frame size (multiple of ALIGNSZ) */ +#define CF_ARGSZ 32 /* Call frame arg size */ +#define CF_RA_OFFS 40 /* Call ra save offset */ +#endif + +#define REGSZ_FP 8 /* 64 bit FP register size */ + +#ifndef __LP64__ +#define PTR_L lw +#define PTR_S sw +#define PTR_SUB sub +#define PTR_ADD add +#define PTR_SUBU subu +#define PTR_ADDU addu +#define LI li +#define LA la +#define PTR_SLL sll +#define PTR_SRL srl +#define PTR_VAL .word +#else +#define PTR_L ld +#define PTR_S sd +#define PTR_ADD dadd +#define PTR_SUB dsub +#define PTR_SUBU dsubu +#define PTR_ADDU daddu +#define LI dli +#define LA dla +#define PTR_SLL dsll +#define PTR_SRL dsrl +#define PTR_VAL .dword +#endif + +/* + * LEAF(x, fsize) + * + * Declare a leaf routine. + */ +#define LEAF(x, fsize) \ + .align 3; \ + .globl x; \ + .ent x, 0; \ +x: ; \ + .cfi_startproc; \ + .frame $sp, fsize, $ra; \ + SETUP_GP \ + +/* + * NON_LEAF(x) + * + * Declare a non-leaf routine (a routine that makes other C calls). + */ +#define NON_LEAF(x, fsize, retpc) \ + .align 3; \ + .globl x; \ + .ent x, 0; \ +x: ; \ + .cfi_startproc; \ + .frame $sp, fsize, retpc; \ + SETUP_GP \ diff --git a/private/bionic_asm_x86.h b/private/bionic_asm_x86.h new file mode 100644 index 0000000..fcec40b --- /dev/null +++ b/private/bionic_asm_x86.h @@ -0,0 +1,51 @@ +/* $NetBSD: asm.h,v 1.40 2011/06/16 13:16:20 joerg Exp $ */ + +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)asm.h 5.5 (Berkeley) 5/7/91 + */ + +#pragma once + +#define PIC_PROLOGUE \ + pushl %ebx; \ + call 666f; \ +666: \ + popl %ebx; \ + addl $_GLOBAL_OFFSET_TABLE_+[.-666b], %ebx +#define PIC_EPILOGUE \ + popl %ebx +#define PIC_PLT(x) x@PLT +#define PIC_GOT(x) x@GOT(%ebx) +#define PIC_GOTOFF(x) x@GOTOFF(%ebx) + +#define __bionic_asm_align 16 diff --git a/private/bionic_asm_x86_64.h b/private/bionic_asm_x86_64.h new file mode 100644 index 0000000..c553b0c --- /dev/null +++ b/private/bionic_asm_x86_64.h @@ -0,0 +1,42 @@ +/* $NetBSD: asm.h,v 1.18 2013/09/12 15:36:17 joerg Exp $ */ + +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)asm.h 5.5 (Berkeley) 5/7/91 + */ + +#pragma once + +#define PIC_PLT(x) x@PLT +#define PIC_GOT(x) x@GOTPCREL(%rip) + +#define __bionic_asm_align 16 diff --git a/private/bionic_auxv.h b/private/bionic_auxv.h new file mode 100644 index 0000000..53fcc49 --- /dev/null +++ b/private/bionic_auxv.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +#ifndef _PRIVATE_BIONIC_AUXV_H_ +#define _PRIVATE_BIONIC_AUXV_H_ + +#include +#include +#include + +__BEGIN_DECLS + +extern ElfW(auxv_t)* __libc_auxv; + +__END_DECLS + +#endif /* _PRIVATE_BIONIC_AUXV_H_ */ diff --git a/libnfc-nxp/phLibNfc_discovery.h b/private/bionic_config.h similarity index 59% rename from libnfc-nxp/phLibNfc_discovery.h rename to private/bionic_config.h index a825413..0c9811c 100644 --- a/libnfc-nxp/phLibNfc_discovery.h +++ b/private/bionic_config.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 NXP Semiconductors + * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,26 +14,13 @@ * limitations under the License. */ -/*! - * \file phLibNfc_1.1.h - * - * Project: NFC-FRI 1.1 - * - * $Workfile:: phLibNfc_1.1.h $ - * $Modtime:: $ - * $Author: ing07299 $ - * $Revision: 1.9 $ - * - */ -#ifndef PHLIBNFC_DISCOVERY_H -#define PHLIBNFC_DISCOVERY_H - - - -extern void -phLibNfc_config_discovery_cb(void *context, - NFCSTATUS status - ); +#ifndef _BIONIC_CONFIG_H_ +#define _BIONIC_CONFIG_H_ +// valloc(3) and pvalloc(3) were removed from POSIX 2004. We do not include them +// for LP64, but the symbols remain in LP32 for binary compatibility. +#if !defined(__LP64__) +#define HAVE_DEPRECATED_MALLOC_FUNCS 1 #endif +#endif // _BIONIC_CONFIG_H_ diff --git a/private/bionic_constants.h b/private/bionic_constants.h new file mode 100644 index 0000000..9ae1c8d --- /dev/null +++ b/private/bionic_constants.h @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _BIONIC_CONSTANTS_H_ +#define _BIONIC_CONSTANTS_H_ + +#define NS_PER_S 1000000000 + +#endif // _BIONIC_CONSTANTS_H_ diff --git a/private/bionic_ctype.h b/private/bionic_ctype.h new file mode 100644 index 0000000..96df974 --- /dev/null +++ b/private/bionic_ctype.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef __BIONIC_PRIVATE_BIONIC_CTYPE_H_ +#define __BIONIC_PRIVATE_BIONIC_CTYPE_H_ + +static inline bool IsAlpha(int ch) { + return (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z'); +} + +static inline bool IsDigit(int ch) { + return (ch >= '0' && ch <= '9'); +} + +static inline bool IsSpace(int ch) { + return (ch == ' ') || (ch >= '\t' && ch <= '\r'); +} + +static inline bool IsUpper(int ch) { + return (ch >= 'A' && ch <= 'Z'); +} + +static inline bool IsXDigit(int ch) { + return (ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'F') || (ch >= 'a' && ch <= 'f'); +} + +#endif diff --git a/private/bionic_defs.h b/private/bionic_defs.h new file mode 100644 index 0000000..1d4f86b --- /dev/null +++ b/private/bionic_defs.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef __BIONIC_PRIVATE_BIONIC_DEFS_H_ +#define __BIONIC_PRIVATE_BIONIC_DEFS_H_ + +/* + * This label is used to mark libc/libdl symbols that may need to be replaced + * by native bridge implementation. + */ +#define __BIONIC_WEAK_FOR_NATIVE_BRIDGE __attribute__((__weak__, __noinline__)) +#define __BIONIC_WEAK_VARIABLE_FOR_NATIVE_BRIDGE __attribute__((__weak__)) + +#endif /* __BIONIC_PRIVATE_BIONIC_DEFS_H_ */ diff --git a/private/bionic_errdefs.h b/private/bionic_errdefs.h new file mode 100644 index 0000000..3c3c9d7 --- /dev/null +++ b/private/bionic_errdefs.h @@ -0,0 +1,170 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* the following corresponds to the error codes of the Linux kernel used by the Android platform + * these are distinct from the OpenBSD ones, which is why we need to redeclare them here + * + * this file may be included several times to define either error constants or their + * string representation + */ + +#ifndef __BIONIC_ERRDEF +#error "__BIONIC_ERRDEF must be defined before including this file" +#endif +__BIONIC_ERRDEF( 0 , 0, "Success" ) +__BIONIC_ERRDEF( EPERM , 1, "Operation not permitted" ) +__BIONIC_ERRDEF( ENOENT , 2, "No such file or directory" ) +__BIONIC_ERRDEF( ESRCH , 3, "No such process" ) +__BIONIC_ERRDEF( EINTR , 4, "Interrupted system call" ) +__BIONIC_ERRDEF( EIO , 5, "I/O error" ) +__BIONIC_ERRDEF( ENXIO , 6, "No such device or address" ) +__BIONIC_ERRDEF( E2BIG , 7, "Argument list too long" ) +__BIONIC_ERRDEF( ENOEXEC , 8, "Exec format error" ) +__BIONIC_ERRDEF( EBADF , 9, "Bad file descriptor" ) +__BIONIC_ERRDEF( ECHILD , 10, "No child processes" ) +__BIONIC_ERRDEF( EAGAIN , 11, "Try again" ) +__BIONIC_ERRDEF( ENOMEM , 12, "Out of memory" ) +__BIONIC_ERRDEF( EACCES , 13, "Permission denied" ) +__BIONIC_ERRDEF( EFAULT , 14, "Bad address" ) +__BIONIC_ERRDEF( ENOTBLK , 15, "Block device required" ) +__BIONIC_ERRDEF( EBUSY , 16, "Device or resource busy" ) +__BIONIC_ERRDEF( EEXIST , 17, "File exists" ) +__BIONIC_ERRDEF( EXDEV , 18, "Cross-device link" ) +__BIONIC_ERRDEF( ENODEV , 19, "No such device" ) +__BIONIC_ERRDEF( ENOTDIR , 20, "Not a directory" ) +__BIONIC_ERRDEF( EISDIR , 21, "Is a directory" ) +__BIONIC_ERRDEF( EINVAL , 22, "Invalid argument" ) +__BIONIC_ERRDEF( ENFILE , 23, "File table overflow" ) +__BIONIC_ERRDEF( EMFILE , 24, "Too many open files" ) +__BIONIC_ERRDEF( ENOTTY , 25, "Not a typewriter" ) +__BIONIC_ERRDEF( ETXTBSY , 26, "Text file busy" ) +__BIONIC_ERRDEF( EFBIG , 27, "File too large" ) +__BIONIC_ERRDEF( ENOSPC , 28, "No space left on device" ) +__BIONIC_ERRDEF( ESPIPE , 29, "Illegal seek" ) +__BIONIC_ERRDEF( EROFS , 30, "Read-only file system" ) +__BIONIC_ERRDEF( EMLINK , 31, "Too many links" ) +__BIONIC_ERRDEF( EPIPE , 32, "Broken pipe" ) +__BIONIC_ERRDEF( EDOM , 33, "Math argument out of domain of func" ) +__BIONIC_ERRDEF( ERANGE , 34, "Math result not representable" ) +__BIONIC_ERRDEF( EDEADLK , 35, "Resource deadlock would occur" ) +__BIONIC_ERRDEF( ENAMETOOLONG , 36, "File name too long" ) +__BIONIC_ERRDEF( ENOLCK , 37, "No record locks available" ) +__BIONIC_ERRDEF( ENOSYS , 38, "Function not implemented" ) +__BIONIC_ERRDEF( ENOTEMPTY , 39, "Directory not empty" ) +__BIONIC_ERRDEF( ELOOP , 40, "Too many symbolic links encountered" ) +__BIONIC_ERRDEF( ENOMSG , 42, "No message of desired type" ) +__BIONIC_ERRDEF( EIDRM , 43, "Identifier removed" ) +__BIONIC_ERRDEF( ECHRNG , 44, "Channel number out of range" ) +__BIONIC_ERRDEF( EL2NSYNC , 45, "Level 2 not synchronized" ) +__BIONIC_ERRDEF( EL3HLT , 46, "Level 3 halted" ) +__BIONIC_ERRDEF( EL3RST , 47, "Level 3 reset" ) +__BIONIC_ERRDEF( ELNRNG , 48, "Link number out of range" ) +__BIONIC_ERRDEF( EUNATCH , 49, "Protocol driver not attached" ) +__BIONIC_ERRDEF( ENOCSI , 50, "No CSI structure available" ) +__BIONIC_ERRDEF( EL2HLT , 51, "Level 2 halted" ) +__BIONIC_ERRDEF( EBADE , 52, "Invalid exchange" ) +__BIONIC_ERRDEF( EBADR , 53, "Invalid request descriptor" ) +__BIONIC_ERRDEF( EXFULL , 54, "Exchange full" ) +__BIONIC_ERRDEF( ENOANO , 55, "No anode" ) +__BIONIC_ERRDEF( EBADRQC , 56, "Invalid request code" ) +__BIONIC_ERRDEF( EBADSLT , 57, "Invalid slot" ) +__BIONIC_ERRDEF( EBFONT , 59, "Bad font file format" ) +__BIONIC_ERRDEF( ENOSTR , 60, "Device not a stream" ) +__BIONIC_ERRDEF( ENODATA , 61, "No data available" ) +__BIONIC_ERRDEF( ETIME , 62, "Timer expired" ) +__BIONIC_ERRDEF( ENOSR , 63, "Out of streams resources" ) +__BIONIC_ERRDEF( ENONET , 64, "Machine is not on the network" ) +__BIONIC_ERRDEF( ENOPKG , 65, "Package not installed" ) +__BIONIC_ERRDEF( EREMOTE , 66, "Object is remote" ) +__BIONIC_ERRDEF( ENOLINK , 67, "Link has been severed" ) +__BIONIC_ERRDEF( EADV , 68, "Advertise error" ) +__BIONIC_ERRDEF( ESRMNT , 69, "Srmount error" ) +__BIONIC_ERRDEF( ECOMM , 70, "Communication error on send" ) +__BIONIC_ERRDEF( EPROTO , 71, "Protocol error" ) +__BIONIC_ERRDEF( EMULTIHOP , 72, "Multihop attempted" ) +__BIONIC_ERRDEF( EDOTDOT , 73, "RFS specific error" ) +__BIONIC_ERRDEF( EBADMSG , 74, "Not a data message" ) +__BIONIC_ERRDEF( EOVERFLOW , 75, "Value too large for defined data type" ) +__BIONIC_ERRDEF( ENOTUNIQ , 76, "Name not unique on network" ) +__BIONIC_ERRDEF( EBADFD , 77, "File descriptor in bad state" ) +__BIONIC_ERRDEF( EREMCHG , 78, "Remote address changed" ) +__BIONIC_ERRDEF( ELIBACC , 79, "Can not access a needed shared library" ) +__BIONIC_ERRDEF( ELIBBAD , 80, "Accessing a corrupted shared library" ) +__BIONIC_ERRDEF( ELIBSCN , 81, ".lib section in a.out corrupted" ) +__BIONIC_ERRDEF( ELIBMAX , 82, "Attempting to link in too many shared libraries" ) +__BIONIC_ERRDEF( ELIBEXEC , 83, "Cannot exec a shared library directly" ) +__BIONIC_ERRDEF( EILSEQ , 84, "Illegal byte sequence" ) +__BIONIC_ERRDEF( ERESTART , 85, "Interrupted system call should be restarted" ) +__BIONIC_ERRDEF( ESTRPIPE , 86, "Streams pipe error" ) +__BIONIC_ERRDEF( EUSERS , 87, "Too many users" ) +__BIONIC_ERRDEF( ENOTSOCK , 88, "Socket operation on non-socket" ) +__BIONIC_ERRDEF( EDESTADDRREQ , 89, "Destination address required" ) +__BIONIC_ERRDEF( EMSGSIZE , 90, "Message too long" ) +__BIONIC_ERRDEF( EPROTOTYPE , 91, "Protocol wrong type for socket" ) +__BIONIC_ERRDEF( ENOPROTOOPT , 92, "Protocol not available" ) +__BIONIC_ERRDEF( EPROTONOSUPPORT, 93, "Protocol not supported" ) +__BIONIC_ERRDEF( ESOCKTNOSUPPORT, 94, "Socket type not supported" ) +__BIONIC_ERRDEF( EOPNOTSUPP , 95, "Operation not supported on transport endpoint" ) +__BIONIC_ERRDEF( EPFNOSUPPORT , 96, "Protocol family not supported" ) +__BIONIC_ERRDEF( EAFNOSUPPORT , 97, "Address family not supported by protocol" ) +__BIONIC_ERRDEF( EADDRINUSE , 98, "Address already in use" ) +__BIONIC_ERRDEF( EADDRNOTAVAIL , 99, "Cannot assign requested address" ) +__BIONIC_ERRDEF( ENETDOWN , 100, "Network is down" ) +__BIONIC_ERRDEF( ENETUNREACH , 101, "Network is unreachable" ) +__BIONIC_ERRDEF( ENETRESET , 102, "Network dropped connection because of reset" ) +__BIONIC_ERRDEF( ECONNABORTED , 103, "Software caused connection abort" ) +__BIONIC_ERRDEF( ECONNRESET , 104, "Connection reset by peer" ) +__BIONIC_ERRDEF( ENOBUFS , 105, "No buffer space available" ) +__BIONIC_ERRDEF( EISCONN , 106, "Transport endpoint is already connected" ) +__BIONIC_ERRDEF( ENOTCONN , 107, "Transport endpoint is not connected" ) +__BIONIC_ERRDEF( ESHUTDOWN , 108, "Cannot send after transport endpoint shutdown" ) +__BIONIC_ERRDEF( ETOOMANYREFS , 109, "Too many references: cannot splice" ) +__BIONIC_ERRDEF( ETIMEDOUT , 110, "Connection timed out" ) +__BIONIC_ERRDEF( ECONNREFUSED , 111, "Connection refused" ) +__BIONIC_ERRDEF( EHOSTDOWN , 112, "Host is down" ) +__BIONIC_ERRDEF( EHOSTUNREACH , 113, "No route to host" ) +__BIONIC_ERRDEF( EALREADY , 114, "Operation already in progress" ) +__BIONIC_ERRDEF( EINPROGRESS , 115, "Operation now in progress" ) +__BIONIC_ERRDEF( ESTALE , 116, "Stale NFS file handle" ) +__BIONIC_ERRDEF( EUCLEAN , 117, "Structure needs cleaning" ) +__BIONIC_ERRDEF( ENOTNAM , 118, "Not a XENIX named type file" ) +__BIONIC_ERRDEF( ENAVAIL , 119, "No XENIX semaphores available" ) +__BIONIC_ERRDEF( EISNAM , 120, "Is a named type file" ) +__BIONIC_ERRDEF( EREMOTEIO , 121, "Remote I/O error" ) +__BIONIC_ERRDEF( EDQUOT , 122, "Quota exceeded" ) +__BIONIC_ERRDEF( ENOMEDIUM , 123, "No medium found" ) +__BIONIC_ERRDEF( EMEDIUMTYPE , 124, "Wrong medium type" ) +__BIONIC_ERRDEF( ECANCELED , 125, "Operation Canceled" ) +__BIONIC_ERRDEF( ENOKEY , 126, "Required key not available" ) +__BIONIC_ERRDEF( EKEYEXPIRED , 127, "Key has expired" ) +__BIONIC_ERRDEF( EKEYREVOKED , 128, "Key has been revoked" ) +__BIONIC_ERRDEF( EKEYREJECTED , 129, "Key was rejected by service" ) +__BIONIC_ERRDEF( EOWNERDEAD , 130, "Owner died" ) +__BIONIC_ERRDEF( ENOTRECOVERABLE, 131, "State not recoverable" ) + +#undef __BIONIC_ERRDEF diff --git a/private/bionic_fortify.h b/private/bionic_fortify.h new file mode 100644 index 0000000..7f22963 --- /dev/null +++ b/private/bionic_fortify.h @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#pragma once + +#include // For struct pollfd. +#include +#include +#include // For struct fd_set. + +#include + +static inline __noreturn void __fortify_fatal(const char* fmt, ...) { + va_list args; + va_start(args, fmt); + async_safe_fatal_va_list("FORTIFY", fmt, args); + va_end(args); + abort(); +} + +// +// Common helpers. +// + +static inline void __check_fd_set(const char* fn, int fd, size_t set_size) { + if (__predict_false(fd < 0)) { + __fortify_fatal("%s: file descriptor %d < 0", fn, fd); + } + if (__predict_false(fd >= FD_SETSIZE)) { + __fortify_fatal("%s: file descriptor %d >= FD_SETSIZE %zu", fn, fd, set_size); + } + if (__predict_false(set_size < sizeof(fd_set))) { + __fortify_fatal("%s: set size %zu is too small to be an fd_set", fn, set_size); + } +} + +static inline void __check_pollfd_array(const char* fn, size_t fds_size, nfds_t fd_count) { + size_t pollfd_array_length = fds_size / sizeof(pollfd); + if (__predict_false(pollfd_array_length < fd_count)) { + __fortify_fatal("%s: %zu-element pollfd array too small for %u fds", + fn, pollfd_array_length, fd_count); + } +} + +static inline void __check_count(const char* fn, const char* identifier, size_t value) { + if (__predict_false(value > SSIZE_MAX)) { + __fortify_fatal("%s: %s %zu > SSIZE_MAX", fn, identifier, value); + } +} + +static inline void __check_buffer_access(const char* fn, const char* action, + size_t claim, size_t actual) { + if (__predict_false(claim > actual)) { + __fortify_fatal("%s: prevented %zu-byte %s %zu-byte buffer", fn, claim, action, actual); + } +} diff --git a/private/bionic_futex.h b/private/bionic_futex.h new file mode 100644 index 0000000..fd68007 --- /dev/null +++ b/private/bionic_futex.h @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +#ifndef _BIONIC_FUTEX_H +#define _BIONIC_FUTEX_H + +#include +#include +#include +#include +#include +#include +#include + +struct timespec; + +static inline __always_inline int __futex(volatile void* ftx, int op, int value, + const timespec* timeout, int bitset) { + // Our generated syscall assembler sets errno, but our callers (pthread functions) don't want to. + int saved_errno = errno; + int result = syscall(__NR_futex, ftx, op, value, timeout, NULL, bitset); + if (__predict_false(result == -1)) { + result = -errno; + errno = saved_errno; + } + return result; +} + +static inline int __futex_wake(volatile void* ftx, int count) { + return __futex(ftx, FUTEX_WAKE, count, NULL, 0); +} + +static inline int __futex_wake_ex(volatile void* ftx, bool shared, int count) { + return __futex(ftx, shared ? FUTEX_WAKE : FUTEX_WAKE_PRIVATE, count, NULL, 0); +} + +static inline int __futex_wait(volatile void* ftx, int value, const timespec* timeout) { + return __futex(ftx, FUTEX_WAIT, value, timeout, 0); +} + +static inline int __futex_wait_ex(volatile void* ftx, bool shared, int value) { + return __futex(ftx, (shared ? FUTEX_WAIT_BITSET : FUTEX_WAIT_BITSET_PRIVATE), value, nullptr, + FUTEX_BITSET_MATCH_ANY); +} + +__LIBC_HIDDEN__ int __futex_wait_ex(volatile void* ftx, bool shared, int value, + bool use_realtime_clock, const timespec* abs_timeout); + +static inline int __futex_pi_unlock(volatile void* ftx, bool shared) { + return __futex(ftx, shared ? FUTEX_UNLOCK_PI : FUTEX_UNLOCK_PI_PRIVATE, 0, nullptr, 0); +} + +__LIBC_HIDDEN__ int __futex_pi_lock_ex(volatile void* ftx, bool shared, bool use_realtime_clock, + const timespec* abs_timeout); + +#endif /* _BIONIC_FUTEX_H */ diff --git a/private/bionic_globals.h b/private/bionic_globals.h new file mode 100644 index 0000000..94dd7e8 --- /dev/null +++ b/private/bionic_globals.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _PRIVATE_BIONIC_GLOBALS_H +#define _PRIVATE_BIONIC_GLOBALS_H + +#include + +#include "private/bionic_malloc_dispatch.h" +#include "private/bionic_vdso.h" +#include "private/WriteProtected.h" + +struct libc_globals { + vdso_entry vdso[VDSO_END]; + long setjmp_cookie; + MallocDispatch malloc_dispatch; +}; + +__LIBC_HIDDEN__ extern WriteProtected __libc_globals; + +class KernelArgumentBlock; +__LIBC_HIDDEN__ void __libc_init_malloc(libc_globals* globals); +__LIBC_HIDDEN__ void __libc_init_setjmp_cookie(libc_globals* globals, KernelArgumentBlock& args); +__LIBC_HIDDEN__ void __libc_init_vdso(libc_globals* globals, KernelArgumentBlock& args); + +#if defined(__i386__) +__LIBC_HIDDEN__ extern void* __libc_sysinfo; +__LIBC_HIDDEN__ void __libc_init_sysinfo(KernelArgumentBlock& args); +#endif + +#endif diff --git a/private/bionic_ieee.h b/private/bionic_ieee.h new file mode 100644 index 0000000..69095f0 --- /dev/null +++ b/private/bionic_ieee.h @@ -0,0 +1,118 @@ +/* $OpenBSD: ieee.h,v 1.4 2011/11/08 17:06:51 deraadt Exp $ */ +/* $NetBSD: ieee.h,v 1.2 2001/02/21 17:43:50 bjh21 Exp $ */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Lawrence Berkeley Laboratory. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ieee.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _MACHINE_IEEE_H_ +#define _MACHINE_IEEE_H_ + +#include + +__BEGIN_DECLS + +#define SNG_EXPBITS 8 +#define SNG_FRACBITS 23 + +#define SNG_EXP_INFNAN 255 +#define SNG_EXP_BIAS 127 + +struct ieee_single { + unsigned sng_frac:23; + unsigned sng_exp:8; + unsigned sng_sign:1; +}; + +#define DBL_EXPBITS 11 +#define DBL_FRACHBITS 20 +#define DBL_FRACLBITS 32 +#define DBL_FRACBITS 52 + +#define DBL_EXP_INFNAN 2047 +#define DBL_EXP_BIAS 1023 + +struct ieee_double { + unsigned dbl_fracl; + unsigned dbl_frach:20; + unsigned dbl_exp:11; + unsigned dbl_sign:1; +}; + +#if defined(__LP64__) + +/* 64-bit Android uses ld128 long doubles. */ + +#define EXT_EXPBITS 15 +#define EXT_FRACHBITS 16 +#define EXT_FRACHMBITS 32 +#define EXT_FRACLMBITS 32 +#define EXT_FRACLBITS 32 +#define EXT_FRACBITS 112 + +#define EXT_EXP_INFNAN 32767 +#define EXT_EXP_BIAS 16383 + +#define EXT_IMPLICIT_NBIT + +#define EXT_TO_ARRAY32(p, a) do { \ + (a)[0] = (uint32_t)(p)->ext_fracl; \ + (a)[1] = (uint32_t)(p)->ext_fraclm; \ + (a)[2] = (uint32_t)(p)->ext_frachm; \ + (a)[3] = (uint32_t)(p)->ext_frach; \ +} while(0) + +struct ieee_ext { + unsigned ext_fracl; + unsigned ext_fraclm; + unsigned ext_frachm; + unsigned ext_frach:16; + unsigned ext_exp:15; + unsigned ext_sign:1; +}; + +#endif + +__END_DECLS + +#endif /* _MACHINE_IEEE_H_ */ diff --git a/private/bionic_lock.h b/private/bionic_lock.h new file mode 100644 index 0000000..54168d3 --- /dev/null +++ b/private/bionic_lock.h @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +#ifndef _BIONIC_LOCK_H +#define _BIONIC_LOCK_H + +#include +#include "private/bionic_futex.h" +#include "private/bionic_macros.h" + +// Lock is used in places like pthread_rwlock_t, which can be initialized without calling +// an initialization function. So make sure Lock can be initialized by setting its memory to 0. +class Lock { + private: + enum LockState { + Unlocked = 0, + LockedWithoutWaiter, + LockedWithWaiter, + }; + _Atomic(LockState) state; + bool process_shared; + + public: + void init(bool process_shared) { + atomic_init(&state, Unlocked); + this->process_shared = process_shared; + } + + bool trylock() { + LockState old_state = Unlocked; + return __predict_true(atomic_compare_exchange_strong_explicit(&state, &old_state, + LockedWithoutWaiter, memory_order_acquire, memory_order_relaxed)); + } + + void lock() { + LockState old_state = Unlocked; + if (__predict_true(atomic_compare_exchange_strong_explicit(&state, &old_state, + LockedWithoutWaiter, memory_order_acquire, memory_order_relaxed))) { + return; + } + while (atomic_exchange_explicit(&state, LockedWithWaiter, memory_order_acquire) != Unlocked) { + // TODO: As the critical section is brief, it is a better choice to spin a few times befor sleeping. + __futex_wait_ex(&state, process_shared, LockedWithWaiter); + } + return; + } + + void unlock() { + if (atomic_exchange_explicit(&state, Unlocked, memory_order_release) == LockedWithWaiter) { + __futex_wake_ex(&state, process_shared, 1); + } + } +}; + +class LockGuard { + public: + LockGuard(Lock& lock) : lock_(lock) { + lock_.lock(); + } + ~LockGuard() { + lock_.unlock(); + } + + DISALLOW_COPY_AND_ASSIGN(LockGuard); + + private: + Lock& lock_; +}; + +#endif // _BIONIC_LOCK_H diff --git a/private/bionic_macros.h b/private/bionic_macros.h new file mode 100644 index 0000000..979a704 --- /dev/null +++ b/private/bionic_macros.h @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _BIONIC_MACROS_H_ +#define _BIONIC_MACROS_H_ + +#include + +// Frameworks OpenGL code currently leaks this header and allows +// collisions with other declarations, e.g., from libnativehelper. +// TODO: Remove once cleaned up. b/18334516 +#if !defined(DISALLOW_COPY_AND_ASSIGN) +// DISALLOW_COPY_AND_ASSIGN disallows the copy and operator= functions. +// It goes in the private: declarations in a class. +#define DISALLOW_COPY_AND_ASSIGN(TypeName) \ + TypeName(const TypeName&) = delete; \ + void operator=(const TypeName&) = delete +#endif // !defined(DISALLOW_COPY_AND_ASSIGN) + +// A macro to disallow all the implicit constructors, namely the +// default constructor, copy constructor and operator= functions. +// +// This should be used in the private: declarations for a class +// that wants to prevent anyone from instantiating it. This is +// especially useful for classes containing only static methods. +#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ + TypeName() = delete; \ + DISALLOW_COPY_AND_ASSIGN(TypeName) + +#define BIONIC_ROUND_UP_POWER_OF_2(value) \ + ((sizeof(value) == 8) \ + ? (1UL << (64 - __builtin_clzl(static_cast(value)))) \ + : (1UL << (32 - __builtin_clz(static_cast(value))))) + +static constexpr uintptr_t align_down(uintptr_t p, size_t align) { + return p & ~(align - 1); +} + +static constexpr uintptr_t align_up(uintptr_t p, size_t align) { + return (p + align - 1) & ~(align - 1); +} + +template +static inline T* align_down(T* p, size_t align) { + return reinterpret_cast(align_down(reinterpret_cast(p), align)); +} + +template +static inline T* align_up(T* p, size_t align) { + return reinterpret_cast(align_up(reinterpret_cast(p), align)); +} + +#if defined(__arm__) +// Do not emit anything for arm, clang does not allow emiting an arm unwind +// directive. +// #define BIONIC_STOP_UNWIND asm volatile(".cantunwind") +#define BIONIC_STOP_UNWIND +#elif defined(__aarch64__) +#define BIONIC_STOP_UNWIND asm volatile(".cfi_undefined x30") +#elif defined(__i386__) +#define BIONIC_STOP_UNWIND asm volatile(".cfi_undefined \%eip") +#elif defined(__x86_64__) +#define BIONIC_STOP_UNWIND asm volatile(".cfi_undefined \%rip") +#elif defined (__mips__) +#define BIONIC_STOP_UNWIND asm volatile(".cfi_undefined $ra") +#endif + +// The arraysize(arr) macro returns the # of elements in an array arr. +// The expression is a compile-time constant, and therefore can be +// used in defining new arrays, for example. If you use arraysize on +// a pointer by mistake, you will get a compile-time error. +// +// One caveat is that arraysize() doesn't accept any array of an +// anonymous type or a type defined inside a function. +// +// This template function declaration is used in defining arraysize. +// Note that the function doesn't need an implementation, as we only +// use its type. +template +char (&ArraySizeHelper(T (&array)[N]))[N]; // NOLINT(readability/casting) + +#define arraysize(array) (sizeof(ArraySizeHelper(array))) + +#endif // _BIONIC_MACROS_H_ diff --git a/private/bionic_malloc_dispatch.h b/private/bionic_malloc_dispatch.h new file mode 100644 index 0000000..0dce03d --- /dev/null +++ b/private/bionic_malloc_dispatch.h @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _PRIVATE_BIONIC_MALLOC_DISPATCH_H +#define _PRIVATE_BIONIC_MALLOC_DISPATCH_H + +#include +#include +#include + +// Entry in malloc dispatch table. +typedef void* (*MallocCalloc)(size_t, size_t); +typedef void (*MallocFree)(void*); +typedef struct mallinfo (*MallocMallinfo)(); +typedef void* (*MallocMalloc)(size_t); +typedef size_t (*MallocMallocUsableSize)(const void*); +typedef void* (*MallocMemalign)(size_t, size_t); +typedef int (*MallocPosixMemalign)(void**, size_t, size_t); +typedef void* (*MallocRealloc)(void*, size_t); +typedef int (*MallocIterate)(uintptr_t, size_t, void (*)(uintptr_t, size_t, void*), void*); +typedef void (*MallocMallocDisable)(); +typedef void (*MallocMallocEnable)(); +typedef int (*MallocMallopt)(int, int); +typedef void* (*MallocAlignedAlloc)(size_t, size_t); + +#if defined(HAVE_DEPRECATED_MALLOC_FUNCS) +typedef void* (*MallocPvalloc)(size_t); +typedef void* (*MallocValloc)(size_t); +#endif + +struct MallocDispatch { + MallocCalloc calloc; + MallocFree free; + MallocMallinfo mallinfo; + MallocMalloc malloc; + MallocMallocUsableSize malloc_usable_size; + MallocMemalign memalign; + MallocPosixMemalign posix_memalign; +#if defined(HAVE_DEPRECATED_MALLOC_FUNCS) + MallocPvalloc pvalloc; +#endif + MallocRealloc realloc; +#if defined(HAVE_DEPRECATED_MALLOC_FUNCS) + MallocValloc valloc; +#endif + MallocIterate iterate; + MallocMallocDisable malloc_disable; + MallocMallocEnable malloc_enable; + MallocMallopt mallopt; + MallocAlignedAlloc aligned_alloc; +} __attribute__((aligned(32))); + +#endif diff --git a/private/bionic_mbstate.h b/private/bionic_mbstate.h new file mode 100644 index 0000000..352115a --- /dev/null +++ b/private/bionic_mbstate.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _BIONIC_MBSTATE_H +#define _BIONIC_MBSTATE_H + +#include +#include + +__BEGIN_DECLS + +/* + * These return values are specified by POSIX for multibyte conversion + * functions. + */ +#define __MB_ERR_ILLEGAL_SEQUENCE static_cast(-1) +#define __MB_ERR_INCOMPLETE_SEQUENCE static_cast(-2) + +#define __MB_IS_ERR(rv) (rv == __MB_ERR_ILLEGAL_SEQUENCE || \ + rv == __MB_ERR_INCOMPLETE_SEQUENCE) + +static inline __wur size_t mbstate_bytes_so_far(const mbstate_t* ps) { + return + (ps->__seq[2] != 0) ? 3 : + (ps->__seq[1] != 0) ? 2 : + (ps->__seq[0] != 0) ? 1 : 0; +} + +static inline void mbstate_set_byte(mbstate_t* ps, int i, char byte) { + ps->__seq[i] = static_cast(byte); +} + +static inline __wur uint8_t mbstate_get_byte(const mbstate_t* ps, int n) { + return ps->__seq[n]; +} + +static inline __wur size_t mbstate_reset_and_return_illegal(int _errno, mbstate_t* ps) { + errno = _errno; + *(reinterpret_cast(ps->__seq)) = 0; + return __MB_ERR_ILLEGAL_SEQUENCE; +} + +static inline __wur size_t mbstate_reset_and_return(int _return, mbstate_t* ps) { + *(reinterpret_cast(ps->__seq)) = 0; + return _return; +} + +__END_DECLS + +#endif // _BIONIC_MBSTATE_H diff --git a/private/bionic_page.h b/private/bionic_page.h new file mode 100644 index 0000000..0beb708 --- /dev/null +++ b/private/bionic_page.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _BIONIC_PAGE_H_ +#define _BIONIC_PAGE_H_ + +// Get PAGE_SIZE and PAGE_MASK. +#include + +// Returns the address of the page containing address 'x'. +#define PAGE_START(x) ((x) & PAGE_MASK) + +// Returns the offset of address 'x' in its page. +#define PAGE_OFFSET(x) ((x) & ~PAGE_MASK) + +// Returns the address of the next page after address 'x', unless 'x' is +// itself at the start of a page. +#define PAGE_END(x) PAGE_START((x) + (PAGE_SIZE-1)) + +#endif // _BIONIC_PAGE_H_ diff --git a/private/bionic_prctl.h b/private/bionic_prctl.h new file mode 100644 index 0000000..103cccb --- /dev/null +++ b/private/bionic_prctl.h @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef BIONIC_PRCTL_H +#define BIONIC_PRCTL_H + +#include + +// This is only supported by Android kernels, so it's not in the uapi headers. +#define PR_SET_VMA 0x53564d41 +#define PR_SET_VMA_ANON_NAME 0 + +#endif // BIONIC_PRCTL_H diff --git a/private/bionic_sdk_version.h b/private/bionic_sdk_version.h new file mode 100644 index 0000000..871d25c --- /dev/null +++ b/private/bionic_sdk_version.h @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _BIONIC_SDK_VERSION_H_ +#define _BIONIC_SDK_VERSION_H_ + +#include + +uint32_t bionic_get_application_target_sdk_version(); + +#endif // _BIONIC_SDK_VERSION_H_ diff --git a/private/bionic_sigdefs.h b/private/bionic_sigdefs.h new file mode 100644 index 0000000..44d60d9 --- /dev/null +++ b/private/bionic_sigdefs.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * this header is used to define signal constants and names; + * it might be included several times + */ + +#ifndef __BIONIC_SIGDEF +#error __BIONIC_SIGDEF not defined +#endif + +__BIONIC_SIGDEF(SIGHUP, "Hangup") +__BIONIC_SIGDEF(SIGINT, "Interrupt") +__BIONIC_SIGDEF(SIGQUIT, "Quit") +__BIONIC_SIGDEF(SIGILL, "Illegal instruction") +__BIONIC_SIGDEF(SIGTRAP, "Trap") +__BIONIC_SIGDEF(SIGABRT, "Aborted") +#ifdef SIGEMT +__BIONIC_SIGDEF(SIGEMT, "EMT") +#endif +__BIONIC_SIGDEF(SIGFPE, "Floating point exception") +__BIONIC_SIGDEF(SIGKILL, "Killed") +__BIONIC_SIGDEF(SIGBUS, "Bus error") +__BIONIC_SIGDEF(SIGSEGV, "Segmentation fault") +__BIONIC_SIGDEF(SIGPIPE, "Broken pipe") +__BIONIC_SIGDEF(SIGALRM, "Alarm clock") +__BIONIC_SIGDEF(SIGTERM, "Terminated") +__BIONIC_SIGDEF(SIGUSR1, "User signal 1") +__BIONIC_SIGDEF(SIGUSR2, "User signal 2") +__BIONIC_SIGDEF(SIGCHLD, "Child exited") +__BIONIC_SIGDEF(SIGPWR, "Power failure") +__BIONIC_SIGDEF(SIGWINCH, "Window size changed") +__BIONIC_SIGDEF(SIGURG, "Urgent I/O condition") +__BIONIC_SIGDEF(SIGIO, "I/O possible") +__BIONIC_SIGDEF(SIGSTOP, "Stopped (signal)") +__BIONIC_SIGDEF(SIGTSTP, "Stopped") +__BIONIC_SIGDEF(SIGCONT, "Continue") +__BIONIC_SIGDEF(SIGTTIN, "Stopped (tty input)") +__BIONIC_SIGDEF(SIGTTOU, "Stopped (tty output)") +__BIONIC_SIGDEF(SIGVTALRM, "Virtual timer expired") +__BIONIC_SIGDEF(SIGPROF, "Profiling timer expired") +__BIONIC_SIGDEF(SIGXCPU, "CPU time limit exceeded") +__BIONIC_SIGDEF(SIGXFSZ, "File size limit exceeded") +#if defined(SIGSTKFLT) +__BIONIC_SIGDEF(SIGSTKFLT, "Stack fault") +#endif +__BIONIC_SIGDEF(SIGSYS, "Bad system call") + +#undef __BIONIC_SIGDEF diff --git a/private/bionic_ssp.h b/private/bionic_ssp.h new file mode 100644 index 0000000..9883d72 --- /dev/null +++ b/private/bionic_ssp.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _PRIVATE_SSP_H +#define _PRIVATE_SSP_H + +#include +#include + +__BEGIN_DECLS + +/* GCC uses this on ARM and MIPS; we use it on x86 to set the guard in TLS. */ +extern uintptr_t __stack_chk_guard; + +/* GCC calls this if a stack guard check fails. */ +extern void __stack_chk_fail(); + +__END_DECLS + +#endif diff --git a/cutils/cpu_info.h b/private/bionic_string_utils.h similarity index 55% rename from cutils/cpu_info.h rename to private/bionic_string_utils.h index 78c1884..ab0eccf 100644 --- a/cutils/cpu_info.h +++ b/private/bionic_string_utils.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007 The Android Open Source Project + * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,21 +14,18 @@ * limitations under the License. */ -#ifndef __CUTILS_CPU_INFO_H -#define __CUTILS_CPU_INFO_H +#ifndef _BIONIC_STRING_UTILS_H_ +#define _BIONIC_STRING_UTILS_H_ -#ifdef __cplusplus -extern "C" { -#endif +#include -/* returns a string contiaining an ASCII representation of the CPU serial number, -** or NULL if cpu info not available. -** The string is a static variable, so don't call free() on it. -*/ -extern const char* get_cpu_serial_number(void); - -#ifdef __cplusplus +static inline bool ends_with(const char* s1, const char* s2) { + size_t s1_length = strlen(s1); + size_t s2_length = strlen(s2); + if (s2_length > s1_length) { + return false; + } + return memcmp(s1 + (s1_length - s2_length), s2, s2_length) == 0; } -#endif -#endif /* __CUTILS_CPU_INFO_H */ +#endif // _BIONIC_STRING_UTILS_H_ diff --git a/private/bionic_systrace.h b/private/bionic_systrace.h new file mode 100644 index 0000000..304fb80 --- /dev/null +++ b/private/bionic_systrace.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef BIONIC_SYSTRACE_H +#define BIONIC_SYSTRACE_H + +#include "bionic_macros.h" + +// Tracing class for bionic. To begin a trace at a specified point: +// ScopedTrace("Trace message"); +// The trace will end when the contructor goes out of scope. + +class __LIBC_HIDDEN__ ScopedTrace { + public: + explicit ScopedTrace(const char* message); + ~ScopedTrace(); + + void End(); + private: + bool called_end_; + DISALLOW_COPY_AND_ASSIGN(ScopedTrace); +}; + +void bionic_trace_begin(const char* message); +void bionic_trace_end(); + +#endif diff --git a/private/bionic_time_conversions.h b/private/bionic_time_conversions.h new file mode 100644 index 0000000..fb049f2 --- /dev/null +++ b/private/bionic_time_conversions.h @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _BIONIC_TIME_CONVERSIONS_H +#define _BIONIC_TIME_CONVERSIONS_H + +#include +#include +#include + +#include "private/bionic_constants.h" + +__BEGIN_DECLS + +__LIBC_HIDDEN__ bool timespec_from_timeval(timespec& ts, const timeval& tv); +__LIBC_HIDDEN__ void timespec_from_ms(timespec& ts, const int ms); + +__LIBC_HIDDEN__ void timeval_from_timespec(timeval& tv, const timespec& ts); + +__LIBC_HIDDEN__ void monotonic_time_from_realtime_time(timespec& monotonic_time, + const timespec& realtime_time); + +__END_DECLS + +static inline int check_timespec(const timespec* ts, bool null_allowed) { + if (null_allowed && ts == nullptr) { + return 0; + } + // glibc just segfaults if you pass a null timespec. + // That seems a lot more likely to catch bad code than returning EINVAL. + if (ts->tv_nsec < 0 || ts->tv_nsec >= NS_PER_S) { + return EINVAL; + } + if (ts->tv_sec < 0) { + return ETIMEDOUT; + } + return 0; +} + +#if !defined(__LP64__) +static inline void absolute_timespec_from_timespec(timespec& abs_ts, const timespec& ts, clockid_t clock) { + clock_gettime(clock, &abs_ts); + abs_ts.tv_sec += ts.tv_sec; + abs_ts.tv_nsec += ts.tv_nsec; + if (abs_ts.tv_nsec >= NS_PER_S) { + abs_ts.tv_nsec -= NS_PER_S; + abs_ts.tv_sec++; + } +} +#endif + +#endif diff --git a/private/bionic_tls.h b/private/bionic_tls.h new file mode 100644 index 0000000..de086f2 --- /dev/null +++ b/private/bionic_tls.h @@ -0,0 +1,138 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef __BIONIC_PRIVATE_BIONIC_TLS_H_ +#define __BIONIC_PRIVATE_BIONIC_TLS_H_ + +#include +#include +#include +#include +#include + +#include "bionic_macros.h" +#include "__get_tls.h" +#include "grp_pwd.h" + +__BEGIN_DECLS + +/** WARNING WARNING WARNING + ** + ** This header file is *NOT* part of the public Bionic ABI/API + ** and should not be used/included by user-serviceable parts of + ** the system (e.g. applications). + ** + ** It is only provided here for the benefit of the system dynamic + ** linker and the OpenGL sub-system (which needs to access the + ** pre-allocated slot directly for performance reason). + **/ + +// Well-known TLS slots. What data goes in which slot is arbitrary unless otherwise noted. +enum { + TLS_SLOT_SELF = 0, // The kernel requires this specific slot for x86. + TLS_SLOT_THREAD_ID, + TLS_SLOT_ERRNO, + + // These two aren't used by bionic itself, but allow the graphics code to + // access TLS directly rather than using the pthread API. + TLS_SLOT_OPENGL_API = 3, + TLS_SLOT_OPENGL = 4, + + // This slot is only used to pass information from the dynamic linker to + // libc.so when the C library is loaded in to memory. The C runtime init + // function will then clear it. Since its use is extremely temporary, + // we reuse an existing location that isn't needed during libc startup. + TLS_SLOT_BIONIC_PREINIT = TLS_SLOT_OPENGL_API, + + TLS_SLOT_STACK_GUARD = 5, // GCC requires this specific slot for x86. + TLS_SLOT_DLERROR, + + // Fast storage for Thread::Current() in ART. + TLS_SLOT_ART_THREAD_SELF, + + // Lets TSAN avoid using pthread_getspecific for finding the current thread + // state. + TLS_SLOT_TSAN, + + BIONIC_TLS_SLOTS // Must come last! +}; + +// ~3 pages. +struct bionic_tls { + locale_t locale; + + char basename_buf[MAXPATHLEN]; + char dirname_buf[MAXPATHLEN]; + + mntent mntent_buf; + char mntent_strings[BUFSIZ]; + + char ptsname_buf[32]; + char ttyname_buf[64]; + + char strerror_buf[NL_TEXTMAX]; + char strsignal_buf[NL_TEXTMAX]; + + group_state_t group; + passwd_state_t passwd; +}; + +#define BIONIC_TLS_SIZE (__BIONIC_ALIGN(sizeof(bionic_tls), PAGE_SIZE)) + +/* + * Bionic uses some pthread keys internally. All pthread keys used internally + * should be created in constructors, except for keys that may be used in or + * before constructors. + * + * We need to manually maintain the count of pthread keys used internally, but + * pthread_test should fail if we forget. + * + * These are the pthread keys currently used internally by libc: + * _res_key libc (constructor in BSD code) + */ + +#define LIBC_PTHREAD_KEY_RESERVED_COUNT 1 + +/* Internally, jemalloc uses a single key for per thread data. */ +#define JEMALLOC_PTHREAD_KEY_RESERVED_COUNT 1 +#define BIONIC_PTHREAD_KEY_RESERVED_COUNT (LIBC_PTHREAD_KEY_RESERVED_COUNT + JEMALLOC_PTHREAD_KEY_RESERVED_COUNT) + +/* + * Maximum number of pthread keys allocated. + * This includes pthread keys used internally and externally. + */ +#define BIONIC_PTHREAD_KEY_COUNT (BIONIC_PTHREAD_KEY_RESERVED_COUNT + PTHREAD_KEYS_MAX) + +__END_DECLS + +#if defined(__cplusplus) +class KernelArgumentBlock; +extern void __libc_init_main_thread(KernelArgumentBlock&); +#endif + +#endif /* __BIONIC_PRIVATE_BIONIC_TLS_H_ */ diff --git a/private/bionic_vdso.h b/private/bionic_vdso.h new file mode 100644 index 0000000..da19b29 --- /dev/null +++ b/private/bionic_vdso.h @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _PRIVATE_BIONIC_VDSO_H +#define _PRIVATE_BIONIC_VDSO_H + +#include + +#if defined(__aarch64__) +#define VDSO_CLOCK_GETTIME_SYMBOL "__kernel_clock_gettime" +#define VDSO_CLOCK_GETRES_SYMBOL "__kernel_clock_getres" +#define VDSO_GETTIMEOFDAY_SYMBOL "__kernel_gettimeofday" +#define VDSO_TIME_SYMBOL "__kernel_time" +#else +#define VDSO_CLOCK_GETTIME_SYMBOL "__vdso_clock_gettime" +#define VDSO_CLOCK_GETRES_SYMBOL "__vdso_clock_getres" +#define VDSO_GETTIMEOFDAY_SYMBOL "__vdso_gettimeofday" +#define VDSO_TIME_SYMBOL "__vdso_time" +#endif + +extern "C" int __clock_gettime(int, timespec*); +extern "C" int __clock_getres(int, timespec*); +extern "C" int __gettimeofday(timeval*, struct timezone*); + +struct vdso_entry { + const char* name; + void* fn; +}; + +enum { + VDSO_CLOCK_GETTIME = 0, + VDSO_CLOCK_GETRES, + VDSO_GETTIMEOFDAY, + VDSO_TIME, + VDSO_END +}; + +#endif // _PRIVATE_BIONIC_VDSO_H diff --git a/private/get_cpu_count_from_string.h b/private/get_cpu_count_from_string.h new file mode 100644 index 0000000..a0cb95d --- /dev/null +++ b/private/get_cpu_count_from_string.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include + +// Parse a string like: 0, 2-4, 6. +static int GetCpuCountFromString(const char* s) { + int cpu_count = 0; + int last_cpu = -1; + while (*s != '\0') { + if (isdigit(*s)) { + int cpu = static_cast(strtol(s, const_cast(&s), 10)); + if (last_cpu != -1) { + cpu_count += cpu - last_cpu; + } else { + cpu_count++; + } + last_cpu = cpu; + } else { + if (*s == ',') { + last_cpu = -1; + } + s++; + } + } + return cpu_count; +} diff --git a/private/grp_pwd.h b/private/grp_pwd.h new file mode 100644 index 0000000..ab79586 --- /dev/null +++ b/private/grp_pwd.h @@ -0,0 +1,50 @@ +#pragma once + +/* + * Copyright (C) 2017 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include + +static constexpr size_t kGrpPwdBufferSize = 32; + +struct group_state_t { + group group_; + char* group_members_[2]; + char group_name_buffer_[kGrpPwdBufferSize]; + // Must be last so init_group_state can run a simple memset for the above + ssize_t getgrent_idx; +}; + +struct passwd_state_t { + passwd passwd_; + char name_buffer_[kGrpPwdBufferSize]; + char dir_buffer_[kGrpPwdBufferSize]; + char sh_buffer_[kGrpPwdBufferSize]; + ssize_t getpwent_idx; +}; diff --git a/private/icu.h b/private/icu.h new file mode 100644 index 0000000..a671e98 --- /dev/null +++ b/private/icu.h @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _PRIVATE_ICU_H +#define _PRIVATE_ICU_H + +#include +#include + +typedef int8_t UBool; +#define FALSE 0 +#define TRUE 1 + +typedef int32_t UChar32; + +enum UProperty { + UCHAR_ALPHABETIC = 0, + UCHAR_DEFAULT_IGNORABLE_CODE_POINT = 5, + UCHAR_LOWERCASE = 22, + UCHAR_POSIX_ALNUM = 44, + UCHAR_POSIX_BLANK = 45, + UCHAR_POSIX_GRAPH = 46, + UCHAR_POSIX_PRINT = 47, + UCHAR_POSIX_XDIGIT = 48, + UCHAR_UPPERCASE = 30, + UCHAR_WHITE_SPACE = 31, + UCHAR_EAST_ASIAN_WIDTH = 0x1004, + UCHAR_HANGUL_SYLLABLE_TYPE = 0x100b, +}; + +enum UCharCategory { + U_NON_SPACING_MARK = 6, + U_ENCLOSING_MARK = 7, + U_CONTROL_CHAR = 15, + U_FORMAT_CHAR = 16, +}; + +enum UEastAsianWidth { + U_EA_NEUTRAL, + U_EA_AMBIGUOUS, + U_EA_HALFWIDTH, + U_EA_FULLWIDTH, + U_EA_NARROW, + U_EA_WIDE, +}; + +enum UHangulSyllableType { + U_HST_NOT_APPLICABLE, + U_HST_LEADING_JAMO, + U_HST_VOWEL_JAMO, + U_HST_TRAILING_JAMO, + U_HST_LV_SYLLABLE, + U_HST_LVT_SYLLABLE, +}; + +int8_t __icu_charType(wint_t wc); +int32_t __icu_getIntPropertyValue(wint_t wc, UProperty property); +bool __icu_hasBinaryProperty(wint_t wc, UProperty property, int (*fallback)(int)); + +void* __find_icu_symbol(const char* symbol_name); + +#endif // _PRIVATE_ICU_H diff --git a/private/sigrtmin.h b/private/sigrtmin.h new file mode 100644 index 0000000..ea8673d --- /dev/null +++ b/private/sigrtmin.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#pragma once + +#include + +#include + +// Realtime signals reserved for internal use: +// 32 (__SIGRTMIN + 0) POSIX timers +// 33 (__SIGRTMIN + 1) libbacktrace +// 34 (__SIGRTMIN + 2) libcore +// 35 (__SIGRTMIN + 3) debuggerd -b +// +// If you change this, also change __ndk_legacy___libc_current_sigrtmin +// in to match. + +#define __SIGRT_RESERVED 4 +static inline __always_inline sigset64_t filter_reserved_signals(sigset64_t sigset) { + for (int signo = __SIGRTMIN; signo < __SIGRTMIN + __SIGRT_RESERVED; ++signo) { + sigdelset64(&sigset, signo); + } + return sigset; +} diff --git a/private/thread_private.h b/private/thread_private.h new file mode 100644 index 0000000..0081ad0 --- /dev/null +++ b/private/thread_private.h @@ -0,0 +1,57 @@ +/* $OpenBSD: thread_private.h,v 1.18 2006/02/22 07:16:31 otto Exp $ */ + +/* PUBLIC DOMAIN: No Rights Reserved. Marco S Hyman */ + +#ifndef _THREAD_PRIVATE_H_ +#define _THREAD_PRIVATE_H_ + +#include + +__BEGIN_DECLS + +/* + * This file defines the thread library interface to libc. Thread + * libraries must implement the functions described here for proper + * inter-operation with libc. libc contains weak versions of the + * described functions for operation in a non-threaded environment. + */ + +/* + * helper macro to make unique names in the thread namespace + */ +#define __THREAD_NAME(name) __CONCAT(_thread_tagname_,name) + +struct __thread_private_tag_t { + pthread_mutex_t _private_lock; + pthread_key_t _private_key; +}; + +#define _THREAD_PRIVATE_MUTEX(name) \ + static struct __thread_private_tag_t __THREAD_NAME(name) = { PTHREAD_MUTEX_INITIALIZER, -1 } +#define _THREAD_PRIVATE_MUTEX_LOCK(name) \ + pthread_mutex_lock( &__THREAD_NAME(name)._private_lock ) +#define _THREAD_PRIVATE_MUTEX_UNLOCK(name) \ + pthread_mutex_unlock( &__THREAD_NAME(name)._private_lock ) + +/* Note that these aren't compatible with the usual OpenBSD ones which lazy-initialize! */ +#define _MUTEX_LOCK(l) pthread_mutex_lock((pthread_mutex_t*) l) +#define _MUTEX_UNLOCK(l) pthread_mutex_unlock((pthread_mutex_t*) l) + +__LIBC_HIDDEN__ void _thread_atexit_lock(void); +__LIBC_HIDDEN__ void _thread_atexit_unlock(void); + +#define _ATEXIT_LOCK() _thread_atexit_lock() +#define _ATEXIT_UNLOCK() _thread_atexit_unlock() + +__LIBC_HIDDEN__ void _thread_arc4_lock(void); +__LIBC_HIDDEN__ void _thread_arc4_unlock(void); + +#define _ARC4_LOCK() _thread_arc4_lock() +#define _ARC4_UNLOCK() _thread_arc4_unlock() +#define _ARC4_ATFORK(f) pthread_atfork(NULL, NULL, (f)) + +extern volatile sig_atomic_t _rs_forked; + +__END_DECLS + +#endif /* _THREAD_PRIVATE_H_ */ diff --git a/sync/sync.h b/sync/sync.h index 2e5d82f..68f74a0 100644 --- a/sync/sync.h +++ b/sync/sync.h @@ -19,12 +19,28 @@ #ifndef __SYS_CORE_SYNC_H #define __SYS_CORE_SYNC_H -#include -#include +/* This file contains the legacy sync interface used by Android platform and + * device code. The direct contents will be removed over time as code + * transitions to using the updated interface in ndk/sync.h. When this file is + * empty other than the ndk/sync.h include, that file will be renamed to + * replace this one. + * + * New code should continue to include this file (#include ) + * instead of ndk/sync.h so the eventual rename is seamless, but should only + * use the things declared in ndk/sync.h. + * + * This file used to be called sync/sync.h, but we renamed to that both the + * platform and NDK call it android/sync.h. A symlink from the old name to this + * one exists temporarily to avoid having to change all sync clients + * simultaneously. It will be removed when they've been updated, and probably + * after this change has been delivered to AOSP so that integrations don't + * break builds. + */ + +#include "../ndk/sync.h" __BEGIN_DECLS -// XXX: These structs are copied from the header "linux/sync.h". struct sync_fence_info_data { uint32_t len; char name[32]; @@ -43,7 +59,6 @@ struct sync_pt_info { /* timeout in msecs */ int sync_wait(int fd, int timeout); -int sync_merge(const char *name, int fd1, int fd2); struct sync_fence_info_data *sync_fence_info(int fd); struct sync_pt_info *sync_pt_info(struct sync_fence_info_data *info, struct sync_pt_info *itr); diff --git a/system/audio-base-utils.h b/system/audio-base-utils.h new file mode 100644 index 0000000..016a085 --- /dev/null +++ b/system/audio-base-utils.h @@ -0,0 +1,177 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_AUDIO_BASE_UTILS_H +#define ANDROID_AUDIO_BASE_UTILS_H + +#include "audio-base.h" + +/** Define helper values to iterate over enum, extend them or checking value validity. + * Those values are compatible with the O corresponding enum values. + * They are not macro like similar values in audio.h to avoid conflicting + * with the libhardware_legacy audio.h. + */ +enum { + /** Number of audio stream available to vendors. */ + AUDIO_STREAM_PUBLIC_CNT = AUDIO_STREAM_ACCESSIBILITY + 1, + +#ifndef AUDIO_NO_SYSTEM_DECLARATIONS + /** Total number of stream handled by the policy*/ + AUDIO_STREAM_FOR_POLICY_CNT= AUDIO_STREAM_REROUTING + 1, +#endif + + /** Total number of stream. */ + AUDIO_STREAM_CNT = AUDIO_STREAM_PATCH + 1, + + AUDIO_SOURCE_MAX = AUDIO_SOURCE_UNPROCESSED, + AUDIO_SOURCE_CNT = AUDIO_SOURCE_MAX + 1, + + AUDIO_MODE_MAX = AUDIO_MODE_IN_COMMUNICATION, + AUDIO_MODE_CNT = AUDIO_MODE_MAX + 1, + + /** For retrocompatibility AUDIO_MODE_* and AUDIO_STREAM_* must be signed. */ + AUDIO_DETAIL_NEGATIVE_VALUE = -1, +}; + +enum { + AUDIO_CHANNEL_OUT_ALL = AUDIO_CHANNEL_OUT_FRONT_LEFT | + AUDIO_CHANNEL_OUT_FRONT_RIGHT | + AUDIO_CHANNEL_OUT_FRONT_CENTER | + AUDIO_CHANNEL_OUT_LOW_FREQUENCY | + AUDIO_CHANNEL_OUT_BACK_LEFT | + AUDIO_CHANNEL_OUT_BACK_RIGHT | + AUDIO_CHANNEL_OUT_FRONT_LEFT_OF_CENTER | + AUDIO_CHANNEL_OUT_FRONT_RIGHT_OF_CENTER | + AUDIO_CHANNEL_OUT_BACK_CENTER | + AUDIO_CHANNEL_OUT_SIDE_LEFT | + AUDIO_CHANNEL_OUT_SIDE_RIGHT | + AUDIO_CHANNEL_OUT_TOP_CENTER | + AUDIO_CHANNEL_OUT_TOP_FRONT_LEFT | + AUDIO_CHANNEL_OUT_TOP_FRONT_CENTER | + AUDIO_CHANNEL_OUT_TOP_FRONT_RIGHT | + AUDIO_CHANNEL_OUT_TOP_BACK_LEFT | + AUDIO_CHANNEL_OUT_TOP_BACK_CENTER | + AUDIO_CHANNEL_OUT_TOP_BACK_RIGHT | + AUDIO_CHANNEL_OUT_TOP_SIDE_LEFT | + AUDIO_CHANNEL_OUT_TOP_SIDE_RIGHT, + + AUDIO_CHANNEL_IN_ALL = AUDIO_CHANNEL_IN_LEFT | + AUDIO_CHANNEL_IN_RIGHT | + AUDIO_CHANNEL_IN_FRONT | + AUDIO_CHANNEL_IN_BACK| + AUDIO_CHANNEL_IN_LEFT_PROCESSED | + AUDIO_CHANNEL_IN_RIGHT_PROCESSED | + AUDIO_CHANNEL_IN_FRONT_PROCESSED | + AUDIO_CHANNEL_IN_BACK_PROCESSED| + AUDIO_CHANNEL_IN_PRESSURE | + AUDIO_CHANNEL_IN_X_AXIS | + AUDIO_CHANNEL_IN_Y_AXIS | + AUDIO_CHANNEL_IN_Z_AXIS | + AUDIO_CHANNEL_IN_VOICE_UPLINK | + AUDIO_CHANNEL_IN_VOICE_DNLINK | + AUDIO_CHANNEL_IN_BACK_LEFT | + AUDIO_CHANNEL_IN_BACK_RIGHT | + AUDIO_CHANNEL_IN_CENTER | + AUDIO_CHANNEL_IN_LOW_FREQUENCY | + AUDIO_CHANNEL_IN_TOP_LEFT | + AUDIO_CHANNEL_IN_TOP_RIGHT, + + AUDIO_DEVICE_OUT_ALL = AUDIO_DEVICE_OUT_EARPIECE | + AUDIO_DEVICE_OUT_SPEAKER | + AUDIO_DEVICE_OUT_WIRED_HEADSET | + AUDIO_DEVICE_OUT_WIRED_HEADPHONE | + AUDIO_DEVICE_OUT_BLUETOOTH_SCO | + AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET | + AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT | + AUDIO_DEVICE_OUT_BLUETOOTH_A2DP | + AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES | + AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER | + AUDIO_DEVICE_OUT_HDMI | + AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET | + AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET | + AUDIO_DEVICE_OUT_USB_ACCESSORY | + AUDIO_DEVICE_OUT_USB_DEVICE | + AUDIO_DEVICE_OUT_REMOTE_SUBMIX | + AUDIO_DEVICE_OUT_TELEPHONY_TX | + AUDIO_DEVICE_OUT_LINE | + AUDIO_DEVICE_OUT_HDMI_ARC | + AUDIO_DEVICE_OUT_SPDIF | + AUDIO_DEVICE_OUT_FM | + AUDIO_DEVICE_OUT_AUX_LINE | + AUDIO_DEVICE_OUT_SPEAKER_SAFE | + AUDIO_DEVICE_OUT_IP | + AUDIO_DEVICE_OUT_BUS | + AUDIO_DEVICE_OUT_PROXY | + AUDIO_DEVICE_OUT_USB_HEADSET | + AUDIO_DEVICE_OUT_HEARING_AID | + AUDIO_DEVICE_OUT_ECHO_CANCELLER | + AUDIO_DEVICE_OUT_DEFAULT, + + AUDIO_DEVICE_OUT_ALL_A2DP = AUDIO_DEVICE_OUT_BLUETOOTH_A2DP | + AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES | + AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER, + + AUDIO_DEVICE_OUT_ALL_SCO = AUDIO_DEVICE_OUT_BLUETOOTH_SCO | + AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET | + AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT, + + AUDIO_DEVICE_OUT_ALL_USB = AUDIO_DEVICE_OUT_USB_ACCESSORY | + AUDIO_DEVICE_OUT_USB_DEVICE | + AUDIO_DEVICE_OUT_USB_HEADSET, + + AUDIO_DEVICE_IN_ALL = AUDIO_DEVICE_IN_COMMUNICATION | + AUDIO_DEVICE_IN_AMBIENT | + AUDIO_DEVICE_IN_BUILTIN_MIC | + AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET | + AUDIO_DEVICE_IN_WIRED_HEADSET | + AUDIO_DEVICE_IN_HDMI | + AUDIO_DEVICE_IN_TELEPHONY_RX | + AUDIO_DEVICE_IN_BACK_MIC | + AUDIO_DEVICE_IN_REMOTE_SUBMIX | + AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET | + AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET | + AUDIO_DEVICE_IN_USB_ACCESSORY | + AUDIO_DEVICE_IN_USB_DEVICE | + AUDIO_DEVICE_IN_FM_TUNER | + AUDIO_DEVICE_IN_TV_TUNER | + AUDIO_DEVICE_IN_LINE | + AUDIO_DEVICE_IN_SPDIF | + AUDIO_DEVICE_IN_BLUETOOTH_A2DP | + AUDIO_DEVICE_IN_LOOPBACK | + AUDIO_DEVICE_IN_IP | + AUDIO_DEVICE_IN_BUS | + AUDIO_DEVICE_IN_PROXY | + AUDIO_DEVICE_IN_USB_HEADSET | + AUDIO_DEVICE_IN_BLUETOOTH_BLE | + AUDIO_DEVICE_IN_DEFAULT, + + AUDIO_DEVICE_IN_ALL_SCO = AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET, + + AUDIO_DEVICE_IN_ALL_USB = AUDIO_DEVICE_IN_USB_ACCESSORY | + AUDIO_DEVICE_IN_USB_DEVICE | + AUDIO_DEVICE_IN_USB_HEADSET, + + AUDIO_USAGE_MAX = AUDIO_USAGE_ASSISTANT, + AUDIO_USAGE_CNT = AUDIO_USAGE_ASSISTANT + 1, + + AUDIO_PORT_CONFIG_ALL = AUDIO_PORT_CONFIG_SAMPLE_RATE | + AUDIO_PORT_CONFIG_CHANNEL_MASK | + AUDIO_PORT_CONFIG_FORMAT | + AUDIO_PORT_CONFIG_GAIN, +}; // enum + + +#endif // ANDROID_AUDIO_BASE_UTILS_H diff --git a/system/audio-base.h b/system/audio-base.h new file mode 100644 index 0000000..3d0638d --- /dev/null +++ b/system/audio-base.h @@ -0,0 +1,450 @@ +// This file is autogenerated by hidl-gen +// then manualy edited for retrocompatiblity +// Source: android.hardware.audio.common@4.0 +// Root: android.hardware:hardware/interfaces + +#ifndef HIDL_GENERATED_ANDROID_HARDWARE_AUDIO_COMMON_V4_0_EXPORTED_CONSTANTS_H_ +#define HIDL_GENERATED_ANDROID_HARDWARE_AUDIO_COMMON_V4_0_EXPORTED_CONSTANTS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + AUDIO_IO_HANDLE_NONE = 0, + AUDIO_MODULE_HANDLE_NONE = 0, + AUDIO_PORT_HANDLE_NONE = 0, + AUDIO_PATCH_HANDLE_NONE = 0, +}; + +typedef enum { + AUDIO_STREAM_DEFAULT = -1, // (-1) + AUDIO_STREAM_MIN = 0, + AUDIO_STREAM_VOICE_CALL = 0, + AUDIO_STREAM_SYSTEM = 1, + AUDIO_STREAM_RING = 2, + AUDIO_STREAM_MUSIC = 3, + AUDIO_STREAM_ALARM = 4, + AUDIO_STREAM_NOTIFICATION = 5, + AUDIO_STREAM_BLUETOOTH_SCO = 6, + AUDIO_STREAM_ENFORCED_AUDIBLE = 7, + AUDIO_STREAM_DTMF = 8, + AUDIO_STREAM_TTS = 9, + AUDIO_STREAM_ACCESSIBILITY = 10, +#ifndef AUDIO_NO_SYSTEM_DECLARATIONS + /** For dynamic policy output mixes. Only used by the audio policy */ + AUDIO_STREAM_REROUTING = 11, + /** For audio flinger tracks volume. Only used by the audioflinger */ + AUDIO_STREAM_PATCH = 12, +#endif // AUDIO_NO_SYSTEM_DECLARATIONS +} audio_stream_type_t; + +typedef enum { + AUDIO_SOURCE_DEFAULT = 0, + AUDIO_SOURCE_MIC = 1, + AUDIO_SOURCE_VOICE_UPLINK = 2, + AUDIO_SOURCE_VOICE_DOWNLINK = 3, + AUDIO_SOURCE_VOICE_CALL = 4, + AUDIO_SOURCE_CAMCORDER = 5, + AUDIO_SOURCE_VOICE_RECOGNITION = 6, + AUDIO_SOURCE_VOICE_COMMUNICATION = 7, + AUDIO_SOURCE_REMOTE_SUBMIX = 8, + AUDIO_SOURCE_UNPROCESSED = 9, + AUDIO_SOURCE_FM_TUNER = 1998, +#ifndef AUDIO_NO_SYSTEM_DECLARATIONS + /** + * A low-priority, preemptible audio source for for background software + * hotword detection. Same tuning as VOICE_RECOGNITION. + * Used only internally by the framework. + */ + AUDIO_SOURCE_HOTWORD = 1999, +#endif // AUDIO_NO_SYSTEM_DECLARATIONS +} audio_source_t; + +typedef enum { + AUDIO_SESSION_OUTPUT_STAGE = -1, // (-1) + AUDIO_SESSION_OUTPUT_MIX = 0, + AUDIO_SESSION_ALLOCATE = 0, + AUDIO_SESSION_NONE = 0, +} audio_session_t; + +typedef enum { + AUDIO_FORMAT_INVALID = 0xFFFFFFFFu, + AUDIO_FORMAT_DEFAULT = 0, + AUDIO_FORMAT_PCM = 0x00000000u, + AUDIO_FORMAT_MP3 = 0x01000000u, + AUDIO_FORMAT_AMR_NB = 0x02000000u, + AUDIO_FORMAT_AMR_WB = 0x03000000u, + AUDIO_FORMAT_AAC = 0x04000000u, + AUDIO_FORMAT_HE_AAC_V1 = 0x05000000u, + AUDIO_FORMAT_HE_AAC_V2 = 0x06000000u, + AUDIO_FORMAT_VORBIS = 0x07000000u, + AUDIO_FORMAT_OPUS = 0x08000000u, + AUDIO_FORMAT_AC3 = 0x09000000u, + AUDIO_FORMAT_E_AC3 = 0x0A000000u, + AUDIO_FORMAT_DTS = 0x0B000000u, + AUDIO_FORMAT_DTS_HD = 0x0C000000u, + AUDIO_FORMAT_IEC61937 = 0x0D000000u, + AUDIO_FORMAT_DOLBY_TRUEHD = 0x0E000000u, + AUDIO_FORMAT_EVRC = 0x10000000u, + AUDIO_FORMAT_EVRCB = 0x11000000u, + AUDIO_FORMAT_EVRCWB = 0x12000000u, + AUDIO_FORMAT_EVRCNW = 0x13000000u, + AUDIO_FORMAT_AAC_ADIF = 0x14000000u, + AUDIO_FORMAT_WMA = 0x15000000u, + AUDIO_FORMAT_WMA_PRO = 0x16000000u, + AUDIO_FORMAT_AMR_WB_PLUS = 0x17000000u, + AUDIO_FORMAT_MP2 = 0x18000000u, + AUDIO_FORMAT_QCELP = 0x19000000u, + AUDIO_FORMAT_DSD = 0x1A000000u, + AUDIO_FORMAT_FLAC = 0x1B000000u, + AUDIO_FORMAT_ALAC = 0x1C000000u, + AUDIO_FORMAT_APE = 0x1D000000u, + AUDIO_FORMAT_AAC_ADTS = 0x1E000000u, + AUDIO_FORMAT_SBC = 0x1F000000u, + AUDIO_FORMAT_APTX = 0x20000000u, + AUDIO_FORMAT_APTX_HD = 0x21000000u, + AUDIO_FORMAT_AC4 = 0x22000000u, + AUDIO_FORMAT_LDAC = 0x23000000u, + AUDIO_FORMAT_MAT = 0x24000000u, + AUDIO_FORMAT_MAIN_MASK = 0xFF000000u, + AUDIO_FORMAT_SUB_MASK = 0x00FFFFFFu, + + /* Subformats */ + AUDIO_FORMAT_PCM_SUB_16_BIT = 0x1u, + AUDIO_FORMAT_PCM_SUB_8_BIT = 0x2u, + AUDIO_FORMAT_PCM_SUB_32_BIT = 0x3u, + AUDIO_FORMAT_PCM_SUB_8_24_BIT = 0x4u, + AUDIO_FORMAT_PCM_SUB_FLOAT = 0x5u, + AUDIO_FORMAT_PCM_SUB_24_BIT_PACKED = 0x6u, + + AUDIO_FORMAT_MP3_SUB_NONE = 0x0u, + + AUDIO_FORMAT_AMR_SUB_NONE = 0x0u, + + AUDIO_FORMAT_AAC_SUB_MAIN = 0x1u, + AUDIO_FORMAT_AAC_SUB_LC = 0x2u, + AUDIO_FORMAT_AAC_SUB_SSR = 0x4u, + AUDIO_FORMAT_AAC_SUB_LTP = 0x8u, + AUDIO_FORMAT_AAC_SUB_HE_V1 = 0x10u, + AUDIO_FORMAT_AAC_SUB_SCALABLE = 0x20u, + AUDIO_FORMAT_AAC_SUB_ERLC = 0x40u, + AUDIO_FORMAT_AAC_SUB_LD = 0x80u, + AUDIO_FORMAT_AAC_SUB_HE_V2 = 0x100u, + AUDIO_FORMAT_AAC_SUB_ELD = 0x200u, + AUDIO_FORMAT_AAC_SUB_XHE = 0x300u, + + AUDIO_FORMAT_VORBIS_SUB_NONE = 0x0u, + + AUDIO_FORMAT_E_AC3_SUB_JOC = 0x1u, + + AUDIO_FORMAT_MAT_SUB_1_0 = 0x1u, + AUDIO_FORMAT_MAT_SUB_2_0 = 0x2u, + AUDIO_FORMAT_MAT_SUB_2_1 = 0x3u, + + /* Aliases */ + AUDIO_FORMAT_PCM_16_BIT = 0x1u, // (PCM | PCM_SUB_16_BIT) + AUDIO_FORMAT_PCM_8_BIT = 0x2u, // (PCM | PCM_SUB_8_BIT) + AUDIO_FORMAT_PCM_32_BIT = 0x3u, // (PCM | PCM_SUB_32_BIT) + AUDIO_FORMAT_PCM_8_24_BIT = 0x4u, // (PCM | PCM_SUB_8_24_BIT) + AUDIO_FORMAT_PCM_FLOAT = 0x5u, // (PCM | PCM_SUB_FLOAT) + AUDIO_FORMAT_PCM_24_BIT_PACKED = 0x6u, // (PCM | PCM_SUB_24_BIT_PACKED) + AUDIO_FORMAT_AAC_MAIN = 0x4000001u, // (AAC | AAC_SUB_MAIN) + AUDIO_FORMAT_AAC_LC = 0x4000002u, // (AAC | AAC_SUB_LC) + AUDIO_FORMAT_AAC_SSR = 0x4000004u, // (AAC | AAC_SUB_SSR) + AUDIO_FORMAT_AAC_LTP = 0x4000008u, // (AAC | AAC_SUB_LTP) + AUDIO_FORMAT_AAC_HE_V1 = 0x4000010u, // (AAC | AAC_SUB_HE_V1) + AUDIO_FORMAT_AAC_SCALABLE = 0x4000020u, // (AAC | AAC_SUB_SCALABLE) + AUDIO_FORMAT_AAC_ERLC = 0x4000040u, // (AAC | AAC_SUB_ERLC) + AUDIO_FORMAT_AAC_LD = 0x4000080u, // (AAC | AAC_SUB_LD) + AUDIO_FORMAT_AAC_HE_V2 = 0x4000100u, // (AAC | AAC_SUB_HE_V2) + AUDIO_FORMAT_AAC_ELD = 0x4000200u, // (AAC | AAC_SUB_ELD) + AUDIO_FORMAT_AAC_XHE = 0x4000300u, // (AAC | AAC_SUB_XHE) + AUDIO_FORMAT_AAC_ADTS_MAIN = 0x1e000001u, // (AAC_ADTS | AAC_SUB_MAIN) + AUDIO_FORMAT_AAC_ADTS_LC = 0x1e000002u, // (AAC_ADTS | AAC_SUB_LC) + AUDIO_FORMAT_AAC_ADTS_SSR = 0x1e000004u, // (AAC_ADTS | AAC_SUB_SSR) + AUDIO_FORMAT_AAC_ADTS_LTP = 0x1e000008u, // (AAC_ADTS | AAC_SUB_LTP) + AUDIO_FORMAT_AAC_ADTS_HE_V1 = 0x1e000010u, // (AAC_ADTS | AAC_SUB_HE_V1) + AUDIO_FORMAT_AAC_ADTS_SCALABLE = 0x1e000020u, // (AAC_ADTS | AAC_SUB_SCALABLE) + AUDIO_FORMAT_AAC_ADTS_ERLC = 0x1e000040u, // (AAC_ADTS | AAC_SUB_ERLC) + AUDIO_FORMAT_AAC_ADTS_LD = 0x1e000080u, // (AAC_ADTS | AAC_SUB_LD) + AUDIO_FORMAT_AAC_ADTS_HE_V2 = 0x1e000100u, // (AAC_ADTS | AAC_SUB_HE_V2) + AUDIO_FORMAT_AAC_ADTS_ELD = 0x1e000200u, // (AAC_ADTS | AAC_SUB_ELD) + AUDIO_FORMAT_AAC_ADTS_XHE = 0x1e000300u, // (AAC_ADTS | AAC_SUB_XHE) + AUDIO_FORMAT_E_AC3_JOC = 0xA000001u, // (E_AC3 | E_AC3_SUB_JOC) + AUDIO_FORMAT_MAT_1_0 = 0x24000001u, // (MAT | MAT_SUB_1_0) + AUDIO_FORMAT_MAT_2_0 = 0x24000002u, // (MAT | MAT_SUB_2_0) + AUDIO_FORMAT_MAT_2_1 = 0x24000003u, // (MAT | MAT_SUB_2_1) +} audio_format_t; + +enum { + FCC_2 = 2, + FCC_8 = 8, +}; + +enum { + AUDIO_CHANNEL_REPRESENTATION_POSITION = 0x0u, + AUDIO_CHANNEL_REPRESENTATION_INDEX = 0x2u, + AUDIO_CHANNEL_NONE = 0x0u, + AUDIO_CHANNEL_INVALID = 0xC0000000u, + + AUDIO_CHANNEL_OUT_FRONT_LEFT = 0x1u, + AUDIO_CHANNEL_OUT_FRONT_RIGHT = 0x2u, + AUDIO_CHANNEL_OUT_FRONT_CENTER = 0x4u, + AUDIO_CHANNEL_OUT_LOW_FREQUENCY = 0x8u, + AUDIO_CHANNEL_OUT_BACK_LEFT = 0x10u, + AUDIO_CHANNEL_OUT_BACK_RIGHT = 0x20u, + AUDIO_CHANNEL_OUT_FRONT_LEFT_OF_CENTER = 0x40u, + AUDIO_CHANNEL_OUT_FRONT_RIGHT_OF_CENTER = 0x80u, + AUDIO_CHANNEL_OUT_BACK_CENTER = 0x100u, + AUDIO_CHANNEL_OUT_SIDE_LEFT = 0x200u, + AUDIO_CHANNEL_OUT_SIDE_RIGHT = 0x400u, + AUDIO_CHANNEL_OUT_TOP_CENTER = 0x800u, + AUDIO_CHANNEL_OUT_TOP_FRONT_LEFT = 0x1000u, + AUDIO_CHANNEL_OUT_TOP_FRONT_CENTER = 0x2000u, + AUDIO_CHANNEL_OUT_TOP_FRONT_RIGHT = 0x4000u, + AUDIO_CHANNEL_OUT_TOP_BACK_LEFT = 0x8000u, + AUDIO_CHANNEL_OUT_TOP_BACK_CENTER = 0x10000u, + AUDIO_CHANNEL_OUT_TOP_BACK_RIGHT = 0x20000u, + AUDIO_CHANNEL_OUT_TOP_SIDE_LEFT = 0x40000u, + AUDIO_CHANNEL_OUT_TOP_SIDE_RIGHT = 0x80000u, + AUDIO_CHANNEL_OUT_MONO = 0x1u, // OUT_FRONT_LEFT + AUDIO_CHANNEL_OUT_STEREO = 0x3u, // OUT_FRONT_LEFT | OUT_FRONT_RIGHT + AUDIO_CHANNEL_OUT_2POINT1 = 0xBu, // OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_LOW_FREQUENCY + AUDIO_CHANNEL_OUT_2POINT0POINT2 = 0xC0003u, // OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT + AUDIO_CHANNEL_OUT_2POINT1POINT2 = 0xC000Bu, // OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT | OUT_LOW_FREQUENCY + AUDIO_CHANNEL_OUT_3POINT0POINT2 = 0xC0007u, // OUT_FRONT_LEFT | OUT_FRONT_CENTER | OUT_FRONT_RIGHT | OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT + AUDIO_CHANNEL_OUT_3POINT1POINT2 = 0xC000Fu, // OUT_FRONT_LEFT | OUT_FRONT_CENTER | OUT_FRONT_RIGHT | OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT | OUT_LOW_FREQUENCY + AUDIO_CHANNEL_OUT_QUAD = 0x33u, // OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_BACK_LEFT | OUT_BACK_RIGHT + AUDIO_CHANNEL_OUT_QUAD_BACK = 0x33u, // OUT_QUAD + AUDIO_CHANNEL_OUT_QUAD_SIDE = 0x603u, // OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_SIDE_LEFT | OUT_SIDE_RIGHT + AUDIO_CHANNEL_OUT_SURROUND = 0x107u, // OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_FRONT_CENTER | OUT_BACK_CENTER + AUDIO_CHANNEL_OUT_PENTA = 0x37u, // OUT_QUAD | OUT_FRONT_CENTER + AUDIO_CHANNEL_OUT_5POINT1 = 0x3Fu, // OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_FRONT_CENTER | OUT_LOW_FREQUENCY | OUT_BACK_LEFT | OUT_BACK_RIGHT + AUDIO_CHANNEL_OUT_5POINT1_BACK = 0x3Fu, // OUT_5POINT1 + AUDIO_CHANNEL_OUT_5POINT1_SIDE = 0x60Fu, // OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_FRONT_CENTER | OUT_LOW_FREQUENCY | OUT_SIDE_LEFT | OUT_SIDE_RIGHT + AUDIO_CHANNEL_OUT_5POINT1POINT2 = 0xC003Fu, // OUT_5POINT1 | OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT + AUDIO_CHANNEL_OUT_5POINT1POINT4 = 0x2D03Fu, // OUT_5POINT1 | OUT_TOP_FRONT_LEFT | OUT_TOP_FRONT_RIGHT | OUT_TOP_BACK_LEFT | OUT_TOP_BACK_RIGHT + AUDIO_CHANNEL_OUT_6POINT1 = 0x13Fu, // OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_FRONT_CENTER | OUT_LOW_FREQUENCY | OUT_BACK_LEFT | OUT_BACK_RIGHT | OUT_BACK_CENTER + AUDIO_CHANNEL_OUT_7POINT1 = 0x63Fu, // OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_FRONT_CENTER | OUT_LOW_FREQUENCY | OUT_BACK_LEFT | OUT_BACK_RIGHT | OUT_SIDE_LEFT | OUT_SIDE_RIGHT + AUDIO_CHANNEL_OUT_7POINT1POINT2 = 0xC063Fu, // OUT_7POINT1 | OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT + AUDIO_CHANNEL_OUT_7POINT1POINT4 = 0x2D63Fu, // OUT_7POINT1 | OUT_TOP_FRONT_LEFT | OUT_TOP_FRONT_RIGHT | OUT_TOP_BACK_LEFT | OUT_TOP_BACK_RIGHT + + AUDIO_CHANNEL_IN_LEFT = 0x4u, + AUDIO_CHANNEL_IN_RIGHT = 0x8u, + AUDIO_CHANNEL_IN_FRONT = 0x10u, + AUDIO_CHANNEL_IN_BACK = 0x20u, + AUDIO_CHANNEL_IN_LEFT_PROCESSED = 0x40u, + AUDIO_CHANNEL_IN_RIGHT_PROCESSED = 0x80u, + AUDIO_CHANNEL_IN_FRONT_PROCESSED = 0x100u, + AUDIO_CHANNEL_IN_BACK_PROCESSED = 0x200u, + AUDIO_CHANNEL_IN_PRESSURE = 0x400u, + AUDIO_CHANNEL_IN_X_AXIS = 0x800u, + AUDIO_CHANNEL_IN_Y_AXIS = 0x1000u, + AUDIO_CHANNEL_IN_Z_AXIS = 0x2000u, + AUDIO_CHANNEL_IN_BACK_LEFT = 0x10000u, + AUDIO_CHANNEL_IN_BACK_RIGHT = 0x20000u, + AUDIO_CHANNEL_IN_CENTER = 0x40000u, + AUDIO_CHANNEL_IN_LOW_FREQUENCY = 0x100000u, + AUDIO_CHANNEL_IN_TOP_LEFT = 0x200000u, + AUDIO_CHANNEL_IN_TOP_RIGHT = 0x400000u, + AUDIO_CHANNEL_IN_VOICE_UPLINK = 0x4000u, + AUDIO_CHANNEL_IN_VOICE_DNLINK = 0x8000u, + AUDIO_CHANNEL_IN_MONO = 0x10u, // IN_FRONT + AUDIO_CHANNEL_IN_STEREO = 0xCu, // IN_LEFT | IN_RIGHT + AUDIO_CHANNEL_IN_FRONT_BACK = 0x30u, // IN_FRONT | IN_BACK + AUDIO_CHANNEL_IN_6 = 0xFCu, // IN_LEFT | IN_RIGHT | IN_FRONT | IN_BACK | IN_LEFT_PROCESSED | IN_RIGHT_PROCESSED + AUDIO_CHANNEL_IN_2POINT0POINT2 = 0x60000Cu, // IN_LEFT | IN_RIGHT | IN_TOP_LEFT | IN_TOP_RIGHT + AUDIO_CHANNEL_IN_2POINT1POINT2 = 0x70000Cu, // IN_LEFT | IN_RIGHT | IN_TOP_LEFT | IN_TOP_RIGHT | IN_LOW_FREQUENCY + AUDIO_CHANNEL_IN_3POINT0POINT2 = 0x64000Cu, // IN_LEFT | IN_CENTER | IN_RIGHT | IN_TOP_LEFT | IN_TOP_RIGHT + AUDIO_CHANNEL_IN_3POINT1POINT2 = 0x74000Cu, // IN_LEFT | IN_CENTER | IN_RIGHT | IN_TOP_LEFT | IN_TOP_RIGHT | IN_LOW_FREQUENCY + AUDIO_CHANNEL_IN_5POINT1 = 0x17000Cu, // IN_LEFT | IN_CENTER | IN_RIGHT | IN_BACK_LEFT | IN_BACK_RIGHT | IN_LOW_FREQUENCY + AUDIO_CHANNEL_IN_VOICE_UPLINK_MONO = 0x4010u, // IN_VOICE_UPLINK | IN_MONO + AUDIO_CHANNEL_IN_VOICE_DNLINK_MONO = 0x8010u, // IN_VOICE_DNLINK | IN_MONO + AUDIO_CHANNEL_IN_VOICE_CALL_MONO = 0xC010u, // IN_VOICE_UPLINK_MONO | IN_VOICE_DNLINK_MONO + + AUDIO_CHANNEL_COUNT_MAX = 30u, + AUDIO_CHANNEL_INDEX_HDR = 0x80000000u, // REPRESENTATION_INDEX << COUNT_MAX + AUDIO_CHANNEL_INDEX_MASK_1 = 0x80000001u, // INDEX_HDR | (1 << 1) - 1 + AUDIO_CHANNEL_INDEX_MASK_2 = 0x80000003u, // INDEX_HDR | (1 << 2) - 1 + AUDIO_CHANNEL_INDEX_MASK_3 = 0x80000007u, // INDEX_HDR | (1 << 3) - 1 + AUDIO_CHANNEL_INDEX_MASK_4 = 0x8000000Fu, // INDEX_HDR | (1 << 4) - 1 + AUDIO_CHANNEL_INDEX_MASK_5 = 0x8000001Fu, // INDEX_HDR | (1 << 5) - 1 + AUDIO_CHANNEL_INDEX_MASK_6 = 0x8000003Fu, // INDEX_HDR | (1 << 6) - 1 + AUDIO_CHANNEL_INDEX_MASK_7 = 0x8000007Fu, // INDEX_HDR | (1 << 7) - 1 + AUDIO_CHANNEL_INDEX_MASK_8 = 0x800000FFu, // INDEX_HDR | (1 << 8) - 1 +}; + +typedef enum { +#ifndef AUDIO_NO_SYSTEM_DECLARATIONS + AUDIO_MODE_INVALID = -2, // (-2) + AUDIO_MODE_CURRENT = -1, // (-1) +#endif // AUDIO_NO_SYSTEM_DECLARATIONS + AUDIO_MODE_NORMAL = 0, + AUDIO_MODE_RINGTONE = 1, + AUDIO_MODE_IN_CALL = 2, + AUDIO_MODE_IN_COMMUNICATION = 3, +} audio_mode_t; + +enum { + AUDIO_DEVICE_NONE = 0x0u, + AUDIO_DEVICE_BIT_IN = 0x80000000u, + AUDIO_DEVICE_BIT_DEFAULT = 0x40000000u, + + AUDIO_DEVICE_OUT_EARPIECE = 0x1u, + AUDIO_DEVICE_OUT_SPEAKER = 0x2u, + AUDIO_DEVICE_OUT_WIRED_HEADSET = 0x4u, + AUDIO_DEVICE_OUT_WIRED_HEADPHONE = 0x8u, + AUDIO_DEVICE_OUT_BLUETOOTH_SCO = 0x10u, + AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET = 0x20u, + AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT = 0x40u, + AUDIO_DEVICE_OUT_BLUETOOTH_A2DP = 0x80u, + AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES = 0x100u, + AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER = 0x200u, + AUDIO_DEVICE_OUT_AUX_DIGITAL = 0x400u, + AUDIO_DEVICE_OUT_HDMI = 0x400u, // OUT_AUX_DIGITAL + AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET = 0x800u, + AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET = 0x1000u, + AUDIO_DEVICE_OUT_USB_ACCESSORY = 0x2000u, + AUDIO_DEVICE_OUT_USB_DEVICE = 0x4000u, + AUDIO_DEVICE_OUT_REMOTE_SUBMIX = 0x8000u, + AUDIO_DEVICE_OUT_TELEPHONY_TX = 0x10000u, + AUDIO_DEVICE_OUT_LINE = 0x20000u, + AUDIO_DEVICE_OUT_HDMI_ARC = 0x40000u, + AUDIO_DEVICE_OUT_SPDIF = 0x80000u, + AUDIO_DEVICE_OUT_FM = 0x100000u, + AUDIO_DEVICE_OUT_AUX_LINE = 0x200000u, + AUDIO_DEVICE_OUT_SPEAKER_SAFE = 0x400000u, + AUDIO_DEVICE_OUT_IP = 0x800000u, + AUDIO_DEVICE_OUT_BUS = 0x1000000u, + AUDIO_DEVICE_OUT_PROXY = 0x2000000u, + AUDIO_DEVICE_OUT_USB_HEADSET = 0x4000000u, + AUDIO_DEVICE_OUT_HEARING_AID = 0x8000000u, + AUDIO_DEVICE_OUT_ECHO_CANCELLER = 0x10000000u, + AUDIO_DEVICE_OUT_DEFAULT = 0x40000000u, // BIT_DEFAULT + + AUDIO_DEVICE_IN_COMMUNICATION = 0x80000001u, // BIT_IN | 0x1 + AUDIO_DEVICE_IN_AMBIENT = 0x80000002u, // BIT_IN | 0x2 + AUDIO_DEVICE_IN_BUILTIN_MIC = 0x80000004u, // BIT_IN | 0x4 + AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET = 0x80000008u, // BIT_IN | 0x8 + AUDIO_DEVICE_IN_WIRED_HEADSET = 0x80000010u, // BIT_IN | 0x10 + AUDIO_DEVICE_IN_AUX_DIGITAL = 0x80000020u, // BIT_IN | 0x20 + AUDIO_DEVICE_IN_HDMI = 0x80000020u, // IN_AUX_DIGITAL + AUDIO_DEVICE_IN_VOICE_CALL = 0x80000040u, // BIT_IN | 0x40 + AUDIO_DEVICE_IN_TELEPHONY_RX = 0x80000040u, // IN_VOICE_CALL + AUDIO_DEVICE_IN_BACK_MIC = 0x80000080u, // BIT_IN | 0x80 + AUDIO_DEVICE_IN_REMOTE_SUBMIX = 0x80000100u, // BIT_IN | 0x100 + AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET = 0x80000200u, // BIT_IN | 0x200 + AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET = 0x80000400u, // BIT_IN | 0x400 + AUDIO_DEVICE_IN_USB_ACCESSORY = 0x80000800u, // BIT_IN | 0x800 + AUDIO_DEVICE_IN_USB_DEVICE = 0x80001000u, // BIT_IN | 0x1000 + AUDIO_DEVICE_IN_FM_TUNER = 0x80002000u, // BIT_IN | 0x2000 + AUDIO_DEVICE_IN_TV_TUNER = 0x80004000u, // BIT_IN | 0x4000 + AUDIO_DEVICE_IN_LINE = 0x80008000u, // BIT_IN | 0x8000 + AUDIO_DEVICE_IN_SPDIF = 0x80010000u, // BIT_IN | 0x10000 + AUDIO_DEVICE_IN_BLUETOOTH_A2DP = 0x80020000u, // BIT_IN | 0x20000 + AUDIO_DEVICE_IN_LOOPBACK = 0x80040000u, // BIT_IN | 0x40000 + AUDIO_DEVICE_IN_IP = 0x80080000u, // BIT_IN | 0x80000 + AUDIO_DEVICE_IN_BUS = 0x80100000u, // BIT_IN | 0x100000 + AUDIO_DEVICE_IN_PROXY = 0x81000000u, // BIT_IN | 0x1000000 + AUDIO_DEVICE_IN_USB_HEADSET = 0x82000000u, // BIT_IN | 0x2000000 + AUDIO_DEVICE_IN_BLUETOOTH_BLE = 0x84000000u, // BIT_IN | 0x4000000 + AUDIO_DEVICE_IN_DEFAULT = 0xC0000000u, // BIT_IN | BIT_DEFAULT +}; + +typedef enum { + AUDIO_OUTPUT_FLAG_NONE = 0x0, + AUDIO_OUTPUT_FLAG_DIRECT = 0x1, + AUDIO_OUTPUT_FLAG_PRIMARY = 0x2, + AUDIO_OUTPUT_FLAG_FAST = 0x4, + AUDIO_OUTPUT_FLAG_DEEP_BUFFER = 0x8, + AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD = 0x10, + AUDIO_OUTPUT_FLAG_NON_BLOCKING = 0x20, + AUDIO_OUTPUT_FLAG_HW_AV_SYNC = 0x40, + AUDIO_OUTPUT_FLAG_TTS = 0x80, + AUDIO_OUTPUT_FLAG_RAW = 0x100, + AUDIO_OUTPUT_FLAG_SYNC = 0x200, + AUDIO_OUTPUT_FLAG_IEC958_NONAUDIO = 0x400, + AUDIO_OUTPUT_FLAG_DIRECT_PCM = 0x2000, + AUDIO_OUTPUT_FLAG_MMAP_NOIRQ = 0x4000, + AUDIO_OUTPUT_FLAG_VOIP_RX = 0x8000, + AUDIO_OUTPUT_FLAG_INCALL_MUSIC = 0x10000, +} audio_output_flags_t; + +typedef enum { + AUDIO_INPUT_FLAG_NONE = 0x0, + AUDIO_INPUT_FLAG_FAST = 0x1, + AUDIO_INPUT_FLAG_HW_HOTWORD = 0x2, + AUDIO_INPUT_FLAG_RAW = 0x4, + AUDIO_INPUT_FLAG_SYNC = 0x8, + AUDIO_INPUT_FLAG_MMAP_NOIRQ = 0x10, + AUDIO_INPUT_FLAG_VOIP_TX = 0x20, + AUDIO_INPUT_FLAG_HW_AV_SYNC = 0x40, +} audio_input_flags_t; + +typedef enum { + AUDIO_USAGE_UNKNOWN = 0, + AUDIO_USAGE_MEDIA = 1, + AUDIO_USAGE_VOICE_COMMUNICATION = 2, + AUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING = 3, + AUDIO_USAGE_ALARM = 4, + AUDIO_USAGE_NOTIFICATION = 5, + AUDIO_USAGE_NOTIFICATION_TELEPHONY_RINGTONE = 6, +#ifndef AUDIO_NO_SYSTEM_DECLARATIONS + AUDIO_USAGE_NOTIFICATION_COMMUNICATION_REQUEST = 7, + AUDIO_USAGE_NOTIFICATION_COMMUNICATION_INSTANT = 8, + AUDIO_USAGE_NOTIFICATION_COMMUNICATION_DELAYED = 9, + AUDIO_USAGE_NOTIFICATION_EVENT = 10, +#endif // AUDIO_NO_SYSTEM_DECLARATIONS + AUDIO_USAGE_ASSISTANCE_ACCESSIBILITY = 11, + AUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE = 12, + AUDIO_USAGE_ASSISTANCE_SONIFICATION = 13, + AUDIO_USAGE_GAME = 14, + AUDIO_USAGE_VIRTUAL_SOURCE = 15, + AUDIO_USAGE_ASSISTANT = 16, +} audio_usage_t; + +typedef enum { + AUDIO_CONTENT_TYPE_UNKNOWN = 0u, + AUDIO_CONTENT_TYPE_SPEECH = 1u, + AUDIO_CONTENT_TYPE_MUSIC = 2u, + AUDIO_CONTENT_TYPE_MOVIE = 3u, + AUDIO_CONTENT_TYPE_SONIFICATION = 4u, +} audio_content_type_t; + +enum { + AUDIO_GAIN_MODE_JOINT = 0x1u, + AUDIO_GAIN_MODE_CHANNELS = 0x2u, + AUDIO_GAIN_MODE_RAMP = 0x4u, +}; + +typedef enum { + AUDIO_PORT_ROLE_NONE = 0, + AUDIO_PORT_ROLE_SOURCE = 1, // (::android::hardware::audio::common::V4_0::AudioPortRole.NONE implicitly + 1) + AUDIO_PORT_ROLE_SINK = 2, // (::android::hardware::audio::common::V4_0::AudioPortRole.SOURCE implicitly + 1) +} audio_port_role_t; + +typedef enum { + AUDIO_PORT_TYPE_NONE = 0, + AUDIO_PORT_TYPE_DEVICE = 1, // (::android::hardware::audio::common::V4_0::AudioPortType.NONE implicitly + 1) + AUDIO_PORT_TYPE_MIX = 2, // (::android::hardware::audio::common::V4_0::AudioPortType.DEVICE implicitly + 1) + AUDIO_PORT_TYPE_SESSION = 3, // (::android::hardware::audio::common::V4_0::AudioPortType.MIX implicitly + 1) +} audio_port_type_t; + +enum { + AUDIO_PORT_CONFIG_SAMPLE_RATE = 0x1u, + AUDIO_PORT_CONFIG_CHANNEL_MASK = 0x2u, + AUDIO_PORT_CONFIG_FORMAT = 0x4u, + AUDIO_PORT_CONFIG_GAIN = 0x8u, +}; + +typedef enum { + AUDIO_LATENCY_LOW = 0, + AUDIO_LATENCY_NORMAL = 1, // (::android::hardware::audio::common::V4_0::AudioMixLatencyClass.LOW implicitly + 1) +} audio_mix_latency_class_t; + +#ifdef __cplusplus +} +#endif + +#endif // HIDL_GENERATED_ANDROID_HARDWARE_AUDIO_COMMON_V4_0_EXPORTED_CONSTANTS_H_ diff --git a/system/audio.h b/system/audio.h index a5ed774..0097264 100644 --- a/system/audio.h +++ b/system/audio.h @@ -26,100 +26,23 @@ #include -__BEGIN_DECLS - -/* The macro FCC_2 highlights places where there are 2-channel assumptions. - * This is typically due to legacy implementation of stereo input or output. - * Search also for "2", "left", "right", "[0]", "[1]", ">> 16", "<< 16", etc. - * Do not change this value. - */ -#define FCC_2 2 // FCC_2 = Fixed Channel Count 2 +#include "audio-base.h" +#include "audio-base-utils.h" -/* The macro FCC_8 highlights places where there are 8-channel assumptions. - * This is typically due to audio mixer and resampler limitations. - * Do not change this value without verifying all locations that use it. - */ -#define FCC_8 8 // FCC_8 = Fixed Channel Count 8 +__BEGIN_DECLS /* The enums were moved here mostly from * frameworks/base/include/media/AudioSystem.h */ +/* represents an invalid uid for tracks; the calling or client uid is often substituted. */ +#define AUDIO_UID_INVALID ((uid_t)-1) + /* device address used to refer to the standard remote submix */ #define AUDIO_REMOTE_SUBMIX_DEVICE_ADDRESS "0" /* AudioFlinger and AudioPolicy services use I/O handles to identify audio sources and sinks */ typedef int audio_io_handle_t; -#define AUDIO_IO_HANDLE_NONE 0 - -/* Audio stream types */ -typedef enum { - /* These values must kept in sync with - * frameworks/base/media/java/android/media/AudioSystem.java - */ - AUDIO_STREAM_DEFAULT = -1, - AUDIO_STREAM_MIN = 0, - AUDIO_STREAM_VOICE_CALL = 0, - AUDIO_STREAM_SYSTEM = 1, - AUDIO_STREAM_RING = 2, - AUDIO_STREAM_MUSIC = 3, - AUDIO_STREAM_ALARM = 4, - AUDIO_STREAM_NOTIFICATION = 5, - AUDIO_STREAM_BLUETOOTH_SCO = 6, - AUDIO_STREAM_ENFORCED_AUDIBLE = 7, /* Sounds that cannot be muted by user - * and must be routed to speaker - */ - AUDIO_STREAM_DTMF = 8, - AUDIO_STREAM_TTS = 9, /* Transmitted Through Speaker. - * Plays over speaker only, silent on other devices. - */ - AUDIO_STREAM_ACCESSIBILITY = 10, /* For accessibility talk back prompts */ - AUDIO_STREAM_REROUTING = 11, /* For dynamic policy output mixes */ - AUDIO_STREAM_PATCH = 12, /* For internal audio flinger tracks. Fixed volume */ - AUDIO_STREAM_PUBLIC_CNT = AUDIO_STREAM_TTS + 1, - AUDIO_STREAM_FOR_POLICY_CNT = AUDIO_STREAM_PATCH, /* number of streams considered by - audio policy for volume and routing */ - AUDIO_STREAM_CNT = AUDIO_STREAM_PATCH + 1, -} audio_stream_type_t; - -/* Do not change these values without updating their counterparts - * in frameworks/base/media/java/android/media/AudioAttributes.java - */ -typedef enum { - AUDIO_CONTENT_TYPE_UNKNOWN = 0, - AUDIO_CONTENT_TYPE_SPEECH = 1, - AUDIO_CONTENT_TYPE_MUSIC = 2, - AUDIO_CONTENT_TYPE_MOVIE = 3, - AUDIO_CONTENT_TYPE_SONIFICATION = 4, - - AUDIO_CONTENT_TYPE_CNT, - AUDIO_CONTENT_TYPE_MAX = AUDIO_CONTENT_TYPE_CNT - 1, -} audio_content_type_t; - -/* Do not change these values without updating their counterparts - * in frameworks/base/media/java/android/media/AudioAttributes.java - */ -typedef enum { - AUDIO_USAGE_UNKNOWN = 0, - AUDIO_USAGE_MEDIA = 1, - AUDIO_USAGE_VOICE_COMMUNICATION = 2, - AUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING = 3, - AUDIO_USAGE_ALARM = 4, - AUDIO_USAGE_NOTIFICATION = 5, - AUDIO_USAGE_NOTIFICATION_TELEPHONY_RINGTONE = 6, - AUDIO_USAGE_NOTIFICATION_COMMUNICATION_REQUEST = 7, - AUDIO_USAGE_NOTIFICATION_COMMUNICATION_INSTANT = 8, - AUDIO_USAGE_NOTIFICATION_COMMUNICATION_DELAYED = 9, - AUDIO_USAGE_NOTIFICATION_EVENT = 10, - AUDIO_USAGE_ASSISTANCE_ACCESSIBILITY = 11, - AUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE = 12, - AUDIO_USAGE_ASSISTANCE_SONIFICATION = 13, - AUDIO_USAGE_GAME = 14, - AUDIO_USAGE_VIRTUAL_SOURCE = 15, - - AUDIO_USAGE_CNT, - AUDIO_USAGE_MAX = AUDIO_USAGE_CNT - 1, -} audio_usage_t; typedef uint32_t audio_flags_mask_t; @@ -127,6 +50,7 @@ typedef uint32_t audio_flags_mask_t; * in frameworks/base/media/java/android/media/AudioAttributes.java */ enum { + AUDIO_FLAG_NONE = 0x0, AUDIO_FLAG_AUDIBILITY_ENFORCED = 0x1, AUDIO_FLAG_SECURE = 0x2, AUDIO_FLAG_SCO = 0x4, @@ -136,39 +60,9 @@ enum { AUDIO_FLAG_BYPASS_INTERRUPTION_POLICY = 0x40, AUDIO_FLAG_BYPASS_MUTE = 0x80, AUDIO_FLAG_LOW_LATENCY = 0x100, + AUDIO_FLAG_DEEP_BUFFER = 0x200, }; -/* Do not change these values without updating their counterparts - * in frameworks/base/media/java/android/media/MediaRecorder.java, - * frameworks/av/services/audiopolicy/AudioPolicyService.cpp, - * and system/media/audio_effects/include/audio_effects/audio_effects_conf.h! - */ -typedef enum { - AUDIO_SOURCE_DEFAULT = 0, - AUDIO_SOURCE_MIC = 1, - AUDIO_SOURCE_VOICE_UPLINK = 2, - AUDIO_SOURCE_VOICE_DOWNLINK = 3, - AUDIO_SOURCE_VOICE_CALL = 4, - AUDIO_SOURCE_CAMCORDER = 5, - AUDIO_SOURCE_VOICE_RECOGNITION = 6, - AUDIO_SOURCE_VOICE_COMMUNICATION = 7, - AUDIO_SOURCE_REMOTE_SUBMIX = 8, /* Source for the mix to be presented remotely. */ - /* An example of remote presentation is Wifi Display */ - /* where a dongle attached to a TV can be used to */ - /* play the mix captured by this audio source. */ - AUDIO_SOURCE_UNPROCESSED = 9, /* Source for unprocessed sound. - Usage examples include level measurement and raw - signal analysis. */ - AUDIO_SOURCE_CNT, - AUDIO_SOURCE_MAX = AUDIO_SOURCE_CNT - 1, - AUDIO_SOURCE_FM_TUNER = 1998, - AUDIO_SOURCE_HOTWORD = 1999, /* A low-priority, preemptible audio source for - for background software hotword detection. - Same tuning as AUDIO_SOURCE_VOICE_RECOGNITION. - Used only internally to the framework. Not exposed - at the audio HAL. */ -} audio_source_t; - /* Audio attributes */ #define AUDIO_ATTRIBUTES_TAGS_MAX_SIZE 256 typedef struct { @@ -177,37 +71,7 @@ typedef struct { audio_source_t source; audio_flags_mask_t flags; char tags[AUDIO_ATTRIBUTES_TAGS_MAX_SIZE]; /* UTF8 */ -} audio_attributes_t; - -/* special audio session values - * do not need to have audio_unique_id_get_use(session) == AUDIO_UNIQUE_ID_USE_SESSION - * (XXX: should this be living in the audio effects land?) - */ -typedef enum { - /* session for effects attached to a particular output stream - * (value must be less than 0) - */ - AUDIO_SESSION_OUTPUT_STAGE = -1, - - /* session for effects applied to output mix. These effects can - * be moved by audio policy manager to another output stream - * (value must be 0) - */ - AUDIO_SESSION_OUTPUT_MIX = 0, - - /* application does not specify an explicit session ID to be used, - * and requests a new session ID to be allocated - * TODO use unique values for AUDIO_SESSION_OUTPUT_MIX and AUDIO_SESSION_ALLOCATE, - * after all uses have been updated from 0 to the appropriate symbol, and have been tested. - * Corresponds to AudioManager.AUDIO_SESSION_ID_GENERATE and AudioSystem.AUDIO_SESSION_ALLOCATE. - */ - AUDIO_SESSION_ALLOCATE = 0, - - /* For use with AudioRecord::start(), this indicates no trigger session. - * It is also used with output tracks and patch tracks, which never have a session. - */ - AUDIO_SESSION_NONE = 0, -} audio_session_t; +} __attribute__((packed)) audio_attributes_t; // sent through Binder; /* a unique ID allocated by AudioFlinger for use as an audio_io_handle_t, audio_session_t, * effect ID (int), audio_module_handle_t, and audio_patch_handle_t. @@ -225,7 +89,7 @@ typedef enum { AUDIO_UNIQUE_ID_USE_PATCH = 4, AUDIO_UNIQUE_ID_USE_OUTPUT = 5, AUDIO_UNIQUE_ID_USE_INPUT = 6, - // 7 is available + AUDIO_UNIQUE_ID_USE_PLAYER = 7, AUDIO_UNIQUE_ID_USE_MAX = 8, // must be a power-of-two AUDIO_UNIQUE_ID_USE_MASK = AUDIO_UNIQUE_ID_USE_MAX - 1 } audio_unique_id_use_t; @@ -239,323 +103,6 @@ static inline audio_unique_id_use_t audio_unique_id_get_use(audio_unique_id_t id /* Reserved audio_unique_id_t values. FIXME: not a complete list. */ #define AUDIO_UNIQUE_ID_ALLOCATE AUDIO_SESSION_ALLOCATE -/* Audio sub formats (see enum audio_format). */ - -/* PCM sub formats */ -typedef enum { - /* All of these are in native byte order */ - AUDIO_FORMAT_PCM_SUB_16_BIT = 0x1, /* DO NOT CHANGE - PCM signed 16 bits */ - AUDIO_FORMAT_PCM_SUB_8_BIT = 0x2, /* DO NOT CHANGE - PCM unsigned 8 bits */ - AUDIO_FORMAT_PCM_SUB_32_BIT = 0x3, /* PCM signed .31 fixed point */ - AUDIO_FORMAT_PCM_SUB_8_24_BIT = 0x4, /* PCM signed 8.23 fixed point */ - AUDIO_FORMAT_PCM_SUB_FLOAT = 0x5, /* PCM single-precision floating point */ - AUDIO_FORMAT_PCM_SUB_24_BIT_PACKED = 0x6, /* PCM signed .23 fixed point packed in 3 bytes */ -} audio_format_pcm_sub_fmt_t; - -/* The audio_format_*_sub_fmt_t declarations are not currently used */ - -/* MP3 sub format field definition : can use 11 LSBs in the same way as MP3 - * frame header to specify bit rate, stereo mode, version... - */ -typedef enum { - AUDIO_FORMAT_MP3_SUB_NONE = 0x0, -} audio_format_mp3_sub_fmt_t; - -/* AMR NB/WB sub format field definition: specify frame block interleaving, - * bandwidth efficient or octet aligned, encoding mode for recording... - */ -typedef enum { - AUDIO_FORMAT_AMR_SUB_NONE = 0x0, -} audio_format_amr_sub_fmt_t; - -/* AAC sub format field definition: specify profile or bitrate for recording... */ -typedef enum { - AUDIO_FORMAT_AAC_SUB_MAIN = 0x1, - AUDIO_FORMAT_AAC_SUB_LC = 0x2, - AUDIO_FORMAT_AAC_SUB_SSR = 0x4, - AUDIO_FORMAT_AAC_SUB_LTP = 0x8, - AUDIO_FORMAT_AAC_SUB_HE_V1 = 0x10, - AUDIO_FORMAT_AAC_SUB_SCALABLE = 0x20, - AUDIO_FORMAT_AAC_SUB_ERLC = 0x40, - AUDIO_FORMAT_AAC_SUB_LD = 0x80, - AUDIO_FORMAT_AAC_SUB_HE_V2 = 0x100, - AUDIO_FORMAT_AAC_SUB_ELD = 0x200, -} audio_format_aac_sub_fmt_t; - -/* VORBIS sub format field definition: specify quality for recording... */ -typedef enum { - AUDIO_FORMAT_VORBIS_SUB_NONE = 0x0, -} audio_format_vorbis_sub_fmt_t; - - -/* Audio format is a 32-bit word that consists of: - * main format field (upper 8 bits) - * sub format field (lower 24 bits). - * - * The main format indicates the main codec type. The sub format field - * indicates options and parameters for each format. The sub format is mainly - * used for record to indicate for instance the requested bitrate or profile. - * It can also be used for certain formats to give informations not present in - * the encoded audio stream (e.g. octet alignement for AMR). - */ -typedef enum { - AUDIO_FORMAT_INVALID = 0xFFFFFFFFUL, - AUDIO_FORMAT_DEFAULT = 0, - AUDIO_FORMAT_PCM = 0x00000000UL, /* DO NOT CHANGE */ - AUDIO_FORMAT_MP3 = 0x01000000UL, - AUDIO_FORMAT_AMR_NB = 0x02000000UL, - AUDIO_FORMAT_AMR_WB = 0x03000000UL, - AUDIO_FORMAT_AAC = 0x04000000UL, - AUDIO_FORMAT_HE_AAC_V1 = 0x05000000UL, /* Deprecated, Use AUDIO_FORMAT_AAC_HE_V1*/ - AUDIO_FORMAT_HE_AAC_V2 = 0x06000000UL, /* Deprecated, Use AUDIO_FORMAT_AAC_HE_V2*/ - AUDIO_FORMAT_VORBIS = 0x07000000UL, - AUDIO_FORMAT_OPUS = 0x08000000UL, - AUDIO_FORMAT_AC3 = 0x09000000UL, - AUDIO_FORMAT_E_AC3 = 0x0A000000UL, - AUDIO_FORMAT_DTS = 0x0B000000UL, - AUDIO_FORMAT_DTS_HD = 0x0C000000UL, - // IEC61937 is encoded audio wrapped in 16-bit PCM. - AUDIO_FORMAT_IEC61937 = 0x0D000000UL, - AUDIO_FORMAT_EVRC = 0x10000000UL, - AUDIO_FORMAT_QCELP = 0x11000000UL, - AUDIO_FORMAT_WMA = 0x12000000UL, - AUDIO_FORMAT_WMA_PRO = 0x13000000UL, - AUDIO_FORMAT_AAC_ADIF = 0x14000000UL, - AUDIO_FORMAT_EVRCB = 0x15000000UL, - AUDIO_FORMAT_EVRCWB = 0x16000000UL, - AUDIO_FORMAT_AMR_WB_PLUS = 0x17000000UL, - AUDIO_FORMAT_MP2 = 0x18000000UL, - AUDIO_FORMAT_EVRCNW = 0x19000000UL, - AUDIO_FORMAT_PCM_OFFLOAD = 0x1A000000UL, - AUDIO_FORMAT_FLAC = 0x1B000000UL, - AUDIO_FORMAT_ALAC = 0x1C000000UL, - AUDIO_FORMAT_APE = 0x1D000000UL, - AUDIO_FORMAT_AAC_ADTS = 0x1E000000UL, - AUDIO_FORMAT_DSD = 0x1F000000UL, - AUDIO_FORMAT_SBC = 0x20000000UL, - AUDIO_FORMAT_APTX = 0x21000000UL, - AUDIO_FORMAT_APTX_HD = 0x22000000UL, - - AUDIO_FORMAT_DOLBY_TRUEHD = 0x0E000000UL, - AUDIO_FORMAT_MAIN_MASK = 0xFF000000UL, /* Deprecated. Use audio_get_main_format() */ - AUDIO_FORMAT_SUB_MASK = 0x00FFFFFFUL, - - /* Aliases */ - /* note != AudioFormat.ENCODING_PCM_16BIT */ - AUDIO_FORMAT_PCM_16_BIT = (AUDIO_FORMAT_PCM | - AUDIO_FORMAT_PCM_SUB_16_BIT), - /* note != AudioFormat.ENCODING_PCM_8BIT */ - AUDIO_FORMAT_PCM_8_BIT = (AUDIO_FORMAT_PCM | - AUDIO_FORMAT_PCM_SUB_8_BIT), - AUDIO_FORMAT_PCM_32_BIT = (AUDIO_FORMAT_PCM | - AUDIO_FORMAT_PCM_SUB_32_BIT), - AUDIO_FORMAT_PCM_8_24_BIT = (AUDIO_FORMAT_PCM | - AUDIO_FORMAT_PCM_SUB_8_24_BIT), - AUDIO_FORMAT_PCM_FLOAT = (AUDIO_FORMAT_PCM | - AUDIO_FORMAT_PCM_SUB_FLOAT), - AUDIO_FORMAT_PCM_24_BIT_PACKED = (AUDIO_FORMAT_PCM | - AUDIO_FORMAT_PCM_SUB_24_BIT_PACKED), - AUDIO_FORMAT_AAC_MAIN = (AUDIO_FORMAT_AAC | - AUDIO_FORMAT_AAC_SUB_MAIN), - AUDIO_FORMAT_AAC_LC = (AUDIO_FORMAT_AAC | - AUDIO_FORMAT_AAC_SUB_LC), - AUDIO_FORMAT_AAC_SSR = (AUDIO_FORMAT_AAC | - AUDIO_FORMAT_AAC_SUB_SSR), - AUDIO_FORMAT_AAC_LTP = (AUDIO_FORMAT_AAC | - AUDIO_FORMAT_AAC_SUB_LTP), - AUDIO_FORMAT_AAC_HE_V1 = (AUDIO_FORMAT_AAC | - AUDIO_FORMAT_AAC_SUB_HE_V1), - AUDIO_FORMAT_AAC_SCALABLE = (AUDIO_FORMAT_AAC | - AUDIO_FORMAT_AAC_SUB_SCALABLE), - AUDIO_FORMAT_AAC_ERLC = (AUDIO_FORMAT_AAC | - AUDIO_FORMAT_AAC_SUB_ERLC), - AUDIO_FORMAT_AAC_LD = (AUDIO_FORMAT_AAC | - AUDIO_FORMAT_AAC_SUB_LD), - AUDIO_FORMAT_AAC_HE_V2 = (AUDIO_FORMAT_AAC | - AUDIO_FORMAT_AAC_SUB_HE_V2), - AUDIO_FORMAT_AAC_ELD = (AUDIO_FORMAT_AAC | - AUDIO_FORMAT_AAC_SUB_ELD), - AUDIO_FORMAT_AAC_ADTS_MAIN = (AUDIO_FORMAT_AAC_ADTS | - AUDIO_FORMAT_AAC_SUB_MAIN), - AUDIO_FORMAT_AAC_ADTS_LC = (AUDIO_FORMAT_AAC_ADTS | - AUDIO_FORMAT_AAC_SUB_LC), - AUDIO_FORMAT_AAC_ADTS_SSR = (AUDIO_FORMAT_AAC_ADTS | - AUDIO_FORMAT_AAC_SUB_SSR), - AUDIO_FORMAT_AAC_ADTS_LTP = (AUDIO_FORMAT_AAC_ADTS | - AUDIO_FORMAT_AAC_SUB_LTP), - AUDIO_FORMAT_AAC_ADTS_HE_V1 = (AUDIO_FORMAT_AAC_ADTS | - AUDIO_FORMAT_AAC_SUB_HE_V1), - AUDIO_FORMAT_AAC_ADTS_SCALABLE = (AUDIO_FORMAT_AAC_ADTS | - AUDIO_FORMAT_AAC_SUB_SCALABLE), - AUDIO_FORMAT_AAC_ADTS_ERLC = (AUDIO_FORMAT_AAC_ADTS | - AUDIO_FORMAT_AAC_SUB_ERLC), - AUDIO_FORMAT_AAC_ADTS_LD = (AUDIO_FORMAT_AAC_ADTS | - AUDIO_FORMAT_AAC_SUB_LD), - AUDIO_FORMAT_AAC_ADTS_HE_V2 = (AUDIO_FORMAT_AAC_ADTS | - AUDIO_FORMAT_AAC_SUB_HE_V2), - AUDIO_FORMAT_AAC_ADTS_ELD = (AUDIO_FORMAT_AAC_ADTS | - AUDIO_FORMAT_AAC_SUB_ELD), - /*Offload PCM formats*/ - AUDIO_FORMAT_PCM_16_BIT_OFFLOAD = (AUDIO_FORMAT_PCM_OFFLOAD | - AUDIO_FORMAT_PCM_SUB_16_BIT), - AUDIO_FORMAT_PCM_24_BIT_OFFLOAD = (AUDIO_FORMAT_PCM_OFFLOAD | - AUDIO_FORMAT_PCM_SUB_8_24_BIT), -} audio_format_t; - -/* For the channel mask for position assignment representation */ -enum { - -/* These can be a complete audio_channel_mask_t. */ - - AUDIO_CHANNEL_NONE = 0x0, - AUDIO_CHANNEL_INVALID = 0xC0000000, - -/* These can be the bits portion of an audio_channel_mask_t - * with representation AUDIO_CHANNEL_REPRESENTATION_POSITION. - * Using these bits as a complete audio_channel_mask_t is deprecated. - */ - - /* output channels */ - AUDIO_CHANNEL_OUT_FRONT_LEFT = 0x1, - AUDIO_CHANNEL_OUT_FRONT_RIGHT = 0x2, - AUDIO_CHANNEL_OUT_FRONT_CENTER = 0x4, - AUDIO_CHANNEL_OUT_LOW_FREQUENCY = 0x8, - AUDIO_CHANNEL_OUT_BACK_LEFT = 0x10, - AUDIO_CHANNEL_OUT_BACK_RIGHT = 0x20, - AUDIO_CHANNEL_OUT_FRONT_LEFT_OF_CENTER = 0x40, - AUDIO_CHANNEL_OUT_FRONT_RIGHT_OF_CENTER = 0x80, - AUDIO_CHANNEL_OUT_BACK_CENTER = 0x100, - AUDIO_CHANNEL_OUT_SIDE_LEFT = 0x200, - AUDIO_CHANNEL_OUT_SIDE_RIGHT = 0x400, - AUDIO_CHANNEL_OUT_TOP_CENTER = 0x800, - AUDIO_CHANNEL_OUT_TOP_FRONT_LEFT = 0x1000, - AUDIO_CHANNEL_OUT_TOP_FRONT_CENTER = 0x2000, - AUDIO_CHANNEL_OUT_TOP_FRONT_RIGHT = 0x4000, - AUDIO_CHANNEL_OUT_TOP_BACK_LEFT = 0x8000, - AUDIO_CHANNEL_OUT_TOP_BACK_CENTER = 0x10000, - AUDIO_CHANNEL_OUT_TOP_BACK_RIGHT = 0x20000, - -/* TODO: should these be considered complete channel masks, or only bits? */ - - AUDIO_CHANNEL_OUT_MONO = AUDIO_CHANNEL_OUT_FRONT_LEFT, - AUDIO_CHANNEL_OUT_STEREO = (AUDIO_CHANNEL_OUT_FRONT_LEFT | - AUDIO_CHANNEL_OUT_FRONT_RIGHT), - AUDIO_CHANNEL_OUT_2POINT1 = (AUDIO_CHANNEL_OUT_FRONT_LEFT | - AUDIO_CHANNEL_OUT_FRONT_RIGHT | - AUDIO_CHANNEL_OUT_FRONT_CENTER), - AUDIO_CHANNEL_OUT_QUAD = (AUDIO_CHANNEL_OUT_FRONT_LEFT | - AUDIO_CHANNEL_OUT_FRONT_RIGHT | - AUDIO_CHANNEL_OUT_BACK_LEFT | - AUDIO_CHANNEL_OUT_BACK_RIGHT), - AUDIO_CHANNEL_OUT_QUAD_BACK = AUDIO_CHANNEL_OUT_QUAD, - /* like AUDIO_CHANNEL_OUT_QUAD_BACK with *_SIDE_* instead of *_BACK_* */ - AUDIO_CHANNEL_OUT_QUAD_SIDE = (AUDIO_CHANNEL_OUT_FRONT_LEFT | - AUDIO_CHANNEL_OUT_FRONT_RIGHT | - AUDIO_CHANNEL_OUT_SIDE_LEFT | - AUDIO_CHANNEL_OUT_SIDE_RIGHT), - AUDIO_CHANNEL_OUT_SURROUND = (AUDIO_CHANNEL_OUT_FRONT_LEFT | - AUDIO_CHANNEL_OUT_FRONT_RIGHT | - AUDIO_CHANNEL_OUT_FRONT_CENTER | - AUDIO_CHANNEL_OUT_BACK_CENTER), - AUDIO_CHANNEL_OUT_PENTA = (AUDIO_CHANNEL_OUT_QUAD | - AUDIO_CHANNEL_OUT_FRONT_CENTER), - AUDIO_CHANNEL_OUT_5POINT1 = (AUDIO_CHANNEL_OUT_FRONT_LEFT | - AUDIO_CHANNEL_OUT_FRONT_RIGHT | - AUDIO_CHANNEL_OUT_FRONT_CENTER | - AUDIO_CHANNEL_OUT_LOW_FREQUENCY | - AUDIO_CHANNEL_OUT_BACK_LEFT | - AUDIO_CHANNEL_OUT_BACK_RIGHT), - AUDIO_CHANNEL_OUT_5POINT1_BACK = AUDIO_CHANNEL_OUT_5POINT1, - /* like AUDIO_CHANNEL_OUT_5POINT1_BACK with *_SIDE_* instead of *_BACK_* */ - AUDIO_CHANNEL_OUT_5POINT1_SIDE = (AUDIO_CHANNEL_OUT_FRONT_LEFT | - AUDIO_CHANNEL_OUT_FRONT_RIGHT | - AUDIO_CHANNEL_OUT_FRONT_CENTER | - AUDIO_CHANNEL_OUT_LOW_FREQUENCY | - AUDIO_CHANNEL_OUT_SIDE_LEFT | - AUDIO_CHANNEL_OUT_SIDE_RIGHT), - AUDIO_CHANNEL_OUT_6POINT1 = (AUDIO_CHANNEL_OUT_FRONT_LEFT | - AUDIO_CHANNEL_OUT_FRONT_RIGHT | - AUDIO_CHANNEL_OUT_FRONT_CENTER | - AUDIO_CHANNEL_OUT_LOW_FREQUENCY | - AUDIO_CHANNEL_OUT_BACK_LEFT | - AUDIO_CHANNEL_OUT_BACK_RIGHT | - AUDIO_CHANNEL_OUT_BACK_CENTER), - // matches the correct AudioFormat.CHANNEL_OUT_7POINT1_SURROUND definition for 7.1 - AUDIO_CHANNEL_OUT_7POINT1 = (AUDIO_CHANNEL_OUT_FRONT_LEFT | - AUDIO_CHANNEL_OUT_FRONT_RIGHT | - AUDIO_CHANNEL_OUT_FRONT_CENTER | - AUDIO_CHANNEL_OUT_LOW_FREQUENCY | - AUDIO_CHANNEL_OUT_BACK_LEFT | - AUDIO_CHANNEL_OUT_BACK_RIGHT | - AUDIO_CHANNEL_OUT_SIDE_LEFT | - AUDIO_CHANNEL_OUT_SIDE_RIGHT), - AUDIO_CHANNEL_OUT_ALL = (AUDIO_CHANNEL_OUT_FRONT_LEFT | - AUDIO_CHANNEL_OUT_FRONT_RIGHT | - AUDIO_CHANNEL_OUT_FRONT_CENTER | - AUDIO_CHANNEL_OUT_LOW_FREQUENCY | - AUDIO_CHANNEL_OUT_BACK_LEFT | - AUDIO_CHANNEL_OUT_BACK_RIGHT | - AUDIO_CHANNEL_OUT_FRONT_LEFT_OF_CENTER | - AUDIO_CHANNEL_OUT_FRONT_RIGHT_OF_CENTER | - AUDIO_CHANNEL_OUT_BACK_CENTER| - AUDIO_CHANNEL_OUT_SIDE_LEFT| - AUDIO_CHANNEL_OUT_SIDE_RIGHT| - AUDIO_CHANNEL_OUT_TOP_CENTER| - AUDIO_CHANNEL_OUT_TOP_FRONT_LEFT| - AUDIO_CHANNEL_OUT_TOP_FRONT_CENTER| - AUDIO_CHANNEL_OUT_TOP_FRONT_RIGHT| - AUDIO_CHANNEL_OUT_TOP_BACK_LEFT| - AUDIO_CHANNEL_OUT_TOP_BACK_CENTER| - AUDIO_CHANNEL_OUT_TOP_BACK_RIGHT), - -/* These are bits only, not complete values */ - - /* input channels */ - AUDIO_CHANNEL_IN_LEFT = 0x4, - AUDIO_CHANNEL_IN_RIGHT = 0x8, - AUDIO_CHANNEL_IN_FRONT = 0x10, - AUDIO_CHANNEL_IN_BACK = 0x20, - AUDIO_CHANNEL_IN_LEFT_PROCESSED = 0x40, - AUDIO_CHANNEL_IN_RIGHT_PROCESSED = 0x80, - AUDIO_CHANNEL_IN_FRONT_PROCESSED = 0x100, - AUDIO_CHANNEL_IN_BACK_PROCESSED = 0x200, - AUDIO_CHANNEL_IN_PRESSURE = 0x400, - AUDIO_CHANNEL_IN_X_AXIS = 0x800, - AUDIO_CHANNEL_IN_Y_AXIS = 0x1000, - AUDIO_CHANNEL_IN_Z_AXIS = 0x2000, - AUDIO_CHANNEL_IN_VOICE_UPLINK = 0x4000, - AUDIO_CHANNEL_IN_VOICE_DNLINK = 0x8000, - -/* TODO: should these be considered complete channel masks, or only bits, or deprecated? */ - - AUDIO_CHANNEL_IN_MONO = AUDIO_CHANNEL_IN_FRONT, - AUDIO_CHANNEL_IN_STEREO = (AUDIO_CHANNEL_IN_LEFT | AUDIO_CHANNEL_IN_RIGHT), - AUDIO_CHANNEL_IN_FRONT_BACK = (AUDIO_CHANNEL_IN_FRONT | AUDIO_CHANNEL_IN_BACK), - AUDIO_CHANNEL_IN_5POINT1 = (AUDIO_CHANNEL_IN_LEFT | - AUDIO_CHANNEL_IN_RIGHT | - AUDIO_CHANNEL_IN_FRONT | - AUDIO_CHANNEL_IN_BACK | - AUDIO_CHANNEL_IN_LEFT_PROCESSED | - AUDIO_CHANNEL_IN_RIGHT_PROCESSED), - AUDIO_CHANNEL_IN_VOICE_UPLINK_MONO = (AUDIO_CHANNEL_IN_VOICE_UPLINK | AUDIO_CHANNEL_IN_MONO), - AUDIO_CHANNEL_IN_VOICE_DNLINK_MONO = (AUDIO_CHANNEL_IN_VOICE_DNLINK | AUDIO_CHANNEL_IN_MONO), - AUDIO_CHANNEL_IN_VOICE_CALL_MONO = (AUDIO_CHANNEL_IN_VOICE_UPLINK_MONO | AUDIO_CHANNEL_IN_VOICE_DNLINK_MONO), - AUDIO_CHANNEL_IN_ALL = (AUDIO_CHANNEL_IN_LEFT | - AUDIO_CHANNEL_IN_RIGHT | - AUDIO_CHANNEL_IN_FRONT | - AUDIO_CHANNEL_IN_BACK| - AUDIO_CHANNEL_IN_LEFT_PROCESSED | - AUDIO_CHANNEL_IN_RIGHT_PROCESSED | - AUDIO_CHANNEL_IN_FRONT_PROCESSED | - AUDIO_CHANNEL_IN_BACK_PROCESSED| - AUDIO_CHANNEL_IN_PRESSURE | - AUDIO_CHANNEL_IN_X_AXIS | - AUDIO_CHANNEL_IN_Y_AXIS | - AUDIO_CHANNEL_IN_Z_AXIS | - AUDIO_CHANNEL_IN_VOICE_UPLINK | - AUDIO_CHANNEL_IN_VOICE_DNLINK), -}; - /* A channel mask per se only defines the presence or absence of a channel, not the order. * But see AUDIO_INTERLEAVE_* below for the platform convention of order. * @@ -589,42 +136,17 @@ enum { */ typedef uint32_t audio_channel_mask_t; -/* Maximum number of channels for all representations */ -#define AUDIO_CHANNEL_COUNT_MAX 30 - /* log(2) of maximum number of representations, not part of public API */ #define AUDIO_CHANNEL_REPRESENTATION_LOG2 2 -/* Representations */ -typedef enum { - AUDIO_CHANNEL_REPRESENTATION_POSITION = 0, // must be zero for compatibility - // 1 is reserved for future use - AUDIO_CHANNEL_REPRESENTATION_INDEX = 2, - // 3 is reserved for future use -} audio_channel_representation_t; - -/* The channel index masks defined here are the canonical masks for 1 to 8 channel - * endpoints and apply to both source and sink. - */ -enum { - AUDIO_CHANNEL_INDEX_HDR = AUDIO_CHANNEL_REPRESENTATION_INDEX << AUDIO_CHANNEL_COUNT_MAX, - AUDIO_CHANNEL_INDEX_MASK_1 = AUDIO_CHANNEL_INDEX_HDR | ((1 << 1) - 1), - AUDIO_CHANNEL_INDEX_MASK_2 = AUDIO_CHANNEL_INDEX_HDR | ((1 << 2) - 1), - AUDIO_CHANNEL_INDEX_MASK_3 = AUDIO_CHANNEL_INDEX_HDR | ((1 << 3) - 1), - AUDIO_CHANNEL_INDEX_MASK_4 = AUDIO_CHANNEL_INDEX_HDR | ((1 << 4) - 1), - AUDIO_CHANNEL_INDEX_MASK_5 = AUDIO_CHANNEL_INDEX_HDR | ((1 << 5) - 1), - AUDIO_CHANNEL_INDEX_MASK_6 = AUDIO_CHANNEL_INDEX_HDR | ((1 << 6) - 1), - AUDIO_CHANNEL_INDEX_MASK_7 = AUDIO_CHANNEL_INDEX_HDR | ((1 << 7) - 1), - AUDIO_CHANNEL_INDEX_MASK_8 = AUDIO_CHANNEL_INDEX_HDR | ((1 << 8) - 1), - // FIXME FCC_8 -}; - /* The return value is undefined if the channel mask is invalid. */ static inline uint32_t audio_channel_mask_get_bits(audio_channel_mask_t channel) { return channel & ((1 << AUDIO_CHANNEL_COUNT_MAX) - 1); } +typedef uint32_t audio_channel_representation_t; + /* The return value is undefined if the channel mask is invalid. */ static inline audio_channel_representation_t audio_channel_mask_get_representation( audio_channel_mask_t channel) @@ -663,32 +185,21 @@ static inline audio_channel_mask_t audio_channel_mask_from_representation_and_bi return (audio_channel_mask_t) ((representation << AUDIO_CHANNEL_COUNT_MAX) | bits); } -/* Expresses the convention when stereo audio samples are stored interleaved +/** + * Expresses the convention when stereo audio samples are stored interleaved * in an array. This should improve readability by allowing code to use * symbolic indices instead of hard-coded [0] and [1]. * * For multi-channel beyond stereo, the platform convention is that channels - * are interleaved in order from least significant channel mask bit - * to most significant channel mask bit, with unused bits skipped. - * Any exceptions to this convention will be noted at the appropriate API. + * are interleaved in order from least significant channel mask bit to most + * significant channel mask bit, with unused bits skipped. Any exceptions + * to this convention will be noted at the appropriate API. */ enum { - AUDIO_INTERLEAVE_LEFT = 0, - AUDIO_INTERLEAVE_RIGHT = 1, + AUDIO_INTERLEAVE_LEFT = 0, + AUDIO_INTERLEAVE_RIGHT = 1, }; -typedef enum { - AUDIO_MODE_INVALID = -2, - AUDIO_MODE_CURRENT = -1, - AUDIO_MODE_NORMAL = 0, - AUDIO_MODE_RINGTONE = 1, - AUDIO_MODE_IN_CALL = 2, - AUDIO_MODE_IN_COMMUNICATION = 3, - - AUDIO_MODE_CNT, - AUDIO_MODE_MAX = AUDIO_MODE_CNT - 1, -} audio_mode_t; - /* This enum is deprecated */ typedef enum { AUDIO_IN_ACOUSTICS_NONE = 0, @@ -700,206 +211,23 @@ typedef enum { AUDIO_IN_ACOUSTICS_TX_DISABLE = 0, } audio_in_acoustics_t; -enum { - AUDIO_DEVICE_NONE = 0x0, - /* reserved bits */ - AUDIO_DEVICE_BIT_IN = 0x80000000, - AUDIO_DEVICE_BIT_DEFAULT = 0x40000000, - /* output devices */ - AUDIO_DEVICE_OUT_EARPIECE = 0x1, - AUDIO_DEVICE_OUT_SPEAKER = 0x2, - AUDIO_DEVICE_OUT_WIRED_HEADSET = 0x4, - AUDIO_DEVICE_OUT_WIRED_HEADPHONE = 0x8, - AUDIO_DEVICE_OUT_BLUETOOTH_SCO = 0x10, - AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET = 0x20, - AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT = 0x40, - AUDIO_DEVICE_OUT_BLUETOOTH_A2DP = 0x80, - AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES = 0x100, - AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER = 0x200, - AUDIO_DEVICE_OUT_AUX_DIGITAL = 0x400, - AUDIO_DEVICE_OUT_HDMI = AUDIO_DEVICE_OUT_AUX_DIGITAL, - /* uses an analog connection (multiplexed over the USB connector pins for instance) */ - AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET = 0x800, - AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET = 0x1000, - /* USB accessory mode: your Android device is a USB device and the dock is a USB host */ - AUDIO_DEVICE_OUT_USB_ACCESSORY = 0x2000, - /* USB host mode: your Android device is a USB host and the dock is a USB device */ - AUDIO_DEVICE_OUT_USB_DEVICE = 0x4000, - AUDIO_DEVICE_OUT_REMOTE_SUBMIX = 0x8000, - /* Telephony voice TX path */ - AUDIO_DEVICE_OUT_TELEPHONY_TX = 0x10000, - /* Analog jack with line impedance detected */ - AUDIO_DEVICE_OUT_LINE = 0x20000, - /* HDMI Audio Return Channel */ - AUDIO_DEVICE_OUT_HDMI_ARC = 0x40000, - /* S/PDIF out */ - AUDIO_DEVICE_OUT_SPDIF = 0x80000, - /* FM transmitter out */ - AUDIO_DEVICE_OUT_FM = 0x100000, - /* Line out for av devices */ - AUDIO_DEVICE_OUT_AUX_LINE = 0x200000, - /* limited-output speaker device for acoustic safety */ - AUDIO_DEVICE_OUT_SPEAKER_SAFE = 0x400000, - AUDIO_DEVICE_OUT_IP = 0x800000, - /* audio bus implemented by the audio system (e.g an MOST stereo channel) */ - AUDIO_DEVICE_OUT_BUS = 0x1000000, - AUDIO_DEVICE_OUT_PROXY = 0x2000000, - AUDIO_DEVICE_OUT_DEFAULT = AUDIO_DEVICE_BIT_DEFAULT, - AUDIO_DEVICE_OUT_ALL = (AUDIO_DEVICE_OUT_EARPIECE | - AUDIO_DEVICE_OUT_SPEAKER | - AUDIO_DEVICE_OUT_WIRED_HEADSET | - AUDIO_DEVICE_OUT_WIRED_HEADPHONE | - AUDIO_DEVICE_OUT_BLUETOOTH_SCO | - AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET | - AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT | - AUDIO_DEVICE_OUT_BLUETOOTH_A2DP | - AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES | - AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER | - AUDIO_DEVICE_OUT_HDMI | - AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET | - AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET | - AUDIO_DEVICE_OUT_USB_ACCESSORY | - AUDIO_DEVICE_OUT_USB_DEVICE | - AUDIO_DEVICE_OUT_REMOTE_SUBMIX | - AUDIO_DEVICE_OUT_TELEPHONY_TX | - AUDIO_DEVICE_OUT_LINE | - AUDIO_DEVICE_OUT_HDMI_ARC | - AUDIO_DEVICE_OUT_SPDIF | - AUDIO_DEVICE_OUT_FM | - AUDIO_DEVICE_OUT_AUX_LINE | - AUDIO_DEVICE_OUT_SPEAKER_SAFE | - AUDIO_DEVICE_OUT_IP | - AUDIO_DEVICE_OUT_BUS | - AUDIO_DEVICE_OUT_PROXY | - AUDIO_DEVICE_OUT_DEFAULT), - AUDIO_DEVICE_OUT_ALL_A2DP = (AUDIO_DEVICE_OUT_BLUETOOTH_A2DP | - AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES | - AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER), - AUDIO_DEVICE_OUT_ALL_SCO = (AUDIO_DEVICE_OUT_BLUETOOTH_SCO | - AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET | - AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT), - AUDIO_DEVICE_OUT_ALL_USB = (AUDIO_DEVICE_OUT_USB_ACCESSORY | - AUDIO_DEVICE_OUT_USB_DEVICE), - /* input devices */ - AUDIO_DEVICE_IN_COMMUNICATION = AUDIO_DEVICE_BIT_IN | 0x1, - AUDIO_DEVICE_IN_AMBIENT = AUDIO_DEVICE_BIT_IN | 0x2, - AUDIO_DEVICE_IN_BUILTIN_MIC = AUDIO_DEVICE_BIT_IN | 0x4, - AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET = AUDIO_DEVICE_BIT_IN | 0x8, - AUDIO_DEVICE_IN_WIRED_HEADSET = AUDIO_DEVICE_BIT_IN | 0x10, - AUDIO_DEVICE_IN_AUX_DIGITAL = AUDIO_DEVICE_BIT_IN | 0x20, - AUDIO_DEVICE_IN_HDMI = AUDIO_DEVICE_IN_AUX_DIGITAL, - /* Telephony voice RX path */ - AUDIO_DEVICE_IN_VOICE_CALL = AUDIO_DEVICE_BIT_IN | 0x40, - AUDIO_DEVICE_IN_TELEPHONY_RX = AUDIO_DEVICE_IN_VOICE_CALL, - AUDIO_DEVICE_IN_BACK_MIC = AUDIO_DEVICE_BIT_IN | 0x80, - AUDIO_DEVICE_IN_REMOTE_SUBMIX = AUDIO_DEVICE_BIT_IN | 0x100, - AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET = AUDIO_DEVICE_BIT_IN | 0x200, - AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET = AUDIO_DEVICE_BIT_IN | 0x400, - AUDIO_DEVICE_IN_USB_ACCESSORY = AUDIO_DEVICE_BIT_IN | 0x800, - AUDIO_DEVICE_IN_USB_DEVICE = AUDIO_DEVICE_BIT_IN | 0x1000, - /* FM tuner input */ - AUDIO_DEVICE_IN_FM_TUNER = AUDIO_DEVICE_BIT_IN | 0x2000, - /* TV tuner input */ - AUDIO_DEVICE_IN_TV_TUNER = AUDIO_DEVICE_BIT_IN | 0x4000, - /* Analog jack with line impedance detected */ - AUDIO_DEVICE_IN_LINE = AUDIO_DEVICE_BIT_IN | 0x8000, - /* S/PDIF in */ - AUDIO_DEVICE_IN_SPDIF = AUDIO_DEVICE_BIT_IN | 0x10000, - AUDIO_DEVICE_IN_BLUETOOTH_A2DP = AUDIO_DEVICE_BIT_IN | 0x20000, - AUDIO_DEVICE_IN_LOOPBACK = AUDIO_DEVICE_BIT_IN | 0x40000, - AUDIO_DEVICE_IN_IP = AUDIO_DEVICE_BIT_IN | 0x80000, - /* audio bus implemented by the audio system (e.g an MOST stereo channel) */ - AUDIO_DEVICE_IN_BUS = AUDIO_DEVICE_BIT_IN | 0x100000, - AUDIO_DEVICE_IN_PROXY = AUDIO_DEVICE_BIT_IN | 0x1000000, - AUDIO_DEVICE_IN_DEFAULT = AUDIO_DEVICE_BIT_IN | AUDIO_DEVICE_BIT_DEFAULT, - - AUDIO_DEVICE_IN_ALL = (AUDIO_DEVICE_IN_COMMUNICATION | - AUDIO_DEVICE_IN_AMBIENT | - AUDIO_DEVICE_IN_BUILTIN_MIC | - AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET | - AUDIO_DEVICE_IN_WIRED_HEADSET | - AUDIO_DEVICE_IN_HDMI | - AUDIO_DEVICE_IN_TELEPHONY_RX | - AUDIO_DEVICE_IN_BACK_MIC | - AUDIO_DEVICE_IN_REMOTE_SUBMIX | - AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET | - AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET | - AUDIO_DEVICE_IN_USB_ACCESSORY | - AUDIO_DEVICE_IN_USB_DEVICE | - AUDIO_DEVICE_IN_FM_TUNER | - AUDIO_DEVICE_IN_TV_TUNER | - AUDIO_DEVICE_IN_LINE | - AUDIO_DEVICE_IN_SPDIF | - AUDIO_DEVICE_IN_BLUETOOTH_A2DP | - AUDIO_DEVICE_IN_LOOPBACK | - AUDIO_DEVICE_IN_IP | - AUDIO_DEVICE_IN_BUS | - AUDIO_DEVICE_IN_PROXY | - AUDIO_DEVICE_IN_DEFAULT), - AUDIO_DEVICE_IN_ALL_SCO = AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET, - AUDIO_DEVICE_IN_ALL_USB = (AUDIO_DEVICE_IN_USB_ACCESSORY | - AUDIO_DEVICE_IN_USB_DEVICE), -}; - typedef uint32_t audio_devices_t; - -/* the audio output flags serve two purposes: - * - when an AudioTrack is created they indicate a "wish" to be connected to an - * output stream with attributes corresponding to the specified flags - * - when present in an output profile descriptor listed for a particular audio - * hardware module, they indicate that an output stream can be opened that - * supports the attributes indicated by the flags. - * the audio policy manager will try to match the flags in the request - * (when getOuput() is called) to an available output stream. +/** + * Stub audio output device. Used in policy configuration file on platforms without audio outputs. + * This alias value to AUDIO_DEVICE_OUT_DEFAULT is only used in the audio policy context. */ -typedef enum { - AUDIO_OUTPUT_FLAG_NONE = 0x0, // no attributes - AUDIO_OUTPUT_FLAG_DIRECT = 0x1, // this output directly connects a track - // to one output stream: no software mixer - AUDIO_OUTPUT_FLAG_PRIMARY = 0x2, // this output is the primary output of - // the device. It is unique and must be - // present. It is opened by default and - // receives routing, audio mode and volume - // controls related to voice calls. - AUDIO_OUTPUT_FLAG_FAST = 0x4, // output supports "fast tracks", - // defined elsewhere - AUDIO_OUTPUT_FLAG_DEEP_BUFFER = 0x8, // use deep audio buffers - AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD = 0x10, // offload playback of compressed - // streams to hardware codec - AUDIO_OUTPUT_FLAG_NON_BLOCKING = 0x20, // use non-blocking write - AUDIO_OUTPUT_FLAG_HW_AV_SYNC = 0x40, // output uses a hardware A/V synchronization source - AUDIO_OUTPUT_FLAG_TTS = 0x80, // output for streams transmitted through speaker - // at a sample rate high enough to accommodate - // lower-range ultrasonic playback - AUDIO_OUTPUT_FLAG_RAW = 0x100, // minimize signal processing - AUDIO_OUTPUT_FLAG_SYNC = 0x200, // synchronize I/O streams - - AUDIO_OUTPUT_FLAG_IEC958_NONAUDIO = 0x400, // Audio stream contains compressed audio in - // SPDIF data bursts, not PCM. - AUDIO_OUTPUT_FLAG_VOIP_RX = 0x800, // use this flag in combination with DIRECT to - // start voip over voice path. - AUDIO_OUTPUT_FLAG_COMPRESS_PASSTHROUGH = 0x1000, // flag for HDMI compressed passthrough - AUDIO_OUTPUT_FLAG_DIRECT_PCM = 0x2000, // flag for Direct PCM -} audio_output_flags_t; - -/* The audio input flags are analogous to audio output flags. - * Currently they are used only when an AudioRecord is created, - * to indicate a preference to be connected to an input stream with - * attributes corresponding to the specified flags. +#define AUDIO_DEVICE_OUT_STUB AUDIO_DEVICE_OUT_DEFAULT +/** + * Stub audio input device. Used in policy configuration file on platforms without audio inputs. + * This alias value to AUDIO_DEVICE_IN_DEFAULT is only used in the audio policy context. */ -typedef enum { - AUDIO_INPUT_FLAG_NONE = 0x0, // no attributes - AUDIO_INPUT_FLAG_FAST = 0x1, // prefer an input that supports "fast tracks" - AUDIO_INPUT_FLAG_HW_HOTWORD = 0x2, // prefer an input that captures from hw hotword source - AUDIO_INPUT_FLAG_RAW = 0x4, // minimize signal processing - AUDIO_INPUT_FLAG_SYNC = 0x8, // synchronize I/O streams - -} audio_input_flags_t; +#define AUDIO_DEVICE_IN_STUB AUDIO_DEVICE_IN_DEFAULT /* Additional information about compressed streams offloaded to * hardware playback * The version and size fields must be initialized by the caller by using * one of the constants defined here. + * Must be aligned to transmit as raw memory through Binder. */ typedef struct { uint16_t version; // version of the info structure @@ -915,46 +243,7 @@ typedef struct { uint32_t bit_width; uint32_t offload_buffer_size; // offload fragment size audio_usage_t usage; -} audio_offload_info_t; - -/* Information about BT SBC encoder configuration - * This data is used between audio HAL module and - * BT IPC library to configure DSP encoder - */ -typedef struct { - uint32_t subband; /* 4, 8 */ - uint32_t blk_len; /* 4, 8, 12, 16 */ - uint16_t sampling_rate; /*44.1khz,48khz*/ - uint8_t channels; /*0(Mono),1(Dual_mono),2(Stereo),3(JS)*/ - uint8_t alloc; /*0(Loudness),1(SNR)*/ - uint8_t min_bitpool; /* 2 */ - uint8_t max_bitpool; /*53(44.1khz),51 (48khz) */ - uint32_t bitrate; /* 320kbps to 512kbps */ -} audio_sbc_encoder_config; - - -/* Information about BT APTX encoder configuration - * This data is used between audio HAL module and - * BT IPC library to configure DSP encoder - */ -typedef struct { - uint16_t sampling_rate; - uint8_t channels; - uint32_t bitrate; -} audio_aptx_encoder_config; - - -/* Information about BT AAC encoder configuration - * This data is used between audio HAL module and - * BT IPC library to configure DSP encoder - */ -typedef struct { - uint32_t enc_mode; /* LC, SBR, PS */ - uint16_t format_flag; /* RAW, ADTS */ - uint16_t channels; /* 1-Mono, 2-Stereo */ - uint32_t sampling_rate; - uint32_t bitrate; -} audio_aac_encoder_config; +} __attribute__((aligned(8))) audio_offload_info_t; #define AUDIO_MAKE_OFFLOAD_INFO_VERSION(maj,min) \ ((((maj) & 0xff) << 8) | ((min) & 0xff)) @@ -963,51 +252,55 @@ typedef struct { #define AUDIO_OFFLOAD_INFO_VERSION_CURRENT AUDIO_OFFLOAD_INFO_VERSION_0_1 static const audio_offload_info_t AUDIO_INFO_INITIALIZER = { - version: AUDIO_OFFLOAD_INFO_VERSION_CURRENT, - size: sizeof(audio_offload_info_t), - sample_rate: 0, - channel_mask: 0, - format: AUDIO_FORMAT_DEFAULT, - stream_type: AUDIO_STREAM_VOICE_CALL, - bit_rate: 0, - duration_us: 0, - has_video: false, - is_streaming: false, - bit_width: 16, - offload_buffer_size: 0, - usage: AUDIO_USAGE_UNKNOWN, + /* .version = */ AUDIO_OFFLOAD_INFO_VERSION_CURRENT, + /* .size = */ sizeof(audio_offload_info_t), + /* .sample_rate = */ 0, + /* .channel_mask = */ 0, + /* .format = */ AUDIO_FORMAT_DEFAULT, + /* .stream_type = */ AUDIO_STREAM_VOICE_CALL, + /* .bit_rate = */ 0, + /* .duration_us = */ 0, + /* .has_video = */ false, + /* .is_streaming = */ false, + /* .bit_width = */ 16, + /* .offload_buffer_size = */ 0, + /* .usage = */ AUDIO_USAGE_UNKNOWN }; /* common audio stream configuration parameters * You should memset() the entire structure to zero before use to * ensure forward compatibility + * Must be aligned to transmit as raw memory through Binder. */ -struct audio_config { +struct __attribute__((aligned(8))) audio_config { uint32_t sample_rate; audio_channel_mask_t channel_mask; audio_format_t format; audio_offload_info_t offload_info; - size_t frame_count; + uint32_t frame_count; }; typedef struct audio_config audio_config_t; static const audio_config_t AUDIO_CONFIG_INITIALIZER = { - sample_rate: 0, - channel_mask: AUDIO_CHANNEL_NONE, - format: AUDIO_FORMAT_DEFAULT, - offload_info: { - version: AUDIO_OFFLOAD_INFO_VERSION_CURRENT, - size: sizeof(audio_offload_info_t), - sample_rate: 0, - channel_mask: 0, - format: AUDIO_FORMAT_DEFAULT, - stream_type: AUDIO_STREAM_VOICE_CALL, - bit_rate: 0, - duration_us: 0, - has_video: false, - is_streaming: false + /* .sample_rate = */ 0, + /* .channel_mask = */ AUDIO_CHANNEL_NONE, + /* .format = */ AUDIO_FORMAT_DEFAULT, + /* .offload_info = */ { + /* .version = */ AUDIO_OFFLOAD_INFO_VERSION_CURRENT, + /* .size = */ sizeof(audio_offload_info_t), + /* .sample_rate = */ 0, + /* .channel_mask = */ 0, + /* .format = */ AUDIO_FORMAT_DEFAULT, + /* .stream_type = */ AUDIO_STREAM_VOICE_CALL, + /* .bit_rate = */ 0, + /* .duration_us = */ 0, + /* .has_video = */ false, + /* .is_streaming = */ false, + /* .bit_width = */ 16, + /* .offload_buffer_size = */ 0, + /* .usage = */ AUDIO_USAGE_UNKNOWN }, - frame_count: 0, + /* .frame_count = */ 0, }; struct audio_config_base { @@ -1019,30 +312,28 @@ struct audio_config_base { typedef struct audio_config_base audio_config_base_t; static const audio_config_base_t AUDIO_CONFIG_BASE_INITIALIZER = { - sample_rate: 0, - channel_mask: AUDIO_CHANNEL_NONE, - format: AUDIO_FORMAT_DEFAULT + /* .sample_rate = */ 0, + /* .channel_mask = */ AUDIO_CHANNEL_NONE, + /* .format = */ AUDIO_FORMAT_DEFAULT }; /* audio hw module handle functions or structures referencing a module */ -typedef enum { - AUDIO_MODULE_HANDLE_NONE = 0, -} audio_module_handle_t; +typedef int audio_module_handle_t; /****************************** * Volume control *****************************/ +/** 3 dB headroom are allowed on float samples (3db = 10^(3/20) = 1.412538). +* See: https://developer.android.com/reference/android/media/AudioTrack.html#write(float[], int, int, int) +*/ +#define FLOAT_NOMINAL_RANGE_HEADROOM 1.412538 + /* If the audio hardware supports gain control on some audio paths, * the platform can expose them in the audio_policy.conf file. The audio HAL * will then implement gain control functions that will use the following data * structures. */ -/* Type of gain control exposed by an audio port */ -#define AUDIO_GAIN_MODE_JOINT 0x1 /* supports joint channel gain control */ -#define AUDIO_GAIN_MODE_CHANNELS 0x2 /* supports separate channel gain control */ -#define AUDIO_GAIN_MODE_RAMP 0x4 /* supports gain ramps */ - typedef uint32_t audio_gain_mode_t; @@ -1087,26 +378,8 @@ struct audio_gain_config { * audio end point at the edge of the system managed by the module exposing * the interface. */ -/* Audio port role: either source or sink */ -typedef enum { - AUDIO_PORT_ROLE_NONE, - AUDIO_PORT_ROLE_SOURCE, - AUDIO_PORT_ROLE_SINK, -} audio_port_role_t; - -/* Audio port type indicates if it is a session (e.g AudioTrack), - * a mix (e.g PlaybackThread output) or a physical device - * (e.g AUDIO_DEVICE_OUT_SPEAKER) */ -typedef enum { - AUDIO_PORT_TYPE_NONE, - AUDIO_PORT_TYPE_DEVICE, - AUDIO_PORT_TYPE_MIX, - AUDIO_PORT_TYPE_SESSION, -} audio_port_type_t; - /* Each port has a unique ID or handle allocated by policy manager */ typedef int audio_port_handle_t; -#define AUDIO_PORT_HANDLE_NONE 0 /* the maximum length for the human-readable device name */ #define AUDIO_PORT_MAX_NAME_LEN 128 @@ -1140,16 +413,6 @@ struct audio_port_config_session_ext { audio_session_t session; /* audio session */ }; -/* Flags indicating which fields are to be considered in struct audio_port_config */ -#define AUDIO_PORT_CONFIG_SAMPLE_RATE 0x1 -#define AUDIO_PORT_CONFIG_CHANNEL_MASK 0x2 -#define AUDIO_PORT_CONFIG_FORMAT 0x4 -#define AUDIO_PORT_CONFIG_GAIN 0x8 -#define AUDIO_PORT_CONFIG_ALL (AUDIO_PORT_CONFIG_SAMPLE_RATE | \ - AUDIO_PORT_CONFIG_CHANNEL_MASK | \ - AUDIO_PORT_CONFIG_FORMAT | \ - AUDIO_PORT_CONFIG_GAIN) - /* audio port configuration structure used to specify a particular configuration of * an audio port */ struct audio_port_config { @@ -1170,11 +433,11 @@ struct audio_port_config { /* max number of sampling rates in audio port */ -#define AUDIO_PORT_MAX_SAMPLING_RATES 16 +#define AUDIO_PORT_MAX_SAMPLING_RATES 32 /* max number of channel masks in audio port */ -#define AUDIO_PORT_MAX_CHANNEL_MASKS 16 +#define AUDIO_PORT_MAX_CHANNEL_MASKS 32 /* max number of audio formats in audio port */ -#define AUDIO_PORT_MAX_FORMATS 16 +#define AUDIO_PORT_MAX_FORMATS 32 /* max number of gain controls in audio port */ #define AUDIO_PORT_MAX_GAINS 16 @@ -1185,12 +448,6 @@ struct audio_port_device_ext { char address[AUDIO_DEVICE_MAX_ADDRESS_LEN]; }; -/* Latency class of the audio mix */ -typedef enum { - AUDIO_LATENCY_LOW, - AUDIO_LATENCY_NORMAL, -} audio_mix_latency_class_t; - /* extension for audio port structure when the audio port is a sub mix */ struct audio_port_mix_ext { audio_module_handle_t hw_module; /* module the stream is attached to */ @@ -1234,9 +491,7 @@ struct audio_port { * But the same patch receives another system wide unique handle allocated by the framework. * This unique handle is used for all transactions inside the framework. */ -typedef enum { - AUDIO_PATCH_HANDLE_NONE = 0, -} audio_patch_handle_t; +typedef int audio_patch_handle_t; #define AUDIO_PATCH_PORTS_MAX 16 @@ -1256,6 +511,46 @@ typedef uint32_t audio_hw_sync_t; /* an invalid HW synchronization source indicating an error */ #define AUDIO_HW_SYNC_INVALID 0 +/** + * Mmap buffer descriptor returned by audio_stream->create_mmap_buffer(). + * note\ Used by streams opened in mmap mode. + */ +struct audio_mmap_buffer_info { + void* shared_memory_address; /**< base address of mmap memory buffer. + For use by local process only */ + int32_t shared_memory_fd; /**< FD for mmap memory buffer */ + int32_t buffer_size_frames; /**< total buffer size in frames */ + int32_t burst_size_frames; /**< transfer size granularity in frames */ +}; + +/** + * Mmap buffer read/write position returned by audio_stream->get_mmap_position(). + * note\ Used by streams opened in mmap mode. + */ +struct audio_mmap_position { + int64_t time_nanoseconds; /**< timestamp in ns, CLOCK_MONOTONIC */ + int32_t position_frames; /**< increasing 32 bit frame count reset when stream->stop() + is called */ +}; + +/** Metadata of a record track for an in stream. */ +typedef struct playback_track_metadata { + audio_usage_t usage; + audio_content_type_t content_type; + float gain; // Normalized linear volume. 0=silence, 1=0dbfs... +} playback_track_metadata_t; + +/** Metadata of a playback track for an out stream. */ +typedef struct record_track_metadata { + audio_source_t source; + float gain; // Normalized linear volume. 0=silence, 1=0dbfs... +} record_track_metadata_t; + + +/****************************** + * Helper functions + *****************************/ + static inline bool audio_is_output_device(audio_devices_t device) { if (((device & AUDIO_DEVICE_BIT_IN) == 0) && @@ -1318,6 +613,11 @@ static inline bool audio_is_bluetooth_sco_device(audio_devices_t device) return false; } +static inline bool audio_is_hearing_aid_out_device(audio_devices_t device) +{ + return device == AUDIO_DEVICE_OUT_HEARING_AID; +} + static inline bool audio_is_usb_out_device(audio_devices_t device) { return ((popcount(device) == 1) && (device & AUDIO_DEVICE_OUT_ALL_USB)); @@ -1477,8 +777,8 @@ static inline audio_channel_mask_t audio_channel_out_mask_from_count(uint32_t ch case 2: bits = AUDIO_CHANNEL_OUT_STEREO; break; - case 3: - bits = AUDIO_CHANNEL_OUT_STEREO | AUDIO_CHANNEL_OUT_FRONT_CENTER; + case 3: // 2.1 + bits = AUDIO_CHANNEL_OUT_STEREO | AUDIO_CHANNEL_OUT_LOW_FREQUENCY; break; case 4: // 4.0 bits = AUDIO_CHANNEL_OUT_QUAD; @@ -1537,6 +837,28 @@ static inline audio_channel_mask_t audio_channel_in_mask_from_count(uint32_t cha AUDIO_CHANNEL_REPRESENTATION_POSITION, bits); } +static inline audio_channel_mask_t audio_channel_mask_in_to_out(audio_channel_mask_t in) +{ + switch (in) { + case AUDIO_CHANNEL_IN_MONO: + return AUDIO_CHANNEL_OUT_MONO; + case AUDIO_CHANNEL_IN_STEREO: + return AUDIO_CHANNEL_OUT_STEREO; + case AUDIO_CHANNEL_IN_5POINT1: + return AUDIO_CHANNEL_OUT_5POINT1; + case AUDIO_CHANNEL_IN_3POINT1POINT2: + return AUDIO_CHANNEL_OUT_3POINT1POINT2; + case AUDIO_CHANNEL_IN_3POINT0POINT2: + return AUDIO_CHANNEL_OUT_3POINT0POINT2; + case AUDIO_CHANNEL_IN_2POINT1POINT2: + return AUDIO_CHANNEL_OUT_2POINT1POINT2; + case AUDIO_CHANNEL_IN_2POINT0POINT2: + return AUDIO_CHANNEL_OUT_2POINT0POINT2; + default: + return AUDIO_CHANNEL_INVALID; + } +} + static inline bool audio_is_valid_format(audio_format_t format) { switch (format & AUDIO_FORMAT_MAIN_MASK) { @@ -1560,6 +882,8 @@ static inline bool audio_is_valid_format(audio_format_t format) case AUDIO_FORMAT_AAC_ADTS: case AUDIO_FORMAT_HE_AAC_V1: case AUDIO_FORMAT_HE_AAC_V2: + case AUDIO_FORMAT_AAC_ELD: + case AUDIO_FORMAT_AAC_XHE: case AUDIO_FORMAT_VORBIS: case AUDIO_FORMAT_OPUS: case AUDIO_FORMAT_AC3: @@ -1567,6 +891,7 @@ static inline bool audio_is_valid_format(audio_format_t format) case AUDIO_FORMAT_DTS: case AUDIO_FORMAT_DTS_HD: case AUDIO_FORMAT_IEC61937: + case AUDIO_FORMAT_DOLBY_TRUEHD: case AUDIO_FORMAT_QCELP: case AUDIO_FORMAT_EVRC: case AUDIO_FORMAT_EVRCB: @@ -1581,13 +906,12 @@ static inline bool audio_is_valid_format(audio_format_t format) case AUDIO_FORMAT_WMA: case AUDIO_FORMAT_WMA_PRO: case AUDIO_FORMAT_DSD: - return true; - case AUDIO_FORMAT_PCM_OFFLOAD: - if (format != AUDIO_FORMAT_PCM_16_BIT_OFFLOAD && - format != AUDIO_FORMAT_PCM_24_BIT_OFFLOAD) { - return false; - } - case AUDIO_FORMAT_DOLBY_TRUEHD: + case AUDIO_FORMAT_AC4: + case AUDIO_FORMAT_LDAC: + case AUDIO_FORMAT_E_AC3_JOC: + case AUDIO_FORMAT_MAT_1_0: + case AUDIO_FORMAT_MAT_2_0: + case AUDIO_FORMAT_MAT_2_1: return true; default: return false; @@ -1627,14 +951,6 @@ static inline bool audio_has_proportional_frames(audio_format_t format) || mainFormat == AUDIO_FORMAT_IEC61937); } -static inline bool audio_is_offload_pcm(audio_format_t format) -{ -#ifdef QCOM_HARDWARE - return ((format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_PCM_OFFLOAD); -#endif - return false; -} - static inline size_t audio_bytes_per_sample(audio_format_t format) { size_t size = 0; @@ -1642,7 +958,6 @@ static inline size_t audio_bytes_per_sample(audio_format_t format) switch (format) { case AUDIO_FORMAT_PCM_32_BIT: case AUDIO_FORMAT_PCM_8_24_BIT: - case AUDIO_FORMAT_PCM_24_BIT_OFFLOAD: size = sizeof(int32_t); break; case AUDIO_FORMAT_PCM_24_BIT_PACKED: @@ -1650,7 +965,6 @@ static inline size_t audio_bytes_per_sample(audio_format_t format) break; case AUDIO_FORMAT_PCM_16_BIT: case AUDIO_FORMAT_IEC61937: - case AUDIO_FORMAT_PCM_16_BIT_OFFLOAD: size = sizeof(int16_t); break; case AUDIO_FORMAT_PCM_8_BIT: @@ -1665,6 +979,12 @@ static inline size_t audio_bytes_per_sample(audio_format_t format) return size; } +static inline size_t audio_bytes_per_frame(uint32_t channel_count, audio_format_t format) +{ + // cannot overflow for reasonable channel_count + return channel_count * audio_bytes_per_sample(format); +} + /* converts device address to string sent to audio HAL via set_parameters */ static inline char *audio_device_address_to_parameter(audio_devices_t device, const char *address) { @@ -1700,6 +1020,211 @@ static inline bool audio_device_is_digital(audio_devices_t device) { } } +// Unique effect ID (can be generated from the following site: +// http://www.itu.int/ITU-T/asn1/uuid.html) +// This struct is used for effects identification and in soundtrigger. +typedef struct audio_uuid_s { + uint32_t timeLow; + uint16_t timeMid; + uint16_t timeHiAndVersion; + uint16_t clockSeq; + uint8_t node[6]; +} audio_uuid_t; + +//TODO: audio_microphone_location_t need to move to HAL v4.0 +typedef enum { + AUDIO_MICROPHONE_LOCATION_UNKNOWN = 0, + AUDIO_MICROPHONE_LOCATION_MAINBODY = 1, + AUDIO_MICROPHONE_LOCATION_MAINBODY_MOVABLE = 2, + AUDIO_MICROPHONE_LOCATION_PERIPHERAL = 3, + AUDIO_MICROPHONE_LOCATION_CNT = 4, +} audio_microphone_location_t; + +//TODO: audio_microphone_directionality_t need to move to HAL v4.0 +typedef enum { + AUDIO_MICROPHONE_DIRECTIONALITY_UNKNOWN = 0, + AUDIO_MICROPHONE_DIRECTIONALITY_OMNI = 1, + AUDIO_MICROPHONE_DIRECTIONALITY_BI_DIRECTIONAL = 2, + AUDIO_MICROPHONE_DIRECTIONALITY_CARDIOID = 3, + AUDIO_MICROPHONE_DIRECTIONALITY_HYPER_CARDIOID = 4, + AUDIO_MICROPHONE_DIRECTIONALITY_SUPER_CARDIOID = 5, + AUDIO_MICROPHONE_DIRECTIONALITY_CNT = 6, +} audio_microphone_directionality_t; + +/* A 3D point which could be used to represent geometric location + * or orientation of a microphone. + */ +struct audio_microphone_coordinate { + float x; + float y; + float z; +}; + +/* An number to indicate which group the microphone locate. Main body is + * usually group 0. Developer could use this value to group the microphones + * that locate on the same peripheral or attachments. + */ +typedef int audio_microphone_group_t; + +typedef enum { + AUDIO_MICROPHONE_CHANNEL_MAPPING_UNUSED = 0, + AUDIO_MICROPHONE_CHANNEL_MAPPING_DIRECT = 1, + AUDIO_MICROPHONE_CHANNEL_MAPPING_PROCESSED = 2, + AUDIO_MICROPHONE_CHANNEL_MAPPING_CNT = 3, +} audio_microphone_channel_mapping_t; + +/* the maximum length for the microphone id */ +#define AUDIO_MICROPHONE_ID_MAX_LEN 32 +/* max number of frequency responses in a frequency response table */ +#define AUDIO_MICROPHONE_MAX_FREQUENCY_RESPONSES 256 +/* max number of microphone */ +#define AUDIO_MICROPHONE_MAX_COUNT 32 +/* the value of unknown spl */ +#define AUDIO_MICROPHONE_SPL_UNKNOWN -FLT_MAX +/* the value of unknown sensitivity */ +#define AUDIO_MICROPHONE_SENSITIVITY_UNKNOWN -FLT_MAX +/* the value of unknown coordinate */ +#define AUDIO_MICROPHONE_COORDINATE_UNKNOWN -FLT_MAX +/* the value used as address when the address of bottom microphone is empty */ +#define AUDIO_BOTTOM_MICROPHONE_ADDRESS "bottom" +/* the value used as address when the address of back microphone is empty */ +#define AUDIO_BACK_MICROPHONE_ADDRESS "back" + +struct audio_microphone_characteristic_t { + char device_id[AUDIO_MICROPHONE_ID_MAX_LEN]; + audio_port_handle_t id; + audio_devices_t device; + char address[AUDIO_DEVICE_MAX_ADDRESS_LEN]; + audio_microphone_channel_mapping_t channel_mapping[AUDIO_CHANNEL_COUNT_MAX]; + audio_microphone_location_t location; + audio_microphone_group_t group; + unsigned int index_in_the_group; + float sensitivity; + float max_spl; + float min_spl; + audio_microphone_directionality_t directionality; + unsigned int num_frequency_responses; + float frequency_responses[2][AUDIO_MICROPHONE_MAX_FREQUENCY_RESPONSES]; + struct audio_microphone_coordinate geometric_location; + struct audio_microphone_coordinate orientation; +}; + __END_DECLS +/** + * List of known audio HAL modules. This is the base name of the audio HAL + * library composed of the "audio." prefix, one of the base names below and + * a suffix specific to the device. + * e.g: audio.primary.goldfish.so or audio.a2dp.default.so + * + * The same module names are used in audio policy configuration files. + */ + +#define AUDIO_HARDWARE_MODULE_ID_PRIMARY "primary" +#define AUDIO_HARDWARE_MODULE_ID_A2DP "a2dp" +#define AUDIO_HARDWARE_MODULE_ID_USB "usb" +#define AUDIO_HARDWARE_MODULE_ID_REMOTE_SUBMIX "r_submix" +#define AUDIO_HARDWARE_MODULE_ID_CODEC_OFFLOAD "codec_offload" +#define AUDIO_HARDWARE_MODULE_ID_STUB "stub" +#define AUDIO_HARDWARE_MODULE_ID_HEARING_AID "hearing_aid" + +/** + * Multi-Stream Decoder (MSD) HAL service name. MSD HAL is used to mix + * encoded streams together with PCM streams, producing re-encoded + * streams or PCM streams. + * + * The service must register itself using this name, and audioserver + * tries to instantiate a device factory using this name as well. + * Note that the HIDL implementation library file name *must* have the + * suffix "msd" in order to be picked up by HIDL that is: + * + * android.hardware.audio@x.x-implmsd.so + */ +#define AUDIO_HAL_SERVICE_NAME_MSD "msd" + +/** + * Parameter definitions. + * Note that in the framework code it's recommended to use AudioParameter.h + * instead of these preprocessor defines, and for sure avoid just copying + * the constant values. + */ + +#define AUDIO_PARAMETER_VALUE_ON "on" +#define AUDIO_PARAMETER_VALUE_OFF "off" + +/** + * audio device parameters + */ + +/* BT SCO Noise Reduction + Echo Cancellation parameters */ +#define AUDIO_PARAMETER_KEY_BT_NREC "bt_headset_nrec" + +/* Get a new HW synchronization source identifier. + * Return a valid source (positive integer) or AUDIO_HW_SYNC_INVALID if an error occurs + * or no HW sync is available. */ +#define AUDIO_PARAMETER_HW_AV_SYNC "hw_av_sync" + +/* Screen state */ +#define AUDIO_PARAMETER_KEY_SCREEN_STATE "screen_state" + +/** + * audio stream parameters + */ + +#define AUDIO_PARAMETER_STREAM_ROUTING "routing" /* audio_devices_t */ +#define AUDIO_PARAMETER_STREAM_FORMAT "format" /* audio_format_t */ +#define AUDIO_PARAMETER_STREAM_CHANNELS "channels" /* audio_channel_mask_t */ +#define AUDIO_PARAMETER_STREAM_FRAME_COUNT "frame_count" /* size_t */ +#define AUDIO_PARAMETER_STREAM_INPUT_SOURCE "input_source" /* audio_source_t */ +#define AUDIO_PARAMETER_STREAM_SAMPLING_RATE "sampling_rate" /* uint32_t */ + +/* Request the presentation id to be decoded by a next gen audio decoder */ +#define AUDIO_PARAMETER_STREAM_PRESENTATION_ID "presentation_id" /* int32_t */ + +/* Request the program id to be decoded by a next gen audio decoder */ +#define AUDIO_PARAMETER_STREAM_PROGRAM_ID "program_id" /* int32_t */ + +#define AUDIO_PARAMETER_DEVICE_CONNECT "connect" /* audio_devices_t */ +#define AUDIO_PARAMETER_DEVICE_DISCONNECT "disconnect" /* audio_devices_t */ + +/* Enable mono audio playback if 1, else should be 0. */ +#define AUDIO_PARAMETER_MONO_OUTPUT "mono_output" + +/* Set the HW synchronization source for an output stream. */ +#define AUDIO_PARAMETER_STREAM_HW_AV_SYNC "hw_av_sync" + +/* Query supported formats. The response is a '|' separated list of strings from + * audio_format_t enum e.g: "sup_formats=AUDIO_FORMAT_PCM_16_BIT" */ +#define AUDIO_PARAMETER_STREAM_SUP_FORMATS "sup_formats" +/* Query supported channel masks. The response is a '|' separated list of strings from + * audio_channel_mask_t enum e.g: "sup_channels=AUDIO_CHANNEL_OUT_STEREO|AUDIO_CHANNEL_OUT_MONO" */ +#define AUDIO_PARAMETER_STREAM_SUP_CHANNELS "sup_channels" +/* Query supported sampling rates. The response is a '|' separated list of integer values e.g: + * "sup_sampling_rates=44100|48000" */ +#define AUDIO_PARAMETER_STREAM_SUP_SAMPLING_RATES "sup_sampling_rates" + +#define AUDIO_PARAMETER_VALUE_LIST_SEPARATOR "|" + +/* Reconfigure offloaded A2DP codec */ +#define AUDIO_PARAMETER_RECONFIG_A2DP "reconfigA2dp" +/* Query if HwModule supports reconfiguration of offloaded A2DP codec */ +#define AUDIO_PARAMETER_A2DP_RECONFIG_SUPPORTED "isReconfigA2dpSupported" + +/** + * audio codec parameters + */ + +#define AUDIO_OFFLOAD_CODEC_PARAMS "music_offload_codec_param" +#define AUDIO_OFFLOAD_CODEC_BIT_PER_SAMPLE "music_offload_bit_per_sample" +#define AUDIO_OFFLOAD_CODEC_BIT_RATE "music_offload_bit_rate" +#define AUDIO_OFFLOAD_CODEC_AVG_BIT_RATE "music_offload_avg_bit_rate" +#define AUDIO_OFFLOAD_CODEC_ID "music_offload_codec_id" +#define AUDIO_OFFLOAD_CODEC_BLOCK_ALIGN "music_offload_block_align" +#define AUDIO_OFFLOAD_CODEC_SAMPLE_RATE "music_offload_sample_rate" +#define AUDIO_OFFLOAD_CODEC_ENCODE_OPTION "music_offload_encode_option" +#define AUDIO_OFFLOAD_CODEC_NUM_CHANNEL "music_offload_num_channels" +#define AUDIO_OFFLOAD_CODEC_DOWN_SAMPLING "music_offload_down_sampling" +#define AUDIO_OFFLOAD_CODEC_DELAY_SAMPLES "delay_samples" +#define AUDIO_OFFLOAD_CODEC_PADDING_SAMPLES "padding_samples" + #endif // ANDROID_AUDIO_CORE_H diff --git a/system/audio_effect-base.h b/system/audio_effect-base.h new file mode 100644 index 0000000..7a6a593 --- /dev/null +++ b/system/audio_effect-base.h @@ -0,0 +1,99 @@ +// This file is autogenerated by hidl-gen. Do not edit manually. +// Source: android.hardware.audio.effect@4.0 +// Root: android.hardware:hardware/interfaces + +#ifndef HIDL_GENERATED_ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_EXPORTED_CONSTANTS_H_ +#define HIDL_GENERATED_ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_EXPORTED_CONSTANTS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + EFFECT_FLAG_TYPE_SHIFT = 0, + EFFECT_FLAG_TYPE_SIZE = 3, + EFFECT_FLAG_TYPE_MASK = 7, // (((1 << TYPE_SIZE) - 1) << TYPE_SHIFT) + EFFECT_FLAG_TYPE_INSERT = 0, // (0 << TYPE_SHIFT) + EFFECT_FLAG_TYPE_AUXILIARY = 1, // (1 << TYPE_SHIFT) + EFFECT_FLAG_TYPE_REPLACE = 2, // (2 << TYPE_SHIFT) + EFFECT_FLAG_TYPE_PRE_PROC = 3, // (3 << TYPE_SHIFT) + EFFECT_FLAG_TYPE_POST_PROC = 4, // (4 << TYPE_SHIFT) + EFFECT_FLAG_INSERT_SHIFT = 3, // (TYPE_SHIFT + TYPE_SIZE) + EFFECT_FLAG_INSERT_SIZE = 3, + EFFECT_FLAG_INSERT_MASK = 56, // (((1 << INSERT_SIZE) - 1) << INSERT_SHIFT) + EFFECT_FLAG_INSERT_ANY = 0, // (0 << INSERT_SHIFT) + EFFECT_FLAG_INSERT_FIRST = 8, // (1 << INSERT_SHIFT) + EFFECT_FLAG_INSERT_LAST = 16, // (2 << INSERT_SHIFT) + EFFECT_FLAG_INSERT_EXCLUSIVE = 24, // (3 << INSERT_SHIFT) + EFFECT_FLAG_VOLUME_SHIFT = 6, // (INSERT_SHIFT + INSERT_SIZE) + EFFECT_FLAG_VOLUME_SIZE = 3, + EFFECT_FLAG_VOLUME_MASK = 448, // (((1 << VOLUME_SIZE) - 1) << VOLUME_SHIFT) + EFFECT_FLAG_VOLUME_CTRL = 64, // (1 << VOLUME_SHIFT) + EFFECT_FLAG_VOLUME_IND = 128, // (2 << VOLUME_SHIFT) + EFFECT_FLAG_VOLUME_NONE = 0, // (0 << VOLUME_SHIFT) + EFFECT_FLAG_DEVICE_SHIFT = 9, // (VOLUME_SHIFT + VOLUME_SIZE) + EFFECT_FLAG_DEVICE_SIZE = 3, + EFFECT_FLAG_DEVICE_MASK = 3584, // (((1 << DEVICE_SIZE) - 1) << DEVICE_SHIFT) + EFFECT_FLAG_DEVICE_IND = 512, // (1 << DEVICE_SHIFT) + EFFECT_FLAG_DEVICE_NONE = 0, // (0 << DEVICE_SHIFT) + EFFECT_FLAG_INPUT_SHIFT = 12, // (DEVICE_SHIFT + DEVICE_SIZE) + EFFECT_FLAG_INPUT_SIZE = 2, + EFFECT_FLAG_INPUT_MASK = 12288, // (((1 << INPUT_SIZE) - 1) << INPUT_SHIFT) + EFFECT_FLAG_INPUT_DIRECT = 4096, // (1 << INPUT_SHIFT) + EFFECT_FLAG_INPUT_PROVIDER = 8192, // (2 << INPUT_SHIFT) + EFFECT_FLAG_INPUT_BOTH = 12288, // (3 << INPUT_SHIFT) + EFFECT_FLAG_OUTPUT_SHIFT = 14, // (INPUT_SHIFT + INPUT_SIZE) + EFFECT_FLAG_OUTPUT_SIZE = 2, + EFFECT_FLAG_OUTPUT_MASK = 49152, // (((1 << OUTPUT_SIZE) - 1) << OUTPUT_SHIFT) + EFFECT_FLAG_OUTPUT_DIRECT = 16384, // (1 << OUTPUT_SHIFT) + EFFECT_FLAG_OUTPUT_PROVIDER = 32768, // (2 << OUTPUT_SHIFT) + EFFECT_FLAG_OUTPUT_BOTH = 49152, // (3 << OUTPUT_SHIFT) + EFFECT_FLAG_HW_ACC_SHIFT = 16, // (OUTPUT_SHIFT + OUTPUT_SIZE) + EFFECT_FLAG_HW_ACC_SIZE = 2, + EFFECT_FLAG_HW_ACC_MASK = 196608, // (((1 << HW_ACC_SIZE) - 1) << HW_ACC_SHIFT) + EFFECT_FLAG_HW_ACC_SIMPLE = 65536, // (1 << HW_ACC_SHIFT) + EFFECT_FLAG_HW_ACC_TUNNEL = 131072, // (2 << HW_ACC_SHIFT) + EFFECT_FLAG_AUDIO_MODE_SHIFT = 18, // (HW_ACC_SHIFT + HW_ACC_SIZE) + EFFECT_FLAG_AUDIO_MODE_SIZE = 2, + EFFECT_FLAG_AUDIO_MODE_MASK = 786432, // (((1 << AUDIO_MODE_SIZE) - 1) << AUDIO_MODE_SHIFT) + EFFECT_FLAG_AUDIO_MODE_IND = 262144, // (1 << AUDIO_MODE_SHIFT) + EFFECT_FLAG_AUDIO_MODE_NONE = 0, // (0 << AUDIO_MODE_SHIFT) + EFFECT_FLAG_AUDIO_SOURCE_SHIFT = 20, // (AUDIO_MODE_SHIFT + AUDIO_MODE_SIZE) + EFFECT_FLAG_AUDIO_SOURCE_SIZE = 2, + EFFECT_FLAG_AUDIO_SOURCE_MASK = 3145728, // (((1 << AUDIO_SOURCE_SIZE) - 1) << AUDIO_SOURCE_SHIFT) + EFFECT_FLAG_AUDIO_SOURCE_IND = 1048576, // (1 << AUDIO_SOURCE_SHIFT) + EFFECT_FLAG_AUDIO_SOURCE_NONE = 0, // (0 << AUDIO_SOURCE_SHIFT) + EFFECT_FLAG_OFFLOAD_SHIFT = 22, // (AUDIO_SOURCE_SHIFT + AUDIO_SOURCE_SIZE) + EFFECT_FLAG_OFFLOAD_SIZE = 1, + EFFECT_FLAG_OFFLOAD_MASK = 4194304, // (((1 << OFFLOAD_SIZE) - 1) << OFFLOAD_SHIFT) + EFFECT_FLAG_OFFLOAD_SUPPORTED = 4194304, // (1 << OFFLOAD_SHIFT) + EFFECT_FLAG_NO_PROCESS_SHIFT = 23, // (OFFLOAD_SHIFT + OFFLOAD_SIZE) + EFFECT_FLAG_NO_PROCESS_SIZE = 1, + EFFECT_FLAG_NO_PROCESS_MASK = 8388608, // (((1 << NO_PROCESS_SIZE) - 1) << NO_PROCESS_SHIFT) + EFFECT_FLAG_NO_PROCESS = 8388608, // (1 << NO_PROCESS_SHIFT) +}; + +typedef enum { + EFFECT_BUFFER_ACCESS_WRITE = 0, + EFFECT_BUFFER_ACCESS_READ = 1, // (::android::hardware::audio::effect::V4_0::EffectBufferAccess.ACCESS_WRITE implicitly + 1) + EFFECT_BUFFER_ACCESS_ACCUMULATE = 2, // (::android::hardware::audio::effect::V4_0::EffectBufferAccess.ACCESS_READ implicitly + 1) +} effect_buffer_access_e; + +enum { + EFFECT_CONFIG_BUFFER = 1, + EFFECT_CONFIG_SMP_RATE = 2, + EFFECT_CONFIG_CHANNELS = 4, + EFFECT_CONFIG_FORMAT = 8, + EFFECT_CONFIG_ACC_MODE = 16, +}; + +typedef enum { + EFFECT_FEATURE_AUX_CHANNELS = 0, + EFFECT_FEATURE_CNT = 1, // (::android::hardware::audio::effect::V4_0::EffectFeature.AUX_CHANNELS implicitly + 1) +} effect_feature_e; + +#ifdef __cplusplus +} +#endif + +#endif // HIDL_GENERATED_ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_EXPORTED_CONSTANTS_H_ diff --git a/system/audio_effect.h b/system/audio_effect.h new file mode 100644 index 0000000..4cdc773 --- /dev/null +++ b/system/audio_effect.h @@ -0,0 +1,536 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef ANDROID_AUDIO_EFFECT_CORE_H +#define ANDROID_AUDIO_EFFECT_CORE_H + +#include "audio.h" +#include "audio_effect-base.h" + +__BEGIN_DECLS + +///////////////////////////////////////////////// +// Common Definitions +///////////////////////////////////////////////// + +// +//--- Effect descriptor structure effect_descriptor_t +// + +// This format is used for both "type" and "uuid" fields of the effect descriptor structure. +// - When used for effect type and the engine is implementing and effect corresponding to a standard +// OpenSL ES interface, this ID must be the one defined in OpenSLES_IID.h for that interface. +// - When used as uuid, it should be a unique UUID for this particular implementation. +typedef audio_uuid_t effect_uuid_t; + +// Maximum length of character strings in structures defines by this API. +#define EFFECT_STRING_LEN_MAX 64 + +// NULL UUID definition (matches SL_IID_NULL_) +#define EFFECT_UUID_INITIALIZER { 0xec7178ec, 0xe5e1, 0x4432, 0xa3f4, \ + { 0x46, 0x57, 0xe6, 0x79, 0x52, 0x10 } } +static const effect_uuid_t EFFECT_UUID_NULL_ = EFFECT_UUID_INITIALIZER; +static const effect_uuid_t * const EFFECT_UUID_NULL = &EFFECT_UUID_NULL_; +static const char * const EFFECT_UUID_NULL_STR = "ec7178ec-e5e1-4432-a3f4-4657e6795210"; + +// The effect descriptor contains necessary information to facilitate the enumeration of the effect +// engines present in a library. +typedef struct effect_descriptor_s { + effect_uuid_t type; // UUID of to the OpenSL ES interface implemented by this effect + effect_uuid_t uuid; // UUID for this particular implementation + uint32_t apiVersion; // Version of the effect control API implemented + uint32_t flags; // effect engine capabilities/requirements flags (see below) + uint16_t cpuLoad; // CPU load indication (see below) + uint16_t memoryUsage; // Data Memory usage (see below) + char name[EFFECT_STRING_LEN_MAX]; // human readable effect name + char implementor[EFFECT_STRING_LEN_MAX]; // human readable effect implementor name +} effect_descriptor_t; + +#define EFFECT_CONFIG_ALL (EFFECT_CONFIG_BUFFER | \ + EFFECT_CONFIG_SMP_RATE | \ + EFFECT_CONFIG_CHANNELS | \ + EFFECT_CONFIG_FORMAT | \ + EFFECT_CONFIG_ACC_MODE) + +///////////////////////////////////////////////// +// Effect control interface +///////////////////////////////////////////////// + +// +//--- Standardized command codes for command() function +// +enum effect_command_e { + EFFECT_CMD_INIT, // initialize effect engine + EFFECT_CMD_SET_CONFIG, // configure effect engine (see effect_config_t) + EFFECT_CMD_RESET, // reset effect engine + EFFECT_CMD_ENABLE, // enable effect process + EFFECT_CMD_DISABLE, // disable effect process + EFFECT_CMD_SET_PARAM, // set parameter immediately (see effect_param_t) + EFFECT_CMD_SET_PARAM_DEFERRED, // set parameter deferred + EFFECT_CMD_SET_PARAM_COMMIT, // commit previous set parameter deferred + EFFECT_CMD_GET_PARAM, // get parameter + EFFECT_CMD_SET_DEVICE, // set audio device (see audio.h, audio_devices_t) + EFFECT_CMD_SET_VOLUME, // set volume + EFFECT_CMD_SET_AUDIO_MODE, // set the audio mode (normal, ring, ...) + EFFECT_CMD_SET_CONFIG_REVERSE, // configure effect engine reverse stream(see effect_config_t) + EFFECT_CMD_SET_INPUT_DEVICE, // set capture device (see audio.h, audio_devices_t) + EFFECT_CMD_GET_CONFIG, // read effect engine configuration + EFFECT_CMD_GET_CONFIG_REVERSE, // read configure effect engine reverse stream configuration + EFFECT_CMD_GET_FEATURE_SUPPORTED_CONFIGS,// get all supported configurations for a feature. + EFFECT_CMD_GET_FEATURE_CONFIG, // get current feature configuration + EFFECT_CMD_SET_FEATURE_CONFIG, // set current feature configuration + EFFECT_CMD_SET_AUDIO_SOURCE, // set the audio source (see audio.h, audio_source_t) + EFFECT_CMD_OFFLOAD, // set if effect thread is an offload one, + // send the ioHandle of the effect thread + EFFECT_CMD_FIRST_PROPRIETARY = 0x10000 // first proprietary command code +}; + +//================================================================================================== +// command: EFFECT_CMD_INIT +//-------------------------------------------------------------------------------------------------- +// description: +// Initialize effect engine: All configurations return to default +//-------------------------------------------------------------------------------------------------- +// command format: +// size: 0 +// data: N/A +//-------------------------------------------------------------------------------------------------- +// reply format: +// size: sizeof(int) +// data: status +//================================================================================================== +// command: EFFECT_CMD_SET_CONFIG +//-------------------------------------------------------------------------------------------------- +// description: +// Apply new audio parameters configurations for input and output buffers +//-------------------------------------------------------------------------------------------------- +// command format: +// size: sizeof(effect_config_t) +// data: effect_config_t +//-------------------------------------------------------------------------------------------------- +// reply format: +// size: sizeof(int) +// data: status +//================================================================================================== +// command: EFFECT_CMD_RESET +//-------------------------------------------------------------------------------------------------- +// description: +// Reset the effect engine. Keep configuration but resets state and buffer content +//-------------------------------------------------------------------------------------------------- +// command format: +// size: 0 +// data: N/A +//-------------------------------------------------------------------------------------------------- +// reply format: +// size: 0 +// data: N/A +//================================================================================================== +// command: EFFECT_CMD_ENABLE +//-------------------------------------------------------------------------------------------------- +// description: +// Enable the process. Called by the framework before the first call to process() +//-------------------------------------------------------------------------------------------------- +// command format: +// size: 0 +// data: N/A +//-------------------------------------------------------------------------------------------------- +// reply format: +// size: sizeof(int) +// data: status +//================================================================================================== +// command: EFFECT_CMD_DISABLE +//-------------------------------------------------------------------------------------------------- +// description: +// Disable the process. Called by the framework after the last call to process() +//-------------------------------------------------------------------------------------------------- +// command format: +// size: 0 +// data: N/A +//-------------------------------------------------------------------------------------------------- +// reply format: +// size: sizeof(int) +// data: status +//================================================================================================== +// command: EFFECT_CMD_SET_PARAM +//-------------------------------------------------------------------------------------------------- +// description: +// Set a parameter and apply it immediately +//-------------------------------------------------------------------------------------------------- +// command format: +// size: sizeof(effect_param_t) + size of param and value +// data: effect_param_t + param + value. See effect_param_t definition below for value offset +//-------------------------------------------------------------------------------------------------- +// reply format: +// size: sizeof(int) +// data: status +//================================================================================================== +// command: EFFECT_CMD_SET_PARAM_DEFERRED +//-------------------------------------------------------------------------------------------------- +// description: +// Set a parameter but apply it only when receiving EFFECT_CMD_SET_PARAM_COMMIT command +//-------------------------------------------------------------------------------------------------- +// command format: +// size: sizeof(effect_param_t) + size of param and value +// data: effect_param_t + param + value. See effect_param_t definition below for value offset +//-------------------------------------------------------------------------------------------------- +// reply format: +// size: 0 +// data: N/A +//================================================================================================== +// command: EFFECT_CMD_SET_PARAM_COMMIT +//-------------------------------------------------------------------------------------------------- +// description: +// Apply all previously received EFFECT_CMD_SET_PARAM_DEFERRED commands +//-------------------------------------------------------------------------------------------------- +// command format: +// size: 0 +// data: N/A +//-------------------------------------------------------------------------------------------------- +// reply format: +// size: sizeof(int) +// data: status +//================================================================================================== +// command: EFFECT_CMD_GET_PARAM +//-------------------------------------------------------------------------------------------------- +// description: +// Get a parameter value +//-------------------------------------------------------------------------------------------------- +// command format: +// size: sizeof(effect_param_t) + size of param +// data: effect_param_t + param +//-------------------------------------------------------------------------------------------------- +// reply format: +// size: sizeof(effect_param_t) + size of param and value +// data: effect_param_t + param + value. See effect_param_t definition below for value offset +//================================================================================================== +// command: EFFECT_CMD_SET_DEVICE +//-------------------------------------------------------------------------------------------------- +// description: +// Set the rendering device the audio output path is connected to. See audio.h, audio_devices_t +// for device values. +// The effect implementation must set EFFECT_FLAG_DEVICE_IND flag in its descriptor to receive this +// command when the device changes +//-------------------------------------------------------------------------------------------------- +// command format: +// size: sizeof(uint32_t) +// data: uint32_t +//-------------------------------------------------------------------------------------------------- +// reply format: +// size: 0 +// data: N/A +//================================================================================================== +// command: EFFECT_CMD_SET_VOLUME +//-------------------------------------------------------------------------------------------------- +// description: +// Set and get volume. Used by audio framework to delegate volume control to effect engine. +// The effect implementation must set EFFECT_FLAG_VOLUME_IND or EFFECT_FLAG_VOLUME_CTRL flag in +// its descriptor to receive this command before every call to process() function +// If EFFECT_FLAG_VOLUME_CTRL flag is set in the effect descriptor, the effect engine must return +// the volume that should be applied before the effect is processed. The overall volume (the volume +// actually applied by the effect engine multiplied by the returned value) should match the value +// indicated in the command. +//-------------------------------------------------------------------------------------------------- +// command format: +// size: n * sizeof(uint32_t) +// data: volume for each channel defined in effect_config_t for output buffer expressed in +// 8.24 fixed point format +//-------------------------------------------------------------------------------------------------- +// reply format: +// size: n * sizeof(uint32_t) / 0 +// data: - if EFFECT_FLAG_VOLUME_CTRL is set in effect descriptor: +// volume for each channel defined in effect_config_t for output buffer expressed in +// 8.24 fixed point format +// - if EFFECT_FLAG_VOLUME_CTRL is not set in effect descriptor: +// N/A +// It is legal to receive a null pointer as pReplyData in which case the effect framework has +// delegated volume control to another effect +//================================================================================================== +// command: EFFECT_CMD_SET_AUDIO_MODE +//-------------------------------------------------------------------------------------------------- +// description: +// Set the audio mode. The effect implementation must set EFFECT_FLAG_AUDIO_MODE_IND flag in its +// descriptor to receive this command when the audio mode changes. +//-------------------------------------------------------------------------------------------------- +// command format: +// size: sizeof(uint32_t) +// data: audio_mode_t +//-------------------------------------------------------------------------------------------------- +// reply format: +// size: 0 +// data: N/A +//================================================================================================== +// command: EFFECT_CMD_SET_CONFIG_REVERSE +//-------------------------------------------------------------------------------------------------- +// description: +// Apply new audio parameters configurations for input and output buffers of reverse stream. +// An example of reverse stream is the echo reference supplied to an Acoustic Echo Canceler. +//-------------------------------------------------------------------------------------------------- +// command format: +// size: sizeof(effect_config_t) +// data: effect_config_t +//-------------------------------------------------------------------------------------------------- +// reply format: +// size: sizeof(int) +// data: status +//================================================================================================== +// command: EFFECT_CMD_SET_INPUT_DEVICE +//-------------------------------------------------------------------------------------------------- +// description: +// Set the capture device the audio input path is connected to. See audio.h, audio_devices_t +// for device values. +// The effect implementation must set EFFECT_FLAG_DEVICE_IND flag in its descriptor to receive this +// command when the device changes +//-------------------------------------------------------------------------------------------------- +// command format: +// size: sizeof(uint32_t) +// data: uint32_t +//-------------------------------------------------------------------------------------------------- +// reply format: +// size: 0 +// data: N/A +//================================================================================================== +// command: EFFECT_CMD_GET_CONFIG +//-------------------------------------------------------------------------------------------------- +// description: +// Read audio parameters configurations for input and output buffers +//-------------------------------------------------------------------------------------------------- +// command format: +// size: 0 +// data: N/A +//-------------------------------------------------------------------------------------------------- +// reply format: +// size: sizeof(effect_config_t) +// data: effect_config_t +//================================================================================================== +// command: EFFECT_CMD_GET_CONFIG_REVERSE +//-------------------------------------------------------------------------------------------------- +// description: +// Read audio parameters configurations for input and output buffers of reverse stream +//-------------------------------------------------------------------------------------------------- +// command format: +// size: 0 +// data: N/A +//-------------------------------------------------------------------------------------------------- +// reply format: +// size: sizeof(effect_config_t) +// data: effect_config_t +//================================================================================================== +// command: EFFECT_CMD_GET_FEATURE_SUPPORTED_CONFIGS +//-------------------------------------------------------------------------------------------------- +// description: +// Queries for supported configurations for a particular feature (e.g. get the supported +// combinations of main and auxiliary channels for a noise suppressor). +// The command parameter is the feature identifier (See effect_feature_e for a list of defined +// features) followed by the maximum number of configuration descriptor to return. +// The reply is composed of: +// - status (uint32_t): +// - 0 if feature is supported +// - -ENOSYS if the feature is not supported, +// - -ENOMEM if the feature is supported but the total number of supported configurations +// exceeds the maximum number indicated by the caller. +// - total number of supported configurations (uint32_t) +// - an array of configuration descriptors. +// The actual number of descriptors returned must not exceed the maximum number indicated by +// the caller. +//-------------------------------------------------------------------------------------------------- +// command format: +// size: 2 x sizeof(uint32_t) +// data: effect_feature_e + maximum number of configurations to return +//-------------------------------------------------------------------------------------------------- +// reply format: +// size: 2 x sizeof(uint32_t) + n x sizeof () +// data: status + total number of configurations supported + array of n config descriptors +//================================================================================================== +// command: EFFECT_CMD_GET_FEATURE_CONFIG +//-------------------------------------------------------------------------------------------------- +// description: +// Retrieves current configuration for a given feature. +// The reply status is: +// - 0 if feature is supported +// - -ENOSYS if the feature is not supported, +//-------------------------------------------------------------------------------------------------- +// command format: +// size: sizeof(uint32_t) +// data: effect_feature_e +//-------------------------------------------------------------------------------------------------- +// reply format: +// size: sizeof(uint32_t) + sizeof () +// data: status + config descriptor +//================================================================================================== +// command: EFFECT_CMD_SET_FEATURE_CONFIG +//-------------------------------------------------------------------------------------------------- +// description: +// Sets current configuration for a given feature. +// The reply status is: +// - 0 if feature is supported +// - -ENOSYS if the feature is not supported, +// - -EINVAL if the configuration is invalid +//-------------------------------------------------------------------------------------------------- +// command format: +// size: sizeof(uint32_t) + sizeof () +// data: effect_feature_e + config descriptor +//-------------------------------------------------------------------------------------------------- +// reply format: +// size: sizeof(uint32_t) +// data: status +//================================================================================================== +// command: EFFECT_CMD_SET_AUDIO_SOURCE +//-------------------------------------------------------------------------------------------------- +// description: +// Set the audio source the capture path is configured for (Camcorder, voice recognition...). +// See audio.h, audio_source_t for values. +//-------------------------------------------------------------------------------------------------- +// command format: +// size: sizeof(uint32_t) +// data: uint32_t +//-------------------------------------------------------------------------------------------------- +// reply format: +// size: 0 +// data: N/A +//================================================================================================== +// command: EFFECT_CMD_OFFLOAD +//-------------------------------------------------------------------------------------------------- +// description: +// 1.indicate if the playback thread the effect is attached to is offloaded or not +// 2.update the io handle of the playback thread the effect is attached to +//-------------------------------------------------------------------------------------------------- +// command format: +// size: sizeof(effect_offload_param_t) +// data: effect_offload_param_t +//-------------------------------------------------------------------------------------------------- +// reply format: +// size: sizeof(uint32_t) +// data: uint32_t +//-------------------------------------------------------------------------------------------------- +// command: EFFECT_CMD_FIRST_PROPRIETARY +//-------------------------------------------------------------------------------------------------- +// description: +// All proprietary effect commands must use command codes above this value. The size and format of +// command and response fields is free in this case +//================================================================================================== + +// Audio buffer descriptor used by process(), bufferProvider() functions and buffer_config_t +// structure. Multi-channel audio is always interleaved. The channel order is from LSB to MSB with +// regard to the channel mask definition in audio.h, audio_channel_mask_t e.g : +// Stereo: left, right +// 5 point 1: front left, front right, front center, low frequency, back left, back right +// The buffer size is expressed in frame count, a frame being composed of samples for all +// channels at a given time. Frame size for unspecified format (AUDIO_FORMAT_OTHER) is 8 bit by +// definition +typedef struct audio_buffer_s { + size_t frameCount; // number of frames in buffer + union { + void* raw; // raw pointer to start of buffer + float* f32; // pointer to float 32 bit data at start of buffer + int32_t* s32; // pointer to signed 32 bit data at start of buffer + int16_t* s16; // pointer to signed 16 bit data at start of buffer + uint8_t* u8; // pointer to unsigned 8 bit data at start of buffer + }; +} audio_buffer_t; + +// The buffer_provider_s structure contains functions that can be used +// by the effect engine process() function to query and release input +// or output audio buffer. +// The getBuffer() function is called to retrieve a buffer where data +// should read from or written to by process() function. +// The releaseBuffer() function MUST be called when the buffer retrieved +// with getBuffer() is not needed anymore. +// The process function should use the buffer provider mechanism to retrieve +// input or output buffer if the inBuffer or outBuffer passed as argument is NULL +// and the buffer configuration (buffer_config_t) given by the EFFECT_CMD_SET_CONFIG +// command did not specify an audio buffer. + +typedef int32_t (* buffer_function_t)(void *cookie, audio_buffer_t *buffer); + +typedef struct buffer_provider_s { + buffer_function_t getBuffer; // retrieve next buffer + buffer_function_t releaseBuffer; // release used buffer + void *cookie; // for use by client of buffer provider functions +} buffer_provider_t; + +// The buffer_config_s structure specifies the input or output audio format +// to be used by the effect engine. +typedef struct buffer_config_s { + audio_buffer_t buffer; // buffer for use by process() function if not passed explicitly + uint32_t samplingRate; // sampling rate + uint32_t channels; // channel mask (see audio_channel_mask_t in audio.h) + buffer_provider_t bufferProvider; // buffer provider + uint8_t format; // Audio format (see audio_format_t in audio.h) + uint8_t accessMode; // read/write or accumulate in buffer (effect_buffer_access_e) + uint16_t mask; // indicates which of the above fields is valid +} buffer_config_t; + +// EFFECT_FEATURE_AUX_CHANNELS feature configuration descriptor. Describe a combination +// of main and auxiliary channels supported +typedef struct channel_config_s { + audio_channel_mask_t main_channels; // channel mask for main channels + audio_channel_mask_t aux_channels; // channel mask for auxiliary channels +} channel_config_t; + + +// effect_config_s structure is used to configure audio parameters and buffers for effect engine +// input and output. +typedef struct effect_config_s { + buffer_config_t inputCfg; + buffer_config_t outputCfg; +} effect_config_t; + + +// effect_param_s structure describes the format of the pCmdData argument of EFFECT_CMD_SET_PARAM +// command and pCmdData and pReplyData of EFFECT_CMD_GET_PARAM command. +// psize and vsize represent the actual size of parameter and value. +// +// NOTE: the start of value field inside the data field is always on a 32 bit boundary: +// +// +-----------+ +// | status | sizeof(int) +// +-----------+ +// | psize | sizeof(int) +// +-----------+ +// | vsize | sizeof(int) +// +-----------+ +// | | | | +// ~ parameter ~ > psize | +// | | | > ((psize - 1)/sizeof(int) + 1) * sizeof(int) +// +-----------+ | +// | padding | | +// +-----------+ +// | | | +// ~ value ~ > vsize +// | | | +// +-----------+ + +typedef struct effect_param_s { + int32_t status; // Transaction status (unused for command, used for reply) + uint32_t psize; // Parameter size + uint32_t vsize; // Value size + char data[]; // Start of Parameter + Value data +} effect_param_t; + +// Maximum effect_param_t size +#define EFFECT_PARAM_SIZE_MAX 65536 + +// structure used by EFFECT_CMD_OFFLOAD command +typedef struct effect_offload_param_s { + bool isOffload; // true if the playback thread the effect is attached to is offloaded + int ioHandle; // io handle of the playback thread the effect is attached to +} effect_offload_param_t; + + +__END_DECLS + +#endif // ANDROID_AUDIO_EFFECT_CORE_H diff --git a/system/audio_policy.h b/system/audio_policy.h index 2881104..450125b 100644 --- a/system/audio_policy.h +++ b/system/audio_policy.h @@ -30,7 +30,9 @@ __BEGIN_DECLS * frameworks/base/include/media/AudioSystem.h */ -/* device categories used for audio_policy->set_force_use() */ +/* device categories used for audio_policy->set_force_use() + * These must match the values in AudioSystem.java + */ typedef enum { AUDIO_POLICY_FORCE_NONE, AUDIO_POLICY_FORCE_SPEAKER, @@ -45,6 +47,9 @@ typedef enum { AUDIO_POLICY_FORCE_NO_BT_A2DP, /* A2DP sink is not preferred to speaker or wired HS */ AUDIO_POLICY_FORCE_SYSTEM_ENFORCED, AUDIO_POLICY_FORCE_HDMI_SYSTEM_AUDIO_ENFORCED, + AUDIO_POLICY_FORCE_ENCODED_SURROUND_NEVER, + AUDIO_POLICY_FORCE_ENCODED_SURROUND_ALWAYS, + AUDIO_POLICY_FORCE_ENCODED_SURROUND_MANUAL, AUDIO_POLICY_FORCE_CFG_CNT, AUDIO_POLICY_FORCE_CFG_MAX = AUDIO_POLICY_FORCE_CFG_CNT - 1, @@ -52,7 +57,9 @@ typedef enum { AUDIO_POLICY_FORCE_DEFAULT = AUDIO_POLICY_FORCE_NONE, } audio_policy_forced_cfg_t; -/* usages used for audio_policy->set_force_use() */ +/* usages used for audio_policy->set_force_use() + * These must match the values in AudioSystem.java + */ typedef enum { AUDIO_POLICY_FORCE_FOR_COMMUNICATION, AUDIO_POLICY_FORCE_FOR_MEDIA, @@ -60,6 +67,8 @@ typedef enum { AUDIO_POLICY_FORCE_FOR_DOCK, AUDIO_POLICY_FORCE_FOR_SYSTEM, AUDIO_POLICY_FORCE_FOR_HDMI_SYSTEM_AUDIO, + AUDIO_POLICY_FORCE_FOR_ENCODED_SURROUND, + AUDIO_POLICY_FORCE_FOR_VIBRATE_RINGING, AUDIO_POLICY_FORCE_USE_CNT, AUDIO_POLICY_FORCE_USE_MAX = AUDIO_POLICY_FORCE_USE_CNT - 1, diff --git a/system/camera.h b/system/camera.h index 0570ca0..10acfe6 100644 --- a/system/camera.h +++ b/system/camera.h @@ -200,7 +200,6 @@ enum { * IMPLEMENTATION_DEFINED, then HALv3 devices will use gralloc usage flags * of SW_READ_OFTEN. */ -#ifndef CAMERA_VENDOR_L_COMPAT CAMERA_CMD_SET_VIDEO_FORMAT = 11, CAMERA_CMD_VENDOR_START = 20, @@ -220,21 +219,6 @@ enum { CAMERA_CMD_METADATA_ON = CAMERA_CMD_VENDOR_START + 6, CAMERA_CMD_METADATA_OFF = CAMERA_CMD_VENDOR_START + 7, CAMERA_CMD_VENDOR_END = 200, -#else - - /** - * Values used by older HALs, provided as an option for compatibility - */ - CAMERA_CMD_HISTOGRAM_ON = 11, - CAMERA_CMD_HISTOGRAM_OFF = 12, - CAMERA_CMD_HISTOGRAM_SEND_DATA = 13, - CAMERA_CMD_LONGSHOT_ON = 14, - CAMERA_CMD_LONGSHOT_OFF = 15, - CAMERA_CMD_STOP_LONGSHOT = 16, - CAMERA_CMD_METADATA_ON = 100, - CAMERA_CMD_METADATA_OFF = 101, - CAMERA_CMD_SET_VIDEO_FORMAT = 102, -#endif }; /** camera fatal errors */ @@ -248,6 +232,15 @@ enum { * (except disconnect and sending CAMERA_CMD_PING) after getting this. */ CAMERA_ERROR_RELEASED = 2, + + /** + * Camera was released because device policy change or the client application + * is going to background. The client should call Camera::disconnect + * immediately after getting this notification. Otherwise, the camera will be + * released by camera service in a short time. The client should not call any + * method (except disconnect and sending CAMERA_CMD_PING) after getting this. + */ + CAMERA_ERROR_DISABLED = 3, CAMERA_ERROR_SERVER_DIED = 100 }; diff --git a/system/graphics-base-v1.0.h b/system/graphics-base-v1.0.h new file mode 100644 index 0000000..44913cc --- /dev/null +++ b/system/graphics-base-v1.0.h @@ -0,0 +1,140 @@ +// This file is autogenerated by hidl-gen. Do not edit manually. +// Source: android.hardware.graphics.common@1.0 +// Location: hardware/interfaces/graphics/common/1.0/ + +#ifndef HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_COMMON_V1_0_EXPORTED_CONSTANTS_H_ +#define HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_COMMON_V1_0_EXPORTED_CONSTANTS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + HAL_PIXEL_FORMAT_RGBA_8888 = 1, + HAL_PIXEL_FORMAT_RGBX_8888 = 2, + HAL_PIXEL_FORMAT_RGB_888 = 3, + HAL_PIXEL_FORMAT_RGB_565 = 4, + HAL_PIXEL_FORMAT_BGRA_8888 = 5, + HAL_PIXEL_FORMAT_YCBCR_422_SP = 16, + HAL_PIXEL_FORMAT_YCRCB_420_SP = 17, + HAL_PIXEL_FORMAT_YCBCR_422_I = 20, + HAL_PIXEL_FORMAT_RGBA_FP16 = 22, + HAL_PIXEL_FORMAT_RAW16 = 32, + HAL_PIXEL_FORMAT_BLOB = 33, + HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED = 34, + HAL_PIXEL_FORMAT_YCBCR_420_888 = 35, + HAL_PIXEL_FORMAT_RAW_OPAQUE = 36, + HAL_PIXEL_FORMAT_RAW10 = 37, + HAL_PIXEL_FORMAT_RAW12 = 38, + HAL_PIXEL_FORMAT_RGBA_1010102 = 43, + HAL_PIXEL_FORMAT_Y8 = 538982489, + HAL_PIXEL_FORMAT_Y16 = 540422489, + HAL_PIXEL_FORMAT_YV12 = 842094169, +} android_pixel_format_t; + +typedef enum { + HAL_TRANSFORM_FLIP_H = 1, // (1 << 0) + HAL_TRANSFORM_FLIP_V = 2, // (1 << 1) + HAL_TRANSFORM_ROT_90 = 4, // (1 << 2) + HAL_TRANSFORM_ROT_180 = 3, // (FLIP_H | FLIP_V) + HAL_TRANSFORM_ROT_270 = 7, // ((FLIP_H | FLIP_V) | ROT_90) +} android_transform_t; + +typedef enum { + HAL_DATASPACE_UNKNOWN = 0, + HAL_DATASPACE_ARBITRARY = 1, + HAL_DATASPACE_STANDARD_SHIFT = 16, + HAL_DATASPACE_STANDARD_MASK = 4128768, // (63 << STANDARD_SHIFT) + HAL_DATASPACE_STANDARD_UNSPECIFIED = 0, // (0 << STANDARD_SHIFT) + HAL_DATASPACE_STANDARD_BT709 = 65536, // (1 << STANDARD_SHIFT) + HAL_DATASPACE_STANDARD_BT601_625 = 131072, // (2 << STANDARD_SHIFT) + HAL_DATASPACE_STANDARD_BT601_625_UNADJUSTED = 196608, // (3 << STANDARD_SHIFT) + HAL_DATASPACE_STANDARD_BT601_525 = 262144, // (4 << STANDARD_SHIFT) + HAL_DATASPACE_STANDARD_BT601_525_UNADJUSTED = 327680, // (5 << STANDARD_SHIFT) + HAL_DATASPACE_STANDARD_BT2020 = 393216, // (6 << STANDARD_SHIFT) + HAL_DATASPACE_STANDARD_BT2020_CONSTANT_LUMINANCE = 458752, // (7 << STANDARD_SHIFT) + HAL_DATASPACE_STANDARD_BT470M = 524288, // (8 << STANDARD_SHIFT) + HAL_DATASPACE_STANDARD_FILM = 589824, // (9 << STANDARD_SHIFT) + HAL_DATASPACE_STANDARD_DCI_P3 = 655360, // (10 << STANDARD_SHIFT) + HAL_DATASPACE_STANDARD_ADOBE_RGB = 720896, // (11 << STANDARD_SHIFT) + HAL_DATASPACE_TRANSFER_SHIFT = 22, + HAL_DATASPACE_TRANSFER_MASK = 130023424, // (31 << TRANSFER_SHIFT) + HAL_DATASPACE_TRANSFER_UNSPECIFIED = 0, // (0 << TRANSFER_SHIFT) + HAL_DATASPACE_TRANSFER_LINEAR = 4194304, // (1 << TRANSFER_SHIFT) + HAL_DATASPACE_TRANSFER_SRGB = 8388608, // (2 << TRANSFER_SHIFT) + HAL_DATASPACE_TRANSFER_SMPTE_170M = 12582912, // (3 << TRANSFER_SHIFT) + HAL_DATASPACE_TRANSFER_GAMMA2_2 = 16777216, // (4 << TRANSFER_SHIFT) + HAL_DATASPACE_TRANSFER_GAMMA2_6 = 20971520, // (5 << TRANSFER_SHIFT) + HAL_DATASPACE_TRANSFER_GAMMA2_8 = 25165824, // (6 << TRANSFER_SHIFT) + HAL_DATASPACE_TRANSFER_ST2084 = 29360128, // (7 << TRANSFER_SHIFT) + HAL_DATASPACE_TRANSFER_HLG = 33554432, // (8 << TRANSFER_SHIFT) + HAL_DATASPACE_RANGE_SHIFT = 27, + HAL_DATASPACE_RANGE_MASK = 939524096, // (7 << RANGE_SHIFT) + HAL_DATASPACE_RANGE_UNSPECIFIED = 0, // (0 << RANGE_SHIFT) + HAL_DATASPACE_RANGE_FULL = 134217728, // (1 << RANGE_SHIFT) + HAL_DATASPACE_RANGE_LIMITED = 268435456, // (2 << RANGE_SHIFT) + HAL_DATASPACE_RANGE_EXTENDED = 402653184, // (3 << RANGE_SHIFT) + HAL_DATASPACE_SRGB_LINEAR = 512, + HAL_DATASPACE_V0_SRGB_LINEAR = 138477568, // ((STANDARD_BT709 | TRANSFER_LINEAR) | RANGE_FULL) + HAL_DATASPACE_V0_SCRGB_LINEAR = + 406913024, // ((STANDARD_BT709 | TRANSFER_LINEAR) | RANGE_EXTENDED) + HAL_DATASPACE_SRGB = 513, + HAL_DATASPACE_V0_SRGB = 142671872, // ((STANDARD_BT709 | TRANSFER_SRGB) | RANGE_FULL) + HAL_DATASPACE_V0_SCRGB = 411107328, // ((STANDARD_BT709 | TRANSFER_SRGB) | RANGE_EXTENDED) + HAL_DATASPACE_JFIF = 257, + HAL_DATASPACE_V0_JFIF = 146931712, // ((STANDARD_BT601_625 | TRANSFER_SMPTE_170M) | RANGE_FULL) + HAL_DATASPACE_BT601_625 = 258, + HAL_DATASPACE_V0_BT601_625 = + 281149440, // ((STANDARD_BT601_625 | TRANSFER_SMPTE_170M) | RANGE_LIMITED) + HAL_DATASPACE_BT601_525 = 259, + HAL_DATASPACE_V0_BT601_525 = + 281280512, // ((STANDARD_BT601_525 | TRANSFER_SMPTE_170M) | RANGE_LIMITED) + HAL_DATASPACE_BT709 = 260, + HAL_DATASPACE_V0_BT709 = 281083904, // ((STANDARD_BT709 | TRANSFER_SMPTE_170M) | RANGE_LIMITED) + HAL_DATASPACE_DCI_P3_LINEAR = 139067392, // ((STANDARD_DCI_P3 | TRANSFER_LINEAR) | RANGE_FULL) + HAL_DATASPACE_DCI_P3 = 155844608, // ((STANDARD_DCI_P3 | TRANSFER_GAMMA2_6) | RANGE_FULL) + HAL_DATASPACE_DISPLAY_P3_LINEAR = + 139067392, // ((STANDARD_DCI_P3 | TRANSFER_LINEAR) | RANGE_FULL) + HAL_DATASPACE_DISPLAY_P3 = 143261696, // ((STANDARD_DCI_P3 | TRANSFER_SRGB) | RANGE_FULL) + HAL_DATASPACE_ADOBE_RGB = 151715840, // ((STANDARD_ADOBE_RGB | TRANSFER_GAMMA2_2) | RANGE_FULL) + HAL_DATASPACE_BT2020_LINEAR = 138805248, // ((STANDARD_BT2020 | TRANSFER_LINEAR) | RANGE_FULL) + HAL_DATASPACE_BT2020 = 147193856, // ((STANDARD_BT2020 | TRANSFER_SMPTE_170M) | RANGE_FULL) + HAL_DATASPACE_BT2020_PQ = 163971072, // ((STANDARD_BT2020 | TRANSFER_ST2084) | RANGE_FULL) + HAL_DATASPACE_DEPTH = 4096, + HAL_DATASPACE_SENSOR = 4097, +} android_dataspace_t; + +typedef enum { + HAL_COLOR_MODE_NATIVE = 0, + HAL_COLOR_MODE_STANDARD_BT601_625 = 1, + HAL_COLOR_MODE_STANDARD_BT601_625_UNADJUSTED = 2, + HAL_COLOR_MODE_STANDARD_BT601_525 = 3, + HAL_COLOR_MODE_STANDARD_BT601_525_UNADJUSTED = 4, + HAL_COLOR_MODE_STANDARD_BT709 = 5, + HAL_COLOR_MODE_DCI_P3 = 6, + HAL_COLOR_MODE_SRGB = 7, + HAL_COLOR_MODE_ADOBE_RGB = 8, + HAL_COLOR_MODE_DISPLAY_P3 = 9, +} android_color_mode_t; + +typedef enum { + HAL_COLOR_TRANSFORM_IDENTITY = 0, + HAL_COLOR_TRANSFORM_ARBITRARY_MATRIX = 1, + HAL_COLOR_TRANSFORM_VALUE_INVERSE = 2, + HAL_COLOR_TRANSFORM_GRAYSCALE = 3, + HAL_COLOR_TRANSFORM_CORRECT_PROTANOPIA = 4, + HAL_COLOR_TRANSFORM_CORRECT_DEUTERANOPIA = 5, + HAL_COLOR_TRANSFORM_CORRECT_TRITANOPIA = 6, +} android_color_transform_t; + +typedef enum { + HAL_HDR_DOLBY_VISION = 1, + HAL_HDR_HDR10 = 2, + HAL_HDR_HLG = 3, +} android_hdr_t; + +#ifdef __cplusplus +} +#endif + +#endif // HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_COMMON_V1_0_EXPORTED_CONSTANTS_H_ diff --git a/system/graphics-base-v1.1.h b/system/graphics-base-v1.1.h new file mode 100644 index 0000000..f95b9ba --- /dev/null +++ b/system/graphics-base-v1.1.h @@ -0,0 +1,48 @@ +// This file is autogenerated by hidl-gen. Do not edit manually. +// Source: android.hardware.graphics.common@1.1 +// Location: hardware/interfaces/graphics/common/1.1/ + +#ifndef HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_COMMON_V1_1_EXPORTED_CONSTANTS_H_ +#define HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_COMMON_V1_1_EXPORTED_CONSTANTS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + HAL_PIXEL_FORMAT_DEPTH_16 = 48, + HAL_PIXEL_FORMAT_DEPTH_24 = 49, + HAL_PIXEL_FORMAT_DEPTH_24_STENCIL_8 = 50, + HAL_PIXEL_FORMAT_DEPTH_32F = 51, + HAL_PIXEL_FORMAT_DEPTH_32F_STENCIL_8 = 52, + HAL_PIXEL_FORMAT_STENCIL_8 = 53, + HAL_PIXEL_FORMAT_YCBCR_P010 = 54, +} android_pixel_format_v1_1_t; + +typedef enum { + HAL_DATASPACE_BT2020_ITU = + 281411584, // ((STANDARD_BT2020 | TRANSFER_SMPTE_170M) | RANGE_LIMITED) + HAL_DATASPACE_BT2020_ITU_PQ = + 298188800, // ((STANDARD_BT2020 | TRANSFER_ST2084) | RANGE_LIMITED) + HAL_DATASPACE_BT2020_ITU_HLG = 302383104, // ((STANDARD_BT2020 | TRANSFER_HLG) | RANGE_LIMITED) + HAL_DATASPACE_BT2020_HLG = 168165376, // ((STANDARD_BT2020 | TRANSFER_HLG) | RANGE_FULL) +} android_dataspace_v1_1_t; + +typedef enum { + HAL_COLOR_MODE_BT2020 = 10, + HAL_COLOR_MODE_BT2100_PQ = 11, + HAL_COLOR_MODE_BT2100_HLG = 12, +} android_color_mode_v1_1_t; + +typedef enum { + HAL_RENDER_INTENT_COLORIMETRIC = 0, + HAL_RENDER_INTENT_ENHANCE = 1, + HAL_RENDER_INTENT_TONE_MAP_COLORIMETRIC = 2, + HAL_RENDER_INTENT_TONE_MAP_ENHANCE = 3, +} android_render_intent_v1_1_t; + +#ifdef __cplusplus +} +#endif + +#endif // HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_COMMON_V1_1_EXPORTED_CONSTANTS_H_ diff --git a/system/graphics-base.h b/system/graphics-base.h new file mode 100644 index 0000000..ea92007 --- /dev/null +++ b/system/graphics-base.h @@ -0,0 +1,7 @@ +#ifndef SYSTEM_CORE_GRAPHICS_BASE_H_ +#define SYSTEM_CORE_GRAPHICS_BASE_H_ + +#include "graphics-base-v1.0.h" +#include "graphics-base-v1.1.h" + +#endif // SYSTEM_CORE_GRAPHICS_BASE_H_ diff --git a/system/graphics-sw.h b/system/graphics-sw.h new file mode 100644 index 0000000..9e1a88e --- /dev/null +++ b/system/graphics-sw.h @@ -0,0 +1,16 @@ +#ifndef SYSTEM_CORE_GRAPHICS_SW_H_ +#define SYSTEM_CORE_GRAPHICS_SW_H_ + +/* Software formats not in the HAL definitions. */ +typedef enum { + HAL_PIXEL_FORMAT_YCBCR_422_888 = 39, // 0x27 + HAL_PIXEL_FORMAT_YCBCR_444_888 = 40, // 0x28 + HAL_PIXEL_FORMAT_FLEX_RGB_888 = 41, // 0x29 + HAL_PIXEL_FORMAT_FLEX_RGBA_8888 = 42, // 0x2A +} android_pixel_format_sw_t; + +/* for compatibility */ +#define HAL_PIXEL_FORMAT_YCbCr_422_888 HAL_PIXEL_FORMAT_YCBCR_422_888 +#define HAL_PIXEL_FORMAT_YCbCr_444_888 HAL_PIXEL_FORMAT_YCBCR_444_888 + +#endif // SYSTEM_CORE_GRAPHICS_SW_H_ diff --git a/system/graphics.h b/system/graphics.h index 529a562..1b6060a 100644 --- a/system/graphics.h +++ b/system/graphics.h @@ -20,10 +20,29 @@ #include #include +/* + * Some of the enums are now defined in HIDL in hardware/interfaces and are + * generated. + */ +#include "graphics-base.h" +#include "graphics-sw.h" + #ifdef __cplusplus extern "C" { #endif +/* for compatibility */ +#define HAL_PIXEL_FORMAT_YCbCr_420_888 HAL_PIXEL_FORMAT_YCBCR_420_888 +#define HAL_PIXEL_FORMAT_YCbCr_422_SP HAL_PIXEL_FORMAT_YCBCR_422_SP +#define HAL_PIXEL_FORMAT_YCrCb_420_SP HAL_PIXEL_FORMAT_YCRCB_420_SP +#define HAL_PIXEL_FORMAT_YCbCr_422_I HAL_PIXEL_FORMAT_YCBCR_422_I +typedef android_pixel_format_t android_pixel_format; +typedef android_transform_t android_transform; +typedef android_dataspace_t android_dataspace; +typedef android_color_mode_t android_color_mode; +typedef android_color_transform_t android_color_transform; +typedef android_hdr_t android_hdr; + /* * If the HAL needs to create service threads to handle graphics related * tasks, these threads need to run at HAL_PRIORITY_URGENT_DISPLAY priority @@ -38,411 +57,6 @@ extern "C" { #define HAL_PRIORITY_URGENT_DISPLAY (-8) -/** - * pixel format definitions - */ - -typedef enum android_pixel_format { - /* - * "linear" color pixel formats: - * - * When used with ANativeWindow, the dataSpace field describes the color - * space of the buffer. - * - * The color space determines, for example, if the formats are linear or - * gamma-corrected; or whether any special operations are performed when - * reading or writing into a buffer in one of these formats. - */ - HAL_PIXEL_FORMAT_RGBA_8888 = 1, - HAL_PIXEL_FORMAT_RGBX_8888 = 2, - HAL_PIXEL_FORMAT_RGB_888 = 3, - HAL_PIXEL_FORMAT_RGB_565 = 4, - HAL_PIXEL_FORMAT_BGRA_8888 = 5, - - /* - * 0x100 - 0x1FF - * - * This range is reserved for pixel formats that are specific to the HAL - * implementation. Implementations can use any value in this range to - * communicate video pixel formats between their HAL modules. These formats - * must not have an alpha channel. Additionally, an EGLimage created from a - * gralloc buffer of one of these formats must be supported for use with the - * GL_OES_EGL_image_external OpenGL ES extension. - */ - - /* - * Android YUV format: - * - * This format is exposed outside of the HAL to software decoders and - * applications. EGLImageKHR must support it in conjunction with the - * OES_EGL_image_external extension. - * - * YV12 is a 4:2:0 YCrCb planar format comprised of a WxH Y plane followed - * by (W/2) x (H/2) Cr and Cb planes. - * - * This format assumes - * - an even width - * - an even height - * - a horizontal stride multiple of 16 pixels - * - a vertical stride equal to the height - * - * y_size = stride * height - * c_stride = ALIGN(stride/2, 16) - * c_size = c_stride * height/2 - * size = y_size + c_size * 2 - * cr_offset = y_size - * cb_offset = y_size + c_size - * - * When used with ANativeWindow, the dataSpace field describes the color - * space of the buffer. - */ - HAL_PIXEL_FORMAT_YV12 = 0x32315659, // YCrCb 4:2:0 Planar - - - /* - * Android Y8 format: - * - * This format is exposed outside of the HAL to the framework. - * The expected gralloc usage flags are SW_* and HW_CAMERA_*, - * and no other HW_ flags will be used. - * - * Y8 is a YUV planar format comprised of a WxH Y plane, - * with each pixel being represented by 8 bits. - * - * It is equivalent to just the Y plane from YV12. - * - * This format assumes - * - an even width - * - an even height - * - a horizontal stride multiple of 16 pixels - * - a vertical stride equal to the height - * - * size = stride * height - * - * When used with ANativeWindow, the dataSpace field describes the color - * space of the buffer. - */ - HAL_PIXEL_FORMAT_Y8 = 0x20203859, - - /* - * Android Y16 format: - * - * This format is exposed outside of the HAL to the framework. - * The expected gralloc usage flags are SW_* and HW_CAMERA_*, - * and no other HW_ flags will be used. - * - * Y16 is a YUV planar format comprised of a WxH Y plane, - * with each pixel being represented by 16 bits. - * - * It is just like Y8, but has double the bits per pixel (little endian). - * - * This format assumes - * - an even width - * - an even height - * - a horizontal stride multiple of 16 pixels - * - a vertical stride equal to the height - * - strides are specified in pixels, not in bytes - * - * size = stride * height * 2 - * - * When used with ANativeWindow, the dataSpace field describes the color - * space of the buffer, except that dataSpace field - * HAL_DATASPACE_DEPTH indicates that this buffer contains a depth - * image where each sample is a distance value measured by a depth camera, - * plus an associated confidence value. - */ - HAL_PIXEL_FORMAT_Y16 = 0x20363159, - - /* - * Android RAW sensor format: - * - * This format is exposed outside of the camera HAL to applications. - * - * RAW16 is a single-channel, 16-bit, little endian format, typically - * representing raw Bayer-pattern images from an image sensor, with minimal - * processing. - * - * The exact pixel layout of the data in the buffer is sensor-dependent, and - * needs to be queried from the camera device. - * - * Generally, not all 16 bits are used; more common values are 10 or 12 - * bits. If not all bits are used, the lower-order bits are filled first. - * All parameters to interpret the raw data (black and white points, - * color space, etc) must be queried from the camera device. - * - * This format assumes - * - an even width - * - an even height - * - a horizontal stride multiple of 16 pixels - * - a vertical stride equal to the height - * - strides are specified in pixels, not in bytes - * - * size = stride * height * 2 - * - * This format must be accepted by the gralloc module when used with the - * following usage flags: - * - GRALLOC_USAGE_HW_CAMERA_* - * - GRALLOC_USAGE_SW_* - * - GRALLOC_USAGE_RENDERSCRIPT - * - * When used with ANativeWindow, the dataSpace should be - * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial - * extra metadata to define. - */ - HAL_PIXEL_FORMAT_RAW16 = 0x20, - - /* - * Android RAW10 format: - * - * This format is exposed outside of the camera HAL to applications. - * - * RAW10 is a single-channel, 10-bit per pixel, densely packed in each row, - * unprocessed format, usually representing raw Bayer-pattern images coming from - * an image sensor. - * - * In an image buffer with this format, starting from the first pixel of each - * row, each 4 consecutive pixels are packed into 5 bytes (40 bits). Each one - * of the first 4 bytes contains the top 8 bits of each pixel, The fifth byte - * contains the 2 least significant bits of the 4 pixels, the exact layout data - * for each 4 consecutive pixels is illustrated below (Pi[j] stands for the jth - * bit of the ith pixel): - * - * bit 7 bit 0 - * =====|=====|=====|=====|=====|=====|=====|=====| - * Byte 0: |P0[9]|P0[8]|P0[7]|P0[6]|P0[5]|P0[4]|P0[3]|P0[2]| - * |-----|-----|-----|-----|-----|-----|-----|-----| - * Byte 1: |P1[9]|P1[8]|P1[7]|P1[6]|P1[5]|P1[4]|P1[3]|P1[2]| - * |-----|-----|-----|-----|-----|-----|-----|-----| - * Byte 2: |P2[9]|P2[8]|P2[7]|P2[6]|P2[5]|P2[4]|P2[3]|P2[2]| - * |-----|-----|-----|-----|-----|-----|-----|-----| - * Byte 3: |P3[9]|P3[8]|P3[7]|P3[6]|P3[5]|P3[4]|P3[3]|P3[2]| - * |-----|-----|-----|-----|-----|-----|-----|-----| - * Byte 4: |P3[1]|P3[0]|P2[1]|P2[0]|P1[1]|P1[0]|P0[1]|P0[0]| - * =============================================== - * - * This format assumes - * - a width multiple of 4 pixels - * - an even height - * - a vertical stride equal to the height - * - strides are specified in bytes, not in pixels - * - * size = stride * height - * - * When stride is equal to width * (10 / 8), there will be no padding bytes at - * the end of each row, the entire image data is densely packed. When stride is - * larger than width * (10 / 8), padding bytes will be present at the end of each - * row (including the last row). - * - * This format must be accepted by the gralloc module when used with the - * following usage flags: - * - GRALLOC_USAGE_HW_CAMERA_* - * - GRALLOC_USAGE_SW_* - * - GRALLOC_USAGE_RENDERSCRIPT - * - * When used with ANativeWindow, the dataSpace field should be - * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial - * extra metadata to define. - */ - HAL_PIXEL_FORMAT_RAW10 = 0x25, - - /* - * Android RAW12 format: - * - * This format is exposed outside of camera HAL to applications. - * - * RAW12 is a single-channel, 12-bit per pixel, densely packed in each row, - * unprocessed format, usually representing raw Bayer-pattern images coming from - * an image sensor. - * - * In an image buffer with this format, starting from the first pixel of each - * row, each two consecutive pixels are packed into 3 bytes (24 bits). The first - * and second byte contains the top 8 bits of first and second pixel. The third - * byte contains the 4 least significant bits of the two pixels, the exact layout - * data for each two consecutive pixels is illustrated below (Pi[j] stands for - * the jth bit of the ith pixel): - * - * bit 7 bit 0 - * ======|======|======|======|======|======|======|======| - * Byte 0: |P0[11]|P0[10]|P0[ 9]|P0[ 8]|P0[ 7]|P0[ 6]|P0[ 5]|P0[ 4]| - * |------|------|------|------|------|------|------|------| - * Byte 1: |P1[11]|P1[10]|P1[ 9]|P1[ 8]|P1[ 7]|P1[ 6]|P1[ 5]|P1[ 4]| - * |------|------|------|------|------|------|------|------| - * Byte 2: |P1[ 3]|P1[ 2]|P1[ 1]|P1[ 0]|P0[ 3]|P0[ 2]|P0[ 1]|P0[ 0]| - * ======================================================= - * - * This format assumes: - * - a width multiple of 4 pixels - * - an even height - * - a vertical stride equal to the height - * - strides are specified in bytes, not in pixels - * - * size = stride * height - * - * When stride is equal to width * (12 / 8), there will be no padding bytes at - * the end of each row, the entire image data is densely packed. When stride is - * larger than width * (12 / 8), padding bytes will be present at the end of - * each row (including the last row). - * - * This format must be accepted by the gralloc module when used with the - * following usage flags: - * - GRALLOC_USAGE_HW_CAMERA_* - * - GRALLOC_USAGE_SW_* - * - GRALLOC_USAGE_RENDERSCRIPT - * - * When used with ANativeWindow, the dataSpace field should be - * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial - * extra metadata to define. - */ - HAL_PIXEL_FORMAT_RAW12 = 0x26, - - /* - * Android opaque RAW format: - * - * This format is exposed outside of the camera HAL to applications. - * - * RAW_OPAQUE is a format for unprocessed raw image buffers coming from an - * image sensor. The actual structure of buffers of this format is - * implementation-dependent. - * - * This format must be accepted by the gralloc module when used with the - * following usage flags: - * - GRALLOC_USAGE_HW_CAMERA_* - * - GRALLOC_USAGE_SW_* - * - GRALLOC_USAGE_RENDERSCRIPT - * - * When used with ANativeWindow, the dataSpace field should be - * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial - * extra metadata to define. - */ - HAL_PIXEL_FORMAT_RAW_OPAQUE = 0x24, - - /* - * Android binary blob graphics buffer format: - * - * This format is used to carry task-specific data which does not have a - * standard image structure. The details of the format are left to the two - * endpoints. - * - * A typical use case is for transporting JPEG-compressed images from the - * Camera HAL to the framework or to applications. - * - * Buffers of this format must have a height of 1, and width equal to their - * size in bytes. - * - * When used with ANativeWindow, the mapping of the dataSpace field to - * buffer contents for BLOB is as follows: - * - * dataSpace value | Buffer contents - * -------------------------------+----------------------------------------- - * HAL_DATASPACE_JFIF | An encoded JPEG image - * HAL_DATASPACE_DEPTH | An android_depth_points buffer - * Other | Unsupported - * - */ - HAL_PIXEL_FORMAT_BLOB = 0x21, - - /* - * Android format indicating that the choice of format is entirely up to the - * device-specific Gralloc implementation. - * - * The Gralloc implementation should examine the usage bits passed in when - * allocating a buffer with this format, and it should derive the pixel - * format from those usage flags. This format will never be used with any - * of the GRALLOC_USAGE_SW_* usage flags. - * - * If a buffer of this format is to be used as an OpenGL ES texture, the - * framework will assume that sampling the texture will always return an - * alpha value of 1.0 (i.e. the buffer contains only opaque pixel values). - * - * When used with ANativeWindow, the dataSpace field describes the color - * space of the buffer. - */ - HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED = 0x22, - - /* - * Android flexible YCbCr 4:2:0 formats - * - * This format allows platforms to use an efficient YCbCr/YCrCb 4:2:0 - * buffer layout, while still describing the general format in a - * layout-independent manner. While called YCbCr, it can be - * used to describe formats with either chromatic ordering, as well as - * whole planar or semiplanar layouts. - * - * struct android_ycbcr (below) is the the struct used to describe it. - * - * This format must be accepted by the gralloc module when - * USAGE_SW_WRITE_* or USAGE_SW_READ_* are set. - * - * This format is locked for use by gralloc's (*lock_ycbcr) method, and - * locking with the (*lock) method will return an error. - * - * When used with ANativeWindow, the dataSpace field describes the color - * space of the buffer. - */ - HAL_PIXEL_FORMAT_YCbCr_420_888 = 0x23, - - /* - * Android flexible YCbCr 4:2:2 formats - * - * This format allows platforms to use an efficient YCbCr/YCrCb 4:2:2 - * buffer layout, while still describing the general format in a - * layout-independent manner. While called YCbCr, it can be - * used to describe formats with either chromatic ordering, as well as - * whole planar or semiplanar layouts. - * - * This format is currently only used by SW readable buffers - * produced by MediaCodecs, so the gralloc module can ignore this format. - */ - HAL_PIXEL_FORMAT_YCbCr_422_888 = 0x27, - - /* - * Android flexible YCbCr 4:4:4 formats - * - * This format allows platforms to use an efficient YCbCr/YCrCb 4:4:4 - * buffer layout, while still describing the general format in a - * layout-independent manner. While called YCbCr, it can be - * used to describe formats with either chromatic ordering, as well as - * whole planar or semiplanar layouts. - * - * This format is currently only used by SW readable buffers - * produced by MediaCodecs, so the gralloc module can ignore this format. - */ - HAL_PIXEL_FORMAT_YCbCr_444_888 = 0x28, - - /* - * Android flexible RGB 888 formats - * - * This format allows platforms to use an efficient RGB/BGR/RGBX/BGRX - * buffer layout, while still describing the general format in a - * layout-independent manner. While called RGB, it can be - * used to describe formats with either color ordering and optional - * padding, as well as whole planar layout. - * - * This format is currently only used by SW readable buffers - * produced by MediaCodecs, so the gralloc module can ignore this format. - */ - HAL_PIXEL_FORMAT_FLEX_RGB_888 = 0x29, - - /* - * Android flexible RGBA 8888 formats - * - * This format allows platforms to use an efficient RGBA/BGRA/ARGB/ABGR - * buffer layout, while still describing the general format in a - * layout-independent manner. While called RGBA, it can be - * used to describe formats with any of the component orderings, as - * well as whole planar layout. - * - * This format is currently only used by SW readable buffers - * produced by MediaCodecs, so the gralloc module can ignore this format. - */ - HAL_PIXEL_FORMAT_FLEX_RGBA_8888 = 0x2A, - - /* Legacy formats (deprecated), used by ImageFormat.java */ - HAL_PIXEL_FORMAT_YCbCr_422_SP = 0x10, // NV16 - HAL_PIXEL_FORMAT_YCrCb_420_SP = 0x11, // NV21 - HAL_PIXEL_FORMAT_YCbCr_422_I = 0x14, // YUY2 -} android_pixel_format_t; - /* * Structure for describing YCbCr formats for consumption by applications. * This is used with HAL_PIXEL_FORMAT_YCbCr_*_888. @@ -452,15 +66,15 @@ typedef enum android_pixel_format { * * Buffers must have a 8 bit depth. * - * @y, @cb, and @cr point to the first byte of their respective planes. + * y, cb, and cr point to the first byte of their respective planes. * * Stride describes the distance in bytes from the first value of one row of * the image to the first value of the next row. It includes the width of the * image plus padding. - * @ystride is the stride of the luma plane. - * @cstride is the stride of the chroma planes. + * ystride is the stride of the luma plane. + * cstride is the stride of the chroma planes. * - * @chroma_step is the distance in bytes from one chroma pixel value to the + * chroma_step is the distance in bytes from one chroma pixel value to the * next. This is 2 bytes for semiplanar (because chroma values are interleaved * and each chroma value is one byte) and 1 for planar. */ @@ -585,9 +199,9 @@ typedef struct android_flex_layout { * measurement is correct. It is between 0.f and 1.f, inclusive, with 1.f == * 100% confidence. * - * @num_points is the number of points in the list + * num_points is the number of points in the list * - * @xyz_points is the flexible array of floating-point values. + * xyz_points is the flexible array of floating-point values. * It contains (num_points) * 4 floats. * * For example: @@ -612,799 +226,40 @@ struct android_depth_points { /** reserved for future use, set to 0 by gralloc's (*lock)() */ uint32_t reserved[8]; +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wc99-extensions" +#endif float xyzc_points[]; +#if defined(__clang__) +#pragma clang diagnostic pop +#endif }; /** - * Transformation definitions - * - * IMPORTANT NOTE: - * HAL_TRANSFORM_ROT_90 is applied CLOCKWISE and AFTER HAL_TRANSFORM_FLIP_{H|V}. - * - */ - -typedef enum android_transform { - /* flip source image horizontally (around the vertical axis) */ - HAL_TRANSFORM_FLIP_H = 0x01, - /* flip source image vertically (around the horizontal axis)*/ - HAL_TRANSFORM_FLIP_V = 0x02, - /* rotate source image 90 degrees clockwise */ - HAL_TRANSFORM_ROT_90 = 0x04, - /* rotate source image 180 degrees */ - HAL_TRANSFORM_ROT_180 = 0x03, - /* rotate source image 270 degrees clockwise */ - HAL_TRANSFORM_ROT_270 = 0x07, - /* don't use. see system/window.h */ - HAL_TRANSFORM_RESERVED = 0x08, -} android_transform_t; - -/** - * Dataspace Definitions - * ====================== - * - * Dataspace is the definition of how pixel values should be interpreted. - * - * For many formats, this is the colorspace of the image data, which includes - * primaries (including white point) and the transfer characteristic function, - * which describes both gamma curve and numeric range (within the bit depth). - * - * Other dataspaces include depth measurement data from a depth camera. - * - * A dataspace is comprised of a number of fields. - * - * Version - * -------- - * The top 2 bits represent the revision of the field specification. This is - * currently always 0. - * - * - * bits 31-30 29 - 0 - * +-----+----------------------------------------------------+ - * fields | Rev | Revision specific fields | - * +-----+----------------------------------------------------+ - * - * Field layout for version = 0: - * ---------------------------- - * - * A dataspace is comprised of the following fields: - * Standard - * Transfer function - * Range - * - * bits 31-30 29-27 26 - 22 21 - 16 15 - 0 - * +-----+-----+--------+--------+----------------------------+ - * fields | 0 |Range|Transfer|Standard| Legacy and custom | - * +-----+-----+--------+--------+----------------------------+ - * VV RRR TTTTT SSSSSS LLLLLLLL LLLLLLLL - * - * If range, transfer and standard fields are all 0 (e.g. top 16 bits are - * all zeroes), the bottom 16 bits contain either a legacy dataspace value, - * or a custom value. - */ - -typedef enum android_dataspace { - /* - * Default-assumption data space, when not explicitly specified. - * - * It is safest to assume the buffer is an image with sRGB primaries and - * encoding ranges, but the consumer and/or the producer of the data may - * simply be using defaults. No automatic gamma transform should be - * expected, except for a possible display gamma transform when drawn to a - * screen. - */ - HAL_DATASPACE_UNKNOWN = 0x0, - - /* - * Arbitrary dataspace with manually defined characteristics. Definition - * for colorspaces or other meaning must be communicated separately. - * - * This is used when specifying primaries, transfer characteristics, - * etc. separately. - * - * A typical use case is in video encoding parameters (e.g. for H.264), - * where a colorspace can have separately defined primaries, transfer - * characteristics, etc. - */ - HAL_DATASPACE_ARBITRARY = 0x1, - - /* - * Color-description aspects - * - * The following aspects define various characteristics of the color - * specification. These represent bitfields, so that a data space value - * can specify each of them independently. - */ - - HAL_DATASPACE_STANDARD_SHIFT = 16, - - /* - * Standard aspect - * - * Defines the chromaticity coordinates of the source primaries in terms of - * the CIE 1931 definition of x and y specified in ISO 11664-1. - */ - HAL_DATASPACE_STANDARD_MASK = 63 << HAL_DATASPACE_STANDARD_SHIFT, // 0x3F - - /* - * Chromacity coordinates are unknown or are determined by the application. - * Implementations shall use the following suggested standards: - * - * All YCbCr formats: BT709 if size is 720p or larger (since most video - * content is letterboxed this corresponds to width is - * 1280 or greater, or height is 720 or greater). - * BT601_625 if size is smaller than 720p or is JPEG. - * All RGB formats: BT709. - * - * For all other formats standard is undefined, and implementations should use - * an appropriate standard for the data represented. - */ - HAL_DATASPACE_STANDARD_UNSPECIFIED = 0 << HAL_DATASPACE_STANDARD_SHIFT, - - /* - * Primaries: x y - * green 0.300 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - * - * Use the unadjusted KR = 0.2126, KB = 0.0722 luminance interpretation - * for RGB conversion. - */ - HAL_DATASPACE_STANDARD_BT709 = 1 << HAL_DATASPACE_STANDARD_SHIFT, - - /* - * Primaries: x y - * green 0.290 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - * - * KR = 0.299, KB = 0.114. This adjusts the luminance interpretation - * for RGB conversion from the one purely determined by the primaries - * to minimize the color shift into RGB space that uses BT.709 - * primaries. - */ - HAL_DATASPACE_STANDARD_BT601_625 = 2 << HAL_DATASPACE_STANDARD_SHIFT, - - /* - * Primaries: x y - * green 0.290 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - * - * Use the unadjusted KR = 0.222, KB = 0.071 luminance interpretation - * for RGB conversion. - */ - HAL_DATASPACE_STANDARD_BT601_625_UNADJUSTED = 3 << HAL_DATASPACE_STANDARD_SHIFT, - - /* - * Primaries: x y - * green 0.310 0.595 - * blue 0.155 0.070 - * red 0.630 0.340 - * white (D65) 0.3127 0.3290 - * - * KR = 0.299, KB = 0.114. This adjusts the luminance interpretation - * for RGB conversion from the one purely determined by the primaries - * to minimize the color shift into RGB space that uses BT.709 - * primaries. - */ - HAL_DATASPACE_STANDARD_BT601_525 = 4 << HAL_DATASPACE_STANDARD_SHIFT, - - /* - * Primaries: x y - * green 0.310 0.595 - * blue 0.155 0.070 - * red 0.630 0.340 - * white (D65) 0.3127 0.3290 - * - * Use the unadjusted KR = 0.212, KB = 0.087 luminance interpretation - * for RGB conversion (as in SMPTE 240M). - */ - HAL_DATASPACE_STANDARD_BT601_525_UNADJUSTED = 5 << HAL_DATASPACE_STANDARD_SHIFT, - - /* - * Primaries: x y - * green 0.170 0.797 - * blue 0.131 0.046 - * red 0.708 0.292 - * white (D65) 0.3127 0.3290 - * - * Use the unadjusted KR = 0.2627, KB = 0.0593 luminance interpretation - * for RGB conversion. - */ - HAL_DATASPACE_STANDARD_BT2020 = 6 << HAL_DATASPACE_STANDARD_SHIFT, - - /* - * Primaries: x y - * green 0.170 0.797 - * blue 0.131 0.046 - * red 0.708 0.292 - * white (D65) 0.3127 0.3290 - * - * Use the unadjusted KR = 0.2627, KB = 0.0593 luminance interpretation - * for RGB conversion using the linear domain. - */ - HAL_DATASPACE_STANDARD_BT2020_CONSTANT_LUMINANCE = 7 << HAL_DATASPACE_STANDARD_SHIFT, - - /* - * Primaries: x y - * green 0.21 0.71 - * blue 0.14 0.08 - * red 0.67 0.33 - * white (C) 0.310 0.316 - * - * Use the unadjusted KR = 0.30, KB = 0.11 luminance interpretation - * for RGB conversion. - */ - HAL_DATASPACE_STANDARD_BT470M = 8 << HAL_DATASPACE_STANDARD_SHIFT, - - /* - * Primaries: x y - * green 0.243 0.692 - * blue 0.145 0.049 - * red 0.681 0.319 - * white (C) 0.310 0.316 - * - * Use the unadjusted KR = 0.254, KB = 0.068 luminance interpretation - * for RGB conversion. - */ - HAL_DATASPACE_STANDARD_FILM = 9 << HAL_DATASPACE_STANDARD_SHIFT, - - HAL_DATASPACE_TRANSFER_SHIFT = 22, - - /* - * Transfer aspect - * - * Transfer characteristics are the opto-electronic transfer characteristic - * at the source as a function of linear optical intensity (luminance). - * - * For digital signals, E corresponds to the recorded value. Normally, the - * transfer function is applied in RGB space to each of the R, G and B - * components independently. This may result in color shift that can be - * minized by applying the transfer function in Lab space only for the L - * component. Implementation may apply the transfer function in RGB space - * for all pixel formats if desired. - */ - - HAL_DATASPACE_TRANSFER_MASK = 31 << HAL_DATASPACE_TRANSFER_SHIFT, // 0x1F - - /* - * Transfer characteristics are unknown or are determined by the - * application. - * - * Implementations should use the following transfer functions: - * - * For YCbCr formats: use HAL_DATASPACE_TRANSFER_SMPTE_170M - * For RGB formats: use HAL_DATASPACE_TRANSFER_SRGB - * - * For all other formats transfer function is undefined, and implementations - * should use an appropriate standard for the data represented. - */ - HAL_DATASPACE_TRANSFER_UNSPECIFIED = 0 << HAL_DATASPACE_TRANSFER_SHIFT, - - /* - * Transfer characteristic curve: - * E = L - * L - luminance of image 0 <= L <= 1 for conventional colorimetry - * E - corresponding electrical signal - */ - HAL_DATASPACE_TRANSFER_LINEAR = 1 << HAL_DATASPACE_TRANSFER_SHIFT, - - /* - * Transfer characteristic curve: - * - * E = 1.055 * L^(1/2.4) - 0.055 for 0.0031308 <= L <= 1 - * = 12.92 * L for 0 <= L < 0.0031308 - * L - luminance of image 0 <= L <= 1 for conventional colorimetry - * E - corresponding electrical signal - */ - HAL_DATASPACE_TRANSFER_SRGB = 2 << HAL_DATASPACE_TRANSFER_SHIFT, - - /* - * BT.601 525, BT.601 625, BT.709, BT.2020 - * - * Transfer characteristic curve: - * E = 1.099 * L ^ 0.45 - 0.099 for 0.018 <= L <= 1 - * = 4.500 * L for 0 <= L < 0.018 - * L - luminance of image 0 <= L <= 1 for conventional colorimetry - * E - corresponding electrical signal - */ - HAL_DATASPACE_TRANSFER_SMPTE_170M = 3 << HAL_DATASPACE_TRANSFER_SHIFT, - - /* - * Assumed display gamma 2.2. - * - * Transfer characteristic curve: - * E = L ^ (1/2.2) - * L - luminance of image 0 <= L <= 1 for conventional colorimetry - * E - corresponding electrical signal - */ - HAL_DATASPACE_TRANSFER_GAMMA2_2 = 4 << HAL_DATASPACE_TRANSFER_SHIFT, - - /* - * display gamma 2.8. - * - * Transfer characteristic curve: - * E = L ^ (1/2.8) - * L - luminance of image 0 <= L <= 1 for conventional colorimetry - * E - corresponding electrical signal - */ - HAL_DATASPACE_TRANSFER_GAMMA2_8 = 5 << HAL_DATASPACE_TRANSFER_SHIFT, - - /* - * SMPTE ST 2084 - * - * Transfer characteristic curve: - * E = ((c1 + c2 * L^n) / (1 + c3 * L^n)) ^ m - * c1 = c3 - c2 + 1 = 3424 / 4096 = 0.8359375 - * c2 = 32 * 2413 / 4096 = 18.8515625 - * c3 = 32 * 2392 / 4096 = 18.6875 - * m = 128 * 2523 / 4096 = 78.84375 - * n = 0.25 * 2610 / 4096 = 0.1593017578125 - * L - luminance of image 0 <= L <= 1 for HDR colorimetry. - * L = 1 corresponds to 10000 cd/m2 - * E - corresponding electrical signal - */ - HAL_DATASPACE_TRANSFER_ST2084 = 6 << HAL_DATASPACE_TRANSFER_SHIFT, - - /* - * ARIB STD-B67 Hybrid Log Gamma - * - * Transfer characteristic curve: - * E = r * L^0.5 for 0 <= L <= 1 - * = a * ln(L - b) + c for 1 < L - * a = 0.17883277 - * b = 0.28466892 - * c = 0.55991073 - * r = 0.5 - * L - luminance of image 0 <= L for HDR colorimetry. L = 1 corresponds - * to reference white level of 100 cd/m2 - * E - corresponding electrical signal - */ - HAL_DATASPACE_TRANSFER_HLG = 7 << HAL_DATASPACE_TRANSFER_SHIFT, - - HAL_DATASPACE_RANGE_SHIFT = 27, - - /* - * Range aspect - * - * Defines the range of values corresponding to the unit range of 0-1. - * This is defined for YCbCr only, but can be expanded to RGB space. - */ - HAL_DATASPACE_RANGE_MASK = 7 << HAL_DATASPACE_RANGE_SHIFT, // 0x7 - - /* - * Range is unknown or are determined by the application. Implementations - * shall use the following suggested ranges: - * - * All YCbCr formats: limited range. - * All RGB or RGBA formats (including RAW and Bayer): full range. - * All Y formats: full range - * - * For all other formats range is undefined, and implementations should use - * an appropriate range for the data represented. - */ - HAL_DATASPACE_RANGE_UNSPECIFIED = 0 << HAL_DATASPACE_RANGE_SHIFT, - - /* - * Full range uses all values for Y, Cb and Cr from - * 0 to 2^b-1, where b is the bit depth of the color format. - */ - HAL_DATASPACE_RANGE_FULL = 1 << HAL_DATASPACE_RANGE_SHIFT, - - /* - * Limited range uses values 16/256*2^b to 235/256*2^b for Y, and - * 1/16*2^b to 15/16*2^b for Cb, Cr, R, G and B, where b is the bit depth of - * the color format. - * - * E.g. For 8-bit-depth formats: - * Luma (Y) samples should range from 16 to 235, inclusive - * Chroma (Cb, Cr) samples should range from 16 to 240, inclusive - * - * For 10-bit-depth formats: - * Luma (Y) samples should range from 64 to 940, inclusive - * Chroma (Cb, Cr) samples should range from 64 to 960, inclusive - */ - HAL_DATASPACE_RANGE_LIMITED = 2 << HAL_DATASPACE_RANGE_SHIFT, - - /* - * Legacy dataspaces - */ - - /* - * sRGB linear encoding: - * - * The red, green, and blue components are stored in sRGB space, but - * are linear, not gamma-encoded. - * The RGB primaries and the white point are the same as BT.709. - * - * The values are encoded using the full range ([0,255] for 8-bit) for all - * components. - */ - HAL_DATASPACE_SRGB_LINEAR = 0x200, // deprecated, use HAL_DATASPACE_V0_SRGB_LINEAR - - HAL_DATASPACE_V0_SRGB_LINEAR = HAL_DATASPACE_STANDARD_BT709 | - HAL_DATASPACE_TRANSFER_LINEAR | HAL_DATASPACE_RANGE_FULL, - - - /* - * sRGB gamma encoding: - * - * The red, green and blue components are stored in sRGB space, and - * converted to linear space when read, using the SRGB transfer function - * for each of the R, G and B components. When written, the inverse - * transformation is performed. - * - * The alpha component, if present, is always stored in linear space and - * is left unmodified when read or written. - * - * Use full range and BT.709 standard. - */ - HAL_DATASPACE_SRGB = 0x201, // deprecated, use HAL_DATASPACE_V0_SRGB - - HAL_DATASPACE_V0_SRGB = HAL_DATASPACE_STANDARD_BT709 | - HAL_DATASPACE_TRANSFER_SRGB | HAL_DATASPACE_RANGE_FULL, - - - /* - * YCbCr Colorspaces - * ----------------- - * - * Primaries are given using (x,y) coordinates in the CIE 1931 definition - * of x and y specified by ISO 11664-1. - * - * Transfer characteristics are the opto-electronic transfer characteristic - * at the source as a function of linear optical intensity (luminance). - */ - - /* - * JPEG File Interchange Format (JFIF) - * - * Same model as BT.601-625, but all values (Y, Cb, Cr) range from 0 to 255 - * - * Use full range, BT.601 transfer and BT.601_625 standard. - */ - HAL_DATASPACE_JFIF = 0x101, // deprecated, use HAL_DATASPACE_V0_JFIF - - HAL_DATASPACE_V0_JFIF = HAL_DATASPACE_STANDARD_BT601_625 | - HAL_DATASPACE_TRANSFER_SMPTE_170M | HAL_DATASPACE_RANGE_FULL, - - /* - * ITU-R Recommendation 601 (BT.601) - 625-line - * - * Standard-definition television, 625 Lines (PAL) - * - * Use limited range, BT.601 transfer and BT.601_625 standard. - */ - HAL_DATASPACE_BT601_625 = 0x102, // deprecated, use HAL_DATASPACE_V0_BT601_625 - - HAL_DATASPACE_V0_BT601_625 = HAL_DATASPACE_STANDARD_BT601_625 | - HAL_DATASPACE_TRANSFER_SMPTE_170M | HAL_DATASPACE_RANGE_LIMITED, - - - /* - * ITU-R Recommendation 601 (BT.601) - 525-line - * - * Standard-definition television, 525 Lines (NTSC) - * - * Use limited range, BT.601 transfer and BT.601_525 standard. - */ - HAL_DATASPACE_BT601_525 = 0x103, // deprecated, use HAL_DATASPACE_V0_BT601_525 - - HAL_DATASPACE_V0_BT601_525 = HAL_DATASPACE_STANDARD_BT601_525 | - HAL_DATASPACE_TRANSFER_SMPTE_170M | HAL_DATASPACE_RANGE_LIMITED, - - /* - * ITU-R Recommendation 709 (BT.709) - * - * High-definition television - * - * Use limited range, BT.709 transfer and BT.709 standard. - */ - HAL_DATASPACE_BT709 = 0x104, // deprecated, use HAL_DATASPACE_V0_BT709 - - HAL_DATASPACE_V0_BT709 = HAL_DATASPACE_STANDARD_BT709 | - HAL_DATASPACE_TRANSFER_SMPTE_170M | HAL_DATASPACE_RANGE_LIMITED, - - /* - * Data spaces for non-color formats - */ - - /* - * The buffer contains depth ranging measurements from a depth camera. - * This value is valid with formats: - * HAL_PIXEL_FORMAT_Y16: 16-bit samples, consisting of a depth measurement - * and an associated confidence value. The 3 MSBs of the sample make - * up the confidence value, and the low 13 LSBs of the sample make up - * the depth measurement. - * For the confidence section, 0 means 100% confidence, 1 means 0% - * confidence. The mapping to a linear float confidence value between - * 0.f and 1.f can be obtained with - * float confidence = (((depthSample >> 13) - 1) & 0x7) / 7.0f; - * The depth measurement can be extracted simply with - * uint16_t range = (depthSample & 0x1FFF); - * HAL_PIXEL_FORMAT_BLOB: A depth point cloud, as - * a variable-length float (x,y,z, confidence) coordinate point list. - * The point cloud will be represented with the android_depth_points - * structure. - */ - HAL_DATASPACE_DEPTH = 0x1000 - -} android_dataspace_t; - -/* - * Color modes that may be supported by a display. - * - * Definitions: - * Rendering intent generally defines the goal in mapping a source (input) - * color to a destination device color for a given color mode. - * - * It is important to keep in mind three cases where mapping may be applied: - * 1. The source gamut is much smaller than the destination (display) gamut - * 2. The source gamut is much larger than the destination gamut (this will - * ordinarily be handled using colorimetric rendering, below) - * 3. The source and destination gamuts are roughly equal, although not - * completely overlapping - * Also, a common requirement for mappings is that skin tones should be - * preserved, or at least remain natural in appearance. - * - * Colorimetric Rendering Intent (All cases): - * Colorimetric indicates that colors should be preserved. In the case - * that the source gamut lies wholly within the destination gamut or is - * about the same (#1, #3), this will simply mean that no manipulations - * (no saturation boost, for example) are applied. In the case where some - * source colors lie outside the destination gamut (#2, #3), those will - * need to be mapped to colors that are within the destination gamut, - * while the already in-gamut colors remain unchanged. - * - * Non-colorimetric transforms can take many forms. There are no hard - * rules and it's left to the implementation to define. - * Two common intents are described below. - * - * Stretched-Gamut Enhancement Intent (Source < Destination): - * When the destination gamut is much larger than the source gamut (#1), the - * source primaries may be redefined to reflect the full extent of the - * destination space, or to reflect an intermediate gamut. - * Skin-tone preservation would likely be applied. An example might be sRGB - * input displayed on a DCI-P3 capable device, with skin-tone preservation. - * - * Within-Gamut Enhancement Intent (Source >= Destination): - * When the device (destination) gamut is not larger than the source gamut - * (#2 or #3), but the appearance of a larger gamut is desired, techniques - * such as saturation boost may be applied to the source colors. Skin-tone - * preservation may be applied. There is no unique method for within-gamut - * enhancement; it would be defined within a flexible color mode. - * - */ -typedef enum android_color_mode { - - /* - * HAL_COLOR_MODE_DEFAULT is the "native" gamut of the display. - * White Point: Vendor/OEM defined - * Panel Gamma: Vendor/OEM defined (typically 2.2) - * Rendering Intent: Vendor/OEM defined (typically 'enhanced') - */ - HAL_COLOR_MODE_NATIVE = 0, - - /* - * HAL_COLOR_MODE_STANDARD_BT601_625 corresponds with display - * settings that implement the ITU-R Recommendation BT.601 - * or Rec 601. Using 625 line version - * Rendering Intent: Colorimetric - * Primaries: - * x y - * green 0.290 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - * - * KR = 0.299, KB = 0.114. This adjusts the luminance interpretation - * for RGB conversion from the one purely determined by the primaries - * to minimize the color shift into RGB space that uses BT.709 - * primaries. - * - * Gamma Correction (GC): - * - * if Vlinear < 0.018 - * Vnonlinear = 4.500 * Vlinear - * else - * Vnonlinear = 1.099 * (Vlinear)^(0.45) – 0.099 - */ - HAL_COLOR_MODE_STANDARD_BT601_625 = 1, - - /* - * Primaries: - * x y - * green 0.290 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - * - * Use the unadjusted KR = 0.222, KB = 0.071 luminance interpretation - * for RGB conversion. - * - * Gamma Correction (GC): - * - * if Vlinear < 0.018 - * Vnonlinear = 4.500 * Vlinear - * else - * Vnonlinear = 1.099 * (Vlinear)^(0.45) – 0.099 - */ - HAL_COLOR_MODE_STANDARD_BT601_625_UNADJUSTED = 2, - - /* - * Primaries: - * x y - * green 0.310 0.595 - * blue 0.155 0.070 - * red 0.630 0.340 - * white (D65) 0.3127 0.3290 - * - * KR = 0.299, KB = 0.114. This adjusts the luminance interpretation - * for RGB conversion from the one purely determined by the primaries - * to minimize the color shift into RGB space that uses BT.709 - * primaries. - * - * Gamma Correction (GC): - * - * if Vlinear < 0.018 - * Vnonlinear = 4.500 * Vlinear - * else - * Vnonlinear = 1.099 * (Vlinear)^(0.45) – 0.099 - */ - HAL_COLOR_MODE_STANDARD_BT601_525 = 3, - - /* - * Primaries: - * x y - * green 0.310 0.595 - * blue 0.155 0.070 - * red 0.630 0.340 - * white (D65) 0.3127 0.3290 - * - * Use the unadjusted KR = 0.212, KB = 0.087 luminance interpretation - * for RGB conversion (as in SMPTE 240M). - * - * Gamma Correction (GC): - * - * if Vlinear < 0.018 - * Vnonlinear = 4.500 * Vlinear - * else - * Vnonlinear = 1.099 * (Vlinear)^(0.45) – 0.099 - */ - HAL_COLOR_MODE_STANDARD_BT601_525_UNADJUSTED = 4, - - /* - * HAL_COLOR_MODE_REC709 corresponds with display settings that implement - * the ITU-R Recommendation BT.709 / Rec. 709 for high-definition television. - * Rendering Intent: Colorimetric - * Primaries: - * x y - * green 0.300 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - * - * HDTV REC709 Inverse Gamma Correction (IGC): V represents normalized - * (with [0 to 1] range) value of R, G, or B. - * - * if Vnonlinear < 0.081 - * Vlinear = Vnonlinear / 4.5 - * else - * Vlinear = ((Vnonlinear + 0.099) / 1.099) ^ (1/0.45) - * - * HDTV REC709 Gamma Correction (GC): - * - * if Vlinear < 0.018 - * Vnonlinear = 4.5 * Vlinear - * else - * Vnonlinear = 1.099 * (Vlinear) ^ 0.45 – 0.099 - */ - HAL_COLOR_MODE_STANDARD_BT709 = 5, - - /* - * HAL_COLOR_MODE_DCI_P3 corresponds with display settings that implement - * SMPTE EG 432-1 and SMPTE RP 431-2 - * Rendering Intent: Colorimetric - * Primaries: - * x y - * green 0.265 0.690 - * blue 0.150 0.060 - * red 0.680 0.320 - * white (D65) 0.3127 0.3290 - * - * Gamma: 2.2 - */ - HAL_COLOR_MODE_DCI_P3 = 6, - - /* - * HAL_COLOR_MODE_SRGB corresponds with display settings that implement - * the sRGB color space. Uses the same primaries as ITU-R Recommendation - * BT.709 - * Rendering Intent: Colorimetric - * Primaries: - * x y - * green 0.300 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - * - * PC/Internet (sRGB) Inverse Gamma Correction (IGC): - * - * if Vnonlinear ≤ 0.03928 - * Vlinear = Vnonlinear / 12.92 - * else - * Vlinear = ((Vnonlinear + 0.055)/1.055) ^ 2.4 - * - * PC/Internet (sRGB) Gamma Correction (GC): - * - * if Vlinear ≤ 0.0031308 - * Vnonlinear = 12.92 * Vlinear - * else - * Vnonlinear = 1.055 * (Vlinear)^(1/2.4) – 0.055 - */ - HAL_COLOR_MODE_SRGB = 7, - - /* - * HAL_COLOR_MODE_ADOBE_RGB corresponds with the RGB color space developed - * by Adobe Systems, Inc. in 1998. - * Rendering Intent: Colorimetric - * Primaries: - * x y - * green 0.210 0.710 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - * - * Gamma: 2.2 - */ - HAL_COLOR_MODE_ADOBE_RGB = 8 - -} android_color_mode_t; - -/* - * Color transforms that may be applied by hardware composer to the whole - * display. - */ -typedef enum android_color_transform { - /* Applies no transform to the output color */ - HAL_COLOR_TRANSFORM_IDENTITY = 0, - - /* Applies an arbitrary transform defined by a 4x4 affine matrix */ - HAL_COLOR_TRANSFORM_ARBITRARY_MATRIX = 1, - - /* Applies a transform that inverts the value or luminance of the color, but - * does not modify hue or saturation */ - HAL_COLOR_TRANSFORM_VALUE_INVERSE = 2, - - /* Applies a transform that maps all colors to shades of gray */ - HAL_COLOR_TRANSFORM_GRAYSCALE = 3, - - /* Applies a transform which corrects for protanopic color blindness */ - HAL_COLOR_TRANSFORM_CORRECT_PROTANOPIA = 4, - - /* Applies a transform which corrects for deuteranopic color blindness */ - HAL_COLOR_TRANSFORM_CORRECT_DEUTERANOPIA = 5, - - /* Applies a transform which corrects for tritanopic color blindness */ - HAL_COLOR_TRANSFORM_CORRECT_TRITANOPIA = 6 -} android_color_transform_t; - -/* - * Supported HDR formats. Must be kept in sync with equivalents in Display.java. - */ -typedef enum android_hdr { - /* Device supports Dolby Vision HDR */ - HAL_HDR_DOLBY_VISION = 1, + * These structures are used to define the reference display's + * capabilities for HDR content. Display engine can use this + * to better tone map content to user's display. + * Color is defined in CIE XYZ coordinates + */ +struct android_xy_color { + float x; + float y; +}; - /* Device supports HDR10 */ - HAL_HDR_HDR10 = 2, +struct android_smpte2086_metadata { + struct android_xy_color displayPrimaryRed; + struct android_xy_color displayPrimaryGreen; + struct android_xy_color displayPrimaryBlue; + struct android_xy_color whitePoint; + float maxLuminance; + float minLuminance; +}; - /* Device supports hybrid log-gamma HDR */ - HAL_HDR_HLG = 3 -} android_hdr_t; +struct android_cta861_3_metadata { + float maxContentLightLevel; + float maxFrameAverageLightLevel; +}; #ifdef __cplusplus } diff --git a/system/radio.h b/system/radio.h index 9e291c8..acf3ea7 100644 --- a/system/radio.h +++ b/system/radio.h @@ -81,10 +81,10 @@ typedef enum { } radio_direction_t; /* unique handle allocated to a radio module */ -typedef unsigned int radio_handle_t; +typedef uint32_t radio_handle_t; /* Opaque meta data structure used by radio meta data API (see system/radio_metadata.h) */ -typedef struct radio_medtadata radio_metadata_t; +typedef struct radio_metadata radio_metadata_t; /* Additional attributes for an FM band configuration */ @@ -109,10 +109,10 @@ typedef struct radio_hal_am_band_config { typedef struct radio_hal_band_config { radio_band_t type; bool antenna_connected; - unsigned int lower_limit; - unsigned int upper_limit; - unsigned int num_spacings; - unsigned int spacings[RADIO_NUM_SPACINGS_MAX]; + uint32_t lower_limit; + uint32_t upper_limit; + uint32_t num_spacings; + uint32_t spacings[RADIO_NUM_SPACINGS_MAX]; union { radio_hal_fm_band_config_t fm; radio_hal_am_band_config_t am; @@ -137,10 +137,10 @@ typedef struct radio_hal_properties { char product[RADIO_STRING_LEN_MAX]; /* product name */ char version[RADIO_STRING_LEN_MAX]; /* product version */ char serial[RADIO_STRING_LEN_MAX]; /* serial number (for subscription services) */ - unsigned int num_tuners; /* number of tuners controllable independently */ - unsigned int num_audio_sources; /* number of audio sources driven simultaneously */ + uint32_t num_tuners; /* number of tuners controllable independently */ + uint32_t num_audio_sources; /* number of audio sources driven simultaneously */ bool supports_capture; /* the hardware supports capture of audio source audio HAL */ - unsigned int num_bands; /* number of band descriptors */ + uint32_t num_bands; /* number of band descriptors */ radio_hal_band_config_t bands[RADIO_NUM_BANDS_MAX]; /* band descriptors */ } radio_hal_properties_t; @@ -153,10 +153,10 @@ typedef struct radio_properties { char product[RADIO_STRING_LEN_MAX]; char version[RADIO_STRING_LEN_MAX]; char serial[RADIO_STRING_LEN_MAX]; - unsigned int num_tuners; - unsigned int num_audio_sources; + uint32_t num_tuners; + uint32_t num_audio_sources; bool supports_capture; - unsigned int num_bands; + uint32_t num_bands; radio_band_config_t bands[RADIO_NUM_BANDS_MAX]; } radio_properties_t; @@ -164,13 +164,14 @@ typedef struct radio_properties { * Contains information on currently tuned channel. */ typedef struct radio_program_info { - unsigned int channel; /* current channel. (e.g kHz for band type RADIO_BAND_FM) */ - unsigned int sub_channel; /* current sub channel. (used for RADIO_BAND_FM_HD) */ + uint32_t channel; /* current channel. (e.g kHz for band type RADIO_BAND_FM) */ + uint32_t sub_channel; /* current sub channel. (used for RADIO_BAND_FM_HD) */ bool tuned; /* tuned to a program or not */ bool stereo; /* program is stereo or not */ bool digital; /* digital program or not (e.g HD Radio program) */ - unsigned int signal_strength; /* signal strength from 0 to 100 */ - radio_metadata_t *metadata; /* non null if meta data are present (e.g PTY, song title ...) */ + uint32_t signal_strength; /* signal strength from 0 to 100 */ + /* meta data (e.g PTY, song title ...), must not be NULL */ + __attribute__((aligned(8))) radio_metadata_t *metadata; } radio_program_info_t; @@ -195,7 +196,7 @@ typedef unsigned int radio_event_type_t; /* Event passed to the framework by the HAL callback */ typedef struct radio_hal_event { radio_event_type_t type; /* event type */ - int status; /* used by RADIO_EVENT_CONFIG, RADIO_EVENT_TUNED */ + int32_t status; /* used by RADIO_EVENT_CONFIG, RADIO_EVENT_TUNED */ union { /* RADIO_EVENT_ANTENNA, RADIO_EVENT_TA, RADIO_EVENT_EA */ bool on; @@ -208,17 +209,19 @@ typedef struct radio_hal_event { /* Used internally by the framework. Same information as in struct radio_hal_event */ typedef struct radio_event { radio_event_type_t type; - int status; + int32_t status; union { bool on; radio_band_config_t config; radio_program_info_t info; - radio_metadata_t *metadata; /* offset from start of struct when in shared memory */ + /* meta data (e.g PTY, song title ...), must not be NULL */ + __attribute__((aligned(8))) radio_metadata_t *metadata; }; } radio_event_t; -static radio_rds_t radio_rds_for_region(bool rds, radio_region_t region) { +static inline +radio_rds_t radio_rds_for_region(bool rds, radio_region_t region) { if (!rds) return RADIO_RDS_NONE; switch(region) { @@ -234,7 +237,8 @@ static radio_rds_t radio_rds_for_region(bool rds, radio_region_t region) { } } -static radio_deemphasis_t radio_demephasis_for_region(radio_region_t region) { +static inline +radio_deemphasis_t radio_demephasis_for_region(radio_region_t region) { switch(region) { case RADIO_REGION_KOREA: case RADIO_REGION_ITU_2: diff --git a/system/radio_metadata.h b/system/radio_metadata.h new file mode 100644 index 0000000..0afa3d3 --- /dev/null +++ b/system/radio_metadata.h @@ -0,0 +1,310 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_RADIO_METADATA_H +#define ANDROID_RADIO_METADATA_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* maximum length for text metadata including NUL terminator */ +#define RADIO_METADATA_TEXT_LEN_MAX 1024 + +/* radio meta data key values */ +enum { + RADIO_METADATA_KEY_INVALID = -1, + RADIO_METADATA_KEY_RDS_PI = 0, /* RDS PI - int */ + RADIO_METADATA_KEY_RDS_PS = 1, /* RDS PS - text */ + RADIO_METADATA_KEY_RDS_PTY = 2, /* RDS PTY - int */ + RADIO_METADATA_KEY_RBDS_PTY = 3, /* RBDS PTY - int */ + RADIO_METADATA_KEY_RDS_RT = 4, /* RDS RT - text */ + RADIO_METADATA_KEY_TITLE = 5, /* Song title - text */ + RADIO_METADATA_KEY_ARTIST = 6, /* Artist name - text */ + RADIO_METADATA_KEY_ALBUM = 7, /* Album name - text */ + RADIO_METADATA_KEY_GENRE = 8, /* Musical genre - text */ + RADIO_METADATA_KEY_ICON = 9, /* Station icon - raw */ + RADIO_METADATA_KEY_ART = 10, /* Album art - raw */ + RADIO_METADATA_KEY_CLOCK = 11, /* Clock - radio_metadata_clock_t */ + RADIO_METADATA_KEY_MIN = RADIO_METADATA_KEY_RDS_PI, + RADIO_METADATA_KEY_MAX = RADIO_METADATA_KEY_CLOCK, +}; +typedef int32_t radio_metadata_key_t; + +enum { + RADIO_METADATA_TYPE_INVALID = -1, + RADIO_METADATA_TYPE_INT = 0, /* signed 32 bit integer */ + RADIO_METADATA_TYPE_TEXT = 1, /* text in UTF-8 format, NUL terminated. + RADIO_METADATA_TEXT_LEN_MAX length including NUL. */ + RADIO_METADATA_TYPE_RAW = 2, /* raw binary data (icon or art) */ + RADIO_METADATA_TYPE_CLOCK = 3, /* clock data, see radio_metadata_clock_t */ +}; +typedef int32_t radio_metadata_type_t; + +typedef struct radio_metadata_clock { + uint64_t utc_seconds_since_epoch; /* Seconds since epoch at GMT + 0. */ + int32_t timezone_offset_in_minutes; /* Minutes offset from the GMT. */ +} radio_metadata_clock_t; + +/* + * Return the type of the meta data corresponding to the key specified + * + * arguments: + * - key: the meta data key. + * + * returns: + * the meta data type corresponding to the key or RADIO_METADATA_TYPE_INVALID + */ +ANDROID_API +radio_metadata_type_t radio_metadata_type_of_key(const radio_metadata_key_t key); + +/* + * Allocate a meta data buffer for use by radio HAL callback for RADIO_EVENT_TUNED and + * RADIO_EVENT_METADATA events. + * + * arguments: + * - metadata: the address where the allocate meta data buffer should be returned. + * - channel: channel (frequency) this meta data is associated with. + * - sub_channel: sub channel this meta data is associated with. + * + * returns: + * 0 if successfully allocated + * -ENOMEM if meta data buffer cannot be allocated + */ +ANDROID_API +int radio_metadata_allocate(radio_metadata_t **metadata, + const uint32_t channel, + const uint32_t sub_channel); + +/* + * De-allocate a meta data buffer. + * + * arguments: + * - metadata: the meta data buffer to be de-allocated. + */ +ANDROID_API +void radio_metadata_deallocate(radio_metadata_t *metadata); + +/* + * Add an integer meta data to the buffer. + * + * arguments: + * - metadata: the address of the meta data buffer. I/O. the meta data can be modified if the + * buffer is re-allocated + * - key: the meta data key. + * - value: the meta data value. + * + * returns: + * 0 if successfully added + * -EINVAL if the buffer passed is invalid or the key does not match an integer type + * -ENOMEM if meta data buffer cannot be re-allocated + */ +ANDROID_API +int radio_metadata_add_int(radio_metadata_t **metadata, + const radio_metadata_key_t key, + const int32_t value); + +/* + * Add an text meta data to the buffer. + * + * arguments: + * - metadata: the address of the meta data buffer. I/O. the meta data can be modified if the + * buffer is re-allocated + * - key: the meta data key. + * - value: the meta data value. + * + * returns: + * 0 if successfully added + * -EINVAL if the buffer passed is invalid or the key does not match a text type or text + * is too long + * -ENOMEM if meta data buffer cannot be re-allocated + */ +ANDROID_API +int radio_metadata_add_text(radio_metadata_t **metadata, + const radio_metadata_key_t key, + const char *value); + +/* + * Add an raw meta data to the buffer. + * + * arguments: + * - metadata: the address of the meta data buffer. I/O. the meta data can be modified if the + * buffer is re-allocated + * - key: the meta data key. + * - value: the meta data value. + * + * returns: + * 0 if successfully added + * -EINVAL if the buffer passed is invalid or the key does not match a raw type + * -ENOMEM if meta data buffer cannot be re-allocated + */ +ANDROID_API +int radio_metadata_add_raw(radio_metadata_t **metadata, + const radio_metadata_key_t key, + const unsigned char *value, + const size_t size); + +/* + * Add a clock meta data to the buffer. + * + * arguments: + * - metadata: the address of the meta data buffer. I/O. the meta data can be modified if the + * buffer is re-allocated. + * - key: the meta data key. + * - value: the meta data value. + * + * returns: + * 0 if successfully added + * - EINVAL if the buffer passed is invalid or the key does not match a raw type + * - ENOMEM if meta data buffer cannot be re-allocated + */ +ANDROID_API +int radio_metadata_add_clock(radio_metadata_t **metadata, + const radio_metadata_key_t key, + const radio_metadata_clock_t *clock); + +/* + * add all meta data in source buffer to destinaiton buffer. + * + * arguments: + * - dst_metadata: the address of the destination meta data buffer. if *dst_metadata is NULL, + * a new buffer is created. + * - src_metadata: the source meta data buffer. + * + * returns: + * 0 if successfully added + * -ENOMEM if meta data buffer cannot be re-allocated + */ +ANDROID_API +int radio_metadata_add_metadata(radio_metadata_t **dst_metadata, + radio_metadata_t *src_metadata); + +/* + * Perform sanity check on a meta data buffer. + * + * arguments: + * - metadata: the meta data buffer. + * + * returns: + * 0 if no error found + * -EINVAL if a consistency problem is found in the meta data buffer + */ +ANDROID_API +int radio_metadata_check(const radio_metadata_t *metadata); + +/* + * Return the total size used by the meta data buffer. + * No sanity check is performed on the meta data buffer. + * + * arguments: + * - metadata: the meta data buffer. + * + * returns: + * 0 if an invalid meta data buffer is passed + * the size in bytes otherwise + */ +ANDROID_API +size_t radio_metadata_get_size(const radio_metadata_t *metadata); + +/* + * Return the number of meta data entries in the buffer. + * No sanity check is performed on the meta data buffer. + * + * arguments: + * - metadata: the meta data buffer. + * + * returns: + * -EINVAL if an invalid meta data buffer is passed + * the number of entries otherwise + */ +ANDROID_API +int radio_metadata_get_count(const radio_metadata_t *metadata); + +/* + * Get a meta data at a specified index. Used to parse a meta data buffer. + * No sanity check is performed on the meta data buffer. + * + * arguments: + * - metadata: the meta data buffer. + * - index: the index to read from + * - key: where the meta data key should be returned + * - type: where the meta data type should be returned + * - value: where the address of the meta data value should be returned + * - size: where the size of the meta data value should be returned + * + * returns: + * -EINVAL if an invalid argument is passed + * 0 otherwise + */ +ANDROID_API +int radio_metadata_get_at_index(const radio_metadata_t *metadata, + const uint32_t index, + radio_metadata_key_t *key, + radio_metadata_type_t *type, + void **value, + size_t *size); + +/* + * Get a meta data with the specified key. + * No sanity check is performed on the meta data buffer. + * This will return the first meta data found with the matching key. + * + * arguments: + * - metadata: the meta data buffer. + * - index: the index to read from + * - key: the meta data key to look for + * - type: where the meta data type should be returned + * - value: where the address of the meta data value should be returned + * - size: where the size of the meta data value should be returned + * + * returns: + * -EINVAL if an invalid argument is passed + * -ENOENT if no entry with the specified key is found + * 0 otherwise + */ +ANDROID_API +int radio_metadata_get_from_key(const radio_metadata_t *metadata, + const radio_metadata_key_t key, + radio_metadata_type_t *type, + void **value, + size_t *size); + +/* + * Get channel and sub channel associated with metadata. + * + * arguments: + * - metadata: the meta data buffer + * - channel: address where to return the channel. + * - sub_channel: address where to return the sub channel. + * + * returns: + * 0 if successfully added + * -EINVAL if the buffer passed is invalid + */ +ANDROID_API +int radio_metadata_get_channel(radio_metadata_t *metadata, + uint32_t *channel, + uint32_t *sub_channel); + +#ifdef __cplusplus +} +#endif + +#endif // ANDROID_RADIO_METADATA_H diff --git a/system/sound_trigger.h b/system/sound_trigger.h index 773e4f7..6182ff3 100644 --- a/system/sound_trigger.h +++ b/system/sound_trigger.h @@ -36,6 +36,8 @@ typedef enum { #define RECOGNITION_MODE_USER_IDENTIFICATION 0x2 /* trigger only if one user in model identified */ #define RECOGNITION_MODE_USER_AUTHENTICATION 0x4 /* trigger only if one user in mode authenticated */ +#define RECOGNITION_MODE_GENERIC_TRIGGER 0x8 /* generic sound trigger */ + #define RECOGNITION_STATUS_SUCCESS 0 #define RECOGNITION_STATUS_ABORT 1 #define RECOGNITION_STATUS_FAILURE 2 @@ -44,16 +46,11 @@ typedef enum { typedef enum { SOUND_MODEL_TYPE_UNKNOWN = -1, /* use for unspecified sound model type */ - SOUND_MODEL_TYPE_KEYPHRASE = 0 /* use for key phrase sound models */ + SOUND_MODEL_TYPE_KEYPHRASE = 0, /* use for key phrase sound models */ + SOUND_MODEL_TYPE_GENERIC = 1 /* use for all models other than keyphrase */ } sound_trigger_sound_model_type_t; -typedef struct sound_trigger_uuid_s { - unsigned int timeLow; - unsigned short timeMid; - unsigned short timeHiAndVersion; - unsigned short clockSeq; - unsigned char node[6]; -} sound_trigger_uuid_t; +typedef audio_uuid_t sound_trigger_uuid_t; /* * sound trigger implementation descriptor read by the framework via get_properties(). @@ -92,7 +89,7 @@ struct sound_trigger_module_descriptor { typedef int sound_model_handle_t; /* - * Generic sound model descriptor. This struct is the header of a larger block passed to + * Base sound model descriptor. This struct is the header of a larger block passed to * load_sound_model() and containing the binary data of the sound model. * Proprietary representation of users in binary data must match information indicated * by users field @@ -130,10 +127,19 @@ struct sound_trigger_phrase_sound_model { }; +/* + * Generic sound model, used for all cases except key phrase detection. + */ +struct sound_trigger_generic_sound_model { + struct sound_trigger_sound_model common; +}; + + /* * Generic recognition event sent via recognition callback + * Must be aligned to transmit as raw memory through Binder. */ -struct sound_trigger_recognition_event { +struct __attribute__((aligned(8))) sound_trigger_recognition_event { int status; /* recognition status e.g. RECOGNITION_STATUS_SUCCESS */ sound_trigger_sound_model_type_t type; /* event type, same as sound model type. @@ -190,6 +196,10 @@ struct sound_trigger_phrase_recognition_event { struct sound_trigger_phrase_recognition_extra phrase_extras[SOUND_TRIGGER_MAX_PHRASES]; }; +struct sound_trigger_generic_recognition_event { + struct sound_trigger_recognition_event common; +}; + /* * configuration for sound trigger capture session passed to start_recognition() */ diff --git a/system/thread_defs.h b/system/thread_defs.h index 377a48c..80d1160 100644 --- a/system/thread_defs.h +++ b/system/thread_defs.h @@ -55,6 +55,9 @@ enum { /* ui service treads might want to run at a urgent display (uncommon) */ ANDROID_PRIORITY_URGENT_DISPLAY = HAL_PRIORITY_URGENT_DISPLAY, + /* all normal video threads */ + ANDROID_PRIORITY_VIDEO = -10, + /* all normal audio threads */ ANDROID_PRIORITY_AUDIO = -16, diff --git a/system/window.h b/system/window.h index 33b7c3d..197f73f 100644 --- a/system/window.h +++ b/system/window.h @@ -14,8 +14,22 @@ * limitations under the License. */ -#ifndef SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H -#define SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H +/************************************************************************************************* + * + * IMPORTANT: + * + * There is an old copy of this file in system/core/include/system/window.h, which exists only + * for backward source compatibility. + * But there are binaries out there as well, so this version of window.h must stay binary + * backward compatible with the one found in system/core. + * + * + * Source compatibility is also required for now, because this is how we're handling the + * transition from system/core/include (global include path) to nativewindow/include. + * + *************************************************************************************************/ + +#pragma once #include #include @@ -27,6 +41,10 @@ #include #include +// system/window.h is a superset of the vndk +#include + + #ifndef __UNUSED #define __UNUSED __attribute__((__unused__)) #endif @@ -38,90 +56,7 @@ __BEGIN_DECLS /*****************************************************************************/ -#define ANDROID_NATIVE_MAKE_CONSTANT(a,b,c,d) \ - (((unsigned)(a)<<24)|((unsigned)(b)<<16)|((unsigned)(c)<<8)|(unsigned)(d)) - -#define ANDROID_NATIVE_WINDOW_MAGIC \ - ANDROID_NATIVE_MAKE_CONSTANT('_','w','n','d') - -#define ANDROID_NATIVE_BUFFER_MAGIC \ - ANDROID_NATIVE_MAKE_CONSTANT('_','b','f','r') - -// --------------------------------------------------------------------------- - -// This #define may be used to conditionally compile device-specific code to -// support either the prior ANativeWindow interface, which did not pass libsync -// fences around, or the new interface that does. This #define is only present -// when the ANativeWindow interface does include libsync support. -#define ANDROID_NATIVE_WINDOW_HAS_SYNC 1 - -// --------------------------------------------------------------------------- - -typedef const native_handle_t* buffer_handle_t; - -// --------------------------------------------------------------------------- - -typedef struct android_native_rect_t -{ - int32_t left; - int32_t top; - int32_t right; - int32_t bottom; -} android_native_rect_t; - -// --------------------------------------------------------------------------- - -typedef struct android_native_base_t -{ - /* a magic value defined by the actual EGL native type */ - int magic; - - /* the sizeof() of the actual EGL native type */ - int version; - - void* reserved[4]; - - /* reference-counting interface */ - void (*incRef)(struct android_native_base_t* base); - void (*decRef)(struct android_native_base_t* base); -} android_native_base_t; - -typedef struct ANativeWindowBuffer -{ -#ifdef __cplusplus - ANativeWindowBuffer() { - common.magic = ANDROID_NATIVE_BUFFER_MAGIC; - common.version = sizeof(ANativeWindowBuffer); - memset(common.reserved, 0, sizeof(common.reserved)); - } - - // Implement the methods that sp expects so that it - // can be used to automatically refcount ANativeWindowBuffer's. - void incStrong(const void* /*id*/) const { - common.incRef(const_cast(&common)); - } - void decStrong(const void* /*id*/) const { - common.decRef(const_cast(&common)); - } -#endif - - struct android_native_base_t common; - - int width; - int height; - int stride; - int format; - int usage; - - void* reserved[2]; - - buffer_handle_t handle; - - void* reserved_proc[8]; -} ANativeWindowBuffer_t; - -// Old typedef for backwards compatibility. -typedef ANativeWindowBuffer_t android_native_buffer_t; +#define ANDROID_NATIVE_WINDOW_MAGIC ANDROID_NATIVE_MAKE_CONSTANT('_','w','n','d') // --------------------------------------------------------------------------- @@ -131,25 +66,8 @@ enum { NATIVE_WINDOW_HEIGHT = 1, NATIVE_WINDOW_FORMAT = 2, - /* The minimum number of buffers that must remain un-dequeued after a buffer - * has been queued. This value applies only if set_buffer_count was used to - * override the number of buffers and if a buffer has since been queued. - * Users of the set_buffer_count ANativeWindow method should query this - * value before calling set_buffer_count. If it is necessary to have N - * buffers simultaneously dequeued as part of the steady-state operation, - * and this query returns M then N+M buffers should be requested via - * native_window_set_buffer_count. - * - * Note that this value does NOT apply until a single buffer has been - * queued. In particular this means that it is possible to: - * - * 1. Query M = min undequeued buffers - * 2. Set the buffer count to N + M - * 3. Dequeue all N + M buffers - * 4. Cancel M buffers - * 5. Queue, dequeue, queue, dequeue, ad infinitum - */ - NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS = 3, + /* see ANativeWindowQuery in vndk/window.h */ + NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS = ANATIVEWINDOW_QUERY_MIN_UNDEQUEUED_BUFFERS, /* Check whether queueBuffer operations on the ANativeWindow send the buffer * to the window compositor. The query sets the returned 'value' argument @@ -181,57 +99,11 @@ enum { * NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS call and match the native window * size unless overridden by NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS. */ - NATIVE_WINDOW_DEFAULT_WIDTH = 6, - NATIVE_WINDOW_DEFAULT_HEIGHT = 7, + NATIVE_WINDOW_DEFAULT_WIDTH = ANATIVEWINDOW_QUERY_DEFAULT_WIDTH, + NATIVE_WINDOW_DEFAULT_HEIGHT = ANATIVEWINDOW_QUERY_DEFAULT_HEIGHT, - /* - * transformation that will most-likely be applied to buffers. This is only - * a hint, the actual transformation applied might be different. - * - * INTENDED USE: - * - * The transform hint can be used by a producer, for instance the GLES - * driver, to pre-rotate the rendering such that the final transformation - * in the composer is identity. This can be very useful when used in - * conjunction with the h/w composer HAL, in situations where it - * cannot handle arbitrary rotations. - * - * 1. Before dequeuing a buffer, the GL driver (or any other ANW client) - * queries the ANW for NATIVE_WINDOW_TRANSFORM_HINT. - * - * 2. The GL driver overrides the width and height of the ANW to - * account for NATIVE_WINDOW_TRANSFORM_HINT. This is done by querying - * NATIVE_WINDOW_DEFAULT_{WIDTH | HEIGHT}, swapping the dimensions - * according to NATIVE_WINDOW_TRANSFORM_HINT and calling - * native_window_set_buffers_dimensions(). - * - * 3. The GL driver dequeues a buffer of the new pre-rotated size. - * - * 4. The GL driver renders to the buffer such that the image is - * already transformed, that is applying NATIVE_WINDOW_TRANSFORM_HINT - * to the rendering. - * - * 5. The GL driver calls native_window_set_transform to apply - * inverse transformation to the buffer it just rendered. - * In order to do this, the GL driver needs - * to calculate the inverse of NATIVE_WINDOW_TRANSFORM_HINT, this is - * done easily: - * - * int hintTransform, inverseTransform; - * query(..., NATIVE_WINDOW_TRANSFORM_HINT, &hintTransform); - * inverseTransform = hintTransform; - * if (hintTransform & HAL_TRANSFORM_ROT_90) - * inverseTransform ^= HAL_TRANSFORM_ROT_180; - * - * - * 6. The GL driver queues the pre-transformed buffer. - * - * 7. The composer combines the buffer transform with the display - * transform. If the buffer transform happens to cancel out the - * display transform then no rotation is needed. - * - */ - NATIVE_WINDOW_TRANSFORM_HINT = 8, + /* see ANativeWindowQuery in vndk/window.h */ + NATIVE_WINDOW_TRANSFORM_HINT = ANATIVEWINDOW_QUERY_TRANSFORM_HINT, /* * Boolean that indicates whether the consumer is running more than @@ -243,7 +115,7 @@ enum { * The consumer gralloc usage bits currently set by the consumer. * The values are defined in hardware/libhardware/include/gralloc.h. */ - NATIVE_WINDOW_CONSUMER_USAGE_BITS = 10, + NATIVE_WINDOW_CONSUMER_USAGE_BITS = 10, /* deprecated */ /** * Transformation that will by applied to buffers by the hwcomposer. @@ -270,14 +142,8 @@ enum { */ NATIVE_WINDOW_DEFAULT_DATASPACE = 12, - /* - * Returns the age of the contents of the most recently dequeued buffer as - * the number of frames that have elapsed since it was last queued. For - * example, if the window is double-buffered, the age of any given buffer in - * steady state will be 2. If the dequeued buffer has never been queued, its - * age will be 0. - */ - NATIVE_WINDOW_BUFFER_AGE = 13, + /* see ANativeWindowQuery in vndk/window.h */ + NATIVE_WINDOW_BUFFER_AGE = ANATIVEWINDOW_QUERY_BUFFER_AGE, /* * Returns the duration of the last dequeueBuffer call in microseconds @@ -288,6 +154,41 @@ enum { * Returns the duration of the last queueBuffer call in microseconds */ NATIVE_WINDOW_LAST_QUEUE_DURATION = 15, + + /* + * Returns the number of image layers that the ANativeWindow buffer + * contains. By default this is 1, unless a buffer is explicitly allocated + * to contain multiple layers. + */ + NATIVE_WINDOW_LAYER_COUNT = 16, + + /* + * Returns 1 if the native window is valid, 0 otherwise. native window is valid + * if it is safe (i.e. no crash will occur) to call any method on it. + */ + NATIVE_WINDOW_IS_VALID = 17, + + /* + * Returns 1 if NATIVE_WINDOW_GET_FRAME_TIMESTAMPS will return display + * present info, 0 if it won't. + */ + NATIVE_WINDOW_FRAME_TIMESTAMPS_SUPPORTS_PRESENT = 18, + + /* + * The consumer end is capable of handling protected buffers, i.e. buffer + * with GRALLOC_USAGE_PROTECTED usage bits on. + */ + NATIVE_WINDOW_CONSUMER_IS_PROTECTED = 19, + + /* + * Returns data space for the buffers. + */ + NATIVE_WINDOW_DATASPACE = 20, + + /* + * Returns maxBufferCount set by BufferQueueConsumer + */ + NATIVE_WINDOW_MAX_BUFFER_COUNT = 21, }; /* Valid operations for the (*perform)() hook. @@ -301,30 +202,42 @@ enum { * ANativeWindow. */ enum { - NATIVE_WINDOW_SET_USAGE = 0, - NATIVE_WINDOW_CONNECT = 1, /* deprecated */ - NATIVE_WINDOW_DISCONNECT = 2, /* deprecated */ - NATIVE_WINDOW_SET_CROP = 3, /* private */ - NATIVE_WINDOW_SET_BUFFER_COUNT = 4, - NATIVE_WINDOW_SET_BUFFERS_GEOMETRY = 5, /* deprecated */ - NATIVE_WINDOW_SET_BUFFERS_TRANSFORM = 6, - NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP = 7, - NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS = 8, - NATIVE_WINDOW_SET_BUFFERS_FORMAT = 9, - NATIVE_WINDOW_SET_SCALING_MODE = 10, /* private */ - NATIVE_WINDOW_LOCK = 11, /* private */ - NATIVE_WINDOW_UNLOCK_AND_POST = 12, /* private */ - NATIVE_WINDOW_API_CONNECT = 13, /* private */ - NATIVE_WINDOW_API_DISCONNECT = 14, /* private */ - NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS = 15, /* private */ - NATIVE_WINDOW_SET_POST_TRANSFORM_CROP = 16, /* private */ - NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM = 17,/* private */ - NATIVE_WINDOW_SET_SIDEBAND_STREAM = 18, - NATIVE_WINDOW_SET_BUFFERS_DATASPACE = 19, - NATIVE_WINDOW_SET_SURFACE_DAMAGE = 20, /* private */ - NATIVE_WINDOW_SET_SHARED_BUFFER_MODE = 21, - NATIVE_WINDOW_SET_AUTO_REFRESH = 22, - NATIVE_WINDOW_GET_FRAME_TIMESTAMPS = 23, +// clang-format off + NATIVE_WINDOW_SET_USAGE = 0, /* deprecated */ + NATIVE_WINDOW_CONNECT = 1, /* deprecated */ + NATIVE_WINDOW_DISCONNECT = 2, /* deprecated */ + NATIVE_WINDOW_SET_CROP = 3, /* private */ + NATIVE_WINDOW_SET_BUFFER_COUNT = 4, + NATIVE_WINDOW_SET_BUFFERS_GEOMETRY = 5, /* deprecated */ + NATIVE_WINDOW_SET_BUFFERS_TRANSFORM = 6, + NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP = 7, + NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS = 8, + NATIVE_WINDOW_SET_BUFFERS_FORMAT = 9, + NATIVE_WINDOW_SET_SCALING_MODE = 10, /* private */ + NATIVE_WINDOW_LOCK = 11, /* private */ + NATIVE_WINDOW_UNLOCK_AND_POST = 12, /* private */ + NATIVE_WINDOW_API_CONNECT = 13, /* private */ + NATIVE_WINDOW_API_DISCONNECT = 14, /* private */ + NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS = 15, /* private */ + NATIVE_WINDOW_SET_POST_TRANSFORM_CROP = 16, /* deprecated, unimplemented */ + NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM = 17, /* private */ + NATIVE_WINDOW_SET_SIDEBAND_STREAM = 18, + NATIVE_WINDOW_SET_BUFFERS_DATASPACE = 19, + NATIVE_WINDOW_SET_SURFACE_DAMAGE = 20, /* private */ + NATIVE_WINDOW_SET_SHARED_BUFFER_MODE = 21, + NATIVE_WINDOW_SET_AUTO_REFRESH = 22, + NATIVE_WINDOW_GET_REFRESH_CYCLE_DURATION = 23, + NATIVE_WINDOW_GET_NEXT_FRAME_ID = 24, + NATIVE_WINDOW_ENABLE_FRAME_TIMESTAMPS = 25, + NATIVE_WINDOW_GET_COMPOSITOR_TIMING = 26, + NATIVE_WINDOW_GET_FRAME_TIMESTAMPS = 27, + NATIVE_WINDOW_GET_WIDE_COLOR_SUPPORT = 28, + NATIVE_WINDOW_GET_HDR_SUPPORT = 29, + NATIVE_WINDOW_SET_USAGE64 = 30, + NATIVE_WINDOW_GET_CONSUMER_USAGE64 = 31, + NATIVE_WINDOW_SET_BUFFERS_SMPTE2086_METADATA = 32, + NATIVE_WINDOW_SET_BUFFERS_CTA861_3_METADATA = 33, +// clang-format on }; /* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */ @@ -399,6 +312,14 @@ enum { */ static const int64_t NATIVE_WINDOW_TIMESTAMP_AUTO = (-9223372036854775807LL-1); +/* parameter for NATIVE_WINDOW_GET_FRAME_TIMESTAMPS + * + * Special timestamp value to indicate the timestamps aren't yet known or + * that they are invalid. + */ +static const int64_t NATIVE_WINDOW_TIMESTAMP_PENDING = -2; +static const int64_t NATIVE_WINDOW_TIMESTAMP_INVALID = -1; + struct ANativeWindow { #ifdef __cplusplus @@ -623,24 +544,21 @@ struct ANativeWindow /* Backwards compatibility: use ANativeWindow (struct ANativeWindow in C). * android_native_window_t is deprecated. */ -typedef struct ANativeWindow ANativeWindow; typedef struct ANativeWindow android_native_window_t __deprecated; /* - * native_window_set_usage(..., usage) + * native_window_set_usage64(..., usage) * Sets the intended usage flags for the next buffers * acquired with (*lockBuffer)() and on. - * By default (if this function is never called), a usage of - * GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE - * is assumed. + * + * Valid usage flags are defined in android/hardware_buffer.h + * All AHARDWAREBUFFER_USAGE_* flags can be specified as needed. + * * Calling this function will usually cause following buffers to be * reallocated. */ - -static inline int native_window_set_usage( - struct ANativeWindow* window, int usage) -{ - return window->perform(window, NATIVE_WINDOW_SET_USAGE, usage); +static inline int native_window_set_usage(struct ANativeWindow* window, uint64_t usage) { + return window->perform(window, NATIVE_WINDOW_SET_USAGE64, usage); } /* deprecated. Always returns 0. Don't call. */ @@ -682,45 +600,6 @@ static inline int native_window_set_crop( return window->perform(window, NATIVE_WINDOW_SET_CROP, crop); } -/* - * native_window_set_post_transform_crop(..., crop) - * Sets which region of the next queued buffers needs to be considered. - * Depending on the scaling mode, a buffer's crop region is scaled and/or - * cropped to match the surface's size. This function sets the crop in - * post-transformed pixel coordinates. - * - * The specified crop region applies to all buffers queued after it is called. - * - * If 'crop' is NULL, subsequently queued buffers won't be cropped. - * - * An error is returned if for instance the crop region is invalid, out of the - * buffer's bound or if the window is invalid. - */ -static inline int native_window_set_post_transform_crop( - struct ANativeWindow* window, - android_native_rect_t const * crop) -{ - return window->perform(window, NATIVE_WINDOW_SET_POST_TRANSFORM_CROP, crop); -} - -/* - * native_window_set_active_rect(..., active_rect) - * - * This function is deprecated and will be removed soon. For now it simply - * sets the post-transform crop for compatibility while multi-project commits - * get checked. - */ -static inline int native_window_set_active_rect( - struct ANativeWindow* window, - android_native_rect_t const * active_rect) __deprecated; - -static inline int native_window_set_active_rect( - struct ANativeWindow* window, - android_native_rect_t const * active_rect) -{ - return native_window_set_post_transform_crop(window, active_rect); -} - /* * native_window_set_buffer_count(..., count) * Sets the number of buffers associated with this native window. @@ -832,6 +711,42 @@ static inline int native_window_set_buffers_data_space( dataSpace); } +/* + * native_window_set_buffers_smpte2086_metadata(..., metadata) + * All buffers queued after this call will be associated with the SMPTE + * ST.2086 metadata specified. + * + * metadata specifies additional information about the contents of the buffer + * that may affect how it's displayed. When it is nullptr, it means no such + * information is available. No SMPTE ST.2086 metadata is associated with the + * buffers by default. + */ +static inline int native_window_set_buffers_smpte2086_metadata( + struct ANativeWindow* window, + const struct android_smpte2086_metadata* metadata) +{ + return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_SMPTE2086_METADATA, + metadata); +} + +/* + * native_window_set_buffers_cta861_3_metadata(..., metadata) + * All buffers queued after this call will be associated with the CTA-861.3 + * metadata specified. + * + * metadata specifies additional information about the contents of the buffer + * that may affect how it's displayed. When it is nullptr, it means no such + * information is available. No CTA-861.3 metadata is associated with the + * buffers by default. + */ +static inline int native_window_set_buffers_cta861_3_metadata( + struct ANativeWindow* window, + const struct android_cta861_3_metadata* metadata) +{ + return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_CTA861_3_METADATA, + metadata); +} + /* * native_window_set_buffers_transform(..., int transform) * All buffers queued after this call will be displayed transformed according @@ -987,18 +902,65 @@ static inline int native_window_set_auto_refresh( return window->perform(window, NATIVE_WINDOW_SET_AUTO_REFRESH, autoRefresh); } +static inline int native_window_get_refresh_cycle_duration( + struct ANativeWindow* window, + int64_t* outRefreshDuration) +{ + return window->perform(window, NATIVE_WINDOW_GET_REFRESH_CYCLE_DURATION, + outRefreshDuration); +} + +static inline int native_window_get_next_frame_id( + struct ANativeWindow* window, uint64_t* frameId) +{ + return window->perform(window, NATIVE_WINDOW_GET_NEXT_FRAME_ID, frameId); +} + +static inline int native_window_enable_frame_timestamps( + struct ANativeWindow* window, bool enable) +{ + return window->perform(window, NATIVE_WINDOW_ENABLE_FRAME_TIMESTAMPS, + enable); +} + +static inline int native_window_get_compositor_timing( + struct ANativeWindow* window, + int64_t* compositeDeadline, int64_t* compositeInterval, + int64_t* compositeToPresentLatency) +{ + return window->perform(window, NATIVE_WINDOW_GET_COMPOSITOR_TIMING, + compositeDeadline, compositeInterval, compositeToPresentLatency); +} + static inline int native_window_get_frame_timestamps( - struct ANativeWindow* window, uint32_t framesAgo, - int64_t* outPostedTime, int64_t* outAcquireTime, - int64_t* outRefreshStartTime, int64_t* outGlCompositionDoneTime, - int64_t* outDisplayRetireTime, int64_t* outReleaseTime) + struct ANativeWindow* window, uint64_t frameId, + int64_t* outRequestedPresentTime, int64_t* outAcquireTime, + int64_t* outLatchTime, int64_t* outFirstRefreshStartTime, + int64_t* outLastRefreshStartTime, int64_t* outGpuCompositionDoneTime, + int64_t* outDisplayPresentTime, int64_t* outDequeueReadyTime, + int64_t* outReleaseTime) { return window->perform(window, NATIVE_WINDOW_GET_FRAME_TIMESTAMPS, - framesAgo, outPostedTime, outAcquireTime, outRefreshStartTime, - outGlCompositionDoneTime, outDisplayRetireTime, outReleaseTime); + frameId, outRequestedPresentTime, outAcquireTime, outLatchTime, + outFirstRefreshStartTime, outLastRefreshStartTime, + outGpuCompositionDoneTime, outDisplayPresentTime, + outDequeueReadyTime, outReleaseTime); } +static inline int native_window_get_wide_color_support( + struct ANativeWindow* window, bool* outSupport) { + return window->perform(window, NATIVE_WINDOW_GET_WIDE_COLOR_SUPPORT, + outSupport); +} -__END_DECLS +static inline int native_window_get_hdr_support(struct ANativeWindow* window, + bool* outSupport) { + return window->perform(window, NATIVE_WINDOW_GET_HDR_SUPPORT, outSupport); +} + +static inline int native_window_get_consumer_usage(struct ANativeWindow* window, + uint64_t* outUsage) { + return window->perform(window, NATIVE_WINDOW_GET_CONSUMER_USAGE64, outUsage); +} -#endif /* SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H */ +__END_DECLS diff --git a/vndk/hardware_buffer.h b/vndk/hardware_buffer.h new file mode 100644 index 0000000..7a4b31f --- /dev/null +++ b/vndk/hardware_buffer.h @@ -0,0 +1,66 @@ +/* + * Copyright 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_VNDK_NATIVEWINDOW_AHARDWAREBUFFER_H +#define ANDROID_VNDK_NATIVEWINDOW_AHARDWAREBUFFER_H + +// vndk is a superset of the NDK +#include + +#include + +__BEGIN_DECLS + +const native_handle_t* AHardwareBuffer_getNativeHandle(const AHardwareBuffer* buffer); + + +/** + * Buffer pixel formats. + */ +enum { + /* for future proofing, keep these in sync with system/graphics-base.h */ + + /* same as HAL_PIXEL_FORMAT_BGRA_8888 */ + AHARDWAREBUFFER_FORMAT_B8G8R8A8_UNORM = 5, + /* same as HAL_PIXEL_FORMAT_YV12 */ + AHARDWAREBUFFER_FORMAT_YV12 = 0x32315659, + /* same as HAL_PIXEL_FORMAT_Y8 */ + AHARDWAREBUFFER_FORMAT_Y8 = 0x20203859, + /* same as HAL_PIXEL_FORMAT_Y16 */ + AHARDWAREBUFFER_FORMAT_Y16 = 0x20363159, + /* same as HAL_PIXEL_FORMAT_RAW16 */ + AHARDWAREBUFFER_FORMAT_RAW16 = 0x20, + /* same as HAL_PIXEL_FORMAT_RAW10 */ + AHARDWAREBUFFER_FORMAT_RAW10 = 0x25, + /* same as HAL_PIXEL_FORMAT_RAW12 */ + AHARDWAREBUFFER_FORMAT_RAW12 = 0x26, + /* same as HAL_PIXEL_FORMAT_RAW_OPAQUE */ + AHARDWAREBUFFER_FORMAT_RAW_OPAQUE = 0x24, + /* same as HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED */ + AHARDWAREBUFFER_FORMAT_IMPLEMENTATION_DEFINED = 0x22, + /* same as HAL_PIXEL_FORMAT_YCBCR_420_888 */ + AHARDWAREBUFFER_FORMAT_Y8Cb8Cr8_420 = 0x23, + /* same as HAL_PIXEL_FORMAT_YCBCR_422_SP */ + AHARDWAREBUFFER_FORMAT_YCbCr_422_SP = 0x10, + /* same as HAL_PIXEL_FORMAT_YCRCB_420_SP */ + AHARDWAREBUFFER_FORMAT_YCrCb_420_SP = 0x11, + /* same as HAL_PIXEL_FORMAT_YCBCR_422_I */ + AHARDWAREBUFFER_FORMAT_YCbCr_422_I = 0x14, +}; + +__END_DECLS + +#endif /* ANDROID_VNDK_NATIVEWINDOW_AHARDWAREBUFFER_H */ diff --git a/vndk/window.h b/vndk/window.h new file mode 100644 index 0000000..995ba44 --- /dev/null +++ b/vndk/window.h @@ -0,0 +1,324 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_VNDK_NATIVEWINDOW_ANATIVEWINDOW_H +#define ANDROID_VNDK_NATIVEWINDOW_ANATIVEWINDOW_H + +#include + +// vndk is a superset of the NDK +#include + + +__BEGIN_DECLS + +/* + * Convert this ANativeWindowBuffer into a AHardwareBuffer + */ +AHardwareBuffer* ANativeWindowBuffer_getHardwareBuffer(ANativeWindowBuffer* anwb); + +/*****************************************************************************/ + +/* + * Stores a value into one of the 4 available slots + * Retrieve the value with ANativeWindow_OemStorageGet() + * + * slot: 0 to 3 + * + * Returns 0 on success or -errno on error. + */ +int ANativeWindow_OemStorageSet(ANativeWindow* window, uint32_t slot, intptr_t value); + + +/* + * Retrieves a value from one of the 4 available slots + * By default the returned value is 0 if it wasn't set by ANativeWindow_OemStorageSet() + * + * slot: 0 to 3 + * + * Returns 0 on success or -errno on error. + */ +int ANativeWindow_OemStorageGet(ANativeWindow* window, uint32_t slot, intptr_t* value); + + +/* + * Set the swap interval for this surface. + * + * Returns 0 on success or -errno on error. + */ +int ANativeWindow_setSwapInterval(ANativeWindow* window, int interval); + + +/* + * queries that can be used with ANativeWindow_query() and ANativeWindow_queryf() + */ +enum ANativeWindowQuery { + /* The minimum number of buffers that must remain un-dequeued after a buffer + * has been queued. This value applies only if set_buffer_count was used to + * override the number of buffers and if a buffer has since been queued. + * Users of the set_buffer_count ANativeWindow method should query this + * value before calling set_buffer_count. If it is necessary to have N + * buffers simultaneously dequeued as part of the steady-state operation, + * and this query returns M then N+M buffers should be requested via + * native_window_set_buffer_count. + * + * Note that this value does NOT apply until a single buffer has been + * queued. In particular this means that it is possible to: + * + * 1. Query M = min undequeued buffers + * 2. Set the buffer count to N + M + * 3. Dequeue all N + M buffers + * 4. Cancel M buffers + * 5. Queue, dequeue, queue, dequeue, ad infinitum + */ + ANATIVEWINDOW_QUERY_MIN_UNDEQUEUED_BUFFERS = 3, + + /* + * Default width of ANativeWindow buffers, these are the + * dimensions of the window buffers irrespective of the + * ANativeWindow_setBuffersDimensions() call and match the native window + * size. + */ + ANATIVEWINDOW_QUERY_DEFAULT_WIDTH = 6, + ANATIVEWINDOW_QUERY_DEFAULT_HEIGHT = 7, + + /* + * transformation that will most-likely be applied to buffers. This is only + * a hint, the actual transformation applied might be different. + * + * INTENDED USE: + * + * The transform hint can be used by a producer, for instance the GLES + * driver, to pre-rotate the rendering such that the final transformation + * in the composer is identity. This can be very useful when used in + * conjunction with the h/w composer HAL, in situations where it + * cannot handle arbitrary rotations. + * + * 1. Before dequeuing a buffer, the GL driver (or any other ANW client) + * queries the ANW for NATIVE_WINDOW_TRANSFORM_HINT. + * + * 2. The GL driver overrides the width and height of the ANW to + * account for NATIVE_WINDOW_TRANSFORM_HINT. This is done by querying + * NATIVE_WINDOW_DEFAULT_{WIDTH | HEIGHT}, swapping the dimensions + * according to NATIVE_WINDOW_TRANSFORM_HINT and calling + * native_window_set_buffers_dimensions(). + * + * 3. The GL driver dequeues a buffer of the new pre-rotated size. + * + * 4. The GL driver renders to the buffer such that the image is + * already transformed, that is applying NATIVE_WINDOW_TRANSFORM_HINT + * to the rendering. + * + * 5. The GL driver calls native_window_set_transform to apply + * inverse transformation to the buffer it just rendered. + * In order to do this, the GL driver needs + * to calculate the inverse of NATIVE_WINDOW_TRANSFORM_HINT, this is + * done easily: + * + * int hintTransform, inverseTransform; + * query(..., NATIVE_WINDOW_TRANSFORM_HINT, &hintTransform); + * inverseTransform = hintTransform; + * if (hintTransform & HAL_TRANSFORM_ROT_90) + * inverseTransform ^= HAL_TRANSFORM_ROT_180; + * + * + * 6. The GL driver queues the pre-transformed buffer. + * + * 7. The composer combines the buffer transform with the display + * transform. If the buffer transform happens to cancel out the + * display transform then no rotation is needed. + * + */ + ANATIVEWINDOW_QUERY_TRANSFORM_HINT = 8, + + /* + * Returns the age of the contents of the most recently dequeued buffer as + * the number of frames that have elapsed since it was last queued. For + * example, if the window is double-buffered, the age of any given buffer in + * steady state will be 2. If the dequeued buffer has never been queued, its + * age will be 0. + */ + ANATIVEWINDOW_QUERY_BUFFER_AGE = 13, + + /* min swap interval supported by this compositor */ + ANATIVEWINDOW_QUERY_MIN_SWAP_INTERVAL = 0x10000, + + /* max swap interval supported by this compositor */ + ANATIVEWINDOW_QUERY_MAX_SWAP_INTERVAL = 0x10001, + + /* horizontal resolution in DPI. value is float, use queryf() */ + ANATIVEWINDOW_QUERY_XDPI = 0x10002, + + /* vertical resolution in DPI. value is float, use queryf() */ + ANATIVEWINDOW_QUERY_YDPI = 0x10003, +}; + +typedef enum ANativeWindowQuery ANativeWindowQuery; + +/* + * hook used to retrieve information about the native window. + * + * Returns 0 on success or -errno on error. + */ +int ANativeWindow_query(const ANativeWindow* window, ANativeWindowQuery query, int* value); +int ANativeWindow_queryf(const ANativeWindow* window, ANativeWindowQuery query, float* value); + + +/* + * Hook called by EGL to acquire a buffer. This call may block if no + * buffers are available. + * + * The window holds a reference to the buffer between dequeueBuffer and + * either queueBuffer or cancelBuffer, so clients only need their own + * reference if they might use the buffer after queueing or canceling it. + * Holding a reference to a buffer after queueing or canceling it is only + * allowed if a specific buffer count has been set. + * + * The libsync fence file descriptor returned in the int pointed to by the + * fenceFd argument will refer to the fence that must signal before the + * dequeued buffer may be written to. A value of -1 indicates that the + * caller may access the buffer immediately without waiting on a fence. If + * a valid file descriptor is returned (i.e. any value except -1) then the + * caller is responsible for closing the file descriptor. + * + * Returns 0 on success or -errno on error. + */ +int ANativeWindow_dequeueBuffer(ANativeWindow* window, ANativeWindowBuffer** buffer, int* fenceFd); + + +/* + * Hook called by EGL when modifications to the render buffer are done. + * This unlocks and post the buffer. + * + * The window holds a reference to the buffer between dequeueBuffer and + * either queueBuffer or cancelBuffer, so clients only need their own + * reference if they might use the buffer after queueing or canceling it. + * Holding a reference to a buffer after queueing or canceling it is only + * allowed if a specific buffer count has been set. + * + * The fenceFd argument specifies a libsync fence file descriptor for a + * fence that must signal before the buffer can be accessed. If the buffer + * can be accessed immediately then a value of -1 should be used. The + * caller must not use the file descriptor after it is passed to + * queueBuffer, and the ANativeWindow implementation is responsible for + * closing it. + * + * Returns 0 on success or -errno on error. + */ +int ANativeWindow_queueBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd); + + +/* + * Hook used to cancel a buffer that has been dequeued. + * No synchronization is performed between dequeue() and cancel(), so + * either external synchronization is needed, or these functions must be + * called from the same thread. + * + * The window holds a reference to the buffer between dequeueBuffer and + * either queueBuffer or cancelBuffer, so clients only need their own + * reference if they might use the buffer after queueing or canceling it. + * Holding a reference to a buffer after queueing or canceling it is only + * allowed if a specific buffer count has been set. + * + * The fenceFd argument specifies a libsync fence file decsriptor for a + * fence that must signal before the buffer can be accessed. If the buffer + * can be accessed immediately then a value of -1 should be used. + * + * Note that if the client has not waited on the fence that was returned + * from dequeueBuffer, that same fence should be passed to cancelBuffer to + * ensure that future uses of the buffer are preceded by a wait on that + * fence. The caller must not use the file descriptor after it is passed + * to cancelBuffer, and the ANativeWindow implementation is responsible for + * closing it. + * + * Returns 0 on success or -errno on error. + */ +int ANativeWindow_cancelBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd); + +/* + * Sets the intended usage flags for the next buffers. + * + * usage: one of AHARDWAREBUFFER_USAGE_* constant + * + * By default (if this function is never called), a usage of + * AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE | AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT + * is assumed. + * + * Calling this function will usually cause following buffers to be + * reallocated. + */ +int ANativeWindow_setUsage(ANativeWindow* window, uint64_t usage); + + +/* + * Sets the number of buffers associated with this native window. + */ +int ANativeWindow_setBufferCount(ANativeWindow* window, size_t bufferCount); + + +/* + * All buffers dequeued after this call will have the dimensions specified. + * In particular, all buffers will have a fixed-size, independent from the + * native-window size. They will be scaled according to the scaling mode + * (see native_window_set_scaling_mode) upon window composition. + * + * If w and h are 0, the normal behavior is restored. That is, dequeued buffers + * following this call will be sized to match the window's size. + * + * Calling this function will reset the window crop to a NULL value, which + * disables cropping of the buffers. + */ +int ANativeWindow_setBuffersDimensions(ANativeWindow* window, uint32_t w, uint32_t h); + + +/* + * All buffers dequeued after this call will have the format specified. + * format: one of AHARDWAREBUFFER_FORMAT_* constant + * + * If the specified format is 0, the default buffer format will be used. + */ +int ANativeWindow_setBuffersFormat(ANativeWindow* window, int format); + + +/* + * All buffers queued after this call will be associated with the timestamp in nanosecond + * parameter specified. If the timestamp is set to NATIVE_WINDOW_TIMESTAMP_AUTO + * (the default), timestamps will be generated automatically when queueBuffer is + * called. The timestamp is measured in nanoseconds, and is normally monotonically + * increasing. The timestamp should be unaffected by time-of-day adjustments, + * and for a camera should be strictly monotonic but for a media player may be + * reset when the position is set. + */ +int ANativeWindow_setBuffersTimestamp(ANativeWindow* window, int64_t timestamp); + + +/* + * Enable/disable shared buffer mode + */ +int ANativeWindow_setSharedBufferMode(ANativeWindow* window, bool sharedBufferMode); + + +/* + * Enable/disable auto refresh when in shared buffer mode + */ +int ANativeWindow_setAutoRefresh(ANativeWindow* window, bool autoRefresh); + + +/*****************************************************************************/ + +__END_DECLS + +#endif /* ANDROID_VNDK_NATIVEWINDOW_ANATIVEWINDOW_H */