pax_global_header00006660000000000000000000000064126446541100014515gustar00rootroot0000000000000052 comment=39bc56a497c29c8641b7c77cb1f60041b92d5c38 android-headers-23/000077500000000000000000000000001264465411000143345ustar00rootroot00000000000000android-headers-23/19/000077500000000000000000000000001264465411000145655ustar00rootroot00000000000000android-headers-23/19/android-config.h000066400000000000000000000013371264465411000176250ustar00rootroot00000000000000#ifndef HYBRIS_CONFIG_H_ #define HYBRIS_CONFIG_H_ /* 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: COMMON_GLOBAL_CFLAGS += -DCAMERA_WITH_CITYID_PARAM device/samsung/smdk4412-common/BoardCommonConfig.mk: COMMON_GLOBAL_CFLAGS += -DEXYNOS4_ENHANCEMENTS This file allows those global configurations, which are not otherwise defined in the build headers, to be available in hybris builds. Typically it is generated at hardware adaptation time. The CONFIG GOES HERE line can be used by automation to modify this file. */ #include /* CONFIG GOES HERE */ #endif android-headers-23/19/android-version.h000066400000000000000000000003411264465411000200370ustar00rootroot00000000000000#ifndef ANDROID_VERSION_H_ #define ANDROID_VERSION_H_ #define ANDROID_VERSION_MAJOR 4 #define ANDROID_VERSION_MINOR 4 #define ANDROID_VERSION_PATCH 0 #define ANDROID_VERSION_PATCH2 1 #define ANDROID_VERSION_PATCH3 0 #endif android-headers-23/19/android/000077500000000000000000000000001264465411000162055ustar00rootroot00000000000000android-headers-23/19/android/log.h000066400000000000000000000074271264465411000171510ustar00rootroot00000000000000/* * 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_LOG_H #define _ANDROID_LOG_H /****************************************************************** * * IMPORTANT NOTICE: * * This file is part of Android's set of stable system headers * exposed by the Android NDK (Native Development Kit) since * platform release 1.5 * * Third-party source AND binary code relies on the definitions * here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES. * * - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES) * - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS * - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY * - 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. * * Each log message must have * - a priority * - a log tag * - some text * * The tag normally corresponds to the component that emits the log message, * and should be reasonably small. * * Log message text may be truncated to less than an implementation-specific * limit (e.g. 1023 characters max). * * 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. * * PLEASE USE LOGS WITH 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. * * - In release builds, only send log messages to account for exceptional * conditions. * * NOTE: These functions MUST be implemented by /system/lib/liblog.so */ #include #ifdef __cplusplus extern "C" { #endif /* * Android log priority values, in ascending priority order. */ 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 */ } android_LogPriority; /* * Send a simple string to the log. */ int __android_log_write(int prio, const char *tag, const char *text); /* * Send a formatted string to the log, used like printf(fmt,...) */ int __android_log_print(int prio, const char *tag, const char *fmt, ...) #if defined(__GNUC__) __attribute__ ((format(printf, 3, 4))) #endif ; /* * A variant of __android_log_print() that takes a va_list to list * additional parameters. */ int __android_log_vprint(int prio, const char *tag, const char *fmt, va_list ap); /* * Log an assertion failure and SIGTRAP the process to have a chance * to inspect it, if a debugger is attached. This uses the FATAL priority. */ void __android_log_assert(const char *cond, const char *tag, const char *fmt, ...) #if defined(__GNUC__) __attribute__ ((noreturn)) __attribute__ ((format(printf, 3, 4))) #endif ; #ifdef __cplusplus } #endif #endif /* _ANDROID_LOG_H */ android-headers-23/19/cutils/000077500000000000000000000000001264465411000160705ustar00rootroot00000000000000android-headers-23/19/cutils/android_reboot.h000066400000000000000000000017551264465411000212430ustar00rootroot00000000000000/* * Copyright 2011, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __CUTILS_ANDROID_REBOOT_H__ #define __CUTILS_ANDROID_REBOOT_H__ __BEGIN_DECLS /* Commands */ #define ANDROID_RB_RESTART 0xDEAD0001 #define ANDROID_RB_POWEROFF 0xDEAD0002 #define ANDROID_RB_RESTART2 0xDEAD0003 /* Properties */ #define ANDROID_RB_PROPERTY "sys.powerctl" int android_reboot(int cmd, int flags, char *arg); __END_DECLS #endif /* __CUTILS_ANDROID_REBOOT_H__ */ android-headers-23/19/cutils/aref.h000066400000000000000000000025641264465411000171650ustar00rootroot00000000000000/* * 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_ android-headers-23/19/cutils/ashmem.h000066400000000000000000000021411264465411000175110ustar00rootroot00000000000000/* cutils/ashmem.h ** ** Copyright 2008 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 _CUTILS_ASHMEM_H #define _CUTILS_ASHMEM_H #include #ifdef __cplusplus extern "C" { #endif 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); int ashmem_unpin_region(int fd, size_t offset, size_t len); int ashmem_get_size_region(int fd); #ifdef __cplusplus } #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 */ android-headers-23/19/cutils/atomic-arm.h000066400000000000000000000121601264465411000202720ustar00rootroot00000000000000/* * 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 void android_memory_store_barrier() { #if ANDROID_SMP == 0 android_compiler_barrier(); #else __asm__ __volatile__ ("dmb st" : : : "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 */ android-headers-23/19/cutils/atomic-inline.h000066400000000000000000000037621264465411000210010ustar00rootroot00000000000000/* * 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(__arm__) #include #elif defined(__i386__) || defined(__x86_64__) #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 #if ANDROID_SMP == 0 #define ANDROID_MEMBAR_STORE android_compiler_barrier #else #define ANDROID_MEMBAR_STORE android_memory_store_barrier #endif #ifdef __cplusplus } #endif #endif /* ANDROID_CUTILS_ATOMIC_INLINE_H */ android-headers-23/19/cutils/atomic-mips.h000066400000000000000000000127441264465411000204730ustar00rootroot00000000000000/* * 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(); } extern ANDROID_ATOMIC_INLINE void android_memory_store_barrier(void) { android_compiler_barrier(); } #else extern ANDROID_ATOMIC_INLINE void android_memory_barrier(void) { __asm__ __volatile__ ("sync" : : : "memory"); } extern ANDROID_ATOMIC_INLINE void android_memory_store_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_swap(int32_t new_value, volatile int32_t *ptr) { int32_t prev, status; do { __asm__ __volatile__ ( " move %[status], %[new_value]\n" " ll %[prev], (%[ptr])\n" " sc %[status], (%[ptr])\n" : [prev] "=&r" (prev), [status] "=&r" (status) : [ptr] "r" (ptr), [new_value] "r" (new_value) ); } while (__builtin_expect(status == 0, 0)); android_memory_barrier(); return prev; } 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 */ android-headers-23/19/cutils/atomic-x86.h000066400000000000000000000100771264465411000201450ustar00rootroot00000000000000/* * 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(); } extern ANDROID_ATOMIC_INLINE void android_memory_store_barrier(void) { android_compiler_barrier(); } #else extern ANDROID_ATOMIC_INLINE void android_memory_barrier(void) { __asm__ __volatile__ ("mfence" : : : "memory"); } extern ANDROID_ATOMIC_INLINE void android_memory_store_barrier(void) { android_compiler_barrier(); } #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 */ android-headers-23/19/cutils/atomic.h000066400000000000000000000111571264465411000175220ustar00rootroot00000000000000/* * 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. */ #ifndef ANDROID_CUTILS_ATOMIC_H #define ANDROID_CUTILS_ATOMIC_H #include #include #ifdef __cplusplus extern "C" { #endif /* * A handful of basic atomic operations. The appropriate pthread * functions should be used instead of these whenever possible. * * The "acquire" and "release" terms can be defined intuitively in terms * of the placement of memory barriers in a simple lock implementation: * - wait until compare-and-swap(lock-is-free --> lock-is-held) succeeds * - barrier * - [do work] * - barrier * - store(lock-is-free) * In very crude terms, the initial (acquire) barrier prevents any of the * "work" from happening before the lock is held, and the later (release) * barrier ensures that all of the work happens before the lock is released. * (Think of cached writes, cache read-ahead, and instruction reordering * around the CAS and store instructions.) * * The barriers must apply to both the compiler and the CPU. Note it is * legal for instructions that occur before an "acquire" barrier to be * moved down below it, and for instructions that occur after a "release" * barrier to be moved up above it. * * The ARM-driven implementation we use here is short on subtlety, * and actually requests a full barrier from the compiler and the CPU. * The only difference between acquire and release is in whether they * are issued before or after the atomic operation with which they * are associated. To ease the transition to C/C++ atomic intrinsics, * you should not rely on this, and instead assume that only the minimal * acquire/release protection is provided. * * NOTE: all int32_t* values are expected to be aligned on 32-bit boundaries. * If they are not, atomicity is not guaranteed. */ /* * Basic arithmetic and bitwise operations. These all provide a * barrier with "release" ordering, and return the previous value. * * These have the same characteristics (e.g. what happens on overflow) * as the equivalent non-atomic C operations. */ int32_t android_atomic_inc(volatile int32_t* addr); int32_t android_atomic_dec(volatile int32_t* addr); int32_t android_atomic_add(int32_t value, volatile int32_t* addr); int32_t android_atomic_and(int32_t value, volatile int32_t* addr); int32_t android_atomic_or(int32_t value, volatile int32_t* addr); /* * Perform an atomic load with "acquire" or "release" ordering. * * This is only necessary if you need the memory barrier. A 32-bit read * from a 32-bit aligned address is atomic on all supported platforms. */ int32_t android_atomic_acquire_load(volatile const int32_t* addr); int32_t android_atomic_release_load(volatile const int32_t* addr); /* * Perform an atomic store with "acquire" or "release" ordering. * * This is only necessary if you need the memory barrier. A 32-bit write * to a 32-bit aligned address is atomic on all supported platforms. */ void android_atomic_acquire_store(int32_t value, volatile int32_t* addr); void android_atomic_release_store(int32_t value, volatile int32_t* addr); /* * Compare-and-set operation with "acquire" or "release" ordering. * * This returns zero if the new value was successfully stored, which will * only happen when *addr == oldvalue. * * (The return value is inverted from implementations on other platforms, * but matches the ARM ldrex/strex result.) * * Implementations that use the release CAS in a loop may be less efficient * than possible, because we re-issue the memory barrier on each iteration. */ int android_atomic_acquire_cas(int32_t oldvalue, int32_t newvalue, volatile int32_t* addr); int android_atomic_release_cas(int32_t oldvalue, int32_t newvalue, volatile int32_t* addr); /* * Aliases for code using an older version of this header. These are now * deprecated and should not be used. The definitions will be removed * in a future release. */ #define android_atomic_write android_atomic_release_store #define android_atomic_cmpxchg android_atomic_release_cas #ifdef __cplusplus } // extern "C" #endif #endif // ANDROID_CUTILS_ATOMIC_H android-headers-23/19/cutils/bitops.h000066400000000000000000000057371264465411000175550ustar00rootroot00000000000000/* * 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 __CUTILS_BITOPS_H #define __CUTILS_BITOPS_H #include #include #include #include __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; unsigned int 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) { int 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) { return __builtin_popcount(x); } static inline int popcountl(unsigned long x) { return __builtin_popcountl(x); } static inline int popcountll(unsigned long long x) { return __builtin_popcountll(x); } __END_DECLS #endif /* __CUTILS_BITOPS_H */ android-headers-23/19/cutils/compiler.h000066400000000000000000000025171264465411000200600ustar00rootroot00000000000000/* * 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_COMPILER_H #define ANDROID_CUTILS_COMPILER_H /* * helps the compiler's optimizer predicting branches */ #ifdef __cplusplus # define CC_LIKELY( exp ) (__builtin_expect( !!(exp), true )) # define CC_UNLIKELY( exp ) (__builtin_expect( !!(exp), false )) #else # define CC_LIKELY( exp ) (__builtin_expect( !!(exp), 1 )) # define CC_UNLIKELY( exp ) (__builtin_expect( !!(exp), 0 )) #endif /** * exports marked symbols * * if used on a C++ class declaration, this macro must be inserted * after the "class" keyword. For instance: * * template * class ANDROID_API Singleton { } */ #define ANDROID_API __attribute__((visibility("default"))) #endif // ANDROID_CUTILS_COMPILER_H android-headers-23/19/cutils/config_utils.h000066400000000000000000000033471264465411000207350ustar00rootroot00000000000000/* * Copyright (C) 2006 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_CONFIG_UTILS_H #define __CUTILS_CONFIG_UTILS_H #ifdef __cplusplus extern "C" { #endif typedef struct cnode cnode; struct cnode { cnode *next; cnode *first_child; cnode *last_child; const char *name; const char *value; }; /* parse a text string into a config node tree */ void config_load(cnode *root, char *data); /* parse a file into a config node tree */ void config_load_file(cnode *root, const char *fn); /* create a single config node */ cnode* config_node(const char *name, const char *value); /* locate a named child of a config node */ cnode* config_find(cnode *root, const char *name); /* look up a child by name and return the boolean value */ int config_bool(cnode *root, const char *name, int _default); /* look up a child by name and return the string value */ const char* config_str(cnode *root, const char *name, const char *_default); /* add a named child to a config node (or modify it if it already exists) */ void config_set(cnode *root, const char *name, const char *value); /* free a config node tree */ void config_free(cnode *root); #ifdef __cplusplus } #endif #endif android-headers-23/19/cutils/cpu_info.h000066400000000000000000000017761264465411000200560ustar00rootroot00000000000000/* * 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. */ #ifndef __CUTILS_CPU_INFO_H #define __CUTILS_CPU_INFO_H #ifdef __cplusplus extern "C" { #endif /* 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 } #endif #endif /* __CUTILS_CPU_INFO_H */ android-headers-23/19/cutils/debugger.h000066400000000000000000000031121264465411000200220ustar00rootroot00000000000000/* * 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 #ifdef __cplusplus extern "C" { #endif #define DEBUGGER_SOCKET_NAME "android:debuggerd" 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; typedef struct { debugger_action_t action; pid_t tid; uintptr_t abort_msg_address; } 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 only to the specified file (requires root). * Returns 0 on success, -1 on error. */ int dump_backtrace_to_file(pid_t tid, int fd); #ifdef __cplusplus } #endif #endif /* __CUTILS_DEBUGGER_H */ android-headers-23/19/cutils/dir_hash.h000066400000000000000000000017051264465411000200250ustar00rootroot00000000000000/* * 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. */ typedef enum { SHA_1, } HashAlgorithm; int get_file_hash(HashAlgorithm algorithm, const char *path, char *output_string, size_t max_output_string); int get_recursive_hash_manifest(HashAlgorithm algorithm, const char *directory_path, char **output_string); android-headers-23/19/cutils/fs.h000066400000000000000000000041471264465411000166570ustar00rootroot00000000000000/* * 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_FS_H #define __CUTILS_FS_H #include /* * TEMP_FAILURE_RETRY is defined by some, but not all, versions of * . (Alas, it is not as standard as we'd hoped!) So, if it's * not already defined, then define it here. */ #ifndef TEMP_FAILURE_RETRY /* Used to retry syscalls that can return EINTR. */ #define TEMP_FAILURE_RETRY(exp) ({ \ typeof (exp) _rc; \ do { \ _rc = (exp); \ } while (_rc == -1 && errno == EINTR); \ _rc; }) #endif #ifdef __cplusplus extern "C" { #endif /* * Ensure that directory exists with given mode and owners. */ extern int fs_prepare_dir(const char* path, mode_t mode, uid_t uid, gid_t gid); /* * Read single plaintext integer from given file, correctly handling files * partially written with fs_write_atomic_int(). */ extern int fs_read_atomic_int(const char* path, int* value); /* * Write single plaintext integer to given file, creating backup while * in progress. */ extern int fs_write_atomic_int(const char* path, int value); /* * Ensure that all directories along given path exist, creating parent * directories as needed. Validates that given path is absolute and that * it contains no relative "." or ".." paths or symlinks. Last path segment * is treated as filename and ignored, unless the path ends with "/". */ extern int fs_mkdirs(const char* path, mode_t mode); #ifdef __cplusplus } #endif #endif /* __CUTILS_FS_H */ android-headers-23/19/cutils/hashmap.h000066400000000000000000000067551264465411000176770ustar00rootroot00000000000000/* * 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. */ /** * Hash map. */ #ifndef __HASHMAP_H #define __HASHMAP_H #include #include #ifdef __cplusplus extern "C" { #endif /** A hash map. */ typedef struct Hashmap Hashmap; /** * Creates a new hash map. Returns NULL if memory allocation fails. * * @param initialCapacity number of expected entries * @param hash function which hashes keys * @param equals function which compares keys for equality */ Hashmap* hashmapCreate(size_t initialCapacity, int (*hash)(void* key), bool (*equals)(void* keyA, void* keyB)); /** * Frees the hash map. Does not free the keys or values themselves. */ void hashmapFree(Hashmap* map); /** * Hashes the memory pointed to by key with the given size. Useful for * implementing hash functions. */ int hashmapHash(void* key, size_t keySize); /** * Puts value for the given key in the map. Returns pre-existing value if * any. * * If memory allocation fails, this function returns NULL, the map's size * does not increase, and errno is set to ENOMEM. */ void* hashmapPut(Hashmap* map, void* key, void* value); /** * Gets a value from the map. Returns NULL if no entry for the given key is * found or if the value itself is NULL. */ void* hashmapGet(Hashmap* map, void* key); /** * Returns true if the map contains an entry for the given key. */ bool hashmapContainsKey(Hashmap* map, void* key); /** * Gets the value for a key. If a value is not found, this function gets a * value and creates an entry using the given callback. * * If memory allocation fails, the callback is not called, this function * returns NULL, and errno is set to ENOMEM. */ void* hashmapMemoize(Hashmap* map, void* key, void* (*initialValue)(void* key, void* context), void* context); /** * Removes an entry from the map. Returns the removed value or NULL if no * entry was present. */ void* hashmapRemove(Hashmap* map, void* key); /** * Gets the number of entries in this map. */ size_t hashmapSize(Hashmap* map); /** * Invokes the given callback on each entry in the map. Stops iterating if * the callback returns false. */ void hashmapForEach(Hashmap* map, bool (*callback)(void* key, void* value, void* context), void* context); /** * Concurrency support. */ /** * Locks the hash map so only the current thread can access it. */ void hashmapLock(Hashmap* map); /** * Unlocks the hash map so other threads can access it. */ void hashmapUnlock(Hashmap* map); /** * Key utilities. */ /** * Hashes int keys. 'key' is a pointer to int. */ int hashmapIntHash(void* key); /** * Compares two int keys for equality. */ bool hashmapIntEquals(void* keyA, void* keyB); /** * For debugging. */ /** * Gets current capacity. */ size_t hashmapCurrentCapacity(Hashmap* map); /** * Counts the number of entry collisions. */ size_t hashmapCountCollisions(Hashmap* map); #ifdef __cplusplus } #endif #endif /* __HASHMAP_H */ android-headers-23/19/cutils/iosched_policy.h000066400000000000000000000020521264465411000212350ustar00rootroot00000000000000/* * 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. */ #ifndef __CUTILS_IOSCHED_POLICY_H #define __CUTILS_IOSCHED_POLICY_H #ifdef __cplusplus extern "C" { #endif typedef enum { IoSchedClass_NONE, IoSchedClass_RT, IoSchedClass_BE, IoSchedClass_IDLE, } IoSchedClass; extern int android_set_ioprio(int pid, IoSchedClass clazz, int ioprio); extern int android_get_ioprio(int pid, IoSchedClass *clazz, int *ioprio); #ifdef __cplusplus } #endif #endif /* __CUTILS_IOSCHED_POLICY_H */ android-headers-23/19/cutils/jstring.h000066400000000000000000000024561264465411000177300ustar00rootroot00000000000000/* * Copyright (C) 2006 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_STRING16_H #define __CUTILS_STRING16_H #include #include #ifdef __cplusplus extern "C" { #endif typedef uint16_t char16_t; extern char * strndup16to8 (const char16_t* s, size_t n); extern size_t strnlen16to8 (const char16_t* s, size_t n); extern char * strncpy16to8 (char *dest, const char16_t*s, size_t n); extern char16_t * strdup8to16 (const char* s, size_t *out_len); extern size_t strlen8to16 (const char* utf8Str); extern char16_t * strcpy8to16 (char16_t *dest, const char*s, size_t *out_len); extern char16_t * strcpylen8to16 (char16_t *dest, const char*s, int length, size_t *out_len); #ifdef __cplusplus } #endif #endif /* __CUTILS_STRING16_H */ android-headers-23/19/cutils/klog.h000066400000000000000000000024101264465411000171720ustar00rootroot00000000000000/* * 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 _CUTILS_KLOG_H_ #define _CUTILS_KLOG_H_ #include __BEGIN_DECLS void klog_init(void); void klog_set_level(int level); void klog_close(void); void klog_write(int level, const char *fmt, ...) __attribute__ ((format(printf, 2, 3))); __END_DECLS #define KLOG_ERROR(tag,x...) klog_write(3, "<3>" tag ": " x) #define KLOG_WARNING(tag,x...) klog_write(4, "<4>" tag ": " x) #define KLOG_NOTICE(tag,x...) klog_write(5, "<5>" tag ": " x) #define KLOG_INFO(tag,x...) klog_write(6, "<6>" tag ": " x) #define KLOG_DEBUG(tag,x...) klog_write(7, "<7>" tag ": " x) #define KLOG_DEFAULT_LEVEL 3 /* messages <= this level are logged */ #endif android-headers-23/19/cutils/list.h000066400000000000000000000031011264465411000172070ustar00rootroot00000000000000/* * 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 _CUTILS_LIST_H_ #define _CUTILS_LIST_H_ #include #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ struct listnode { struct listnode *next; struct listnode *prev; }; #define node_to_item(node, container, member) \ (container *) (((char*) (node)) - offsetof(container, member)) #define list_declare(name) \ struct listnode name = { \ .next = &name, \ .prev = &name, \ } #define list_for_each(node, list) \ 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) void list_init(struct listnode *list); void list_add_tail(struct listnode *list, struct listnode *item); void list_remove(struct listnode *item); #define list_empty(list) ((list) == (list)->next) #define list_head(list) ((list)->next) #define list_tail(list) ((list)->prev) #ifdef __cplusplus }; #endif /* __cplusplus */ #endif android-headers-23/19/cutils/log.h000066400000000000000000000000251264465411000170170ustar00rootroot00000000000000#include android-headers-23/19/cutils/memory.h000066400000000000000000000023411264465411000175510ustar00rootroot00000000000000/* * Copyright (C) 2006 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_MEMORY_H #define ANDROID_CUTILS_MEMORY_H #include #include #ifdef __cplusplus extern "C" { #endif /* size is given in bytes and must be multiple of 2 */ void android_memset16(uint16_t* dst, uint16_t value, size_t size); /* size is given in bytes and must be multiple of 4 */ void android_memset32(uint32_t* dst, uint32_t value, size_t size); #if !HAVE_STRLCPY /* Declaration of strlcpy() for platforms that don't already have it. */ size_t strlcpy(char *dst, const char *src, size_t size); #endif #ifdef __cplusplus } // extern "C" #endif #endif // ANDROID_CUTILS_MEMORY_H android-headers-23/19/cutils/misc.h000066400000000000000000000027061264465411000172010ustar00rootroot00000000000000/* * Copyright (C) 2006 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_MISC_H #define __CUTILS_MISC_H #ifdef __cplusplus extern "C" { #endif /* Load an entire file into a malloc'd chunk of memory * that is length_of_file + 1 (null terminator). If * sz is non-zero, return the size of the file via sz. * Returns 0 on failure. */ extern void *load_file(const char *fn, unsigned *sz); /* Connects your process to the system debugger daemon * so that on a crash it may be logged or interactively * debugged (depending on system settings). */ extern void debuggerd_connect(void); /* This is the range of UIDs (and GIDs) that are reserved * for assigning to applications. */ #define FIRST_APPLICATION_UID 10000 #define LAST_APPLICATION_UID 99999 #ifdef __cplusplus } #endif #endif /* __CUTILS_MISC_H */ android-headers-23/19/cutils/multiuser.h000066400000000000000000000021251264465411000202720ustar00rootroot00000000000000/* * 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_MULTIUSER_H #define __CUTILS_MULTIUSER_H #include #ifdef __cplusplus extern "C" { #endif // NOTE: keep in sync with android.os.UserId #define MULTIUSER_APP_PER_USER_RANGE 100000 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); #ifdef __cplusplus } #endif #endif /* __CUTILS_MULTIUSER_H */ android-headers-23/19/cutils/native_handle.h000066400000000000000000000035011264465411000210410ustar00rootroot00000000000000/* * 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 NATIVE_HANDLE_H_ #define NATIVE_HANDLE_H_ #ifdef __cplusplus extern "C" { #endif 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] */ int data[0]; /* numFds + numInts ints */ } native_handle_t; /* * native_handle_close * * closes the file descriptors contained in this native_handle_t * * return 0 on success, or a negative error code on failure * */ int native_handle_close(const native_handle_t* h); /* * native_handle_create * * creates a native_handle_t and initializes it. must be destroyed with * native_handle_delete(). * */ native_handle_t* native_handle_create(int numFds, int numInts); /* * native_handle_delete * * frees a native_handle_t allocated with native_handle_create(). * This ONLY frees the memory allocated for the native_handle_t, but doesn't * close the file descriptors; which can be achieved with native_handle_close(). * * return 0 on success, or a negative error code on failure * */ int native_handle_delete(native_handle_t* h); #ifdef __cplusplus } #endif #endif /* NATIVE_HANDLE_H_ */ android-headers-23/19/cutils/open_memstream.h000066400000000000000000000016471264465411000212640ustar00rootroot00000000000000/* * 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 __CUTILS_OPEN_MEMSTREAM_H__ #define __CUTILS_OPEN_MEMSTREAM_H__ #include #ifndef HAVE_OPEN_MEMSTREAM #ifdef __cplusplus extern "C" { #endif FILE* open_memstream(char** bufp, size_t* sizep); #ifdef __cplusplus } #endif #endif /*!HAVE_OPEN_MEMSTREAM*/ #endif /*__CUTILS_OPEN_MEMSTREAM_H__*/ android-headers-23/19/cutils/partition_utils.h000066400000000000000000000015271264465411000214770ustar00rootroot00000000000000/* * Copyright 2011, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __CUTILS_PARTITION_WIPED_H__ #define __CUTILS_PARTITION_WIPED_H__ __BEGIN_DECLS int partition_wiped(char *source); void erase_footer(const char *dev_path, long long size); __END_DECLS #endif /* __CUTILS_PARTITION_WIPED_H__ */ android-headers-23/19/cutils/process_name.h000066400000000000000000000020451264465411000207200ustar00rootroot00000000000000/* * 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. */ /** * Gives the current process a name. */ #ifndef __PROCESS_NAME_H #define __PROCESS_NAME_H #ifdef __cplusplus extern "C" { #endif /** * Sets the current process name. * * Warning: This leaks a string every time you call it. Use judiciously! */ void set_process_name(const char* process_name); /** Gets the current process name. */ const char* get_process_name(void); #ifdef __cplusplus } #endif #endif /* __PROCESS_NAME_H */ android-headers-23/19/cutils/properties.h000066400000000000000000000052611264465411000204410ustar00rootroot00000000000000/* * Copyright (C) 2006 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_PROPERTIES_H #define __CUTILS_PROPERTIES_H #include #include #include #ifdef __cplusplus extern "C" { #endif /* System properties are *small* name value pairs managed by the ** property service. If your data doesn't fit in the provided ** space it is not appropriate for a system property. ** ** WARNING: system/bionic/include/sys/system_properties.h also defines ** these, but with different names. (TODO: fix that) */ #define PROPERTY_KEY_MAX PROP_NAME_MAX #define PROPERTY_VALUE_MAX PROP_VALUE_MAX /* property_get: returns the length of the value which will never be ** greater than PROPERTY_VALUE_MAX - 1 and will always be zero terminated. ** (the length does not include the terminating zero). ** ** 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); /* 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); #if defined(__BIONIC_FORTIFY) 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"); __BIONIC_FORTIFY_INLINE int property_get(const char *key, char *value, const char *default_value) { size_t bos = __bos(value); if (bos < PROPERTY_VALUE_MAX) { __property_get_too_small_error(); } return __property_get_real(key, value, default_value); } #endif #ifdef HAVE_SYSTEM_PROPERTY_SERVER /* * We have an external property server instead of built-in libc support. * Used by the simulator. */ #define SYSTEM_PROPERTY_PIPE_NAME "/tmp/android-sysprop" enum { kSystemPropertyUnknown = 0, kSystemPropertyGet, kSystemPropertySet, kSystemPropertyList }; #endif /*HAVE_SYSTEM_PROPERTY_SERVER*/ #ifdef __cplusplus } #endif #endif android-headers-23/19/cutils/qtaguid.h000066400000000000000000000034501264465411000177010ustar00rootroot00000000000000/* * 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 __CUTILS_QTAGUID_H #define __CUTILS_QTAGUID_H #include #include #include #ifdef __cplusplus extern "C" { #endif /* * 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); /* * For the given uid, switch counter sets. * The kernel only keeps a limited number of sets. * 2 for now. */ 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 * then untagged. * The calling process can only operate on its own tags. * Unless it is part of the happy AID_NET_BW_ACCT group. * In which case it can clobber everything. */ extern int qtaguid_deleteTagData(int tag, uid_t uid); /* * Enable/disable qtaguid functionnality at a lower level. * When pacified, the kernel will accept commands but do nothing. */ extern int qtaguid_setPacifier(int on); #ifdef __cplusplus } #endif #endif /* __CUTILS_QTAG_UID_H */ android-headers-23/19/cutils/record_stream.h000066400000000000000000000022221264465411000210700ustar00rootroot00000000000000/* * Copyright (C) 2006 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. */ /* * A simple utility for reading fixed records out of a stream fd */ #ifndef _CUTILS_RECORD_STREAM_H #define _CUTILS_RECORD_STREAM_H #ifdef __cplusplus extern "C" { #endif typedef struct RecordStream RecordStream; extern RecordStream *record_stream_new(int fd, size_t maxRecordLen); extern void record_stream_free(RecordStream *p_rs); extern int record_stream_get_next (RecordStream *p_rs, void ** p_outRecord, size_t *p_outRecordLen); #ifdef __cplusplus } #endif #endif /*_CUTILS_RECORD_STREAM_H*/ android-headers-23/19/cutils/sched_policy.h000066400000000000000000000041301264465411000207040ustar00rootroot00000000000000/* * 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. */ #ifndef __CUTILS_SCHED_POLICY_H #define __CUTILS_SCHED_POLICY_H #ifdef __cplusplus extern "C" { #endif /* Keep in sync with THREAD_GROUP_* in frameworks/base/core/java/android/os/Process.java */ typedef enum { 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_CNT, SP_MAX = SP_CNT - 1, SP_SYSTEM_DEFAULT = SP_FOREGROUND, } SchedPolicy; /* Assign thread tid to the cgroup associated with the specified policy. * If the thread is a thread group leader, that is it's gettid() == getpid(), * then the other threads in the same thread group are _not_ affected. * On platforms which support gettid(), zero tid means current thread. * Return value: 0 for success, or -errno for error. */ extern int set_sched_policy(int tid, SchedPolicy policy); /* Return the policy associated with the cgroup of thread tid via policy pointer. * On platforms which support gettid(), zero tid means current thread. * Return value: 0 for success, or -1 for error and set errno. */ extern int get_sched_policy(int tid, SchedPolicy *policy); /* Return a displayable string corresponding to policy. * Return value: non-NULL NUL-terminated name of unspecified length; * the caller is responsible for displaying the useful part of the string. */ extern const char *get_sched_policy_name(SchedPolicy policy); #ifdef __cplusplus } #endif #endif /* __CUTILS_SCHED_POLICY_H */ android-headers-23/19/cutils/sockets.h000066400000000000000000000065571264465411000177310ustar00rootroot00000000000000/* * Copyright (C) 2006 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_SOCKETS_H #define __CUTILS_SOCKETS_H #include #include #include #include #ifdef HAVE_WINSOCK #include typedef int socklen_t; #elif HAVE_SYS_SOCKET_H #include #endif #define ANDROID_SOCKET_ENV_PREFIX "ANDROID_SOCKET_" #define ANDROID_SOCKET_DIR "/dev/socket" #ifdef __cplusplus extern "C" { #endif /* * 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] = ANDROID_SOCKET_ENV_PREFIX; const char *val; int fd; /* build our environment variable, counting cycles like a wolf ... */ #if HAVE_STRLCPY strlcpy(key + sizeof(ANDROID_SOCKET_ENV_PREFIX) - 1, name, sizeof(key) - sizeof(ANDROID_SOCKET_ENV_PREFIX)); #else /* for the host, which may lack the almightly strncpy ... */ strncpy(key + sizeof(ANDROID_SOCKET_ENV_PREFIX) - 1, name, sizeof(key) - sizeof(ANDROID_SOCKET_ENV_PREFIX)); key[sizeof(key)-1] = '\0'; #endif val = getenv(key); if (!val) return -1; errno = 0; fd = strtol(val, NULL, 10); if (errno) return -1; return fd; } /* * See also android.os.LocalSocketAddress.Namespace */ // Linux "abstract" (non-filesystem) namespace #define ANDROID_SOCKET_NAMESPACE_ABSTRACT 0 // Android "reserved" (/dev/socket) namespace #define ANDROID_SOCKET_NAMESPACE_RESERVED 1 // Normal filesystem namespace #define ANDROID_SOCKET_NAMESPACE_FILESYSTEM 2 extern int socket_loopback_client(int port, int type); extern int socket_network_client(const char *host, int port, int type); extern int socket_loopback_server(int port, int type); extern int socket_local_server(const char *name, int namespaceId, int type); extern int socket_local_server_bind(int s, const char *name, int namespaceId); extern int socket_local_client_connect(int fd, const char *name, int namespaceId, int type); extern int socket_local_client(const char *name, int namespaceId, int type); extern int socket_inaddr_any_server(int port, int type); /* * socket_peer_is_trusted - Takes a socket which is presumed to be a * connected local socket (e.g. AF_LOCAL) and returns whether the peer * (the userid that owns the process on the other end of that socket) * is one of the two trusted userids, root or shell. * * Note: This only works as advertised on the Android OS and always * just returns true when called on other operating systems. */ extern bool socket_peer_is_trusted(int fd); #ifdef __cplusplus } #endif #endif /* __CUTILS_SOCKETS_H */ android-headers-23/19/cutils/str_parms.h000066400000000000000000000032771264465411000202640ustar00rootroot00000000000000/* * 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 __CUTILS_STR_PARMS_H #define __CUTILS_STR_PARMS_H #include struct str_parms; struct str_parms *str_parms_create(void); struct str_parms *str_parms_create_str(const char *_string); void str_parms_destroy(struct str_parms *str_parms); void str_parms_del(struct str_parms *str_parms, const char *key); int str_parms_add_str(struct str_parms *str_parms, const char *key, const char *value); int str_parms_add_int(struct str_parms *str_parms, const char *key, int value); int str_parms_add_float(struct str_parms *str_parms, const char *key, float value); int str_parms_get_str(struct str_parms *str_parms, const char *key, char *out_val, int len); int str_parms_get_int(struct str_parms *str_parms, const char *key, int *out_val); int str_parms_get_float(struct str_parms *str_parms, const char *key, float *out_val); char *str_parms_to_str(struct str_parms *str_parms); /* debug */ void str_parms_dump(struct str_parms *str_parms); #endif /* __CUTILS_STR_PARMS_H */ android-headers-23/19/cutils/threads.h000066400000000000000000000077331264465411000177050ustar00rootroot00000000000000/* * 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. */ #ifndef _LIBS_CUTILS_THREADS_H #define _LIBS_CUTILS_THREADS_H #ifdef __cplusplus extern "C" { #endif /***********************************************************************/ /***********************************************************************/ /***** *****/ /***** local thread storage *****/ /***** *****/ /***********************************************************************/ /***********************************************************************/ #ifdef HAVE_PTHREADS #include typedef struct { pthread_mutex_t lock; int has_tls; pthread_key_t tls; } thread_store_t; #define THREAD_STORE_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, 0, 0 } #elif defined HAVE_WIN32_THREADS #include typedef struct { int lock_init; int has_tls; DWORD tls; CRITICAL_SECTION lock; } thread_store_t; #define THREAD_STORE_INITIALIZER { 0, 0, 0, {0, 0, 0, 0, 0, 0} } #else # error "no thread_store_t implementation for your platform !!" #endif typedef void (*thread_store_destruct_t)(void* value); extern void* thread_store_get(thread_store_t* store); extern void thread_store_set(thread_store_t* store, void* value, thread_store_destruct_t destroy); /***********************************************************************/ /***********************************************************************/ /***** *****/ /***** mutexes *****/ /***** *****/ /***********************************************************************/ /***********************************************************************/ #ifdef HAVE_PTHREADS typedef pthread_mutex_t mutex_t; #define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER static __inline__ void mutex_lock(mutex_t* lock) { pthread_mutex_lock(lock); } static __inline__ void mutex_unlock(mutex_t* lock) { pthread_mutex_unlock(lock); } static __inline__ int mutex_init(mutex_t* lock) { return pthread_mutex_init(lock, NULL); } static __inline__ void mutex_destroy(mutex_t* lock) { pthread_mutex_destroy(lock); } #endif #ifdef HAVE_WIN32_THREADS typedef struct { int init; CRITICAL_SECTION lock[1]; } mutex_t; #define MUTEX_INITIALIZER { 0, {{ NULL, 0, 0, NULL, NULL, 0 }} } static __inline__ void mutex_lock(mutex_t* lock) { if (!lock->init) { lock->init = 1; InitializeCriticalSection( lock->lock ); lock->init = 2; } else while (lock->init != 2) Sleep(10); EnterCriticalSection(lock->lock); } static __inline__ void mutex_unlock(mutex_t* lock) { LeaveCriticalSection(lock->lock); } static __inline__ int mutex_init(mutex_t* lock) { InitializeCriticalSection(lock->lock); lock->init = 2; return 0; } static __inline__ void mutex_destroy(mutex_t* lock) { if (lock->init) { lock->init = 0; DeleteCriticalSection(lock->lock); } } #endif #ifdef __cplusplus } #endif #endif /* _LIBS_CUTILS_THREADS_H */ android-headers-23/19/cutils/trace.h000066400000000000000000000231151264465411000173410ustar00rootroot00000000000000/* * 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 _LIBS_CUTILS_TRACE_H #define _LIBS_CUTILS_TRACE_H #include #include #include #include #include #include #ifdef ANDROID_SMP #include #else #include #endif __BEGIN_DECLS /** * The ATRACE_TAG macro can be defined before including this header to trace * using one of the tags defined below. It must be defined to one of the * following ATRACE_TAG_* macros. The trace tag is used to filter tracing in * userland to avoid some of the runtime cost of tracing when it is not desired. * * Defining ATRACE_TAG to be ATRACE_TAG_ALWAYS will result in the tracing always * being enabled - this should ONLY be done for debug code, as userland tracing * has a performance cost even when the trace is not being recorded. Defining * ATRACE_TAG to be ATRACE_TAG_NEVER or leaving ATRACE_TAG undefined will result * in the tracing always being disabled. * * ATRACE_TAG_HAL should be bitwise ORed with the relevant tags for tracing * within a hardware module. For example a camera hardware module would set: * #define ATRACE_TAG (ATRACE_TAG_CAMERA | ATRACE_TAG_HAL) * * Keep these in sync with frameworks/base/core/java/android/os/Trace.java. */ #define ATRACE_TAG_NEVER 0 // This tag is never enabled. #define ATRACE_TAG_ALWAYS (1<<0) // This tag is always enabled. #define ATRACE_TAG_GRAPHICS (1<<1) #define ATRACE_TAG_INPUT (1<<2) #define ATRACE_TAG_VIEW (1<<3) #define ATRACE_TAG_WEBVIEW (1<<4) #define ATRACE_TAG_WINDOW_MANAGER (1<<5) #define ATRACE_TAG_ACTIVITY_MANAGER (1<<6) #define ATRACE_TAG_SYNC_MANAGER (1<<7) #define ATRACE_TAG_AUDIO (1<<8) #define ATRACE_TAG_VIDEO (1<<9) #define ATRACE_TAG_CAMERA (1<<10) #define ATRACE_TAG_HAL (1<<11) #define ATRACE_TAG_APP (1<<12) #define ATRACE_TAG_RESOURCES (1<<13) #define ATRACE_TAG_DALVIK (1<<14) #define ATRACE_TAG_RS (1<<15) #define ATRACE_TAG_LAST ATRACE_TAG_RS // Reserved for initialization. #define ATRACE_TAG_NOT_READY (1LL<<63) #define ATRACE_TAG_VALID_MASK ((ATRACE_TAG_LAST - 1) | ATRACE_TAG_LAST) #ifndef ATRACE_TAG #define ATRACE_TAG ATRACE_TAG_NEVER #elif ATRACE_TAG > ATRACE_TAG_VALID_MASK #error ATRACE_TAG must be defined to be one of the tags defined in cutils/trace.h #endif #ifdef HAVE_ANDROID_OS /** * Maximum size of a message that can be logged to the trace buffer. * Note this message includes a tag, the pid, and the string given as the name. * Names should be kept short to get the most use of the trace buffer. */ #define ATRACE_MESSAGE_LENGTH 1024 /** * Opens the trace file for writing and reads the property for initial tags. * The atrace.tags.enableflags property sets the tags to trace. * This function should not be explicitly called, the first call to any normal * trace function will cause it to be run safely. */ void atrace_setup(); /** * If tracing is ready, set atrace_enabled_tags to the system property * debug.atrace.tags.enableflags. Can be used as a sysprop change callback. */ void atrace_update_tags(); /** * Set whether the process is debuggable. By default the process is not * considered debuggable. If the process is not debuggable then application- * level tracing is not allowed unless the ro.debuggable system property is * set to '1'. */ void atrace_set_debuggable(bool debuggable); /** * Set whether tracing is enabled for the current process. This is used to * prevent tracing within the Zygote process. */ void atrace_set_tracing_enabled(bool enabled); /** * Flag indicating whether setup has been completed, initialized to 0. * Nonzero indicates setup has completed. * Note: This does NOT indicate whether or not setup was successful. */ extern volatile int32_t atrace_is_ready; /** * Set of ATRACE_TAG flags to trace for, initialized to ATRACE_TAG_NOT_READY. * A value of zero indicates setup has failed. * Any other nonzero value indicates setup has succeeded, and tracing is on. */ extern uint64_t atrace_enabled_tags; /** * Handle to the kernel's trace buffer, initialized to -1. * Any other value indicates setup has succeeded, and is a valid fd for tracing. */ extern int atrace_marker_fd; /** * atrace_init readies the process for tracing by opening the trace_marker file. * Calling any trace function causes this to be run, so calling it is optional. * This can be explicitly run to avoid setup delay on first trace function. */ #define ATRACE_INIT() atrace_init() static inline void atrace_init() { if (CC_UNLIKELY(!android_atomic_acquire_load(&atrace_is_ready))) { atrace_setup(); } } /** * Get the mask of all tags currently enabled. * It can be used as a guard condition around more expensive trace calculations. * Every trace function calls this, which ensures atrace_init is run. */ #define ATRACE_GET_ENABLED_TAGS() atrace_get_enabled_tags() static inline uint64_t atrace_get_enabled_tags() { atrace_init(); return atrace_enabled_tags; } /** * Test if a given tag is currently enabled. * Returns nonzero if the tag is enabled, otherwise zero. * It can be used as a guard condition around more expensive trace calculations. */ #define ATRACE_ENABLED() atrace_is_tag_enabled(ATRACE_TAG) static inline uint64_t atrace_is_tag_enabled(uint64_t tag) { return atrace_get_enabled_tags() & tag; } /** * Trace the beginning of a context. name is used to identify the context. * This is often used to time function execution. */ #define ATRACE_BEGIN(name) atrace_begin(ATRACE_TAG, name) static inline void atrace_begin(uint64_t tag, const char* name) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { char buf[ATRACE_MESSAGE_LENGTH]; size_t len; len = snprintf(buf, ATRACE_MESSAGE_LENGTH, "B|%d|%s", getpid(), name); write(atrace_marker_fd, buf, len); } } /** * Trace the end of a context. * This should match up (and occur after) a corresponding ATRACE_BEGIN. */ #define ATRACE_END() atrace_end(ATRACE_TAG) 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); } } /** * Trace the beginning of an asynchronous event. Unlike ATRACE_BEGIN/ATRACE_END * contexts, asynchronous events do not need to be nested. The name describes * the event, and the cookie provides a unique identifier for distinguishing * simultaneous events. The name and cookie used to begin an event must be * used to end it. */ #define ATRACE_ASYNC_BEGIN(name, cookie) \ atrace_async_begin(ATRACE_TAG, name, cookie) static inline void atrace_async_begin(uint64_t tag, const char* name, int32_t cookie) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { char buf[ATRACE_MESSAGE_LENGTH]; size_t len; len = snprintf(buf, ATRACE_MESSAGE_LENGTH, "S|%d|%s|%d", getpid(), name, cookie); write(atrace_marker_fd, buf, len); } } /** * Trace the end of an asynchronous event. * This should have a corresponding ATRACE_ASYNC_BEGIN. */ #define ATRACE_ASYNC_END(name, cookie) atrace_async_end(ATRACE_TAG, name, cookie) static inline void atrace_async_end(uint64_t tag, const char* name, int32_t cookie) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { char buf[ATRACE_MESSAGE_LENGTH]; size_t len; len = snprintf(buf, ATRACE_MESSAGE_LENGTH, "F|%d|%s|%d", getpid(), name, cookie); write(atrace_marker_fd, buf, len); } } /** * Traces an integer counter value. name is used to identify the counter. * This can be used to track how a value changes over time. */ #define ATRACE_INT(name, value) atrace_int(ATRACE_TAG, name, value) static inline void atrace_int(uint64_t tag, const char* name, int32_t value) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { char buf[ATRACE_MESSAGE_LENGTH]; size_t len; len = snprintf(buf, ATRACE_MESSAGE_LENGTH, "C|%d|%s|%d", getpid(), name, value); write(atrace_marker_fd, buf, len); } } /** * Traces a 64-bit integer counter value. name is used to identify the * counter. This can be used to track how a value changes over time. */ #define ATRACE_INT64(name, value) atrace_int64(ATRACE_TAG, name, value) static inline void atrace_int64(uint64_t tag, const char* name, int64_t value) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { char buf[ATRACE_MESSAGE_LENGTH]; size_t len; len = snprintf(buf, ATRACE_MESSAGE_LENGTH, "C|%d|%s|%lld", getpid(), name, value); write(atrace_marker_fd, buf, len); } } #else // not HAVE_ANDROID_OS #define ATRACE_INIT() #define ATRACE_GET_ENABLED_TAGS() #define ATRACE_ENABLED() 0 #define ATRACE_BEGIN(name) #define ATRACE_END() #define ATRACE_ASYNC_BEGIN(name, cookie) #define ATRACE_ASYNC_END(name, cookie) #define ATRACE_INT(name, value) #endif // not HAVE_ANDROID_OS __END_DECLS #endif // _LIBS_CUTILS_TRACE_H android-headers-23/19/cutils/tztime.h000066400000000000000000000014411264465411000175550ustar00rootroot00000000000000/* * Copyright (C) 2006 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_TZTIME_H #define _CUTILS_TZTIME_H // TODO: fix both callers to just include themselves. #include #endif /* __CUTILS_TZTIME_H */ android-headers-23/19/cutils/uevent.h000066400000000000000000000020261264465411000175470ustar00rootroot00000000000000/* * 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 __CUTILS_UEVENT_H #define __CUTILS_UEVENT_H #include #include #ifdef __cplusplus extern "C" { #endif int uevent_open_socket(int buf_sz, bool passcred); ssize_t uevent_kernel_multicast_recv(int socket, void *buffer, size_t length); ssize_t uevent_kernel_multicast_uid_recv(int socket, void *buffer, size_t length, uid_t *uid); #ifdef __cplusplus } #endif #endif /* __CUTILS_UEVENT_H */ android-headers-23/19/hardware/000077500000000000000000000000001264465411000163625ustar00rootroot00000000000000android-headers-23/19/hardware/audio.h000066400000000000000000000537451264465411000176520ustar00rootroot00000000000000/* * 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_AUDIO_HAL_INTERFACE_H #define ANDROID_AUDIO_HAL_INTERFACE_H #include #include #include #include #include #include #include #include __BEGIN_DECLS /** * The id of this module */ #define AUDIO_HARDWARE_MODULE_ID "audio" /** * Name of the audio devices to open */ #define AUDIO_HARDWARE_INTERFACE "audio_hw_if" /* Use version 0.1 to be compatible with first generation of audio hw module with version_major * hardcoded to 1. No audio module API change. */ #define AUDIO_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define AUDIO_MODULE_API_VERSION_CURRENT AUDIO_MODULE_API_VERSION_0_1 /* First generation of audio devices had version hardcoded to 0. all devices with versions < 1.0 * will be considered of first generation API. */ #define AUDIO_DEVICE_API_VERSION_0_0 HARDWARE_DEVICE_API_VERSION(0, 0) #define AUDIO_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) #define AUDIO_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 0) #define AUDIO_DEVICE_API_VERSION_CURRENT 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" /**************************************/ /** * standard audio parameters that the HAL may need to handle */ /** * 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" #define AUDIO_PARAMETER_VALUE_TTY_VCO "tty_vco" #define AUDIO_PARAMETER_VALUE_TTY_HCO "tty_hco" #define AUDIO_PARAMETER_VALUE_TTY_FULL "tty_full" /* A2DP sink address set by framework */ #define AUDIO_PARAMETER_A2DP_SINK_ADDRESS "a2dp_sink_address" /* 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 /* 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" /** * 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" /**************************************/ /* common audio stream configuration parameters * You should memset() the entire structure to zero before use to * ensure forward compatibility */ struct audio_config { uint32_t sample_rate; audio_channel_mask_t channel_mask; audio_format_t format; audio_offload_info_t offload_info; }; typedef struct audio_config audio_config_t; /* common audio stream parameters and operations */ struct audio_stream { /** * Return the sampling rate in Hz - eg. 44100. */ uint32_t (*get_sample_rate)(const struct audio_stream *stream); /* currently unused - use set_parameters with key * AUDIO_PARAMETER_STREAM_SAMPLING_RATE */ int (*set_sample_rate)(struct audio_stream *stream, uint32_t rate); /** * Return size of input/output buffer in bytes for this stream - eg. 4800. * It should be a multiple of the frame size. See also get_input_buffer_size. */ size_t (*get_buffer_size)(const struct audio_stream *stream); /** * Return the channel mask - * e.g. AUDIO_CHANNEL_OUT_STEREO or AUDIO_CHANNEL_IN_STEREO */ audio_channel_mask_t (*get_channels)(const struct audio_stream *stream); /** * Return the audio format - e.g. AUDIO_FORMAT_PCM_16_BIT */ audio_format_t (*get_format)(const struct audio_stream *stream); /* currently unused - use set_parameters with key * AUDIO_PARAMETER_STREAM_FORMAT */ int (*set_format)(struct audio_stream *stream, audio_format_t format); /** * Put the audio hardware input/output into standby mode. * Driver should exit from standby mode at the next I/O operation. * Returns 0 on success and <0 on failure. */ int (*standby)(struct audio_stream *stream); /** dump the state of the audio input/output device */ int (*dump)(const struct audio_stream *stream, int fd); /** Return the set of device(s) which this stream is connected to */ audio_devices_t (*get_device)(const struct audio_stream *stream); /** * Currently unused - set_device() corresponds to set_parameters() with key * AUDIO_PARAMETER_STREAM_ROUTING for both input and output. * AUDIO_PARAMETER_STREAM_INPUT_SOURCE is an additional information used by * input streams only. */ int (*set_device)(struct audio_stream *stream, audio_devices_t device); /** * set/get audio stream parameters. The function accepts a list of * parameter key value pairs in the form: key1=value1;key2=value2;... * * Some keys are reserved for standard parameters (See AudioParameter class) * * If the implementation does not accept a parameter change while * the output is active but the parameter is acceptable otherwise, it must * return -ENOSYS. * * The audio flinger will put the stream in standby and then change the * parameter value. */ int (*set_parameters)(struct audio_stream *stream, const char *kv_pairs); /* * Returns a pointer to a heap allocated string. The caller is responsible * for freeing the memory for it using free(). */ char * (*get_parameters)(const struct audio_stream *stream, const char *keys); int (*add_audio_effect)(const struct audio_stream *stream, effect_handle_t effect); int (*remove_audio_effect)(const struct audio_stream *stream, effect_handle_t effect); }; typedef struct audio_stream audio_stream_t; /* type of asynchronous write callback events. Mutually exclusive */ typedef enum { STREAM_CBK_EVENT_WRITE_READY, /* non blocking write completed */ STREAM_CBK_EVENT_DRAIN_READY /* drain completed */ } stream_callback_event_t; typedef int (*stream_callback_t)(stream_callback_event_t event, void *param, void *cookie); /* type of drain requested to audio_stream_out->drain(). Mutually exclusive */ typedef enum { AUDIO_DRAIN_ALL, /* drain() returns when all data has been played */ AUDIO_DRAIN_EARLY_NOTIFY /* drain() returns a short time before all data from the current track has been played to give time for gapless track switch */ } audio_drain_type_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 { struct audio_stream common; /** * Return the audio hardware driver estimated latency in milliseconds. */ uint32_t (*get_latency)(const struct audio_stream_out *stream); /** * Use this method in situations where audio mixing is done in the * hardware. This method serves as a direct interface with hardware, * allowing you to directly set the volume as apposed to via the framework. * This method might produce multiple PCM outputs or hardware accelerated * codecs, such as MP3 or AAC. */ int (*set_volume)(struct audio_stream_out *stream, float left, float right); /** * Write audio buffer to driver. Returns number of bytes written, or a * negative status_t. If at least one frame was written successfully prior to the error, * it is suggested that the driver return that successful (short) byte count * and then return an error in the subsequent call. * * If set_callback() has previously been called to enable non-blocking mode * the write() is not allowed to block. It must write only the number of * bytes that currently fit in the driver/hardware buffer and then return * this byte count. If this is less than the requested write size the * callback function must be called when more space is available in the * driver/hardware buffer. */ ssize_t (*write)(struct audio_stream_out *stream, const void* buffer, size_t bytes); /* return the number of audio frames written by the audio dsp to DAC since * the output has exited standby */ int (*get_render_position)(const struct audio_stream_out *stream, uint32_t *dsp_frames); /** * get the local time at which the next write to the audio driver will be presented. * The units are microseconds, where the epoch is decided by the local audio HAL. */ int (*get_next_write_timestamp)(const struct audio_stream_out *stream, int64_t *timestamp); /** * set the callback function for notifying completion of non-blocking * write and drain. * Calling this function implies that all future write() and drain() * must be non-blocking and use the callback to signal completion. */ int (*set_callback)(struct audio_stream_out *stream, stream_callback_t callback, void *cookie); /** * Notifies to the audio driver to stop playback however the queued buffers are * retained by the hardware. Useful for implementing pause/resume. Empty implementation * if not supported however should be implemented for hardware with non-trivial * latency. In the pause state audio hardware could still be using power. User may * consider calling suspend after a timeout. * * Implementation of this function is mandatory for offloaded playback. */ int (*pause)(struct audio_stream_out* stream); /** * Notifies to the audio driver to resume playback following a pause. * Returns error if called without matching pause. * * Implementation of this function is mandatory for offloaded playback. */ int (*resume)(struct audio_stream_out* stream); /** * Requests notification when data buffered by the driver/hardware has * been played. If set_callback() has previously been called to enable * non-blocking mode, the drain() must not block, instead it should return * quickly and completion of the drain is notified through the callback. * If set_callback() has not been called, the drain() must block until * completion. * If type==AUDIO_DRAIN_ALL, the drain completes when all previously written * data has been played. * If type==AUDIO_DRAIN_EARLY_NOTIFY, the drain completes shortly before all * data for the current track has played to allow time for the framework * to perform a gapless track switch. * * Drain must return immediately on stop() and flush() call * * Implementation of this function is mandatory for offloaded playback. */ int (*drain)(struct audio_stream_out* stream, audio_drain_type_t type ); /** * Notifies to the audio driver to flush the queued data. Stream must already * be paused before calling flush(). * * Implementation of this function is mandatory for offloaded playback. */ int (*flush)(struct audio_stream_out* stream); /** * Return a recent count of the number of audio frames presented to an external observer. * This excludes frames which have been written but are still in the pipeline. * The count is not reset to zero when output enters standby. * Also returns the value of CLOCK_MONOTONIC as of this presentation count. * The returned count is expected to be 'recent', * but does not need to be the most recent possible value. * However, the associated time should correspond to whatever count is returned. * Example: assume that N+M frames have been presented, where M is a 'small' number. * Then it is permissible to return N instead of N+M, * and the timestamp should correspond to N rather than N+M. * The terms 'recent' and 'small' are not defined. * They reflect the quality of the implementation. * * 3.0 and higher only. */ int (*get_presentation_position)(const struct audio_stream_out *stream, uint64_t *frames, struct timespec *timestamp); }; typedef struct audio_stream_out audio_stream_out_t; struct audio_stream_in { struct audio_stream common; /** set the input gain for the audio driver. This method is for * for future use */ int (*set_gain)(struct audio_stream_in *stream, float gain); /** Read audio buffer in from audio driver. Returns number of bytes read, or a * negative status_t. If at least one frame was read prior to the error, * read should return that byte count and then return an error in the subsequent call. */ ssize_t (*read)(struct audio_stream_in *stream, void* buffer, size_t bytes); /** * Return the amount of input frames lost in the audio driver since the * last call of this function. * Audio driver is expected to reset the value to 0 and restart counting * upon returning the current value by this function call. * Such loss typically occurs when the user space process is blocked * longer than the capacity of audio driver buffers. * * Unit: the number of input audio frames */ uint32_t (*get_input_frames_lost)(struct audio_stream_in *stream); }; typedef struct audio_stream_in audio_stream_in_t; /** * return the frame size (number of bytes per sample). */ static inline size_t audio_stream_frame_size(const struct audio_stream *s) { size_t chan_samp_sz; audio_format_t format = s->get_format(s); if (audio_is_linear_pcm(format)) { chan_samp_sz = audio_bytes_per_sample(format); return popcount(s->get_channels(s)) * chan_samp_sz; } return sizeof(int8_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. */ struct audio_module { struct hw_module_t common; }; struct audio_hw_device { struct hw_device_t common; /** * used by audio flinger to enumerate what devices are supported by * each audio_hw_device implementation. * * Return value is a bitmask of 1 or more values of audio_devices_t * * NOTE: audio HAL implementations starting with * AUDIO_DEVICE_API_VERSION_2_0 do not implement this function. * All supported devices should be listed in audio_policy.conf * file and the audio policy manager must choose the appropriate * audio module based on information in this file. */ uint32_t (*get_supported_devices)(const struct audio_hw_device *dev); /** * check to see if the audio hardware interface has been initialized. * returns 0 on success, -ENODEV on failure. */ int (*init_check)(const struct audio_hw_device *dev); /** set the audio volume of a voice call. Range is between 0.0 and 1.0 */ int (*set_voice_volume)(struct audio_hw_device *dev, float volume); /** * set the audio volume for all audio activities other than voice call. * Range between 0.0 and 1.0. If any value other than 0 is returned, * the software mixer will emulate this capability. */ int (*set_master_volume)(struct audio_hw_device *dev, float volume); /** * Get the current master volume value for the HAL, if the HAL supports * master volume control. AudioFlinger will query this value from the * primary audio HAL when the service starts and use the value for setting * the initial master volume across all HALs. HALs which do not support * this method may leave it set to NULL. */ int (*get_master_volume)(struct audio_hw_device *dev, float *volume); /** * set_mode is called when the audio mode changes. AUDIO_MODE_NORMAL mode * is for standard audio playback, AUDIO_MODE_RINGTONE when a ringtone is * playing, and AUDIO_MODE_IN_CALL when a call is in progress. */ int (*set_mode)(struct audio_hw_device *dev, audio_mode_t mode); /* mic mute */ int (*set_mic_mute)(struct audio_hw_device *dev, bool state); int (*get_mic_mute)(const struct audio_hw_device *dev, bool *state); /* set/get global audio parameters */ int (*set_parameters)(struct audio_hw_device *dev, const char *kv_pairs); /* * Returns a pointer to a heap allocated string. The caller is responsible * for freeing the memory for it using free(). */ char * (*get_parameters)(const struct audio_hw_device *dev, const char *keys); /* Returns audio input buffer size according to parameters passed or * 0 if one of the parameters is not supported. * See also get_buffer_size which is for a particular stream. */ size_t (*get_input_buffer_size)(const struct audio_hw_device *dev, const struct audio_config *config); /** This method creates and opens the audio hardware output stream */ int (*open_output_stream)(struct audio_hw_device *dev, audio_io_handle_t handle, audio_devices_t devices, audio_output_flags_t flags, struct audio_config *config, struct audio_stream_out **stream_out); void (*close_output_stream)(struct audio_hw_device *dev, struct audio_stream_out* stream_out); /** This method creates and opens the audio hardware input stream */ int (*open_input_stream)(struct audio_hw_device *dev, audio_io_handle_t handle, audio_devices_t devices, struct audio_config *config, struct audio_stream_in **stream_in); void (*close_input_stream)(struct audio_hw_device *dev, struct audio_stream_in *stream_in); /** This method dumps the state of the audio hardware */ int (*dump)(const struct audio_hw_device *dev, int fd); /** * set the audio mute status for all audio activities. If any value other * than 0 is returned, the software mixer will emulate this capability. */ int (*set_master_mute)(struct audio_hw_device *dev, bool mute); /** * Get the current master mute status for the HAL, if the HAL supports * master mute control. AudioFlinger will query this value from the primary * audio HAL when the service starts and use the value for setting the * initial master mute across all HALs. HALs which do not support this * method may leave it set to NULL. */ int (*get_master_mute)(struct audio_hw_device *dev, bool *mute); }; typedef struct audio_hw_device audio_hw_device_t; /** convenience API for opening and closing a supported device */ 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); } static inline int audio_hw_device_close(struct audio_hw_device* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_AUDIO_INTERFACE_H android-headers-23/19/hardware/audio_effect.h000066400000000000000000001476741264465411000211730ustar00rootroot00000000000000/* * 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_AUDIO_EFFECT_H #define ANDROID_AUDIO_EFFECT_H #include #include #include #include #include #include #include __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 // +---------------------------+-----------+----------------------------------- // 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) #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 ///////////////////////////////////////////////// // Effect control interface version 2.0 #define EFFECT_CONTROL_API_VERSION EFFECT_MAKE_API_VERSION(2,0) // Effect control interface structure: effect_interface_s // The effect control interface is exposed by each effect engine implementation. It consists of // a set of functions controlling the configuration, activation and process of the engine. // The functions are grouped in a structure of type effect_interface_s. // // Effect control interface handle: effect_handle_t // The effect_handle_t serves two purposes regarding the implementation of the effect engine: // - 1 it is the address of a pointer to an effect_interface_s structure where the functions // of the effect control API for a particular effect are located. // - 2 it is the address of the context of a particular effect instance. // A typical implementation in the effect library would define a structure as follows: // struct effect_module_s { // const struct effect_interface_s *itfe; // effect_config_t config; // effect_context_t context; // } // The implementation of EffectCreate() function would then allocate a structure of this // 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 { //////////////////////////////////////////////////////////////////////////////// // // Function: process // // Description: Effect process function. Takes input samples as specified // (count and location) in input buffer descriptor and output processed // samples as specified in output buffer descriptor. If the buffer descriptor // is not specified the function must use either the buffer or the // buffer provider function installed by the EFFECT_CMD_SET_CONFIG command. // The effect framework will call the process() function after the EFFECT_CMD_ENABLE // command is received and until the EFFECT_CMD_DISABLE is received. When the engine // receives the EFFECT_CMD_DISABLE command it should turn off the effect gracefully // and when done indicate that it is OK to stop calling the process() function by // returning the -ENODATA status. // // NOTE: the process() function implementation should be "real-time safe" that is // it should not perform blocking calls: malloc/free, sleep, read/write/open/close, // pthread_cond_wait/pthread_mutex_lock... // // Input: // self: handle to the effect interface this function // is called on. // inBuffer: buffer descriptor indicating where to read samples to process. // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG command. // // outBuffer: buffer descriptor indicating where to write processed samples. // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG command. // // Output: // returned value: 0 successful operation // -ENODATA the engine has finished the disable phase and the framework // can stop calling process() // -EINVAL invalid interface handle or // invalid input/output buffer description //////////////////////////////////////////////////////////////////////////////// int32_t (*process)(effect_handle_t self, audio_buffer_t *inBuffer, audio_buffer_t *outBuffer); //////////////////////////////////////////////////////////////////////////////// // // Function: command // // Description: Send a command and receive a response to/from effect engine. // // Input: // self: handle to the effect interface this function // is called on. // cmdCode: command code: the command can be a standardized command defined in // effect_command_e (see below) or a proprietary command. // cmdSize: size of command in bytes // pCmdData: pointer to command data // pReplyData: pointer to reply data // // Input/Output: // replySize: maximum size of reply data as input // actual size of reply data as output // // Output: // returned value: 0 successful operation // -EINVAL invalid interface handle or // invalid command/reply size or format according to command code // The return code should be restricted to indicate problems related to the this // API specification. Status related to the execution of a particular command should be // indicated as part of the reply field. // // *pReplyData updated with command response // //////////////////////////////////////////////////////////////////////////////// int32_t (*command)(effect_handle_t self, uint32_t cmdCode, uint32_t cmdSize, void *pCmdData, uint32_t *replySize, void *pReplyData); //////////////////////////////////////////////////////////////////////////////// // // Function: get_descriptor // // Description: Returns the effect descriptor // // Input: // self: handle to the effect interface this function // is called on. // // Input/Output: // pDescriptor: address where to return the effect descriptor. // // Output: // returned value: 0 successful operation. // -EINVAL invalid interface handle or invalid pDescriptor // *pDescriptor: updated with the effect descriptor. // //////////////////////////////////////////////////////////////////////////////// int32_t (*get_descriptor)(effect_handle_t self, effect_descriptor_t *pDescriptor); //////////////////////////////////////////////////////////////////////////////// // // Function: process_reverse // // Description: Process reverse stream function. This function is used to pass // a reference stream to the effect engine. If the engine does not need a reference // stream, this function pointer can be set to NULL. // This function would typically implemented by an Echo Canceler. // // Input: // self: handle to the effect interface this function // is called on. // inBuffer: buffer descriptor indicating where to read samples to process. // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG_REVERSE command. // // outBuffer: buffer descriptor indicating where to write processed samples. // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG_REVERSE command. // If the buffer and buffer provider in the configuration received by // EFFECT_CMD_SET_CONFIG_REVERSE are also NULL, do not return modified reverse // stream data // // Output: // returned value: 0 successful operation // -ENODATA the engine has finished the disable phase and the framework // can stop calling process_reverse() // -EINVAL invalid interface handle or // invalid input/output buffer description //////////////////////////////////////////////////////////////////////////////// int32_t (*process_reverse)(effect_handle_t self, audio_buffer_t *inBuffer, 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 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; // 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 ///////////////////////////////////////////////// // Effect library interface version 3.0 // Note that EffectsFactory.c only checks the major version component, so changes to the minor // number can only be used for fully backwards compatible changes #define EFFECT_LIBRARY_API_VERSION EFFECT_MAKE_API_VERSION(3,0) #define AUDIO_EFFECT_LIBRARY_TAG ((('A') << 24) | (('E') << 16) | (('L') << 8) | ('T')) // Every effect library must have a data structure named AUDIO_EFFECT_LIBRARY_INFO_SYM // and the fields of this data structure must begin with audio_effect_library_t typedef struct audio_effect_library_s { // tag must be initialized to AUDIO_EFFECT_LIBRARY_TAG uint32_t tag; // Version of the effect library API : 0xMMMMmmmm MMMM: Major, mmmm: minor uint32_t version; // Name of this library const char *name; // Author/owner/implementor of the library const char *implementor; //////////////////////////////////////////////////////////////////////////////// // // Function: create_effect // // Description: Creates an effect engine of the specified implementation uuid and // returns an effect control interface on this engine. The function will allocate the // resources for an instance of the requested effect engine and return // a handle on the effect control interface. // // Input: // uuid: pointer to the effect uuid. // sessionId: audio session to which this effect instance will be attached. All effects // created with the same session ID are connected in series and process the same signal // stream. Knowing that two effects are part of the same effect chain can help the // library implement some kind of optimizations. // ioId: identifies the output or input stream this effect is directed to at audio HAL. // For future use especially with tunneled HW accelerated effects // // Input/Output: // pHandle: address where to return the effect interface handle. // // Output: // returned value: 0 successful operation. // -ENODEV library failed to initialize // -EINVAL invalid pEffectUuid or pHandle // -ENOENT no effect with this uuid found // *pHandle: updated with the effect interface handle. // //////////////////////////////////////////////////////////////////////////////// int32_t (*create_effect)(const effect_uuid_t *uuid, int32_t sessionId, int32_t ioId, effect_handle_t *pHandle); //////////////////////////////////////////////////////////////////////////////// // // Function: release_effect // // Description: Releases the effect engine whose handle is given as argument. // All resources allocated to this particular instance of the effect are // released. // // Input: // handle: handle on the effect interface to be released. // // Output: // returned value: 0 successful operation. // -ENODEV library failed to initialize // -EINVAL invalid interface handle // //////////////////////////////////////////////////////////////////////////////// int32_t (*release_effect)(effect_handle_t handle); //////////////////////////////////////////////////////////////////////////////// // // Function: get_descriptor // // Description: Returns the descriptor of the effect engine which implementation UUID is // given as argument. // // Input/Output: // uuid: pointer to the effect uuid. // pDescriptor: address where to return the effect descriptor. // // Output: // returned value: 0 successful operation. // -ENODEV library failed to initialize // -EINVAL invalid pDescriptor or uuid // *pDescriptor: updated with the effect descriptor. // //////////////////////////////////////////////////////////////////////////////// int32_t (*get_descriptor)(const effect_uuid_t *uuid, effect_descriptor_t *pDescriptor); } audio_effect_library_t; // Name of the hal_module_info #define AUDIO_EFFECT_LIBRARY_INFO_SYM AELI // Name of the hal_module_info as a string #define AUDIO_EFFECT_LIBRARY_INFO_SYM_AS_STR "AELI" __END_DECLS #endif // ANDROID_AUDIO_EFFECT_H android-headers-23/19/hardware/audio_policy.h000066400000000000000000000450061264465411000212200ustar00rootroot00000000000000/* * 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_AUDIO_POLICY_INTERFACE_H #define ANDROID_AUDIO_POLICY_INTERFACE_H #include #include #include #include #include #include __BEGIN_DECLS /** * The id of this module */ #define AUDIO_POLICY_HARDWARE_MODULE_ID "audio_policy" /** * Name of the audio devices to open */ #define AUDIO_POLICY_INTERFACE "policy" /* ---------------------------------------------------------------------------- */ /* * The audio_policy and audio_policy_service_ops structs define the * communication interfaces between the platform specific audio policy manager * and Android generic audio policy manager. * The platform specific audio policy manager must implement methods of the * audio_policy struct. * This implementation makes use of the audio_policy_service_ops to control * the activity and configuration of audio input and output streams. * * The platform specific audio policy manager is in charge of the audio * routing and volume control policies for a given platform. * The main roles of this module are: * - keep track of current system state (removable device connections, phone * state, user requests...). * System state changes and user actions are notified to audio policy * manager with methods of the audio_policy. * * - process get_output() queries received when AudioTrack objects are * created: Those queries return a handler on an output that has been * selected, configured and opened by the audio policy manager and that * must be used by the AudioTrack when registering to the AudioFlinger * with the createTrack() method. * When the AudioTrack object is released, a release_output() query * is received and the audio policy manager can decide to close or * reconfigure the output depending on other streams using this output and * current system state. * * - similarly process get_input() and release_input() queries received from * AudioRecord objects and configure audio inputs. * - process volume control requests: the stream volume is converted from * an index value (received from UI) to a float value applicable to each * output as a function of platform specific settings and current output * route (destination device). It also make sure that streams are not * muted if not allowed (e.g. camera shutter sound in some countries). */ /* XXX: this should be defined OUTSIDE of frameworks/base */ struct effect_descriptor_s; struct audio_policy { /* * configuration functions */ /* indicate a change in device connection status */ int (*set_device_connection_state)(struct audio_policy *pol, audio_devices_t device, audio_policy_dev_state_t state, const char *device_address); /* retrieve a device connection status */ audio_policy_dev_state_t (*get_device_connection_state)( const struct audio_policy *pol, audio_devices_t device, const char *device_address); /* indicate a change in phone state. Valid phones states are defined * by audio_mode_t */ void (*set_phone_state)(struct audio_policy *pol, audio_mode_t state); /* deprecated, never called (was "indicate a change in ringer mode") */ void (*set_ringer_mode)(struct audio_policy *pol, uint32_t mode, uint32_t mask); /* force using a specific device category for the specified usage */ void (*set_force_use)(struct audio_policy *pol, audio_policy_force_use_t usage, audio_policy_forced_cfg_t config); /* retrieve current device category forced for a given usage */ audio_policy_forced_cfg_t (*get_force_use)(const struct audio_policy *pol, audio_policy_force_use_t usage); /* if can_mute is true, then audio streams that are marked ENFORCED_AUDIBLE * can still be muted. */ void (*set_can_mute_enforced_audible)(struct audio_policy *pol, bool can_mute); /* check proper initialization */ int (*init_check)(const struct audio_policy *pol); /* * Audio routing query functions */ /* request an output appropriate for playback of the supplied stream type and * parameters */ audio_io_handle_t (*get_output)(struct audio_policy *pol, audio_stream_type_t stream, uint32_t samplingRate, audio_format_t format, audio_channel_mask_t channelMask, audio_output_flags_t flags, const audio_offload_info_t *offloadInfo); /* indicates to the audio policy manager that the output starts being used * by corresponding stream. */ int (*start_output)(struct audio_policy *pol, audio_io_handle_t output, audio_stream_type_t stream, int session); /* indicates to the audio policy manager that the output stops being used * by corresponding stream. */ int (*stop_output)(struct audio_policy *pol, audio_io_handle_t output, audio_stream_type_t stream, int session); /* releases the output. */ void (*release_output)(struct audio_policy *pol, audio_io_handle_t output); /* request an input appropriate for record from the supplied device with * supplied parameters. */ audio_io_handle_t (*get_input)(struct audio_policy *pol, audio_source_t inputSource, uint32_t samplingRate, audio_format_t format, audio_channel_mask_t channelMask, audio_in_acoustics_t acoustics); /* indicates to the audio policy manager that the input starts being used */ int (*start_input)(struct audio_policy *pol, audio_io_handle_t input); /* indicates to the audio policy manager that the input stops being used. */ int (*stop_input)(struct audio_policy *pol, audio_io_handle_t input); /* releases the input. */ void (*release_input)(struct audio_policy *pol, audio_io_handle_t input); /* * volume control functions */ /* initialises stream volume conversion parameters by specifying volume * index range. The index range for each stream is defined by AudioService. */ void (*init_stream_volume)(struct audio_policy *pol, audio_stream_type_t stream, int index_min, int index_max); /* sets the new stream volume at a level corresponding to the supplied * index. The index is within the range specified by init_stream_volume() */ int (*set_stream_volume_index)(struct audio_policy *pol, audio_stream_type_t stream, int index); /* retrieve current volume index for the specified stream */ int (*get_stream_volume_index)(const struct audio_policy *pol, audio_stream_type_t stream, int *index); /* sets the new stream volume at a level corresponding to the supplied * index for the specified device. * The index is within the range specified by init_stream_volume() */ int (*set_stream_volume_index_for_device)(struct audio_policy *pol, audio_stream_type_t stream, int index, audio_devices_t device); /* retrieve current volume index for the specified stream for the specified device */ int (*get_stream_volume_index_for_device)(const struct audio_policy *pol, audio_stream_type_t stream, int *index, audio_devices_t device); /* return the strategy corresponding to a given stream type */ uint32_t (*get_strategy_for_stream)(const struct audio_policy *pol, audio_stream_type_t stream); /* return the enabled output devices for the given stream type */ audio_devices_t (*get_devices_for_stream)(const struct audio_policy *pol, audio_stream_type_t stream); /* Audio effect management */ audio_io_handle_t (*get_output_for_effect)(struct audio_policy *pol, const struct effect_descriptor_s *desc); int (*register_effect)(struct audio_policy *pol, const struct effect_descriptor_s *desc, audio_io_handle_t output, uint32_t strategy, int session, int id); int (*unregister_effect)(struct audio_policy *pol, int id); int (*set_effect_enabled)(struct audio_policy *pol, int id, bool enabled); bool (*is_stream_active)(const struct audio_policy *pol, audio_stream_type_t stream, uint32_t in_past_ms); bool (*is_stream_active_remotely)(const struct audio_policy *pol, audio_stream_type_t stream, uint32_t in_past_ms); bool (*is_source_active)(const struct audio_policy *pol, audio_source_t source); /* dump state */ int (*dump)(const struct audio_policy *pol, int fd); /* check if offload is possible for given sample rate, bitrate, duration, ... */ bool (*is_offload_supported)(const struct audio_policy *pol, const audio_offload_info_t *info); }; /* audio hw module handle used by load_hw_module(), open_output_on_module() * and open_input_on_module() */ typedef int audio_module_handle_t; struct audio_policy_service_ops { /* * Audio output Control functions */ /* Opens an audio output with the requested parameters. * * The parameter values can indicate to use the default values in case the * audio policy manager has no specific requirements for the output being * opened. * * When the function returns, the parameter values reflect the actual * values used by the audio hardware output stream. * * The audio policy manager can check if the proposed parameters are * suitable or not and act accordingly. */ audio_io_handle_t (*open_output)(void *service, audio_devices_t *pDevices, uint32_t *pSamplingRate, audio_format_t *pFormat, audio_channel_mask_t *pChannelMask, uint32_t *pLatencyMs, audio_output_flags_t flags); /* creates a special output that is duplicated to the two outputs passed as * arguments. The duplication is performed by * a special mixer thread in the AudioFlinger. */ audio_io_handle_t (*open_duplicate_output)(void *service, audio_io_handle_t output1, audio_io_handle_t output2); /* closes the output stream */ int (*close_output)(void *service, audio_io_handle_t output); /* suspends the output. * * When an output is suspended, the corresponding audio hardware output * stream is placed in standby and the AudioTracks attached to the mixer * thread are still processed but the output mix is discarded. */ int (*suspend_output)(void *service, audio_io_handle_t output); /* restores a suspended output. */ int (*restore_output)(void *service, audio_io_handle_t output); /* */ /* Audio input Control functions */ /* */ /* opens an audio input * deprecated - new implementations should use open_input_on_module, * and the acoustics parameter is ignored */ audio_io_handle_t (*open_input)(void *service, audio_devices_t *pDevices, uint32_t *pSamplingRate, audio_format_t *pFormat, audio_channel_mask_t *pChannelMask, audio_in_acoustics_t acoustics); /* closes an audio input */ int (*close_input)(void *service, audio_io_handle_t input); /* */ /* misc control functions */ /* */ /* set a stream volume for a particular output. * * For the same user setting, a given stream type can have different * volumes for each output (destination device) it is attached to. */ int (*set_stream_volume)(void *service, audio_stream_type_t stream, float volume, audio_io_handle_t output, int delay_ms); /* reroute a given stream type to the specified output */ int (*set_stream_output)(void *service, audio_stream_type_t stream, audio_io_handle_t output); /* function enabling to send proprietary informations directly from audio * policy manager to audio hardware interface. */ void (*set_parameters)(void *service, audio_io_handle_t io_handle, const char *kv_pairs, int delay_ms); /* function enabling to receive proprietary informations directly from * audio hardware interface to audio policy manager. * * Returns a pointer to a heap allocated string. The caller is responsible * for freeing the memory for it using free(). */ char * (*get_parameters)(void *service, audio_io_handle_t io_handle, const char *keys); /* request the playback of a tone on the specified stream. * used for instance to replace notification sounds when playing over a * telephony device during a phone call. */ int (*start_tone)(void *service, audio_policy_tone_t tone, audio_stream_type_t stream); int (*stop_tone)(void *service); /* set down link audio volume. */ int (*set_voice_volume)(void *service, float volume, int delay_ms); /* move effect to the specified output */ int (*move_effects)(void *service, int session, audio_io_handle_t src_output, audio_io_handle_t dst_output); /* loads an audio hw module. * * The module name passed is the base name of the HW module library, e.g "primary" or "a2dp". * The function returns a handle on the module that will be used to specify a particular * module when calling open_output_on_module() or open_input_on_module() */ audio_module_handle_t (*load_hw_module)(void *service, const char *name); /* Opens an audio output on a particular HW module. * * Same as open_output() but specifying a specific HW module on which the output must be opened. */ audio_io_handle_t (*open_output_on_module)(void *service, audio_module_handle_t module, audio_devices_t *pDevices, uint32_t *pSamplingRate, audio_format_t *pFormat, audio_channel_mask_t *pChannelMask, uint32_t *pLatencyMs, audio_output_flags_t flags, const audio_offload_info_t *offloadInfo); /* Opens an audio input on a particular HW module. * * Same as open_input() but specifying a specific HW module on which the input must be opened. * Also removed deprecated acoustics parameter */ audio_io_handle_t (*open_input_on_module)(void *service, audio_module_handle_t module, audio_devices_t *pDevices, uint32_t *pSamplingRate, audio_format_t *pFormat, audio_channel_mask_t *pChannelMask); }; /**********************************************************************/ /** * 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 audio_policy_module { struct hw_module_t common; } audio_policy_module_t; struct audio_policy_device { struct hw_device_t common; int (*create_audio_policy)(const struct audio_policy_device *device, struct audio_policy_service_ops *aps_ops, void *service, struct audio_policy **ap); int (*destroy_audio_policy)(const struct audio_policy_device *device, struct audio_policy *ap); }; /** convenience API for opening and closing a supported device */ static inline int audio_policy_dev_open(const hw_module_t* module, struct audio_policy_device** device) { return module->methods->open(module, AUDIO_POLICY_INTERFACE, (hw_device_t**)device); } static inline int audio_policy_dev_close(struct audio_policy_device* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_AUDIO_POLICY_INTERFACE_H android-headers-23/19/hardware/bluetooth.h000066400000000000000000000363431264465411000205510ustar00rootroot00000000000000/* * 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_BLUETOOTH_H #define ANDROID_INCLUDE_BLUETOOTH_H #include #include #include #include __BEGIN_DECLS /** * The Bluetooth Hardware Module ID */ #define BT_HARDWARE_MODULE_ID "bluetooth" #define BT_STACK_MODULE_ID "bluetooth" #define BT_STACK_TEST_MODULE_ID "bluetooth_test" /* Bluetooth profile interface IDs */ #define BT_PROFILE_HANDSFREE_ID "handsfree" #define BT_PROFILE_ADVANCED_AUDIO_ID "a2dp" #define BT_PROFILE_HEALTH_ID "health" #define BT_PROFILE_SOCKETS_ID "socket" #define BT_PROFILE_HIDHOST_ID "hidhost" #define BT_PROFILE_PAN_ID "pan" #define BT_PROFILE_GATT_ID "gatt" #define BT_PROFILE_AV_RC_ID "avrcp" /** Bluetooth Address */ typedef struct { uint8_t address[6]; } __attribute__((packed))bt_bdaddr_t; /** Bluetooth Device Name */ typedef struct { uint8_t name[249]; } __attribute__((packed))bt_bdname_t; /** Bluetooth Adapter Visibility Modes*/ typedef enum { BT_SCAN_MODE_NONE, BT_SCAN_MODE_CONNECTABLE, BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE } bt_scan_mode_t; /** Bluetooth Adapter State */ typedef enum { BT_STATE_OFF, BT_STATE_ON } bt_state_t; /** Bluetooth Error Status */ /** We need to build on this */ typedef enum { BT_STATUS_SUCCESS, BT_STATUS_FAIL, BT_STATUS_NOT_READY, BT_STATUS_NOMEM, BT_STATUS_BUSY, BT_STATUS_DONE, /* request already completed */ BT_STATUS_UNSUPPORTED, BT_STATUS_PARM_INVALID, BT_STATUS_UNHANDLED, BT_STATUS_AUTH_FAILURE, BT_STATUS_RMT_DEV_DOWN } bt_status_t; /** Bluetooth PinKey Code */ typedef struct { uint8_t pin[16]; } __attribute__((packed))bt_pin_code_t; /** Bluetooth Adapter Discovery state */ typedef enum { BT_DISCOVERY_STOPPED, BT_DISCOVERY_STARTED } bt_discovery_state_t; /** Bluetooth ACL connection state */ typedef enum { BT_ACL_STATE_CONNECTED, 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; uint16_t channel; char name[256]; // what's the maximum length } bt_service_record_t; /** Bluetooth Remote Version info */ typedef struct { int version; int sub_ver; int manufacturer; } bt_remote_version_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, BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP = 0xFF, } bt_property_type_t; /** Bluetooth Adapter Property data structure */ typedef struct { bt_property_type_t type; int len; void *val; } bt_property_t; /** Bluetooth Device Type */ typedef enum { BT_DEVICE_DEVTYPE_BREDR = 0x1, BT_DEVICE_DEVTYPE_BLE, BT_DEVICE_DEVTYPE_DUAL } bt_device_type_t; /** Bluetooth Bond state */ typedef enum { BT_BOND_STATE_NONE, BT_BOND_STATE_BONDING, BT_BOND_STATE_BONDED } bt_bond_state_t; /** Bluetooth SSP Bonding Variant */ typedef enum { BT_SSP_VARIANT_PASSKEY_CONFIRMATION, BT_SSP_VARIANT_PASSKEY_ENTRY, BT_SSP_VARIANT_CONSENT, BT_SSP_VARIANT_PASSKEY_NOTIFICATION } bt_ssp_variant_t; #define BT_MAX_NUM_UUIDS 32 /** Bluetooth Interface callbacks */ /** Bluetooth Enable/Disable Callback. */ typedef void (*adapter_state_changed_callback)(bt_state_t state); /** GET/SET Adapter Properties callback */ /* TODO: For the GET/SET property APIs/callbacks, we may need a session * identifier to associate the call with the callback. This would be needed * whenever more than one simultaneous instance of the same adapter_type * is get/set. * * If this is going to be handled in the Java framework, then we do not need * to manage sessions here. */ typedef void (*adapter_properties_callback)(bt_status_t status, int num_properties, bt_property_t *properties); /** GET/SET Remote Device Properties callback */ /** TODO: For remote device properties, do not see a need to get/set * multiple properties - num_properties shall be 1 */ typedef void (*remote_device_properties_callback)(bt_status_t status, bt_bdaddr_t *bd_addr, int num_properties, bt_property_t *properties); /** New device discovered callback */ /** If EIR data is not present, then BD_NAME and RSSI shall be NULL and -1 * respectively */ typedef void (*device_found_callback)(int num_properties, bt_property_t *properties); /** Discovery state changed callback */ 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, bt_bdname_t *bd_name, uint32_t cod); /** Bluetooth SSP Request callback - Just Works & Numeric Comparison*/ /** pass_key - Shall be 0 for BT_SSP_PAIRING_VARIANT_CONSENT & * 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, bt_bdname_t *bd_name, uint32_t cod, bt_ssp_variant_t pairing_variant, uint32_t pass_key); /** 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, 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, bt_acl_state_t state); typedef enum { ASSOCIATE_JVM, DISASSOCIATE_JVM } bt_cb_thread_evt; /** Thread Associate/Disassociate JVM Callback */ /* Callback that is invoked by the callback thread to allow upper layer to attach/detach to/from * the JVM */ typedef void (*callback_thread_event)(bt_cb_thread_evt evt); /** Bluetooth Test Mode Callback */ /* 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); /* 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 */ typedef void (*le_test_mode_callback)(bt_status_t status, uint16_t num_packets); /** TODO: Add callbacks for Link Up/Down and other generic * notifications/callbacks */ /** Bluetooth DM callback structure. */ typedef struct { /** set to sizeof(bt_callbacks_t) */ size_t size; adapter_state_changed_callback adapter_state_changed_cb; adapter_properties_callback adapter_properties_cb; remote_device_properties_callback remote_device_properties_cb; device_found_callback device_found_cb; discovery_state_changed_callback discovery_state_changed_cb; pin_request_callback pin_request_cb; ssp_request_callback ssp_request_cb; bond_state_changed_callback bond_state_changed_cb; acl_state_changed_callback acl_state_changed_cb; callback_thread_event thread_evt_cb; dut_mode_recv_callback dut_mode_recv_cb; le_test_mode_callback le_test_mode_cb; } bt_callbacks_t; /** NOTE: By default, no profiles are initialized at the time of init/enable. * Whenever the application invokes the 'init' API of a profile, then one of * the following shall occur: * * 1.) If Bluetooth is not enabled, then the Bluetooth core shall mark the * profile as enabled. Subsequently, when the application invokes the * Bluetooth 'enable', as part of the enable sequence the profile that were * marked shall be enabled by calling appropriate stack APIs. The * 'adapter_properties_cb' shall return the list of UUIDs of the * enabled profiles. * * 2.) If Bluetooth is enabled, then the Bluetooth core shall invoke the stack * profile API to initialize the profile and trigger a * 'adapter_properties_cb' with the current list of UUIDs including the * newly added profile's UUID. * * The reverse shall occur whenever the profile 'cleanup' APIs are invoked */ /** Represents the standard Bluetooth DM interface. */ typedef struct { /** set to sizeof(bt_interface_t) */ size_t size; /** * Opens the interface and provides the callback routines * to the implemenation of this interface. */ int (*init)(bt_callbacks_t* callbacks ); /** Enable Bluetooth. */ int (*enable)(void); /** Disable Bluetooth. */ int (*disable)(void); /** Closes the interface. */ void (*cleanup)(void); /** Get all Bluetooth Adapter properties at init */ int (*get_adapter_properties)(void); /** Get Bluetooth Adapter property of 'type' */ int (*get_adapter_property)(bt_property_type_t type); /** 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 */ int (*set_adapter_property)(const bt_property_t *property); /** Get all Remote Device properties */ int (*get_remote_device_properties)(bt_bdaddr_t *remote_addr); /** Get Remote Device property of 'type' */ int (*get_remote_device_property)(bt_bdaddr_t *remote_addr, bt_property_type_t type); /** Set Remote Device property of 'type' */ int (*set_remote_device_property)(bt_bdaddr_t *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); /** Start SDP to get remote services */ int (*get_remote_services)(bt_bdaddr_t *remote_addr); /** Start Discovery */ int (*start_discovery)(void); /** Cancel Discovery */ int (*cancel_discovery)(void); /** Create Bluetooth Bonding */ int (*create_bond)(const bt_bdaddr_t *bd_addr); /** Remove Bond */ int (*remove_bond)(const bt_bdaddr_t *bd_addr); /** Cancel Bond */ int (*cancel_bond)(const bt_bdaddr_t *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, uint8_t pin_len, bt_pin_code_t *pin_code); /** BT SSP Reply - Just Works, Numeric Comparison and Passkey * passkey shall be zero for BT_SSP_VARIANT_PASSKEY_COMPARISON & * 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, uint8_t accept, uint32_t passkey); /** Get Bluetooth profile interface */ const void* (*get_profile_interface) (const char *profile_id); /** Bluetooth Test Mode APIs - Bluetooth must be enabled for these APIs */ /* Configure DUT Mode - Use this mode to enter/exit DUT mode */ int (*dut_mode_configure)(uint8_t enable); /* 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); /** 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); } 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 */ android-headers-23/19/hardware/bt_av.h000066400000000000000000000052231264465411000176300ustar00rootroot00000000000000/* * 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); /** 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_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. */ typedef struct { /** set to sizeof(btav_interface_t) */ size_t size; /** * Register the BtAv callbacks */ bt_status_t (*init)( btav_callbacks_t* callbacks ); /** 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 ); } btav_interface_t; __END_DECLS #endif /* ANDROID_INCLUDE_BT_AV_H */ android-headers-23/19/hardware/bt_gatt.h000066400000000000000000000032431264465411000201610ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/hardware/bt_gatt_client.h000066400000000000000000000254151264465411000215240ustar00rootroot00000000000000/* * 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" __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 { btgatt_srvc_id_t srvc_id; btgatt_gatt_id_t char_id; btgatt_gatt_id_t descr_id; 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; btgatt_srvc_id_t srvc_id; btgatt_gatt_id_t char_id; uint16_t len; uint8_t is_notify; } btgatt_notify_params_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 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); /** Reports GATT services on a remote device */ typedef void (*search_result_callback)( int conn_id, btgatt_srvc_id_t *srvc_id); /** GATT characteristic enumeration result callback */ typedef void (*get_characteristic_callback)(int conn_id, int status, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, int char_prop); /** GATT descriptor enumeration result callback */ typedef void (*get_descriptor_callback)(int conn_id, int status, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, btgatt_gatt_id_t *descr_id); /** GATT included service enumeration result callback */ typedef void (*get_included_service_callback)(int conn_id, int status, btgatt_srvc_id_t *srvc_id, btgatt_srvc_id_t *incl_srvc_id); /** Callback invoked in response to [de]register_for_notification */ typedef void (*register_for_notification_callback)(int conn_id, int registered, int status, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id); /** * 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, btgatt_write_params_t *p_data); /** 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, btgatt_write_params_t *p_data); /** 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 indicationg the status of a listen() operation */ typedef void (*listen_callback)(int status, int server_if); 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; search_result_callback search_result_cb; get_characteristic_callback get_characteristic_cb; get_descriptor_callback get_descriptor_cb; get_included_service_callback get_included_service_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; } 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)( int client_if, 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 ); /** 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 ); /** * Enumerate included services for a given service. * Set start_incl_srvc_id to NULL to get the first included service. */ bt_status_t (*get_included_service)( int conn_id, btgatt_srvc_id_t *srvc_id, btgatt_srvc_id_t *start_incl_srvc_id); /** * Enumerate characteristics for a given service. * Set start_char_id to NULL to get the first characteristic. */ bt_status_t (*get_characteristic)( int conn_id, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *start_char_id); /** * Enumerate descriptors for a given characteristic. * Set start_descr_id to NULL to get the first descriptor. */ bt_status_t (*get_descriptor)( int conn_id, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, btgatt_gatt_id_t *start_descr_id); /** Read a characteristic on a remote device */ bt_status_t (*read_characteristic)( int conn_id, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, int auth_req ); /** Write a remote characteristic */ bt_status_t (*write_characteristic)(int conn_id, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, 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, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, btgatt_gatt_id_t *descr_id, int auth_req); /** Write a remote descriptor for a given characteristic */ bt_status_t (*write_descriptor)( int conn_id, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, btgatt_gatt_id_t *descr_id, 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, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id); /** Deregister a previous request for notifications/indications */ bt_status_t (*deregister_for_notification)( int client_if, const bt_bdaddr_t *bd_addr, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id); /** Request RSSI for a given remote device */ bt_status_t (*read_remote_rssi)( int client_if, const bt_bdaddr_t *bd_addr); /** 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 server_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); /** Test mode interface */ bt_status_t (*test_command)( int command, btgatt_test_params_t* params); } btgatt_client_interface_t; __END_DECLS #endif /* ANDROID_INCLUDE_BT_GATT_CLIENT_H */ android-headers-23/19/hardware/bt_gatt_server.h000066400000000000000000000156111264465411000215510ustar00rootroot00000000000000/* * 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); 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; } 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 ); /** 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 */ android-headers-23/19/hardware/bt_gatt_types.h000066400000000000000000000023551264465411000214100ustar00rootroot00000000000000/* * 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; __END_DECLS #endif /* ANDROID_INCLUDE_BT_GATT_TYPES_H */ android-headers-23/19/hardware/bt_hf.h000066400000000000000000000214101264465411000176130ustar00rootroot00000000000000/* * 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; /* 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); /** Callback for answer incoming call (ATA) */ typedef void (* bthf_answer_call_cmd_callback)(); /** Callback for disconnect call (AT+CHUP) */ typedef void (* bthf_hangup_call_cmd_callback)(); /** 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); /** Callback for dialing an outgoing call * If number is NULL, redial */ typedef void (* bthf_dial_call_cmd_callback)(char *number); /** Callback for sending DTMF tones * tone contains the dtmf character to be sent */ typedef void (* bthf_dtmf_cmd_callback)(char tone); /** 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); /** 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); /** Callback for CNUM (subscriber number) */ typedef void (* bthf_cnum_cmd_callback)(); /** Callback for indicators (CIND) */ typedef void (* bthf_cind_cmd_callback)(); /** Callback for operator selection (COPS) */ typedef void (* bthf_cops_cmd_callback)(); /** Callback for call list (AT+CLCC) */ typedef void (* bthf_clcc_cmd_callback) (); /** 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); /** Callback for keypressed (HSP) event. */ typedef void (* bthf_key_pressed_cmd_callback)(); /** 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_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_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_CALL_ADDRTYPE_UNKNOWN = 0x81, BTHF_CALL_ADDRTYPE_INTERNATIONAL = 0x91 } bthf_call_addrtype_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 ); /** 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)(); /** stop voice recognition */ bt_status_t (*stop_voice_recognition)(); /** volume control */ bt_status_t (*volume_control) (bthf_volume_type_t type, int volume); /** 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); /** 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); /** Pre-formatted AT response, typically in response to unknown AT cmd */ bt_status_t (*formatted_at_response)(const char *rsp); /** ok/error response * ERROR (0) * OK (1) */ bt_status_t (*at_response) (bthf_at_response_t response_code, int error_code); /** 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); /** 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 ); } bthf_interface_t; __END_DECLS #endif /* ANDROID_INCLUDE_BT_HF_H */ android-headers-23/19/hardware/bt_hh.h000066400000000000000000000134731264465411000176270ustar00rootroot00000000000000/* * 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/set protocal 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); /** 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_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); /** 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 */ android-headers-23/19/hardware/bt_hl.h000066400000000000000000000071711264465411000176310ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/hardware/bt_pan.h000066400000000000000000000055131264465411000200020ustar00rootroot00000000000000/* * 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, bt_status_t error, int local_role, 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 */ android-headers-23/19/hardware/bt_rc.h000066400000000000000000000243571264465411000176370ustar00rootroot00000000000000/* * 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 7 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_event_id_t; typedef enum { BTRC_NOTIFICATION_TYPE_INTERIM = 0, BTRC_NOTIFICATION_TYPE_CHANGED = 1, } 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_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 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 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; } 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); /** Callback for play status request */ typedef void (* btrc_get_play_status_callback)(); /** Callback for list player application attributes (Shuffle, Repeat,...) */ typedef void (* btrc_list_player_app_attr_callback)(); /** Callback for list player application attributes (Shuffle, Repeat,...) */ typedef void (* btrc_list_player_app_values_callback)(btrc_player_attr_t attr_id); /** 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); /** 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); /** 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); /** Callback for setting the player application settings values */ typedef void (* btrc_set_player_app_value_callback) (btrc_player_settings_t *p_vals); /** 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); /** 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); /* 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); /** Callback for passthrough commands */ typedef void (* btrc_passthrough_cmd_callback) (int id, int key_state); /** BT-RC callback structure. */ 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_callbacks_t; /** Represents the standard BT-RC interface. */ typedef struct { /** set to sizeof(BtRcInterface) */ size_t size; /** * Register the BtRc callbacks */ bt_status_t (*init)( btrc_callbacks_t* callbacks ); /** 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); /** 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)( int num_attr, btrc_player_attr_t *p_attrs); /** 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)( int num_val, uint8_t *p_vals); /** 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); /** 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); /** 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); /** 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); /** 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); /* 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); /* 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); /** Closes the interface. */ void (*cleanup)( void ); } btrc_interface_t; __END_DECLS #endif /* ANDROID_INCLUDE_BT_RC_H */ android-headers-23/19/hardware/bt_sock.h000066400000000000000000000035171264465411000201650ustar00rootroot00000000000000/* * 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_SOCK_H #define ANDROID_INCLUDE_BT_SOCK_H __BEGIN_DECLS #define BTSOCK_FLAG_ENCRYPT 1 #define BTSOCK_FLAG_AUTH (1 << 1) typedef enum { BTSOCK_RFCOMM = 1, BTSOCK_SCO = 2, BTSOCK_L2CAP = 3 } btsock_type_t; /** Represents the standard BT SOCKET interface. */ typedef struct { short size; bt_bdaddr_t bd_addr; int channel; int status; } __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 */ bt_status_t (*listen)(btsock_type_t type, const char* service_name, const uint8_t* service_uuid, int channel, int* sock_fd, int flags); /* * 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 */ 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); } btsock_interface_t; __END_DECLS #endif /* ANDROID_INCLUDE_BT_SOCK_H */ android-headers-23/19/hardware/camera.h000066400000000000000000000255521264465411000177740ustar00rootroot00000000000000/* * Copyright (C) 2010-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_CAMERA_H #define ANDROID_INCLUDE_CAMERA_H #include "camera_common.h" /** * Camera device HAL, initial version [ CAMERA_DEVICE_API_VERSION_1_0 ] * * Supports the android.hardware.Camera API. * * Camera devices that support this version of the HAL must return a value in * the range HARDWARE_DEVICE_API_VERSION(0,0)-(1,FF) in * camera_device_t.common.version. CAMERA_DEVICE_API_VERSION_1_0 is the * recommended value. * * Camera modules that implement version 2.0 or higher of camera_module_t must * also return the value of camera_device_t.common.version in * camera_info_t.device_version. * * See camera_common.h for more details. */ __BEGIN_DECLS struct camera_memory; typedef void (*camera_release_memory)(struct camera_memory *mem); typedef struct camera_memory { void *data; size_t size; void *handle; camera_release_memory release; } camera_memory_t; typedef camera_memory_t* (*camera_request_memory)(int fd, size_t buf_size, unsigned int num_bufs, void *user); typedef void (*camera_notify_callback)(int32_t msg_type, int32_t ext1, int32_t ext2, void *user); typedef void (*camera_data_callback)(int32_t msg_type, const camera_memory_t *data, unsigned int index, camera_frame_metadata_t *metadata, void *user); typedef void (*camera_data_timestamp_callback)(int64_t timestamp, int32_t msg_type, const camera_memory_t *data, unsigned int index, void *user); #define HAL_CAMERA_PREVIEW_WINDOW_TAG 0xcafed00d typedef struct preview_stream_ops { int (*dequeue_buffer)(struct preview_stream_ops* w, buffer_handle_t** buffer, int *stride); int (*enqueue_buffer)(struct preview_stream_ops* w, buffer_handle_t* buffer); int (*cancel_buffer)(struct preview_stream_ops* w, buffer_handle_t* buffer); int (*set_buffer_count)(struct preview_stream_ops* w, int count); int (*set_buffers_geometry)(struct preview_stream_ops* pw, int w, int h, int format); int (*set_crop)(struct preview_stream_ops *w, int left, int top, int right, int bottom); int (*set_usage)(struct preview_stream_ops* w, int usage); int (*set_swap_interval)(struct preview_stream_ops *w, int interval); int (*get_min_undequeued_buffer_count)(const struct preview_stream_ops *w, int *count); int (*lock_buffer)(struct preview_stream_ops* w, buffer_handle_t* buffer); // Timestamps are measured in nanoseconds, and must be comparable // and monotonically increasing between two frames in the same // preview stream. They do not need to be comparable between // consecutive or parallel preview streams, cameras, or app runs. int (*set_timestamp)(struct preview_stream_ops *w, int64_t timestamp); } preview_stream_ops_t; struct camera_device; typedef struct camera_device_ops { /** Set the ANativeWindow to which preview frames are sent */ int (*set_preview_window)(struct camera_device *, struct preview_stream_ops *window); /** Set the notification and data callbacks */ void (*set_callbacks)(struct camera_device *, camera_notify_callback notify_cb, camera_data_callback data_cb, camera_data_timestamp_callback data_cb_timestamp, camera_request_memory get_memory, void *user); /** * The following three functions all take a msg_type, which is a bitmask of * the messages defined in include/ui/Camera.h */ /** * Enable a message, or set of messages. */ void (*enable_msg_type)(struct camera_device *, int32_t msg_type); /** * Disable a message, or a set of messages. * * Once received a call to disableMsgType(CAMERA_MSG_VIDEO_FRAME), camera * HAL should not rely on its client to call releaseRecordingFrame() to * release video recording frames sent out by the cameral HAL before and * after the disableMsgType(CAMERA_MSG_VIDEO_FRAME) call. Camera HAL * clients must not modify/access any video recording frame after calling * disableMsgType(CAMERA_MSG_VIDEO_FRAME). */ void (*disable_msg_type)(struct camera_device *, int32_t msg_type); /** * Query whether a message, or a set of messages, is enabled. Note that * this is operates as an AND, if any of the messages queried are off, this * will return false. */ int (*msg_type_enabled)(struct camera_device *, int32_t msg_type); /** * Start preview mode. */ int (*start_preview)(struct camera_device *); /** * Stop a previously started preview. */ void (*stop_preview)(struct camera_device *); /** * Returns true if preview is enabled. */ int (*preview_enabled)(struct camera_device *); /** * Request the camera HAL to store meta data or real YUV data in the video * buffers sent out via CAMERA_MSG_VIDEO_FRAME for a recording session. If * it is not called, the default camera HAL behavior is to store real YUV * data in the video buffers. * * This method should be called before startRecording() in order to be * effective. * * If meta data is stored in the video buffers, it is up to the receiver of * the video buffers to interpret the contents and to find the actual frame * data with the help of the meta data in the buffer. How this is done is * outside of the scope of this method. * * Some camera HALs may not support storing meta data in the video buffers, * but all camera HALs should support storing real YUV data in the video * buffers. If the camera HAL does not support storing the meta data in the * video buffers when it is requested to do do, INVALID_OPERATION must be * returned. It is very useful for the camera HAL to pass meta data rather * than the actual frame data directly to the video encoder, since the * amount of the uncompressed frame data can be very large if video size is * large. * * @param enable if true to instruct the camera HAL to store * meta data in the video buffers; false to instruct * the camera HAL to store real YUV data in the video * buffers. * * @return OK on success. */ int (*store_meta_data_in_buffers)(struct camera_device *, int enable); /** * Start record mode. When a record image is available, a * CAMERA_MSG_VIDEO_FRAME message is sent with the corresponding * frame. Every record frame must be released by a camera HAL client via * releaseRecordingFrame() before the client calls * disableMsgType(CAMERA_MSG_VIDEO_FRAME). After the client calls * disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's * responsibility to manage the life-cycle of the video recording frames, * and the client must not modify/access any video recording frames. */ int (*start_recording)(struct camera_device *); /** * Stop a previously started recording. */ void (*stop_recording)(struct camera_device *); /** * Returns true if recording is enabled. */ int (*recording_enabled)(struct camera_device *); /** * Release a record frame previously returned by CAMERA_MSG_VIDEO_FRAME. * * It is camera HAL client's responsibility to release video recording * frames sent out by the camera HAL before the camera HAL receives a call * to disableMsgType(CAMERA_MSG_VIDEO_FRAME). After it receives the call to * disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's * responsibility to manage the life-cycle of the video recording frames. */ void (*release_recording_frame)(struct camera_device *, const void *opaque); /** * Start auto focus, the notification callback routine is called with * CAMERA_MSG_FOCUS once when focusing is complete. autoFocus() will be * called again if another auto focus is needed. */ int (*auto_focus)(struct camera_device *); /** * Cancels auto-focus function. If the auto-focus is still in progress, * this function will cancel it. Whether the auto-focus is in progress or * not, this function will return the focus position to the default. If * the camera does not support auto-focus, this is a no-op. */ int (*cancel_auto_focus)(struct camera_device *); /** * Take a picture. */ int (*take_picture)(struct camera_device *); /** * Cancel a picture that was started with takePicture. Calling this method * when no picture is being taken is a no-op. */ int (*cancel_picture)(struct camera_device *); /** * Set the camera parameters. This returns BAD_VALUE if any parameter is * invalid or not supported. */ int (*set_parameters)(struct camera_device *, const char *parms); /** Retrieve the camera parameters. The buffer returned by the camera HAL must be returned back to it with put_parameters, if put_parameters is not NULL. */ char *(*get_parameters)(struct camera_device *); /** The camera HAL uses its own memory to pass us the parameters when we call get_parameters. Use this function to return the memory back to the camera HAL, if put_parameters is not NULL. If put_parameters is NULL, then you have to use free() to release the memory. */ void (*put_parameters)(struct camera_device *, char *); /** * Send command to camera driver. */ int (*send_command)(struct camera_device *, int32_t cmd, int32_t arg1, int32_t arg2); /** * Release the hardware resources owned by this object. Note that this is * *not* done in the destructor. */ void (*release)(struct camera_device *); /** * Dump state of the camera hardware */ int (*dump)(struct camera_device *, int fd); } camera_device_ops_t; typedef struct camera_device { /** * camera_device.common.version must be in the range * HARDWARE_DEVICE_API_VERSION(0,0)-(1,FF). CAMERA_DEVICE_API_VERSION_1_0 is * recommended. */ hw_device_t common; camera_device_ops_t *ops; void *priv; } camera_device_t; __END_DECLS #endif /* #ifdef ANDROID_INCLUDE_CAMERA_H */ android-headers-23/19/hardware/camera2.h000066400000000000000000001025771264465411000200610ustar00rootroot00000000000000/* * 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_CAMERA2_H #define ANDROID_INCLUDE_CAMERA2_H #include "camera_common.h" #include "system/camera_metadata.h" /** * Camera device HAL 2.1 [ CAMERA_DEVICE_API_VERSION_2_0, CAMERA_DEVICE_API_VERSION_2_1 ] * * EXPERIMENTAL. * * Supports the android.hardware.Camera APIs. * * Camera devices that support this version of the HAL must return * CAMERA_DEVICE_API_VERSION_2_1 in camera_device_t.common.version and in * camera_info_t.device_version (from camera_module_t.get_camera_info). * * Camera modules that may contain version 2.x devices must implement at least * version 2.0 of the camera module interface (as defined by * camera_module_t.common.module_api_version). * * See camera_common.h for more versioning details. * * Version history: * * 2.0: CAMERA_DEVICE_API_VERSION_2_0. Initial release (Android 4.2): * - Sufficient for implementing existing android.hardware.Camera API. * - Allows for ZSL queue in camera service layer * - Not tested for any new features such manual capture control, * Bayer RAW capture, reprocessing of RAW data. * * 2.1: CAMERA_DEVICE_API_VERSION_2_1. Support per-device static metadata: * - Add get_instance_metadata() method to retrieve metadata that is fixed * after device open, but may be variable between open() calls. */ __BEGIN_DECLS struct camera2_device; /********************************************************************** * * Input/output stream buffer queue interface definitions * */ /** * Output image stream queue interface. A set of these methods is provided to * the HAL device in allocate_stream(), and are used to interact with the * gralloc buffer queue for that stream. They may not be called until after * allocate_stream returns. */ typedef struct camera2_stream_ops { /** * Get a buffer to fill from the queue. The size and format of the buffer * are fixed for a given stream (defined in allocate_stream), and the stride * should be queried from the platform gralloc module. The gralloc buffer * will have been allocated based on the usage flags provided by * allocate_stream, and will be locked for use. */ int (*dequeue_buffer)(const struct camera2_stream_ops* w, buffer_handle_t** buffer); /** * Push a filled buffer to the stream to be used by the consumer. * * The timestamp represents the time at start of exposure of the first row * of the image; it must be from a monotonic clock, and is measured in * nanoseconds. The timestamps do not need to be comparable between * different cameras, or consecutive instances of the same camera. However, * they must be comparable between streams from the same camera. If one * capture produces buffers for multiple streams, each stream must have the * same timestamp for that buffer, and that timestamp must match the * timestamp in the output frame metadata. */ int (*enqueue_buffer)(const struct camera2_stream_ops* w, int64_t timestamp, buffer_handle_t* buffer); /** * Return a buffer to the queue without marking it as filled. */ int (*cancel_buffer)(const struct camera2_stream_ops* w, buffer_handle_t* buffer); /** * Set the crop window for subsequently enqueued buffers. The parameters are * measured in pixels relative to the buffer width and height. */ int (*set_crop)(const struct camera2_stream_ops *w, int left, int top, int right, int bottom); } camera2_stream_ops_t; /** * Temporary definition during transition. * * These formats will be removed and replaced with * HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED. To maximize forward compatibility, * HAL implementations are strongly recommended to treat FORMAT_OPAQUE and * FORMAT_ZSL as equivalent to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, and * return HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED in the format_actual output * parameter of allocate_stream, allowing the gralloc module to select the * specific format based on the usage flags from the camera and the stream * consumer. */ enum { CAMERA2_HAL_PIXEL_FORMAT_OPAQUE = HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, CAMERA2_HAL_PIXEL_FORMAT_ZSL = -1 }; /** * Transport header for compressed JPEG buffers in output streams. * * To capture JPEG images, a stream is created using the pixel format * HAL_PIXEL_FORMAT_BLOB, and the static metadata field android.jpeg.maxSize is * used as the buffer size. Since compressed JPEG images are of variable size, * the HAL needs to include the final size of the compressed image using this * structure inside the output stream buffer. The JPEG blob ID field must be set * to CAMERA2_JPEG_BLOB_ID. * * Transport header should be at the end of the JPEG output stream buffer. That * means the jpeg_blob_id must start at byte[android.jpeg.maxSize - * sizeof(camera2_jpeg_blob)]. Any HAL using this transport header must * account for it in android.jpeg.maxSize. The JPEG data itself starts at * byte[0] and should be jpeg_size bytes long. */ typedef struct camera2_jpeg_blob { uint16_t jpeg_blob_id; uint32_t jpeg_size; }; enum { CAMERA2_JPEG_BLOB_ID = 0x00FF }; /** * Input reprocess stream queue management. A set of these methods is provided * to the HAL device in allocate_reprocess_stream(); they are used to interact * with the reprocess stream's input gralloc buffer queue. */ typedef struct camera2_stream_in_ops { /** * Get the next buffer of image data to reprocess. The width, height, and * format of the buffer is fixed in allocate_reprocess_stream(), and the * stride and other details should be queried from the platform gralloc * module as needed. The buffer will already be locked for use. */ int (*acquire_buffer)(const struct camera2_stream_in_ops *w, buffer_handle_t** buffer); /** * Return a used buffer to the buffer queue for reuse. */ int (*release_buffer)(const struct camera2_stream_in_ops *w, buffer_handle_t* buffer); } camera2_stream_in_ops_t; /********************************************************************** * * Metadata queue management, used for requests sent to HAL module, and for * frames produced by the HAL. * */ enum { CAMERA2_REQUEST_QUEUE_IS_BOTTOMLESS = -1 }; /** * Request input queue protocol: * * The framework holds the queue and its contents. At start, the queue is empty. * * 1. When the first metadata buffer is placed into the queue, the framework * signals the device by calling notify_request_queue_not_empty(). * * 2. After receiving notify_request_queue_not_empty, the device must call * dequeue() once it's ready to handle the next buffer. * * 3. Once the device has processed a buffer, and is ready for the next buffer, * it must call dequeue() again instead of waiting for a notification. If * there are no more buffers available, dequeue() will return NULL. After * this point, when a buffer becomes available, the framework must call * notify_request_queue_not_empty() again. If the device receives a NULL * return from dequeue, it does not need to query the queue again until a * notify_request_queue_not_empty() call is received from the source. * * 4. If the device calls buffer_count() and receives 0, this does not mean that * the framework will provide a notify_request_queue_not_empty() call. The * framework will only provide such a notification after the device has * received a NULL from dequeue, or on initial startup. * * 5. The dequeue() call in response to notify_request_queue_not_empty() may be * on the same thread as the notify_request_queue_not_empty() call, and may * be performed from within the notify call. * * 6. All dequeued request buffers must be returned to the framework by calling * free_request, including when errors occur, a device flush is requested, or * when the device is shutting down. */ typedef struct camera2_request_queue_src_ops { /** * Get the count of request buffers pending in the queue. May return * CAMERA2_REQUEST_QUEUE_IS_BOTTOMLESS if a repeating request (stream * request) is currently configured. Calling this method has no effect on * whether the notify_request_queue_not_empty() method will be called by the * framework. */ int (*request_count)(const struct camera2_request_queue_src_ops *q); /** * Get a metadata buffer from the framework. Returns OK if there is no * error. If the queue is empty, returns NULL in buffer. In that case, the * device must wait for a notify_request_queue_not_empty() message before * attempting to dequeue again. Buffers obtained in this way must be * returned to the framework with free_request(). */ int (*dequeue_request)(const struct camera2_request_queue_src_ops *q, camera_metadata_t **buffer); /** * Return a metadata buffer to the framework once it has been used, or if * an error or shutdown occurs. */ int (*free_request)(const struct camera2_request_queue_src_ops *q, camera_metadata_t *old_buffer); } camera2_request_queue_src_ops_t; /** * Frame output queue protocol: * * The framework holds the queue and its contents. At start, the queue is empty. * * 1. When the device is ready to fill an output metadata frame, it must dequeue * a metadata buffer of the required size. * * 2. It should then fill the metadata buffer, and place it on the frame queue * using enqueue_frame. The framework takes ownership of the frame. * * 3. In case of an error, a request to flush the pipeline, or shutdown, the * device must return any affected dequeued frames to the framework by * calling cancel_frame. */ typedef struct camera2_frame_queue_dst_ops { /** * Get an empty metadata buffer to fill from the framework. The new metadata * buffer will have room for entries number of metadata entries, plus * data_bytes worth of extra storage. Frames dequeued here must be returned * to the framework with either cancel_frame or enqueue_frame. */ int (*dequeue_frame)(const struct camera2_frame_queue_dst_ops *q, size_t entries, size_t data_bytes, camera_metadata_t **buffer); /** * Return a dequeued metadata buffer to the framework for reuse; do not mark it as * filled. Use when encountering errors, or flushing the internal request queue. */ int (*cancel_frame)(const struct camera2_frame_queue_dst_ops *q, camera_metadata_t *buffer); /** * Place a completed metadata frame on the frame output queue. */ int (*enqueue_frame)(const struct camera2_frame_queue_dst_ops *q, camera_metadata_t *buffer); } camera2_frame_queue_dst_ops_t; /********************************************************************** * * Notification callback and message definition, and trigger definitions * */ /** * Asynchronous notification callback from the HAL, fired for various * reasons. Only for information independent of frame capture, or that require * specific timing. The user pointer must be the same one that was passed to the * device in set_notify_callback(). */ typedef void (*camera2_notify_callback)(int32_t msg_type, int32_t ext1, int32_t ext2, int32_t ext3, void *user); /** * Possible message types for camera2_notify_callback */ enum { /** * An error has occurred. Argument ext1 contains the error code, and * ext2 and ext3 contain any error-specific information. */ CAMERA2_MSG_ERROR = 0x0001, /** * The exposure of a given request has begun. Argument ext1 contains the * frame number, and ext2 and ext3 contain the low-order and high-order * bytes of the timestamp for when exposure began. * (timestamp = (ext3 << 32 | ext2)) */ CAMERA2_MSG_SHUTTER = 0x0010, /** * The autofocus routine has changed state. Argument ext1 contains the new * state; the values are the same as those for the metadata field * android.control.afState. Ext2 contains the latest trigger ID passed to * trigger_action(CAMERA2_TRIGGER_AUTOFOCUS) or * trigger_action(CAMERA2_TRIGGER_CANCEL_AUTOFOCUS), or 0 if trigger has not * been called with either of those actions. */ CAMERA2_MSG_AUTOFOCUS = 0x0020, /** * The autoexposure routine has changed state. Argument ext1 contains the * new state; the values are the same as those for the metadata field * android.control.aeState. Ext2 contains the latest trigger ID value passed to * trigger_action(CAMERA2_TRIGGER_PRECAPTURE_METERING), or 0 if that method * has not been called. */ CAMERA2_MSG_AUTOEXPOSURE = 0x0021, /** * The auto-whitebalance routine has changed state. Argument ext1 contains * the new state; the values are the same as those for the metadata field * android.control.awbState. Ext2 contains the latest trigger ID passed to * trigger_action(CAMERA2_TRIGGER_PRECAPTURE_METERING), or 0 if that method * has not been called. */ CAMERA2_MSG_AUTOWB = 0x0022 }; /** * Error codes for CAMERA_MSG_ERROR */ enum { /** * A serious failure occured. Camera device may not work without reboot, and * no further frames or buffer streams will be produced by the * device. Device should be treated as closed. */ CAMERA2_MSG_ERROR_HARDWARE = 0x0001, /** * A serious failure occured. No further frames or buffer streams will be * produced by the device. Device should be treated as closed. The client * must reopen the device to use it again. */ CAMERA2_MSG_ERROR_DEVICE, /** * An error has occurred in processing a request. No output (metadata or * buffers) will be produced for this request. ext2 contains the frame * number of the request. Subsequent requests are unaffected, and the device * remains operational. */ CAMERA2_MSG_ERROR_REQUEST, /** * An error has occurred in producing an output frame metadata buffer for a * request, but image buffers for it will still be available. Subsequent * requests are unaffected, and the device remains operational. ext2 * contains the frame number of the request. */ CAMERA2_MSG_ERROR_FRAME, /** * An error has occurred in placing an output buffer into a stream for a * request. The frame metadata and other buffers may still be * available. Subsequent requests are unaffected, and the device remains * operational. ext2 contains the frame number of the request, and ext3 * contains the stream id. */ CAMERA2_MSG_ERROR_STREAM, /** * Number of error types */ CAMERA2_MSG_NUM_ERRORS }; /** * Possible trigger ids for trigger_action() */ enum { /** * Trigger an autofocus cycle. The effect of the trigger depends on the * autofocus mode in effect when the trigger is received, which is the mode * listed in the latest capture request to be dequeued by the HAL. If the * mode is OFF, EDOF, or FIXED, the trigger has no effect. In AUTO, MACRO, * or CONTINUOUS_* modes, see below for the expected behavior. The state of * the autofocus cycle can be tracked in android.control.afMode and the * corresponding notifications. * ** * In AUTO or MACRO mode, the AF state transitions (and notifications) * when calling with trigger ID = N with the previous ID being K are: * * Initial state Transitions * INACTIVE (K) -> ACTIVE_SCAN (N) -> AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * AF_FOCUSED (K) -> ACTIVE_SCAN (N) -> AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * AF_NOT_FOCUSED (K) -> ACTIVE_SCAN (N) -> AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * ACTIVE_SCAN (K) -> AF_FOCUSED(N) or AF_NOT_FOCUSED(N) * PASSIVE_SCAN (K) Not used in AUTO/MACRO mode * PASSIVE_FOCUSED (K) Not used in AUTO/MACRO mode * ** * In CONTINUOUS_PICTURE mode, triggering AF must lock the AF to the current * lens position and transition the AF state to either AF_FOCUSED or * NOT_FOCUSED. If a passive scan is underway, that scan must complete and * then lock the lens position and change AF state. TRIGGER_CANCEL_AUTOFOCUS * will allow the AF to restart its operation. * * Initial state Transitions * INACTIVE (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * PASSIVE_FOCUSED (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * PASSIVE_SCAN (K) -> AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * AF_FOCUSED (K) no effect except to change next notification ID to N * AF_NOT_FOCUSED (K) no effect except to change next notification ID to N * ** * In CONTINUOUS_VIDEO mode, triggering AF must lock the AF to the current * lens position and transition the AF state to either AF_FOCUSED or * NOT_FOCUSED. If a passive scan is underway, it must immediately halt, in * contrast with CONTINUOUS_PICTURE mode. TRIGGER_CANCEL_AUTOFOCUS will * allow the AF to restart its operation. * * Initial state Transitions * INACTIVE (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * PASSIVE_FOCUSED (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * PASSIVE_SCAN (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * AF_FOCUSED (K) no effect except to change next notification ID to N * AF_NOT_FOCUSED (K) no effect except to change next notification ID to N * * Ext1 is an ID that must be returned in subsequent auto-focus state change * notifications through camera2_notify_callback() and stored in * android.control.afTriggerId. */ CAMERA2_TRIGGER_AUTOFOCUS = 0x0001, /** * Send a cancel message to the autofocus algorithm. The effect of the * cancellation depends on the autofocus mode in effect when the trigger is * received, which is the mode listed in the latest capture request to be * dequeued by the HAL. If the AF mode is OFF or EDOF, the cancel has no * effect. For other modes, the lens should return to its default position, * any current autofocus scan must be canceled, and the AF state should be * set to INACTIVE. * * The state of the autofocus cycle can be tracked in android.control.afMode * and the corresponding notification. Continuous autofocus modes may resume * focusing operations thereafter exactly as if the camera had just been set * to a continuous AF mode. * * Ext1 is an ID that must be returned in subsequent auto-focus state change * notifications through camera2_notify_callback() and stored in * android.control.afTriggerId. */ CAMERA2_TRIGGER_CANCEL_AUTOFOCUS, /** * Trigger a pre-capture metering cycle, which may include firing the flash * to determine proper capture parameters. Typically, this trigger would be * fired for a half-depress of a camera shutter key, or before a snapshot * capture in general. The state of the metering cycle can be tracked in * android.control.aeMode and the corresponding notification. If the * auto-exposure mode is OFF, the trigger does nothing. * * Ext1 is an ID that must be returned in subsequent * auto-exposure/auto-white balance state change notifications through * camera2_notify_callback() and stored in android.control.aePrecaptureId. */ CAMERA2_TRIGGER_PRECAPTURE_METERING }; /** * Possible template types for construct_default_request() */ enum { /** * Standard camera preview operation with 3A on auto. */ CAMERA2_TEMPLATE_PREVIEW = 1, /** * Standard camera high-quality still capture with 3A and flash on auto. */ CAMERA2_TEMPLATE_STILL_CAPTURE, /** * Standard video recording plus preview with 3A on auto, torch off. */ CAMERA2_TEMPLATE_VIDEO_RECORD, /** * High-quality still capture while recording video. Application will * include preview, video record, and full-resolution YUV or JPEG streams in * request. Must not cause stuttering on video stream. 3A on auto. */ CAMERA2_TEMPLATE_VIDEO_SNAPSHOT, /** * Zero-shutter-lag mode. Application will request preview and * full-resolution data for each frame, and reprocess it to JPEG when a * still image is requested by user. Settings should provide highest-quality * full-resolution images without compromising preview frame rate. 3A on * auto. */ CAMERA2_TEMPLATE_ZERO_SHUTTER_LAG, /* Total number of templates */ CAMERA2_TEMPLATE_COUNT }; /********************************************************************** * * Camera device operations * */ typedef struct camera2_device_ops { /********************************************************************** * Request and frame queue setup and management methods */ /** * Pass in input request queue interface methods. */ int (*set_request_queue_src_ops)(const struct camera2_device *, const camera2_request_queue_src_ops_t *request_src_ops); /** * Notify device that the request queue is no longer empty. Must only be * called when the first buffer is added a new queue, or after the source * has returned NULL in response to a dequeue call. */ int (*notify_request_queue_not_empty)(const struct camera2_device *); /** * Pass in output frame queue interface methods */ int (*set_frame_queue_dst_ops)(const struct camera2_device *, const camera2_frame_queue_dst_ops_t *frame_dst_ops); /** * Number of camera requests being processed by the device at the moment * (captures/reprocesses that have had their request dequeued, but have not * yet been enqueued onto output pipeline(s) ). No streams may be released * by the framework until the in-progress count is 0. */ int (*get_in_progress_count)(const struct camera2_device *); /** * Flush all in-progress captures. This includes all dequeued requests * (regular or reprocessing) that have not yet placed any outputs into a * stream or the frame queue. Partially completed captures must be completed * normally. No new requests may be dequeued from the request queue until * the flush completes. */ int (*flush_captures_in_progress)(const struct camera2_device *); /** * Create a filled-in default request for standard camera use cases. * * The device must return a complete request that is configured to meet the * requested use case, which must be one of the CAMERA2_TEMPLATE_* * enums. All request control fields must be included, except for * android.request.outputStreams. * * The metadata buffer returned must be allocated with * allocate_camera_metadata. The framework takes ownership of the buffer. */ int (*construct_default_request)(const struct camera2_device *, int request_template, camera_metadata_t **request); /********************************************************************** * Stream management */ /** * allocate_stream: * * Allocate a new output stream for use, defined by the output buffer width, * height, target, and possibly the pixel format. Returns the new stream's * ID, gralloc usage flags, minimum queue buffer count, and possibly the * pixel format, on success. Error conditions: * * - Requesting a width/height/format combination not listed as * supported by the sensor's static characteristics * * - Asking for too many streams of a given format type (2 bayer raw * streams, for example). * * Input parameters: * * - width, height, format: Specification for the buffers to be sent through * this stream. Format is a value from the HAL_PIXEL_FORMAT_* list. If * HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, then the platform * gralloc module will select a format based on the usage flags provided * by the camera HAL and the consumer of the stream. The camera HAL should * inspect the buffers handed to it in the register_stream_buffers call to * obtain the implementation-specific format if necessary. * * - stream_ops: A structure of function pointers for obtaining and queuing * up buffers for this stream. The underlying stream will be configured * based on the usage and max_buffers outputs. The methods in this * structure may not be called until after allocate_stream returns. * * Output parameters: * * - stream_id: An unsigned integer identifying this stream. This value is * used in incoming requests to identify the stream, and in releasing the * stream. * * - usage: The gralloc usage mask needed by the HAL device for producing * the requested type of data. This is used in allocating new gralloc * buffers for the stream buffer queue. * * - max_buffers: The maximum number of buffers the HAL device may need to * have dequeued at the same time. The device may not dequeue more buffers * than this value at the same time. * */ int (*allocate_stream)( const struct camera2_device *, // inputs uint32_t width, uint32_t height, int format, const camera2_stream_ops_t *stream_ops, // outputs uint32_t *stream_id, uint32_t *format_actual, // IGNORED, will be removed uint32_t *usage, uint32_t *max_buffers); /** * Register buffers for a given stream. This is called after a successful * allocate_stream call, and before the first request referencing the stream * is enqueued. This method is intended to allow the HAL device to map or * otherwise prepare the buffers for later use. num_buffers is guaranteed to * be at least max_buffers (from allocate_stream), but may be larger. The * buffers will already be locked for use. At the end of the call, all the * buffers must be ready to be returned to the queue. If the stream format * was set to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, the camera HAL should * inspect the passed-in buffers here to determine any platform-private * pixel format information. */ int (*register_stream_buffers)( const struct camera2_device *, uint32_t stream_id, int num_buffers, buffer_handle_t *buffers); /** * Release a stream. Returns an error if called when get_in_progress_count * is non-zero, or if the stream id is invalid. */ int (*release_stream)( const struct camera2_device *, uint32_t stream_id); /** * allocate_reprocess_stream: * * Allocate a new input stream for use, defined by the output buffer width, * height, and the pixel format. Returns the new stream's ID, gralloc usage * flags, and required simultaneously acquirable buffer count, on * success. Error conditions: * * - Requesting a width/height/format combination not listed as * supported by the sensor's static characteristics * * - Asking for too many reprocessing streams to be configured at once. * * Input parameters: * * - width, height, format: Specification for the buffers to be sent through * this stream. Format must be a value from the HAL_PIXEL_FORMAT_* list. * * - reprocess_stream_ops: A structure of function pointers for acquiring * and releasing buffers for this stream. The underlying stream will be * configured based on the usage and max_buffers outputs. * * Output parameters: * * - stream_id: An unsigned integer identifying this stream. This value is * used in incoming requests to identify the stream, and in releasing the * stream. These ids are numbered separately from the input stream ids. * * - consumer_usage: The gralloc usage mask needed by the HAL device for * consuming the requested type of data. This is used in allocating new * gralloc buffers for the stream buffer queue. * * - max_buffers: The maximum number of buffers the HAL device may need to * have acquired at the same time. The device may not have more buffers * acquired at the same time than this value. * */ int (*allocate_reprocess_stream)(const struct camera2_device *, uint32_t width, uint32_t height, uint32_t format, const camera2_stream_in_ops_t *reprocess_stream_ops, // outputs uint32_t *stream_id, uint32_t *consumer_usage, uint32_t *max_buffers); /** * allocate_reprocess_stream_from_stream: * * Allocate a new input stream for use, which will use the buffers allocated * for an existing output stream. That is, after the HAL enqueues a buffer * onto the output stream, it may see that same buffer handed to it from * this input reprocessing stream. After the HAL releases the buffer back to * the reprocessing stream, it will be returned to the output queue for * reuse. * * Error conditions: * * - Using an output stream of unsuitable size/format for the basis of the * reprocessing stream. * * - Attempting to allocatee too many reprocessing streams at once. * * Input parameters: * * - output_stream_id: The ID of an existing output stream which has * a size and format suitable for reprocessing. * * - reprocess_stream_ops: A structure of function pointers for acquiring * and releasing buffers for this stream. The underlying stream will use * the same graphics buffer handles as the output stream uses. * * Output parameters: * * - stream_id: An unsigned integer identifying this stream. This value is * used in incoming requests to identify the stream, and in releasing the * stream. These ids are numbered separately from the input stream ids. * * The HAL client must always release the reprocessing stream before it * releases the output stream it is based on. * */ int (*allocate_reprocess_stream_from_stream)(const struct camera2_device *, uint32_t output_stream_id, const camera2_stream_in_ops_t *reprocess_stream_ops, // outputs uint32_t *stream_id); /** * Release a reprocessing stream. Returns an error if called when * get_in_progress_count is non-zero, or if the stream id is not * valid. */ int (*release_reprocess_stream)( const struct camera2_device *, uint32_t stream_id); /********************************************************************** * Miscellaneous methods */ /** * Trigger asynchronous activity. This is used for triggering special * behaviors of the camera 3A routines when they are in use. See the * documentation for CAMERA2_TRIGGER_* above for details of the trigger ids * and their arguments. */ int (*trigger_action)(const struct camera2_device *, uint32_t trigger_id, int32_t ext1, int32_t ext2); /** * Notification callback setup */ int (*set_notify_callback)(const struct camera2_device *, camera2_notify_callback notify_cb, void *user); /** * Get methods to query for vendor extension metadata tag infomation. May * set ops to NULL if no vendor extension tags are defined. */ int (*get_metadata_vendor_tag_ops)(const struct camera2_device*, vendor_tag_query_ops_t **ops); /** * Dump state of the camera hardware */ int (*dump)(const struct camera2_device *, int fd); /** * Get device-instance-specific metadata. This metadata must be constant for * a single instance of the camera device, but may be different between * open() calls. The returned camera_metadata pointer must be valid until * the device close() method is called. * * Version information: * * CAMERA_DEVICE_API_VERSION_2_0: * * Not available. Framework may not access this function pointer. * * CAMERA_DEVICE_API_VERSION_2_1: * * Valid. Can be called by the framework. * */ int (*get_instance_metadata)(const struct camera2_device *, camera_metadata **instance_metadata); } camera2_device_ops_t; /********************************************************************** * * Camera device definition * */ typedef struct camera2_device { /** * common.version must equal CAMERA_DEVICE_API_VERSION_2_0 to identify * this device as implementing version 2.0 of the camera device HAL. */ hw_device_t common; camera2_device_ops_t *ops; void *priv; } camera2_device_t; __END_DECLS #endif /* #ifdef ANDROID_INCLUDE_CAMERA2_H */ android-headers-23/19/hardware/camera3.h000066400000000000000000002742261264465411000200630ustar00rootroot00000000000000/* * 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_CAMERA3_H #define ANDROID_INCLUDE_CAMERA3_H #include #include "camera_common.h" /** * Camera device HAL 3.1 [ CAMERA_DEVICE_API_VERSION_3_1 ] * * EXPERIMENTAL. * * Supports the android.hardware.Camera API. * * Camera devices that support this version of the HAL must return * CAMERA_DEVICE_API_VERSION_3_1 in camera_device_t.common.version and in * camera_info_t.device_version (from camera_module_t.get_camera_info). * * Camera modules that may contain version 3.1 devices must implement at least * version 2.0 of the camera module interface (as defined by * camera_module_t.common.module_api_version). * * See camera_common.h for more versioning details. * * Documentation index: * S1. Version history * S2. Startup and operation sequencing * S3. Operational modes * S4. 3A modes and state machines * S5. Cropping * S6. Error management */ /** * S1. Version history: * * 1.0: Initial Android camera HAL (Android 4.0) [camera.h]: * * - Converted from C++ CameraHardwareInterface abstraction layer. * * - Supports android.hardware.Camera API. * * 2.0: Initial release of expanded-capability HAL (Android 4.2) [camera2.h]: * * - Sufficient for implementing existing android.hardware.Camera API. * * - Allows for ZSL queue in camera service layer * * - Not tested for any new features such manual capture control, Bayer RAW * capture, reprocessing of RAW data. * * 3.0: First revision of expanded-capability HAL: * * - Major version change since the ABI is completely different. No change to * the required hardware capabilities or operational model from 2.0. * * - Reworked input request and stream queue interfaces: Framework calls into * HAL with next request and stream buffers already dequeued. Sync framework * support is included, necessary for efficient implementations. * * - Moved triggers into requests, most notifications into results. * * - Consolidated all callbacks into framework into one structure, and all * setup methods into a single initialize() call. * * - Made stream configuration into a single call to simplify stream * management. Bidirectional streams replace STREAM_FROM_STREAM construct. * * - Limited mode semantics for older/limited hardware devices. * * 3.1: Minor revision of expanded-capability HAL: * * - configure_streams passes consumer usage flags to the HAL. * * - flush call to drop all in-flight requests/buffers as fast as possible. */ /** * S2. Startup and general expected operation sequence: * * 1. Framework calls camera_module_t->common.open(), which returns a * hardware_device_t structure. * * 2. Framework inspects the hardware_device_t->version field, and instantiates * the appropriate handler for that version of the camera hardware device. In * case the version is CAMERA_DEVICE_API_VERSION_3_0, the device is cast to * a camera3_device_t. * * 3. Framework calls camera3_device_t->ops->initialize() with the framework * callback function pointers. This will only be called this one time after * open(), before any other functions in the ops structure are called. * * 4. The framework calls camera3_device_t->ops->configure_streams() with a list * of input/output streams to the HAL device. * * 5. The framework allocates gralloc buffers and calls * camera3_device_t->ops->register_stream_buffers() for at least one of the * output streams listed in configure_streams. The same stream is registered * only once. * * 5. The framework requests default settings for some number of use cases with * calls to camera3_device_t->ops->construct_default_request_settings(). This * may occur any time after step 3. * * 7. The framework constructs and sends the first capture request to the HAL, * with settings based on one of the sets of default settings, and with at * least one output stream, which has been registered earlier by the * framework. This is sent to the HAL with * camera3_device_t->ops->process_capture_request(). The HAL must block the * return of this call until it is ready for the next request to be sent. * * 8. The framework continues to submit requests, and possibly call * register_stream_buffers() for not-yet-registered streams, and call * construct_default_request_settings to get default settings buffers for * other use cases. * * 9. When the capture of a request begins (sensor starts exposing for the * capture), the HAL calls camera3_callback_ops_t->notify() with the SHUTTER * event, including the frame number and the timestamp for start of exposure. * This notify call must be made before the first call to * process_capture_result() for that frame number. * * 10. After some pipeline delay, the HAL begins to return completed captures to * the framework with camera3_callback_ops_t->process_capture_result(). These * are returned in the same order as the requests were submitted. Multiple * requests can be in flight at once, depending on the pipeline depth of the * camera HAL device. * * 11. After some time, the framework may stop submitting new requests, wait for * the existing captures to complete (all buffers filled, all results * returned), and then call configure_streams() again. This resets the camera * hardware and pipeline for a new set of input/output streams. Some streams * may be reused from the previous configuration; if these streams' buffers * had already been registered with the HAL, they will not be registered * again. The framework then continues from step 7, if at least one * registered output stream remains (otherwise, step 5 is required first). * * 12. Alternatively, the framework may call camera3_device_t->common->close() * to end the camera session. This may be called at any time when no other * calls from the framework are active, although the call may block until all * in-flight captures have completed (all results returned, all buffers * filled). After the close call returns, no more calls to the * camera3_callback_ops_t functions are allowed from the HAL. Once the * close() call is underway, the framework may not call any other HAL device * functions. * * 13. In case of an error or other asynchronous event, the HAL must call * camera3_callback_ops_t->notify() with the appropriate error/event * message. After returning from a fatal device-wide error notification, the * HAL should act as if close() had been called on it. However, the HAL must * either cancel or complete all outstanding captures before calling * notify(), so that once notify() is called with a fatal error, the * framework will not receive further callbacks from the device. Methods * besides close() should return -ENODEV or NULL after the notify() method * returns from a fatal error message. */ /** * S3. Operational modes: * * The camera 3 HAL device can implement one of two possible operational modes; * limited and full. Full support is expected from new higher-end * devices. Limited mode has hardware requirements roughly in line with those * for a camera HAL device v1 implementation, and is expected from older or * inexpensive devices. Full is a strict superset of limited, and they share the * same essential operational flow, as documented above. * * The HAL must indicate its level of support with the * android.info.supportedHardwareLevel static metadata entry, with 0 indicating * limited mode, and 1 indicating full mode support. * * Roughly speaking, limited-mode devices do not allow for application control * of capture settings (3A control only), high-rate capture of high-resolution * images, raw sensor readout, or support for YUV output streams above maximum * recording resolution (JPEG only for large images). * * ** Details of limited mode behavior: * * - Limited-mode devices do not need to implement accurate synchronization * between capture request settings and the actual image data * captured. Instead, changes to settings may take effect some time in the * future, and possibly not for the same output frame for each settings * entry. Rapid changes in settings may result in some settings never being * used for a capture. However, captures that include high-resolution output * buffers ( > 1080p ) have to use the settings as specified (but see below * for processing rate). * * - Limited-mode devices do not need to support most of the * settings/result/static info metadata. Full-mode devices must support all * metadata fields listed in TODO. Specifically, only the following settings * are expected to be consumed or produced by a limited-mode HAL device: * * android.control.aeAntibandingMode (controls) * android.control.aeExposureCompensation (controls) * android.control.aeLock (controls) * android.control.aeMode (controls) * [OFF means ON_FLASH_TORCH - TODO] * android.control.aeRegions (controls) * android.control.aeTargetFpsRange (controls) * android.control.afMode (controls) * [OFF means infinity focus] * android.control.afRegions (controls) * android.control.awbLock (controls) * android.control.awbMode (controls) * [OFF not supported] * android.control.awbRegions (controls) * android.control.captureIntent (controls) * android.control.effectMode (controls) * android.control.mode (controls) * [OFF not supported] * android.control.sceneMode (controls) * android.control.videoStabilizationMode (controls) * android.control.aeAvailableAntibandingModes (static) * android.control.aeAvailableModes (static) * android.control.aeAvailableTargetFpsRanges (static) * android.control.aeCompensationRange (static) * android.control.aeCompensationStep (static) * android.control.afAvailableModes (static) * android.control.availableEffects (static) * android.control.availableSceneModes (static) * android.control.availableVideoStabilizationModes (static) * android.control.awbAvailableModes (static) * android.control.maxRegions (static) * android.control.sceneModeOverrides (static) * android.control.aeRegions (dynamic) * android.control.aeState (dynamic) * android.control.afMode (dynamic) * android.control.afRegions (dynamic) * android.control.afState (dynamic) * android.control.awbMode (dynamic) * android.control.awbRegions (dynamic) * android.control.awbState (dynamic) * android.control.mode (dynamic) * * android.flash.info.available (static) * * android.info.supportedHardwareLevel (static) * * android.jpeg.gpsCoordinates (controls) * android.jpeg.gpsProcessingMethod (controls) * android.jpeg.gpsTimestamp (controls) * android.jpeg.orientation (controls) * android.jpeg.quality (controls) * android.jpeg.thumbnailQuality (controls) * android.jpeg.thumbnailSize (controls) * android.jpeg.availableThumbnailSizes (static) * android.jpeg.maxSize (static) * android.jpeg.gpsCoordinates (dynamic) * android.jpeg.gpsProcessingMethod (dynamic) * android.jpeg.gpsTimestamp (dynamic) * android.jpeg.orientation (dynamic) * android.jpeg.quality (dynamic) * android.jpeg.size (dynamic) * android.jpeg.thumbnailQuality (dynamic) * android.jpeg.thumbnailSize (dynamic) * * android.lens.info.minimumFocusDistance (static) * * android.request.id (controls) * android.request.id (dynamic) * * android.scaler.cropRegion (controls) * [ignores (x,y), assumes center-zoom] * android.scaler.availableFormats (static) * [RAW not supported] * android.scaler.availableJpegMinDurations (static) * android.scaler.availableJpegSizes (static) * android.scaler.availableMaxDigitalZoom (static) * android.scaler.availableProcessedMinDurations (static) * android.scaler.availableProcessedSizes (static) * [full resolution not supported] * android.scaler.maxDigitalZoom (static) * android.scaler.cropRegion (dynamic) * * android.sensor.orientation (static) * android.sensor.timestamp (dynamic) * * android.statistics.faceDetectMode (controls) * android.statistics.info.availableFaceDetectModes (static) * android.statistics.faceDetectMode (dynamic) * android.statistics.faceIds (dynamic) * android.statistics.faceLandmarks (dynamic) * android.statistics.faceRectangles (dynamic) * android.statistics.faceScores (dynamic) * * - Captures in limited mode that include high-resolution (> 1080p) output * buffers may block in process_capture_request() until all the output buffers * have been filled. A full-mode HAL device must process sequences of * high-resolution requests at the rate indicated in the static metadata for * that pixel format. The HAL must still call process_capture_result() to * provide the output; the framework must simply be prepared for * process_capture_request() to block until after process_capture_result() for * that request completes for high-resolution captures for limited-mode * devices. * */ /** * S4. 3A modes and state machines: * * While the actual 3A algorithms are up to the HAL implementation, a high-level * state machine description is defined by the HAL interface, to allow the HAL * device and the framework to communicate about the current state of 3A, and to * trigger 3A events. * * When the device is opened, all the individual 3A states must be * STATE_INACTIVE. Stream configuration does not reset 3A. For example, locked * focus must be maintained across the configure() call. * * Triggering a 3A action involves simply setting the relevant trigger entry in * the settings for the next request to indicate start of trigger. For example, * the trigger for starting an autofocus scan is setting the entry * ANDROID_CONTROL_AF_TRIGGER to ANDROID_CONTROL_AF_TRIGGER_START for one * request, and cancelling an autofocus scan is triggered by setting * ANDROID_CONTROL_AF_TRIGGER to ANDROID_CONTRL_AF_TRIGGER_CANCEL. Otherwise, * the entry will not exist, or be set to ANDROID_CONTROL_AF_TRIGGER_IDLE. Each * request with a trigger entry set to a non-IDLE value will be treated as an * independent triggering event. * * At the top level, 3A is controlled by the ANDROID_CONTROL_MODE setting, which * selects between no 3A (ANDROID_CONTROL_MODE_OFF), normal AUTO mode * (ANDROID_CONTROL_MODE_AUTO), and using the scene mode setting * (ANDROID_CONTROL_USE_SCENE_MODE). * * - In OFF mode, each of the individual AE/AF/AWB modes are effectively OFF, * and none of the capture controls may be overridden by the 3A routines. * * - In AUTO mode, Auto-focus, auto-exposure, and auto-whitebalance all run * their own independent algorithms, and have their own mode, state, and * trigger metadata entries, as listed in the next section. * * - In USE_SCENE_MODE, the value of the ANDROID_CONTROL_SCENE_MODE entry must * be used to determine the behavior of 3A routines. In SCENE_MODEs other than * FACE_PRIORITY, the HAL must override the values of * ANDROId_CONTROL_AE/AWB/AF_MODE to be the mode it prefers for the selected * SCENE_MODE. For example, the HAL may prefer SCENE_MODE_NIGHT to use * CONTINUOUS_FOCUS AF mode. Any user selection of AE/AWB/AF_MODE when scene * must be ignored for these scene modes. * * - For SCENE_MODE_FACE_PRIORITY, the AE/AWB/AF_MODE controls work as in * ANDROID_CONTROL_MODE_AUTO, but the 3A routines must bias toward metering * and focusing on any detected faces in the scene. * * S4.1. Auto-focus settings and result entries: * * Main metadata entries: * * ANDROID_CONTROL_AF_MODE: Control for selecting the current autofocus * mode. Set by the framework in the request settings. * * AF_MODE_OFF: AF is disabled; the framework/app directly controls lens * position. * * AF_MODE_AUTO: Single-sweep autofocus. No lens movement unless AF is * triggered. * * AF_MODE_MACRO: Single-sweep up-close autofocus. No lens movement unless * AF is triggered. * * AF_MODE_CONTINUOUS_VIDEO: Smooth continuous focusing, for recording * video. Triggering immediately locks focus in current * position. Canceling resumes cotinuous focusing. * * AF_MODE_CONTINUOUS_PICTURE: Fast continuous focusing, for * zero-shutter-lag still capture. Triggering locks focus once currently * active sweep concludes. Canceling resumes continuous focusing. * * AF_MODE_EDOF: Advanced extended depth of field focusing. There is no * autofocus scan, so triggering one or canceling one has no effect. * Images are focused automatically by the HAL. * * ANDROID_CONTROL_AF_STATE: Dynamic metadata describing the current AF * algorithm state, reported by the HAL in the result metadata. * * AF_STATE_INACTIVE: No focusing has been done, or algorithm was * reset. Lens is not moving. Always the state for MODE_OFF or MODE_EDOF. * When the device is opened, it must start in this state. * * AF_STATE_PASSIVE_SCAN: A continuous focus algorithm is currently scanning * for good focus. The lens is moving. * * AF_STATE_PASSIVE_FOCUSED: A continuous focus algorithm believes it is * well focused. The lens is not moving. The HAL may spontaneously leave * this state. * * AF_STATE_PASSIVE_UNFOCUSED: A continuous focus algorithm believes it is * not well focused. The lens is not moving. The HAL may spontaneously * leave this state. * * AF_STATE_ACTIVE_SCAN: A scan triggered by the user is underway. * * AF_STATE_FOCUSED_LOCKED: The AF algorithm believes it is focused. The * lens is not moving. * * AF_STATE_NOT_FOCUSED_LOCKED: The AF algorithm has been unable to * focus. The lens is not moving. * * ANDROID_CONTROL_AF_TRIGGER: Control for starting an autofocus scan, the * meaning of which is mode- and state- dependent. Set by the framework in * the request settings. * * AF_TRIGGER_IDLE: No current trigger. * * AF_TRIGGER_START: Trigger start of AF scan. Effect is mode and state * dependent. * * AF_TRIGGER_CANCEL: Cancel current AF scan if any, and reset algorithm to * default. * * Additional metadata entries: * * ANDROID_CONTROL_AF_REGIONS: Control for selecting the regions of the FOV * that should be used to determine good focus. This applies to all AF * modes that scan for focus. Set by the framework in the request * settings. * * S4.2. Auto-exposure settings and result entries: * * Main metadata entries: * * ANDROID_CONTROL_AE_MODE: Control for selecting the current auto-exposure * mode. Set by the framework in the request settings. * * AE_MODE_OFF: Autoexposure is disabled; the user controls exposure, gain, * frame duration, and flash. * * AE_MODE_ON: Standard autoexposure, with flash control disabled. User may * set flash to fire or to torch mode. * * AE_MODE_ON_AUTO_FLASH: Standard autoexposure, with flash on at HAL's * discretion for precapture and still capture. User control of flash * disabled. * * AE_MODE_ON_ALWAYS_FLASH: Standard autoexposure, with flash always fired * for capture, and at HAL's discretion for precapture.. User control of * flash disabled. * * AE_MODE_ON_AUTO_FLASH_REDEYE: Standard autoexposure, with flash on at * HAL's discretion for precapture and still capture. Use a flash burst * at end of precapture sequence to reduce redeye in the final * picture. User control of flash disabled. * * ANDROID_CONTROL_AE_STATE: Dynamic metadata describing the current AE * algorithm state, reported by the HAL in the result metadata. * * AE_STATE_INACTIVE: Initial AE state after mode switch. When the device is * opened, it must start in this state. * * AE_STATE_SEARCHING: AE is not converged to a good value, and is adjusting * exposure parameters. * * AE_STATE_CONVERGED: AE has found good exposure values for the current * scene, and the exposure parameters are not changing. HAL may * spontaneously leave this state to search for better solution. * * AE_STATE_LOCKED: AE has been locked with the AE_LOCK control. Exposure * values are not changing. * * AE_STATE_FLASH_REQUIRED: The HAL has converged exposure, but believes * flash is required for a sufficiently bright picture. Used for * determining if a zero-shutter-lag frame can be used. * * AE_STATE_PRECAPTURE: The HAL is in the middle of a precapture * sequence. Depending on AE mode, this mode may involve firing the * flash for metering, or a burst of flash pulses for redeye reduction. * * ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER: Control for starting a metering * sequence before capturing a high-quality image. Set by the framework in * the request settings. * * PRECAPTURE_TRIGGER_IDLE: No current trigger. * * PRECAPTURE_TRIGGER_START: Start a precapture sequence. The HAL should * use the subsequent requests to measure good exposure/white balance * for an upcoming high-resolution capture. * * Additional metadata entries: * * ANDROID_CONTROL_AE_LOCK: Control for locking AE controls to their current * values * * ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION: Control for adjusting AE * algorithm target brightness point. * * ANDROID_CONTROL_AE_TARGET_FPS_RANGE: Control for selecting the target frame * rate range for the AE algorithm. The AE routine cannot change the frame * rate to be outside these bounds. * * ANDROID_CONTROL_AE_REGIONS: Control for selecting the regions of the FOV * that should be used to determine good exposure levels. This applies to * all AE modes besides OFF. * * S4.3. Auto-whitebalance settings and result entries: * * Main metadata entries: * * ANDROID_CONTROL_AWB_MODE: Control for selecting the current white-balance * mode. * * AWB_MODE_OFF: Auto-whitebalance is disabled. User controls color matrix. * * AWB_MODE_AUTO: Automatic white balance is enabled; 3A controls color * transform, possibly using more complex transforms than a simple * matrix. * * AWB_MODE_INCANDESCENT: Fixed white balance settings good for indoor * incandescent (tungsten) lighting, roughly 2700K. * * AWB_MODE_FLUORESCENT: Fixed white balance settings good for fluorescent * lighting, roughly 5000K. * * AWB_MODE_WARM_FLUORESCENT: Fixed white balance settings good for * fluorescent lighting, roughly 3000K. * * AWB_MODE_DAYLIGHT: Fixed white balance settings good for daylight, * roughly 5500K. * * AWB_MODE_CLOUDY_DAYLIGHT: Fixed white balance settings good for clouded * daylight, roughly 6500K. * * AWB_MODE_TWILIGHT: Fixed white balance settings good for * near-sunset/sunrise, roughly 15000K. * * AWB_MODE_SHADE: Fixed white balance settings good for areas indirectly * lit by the sun, roughly 7500K. * * ANDROID_CONTROL_AWB_STATE: Dynamic metadata describing the current AWB * algorithm state, reported by the HAL in the result metadata. * * AWB_STATE_INACTIVE: Initial AWB state after mode switch. When the device * is opened, it must start in this state. * * AWB_STATE_SEARCHING: AWB is not converged to a good value, and is * changing color adjustment parameters. * * AWB_STATE_CONVERGED: AWB has found good color adjustment values for the * current scene, and the parameters are not changing. HAL may * spontaneously leave this state to search for better solution. * * AWB_STATE_LOCKED: AWB has been locked with the AWB_LOCK control. Color * adjustment values are not changing. * * Additional metadata entries: * * ANDROID_CONTROL_AWB_LOCK: Control for locking AWB color adjustments to * their current values. * * ANDROID_CONTROL_AWB_REGIONS: Control for selecting the regions of the FOV * that should be used to determine good color balance. This applies only * to auto-WB mode. * * S4.4. General state machine transition notes * * Switching between AF, AE, or AWB modes always resets the algorithm's state * to INACTIVE. Similarly, switching between CONTROL_MODE or * CONTROL_SCENE_MODE if CONTROL_MODE == USE_SCENE_MODE resets all the * algorithm states to INACTIVE. * * The tables below are per-mode. * * S4.5. AF state machines * * when enabling AF or changing AF mode *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| Any | AF mode change| INACTIVE | | *+--------------------+---------------+--------------------+------------------+ * * mode = AF_MODE_OFF or AF_MODE_EDOF *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | | INACTIVE | Never changes | *+--------------------+---------------+--------------------+------------------+ * * mode = AF_MODE_AUTO or AF_MODE_MACRO *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | AF_TRIGGER | ACTIVE_SCAN | Start AF sweep | *| | | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| ACTIVE_SCAN | AF sweep done | FOCUSED_LOCKED | If AF successful | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| ACTIVE_SCAN | AF sweep done | NOT_FOCUSED_LOCKED | If AF successful | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| ACTIVE_SCAN | AF_CANCEL | INACTIVE | Cancel/reset AF | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Cancel/reset AF | *+--------------------+---------------+--------------------+------------------+ *| FOCUSED_LOCKED | AF_TRIGGER | ACTIVE_SCAN | Start new sweep | *| | | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| NOT_FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Cancel/reset AF | *+--------------------+---------------+--------------------+------------------+ *| NOT_FOCUSED_LOCKED | AF_TRIGGER | ACTIVE_SCAN | Start new sweep | *| | | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| All states | mode change | INACTIVE | | *+--------------------+---------------+--------------------+------------------+ * * mode = AF_MODE_CONTINUOUS_VIDEO *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | HAL initiates | PASSIVE_SCAN | Start AF scan | *| | new scan | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | AF_TRIGGER | NOT_FOCUSED_LOCKED | AF state query | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | HAL completes | PASSIVE_FOCUSED | End AF scan | *| | current scan | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | HAL fails | PASSIVE_UNFOCUSED | End AF scan | *| | current scan | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | AF_TRIGGER | FOCUSED_LOCKED | Immediate trans. | *| | | | if focus is good | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | AF_TRIGGER | NOT_FOCUSED_LOCKED | Immediate trans. | *| | | | if focus is bad | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | AF_CANCEL | INACTIVE | Reset lens | *| | | | position | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_FOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan | *| | new scan | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_UNFOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan | *| | new scan | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_FOCUSED | AF_TRIGGER | FOCUSED_LOCKED | Immediate trans. | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_UNFOCUSED | AF_TRIGGER | NOT_FOCUSED_LOCKED | Immediate trans. | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| FOCUSED_LOCKED | AF_TRIGGER | FOCUSED_LOCKED | No effect | *+--------------------+---------------+--------------------+------------------+ *| FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan | *+--------------------+---------------+--------------------+------------------+ *| NOT_FOCUSED_LOCKED | AF_TRIGGER | NOT_FOCUSED_LOCKED | No effect | *+--------------------+---------------+--------------------+------------------+ *| NOT_FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan | *+--------------------+---------------+--------------------+------------------+ * * mode = AF_MODE_CONTINUOUS_PICTURE *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | HAL initiates | PASSIVE_SCAN | Start AF scan | *| | new scan | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | AF_TRIGGER | NOT_FOCUSED_LOCKED | AF state query | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | HAL completes | PASSIVE_FOCUSED | End AF scan | *| | current scan | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | HAL fails | PASSIVE_UNFOCUSED | End AF scan | *| | current scan | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | AF_TRIGGER | FOCUSED_LOCKED | Eventual trans. | *| | | | once focus good | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | AF_TRIGGER | NOT_FOCUSED_LOCKED | Eventual trans. | *| | | | if cannot focus | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | AF_CANCEL | INACTIVE | Reset lens | *| | | | position | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_FOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan | *| | new scan | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_UNFOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan | *| | new scan | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_FOCUSED | AF_TRIGGER | FOCUSED_LOCKED | Immediate trans. | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_UNFOCUSED | AF_TRIGGER | NOT_FOCUSED_LOCKED | Immediate trans. | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| FOCUSED_LOCKED | AF_TRIGGER | FOCUSED_LOCKED | No effect | *+--------------------+---------------+--------------------+------------------+ *| FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan | *+--------------------+---------------+--------------------+------------------+ *| NOT_FOCUSED_LOCKED | AF_TRIGGER | NOT_FOCUSED_LOCKED | No effect | *+--------------------+---------------+--------------------+------------------+ *| NOT_FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan | *+--------------------+---------------+--------------------+------------------+ * * S4.6. AE and AWB state machines * * The AE and AWB state machines are mostly identical. AE has additional * FLASH_REQUIRED and PRECAPTURE states. So rows below that refer to those two * states should be ignored for the AWB state machine. * * when enabling AE/AWB or changing AE/AWB mode *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| Any | mode change | INACTIVE | | *+--------------------+---------------+--------------------+------------------+ * * mode = AE_MODE_OFF / AWB mode not AUTO *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | | INACTIVE | AE/AWB disabled | *+--------------------+---------------+--------------------+------------------+ * * mode = AE_MODE_ON_* / AWB_MODE_AUTO *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | HAL initiates | SEARCHING | | *| | AE/AWB scan | | | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | AE/AWB_LOCK | LOCKED | values locked | *| | on | | | *+--------------------+---------------+--------------------+------------------+ *| SEARCHING | HAL finishes | CONVERGED | good values, not | *| | AE/AWB scan | | changing | *+--------------------+---------------+--------------------+------------------+ *| SEARCHING | HAL finishes | FLASH_REQUIRED | converged but too| *| | AE scan | | dark w/o flash | *+--------------------+---------------+--------------------+------------------+ *| SEARCHING | AE/AWB_LOCK | LOCKED | values locked | *| | on | | | *+--------------------+---------------+--------------------+------------------+ *| CONVERGED | HAL initiates | SEARCHING | values locked | *| | AE/AWB scan | | | *+--------------------+---------------+--------------------+------------------+ *| CONVERGED | AE/AWB_LOCK | LOCKED | values locked | *| | on | | | *+--------------------+---------------+--------------------+------------------+ *| FLASH_REQUIRED | HAL initiates | SEARCHING | values locked | *| | AE/AWB scan | | | *+--------------------+---------------+--------------------+------------------+ *| FLASH_REQUIRED | AE/AWB_LOCK | LOCKED | values locked | *| | on | | | *+--------------------+---------------+--------------------+------------------+ *| LOCKED | AE/AWB_LOCK | SEARCHING | values not good | *| | off | | after unlock | *+--------------------+---------------+--------------------+------------------+ *| LOCKED | AE/AWB_LOCK | CONVERGED | values good | *| | off | | after unlock | *+--------------------+---------------+--------------------+------------------+ *| LOCKED | AE_LOCK | FLASH_REQUIRED | exposure good, | *| | off | | but too dark | *+--------------------+---------------+--------------------+------------------+ *| All AE states | PRECAPTURE_ | PRECAPTURE | Start precapture | *| | START | | sequence | *+--------------------+---------------+--------------------+------------------+ *| PRECAPTURE | Sequence done.| CONVERGED | Ready for high- | *| | AE_LOCK off | | quality capture | *+--------------------+---------------+--------------------+------------------+ *| PRECAPTURE | Sequence done.| LOCKED | Ready for high- | *| | AE_LOCK on | | quality capture | *+--------------------+---------------+--------------------+------------------+ * */ /** * S5. Cropping: * * Cropping of the full pixel array (for digital zoom and other use cases where * a smaller FOV is desirable) is communicated through the * ANDROID_SCALER_CROP_REGION setting. This is a per-request setting, and can * change on a per-request basis, which is critical for implementing smooth * digital zoom. * * The region is defined as a rectangle (x, y, width, height), with (x, y) * describing the top-left corner of the rectangle. The rectangle is defined on * the coordinate system of the sensor active pixel array, with (0,0) being the * top-left pixel of the active pixel array. Therefore, the width and height * cannot be larger than the dimensions reported in the * ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY static info field. The minimum allowed * width and height are reported by the HAL through the * ANDROID_SCALER_MAX_DIGITAL_ZOOM static info field, which describes the * maximum supported zoom factor. Therefore, the minimum crop region width and * height are: * * {width, height} = * { floor(ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY[0] / * ANDROID_SCALER_MAX_DIGITAL_ZOOM), * floor(ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY[1] / * ANDROID_SCALER_MAX_DIGITAL_ZOOM) } * * If the crop region needs to fulfill specific requirements (for example, it * needs to start on even coordinates, and its width/height needs to be even), * the HAL must do the necessary rounding and write out the final crop region * used in the output result metadata. Similarly, if the HAL implements video * stabilization, it must adjust the result crop region to describe the region * actually included in the output after video stabilization is applied. In * general, a camera-using application must be able to determine the field of * view it is receiving based on the crop region, the dimensions of the image * sensor, and the lens focal length. * * Since the crop region applies to all streams, which may have different aspect * ratios than the crop region, the exact sensor region used for each stream may * be smaller than the crop region. Specifically, each stream should maintain * square pixels and its aspect ratio by minimally further cropping the defined * crop region. If the stream's aspect ratio is wider than the crop region, the * stream should be further cropped vertically, and if the stream's aspect ratio * is narrower than the crop region, the stream should be further cropped * horizontally. * * In all cases, the stream crop must be centered within the full crop region, * and each stream is only either cropped horizontally or vertical relative to * the full crop region, never both. * * For example, if two streams are defined, a 640x480 stream (4:3 aspect), and a * 1280x720 stream (16:9 aspect), below demonstrates the expected output regions * for each stream for a few sample crop regions, on a hypothetical 3 MP (2000 x * 1500 pixel array) sensor. * * Crop region: (500, 375, 1000, 750) (4:3 aspect ratio) * * 640x480 stream crop: (500, 375, 1000, 750) (equal to crop region) * 1280x720 stream crop: (500, 469, 1000, 562) (marked with =) * * 0 1000 2000 * +---------+---------+---------+----------+ * | Active pixel array | * | | * | | * + +-------------------+ + 375 * | | | | * | O===================O | * | I 1280x720 stream I | * + I I + 750 * | I I | * | O===================O | * | | | | * + +-------------------+ + 1125 * | Crop region, 640x480 stream | * | | * | | * +---------+---------+---------+----------+ 1500 * * Crop region: (500, 375, 1333, 750) (16:9 aspect ratio) * * 640x480 stream crop: (666, 375, 1000, 750) (marked with =) * 1280x720 stream crop: (500, 375, 1333, 750) (equal to crop region) * * 0 1000 2000 * +---------+---------+---------+----------+ * | Active pixel array | * | | * | | * + +---O==================O---+ + 375 * | | I 640x480 stream I | | * | | I I | | * | | I I | | * + | I I | + 750 * | | I I | | * | | I I | | * | | I I | | * + +---O==================O---+ + 1125 * | Crop region, 1280x720 stream | * | | * | | * +---------+---------+---------+----------+ 1500 * * Crop region: (500, 375, 750, 750) (1:1 aspect ratio) * * 640x480 stream crop: (500, 469, 750, 562) (marked with =) * 1280x720 stream crop: (500, 543, 750, 414) (marged with #) * * 0 1000 2000 * +---------+---------+---------+----------+ * | Active pixel array | * | | * | | * + +--------------+ + 375 * | O==============O | * | ################ | * | # # | * + # # + 750 * | # # | * | ################ 1280x720 | * | O==============O 640x480 | * + +--------------+ + 1125 * | Crop region | * | | * | | * +---------+---------+---------+----------+ 1500 * * And a final example, a 1024x1024 square aspect ratio stream instead of the * 480p stream: * * Crop region: (500, 375, 1000, 750) (4:3 aspect ratio) * * 1024x1024 stream crop: (625, 375, 750, 750) (marked with #) * 1280x720 stream crop: (500, 469, 1000, 562) (marked with =) * * 0 1000 2000 * +---------+---------+---------+----------+ * | Active pixel array | * | | * | 1024x1024 stream | * + +--###############--+ + 375 * | | # # | | * | O===================O | * | I 1280x720 stream I | * + I I + 750 * | I I | * | O===================O | * | | # # | | * + +--###############--+ + 1125 * | Crop region | * | | * | | * +---------+---------+---------+----------+ 1500 * */ /** * S6. Error management: * * Camera HAL device ops functions that have a return value will all return * -ENODEV / NULL in case of a serious error. This means the device cannot * continue operation, and must be closed by the framework. Once this error is * returned by some method, or if notify() is called with ERROR_DEVICE, only * the close() method can be called successfully. All other methods will return * -ENODEV / NULL. * * If a device op is called in the wrong sequence, for example if the framework * calls configure_streams() is called before initialize(), the device must * return -ENOSYS from the call, and do nothing. * * Transient errors in image capture must be reported through notify() as follows: * * - The failure of an entire capture to occur must be reported by the HAL by * calling notify() with ERROR_REQUEST. Individual errors for the result * metadata or the output buffers must not be reported in this case. * * - If the metadata for a capture cannot be produced, but some image buffers * were filled, the HAL must call notify() with ERROR_RESULT. * * - If an output image buffer could not be filled, but either the metadata was * produced or some other buffers were filled, the HAL must call notify() with * ERROR_BUFFER for each failed buffer. * * In each of these transient failure cases, the HAL must still call * process_capture_result, with valid output buffer_handle_t. If the result * metadata could not be produced, it should be NULL. If some buffers could not * be filled, their sync fences must be set to the error state. * * Invalid input arguments result in -EINVAL from the appropriate methods. In * that case, the framework must act as if that call had never been made. * */ __BEGIN_DECLS struct camera3_device; /********************************************************************** * * Camera3 stream and stream buffer definitions. * * These structs and enums define the handles and contents of the input and * output streams connecting the HAL to various framework and application buffer * consumers. Each stream is backed by a gralloc buffer queue. * */ /** * camera3_stream_type_t: * * The type of the camera stream, which defines whether the camera HAL device is * the producer or the consumer for that stream, and how the buffers of the * stream relate to the other streams. */ typedef enum camera3_stream_type { /** * This stream is an output stream; the camera HAL device will be * responsible for filling buffers from this stream with newly captured or * reprocessed image data. */ CAMERA3_STREAM_OUTPUT = 0, /** * This stream is an input stream; the camera HAL device will be responsible * for reading buffers from this stream and sending them through the camera * processing pipeline, as if the buffer was a newly captured image from the * imager. */ CAMERA3_STREAM_INPUT = 1, /** * This stream can be used for input and output. Typically, the stream is * used as an output stream, but occasionally one already-filled buffer may * be sent back to the HAL device for reprocessing. * * This kind of stream is meant generally for zero-shutter-lag features, * where copying the captured image from the output buffer to the * reprocessing input buffer would be expensive. The stream will be used by * the framework as follows: * * 1. The framework includes a buffer from this stream as output buffer in a * request as normal. * * 2. Once the HAL device returns a filled output buffer to the framework, * the framework may do one of two things with the filled buffer: * * 2. a. The framework uses the filled data, and returns the now-used buffer * to the stream queue for reuse. This behavior exactly matches the * OUTPUT type of stream. * * 2. b. The framework wants to reprocess the filled data, and uses the * buffer as an input buffer for a request. Once the HAL device has * used the reprocessing buffer, it then returns it to the * framework. The framework then returns the now-used buffer to the * stream queue for reuse. * * 3. The HAL device will be given the buffer again as an output buffer for * a request at some future point. * * Note that the HAL will always be reprocessing data it produced. * */ CAMERA3_STREAM_BIDIRECTIONAL = 2, /** * Total number of framework-defined stream types */ CAMERA3_NUM_STREAM_TYPES } camera3_stream_type_t; /** * camera3_stream_t: * * A handle to a single camera input or output stream. A stream is defined by * the framework by its buffer resolution and format, and additionally by the * HAL with the gralloc usage flags and the maximum in-flight buffer count. * * The stream structures are owned by the framework, but pointers to a * camera3_stream passed into the HAL by configure_streams() are valid until the * end of the first subsequent configure_streams() call that _does not_ include * that camera3_stream as an argument, or until the end of the close() call. * * All camera3_stream framework-controlled members are immutable once the * camera3_stream is passed into configure_streams(). The HAL may only change * the HAL-controlled parameters during a configure_streams() call, except for * the contents of the private pointer. * * If a configure_streams() call returns a non-fatal error, all active streams * remain valid as if configure_streams() had not been called. * * The endpoint of the stream is not visible to the camera HAL device. * In DEVICE_API_VERSION_3_1, this was changed to share consumer usage flags * on streams where the camera is a producer (OUTPUT and BIDIRECTIONAL stream * types) see the usage field below. */ typedef struct camera3_stream { /***** * Set by framework before configure_streams() */ /** * The type of the stream, one of the camera3_stream_type_t values. */ int stream_type; /** * The width in pixels of the buffers in this stream */ uint32_t width; /** * The height in pixels of the buffers in this stream */ uint32_t height; /** * The pixel format for the buffers in this stream. Format is a value from * the HAL_PIXEL_FORMAT_* list in system/core/include/system/graphics.h, or * from device-specific headers. * * If HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, then the platform * gralloc module will select a format based on the usage flags provided by * the camera device and the other endpoint of the stream. * * The camera HAL device must inspect the buffers handed to it in the * subsequent register_stream_buffers() call to obtain the * implementation-specific format details, if necessary. */ int format; /***** * Set by HAL during configure_streams(). */ /** * The gralloc usage flags for this stream, as needed by the HAL. The usage * flags are defined in gralloc.h (GRALLOC_USAGE_*), or in device-specific * headers. * * For output streams, these are the HAL's producer usage flags. For input * streams, these are the HAL's consumer usage flags. The usage flags from * the producer and the consumer will be combined together and then passed * to the platform gralloc HAL module for allocating the gralloc buffers for * each stream. * * Version information: * * == CAMERA_DEVICE_API_VERSION_3_0: * * No initial value guaranteed when passed via configure_streams(). * HAL may not use this field as input, and must write over this field * with its usage flags. * * >= CAMERA_DEVICE_API_VERSION_3_1: * * For stream_type OUTPUT and BIDIRECTIONAL, when passed via * configure_streams(), the initial value of this is the consumer's * usage flags. The HAL may use these consumer flags to decide stream * configuration. * For stream_type INPUT, when passed via configure_streams(), the initial * value of this is 0. * For all streams passed via configure_streams(), the HAL must write * over this field with its usage flags. */ uint32_t usage; /** * The maximum number of buffers the HAL device may need to have dequeued at * the same time. The HAL device may not have more buffers in-flight from * this stream than this value. */ uint32_t max_buffers; /** * A handle to HAL-private information for the stream. Will not be inspected * by the framework code. */ void *priv; } camera3_stream_t; /** * camera3_stream_configuration_t: * * A structure of stream definitions, used by configure_streams(). This * structure defines all the output streams and the reprocessing input * stream for the current camera use case. */ typedef struct camera3_stream_configuration { /** * The total number of streams requested by the framework. This includes * both input and output streams. The number of streams will be at least 1, * and there will be at least one output-capable stream. */ uint32_t num_streams; /** * An array of camera stream pointers, defining the input/output * configuration for the camera HAL device. * * At most one input-capable stream may be defined (INPUT or BIDIRECTIONAL) * in a single configuration. * * At least one output-capable stream must be defined (OUTPUT or * BIDIRECTIONAL). */ camera3_stream_t **streams; } camera3_stream_configuration_t; /** * camera3_buffer_status_t: * * The current status of a single stream buffer. */ typedef enum camera3_buffer_status { /** * The buffer is in a normal state, and can be used after waiting on its * sync fence. */ CAMERA3_BUFFER_STATUS_OK = 0, /** * The buffer does not contain valid data, and the data in it should not be * used. The sync fence must still be waited on before reusing the buffer. */ CAMERA3_BUFFER_STATUS_ERROR = 1 } camera3_buffer_status_t; /** * camera3_stream_buffer_t: * * A single buffer from a camera3 stream. It includes a handle to its parent * stream, the handle to the gralloc buffer itself, and sync fences * * The buffer does not specify whether it is to be used for input or output; * that is determined by its parent stream type and how the buffer is passed to * the HAL device. */ typedef struct camera3_stream_buffer { /** * The handle of the stream this buffer is associated with */ camera3_stream_t *stream; /** * The native handle to the buffer */ buffer_handle_t *buffer; /** * Current state of the buffer, one of the camera3_buffer_status_t * values. The framework will not pass buffers to the HAL that are in an * error state. In case a buffer could not be filled by the HAL, it must * have its status set to CAMERA3_BUFFER_STATUS_ERROR when returned to the * framework with process_capture_result(). */ int status; /** * The acquire sync fence for this buffer. The HAL must wait on this fence * fd before attempting to read from or write to this buffer. * * The framework may be set to -1 to indicate that no waiting is necessary * for this buffer. * * When the HAL returns an output buffer to the framework with * process_capture_result(), the acquire_fence must be set to -1. If the HAL * never waits on the acquire_fence due to an error in filling a buffer, * when calling process_capture_result() the HAL must set the release_fence * of the buffer to be the acquire_fence passed to it by the framework. This * will allow the framework to wait on the fence before reusing the buffer. * * For input buffers, the HAL must not change the acquire_fence field during * the process_capture_request() call. */ int acquire_fence; /** * The release sync fence for this buffer. The HAL must set this fence when * returning buffers to the framework, or write -1 to indicate that no * waiting is required for this buffer. * * For the input buffer, the release fence must be set by the * process_capture_request() call. For the output buffers, the fences must * be set in the output_buffers array passed to process_capture_result(). * */ int release_fence; } camera3_stream_buffer_t; /** * camera3_stream_buffer_set_t: * * The complete set of gralloc buffers for a stream. This structure is given to * register_stream_buffers() to allow the camera HAL device to register/map/etc * newly allocated stream buffers. */ typedef struct camera3_stream_buffer_set { /** * The stream handle for the stream these buffers belong to */ camera3_stream_t *stream; /** * The number of buffers in this stream. It is guaranteed to be at least * stream->max_buffers. */ uint32_t num_buffers; /** * The array of gralloc buffer handles for this stream. If the stream format * is set to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, the camera HAL device * should inspect the passed-in buffers to determine any platform-private * pixel format information. */ buffer_handle_t **buffers; } camera3_stream_buffer_set_t; /** * camera3_jpeg_blob: * * Transport header for compressed JPEG buffers in output streams. * * To capture JPEG images, a stream is created using the pixel format * HAL_PIXEL_FORMAT_BLOB, and the static metadata field android.jpeg.maxSize is * used as the buffer size. Since compressed JPEG images are of variable size, * the HAL needs to include the final size of the compressed image using this * structure inside the output stream buffer. The JPEG blob ID field must be set * to CAMERA3_JPEG_BLOB_ID. * * Transport header should be at the end of the JPEG output stream buffer. That * means the jpeg_blob_id must start at byte[android.jpeg.maxSize - * sizeof(camera3_jpeg_blob)]. Any HAL using this transport header must * account for it in android.jpeg.maxSize. The JPEG data itself starts at * the beginning of the buffer and should be jpeg_size bytes long. */ typedef struct camera3_jpeg_blob { uint16_t jpeg_blob_id; uint32_t jpeg_size; } camera3_jpeg_blob_t; enum { CAMERA3_JPEG_BLOB_ID = 0x00FF }; /********************************************************************** * * Message definitions for the HAL notify() callback. * * These definitions are used for the HAL notify callback, to signal * asynchronous events from the HAL device to the Android framework. * */ /** * camera3_msg_type: * * Indicates the type of message sent, which specifies which member of the * message union is valid. * */ typedef enum camera3_msg_type { /** * An error has occurred. camera3_notify_msg.message.error contains the * error information. */ CAMERA3_MSG_ERROR = 1, /** * The exposure of a given request has * begun. camera3_notify_msg.message.shutter contains the information * the capture. */ CAMERA3_MSG_SHUTTER = 2, /** * Number of framework message types */ CAMERA3_NUM_MESSAGES } camera3_msg_type_t; /** * Defined error codes for CAMERA_MSG_ERROR */ typedef enum camera3_error_msg_code { /** * A serious failure occured. No further frames or buffer streams will * be produced by the device. Device should be treated as closed. The * client must reopen the device to use it again. The frame_number field * is unused. */ CAMERA3_MSG_ERROR_DEVICE = 1, /** * An error has occurred in processing a request. No output (metadata or * buffers) will be produced for this request. The frame_number field * specifies which request has been dropped. Subsequent requests are * unaffected, and the device remains operational. */ CAMERA3_MSG_ERROR_REQUEST = 2, /** * An error has occurred in producing an output result metadata buffer * for a request, but output stream buffers for it will still be * available. Subsequent requests are unaffected, and the device remains * operational. The frame_number field specifies the request for which * result metadata won't be available. */ CAMERA3_MSG_ERROR_RESULT = 3, /** * An error has occurred in placing an output buffer into a stream for a * request. The frame metadata and other buffers may still be * available. Subsequent requests are unaffected, and the device remains * operational. The frame_number field specifies the request for which the * buffer was dropped, and error_stream contains a pointer to the stream * that dropped the frame.u */ CAMERA3_MSG_ERROR_BUFFER = 4, /** * Number of error types */ CAMERA3_MSG_NUM_ERRORS } camera3_error_msg_code_t; /** * camera3_error_msg_t: * * Message contents for CAMERA3_MSG_ERROR */ typedef struct camera3_error_msg { /** * Frame number of the request the error applies to. 0 if the frame number * isn't applicable to the error. */ uint32_t frame_number; /** * Pointer to the stream that had a failure. NULL if the stream isn't * applicable to the error. */ camera3_stream_t *error_stream; /** * The code for this error; one of the CAMERA_MSG_ERROR enum values. */ int error_code; } camera3_error_msg_t; /** * camera3_shutter_msg_t: * * Message contents for CAMERA3_MSG_SHUTTER */ typedef struct camera3_shutter_msg { /** * Frame number of the request that has begun exposure */ uint32_t frame_number; /** * Timestamp for the start of capture. This must match the capture result * metadata's sensor exposure start timestamp. */ uint64_t timestamp; } camera3_shutter_msg_t; /** * camera3_notify_msg_t: * * The message structure sent to camera3_callback_ops_t.notify() */ typedef struct camera3_notify_msg { /** * The message type. One of camera3_notify_msg_type, or a private extension. */ int type; union { /** * Error message contents. Valid if type is CAMERA3_MSG_ERROR */ camera3_error_msg_t error; /** * Shutter message contents. Valid if type is CAMERA3_MSG_SHUTTER */ camera3_shutter_msg_t shutter; /** * Generic message contents. Used to ensure a minimum size for custom * message types. */ uint8_t generic[32]; } message; } camera3_notify_msg_t; /********************************************************************** * * Capture request/result definitions for the HAL process_capture_request() * method, and the process_capture_result() callback. * */ /** * camera3_request_template_t: * * Available template types for * camera3_device_ops.construct_default_request_settings() */ typedef enum camera3_request_template { /** * Standard camera preview operation with 3A on auto. */ CAMERA3_TEMPLATE_PREVIEW = 1, /** * Standard camera high-quality still capture with 3A and flash on auto. */ CAMERA3_TEMPLATE_STILL_CAPTURE = 2, /** * Standard video recording plus preview with 3A on auto, torch off. */ CAMERA3_TEMPLATE_VIDEO_RECORD = 3, /** * High-quality still capture while recording video. Application will * include preview, video record, and full-resolution YUV or JPEG streams in * request. Must not cause stuttering on video stream. 3A on auto. */ CAMERA3_TEMPLATE_VIDEO_SNAPSHOT = 4, /** * Zero-shutter-lag mode. Application will request preview and * full-resolution data for each frame, and reprocess it to JPEG when a * still image is requested by user. Settings should provide highest-quality * full-resolution images without compromising preview frame rate. 3A on * auto. */ CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG = 5, /* Total number of templates */ CAMERA3_TEMPLATE_COUNT, /** * First value for vendor-defined request templates */ CAMERA3_VENDOR_TEMPLATE_START = 0x40000000 } camera3_request_template_t; /** * camera3_capture_request_t: * * A single request for image capture/buffer reprocessing, sent to the Camera * HAL device by the framework in process_capture_request(). * * The request contains the settings to be used for this capture, and the set of * output buffers to write the resulting image data in. It may optionally * contain an input buffer, in which case the request is for reprocessing that * input buffer instead of capturing a new image with the camera sensor. The * capture is identified by the frame_number. * * In response, the camera HAL device must send a camera3_capture_result * structure asynchronously to the framework, using the process_capture_result() * callback. */ typedef struct camera3_capture_request { /** * The frame number is an incrementing integer set by the framework to * uniquely identify this capture. It needs to be returned in the result * call, and is also used to identify the request in asynchronous * notifications sent to camera3_callback_ops_t.notify(). */ uint32_t frame_number; /** * The settings buffer contains the capture and processing parameters for * the request. As a special case, a NULL settings buffer indicates that the * settings are identical to the most-recently submitted capture request. A * NULL buffer cannot be used as the first submitted request after a * configure_streams() call. */ const camera_metadata_t *settings; /** * The input stream buffer to use for this request, if any. * * If input_buffer is NULL, then the request is for a new capture from the * imager. If input_buffer is valid, the request is for reprocessing the * image contained in input_buffer. * * In the latter case, the HAL must set the release_fence of the * input_buffer to a valid sync fence, or to -1 if the HAL does not support * sync, before process_capture_request() returns. * * The HAL is required to wait on the acquire sync fence of the input buffer * before accessing it. * * Any input buffer included here will have been registered with the HAL * through register_stream_buffers() before its inclusion in a request. */ camera3_stream_buffer_t *input_buffer; /** * The number of output buffers for this capture request. Must be at least * 1. */ uint32_t num_output_buffers; /** * An array of num_output_buffers stream buffers, to be filled with image * data from this capture/reprocess. The HAL must wait on the acquire fences * of each stream buffer before writing to them. All the buffers included * here will have been registered with the HAL through * register_stream_buffers() before their inclusion in a request. * * The HAL takes ownership of the actual buffer_handle_t entries in * output_buffers; the framework does not access them until they are * returned in a camera3_capture_result_t. */ const camera3_stream_buffer_t *output_buffers; } camera3_capture_request_t; /** * camera3_capture_result_t: * * The result of a single capture/reprocess by the camera HAL device. This is * sent to the framework asynchronously with process_capture_result(), in * response to a single capture request sent to the HAL with * process_capture_request(). Multiple process_capture_result() calls may be * performed by the HAL for each request. Each call, all with the same frame * number, may contain some subset of the output buffers, and/or the result * metadata. The metadata may only be provided once for a given frame number; * all other calls must set the result metadata to NULL. * * The result structure contains the output metadata from this capture, and the * set of output buffers that have been/will be filled for this capture. Each * output buffer may come with a release sync fence that the framework will wait * on before reading, in case the buffer has not yet been filled by the HAL. * */ typedef struct camera3_capture_result { /** * The frame number is an incrementing integer set by the framework in the * submitted request to uniquely identify this capture. It is also used to * identify the request in asynchronous notifications sent to * camera3_callback_ops_t.notify(). */ uint32_t frame_number; /** * The result metadata for this capture. This contains information about the * final capture parameters, the state of the capture and post-processing * hardware, the state of the 3A algorithms, if enabled, and the output of * any enabled statistics units. * * Only one call to process_capture_result() with a given frame_number may * include the result metadata. All other calls for the same frame_number * must set this to NULL. * * If there was an error producing the result metadata, result must be an * empty metadata buffer, and notify() must be called with ERROR_RESULT. */ const camera_metadata_t *result; /** * The number of output buffers returned in this result structure. Must be * less than or equal to the matching capture request's count. If this is * less than the buffer count in the capture request, at least one more call * to process_capture_result with the same frame_number must be made, to * return the remaining output buffers to the framework. This may only be * zero if the structure includes valid result metadata. */ uint32_t num_output_buffers; /** * The handles for the output stream buffers for this capture. They may not * yet be filled at the time the HAL calls process_capture_result(); the * framework will wait on the release sync fences provided by the HAL before * reading the buffers. * * The HAL must set the stream buffer's release sync fence to a valid sync * fd, or to -1 if the buffer has already been filled. * * If the HAL encounters an error while processing the buffer, and the * buffer is not filled, the buffer's status field must be set to * CAMERA3_BUFFER_STATUS_ERROR. If the HAL did not wait on the acquire fence * before encountering the error, the acquire fence should be copied into * the release fence, to allow the framework to wait on the fence before * reusing the buffer. * * The acquire fence must be set to -1 for all output buffers. If * num_output_buffers is zero, this may be NULL. In that case, at least one * more process_capture_result call must be made by the HAL to provide the * output buffers. */ const camera3_stream_buffer_t *output_buffers; } camera3_capture_result_t; /********************************************************************** * * Callback methods for the HAL to call into the framework. * * These methods are used to return metadata and image buffers for a completed * or failed captures, and to notify the framework of asynchronous events such * as errors. * * The framework will not call back into the HAL from within these callbacks, * and these calls will not block for extended periods. * */ typedef struct camera3_callback_ops { /** * process_capture_result: * * Send results from a completed capture to the framework. * process_capture_result() may be invoked multiple times by the HAL in * response to a single capture request. This allows, for example, the * metadata and low-resolution buffers to be returned in one call, and * post-processed JPEG buffers in a later call, once it is available. Each * call must include the frame number of the request it is returning * metadata or buffers for. * * A component (buffer or metadata) of the complete result may only be * included in one process_capture_result call. A buffer for each stream, * and the result metadata, must be returned by the HAL for each request in * one of the process_capture_result calls, even in case of errors producing * some of the output. A call to process_capture_result() with neither * output buffers or result metadata is not allowed. * * The order of returning metadata and buffers for a single result does not * matter, but buffers for a given stream must be returned in FIFO order. So * the buffer for request 5 for stream A must always be returned before the * buffer for request 6 for stream A. This also applies to the result * metadata; the metadata for request 5 must be returned before the metadata * for request 6. * * However, different streams are independent of each other, so it is * acceptable and expected that the buffer for request 5 for stream A may be * returned after the buffer for request 6 for stream B is. And it is * acceptable that the result metadata for request 6 for stream B is * returned before the buffer for request 5 for stream A is. * * The HAL retains ownership of result structure, which only needs to be * valid to access during this call. The framework will copy whatever it * needs before this call returns. * * The output buffers do not need to be filled yet; the framework will wait * on the stream buffer release sync fence before reading the buffer * data. Therefore, this method should be called by the HAL as soon as * possible, even if some or all of the output buffers are still in * being filled. The HAL must include valid release sync fences into each * output_buffers stream buffer entry, or -1 if that stream buffer is * already filled. * * If the result buffer cannot be constructed for a request, the HAL should * return an empty metadata buffer, but still provide the output buffers and * their sync fences. In addition, notify() must be called with an * ERROR_RESULT message. * * If an output buffer cannot be filled, its status field must be set to * STATUS_ERROR. In addition, notify() must be called with a ERROR_BUFFER * message. * * If the entire capture has failed, then this method still needs to be * called to return the output buffers to the framework. All the buffer * statuses should be STATUS_ERROR, and the result metadata should be an * empty buffer. In addition, notify() must be called with a ERROR_REQUEST * message. In this case, individual ERROR_RESULT/ERROR_BUFFER messages * should not be sent. * */ void (*process_capture_result)(const struct camera3_callback_ops *, const camera3_capture_result_t *result); /** * notify: * * Asynchronous notification callback from the HAL, fired for various * reasons. Only for information independent of frame capture, or that * require specific timing. The ownership of the message structure remains * with the HAL, and the msg only needs to be valid for the duration of this * call. * * The notification for the start of exposure for a given request must be * sent by the HAL before the first call to process_capture_result() for * that request is made. * * Multiple threads may call notify() simultaneously. */ void (*notify)(const struct camera3_callback_ops *, const camera3_notify_msg_t *msg); } camera3_callback_ops_t; /********************************************************************** * * Camera device operations * */ typedef struct camera3_device_ops { /** * initialize: * * One-time initialization to pass framework callback function pointers to * the HAL. Will be called once after a successful open() call, before any * other functions are called on the camera3_device_ops structure. * * Return values: * * 0: On successful initialization * * -ENODEV: If initialization fails. Only close() can be called successfully * by the framework after this. */ int (*initialize)(const struct camera3_device *, const camera3_callback_ops_t *callback_ops); /********************************************************************** * Stream management */ /** * configure_streams: * * Reset the HAL camera device processing pipeline and set up new input and * output streams. This call replaces any existing stream configuration with * the streams defined in the stream_list. This method will be called at * least once after initialize() before a request is submitted with * process_capture_request(). * * The stream_list must contain at least one output-capable stream, and may * not contain more than one input-capable stream. * * The stream_list may contain streams that are also in the currently-active * set of streams (from the previous call to configure_stream()). These * streams will already have valid values for usage, max_buffers, and the * private pointer. If such a stream has already had its buffers registered, * register_stream_buffers() will not be called again for the stream, and * buffers from the stream can be immediately included in input requests. * * If the HAL needs to change the stream configuration for an existing * stream due to the new configuration, it may rewrite the values of usage * and/or max_buffers during the configure call. The framework will detect * such a change, and will then reallocate the stream buffers, and call * register_stream_buffers() again before using buffers from that stream in * a request. * * If a currently-active stream is not included in stream_list, the HAL may * safely remove any references to that stream. It will not be reused in a * later configure() call by the framework, and all the gralloc buffers for * it will be freed after the configure_streams() call returns. * * The stream_list structure is owned by the framework, and may not be * accessed once this call completes. The address of an individual * camera3_stream_t structure will remain valid for access by the HAL until * the end of the first configure_stream() call which no longer includes * that camera3_stream_t in the stream_list argument. The HAL may not change * values in the stream structure outside of the private pointer, except for * the usage and max_buffers members during the configure_streams() call * itself. * * If the stream is new, the usage, max_buffer, and private pointer fields * of the stream structure will all be set to 0. The HAL device must set * these fields before the configure_streams() call returns. These fields * are then used by the framework and the platform gralloc module to * allocate the gralloc buffers for each stream. * * Before such a new stream can have its buffers included in a capture * request, the framework will call register_stream_buffers() with that * stream. However, the framework is not required to register buffers for * _all_ streams before submitting a request. This allows for quick startup * of (for example) a preview stream, with allocation for other streams * happening later or concurrently. * * Preconditions: * * The framework will only call this method when no captures are being * processed. That is, all results have been returned to the framework, and * all in-flight input and output buffers have been returned and their * release sync fences have been signaled by the HAL. The framework will not * submit new requests for capture while the configure_streams() call is * underway. * * Postconditions: * * The HAL device must configure itself to provide maximum possible output * frame rate given the sizes and formats of the output streams, as * documented in the camera device's static metadata. * * Performance expectations: * * This call is expected to be heavyweight and possibly take several hundred * milliseconds to complete, since it may require resetting and * reconfiguring the image sensor and the camera processing pipeline. * Nevertheless, the HAL device should attempt to minimize the * reconfiguration delay to minimize the user-visible pauses during * application operational mode changes (such as switching from still * capture to video recording). * * Return values: * * 0: On successful stream configuration * * -EINVAL: If the requested stream configuration is invalid. Some examples * of invalid stream configurations include: * * - Including more than 1 input-capable stream (INPUT or * BIDIRECTIONAL) * * - Not including any output-capable streams (OUTPUT or * BIDIRECTIONAL) * * - Including streams with unsupported formats, or an unsupported * size for that format. * * - Including too many output streams of a certain format. * * Note that the framework submitting an invalid stream * configuration is not normal operation, since stream * configurations are checked before configure. An invalid * configuration means that a bug exists in the framework code, or * there is a mismatch between the HAL's static metadata and the * requirements on streams. * * -ENODEV: If there has been a fatal error and the device is no longer * operational. Only close() can be called successfully by the * framework after this error is returned. */ int (*configure_streams)(const struct camera3_device *, camera3_stream_configuration_t *stream_list); /** * register_stream_buffers: * * Register buffers for a given stream with the HAL device. This method is * called by the framework after a new stream is defined by * configure_streams, and before buffers from that stream are included in a * capture request. If the same stream is listed in a subsequent * configure_streams() call, register_stream_buffers will _not_ be called * again for that stream. * * The framework does not need to register buffers for all configured * streams before it submits the first capture request. This allows quick * startup for preview (or similar use cases) while other streams are still * being allocated. * * This method is intended to allow the HAL device to map or otherwise * prepare the buffers for later use. The buffers passed in will already be * locked for use. At the end of the call, all the buffers must be ready to * be returned to the stream. The buffer_set argument is only valid for the * duration of this call. * * If the stream format was set to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, * the camera HAL should inspect the passed-in buffers here to determine any * platform-private pixel format information. * * Return values: * * 0: On successful registration of the new stream buffers * * -EINVAL: If the stream_buffer_set does not refer to a valid active * stream, or if the buffers array is invalid. * * -ENOMEM: If there was a failure in registering the buffers. The framework * must consider all the stream buffers to be unregistered, and can * try to register again later. * * -ENODEV: If there is a fatal error, and the device is no longer * operational. Only close() can be called successfully by the * framework after this error is returned. */ int (*register_stream_buffers)(const struct camera3_device *, const camera3_stream_buffer_set_t *buffer_set); /********************************************************************** * Request creation and submission */ /** * construct_default_request_settings: * * Create capture settings for standard camera use cases. * * The device must return a settings buffer that is configured to meet the * requested use case, which must be one of the CAMERA3_TEMPLATE_* * enums. All request control fields must be included. * * The HAL retains ownership of this structure, but the pointer to the * structure must be valid until the device is closed. The framework and the * HAL may not modify the buffer once it is returned by this call. The same * buffer may be returned for subsequent calls for the same template, or for * other templates. * * Return values: * * Valid metadata: On successful creation of a default settings * buffer. * * NULL: In case of a fatal error. After this is returned, only * the close() method can be called successfully by the * framework. */ const camera_metadata_t* (*construct_default_request_settings)( const struct camera3_device *, int type); /** * process_capture_request: * * Send a new capture request to the HAL. The HAL should not return from * this call until it is ready to accept the next request to process. Only * one call to process_capture_request() will be made at a time by the * framework, and the calls will all be from the same thread. The next call * to process_capture_request() will be made as soon as a new request and * its associated buffers are available. In a normal preview scenario, this * means the function will be called again by the framework almost * instantly. * * The actual request processing is asynchronous, with the results of * capture being returned by the HAL through the process_capture_result() * call. This call requires the result metadata to be available, but output * buffers may simply provide sync fences to wait on. Multiple requests are * expected to be in flight at once, to maintain full output frame rate. * * The framework retains ownership of the request structure. It is only * guaranteed to be valid during this call. The HAL device must make copies * of the information it needs to retain for the capture processing. The HAL * is responsible for waiting on and closing the buffers' fences and * returning the buffer handles to the framework. * * The HAL must write the file descriptor for the input buffer's release * sync fence into input_buffer->release_fence, if input_buffer is not * NULL. If the HAL returns -1 for the input buffer release sync fence, the * framework is free to immediately reuse the input buffer. Otherwise, the * framework will wait on the sync fence before refilling and reusing the * input buffer. * * Return values: * * 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 * 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 * stream buffers' fences and the buffer handles; the HAL should * not close the fences or return these buffers with * process_capture_result. * * -ENODEV: If the camera device has encountered a serious error. After this * error is returned, only the close() method can be successfully * called by the framework. * */ int (*process_capture_request)(const struct camera3_device *, camera3_capture_request_t *request); /********************************************************************** * Miscellaneous methods */ /** * get_metadata_vendor_tag_ops: * * Get methods to query for vendor extension metadata tag information. The * HAL should fill in all the vendor tag operation methods, or leave ops * unchanged if no vendor tags are defined. * * The definition of vendor_tag_query_ops_t can be found in * system/media/camera/include/system/camera_metadata.h. * */ void (*get_metadata_vendor_tag_ops)(const struct camera3_device*, vendor_tag_query_ops_t* ops); /** * dump: * * Print out debugging state for the camera device. This will be called by * the framework when the camera service is asked for a debug dump, which * happens when using the dumpsys tool, or when capturing a bugreport. * * The passed-in file descriptor can be used to write debugging text using * dprintf() or write(). The text should be in ASCII encoding only. */ void (*dump)(const struct camera3_device *, int fd); /** * flush: * * Flush all currently in-process captures and all buffers in the pipeline * on the given device. The framework will use this to dump all state as * quickly as possible in order to prepare for a configure_streams() call. * * No buffers are required to be successfully returned, so every buffer * held at the time of flush() (whether sucessfully filled or not) may be * returned with CAMERA3_BUFFER_STATUS_ERROR. Note the HAL is still allowed * to return valid (STATUS_OK) buffers during this call, provided they are * succesfully filled. * * All requests currently in the HAL are expected to be returned as soon as * possible. Not-in-process requests should return errors immediately. Any * interruptible hardware blocks should be stopped, and any uninterruptible * blocks should be waited on. * * flush() should only return when there are no more outstanding buffers or * requests left in the HAL. The framework may call configure_streams (as * the HAL state is now quiesced) or may issue new requests. * * A flush() call should only take 100ms or less. The maximum time it can * take is 1 second. * * Version information: * * only available if device version >= CAMERA_DEVICE_API_VERSION_3_1. * * Return values: * * 0: On a successful flush of the camera HAL. * * -EINVAL: If the input is malformed (the device is not valid). * * -ENODEV: If the camera device has encountered a serious error. After this * error is returned, only the close() method can be successfully * called by the framework. */ int (*flush)(const struct camera3_device *); /* reserved for future use */ void *reserved[8]; } camera3_device_ops_t; /********************************************************************** * * Camera device definition * */ typedef struct camera3_device { /** * common.version must equal CAMERA_DEVICE_API_VERSION_3_0 to identify this * device as implementing version 3.0 of the camera device HAL. */ hw_device_t common; camera3_device_ops_t *ops; void *priv; } camera3_device_t; __END_DECLS #endif /* #ifdef ANDROID_INCLUDE_CAMERA3_H */ android-headers-23/19/hardware/camera_common.h000066400000000000000000000342261264465411000213420ustar00rootroot00000000000000/* * 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. */ // FIXME: add well-defined names for cameras #ifndef ANDROID_INCLUDE_CAMERA_COMMON_H #define ANDROID_INCLUDE_CAMERA_COMMON_H #include #include #include #include #include #include #include __BEGIN_DECLS /** * The id of this module */ #define CAMERA_HARDWARE_MODULE_ID "camera" /** * Module versioning information for the Camera hardware module, based on * camera_module_t.common.module_api_version. The two most significant hex * digits represent the major version, and the two least significant represent * the minor version. * ******************************************************************************* * Versions: 0.X - 1.X [CAMERA_MODULE_API_VERSION_1_0] * * Camera modules that report these version numbers implement the initial * camera module HAL interface. All camera devices openable through this * module support only version 1 of the camera device HAL. The device_version * and static_camera_characteristics fields of camera_info are not valid. Only * the android.hardware.Camera API can be supported by this module and its * devices. * ******************************************************************************* * Version: 2.0 [CAMERA_MODULE_API_VERSION_2_0] * * Camera modules that report this version number implement the second version * of the camera module HAL interface. Camera devices openable through this * module may support either version 1.0 or version 2.0 of the camera device * HAL interface. The device_version field of camera_info is always valid; the * static_camera_characteristics field of camera_info is valid if the * device_version field is 2.0 or higher. * ******************************************************************************* * Version: 2.1 [CAMERA_MODULE_API_VERSION_2_1] * * This camera module version adds support for asynchronous callbacks to the * framework from the camera HAL module, which is used to notify the framework * about changes to the camera module state. Modules that provide a valid * set_callbacks() method must report at least this version number. * ******************************************************************************* * Version: 2.2 [CAMERA_MODULE_API_VERSION_2_2] * * This camera module version adds vendor tag support from the module, and * deprecates the old vendor_tag_query_ops that were previously only * accessible with a device open. */ /** * Predefined macros for currently-defined version numbers */ /** * All module versions <= HARDWARE_MODULE_API_VERSION(1, 0xFF) must be treated * as CAMERA_MODULE_API_VERSION_1_0 */ #define CAMERA_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) #define CAMERA_MODULE_API_VERSION_2_0 HARDWARE_MODULE_API_VERSION(2, 0) #define CAMERA_MODULE_API_VERSION_2_1 HARDWARE_MODULE_API_VERSION(2, 1) #define CAMERA_MODULE_API_VERSION_2_2 HARDWARE_MODULE_API_VERSION(2, 2) #define CAMERA_MODULE_API_VERSION_CURRENT CAMERA_MODULE_API_VERSION_2_2 /** * All device versions <= HARDWARE_DEVICE_API_VERSION(1, 0xFF) must be treated * as CAMERA_DEVICE_API_VERSION_1_0 */ #define CAMERA_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) #define CAMERA_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 0) #define CAMERA_DEVICE_API_VERSION_2_1 HARDWARE_DEVICE_API_VERSION(2, 1) #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) // Device version 2.x is outdated; device version 3.0 is experimental #define CAMERA_DEVICE_API_VERSION_CURRENT CAMERA_DEVICE_API_VERSION_1_0 /** * Defined in /system/media/camera/include/system/camera_metadata.h */ typedef struct camera_metadata camera_metadata_t; typedef struct camera_info { /** * The direction that the camera faces to. It should be CAMERA_FACING_BACK * or CAMERA_FACING_FRONT. * * Version information: * Valid in all camera_module versions */ int facing; /** * The orientation of the camera image. The value is the angle that the * camera image needs to be rotated clockwise so it shows correctly on the * display in its natural orientation. It should be 0, 90, 180, or 270. * * For example, suppose a device has a naturally tall screen. The * back-facing camera sensor is mounted in landscape. You are looking at the * screen. If the top side of the camera sensor is aligned with the right * edge of the screen in natural orientation, the value should be 90. If the * top side of a front-facing camera sensor is aligned with the right of the * screen, the value should be 270. * * Version information: * Valid in all camera_module versions */ int orientation; /** * The value of camera_device_t.common.version. * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_1_0: * * Not valid. Can be assumed to be CAMERA_DEVICE_API_VERSION_1_0. Do * not read this field. * * CAMERA_MODULE_API_VERSION_2_0 or higher: * * Always valid * */ uint32_t device_version; /** * The camera's fixed characteristics, which include all camera metadata in * the android.*.info.* sections. This should be a sorted metadata buffer, * and may not be modified or freed by the caller. The pointer should remain * valid for the lifetime of the camera module, and values in it may not * change after it is returned by get_camera_info(). * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_1_0: * * Not valid. Extra characteristics are not available. Do not read this * field. * * CAMERA_MODULE_API_VERSION_2_0 or higher: * * Valid if device_version >= CAMERA_DEVICE_API_VERSION_2_0. Do not read * otherwise. * */ const camera_metadata_t *static_camera_characteristics; } camera_info_t; /** * camera_device_status_t: * * The current status of the camera device, as provided by the HAL through the * camera_module_callbacks.camera_device_status_change() call. * * At module load time, the framework will assume all camera devices are in the * CAMERA_DEVICE_STATUS_PRESENT state. The HAL should invoke * camera_module_callbacks::camera_device_status_change to inform the framework * of any initially NOT_PRESENT devices. * * Allowed transitions: * PRESENT -> NOT_PRESENT * NOT_PRESENT -> ENUMERATING * NOT_PRESENT -> PRESENT * ENUMERATING -> PRESENT * ENUMERATING -> NOT_PRESENT */ typedef enum camera_device_status { /** * The camera device is not currently connected, and opening it will return * failure. Calls to get_camera_info must still succeed, and provide the * same information it would if the camera were connected */ CAMERA_DEVICE_STATUS_NOT_PRESENT = 0, /** * The camera device is connected, and opening it will succeed. The * information returned by get_camera_info cannot change due to this status * change. By default, the framework will assume all devices are in this * state. */ CAMERA_DEVICE_STATUS_PRESENT = 1, /** * The camera device is connected, but it is undergoing an enumeration and * so opening the device will return -EBUSY. Calls to get_camera_info * must still succeed, as if the camera was in the PRESENT status. */ CAMERA_DEVICE_STATUS_ENUMERATING = 2, } camera_device_status_t; /** * Callback functions for the camera HAL module to use to inform the framework * of changes to the camera subsystem. These are called only by HAL modules * implementing version CAMERA_MODULE_API_VERSION_2_1 or higher of the HAL * module API interface. */ typedef struct camera_module_callbacks { /** * camera_device_status_change: * * Callback to the framework to indicate that the state of a specific camera * device has changed. At module load time, the framework will assume all * camera devices are in the CAMERA_DEVICE_STATUS_PRESENT state. The HAL * must call this method to inform the framework of any initially * NOT_PRESENT devices. * * camera_module_callbacks: The instance of camera_module_callbacks_t passed * to the module with set_callbacks. * * camera_id: The ID of the camera device that has a new status. * * new_status: The new status code, one of the camera_device_status_t enums, * or a platform-specific status. * */ void (*camera_device_status_change)(const struct camera_module_callbacks*, int camera_id, int new_status); } camera_module_callbacks_t; /** * Set up vendor-specific tag query methods. These are needed to properly query * entries with vendor-specified tags, potentially returned by get_camera_info. * * This should be used in place of vendor_tag_query_ops, which are deprecated. */ typedef struct vendor_tag_ops vendor_tag_ops_t; struct vendor_tag_ops { /** * Get the number of vendor tags supported on this platform. Used to * calculate the size of buffer needed for holding the array of all tags * returned by get_all_tags(). */ int (*get_tag_count)(const vendor_tag_ops_t *v); /** * Fill an array with all the supported vendor tags on this platform. * get_tag_count() returns the number of tags supported, and * tag_array will be allocated with enough space to hold all of the tags. */ void (*get_all_tags)(const vendor_tag_ops_t *v, uint32_t *tag_array); /** * Get vendor section name for a vendor-specified entry tag. Only called for * vendor-defined tags. The section name must start with the name of the * vendor in the Java package style. For example, CameraZoom Inc. must * prefix their sections with "com.camerazoom." Must return NULL if the tag * is outside the bounds of vendor-defined sections. * * There may be different vendor-defined tag sections, for example the * phone maker, the chipset maker, and the camera module maker may each * have their own "com.vendor."-prefixed section. * * The memory pointed to by the return value must remain valid for the * lifetime that the module is loaded, and is owned by the module. */ const char *(*get_section_name)(const vendor_tag_ops_t *v, uint32_t tag); /** * Get tag name for a vendor-specified entry tag. Only called for * vendor-defined tags. Must return NULL if the it is not a vendor-defined * tag. * * The memory pointed to by the return value must remain valid for the * lifetime that the module is loaded, and is owned by the module. */ const char *(*get_tag_name)(const vendor_tag_ops_t *v, uint32_t tag); /** * Get tag type for a vendor-specified entry tag. Only called for tags >= * 0x80000000. Must return -1 if the tag is outside the bounds of * vendor-defined sections. */ int (*get_tag_type)(const vendor_tag_ops_t *v, uint32_t tag); /* reserved for future use */ void* reserved[8]; }; typedef struct camera_module { hw_module_t common; /** * get_number_of_cameras: * * Returns the number of camera devices accessible through the camera * module. The camera devices are numbered 0 through N-1, where N is the * value returned by this call. The name of the camera device for open() is * simply the number converted to a string. That is, "0" for camera ID 0, * "1" for camera ID 1. * * The value here must be static, and cannot change after the first call to * this method */ int (*get_number_of_cameras)(void); /** * get_camera_info: * * Return the static camera information for a given camera device. This * information may not change for a camera device. * */ int (*get_camera_info)(int camera_id, struct camera_info *info); /** * set_callbacks: * * Provide callback function pointers to the HAL module to inform framework * of asynchronous camera module events. The framework will call this * function once after initial camera HAL module load, after the * get_number_of_cameras() method is called for the first time, and before * any other calls to the module. * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_1_0, CAMERA_MODULE_API_VERSION_2_0: * * Not provided by HAL module. Framework may not call this function. * * CAMERA_MODULE_API_VERSION_2_1: * * Valid to be called by the framework. * */ int (*set_callbacks)(const camera_module_callbacks_t *callbacks); /** * get_vendor_tag_ops: * * Get methods to query for vendor extension metadata tag information. The * HAL should fill in all the vendor tag operation methods, or leave ops * unchanged if no vendor tags are defined. * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1: * Not provided by HAL module. Framework may not call this function. * * CAMERA_MODULE_API_VERSION_2_2: * Valid to be called by the framework. */ void (*get_vendor_tag_ops)(vendor_tag_ops_t* ops); /* reserved for future use */ void* reserved[8]; } camera_module_t; __END_DECLS #endif /* ANDROID_INCLUDE_CAMERA_COMMON_H */ android-headers-23/19/hardware/consumerir.h000066400000000000000000000056041264465411000207260ustar00rootroot00000000000000/* * 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_HARDWARE_CONSUMERIR_H #define ANDROID_INCLUDE_HARDWARE_CONSUMERIR_H #include #include #include #include #define CONSUMERIR_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) #define CONSUMERIR_HARDWARE_MODULE_ID "consumerir" #define CONSUMERIR_TRANSMITTER "transmitter" typedef struct consumerir_freq_range { int min; int max; } consumerir_freq_range_t; typedef struct consumerir_module { struct hw_module_t common; } consumerir_module_t; typedef struct consumerir_device { struct hw_device_t common; /* * (*transmit)() is called to by the ConsumerIrService to send an IR pattern * at a given carrier_freq. * * The pattern is alternating series of carrier on and off periods measured in * microseconds. The carrier should be turned off at the end of a transmit * even if there are and odd number of entries in the pattern array. * * This call should return when the transmit is complete or encounters an error. * * returns: 0 on success. A negative error code on error. */ int (*transmit)(struct consumerir_device *dev, int carrier_freq, const int pattern[], int pattern_len); /* * (*get_num_carrier_freqs)() is called by the ConsumerIrService to get the * number of carrier freqs to allocate space for, which is then filled by * a subsequent call to (*get_carrier_freqs)(). * * returns: the number of ranges on success. A negative error code on error. */ int (*get_num_carrier_freqs)(struct consumerir_device *dev); /* * (*get_carrier_freqs)() is called by the ConsumerIrService to enumerate * which frequencies the IR transmitter supports. The HAL implementation * should fill an array of consumerir_freq_range structs with the * appropriate values for the transmitter, up to len elements. * * returns: the number of ranges on success. A negative error code on error. */ int (*get_carrier_freqs)(struct consumerir_device *dev, size_t len, consumerir_freq_range_t *ranges); /* Reserved for future use. Must be NULL. */ void* reserved[8 - 3]; } consumerir_device_t; #endif /* ANDROID_INCLUDE_HARDWARE_CONSUMERIR_H */ android-headers-23/19/hardware/fb.h000066400000000000000000000121731264465411000171260ustar00rootroot00000000000000/* * 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_FB_INTERFACE_H #define ANDROID_FB_INTERFACE_H #include #include #include #include #include __BEGIN_DECLS #define GRALLOC_HARDWARE_FB0 "fb0" /*****************************************************************************/ /*****************************************************************************/ typedef struct framebuffer_device_t { struct hw_device_t common; /* flags describing some attributes of the framebuffer */ const uint32_t flags; /* dimensions of the framebuffer in pixels */ const uint32_t width; const uint32_t height; /* frambuffer stride in pixels */ const int stride; /* framebuffer pixel format */ const int format; /* resolution of the framebuffer's display panel in pixel per inch*/ const float xdpi; const float ydpi; /* framebuffer's display panel refresh rate in frames per second */ const float fps; /* min swap interval supported by this framebuffer */ const int minSwapInterval; /* max swap interval supported by this framebuffer */ const int maxSwapInterval; /* Number of framebuffers supported*/ const int numFramebuffers; int reserved[7]; /* * requests a specific swap-interval (same definition than EGL) * * Returns 0 on success or -errno on error. */ int (*setSwapInterval)(struct framebuffer_device_t* window, int interval); /* * This hook is OPTIONAL. * * It is non NULL If the framebuffer driver supports "update-on-demand" * and the given rectangle is the area of the screen that gets * updated during (*post)(). * * This is useful on devices that are able to DMA only a portion of * the screen to the display panel, upon demand -- as opposed to * constantly refreshing the panel 60 times per second, for instance. * * Only the area defined by this rectangle is guaranteed to be valid, that * is, the driver is not allowed to post anything outside of this * rectangle. * * The rectangle evaluated during (*post)() and specifies which area * of the buffer passed in (*post)() shall to be posted. * * return -EINVAL if width or height <=0, or if left or top < 0 */ int (*setUpdateRect)(struct framebuffer_device_t* window, int left, int top, int width, int height); /* * Post to the display (display it on the screen) * The buffer must have been allocated with the * GRALLOC_USAGE_HW_FB usage flag. * buffer must be the same width and height as the display and must NOT * be locked. * * The buffer is shown during the next VSYNC. * * If the same buffer is posted again (possibly after some other buffer), * post() will block until the the first post is completed. * * Internally, post() is expected to lock the buffer so that a * subsequent call to gralloc_module_t::(*lock)() with USAGE_RENDER or * USAGE_*_WRITE will block until it is safe; that is typically once this * buffer is shown and another buffer has been posted. * * Returns 0 on success or -errno on error. */ int (*post)(struct framebuffer_device_t* dev, buffer_handle_t buffer); /* * The (*compositionComplete)() method must be called after the * compositor has finished issuing GL commands for client buffers. */ int (*compositionComplete)(struct framebuffer_device_t* dev); /* * This hook is OPTIONAL. * * If non NULL it will be caused by SurfaceFlinger on dumpsys */ void (*dump)(struct framebuffer_device_t* dev, char *buff, int buff_len); /* * (*enableScreen)() is used to either blank (enable=0) or * unblank (enable=1) the screen this framebuffer is attached to. * * Returns 0 on success or -errno on error. */ int (*enableScreen)(struct framebuffer_device_t* dev, int enable); void* reserved_proc[6]; } framebuffer_device_t; /** convenience API for opening and closing a supported device */ 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); } static inline int framebuffer_close(struct framebuffer_device_t* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_FB_INTERFACE_H android-headers-23/19/hardware/fused_location.h000066400000000000000000000644501264465411000215420ustar00rootroot00000000000000/* * 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_HARDWARE_FUSED_LOCATION_H #define ANDROID_INCLUDE_HARDWARE_FUSED_LOCATION_H #include /** * This header file defines the interface of the Fused Location Provider. * Fused Location Provider is designed to fuse data from various sources * like GPS, Wifi, Cell, Sensors, Bluetooth etc to provide a fused location to the * upper layers. The advantage of doing fusion in hardware is power savings. * The goal is to do this without waking up the AP to get additional data. * The software implementation of FLP will decide when to use * the hardware fused location. Other location features like geofencing will * also be implemented using fusion in hardware. */ __BEGIN_DECLS #define FLP_HEADER_VERSION 1 #define FLP_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define FLP_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION_2(0, 1, FLP_HEADER_VERSION) /** * The id of this module */ #define FUSED_LOCATION_HARDWARE_MODULE_ID "flp" /** * Name for the FLP location interface */ #define FLP_LOCATION_INTERFACE "flp_location" /** * Name for the FLP location interface */ #define FLP_DIAGNOSTIC_INTERFACE "flp_diagnostic" /** * Name for the FLP_Geofencing interface. */ #define FLP_GEOFENCING_INTERFACE "flp_geofencing" /** * Name for the FLP_device context interface. */ #define FLP_DEVICE_CONTEXT_INTERFACE "flp_device_context" /** * Constants to indicate the various subsystems * that will be used. */ #define FLP_TECH_MASK_GNSS (1U<<0) #define FLP_TECH_MASK_WIFI (1U<<1) #define FLP_TECH_MASK_SENSORS (1U<<2) #define FLP_TECH_MASK_CELL (1U<<3) #define FLP_TECH_MASK_BLUETOOTH (1U<<4) /** * 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, * sometimes in high power mode, the system might need * a location callback every single time the location * fix has been obtained. This flag controls that option. * Its the responsibility of the upper layers (caller) to switch * it off, if it knows that the AP might go to sleep. * When this bit is on amidst a batching session, batching should * continue while location fixes are reported in real time. */ #define FLP_BATCH_CALLBACK_ON_LOCATION_FIX 0x0000002 /** Flags to indicate which values are valid in a FlpLocation. */ typedef uint16_t FlpLocationFlags; // IMPORTANT: Note that the following values must match // constants in the corresponding java file. /** FlpLocation has valid latitude and longitude. */ #define FLP_LOCATION_HAS_LAT_LONG (1U<<0) /** FlpLocation has valid altitude. */ #define FLP_LOCATION_HAS_ALTITUDE (1U<<1) /** FlpLocation has valid speed. */ #define FLP_LOCATION_HAS_SPEED (1U<<2) /** FlpLocation has valid bearing. */ #define FLP_LOCATION_HAS_BEARING (1U<<4) /** FlpLocation has valid accuracy. */ #define FLP_LOCATION_HAS_ACCURACY (1U<<8) typedef int64_t FlpUtcTime; /** Represents a location. */ typedef struct { /** set to sizeof(FlpLocation) */ size_t size; /** Flags associated with the location object. */ FlpLocationFlags flags; /** Represents latitude in degrees. */ double latitude; /** Represents longitude in degrees. */ double longitude; /** * Represents altitude in meters above the WGS 84 reference * ellipsoid. */ double altitude; /** Represents speed in meters per second. */ float speed; /** Represents heading in degrees. */ float bearing; /** Represents expected accuracy in meters. */ float accuracy; /** Timestamp for the location fix. */ FlpUtcTime timestamp; /** Sources used, will be Bitwise OR of the FLP_TECH_MASK bits. */ uint32_t sources_used; } FlpLocation; typedef enum { ASSOCIATE_JVM, DISASSOCIATE_JVM, } ThreadEvent; /** * Callback with location information. * Can only be called from a thread associated to JVM using set_thread_event_cb. * Parameters: * num_locations is the number of batched locations available. * location is the pointer to an array of pointers to location objects. */ typedef void (*flp_location_callback)(int32_t num_locations, FlpLocation** location); /** * Callback utility for acquiring a wakelock. * This can be used to prevent the CPU from suspending while handling FLP events. */ typedef void (*flp_acquire_wakelock)(); /** * Callback utility for releasing the FLP wakelock. */ typedef void (*flp_release_wakelock)(); /** * Callback for associating a thread that can call into the Java framework code. * This must be used to initialize any threads that report events up to the framework. * Return value: * FLP_RESULT_SUCCESS on success. * FLP_RESULT_ERROR if the association failed in the current thread. */ typedef int (*flp_set_thread_event)(ThreadEvent event); /** FLP callback structure. */ typedef struct { /** set to sizeof(FlpCallbacks) */ size_t size; flp_location_callback location_cb; flp_acquire_wakelock acquire_wakelock_cb; flp_release_wakelock release_wakelock_cb; flp_set_thread_event set_thread_event_cb; } FlpCallbacks; /** Options with the batching FLP APIs */ typedef struct { /** * Maximum power in mW that the underlying implementation * can use for this batching call. * If max_power_allocation_mW is 0, only fixes that are generated * at no additional cost of power shall be reported. */ double max_power_allocation_mW; /** Bitwise OR of the FLP_TECH_MASKS to use */ uint32_t sources_to_use; /** * FLP_BATCH_WAKEUP_ON_FIFO_FULL - If set the hardware * will wake up the AP when the buffer is full. If not set, the * hardware will drop the oldest location object. * * FLP_BATCH_CALLBACK_ON_LOCATION_FIX - If set the location * callback will be called every time there is a location fix. * Its the responsibility of the upper layers (caller) to switch * it off, if it knows that the AP might go to sleep. When this * bit is on amidst a batching session, batching should continue * while location fixes are reported in real time. * * Other flags to be bitwised ORed in the future. */ uint32_t flags; /** * Frequency with which location needs to be batched in nano * seconds. */ int64_t period_ns; } FlpBatchOptions; #define FLP_RESULT_SUCCESS 0 #define FLP_RESULT_ERROR -1 #define FLP_RESULT_INSUFFICIENT_MEMORY -2 #define FLP_RESULT_TOO_MANY_GEOFENCES -3 #define FLP_RESULT_ID_EXISTS -4 #define FLP_RESULT_ID_UNKNOWN -5 #define FLP_RESULT_INVALID_GEOFENCE_TRANSITION -6 /** * Represents the standard FLP interface. */ typedef struct { /** * set to sizeof(FlpLocationInterface) */ size_t size; /** * Opens the interface and provides the callback routines * to the implemenation of this interface. */ int (*init)(FlpCallbacks* callbacks ); /** * Return the batch size (in number of FlpLocation objects) * available in the hardware. Note, different HW implementations * may have different sample sizes. This shall return number * of samples defined in the format of FlpLocation. * This will be used by the upper layer, to decide on the batching * interval and whether the AP should be woken up or not. */ int (*get_batch_size)(); /** * Start batching locations. This API is primarily used when the AP is * asleep and the device can batch locations in the hardware. * flp_location_callback is used to return the locations. When the buffer * is full and FLP_BATCH_WAKEUP_ON_FIFO_FULL is used, the AP is woken up. * When the buffer is full and FLP_BATCH_WAKEUP_ON_FIFO_FULL is not set, * the oldest location object is dropped. In this case the AP will not be * woken up. The upper layer will use get_batched_location * API to explicitly ask for the location. * If FLP_BATCH_CALLBACK_ON_LOCATION_FIX is set, the implementation * will call the flp_location_callback every single time there is a location * fix. This overrides FLP_BATCH_WAKEUP_ON_FIFO_FULL flag setting. * It's the responsibility of the upper layers (caller) to switch * it off, if it knows that the AP might go to sleep. This is useful * for nagivational applications when the system is in high power mode. * Parameters: * id - Id for the request. * options - See FlpBatchOptions struct definition. * Return value: * FLP_RESULT_SUCCESS on success, FLP_RESULT_INSUFFICIENT_MEMORY, * FLP_RESULT_ID_EXISTS, FLP_RESULT_ERROR on failure. */ int (*start_batching)(int id, FlpBatchOptions* options); /** * Update FlpBatchOptions associated with a batching request. * When a batching operation is in progress and a batching option * such as FLP_BATCH_WAKEUP_ON_FIFO_FULL needs to be updated, this API * will be used. For instance, this can happen when the AP is awake and * the maps application is being used. * Parameters: * id - Id of an existing batch request. * new_options - Updated FlpBatchOptions * Return value: * FLP_RESULT_SUCCESS on success, FLP_RESULT_ID_UNKNOWN, * FLP_RESULT_ERROR on error. */ int (*update_batching_options)(int id, FlpBatchOptions* new_options); /** * Stop batching. * Parameters: * id - Id for the request. * Return Value: * FLP_RESULT_SUCCESS on success, FLP_RESULT_ID_UNKNOWN or * FLP_RESULT_ERROR on failure. */ int (*stop_batching)(int id); /** * Closes the interface. If any batch operations are in progress, * they should be stopped. */ void (*cleanup)(); /** * Get the fused location that was batched. * flp_location_callback is used to return the location. The location object * is dropped from the buffer only when the buffer is full. Do not remove it * from the buffer just because it has been returned using the callback. * In other words, when there is no new location object, two calls to * get_batched_location(1) should return the same location object. * Parameters: * last_n_locations - Number of locations to get. This can be one or many. * If the last_n_locations is 1, you get the latest location known to the * hardware. */ void (*get_batched_location)(int last_n_locations); /** * Injects current location from another location provider * latitude and longitude are measured in degrees * expected accuracy is measured in meters * Parameters: * location - The location object being injected. * Return value: FLP_RESULT_SUCCESS or FLP_RESULT_ERROR. */ int (*inject_location)(FlpLocation* location); /** * Get a pointer to extension information. */ const void* (*get_extension)(const char* name); } FlpLocationInterface; struct flp_device_t { struct hw_device_t common; /** * Get a handle to the FLP Interface. */ const FlpLocationInterface* (*get_flp_interface)(struct flp_device_t* dev); }; /** * Callback for reports diagnostic data into the Java framework code. */ typedef void (*report_data)(char* data, int length); /** * FLP diagnostic callback structure. * Currently, not used - but this for future extension. */ typedef struct { /** set to sizeof(FlpDiagnosticCallbacks) */ size_t size; flp_set_thread_event set_thread_event_cb; /** reports diagnostic data into the Java framework code */ report_data data_cb; } FlpDiagnosticCallbacks; /** Extended interface for diagnostic support. */ typedef struct { /** set to sizeof(FlpDiagnosticInterface) */ size_t size; /** * Opens the diagnostic interface and provides the callback routines * to the implemenation of this interface. */ void (*init)(FlpDiagnosticCallbacks* callbacks); /** * Injects diagnostic data into the FLP subsystem. * Return 0 on success, -1 on error. **/ int (*inject_data)(char* data, int length ); } FlpDiagnosticInterface; /** * Context setting information. * All these settings shall be injected to FLP HAL at FLP init time. * Following that, only the changed setting need to be re-injected * upon changes. */ #define FLP_DEVICE_CONTEXT_GPS_ENABLED (1U<<0) #define FLP_DEVICE_CONTEXT_AGPS_ENABLED (1U<<1) #define FLP_DEVICE_CONTEXT_NETWORK_POSITIONING_ENABLED (1U<<2) #define FLP_DEVICE_CONTEXT_WIFI_CONNECTIVITY_ENABLED (1U<<3) #define FLP_DEVICE_CONTEXT_WIFI_POSITIONING_ENABLED (1U<<4) #define FLP_DEVICE_CONTEXT_HW_NETWORK_POSITIONING_ENABLED (1U<<5) #define FLP_DEVICE_CONTEXT_AIRPLANE_MODE_ON (1U<<6) #define FLP_DEVICE_CONTEXT_DATA_ENABLED (1U<<7) #define FLP_DEVICE_CONTEXT_ROAMING_ENABLED (1U<<8) #define FLP_DEVICE_CONTEXT_CURRENTLY_ROAMING (1U<<9) #define FLP_DEVICE_CONTEXT_SENSOR_ENABLED (1U<<10) #define FLP_DEVICE_CONTEXT_BLUETOOTH_ENABLED (1U<<11) #define FLP_DEVICE_CONTEXT_CHARGER_ON (1U<<12) /** Extended interface for device context support. */ typedef struct { /** set to sizeof(FlpDeviceContextInterface) */ size_t size; /** * Injects debug data into the FLP subsystem. * Return 0 on success, -1 on error. **/ int (*inject_device_context)(uint32_t enabledMask); } FlpDeviceContextInterface; /** * There are 3 states associated with a Geofence: Inside, Outside, Unknown. * There are 3 transitions: ENTERED, EXITED, UNCERTAIN. * * An example state diagram with confidence level: 95% and Unknown time limit * set as 30 secs is shown below. (confidence level and Unknown time limit are * explained latter) * ____________________________ * | Unknown (30 secs) | * """""""""""""""""""""""""""" * ^ | | ^ * UNCERTAIN| |ENTERED EXITED| |UNCERTAIN * | v v | * ________ EXITED _________ * | Inside | -----------> | Outside | * | | <----------- | | * """""""" ENTERED """"""""" * * Inside state: We are 95% confident that the user is inside the geofence. * Outside state: We are 95% confident that the user is outside the geofence * Unknown state: Rest of the time. * * The Unknown state is better explained with an example: * * __________ * | c| * | ___ | _______ * | |a| | | b | * | """ | """"""" * | | * """""""""" * In the diagram above, "a" and "b" are 2 geofences and "c" is the accuracy * circle reported by the FLP subsystem. Now with regard to "b", the system is * confident that the user is outside. But with regard to "a" is not confident * whether it is inside or outside the geofence. If the accuracy remains the * same for a sufficient period of time, the UNCERTAIN transition would be * triggered with the state set to Unknown. If the accuracy improves later, an * appropriate transition should be triggered. This "sufficient period of time" * is defined by the parameter in the add_geofence_area API. * In other words, Unknown state can be interpreted as a state in which the * FLP subsystem isn't confident enough that the user is either inside or * outside the Geofence. It moves to Unknown state only after the expiry of the * timeout. * * The geofence callback needs to be triggered for the ENTERED and EXITED * transitions, when the FLP system is confident that the user has entered * (Inside state) or exited (Outside state) the Geofence. An implementation * which uses a value of 95% as the confidence is recommended. The callback * should be triggered only for the transitions requested by the * add_geofence_area call. * * Even though the diagram and explanation talks about states and transitions, * the callee is only interested in the transistions. The states are mentioned * here for illustrative purposes. * * Startup Scenario: When the device boots up, if an application adds geofences, * and then we get an accurate FLP location fix, it needs to trigger the * appropriate (ENTERED or EXITED) transition for every Geofence it knows about. * By default, all the Geofences will be in the Unknown state. * * When the FLP system is unavailable, flp_geofence_status_callback should be * called to inform the upper layers of the same. Similarly, when it becomes * available the callback should be called. This is a global state while the * UNKNOWN transition described above is per geofence. * */ #define FLP_GEOFENCE_TRANSITION_ENTERED (1L<<0) #define FLP_GEOFENCE_TRANSITION_EXITED (1L<<1) #define FLP_GEOFENCE_TRANSITION_UNCERTAIN (1L<<2) #define FLP_GEOFENCE_MONITOR_STATUS_UNAVAILABLE (1L<<0) #define FLP_GEOFENCE_MONITOR_STATUS_AVAILABLE (1L<<1) /** * The callback associated with the geofence. * Parameters: * geofence_id - The id associated with the add_geofence_area. * location - The current location as determined by the FLP subsystem. * transition - Can be one of FLP_GEOFENCE_TRANSITION_ENTERED, FLP_GEOFENCE_TRANSITION_EXITED, * FLP_GEOFENCE_TRANSITION_UNCERTAIN. * timestamp - Timestamp when the transition was detected; -1 if not available. * sources_used - Bitwise OR of FLP_TECH_MASK flags indicating which * subsystems were used. * * The callback should only be called when the caller is interested in that * particular transition. For instance, if the caller is interested only in * ENTERED transition, then the callback should NOT be called with the EXITED * transition. * * IMPORTANT: If a transition is triggered resulting in this callback, the * subsystem will wake up the application processor, if its in suspend state. */ typedef void (*flp_geofence_transition_callback) (int32_t geofence_id, FlpLocation* location, int32_t transition, FlpUtcTime timestamp, uint32_t sources_used); /** * The callback associated with the availablity of one the sources used for geofence * monitoring by the FLP sub-system For example, if the GPS system determines that it cannot * monitor geofences because of lack of reliability or unavailability of the GPS signals, * it will call this callback with FLP_GEOFENCE_MONITOR_STATUS_UNAVAILABLE parameter and the * source set to FLP_TECH_MASK_GNSS. * * Parameters: * status - FLP_GEOFENCE_MONITOR_STATUS_UNAVAILABLE or FLP_GEOFENCE_MONITOR_STATUS_AVAILABLE. * source - One of the FLP_TECH_MASKS * last_location - Last known location. */ typedef void (*flp_geofence_monitor_status_callback) (int32_t status, uint32_t source, FlpLocation* last_location); /** * The callback associated with the add_geofence call. * * Parameter: * geofence_id - Id of the geofence. * result - FLP_RESULT_SUCCESS * FLP_RESULT_ERROR_TOO_MANY_GEOFENCES - geofence limit has been reached. * FLP_RESULT_ID_EXISTS - geofence with id already exists * FLP_RESULT_INVALID_GEOFENCE_TRANSITION - the monitorTransition contains an * invalid transition * FLP_RESULT_ERROR - for other errors. */ typedef void (*flp_geofence_add_callback) (int32_t geofence_id, int32_t result); /** * The callback associated with the remove_geofence call. * * Parameter: * geofence_id - Id of the geofence. * result - FLP_RESULT_SUCCESS * FLP_RESULT_ID_UNKNOWN - for invalid id * FLP_RESULT_ERROR for others. */ typedef void (*flp_geofence_remove_callback) (int32_t geofence_id, int32_t result); /** * The callback associated with the pause_geofence call. * * Parameter: * geofence_id - Id of the geofence. * result - FLP_RESULT_SUCCESS * FLP_RESULT__ID_UNKNOWN - for invalid id * FLP_RESULT_INVALID_TRANSITION - * when monitor_transitions is invalid * FLP_RESULT_ERROR for others. */ typedef void (*flp_geofence_pause_callback) (int32_t geofence_id, int32_t result); /** * The callback associated with the resume_geofence call. * * Parameter: * geofence_id - Id of the geofence. * result - FLP_RESULT_SUCCESS * FLP_RESULT_ID_UNKNOWN - for invalid id * FLP_RESULT_ERROR for others. */ typedef void (*flp_geofence_resume_callback) (int32_t geofence_id, int32_t result); typedef struct { /** set to sizeof(FlpGeofenceCallbacks) */ size_t size; flp_geofence_transition_callback geofence_transition_callback; flp_geofence_monitor_status_callback geofence_status_callback; flp_geofence_add_callback geofence_add_callback; flp_geofence_remove_callback geofence_remove_callback; flp_geofence_pause_callback geofence_pause_callback; flp_geofence_resume_callback geofence_resume_callback; flp_set_thread_event set_thread_event_cb; } FlpGeofenceCallbacks; /** Type of geofence */ typedef enum { TYPE_CIRCLE = 0, } GeofenceType; /** Circular geofence is represented by lat / long / radius */ typedef struct { double latitude; double longitude; double radius_m; } GeofenceCircle; /** Represents the type of geofence and data */ typedef struct { GeofenceType type; union { GeofenceCircle circle; } geofence; } GeofenceData; /** Geofence Options */ typedef struct { /** * The current state of the geofence. For example, if * the system already knows that the user is inside the geofence, * this will be set to FLP_GEOFENCE_TRANSITION_ENTERED. In most cases, it * will be FLP_GEOFENCE_TRANSITION_UNCERTAIN. */ int last_transition; /** * Transitions to monitor. Bitwise OR of * FLP_GEOFENCE_TRANSITION_ENTERED, FLP_GEOFENCE_TRANSITION_EXITED and * FLP_GEOFENCE_TRANSITION_UNCERTAIN. */ int monitor_transitions; /** * Defines the best-effort description * of how soon should the callback be called when the transition * associated with the Geofence is triggered. For instance, if set * to 1000 millseconds with FLP_GEOFENCE_TRANSITION_ENTERED, the callback * should be called 1000 milliseconds within entering the geofence. * This parameter is defined in milliseconds. * NOTE: This is not to be confused with the rate that the GPS is * polled at. It is acceptable to dynamically vary the rate of * sampling the GPS for power-saving reasons; thus the rate of * sampling may be faster or slower than this. */ int notification_responsivenes_ms; /** * The time limit after which the UNCERTAIN transition * should be triggered. This paramter is defined in milliseconds. */ int unknown_timer_ms; /** * The sources to use for monitoring geofences. Its a BITWISE-OR * of FLP_TECH_MASK flags. */ uint32_t sources_to_use; } GeofenceOptions; /** Geofence struct */ typedef struct { int32_t geofence_id; GeofenceData* data; GeofenceOptions* options; } Geofence; /** Extended interface for FLP_Geofencing support */ typedef struct { /** set to sizeof(FlpGeofencingInterface) */ size_t size; /** * Opens the geofence interface and provides the callback routines * to the implemenation of this interface. */ void (*init)( FlpGeofenceCallbacks* callbacks ); /** * Add a list of geofences. * Parameters: * number_of_geofences - The number of geofences that needed to be added. * geofences - Pointer to array of pointers to Geofence structure. */ void (*add_geofences) (int32_t number_of_geofences, Geofence** geofences); /** * Pause monitoring a particular geofence. * Parameters: * geofence_id - The id for the geofence. */ void (*pause_geofence) (int32_t geofence_id); /** * Resume monitoring a particular geofence. * Parameters: * geofence_id - The id for the geofence. * monitor_transitions - Which transitions to monitor. Bitwise OR of * FLP_GEOFENCE_TRANSITION_ENTERED, FLP_GEOFENCE_TRANSITION_EXITED and * FLP_GEOFENCE_TRANSITION_UNCERTAIN. * This supersedes the value associated provided in the * add_geofence_area call. */ void (*resume_geofence) (int32_t geofence_id, int monitor_transitions); /** * Modify a particular geofence option. * Parameters: * geofence_id - The id for the geofence. * options - Various options associated with the geofence. See * GeofenceOptions structure for details. */ void (*modify_geofence_option) (int32_t geofence_id, GeofenceOptions* options); /** * Remove a list of geofences. After the function returns, no notifications * should be sent. * Parameter: * number_of_geofences - The number of geofences that needed to be added. * geofence_id - Pointer to array of geofence_ids to be removed. */ void (*remove_geofences) (int32_t number_of_geofences, int32_t* geofence_id); } FlpGeofencingInterface; __END_DECLS #endif /* ANDROID_INCLUDE_HARDWARE_FLP_H */ android-headers-23/19/hardware/gps.h000066400000000000000000000757661264465411000173510ustar00rootroot00000000000000/* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_HARDWARE_GPS_H #define ANDROID_INCLUDE_HARDWARE_GPS_H #include #include #include #include #include __BEGIN_DECLS /** * The id of this module */ #define GPS_HARDWARE_MODULE_ID "gps" /** Milliseconds since January 1, 1970 */ typedef int64_t GpsUtcTime; /** Maximum number of SVs for gps_sv_status_callback(). */ #define GPS_MAX_SVS 32 /** 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. */ #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 0x0000001 /** GPS supports MS-Based AGPS mode */ #define GPS_CAPABILITY_MSB 0x0000002 /** GPS supports MS-Assisted AGPS mode */ #define GPS_CAPABILITY_MSA 0x0000004 /** GPS supports single-shot fixes */ #define GPS_CAPABILITY_SINGLE_SHOT 0x0000008 /** GPS supports on demand time injection */ #define GPS_CAPABILITY_ON_DEMAND_TIME 0x0000010 /** GPS supports Geofencing */ #define GPS_CAPABILITY_GEOFENCING 0x0000020 /** 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 /** * String length constants */ #define GPS_NI_SHORT_STRING_MAXLEN 256 #define GPS_NI_LONG_STRING_MAXLEN 2048 /** * 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 #define AGPS_REF_LOCATION_TYPE_GSM_CELLID 1 #define AGPS_REF_LOCATION_TYPE_UMTS_CELLID 2 #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 /** * Name for the GPS XTRA interface. */ #define GPS_XTRA_INTERFACE "gps-xtra" /** * Name for the GPS DEBUG interface. */ #define GPS_DEBUG_INTERFACE "gps-debug" /** * Name for the AGPS interface. */ #define AGPS_INTERFACE "agps" /** * Name for NI interface */ #define GPS_NI_INTERFACE "gps-ni" /** * Name for the AGPS-RIL interface. */ #define AGPS_RIL_INTERFACE "agps_ril" /** * Name for the GPS_Geofencing interface. */ #define GPS_GEOFENCING_INTERFACE "gps_geofencing" /** Represents a location. */ typedef struct { /** set to sizeof(GpsLocation) */ size_t size; /** Contains GpsLocationFlags bits. */ uint16_t flags; /** Represents latitude in degrees. */ double latitude; /** Represents longitude in degrees. */ double longitude; /** Represents altitude in meters above the WGS 84 reference * ellipsoid. */ double altitude; /** Represents speed in meters per second. */ float speed; /** Represents heading in degrees. */ float bearing; /** Represents expected accuracy in meters. */ float accuracy; /** Timestamp for the location fix. */ GpsUtcTime timestamp; } GpsLocation; /** Represents the status. */ typedef struct { /** set to sizeof(GpsStatus) */ size_t size; GpsStatusValue status; } GpsStatus; /** Represents SV information. */ typedef struct { /** set to sizeof(GpsSvInfo) */ size_t size; /** Pseudo-random number for the SV. */ int prn; /** Signal to noise ratio. */ float snr; /** Elevation of SV in degrees. */ float elevation; /** Azimuth of SV in degrees. */ float azimuth; } GpsSvInfo; /** Represents SV status. */ typedef struct { /** set to sizeof(GpsSvStatus) */ size_t size; /** Number of SVs currently visible. */ int num_svs; /** Contains an array of SV information. */ GpsSvInfo sv_list[GPS_MAX_SVS]; /** Represents a bit mask indicating which SVs * have ephemeris data. */ uint32_t ephemeris_mask; /** Represents a bit mask indicating which SVs * have almanac data. */ uint32_t almanac_mask; /** * Represents a bit mask indicating which SVs * were used for computing the most recent position fix. */ uint32_t used_in_fix_mask; } GpsSvStatus; /* 2G and 3G */ /* In 3G lac is discarded */ typedef struct { uint16_t type; uint16_t mcc; uint16_t mnc; uint16_t lac; uint32_t cid; } AGpsRefLocationCellID; typedef struct { uint8_t mac[6]; } AGpsRefLocationMac; /** Represents ref locations */ typedef struct { uint16_t type; union { AGpsRefLocationCellID cellID; AGpsRefLocationMac mac; } u; } AGpsRefLocation; /** Callback with location information. * Can only be called from a thread created by create_thread_cb. */ typedef void (* gps_location_callback)(GpsLocation* location); /** Callback with status information. * Can only be called from a thread created by create_thread_cb. */ typedef void (* gps_status_callback)(GpsStatus* status); /** Callback with SV status information. * Can only be called from a thread created by create_thread_cb. */ typedef void (* gps_sv_status_callback)(GpsSvStatus* sv_info); /** Callback for reporting NMEA sentences. * Can only be called from a thread created by create_thread_cb. */ typedef void (* gps_nmea_callback)(GpsUtcTime timestamp, const char* nmea, int length); /** Callback to inform framework of the GPS engine's capabilities. * Capability parameter is a bit field of GPS_CAPABILITY_* flags. */ typedef void (* gps_set_capabilities)(uint32_t capabilities); /** Callback utility for acquiring the GPS wakelock. * This can be used to prevent the CPU from suspending while handling GPS events. */ typedef void (* gps_acquire_wakelock)(); /** Callback utility for releasing the GPS wakelock. */ typedef void (* gps_release_wakelock)(); /** Callback for requesting NTP time */ typedef void (* gps_request_utc_time)(); /** Callback for creating a thread that can call into the Java framework code. * This must be used to create any threads that report events up to the framework. */ typedef pthread_t (* gps_create_thread)(const char* name, void (*start)(void *), void* arg); /** GPS callback structure. */ typedef struct { /** set to sizeof(GpsCallbacks) */ size_t size; gps_location_callback location_cb; gps_status_callback status_cb; gps_sv_status_callback sv_status_cb; gps_nmea_callback nmea_cb; gps_set_capabilities set_capabilities_cb; gps_acquire_wakelock acquire_wakelock_cb; gps_release_wakelock release_wakelock_cb; gps_create_thread create_thread_cb; gps_request_utc_time request_utc_time_cb; } GpsCallbacks; /** Represents the standard GPS interface. */ typedef struct { /** set to sizeof(GpsInterface) */ size_t size; /** * Opens the interface and provides the callback routines * to the implemenation of this interface. */ int (*init)( GpsCallbacks* callbacks ); /** Starts navigating. */ int (*start)( void ); /** Stops navigating. */ int (*stop)( void ); /** Closes the interface. */ void (*cleanup)( void ); /** Injects the current time. */ int (*inject_time)(GpsUtcTime time, int64_t timeReference, int uncertainty); /** Injects current location from another location provider * (typically cell ID). * latitude and longitude are measured in degrees * expected accuracy is measured in meters */ int (*inject_location)(double latitude, double longitude, float accuracy); /** * Specifies that the next call to start will not use the * information defined in the flags. GPS_DELETE_ALL is passed for * a cold start. */ void (*delete_aiding_data)(GpsAidingData flags); /** * min_interval represents the time between fixes in milliseconds. * preferred_accuracy represents the requested fix accuracy in meters. * preferred_time represents the requested time to first fix in milliseconds. */ int (*set_position_mode)(GpsPositionMode mode, GpsPositionRecurrence recurrence, uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time); /** Get a pointer to extension information. */ const void* (*get_extension)(const char* name); } GpsInterface; /** Callback to request the client to download XTRA data. * The client should download XTRA data and inject it by calling inject_xtra_data(). * Can only be called from a thread created by create_thread_cb. */ typedef void (* gps_xtra_download_request)(); /** Callback structure for the XTRA interface. */ typedef struct { gps_xtra_download_request download_request_cb; gps_create_thread create_thread_cb; } GpsXtraCallbacks; /** Extended interface for XTRA support. */ typedef struct { /** set to sizeof(GpsXtraInterface) */ size_t size; /** * Opens the XTRA interface and provides the callback routines * to the implemenation of this interface. */ int (*init)( GpsXtraCallbacks* callbacks ); /** Injects XTRA data into the GPS. */ int (*inject_xtra_data)( char* data, int length ); } GpsXtraInterface; /** Extended interface for DEBUG support. */ typedef struct { /** set to sizeof(GpsDebugInterface) */ size_t size; /** * This function should return any information that the native * implementation wishes to include in a bugreport. */ size_t (*get_internal_state)(char* buffer, size_t bufferSize); } GpsDebugInterface; /** Represents the status of AGPS. */ typedef struct { /** set to sizeof(AGpsStatus) */ size_t size; AGpsType type; AGpsStatusValue status; uint32_t ipaddr; } AGpsStatus; /** Callback with AGPS status information. * Can only be called from a thread created by create_thread_cb. */ typedef void (* agps_status_callback)(AGpsStatus* status); /** Callback structure for the AGPS interface. */ typedef struct { agps_status_callback status_cb; gps_create_thread create_thread_cb; } AGpsCallbacks; /** Extended interface for AGPS support. */ typedef struct { /** set to sizeof(AGpsInterface) */ size_t size; /** * Opens the AGPS interface and provides the callback routines * to the implemenation of this interface. */ void (*init)( AGpsCallbacks* callbacks ); /** * Notifies that a data connection is available and sets * the name of the APN to be used for SUPL. */ int (*data_conn_open)( const char* apn ); /** * Notifies that the AGPS data connection has been closed. */ int (*data_conn_closed)(); /** * Notifies that a data connection is not available for AGPS. */ int (*data_conn_failed)(); /** * Sets the hostname and port for the AGPS server. */ int (*set_server)( AGpsType type, const char* hostname, int port ); } AGpsInterface; /** Represents an NI request */ typedef struct { /** set to sizeof(GpsNiNotification) */ size_t size; /** * An ID generated by HAL to associate NI notifications and UI * responses */ int notification_id; /** * An NI type used to distinguish different categories of NI * events, such as GPS_NI_TYPE_VOICE, GPS_NI_TYPE_UMTS_SUPL, ... */ GpsNiType ni_type; /** * Notification/verification options, combinations of GpsNiNotifyFlags constants */ GpsNiNotifyFlags notify_flags; /** * Timeout period to wait for user response. * Set to 0 for no time out limit. */ int timeout; /** * Default response when time out. */ GpsUserResponseType default_response; /** * Requestor ID */ char requestor_id[GPS_NI_SHORT_STRING_MAXLEN]; /** * Notification message. It can also be used to store client_id in some cases */ char text[GPS_NI_LONG_STRING_MAXLEN]; /** * Client name decoding scheme */ GpsNiEncodingType requestor_id_encoding; /** * Client name decoding scheme */ GpsNiEncodingType text_encoding; /** * A pointer to extra data. Format: * key_1 = value_1 * key_2 = value_2 */ char extras[GPS_NI_LONG_STRING_MAXLEN]; } GpsNiNotification; /** Callback with NI notification. * Can only be called from a thread created by create_thread_cb. */ typedef void (*gps_ni_notify_callback)(GpsNiNotification *notification); /** GPS NI callback structure. */ typedef struct { /** * Sends the notification request from HAL to GPSLocationProvider. */ gps_ni_notify_callback notify_cb; gps_create_thread create_thread_cb; } GpsNiCallbacks; /** * Extended interface for Network-initiated (NI) support. */ typedef struct { /** set to sizeof(GpsNiInterface) */ size_t size; /** Registers the callbacks for HAL to use. */ void (*init) (GpsNiCallbacks *callbacks); /** Sends a response to HAL. */ void (*respond) (int notif_id, GpsUserResponseType user_response); } GpsNiInterface; struct gps_device_t { struct hw_device_t common; /** * Set the provided lights to the provided values. * * Returns: 0 on succes, error code on failure. */ 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) typedef void (*agps_ril_request_set_id)(uint32_t flags); typedef void (*agps_ril_request_ref_loc)(uint32_t flags); typedef struct { agps_ril_request_set_id request_setid; agps_ril_request_ref_loc request_refloc; gps_create_thread create_thread_cb; } AGpsRilCallbacks; /** Extended interface for AGPS_RIL support. */ typedef struct { /** set to sizeof(AGpsRilInterface) */ size_t size; /** * Opens the AGPS interface and provides the callback routines * to the implemenation of this interface. */ void (*init)( AGpsRilCallbacks* callbacks ); /** * Sets the reference location. */ void (*set_ref_location) (const AGpsRefLocation *agps_reflocation, size_t sz_struct); /** * Sets the set ID. */ void (*set_set_id) (AGpsSetIDType type, const char* setid); /** * Send network initiated message. */ void (*ni_message) (uint8_t *msg, size_t len); /** * Notify GPS of network status changes. * These parameters match values in the android.net.NetworkInfo class. */ void (*update_network_state) (int connected, int type, int roaming, const char* extra_info); /** * Notify GPS of network status changes. * These parameters match values in the android.net.NetworkInfo class. */ void (*update_network_availability) (int avaiable, const char* apn); } AGpsRilInterface; /** * GPS Geofence. * There are 3 states associated with a Geofence: Inside, Outside, Unknown. * There are 3 transitions: ENTERED, EXITED, UNCERTAIN. * * An example state diagram with confidence level: 95% and Unknown time limit * set as 30 secs is shown below. (confidence level and Unknown time limit are * explained latter) * ____________________________ * | Unknown (30 secs) | * """""""""""""""""""""""""""" * ^ | | ^ * UNCERTAIN| |ENTERED EXITED| |UNCERTAIN * | v v | * ________ EXITED _________ * | Inside | -----------> | Outside | * | | <----------- | | * """""""" ENTERED """"""""" * * Inside state: We are 95% confident that the user is inside the geofence. * Outside state: We are 95% confident that the user is outside the geofence * Unknown state: Rest of the time. * * The Unknown state is better explained with an example: * * __________ * | c| * | ___ | _______ * | |a| | | b | * | """ | """"""" * | | * """""""""" * In the diagram above, "a" and "b" are 2 geofences and "c" is the accuracy * circle reported by the GPS subsystem. Now with regard to "b", the system is * confident that the user is outside. But with regard to "a" is not confident * whether it is inside or outside the geofence. If the accuracy remains the * same for a sufficient period of time, the UNCERTAIN transition would be * triggered with the state set to Unknown. If the accuracy improves later, an * appropriate transition should be triggered. This "sufficient period of time" * is defined by the parameter in the add_geofence_area API. * In other words, Unknown state can be interpreted as a state in which the * GPS subsystem isn't confident enough that the user is either inside or * outside the Geofence. It moves to Unknown state only after the expiry of the * timeout. * * The geofence callback needs to be triggered for the ENTERED and EXITED * transitions, when the GPS system is confident that the user has entered * (Inside state) or exited (Outside state) the Geofence. An implementation * which uses a value of 95% as the confidence is recommended. The callback * should be triggered only for the transitions requested by the * add_geofence_area call. * * Even though the diagram and explanation talks about states and transitions, * the callee is only interested in the transistions. The states are mentioned * here for illustrative purposes. * * Startup Scenario: When the device boots up, if an application adds geofences, * and then we get an accurate GPS location fix, it needs to trigger the * appropriate (ENTERED or EXITED) transition for every Geofence it knows about. * By default, all the Geofences will be in the Unknown state. * * When the GPS system is unavailable, gps_geofence_status_callback should be * called to inform the upper layers of the same. Similarly, when it becomes * available the callback should be called. This is a global state while the * UNKNOWN transition described above is per geofence. * * An important aspect to note is that users of this API (framework), will use * other subsystems like wifi, sensors, cell to handle Unknown case and * hopefully provide a definitive state transition to the third party * application. GPS Geofence will just be a signal indicating what the GPS * 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. * Parameters: * geofence_id - The id associated with the add_geofence_area. * location - The current GPS location. * transition - Can be one of GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED, * GPS_GEOFENCE_UNCERTAIN. * timestamp - Timestamp when the transition was detected. * * The callback should only be called when the caller is interested in that * particular transition. For instance, if the caller is interested only in * ENTERED transition, then the callback should NOT be called with the EXITED * transition. * * IMPORTANT: If a transition is triggered resulting in this callback, the GPS * subsystem will wake up the application processor, if its in suspend state. */ typedef void (*gps_geofence_transition_callback) (int32_t geofence_id, GpsLocation* location, int32_t transition, GpsUtcTime timestamp); /** * The callback associated with the availablity of the GPS system for geofencing * monitoring. If the GPS system determines that it cannot monitor geofences * because of lack of reliability or unavailability of the GPS signals, it will * call this callback with GPS_GEOFENCE_UNAVAILABLE parameter. * * Parameters: * status - GPS_GEOFENCE_UNAVAILABLE or GPS_GEOFENCE_AVAILABLE. * last_location - Last known location. */ typedef void (*gps_geofence_status_callback) (int32_t status, GpsLocation* last_location); /** * The callback associated with the add_geofence call. * * Parameter: * geofence_id - Id of the geofence. * status - GPS_GEOFENCE_OPERATION_SUCCESS * GPS_GEOFENCE_ERROR_TOO_MANY_GEOFENCES - geofence limit has been reached. * GPS_GEOFENCE_ERROR_ID_EXISTS - geofence with id already exists * GPS_GEOFENCE_ERROR_INVALID_TRANSITION - the monitorTransition contains an * invalid transition * GPS_GEOFENCE_ERROR_GENERIC - for other errors. */ typedef void (*gps_geofence_add_callback) (int32_t geofence_id, int32_t status); /** * The callback associated with the remove_geofence call. * * Parameter: * geofence_id - Id of the geofence. * status - GPS_GEOFENCE_OPERATION_SUCCESS * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id * GPS_GEOFENCE_ERROR_GENERIC for others. */ typedef void (*gps_geofence_remove_callback) (int32_t geofence_id, int32_t status); /** * The callback associated with the pause_geofence call. * * Parameter: * geofence_id - Id of the geofence. * status - GPS_GEOFENCE_OPERATION_SUCCESS * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id * GPS_GEOFENCE_ERROR_INVALID_TRANSITION - * when monitor_transitions is invalid * GPS_GEOFENCE_ERROR_GENERIC for others. */ typedef void (*gps_geofence_pause_callback) (int32_t geofence_id, int32_t status); /** * The callback associated with the resume_geofence call. * * Parameter: * geofence_id - Id of the geofence. * status - GPS_GEOFENCE_OPERATION_SUCCESS * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id * GPS_GEOFENCE_ERROR_GENERIC for others. */ typedef void (*gps_geofence_resume_callback) (int32_t geofence_id, int32_t status); typedef struct { gps_geofence_transition_callback geofence_transition_callback; gps_geofence_status_callback geofence_status_callback; gps_geofence_add_callback geofence_add_callback; gps_geofence_remove_callback geofence_remove_callback; gps_geofence_pause_callback geofence_pause_callback; gps_geofence_resume_callback geofence_resume_callback; gps_create_thread create_thread_cb; } GpsGeofenceCallbacks; /** Extended interface for GPS_Geofencing support */ typedef struct { /** set to sizeof(GpsGeofencingInterface) */ size_t size; /** * Opens the geofence interface and provides the callback routines * to the implemenation of this interface. */ void (*init)( GpsGeofenceCallbacks* callbacks ); /** * Add a geofence area. This api currently supports circular geofences. * Parameters: * geofence_id - The id for the geofence. If a geofence with this id * already exists, an error value (GPS_GEOFENCE_ERROR_ID_EXISTS) * should be returned. * latitude, longtitude, radius_meters - The lat, long and radius * (in meters) for the geofence * last_transition - The current state of the geofence. For example, if * the system already knows that the user is inside the geofence, * this will be set to GPS_GEOFENCE_ENTERED. In most cases, it * will be GPS_GEOFENCE_UNCERTAIN. * monitor_transition - Which transitions to monitor. Bitwise OR of * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and * GPS_GEOFENCE_UNCERTAIN. * notification_responsiveness_ms - Defines the best-effort description * of how soon should the callback be called when the transition * associated with the Geofence is triggered. For instance, if set * to 1000 millseconds with GPS_GEOFENCE_ENTERED, the callback * should be called 1000 milliseconds within entering the geofence. * This parameter is defined in milliseconds. * NOTE: This is not to be confused with the rate that the GPS is * polled at. It is acceptable to dynamically vary the rate of * sampling the GPS for power-saving reasons; thus the rate of * sampling may be faster or slower than this. * unknown_timer_ms - The time limit after which the UNCERTAIN transition * should be triggered. This paramter is defined in milliseconds. * See above for a detailed explanation. */ void (*add_geofence_area) (int32_t geofence_id, double latitude, double longitude, double radius_meters, int last_transition, int monitor_transitions, int notification_responsiveness_ms, int unknown_timer_ms); /** * Pause monitoring a particular geofence. * Parameters: * geofence_id - The id for the geofence. */ void (*pause_geofence) (int32_t geofence_id); /** * Resume monitoring a particular geofence. * Parameters: * geofence_id - The id for the geofence. * monitor_transitions - Which transitions to monitor. Bitwise OR of * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and * GPS_GEOFENCE_UNCERTAIN. * This supersedes the value associated provided in the * add_geofence_area call. */ void (*resume_geofence) (int32_t geofence_id, int monitor_transitions); /** * Remove a geofence area. After the function returns, no notifications * should be sent. * Parameter: * geofence_id - The id for the geofence. */ void (*remove_geofence_area) (int32_t geofence_id); } GpsGeofencingInterface; __END_DECLS #endif /* ANDROID_INCLUDE_HARDWARE_GPS_H */ android-headers-23/19/hardware/gralloc.h000066400000000000000000000257161264465411000201710ustar00rootroot00000000000000/* * 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_GRALLOC_INTERFACE_H #define ANDROID_GRALLOC_INTERFACE_H #include #include #include #include #include #include #include #include #include __BEGIN_DECLS /** * Module versioning information for the Gralloc hardware module, based on * gralloc_module_t.common.module_api_version. * * Version History: * * GRALLOC_MODULE_API_VERSION_0_1: * Initial Gralloc hardware module API. * * GRALLOC_MODULE_API_VERSION_0_2: * Add support for flexible YCbCr format with (*lock_ycbcr)() method. */ #define GRALLOC_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define GRALLOC_MODULE_API_VERSION_0_2 HARDWARE_MODULE_API_VERSION(0, 2) #define GRALLOC_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION(0, 1) /** * The id of this module */ #define GRALLOC_HARDWARE_MODULE_ID "gralloc" /** * Name of the graphics device to open */ #define GRALLOC_HARDWARE_GPU0 "gpu0" enum { /* buffer is never read in software */ GRALLOC_USAGE_SW_READ_NEVER = 0x00000000, /* buffer is rarely read in software */ GRALLOC_USAGE_SW_READ_RARELY = 0x00000002, /* buffer is often read in software */ GRALLOC_USAGE_SW_READ_OFTEN = 0x00000003, /* mask for the software read values */ GRALLOC_USAGE_SW_READ_MASK = 0x0000000F, /* buffer is never written in software */ GRALLOC_USAGE_SW_WRITE_NEVER = 0x00000000, /* buffer is rarely written in software */ GRALLOC_USAGE_SW_WRITE_RARELY = 0x00000020, /* buffer is often written in software */ GRALLOC_USAGE_SW_WRITE_OFTEN = 0x00000030, /* mask for the software write values */ GRALLOC_USAGE_SW_WRITE_MASK = 0x000000F0, /* buffer will be used as an OpenGL ES texture */ GRALLOC_USAGE_HW_TEXTURE = 0x00000100, /* buffer will be used as an OpenGL ES render target */ GRALLOC_USAGE_HW_RENDER = 0x00000200, /* buffer will be used by the 2D hardware blitter */ GRALLOC_USAGE_HW_2D = 0x00000400, /* buffer will be used by the HWComposer HAL module */ GRALLOC_USAGE_HW_COMPOSER = 0x00000800, /* buffer will be used with the framebuffer device */ GRALLOC_USAGE_HW_FB = 0x00001000, /* buffer will be used with the HW video encoder */ GRALLOC_USAGE_HW_VIDEO_ENCODER = 0x00010000, /* buffer will be written by the HW camera pipeline */ GRALLOC_USAGE_HW_CAMERA_WRITE = 0x00020000, /* buffer will be read by the HW camera pipeline */ GRALLOC_USAGE_HW_CAMERA_READ = 0x00040000, /* buffer will be used as part of zero-shutter-lag queue */ GRALLOC_USAGE_HW_CAMERA_ZSL = 0x00060000, /* mask for the camera access values */ GRALLOC_USAGE_HW_CAMERA_MASK = 0x00060000, /* mask for the software usage bit-mask */ GRALLOC_USAGE_HW_MASK = 0x00071F00, /* buffer will be used as a RenderScript Allocation */ GRALLOC_USAGE_RENDERSCRIPT = 0x00100000, /* buffer should be displayed full-screen on an external display when * possible */ GRALLOC_USAGE_EXTERNAL_DISP = 0x00002000, /* Must have a hardware-protected path to external display sink for * this buffer. If a hardware-protected path is not available, then * either don't composite only this buffer (preferred) to the * external sink, or (less desirable) do not route the entire * composition to the external sink. */ GRALLOC_USAGE_PROTECTED = 0x00004000, /* implementation-specific private usage flags */ GRALLOC_USAGE_PRIVATE_0 = 0x10000000, GRALLOC_USAGE_PRIVATE_1 = 0x20000000, GRALLOC_USAGE_PRIVATE_2 = 0x40000000, GRALLOC_USAGE_PRIVATE_3 = 0x80000000, GRALLOC_USAGE_PRIVATE_MASK = 0xF0000000, }; /*****************************************************************************/ /** * 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 gralloc_module_t { struct hw_module_t common; /* * (*registerBuffer)() must be called before a buffer_handle_t that has not * been created with (*alloc_device_t::alloc)() can be used. * * This is intended to be used with buffer_handle_t's that have been * received in this process through IPC. * * This function checks that the handle is indeed a valid one and prepares * it for use with (*lock)() and (*unlock)(). * * It is not necessary to call (*registerBuffer)() on a handle created * with (*alloc_device_t::alloc)(). * * returns an error if this buffer_handle_t is not valid. */ int (*registerBuffer)(struct gralloc_module_t const* module, buffer_handle_t handle); /* * (*unregisterBuffer)() is called once this handle is no longer needed in * this process. After this call, it is an error to call (*lock)(), * (*unlock)(), or (*registerBuffer)(). * * This function doesn't close or free the handle itself; this is done * by other means, usually through libcutils's native_handle_close() and * native_handle_free(). * * It is an error to call (*unregisterBuffer)() on a buffer that wasn't * explicitly registered first. */ int (*unregisterBuffer)(struct gralloc_module_t const* module, buffer_handle_t handle); /* * The (*lock)() method is called before a buffer is accessed for the * specified usage. This call may block, for instance if the h/w needs * to finish rendering or if CPU caches need to be synchronized. * * The caller promises to modify only pixels in the area specified * by (l,t,w,h). * * The content of the buffer outside of the specified area is NOT modified * by this call. * * If usage specifies GRALLOC_USAGE_SW_*, vaddr is filled with the address * of the buffer in virtual memory. * * Note calling (*lock)() on HAL_PIXEL_FORMAT_YCbCr_*_888 buffers will fail * and return -EINVAL. These buffers must be locked with (*lock_ycbcr)() * instead. * * THREADING CONSIDERATIONS: * * It is legal for several different threads to lock a buffer from * read access, none of the threads are blocked. * * However, locking a buffer simultaneously for write or read/write is * undefined, but: * - shall not result in termination of the process * - shall not block the caller * It is acceptable to return an error or to leave the buffer's content * into an indeterminate state. * * If the buffer was created with a usage mask incompatible with the * requested usage flags here, -EINVAL is returned. * */ int (*lock)(struct gralloc_module_t const* module, buffer_handle_t handle, int usage, int l, int t, int w, int h, void** vaddr); /* * The (*unlock)() method must be called after all changes to the buffer * are completed. */ int (*unlock)(struct gralloc_module_t const* module, buffer_handle_t handle); /* reserved for future use */ int (*perform)(struct gralloc_module_t const* module, int operation, ... ); /* * The (*lock_ycbcr)() method is like the (*lock)() method, with the * difference that it fills a struct ycbcr with a description of the buffer * layout, and zeroes out the reserved fields. * * This will only work on buffers with HAL_PIXEL_FORMAT_YCbCr_*_888, and * will return -EINVAL on any other buffer formats. * * Added in GRALLOC_MODULE_API_VERSION_0_2. */ int (*lock_ycbcr)(struct gralloc_module_t const* module, buffer_handle_t handle, int usage, int l, int t, int w, int h, struct android_ycbcr *ycbcr); /* reserved for future use */ void* reserved_proc[6]; } gralloc_module_t; /*****************************************************************************/ /** * Every device data structure must begin with hw_device_t * followed by module specific public methods and attributes. */ typedef struct alloc_device_t { struct hw_device_t common; /* * (*alloc)() Allocates a buffer in graphic memory with the requested * parameters and returns a buffer_handle_t and the stride in pixels to * allow the implementation to satisfy hardware constraints on the width * of a pixmap (eg: it may have to be multiple of 8 pixels). * The CALLER TAKES OWNERSHIP of the buffer_handle_t. * * If format is HAL_PIXEL_FORMAT_YCbCr_420_888, the returned stride must be * 0, since the actual strides are available from the android_ycbcr * structure. * * Returns 0 on success or -errno on error. */ int (*alloc)(struct alloc_device_t* dev, int w, int h, int format, int usage, buffer_handle_t* handle, int* stride); /* * (*free)() Frees a previously allocated buffer. * Behavior is undefined if the buffer is still mapped in any process, * but shall not result in termination of the program or security breaches * (allowing a process to get access to another process' buffers). * THIS FUNCTION TAKES OWNERSHIP of the buffer_handle_t which becomes * invalid after the call. * * Returns 0 on success or -errno on error. */ int (*free)(struct alloc_device_t* dev, buffer_handle_t handle); /* This hook is OPTIONAL. * * If non NULL it will be caused by SurfaceFlinger on dumpsys */ void (*dump)(struct alloc_device_t *dev, char *buff, int buff_len); void* reserved_proc[7]; } alloc_device_t; /** convenience API for opening and closing a supported device */ 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); } static inline int gralloc_close(struct alloc_device_t* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_GRALLOC_INTERFACE_H android-headers-23/19/hardware/hardware.h000066400000000000000000000171521264465411000203360ustar00rootroot00000000000000/* * 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_HARDWARE_H #define ANDROID_INCLUDE_HARDWARE_HARDWARE_H #include #include #include #include __BEGIN_DECLS /* * Value for the hw_module_t.tag field */ #define MAKE_TAG_CONSTANT(A,B,C,D) (((A) << 24) | ((B) << 16) | ((C) << 8) | (D)) #define HARDWARE_MODULE_TAG MAKE_TAG_CONSTANT('H', 'W', 'M', 'T') #define HARDWARE_DEVICE_TAG MAKE_TAG_CONSTANT('H', 'W', 'D', 'T') #define HARDWARE_MAKE_API_VERSION(maj,min) \ ((((maj) & 0xff) << 8) | ((min) & 0xff)) #define HARDWARE_MAKE_API_VERSION_2(maj,min,hdr) \ ((((maj) & 0xff) << 24) | (((min) & 0xff) << 16) | ((hdr) & 0xffff)) #define HARDWARE_API_VERSION_2_MAJ_MIN_MASK 0xffff0000 #define HARDWARE_API_VERSION_2_HEADER_MASK 0x0000ffff /* * The current HAL API version. * * All module implementations must set the hw_module_t.hal_api_version field * to this value when declaring the module with HAL_MODULE_INFO_SYM. * * Note that previous implementations have always set this field to 0. * Therefore, libhardware HAL API will always consider versions 0.0 and 1.0 * to be 100% binary compatible. * */ #define HARDWARE_HAL_API_VERSION HARDWARE_MAKE_API_VERSION(1, 0) /* * Helper macros for module implementors. * * The derived modules should provide convenience macros for supported * versions so that implementations can explicitly specify module/device * versions at definition time. * * Use this macro to set the hw_module_t.module_api_version field. */ #define HARDWARE_MODULE_API_VERSION(maj,min) HARDWARE_MAKE_API_VERSION(maj,min) #define HARDWARE_MODULE_API_VERSION_2(maj,min,hdr) HARDWARE_MAKE_API_VERSION_2(maj,min,hdr) /* * Use this macro to set the hw_device_t.version field */ #define HARDWARE_DEVICE_API_VERSION(maj,min) HARDWARE_MAKE_API_VERSION(maj,min) #define HARDWARE_DEVICE_API_VERSION_2(maj,min,hdr) HARDWARE_MAKE_API_VERSION_2(maj,min,hdr) struct hw_module_t; struct hw_module_methods_t; struct hw_device_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 hw_module_t { /** tag must be initialized to HARDWARE_MODULE_TAG */ uint32_t tag; /** * The API version of the implemented module. The module owner is * responsible for updating the version when a module interface has * changed. * * The derived modules such as gralloc and audio own and manage this field. * The module user must interpret the version field to decide whether or * not to inter-operate with the supplied module implementation. * For example, SurfaceFlinger is responsible for making sure that * it knows how to manage different versions of the gralloc-module API, * and AudioFlinger must know how to do the same for audio-module API. * * The module API version should include a major and a minor component. * For example, version 1.0 could be represented as 0x0100. This format * implies that versions 0x0100-0x01ff are all API-compatible. * * In the future, libhardware will expose a hw_get_module_version() * (or equivalent) function that will take minimum/maximum supported * versions as arguments and would be able to reject modules with * versions outside of the supplied range. */ uint16_t module_api_version; #define version_major module_api_version /** * version_major/version_minor defines are supplied here for temporary * source code compatibility. They will be removed in the next version. * ALL clients must convert to the new version format. */ /** * The API version of the HAL module interface. This is meant to * version the hw_module_t, hw_module_methods_t, and hw_device_t * structures and definitions. * * The HAL interface owns this field. Module users/implementations * must NOT rely on this value for version information. * * Presently, 0 is the only valid value. */ uint16_t hal_api_version; #define version_minor hal_api_version /** Identifier of module */ const char *id; /** Name of this module */ const char *name; /** Author/owner/implementor of the module */ const char *author; /** Modules methods */ struct hw_module_methods_t* methods; /** module's dso */ void* dso; /** padding to 128 bytes, reserved for future use */ uint32_t reserved[32-7]; } hw_module_t; typedef struct hw_module_methods_t { /** Open a specific device */ int (*open)(const struct hw_module_t* module, const char* id, struct hw_device_t** device); } hw_module_methods_t; /** * Every device data structure must begin with hw_device_t * followed by module specific public methods and attributes. */ typedef struct hw_device_t { /** tag must be initialized to HARDWARE_DEVICE_TAG */ uint32_t tag; /** * Version of the module-specific device API. This value is used by * the derived-module user to manage different device implementations. * * The module user is responsible for checking the module_api_version * and device version fields to ensure that the user is capable of * communicating with the specific module implementation. * * One module can support multiple devices with different versions. This * can be useful when a device interface changes in an incompatible way * but it is still necessary to support older implementations at the same * time. One such example is the Camera 2.0 API. * * This field is interpreted by the module user and is ignored by the * HAL interface itself. */ uint32_t version; /** reference to the module this device belongs to */ struct hw_module_t* module; /** padding reserved for future use */ uint32_t reserved[12]; /** Close this device */ int (*close)(struct hw_device_t* device); } hw_device_t; /** * Name of the hal_module_info */ #define HAL_MODULE_INFO_SYM HMI /** * Name of the hal_module_info as a string */ #define HAL_MODULE_INFO_SYM_AS_STR "HMI" /** * Get the module info associated with a module by id. * * @return: 0 == success, <0 == error and *module == NULL */ int hw_get_module(const char *id, const struct hw_module_t **module); /** * Get the module info associated with a module instance by class 'class_id' * and instance 'inst'. * * Some modules types necessitate multiple instances. For example audio supports * multiple concurrent interfaces and thus 'audio' is the module class * and 'primary' or 'a2dp' are module interfaces. This implies that the files * providing these modules would be named audio.primary..so and * audio.a2dp..so * * @return: 0 == success, <0 == error and *module == NULL */ int hw_get_module_by_class(const char *class_id, const char *inst, const struct hw_module_t **module); __END_DECLS #endif /* ANDROID_INCLUDE_HARDWARE_HARDWARE_H */ android-headers-23/19/hardware/hwcomposer.h000066400000000000000000000620231264465411000207240ustar00rootroot00000000000000/* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H #define ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H #include #include #include #include #include #include __BEGIN_DECLS /*****************************************************************************/ /* for compatibility */ #define HWC_MODULE_API_VERSION HWC_MODULE_API_VERSION_0_1 #define HWC_DEVICE_API_VERSION HWC_DEVICE_API_VERSION_0_1 #define HWC_API_VERSION HWC_DEVICE_API_VERSION /*****************************************************************************/ /** * The id of this module */ #define HWC_HARDWARE_MODULE_ID "hwcomposer" /** * Name of the sensors device to open */ #define HWC_HARDWARE_COMPOSER "composer" typedef struct hwc_rect { int left; int top; int right; int bottom; } hwc_rect_t; typedef struct hwc_frect { float left; float top; float right; float bottom; } hwc_frect_t; typedef struct hwc_region { size_t numRects; hwc_rect_t const* rects; } hwc_region_t; typedef struct hwc_color { uint8_t r; uint8_t g; uint8_t b; uint8_t a; } hwc_color_t; typedef struct hwc_layer_1 { /* * compositionType is used to specify this layer's type and is set by either * the hardware composer implementation, or by the caller (see below). * * This field is always reset to HWC_BACKGROUND or HWC_FRAMEBUFFER * before (*prepare)() is called when the HWC_GEOMETRY_CHANGED flag is * also set, otherwise, this field is preserved between (*prepare)() * calls. * * HWC_BACKGROUND * Always set by the caller before calling (*prepare)(), this value * indicates this is a special "background" layer. The only valid field * is backgroundColor. * The HWC can toggle this value to HWC_FRAMEBUFFER to indicate it CANNOT * handle the background color. * * * HWC_FRAMEBUFFER_TARGET * Always set by the caller before calling (*prepare)(), this value * indicates this layer is the framebuffer surface used as the target of * OpenGL ES composition. If the HWC sets all other layers to HWC_OVERLAY * or HWC_BACKGROUND, then no OpenGL ES composition will be done, and * this layer should be ignored during set(). * * This flag (and the framebuffer surface layer) will only be used if the * HWC version is HWC_DEVICE_API_VERSION_1_1 or higher. In older versions, * the OpenGL ES target surface is communicated by the (dpy, sur) fields * in hwc_compositor_device_1_t. * * This value cannot be set by the HWC implementation. * * * HWC_FRAMEBUFFER * Set by the caller before calling (*prepare)() ONLY when the * HWC_GEOMETRY_CHANGED flag is also set. * * Set by the HWC implementation during (*prepare)(), this indicates * that the layer will be drawn into the framebuffer using OpenGL ES. * The HWC can toggle this value to HWC_OVERLAY to indicate it will * handle the layer. * * * HWC_OVERLAY * Set by the HWC implementation during (*prepare)(), this indicates * that the layer will be handled by the HWC (ie: it must not be * composited with OpenGL ES). * */ int32_t compositionType; /* * hints is bit mask set by the HWC implementation during (*prepare)(). * It is preserved between (*prepare)() calls, unless the * HWC_GEOMETRY_CHANGED flag is set, in which case it is reset to 0. * * see hwc_layer_t::hints */ uint32_t hints; /* see hwc_layer_t::flags */ uint32_t flags; union { /* color of the background. hwc_color_t.a is ignored */ hwc_color_t backgroundColor; struct { /* handle of buffer to compose. This handle is guaranteed to have been * allocated from gralloc using the GRALLOC_USAGE_HW_COMPOSER usage flag. If * the layer's handle is unchanged across two consecutive prepare calls and * the HWC_GEOMETRY_CHANGED flag is not set for the second call then the * HWComposer implementation may assume that the contents of the buffer have * not changed. */ buffer_handle_t handle; /* transformation to apply to the buffer during composition */ uint32_t transform; /* blending to apply during composition */ int32_t blending; /* area of the source to consider, the origin is the top-left corner of * the buffer. As of HWC_DEVICE_API_VERSION_1_3, sourceRect uses floats. * If the h/w can't support a non-integer source crop rectangle, it should * punt to OpenGL ES composition. */ union { // crop rectangle in integer (pre HWC_DEVICE_API_VERSION_1_3) hwc_rect_t sourceCropi; hwc_rect_t sourceCrop; // just for source compatibility // crop rectangle in floats (as of HWC_DEVICE_API_VERSION_1_3) hwc_frect_t sourceCropf; }; /* where to composite the sourceCrop onto the display. The sourceCrop * is scaled using linear filtering to the displayFrame. The origin is the * top-left corner of the screen. */ hwc_rect_t displayFrame; /* visible region in screen space. The origin is the * top-left corner of the screen. * The visible region INCLUDES areas overlapped by a translucent layer. */ hwc_region_t visibleRegionScreen; /* Sync fence object that will be signaled when the buffer's * contents are available. May be -1 if the contents are already * available. This field is only valid during set(), and should be * ignored during prepare(). The set() call must not wait for the * fence to be signaled before returning, but the HWC must wait for * all buffers to be signaled before reading from them. * * HWC_FRAMEBUFFER layers will never have an acquire fence, since * reads from them are complete before the framebuffer is ready for * display. * * The HWC takes ownership of the acquireFenceFd and is responsible * for closing it when no longer needed. */ int acquireFenceFd; /* During set() the HWC must set this field to a file descriptor for * a sync fence object that will signal after the HWC has finished * reading from the buffer. The field is ignored by prepare(). Each * layer should have a unique file descriptor, even if more than one * refer to the same underlying fence object; this allows each to be * closed independently. * * If buffer reads can complete at significantly different times, * then using independent fences is preferred. For example, if the * HWC handles some layers with a blit engine and others with * overlays, then the blit layers can be reused immediately after * the blit completes, but the overlay layers can't be reused until * a subsequent frame has been displayed. * * Since HWC doesn't read from HWC_FRAMEBUFFER layers, it shouldn't * produce a release fence for them. The releaseFenceFd will be -1 * for these layers when set() is called. * * The HWC client taks ownership of the releaseFenceFd and is * responsible for closing it when no longer needed. */ int releaseFenceFd; /* * Availability: HWC_DEVICE_API_VERSION_1_2 * * Alpha value applied to the whole layer. The effective * value of each pixel is computed as: * * if (blending == HWC_BLENDING_PREMULT) * pixel.rgb = pixel.rgb * planeAlpha / 255 * pixel.a = pixel.a * planeAlpha / 255 * * Then blending proceeds as usual according to the "blending" * field above. * * NOTE: planeAlpha applies to YUV layers as well: * * pixel.rgb = yuv_to_rgb(pixel.yuv) * if (blending == HWC_BLENDING_PREMULT) * pixel.rgb = pixel.rgb * planeAlpha / 255 * pixel.a = planeAlpha * * * IMPLEMENTATION NOTE: * * If the source image doesn't have an alpha channel, then * the h/w can use the HWC_BLENDING_COVERAGE equations instead of * HWC_BLENDING_PREMULT and simply set the alpha channel to * planeAlpha. * * e.g.: * * if (blending == HWC_BLENDING_PREMULT) * blending = HWC_BLENDING_COVERAGE; * pixel.a = planeAlpha; * */ uint8_t planeAlpha; /* reserved for future use */ uint8_t _pad[3]; }; }; /* Allow for expansion w/o breaking binary compatibility. * Pad layer to 96 bytes, assuming 32-bit pointers. */ int32_t reserved[24 - 19]; } hwc_layer_1_t; /* This represents a display, typically an EGLDisplay object */ typedef void* hwc_display_t; /* This represents a surface, typically an EGLSurface object */ typedef void* hwc_surface_t; /* * hwc_display_contents_1_t::flags values */ enum { /* * HWC_GEOMETRY_CHANGED is set by SurfaceFlinger to indicate that the list * passed to (*prepare)() has changed by more than just the buffer handles * and acquire fences. */ HWC_GEOMETRY_CHANGED = 0x00000001, }; /* * Description of the contents to output on a display. * * This is the top-level structure passed to the prepare and set calls to * negotiate and commit the composition of a display image. */ typedef struct hwc_display_contents_1 { /* File descriptor referring to a Sync HAL fence object which will signal * when this composition is retired. For a physical display, a composition * is retired when it has been replaced on-screen by a subsequent set. For * a virtual display, the composition is retired when the writes to * outputBuffer are complete and can be read. The fence object is created * and returned by the set call; this field will be -1 on entry to prepare * and set. SurfaceFlinger will close the returned file descriptor. */ int retireFenceFd; union { /* Fields only relevant for HWC_DEVICE_VERSION_1_0. */ struct { /* (dpy, sur) is the target of SurfaceFlinger's OpenGL ES * composition for HWC_DEVICE_VERSION_1_0. They aren't relevant to * prepare. The set call should commit this surface atomically to * the display along with any overlay layers. */ hwc_display_t dpy; hwc_surface_t sur; }; /* WARNING: These fields are for experimental virtual display support, * and are not currently used. */ struct { /* outbuf is the buffer that receives the composed image for * virtual displays. Writes to the outbuf must wait until * outbufAcquireFenceFd signals. A fence that will signal when * writes to outbuf are complete should be returned in * retireFenceFd. * * This field will not be updated until after prepare(). If * prepare() sets all non-FB layers to OVERLAY or sets all non-FB * layers to FRAMEBUFFER, then the FRAMEBUFFER_TARGET buffer and * the output buffer may be the same. In mixed OVERLAY/FRAMEBUFFER * configurations they will have different buffers so the * h/w composer does not have to read and write the same buffer. * * For physical displays, outbuf will be NULL. */ buffer_handle_t outbuf; /* File descriptor for a fence that will signal when outbuf is * ready to be written. The h/w composer is responsible for closing * this when no longer needed. * * Will be -1 whenever outbuf is NULL, or when the outbuf can be * written immediately. */ int outbufAcquireFenceFd; }; }; /* List of layers that will be composed on the display. The buffer handles * in the list will be unique. If numHwLayers is 0, all composition will be * performed by SurfaceFlinger. */ uint32_t flags; size_t numHwLayers; hwc_layer_1_t hwLayers[0]; } hwc_display_contents_1_t; /* see hwc_composer_device::registerProcs() * All of the callbacks are required and non-NULL unless otherwise noted. */ typedef struct hwc_procs { /* * (*invalidate)() triggers a screen refresh, in particular prepare and set * will be called shortly after this call is made. Note that there is * NO GUARANTEE that the screen refresh will happen after invalidate() * returns (in particular, it could happen before). * invalidate() is GUARANTEED TO NOT CALL BACK into the h/w composer HAL and * it is safe to call invalidate() from any of hwc_composer_device * hooks, unless noted otherwise. */ void (*invalidate)(const struct hwc_procs* procs); /* * (*vsync)() is called by the h/w composer HAL when a vsync event is * received and HWC_EVENT_VSYNC is enabled on a display * (see: hwc_event_control). * * the "disp" parameter indicates which display the vsync event is for. * the "timestamp" parameter is the system monotonic clock timestamp in * nanosecond of when the vsync event happened. * * vsync() is GUARANTEED TO NOT CALL BACK into the h/w composer HAL. * * It is expected that vsync() is called from a thread of at least * HAL_PRIORITY_URGENT_DISPLAY with as little latency as possible, * typically less than 0.5 ms. * * It is a (silent) error to have HWC_EVENT_VSYNC enabled when calling * hwc_composer_device.set(..., 0, 0, 0) (screen off). The implementation * can either stop or continue to process VSYNC events, but must not * crash or cause other problems. */ void (*vsync)(const struct hwc_procs* procs, int disp, int64_t timestamp); /* * (*hotplug)() is called by the h/w composer HAL when a display is * connected or disconnected. The PRIMARY display is always connected and * the hotplug callback should not be called for it. * * The disp parameter indicates which display type this event is for. * The connected parameter indicates whether the display has just been * connected (1) or disconnected (0). * * The hotplug() callback may call back into the h/w composer on the same * thread to query refresh rate and dpi for the display. Additionally, * other threads may be calling into the h/w composer while the callback * is in progress. * * The h/w composer must serialize calls to the hotplug callback; only * one thread may call it at a time. * * This callback will be NULL if the h/w composer is using * HWC_DEVICE_API_VERSION_1_0. */ void (*hotplug)(const struct hwc_procs* procs, int disp, int connected); } hwc_procs_t; /*****************************************************************************/ typedef struct hwc_module { struct hw_module_t common; } hwc_module_t; typedef struct hwc_composer_device_1 { struct hw_device_t common; /* * (*prepare)() is called for each frame before composition and is used by * SurfaceFlinger to determine what composition steps the HWC can handle. * * (*prepare)() can be called more than once, the last call prevails. * * The HWC responds by setting the compositionType field in each layer to * either HWC_FRAMEBUFFER or HWC_OVERLAY. In the former case, the * composition for the layer is handled by SurfaceFlinger with OpenGL ES, * in the later case, the HWC will have to handle the layer's composition. * compositionType and hints are preserved between (*prepare)() calles * unless the HWC_GEOMETRY_CHANGED flag is set. * * (*prepare)() is called with HWC_GEOMETRY_CHANGED to indicate that the * list's geometry has changed, that is, when more than just the buffer's * handles have been updated. Typically this happens (but is not limited to) * when a window is added, removed, resized or moved. In this case * compositionType and hints are reset to their default value. * * For HWC 1.0, numDisplays will always be one, and displays[0] will be * non-NULL. * * For HWC 1.1, numDisplays will always be HWC_NUM_PHYSICAL_DISPLAY_TYPES. * Entries for unsupported or disabled/disconnected display types will be * NULL. * * In HWC 1.3, numDisplays may be up to HWC_NUM_DISPLAY_TYPES. The extra * entries correspond to enabled virtual displays, and will be non-NULL. * * returns: 0 on success. An negative error code on error. If an error is * returned, SurfaceFlinger will assume that none of the layer will be * handled by the HWC. */ int (*prepare)(struct hwc_composer_device_1 *dev, size_t numDisplays, hwc_display_contents_1_t** displays); /* * (*set)() is used in place of eglSwapBuffers(), and assumes the same * functionality, except it also commits the work list atomically with * the actual eglSwapBuffers(). * * The layer lists are guaranteed to be the same as the ones returned from * the last call to (*prepare)(). * * When this call returns the caller assumes that the displays will be * updated in the near future with the content of their work lists, without * artifacts during the transition from the previous frame. * * A display with zero layers indicates that the entire composition has * been handled by SurfaceFlinger with OpenGL ES. In this case, (*set)() * behaves just like eglSwapBuffers(). * * For HWC 1.0, numDisplays will always be one, and displays[0] will be * non-NULL. * * For HWC 1.1, numDisplays will always be HWC_NUM_PHYSICAL_DISPLAY_TYPES. * Entries for unsupported or disabled/disconnected display types will be * NULL. * * In HWC 1.3, numDisplays may be up to HWC_NUM_DISPLAY_TYPES. The extra * entries correspond to enabled virtual displays, and will be non-NULL. * * IMPORTANT NOTE: There is an implicit layer containing opaque black * pixels behind all the layers in the list. It is the responsibility of * the hwcomposer module to make sure black pixels are output (or blended * from). * * IMPORTANT NOTE: In the event of an error this call *MUST* still cause * any fences returned in the previous call to set to eventually become * signaled. The caller may have already issued wait commands on these * fences, and having set return without causing those fences to signal * will likely result in a deadlock. * * returns: 0 on success. A negative error code on error: * HWC_EGL_ERROR: eglGetError() will provide the proper error code (only * allowed prior to HWComposer 1.1) * Another code for non EGL errors. */ int (*set)(struct hwc_composer_device_1 *dev, size_t numDisplays, hwc_display_contents_1_t** displays); /* * eventControl(..., event, enabled) * Enables or disables h/w composer events for a display. * * eventControl can be called from any thread and takes effect * immediately. * * Supported events are: * HWC_EVENT_VSYNC * * returns -EINVAL if the "event" parameter is not one of the value above * or if the "enabled" parameter is not 0 or 1. */ int (*eventControl)(struct hwc_composer_device_1* dev, int disp, int event, int enabled); /* * blank(..., blank) * Blanks or unblanks a display's screen. * * Turns the screen off when blank is nonzero, on when blank is zero. * Multiple sequential calls with the same blank value must be supported. * The screen state transition must be be complete when the function * returns. * * returns 0 on success, negative on error. */ int (*blank)(struct hwc_composer_device_1* dev, int disp, int blank); /* * Used to retrieve information about the h/w composer * * Returns 0 on success or -errno on error. */ int (*query)(struct hwc_composer_device_1* dev, int what, int* value); /* * (*registerProcs)() registers callbacks that the h/w composer HAL can * later use. It will be called immediately after the composer device is * opened with non-NULL procs. It is FORBIDDEN to call any of the callbacks * from within registerProcs(). registerProcs() must save the hwc_procs_t * pointer which is needed when calling a registered callback. */ void (*registerProcs)(struct hwc_composer_device_1* dev, hwc_procs_t const* procs); /* * This field is OPTIONAL and can be NULL. * * If non NULL it will be called by SurfaceFlinger on dumpsys */ void (*dump)(struct hwc_composer_device_1* dev, char *buff, int buff_len); /* * (*getDisplayConfigs)() returns handles for the configurations available * on the connected display. These handles must remain valid as long as the * display is connected. * * Configuration handles are written to configs. The number of entries * allocated by the caller is passed in *numConfigs; getDisplayConfigs must * not try to write more than this number of config handles. On return, the * total number of configurations available for the display is returned in * *numConfigs. If *numConfigs is zero on entry, then configs may be NULL. * * HWC_DEVICE_API_VERSION_1_1 does not provide a way to choose a config. * For displays that support multiple configurations, the h/w composer * implementation should choose one and report it as the first config in * the list. Reporting the not-chosen configs is not required. * * Returns 0 on success or -errno on error. If disp is a hotpluggable * display type and no display is connected, an error should be returned. * * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_1 and later. * It should be NULL for previous versions. */ int (*getDisplayConfigs)(struct hwc_composer_device_1* dev, int disp, uint32_t* configs, size_t* numConfigs); /* * (*getDisplayAttributes)() returns attributes for a specific config of a * connected display. The config parameter is one of the config handles * returned by getDisplayConfigs. * * The list of attributes to return is provided in the attributes * parameter, terminated by HWC_DISPLAY_NO_ATTRIBUTE. The value for each * requested attribute is written in order to the values array. The * HWC_DISPLAY_NO_ATTRIBUTE attribute does not have a value, so the values * array will have one less value than the attributes array. * * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_1 and later. * It should be NULL for previous versions. * * If disp is a hotpluggable display type and no display is connected, * or if config is not a valid configuration for the display, a negative * value should be returned. */ int (*getDisplayAttributes)(struct hwc_composer_device_1* dev, int disp, uint32_t config, const uint32_t* attributes, int32_t* values); /* * Reserved for future use. Must be NULL. */ void* reserved_proc[4]; } hwc_composer_device_1_t; /** convenience API for opening and closing a device */ 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); } static inline int hwc_close_1(hwc_composer_device_1_t* device) { return device->common.close(&device->common); } /*****************************************************************************/ __END_DECLS #endif /* ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H */ android-headers-23/19/hardware/hwcomposer_defs.h000066400000000000000000000141241264465411000217240ustar00rootroot00000000000000/* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_DEFS_H #define ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_DEFS_H #include #include #include #include #include __BEGIN_DECLS /*****************************************************************************/ #define HWC_HEADER_VERSION 1 #define HWC_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define HWC_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION_2(1, 0, HWC_HEADER_VERSION) #define HWC_DEVICE_API_VERSION_1_1 HARDWARE_DEVICE_API_VERSION_2(1, 1, HWC_HEADER_VERSION) #define HWC_DEVICE_API_VERSION_1_2 HARDWARE_DEVICE_API_VERSION_2(1, 2, HWC_HEADER_VERSION) #define HWC_DEVICE_API_VERSION_1_3 HARDWARE_DEVICE_API_VERSION_2(1, 3, HWC_HEADER_VERSION) enum { /* hwc_composer_device_t::set failed in EGL */ HWC_EGL_ERROR = -1 }; /* * hwc_layer_t::hints values * Hints are set by the HAL and read by SurfaceFlinger */ enum { /* * HWC can set the HWC_HINT_TRIPLE_BUFFER hint to indicate to SurfaceFlinger * that it should triple buffer this layer. Typically HWC does this when * the layer will be unavailable for use for an extended period of time, * e.g. if the display will be fetching data directly from the layer and * the layer can not be modified until after the next set(). */ HWC_HINT_TRIPLE_BUFFER = 0x00000001, /* * HWC sets HWC_HINT_CLEAR_FB to tell SurfaceFlinger that it should clear the * framebuffer with transparent pixels where this layer would be. * SurfaceFlinger will only honor this flag when the layer has no blending * */ HWC_HINT_CLEAR_FB = 0x00000002 }; /* * hwc_layer_t::flags values * Flags are set by SurfaceFlinger and read by the HAL */ enum { /* * HWC_SKIP_LAYER is set by SurfaceFlnger 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). */ HWC_SKIP_LAYER = 0x00000001, }; /* * hwc_layer_t::compositionType values */ enum { /* this layer is to be drawn into the framebuffer by SurfaceFlinger */ HWC_FRAMEBUFFER = 0, /* this layer will be handled in the HWC */ HWC_OVERLAY = 1, /* this is the background layer. it's used to set the background color. * there is only a single background layer */ HWC_BACKGROUND = 2, /* this layer holds the result of compositing the HWC_FRAMEBUFFER layers. * Added in HWC_DEVICE_API_VERSION_1_1. */ HWC_FRAMEBUFFER_TARGET = 3, }; /* * hwc_layer_t::blending values */ enum { /* no blending */ HWC_BLENDING_NONE = 0x0100, /* ONE / ONE_MINUS_SRC_ALPHA */ HWC_BLENDING_PREMULT = 0x0105, /* SRC_ALPHA / ONE_MINUS_SRC_ALPHA */ HWC_BLENDING_COVERAGE = 0x0405 }; /* * hwc_layer_t::transform values */ enum { /* flip source image horizontally */ HWC_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H, /* flip source image vertically */ HWC_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V, /* rotate source image 90 degrees clock-wise */ HWC_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90, /* rotate source image 180 degrees */ HWC_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180, /* rotate source image 270 degrees clock-wise */ HWC_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270, }; /* attributes queriable with query() */ enum { /* * Must return 1 if the background layer is supported, 0 otherwise. */ HWC_BACKGROUND_LAYER_SUPPORTED = 0, /* * Returns the vsync period in nanoseconds. * * This query is not used for HWC_DEVICE_API_VERSION_1_1 and later. * Instead, the per-display attribute HWC_DISPLAY_VSYNC_PERIOD is used. */ HWC_VSYNC_PERIOD = 1, /* * Availability: HWC_DEVICE_API_VERSION_1_1 * Returns a mask of supported display types. */ HWC_DISPLAY_TYPES_SUPPORTED = 2, }; /* display attributes returned by getDisplayAttributes() */ enum { /* Indicates the end of an attribute list */ HWC_DISPLAY_NO_ATTRIBUTE = 0, /* The vsync period in nanoseconds */ HWC_DISPLAY_VSYNC_PERIOD = 1, /* The number of pixels in the horizontal and vertical directions. */ HWC_DISPLAY_WIDTH = 2, HWC_DISPLAY_HEIGHT = 3, /* The number of pixels per thousand inches of this configuration. * * Scaling DPI by 1000 allows it to be stored in an int without losing * too much precision. * * If the DPI for a configuration is unavailable or the HWC implementation * considers it unreliable, it should set these attributes to zero. */ HWC_DISPLAY_DPI_X = 4, HWC_DISPLAY_DPI_Y = 5, }; /* Allowed events for hwc_methods::eventControl() */ enum { HWC_EVENT_VSYNC = 0 }; /* Display types and associated mask bits. */ enum { HWC_DISPLAY_PRIMARY = 0, HWC_DISPLAY_EXTERNAL = 1, // HDMI, DP, etc. HWC_DISPLAY_VIRTUAL = 2, HWC_NUM_PHYSICAL_DISPLAY_TYPES = 2, HWC_NUM_DISPLAY_TYPES = 3, }; enum { HWC_DISPLAY_PRIMARY_BIT = 1 << HWC_DISPLAY_PRIMARY, HWC_DISPLAY_EXTERNAL_BIT = 1 << HWC_DISPLAY_EXTERNAL, HWC_DISPLAY_VIRTUAL_BIT = 1 << HWC_DISPLAY_VIRTUAL, }; /*****************************************************************************/ __END_DECLS #endif /* ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_DEFS_H */ android-headers-23/19/hardware/keymaster.h000066400000000000000000000160751264465411000205500ustar00rootroot00000000000000/* * 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 2 #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) /** * 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 = 0x00000001, }; struct 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 { 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 android-headers-23/19/hardware/lights.h000066400000000000000000000074721264465411000200370ustar00rootroot00000000000000/* * 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_LIGHTS_INTERFACE_H #define ANDROID_LIGHTS_INTERFACE_H #include #include #include #include __BEGIN_DECLS /** * The id of this module */ #define LIGHTS_HARDWARE_MODULE_ID "lights" /* * These light IDs correspond to logical lights, not physical. * So for example, if your INDICATOR light is in line with your * BUTTONS, it might make sense to also light the INDICATOR * light to a reasonable color when the BUTTONS are lit. */ #define LIGHT_ID_BACKLIGHT "backlight" #define LIGHT_ID_KEYBOARD "keyboard" #define LIGHT_ID_BUTTONS "buttons" #define LIGHT_ID_BATTERY "battery" #define LIGHT_ID_NOTIFICATIONS "notifications" #define LIGHT_ID_ATTENTION "attention" /* * These lights aren't currently supported by the higher * layers, but could be someday, so we have the constants * here now. */ #define LIGHT_ID_BLUETOOTH "bluetooth" #define LIGHT_ID_WIFI "wifi" /* ************************************************************************ * Flash modes for the flashMode field of light_state_t. */ #define LIGHT_FLASH_NONE 0 /** * To flash the light at a given rate, set flashMode to LIGHT_FLASH_TIMED, * and then flashOnMS should be set to the number of milliseconds to turn * the light on, followed by the number of milliseconds to turn the light * off. */ #define LIGHT_FLASH_TIMED 1 /** * To flash the light using hardware assist, set flashMode to * the hardware mode. */ #define LIGHT_FLASH_HARDWARE 2 /** * Light brightness is managed by a user setting. */ #define BRIGHTNESS_MODE_USER 0 /** * Light brightness is managed by a light sensor. */ #define BRIGHTNESS_MODE_SENSOR 1 /** * The parameters that can be set for a given light. * * Not all lights must support all parameters. If you * can do something backward-compatible, you should. */ struct light_state_t { /** * The color of the LED in ARGB. * * Do your best here. * - If your light can only do red or green, if they ask for blue, * you should do green. * - If you can only do a brightness ramp, then use this formula: * unsigned char brightness = ((77*((color>>16)&0x00ff)) * + (150*((color>>8)&0x00ff)) + (29*(color&0x00ff))) >> 8; * - If you can only do on or off, 0 is off, anything else is on. * * The high byte should be ignored. Callers will set it to 0xff (which * would correspond to 255 alpha). */ unsigned int color; /** * See the LIGHT_FLASH_* constants */ int flashMode; int flashOnMS; int flashOffMS; /** * Policy used by the framework to manage the light's brightness. * Currently the values are BRIGHTNESS_MODE_USER and BRIGHTNESS_MODE_SENSOR. */ int brightnessMode; }; struct light_device_t { struct hw_device_t common; /** * Set the provided lights to the provided values. * * Returns: 0 on succes, error code on failure. */ int (*set_light)(struct light_device_t* dev, struct light_state_t const* state); }; __END_DECLS #endif // ANDROID_LIGHTS_INTERFACE_H android-headers-23/19/hardware/local_time_hal.h000066400000000000000000000067171264465411000215020ustar00rootroot00000000000000/* * 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_LOCAL_TIME_HAL_INTERFACE_H #define ANDROID_LOCAL_TIME_HAL_INTERFACE_H #include #include __BEGIN_DECLS /** * The id of this module */ #define LOCAL_TIME_HARDWARE_MODULE_ID "local_time" /** * Name of the local time devices to open */ #define LOCAL_TIME_HARDWARE_INTERFACE "local_time_hw_if" /**********************************************************************/ /** * A structure used to collect low level sync data in a lab environment. Most * HAL implementations will never need this structure. */ struct local_time_debug_event { int64_t local_timesync_event_id; int64_t local_time; }; /** * 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. */ struct local_time_module { struct hw_module_t common; }; struct local_time_hw_device { struct hw_device_t common; /** * * Returns the current value of the system wide local time counter */ int64_t (*get_local_time)(struct local_time_hw_device* dev); /** * * Returns the nominal frequency (in hertz) of the system wide local time * counter */ uint64_t (*get_local_freq)(struct local_time_hw_device* dev); /** * * Sets the HW slew rate of oscillator which drives the system wide local * time counter. On success, platforms should return 0. Platforms which * do not support HW slew should leave this method set to NULL. * * Valid values for rate range from MIN_INT16 to MAX_INT16. Platform * implementations should attempt map this range linearly to the min/max * slew rate of their hardware. */ int (*set_local_slew)(struct local_time_hw_device* dev, int16_t rate); /** * * A method used to collect low level sync data in a lab environments. * Most HAL implementations will simply set this member to NULL, or return * -EINVAL to indicate that this functionality is not supported. * Production HALs should never support this method. */ int (*get_debug_log)(struct local_time_hw_device* dev, struct local_time_debug_event* records, int max_records); }; typedef struct local_time_hw_device local_time_hw_device_t; /** convenience API for opening and closing a supported device */ static inline int local_time_hw_device_open( const struct hw_module_t* module, struct local_time_hw_device** device) { return module->methods->open(module, LOCAL_TIME_HARDWARE_INTERFACE, (struct hw_device_t**)device); } static inline int local_time_hw_device_close(struct local_time_hw_device* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_LOCAL_TIME_INTERFACE_H android-headers-23/19/hardware/memtrack.h000066400000000000000000000140221264465411000203350ustar00rootroot00000000000000/* * 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_HARDWARE_MEMTRACK_H #define ANDROID_INCLUDE_HARDWARE_MEMTRACK_H #include #include #include #include __BEGIN_DECLS #define MEMTRACK_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) /** * The id of this module */ #define MEMTRACK_HARDWARE_MODULE_ID "memtrack" /* * The Memory Tracker HAL is designed to return information about device-specific * memory usage. The primary goal is to be able to track memory that is not * trackable in any other way, for example texture memory that is allocated by * a process, but not mapped in to that process' address space. * A secondary goal is to be able to categorize memory used by a process into * GL, graphics, etc. All memory sizes should be in real memory usage, * accounting for stride, bit depth, rounding up to page size, etc. * * A process collecting memory statistics will call getMemory for each * combination of pid and memory type. For each memory type that it recognizes * the HAL should fill out an array of memtrack_record structures breaking * down the statistics of that memory type as much as possible. For example, * getMemory(, MEMTRACK_TYPE_GL) might return: * { { 4096, ACCOUNTED | PRIVATE | SYSTEM }, * { 40960, UNACCOUNTED | PRIVATE | SYSTEM }, * { 8192, ACCOUNTED | PRIVATE | DEDICATED }, * { 8192, UNACCOUNTED | PRIVATE | DEDICATED } } * If the HAL could not differentiate between SYSTEM and DEDICATED memory, it * could return: * { { 12288, ACCOUNTED | PRIVATE }, * { 49152, UNACCOUNTED | PRIVATE } } * * Memory should not overlap between types. For example, a graphics buffer * that has been mapped into the GPU as a surface should show up when * MEMTRACK_TYPE_GRAPHICS is requested, and not when MEMTRACK_TYPE_GL * is requested. */ enum memtrack_type { MEMTRACK_TYPE_OTHER = 0, MEMTRACK_TYPE_GL = 1, MEMTRACK_TYPE_GRAPHICS = 2, MEMTRACK_TYPE_MULTIMEDIA = 3, MEMTRACK_TYPE_CAMERA = 4, MEMTRACK_NUM_TYPES, }; struct memtrack_record { size_t size_in_bytes; unsigned int flags; }; /** * Flags to differentiate memory that can already be accounted for in * /proc//smaps, * (Shared_Clean + Shared_Dirty + Private_Clean + Private_Dirty = Size). * In general, memory mapped in to a userspace process is accounted unless * it was mapped with remap_pfn_range. * Exactly one of these should be set. */ #define MEMTRACK_FLAG_SMAPS_ACCOUNTED (1 << 1) #define MEMTRACK_FLAG_SMAPS_UNACCOUNTED (1 << 2) /** * Flags to differentiate memory shared across multiple processes vs. memory * used by a single process. Only zero or one of these may be set in a record. * If none are set, record is assumed to count shared + private memory. */ #define MEMTRACK_FLAG_SHARED (1 << 3) #define MEMTRACK_FLAG_SHARED_PSS (1 << 4) /* shared / num_procesess */ #define MEMTRACK_FLAG_PRIVATE (1 << 5) /** * Flags to differentiate memory taken from the kernel's allocation pool vs. * memory that is dedicated to non-kernel allocations, for example a carveout * or separate video memory. Only zero or one of these may be set in a record. * If none are set, record is assumed to count system + dedicated memory. */ #define MEMTRACK_FLAG_SYSTEM (1 << 6) #define MEMTRACK_FLAG_DEDICATED (1 << 7) /** * Flags to differentiate memory accessible by the CPU in non-secure mode vs. * memory that is protected. Only zero or one of these may be set in a record. * If none are set, record is assumed to count secure + nonsecure memory. */ #define MEMTRACK_FLAG_NONSECURE (1 << 8) #define MEMTRACK_FLAG_SECURE (1 << 9) /** * 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 memtrack_module { struct hw_module_t common; /** * (*init)() performs memtrack management setup actions and is called * once before any calls to getMemory(). * Returns 0 on success, -errno on error. */ int (*init)(const struct memtrack_module *module); /** * (*getMemory)() expects an array of record objects and populates up to * *num_record structures with the sizes of memory plus associated flags for * that memory. It also updates *num_records with the total number of * records it could return if *num_records was large enough when passed in. * Returning records with size 0 is expected, the number of records should * not vary between calls to getMemory for the same memory type, even * for different pids. * * The caller will often call getMemory for a type and pid with * *num_records == 0 to determine how many records to allocate room for, * this case should be a fast-path in the HAL, returning a constant and * not querying any kernel files. If *num_records passed in is 0, * then records may be NULL. * * This function must be thread-safe, it may get called from multiple * threads at the same time. * * Returns 0 on success, -ENODEV if the type is not supported, -errno * on other errors. */ int (*getMemory)(const struct memtrack_module *module, pid_t pid, int type, struct memtrack_record *records, size_t *num_records); } memtrack_module_t; __END_DECLS #endif // ANDROID_INCLUDE_HARDWARE_MEMTRACK_H android-headers-23/19/hardware/nfc.h000066400000000000000000000211031264465411000172760ustar00rootroot00000000000000/* * Copyright (C) 2011, 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_NFC_HAL_INTERFACE_H #define ANDROID_NFC_HAL_INTERFACE_H #include #include #include #include #include __BEGIN_DECLS /* NFC device HAL for NCI-based NFC controllers. * * This HAL allows NCI silicon vendors to make use * of the core NCI stack in Android for their own silicon. * * The responibilities of the NCI HAL implementation * are as follows: * * - Implement the transport to the NFC controller * - Implement each of the HAL methods specified below as applicable to their silicon * - Pass up received NCI messages from the controller to the stack * * A simplified timeline of NCI HAL method calls: * 1) Core NCI stack calls open() * 2) Core NCI stack executes CORE_RESET and CORE_INIT through calls to write() * 3) Core NCI stack calls core_initialized() to allow HAL to do post-init configuration * 4) Core NCI stack calls pre_discover() to allow HAL to prepare for RF discovery * 5) Core NCI stack starts discovery through calls to write() * 6) Core NCI stack stops discovery through calls to write() (e.g. screen turns off) * 7) Core NCI stack calls pre_discover() to prepare for RF discovery (e.g. screen turned back on) * 8) Core NCI stack starts discovery through calls to write() * ... * ... * 9) Core NCI stack calls close() */ #define NFC_NCI_HARDWARE_MODULE_ID "nfc_nci" #define NFC_NCI_CONTROLLER "nci" /* * nfc_nci_module_t should contain module-specific parameters */ 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. */ typedef void (nfc_stack_callback_t) (nfc_event_t event, nfc_status_t event_status); /* * The callback passed in from the NFC stack that the HAL * can use to pass incomming data to the stack. */ typedef void (nfc_stack_data_callback_t) (uint16_t data_len, uint8_t* p_data); /* nfc_nci_device_t starts with a hw_device_t struct, * followed by device-specific methods and members. * * All methods in the NCI HAL are asynchronous. */ typedef struct nfc_nci_device { struct hw_device_t common; /* * (*open)() Opens the NFC controller device and performs initialization. * This may include patch download and other vendor-specific initialization. * * If open completes successfully, the controller should be ready to perform * NCI initialization - ie accept CORE_RESET and subsequent commands through * the write() call. * * If open() returns 0, the NCI stack will wait for a HAL_NFC_OPEN_CPLT_EVT * before continuing. * * If open() returns any other value, the NCI stack will stop. * */ int (*open)(const struct nfc_nci_device *p_dev, nfc_stack_callback_t *p_cback, nfc_stack_data_callback_t *p_data_cback); /* * (*write)() Performs an NCI write. * * This method may queue writes and return immediately. The only * requirement is that the writes are executed in order. */ int (*write)(const struct nfc_nci_device *p_dev, uint16_t data_len, const uint8_t *p_data); /* * (*core_initialized)() is called after the CORE_INIT_RSP is received from the NFCC. * At this time, the HAL can do any chip-specific configuration. * * If core_initialized() returns 0, the NCI stack will wait for a HAL_NFC_POST_INIT_CPLT_EVT * before continuing. * * If core_initialized() returns any other value, the NCI stack will continue * immediately. */ int (*core_initialized)(const struct nfc_nci_device *p_dev, uint8_t* p_core_init_rsp_params); /* * (*pre_discover)() Is called every time before starting RF discovery. * It is a good place to do vendor-specific configuration that must be * performed every time RF discovery is about to be started. * * If pre_discover() returns 0, the NCI stack will wait for a HAL_NFC_PRE_DISCOVER_CPLT_EVT * before continuing. * * If pre_discover() returns any other value, the NCI stack will start * RF discovery immediately. */ int (*pre_discover)(const struct nfc_nci_device *p_dev); /* * (*close)() Closed the NFC controller. Should free all resources. */ int (*close)(const struct nfc_nci_device *p_dev); /* * (*control_granted)() Grant HAL the exclusive control to send NCI commands. * Called in response to HAL_REQUEST_CONTROL_EVT. * Must only be called when there are no NCI commands pending. * HAL_RELEASE_CONTROL_EVT will notify when HAL no longer needs exclusive control. */ int (*control_granted)(const struct nfc_nci_device *p_dev); /* * (*power_cycle)() Restart controller by power cyle; * HAL_OPEN_CPLT_EVT will notify when operation is complete. */ int (*power_cycle)(const struct nfc_nci_device *p_dev); } nfc_nci_device_t; /* * Convenience methods that the NFC stack can use to open * and close an NCI device */ static inline int nfc_nci_open(const struct hw_module_t* module, nfc_nci_device_t** dev) { return module->methods->open(module, NFC_NCI_CONTROLLER, (struct hw_device_t**) dev); } static inline int nfc_nci_close(nfc_nci_device_t* dev) { return dev->common.close(&dev->common); } /* * End NFC NCI HAL */ /* * This is a limited NFC HAL for NXP PN544-based devices. * This HAL as Android is moving to * an NCI-based NFC stack. * * All NCI-based NFC controllers should use the NFC-NCI * HAL instead. * Begin PN544 specific HAL */ #define NFC_HARDWARE_MODULE_ID "nfc" #define NFC_PN544_CONTROLLER "pn544" typedef struct nfc_module_t { struct hw_module_t common; } nfc_module_t; /* * PN544 linktypes. * UART * I2C * USB (uses UART DAL) */ typedef enum { PN544_LINK_TYPE_UART, PN544_LINK_TYPE_I2C, PN544_LINK_TYPE_USB, PN544_LINK_TYPE_INVALID, } nfc_pn544_linktype; typedef struct { struct hw_device_t common; /* The number of EEPROM registers to write */ uint32_t num_eeprom_settings; /* The actual EEPROM settings * For PN544, each EEPROM setting is a 4-byte entry, * of the format [0x00, addr_msb, addr_lsb, value]. */ uint8_t* eeprom_settings; /* The link type to which the PN544 is connected */ nfc_pn544_linktype linktype; /* The device node to which the PN544 is connected */ const char* device_node; /* On Crespo we had an I2C issue that would cause us to sometimes read * the I2C slave address (0x57) over the bus. libnfc contains * a hack to ignore this byte and try to read the length byte * again. * Set to 0 to disable the workaround, 1 to enable it. */ uint8_t enable_i2c_workaround; /* I2C slave address. Multiple I2C addresses are * possible for PN544 module. Configure address according to * board design. */ uint8_t i2c_device_address; } nfc_pn544_device_t; static inline int nfc_pn544_open(const struct hw_module_t* module, nfc_pn544_device_t** dev) { return module->methods->open(module, NFC_PN544_CONTROLLER, (struct hw_device_t**) dev); } static inline int nfc_pn544_close(nfc_pn544_device_t* dev) { return dev->common.close(&dev->common); } /* * End PN544 specific HAL */ __END_DECLS #endif // ANDROID_NFC_HAL_INTERFACE_H android-headers-23/19/hardware/power.h000066400000000000000000000110341264465411000176660ustar00rootroot00000000000000/* * 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_HARDWARE_POWER_H #define ANDROID_INCLUDE_HARDWARE_POWER_H #include #include #include #include __BEGIN_DECLS #define POWER_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define POWER_MODULE_API_VERSION_0_2 HARDWARE_MODULE_API_VERSION(0, 2) /** * The id of this module */ #define POWER_HARDWARE_MODULE_ID "power" /* * Power hint identifiers passed to (*powerHint) */ typedef enum { POWER_HINT_VSYNC = 0x00000001, POWER_HINT_INTERACTION = 0x00000002, /* DO NOT USE POWER_HINT_VIDEO_ENCODE/_DECODE! They will be removed in * KLP. */ POWER_HINT_VIDEO_ENCODE = 0x00000003, POWER_HINT_VIDEO_DECODE = 0x00000004 } power_hint_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 power_module { struct hw_module_t common; /* * (*init)() performs power management setup actions at runtime * startup, such as to set default cpufreq parameters. This is * called only by the Power HAL instance loaded by * PowerManagerService. */ void (*init)(struct power_module *module); /* * (*setInteractive)() performs power management actions upon the * system entering interactive state (that is, the system is awake * and ready for interaction, often with UI devices such as * display and touchscreen enabled) or non-interactive state (the * system appears asleep, display usually turned off). The * non-interactive state is usually entered after a period of * inactivity, in order to conserve battery power during * such inactive periods. * * Typical actions are to turn on or off devices and adjust * cpufreq parameters. This function may also call the * appropriate interfaces to allow the kernel to suspend the * system to low-power sleep state when entering non-interactive * state, and to disallow low-power suspend when the system is in * interactive state. When low-power suspend state is allowed, the * kernel may suspend the system whenever no wakelocks are held. * * on is non-zero when the system is transitioning to an * interactive / awake state, and zero when transitioning to a * non-interactive / asleep state. * * This function is called to enter non-interactive state after * turning off the screen (if present), and called to enter * interactive state prior to turning on the screen. */ void (*setInteractive)(struct power_module *module, int on); /* * (*powerHint) is called to pass hints on power requirements, which * may result in adjustment of power/performance parameters of the * cpufreq governor and other controls. The possible hints are: * * POWER_HINT_VSYNC * * Foreground app has started or stopped requesting a VSYNC pulse * from SurfaceFlinger. If the app has started requesting VSYNC * then CPU and GPU load is expected soon, and it may be appropriate * to raise speeds of CPU, memory bus, etc. The data parameter is * non-zero to indicate VSYNC pulse is now requested, or zero for * VSYNC pulse no longer requested. * * POWER_HINT_INTERACTION * * User is interacting with the device, for example, touchscreen * events are incoming. CPU and GPU load may be expected soon, * and it may be appropriate to raise speeds of CPU, memory bus, * etc. The data parameter is unused. * * A particular platform may choose to ignore any hint. * * availability: version 0.2 * */ void (*powerHint)(struct power_module *module, power_hint_t hint, void *data); } power_module_t; __END_DECLS #endif // ANDROID_INCLUDE_HARDWARE_POWER_H android-headers-23/19/hardware/qemu_pipe.h000066400000000000000000000052551264465411000205260ustar00rootroot00000000000000/* * 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 #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) { 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 */ android-headers-23/19/hardware/qemud.h000066400000000000000000000102441264465411000176470ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/hardware/sensors.h000066400000000000000000001416241264465411000202370ustar00rootroot00000000000000/* * 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_SENSORS_INTERFACE_H #define ANDROID_SENSORS_INTERFACE_H #include #include #include #include #include __BEGIN_DECLS /*****************************************************************************/ #define SENSORS_HEADER_VERSION 1 #define SENSORS_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define SENSORS_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION_2(0, 1, SENSORS_HEADER_VERSION) #define SENSORS_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION_2(1, 0, SENSORS_HEADER_VERSION) #define SENSORS_DEVICE_API_VERSION_1_1 HARDWARE_DEVICE_API_VERSION_2(1, 1, SENSORS_HEADER_VERSION) /** * The id of this module */ #define SENSORS_HARDWARE_MODULE_ID "sensors" /** * Name of the sensors device to open */ #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. */ #define SENSORS_HANDLE_BASE 0 #define SENSORS_HANDLE_BITS 8 #define SENSORS_HANDLE_COUNT (1<0 * ^ * | * +-----------+--> y>0 * | | * | | * | | * | | / z<0 * | | / * | | / * O-----------+/ * |[] [ ] []/ * +----------/+ y<0 * / * / * |/ z>0 (toward the sky) * * O: Origin (x=0,y=0,z=0) * */ /* * Interaction with suspend mode * * Unless otherwise noted, an enabled sensor shall not prevent the * SoC to go into suspend mode. It is the responsibility of applications * to keep a partial wake-lock should they wish to receive sensor * events while the screen is off. While in suspend mode, and unless * otherwise noted (batch mode, sensor particularities, ...), enabled sensors' * events are lost. * * Note that conceptually, the sensor itself is not de-activated while in * suspend mode -- it's just that the data it returns are lost. As soon as * the SoC gets out of suspend mode, operations resume as usual. Of course, * in practice sensors shall be disabled while in suspend mode to * save power, unless batch mode is active, in which case they must * continue fill their internal FIFO (see the documentation of batch() to * learn how suspend interacts with batch mode). * * In batch mode, and only when the flag SENSORS_BATCH_WAKE_UPON_FIFO_FULL is * set and supported, the specified sensor must be able to wake-up the SoC and * be able to buffer at least 10 seconds worth of the requested sensor events. * * There are notable exceptions to this behavior, which are sensor-dependent * (see sensor types definitions below) * * * The sensor type documentation below specifies the wake-up behavior of * each sensor: * wake-up: yes this sensor must wake-up the SoC to deliver events * wake-up: no this sensor shall not wake-up the SoC, events are dropped * */ /* * Sensor type * * Each sensor has a type which defines what this sensor measures and how * measures are reported. All types are defined below. * * Device manufacturers (OEMs) can define their own sensor types, for * their private use by applications or services provided by them. Such * sensor types are specific to an OEM and can't be exposed in the SDK. * These types must start at SENSOR_TYPE_DEVICE_PRIVATE_BASE. */ /* * Base for device manufacturers private sensor types. * These sensor types can't be exposed in the SDK. */ #define SENSOR_TYPE_DEVICE_PRIVATE_BASE 0x10000 /* * Sensor fusion and virtual sensors * * Many sensor types are or can be implemented as virtual sensors from * physical sensors on the device. For instance the rotation vector sensor, * orientation sensor, step-detector, step-counter, etc... * * From the point of view of this API these virtual sensors MUST appear as * real, individual sensors. It is the responsibility of the driver and HAL * to make sure this is the case. * * In particular, all sensors must be able to function concurrently. * For example, if defining both an accelerometer and a step counter, * then both must be able to work concurrently. */ /* * Trigger modes * * Sensors can report events in different ways called trigger modes, * each sensor type has one and only one trigger mode associated to it. * Currently there are four trigger modes defined: * * continuous: events are reported at a constant rate defined by setDelay(). * eg: accelerometers, gyroscopes. * on-change: events are reported only if the sensor's value has changed. * setDelay() is used to set a lower limit to the reporting * period (minimum time between two events). * The HAL must return an event immediately when an on-change * sensor is activated. * eg: proximity, light sensors * one-shot: upon detection of an event, the sensor deactivates itself and * then sends a single event. Order matters to avoid race * conditions. No other event is sent until the sensor get * reactivated. setDelay() is ignored. * eg: significant motion sensor * special: see details in the sensor type specification below * */ /* * SENSOR_TYPE_META_DATA * trigger-mode: n/a * wake-up sensor: n/a * * NO SENSOR OF THAT TYPE MUST BE RETURNED (*get_sensors_list)() * * SENSOR_TYPE_META_DATA is a special token used to populate the * sensors_meta_data_event structure. It doesn't correspond to a physical * sensor. sensors_meta_data_event are special, they exist only inside * the HAL and are generated spontaneously, as opposed to be related to * a physical sensor. * * sensors_meta_data_event_t.version must be META_DATA_VERSION * sensors_meta_data_event_t.sensor must be 0 * sensors_meta_data_event_t.type must be SENSOR_TYPE_META_DATA * sensors_meta_data_event_t.reserved must be 0 * sensors_meta_data_event_t.timestamp must be 0 * * The payload is a meta_data_event_t, where: * meta_data_event_t.what can take the following values: * * META_DATA_FLUSH_COMPLETE * This event indicates that a previous (*flush)() call has completed for the sensor * handle specified in meta_data_event_t.sensor. * see (*flush)() for more details * * All other values for meta_data_event_t.what are reserved and * must not be used. * */ #define SENSOR_TYPE_META_DATA (0) /* * SENSOR_TYPE_ACCELEROMETER * trigger-mode: continuous * wake-up sensor: no * * All values are in SI units (m/s^2) and measure the acceleration of the * device minus the force of gravity. * * Acceleration sensors return sensor events for all 3 axes at a constant * rate defined by setDelay(). * * x: Acceleration on the x-axis * y: Acceleration on the y-axis * z: Acceleration on the z-axis * * Note that the readings from the accelerometer include the acceleration * due to gravity (which is opposite to the direction of the gravity vector). * * Examples: * The norm of should be close to 0 when in free fall. * * When the device lies flat on a table and is pushed on its left side * toward the right, the x acceleration value is positive. * * When the device lies flat on a table, the acceleration value is +9.81, * which correspond to the acceleration of the device (0 m/s^2) minus the * force of gravity (-9.81 m/s^2). * * When the device lies flat on a table and is pushed toward the sky, the * acceleration value is greater than +9.81, which correspond to the * acceleration of the device (+A m/s^2) minus the force of * gravity (-9.81 m/s^2). */ #define SENSOR_TYPE_ACCELEROMETER (1) /* * SENSOR_TYPE_GEOMAGNETIC_FIELD * trigger-mode: continuous * wake-up sensor: no * * All values are in micro-Tesla (uT) and measure the geomagnetic * field in the X, Y and Z axis. * * Returned values include calibration mechanisms such that the vector is * aligned with the magnetic declination and heading of the earth's * geomagnetic field. * * Magnetic Field sensors return sensor events for all 3 axes at a constant * rate defined by setDelay(). */ #define SENSOR_TYPE_GEOMAGNETIC_FIELD (2) #define SENSOR_TYPE_MAGNETIC_FIELD SENSOR_TYPE_GEOMAGNETIC_FIELD /* * SENSOR_TYPE_ORIENTATION * trigger-mode: continuous * wake-up sensor: no * * All values are angles in degrees. * * Orientation sensors return sensor events for all 3 axes at a constant * rate defined by setDelay(). * * azimuth: angle between the magnetic north direction and the Y axis, around * the Z axis (0<=azimuth<360). * 0=North, 90=East, 180=South, 270=West * * pitch: Rotation around X axis (-180<=pitch<=180), with positive values when * the z-axis moves toward the y-axis. * * roll: Rotation around Y axis (-90<=roll<=90), with positive values when * the x-axis moves towards the z-axis. * * Note: For historical reasons the roll angle is positive in the clockwise * direction (mathematically speaking, it should be positive in the * counter-clockwise direction): * * Z * ^ * (+roll) .--> | * / | * | | roll: rotation around Y axis * X <-------(.) * Y * note that +Y == -roll * * * * Note: This definition is different from yaw, pitch and roll used in aviation * where the X axis is along the long side of the plane (tail to nose). */ #define SENSOR_TYPE_ORIENTATION (3) /* * SENSOR_TYPE_GYROSCOPE * trigger-mode: continuous * wake-up sensor: no * * All values are in radians/second and measure the rate of rotation * around the X, Y and Z axis. The coordinate system is the same as is * used for the acceleration sensor. Rotation is positive in the * counter-clockwise direction (right-hand rule). That is, an observer * looking from some positive location on the x, y or z axis at a device * positioned on the origin would report positive rotation if the device * appeared to be rotating counter clockwise. Note that this is the * standard mathematical definition of positive rotation and does not agree * with the definition of roll given earlier. * The range should at least be 17.45 rad/s (ie: ~1000 deg/s). * * automatic gyro-drift compensation is allowed but not required. */ #define SENSOR_TYPE_GYROSCOPE (4) /* * SENSOR_TYPE_LIGHT * trigger-mode: on-change * wake-up sensor: no * * The light sensor value is returned in SI lux units. */ #define SENSOR_TYPE_LIGHT (5) /* * SENSOR_TYPE_PRESSURE * trigger-mode: continuous * wake-up sensor: no * * The pressure sensor return the athmospheric pressure in hectopascal (hPa) */ #define SENSOR_TYPE_PRESSURE (6) /* SENSOR_TYPE_TEMPERATURE is deprecated in the HAL */ #define SENSOR_TYPE_TEMPERATURE (7) /* * SENSOR_TYPE_PROXIMITY * trigger-mode: on-change * wake-up sensor: yes * * The distance value is measured in centimeters. Note that some proximity * sensors only support a binary "close" or "far" measurement. In this case, * the sensor should report its maxRange value in the "far" state and a value * less than maxRange in the "near" state. */ #define SENSOR_TYPE_PROXIMITY (8) /* * SENSOR_TYPE_GRAVITY * trigger-mode: continuous * wake-up sensor: no * * A gravity output indicates the direction of and magnitude of gravity in * the devices's coordinates. On Earth, the magnitude is 9.8 m/s^2. * Units are m/s^2. The coordinate system is the same as is used for the * acceleration sensor. When the device is at rest, the output of the * gravity sensor should be identical to that of the accelerometer. */ #define SENSOR_TYPE_GRAVITY (9) /* * SENSOR_TYPE_LINEAR_ACCELERATION * trigger-mode: continuous * wake-up sensor: no * * Indicates the linear acceleration of the device in device coordinates, * not including gravity. * * The output is conceptually: * output of TYPE_ACCELERATION - output of TYPE_GRAVITY * * Readings on all axes should be close to 0 when device lies on a table. * Units are m/s^2. * The coordinate system is the same as is used for the acceleration sensor. */ #define SENSOR_TYPE_LINEAR_ACCELERATION (10) /* * SENSOR_TYPE_ROTATION_VECTOR * trigger-mode: continuous * wake-up sensor: no * * The rotation vector symbolizes the orientation of the device relative to the * East-North-Up coordinates frame. It is usually obtained by integration of * accelerometer, gyroscope and magnetometer readings. * * The East-North-Up coordinate system is defined as a direct orthonormal basis * where: * - X points east and is tangential to the ground. * - Y points north and is tangential to the ground. * - Z points towards the sky and is perpendicular to the ground. * * The orientation of the phone is represented by the rotation necessary to * align the East-North-Up coordinates with the phone's coordinates. That is, * applying the rotation to the world frame (X,Y,Z) would align them with the * phone coordinates (x,y,z). * * The rotation can be seen as rotating the phone by an angle theta around * an axis rot_axis to go from the reference (East-North-Up aligned) device * orientation to the current device orientation. * * The rotation is encoded as the 4 (reordered) components of a unit quaternion: * sensors_event_t.data[0] = rot_axis.x*sin(theta/2) * sensors_event_t.data[1] = rot_axis.y*sin(theta/2) * sensors_event_t.data[2] = rot_axis.z*sin(theta/2) * sensors_event_t.data[3] = cos(theta/2) * where * - rot_axis.x,y,z are the North-East-Up coordinates of a unit length vector * representing the rotation axis * - theta is the rotation angle * * The quaternion must be of norm 1 (it is a unit quaternion). Failure to ensure * this will cause erratic client behaviour. * * In addition, this sensor reports an estimated heading accuracy. * sensors_event_t.data[4] = estimated_accuracy (in radians) * The heading error must be less than estimated_accuracy 95% of the time * * This sensor must use a gyroscope and an accelerometer as main orientation * change input. * * This sensor can also include magnetometer input to make up for gyro drift, * but it cannot be implemented using only a magnetometer. */ #define SENSOR_TYPE_ROTATION_VECTOR (11) /* * SENSOR_TYPE_RELATIVE_HUMIDITY * trigger-mode: on-change * wake-up sensor: no * * A relative humidity sensor measures relative ambient air humidity and * returns a value in percent. */ #define SENSOR_TYPE_RELATIVE_HUMIDITY (12) /* * SENSOR_TYPE_AMBIENT_TEMPERATURE * trigger-mode: on-change * wake-up sensor: no * * The ambient (room) temperature in degree Celsius. */ #define SENSOR_TYPE_AMBIENT_TEMPERATURE (13) /* * SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED * trigger-mode: continuous * wake-up sensor: no * * Similar to SENSOR_TYPE_MAGNETIC_FIELD, but the hard iron calibration is * reported separately instead of being included in the measurement. * Factory calibration and temperature compensation should still be applied to * the "uncalibrated" measurement. * Separating away the hard iron calibration estimation allows the system to * better recover from bad hard iron estimation. * * All values are in micro-Tesla (uT) and measure the ambient magnetic * field in the X, Y and Z axis. Assumptions that the the magnetic field * is due to the Earth's poles should be avoided. * * The uncalibrated_magnetic event contains * - 3 fields for uncalibrated measurement: x_uncalib, y_uncalib, z_uncalib. * Each is a component of the measured magnetic field, with soft iron * and temperature compensation applied, but not hard iron calibration. * These values should be continuous (no re-calibration should cause a jump). * - 3 fields for hard iron bias estimates: x_bias, y_bias, z_bias. * Each field is a component of the estimated hard iron calibration. * They represent the offsets to apply to the calibrated readings to obtain * uncalibrated readings (x_uncalib ~= x_calibrated + x_bias) * These values are expected to jump as soon as the estimate of the hard iron * changes, and they should be stable the rest of the time. * * If this sensor is present, then the corresponding * SENSOR_TYPE_MAGNETIC_FIELD must be present and both must return the * same sensor_t::name and sensor_t::vendor. * * Minimum filtering should be applied to this sensor. In particular, low pass * filters should be avoided. * * See SENSOR_TYPE_MAGNETIC_FIELD for more information */ #define SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED (14) /* * SENSOR_TYPE_GAME_ROTATION_VECTOR * trigger-mode: continuous * wake-up sensor: no * * Similar to SENSOR_TYPE_ROTATION_VECTOR, but not using the geomagnetic * field. Therefore the Y axis doesn't point north, but instead to some other * reference. That reference is allowed to drift by the same order of * magnitude than the gyroscope drift around the Z axis. * * This sensor does not report an estimated heading accuracy: * sensors_event_t.data[4] is reserved and should be set to 0 * * In the ideal case, a phone rotated and returning to the same real-world * orientation should report the same game rotation vector * (without using the earth's geomagnetic field). * * This sensor must be based on a gyroscope. It cannot be implemented using * a magnetometer. * * see SENSOR_TYPE_ROTATION_VECTOR for more details */ #define SENSOR_TYPE_GAME_ROTATION_VECTOR (15) /* * SENSOR_TYPE_GYROSCOPE_UNCALIBRATED * trigger-mode: continuous * wake-up sensor: no * * All values are in radians/second and measure the rate of rotation * around the X, Y and Z axis. An estimation of the drift on each axis is * reported as well. * * No gyro-drift compensation shall be performed. * Factory calibration and temperature compensation should still be applied * to the rate of rotation (angular speeds). * * The coordinate system is the same as is * used for the acceleration sensor. Rotation is positive in the * counter-clockwise direction (right-hand rule). That is, an observer * looking from some positive location on the x, y or z axis at a device * positioned on the origin would report positive rotation if the device * appeared to be rotating counter clockwise. Note that this is the * standard mathematical definition of positive rotation and does not agree * with the definition of roll given earlier. * The range should at least be 17.45 rad/s (ie: ~1000 deg/s). * * Content of an uncalibrated_gyro event: (units are rad/sec) * x_uncalib : angular speed (w/o drift compensation) around the X axis * y_uncalib : angular speed (w/o drift compensation) around the Y axis * z_uncalib : angular speed (w/o drift compensation) around the Z axis * x_bias : estimated drift around X axis in rad/s * y_bias : estimated drift around Y axis in rad/s * z_bias : estimated drift around Z axis in rad/s * * IMPLEMENTATION NOTES: * * If the implementation is not able to estimate the drift, then this * sensor MUST NOT be reported by this HAL. Instead, the regular * SENSOR_TYPE_GYROSCOPE is used without drift compensation. * * If this sensor is present, then the corresponding * SENSOR_TYPE_GYROSCOPE must be present and both must return the * same sensor_t::name and sensor_t::vendor. */ #define SENSOR_TYPE_GYROSCOPE_UNCALIBRATED (16) /* * SENSOR_TYPE_SIGNIFICANT_MOTION * trigger-mode: one-shot * wake-up sensor: yes * * A sensor of this type triggers an event each time significant motion * is detected and automatically disables itself. * The only allowed value to return is 1.0. * * A significant motion is a motion that might lead to a change in the user * location. * Examples of such motions are: * walking, biking, sitting in a moving car, coach or train. * Examples of situations that should not trigger significant motion: * - phone in pocket and person is not moving * - phone is on a table, even if the table shakes a bit due to nearby traffic * or washing machine * * A note on false positive / false negative / power consumption tradeoff * - The goal of this sensor is to save power. * - Triggering an event when the user is not moving (false positive) is costly * in terms of power, so it should be avoided. * - Not triggering an event when the user is moving (false negative) is * acceptable as long as it is not done repeatedly. If the user has been * walking for 10 seconds, not triggering an event within those 10 seconds * is not acceptable. * * IMPORTANT NOTE: this sensor type is very different from other types * in that it must work when the screen is off without the need of * holding a partial wake-lock and MUST allow the SoC to go into suspend. * When significant motion is detected, the sensor must awaken the SoC and * the event be reported. * * If a particular hardware cannot support this mode of operation then this * sensor type MUST NOT be reported by the HAL. ie: it is not acceptable * to "emulate" this sensor in the HAL. * * The whole point of this sensor type is to save power by keeping the * SoC in suspend mode when the device is at rest. * * When the sensor is not activated, it must also be deactivated in the * hardware: it must not wake up the SoC anymore, even in case of * significant motion. * * setDelay() has no effect and is ignored. * Once a "significant motion" event is returned, a sensor of this type * must disables itself automatically, as if activate(..., 0) had been called. */ #define SENSOR_TYPE_SIGNIFICANT_MOTION (17) /* * SENSOR_TYPE_STEP_DETECTOR * trigger-mode: special * wake-up sensor: no * * A sensor of this type triggers an event each time a step is taken * by the user. The only allowed value to return is 1.0 and an event is * generated for each step. Like with any other event, the timestamp * indicates when the event (here the step) occurred, this corresponds to when * the foot hit the ground, generating a high variation in acceleration. * * While this sensor operates, it shall not disrupt any other sensors, in * particular, but not limited to, the accelerometer; which might very well * be in use as well. * * This sensor must be low power. That is, if the step detection cannot be * done in hardware, this sensor should not be defined. Also, when the * step detector is activated and the accelerometer is not, only steps should * trigger interrupts (not accelerometer data). * * setDelay() has no impact on this sensor type */ #define SENSOR_TYPE_STEP_DETECTOR (18) /* * SENSOR_TYPE_STEP_COUNTER * trigger-mode: on-change * wake-up sensor: no * * A sensor of this type returns the number of steps taken by the user since * the last reboot while activated. The value is returned as a uint64_t and is * reset to zero only on a system / android reboot. * * The timestamp of the event is set to the time when the first step * for that event was taken. * See SENSOR_TYPE_STEP_DETECTOR for the signification of the time of a step. * * The minimum size of the hardware's internal counter shall be 16 bits * (this restriction is here to avoid too frequent wake-ups when the * delay is very large). * * IMPORTANT NOTE: this sensor type is different from other types * in that it must work when the screen is off without the need of * holding a partial wake-lock and MUST allow the SoC to go into suspend. * Unlike other sensors, while in suspend mode this sensor must stay active, * no events are reported during that time but, steps continue to be * accounted for; an event will be reported as soon as the SoC resumes if * the timeout has expired. * * In other words, when the screen is off and the device allowed to * go into suspend mode, we don't want to be woken up, regardless of the * setDelay() value, but the steps shall continue to be counted. * * The driver must however ensure that the internal step count never * overflows. It is allowed in this situation to wake the SoC up so the * driver can do the counter maintenance. * * While this sensor operates, it shall not disrupt any other sensors, in * particular, but not limited to, the accelerometer; which might very well * be in use as well. * * If a particular hardware cannot support these modes of operation then this * sensor type MUST NOT be reported by the HAL. ie: it is not acceptable * to "emulate" this sensor in the HAL. * * This sensor must be low power. That is, if the step detection cannot be * done in hardware, this sensor should not be defined. Also, when the * step counter is activated and the accelerometer is not, only steps should * trigger interrupts (not accelerometer data). * * The whole point of this sensor type is to save power by keeping the * SoC in suspend mode when the device is at rest. */ #define SENSOR_TYPE_STEP_COUNTER (19) /* * SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR * trigger-mode: continuous * wake-up sensor: no * * Similar to SENSOR_TYPE_ROTATION_VECTOR, but using a magnetometer instead * of using a gyroscope. * * This sensor must be based on a magnetometer. It cannot be implemented using * a gyroscope, and gyroscope input cannot be used by this sensor, as the * goal of this sensor is to be low power. * The accelerometer can be (and usually is) used. * * Just like SENSOR_TYPE_ROTATION_VECTOR, this sensor reports an estimated * heading accuracy: * sensors_event_t.data[4] = estimated_accuracy (in radians) * The heading error must be less than estimated_accuracy 95% of the time * * see SENSOR_TYPE_ROTATION_VECTOR for more details */ #define SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR (20) /** * Values returned by the accelerometer in various locations in the universe. * all values are in SI units (m/s^2) */ #define GRAVITY_SUN (275.0f) #define GRAVITY_EARTH (9.80665f) /** Maximum magnetic field on Earth's surface */ #define MAGNETIC_FIELD_EARTH_MAX (60.0f) /** Minimum magnetic field on Earth's surface */ #define MAGNETIC_FIELD_EARTH_MIN (30.0f) /** * status of orientation sensor */ #define SENSOR_STATUS_UNRELIABLE 0 #define SENSOR_STATUS_ACCURACY_LOW 1 #define SENSOR_STATUS_ACCURACY_MEDIUM 2 #define SENSOR_STATUS_ACCURACY_HIGH 3 /** * sensor event data */ typedef struct { union { float v[3]; struct { float x; float y; float z; }; struct { float azimuth; float pitch; float roll; }; }; int8_t status; uint8_t reserved[3]; } sensors_vec_t; /** * uncalibrated gyroscope and magnetometer event data */ typedef struct { union { float uncalib[3]; struct { float x_uncalib; float y_uncalib; float z_uncalib; }; }; union { float bias[3]; struct { float x_bias; float y_bias; float z_bias; }; }; } uncalibrated_event_t; typedef struct meta_data_event { int32_t what; int32_t sensor; } meta_data_event_t; /** * Union of the various types of sensor data * that can be returned. */ typedef struct sensors_event_t { /* must be sizeof(struct sensors_event_t) */ int32_t version; /* sensor identifier */ int32_t sensor; /* sensor type */ int32_t type; /* reserved */ int32_t reserved0; /* time is in nanosecond */ int64_t timestamp; union { union { float data[16]; /* acceleration values are in meter per second per second (m/s^2) */ sensors_vec_t acceleration; /* magnetic vector values are in micro-Tesla (uT) */ sensors_vec_t magnetic; /* orientation values are in degrees */ sensors_vec_t orientation; /* gyroscope values are in rad/s */ sensors_vec_t gyro; /* temperature is in degrees centigrade (Celsius) */ float temperature; /* distance in centimeters */ float distance; /* light in SI lux units */ float light; /* pressure in hectopascal (hPa) */ float pressure; /* relative humidity in percent */ float relative_humidity; /* uncalibrated gyroscope values are in rad/s */ uncalibrated_event_t uncalibrated_gyro; /* uncalibrated magnetometer values are in micro-Teslas */ uncalibrated_event_t uncalibrated_magnetic; /* this is a special event. see SENSOR_TYPE_META_DATA above. * sensors_meta_data_event_t events are all reported with a type of * SENSOR_TYPE_META_DATA. The handle is ignored and must be zero. */ meta_data_event_t meta_data; }; union { uint64_t data[8]; /* step-counter */ uint64_t step_counter; } u64; }; uint32_t reserved1[4]; } sensors_event_t; /* see SENSOR_TYPE_META_DATA */ typedef sensors_event_t sensors_meta_data_event_t; struct sensor_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. */ struct sensors_module_t { struct hw_module_t common; /** * Enumerate all available sensors. The list is returned in "list". * @return number of sensors in the list */ int (*get_sensors_list)(struct sensors_module_t* module, struct sensor_t const** list); }; struct sensor_t { /* Name of this sensor. * All sensors of the same "type" must have a different "name". */ const char* name; /* vendor of the hardware part */ const char* vendor; /* version of the hardware part + driver. The value of this field * must increase when the driver is updated in a way that changes the * output of this sensor. This is important for fused sensors when the * fusion algorithm is updated. */ int version; /* handle that identifies this sensors. This handle is used to reference * this sensor throughout the HAL API. */ int handle; /* this sensor's type. */ int type; /* maximum range of this sensor's value in SI units */ float maxRange; /* smallest difference between two values reported by this sensor */ float resolution; /* rough estimate of this sensor's power consumption in mA */ float power; /* this value depends on the trigger mode: * * continuous: minimum sample period allowed in microseconds * on-change : 0 * one-shot :-1 * special : 0, unless otherwise noted */ int32_t minDelay; /* number of events reserved for this sensor in the batch mode FIFO. * If there is a dedicated FIFO for this sensor, then this is the * size of this FIFO. If the FIFO is shared with other sensors, * this is the size reserved for that sensor and it can be zero. */ uint32_t fifoReservedEventCount; /* maximum number of events of this sensor that could be batched. * This is especially relevant when the FIFO is shared between * several sensors; this value is then set to the size of that FIFO. */ uint32_t fifoMaxEventCount; /* reserved fields, must be zero */ void* reserved[6]; }; /* * sensors_poll_device_t is used with SENSORS_DEVICE_API_VERSION_0_1 * and is present for backward binary and source compatibility. * (see documentation of the hooks in struct sensors_poll_device_1 below) */ struct sensors_poll_device_t { struct hw_device_t common; int (*activate)(struct sensors_poll_device_t *dev, int handle, int enabled); int (*setDelay)(struct sensors_poll_device_t *dev, int handle, int64_t ns); int (*poll)(struct sensors_poll_device_t *dev, sensors_event_t* data, int count); }; /* * struct sensors_poll_device_1 is used with SENSORS_DEVICE_API_VERSION_1_0 */ typedef struct sensors_poll_device_1 { union { /* sensors_poll_device_1 is compatible with sensors_poll_device_t, * and can be down-cast to it */ struct sensors_poll_device_t v0; struct { struct hw_device_t common; /* Activate/de-activate one sensor. * * handle is the handle of the sensor to change. * enabled set to 1 to enable, or 0 to disable the sensor. * * if enabled is set to 1, the sensor is activated even if * setDelay() wasn't called before. In this case, a default rate * should be used. * * unless otherwise noted in the sensor types definitions, an * activated sensor never prevents the SoC to go into suspend * mode; that is, the HAL shall not hold a partial wake-lock on * behalf of applications. * * one-shot sensors de-activate themselves automatically upon * receiving an event and they must still accept to be deactivated * through a call to activate(..., ..., 0). * * if "enabled" is 1 and the sensor is already activated, this * function is a no-op and succeeds. * * if "enabled" is 0 and the sensor is already de-activated, * this function is a no-op and succeeds. * * return 0 on success, negative errno code otherwise */ int (*activate)(struct sensors_poll_device_t *dev, int handle, int enabled); /** * Set the events's period in nanoseconds for a given sensor. * * What the period_ns parameter means depends on the specified * sensor's trigger mode: * * continuous: setDelay() sets the sampling rate. * on-change: setDelay() limits the delivery rate of events * one-shot: setDelay() is ignored. it has no effect. * special: see specific sensor type definitions * * For continuous and on-change sensors, if the requested value is * less than sensor_t::minDelay, then it's silently clamped to * sensor_t::minDelay unless sensor_t::minDelay is 0, in which * case it is clamped to >= 1ms. * * setDelay will not be called when the sensor is in batching mode. * In this case, batch() will be called with the new period. * * @return 0 if successful, < 0 on error */ int (*setDelay)(struct sensors_poll_device_t *dev, int handle, int64_t period_ns); /** * Returns an array of sensor data. * This function must block until events are available. * * return the number of events read on success, or -errno in case * of an error. * * The number of events returned in data must be less or equal * to the "count" argument. * * This function shall never return 0 (no event). */ int (*poll)(struct sensors_poll_device_t *dev, sensors_event_t* data, int count); }; }; /* * Enables batch mode for the given sensor and sets the delay between events * * A timeout value of zero disables batch mode for the given sensor. * * The period_ns parameter is equivalent to calling setDelay() -- this * function both enables or disables the batch mode AND sets the events's * period in nanosecond. See setDelay() above for a detailed explanation of * the period_ns parameter. * * BATCH MODE: * ----------- * In non-batch mode, all sensor events must be reported as soon as they * are detected. For example, an accelerometer activated at 50Hz will * trigger interrupts 50 times per second. * While in batch mode, sensor events do not need to be reported as soon * as they are detected. They can be temporarily stored in batches and * reported in batches, as long as no event is delayed by more than * "timeout" nanoseconds. That is, all events since the previous batch * are recorded and returned all at once. This allows to reduce the amount * of interrupts sent to the SoC, and allow the SoC to switch to a lower * power state (Idle) while the sensor is capturing and batching data. * * setDelay() is not affected and it behaves as usual. * * Each event has a timestamp associated with it, the timestamp * must be accurate and correspond to the time at which the event * physically happened. * * Batching does not modify the behavior of poll(): batches from different * sensors can be interleaved and split. As usual, all events from the same * sensor are time-ordered. * * BEHAVIOUR OUTSIDE OF SUSPEND MODE: * ---------------------------------- * * When the SoC is awake (not in suspend mode), events must be reported in * batches at least every "timeout". No event shall be dropped or lost. * If internal h/w FIFOs fill-up before the timeout, then events are * reported at that point to ensure no event is lost. * * * NORMAL BEHAVIOR IN SUSPEND MODE: * --------------------------------- * * By default, batch mode doesn't significantly change the interaction with * suspend mode. That is, sensors must continue to allow the SoC to * go into suspend mode and sensors must stay active to fill their * internal FIFO. In this mode, when the FIFO fills up, it shall wrap * around (basically behave like a circular buffer, overwriting events). * As soon as the SoC comes out of suspend mode, a batch is produced with * as much as the recent history as possible, and batch operation * resumes as usual. * * The behavior described above allows applications to record the recent * history of a set of sensor while keeping the SoC into suspend. It * also allows the hardware to not have to rely on a wake-up interrupt line. * * WAKE_UPON_FIFO_FULL BEHAVIOR IN SUSPEND MODE: * ---------------------------------------------- * * There are cases, however, where an application cannot afford to lose * any events, even when the device goes into suspend mode. * For a given rate, if a sensor has the capability to store at least 10 * seconds worth of events in its FIFO and is able to wake up the Soc, it * can implement an optional secondary mode: the WAKE_UPON_FIFO_FULL mode. * * The caller will set the SENSORS_BATCH_WAKE_UPON_FIFO_FULL flag to * activate this mode. If the sensor does not support this mode, batch() * will fail when the flag is set. * * When running with the WAKE_UPON_FIFO_FULL flag set, no events can be * lost. When the FIFO is getting full, the sensor must wake up the SoC from * suspend and return a batch before the FIFO fills-up. * Depending on the device, it might take a few miliseconds for the SoC to * entirely come out of suspend and start flushing the FIFO. Enough head * room must be allocated in the FIFO to allow the device to entirely come * out of suspend without the FIFO overflowing (no events shall be lost). * * Implementing the WAKE_UPON_FIFO_FULL mode is optional. * If the hardware cannot support this mode, or if the physical * FIFO is so small that the device would never be allowed to go into * suspend for at least 10 seconds, then this function MUST fail when * the flag SENSORS_BATCH_WAKE_UPON_FIFO_FULL is set, regardless of * the value of the timeout parameter. * * * DRY RUN: * -------- * * If the flag SENSORS_BATCH_DRY_RUN is set, this function returns * without modifying the batch mode or the event period and has no side * effects, but returns errors as usual (as it would if this flag was * not set). This flag is used to check if batch mode is available for a * given configuration -- in particular for a given sensor at a given rate. * * * Return values: * -------------- * * Because sensors must be independent, the return value must not depend * on the state of the system (whether another sensor is on or not), * nor on whether the flag SENSORS_BATCH_DRY_RUN is set (in other words, * if a batch call with SENSORS_BATCH_DRY_RUN is successful, * the same call without SENSORS_BATCH_DRY_RUN must succeed as well). * * When timeout is not 0: * If successful, 0 is returned. * If the specified sensor doesn't support batch mode, return -EINVAL. * If the specified sensor's trigger-mode is one-shot, return -EINVAL. * If WAKE_UPON_FIFO_FULL is specified and the specified sensor's internal * FIFO is too small to store at least 10 seconds worth of data at the * given rate, -EINVAL is returned. Note that as stated above, this has to * be determined at compile time, and not based on the state of the * system. * If some other constraints above cannot be satisfied, return -EINVAL. * * Note: the timeout parameter, when > 0, has no impact on whether this * function succeeds or fails. * * When timeout is 0: * The caller will never set the wake_upon_fifo_full flag. * The function must succeed, and batch mode must be deactivated. * * Independently of whether DRY_RUN is specified, When the call to batch() * fails, no state should be changed. In particular, a failed call to * batch() should not change the rate of the sensor. Example: * setDelay(..., 10ms) * batch(..., 20ms, ...) fails * rate should stay 10ms. * * * IMPLEMENTATION NOTES: * --------------------- * * Batch mode, if supported, should happen at the hardware level, * typically using hardware FIFOs. In particular, it SHALL NOT be * implemented in the HAL, as this would be counter productive. * The goal here is to save significant amounts of power. * * In some implementations, events from several sensors can share the * same physical FIFO. In that case, all events in the FIFO can be sent and * processed by the HAL as soon as one batch must be reported. * For example, if the following sensors are activated: * - accelerometer batched with timeout = 20s * - gyroscope batched with timeout = 5s * then the accelerometer batches can be reported at the same time the * gyroscope batches are reported (every 5 seconds) * * Batch mode can be enabled or disabled at any time, in particular * while the specified sensor is already enabled, and this shall not * result in the loss of events. * * COMPARATIVE IMPORTANCE OF BATCHING FOR DIFFERENT SENSORS: * --------------------------------------------------------- * * On platforms on which hardware fifo size is limited, the system designers * might have to choose how much fifo to reserve for each sensor. To help * with this choice, here is a list of applications made possible when * batching is implemented on the different sensors. * * High value: Low power pedestrian dead reckoning * Target batching time: 20 seconds to 1 minute * Sensors to batch: * - Step detector * - Rotation vector or game rotation vector at 5Hz * Gives us step and heading while letting the SoC go to Suspend. * * High value: Medium power activity/gesture recognition * Target batching time: 3 seconds * Sensors to batch: accelerometer between 20Hz and 50Hz * Allows recognizing arbitrary activities and gestures without having * to keep the SoC fully awake while the data is collected. * * Medium-high value: Interrupt load reduction * Target batching time: < 1 second * Sensors to batch: any high frequency sensor. * If the gyroscope is set at 800Hz, even batching just 10 gyro events can * reduce the number of interrupts from 800/second to 80/second. * * Medium value: Continuous low frequency data collection * Target batching time: > 1 minute * Sensors to batch: barometer, humidity sensor, other low frequency * sensors. * Allows creating monitoring applications at low power. * * Medium value: Continuous full-sensors collection * Target batching time: > 1 minute * Sensors to batch: all, at high frequencies * Allows full collection of sensor data while leaving the SoC in * suspend mode. Only to consider if fifo space is not an issue. * * In each of the cases above, if WAKE_UPON_FIFO_FULL is implemented, the * applications might decide to let the SoC go to suspend, allowing for even * more power savings. */ int (*batch)(struct sensors_poll_device_1* dev, int handle, int flags, int64_t period_ns, int64_t timeout); /* * Flush adds a META_DATA_FLUSH_COMPLETE event (sensors_event_meta_data_t) * to the end of the "batch mode" FIFO for the specified sensor and flushes * the FIFO; those events are delivered as usual (i.e.: as if the batch * timeout had expired) and removed from the FIFO. * * See the META_DATA_FLUSH_COMPLETE section for details about the * META_DATA_FLUSH_COMPLETE event. * * The flush happens asynchronously (i.e.: this function must return * immediately). * * If the implementation uses a single FIFO for several sensors, that * FIFO is flushed and the META_DATA_FLUSH_COMPLETE event is added only * for the specified sensor. * * If the specified sensor wasn't in batch mode, flush succeeds and * promptly sends a META_DATA_FLUSH_COMPLETE event for that sensor. * * If the FIFO was empty at the time of the call, flush returns * 0 (success) and promptly sends a META_DATA_FLUSH_COMPLETE event * for that sensor. * * If the specified sensor wasn't enabled, flush returns -EINVAL. * * return 0 on success, negative errno code otherwise. */ int (*flush)(struct sensors_poll_device_1* dev, int handle); void (*reserved_procs[8])(void); } sensors_poll_device_1_t; /** convenience API for opening and closing a device */ static inline int sensors_open(const struct hw_module_t* module, struct sensors_poll_device_t** device) { return module->methods->open(module, SENSORS_HARDWARE_POLL, (struct hw_device_t**)device); } static inline int sensors_close(struct sensors_poll_device_t* device) { return device->common.close(&device->common); } 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); } static inline int sensors_close_1(sensors_poll_device_1_t* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_SENSORS_INTERFACE_H android-headers-23/19/hardware_legacy/000077500000000000000000000000001264465411000177065ustar00rootroot00000000000000android-headers-23/19/hardware_legacy/audio_policy_conf.h000066400000000000000000000036201264465411000235450ustar00rootroot00000000000000/* * 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_AUDIO_POLICY_CONF_H #define ANDROID_AUDIO_POLICY_CONF_H ///////////////////////////////////////////////// // Definitions for audio policy configuration file (audio_policy.conf) ///////////////////////////////////////////////// #define AUDIO_HARDWARE_MODULE_ID_MAX_LEN 32 #define AUDIO_POLICY_CONFIG_FILE "/system/etc/audio_policy.conf" #define AUDIO_POLICY_VENDOR_CONFIG_FILE "/vendor/etc/audio_policy.conf" // global configuration #define GLOBAL_CONFIG_TAG "global_configuration" #define ATTACHED_OUTPUT_DEVICES_TAG "attached_output_devices" #define DEFAULT_OUTPUT_DEVICE_TAG "default_output_device" #define ATTACHED_INPUT_DEVICES_TAG "attached_input_devices" // hw modules descriptions #define AUDIO_HW_MODULE_TAG "audio_hw_modules" #define OUTPUTS_TAG "outputs" #define INPUTS_TAG "inputs" #define SAMPLING_RATES_TAG "sampling_rates" #define FORMATS_TAG "formats" #define CHANNELS_TAG "channel_masks" #define DEVICES_TAG "devices" #define FLAGS_TAG "flags" #define DYNAMIC_VALUE_TAG "dynamic" // special value for "channel_masks", "sampling_rates" and // "formats" in outputs descriptors indicating that supported // values should be queried after opening the output. #endif // ANDROID_AUDIO_POLICY_CONF_H android-headers-23/19/hardware_legacy/vibrator.h000066400000000000000000000022321264465411000217060ustar00rootroot00000000000000/* * 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 android-headers-23/19/hardware_legacy/wifi.h000066400000000000000000000077041264465411000210250ustar00rootroot00000000000000/* * 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 _WIFI_H #define _WIFI_H #if __cplusplus extern "C" { #endif /** * Load the Wi-Fi driver. * * @return 0 on success, < 0 on failure. */ int wifi_load_driver(); /** * Unload the Wi-Fi driver. * * @return 0 on success, < 0 on failure. */ int wifi_unload_driver(); /** * Check if the Wi-Fi driver is loaded. * * @return 0 on success, < 0 on failure. */ 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 const char *wifi_get_fw_path(int fw_type); /** * Change the path to firmware for the wlan driver */ int wifi_change_fw_path(const char *fwpath); /** * Check and create if necessary initial entropy file */ #define WIFI_ENTROPY_FILE "/data/misc/wifi/entropy.bin" int ensure_entropy_file_exists(); #if __cplusplus }; // extern "C" #endif #endif // _WIFI_H android-headers-23/19/libnfc-nxp/000077500000000000000000000000001264465411000166255ustar00rootroot00000000000000android-headers-23/19/libnfc-nxp/nfc_custom_config_example.h000066400000000000000000000124361264465411000242040ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/nfc_osal_deferred_call.h000066400000000000000000000021511264465411000234140ustar00rootroot00000000000000#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); #endifandroid-headers-23/19/libnfc-nxp/phDal4Nfc.h000066400000000000000000000630601264465411000205460ustar00rootroot00000000000000/* * 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 android-headers-23/19/libnfc-nxp/phDal4Nfc_messageQueueLib.h000066400000000000000000000026351264465411000237070ustar00rootroot00000000000000/* * 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; int phDal4Nfc_msgget(key_t key, int msgflg); int phDal4Nfc_msgctl(int msqid, int cmd, void *buf); int phDal4Nfc_msgsnd(int msqid, void * msgp, size_t msgsz, int msgflg); int phDal4Nfc_msgrcv (int msqid, void * msgp, size_t msgsz, long msgtyp, int msgflg); #endif #endif /* PHDAL4NFC_MESSAGEQUEUE_H */ android-headers-23/19/libnfc-nxp/phDbgTrace.h000066400000000000000000000133441264465411000210060ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phDnldNfc.h000066400000000000000000000114311264465411000206360ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phFriNfc.h000066400000000000000000000133601264465411000205000ustar00rootroot00000000000000/* * 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__ */ android-headers-23/19/libnfc-nxp/phFriNfc_DesfireFormat.h000066400000000000000000000253751264465411000233230ustar00rootroot00000000000000/* * 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 android-headers-23/19/libnfc-nxp/phFriNfc_DesfireMap.h000066400000000000000000000344271264465411000226060ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phFriNfc_FelicaMap.h000066400000000000000000000340361264465411000224040ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phFriNfc_ISO15693Format.h000066400000000000000000000111301264465411000227640ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phFriNfc_ISO15693Map.h000066400000000000000000000243771264465411000222720ustar00rootroot00000000000000/* * * 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 */ android-headers-23/19/libnfc-nxp/phFriNfc_IntNdefMap.h000066400000000000000000000072241264465411000225470ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phFriNfc_Llcp.h000066400000000000000000000367111264465411000214570ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phFriNfc_LlcpMac.h000066400000000000000000000210611264465411000220700ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phFriNfc_LlcpMacNfcip.h000066400000000000000000000022321264465411000230470ustar00rootroot00000000000000/* * 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_LlcpMacNfcip.h * \brief NFC LLCP MAC Mapping for NFCIP. * * Project: NFC-FRI * */ #ifndef PHFRINFC_LLCPMACNFCIP_H #define PHFRINFC_LLCPMACNFCIP_H /*include files*/ #include #include #include #include /** * \name MAC Mapping for NFCIP * * File: \ref phFriNfc_LlcpMacNfcip.h * */ /** \defgroup grp_fri_nfc_llcp_macnfcip NFCIP MAC Mapping * * TODO * */ NFCSTATUS phFriNfc_LlcpMac_Nfcip_Register (phFriNfc_LlcpMac_t *LlcpMac); #endif /* PHFRINFC_LLCPMACNFCIP_H */ android-headers-23/19/libnfc-nxp/phFriNfc_LlcpTransport.h000066400000000000000000001155541264465411000233770ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phFriNfc_LlcpTransport_Connection.h000066400000000000000000000415061264465411000255510ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phFriNfc_LlcpTransport_Connectionless.h000066400000000000000000000136471264465411000264450ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phFriNfc_LlcpUtils.h000066400000000000000000000114131264465411000224700ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phFriNfc_MapTools.h000066400000000000000000000061721264465411000223210ustar00rootroot00000000000000/* * 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 android-headers-23/19/libnfc-nxp/phFriNfc_MifStdFormat.h000066400000000000000000000452731264465411000231270ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phFriNfc_MifULFormat.h000066400000000000000000000167131264465411000227120ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phFriNfc_MifareStdMap.h000066400000000000000000000563431264465411000231040ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phFriNfc_MifareULMap.h000066400000000000000000000373411264465411000226670ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phFriNfc_NdefMap.h000066400000000000000000001525511264465411000221000ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phFriNfc_NdefRecord.h000066400000000000000000000665561264465411000226120ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phFriNfc_NdefReg.h000066400000000000000000000543301264465411000220740ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phFriNfc_OvrHal.h000066400000000000000000000373351264465411000217630ustar00rootroot00000000000000/* * 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 android-headers-23/19/libnfc-nxp/phFriNfc_OvrHalCmd.h000066400000000000000000000256351264465411000224070ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phFriNfc_SmtCrdFmt.h000066400000000000000000000446671264465411000224410ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phFriNfc_TopazMap.h000066400000000000000000000754451264465411000223270ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phHal4Nfc.h000066400000000000000000001414511264465411000205530ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phHal4Nfc_Internal.h000066400000000000000000000307131264465411000224050ustar00rootroot00000000000000/* * 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 android-headers-23/19/libnfc-nxp/phHciNfc_AdminMgmt.h000066400000000000000000000167221264465411000224250ustar00rootroot00000000000000/* * 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 android-headers-23/19/libnfc-nxp/phHciNfc_CE_A.h000066400000000000000000000255241264465411000212770ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phHciNfc_CE_B.h000066400000000000000000000252721264465411000213000ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phHciNfc_DevMgmt.h000066400000000000000000000272201264465411000221060ustar00rootroot00000000000000/* * 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 android-headers-23/19/libnfc-nxp/phHciNfc_Emulation.h000066400000000000000000000132771264465411000225070ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phHciNfc_Felica.h000066400000000000000000000251121264465411000217240ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phHciNfc_Generic.h000066400000000000000000001241051264465411000221170ustar00rootroot00000000000000/* * 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 android-headers-23/19/libnfc-nxp/phHciNfc_IDMgmt.h000066400000000000000000000200761264465411000216660ustar00rootroot00000000000000/* * 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 android-headers-23/19/libnfc-nxp/phHciNfc_ISO15693.h000066400000000000000000000237231264465411000216110ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phHciNfc_Jewel.h000066400000000000000000000231221264465411000216060ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phHciNfc_LinkMgmt.h000066400000000000000000000127131264465411000222660ustar00rootroot00000000000000/* * 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 android-headers-23/19/libnfc-nxp/phHciNfc_NfcIPMgmt.h000066400000000000000000000667011264465411000223360ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phHciNfc_Pipe.h000066400000000000000000000231451264465411000214420ustar00rootroot00000000000000/* * 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 android-headers-23/19/libnfc-nxp/phHciNfc_PollingLoop.h000066400000000000000000000173671264465411000230140ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phHciNfc_RFReader.h000066400000000000000000000545371264465411000222100ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phHciNfc_RFReaderA.h000066400000000000000000000345311264465411000223010ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phHciNfc_RFReaderB.h000066400000000000000000000236401264465411000223010ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phHciNfc_SWP.h000066400000000000000000000301461264465411000212150ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phHciNfc_Sequence.h000066400000000000000000000364271264465411000223240ustar00rootroot00000000000000/* * 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 android-headers-23/19/libnfc-nxp/phHciNfc_WI.h000066400000000000000000000211351264465411000210610ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phLibNfc.h000066400000000000000000004736111264465411000204770ustar00rootroot00000000000000/* * 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 uint32_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 */ android-headers-23/19/libnfc-nxp/phLibNfcStatus.h000066400000000000000000000050551264465411000216740ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phLibNfc_Internal.h000066400000000000000000000221331264465411000223200ustar00rootroot00000000000000/* * 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; uint32_t Connected_handle, Discov_handle[MAX_REMOTE_DEVICES]; /* To store the previous connected handle in case of Multiple protocol tags */ uint32_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 android-headers-23/19/libnfc-nxp/phLibNfc_SE.h000066400000000000000000000047561264465411000210660ustar00rootroot00000000000000/* * 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 android-headers-23/19/libnfc-nxp/phLibNfc_discovery.h000066400000000000000000000017161264465411000225570ustar00rootroot00000000000000/* * 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 * * 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 ); #endif android-headers-23/19/libnfc-nxp/phLibNfc_initiator.h000066400000000000000000000031531264465411000225470ustar00rootroot00000000000000/* * 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 android-headers-23/19/libnfc-nxp/phLibNfc_ioctl.h000066400000000000000000000050111264465411000216520ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phLibNfc_ndef_raw.h000066400000000000000000000045331264465411000223350ustar00rootroot00000000000000/* * 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 android-headers-23/19/libnfc-nxp/phLlcNfc.h000066400000000000000000000131161264465411000204710ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phLlcNfc_DataTypes.h000066400000000000000000000472721264465411000224610ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phLlcNfc_Frame.h000066400000000000000000000360611264465411000216070ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phLlcNfc_Interface.h000066400000000000000000000142661264465411000224600ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phLlcNfc_Timer.h000066400000000000000000000135271264465411000216370ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phNfcCompId.h000066400000000000000000000145551264465411000211420ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phNfcConfig.h000066400000000000000000000314371264465411000211720ustar00rootroot00000000000000/* * 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*/ android-headers-23/19/libnfc-nxp/phNfcHalTypes.h000066400000000000000000001075141264465411000215160ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phNfcInterface.h000066400000000000000000000332641264465411000216650ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phNfcStatus.h000066400000000000000000000301521264465411000212410ustar00rootroot00000000000000/* * 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 */ android-headers-23/19/libnfc-nxp/phNfcTypes.h000066400000000000000000001314201264465411000210620ustar00rootroot00000000000000/* * 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) */ unsigned int 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 */ android-headers-23/19/libnfc-nxp/phOsalNfc.h000066400000000000000000000146071264465411000206630ustar00rootroot00000000000000/* * 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, /** #else #ifdef __linux__ #include #else #include #endif #endif #endif /* PHOSALNFC_MSG_H */ android-headers-23/19/libnfc-nxp/phOsalNfc_Timer.h000066400000000000000000000164661264465411000220300ustar00rootroot00000000000000/* * 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_Timer.h * \brief Timer Implementation. * * Project: NFC-FRI 1.1 * * $Date: Mon Mar 16 20:30:44 2009 $ * $Author: ing01697 $ * $Revision: 1.19 $ * $Aliases: 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 PHOSALNFC_TIMER_H #define PHOSALNFC_TIMER_H /* -----------------Include files ---------------------------------------*/ #include #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 */ android-headers-23/19/linux/000077500000000000000000000000001264465411000157245ustar00rootroot00000000000000android-headers-23/19/linux/android_alarm.h000066400000000000000000000035651264465411000207020ustar00rootroot00000000000000/* linux/android_alarm.h ** ** Copyright 2006, The Android Open Source Project ** Author: Arve Hjønnevåg ** ** 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 _LINUX_ANDROID_ALARM_H #define _LINUX_ANDROID_ALARM_H #include #include typedef enum { // return code bit numbers or set alarm arg ANDROID_ALARM_RTC_WAKEUP, ANDROID_ALARM_RTC, ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP, ANDROID_ALARM_ELAPSED_REALTIME, ANDROID_ALARM_SYSTEMTIME, // ANDROID_ALARM_TYPE_COUNT, // return code bit numbers // ANDROID_ALARM_TIME_CHANGE = 16 } android_alarm_type_t; typedef enum { ANDROID_ALARM_RTC_WAKEUP_MASK = 1U << ANDROID_ALARM_RTC_WAKEUP, ANDROID_ALARM_RTC_MASK = 1U << ANDROID_ALARM_RTC, 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_TIME_CHANGE_MASK = 1U << 16 } android_alarm_return_flags_t; #define ANDROID_ALARM_CLEAR(type) _IO('a', 0 | ((type) << 4)) // diasable alarm #define ANDROID_ALARM_WAIT _IO('a', 1) // ack last alarm and wait for next #define ANDROID_ALARM_SET(type) _IOW('a', 2 | ((type) << 4), struct timespec) // set alarm #define ANDROID_ALARM_SET_AND_WAIT(type) _IOW('a', 3 | ((type) << 4), struct timespec) #define ANDROID_ALARM_GET_TIME(type) _IOW('a', 4 | ((type) << 4), struct timespec) #define ANDROID_ALARM_SET_RTC _IOW('a', 5, struct timespec) #define ANDROID_ALARM_SET_TIMEZONE _IOW('a', 6, struct timezone) #define ANDROID_ALARM_BASE_CMD(cmd) (cmd & ~(_IOC(0, 0, 0xf0, 0))) #define ANDROID_ALARM_IOCTL_TO_TYPE(cmd) (_IOC_NR(cmd) >> 4) #endif android-headers-23/19/linux/binder.h000066400000000000000000000221511264465411000173410ustar00rootroot00000000000000/* * Copyright (C) 2008 The Android Open Source Project * * Based on, but no longer compatible with, the original * OpenBinder.org binder driver interface, which is: * * Copyright (c) 2005 Palmsource, Inc. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and * may be copied, distributed, and modified under those terms. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * */ #ifndef _LINUX_BINDER_H #define _LINUX_BINDER_H #include #define B_PACK_CHARS(c1, c2, c3, c4) \ ((((c1)<<24)) | (((c2)<<16)) | (((c3)<<8)) | (c4)) #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), 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), }; enum { FLAT_BINDER_FLAG_PRIORITY_MASK = 0xff, FLAT_BINDER_FLAG_ACCEPTS_FDS = 0x100, }; /* * This is the flattened representation of a Binder object for transfer * between processes. The 'offsets' supplied as part of a binder transaction * contains offsets into the data where these structures occur. The Binder * driver takes care of re-writing the structure type and data as it moves * between processes. */ struct flat_binder_object { /* 8 bytes for large_flat_header. */ unsigned long type; unsigned long flags; /* 8 bytes of data. */ union { void *binder; /* local object */ signed long handle; /* remote object */ }; /* extra data associated with local object */ void *cookie; }; /* * On 64-bit platforms where user code may run in 32-bits the driver must * translate the buffer (and local binder) addresses apropriately. */ struct binder_write_read { signed long write_size; /* bytes to write */ signed long write_consumed; /* bytes consumed by driver */ unsigned long write_buffer; signed long read_size; /* bytes to read */ signed long read_consumed; /* bytes consumed by driver */ unsigned long read_buffer; }; /* Use with BINDER_VERSION, driver fills in fields. */ struct binder_version { /* driver protocol version -- increment with incompatible change */ signed long protocol_version; }; /* This is the current protocol version. */ #define BINDER_CURRENT_PROTOCOL_VERSION 7 #define BINDER_WRITE_READ _IOWR('b', 1, struct binder_write_read) #define BINDER_SET_IDLE_TIMEOUT _IOW('b', 3, int64_t) #define BINDER_SET_MAX_THREADS _IOW('b', 5, size_t) #define BINDER_SET_IDLE_PRIORITY _IOW('b', 6, int) #define BINDER_SET_CONTEXT_MGR _IOW('b', 7, int) #define BINDER_THREAD_EXIT _IOW('b', 8, int) #define BINDER_VERSION _IOWR('b', 9, struct binder_version) /* * NOTE: Two special error codes you should check for when calling * in to the driver are: * * EINTR -- The operation has been interupted. This should be * handled by retrying the ioctl() until a different error code * is returned. * * ECONNREFUSED -- The driver is no longer accepting operations * from your process. That is, the process is being destroyed. * You should handle this by exiting from your process. Note * that once this error code is returned, all further calls to * the driver from any thread will return this same code. */ enum transaction_flags { TF_ONE_WAY = 0x01, /* this is a one-way call: async, no return */ TF_ROOT_OBJECT = 0x04, /* contents are the component's root object */ TF_STATUS_CODE = 0x08, /* contents are a 32-bit status code */ TF_ACCEPT_FDS = 0x10, /* allow replies with file descriptors */ }; struct binder_transaction_data { /* The first two are only used for bcTRANSACTION and brTRANSACTION, * identifying the target and contents of the transaction. */ union { size_t handle; /* target descriptor of command transaction */ void *ptr; /* target descriptor of return transaction */ } target; void *cookie; /* target object cookie */ unsigned int code; /* transaction command */ /* General information about the transaction. */ unsigned int flags; pid_t sender_pid; uid_t sender_euid; size_t data_size; /* number of bytes of data */ size_t offsets_size; /* number of bytes of offsets */ /* If this transaction is inline, the data immediately * follows here; otherwise, it ends with a pointer to * the data buffer. */ union { struct { /* transaction data */ const void *buffer; /* offsets from buffer to flat_binder_object structs */ const void *offsets; } ptr; uint8_t buf[8]; } data; }; struct binder_ptr_cookie { void *ptr; void *cookie; }; struct binder_pri_desc { int priority; int desc; }; struct binder_pri_ptr_cookie { int priority; void *ptr; void *cookie; }; /* The _IO?_BAD() macros required so that these evaluate to a * constant expression, otherwise this fails to compile in C++ */ enum BinderDriverReturnProtocol { BR_ERROR = _IOR_BAD('r', 0, int), /* * int: error code */ BR_OK = _IO('r', 1), /* No parameters! */ BR_TRANSACTION = _IOR_BAD('r', 2, struct binder_transaction_data), BR_REPLY = _IOR_BAD('r', 3, struct binder_transaction_data), /* * binder_transaction_data: the received command. */ BR_ACQUIRE_RESULT = _IOR_BAD('r', 4, int), /* * not currently supported * int: 0 if the last bcATTEMPT_ACQUIRE was not successful. * Else the remote object has acquired a primary reference. */ BR_DEAD_REPLY = _IO('r', 5), /* * The target of the last transaction (either a bcTRANSACTION or * a bcATTEMPT_ACQUIRE) is no longer with us. No parameters. */ BR_TRANSACTION_COMPLETE = _IO('r', 6), /* * No parameters... always refers to the last transaction requested * (including replies). Note that this will be sent even for * asynchronous transactions. */ BR_INCREFS = _IOR_BAD('r', 7, struct binder_ptr_cookie), BR_ACQUIRE = _IOR_BAD('r', 8, struct binder_ptr_cookie), BR_RELEASE = _IOR_BAD('r', 9, struct binder_ptr_cookie), BR_DECREFS = _IOR_BAD('r', 10, struct binder_ptr_cookie), /* * void *: ptr to binder * void *: cookie for binder */ BR_ATTEMPT_ACQUIRE = _IOR_BAD('r', 11, struct binder_pri_ptr_cookie), /* * not currently supported * int: priority * void *: ptr to binder * void *: cookie for binder */ BR_NOOP = _IO('r', 12), /* * No parameters. Do nothing and examine the next command. It exists * primarily so that we can replace it with a BR_SPAWN_LOOPER command. */ BR_SPAWN_LOOPER = _IO('r', 13), /* * No parameters. The driver has determined that a process has no * threads waiting to service incomming transactions. When a process * receives this command, it must spawn a new service thread and * register it via bcENTER_LOOPER. */ BR_FINISHED = _IO('r', 14), /* * not currently supported * stop threadpool thread */ BR_DEAD_BINDER = _IOR_BAD('r', 15, void *), /* * void *: cookie */ BR_CLEAR_DEATH_NOTIFICATION_DONE = _IOR_BAD('r', 16, void *), /* * void *: cookie */ BR_FAILED_REPLY = _IO('r', 17), /* * The the last transaction (either a bcTRANSACTION or * a bcATTEMPT_ACQUIRE) failed (e.g. out of memory). No parameters. */ }; enum BinderDriverCommandProtocol { BC_TRANSACTION = _IOW_BAD('c', 0, struct binder_transaction_data), BC_REPLY = _IOW_BAD('c', 1, struct binder_transaction_data), /* * binder_transaction_data: the sent command. */ BC_ACQUIRE_RESULT = _IOW_BAD('c', 2, int), /* * not currently supported * int: 0 if the last BR_ATTEMPT_ACQUIRE was not successful. * Else you have acquired a primary reference on the object. */ BC_FREE_BUFFER = _IOW_BAD('c', 3, int), /* * void *: ptr to transaction data received on a read */ BC_INCREFS = _IOW_BAD('c', 4, int), BC_ACQUIRE = _IOW_BAD('c', 5, int), BC_RELEASE = _IOW_BAD('c', 6, int), BC_DECREFS = _IOW_BAD('c', 7, int), /* * int: descriptor */ BC_INCREFS_DONE = _IOW_BAD('c', 8, struct binder_ptr_cookie), BC_ACQUIRE_DONE = _IOW_BAD('c', 9, struct binder_ptr_cookie), /* * void *: ptr to binder * void *: cookie for binder */ BC_ATTEMPT_ACQUIRE = _IOW_BAD('c', 10, struct binder_pri_desc), /* * not currently supported * int: priority * int: descriptor */ BC_REGISTER_LOOPER = _IO('c', 11), /* * No parameters. * Register a spawned looper thread with the device. */ BC_ENTER_LOOPER = _IO('c', 12), BC_EXIT_LOOPER = _IO('c', 13), /* * No parameters. * These two commands are sent as an application-level thread * enters and exits the binder loop, respectively. They are * used so the binder can have an accurate count of the number * of looping threads it has available. */ BC_REQUEST_DEATH_NOTIFICATION = _IOW_BAD('c', 14, struct binder_ptr_cookie), /* * void *: ptr to binder * void *: cookie */ BC_CLEAR_DEATH_NOTIFICATION = _IOW_BAD('c', 15, struct binder_ptr_cookie), /* * void *: ptr to binder * void *: cookie */ BC_DEAD_BINDER_DONE = _IOW_BAD('c', 16, void *), /* * void *: cookie */ }; #endif /* _LINUX_BINDER_H */ android-headers-23/19/linux/sw_sync.h000066400000000000000000000030141264465411000175600ustar00rootroot00000000000000/**************************************************************************** **************************************************************************** *** *** This header was automatically generated from a Linux kernel header *** of the same name, to make information necessary for userspace to *** call into the kernel available to libc. It contains only constants, *** structures, and macros generated from the original header, and thus, *** contains no copyrightable information. *** *** To edit the content of this header, modify the corresponding *** source file (e.g. under external/kernel-headers/original/) then *** run bionic/libc/kernel/tools/update_all.py *** *** Any manual change here will be lost the next time this script will *** be run. You've been warned! *** **************************************************************************** ****************************************************************************/ #ifndef _LINUX_SW_SYNC_H #define _LINUX_SW_SYNC_H #include struct sw_sync_create_fence_data { /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ __u32 value; char name[32]; __s32 fence; }; /* 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) #endif /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ android-headers-23/19/linux/sync.h000066400000000000000000000037661264465411000170650ustar00rootroot00000000000000/**************************************************************************** **************************************************************************** *** *** This header was automatically generated from a Linux kernel header *** of the same name, to make information necessary for userspace to *** call into the kernel available to libc. It contains only constants, *** structures, and macros generated from the original header, and thus, *** contains no copyrightable information. *** *** To edit the content of this header, modify the corresponding *** source file (e.g. under external/kernel-headers/original/) then *** run bionic/libc/kernel/tools/update_all.py *** *** Any manual change here will be lost the next time this script will *** be run. You've been warned! *** **************************************************************************** ****************************************************************************/ #ifndef _LINUX_SYNC_H #define _LINUX_SYNC_H #include struct sync_merge_data { /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ __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]; char driver_name[32]; /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ __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]; __s32 status; /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ __u8 pt_info[0]; }; #define SYNC_IOC_MAGIC '>' #define SYNC_IOC_WAIT _IOW(SYNC_IOC_MAGIC, 0, __s32) /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ #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 android-headers-23/19/log/000077500000000000000000000000001264465411000153465ustar00rootroot00000000000000android-headers-23/19/log/event_tag_map.h000066400000000000000000000024171264465411000203340ustar00rootroot00000000000000/* * 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. */ #ifndef _LIBS_CUTILS_EVENTTAGMAP_H #define _LIBS_CUTILS_EVENTTAGMAP_H #ifdef __cplusplus extern "C" { #endif #define EVENT_TAG_MAP_FILE "/system/etc/event-log-tags" struct EventTagMap; typedef struct EventTagMap EventTagMap; /* * Open the specified file as an event log tag map. * * Returns NULL on failure. */ EventTagMap* android_openEventTagMap(const char* fileName); /* * Close the map. */ 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); #ifdef __cplusplus } #endif #endif /*_LIBS_CUTILS_EVENTTAGMAP_H*/ android-headers-23/19/log/log.h000066400000000000000000000354571264465411000163160ustar00rootroot00000000000000/* * Copyright (C) 2005 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. */ // // 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 #include #include #include #ifdef HAVE_PTHREADS #include #endif #include #include #include #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 * 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 // --------------------------------------------------------------------- /* * Simplified macro to send a verbose log message using the current LOG_TAG. */ #ifndef ALOGV #if LOG_NDEBUG #define ALOGV(...) ((void)0) #else #define ALOGV(...) ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) #endif #endif #define CONDITION(cond) (__builtin_expect((cond)!=0, 0)) #ifndef ALOGV_IF #if LOG_NDEBUG #define ALOGV_IF(cond, ...) ((void)0) #else #define ALOGV_IF(cond, ...) \ ( (CONDITION(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, ...) \ ( (CONDITION(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, ...) \ ( (CONDITION(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, ...) \ ( (CONDITION(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, ...) \ ( (CONDITION(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 // --------------------------------------------------------------------- /* * Simplified macro to send a verbose system log message using the current LOG_TAG. */ #ifndef SLOGV #if LOG_NDEBUG #define SLOGV(...) ((void)0) #else #define SLOGV(...) ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) #endif #endif #define CONDITION(cond) (__builtin_expect((cond)!=0, 0)) #ifndef SLOGV_IF #if LOG_NDEBUG #define SLOGV_IF(cond, ...) ((void)0) #else #define SLOGV_IF(cond, ...) \ ( (CONDITION(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, ...) \ ( (CONDITION(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, ...) \ ( (CONDITION(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__)) #endif #ifndef SLOGW_IF #define SLOGW_IF(cond, ...) \ ( (CONDITION(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__)) #endif #ifndef SLOGE_IF #define SLOGE_IF(cond, ...) \ ( (CONDITION(cond)) \ ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) \ : (void)0 ) #endif // --------------------------------------------------------------------- /* * Simplified macro to send a verbose radio log message using the current LOG_TAG. */ #ifndef RLOGV #if LOG_NDEBUG #define RLOGV(...) ((void)0) #else #define RLOGV(...) ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) #endif #endif #define CONDITION(cond) (__builtin_expect((cond)!=0, 0)) #ifndef RLOGV_IF #if LOG_NDEBUG #define RLOGV_IF(cond, ...) ((void)0) #else #define RLOGV_IF(cond, ...) \ ( (CONDITION(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, ...) \ ( (CONDITION(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, ...) \ ( (CONDITION(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, ...) \ ( (CONDITION(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, ...) \ ( (CONDITION(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, ...) \ ( (CONDITION(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__) //#define ALOG_ASSERT(cond) LOG_FATAL_IF(!(cond), "Assertion failed: " #cond) #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 /* * 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. These must match up with the declarations in * java/android/android/util/EventLog.java. */ typedef enum { EVENT_TYPE_INT = 0, EVENT_TYPE_LONG = 1, EVENT_TYPE_STRING = 2, EVENT_TYPE_LIST = 3, } AndroidEventLogType; #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_STRING #define LOG_EVENT_STRING(_tag, _value) \ ((void) 0) /* not implemented -- must combine len with string */ #endif /* TODO: something for LIST */ /* * =========================================================================== * * 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. */ #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 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) // TODO: remove these prototypes and their users #define android_testLog(prio, tag) (1) #define android_writevLog(vec,num) do{}while(0) #define android_write1Log(str,len) do{}while (0) #define android_setMinPriority(tag, prio) do{}while(0) //#define android_logToCallback(func) do{}while(0) #define android_logToFile(tag, file) (0) #define android_logToFd(tag, fd) (0) typedef enum { LOG_ID_MAIN = 0, LOG_ID_RADIO = 1, LOG_ID_EVENTS = 2, LOG_ID_SYSTEM = 3, LOG_ID_MAX } log_id_t; /* * 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, ...); #ifdef __cplusplus } #endif #endif // _LIBS_CUTILS_LOG_H android-headers-23/19/log/logd.h000066400000000000000000000024451264465411000164510ustar00rootroot00000000000000/* * 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 */ #include #include #include #include #include #ifdef HAVE_PTHREADS #include #endif #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); #ifdef __cplusplus } #endif #endif /* _LOGD_H */ android-headers-23/19/log/logger.h000066400000000000000000000052151264465411000170010ustar00rootroot00000000000000/* utils/logger.h ** ** Copyright 2007, 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 _UTILS_LOGGER_H #define _UTILS_LOGGER_H #include /* * 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 */ }; /* * 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 */ 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 */ }; #define LOGGER_LOG_MAIN "log/main" #define LOGGER_LOG_RADIO "log/radio" #define LOGGER_LOG_EVENTS "log/events" #define LOGGER_LOG_SYSTEM "log/system" /* * The maximum size of the log entry payload that can be * written to the kernel logger driver. An attempt to write * more than this amount to /dev/log/* will result in a * truncated log entry. */ #define LOGGER_ENTRY_MAX_PAYLOAD 4076 /* * 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) #ifdef HAVE_IOCTL #include #define __LOGGERIO 0xAE #define LOGGER_GET_LOG_BUF_SIZE _IO(__LOGGERIO, 1) /* size of log */ #define LOGGER_GET_LOG_LEN _IO(__LOGGERIO, 2) /* used log len */ #define LOGGER_GET_NEXT_ENTRY_LEN _IO(__LOGGERIO, 3) /* next entry len */ #define LOGGER_FLUSH_LOG _IO(__LOGGERIO, 4) /* flush log */ #define LOGGER_GET_VERSION _IO(__LOGGERIO, 5) /* abi version */ #define LOGGER_SET_VERSION _IO(__LOGGERIO, 6) /* abi version */ #endif // HAVE_IOCTL #endif /* _UTILS_LOGGER_H */ android-headers-23/19/log/logprint.h000066400000000000000000000072331264465411000173620ustar00rootroot00000000000000/* * Copyright (C) 2006 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 _LOGPRINT_H #define _LOGPRINT_H #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, } AndroidLogPrintFormat; typedef struct AndroidLogFormat_t AndroidLogFormat; typedef struct AndroidLogEntry_t { time_t tv_sec; long tv_nsec; android_LogPriority priority; int32_t pid; int32_t tid; const char * tag; size_t messageLen; const char * message; } AndroidLogEntry; AndroidLogFormat *android_log_format_new(); void android_log_format_free(AndroidLogFormat *p_format); void android_log_setPrintFormat(AndroidLogFormat *p_format, AndroidLogPrintFormat format); /** * Returns FORMAT_OFF on invalid string */ AndroidLogPrintFormat android_log_formatFromString(const char *s); /** * filterExpression: a single filter expression * eg "AT:d" * * returns 0 on success and -1 on invalid expression * * Assumes single threaded execution * */ int android_log_addFilterRule(AndroidLogFormat *p_format, const char *filterExpression); /** * filterString: a whitespace-separated set of filter expressions * eg "AT:d *:i" * * returns 0 on success and -1 on invalid expression * * Assumes single threaded execution * */ 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); /** * Splits a wire-format buffer into an AndroidLogEntry * entry allocated by caller. Pointers will point directly into buf * * 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); /** * Like android_log_processLogBuffer, but for binary logs. * * 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); /** * Formats a log message into a buffer * * Uses defaultBuffer if it can, otherwise malloc()'s a new buffer * If return value != defaultBuffer, caller must call free() * 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); /** * Either print or do not print log line, based on filter * * Assumes single threaded execution * */ int android_log_printLogLine( AndroidLogFormat *p_format, int fd, const AndroidLogEntry *entry); #ifdef __cplusplus } #endif #endif /*_LOGPRINT_H*/ android-headers-23/19/log/uio.h000066400000000000000000000022121264465411000163100ustar00rootroot00000000000000/* * 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. */ // // implementation of sys/uio.h for platforms that don't have it (Win32) // #ifndef _LIBS_CUTILS_UIO_H #define _LIBS_CUTILS_UIO_H #ifdef HAVE_SYS_UIO_H #include #else #ifdef __cplusplus extern "C" { #endif #include struct iovec { const 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 ); #ifdef __cplusplus } #endif #endif /* !HAVE_SYS_UIO_H */ #endif /* _LIBS_UTILS_UIO_H */ android-headers-23/19/private/000077500000000000000000000000001264465411000162375ustar00rootroot00000000000000android-headers-23/19/private/android_filesystem_config.h000066400000000000000000000303001264465411000236150ustar00rootroot00000000000000/* * 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 used to define the properties of the filesystem ** images generated by build tools (mkbootfs and mkyaffs2image) and ** by the device side of adb. */ #ifndef _ANDROID_FILESYSTEM_CONFIG_H_ #define _ANDROID_FILESYSTEM_CONFIG_H_ #include #include #include #include #ifdef HAVE_ANDROID_OS #include #else #include "android_filesystem_capability.h" #endif /* 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_SHELL 2000 /* adb and debug shell user */ #define AID_CACHE 2001 /* cache access */ #define AID_DIAG 2002 /* access to diagnostic resources */ /* 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_MISC 9998 /* access to misc storage */ #define AID_NOBODY 9999 #define AID_APP 10000 /* first app user */ #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 /* offset for uid ranges for each user */ #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 */ #if !defined(EXCLUDE_FS_CONFIG_STRUCTURES) struct android_id_info { const char *name; unsigned aid; }; static const struct android_id_info android_ids[] = { { "root", AID_ROOT, }, { "system", AID_SYSTEM, }, { "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, }, { "shell", AID_SHELL, }, { "cache", AID_CACHE, }, { "diag", AID_DIAG, }, { "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, }, { "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. ** These rules are applied based on "first match", so they ** should start with the most specific path and work their ** way up to the root. */ static const struct fs_path_config android_dirs[] = { { 00770, AID_SYSTEM, AID_CACHE, 0, "cache" }, { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/app" }, { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/app-private" }, { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/dalvik-cache" }, { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/data" }, { 00771, AID_SHELL, AID_SHELL, 0, "data/local/tmp" }, { 00771, AID_SHELL, AID_SHELL, 0, "data/local" }, { 01771, AID_SYSTEM, AID_MISC, 0, "data/misc" }, { 00770, AID_DHCP, AID_DHCP, 0, "data/misc/dhcp" }, { 00775, AID_MEDIA_RW, AID_MEDIA_RW, 0, "data/media" }, { 00775, AID_MEDIA_RW, AID_MEDIA_RW, 0, "data/media/Music" }, { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data" }, { 00750, AID_ROOT, AID_SHELL, 0, "sbin" }, { 00755, AID_ROOT, AID_SHELL, 0, "system/bin" }, { 00755, AID_ROOT, AID_SHELL, 0, "system/vendor" }, { 00755, AID_ROOT, AID_SHELL, 0, "system/xbin" }, { 00755, AID_ROOT, AID_ROOT, 0, "system/etc/ppp" }, { 00755, AID_ROOT, AID_SHELL, 0, "vendor" }, { 00777, AID_ROOT, AID_ROOT, 0, "sdcard" }, { 00755, AID_ROOT, AID_ROOT, 0, 0 }, }; /* Rules for files. ** These rules are applied based on "first match", so they ** should start with the most specific path and work their ** way up to the root. Prefixes ending in * denotes wildcard ** and will allow partial matches. */ static const struct fs_path_config android_files[] = { { 00440, AID_ROOT, AID_SHELL, 0, "system/etc/init.goldfish.rc" }, { 00550, AID_ROOT, AID_SHELL, 0, "system/etc/init.goldfish.sh" }, { 00440, AID_ROOT, AID_SHELL, 0, "system/etc/init.trout.rc" }, { 00550, AID_ROOT, AID_SHELL, 0, "system/etc/init.ril" }, { 00550, AID_ROOT, AID_SHELL, 0, "system/etc/init.testmenu" }, { 00550, AID_DHCP, AID_SHELL, 0, "system/etc/dhcpcd/dhcpcd-run-hooks" }, { 00444, AID_RADIO, AID_AUDIO, 0, "system/etc/AudioPara4.csv" }, { 00555, AID_ROOT, AID_ROOT, 0, "system/etc/ppp/*" }, { 00555, AID_ROOT, AID_ROOT, 0, "system/etc/rc.*" }, { 00644, AID_SYSTEM, AID_SYSTEM, 0, "data/app/*" }, { 00644, AID_MEDIA_RW, AID_MEDIA_RW, 0, "data/media/*" }, { 00644, AID_SYSTEM, AID_SYSTEM, 0, "data/app-private/*" }, { 00644, AID_APP, AID_APP, 0, "data/data/*" }, { 00755, AID_ROOT, AID_ROOT, 0, "system/bin/ping" }, /* the following file is INTENTIONALLY set-gid and not set-uid. * Do not change. */ { 02750, AID_ROOT, AID_INET, 0, "system/bin/netcfg" }, /* the following five files are INTENTIONALLY set-uid, but they * are NOT included on user builds. */ { 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/su" }, { 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/librank" }, { 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/procrank" }, { 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/procmem" }, { 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/tcpdump" }, { 04770, AID_ROOT, AID_RADIO, 0, "system/bin/pppd-ril" }, /* the following files have enhanced capabilities and ARE included in user builds. */ { 00750, AID_ROOT, AID_SHELL, (1 << CAP_SETUID) | (1 << CAP_SETGID), "system/bin/run-as" }, { 00755, AID_ROOT, AID_SHELL, 0, "system/bin/*" }, { 00755, AID_ROOT, AID_ROOT, 0, "system/lib/valgrind/*" }, { 00755, AID_ROOT, AID_SHELL, 0, "system/xbin/*" }, { 00755, AID_ROOT, AID_SHELL, 0, "system/vendor/bin/*" }, { 00755, AID_ROOT, AID_SHELL, 0, "vendor/bin/*" }, { 00750, AID_ROOT, AID_SHELL, 0, "sbin/*" }, { 00755, AID_ROOT, AID_ROOT, 0, "bin/*" }, { 00750, AID_ROOT, AID_SHELL, 0, "init*" }, { 00750, AID_ROOT, AID_SHELL, 0, "charger*" }, { 00750, AID_ROOT, AID_SHELL, 0, "sbin/fs_mgr" }, { 00640, AID_ROOT, AID_SHELL, 0, "fstab.*" }, { 00644, AID_ROOT, AID_ROOT, 0, 0 }, }; static inline void fs_config(const char *path, int dir, unsigned *uid, unsigned *gid, unsigned *mode, uint64_t *capabilities) { const struct fs_path_config *pc; int plen; if (path[0] == '/') { path++; } pc = dir ? android_dirs : android_files; plen = strlen(path); for(; pc->prefix; pc++){ int len = strlen(pc->prefix); if (dir) { if(plen < len) continue; if(!strncmp(pc->prefix, path, len)) break; continue; } /* If name ends in * then allow partial matches. */ if (pc->prefix[len -1] == '*') { if(!strncmp(pc->prefix, path, len - 1)) break; } else if (plen == len){ if(!strncmp(pc->prefix, path, len)) break; } } *uid = pc->uid; *gid = pc->gid; *mode = (*mode & (~07777)) | pc->mode; *capabilities = pc->capabilities; #if 0 fprintf(stderr,"< '%s' '%s' %d %d %o >\n", path, pc->prefix ? pc->prefix : "", *uid, *gid, *mode); #endif } #endif #endif android-headers-23/19/sync/000077500000000000000000000000001264465411000155415ustar00rootroot00000000000000android-headers-23/19/sync/sw_sync.h000066400000000000000000000017761264465411000174120ustar00rootroot00000000000000/* * sw_sync.h * * Copyright 2013 Google, Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __SYS_CORE_SW_SYNC_H #define __SYS_CORE_SW_SYNC_H #include "sync.h" __BEGIN_DECLS /* * sw_sync is mainly intended for testing and should not be compiled into * production kernels */ int sw_sync_timeline_create(void); int sw_sync_timeline_inc(int fd, unsigned count); int sw_sync_fence_create(int fd, const char *name, unsigned value); __END_DECLS #endif /* __SYS_CORE_SW_SYNC_H */ android-headers-23/19/sync/sync.h000066400000000000000000000026551264465411000166760ustar00rootroot00000000000000/* * sync.h * * Copyright 2012 Google, Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __SYS_CORE_SYNC_H #define __SYS_CORE_SYNC_H #include #include __BEGIN_DECLS // XXX: These structs are copied from the header "linux/sync.h". struct sync_fence_info_data { uint32_t len; char name[32]; int32_t status; uint8_t pt_info[0]; }; struct sync_pt_info { uint32_t len; char obj_name[32]; char driver_name[32]; int32_t status; uint64_t timestamp_ns; uint8_t driver_data[0]; }; /* 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); void sync_fence_info_free(struct sync_fence_info_data *info); __END_DECLS #endif /* __SYS_CORE_SYNC_H */ android-headers-23/19/system/000077500000000000000000000000001264465411000161115ustar00rootroot00000000000000android-headers-23/19/system/audio.h000066400000000000000000000627261264465411000174000ustar00rootroot00000000000000/* * 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_AUDIO_CORE_H #define ANDROID_AUDIO_CORE_H #include #include #include #include #include __BEGIN_DECLS /* The enums were moved here mostly from * frameworks/base/include/media/AudioSystem.h */ /* device address used to refer to the standard remote submix */ #define AUDIO_REMOTE_SUBMIX_DEVICE_ADDRESS "0" typedef int audio_io_handle_t; /* Audio stream types */ typedef enum { AUDIO_STREAM_DEFAULT = -1, 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, AUDIO_STREAM_CNT, AUDIO_STREAM_MAX = AUDIO_STREAM_CNT - 1, } audio_stream_type_t; /* Do not change these values without updating their counterparts * in media/java/android/media/MediaRecorder.java! */ 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_CNT, AUDIO_SOURCE_MAX = AUDIO_SOURCE_CNT - 1, 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; /* special audio session values * (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, } audio_session_t; /* Audio sub formats (see enum audio_format). */ /* PCM sub formats */ typedef enum { 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 7.24 fixed point */ } audio_format_pcm_sub_fmt_t; /* 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_NONE = 0x0, } 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 consists in a main format field (upper 8 bits) and a 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, AUDIO_FORMAT_HE_AAC_V2 = 0x06000000UL, AUDIO_FORMAT_VORBIS = 0x07000000UL, AUDIO_FORMAT_MAIN_MASK = 0xFF000000UL, AUDIO_FORMAT_SUB_MASK = 0x00FFFFFFUL, /* Aliases */ AUDIO_FORMAT_PCM_16_BIT = (AUDIO_FORMAT_PCM | AUDIO_FORMAT_PCM_SUB_16_BIT), 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_t; enum { /* 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, 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_QUAD = (AUDIO_CHANNEL_OUT_FRONT_LEFT | AUDIO_CHANNEL_OUT_FRONT_RIGHT | AUDIO_CHANNEL_OUT_BACK_LEFT | AUDIO_CHANNEL_OUT_BACK_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_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), // 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), /* 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, 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_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), }; typedef uint32_t audio_channel_mask_t; 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; typedef enum { AUDIO_IN_ACOUSTICS_AGC_ENABLE = 0x0001, AUDIO_IN_ACOUSTICS_AGC_DISABLE = 0, AUDIO_IN_ACOUSTICS_NS_ENABLE = 0x0002, AUDIO_IN_ACOUSTICS_NS_DISABLE = 0, AUDIO_IN_ACOUSTICS_TX_IIR_ENABLE = 0x0004, 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_ANLG_DOCK_HEADSET = 0x800, AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET = 0x1000, AUDIO_DEVICE_OUT_USB_ACCESSORY = 0x2000, AUDIO_DEVICE_OUT_USB_DEVICE = 0x4000, AUDIO_DEVICE_OUT_REMOTE_SUBMIX = 0x8000, 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_AUX_DIGITAL | 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_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_VOICE_CALL = AUDIO_DEVICE_BIT_IN | 0x40, 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, 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_AUX_DIGITAL | AUDIO_DEVICE_IN_VOICE_CALL | 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_DEFAULT), AUDIO_DEVICE_IN_ALL_SCO = AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET, }; 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. */ 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_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. */ typedef enum { AUDIO_INPUT_FLAG_NONE = 0x0, // no attributes AUDIO_INPUT_FLAG_FAST = 0x1, // prefer an input that supports "fast tracks" } audio_input_flags_t; /* 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. */ typedef struct { uint16_t version; // version of the info structure uint16_t size; // total size of the structure including version and size uint32_t sample_rate; // sample rate in Hz audio_channel_mask_t channel_mask; // channel mask audio_format_t format; // audio format audio_stream_type_t stream_type; // stream type uint32_t bit_rate; // bit rate in bits per second int64_t duration_us; // duration in microseconds, -1 if unknown bool has_video; // true if stream is tied to a video stream bool is_streaming; // true if streaming, false if local playback } audio_offload_info_t; #define AUDIO_MAKE_OFFLOAD_INFO_VERSION(maj,min) \ ((((maj) & 0xff) << 8) | ((min) & 0xff)) #define AUDIO_OFFLOAD_INFO_VERSION_0_1 AUDIO_MAKE_OFFLOAD_INFO_VERSION(0, 1) #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), }; static inline bool audio_is_output_device(audio_devices_t device) { if (((device & AUDIO_DEVICE_BIT_IN) == 0) && (popcount(device) == 1) && ((device & ~AUDIO_DEVICE_OUT_ALL) == 0)) return true; else return false; } static inline bool audio_is_input_device(audio_devices_t device) { if ((device & AUDIO_DEVICE_BIT_IN) != 0) { device &= ~AUDIO_DEVICE_BIT_IN; if ((popcount(device) == 1) && ((device & ~AUDIO_DEVICE_IN_ALL) == 0)) return true; } return false; } static inline bool audio_is_output_devices(audio_devices_t device) { return (device & AUDIO_DEVICE_BIT_IN) == 0; } static inline bool audio_is_a2dp_device(audio_devices_t device) { if ((popcount(device) == 1) && (device & AUDIO_DEVICE_OUT_ALL_A2DP)) return true; else return false; } static inline bool audio_is_bluetooth_sco_device(audio_devices_t device) { device &= ~AUDIO_DEVICE_BIT_IN; if ((popcount(device) == 1) && (device & (AUDIO_DEVICE_OUT_ALL_SCO | AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET))) return true; else return false; } static inline bool audio_is_usb_device(audio_devices_t device) { if ((popcount(device) == 1) && (device & AUDIO_DEVICE_OUT_ALL_USB)) return true; else return false; } static inline bool audio_is_remote_submix_device(audio_devices_t device) { if ((device & AUDIO_DEVICE_OUT_REMOTE_SUBMIX) == AUDIO_DEVICE_OUT_REMOTE_SUBMIX || (device & AUDIO_DEVICE_IN_REMOTE_SUBMIX) == AUDIO_DEVICE_IN_REMOTE_SUBMIX) return true; else return false; } static inline bool audio_is_input_channel(audio_channel_mask_t channel) { if ((channel & ~AUDIO_CHANNEL_IN_ALL) == 0) return channel != 0; else return false; } static inline bool audio_is_output_channel(audio_channel_mask_t channel) { if ((channel & ~AUDIO_CHANNEL_OUT_ALL) == 0) return channel != 0; else return false; } /* Derive an output channel mask from a channel count. * This is to be used when the content channel mask is unknown. The 1, 2, 4, 5, 6, 7 and 8 channel * cases are mapped to the standard game/home-theater layouts, but note that 4 is mapped to quad, * and not stereo + FC + mono surround. A channel count of 3 is arbitrarily mapped to stereo + FC * for continuity with stereo. * Returns the matching channel mask, or 0 if the number of channels exceeds that of the * configurations for which a default channel mask is defined. */ static inline audio_channel_mask_t audio_channel_out_mask_from_count(uint32_t channel_count) { switch(channel_count) { case 1: return AUDIO_CHANNEL_OUT_MONO; case 2: return AUDIO_CHANNEL_OUT_STEREO; case 3: return (AUDIO_CHANNEL_OUT_STEREO | AUDIO_CHANNEL_OUT_FRONT_CENTER); case 4: // 4.0 return AUDIO_CHANNEL_OUT_QUAD; case 5: // 5.0 return (AUDIO_CHANNEL_OUT_QUAD | AUDIO_CHANNEL_OUT_FRONT_CENTER); case 6: // 5.1 return AUDIO_CHANNEL_OUT_5POINT1; case 7: // 6.1 return (AUDIO_CHANNEL_OUT_5POINT1 | AUDIO_CHANNEL_OUT_BACK_CENTER); case 8: return AUDIO_CHANNEL_OUT_7POINT1; default: return 0; } } /* Similar to above, but for input. Currently handles only mono and stereo. */ static inline audio_channel_mask_t audio_channel_in_mask_from_count(uint32_t channel_count) { switch (channel_count) { case 1: return AUDIO_CHANNEL_IN_MONO; case 2: return AUDIO_CHANNEL_IN_STEREO; default: return 0; } } static inline bool audio_is_valid_format(audio_format_t format) { switch (format & AUDIO_FORMAT_MAIN_MASK) { case AUDIO_FORMAT_PCM: if (format != AUDIO_FORMAT_PCM_16_BIT && format != AUDIO_FORMAT_PCM_8_BIT) { return false; } case AUDIO_FORMAT_MP3: case AUDIO_FORMAT_AMR_NB: case AUDIO_FORMAT_AMR_WB: case AUDIO_FORMAT_AAC: case AUDIO_FORMAT_HE_AAC_V1: case AUDIO_FORMAT_HE_AAC_V2: case AUDIO_FORMAT_VORBIS: return true; default: return false; } } static inline bool audio_is_linear_pcm(audio_format_t format) { return ((format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_PCM); } static inline size_t audio_bytes_per_sample(audio_format_t format) { size_t size = 0; switch (format) { case AUDIO_FORMAT_PCM_32_BIT: case AUDIO_FORMAT_PCM_8_24_BIT: size = sizeof(int32_t); break; case AUDIO_FORMAT_PCM_16_BIT: size = sizeof(int16_t); break; case AUDIO_FORMAT_PCM_8_BIT: size = sizeof(uint8_t); break; default: break; } return size; } __END_DECLS #endif // ANDROID_AUDIO_CORE_H android-headers-23/19/system/audio_policy.h000066400000000000000000000056021264465411000207450ustar00rootroot00000000000000/* * 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_AUDIO_POLICY_CORE_H #define ANDROID_AUDIO_POLICY_CORE_H #include #include #include #include __BEGIN_DECLS /* The enums were moved here mostly from * frameworks/base/include/media/AudioSystem.h */ /* device categories used for audio_policy->set_force_use() */ typedef enum { AUDIO_POLICY_FORCE_NONE, AUDIO_POLICY_FORCE_SPEAKER, AUDIO_POLICY_FORCE_HEADPHONES, AUDIO_POLICY_FORCE_BT_SCO, AUDIO_POLICY_FORCE_BT_A2DP, AUDIO_POLICY_FORCE_WIRED_ACCESSORY, AUDIO_POLICY_FORCE_BT_CAR_DOCK, AUDIO_POLICY_FORCE_BT_DESK_DOCK, AUDIO_POLICY_FORCE_ANALOG_DOCK, AUDIO_POLICY_FORCE_DIGITAL_DOCK, AUDIO_POLICY_FORCE_NO_BT_A2DP, /* A2DP sink is not preferred to speaker or wired HS */ AUDIO_POLICY_FORCE_SYSTEM_ENFORCED, AUDIO_POLICY_FORCE_CFG_CNT, AUDIO_POLICY_FORCE_CFG_MAX = AUDIO_POLICY_FORCE_CFG_CNT - 1, AUDIO_POLICY_FORCE_DEFAULT = AUDIO_POLICY_FORCE_NONE, } audio_policy_forced_cfg_t; /* usages used for audio_policy->set_force_use() */ typedef enum { AUDIO_POLICY_FORCE_FOR_COMMUNICATION, AUDIO_POLICY_FORCE_FOR_MEDIA, AUDIO_POLICY_FORCE_FOR_RECORD, AUDIO_POLICY_FORCE_FOR_DOCK, AUDIO_POLICY_FORCE_FOR_SYSTEM, AUDIO_POLICY_FORCE_USE_CNT, AUDIO_POLICY_FORCE_USE_MAX = AUDIO_POLICY_FORCE_USE_CNT - 1, } audio_policy_force_use_t; /* device connection states used for audio_policy->set_device_connection_state() */ typedef enum { AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE, AUDIO_POLICY_DEVICE_STATE_AVAILABLE, AUDIO_POLICY_DEVICE_STATE_CNT, AUDIO_POLICY_DEVICE_STATE_MAX = AUDIO_POLICY_DEVICE_STATE_CNT - 1, } audio_policy_dev_state_t; typedef enum { /* Used to generate a tone to notify the user of a * notification/alarm/ringtone while they are in a call. */ AUDIO_POLICY_TONE_IN_CALL_NOTIFICATION = 0, AUDIO_POLICY_TONE_CNT, AUDIO_POLICY_TONE_MAX = AUDIO_POLICY_TONE_CNT - 1, } audio_policy_tone_t; static inline bool audio_is_low_visibility(audio_stream_type_t stream) { switch (stream) { case AUDIO_STREAM_SYSTEM: case AUDIO_STREAM_NOTIFICATION: case AUDIO_STREAM_RING: return true; default: return false; } } __END_DECLS #endif // ANDROID_AUDIO_POLICY_CORE_H android-headers-23/19/system/camera.h000066400000000000000000000246121264465411000175170ustar00rootroot00000000000000/* * 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 SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H #define SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H #include #include #include #include #include #include __BEGIN_DECLS /** * A set of bit masks for specifying how the received preview frames are * handled before the previewCallback() call. * * The least significant 3 bits of an "int" value are used for this purpose: * * ..... 0 0 0 * ^ ^ ^ * | | |---------> determine whether the callback is enabled or not * | |-----------> determine whether the callback is one-shot or not * |-------------> determine whether the frame is copied out or not * * WARNING: When a frame is sent directly without copying, it is the frame * receiver's responsiblity to make sure that the frame data won't get * corrupted by subsequent preview frames filled by the camera. This flag is * recommended only when copying out data brings significant performance price * and the handling/processing of the received frame data is always faster than * the preview frame rate so that data corruption won't occur. * * For instance, * 1. 0x00 disables the callback. In this case, copy out and one shot bits * are ignored. * 2. 0x01 enables a callback without copying out the received frames. A * typical use case is the Camcorder application to avoid making costly * frame copies. * 3. 0x05 is enabling a callback with frame copied out repeatedly. A typical * use case is the Camera application. * 4. 0x07 is enabling a callback with frame copied out only once. A typical * use case is the Barcode scanner application. */ enum { CAMERA_FRAME_CALLBACK_FLAG_ENABLE_MASK = 0x01, CAMERA_FRAME_CALLBACK_FLAG_ONE_SHOT_MASK = 0x02, CAMERA_FRAME_CALLBACK_FLAG_COPY_OUT_MASK = 0x04, /** Typical use cases */ CAMERA_FRAME_CALLBACK_FLAG_NOOP = 0x00, CAMERA_FRAME_CALLBACK_FLAG_CAMCORDER = 0x01, CAMERA_FRAME_CALLBACK_FLAG_CAMERA = 0x05, CAMERA_FRAME_CALLBACK_FLAG_BARCODE_SCANNER = 0x07 }; /** msgType in notifyCallback and dataCallback functions */ enum { CAMERA_MSG_ERROR = 0x0001, // notifyCallback CAMERA_MSG_SHUTTER = 0x0002, // notifyCallback CAMERA_MSG_FOCUS = 0x0004, // notifyCallback CAMERA_MSG_ZOOM = 0x0008, // notifyCallback CAMERA_MSG_PREVIEW_FRAME = 0x0010, // dataCallback CAMERA_MSG_VIDEO_FRAME = 0x0020, // data_timestamp_callback CAMERA_MSG_POSTVIEW_FRAME = 0x0040, // dataCallback CAMERA_MSG_RAW_IMAGE = 0x0080, // dataCallback CAMERA_MSG_COMPRESSED_IMAGE = 0x0100, // dataCallback CAMERA_MSG_RAW_IMAGE_NOTIFY = 0x0200, // dataCallback // Preview frame metadata. This can be combined with // CAMERA_MSG_PREVIEW_FRAME in dataCallback. For example, the apps can // request FRAME and METADATA. Or the apps can request only FRAME or only // METADATA. CAMERA_MSG_PREVIEW_METADATA = 0x0400, // dataCallback // Notify on autofocus start and stop. This is useful in continuous // autofocus - FOCUS_MODE_CONTINUOUS_VIDEO and FOCUS_MODE_CONTINUOUS_PICTURE. CAMERA_MSG_FOCUS_MOVE = 0x0800, // notifyCallback CAMERA_MSG_ALL_MSGS = 0xFFFF }; /** cmdType in sendCommand functions */ enum { CAMERA_CMD_START_SMOOTH_ZOOM = 1, CAMERA_CMD_STOP_SMOOTH_ZOOM = 2, /** * Set the clockwise rotation of preview display (setPreviewDisplay) in * degrees. This affects the preview frames and the picture displayed after * snapshot. This method is useful for portrait mode applications. Note * that preview display of front-facing cameras is flipped horizontally * before the rotation, that is, the image is reflected along the central * vertical axis of the camera sensor. So the users can see themselves as * looking into a mirror. * * This does not affect the order of byte array of * CAMERA_MSG_PREVIEW_FRAME, CAMERA_MSG_VIDEO_FRAME, * CAMERA_MSG_POSTVIEW_FRAME, CAMERA_MSG_RAW_IMAGE, or * CAMERA_MSG_COMPRESSED_IMAGE. This is allowed to be set during preview * since API level 14. */ CAMERA_CMD_SET_DISPLAY_ORIENTATION = 3, /** * cmdType to disable/enable shutter sound. In sendCommand passing arg1 = * 0 will disable, while passing arg1 = 1 will enable the shutter sound. */ CAMERA_CMD_ENABLE_SHUTTER_SOUND = 4, /* cmdType to play recording sound */ CAMERA_CMD_PLAY_RECORDING_SOUND = 5, /** * Start the face detection. This should be called after preview is started. * The camera will notify the listener of CAMERA_MSG_FACE and the detected * faces in the preview frame. The detected faces may be the same as the * previous ones. Apps should call CAMERA_CMD_STOP_FACE_DETECTION to stop * the face detection. This method is supported if CameraParameters * KEY_MAX_NUM_HW_DETECTED_FACES or KEY_MAX_NUM_SW_DETECTED_FACES is * bigger than 0. Hardware and software face detection should not be running * at the same time. If the face detection has started, apps should not send * this again. * * In hardware face detection mode, CameraParameters KEY_WHITE_BALANCE, * KEY_FOCUS_AREAS and KEY_METERING_AREAS have no effect. * * arg1 is the face detection type. It can be CAMERA_FACE_DETECTION_HW or * CAMERA_FACE_DETECTION_SW. If the type of face detection requested is not * supported, the HAL must return BAD_VALUE. */ CAMERA_CMD_START_FACE_DETECTION = 6, /** * Stop the face detection. */ CAMERA_CMD_STOP_FACE_DETECTION = 7, /** * Enable/disable focus move callback (CAMERA_MSG_FOCUS_MOVE). Passing * arg1 = 0 will disable, while passing arg1 = 1 will enable the callback. */ CAMERA_CMD_ENABLE_FOCUS_MOVE_MSG = 8, /** * Ping camera service to see if camera hardware is released. * * When any camera method returns error, the client can use ping command * to see if the camera has been taken away by other clients. If the result * is NO_ERROR, it means the camera hardware is not released. If the result * is not NO_ERROR, the camera has been released and the existing client * can silently finish itself or show a dialog. */ CAMERA_CMD_PING = 9, /** * Configure the number of video buffers used for recording. The intended * video buffer count for recording is passed as arg1, which must be * greater than 0. This command must be sent before recording is started. * This command returns INVALID_OPERATION error if it is sent after video * recording is started, or the command is not supported at all. This * command also returns a BAD_VALUE error if the intended video buffer * count is non-positive or too big to be realized. */ CAMERA_CMD_SET_VIDEO_BUFFER_COUNT = 10, }; /** camera fatal errors */ enum { CAMERA_ERROR_UNKNOWN = 1, /** * Camera was released because another client has connected to the camera. * The original 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_RELEASED = 2, CAMERA_ERROR_SERVER_DIED = 100 }; enum { /** The facing of the camera is opposite to that of the screen. */ CAMERA_FACING_BACK = 0, /** The facing of the camera is the same as that of the screen. */ CAMERA_FACING_FRONT = 1 }; enum { /** Hardware face detection. It does not use much CPU. */ CAMERA_FACE_DETECTION_HW = 0, /** * Software face detection. It uses some CPU. Applications must use * Camera.setPreviewTexture for preview in this mode. */ CAMERA_FACE_DETECTION_SW = 1 }; /** * The information of a face from camera face detection. */ typedef struct camera_face { /** * Bounds of the face [left, top, right, bottom]. (-1000, -1000) represents * the top-left of the camera field of view, and (1000, 1000) represents the * bottom-right of the field of view. The width and height cannot be 0 or * negative. This is supported by both hardware and software face detection. * * The direction is relative to the sensor orientation, that is, what the * sensor sees. The direction is not affected by the rotation or mirroring * of CAMERA_CMD_SET_DISPLAY_ORIENTATION. */ int32_t rect[4]; /** * The confidence level of the face. The range is 1 to 100. 100 is the * highest confidence. This is supported by both hardware and software * face detection. */ int32_t score; /** * An unique id per face while the face is visible to the tracker. If * the face leaves the field-of-view and comes back, it will get a new * id. If the value is 0, id is not supported. */ int32_t id; /** * The coordinates of the center of the left eye. The range is -1000 to * 1000. -2000, -2000 if this is not supported. */ int32_t left_eye[2]; /** * The coordinates of the center of the right eye. The range is -1000 to * 1000. -2000, -2000 if this is not supported. */ int32_t right_eye[2]; /** * The coordinates of the center of the mouth. The range is -1000 to 1000. * -2000, -2000 if this is not supported. */ int32_t mouth[2]; } camera_face_t; /** * The metadata of the frame data. */ typedef struct camera_frame_metadata { /** * The number of detected faces in the frame. */ int32_t number_of_faces; /** * An array of the detected faces. The length is number_of_faces. */ camera_face_t *faces; } camera_frame_metadata_t; __END_DECLS #endif /* SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H */ android-headers-23/19/system/graphics.h000066400000000000000000000241421264465411000200650ustar00rootroot00000000000000/* * 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 SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H #define SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H #include #ifdef __cplusplus extern "C" { #endif /* * If the HAL needs to create service threads to handle graphics related * tasks, these threads need to run at HAL_PRIORITY_URGENT_DISPLAY priority * if they can block the main rendering thread in any way. * * the priority of the current thread can be set with: * * #include * setpriority(PRIO_PROCESS, 0, HAL_PRIORITY_URGENT_DISPLAY); * */ #define HAL_PRIORITY_URGENT_DISPLAY (-8) /** * pixel format definitions */ enum { /* * "linear" color pixel formats: * * The pixel formats below contain sRGB data but are otherwise treated * as linear formats, i.e.: no special operation is 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, /* * sRGB color pixel formats: * * The red, green and blue components are stored in sRGB space, and converted * to linear space when read, using the standard sRGB to linear equation: * * Clinear = Csrgb / 12.92 for Csrgb <= 0.04045 * = (Csrgb + 0.055 / 1.055)^2.4 for Csrgb > 0.04045 * * When written the inverse transformation is performed: * * Csrgb = 12.92 * Clinear for Clinear <= 0.0031308 * = 1.055 * Clinear^(1/2.4) - 0.055 for Clinear > 0.0031308 * * * The alpha component, if present, is always stored in linear space and * is left unmodified when read or written. * */ HAL_PIXEL_FORMAT_sRGB_A_8888 = 0xC, HAL_PIXEL_FORMAT_sRGB_X_8888 = 0xD, /* * 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 * */ 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 * */ 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 * */ HAL_PIXEL_FORMAT_Y16 = 0x20363159, /* * Android RAW sensor format: * * This format is exposed outside of the HAL to applications. * * RAW_SENSOR is a single-channel 16-bit 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. 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 (32 bytes). */ HAL_PIXEL_FORMAT_RAW_SENSOR = 0x20, /* * 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. */ 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). * */ HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED = 0x22, /* * Android flexible YCbCr formats * * This format allows platforms to use an efficient YCbCr/YCrCb buffer * layout, while still describing the buffer layout in a way accessible to * the CPU in a device-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_HW_CAMERA_WRITE and 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. */ HAL_PIXEL_FORMAT_YCbCr_420_888 = 0x23, /* 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 }; /* * Structure for describing YCbCr formats for consumption by applications. * This is used with HAL_PIXEL_FORMAT_YCbCr_*_888. * * Buffer chroma subsampling is defined in the format. * e.g. HAL_PIXEL_FORMAT_YCbCr_420_888 has subsampling 4:2:0. * * Buffers must have a 8 bit depth. * * @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. * * @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. */ struct android_ycbcr { void *y; void *cb; void *cr; size_t ystride; size_t cstride; size_t chroma_step; /** reserved for future use, set to 0 by gralloc's (*lock_ycbcr)() */ uint32_t reserved[8]; }; /** * Transformation definitions * * IMPORTANT NOTE: * HAL_TRANSFORM_ROT_90 is applied CLOCKWISE and AFTER HAL_TRANSFORM_FLIP_{H|V}. * */ enum { /* 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, }; #ifdef __cplusplus } #endif #endif /* SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H */ android-headers-23/19/system/thread_defs.h000066400000000000000000000050631264465411000205360ustar00rootroot00000000000000/* * 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_THREAD_DEFS_H #define ANDROID_THREAD_DEFS_H #include "graphics.h" #if defined(__cplusplus) extern "C" { #endif enum { /* * *********************************************** * ** Keep in sync with android.os.Process.java ** * *********************************************** * * This maps directly to the "nice" priorities we use in Android. * A thread priority should be chosen inverse-proportionally to * the amount of work the thread is expected to do. The more work * a thread will do, the less favorable priority it should get so that * it doesn't starve the system. Threads not behaving properly might * be "punished" by the kernel. * Use the levels below when appropriate. Intermediate values are * acceptable, preferably use the {MORE|LESS}_FAVORABLE constants below. */ ANDROID_PRIORITY_LOWEST = 19, /* use for background tasks */ ANDROID_PRIORITY_BACKGROUND = 10, /* most threads run at normal priority */ ANDROID_PRIORITY_NORMAL = 0, /* threads currently running a UI that the user is interacting with */ ANDROID_PRIORITY_FOREGROUND = -2, /* the main UI thread has a slightly more favorable priority */ ANDROID_PRIORITY_DISPLAY = -4, /* ui service treads might want to run at a urgent display (uncommon) */ ANDROID_PRIORITY_URGENT_DISPLAY = HAL_PRIORITY_URGENT_DISPLAY, /* all normal audio threads */ ANDROID_PRIORITY_AUDIO = -16, /* service audio threads (uncommon) */ ANDROID_PRIORITY_URGENT_AUDIO = -19, /* should never be used in practice. regular process might not * be allowed to use this level */ ANDROID_PRIORITY_HIGHEST = -20, ANDROID_PRIORITY_DEFAULT = ANDROID_PRIORITY_NORMAL, ANDROID_PRIORITY_MORE_FAVORABLE = -1, ANDROID_PRIORITY_LESS_FAVORABLE = +1, }; #if defined(__cplusplus) } #endif #endif /* ANDROID_THREAD_DEFS_H */ android-headers-23/19/system/window.h000066400000000000000000000777061264465411000176120ustar00rootroot00000000000000/* * 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 SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H #define SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H #include #include #include #include #include #include #include #include #include __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; // --------------------------------------------------------------------------- /* attributes queriable with query() */ enum { NATIVE_WINDOW_WIDTH = 0, 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, /* Check whether queueBuffer operations on the ANativeWindow send the buffer * to the window compositor. The query sets the returned 'value' argument * to 1 if the ANativeWindow DOES send queued buffers directly to the window * compositor and 0 if the buffers do not go directly to the window * compositor. * * This can be used to determine whether protected buffer content should be * sent to the ANativeWindow. Note, however, that a result of 1 does NOT * indicate that queued buffers will be protected from applications or users * capturing their contents. If that behavior is desired then some other * mechanism (e.g. the GRALLOC_USAGE_PROTECTED flag) should be used in * conjunction with this query. */ NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER = 4, /* Get the concrete type of a ANativeWindow. See below for the list of * possible return values. * * This query should not be used outside the Android framework and will * likely be removed in the near future. */ NATIVE_WINDOW_CONCRETE_TYPE = 5, /* * Default width and height of ANativeWindow buffers, these are the * dimensions of the window buffers irrespective of the * 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, /* * 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, /* * Boolean that indicates whether the consumer is running more than * one buffer behind the producer. */ NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND = 9, /* * 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 }; /* Valid operations for the (*perform)() hook. * * Values marked as 'deprecated' are supported, but have been superceded by * other functionality. * * Values marked as 'private' should be considered private to the framework. * HAL implementation code with access to an ANativeWindow should not use these, * as it may not interact properly with the framework's use of the * 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 */ }; /* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */ enum { /* Buffers will be queued by EGL via eglSwapBuffers after being filled using * OpenGL ES. */ NATIVE_WINDOW_API_EGL = 1, /* Buffers will be queued after being filled using the CPU */ NATIVE_WINDOW_API_CPU = 2, /* Buffers will be queued by Stagefright after being filled by a video * decoder. The video decoder can either be a software or hardware decoder. */ NATIVE_WINDOW_API_MEDIA = 3, /* Buffers will be queued by the the camera HAL. */ NATIVE_WINDOW_API_CAMERA = 4, }; /* parameter for NATIVE_WINDOW_SET_BUFFERS_TRANSFORM */ enum { /* flip source image horizontally */ NATIVE_WINDOW_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H , /* flip source image vertically */ NATIVE_WINDOW_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V, /* rotate source image 90 degrees clock-wise, and is applied after TRANSFORM_FLIP_{H|V} */ NATIVE_WINDOW_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90, /* rotate source image 180 degrees */ NATIVE_WINDOW_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180, /* rotate source image 270 degrees clock-wise */ NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270, /* transforms source by the inverse transform of the screen it is displayed onto. This * transform is applied last */ NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY = 0x08 }; /* parameter for NATIVE_WINDOW_SET_SCALING_MODE */ enum { /* the window content is not updated (frozen) until a buffer of * the window size is received (enqueued) */ NATIVE_WINDOW_SCALING_MODE_FREEZE = 0, /* the buffer is scaled in both dimensions to match the window size */ NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW = 1, /* the buffer is scaled uniformly such that the smaller dimension * of the buffer matches the window size (cropping in the process) */ NATIVE_WINDOW_SCALING_MODE_SCALE_CROP = 2, /* the window is clipped to the size of the buffer's crop rectangle; pixels * outside the crop rectangle are treated as if they are completely * transparent. */ NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP = 3, }; /* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */ enum { NATIVE_WINDOW_FRAMEBUFFER = 0, /* FramebufferNativeWindow */ NATIVE_WINDOW_SURFACE = 1, /* Surface */ }; /* parameter for NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP * * Special timestamp value to indicate that timestamps should be auto-generated * by the native window when queueBuffer is called. This is equal to INT64_MIN, * defined directly to avoid problems with C99/C++ inclusion of stdint.h. */ static const int64_t NATIVE_WINDOW_TIMESTAMP_AUTO = (-9223372036854775807LL-1); struct ANativeWindow { #ifdef __cplusplus ANativeWindow() : flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0) { common.magic = ANDROID_NATIVE_WINDOW_MAGIC; common.version = sizeof(ANativeWindow); memset(common.reserved, 0, sizeof(common.reserved)); } /* Implement the methods that sp expects so that it can be used to automatically refcount ANativeWindow'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; /* flags describing some attributes of this surface or its updater */ const uint32_t flags; /* min swap interval supported by this updated */ const int minSwapInterval; /* max swap interval supported by this updated */ const int maxSwapInterval; /* horizontal and vertical resolution in DPI */ const float xdpi; const float ydpi; /* Some storage reserved for the OEM's driver. */ intptr_t oem[4]; /* * Set the swap interval for this surface. * * Returns 0 on success or -errno on error. */ int (*setSwapInterval)(struct ANativeWindow* window, int interval); /* * Hook called by EGL to acquire a buffer. After this call, the buffer * is not locked, so its content cannot be modified. 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. * * Returns 0 on success or -errno on error. * * XXX: This function is deprecated. It will continue to work for some * time for binary compatibility, but the new dequeueBuffer function that * outputs a fence file descriptor should be used in its place. */ int (*dequeueBuffer_DEPRECATED)(struct ANativeWindow* window, struct ANativeWindowBuffer** buffer); /* * hook called by EGL to lock a buffer. This MUST be called before modifying * the content of a buffer. The buffer must have been acquired with * dequeueBuffer first. * * Returns 0 on success or -errno on error. * * XXX: This function is deprecated. It will continue to work for some * time for binary compatibility, but it is essentially a no-op, and calls * to it should be removed. */ int (*lockBuffer_DEPRECATED)(struct ANativeWindow* window, struct ANativeWindowBuffer* buffer); /* * 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. * * Buffers MUST be queued in the same order than they were dequeued. * * Returns 0 on success or -errno on error. * * XXX: This function is deprecated. It will continue to work for some * time for binary compatibility, but the new queueBuffer function that * takes a fence file descriptor should be used in its place (pass a value * of -1 for the fence file descriptor if there is no valid one to pass). */ int (*queueBuffer_DEPRECATED)(struct ANativeWindow* window, struct ANativeWindowBuffer* buffer); /* * hook used to retrieve information about the native window. * * Returns 0 on success or -errno on error. */ int (*query)(const struct ANativeWindow* window, int what, int* value); /* * hook used to perform various operations on the surface. * (*perform)() is a generic mechanism to add functionality to * ANativeWindow while keeping backward binary compatibility. * * DO NOT CALL THIS HOOK DIRECTLY. Instead, use the helper functions * defined below. * * (*perform)() returns -ENOENT if the 'what' parameter is not supported * by the surface's implementation. * * The valid operations are: * NATIVE_WINDOW_SET_USAGE * NATIVE_WINDOW_CONNECT (deprecated) * NATIVE_WINDOW_DISCONNECT (deprecated) * NATIVE_WINDOW_SET_CROP (private) * NATIVE_WINDOW_SET_BUFFER_COUNT * NATIVE_WINDOW_SET_BUFFERS_GEOMETRY (deprecated) * NATIVE_WINDOW_SET_BUFFERS_TRANSFORM * NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP * NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS * NATIVE_WINDOW_SET_BUFFERS_FORMAT * NATIVE_WINDOW_SET_SCALING_MODE (private) * NATIVE_WINDOW_LOCK (private) * NATIVE_WINDOW_UNLOCK_AND_POST (private) * NATIVE_WINDOW_API_CONNECT (private) * NATIVE_WINDOW_API_DISCONNECT (private) * NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS (private) * NATIVE_WINDOW_SET_POST_TRANSFORM_CROP (private) * */ int (*perform)(struct ANativeWindow* window, int operation, ... ); /* * 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. * * XXX: This function is deprecated. It will continue to work for some * time for binary compatibility, but the new cancelBuffer function that * takes a fence file descriptor should be used in its place (pass a value * of -1 for the fence file descriptor if there is no valid one to pass). */ int (*cancelBuffer_DEPRECATED)(struct ANativeWindow* window, struct ANativeWindowBuffer* buffer); /* * 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 (*dequeueBuffer)(struct ANativeWindow* window, struct 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 (*queueBuffer)(struct ANativeWindow* window, struct 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 (*cancelBuffer)(struct ANativeWindow* window, struct ANativeWindowBuffer* buffer, int fenceFd); }; /* 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; /* * native_window_set_usage(..., 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. * 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); } /* deprecated. Always returns 0. Don't call. */ static inline int native_window_connect( struct ANativeWindow* window, int api) { return 0; } /* deprecated. Always returns 0. Don't call. */ static inline int native_window_disconnect( struct ANativeWindow* window, int api) { return 0; } /* * native_window_set_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 * pre-transformed buffer 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_crop( struct ANativeWindow* window, android_native_rect_t const * 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) { 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. */ static inline int native_window_set_buffer_count( struct ANativeWindow* window, size_t bufferCount) { return window->perform(window, NATIVE_WINDOW_SET_BUFFER_COUNT, bufferCount); } /* * native_window_set_buffers_geometry(..., int w, int h, int format) * All buffers dequeued after this call will have the dimensions and format * specified. A successful call to this function has the same effect as calling * native_window_set_buffers_size and native_window_set_buffers_format. * * XXX: This function is deprecated. The native_window_set_buffers_dimensions * and native_window_set_buffers_format functions should be used instead. */ static inline int native_window_set_buffers_geometry( struct ANativeWindow* window, int w, int h, int format) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY, w, h, format); } /* * native_window_set_buffers_dimensions(..., int w, int h) * 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. */ static inline int native_window_set_buffers_dimensions( struct ANativeWindow* window, int w, int h) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS, w, h); } /* * native_window_set_buffers_user_dimensions(..., int w, int h) * * Sets the user buffer size for the window, which overrides the * window's size. All buffers dequeued after this call will have the * dimensions specified unless overridden by * native_window_set_buffers_dimensions. 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, the * default buffer size will match the windows's size. * * Calling this function will reset the window crop to a NULL value, which * disables cropping of the buffers. */ static inline int native_window_set_buffers_user_dimensions( struct ANativeWindow* window, int w, int h) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS, w, h); } /* * native_window_set_buffers_format(..., int format) * All buffers dequeued after this call will have the format specified. * * If the specified format is 0, the default buffer format will be used. */ static inline int native_window_set_buffers_format( struct ANativeWindow* window, int format) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_FORMAT, format); } /* * native_window_set_buffers_transform(..., int transform) * All buffers queued after this call will be displayed transformed according * to the transform parameter specified. */ static inline int native_window_set_buffers_transform( struct ANativeWindow* window, int transform) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TRANSFORM, transform); } /* * native_window_set_buffers_timestamp(..., int64_t timestamp) * All buffers queued after this call will be associated with the timestamp * 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. */ static inline int native_window_set_buffers_timestamp( struct ANativeWindow* window, int64_t timestamp) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP, timestamp); } /* * native_window_set_scaling_mode(..., int mode) * All buffers queued after this call will be associated with the scaling mode * specified. */ static inline int native_window_set_scaling_mode( struct ANativeWindow* window, int mode) { return window->perform(window, NATIVE_WINDOW_SET_SCALING_MODE, mode); } /* * native_window_api_connect(..., int api) * connects an API to this window. only one API can be connected at a time. * Returns -EINVAL if for some reason the window cannot be connected, which * can happen if it's connected to some other API. */ static inline int native_window_api_connect( struct ANativeWindow* window, int api) { return window->perform(window, NATIVE_WINDOW_API_CONNECT, api); } /* * native_window_api_disconnect(..., int api) * disconnect the API from this window. * An error is returned if for instance the window wasn't connected in the * first place. */ static inline int native_window_api_disconnect( struct ANativeWindow* window, int api) { return window->perform(window, NATIVE_WINDOW_API_DISCONNECT, api); } /* * native_window_dequeue_buffer_and_wait(...) * Dequeue a buffer and wait on the fence associated with that buffer. The * buffer may safely be accessed immediately upon this function returning. An * error is returned if either of the dequeue or the wait operations fail. */ static inline int native_window_dequeue_buffer_and_wait(ANativeWindow *anw, struct ANativeWindowBuffer** anb) { return anw->dequeueBuffer_DEPRECATED(anw, anb); } __END_DECLS #endif /* SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H */ android-headers-23/21/000077500000000000000000000000001264465411000145565ustar00rootroot00000000000000android-headers-23/21/android-config.h000066400000000000000000000013371264465411000176160ustar00rootroot00000000000000#ifndef HYBRIS_CONFIG_H_ #define HYBRIS_CONFIG_H_ /* 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: COMMON_GLOBAL_CFLAGS += -DCAMERA_WITH_CITYID_PARAM device/samsung/smdk4412-common/BoardCommonConfig.mk: COMMON_GLOBAL_CFLAGS += -DEXYNOS4_ENHANCEMENTS This file allows those global configurations, which are not otherwise defined in the build headers, to be available in hybris builds. Typically it is generated at hardware adaptation time. The CONFIG GOES HERE line can be used by automation to modify this file. */ #include /* CONFIG GOES HERE */ #endif android-headers-23/21/android-version.h000066400000000000000000000003411264465411000200300ustar00rootroot00000000000000#ifndef ANDROID_VERSION_H_ #define ANDROID_VERSION_H_ #define ANDROID_VERSION_MAJOR 5 #define ANDROID_VERSION_MINOR 0 #define ANDROID_VERSION_PATCH 0 #define ANDROID_VERSION_PATCH2 1 #define ANDROID_VERSION_PATCH3 0 #endif android-headers-23/21/android/000077500000000000000000000000001264465411000161765ustar00rootroot00000000000000android-headers-23/21/android/log.h000066400000000000000000000101771264465411000171360ustar00rootroot00000000000000/* * 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_LOG_H #define _ANDROID_LOG_H /****************************************************************** * * IMPORTANT NOTICE: * * This file is part of Android's set of stable system headers * exposed by the Android NDK (Native Development Kit) since * platform release 1.5 * * Third-party source AND binary code relies on the definitions * here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES. * * - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES) * - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS * - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY * - 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. * * Each log message must have * - a priority * - a log tag * - some text * * The tag normally corresponds to the component that emits the log message, * and should be reasonably small. * * Log message text may be truncated to less than an implementation-specific * limit (e.g. 1023 characters max). * * 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. * * PLEASE USE LOGS WITH 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. * * - In release builds, only send log messages to account for exceptional * conditions. * * NOTE: These functions MUST be implemented by /system/lib/liblog.so */ #include #ifdef __cplusplus extern "C" { #endif /* * Android log priority values, in ascending priority order. */ 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 */ } android_LogPriority; /* * Send a simple string to the log. */ int __android_log_write(int prio, const char *tag, const char *text); /* * Send a formatted string to the log, used like printf(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))) #else __attribute__ ((format(printf, 3, 4))) #endif #else __attribute__ ((format(printf, 3, 4))) #endif #endif ; /* * A variant of __android_log_print() that takes a va_list to list * additional parameters. */ int __android_log_vprint(int prio, const char *tag, const char *fmt, va_list ap); /* * 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. */ void __android_log_assert(const char *cond, const char *tag, const char *fmt, ...) #if defined(__GNUC__) __attribute__ ((noreturn)) #ifdef __USE_MINGW_ANSI_STDIO #if __USE_MINGW_ANSI_STDIO __attribute__ ((format(gnu_printf, 3, 4))) #else __attribute__ ((format(printf, 3, 4))) #endif #else __attribute__ ((format(printf, 3, 4))) #endif #endif ; #ifdef __cplusplus } #endif #endif /* _ANDROID_LOG_H */ android-headers-23/21/cutils/000077500000000000000000000000001264465411000160615ustar00rootroot00000000000000android-headers-23/21/cutils/android_reboot.h000066400000000000000000000017551264465411000212340ustar00rootroot00000000000000/* * Copyright 2011, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __CUTILS_ANDROID_REBOOT_H__ #define __CUTILS_ANDROID_REBOOT_H__ __BEGIN_DECLS /* Commands */ #define ANDROID_RB_RESTART 0xDEAD0001 #define ANDROID_RB_POWEROFF 0xDEAD0002 #define ANDROID_RB_RESTART2 0xDEAD0003 /* Properties */ #define ANDROID_RB_PROPERTY "sys.powerctl" int android_reboot(int cmd, int flags, char *arg); __END_DECLS #endif /* __CUTILS_ANDROID_REBOOT_H__ */ android-headers-23/21/cutils/aref.h000066400000000000000000000025641264465411000171560ustar00rootroot00000000000000/* * 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_ android-headers-23/21/cutils/ashmem.h000066400000000000000000000021411264465411000175020ustar00rootroot00000000000000/* cutils/ashmem.h ** ** Copyright 2008 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 _CUTILS_ASHMEM_H #define _CUTILS_ASHMEM_H #include #ifdef __cplusplus extern "C" { #endif 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); int ashmem_unpin_region(int fd, size_t offset, size_t len); int ashmem_get_size_region(int fd); #ifdef __cplusplus } #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 */ android-headers-23/21/cutils/atomic-arm.h000066400000000000000000000116641264465411000202730ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/cutils/atomic-arm64.h000066400000000000000000000107341264465411000204420ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/cutils/atomic-inline.h000066400000000000000000000037721264465411000207730ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/cutils/atomic-mips.h000066400000000000000000000114111264465411000204520ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/cutils/atomic-mips64.h000066400000000000000000000112071264465411000206270ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/cutils/atomic-x86.h000066400000000000000000000075551264465411000201450ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/cutils/atomic-x86_64.h000066400000000000000000000107441264465411000204500ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/cutils/atomic.h000066400000000000000000000141361264465411000175130ustar00rootroot00000000000000/* * 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. */ #ifndef ANDROID_CUTILS_ATOMIC_H #define ANDROID_CUTILS_ATOMIC_H #include #include #ifdef __cplusplus extern "C" { #endif /* * A handful of basic atomic operations. * THESE ARE HERE FOR LEGACY REASONS ONLY. AVOID. * * PREFERRED ALTERNATIVES: * - Use C++/C/pthread locks/mutexes whenever there is not a * convincing reason to do otherwise. Note that very clever and * complicated, but correct, lock-free code is often slower than * using locks, especially where nontrivial data structures * are involved. * - C11 stdatomic.h. * - Where supported, C++11 std::atomic . * * PLEASE STOP READING HERE UNLESS YOU ARE TRYING TO UNDERSTAND * OR UPDATE OLD CODE. * * The "acquire" and "release" terms can be defined intuitively in terms * of the placement of memory barriers in a simple lock implementation: * - wait until compare-and-swap(lock-is-free --> lock-is-held) succeeds * - barrier * - [do work] * - barrier * - store(lock-is-free) * In very crude terms, the initial (acquire) barrier prevents any of the * "work" from happening before the lock is held, and the later (release) * barrier ensures that all of the work happens before the lock is released. * (Think of cached writes, cache read-ahead, and instruction reordering * around the CAS and store instructions.) * * The barriers must apply to both the compiler and the CPU. Note it is * legal for instructions that occur before an "acquire" barrier to be * moved down below it, and for instructions that occur after a "release" * barrier to be moved up above it. * * The ARM-driven implementation we use here is short on subtlety, * and actually requests a full barrier from the compiler and the CPU. * The only difference between acquire and release is in whether they * are issued before or after the atomic operation with which they * are associated. To ease the transition to C/C++ atomic intrinsics, * you should not rely on this, and instead assume that only the minimal * acquire/release protection is provided. * * NOTE: all int32_t* values are expected to be aligned on 32-bit boundaries. * If they are not, atomicity is not guaranteed. */ /* * Basic arithmetic and bitwise operations. These all provide a * barrier with "release" ordering, and return the previous value. * * These have the same characteristics (e.g. what happens on overflow) * as the equivalent non-atomic C operations. */ int32_t android_atomic_inc(volatile int32_t* addr); int32_t android_atomic_dec(volatile int32_t* addr); int32_t android_atomic_add(int32_t value, volatile int32_t* addr); int32_t android_atomic_and(int32_t value, volatile int32_t* addr); int32_t android_atomic_or(int32_t value, volatile int32_t* addr); /* * Perform an atomic load with "acquire" or "release" ordering. * * Note that the notion of a "release" ordering for a load does not * really fit into the C11 or C++11 memory model. The extra ordering * is normally observable only by code using memory_order_relaxed * atomics, or data races. In the rare cases in which such ordering * is called for, use memory_order_relaxed atomics and a leading * atomic_thread_fence (typically with memory_order_acquire, * not memory_order_release!) instead. If you do not understand * this comment, you are in the vast majority, and should not be * using release loads or replacing them with anything other than * locks or default sequentially consistent atomics. * * This is only necessary if you need the memory barrier. A 32-bit read * from a 32-bit aligned address is atomic on all supported platforms. */ int32_t android_atomic_acquire_load(volatile const int32_t* addr); int32_t android_atomic_release_load(volatile const int32_t* addr); /* * Perform an atomic store with "acquire" or "release" ordering. * * Note that the notion of a "acquire" ordering for a store does not * really fit into the C11 or C++11 memory model. The extra ordering * is normally observable only by code using memory_order_relaxed * atomics, or data races. In the rare cases in which such ordering * is called for, use memory_order_relaxed atomics and a trailing * atomic_thread_fence (typically with memory_order_release, * not memory_order_acquire!) instead. * * This is only necessary if you need the memory barrier. A 32-bit write * to a 32-bit aligned address is atomic on all supported platforms. */ void android_atomic_acquire_store(int32_t value, volatile int32_t* addr); void android_atomic_release_store(int32_t value, volatile int32_t* addr); /* * Compare-and-set operation with "acquire" or "release" ordering. * * This returns zero if the new value was successfully stored, which will * only happen when *addr == oldvalue. * * (The return value is inverted from implementations on other platforms, * but matches the ARM ldrex/strex result.) * * Implementations that use the release CAS in a loop may be less efficient * than possible, because we re-issue the memory barrier on each iteration. */ int android_atomic_acquire_cas(int32_t oldvalue, int32_t newvalue, volatile int32_t* addr); int android_atomic_release_cas(int32_t oldvalue, int32_t newvalue, volatile int32_t* addr); /* * Aliases for code using an older version of this header. These are now * deprecated and should not be used. The definitions will be removed * in a future release. */ #define android_atomic_write android_atomic_release_store #define android_atomic_cmpxchg android_atomic_release_cas #ifdef __cplusplus } // extern "C" #endif #endif // ANDROID_CUTILS_ATOMIC_H android-headers-23/21/cutils/bitops.h000066400000000000000000000057341264465411000175430ustar00rootroot00000000000000/* * 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 __CUTILS_BITOPS_H #define __CUTILS_BITOPS_H #include #include #include #include __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) { return __builtin_popcount(x); } static inline int popcountl(unsigned long x) { return __builtin_popcountl(x); } static inline int popcountll(unsigned long long x) { return __builtin_popcountll(x); } __END_DECLS #endif /* __CUTILS_BITOPS_H */ android-headers-23/21/cutils/compiler.h000066400000000000000000000025171264465411000200510ustar00rootroot00000000000000/* * 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_COMPILER_H #define ANDROID_CUTILS_COMPILER_H /* * helps the compiler's optimizer predicting branches */ #ifdef __cplusplus # define CC_LIKELY( exp ) (__builtin_expect( !!(exp), true )) # define CC_UNLIKELY( exp ) (__builtin_expect( !!(exp), false )) #else # define CC_LIKELY( exp ) (__builtin_expect( !!(exp), 1 )) # define CC_UNLIKELY( exp ) (__builtin_expect( !!(exp), 0 )) #endif /** * exports marked symbols * * if used on a C++ class declaration, this macro must be inserted * after the "class" keyword. For instance: * * template * class ANDROID_API Singleton { } */ #define ANDROID_API __attribute__((visibility("default"))) #endif // ANDROID_CUTILS_COMPILER_H android-headers-23/21/cutils/config_utils.h000066400000000000000000000033471264465411000207260ustar00rootroot00000000000000/* * Copyright (C) 2006 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_CONFIG_UTILS_H #define __CUTILS_CONFIG_UTILS_H #ifdef __cplusplus extern "C" { #endif typedef struct cnode cnode; struct cnode { cnode *next; cnode *first_child; cnode *last_child; const char *name; const char *value; }; /* parse a text string into a config node tree */ void config_load(cnode *root, char *data); /* parse a file into a config node tree */ void config_load_file(cnode *root, const char *fn); /* create a single config node */ cnode* config_node(const char *name, const char *value); /* locate a named child of a config node */ cnode* config_find(cnode *root, const char *name); /* look up a child by name and return the boolean value */ int config_bool(cnode *root, const char *name, int _default); /* look up a child by name and return the string value */ const char* config_str(cnode *root, const char *name, const char *_default); /* add a named child to a config node (or modify it if it already exists) */ void config_set(cnode *root, const char *name, const char *value); /* free a config node tree */ void config_free(cnode *root); #ifdef __cplusplus } #endif #endif android-headers-23/21/cutils/cpu_info.h000066400000000000000000000017761264465411000200470ustar00rootroot00000000000000/* * 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. */ #ifndef __CUTILS_CPU_INFO_H #define __CUTILS_CPU_INFO_H #ifdef __cplusplus extern "C" { #endif /* 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 } #endif #endif /* __CUTILS_CPU_INFO_H */ android-headers-23/21/cutils/debugger.h000066400000000000000000000040221264465411000200140ustar00rootroot00000000000000/* * 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 #ifdef __cplusplus extern "C" { #endif #define DEBUGGER32_SOCKET_NAME "android:debuggerd" #define DEBUGGER64_SOCKET_NAME "android:debuggerd64" #if defined(__LP64__) #define DEBUGGER_SOCKET_NAME DEBUGGER64_SOCKET_NAME #else #define DEBUGGER_SOCKET_NAME DEBUGGER32_SOCKET_NAME #endif 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; typedef struct { debugger_action_t action; pid_t tid; uintptr_t abort_msg_address; int32_t original_si_code; } debugger_msg_t; #if defined(__LP64__) // For a 64 bit process to contact the 32 bit debuggerd. typedef struct { debugger_action_t action; pid_t tid; uint32_t abort_msg_address; int32_t original_si_code; } debugger32_msg_t; #endif /* 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 only to the specified file (requires root). * Returns 0 on success, -1 on error. */ int dump_backtrace_to_file(pid_t tid, int fd); #ifdef __cplusplus } #endif #endif /* __CUTILS_DEBUGGER_H */ android-headers-23/21/cutils/dir_hash.h000066400000000000000000000017051264465411000200160ustar00rootroot00000000000000/* * 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. */ typedef enum { SHA_1, } HashAlgorithm; int get_file_hash(HashAlgorithm algorithm, const char *path, char *output_string, size_t max_output_string); int get_recursive_hash_manifest(HashAlgorithm algorithm, const char *directory_path, char **output_string); android-headers-23/21/cutils/fs.h000066400000000000000000000041731264465411000166470ustar00rootroot00000000000000/* * 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_FS_H #define __CUTILS_FS_H #include #include /* * TEMP_FAILURE_RETRY is defined by some, but not all, versions of * . (Alas, it is not as standard as we'd hoped!) So, if it's * not already defined, then define it here. */ #ifndef TEMP_FAILURE_RETRY /* Used to retry syscalls that can return EINTR. */ #define TEMP_FAILURE_RETRY(exp) ({ \ typeof (exp) _rc; \ do { \ _rc = (exp); \ } while (_rc == -1 && errno == EINTR); \ _rc; }) #endif #ifdef __cplusplus extern "C" { #endif /* * Ensure that directory exists with given mode and owners. */ extern int fs_prepare_dir(const char* path, mode_t mode, uid_t uid, gid_t gid); /* * Read single plaintext integer from given file, correctly handling files * partially written with fs_write_atomic_int(). */ extern int fs_read_atomic_int(const char* path, int* value); /* * Write single plaintext integer to given file, creating backup while * in progress. */ extern int fs_write_atomic_int(const char* path, int value); /* * Ensure that all directories along given path exist, creating parent * directories as needed. Validates that given path is absolute and that * it contains no relative "." or ".." paths or symlinks. Last path segment * is treated as filename and ignored, unless the path ends with "/". */ extern int fs_mkdirs(const char* path, mode_t mode); #ifdef __cplusplus } #endif #endif /* __CUTILS_FS_H */ android-headers-23/21/cutils/hashmap.h000066400000000000000000000067551264465411000176700ustar00rootroot00000000000000/* * 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. */ /** * Hash map. */ #ifndef __HASHMAP_H #define __HASHMAP_H #include #include #ifdef __cplusplus extern "C" { #endif /** A hash map. */ typedef struct Hashmap Hashmap; /** * Creates a new hash map. Returns NULL if memory allocation fails. * * @param initialCapacity number of expected entries * @param hash function which hashes keys * @param equals function which compares keys for equality */ Hashmap* hashmapCreate(size_t initialCapacity, int (*hash)(void* key), bool (*equals)(void* keyA, void* keyB)); /** * Frees the hash map. Does not free the keys or values themselves. */ void hashmapFree(Hashmap* map); /** * Hashes the memory pointed to by key with the given size. Useful for * implementing hash functions. */ int hashmapHash(void* key, size_t keySize); /** * Puts value for the given key in the map. Returns pre-existing value if * any. * * If memory allocation fails, this function returns NULL, the map's size * does not increase, and errno is set to ENOMEM. */ void* hashmapPut(Hashmap* map, void* key, void* value); /** * Gets a value from the map. Returns NULL if no entry for the given key is * found or if the value itself is NULL. */ void* hashmapGet(Hashmap* map, void* key); /** * Returns true if the map contains an entry for the given key. */ bool hashmapContainsKey(Hashmap* map, void* key); /** * Gets the value for a key. If a value is not found, this function gets a * value and creates an entry using the given callback. * * If memory allocation fails, the callback is not called, this function * returns NULL, and errno is set to ENOMEM. */ void* hashmapMemoize(Hashmap* map, void* key, void* (*initialValue)(void* key, void* context), void* context); /** * Removes an entry from the map. Returns the removed value or NULL if no * entry was present. */ void* hashmapRemove(Hashmap* map, void* key); /** * Gets the number of entries in this map. */ size_t hashmapSize(Hashmap* map); /** * Invokes the given callback on each entry in the map. Stops iterating if * the callback returns false. */ void hashmapForEach(Hashmap* map, bool (*callback)(void* key, void* value, void* context), void* context); /** * Concurrency support. */ /** * Locks the hash map so only the current thread can access it. */ void hashmapLock(Hashmap* map); /** * Unlocks the hash map so other threads can access it. */ void hashmapUnlock(Hashmap* map); /** * Key utilities. */ /** * Hashes int keys. 'key' is a pointer to int. */ int hashmapIntHash(void* key); /** * Compares two int keys for equality. */ bool hashmapIntEquals(void* keyA, void* keyB); /** * For debugging. */ /** * Gets current capacity. */ size_t hashmapCurrentCapacity(Hashmap* map); /** * Counts the number of entry collisions. */ size_t hashmapCountCollisions(Hashmap* map); #ifdef __cplusplus } #endif #endif /* __HASHMAP_H */ android-headers-23/21/cutils/iosched_policy.h000066400000000000000000000020521264465411000212260ustar00rootroot00000000000000/* * 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. */ #ifndef __CUTILS_IOSCHED_POLICY_H #define __CUTILS_IOSCHED_POLICY_H #ifdef __cplusplus extern "C" { #endif typedef enum { IoSchedClass_NONE, IoSchedClass_RT, IoSchedClass_BE, IoSchedClass_IDLE, } IoSchedClass; extern int android_set_ioprio(int pid, IoSchedClass clazz, int ioprio); extern int android_get_ioprio(int pid, IoSchedClass *clazz, int *ioprio); #ifdef __cplusplus } #endif #endif /* __CUTILS_IOSCHED_POLICY_H */ android-headers-23/21/cutils/jstring.h000066400000000000000000000026551264465411000177220ustar00rootroot00000000000000/* * Copyright (C) 2006 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_STRING16_H #define __CUTILS_STRING16_H #include #include #ifdef __cplusplus extern "C" { #endif #if __STDC_VERSION__ < 201112L && __cplusplus < 201103L typedef uint16_t char16_t; #endif // otherwise char16_t is a keyword with the right semantics extern char * strndup16to8 (const char16_t* s, size_t n); extern size_t strnlen16to8 (const char16_t* s, size_t n); extern char * strncpy16to8 (char *dest, const char16_t*s, size_t n); extern char16_t * strdup8to16 (const char* s, size_t *out_len); extern size_t strlen8to16 (const char* utf8Str); extern char16_t * strcpy8to16 (char16_t *dest, const char*s, size_t *out_len); extern char16_t * strcpylen8to16 (char16_t *dest, const char*s, int length, size_t *out_len); #ifdef __cplusplus } #endif #endif /* __CUTILS_STRING16_H */ android-headers-23/21/cutils/klog.h000066400000000000000000000032021264465411000171630ustar00rootroot00000000000000/* * 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 _CUTILS_KLOG_H_ #define _CUTILS_KLOG_H_ #include #include __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))); void klog_vwrite(int level, const char *fmt, va_list ap); __END_DECLS #define KLOG_ERROR_LEVEL 3 #define KLOG_WARNING_LEVEL 4 #define KLOG_NOTICE_LEVEL 5 #define KLOG_INFO_LEVEL 6 #define KLOG_DEBUG_LEVEL 7 #define KLOG_ERROR(tag,x...) klog_write(KLOG_ERROR_LEVEL, "<3>" tag ": " x) #define KLOG_WARNING(tag,x...) klog_write(KLOG_WARNING_LEVEL, "<4>" tag ": " x) #define KLOG_NOTICE(tag,x...) klog_write(KLOG_NOTICE_LEVEL, "<5>" tag ": " x) #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 android-headers-23/21/cutils/list.h000066400000000000000000000042561264465411000172140ustar00rootroot00000000000000/* * Copyright (C) 2008-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_LIST_H_ #define _CUTILS_LIST_H_ #include #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ struct listnode { struct listnode *next; struct listnode *prev; }; #define node_to_item(node, container, member) \ (container *) (((char*) (node)) - offsetof(container, member)) #define list_declare(name) \ struct listnode name = { \ .next = &name, \ .prev = &name, \ } #define list_for_each(node, list) \ 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) #define list_for_each_safe(node, n, list) \ for (node = (list)->next, n = node->next; \ node != (list); \ node = n, n = node->next) static inline void list_init(struct listnode *node) { node->next = node; node->prev = node; } static inline void list_add_tail(struct listnode *head, struct listnode *item) { item->next = head; item->prev = head->prev; head->prev->next = item; head->prev = item; } static inline void list_add_head(struct listnode *head, struct listnode *item) { item->next = head->next; item->prev = head; head->next->prev = item; head->next = item; } static inline void list_remove(struct listnode *item) { item->next->prev = item->prev; item->prev->next = item->next; } #define list_empty(list) ((list) == (list)->next) #define list_head(list) ((list)->next) #define list_tail(list) ((list)->prev) #ifdef __cplusplus }; #endif /* __cplusplus */ #endif android-headers-23/21/cutils/log.h000066400000000000000000000000251264465411000170100ustar00rootroot00000000000000#include android-headers-23/21/cutils/memory.h000066400000000000000000000023411264465411000175420ustar00rootroot00000000000000/* * Copyright (C) 2006 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_MEMORY_H #define ANDROID_CUTILS_MEMORY_H #include #include #ifdef __cplusplus extern "C" { #endif /* size is given in bytes and must be multiple of 2 */ void android_memset16(uint16_t* dst, uint16_t value, size_t size); /* size is given in bytes and must be multiple of 4 */ void android_memset32(uint32_t* dst, uint32_t value, size_t size); #if !HAVE_STRLCPY /* Declaration of strlcpy() for platforms that don't already have it. */ size_t strlcpy(char *dst, const char *src, size_t size); #endif #ifdef __cplusplus } // extern "C" #endif #endif // ANDROID_CUTILS_MEMORY_H android-headers-23/21/cutils/misc.h000066400000000000000000000023401264465411000171640ustar00rootroot00000000000000/* * Copyright (C) 2006 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_MISC_H #define __CUTILS_MISC_H #ifdef __cplusplus extern "C" { #endif /* Load an entire file into a malloc'd chunk of memory * that is length_of_file + 1 (null terminator). If * sz is non-zero, return the size of the file via sz. * Returns 0 on failure. */ extern void *load_file(const char *fn, unsigned *sz); /* This is the range of UIDs (and GIDs) that are reserved * for assigning to applications. */ #define FIRST_APPLICATION_UID 10000 #define LAST_APPLICATION_UID 99999 #ifdef __cplusplus } #endif #endif /* __CUTILS_MISC_H */ android-headers-23/21/cutils/multiuser.h000066400000000000000000000021251264465411000202630ustar00rootroot00000000000000/* * 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_MULTIUSER_H #define __CUTILS_MULTIUSER_H #include #ifdef __cplusplus extern "C" { #endif // NOTE: keep in sync with android.os.UserId #define MULTIUSER_APP_PER_USER_RANGE 100000 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); #ifdef __cplusplus } #endif #endif /* __CUTILS_MULTIUSER_H */ android-headers-23/21/cutils/native_handle.h000066400000000000000000000035011264465411000210320ustar00rootroot00000000000000/* * 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 NATIVE_HANDLE_H_ #define NATIVE_HANDLE_H_ #ifdef __cplusplus extern "C" { #endif 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] */ int data[0]; /* numFds + numInts ints */ } native_handle_t; /* * native_handle_close * * closes the file descriptors contained in this native_handle_t * * return 0 on success, or a negative error code on failure * */ int native_handle_close(const native_handle_t* h); /* * native_handle_create * * creates a native_handle_t and initializes it. must be destroyed with * native_handle_delete(). * */ native_handle_t* native_handle_create(int numFds, int numInts); /* * native_handle_delete * * frees a native_handle_t allocated with native_handle_create(). * This ONLY frees the memory allocated for the native_handle_t, but doesn't * close the file descriptors; which can be achieved with native_handle_close(). * * return 0 on success, or a negative error code on failure * */ int native_handle_delete(native_handle_t* h); #ifdef __cplusplus } #endif #endif /* NATIVE_HANDLE_H_ */ android-headers-23/21/cutils/open_memstream.h000066400000000000000000000016471264465411000212550ustar00rootroot00000000000000/* * 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 __CUTILS_OPEN_MEMSTREAM_H__ #define __CUTILS_OPEN_MEMSTREAM_H__ #include #ifndef HAVE_OPEN_MEMSTREAM #ifdef __cplusplus extern "C" { #endif FILE* open_memstream(char** bufp, size_t* sizep); #ifdef __cplusplus } #endif #endif /*!HAVE_OPEN_MEMSTREAM*/ #endif /*__CUTILS_OPEN_MEMSTREAM_H__*/ android-headers-23/21/cutils/partition_utils.h000066400000000000000000000015271264465411000214700ustar00rootroot00000000000000/* * Copyright 2011, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __CUTILS_PARTITION_WIPED_H__ #define __CUTILS_PARTITION_WIPED_H__ __BEGIN_DECLS int partition_wiped(char *source); void erase_footer(const char *dev_path, long long size); __END_DECLS #endif /* __CUTILS_PARTITION_WIPED_H__ */ android-headers-23/21/cutils/process_name.h000066400000000000000000000020451264465411000207110ustar00rootroot00000000000000/* * 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. */ /** * Gives the current process a name. */ #ifndef __PROCESS_NAME_H #define __PROCESS_NAME_H #ifdef __cplusplus extern "C" { #endif /** * Sets the current process name. * * Warning: This leaks a string every time you call it. Use judiciously! */ void set_process_name(const char* process_name); /** Gets the current process name. */ const char* get_process_name(void); #ifdef __cplusplus } #endif #endif /* __PROCESS_NAME_H */ android-headers-23/21/cutils/properties.h000066400000000000000000000117451264465411000204360ustar00rootroot00000000000000/* * Copyright (C) 2006 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_PROPERTIES_H #define __CUTILS_PROPERTIES_H #include #include #include #include #ifdef __cplusplus extern "C" { #endif /* System properties are *small* name value pairs managed by the ** property service. If your data doesn't fit in the provided ** space it is not appropriate for a system property. ** ** WARNING: system/bionic/include/sys/system_properties.h also defines ** these, but with different names. (TODO: fix that) */ #define PROPERTY_KEY_MAX PROP_NAME_MAX #define PROPERTY_VALUE_MAX PROP_VALUE_MAX /* property_get: returns the length of the value which will never be ** greater than PROPERTY_VALUE_MAX - 1 and will always be zero terminated. ** (the length does not include the terminating zero). ** ** 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); /* property_get_bool: returns the value of key coerced into a ** boolean. If the property is not set, then the default value is returned. ** * The following is considered to be true (1): ** "1", "true", "y", "yes", "on" ** ** The following is considered to be false (0): ** "0", "false", "n", "no", "off" ** ** The conversion is whitespace-sensitive (e.g. " off" will not be false). ** ** If no property with this key is set (or the key is NULL) or the boolean ** conversion fails, the default value is returned. **/ int8_t property_get_bool(const char *key, int8_t default_value); /* property_get_int64: returns the value of key truncated and coerced into a ** int64_t. If the property is not set, then the default value is used. ** ** The numeric conversion is identical to strtoimax with the base inferred: ** - All digits up to the first non-digit characters are read ** - The longest consecutive prefix of digits is converted to a long ** ** Valid strings of digits are: ** - An optional sign character + or - ** - An optional prefix indicating the base (otherwise base 10 is assumed) ** -- 0 prefix is octal ** -- 0x / 0X prefix is hex ** ** Leading/trailing whitespace is ignored. Overflow/underflow will cause ** numeric conversion to fail. ** ** If no property with this key is set (or the key is NULL) or the numeric ** conversion fails, the default value is returned. **/ int64_t property_get_int64(const char *key, int64_t default_value); /* property_get_int32: returns the value of key truncated and coerced into an ** int32_t. If the property is not set, then the default value is used. ** ** The numeric conversion is identical to strtoimax with the base inferred: ** - All digits up to the first non-digit characters are read ** - The longest consecutive prefix of digits is converted to a long ** ** Valid strings of digits are: ** - An optional sign character + or - ** - An optional prefix indicating the base (otherwise base 10 is assumed) ** -- 0 prefix is octal ** -- 0x / 0X prefix is hex ** ** Leading/trailing whitespace is ignored. Overflow/underflow will cause ** numeric conversion to fail. ** ** If no property with this key is set (or the key is NULL) or the numeric ** conversion fails, the default value is returned. **/ 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); #if defined(__BIONIC_FORTIFY) 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"); __BIONIC_FORTIFY_INLINE int property_get(const char *key, char *value, const char *default_value) { size_t bos = __bos(value); if (bos < PROPERTY_VALUE_MAX) { __property_get_too_small_error(); } return __property_get_real(key, value, default_value); } #endif #ifdef HAVE_SYSTEM_PROPERTY_SERVER /* * We have an external property server instead of built-in libc support. * Used by the simulator. */ #define SYSTEM_PROPERTY_PIPE_NAME "/tmp/android-sysprop" enum { kSystemPropertyUnknown = 0, kSystemPropertyGet, kSystemPropertySet, kSystemPropertyList }; #endif /*HAVE_SYSTEM_PROPERTY_SERVER*/ #ifdef __cplusplus } #endif #endif android-headers-23/21/cutils/qtaguid.h000066400000000000000000000034501264465411000176720ustar00rootroot00000000000000/* * 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 __CUTILS_QTAGUID_H #define __CUTILS_QTAGUID_H #include #include #include #ifdef __cplusplus extern "C" { #endif /* * 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); /* * For the given uid, switch counter sets. * The kernel only keeps a limited number of sets. * 2 for now. */ 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 * then untagged. * The calling process can only operate on its own tags. * Unless it is part of the happy AID_NET_BW_ACCT group. * In which case it can clobber everything. */ extern int qtaguid_deleteTagData(int tag, uid_t uid); /* * Enable/disable qtaguid functionnality at a lower level. * When pacified, the kernel will accept commands but do nothing. */ extern int qtaguid_setPacifier(int on); #ifdef __cplusplus } #endif #endif /* __CUTILS_QTAG_UID_H */ android-headers-23/21/cutils/record_stream.h000066400000000000000000000022221264465411000210610ustar00rootroot00000000000000/* * Copyright (C) 2006 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. */ /* * A simple utility for reading fixed records out of a stream fd */ #ifndef _CUTILS_RECORD_STREAM_H #define _CUTILS_RECORD_STREAM_H #ifdef __cplusplus extern "C" { #endif typedef struct RecordStream RecordStream; extern RecordStream *record_stream_new(int fd, size_t maxRecordLen); extern void record_stream_free(RecordStream *p_rs); extern int record_stream_get_next (RecordStream *p_rs, void ** p_outRecord, size_t *p_outRecordLen); #ifdef __cplusplus } #endif #endif /*_CUTILS_RECORD_STREAM_H*/ android-headers-23/21/cutils/sched_policy.h000066400000000000000000000041301264465411000206750ustar00rootroot00000000000000/* * 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. */ #ifndef __CUTILS_SCHED_POLICY_H #define __CUTILS_SCHED_POLICY_H #ifdef __cplusplus extern "C" { #endif /* Keep in sync with THREAD_GROUP_* in frameworks/base/core/java/android/os/Process.java */ typedef enum { 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_CNT, SP_MAX = SP_CNT - 1, SP_SYSTEM_DEFAULT = SP_FOREGROUND, } SchedPolicy; /* Assign thread tid to the cgroup associated with the specified policy. * If the thread is a thread group leader, that is it's gettid() == getpid(), * then the other threads in the same thread group are _not_ affected. * On platforms which support gettid(), zero tid means current thread. * Return value: 0 for success, or -errno for error. */ extern int set_sched_policy(int tid, SchedPolicy policy); /* Return the policy associated with the cgroup of thread tid via policy pointer. * On platforms which support gettid(), zero tid means current thread. * Return value: 0 for success, or -1 for error and set errno. */ extern int get_sched_policy(int tid, SchedPolicy *policy); /* Return a displayable string corresponding to policy. * Return value: non-NULL NUL-terminated name of unspecified length; * the caller is responsible for displaying the useful part of the string. */ extern const char *get_sched_policy_name(SchedPolicy policy); #ifdef __cplusplus } #endif #endif /* __CUTILS_SCHED_POLICY_H */ android-headers-23/21/cutils/sockets.h000066400000000000000000000067651264465411000177230ustar00rootroot00000000000000/* * Copyright (C) 2006 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_SOCKETS_H #define __CUTILS_SOCKETS_H #include #include #include #include #ifdef HAVE_WINSOCK #include typedef int socklen_t; #elif HAVE_SYS_SOCKET_H #include #endif #define ANDROID_SOCKET_ENV_PREFIX "ANDROID_SOCKET_" #define ANDROID_SOCKET_DIR "/dev/socket" #ifdef __cplusplus extern "C" { #endif /* * 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] = ANDROID_SOCKET_ENV_PREFIX; const char *val; int fd; /* build our environment variable, counting cycles like a wolf ... */ #if HAVE_STRLCPY strlcpy(key + sizeof(ANDROID_SOCKET_ENV_PREFIX) - 1, name, sizeof(key) - sizeof(ANDROID_SOCKET_ENV_PREFIX)); #else /* for the host, which may lack the almightly strncpy ... */ strncpy(key + sizeof(ANDROID_SOCKET_ENV_PREFIX) - 1, name, sizeof(key) - sizeof(ANDROID_SOCKET_ENV_PREFIX)); key[sizeof(key)-1] = '\0'; #endif val = getenv(key); if (!val) return -1; errno = 0; fd = strtol(val, NULL, 10); if (errno) return -1; return fd; } /* * See also android.os.LocalSocketAddress.Namespace */ // Linux "abstract" (non-filesystem) namespace #define ANDROID_SOCKET_NAMESPACE_ABSTRACT 0 // Android "reserved" (/dev/socket) namespace #define ANDROID_SOCKET_NAMESPACE_RESERVED 1 // Normal filesystem namespace #define ANDROID_SOCKET_NAMESPACE_FILESYSTEM 2 extern int socket_loopback_client(int port, int type); extern int socket_network_client(const char *host, int port, int type); extern int socket_network_client_timeout(const char *host, int port, int type, int timeout); extern int socket_loopback_server(int port, int type); extern int socket_local_server(const char *name, int namespaceId, int type); extern int socket_local_server_bind(int s, const char *name, int namespaceId); extern int socket_local_client_connect(int fd, const char *name, int namespaceId, int type); extern int socket_local_client(const char *name, int namespaceId, int type); extern int socket_inaddr_any_server(int port, int type); /* * socket_peer_is_trusted - Takes a socket which is presumed to be a * connected local socket (e.g. AF_LOCAL) and returns whether the peer * (the userid that owns the process on the other end of that socket) * is one of the two trusted userids, root or shell. * * Note: This only works as advertised on the Android OS and always * just returns true when called on other operating systems. */ extern bool socket_peer_is_trusted(int fd); #ifdef __cplusplus } #endif #endif /* __CUTILS_SOCKETS_H */ android-headers-23/21/cutils/str_parms.h000066400000000000000000000041171264465411000202470ustar00rootroot00000000000000/* * 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 __CUTILS_STR_PARMS_H #define __CUTILS_STR_PARMS_H #include struct str_parms; struct str_parms *str_parms_create(void); struct str_parms *str_parms_create_str(const char *_string); void str_parms_destroy(struct str_parms *str_parms); void str_parms_del(struct str_parms *str_parms, const char *key); int str_parms_add_str(struct str_parms *str_parms, const char *key, const char *value); int str_parms_add_int(struct str_parms *str_parms, const char *key, int value); int str_parms_add_float(struct str_parms *str_parms, const char *key, float value); // Returns non-zero if the str_parms contains the specified key. int str_parms_has_key(struct str_parms *str_parms, const char *key); // Gets value associated with the specified key (if present), placing it in the buffer // pointed to by the out_val parameter. Returns the length of the returned string value. // If 'key' isn't in the parms, then return -ENOENT (-2) and leave 'out_val' untouched. int str_parms_get_str(struct str_parms *str_parms, const char *key, char *out_val, int len); int str_parms_get_int(struct str_parms *str_parms, const char *key, int *out_val); int str_parms_get_float(struct str_parms *str_parms, const char *key, float *out_val); char *str_parms_to_str(struct str_parms *str_parms); /* debug */ void str_parms_dump(struct str_parms *str_parms); #endif /* __CUTILS_STR_PARMS_H */ android-headers-23/21/cutils/threads.h000066400000000000000000000077331264465411000176760ustar00rootroot00000000000000/* * 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. */ #ifndef _LIBS_CUTILS_THREADS_H #define _LIBS_CUTILS_THREADS_H #ifdef __cplusplus extern "C" { #endif /***********************************************************************/ /***********************************************************************/ /***** *****/ /***** local thread storage *****/ /***** *****/ /***********************************************************************/ /***********************************************************************/ #ifdef HAVE_PTHREADS #include typedef struct { pthread_mutex_t lock; int has_tls; pthread_key_t tls; } thread_store_t; #define THREAD_STORE_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, 0, 0 } #elif defined HAVE_WIN32_THREADS #include typedef struct { int lock_init; int has_tls; DWORD tls; CRITICAL_SECTION lock; } thread_store_t; #define THREAD_STORE_INITIALIZER { 0, 0, 0, {0, 0, 0, 0, 0, 0} } #else # error "no thread_store_t implementation for your platform !!" #endif typedef void (*thread_store_destruct_t)(void* value); extern void* thread_store_get(thread_store_t* store); extern void thread_store_set(thread_store_t* store, void* value, thread_store_destruct_t destroy); /***********************************************************************/ /***********************************************************************/ /***** *****/ /***** mutexes *****/ /***** *****/ /***********************************************************************/ /***********************************************************************/ #ifdef HAVE_PTHREADS typedef pthread_mutex_t mutex_t; #define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER static __inline__ void mutex_lock(mutex_t* lock) { pthread_mutex_lock(lock); } static __inline__ void mutex_unlock(mutex_t* lock) { pthread_mutex_unlock(lock); } static __inline__ int mutex_init(mutex_t* lock) { return pthread_mutex_init(lock, NULL); } static __inline__ void mutex_destroy(mutex_t* lock) { pthread_mutex_destroy(lock); } #endif #ifdef HAVE_WIN32_THREADS typedef struct { int init; CRITICAL_SECTION lock[1]; } mutex_t; #define MUTEX_INITIALIZER { 0, {{ NULL, 0, 0, NULL, NULL, 0 }} } static __inline__ void mutex_lock(mutex_t* lock) { if (!lock->init) { lock->init = 1; InitializeCriticalSection( lock->lock ); lock->init = 2; } else while (lock->init != 2) Sleep(10); EnterCriticalSection(lock->lock); } static __inline__ void mutex_unlock(mutex_t* lock) { LeaveCriticalSection(lock->lock); } static __inline__ int mutex_init(mutex_t* lock) { InitializeCriticalSection(lock->lock); lock->init = 2; return 0; } static __inline__ void mutex_destroy(mutex_t* lock) { if (lock->init) { lock->init = 0; DeleteCriticalSection(lock->lock); } } #endif #ifdef __cplusplus } #endif #endif /* _LIBS_CUTILS_THREADS_H */ android-headers-23/21/cutils/trace.h000066400000000000000000000233471264465411000173410ustar00rootroot00000000000000/* * 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 _LIBS_CUTILS_TRACE_H #define _LIBS_CUTILS_TRACE_H #include #include #include #include #include #include #include #include #ifdef ANDROID_SMP #include #else #include #endif __BEGIN_DECLS /** * The ATRACE_TAG macro can be defined before including this header to trace * using one of the tags defined below. It must be defined to one of the * following ATRACE_TAG_* macros. The trace tag is used to filter tracing in * userland to avoid some of the runtime cost of tracing when it is not desired. * * Defining ATRACE_TAG to be ATRACE_TAG_ALWAYS will result in the tracing always * being enabled - this should ONLY be done for debug code, as userland tracing * has a performance cost even when the trace is not being recorded. Defining * ATRACE_TAG to be ATRACE_TAG_NEVER or leaving ATRACE_TAG undefined will result * in the tracing always being disabled. * * ATRACE_TAG_HAL should be bitwise ORed with the relevant tags for tracing * within a hardware module. For example a camera hardware module would set: * #define ATRACE_TAG (ATRACE_TAG_CAMERA | ATRACE_TAG_HAL) * * Keep these in sync with frameworks/base/core/java/android/os/Trace.java. */ #define ATRACE_TAG_NEVER 0 // This tag is never enabled. #define ATRACE_TAG_ALWAYS (1<<0) // This tag is always enabled. #define ATRACE_TAG_GRAPHICS (1<<1) #define ATRACE_TAG_INPUT (1<<2) #define ATRACE_TAG_VIEW (1<<3) #define ATRACE_TAG_WEBVIEW (1<<4) #define ATRACE_TAG_WINDOW_MANAGER (1<<5) #define ATRACE_TAG_ACTIVITY_MANAGER (1<<6) #define ATRACE_TAG_SYNC_MANAGER (1<<7) #define ATRACE_TAG_AUDIO (1<<8) #define ATRACE_TAG_VIDEO (1<<9) #define ATRACE_TAG_CAMERA (1<<10) #define ATRACE_TAG_HAL (1<<11) #define ATRACE_TAG_APP (1<<12) #define ATRACE_TAG_RESOURCES (1<<13) #define ATRACE_TAG_DALVIK (1<<14) #define ATRACE_TAG_RS (1<<15) #define ATRACE_TAG_BIONIC (1<<16) #define ATRACE_TAG_POWER (1<<17) #define ATRACE_TAG_LAST ATRACE_TAG_POWER // Reserved for initialization. #define ATRACE_TAG_NOT_READY (1LL<<63) #define ATRACE_TAG_VALID_MASK ((ATRACE_TAG_LAST - 1) | ATRACE_TAG_LAST) #ifndef ATRACE_TAG #define ATRACE_TAG ATRACE_TAG_NEVER #elif ATRACE_TAG > ATRACE_TAG_VALID_MASK #error ATRACE_TAG must be defined to be one of the tags defined in cutils/trace.h #endif #ifdef HAVE_ANDROID_OS /** * Maximum size of a message that can be logged to the trace buffer. * Note this message includes a tag, the pid, and the string given as the name. * Names should be kept short to get the most use of the trace buffer. */ #define ATRACE_MESSAGE_LENGTH 1024 /** * Opens the trace file for writing and reads the property for initial tags. * The atrace.tags.enableflags property sets the tags to trace. * This function should not be explicitly called, the first call to any normal * trace function will cause it to be run safely. */ void atrace_setup(); /** * If tracing is ready, set atrace_enabled_tags to the system property * debug.atrace.tags.enableflags. Can be used as a sysprop change callback. */ void atrace_update_tags(); /** * Set whether the process is debuggable. By default the process is not * considered debuggable. If the process is not debuggable then application- * level tracing is not allowed unless the ro.debuggable system property is * set to '1'. */ void atrace_set_debuggable(bool debuggable); /** * Set whether tracing is enabled for the current process. This is used to * prevent tracing within the Zygote process. */ void atrace_set_tracing_enabled(bool enabled); /** * Flag indicating whether setup has been completed, initialized to 0. * Nonzero indicates setup has completed. * Note: This does NOT indicate whether or not setup was successful. */ extern volatile int32_t atrace_is_ready; /** * Set of ATRACE_TAG flags to trace for, initialized to ATRACE_TAG_NOT_READY. * A value of zero indicates setup has failed. * Any other nonzero value indicates setup has succeeded, and tracing is on. */ extern uint64_t atrace_enabled_tags; /** * Handle to the kernel's trace buffer, initialized to -1. * Any other value indicates setup has succeeded, and is a valid fd for tracing. */ extern int atrace_marker_fd; /** * atrace_init readies the process for tracing by opening the trace_marker file. * Calling any trace function causes this to be run, so calling it is optional. * This can be explicitly run to avoid setup delay on first trace function. */ #define ATRACE_INIT() atrace_init() static inline void atrace_init() { if (CC_UNLIKELY(!android_atomic_acquire_load(&atrace_is_ready))) { atrace_setup(); } } /** * Get the mask of all tags currently enabled. * It can be used as a guard condition around more expensive trace calculations. * Every trace function calls this, which ensures atrace_init is run. */ #define ATRACE_GET_ENABLED_TAGS() atrace_get_enabled_tags() static inline uint64_t atrace_get_enabled_tags() { atrace_init(); return atrace_enabled_tags; } /** * Test if a given tag is currently enabled. * Returns nonzero if the tag is enabled, otherwise zero. * It can be used as a guard condition around more expensive trace calculations. */ #define ATRACE_ENABLED() atrace_is_tag_enabled(ATRACE_TAG) static inline uint64_t atrace_is_tag_enabled(uint64_t tag) { return atrace_get_enabled_tags() & tag; } /** * Trace the beginning of a context. name is used to identify the context. * This is often used to time function execution. */ #define ATRACE_BEGIN(name) atrace_begin(ATRACE_TAG, name) static inline void atrace_begin(uint64_t tag, const char* name) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { char buf[ATRACE_MESSAGE_LENGTH]; size_t len; len = snprintf(buf, ATRACE_MESSAGE_LENGTH, "B|%d|%s", getpid(), name); write(atrace_marker_fd, buf, len); } } /** * Trace the end of a context. * This should match up (and occur after) a corresponding ATRACE_BEGIN. */ #define ATRACE_END() atrace_end(ATRACE_TAG) 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); } } /** * Trace the beginning of an asynchronous event. Unlike ATRACE_BEGIN/ATRACE_END * contexts, asynchronous events do not need to be nested. The name describes * the event, and the cookie provides a unique identifier for distinguishing * simultaneous events. The name and cookie used to begin an event must be * used to end it. */ #define ATRACE_ASYNC_BEGIN(name, cookie) \ atrace_async_begin(ATRACE_TAG, name, cookie) static inline void atrace_async_begin(uint64_t tag, const char* name, int32_t cookie) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { char buf[ATRACE_MESSAGE_LENGTH]; size_t len; len = snprintf(buf, ATRACE_MESSAGE_LENGTH, "S|%d|%s|%" PRId32, getpid(), name, cookie); write(atrace_marker_fd, buf, len); } } /** * Trace the end of an asynchronous event. * This should have a corresponding ATRACE_ASYNC_BEGIN. */ #define ATRACE_ASYNC_END(name, cookie) atrace_async_end(ATRACE_TAG, name, cookie) static inline void atrace_async_end(uint64_t tag, const char* name, int32_t cookie) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { char buf[ATRACE_MESSAGE_LENGTH]; size_t len; len = snprintf(buf, ATRACE_MESSAGE_LENGTH, "F|%d|%s|%" PRId32, getpid(), name, cookie); write(atrace_marker_fd, buf, len); } } /** * Traces an integer counter value. name is used to identify the counter. * This can be used to track how a value changes over time. */ #define ATRACE_INT(name, value) atrace_int(ATRACE_TAG, name, value) static inline void atrace_int(uint64_t tag, const char* name, int32_t value) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { char buf[ATRACE_MESSAGE_LENGTH]; size_t len; len = snprintf(buf, ATRACE_MESSAGE_LENGTH, "C|%d|%s|%" PRId32, getpid(), name, value); write(atrace_marker_fd, buf, len); } } /** * Traces a 64-bit integer counter value. name is used to identify the * counter. This can be used to track how a value changes over time. */ #define ATRACE_INT64(name, value) atrace_int64(ATRACE_TAG, name, value) static inline void atrace_int64(uint64_t tag, const char* name, int64_t value) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { char buf[ATRACE_MESSAGE_LENGTH]; size_t len; len = snprintf(buf, ATRACE_MESSAGE_LENGTH, "C|%d|%s|%" PRId64, getpid(), name, value); write(atrace_marker_fd, buf, len); } } #else // not HAVE_ANDROID_OS #define ATRACE_INIT() #define ATRACE_GET_ENABLED_TAGS() #define ATRACE_ENABLED() 0 #define ATRACE_BEGIN(name) #define ATRACE_END() #define ATRACE_ASYNC_BEGIN(name, cookie) #define ATRACE_ASYNC_END(name, cookie) #define ATRACE_INT(name, value) #endif // not HAVE_ANDROID_OS __END_DECLS #endif // _LIBS_CUTILS_TRACE_H android-headers-23/21/cutils/uevent.h000066400000000000000000000020261264465411000175400ustar00rootroot00000000000000/* * 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 __CUTILS_UEVENT_H #define __CUTILS_UEVENT_H #include #include #ifdef __cplusplus extern "C" { #endif int uevent_open_socket(int buf_sz, bool passcred); ssize_t uevent_kernel_multicast_recv(int socket, void *buffer, size_t length); ssize_t uevent_kernel_multicast_uid_recv(int socket, void *buffer, size_t length, uid_t *uid); #ifdef __cplusplus } #endif #endif /* __CUTILS_UEVENT_H */ android-headers-23/21/hardware/000077500000000000000000000000001264465411000163535ustar00rootroot00000000000000android-headers-23/21/hardware/activity_recognition.h000066400000000000000000000242601264465411000227640ustar00rootroot00000000000000/* * 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. */ /* * Activity Recognition HAL. The goal is to provide low power, low latency, always-on activity * recognition implemented in hardware (i.e. these activity recognition algorithms/classifers * should NOT be run on the AP). By low power we mean that this may be activated 24/7 without * impacting the battery drain speed (goal in order of 1mW including the power for sensors). * This HAL does not specify the input sources that are used towards detecting these activities. * It has one monitor interface which can be used to batch activities for always-on * activity_recognition and if the latency is zero, the same interface can be used for low latency * detection. */ #ifndef ANDROID_ACTIVITY_RECOGNITION_INTERFACE_H #define ANDROID_ACTIVITY_RECOGNITION_INTERFACE_H #include __BEGIN_DECLS #define ACTIVITY_RECOGNITION_HEADER_VERSION 1 #define ACTIVITY_RECOGNITION_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION_2(0, 1, ACTIVITY_RECOGNITION_HEADER_VERSION) #define ACTIVITY_RECOGNITION_HARDWARE_MODULE_ID "activity_recognition" #define ACTIVITY_RECOGNITION_HARDWARE_INTERFACE "activity_recognition_hw_if" /* * Define types for various activities. Multiple activities may be active at the same time and * sometimes none of these activities may be active. * * Each activity has a corresponding type. Only activities that are defined here should use * android.activity_recognition.* prefix. OEM defined activities should not use this prefix. * Activity type of OEM-defined activities should start with the reverse domain name of the entity * defining the activity. * * When android introduces a new activity type that can potentially replace an OEM-defined activity * type, the OEM must use the official activity type on versions of the HAL that support this new * official activity type. * * Example (made up): Suppose Google's Glass team wants to detect nodding activity. * - Such an activity is not officially supported in android L * - Glass devices launching on L can implement a custom activity with * type = "com.google.glass.nodding" * - In M android release, if android decides to define ACITIVITY_TYPE_NODDING, those types * should replace the Glass-team-specific types in all future launches. * - When launching glass on the M release, Google should now use the official activity type * - This way, other applications can use this activity. */ #define ACTIVITY_TYPE_IN_VEHICLE "android.activity_recognition.in_vehicle" #define ACTIVITY_TYPE_ON_BICYCLE "android.activity_recognition.on_bicycle" #define ACTIVITY_TYPE_WALKING "android.activity_recognition.walking" #define ACTIVITY_TYPE_RUNNING "android.activity_recognition.running" #define ACTIVITY_TYPE_STILL "android.activity_recognition.still" #define ACTIVITY_TYPE_TILTING "android.activity_recognition.tilting" /* Values for activity_event.event_types. */ enum { /* * A flush_complete event which indicates that a flush() has been successfully completed. This * does not correspond to any activity/event. An event of this type should be added to the end * of a batch FIFO and it indicates that all the events in the batch FIFO have been successfully * reported to the framework. An event of this type should be generated only if flush() has been * explicitly called and if the FIFO is empty at the time flush() is called it should trivially * return a flush_complete_event to indicate that the FIFO is empty. * * A flush complete event should have the following parameters set. * activity_event_t.event_type = ACTIVITY_EVENT_FLUSH_COMPLETE * activity_event_t.activity = 0 * activity_event_t.timestamp = 0 * activity_event_t.reserved = 0 * See (*flush)() for more details. */ ACTIVITY_EVENT_FLUSH_COMPLETE = 0, /* Signifies entering an activity. */ ACTIVITY_EVENT_ENTER = 1, /* Signifies exiting an activity. */ ACTIVITY_EVENT_EXIT = 2 }; /* * Each event is a separate activity with event_type indicating whether this activity has started * or ended. Eg event: (event_type="enter", activity="ON_FOOT", timestamp) */ typedef struct activity_event { /* One of the ACTIVITY_EVENT_* constants defined above. */ uint32_t event_type; /* * Index of the activity in the list returned by get_supported_activities_list. If this event * is a flush complete event, this should be set to zero. */ uint32_t activity; /* Time at which the transition/event has occurred in nanoseconds using elapsedRealTimeNano. */ int64_t timestamp; /* Set to zero. */ int32_t reserved[4]; } activity_event_t; typedef struct activity_recognition_module { /** * Common methods of the activity recognition module. This *must* be the first member of * activity_recognition_module as users of this structure will cast a hw_module_t to * activity_recognition_module pointer in contexts where it's known the hw_module_t * references an activity_recognition_module. */ hw_module_t common; /* * List of all activities supported by this module including OEM defined activities. Each * activity is represented using a string defined above. Each string should be null terminated. * The index of the activity in this array is used as a "handle" for enabling/disabling and * event delivery. * Return value is the size of this list. */ int (*get_supported_activities_list)(struct activity_recognition_module* module, char const* const* *activity_list); } activity_recognition_module_t; struct activity_recognition_device; typedef struct activity_recognition_callback_procs { // Callback for activity_data. This is guaranteed to not invoke any HAL methods. // Memory allocated for the events can be reused after this method returns. // events - Array of activity_event_t s that are reported. // count - size of the array. void (*activity_callback)(const struct activity_recognition_callback_procs* procs, const activity_event_t* events, int count); } activity_recognition_callback_procs_t; typedef struct activity_recognition_device { /** * Common methods of the activity recognition device. This *must* be the first member of * activity_recognition_device as users of this structure will cast a hw_device_t to * activity_recognition_device pointer in contexts where it's known the hw_device_t * references an activity_recognition_device. */ hw_device_t common; /* * Sets the callback to invoke when there are events to report. This call overwrites the * previously registered callback (if any). */ void (*register_activity_callback)(const struct activity_recognition_device* dev, const activity_recognition_callback_procs_t* callback); /* * Activates monitoring of activity transitions. Activities need not be reported as soon as they * are detected. The detected activities are stored in a FIFO and reported in batches when the * "max_batch_report_latency" expires or when the batch FIFO is full. The implementation should * allow the AP to go into suspend mode while the activities are detected and stored in the * batch FIFO. Whenever events need to be reported (like when the FIFO is full or when the * max_batch_report_latency has expired for an activity, event pair), it should wake_up the AP * so that no events are lost. Activities are stored as transitions and they are allowed to * overlap with each other. Each (activity, event_type) pair can be activated or deactivated * independently of the other. The HAL implementation needs to keep track of which pairs are * currently active and needs to detect only those pairs. * * activity_handle - Index of the specific activity that needs to be detected in the list * returned by get_supported_activities_list. * event_type - Specific transition of the activity that needs to be detected. * max_batch_report_latency_ns - a transition can be delayed by at most * “max_batch_report_latency†nanoseconds. * Return 0 on success, negative errno code otherwise. */ int (*enable_activity_event)(const struct activity_recognition_device* dev, uint32_t activity_handle, uint32_t event_type, int64_t max_batch_report_latency_ns); /* * Disables detection of a specific (activity, event_type) pair. */ int (*disable_activity_event)(const struct activity_recognition_device* dev, uint32_t activity_handle, uint32_t event_type); /* * Flush all the batch FIFOs. Report all the activities that were stored in the FIFO so far as * if max_batch_report_latency had expired. This shouldn't change the latency in any way. Add * a flush_complete_event to indicate the end of the FIFO after all events are delivered. * See ACTIVITY_EVENT_FLUSH_COMPLETE for more details. * Return 0 on success, negative errno code otherwise. */ int (*flush)(const struct activity_recognition_device* dev); // Must be set to NULL. void (*reserved_procs[16 - 4])(void); } activity_recognition_device_t; static inline int activity_recognition_open(const hw_module_t* module, activity_recognition_device_t** device) { return module->methods->open(module, ACTIVITY_RECOGNITION_HARDWARE_INTERFACE, (hw_device_t**)device); } static inline int activity_recognition_close(activity_recognition_device_t* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_ACTIVITY_RECOGNITION_INTERFACE_H android-headers-23/21/hardware/audio.h000066400000000000000000000646421264465411000176410ustar00rootroot00000000000000/* * 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_AUDIO_HAL_INTERFACE_H #define ANDROID_AUDIO_HAL_INTERFACE_H #include #include #include #include #include #include #include #include __BEGIN_DECLS /** * The id of this module */ #define AUDIO_HARDWARE_MODULE_ID "audio" /** * Name of the audio devices to open */ #define AUDIO_HARDWARE_INTERFACE "audio_hw_if" /* Use version 0.1 to be compatible with first generation of audio hw module with version_major * hardcoded to 1. No audio module API change. */ #define AUDIO_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define AUDIO_MODULE_API_VERSION_CURRENT AUDIO_MODULE_API_VERSION_0_1 /* First generation of audio devices had version hardcoded to 0. all devices with versions < 1.0 * will be considered of first generation API. */ #define AUDIO_DEVICE_API_VERSION_0_0 HARDWARE_DEVICE_API_VERSION(0, 0) #define AUDIO_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) #define AUDIO_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 0) #define AUDIO_DEVICE_API_VERSION_3_0 HARDWARE_DEVICE_API_VERSION(3, 0) #define AUDIO_DEVICE_API_VERSION_CURRENT AUDIO_DEVICE_API_VERSION_3_0 /* 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" /**************************************/ /** * standard audio parameters that the HAL may need to handle */ /** * 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" #define AUDIO_PARAMETER_VALUE_TTY_VCO "tty_vco" #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 */ #define AUDIO_PARAMETER_KEY_HAC "HACSetting" #define AUDIO_PARAMETER_VALUE_HAC_ON "ON" #define AUDIO_PARAMETER_VALUE_HAC_OFF "OFF" /* A2DP sink address set by framework */ #define AUDIO_PARAMETER_A2DP_SINK_ADDRESS "a2dp_sink_address" /* 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" /** * 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_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" /* Get the HW synchronization source used for an output stream. * Return a valid source (positive integer) or AUDIO_HW_SYNC_INVALID if an error occurs * or no HW sync source is used. */ #define AUDIO_PARAMETER_STREAM_HW_AV_SYNC "hw_av_sync" /** * 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" /**************************************/ /* common audio stream parameters and operations */ struct audio_stream { /** * Return the sampling rate in Hz - eg. 44100. */ uint32_t (*get_sample_rate)(const struct audio_stream *stream); /* currently unused - use set_parameters with key * AUDIO_PARAMETER_STREAM_SAMPLING_RATE */ int (*set_sample_rate)(struct audio_stream *stream, uint32_t rate); /** * Return size of input/output buffer in bytes for this stream - eg. 4800. * It should be a multiple of the frame size. See also get_input_buffer_size. */ size_t (*get_buffer_size)(const struct audio_stream *stream); /** * Return the channel mask - * e.g. AUDIO_CHANNEL_OUT_STEREO or AUDIO_CHANNEL_IN_STEREO */ audio_channel_mask_t (*get_channels)(const struct audio_stream *stream); /** * Return the audio format - e.g. AUDIO_FORMAT_PCM_16_BIT */ audio_format_t (*get_format)(const struct audio_stream *stream); /* currently unused - use set_parameters with key * AUDIO_PARAMETER_STREAM_FORMAT */ int (*set_format)(struct audio_stream *stream, audio_format_t format); /** * Put the audio hardware input/output into standby mode. * Driver should exit from standby mode at the next I/O operation. * Returns 0 on success and <0 on failure. */ int (*standby)(struct audio_stream *stream); /** dump the state of the audio input/output device */ int (*dump)(const struct audio_stream *stream, int fd); /** Return the set of device(s) which this stream is connected to */ audio_devices_t (*get_device)(const struct audio_stream *stream); /** * Currently unused - set_device() corresponds to set_parameters() with key * AUDIO_PARAMETER_STREAM_ROUTING for both input and output. * AUDIO_PARAMETER_STREAM_INPUT_SOURCE is an additional information used by * input streams only. */ int (*set_device)(struct audio_stream *stream, audio_devices_t device); /** * set/get audio stream parameters. The function accepts a list of * parameter key value pairs in the form: key1=value1;key2=value2;... * * Some keys are reserved for standard parameters (See AudioParameter class) * * If the implementation does not accept a parameter change while * the output is active but the parameter is acceptable otherwise, it must * return -ENOSYS. * * The audio flinger will put the stream in standby and then change the * parameter value. */ int (*set_parameters)(struct audio_stream *stream, const char *kv_pairs); /* * Returns a pointer to a heap allocated string. The caller is responsible * for freeing the memory for it using free(). */ char * (*get_parameters)(const struct audio_stream *stream, const char *keys); int (*add_audio_effect)(const struct audio_stream *stream, effect_handle_t effect); int (*remove_audio_effect)(const struct audio_stream *stream, effect_handle_t effect); }; typedef struct audio_stream audio_stream_t; /* type of asynchronous write callback events. Mutually exclusive */ typedef enum { STREAM_CBK_EVENT_WRITE_READY, /* non blocking write completed */ STREAM_CBK_EVENT_DRAIN_READY /* drain completed */ } stream_callback_event_t; typedef int (*stream_callback_t)(stream_callback_event_t event, void *param, void *cookie); /* type of drain requested to audio_stream_out->drain(). Mutually exclusive */ typedef enum { AUDIO_DRAIN_ALL, /* drain() returns when all data has been played */ AUDIO_DRAIN_EARLY_NOTIFY /* drain() returns a short time before all data from the current track has been played to give time for gapless track switch */ } audio_drain_type_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 * as users of this structure will cast a audio_stream to audio_stream_out pointer in contexts * where it's known the audio_stream references an audio_stream_out. */ struct audio_stream common; /** * Return the audio hardware driver estimated latency in milliseconds. */ uint32_t (*get_latency)(const struct audio_stream_out *stream); /** * Use this method in situations where audio mixing is done in the * hardware. This method serves as a direct interface with hardware, * allowing you to directly set the volume as apposed to via the framework. * This method might produce multiple PCM outputs or hardware accelerated * codecs, such as MP3 or AAC. */ int (*set_volume)(struct audio_stream_out *stream, float left, float right); /** * Write audio buffer to driver. Returns number of bytes written, or a * negative status_t. If at least one frame was written successfully prior to the error, * it is suggested that the driver return that successful (short) byte count * and then return an error in the subsequent call. * * If set_callback() has previously been called to enable non-blocking mode * the write() is not allowed to block. It must write only the number of * bytes that currently fit in the driver/hardware buffer and then return * this byte count. If this is less than the requested write size the * callback function must be called when more space is available in the * driver/hardware buffer. */ ssize_t (*write)(struct audio_stream_out *stream, const void* buffer, size_t bytes); /* return the number of audio frames written by the audio dsp to DAC since * the output has exited standby */ int (*get_render_position)(const struct audio_stream_out *stream, uint32_t *dsp_frames); /** * get the local time at which the next write to the audio driver will be presented. * The units are microseconds, where the epoch is decided by the local audio HAL. */ int (*get_next_write_timestamp)(const struct audio_stream_out *stream, int64_t *timestamp); /** * set the callback function for notifying completion of non-blocking * write and drain. * Calling this function implies that all future write() and drain() * must be non-blocking and use the callback to signal completion. */ int (*set_callback)(struct audio_stream_out *stream, stream_callback_t callback, void *cookie); /** * Notifies to the audio driver to stop playback however the queued buffers are * retained by the hardware. Useful for implementing pause/resume. Empty implementation * if not supported however should be implemented for hardware with non-trivial * latency. In the pause state audio hardware could still be using power. User may * consider calling suspend after a timeout. * * Implementation of this function is mandatory for offloaded playback. */ int (*pause)(struct audio_stream_out* stream); /** * Notifies to the audio driver to resume playback following a pause. * Returns error if called without matching pause. * * Implementation of this function is mandatory for offloaded playback. */ int (*resume)(struct audio_stream_out* stream); /** * Requests notification when data buffered by the driver/hardware has * been played. If set_callback() has previously been called to enable * non-blocking mode, the drain() must not block, instead it should return * quickly and completion of the drain is notified through the callback. * If set_callback() has not been called, the drain() must block until * completion. * If type==AUDIO_DRAIN_ALL, the drain completes when all previously written * data has been played. * If type==AUDIO_DRAIN_EARLY_NOTIFY, the drain completes shortly before all * data for the current track has played to allow time for the framework * to perform a gapless track switch. * * Drain must return immediately on stop() and flush() call * * Implementation of this function is mandatory for offloaded playback. */ int (*drain)(struct audio_stream_out* stream, audio_drain_type_t type ); /** * Notifies to the audio driver to flush the queued data. Stream must already * be paused before calling flush(). * * Implementation of this function is mandatory for offloaded playback. */ int (*flush)(struct audio_stream_out* stream); /** * Return a recent count of the number of audio frames presented to an external observer. * This excludes frames which have been written but are still in the pipeline. * The count is not reset to zero when output enters standby. * Also returns the value of CLOCK_MONOTONIC as of this presentation count. * The returned count is expected to be 'recent', * but does not need to be the most recent possible value. * However, the associated time should correspond to whatever count is returned. * Example: assume that N+M frames have been presented, where M is a 'small' number. * Then it is permissible to return N instead of N+M, * and the timestamp should correspond to N rather than N+M. * The terms 'recent' and 'small' are not defined. * They reflect the quality of the implementation. * * 3.0 and higher only. */ int (*get_presentation_position)(const struct audio_stream_out *stream, uint64_t *frames, struct timespec *timestamp); }; typedef struct audio_stream_out audio_stream_out_t; struct audio_stream_in { /** * Common methods of the audio stream in. This *must* be the first member of audio_stream_in * as users of this structure will cast a audio_stream to audio_stream_in pointer in contexts * where it's known the audio_stream references an audio_stream_in. */ struct audio_stream common; /** set the input gain for the audio driver. This method is for * for future use */ int (*set_gain)(struct audio_stream_in *stream, float gain); /** Read audio buffer in from audio driver. Returns number of bytes read, or a * negative status_t. If at least one frame was read prior to the error, * read should return that byte count and then return an error in the subsequent call. */ ssize_t (*read)(struct audio_stream_in *stream, void* buffer, size_t bytes); /** * Return the amount of input frames lost in the audio driver since the * last call of this function. * Audio driver is expected to reset the value to 0 and restart counting * upon returning the current value by this function call. * Such loss typically occurs when the user space process is blocked * longer than the capacity of audio driver buffers. * * Unit: the number of input audio frames */ uint32_t (*get_input_frames_lost)(struct audio_stream_in *stream); }; typedef struct audio_stream_in audio_stream_in_t; /** * return the frame size (number of bytes per sample). * * Deprecated: use audio_stream_out_frame_size() or audio_stream_in_frame_size() instead. */ __attribute__((__deprecated__)) static inline size_t audio_stream_frame_size(const struct audio_stream *s) { size_t chan_samp_sz; audio_format_t format = s->get_format(s); if (audio_is_linear_pcm(format)) { chan_samp_sz = audio_bytes_per_sample(format); return popcount(s->get_channels(s)) * chan_samp_sz; } return sizeof(int8_t); } /** * return the frame size (number of bytes per sample) of an output stream. */ static inline size_t audio_stream_out_frame_size(const struct audio_stream_out *s) { size_t chan_samp_sz; audio_format_t format = s->common.get_format(&s->common); if (audio_is_linear_pcm(format)) { chan_samp_sz = audio_bytes_per_sample(format); return audio_channel_count_from_out_mask(s->common.get_channels(&s->common)) * chan_samp_sz; } return sizeof(int8_t); } /** * return the frame size (number of bytes per sample) of an input stream. */ static inline size_t audio_stream_in_frame_size(const struct audio_stream_in *s) { size_t chan_samp_sz; audio_format_t format = s->common.get_format(&s->common); if (audio_is_linear_pcm(format)) { chan_samp_sz = audio_bytes_per_sample(format); return audio_channel_count_from_in_mask(s->common.get_channels(&s->common)) * chan_samp_sz; } return sizeof(int8_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. */ struct audio_module { struct hw_module_t common; }; struct audio_hw_device { /** * Common methods of the audio device. This *must* be the first member of audio_hw_device * as users of this structure will cast a hw_device_t to audio_hw_device pointer in contexts * where it's known the hw_device_t references an audio_hw_device. */ struct hw_device_t common; /** * used by audio flinger to enumerate what devices are supported by * each audio_hw_device implementation. * * Return value is a bitmask of 1 or more values of audio_devices_t * * NOTE: audio HAL implementations starting with * AUDIO_DEVICE_API_VERSION_2_0 do not implement this function. * All supported devices should be listed in audio_policy.conf * file and the audio policy manager must choose the appropriate * audio module based on information in this file. */ uint32_t (*get_supported_devices)(const struct audio_hw_device *dev); /** * check to see if the audio hardware interface has been initialized. * returns 0 on success, -ENODEV on failure. */ int (*init_check)(const struct audio_hw_device *dev); /** set the audio volume of a voice call. Range is between 0.0 and 1.0 */ int (*set_voice_volume)(struct audio_hw_device *dev, float volume); /** * set the audio volume for all audio activities other than voice call. * Range between 0.0 and 1.0. If any value other than 0 is returned, * the software mixer will emulate this capability. */ int (*set_master_volume)(struct audio_hw_device *dev, float volume); /** * Get the current master volume value for the HAL, if the HAL supports * master volume control. AudioFlinger will query this value from the * primary audio HAL when the service starts and use the value for setting * the initial master volume across all HALs. HALs which do not support * this method may leave it set to NULL. */ int (*get_master_volume)(struct audio_hw_device *dev, float *volume); /** * set_mode is called when the audio mode changes. AUDIO_MODE_NORMAL mode * is for standard audio playback, AUDIO_MODE_RINGTONE when a ringtone is * playing, and AUDIO_MODE_IN_CALL when a call is in progress. */ int (*set_mode)(struct audio_hw_device *dev, audio_mode_t mode); /* mic mute */ int (*set_mic_mute)(struct audio_hw_device *dev, bool state); int (*get_mic_mute)(const struct audio_hw_device *dev, bool *state); /* set/get global audio parameters */ int (*set_parameters)(struct audio_hw_device *dev, const char *kv_pairs); /* * Returns a pointer to a heap allocated string. The caller is responsible * for freeing the memory for it using free(). */ char * (*get_parameters)(const struct audio_hw_device *dev, const char *keys); /* Returns audio input buffer size according to parameters passed or * 0 if one of the parameters is not supported. * See also get_buffer_size which is for a particular stream. */ size_t (*get_input_buffer_size)(const struct audio_hw_device *dev, const struct audio_config *config); /** This method creates and opens the audio hardware output stream. * The "address" parameter qualifies the "devices" audio device type if needed. * The format format depends on the device type: * - Bluetooth devices use the MAC address of the device in the form "00:11:22:AA:BB:CC" * - USB devices use the ALSA card and device numbers in the form "card=X;device=Y" * - Other devices may use a number or any other string. */ int (*open_output_stream)(struct audio_hw_device *dev, audio_io_handle_t handle, audio_devices_t devices, audio_output_flags_t flags, struct audio_config *config, struct audio_stream_out **stream_out, const char *address); void (*close_output_stream)(struct audio_hw_device *dev, struct audio_stream_out* stream_out); /** This method creates and opens the audio hardware input stream */ int (*open_input_stream)(struct audio_hw_device *dev, audio_io_handle_t handle, audio_devices_t devices, struct audio_config *config, struct audio_stream_in **stream_in, audio_input_flags_t flags, const char *address, audio_source_t source); void (*close_input_stream)(struct audio_hw_device *dev, struct audio_stream_in *stream_in); /** This method dumps the state of the audio hardware */ int (*dump)(const struct audio_hw_device *dev, int fd); /** * set the audio mute status for all audio activities. If any value other * than 0 is returned, the software mixer will emulate this capability. */ int (*set_master_mute)(struct audio_hw_device *dev, bool mute); /** * Get the current master mute status for the HAL, if the HAL supports * master mute control. AudioFlinger will query this value from the primary * audio HAL when the service starts and use the value for setting the * initial master mute across all HALs. HALs which do not support this * method may leave it set to NULL. */ int (*get_master_mute)(struct audio_hw_device *dev, bool *mute); /** * Routing control */ /* Creates an audio patch between several source and sink ports. * The handle is allocated by the HAL and should be unique for this * audio HAL module. */ int (*create_audio_patch)(struct audio_hw_device *dev, unsigned int num_sources, const struct audio_port_config *sources, unsigned int num_sinks, const struct audio_port_config *sinks, audio_patch_handle_t *handle); /* Release an audio patch */ int (*release_audio_patch)(struct audio_hw_device *dev, audio_patch_handle_t handle); /* Fills the list of supported attributes for a given audio port. * As input, "port" contains the information (type, role, address etc...) * needed by the HAL to identify the port. * As output, "port" contains possible attributes (sampling rates, formats, * channel masks, gain controllers...) for this port. */ int (*get_audio_port)(struct audio_hw_device *dev, struct audio_port *port); /* Set audio port configuration */ int (*set_audio_port_config)(struct audio_hw_device *dev, const struct audio_port_config *config); }; typedef struct audio_hw_device audio_hw_device_t; /** convenience API for opening and closing a supported device */ 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); } static inline int audio_hw_device_close(struct audio_hw_device* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_AUDIO_INTERFACE_H android-headers-23/21/hardware/audio_alsaops.h000066400000000000000000000061121264465411000213470ustar00rootroot00000000000000/* * 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. */ /* This file contains shared utility functions to handle the tinyalsa * implementation for Android internal audio, generally in the hardware layer. * Some routines may log a fatal error on failure, as noted. */ #ifndef ANDROID_AUDIO_ALSAOPS_H #define ANDROID_AUDIO_ALSAOPS_H #include #include #include __BEGIN_DECLS /* Converts audio_format to pcm_format. * Parameters: * format the audio_format_t to convert * * Logs a fatal error if format is not a valid convertible audio_format_t. */ static inline enum pcm_format pcm_format_from_audio_format(audio_format_t format) { switch (format) { #ifdef HAVE_BIG_ENDIAN case AUDIO_FORMAT_PCM_16_BIT: return PCM_FORMAT_S16_BE; case AUDIO_FORMAT_PCM_24_BIT_PACKED: return PCM_FORMAT_S24_3BE; case AUDIO_FORMAT_PCM_32_BIT: return PCM_FORMAT_S32_BE; case AUDIO_FORMAT_PCM_8_24_BIT: return PCM_FORMAT_S24_BE; #else case AUDIO_FORMAT_PCM_16_BIT: return PCM_FORMAT_S16_LE; case AUDIO_FORMAT_PCM_24_BIT_PACKED: return PCM_FORMAT_S24_3LE; case AUDIO_FORMAT_PCM_32_BIT: return PCM_FORMAT_S32_LE; case AUDIO_FORMAT_PCM_8_24_BIT: return PCM_FORMAT_S24_LE; #endif case AUDIO_FORMAT_PCM_FLOAT: /* there is no equivalent for float */ default: LOG_ALWAYS_FATAL("pcm_format_from_audio_format: invalid audio format %#x", format); return 0; } } /* Converts pcm_format to audio_format. * Parameters: * format the pcm_format to convert * * Logs a fatal error if format is not a valid convertible pcm_format. */ static inline audio_format_t audio_format_from_pcm_format(enum pcm_format format) { switch (format) { #ifdef HAVE_BIG_ENDIAN case PCM_FORMAT_S16_BE: return AUDIO_FORMAT_PCM_16_BIT; case PCM_FORMAT_S24_3BE: return AUDIO_FORMAT_PCM_24_BIT_PACKED; case PCM_FORMAT_S24_BE: return AUDIO_FORMAT_PCM_8_24_BIT; case PCM_FORMAT_S32_BE: return AUDIO_FORMAT_PCM_32_BIT; #else case PCM_FORMAT_S16_LE: return AUDIO_FORMAT_PCM_16_BIT; case PCM_FORMAT_S24_3LE: return AUDIO_FORMAT_PCM_24_BIT_PACKED; case PCM_FORMAT_S24_LE: return AUDIO_FORMAT_PCM_8_24_BIT; case PCM_FORMAT_S32_LE: return AUDIO_FORMAT_PCM_32_BIT; #endif default: LOG_ALWAYS_FATAL("audio_format_from_pcm_format: invalid pcm format %#x", format); return 0; } } __END_DECLS #endif /* ANDROID_AUDIO_ALSAOPS_H */ android-headers-23/21/hardware/audio_effect.h000066400000000000000000001476671264465411000211660ustar00rootroot00000000000000/* * 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_AUDIO_EFFECT_H #define ANDROID_AUDIO_EFFECT_H #include #include #include #include #include #include #include __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 // +---------------------------+-----------+----------------------------------- // 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) #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 ///////////////////////////////////////////////// // Effect control interface version 2.0 #define EFFECT_CONTROL_API_VERSION EFFECT_MAKE_API_VERSION(2,0) // Effect control interface structure: effect_interface_s // The effect control interface is exposed by each effect engine implementation. It consists of // a set of functions controlling the configuration, activation and process of the engine. // The functions are grouped in a structure of type effect_interface_s. // // Effect control interface handle: effect_handle_t // The effect_handle_t serves two purposes regarding the implementation of the effect engine: // - 1 it is the address of a pointer to an effect_interface_s structure where the functions // of the effect control API for a particular effect are located. // - 2 it is the address of the context of a particular effect instance. // A typical implementation in the effect library would define a structure as follows: // struct effect_module_s { // const struct effect_interface_s *itfe; // effect_config_t config; // effect_context_t context; // } // The implementation of EffectCreate() function would then allocate a structure of this // 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 { //////////////////////////////////////////////////////////////////////////////// // // Function: process // // Description: Effect process function. Takes input samples as specified // (count and location) in input buffer descriptor and output processed // samples as specified in output buffer descriptor. If the buffer descriptor // is not specified the function must use either the buffer or the // buffer provider function installed by the EFFECT_CMD_SET_CONFIG command. // The effect framework will call the process() function after the EFFECT_CMD_ENABLE // command is received and until the EFFECT_CMD_DISABLE is received. When the engine // receives the EFFECT_CMD_DISABLE command it should turn off the effect gracefully // and when done indicate that it is OK to stop calling the process() function by // returning the -ENODATA status. // // NOTE: the process() function implementation should be "real-time safe" that is // it should not perform blocking calls: malloc/free, sleep, read/write/open/close, // pthread_cond_wait/pthread_mutex_lock... // // Input: // self: handle to the effect interface this function // is called on. // inBuffer: buffer descriptor indicating where to read samples to process. // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG command. // // outBuffer: buffer descriptor indicating where to write processed samples. // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG command. // // Output: // returned value: 0 successful operation // -ENODATA the engine has finished the disable phase and the framework // can stop calling process() // -EINVAL invalid interface handle or // invalid input/output buffer description //////////////////////////////////////////////////////////////////////////////// int32_t (*process)(effect_handle_t self, audio_buffer_t *inBuffer, audio_buffer_t *outBuffer); //////////////////////////////////////////////////////////////////////////////// // // Function: command // // Description: Send a command and receive a response to/from effect engine. // // Input: // self: handle to the effect interface this function // is called on. // cmdCode: command code: the command can be a standardized command defined in // effect_command_e (see below) or a proprietary command. // cmdSize: size of command in bytes // pCmdData: pointer to command data // pReplyData: pointer to reply data // // Input/Output: // replySize: maximum size of reply data as input // actual size of reply data as output // // Output: // returned value: 0 successful operation // -EINVAL invalid interface handle or // invalid command/reply size or format according to command code // The return code should be restricted to indicate problems related to the this // API specification. Status related to the execution of a particular command should be // indicated as part of the reply field. // // *pReplyData updated with command response // //////////////////////////////////////////////////////////////////////////////// int32_t (*command)(effect_handle_t self, uint32_t cmdCode, uint32_t cmdSize, void *pCmdData, uint32_t *replySize, void *pReplyData); //////////////////////////////////////////////////////////////////////////////// // // Function: get_descriptor // // Description: Returns the effect descriptor // // Input: // self: handle to the effect interface this function // is called on. // // Input/Output: // pDescriptor: address where to return the effect descriptor. // // Output: // returned value: 0 successful operation. // -EINVAL invalid interface handle or invalid pDescriptor // *pDescriptor: updated with the effect descriptor. // //////////////////////////////////////////////////////////////////////////////// int32_t (*get_descriptor)(effect_handle_t self, effect_descriptor_t *pDescriptor); //////////////////////////////////////////////////////////////////////////////// // // Function: process_reverse // // Description: Process reverse stream function. This function is used to pass // a reference stream to the effect engine. If the engine does not need a reference // stream, this function pointer can be set to NULL. // This function would typically implemented by an Echo Canceler. // // Input: // self: handle to the effect interface this function // is called on. // inBuffer: buffer descriptor indicating where to read samples to process. // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG_REVERSE command. // // outBuffer: buffer descriptor indicating where to write processed samples. // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG_REVERSE command. // If the buffer and buffer provider in the configuration received by // EFFECT_CMD_SET_CONFIG_REVERSE are also NULL, do not return modified reverse // stream data // // Output: // returned value: 0 successful operation // -ENODATA the engine has finished the disable phase and the framework // can stop calling process_reverse() // -EINVAL invalid interface handle or // invalid input/output buffer description //////////////////////////////////////////////////////////////////////////////// int32_t (*process_reverse)(effect_handle_t self, audio_buffer_t *inBuffer, 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; // 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 ///////////////////////////////////////////////// // Effect library interface version 3.0 // Note that EffectsFactory.c only checks the major version component, so changes to the minor // number can only be used for fully backwards compatible changes #define EFFECT_LIBRARY_API_VERSION EFFECT_MAKE_API_VERSION(3,0) #define AUDIO_EFFECT_LIBRARY_TAG ((('A') << 24) | (('E') << 16) | (('L') << 8) | ('T')) // Every effect library must have a data structure named AUDIO_EFFECT_LIBRARY_INFO_SYM // and the fields of this data structure must begin with audio_effect_library_t typedef struct audio_effect_library_s { // tag must be initialized to AUDIO_EFFECT_LIBRARY_TAG uint32_t tag; // Version of the effect library API : 0xMMMMmmmm MMMM: Major, mmmm: minor uint32_t version; // Name of this library const char *name; // Author/owner/implementor of the library const char *implementor; //////////////////////////////////////////////////////////////////////////////// // // Function: create_effect // // Description: Creates an effect engine of the specified implementation uuid and // returns an effect control interface on this engine. The function will allocate the // resources for an instance of the requested effect engine and return // a handle on the effect control interface. // // Input: // uuid: pointer to the effect uuid. // sessionId: audio session to which this effect instance will be attached. All effects // created with the same session ID are connected in series and process the same signal // stream. Knowing that two effects are part of the same effect chain can help the // library implement some kind of optimizations. // ioId: identifies the output or input stream this effect is directed to at audio HAL. // For future use especially with tunneled HW accelerated effects // // Input/Output: // pHandle: address where to return the effect interface handle. // // Output: // returned value: 0 successful operation. // -ENODEV library failed to initialize // -EINVAL invalid pEffectUuid or pHandle // -ENOENT no effect with this uuid found // *pHandle: updated with the effect interface handle. // //////////////////////////////////////////////////////////////////////////////// int32_t (*create_effect)(const effect_uuid_t *uuid, int32_t sessionId, int32_t ioId, effect_handle_t *pHandle); //////////////////////////////////////////////////////////////////////////////// // // Function: release_effect // // Description: Releases the effect engine whose handle is given as argument. // All resources allocated to this particular instance of the effect are // released. // // Input: // handle: handle on the effect interface to be released. // // Output: // returned value: 0 successful operation. // -ENODEV library failed to initialize // -EINVAL invalid interface handle // //////////////////////////////////////////////////////////////////////////////// int32_t (*release_effect)(effect_handle_t handle); //////////////////////////////////////////////////////////////////////////////// // // Function: get_descriptor // // Description: Returns the descriptor of the effect engine which implementation UUID is // given as argument. // // Input/Output: // uuid: pointer to the effect uuid. // pDescriptor: address where to return the effect descriptor. // // Output: // returned value: 0 successful operation. // -ENODEV library failed to initialize // -EINVAL invalid pDescriptor or uuid // *pDescriptor: updated with the effect descriptor. // //////////////////////////////////////////////////////////////////////////////// int32_t (*get_descriptor)(const effect_uuid_t *uuid, effect_descriptor_t *pDescriptor); } audio_effect_library_t; // Name of the hal_module_info #define AUDIO_EFFECT_LIBRARY_INFO_SYM AELI // Name of the hal_module_info as a string #define AUDIO_EFFECT_LIBRARY_INFO_SYM_AS_STR "AELI" __END_DECLS #endif // ANDROID_AUDIO_EFFECT_H android-headers-23/21/hardware/audio_policy.h000066400000000000000000000452051264465411000212120ustar00rootroot00000000000000/* * 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_AUDIO_POLICY_INTERFACE_H #define ANDROID_AUDIO_POLICY_INTERFACE_H #include #include #include #include #include #include __BEGIN_DECLS /** * The id of this module */ #define AUDIO_POLICY_HARDWARE_MODULE_ID "audio_policy" /** * Name of the audio devices to open */ #define AUDIO_POLICY_INTERFACE "policy" /* ---------------------------------------------------------------------------- */ /* * The audio_policy and audio_policy_service_ops structs define the * communication interfaces between the platform specific audio policy manager * and Android generic audio policy manager. * The platform specific audio policy manager must implement methods of the * audio_policy struct. * This implementation makes use of the audio_policy_service_ops to control * the activity and configuration of audio input and output streams. * * The platform specific audio policy manager is in charge of the audio * routing and volume control policies for a given platform. * The main roles of this module are: * - keep track of current system state (removable device connections, phone * state, user requests...). * System state changes and user actions are notified to audio policy * manager with methods of the audio_policy. * * - process get_output() queries received when AudioTrack objects are * created: Those queries return a handler on an output that has been * selected, configured and opened by the audio policy manager and that * must be used by the AudioTrack when registering to the AudioFlinger * with the createTrack() method. * When the AudioTrack object is released, a release_output() query * is received and the audio policy manager can decide to close or * reconfigure the output depending on other streams using this output and * current system state. * * - similarly process get_input() and release_input() queries received from * AudioRecord objects and configure audio inputs. * - process volume control requests: the stream volume is converted from * an index value (received from UI) to a float value applicable to each * output as a function of platform specific settings and current output * route (destination device). It also make sure that streams are not * muted if not allowed (e.g. camera shutter sound in some countries). */ /* XXX: this should be defined OUTSIDE of frameworks/base */ struct effect_descriptor_s; struct audio_policy { /* * configuration functions */ /* indicate a change in device connection status */ int (*set_device_connection_state)(struct audio_policy *pol, audio_devices_t device, audio_policy_dev_state_t state, const char *device_address); /* retrieve a device connection status */ audio_policy_dev_state_t (*get_device_connection_state)( const struct audio_policy *pol, audio_devices_t device, const char *device_address); /* indicate a change in phone state. Valid phones states are defined * by audio_mode_t */ void (*set_phone_state)(struct audio_policy *pol, audio_mode_t state); /* deprecated, never called (was "indicate a change in ringer mode") */ void (*set_ringer_mode)(struct audio_policy *pol, uint32_t mode, uint32_t mask); /* force using a specific device category for the specified usage */ void (*set_force_use)(struct audio_policy *pol, audio_policy_force_use_t usage, audio_policy_forced_cfg_t config); /* retrieve current device category forced for a given usage */ audio_policy_forced_cfg_t (*get_force_use)(const struct audio_policy *pol, audio_policy_force_use_t usage); /* if can_mute is true, then audio streams that are marked ENFORCED_AUDIBLE * can still be muted. */ void (*set_can_mute_enforced_audible)(struct audio_policy *pol, bool can_mute); /* check proper initialization */ int (*init_check)(const struct audio_policy *pol); /* * Audio routing query functions */ /* request an output appropriate for playback of the supplied stream type and * parameters */ audio_io_handle_t (*get_output)(struct audio_policy *pol, audio_stream_type_t stream, uint32_t samplingRate, audio_format_t format, audio_channel_mask_t channelMask, audio_output_flags_t flags, const audio_offload_info_t *offloadInfo); /* indicates to the audio policy manager that the output starts being used * by corresponding stream. */ int (*start_output)(struct audio_policy *pol, audio_io_handle_t output, audio_stream_type_t stream, int session); /* indicates to the audio policy manager that the output stops being used * by corresponding stream. */ int (*stop_output)(struct audio_policy *pol, audio_io_handle_t output, audio_stream_type_t stream, int session); /* releases the output. */ void (*release_output)(struct audio_policy *pol, audio_io_handle_t output); /* request an input appropriate for record from the supplied device with * supplied parameters. */ audio_io_handle_t (*get_input)(struct audio_policy *pol, audio_source_t inputSource, uint32_t samplingRate, audio_format_t format, audio_channel_mask_t channelMask, audio_in_acoustics_t acoustics); /* indicates to the audio policy manager that the input starts being used */ int (*start_input)(struct audio_policy *pol, audio_io_handle_t input); /* indicates to the audio policy manager that the input stops being used. */ int (*stop_input)(struct audio_policy *pol, audio_io_handle_t input); /* releases the input. */ void (*release_input)(struct audio_policy *pol, audio_io_handle_t input); /* * volume control functions */ /* initialises stream volume conversion parameters by specifying volume * index range. The index range for each stream is defined by AudioService. */ void (*init_stream_volume)(struct audio_policy *pol, audio_stream_type_t stream, int index_min, int index_max); /* sets the new stream volume at a level corresponding to the supplied * index. The index is within the range specified by init_stream_volume() */ int (*set_stream_volume_index)(struct audio_policy *pol, audio_stream_type_t stream, int index); /* retrieve current volume index for the specified stream */ int (*get_stream_volume_index)(const struct audio_policy *pol, audio_stream_type_t stream, int *index); /* sets the new stream volume at a level corresponding to the supplied * index for the specified device. * The index is within the range specified by init_stream_volume() */ int (*set_stream_volume_index_for_device)(struct audio_policy *pol, audio_stream_type_t stream, int index, audio_devices_t device); /* retrieve current volume index for the specified stream for the specified device */ int (*get_stream_volume_index_for_device)(const struct audio_policy *pol, audio_stream_type_t stream, int *index, audio_devices_t device); /* return the strategy corresponding to a given stream type */ uint32_t (*get_strategy_for_stream)(const struct audio_policy *pol, audio_stream_type_t stream); /* return the enabled output devices for the given stream type */ audio_devices_t (*get_devices_for_stream)(const struct audio_policy *pol, audio_stream_type_t stream); /* Audio effect management */ audio_io_handle_t (*get_output_for_effect)(struct audio_policy *pol, const struct effect_descriptor_s *desc); int (*register_effect)(struct audio_policy *pol, const struct effect_descriptor_s *desc, audio_io_handle_t output, uint32_t strategy, int session, int id); int (*unregister_effect)(struct audio_policy *pol, int id); int (*set_effect_enabled)(struct audio_policy *pol, int id, bool enabled); bool (*is_stream_active)(const struct audio_policy *pol, audio_stream_type_t stream, uint32_t in_past_ms); bool (*is_stream_active_remotely)(const struct audio_policy *pol, audio_stream_type_t stream, uint32_t in_past_ms); bool (*is_source_active)(const struct audio_policy *pol, audio_source_t source); /* dump state */ int (*dump)(const struct audio_policy *pol, int fd); /* check if offload is possible for given sample rate, bitrate, duration, ... */ bool (*is_offload_supported)(const struct audio_policy *pol, const audio_offload_info_t *info); }; struct audio_policy_service_ops { /* * Audio output Control functions */ /* Opens an audio output with the requested parameters. * * The parameter values can indicate to use the default values in case the * audio policy manager has no specific requirements for the output being * opened. * * When the function returns, the parameter values reflect the actual * values used by the audio hardware output stream. * * The audio policy manager can check if the proposed parameters are * suitable or not and act accordingly. */ audio_io_handle_t (*open_output)(void *service, audio_devices_t *pDevices, uint32_t *pSamplingRate, audio_format_t *pFormat, audio_channel_mask_t *pChannelMask, uint32_t *pLatencyMs, audio_output_flags_t flags); /* creates a special output that is duplicated to the two outputs passed as * arguments. The duplication is performed by * a special mixer thread in the AudioFlinger. */ audio_io_handle_t (*open_duplicate_output)(void *service, audio_io_handle_t output1, audio_io_handle_t output2); /* closes the output stream */ int (*close_output)(void *service, audio_io_handle_t output); /* suspends the output. * * When an output is suspended, the corresponding audio hardware output * stream is placed in standby and the AudioTracks attached to the mixer * thread are still processed but the output mix is discarded. */ int (*suspend_output)(void *service, audio_io_handle_t output); /* restores a suspended output. */ int (*restore_output)(void *service, audio_io_handle_t output); /* */ /* Audio input Control functions */ /* */ /* opens an audio input * deprecated - new implementations should use open_input_on_module, * and the acoustics parameter is ignored */ audio_io_handle_t (*open_input)(void *service, audio_devices_t *pDevices, uint32_t *pSamplingRate, audio_format_t *pFormat, audio_channel_mask_t *pChannelMask, audio_in_acoustics_t acoustics); /* closes an audio input */ int (*close_input)(void *service, audio_io_handle_t input); /* */ /* misc control functions */ /* */ /* set a stream volume for a particular output. * * For the same user setting, a given stream type can have different * volumes for each output (destination device) it is attached to. */ int (*set_stream_volume)(void *service, audio_stream_type_t stream, float volume, audio_io_handle_t output, int delay_ms); /* invalidate a stream type, causing a reroute to an unspecified new output */ int (*invalidate_stream)(void *service, audio_stream_type_t stream); /* function enabling to send proprietary informations directly from audio * policy manager to audio hardware interface. */ void (*set_parameters)(void *service, audio_io_handle_t io_handle, const char *kv_pairs, int delay_ms); /* function enabling to receive proprietary informations directly from * audio hardware interface to audio policy manager. * * Returns a pointer to a heap allocated string. The caller is responsible * for freeing the memory for it using free(). */ char * (*get_parameters)(void *service, audio_io_handle_t io_handle, const char *keys); /* request the playback of a tone on the specified stream. * used for instance to replace notification sounds when playing over a * telephony device during a phone call. */ int (*start_tone)(void *service, audio_policy_tone_t tone, audio_stream_type_t stream); int (*stop_tone)(void *service); /* set down link audio volume. */ int (*set_voice_volume)(void *service, float volume, int delay_ms); /* move effect to the specified output */ int (*move_effects)(void *service, int session, audio_io_handle_t src_output, audio_io_handle_t dst_output); /* loads an audio hw module. * * The module name passed is the base name of the HW module library, e.g "primary" or "a2dp". * The function returns a handle on the module that will be used to specify a particular * module when calling open_output_on_module() or open_input_on_module() */ audio_module_handle_t (*load_hw_module)(void *service, const char *name); /* Opens an audio output on a particular HW module. * * Same as open_output() but specifying a specific HW module on which the output must be opened. */ audio_io_handle_t (*open_output_on_module)(void *service, audio_module_handle_t module, audio_devices_t *pDevices, uint32_t *pSamplingRate, audio_format_t *pFormat, audio_channel_mask_t *pChannelMask, uint32_t *pLatencyMs, audio_output_flags_t flags, const audio_offload_info_t *offloadInfo); /* Opens an audio input on a particular HW module. * * Same as open_input() but specifying a specific HW module on which the input must be opened. * Also removed deprecated acoustics parameter */ audio_io_handle_t (*open_input_on_module)(void *service, audio_module_handle_t module, audio_devices_t *pDevices, uint32_t *pSamplingRate, audio_format_t *pFormat, audio_channel_mask_t *pChannelMask); }; /**********************************************************************/ /** * 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 audio_policy_module { struct hw_module_t common; } audio_policy_module_t; struct audio_policy_device { /** * Common methods of the audio policy device. This *must* be the first member of * audio_policy_device as users of this structure will cast a hw_device_t to * audio_policy_device pointer in contexts where it's known the hw_device_t references an * audio_policy_device. */ struct hw_device_t common; int (*create_audio_policy)(const struct audio_policy_device *device, struct audio_policy_service_ops *aps_ops, void *service, struct audio_policy **ap); int (*destroy_audio_policy)(const struct audio_policy_device *device, struct audio_policy *ap); }; /** convenience API for opening and closing a supported device */ static inline int audio_policy_dev_open(const hw_module_t* module, struct audio_policy_device** device) { return module->methods->open(module, AUDIO_POLICY_INTERFACE, (hw_device_t**)device); } static inline int audio_policy_dev_close(struct audio_policy_device* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_AUDIO_POLICY_INTERFACE_H android-headers-23/21/hardware/bluetooth.h000066400000000000000000000442401264465411000205350ustar00rootroot00000000000000/* * 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_BLUETOOTH_H #define ANDROID_INCLUDE_BLUETOOTH_H #include #include #include #include #include __BEGIN_DECLS /** * The Bluetooth Hardware Module ID */ #define BT_HARDWARE_MODULE_ID "bluetooth" #define BT_STACK_MODULE_ID "bluetooth" #define BT_STACK_TEST_MODULE_ID "bluetooth_test" /* Bluetooth profile interface IDs */ #define BT_PROFILE_HANDSFREE_ID "handsfree" #define BT_PROFILE_HANDSFREE_CLIENT_ID "handsfree_client" #define BT_PROFILE_ADVANCED_AUDIO_ID "a2dp" #define BT_PROFILE_ADVANCED_AUDIO_SINK_ID "a2dp_sink" #define BT_PROFILE_HEALTH_ID "health" #define BT_PROFILE_SOCKETS_ID "socket" #define BT_PROFILE_HIDHOST_ID "hidhost" #define BT_PROFILE_PAN_ID "pan" #define BT_PROFILE_MAP_CLIENT_ID "map_client" #define BT_PROFILE_GATT_ID "gatt" #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 Device Name */ typedef struct { uint8_t name[249]; } __attribute__((packed))bt_bdname_t; /** Bluetooth Adapter Visibility Modes*/ typedef enum { BT_SCAN_MODE_NONE, BT_SCAN_MODE_CONNECTABLE, BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE } bt_scan_mode_t; /** Bluetooth Adapter State */ typedef enum { BT_STATE_OFF, BT_STATE_ON } bt_state_t; /** Bluetooth Error Status */ /** We need to build on this */ typedef enum { BT_STATUS_SUCCESS, BT_STATUS_FAIL, BT_STATUS_NOT_READY, BT_STATUS_NOMEM, BT_STATUS_BUSY, BT_STATUS_DONE, /* request already completed */ BT_STATUS_UNSUPPORTED, BT_STATUS_PARM_INVALID, BT_STATUS_UNHANDLED, BT_STATUS_AUTH_FAILURE, BT_STATUS_RMT_DEV_DOWN, BT_STATUS_AUTH_REJECTED } bt_status_t; /** Bluetooth PinKey Code */ typedef struct { uint8_t pin[16]; } __attribute__((packed))bt_pin_code_t; typedef struct { uint8_t status; uint8_t ctrl_state; /* stack reported state */ uint64_t tx_time; /* in ms */ uint64_t rx_time; /* in ms */ uint64_t idle_time; /* in ms */ uint64_t energy_used; /* a product of mA, V and ms */ } __attribute__((packed))bt_activity_energy_info; /** Bluetooth Adapter Discovery state */ typedef enum { BT_DISCOVERY_STOPPED, BT_DISCOVERY_STARTED } bt_discovery_state_t; /** Bluetooth ACL connection state */ typedef enum { BT_ACL_STATE_CONNECTED, 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; uint16_t channel; char name[256]; // what's the maximum length } bt_service_record_t; /** Bluetooth Remote Version info */ typedef struct { int version; int sub_ver; int manufacturer; } bt_remote_version_t; typedef struct { uint8_t local_privacy_enabled; uint8_t max_adv_instance; uint8_t rpa_offload_supported; uint8_t max_irk_list_size; uint8_t max_adv_filter_supported; uint8_t scan_result_storage_size_lobyte; uint8_t scan_result_storage_size_hibyte; uint8_t activity_energy_info_supported; }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, } bt_property_type_t; /** Bluetooth Adapter Property data structure */ typedef struct { bt_property_type_t type; int len; void *val; } bt_property_t; /** Bluetooth Device Type */ typedef enum { BT_DEVICE_DEVTYPE_BREDR = 0x1, BT_DEVICE_DEVTYPE_BLE, BT_DEVICE_DEVTYPE_DUAL } bt_device_type_t; /** Bluetooth Bond state */ typedef enum { BT_BOND_STATE_NONE, BT_BOND_STATE_BONDING, BT_BOND_STATE_BONDED } bt_bond_state_t; /** Bluetooth SSP Bonding Variant */ typedef enum { BT_SSP_VARIANT_PASSKEY_CONFIRMATION, BT_SSP_VARIANT_PASSKEY_ENTRY, BT_SSP_VARIANT_CONSENT, BT_SSP_VARIANT_PASSKEY_NOTIFICATION } bt_ssp_variant_t; #define BT_MAX_NUM_UUIDS 32 /** Bluetooth Interface callbacks */ /** Bluetooth Enable/Disable Callback. */ typedef void (*adapter_state_changed_callback)(bt_state_t state); /** GET/SET Adapter Properties callback */ /* TODO: For the GET/SET property APIs/callbacks, we may need a session * identifier to associate the call with the callback. This would be needed * whenever more than one simultaneous instance of the same adapter_type * is get/set. * * If this is going to be handled in the Java framework, then we do not need * to manage sessions here. */ typedef void (*adapter_properties_callback)(bt_status_t status, int num_properties, bt_property_t *properties); /** GET/SET Remote Device Properties callback */ /** TODO: For remote device properties, do not see a need to get/set * multiple properties - num_properties shall be 1 */ typedef void (*remote_device_properties_callback)(bt_status_t status, bt_bdaddr_t *bd_addr, int num_properties, bt_property_t *properties); /** New device discovered callback */ /** If EIR data is not present, then BD_NAME and RSSI shall be NULL and -1 * respectively */ typedef void (*device_found_callback)(int num_properties, bt_property_t *properties); /** Discovery state changed callback */ 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, bt_bdname_t *bd_name, uint32_t cod); /** Bluetooth SSP Request callback - Just Works & Numeric Comparison*/ /** pass_key - Shall be 0 for BT_SSP_PAIRING_VARIANT_CONSENT & * 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, bt_bdname_t *bd_name, uint32_t cod, bt_ssp_variant_t pairing_variant, uint32_t pass_key); /** 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, 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, bt_acl_state_t state); typedef enum { ASSOCIATE_JVM, DISASSOCIATE_JVM } bt_cb_thread_evt; /** Thread Associate/Disassociate JVM Callback */ /* Callback that is invoked by the callback thread to allow upper layer to attach/detach to/from * the JVM */ typedef void (*callback_thread_event)(bt_cb_thread_evt evt); /** Bluetooth Test Mode Callback */ /* 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); /* 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 */ typedef void (*le_test_mode_callback)(bt_status_t status, uint16_t num_packets); /** Callback invoked when energy details are obtained */ /* Ctrl_state-Current controller state-Active-1,scan-2,or idle-3 state as defined by HCI spec. * If the ctrl_state value is 0, it means the API call failed * Time values-In milliseconds as returned by the controller * Energy used-Value as returned by the controller * Status-Provides the status of the read_energy_info API call */ typedef void (*energy_info_callback)(bt_activity_energy_info *energy_info); /** TODO: Add callbacks for Link Up/Down and other generic * notifications/callbacks */ /** Bluetooth DM callback structure. */ typedef struct { /** set to sizeof(bt_callbacks_t) */ size_t size; adapter_state_changed_callback adapter_state_changed_cb; adapter_properties_callback adapter_properties_cb; remote_device_properties_callback remote_device_properties_cb; device_found_callback device_found_cb; discovery_state_changed_callback discovery_state_changed_cb; pin_request_callback pin_request_cb; ssp_request_callback ssp_request_cb; bond_state_changed_callback bond_state_changed_cb; acl_state_changed_callback acl_state_changed_cb; callback_thread_event thread_evt_cb; dut_mode_recv_callback dut_mode_recv_cb; le_test_mode_callback le_test_mode_cb; energy_info_callback energy_info_cb; } bt_callbacks_t; typedef void (*alarm_cb)(void *data); typedef bool (*set_wake_alarm_callout)(uint64_t delay_millis, bool should_wake, alarm_cb cb, void *data); typedef int (*acquire_wake_lock_callout)(const char *lock_name); typedef int (*release_wake_lock_callout)(const char *lock_name); /** The set of functions required by bluedroid to set wake alarms and * grab wake locks. This struct is passed into the stack through the * |set_os_callouts| function on |bt_interface_t|. */ typedef struct { /* set to sizeof(bt_os_callouts_t) */ size_t size; set_wake_alarm_callout set_wake_alarm; acquire_wake_lock_callout acquire_wake_lock; release_wake_lock_callout release_wake_lock; } bt_os_callouts_t; /** NOTE: By default, no profiles are initialized at the time of init/enable. * Whenever the application invokes the 'init' API of a profile, then one of * the following shall occur: * * 1.) If Bluetooth is not enabled, then the Bluetooth core shall mark the * profile as enabled. Subsequently, when the application invokes the * Bluetooth 'enable', as part of the enable sequence the profile that were * marked shall be enabled by calling appropriate stack APIs. The * 'adapter_properties_cb' shall return the list of UUIDs of the * enabled profiles. * * 2.) If Bluetooth is enabled, then the Bluetooth core shall invoke the stack * profile API to initialize the profile and trigger a * 'adapter_properties_cb' with the current list of UUIDs including the * newly added profile's UUID. * * The reverse shall occur whenever the profile 'cleanup' APIs are invoked */ /** Represents the standard Bluetooth DM interface. */ typedef struct { /** set to sizeof(bt_interface_t) */ size_t size; /** * Opens the interface and provides the callback routines * to the implemenation of this interface. */ int (*init)(bt_callbacks_t* callbacks ); /** Enable Bluetooth. */ int (*enable)(void); /** Disable Bluetooth. */ int (*disable)(void); /** Closes the interface. */ void (*cleanup)(void); /** Get all Bluetooth Adapter properties at init */ int (*get_adapter_properties)(void); /** Get Bluetooth Adapter property of 'type' */ int (*get_adapter_property)(bt_property_type_t type); /** 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 */ int (*set_adapter_property)(const bt_property_t *property); /** Get all Remote Device properties */ int (*get_remote_device_properties)(bt_bdaddr_t *remote_addr); /** Get Remote Device property of 'type' */ int (*get_remote_device_property)(bt_bdaddr_t *remote_addr, bt_property_type_t type); /** Set Remote Device property of 'type' */ int (*set_remote_device_property)(bt_bdaddr_t *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); /** Start SDP to get remote services */ int (*get_remote_services)(bt_bdaddr_t *remote_addr); /** Start Discovery */ int (*start_discovery)(void); /** Cancel Discovery */ int (*cancel_discovery)(void); /** Create Bluetooth Bonding */ int (*create_bond)(const bt_bdaddr_t *bd_addr, int transport); /** Remove Bond */ int (*remove_bond)(const bt_bdaddr_t *bd_addr); /** Cancel Bond */ int (*cancel_bond)(const bt_bdaddr_t *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); /** 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, uint8_t pin_len, bt_pin_code_t *pin_code); /** BT SSP Reply - Just Works, Numeric Comparison and Passkey * passkey shall be zero for BT_SSP_VARIANT_PASSKEY_COMPARISON & * 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, uint8_t accept, uint32_t passkey); /** Get Bluetooth profile interface */ const void* (*get_profile_interface) (const char *profile_id); /** Bluetooth Test Mode APIs - Bluetooth must be enabled for these APIs */ /* Configure DUT Mode - Use this mode to enter/exit DUT mode */ int (*dut_mode_configure)(uint8_t enable); /* 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); /** 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|. */ int (*set_os_callouts)(bt_os_callouts_t *callouts); /** Read Energy info details - return value indicates BT_STATUS_SUCCESS or BT_STATUS_NOT_READY * Success indicates that the VSC command was sent to controller */ int (*read_energy_info)(); } 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 */ android-headers-23/21/hardware/bt_av.h000066400000000000000000000063121264465411000176210ustar00rootroot00000000000000/* * 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 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); /** 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_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 ); /** 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 ); } btav_interface_t; __END_DECLS #endif /* ANDROID_INCLUDE_BT_AV_H */ android-headers-23/21/hardware/bt_gatt.h000066400000000000000000000032431264465411000201520ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/hardware/bt_gatt_client.h000066400000000000000000000426541264465411000215210ustar00rootroot00000000000000/* * 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" __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 { btgatt_srvc_id_t srvc_id; btgatt_gatt_id_t char_id; btgatt_gatt_id_t descr_id; 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; btgatt_srvc_id_t srvc_id; btgatt_gatt_id_t char_id; uint16_t len; uint8_t is_notify; } btgatt_notify_params_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 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); /** Reports GATT services on a remote device */ typedef void (*search_result_callback)( int conn_id, btgatt_srvc_id_t *srvc_id); /** GATT characteristic enumeration result callback */ typedef void (*get_characteristic_callback)(int conn_id, int status, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, int char_prop); /** GATT descriptor enumeration result callback */ typedef void (*get_descriptor_callback)(int conn_id, int status, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, btgatt_gatt_id_t *descr_id); /** GATT included service enumeration result callback */ typedef void (*get_included_service_callback)(int conn_id, int status, btgatt_srvc_id_t *srvc_id, btgatt_srvc_id_t *incl_srvc_id); /** Callback invoked in response to [de]register_for_notification */ typedef void (*register_for_notification_callback)(int conn_id, int registered, int status, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id); /** * 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, btgatt_write_params_t *p_data); /** 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, btgatt_write_params_t *p_data); /** 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)(int client_if, int filt_index, int addr_type, bt_bdaddr_t* bda, int adv_state); 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; search_result_callback search_result_cb; get_characteristic_callback get_characteristic_cb; get_descriptor_callback get_descriptor_cb; get_included_service_callback get_included_service_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; } 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 ); /** * Enumerate included services for a given service. * Set start_incl_srvc_id to NULL to get the first included service. */ bt_status_t (*get_included_service)( int conn_id, btgatt_srvc_id_t *srvc_id, btgatt_srvc_id_t *start_incl_srvc_id); /** * Enumerate characteristics for a given service. * Set start_char_id to NULL to get the first characteristic. */ bt_status_t (*get_characteristic)( int conn_id, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *start_char_id); /** * Enumerate descriptors for a given characteristic. * Set start_descr_id to NULL to get the first descriptor. */ bt_status_t (*get_descriptor)( int conn_id, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, btgatt_gatt_id_t *start_descr_id); /** Read a characteristic on a remote device */ bt_status_t (*read_characteristic)( int conn_id, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, int auth_req ); /** Write a remote characteristic */ bt_status_t (*write_characteristic)(int conn_id, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, 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, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, btgatt_gatt_id_t *descr_id, int auth_req); /** Write a remote descriptor for a given characteristic */ bt_status_t (*write_descriptor)( int conn_id, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, btgatt_gatt_id_t *descr_id, 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, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id); /** Deregister a previous request for notifications/indications */ bt_status_t (*deregister_for_notification)( int client_if, const bt_bdaddr_t *bd_addr, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id); /** 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)(int client_if, int action, int filt_index, int feat_seln, int list_logic_type, int filt_logic_type, int rssi_high_thres, int rssi_low_thres, int dely_mode, int found_timeout, int lost_timeout, int found_timeout_cnt); /** 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 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); } btgatt_client_interface_t; __END_DECLS #endif /* ANDROID_INCLUDE_BT_GATT_CLIENT_H */ android-headers-23/21/hardware/bt_gatt_server.h000066400000000000000000000170361264465411000215450ustar00rootroot00000000000000/* * 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); 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; } 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 */ android-headers-23/21/hardware/bt_gatt_types.h000066400000000000000000000026241264465411000214000ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/hardware/bt_hf.h000066400000000000000000000232571264465411000176170ustar00rootroot00000000000000/* * 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; /* 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); /** 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_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_CALL_ADDRTYPE_UNKNOWN = 0x81, BTHF_CALL_ADDRTYPE_INTERNATIONAL = 0x91 } bthf_call_addrtype_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 ); } bthf_interface_t; __END_DECLS #endif /* ANDROID_INCLUDE_BT_HF_H */ android-headers-23/21/hardware/bt_hf_client.h000066400000000000000000000320361264465411000211500ustar00rootroot00000000000000/* * 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); /** 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_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 */ android-headers-23/21/hardware/bt_hh.h000066400000000000000000000140561264465411000176160ustar00rootroot00000000000000/* * 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); /** 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 */ android-headers-23/21/hardware/bt_hl.h000066400000000000000000000071711264465411000176220ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/hardware/bt_mce.h000066400000000000000000000031211264465411000177520ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/hardware/bt_pan.h000066400000000000000000000055131264465411000177730ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/hardware/bt_rc.h000066400000000000000000000262671264465411000176320ustar00rootroot00000000000000/* * 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 7 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_event_id_t; typedef enum { BTRC_NOTIFICATION_TYPE_INTERIM = 0, BTRC_NOTIFICATION_TYPE_CHANGED = 1, } 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_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 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 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; } 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); /** Callback for play status request */ typedef void (* btrc_get_play_status_callback)(); /** Callback for list player application attributes (Shuffle, Repeat,...) */ typedef void (* btrc_list_player_app_attr_callback)(); /** Callback for list player application attributes (Shuffle, Repeat,...) */ typedef void (* btrc_list_player_app_values_callback)(btrc_player_attr_t attr_id); /** 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); /** 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); /** 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); /** Callback for setting the player application settings values */ typedef void (* btrc_set_player_app_value_callback) (btrc_player_settings_t *p_vals); /** 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); /** 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); /* 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); /** Callback for passthrough commands */ typedef void (* btrc_passthrough_cmd_callback) (int id, int key_state); /** BT-RC Target callback structure. */ 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_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 ); /** 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); /** 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)( int num_attr, btrc_player_attr_t *p_attrs); /** 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)( int num_val, uint8_t *p_vals); /** 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); /** 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); /** 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); /** 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); /** 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); /* 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); /* 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); /** Closes the interface. */ void (*cleanup)( void ); } btrc_interface_t; typedef void (* btrc_passthrough_rsp_callback) (int id, int key_state); typedef void (* btrc_connection_state_callback) (bool state, bt_bdaddr_t *bd_addr); /** BT-RC Controller callback structure. */ typedef struct { /** set to sizeof(BtRcCallbacks) */ size_t size; btrc_passthrough_rsp_callback passthrough_rsp_cb; btrc_connection_state_callback connection_state_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 ); /** Closes the interface. */ void (*cleanup)( void ); } btrc_ctrl_interface_t; __END_DECLS #endif /* ANDROID_INCLUDE_BT_RC_H */ android-headers-23/21/hardware/bt_sock.h000066400000000000000000000035171264465411000201560ustar00rootroot00000000000000/* * 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_SOCK_H #define ANDROID_INCLUDE_BT_SOCK_H __BEGIN_DECLS #define BTSOCK_FLAG_ENCRYPT 1 #define BTSOCK_FLAG_AUTH (1 << 1) typedef enum { BTSOCK_RFCOMM = 1, BTSOCK_SCO = 2, BTSOCK_L2CAP = 3 } btsock_type_t; /** Represents the standard BT SOCKET interface. */ typedef struct { short size; bt_bdaddr_t bd_addr; int channel; int status; } __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 */ bt_status_t (*listen)(btsock_type_t type, const char* service_name, const uint8_t* service_uuid, int channel, int* sock_fd, int flags); /* * 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 */ 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); } btsock_interface_t; __END_DECLS #endif /* ANDROID_INCLUDE_BT_SOCK_H */ android-headers-23/21/hardware/camera.h000066400000000000000000000257521264465411000177670ustar00rootroot00000000000000/* * Copyright (C) 2010-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_CAMERA_H #define ANDROID_INCLUDE_CAMERA_H #include "camera_common.h" /** * Camera device HAL, initial version [ CAMERA_DEVICE_API_VERSION_1_0 ] * * DEPRECATED. New devices should use Camera HAL v3.2 or newer. * * Supports the android.hardware.Camera API, and the android.hardware.camera2 * API in legacy mode only. * * Camera devices that support this version of the HAL must return a value in * the range HARDWARE_DEVICE_API_VERSION(0,0)-(1,FF) in * camera_device_t.common.version. CAMERA_DEVICE_API_VERSION_1_0 is the * recommended value. * * Camera modules that implement version 2.0 or higher of camera_module_t must * also return the value of camera_device_t.common.version in * camera_info_t.device_version. * * See camera_common.h for more details. */ __BEGIN_DECLS struct camera_memory; typedef void (*camera_release_memory)(struct camera_memory *mem); typedef struct camera_memory { void *data; size_t size; void *handle; camera_release_memory release; } camera_memory_t; typedef camera_memory_t* (*camera_request_memory)(int fd, size_t buf_size, unsigned int num_bufs, void *user); typedef void (*camera_notify_callback)(int32_t msg_type, int32_t ext1, int32_t ext2, void *user); typedef void (*camera_data_callback)(int32_t msg_type, const camera_memory_t *data, unsigned int index, camera_frame_metadata_t *metadata, void *user); typedef void (*camera_data_timestamp_callback)(int64_t timestamp, int32_t msg_type, const camera_memory_t *data, unsigned int index, void *user); #define HAL_CAMERA_PREVIEW_WINDOW_TAG 0xcafed00d typedef struct preview_stream_ops { int (*dequeue_buffer)(struct preview_stream_ops* w, buffer_handle_t** buffer, int *stride); int (*enqueue_buffer)(struct preview_stream_ops* w, buffer_handle_t* buffer); int (*cancel_buffer)(struct preview_stream_ops* w, buffer_handle_t* buffer); int (*set_buffer_count)(struct preview_stream_ops* w, int count); int (*set_buffers_geometry)(struct preview_stream_ops* pw, int w, int h, int format); int (*set_crop)(struct preview_stream_ops *w, int left, int top, int right, int bottom); int (*set_usage)(struct preview_stream_ops* w, int usage); int (*set_swap_interval)(struct preview_stream_ops *w, int interval); int (*get_min_undequeued_buffer_count)(const struct preview_stream_ops *w, int *count); int (*lock_buffer)(struct preview_stream_ops* w, buffer_handle_t* buffer); // Timestamps are measured in nanoseconds, and must be comparable // and monotonically increasing between two frames in the same // preview stream. They do not need to be comparable between // consecutive or parallel preview streams, cameras, or app runs. int (*set_timestamp)(struct preview_stream_ops *w, int64_t timestamp); } preview_stream_ops_t; struct camera_device; typedef struct camera_device_ops { /** Set the ANativeWindow to which preview frames are sent */ int (*set_preview_window)(struct camera_device *, struct preview_stream_ops *window); /** Set the notification and data callbacks */ void (*set_callbacks)(struct camera_device *, camera_notify_callback notify_cb, camera_data_callback data_cb, camera_data_timestamp_callback data_cb_timestamp, camera_request_memory get_memory, void *user); /** * The following three functions all take a msg_type, which is a bitmask of * the messages defined in include/ui/Camera.h */ /** * Enable a message, or set of messages. */ void (*enable_msg_type)(struct camera_device *, int32_t msg_type); /** * Disable a message, or a set of messages. * * Once received a call to disableMsgType(CAMERA_MSG_VIDEO_FRAME), camera * HAL should not rely on its client to call releaseRecordingFrame() to * release video recording frames sent out by the cameral HAL before and * after the disableMsgType(CAMERA_MSG_VIDEO_FRAME) call. Camera HAL * clients must not modify/access any video recording frame after calling * disableMsgType(CAMERA_MSG_VIDEO_FRAME). */ void (*disable_msg_type)(struct camera_device *, int32_t msg_type); /** * Query whether a message, or a set of messages, is enabled. Note that * this is operates as an AND, if any of the messages queried are off, this * will return false. */ int (*msg_type_enabled)(struct camera_device *, int32_t msg_type); /** * Start preview mode. */ int (*start_preview)(struct camera_device *); /** * Stop a previously started preview. */ void (*stop_preview)(struct camera_device *); /** * Returns true if preview is enabled. */ int (*preview_enabled)(struct camera_device *); /** * Request the camera HAL to store meta data or real YUV data in the video * buffers sent out via CAMERA_MSG_VIDEO_FRAME for a recording session. If * it is not called, the default camera HAL behavior is to store real YUV * data in the video buffers. * * This method should be called before startRecording() in order to be * effective. * * If meta data is stored in the video buffers, it is up to the receiver of * the video buffers to interpret the contents and to find the actual frame * data with the help of the meta data in the buffer. How this is done is * outside of the scope of this method. * * Some camera HALs may not support storing meta data in the video buffers, * but all camera HALs should support storing real YUV data in the video * buffers. If the camera HAL does not support storing the meta data in the * video buffers when it is requested to do do, INVALID_OPERATION must be * returned. It is very useful for the camera HAL to pass meta data rather * than the actual frame data directly to the video encoder, since the * amount of the uncompressed frame data can be very large if video size is * large. * * @param enable if true to instruct the camera HAL to store * meta data in the video buffers; false to instruct * the camera HAL to store real YUV data in the video * buffers. * * @return OK on success. */ int (*store_meta_data_in_buffers)(struct camera_device *, int enable); /** * Start record mode. When a record image is available, a * CAMERA_MSG_VIDEO_FRAME message is sent with the corresponding * frame. Every record frame must be released by a camera HAL client via * releaseRecordingFrame() before the client calls * disableMsgType(CAMERA_MSG_VIDEO_FRAME). After the client calls * disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's * responsibility to manage the life-cycle of the video recording frames, * and the client must not modify/access any video recording frames. */ int (*start_recording)(struct camera_device *); /** * Stop a previously started recording. */ void (*stop_recording)(struct camera_device *); /** * Returns true if recording is enabled. */ int (*recording_enabled)(struct camera_device *); /** * Release a record frame previously returned by CAMERA_MSG_VIDEO_FRAME. * * It is camera HAL client's responsibility to release video recording * frames sent out by the camera HAL before the camera HAL receives a call * to disableMsgType(CAMERA_MSG_VIDEO_FRAME). After it receives the call to * disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's * responsibility to manage the life-cycle of the video recording frames. */ void (*release_recording_frame)(struct camera_device *, const void *opaque); /** * Start auto focus, the notification callback routine is called with * CAMERA_MSG_FOCUS once when focusing is complete. autoFocus() will be * called again if another auto focus is needed. */ int (*auto_focus)(struct camera_device *); /** * Cancels auto-focus function. If the auto-focus is still in progress, * this function will cancel it. Whether the auto-focus is in progress or * not, this function will return the focus position to the default. If * the camera does not support auto-focus, this is a no-op. */ int (*cancel_auto_focus)(struct camera_device *); /** * Take a picture. */ int (*take_picture)(struct camera_device *); /** * Cancel a picture that was started with takePicture. Calling this method * when no picture is being taken is a no-op. */ int (*cancel_picture)(struct camera_device *); /** * Set the camera parameters. This returns BAD_VALUE if any parameter is * invalid or not supported. */ int (*set_parameters)(struct camera_device *, const char *parms); /** Retrieve the camera parameters. The buffer returned by the camera HAL must be returned back to it with put_parameters, if put_parameters is not NULL. */ char *(*get_parameters)(struct camera_device *); /** The camera HAL uses its own memory to pass us the parameters when we call get_parameters. Use this function to return the memory back to the camera HAL, if put_parameters is not NULL. If put_parameters is NULL, then you have to use free() to release the memory. */ void (*put_parameters)(struct camera_device *, char *); /** * Send command to camera driver. */ int (*send_command)(struct camera_device *, int32_t cmd, int32_t arg1, int32_t arg2); /** * Release the hardware resources owned by this object. Note that this is * *not* done in the destructor. */ void (*release)(struct camera_device *); /** * Dump state of the camera hardware */ int (*dump)(struct camera_device *, int fd); } camera_device_ops_t; typedef struct camera_device { /** * camera_device.common.version must be in the range * HARDWARE_DEVICE_API_VERSION(0,0)-(1,FF). CAMERA_DEVICE_API_VERSION_1_0 is * recommended. */ hw_device_t common; camera_device_ops_t *ops; void *priv; } camera_device_t; __END_DECLS #endif /* #ifdef ANDROID_INCLUDE_CAMERA_H */ android-headers-23/21/hardware/camera2.h000066400000000000000000001027521264465411000200450ustar00rootroot00000000000000/* * 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_CAMERA2_H #define ANDROID_INCLUDE_CAMERA2_H #include "camera_common.h" #include "system/camera_metadata.h" /** * Camera device HAL 2.1 [ CAMERA_DEVICE_API_VERSION_2_0, CAMERA_DEVICE_API_VERSION_2_1 ] * * DEPRECATED. New devices should use Camera HAL v3.2 or newer. * * Supports the android.hardware.Camera API, and the android.hardware.camera2 * API in legacy mode only. * * Camera devices that support this version of the HAL must return * CAMERA_DEVICE_API_VERSION_2_1 in camera_device_t.common.version and in * camera_info_t.device_version (from camera_module_t.get_camera_info). * * Camera modules that may contain version 2.x devices must implement at least * version 2.0 of the camera module interface (as defined by * camera_module_t.common.module_api_version). * * See camera_common.h for more versioning details. * * Version history: * * 2.0: CAMERA_DEVICE_API_VERSION_2_0. Initial release (Android 4.2): * - Sufficient for implementing existing android.hardware.Camera API. * - Allows for ZSL queue in camera service layer * - Not tested for any new features such manual capture control, * Bayer RAW capture, reprocessing of RAW data. * * 2.1: CAMERA_DEVICE_API_VERSION_2_1. Support per-device static metadata: * - Add get_instance_metadata() method to retrieve metadata that is fixed * after device open, but may be variable between open() calls. */ __BEGIN_DECLS struct camera2_device; /********************************************************************** * * Input/output stream buffer queue interface definitions * */ /** * Output image stream queue interface. A set of these methods is provided to * the HAL device in allocate_stream(), and are used to interact with the * gralloc buffer queue for that stream. They may not be called until after * allocate_stream returns. */ typedef struct camera2_stream_ops { /** * Get a buffer to fill from the queue. The size and format of the buffer * are fixed for a given stream (defined in allocate_stream), and the stride * should be queried from the platform gralloc module. The gralloc buffer * will have been allocated based on the usage flags provided by * allocate_stream, and will be locked for use. */ int (*dequeue_buffer)(const struct camera2_stream_ops* w, buffer_handle_t** buffer); /** * Push a filled buffer to the stream to be used by the consumer. * * The timestamp represents the time at start of exposure of the first row * of the image; it must be from a monotonic clock, and is measured in * nanoseconds. The timestamps do not need to be comparable between * different cameras, or consecutive instances of the same camera. However, * they must be comparable between streams from the same camera. If one * capture produces buffers for multiple streams, each stream must have the * same timestamp for that buffer, and that timestamp must match the * timestamp in the output frame metadata. */ int (*enqueue_buffer)(const struct camera2_stream_ops* w, int64_t timestamp, buffer_handle_t* buffer); /** * Return a buffer to the queue without marking it as filled. */ int (*cancel_buffer)(const struct camera2_stream_ops* w, buffer_handle_t* buffer); /** * Set the crop window for subsequently enqueued buffers. The parameters are * measured in pixels relative to the buffer width and height. */ int (*set_crop)(const struct camera2_stream_ops *w, int left, int top, int right, int bottom); } camera2_stream_ops_t; /** * Temporary definition during transition. * * These formats will be removed and replaced with * HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED. To maximize forward compatibility, * HAL implementations are strongly recommended to treat FORMAT_OPAQUE and * FORMAT_ZSL as equivalent to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, and * return HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED in the format_actual output * parameter of allocate_stream, allowing the gralloc module to select the * specific format based on the usage flags from the camera and the stream * consumer. */ enum { CAMERA2_HAL_PIXEL_FORMAT_OPAQUE = HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, CAMERA2_HAL_PIXEL_FORMAT_ZSL = -1 }; /** * Transport header for compressed JPEG buffers in output streams. * * To capture JPEG images, a stream is created using the pixel format * HAL_PIXEL_FORMAT_BLOB, and the static metadata field android.jpeg.maxSize is * used as the buffer size. Since compressed JPEG images are of variable size, * the HAL needs to include the final size of the compressed image using this * structure inside the output stream buffer. The JPEG blob ID field must be set * to CAMERA2_JPEG_BLOB_ID. * * Transport header should be at the end of the JPEG output stream buffer. That * means the jpeg_blob_id must start at byte[android.jpeg.maxSize - * sizeof(camera2_jpeg_blob)]. Any HAL using this transport header must * account for it in android.jpeg.maxSize. The JPEG data itself starts at * byte[0] and should be jpeg_size bytes long. */ typedef struct camera2_jpeg_blob { uint16_t jpeg_blob_id; uint32_t jpeg_size; }; enum { CAMERA2_JPEG_BLOB_ID = 0x00FF }; /** * Input reprocess stream queue management. A set of these methods is provided * to the HAL device in allocate_reprocess_stream(); they are used to interact * with the reprocess stream's input gralloc buffer queue. */ typedef struct camera2_stream_in_ops { /** * Get the next buffer of image data to reprocess. The width, height, and * format of the buffer is fixed in allocate_reprocess_stream(), and the * stride and other details should be queried from the platform gralloc * module as needed. The buffer will already be locked for use. */ int (*acquire_buffer)(const struct camera2_stream_in_ops *w, buffer_handle_t** buffer); /** * Return a used buffer to the buffer queue for reuse. */ int (*release_buffer)(const struct camera2_stream_in_ops *w, buffer_handle_t* buffer); } camera2_stream_in_ops_t; /********************************************************************** * * Metadata queue management, used for requests sent to HAL module, and for * frames produced by the HAL. * */ enum { CAMERA2_REQUEST_QUEUE_IS_BOTTOMLESS = -1 }; /** * Request input queue protocol: * * The framework holds the queue and its contents. At start, the queue is empty. * * 1. When the first metadata buffer is placed into the queue, the framework * signals the device by calling notify_request_queue_not_empty(). * * 2. After receiving notify_request_queue_not_empty, the device must call * dequeue() once it's ready to handle the next buffer. * * 3. Once the device has processed a buffer, and is ready for the next buffer, * it must call dequeue() again instead of waiting for a notification. If * there are no more buffers available, dequeue() will return NULL. After * this point, when a buffer becomes available, the framework must call * notify_request_queue_not_empty() again. If the device receives a NULL * return from dequeue, it does not need to query the queue again until a * notify_request_queue_not_empty() call is received from the source. * * 4. If the device calls buffer_count() and receives 0, this does not mean that * the framework will provide a notify_request_queue_not_empty() call. The * framework will only provide such a notification after the device has * received a NULL from dequeue, or on initial startup. * * 5. The dequeue() call in response to notify_request_queue_not_empty() may be * on the same thread as the notify_request_queue_not_empty() call, and may * be performed from within the notify call. * * 6. All dequeued request buffers must be returned to the framework by calling * free_request, including when errors occur, a device flush is requested, or * when the device is shutting down. */ typedef struct camera2_request_queue_src_ops { /** * Get the count of request buffers pending in the queue. May return * CAMERA2_REQUEST_QUEUE_IS_BOTTOMLESS if a repeating request (stream * request) is currently configured. Calling this method has no effect on * whether the notify_request_queue_not_empty() method will be called by the * framework. */ int (*request_count)(const struct camera2_request_queue_src_ops *q); /** * Get a metadata buffer from the framework. Returns OK if there is no * error. If the queue is empty, returns NULL in buffer. In that case, the * device must wait for a notify_request_queue_not_empty() message before * attempting to dequeue again. Buffers obtained in this way must be * returned to the framework with free_request(). */ int (*dequeue_request)(const struct camera2_request_queue_src_ops *q, camera_metadata_t **buffer); /** * Return a metadata buffer to the framework once it has been used, or if * an error or shutdown occurs. */ int (*free_request)(const struct camera2_request_queue_src_ops *q, camera_metadata_t *old_buffer); } camera2_request_queue_src_ops_t; /** * Frame output queue protocol: * * The framework holds the queue and its contents. At start, the queue is empty. * * 1. When the device is ready to fill an output metadata frame, it must dequeue * a metadata buffer of the required size. * * 2. It should then fill the metadata buffer, and place it on the frame queue * using enqueue_frame. The framework takes ownership of the frame. * * 3. In case of an error, a request to flush the pipeline, or shutdown, the * device must return any affected dequeued frames to the framework by * calling cancel_frame. */ typedef struct camera2_frame_queue_dst_ops { /** * Get an empty metadata buffer to fill from the framework. The new metadata * buffer will have room for entries number of metadata entries, plus * data_bytes worth of extra storage. Frames dequeued here must be returned * to the framework with either cancel_frame or enqueue_frame. */ int (*dequeue_frame)(const struct camera2_frame_queue_dst_ops *q, size_t entries, size_t data_bytes, camera_metadata_t **buffer); /** * Return a dequeued metadata buffer to the framework for reuse; do not mark it as * filled. Use when encountering errors, or flushing the internal request queue. */ int (*cancel_frame)(const struct camera2_frame_queue_dst_ops *q, camera_metadata_t *buffer); /** * Place a completed metadata frame on the frame output queue. */ int (*enqueue_frame)(const struct camera2_frame_queue_dst_ops *q, camera_metadata_t *buffer); } camera2_frame_queue_dst_ops_t; /********************************************************************** * * Notification callback and message definition, and trigger definitions * */ /** * Asynchronous notification callback from the HAL, fired for various * reasons. Only for information independent of frame capture, or that require * specific timing. The user pointer must be the same one that was passed to the * device in set_notify_callback(). */ typedef void (*camera2_notify_callback)(int32_t msg_type, int32_t ext1, int32_t ext2, int32_t ext3, void *user); /** * Possible message types for camera2_notify_callback */ enum { /** * An error has occurred. Argument ext1 contains the error code, and * ext2 and ext3 contain any error-specific information. */ CAMERA2_MSG_ERROR = 0x0001, /** * The exposure of a given request has begun. Argument ext1 contains the * frame number, and ext2 and ext3 contain the low-order and high-order * bytes of the timestamp for when exposure began. * (timestamp = (ext3 << 32 | ext2)) */ CAMERA2_MSG_SHUTTER = 0x0010, /** * The autofocus routine has changed state. Argument ext1 contains the new * state; the values are the same as those for the metadata field * android.control.afState. Ext2 contains the latest trigger ID passed to * trigger_action(CAMERA2_TRIGGER_AUTOFOCUS) or * trigger_action(CAMERA2_TRIGGER_CANCEL_AUTOFOCUS), or 0 if trigger has not * been called with either of those actions. */ CAMERA2_MSG_AUTOFOCUS = 0x0020, /** * The autoexposure routine has changed state. Argument ext1 contains the * new state; the values are the same as those for the metadata field * android.control.aeState. Ext2 contains the latest trigger ID value passed to * trigger_action(CAMERA2_TRIGGER_PRECAPTURE_METERING), or 0 if that method * has not been called. */ CAMERA2_MSG_AUTOEXPOSURE = 0x0021, /** * The auto-whitebalance routine has changed state. Argument ext1 contains * the new state; the values are the same as those for the metadata field * android.control.awbState. Ext2 contains the latest trigger ID passed to * trigger_action(CAMERA2_TRIGGER_PRECAPTURE_METERING), or 0 if that method * has not been called. */ CAMERA2_MSG_AUTOWB = 0x0022 }; /** * Error codes for CAMERA_MSG_ERROR */ enum { /** * A serious failure occured. Camera device may not work without reboot, and * no further frames or buffer streams will be produced by the * device. Device should be treated as closed. */ CAMERA2_MSG_ERROR_HARDWARE = 0x0001, /** * A serious failure occured. No further frames or buffer streams will be * produced by the device. Device should be treated as closed. The client * must reopen the device to use it again. */ CAMERA2_MSG_ERROR_DEVICE, /** * An error has occurred in processing a request. No output (metadata or * buffers) will be produced for this request. ext2 contains the frame * number of the request. Subsequent requests are unaffected, and the device * remains operational. */ CAMERA2_MSG_ERROR_REQUEST, /** * An error has occurred in producing an output frame metadata buffer for a * request, but image buffers for it will still be available. Subsequent * requests are unaffected, and the device remains operational. ext2 * contains the frame number of the request. */ CAMERA2_MSG_ERROR_FRAME, /** * An error has occurred in placing an output buffer into a stream for a * request. The frame metadata and other buffers may still be * available. Subsequent requests are unaffected, and the device remains * operational. ext2 contains the frame number of the request, and ext3 * contains the stream id. */ CAMERA2_MSG_ERROR_STREAM, /** * Number of error types */ CAMERA2_MSG_NUM_ERRORS }; /** * Possible trigger ids for trigger_action() */ enum { /** * Trigger an autofocus cycle. The effect of the trigger depends on the * autofocus mode in effect when the trigger is received, which is the mode * listed in the latest capture request to be dequeued by the HAL. If the * mode is OFF, EDOF, or FIXED, the trigger has no effect. In AUTO, MACRO, * or CONTINUOUS_* modes, see below for the expected behavior. The state of * the autofocus cycle can be tracked in android.control.afMode and the * corresponding notifications. * ** * In AUTO or MACRO mode, the AF state transitions (and notifications) * when calling with trigger ID = N with the previous ID being K are: * * Initial state Transitions * INACTIVE (K) -> ACTIVE_SCAN (N) -> AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * AF_FOCUSED (K) -> ACTIVE_SCAN (N) -> AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * AF_NOT_FOCUSED (K) -> ACTIVE_SCAN (N) -> AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * ACTIVE_SCAN (K) -> AF_FOCUSED(N) or AF_NOT_FOCUSED(N) * PASSIVE_SCAN (K) Not used in AUTO/MACRO mode * PASSIVE_FOCUSED (K) Not used in AUTO/MACRO mode * ** * In CONTINUOUS_PICTURE mode, triggering AF must lock the AF to the current * lens position and transition the AF state to either AF_FOCUSED or * NOT_FOCUSED. If a passive scan is underway, that scan must complete and * then lock the lens position and change AF state. TRIGGER_CANCEL_AUTOFOCUS * will allow the AF to restart its operation. * * Initial state Transitions * INACTIVE (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * PASSIVE_FOCUSED (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * PASSIVE_SCAN (K) -> AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * AF_FOCUSED (K) no effect except to change next notification ID to N * AF_NOT_FOCUSED (K) no effect except to change next notification ID to N * ** * In CONTINUOUS_VIDEO mode, triggering AF must lock the AF to the current * lens position and transition the AF state to either AF_FOCUSED or * NOT_FOCUSED. If a passive scan is underway, it must immediately halt, in * contrast with CONTINUOUS_PICTURE mode. TRIGGER_CANCEL_AUTOFOCUS will * allow the AF to restart its operation. * * Initial state Transitions * INACTIVE (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * PASSIVE_FOCUSED (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * PASSIVE_SCAN (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * AF_FOCUSED (K) no effect except to change next notification ID to N * AF_NOT_FOCUSED (K) no effect except to change next notification ID to N * * Ext1 is an ID that must be returned in subsequent auto-focus state change * notifications through camera2_notify_callback() and stored in * android.control.afTriggerId. */ CAMERA2_TRIGGER_AUTOFOCUS = 0x0001, /** * Send a cancel message to the autofocus algorithm. The effect of the * cancellation depends on the autofocus mode in effect when the trigger is * received, which is the mode listed in the latest capture request to be * dequeued by the HAL. If the AF mode is OFF or EDOF, the cancel has no * effect. For other modes, the lens should return to its default position, * any current autofocus scan must be canceled, and the AF state should be * set to INACTIVE. * * The state of the autofocus cycle can be tracked in android.control.afMode * and the corresponding notification. Continuous autofocus modes may resume * focusing operations thereafter exactly as if the camera had just been set * to a continuous AF mode. * * Ext1 is an ID that must be returned in subsequent auto-focus state change * notifications through camera2_notify_callback() and stored in * android.control.afTriggerId. */ CAMERA2_TRIGGER_CANCEL_AUTOFOCUS, /** * Trigger a pre-capture metering cycle, which may include firing the flash * to determine proper capture parameters. Typically, this trigger would be * fired for a half-depress of a camera shutter key, or before a snapshot * capture in general. The state of the metering cycle can be tracked in * android.control.aeMode and the corresponding notification. If the * auto-exposure mode is OFF, the trigger does nothing. * * Ext1 is an ID that must be returned in subsequent * auto-exposure/auto-white balance state change notifications through * camera2_notify_callback() and stored in android.control.aePrecaptureId. */ CAMERA2_TRIGGER_PRECAPTURE_METERING }; /** * Possible template types for construct_default_request() */ enum { /** * Standard camera preview operation with 3A on auto. */ CAMERA2_TEMPLATE_PREVIEW = 1, /** * Standard camera high-quality still capture with 3A and flash on auto. */ CAMERA2_TEMPLATE_STILL_CAPTURE, /** * Standard video recording plus preview with 3A on auto, torch off. */ CAMERA2_TEMPLATE_VIDEO_RECORD, /** * High-quality still capture while recording video. Application will * include preview, video record, and full-resolution YUV or JPEG streams in * request. Must not cause stuttering on video stream. 3A on auto. */ CAMERA2_TEMPLATE_VIDEO_SNAPSHOT, /** * Zero-shutter-lag mode. Application will request preview and * full-resolution data for each frame, and reprocess it to JPEG when a * still image is requested by user. Settings should provide highest-quality * full-resolution images without compromising preview frame rate. 3A on * auto. */ CAMERA2_TEMPLATE_ZERO_SHUTTER_LAG, /* Total number of templates */ CAMERA2_TEMPLATE_COUNT }; /********************************************************************** * * Camera device operations * */ typedef struct camera2_device_ops { /********************************************************************** * Request and frame queue setup and management methods */ /** * Pass in input request queue interface methods. */ int (*set_request_queue_src_ops)(const struct camera2_device *, const camera2_request_queue_src_ops_t *request_src_ops); /** * Notify device that the request queue is no longer empty. Must only be * called when the first buffer is added a new queue, or after the source * has returned NULL in response to a dequeue call. */ int (*notify_request_queue_not_empty)(const struct camera2_device *); /** * Pass in output frame queue interface methods */ int (*set_frame_queue_dst_ops)(const struct camera2_device *, const camera2_frame_queue_dst_ops_t *frame_dst_ops); /** * Number of camera requests being processed by the device at the moment * (captures/reprocesses that have had their request dequeued, but have not * yet been enqueued onto output pipeline(s) ). No streams may be released * by the framework until the in-progress count is 0. */ int (*get_in_progress_count)(const struct camera2_device *); /** * Flush all in-progress captures. This includes all dequeued requests * (regular or reprocessing) that have not yet placed any outputs into a * stream or the frame queue. Partially completed captures must be completed * normally. No new requests may be dequeued from the request queue until * the flush completes. */ int (*flush_captures_in_progress)(const struct camera2_device *); /** * Create a filled-in default request for standard camera use cases. * * The device must return a complete request that is configured to meet the * requested use case, which must be one of the CAMERA2_TEMPLATE_* * enums. All request control fields must be included, except for * android.request.outputStreams. * * The metadata buffer returned must be allocated with * allocate_camera_metadata. The framework takes ownership of the buffer. */ int (*construct_default_request)(const struct camera2_device *, int request_template, camera_metadata_t **request); /********************************************************************** * Stream management */ /** * allocate_stream: * * Allocate a new output stream for use, defined by the output buffer width, * height, target, and possibly the pixel format. Returns the new stream's * ID, gralloc usage flags, minimum queue buffer count, and possibly the * pixel format, on success. Error conditions: * * - Requesting a width/height/format combination not listed as * supported by the sensor's static characteristics * * - Asking for too many streams of a given format type (2 bayer raw * streams, for example). * * Input parameters: * * - width, height, format: Specification for the buffers to be sent through * this stream. Format is a value from the HAL_PIXEL_FORMAT_* list. If * HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, then the platform * gralloc module will select a format based on the usage flags provided * by the camera HAL and the consumer of the stream. The camera HAL should * inspect the buffers handed to it in the register_stream_buffers call to * obtain the implementation-specific format if necessary. * * - stream_ops: A structure of function pointers for obtaining and queuing * up buffers for this stream. The underlying stream will be configured * based on the usage and max_buffers outputs. The methods in this * structure may not be called until after allocate_stream returns. * * Output parameters: * * - stream_id: An unsigned integer identifying this stream. This value is * used in incoming requests to identify the stream, and in releasing the * stream. * * - usage: The gralloc usage mask needed by the HAL device for producing * the requested type of data. This is used in allocating new gralloc * buffers for the stream buffer queue. * * - max_buffers: The maximum number of buffers the HAL device may need to * have dequeued at the same time. The device may not dequeue more buffers * than this value at the same time. * */ int (*allocate_stream)( const struct camera2_device *, // inputs uint32_t width, uint32_t height, int format, const camera2_stream_ops_t *stream_ops, // outputs uint32_t *stream_id, uint32_t *format_actual, // IGNORED, will be removed uint32_t *usage, uint32_t *max_buffers); /** * Register buffers for a given stream. This is called after a successful * allocate_stream call, and before the first request referencing the stream * is enqueued. This method is intended to allow the HAL device to map or * otherwise prepare the buffers for later use. num_buffers is guaranteed to * be at least max_buffers (from allocate_stream), but may be larger. The * buffers will already be locked for use. At the end of the call, all the * buffers must be ready to be returned to the queue. If the stream format * was set to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, the camera HAL should * inspect the passed-in buffers here to determine any platform-private * pixel format information. */ int (*register_stream_buffers)( const struct camera2_device *, uint32_t stream_id, int num_buffers, buffer_handle_t *buffers); /** * Release a stream. Returns an error if called when get_in_progress_count * is non-zero, or if the stream id is invalid. */ int (*release_stream)( const struct camera2_device *, uint32_t stream_id); /** * allocate_reprocess_stream: * * Allocate a new input stream for use, defined by the output buffer width, * height, and the pixel format. Returns the new stream's ID, gralloc usage * flags, and required simultaneously acquirable buffer count, on * success. Error conditions: * * - Requesting a width/height/format combination not listed as * supported by the sensor's static characteristics * * - Asking for too many reprocessing streams to be configured at once. * * Input parameters: * * - width, height, format: Specification for the buffers to be sent through * this stream. Format must be a value from the HAL_PIXEL_FORMAT_* list. * * - reprocess_stream_ops: A structure of function pointers for acquiring * and releasing buffers for this stream. The underlying stream will be * configured based on the usage and max_buffers outputs. * * Output parameters: * * - stream_id: An unsigned integer identifying this stream. This value is * used in incoming requests to identify the stream, and in releasing the * stream. These ids are numbered separately from the input stream ids. * * - consumer_usage: The gralloc usage mask needed by the HAL device for * consuming the requested type of data. This is used in allocating new * gralloc buffers for the stream buffer queue. * * - max_buffers: The maximum number of buffers the HAL device may need to * have acquired at the same time. The device may not have more buffers * acquired at the same time than this value. * */ int (*allocate_reprocess_stream)(const struct camera2_device *, uint32_t width, uint32_t height, uint32_t format, const camera2_stream_in_ops_t *reprocess_stream_ops, // outputs uint32_t *stream_id, uint32_t *consumer_usage, uint32_t *max_buffers); /** * allocate_reprocess_stream_from_stream: * * Allocate a new input stream for use, which will use the buffers allocated * for an existing output stream. That is, after the HAL enqueues a buffer * onto the output stream, it may see that same buffer handed to it from * this input reprocessing stream. After the HAL releases the buffer back to * the reprocessing stream, it will be returned to the output queue for * reuse. * * Error conditions: * * - Using an output stream of unsuitable size/format for the basis of the * reprocessing stream. * * - Attempting to allocatee too many reprocessing streams at once. * * Input parameters: * * - output_stream_id: The ID of an existing output stream which has * a size and format suitable for reprocessing. * * - reprocess_stream_ops: A structure of function pointers for acquiring * and releasing buffers for this stream. The underlying stream will use * the same graphics buffer handles as the output stream uses. * * Output parameters: * * - stream_id: An unsigned integer identifying this stream. This value is * used in incoming requests to identify the stream, and in releasing the * stream. These ids are numbered separately from the input stream ids. * * The HAL client must always release the reprocessing stream before it * releases the output stream it is based on. * */ int (*allocate_reprocess_stream_from_stream)(const struct camera2_device *, uint32_t output_stream_id, const camera2_stream_in_ops_t *reprocess_stream_ops, // outputs uint32_t *stream_id); /** * Release a reprocessing stream. Returns an error if called when * get_in_progress_count is non-zero, or if the stream id is not * valid. */ int (*release_reprocess_stream)( const struct camera2_device *, uint32_t stream_id); /********************************************************************** * Miscellaneous methods */ /** * Trigger asynchronous activity. This is used for triggering special * behaviors of the camera 3A routines when they are in use. See the * documentation for CAMERA2_TRIGGER_* above for details of the trigger ids * and their arguments. */ int (*trigger_action)(const struct camera2_device *, uint32_t trigger_id, int32_t ext1, int32_t ext2); /** * Notification callback setup */ int (*set_notify_callback)(const struct camera2_device *, camera2_notify_callback notify_cb, void *user); /** * Get methods to query for vendor extension metadata tag infomation. May * set ops to NULL if no vendor extension tags are defined. */ int (*get_metadata_vendor_tag_ops)(const struct camera2_device*, vendor_tag_query_ops_t **ops); /** * Dump state of the camera hardware */ int (*dump)(const struct camera2_device *, int fd); /** * Get device-instance-specific metadata. This metadata must be constant for * a single instance of the camera device, but may be different between * open() calls. The returned camera_metadata pointer must be valid until * the device close() method is called. * * Version information: * * CAMERA_DEVICE_API_VERSION_2_0: * * Not available. Framework may not access this function pointer. * * CAMERA_DEVICE_API_VERSION_2_1: * * Valid. Can be called by the framework. * */ int (*get_instance_metadata)(const struct camera2_device *, camera_metadata **instance_metadata); } camera2_device_ops_t; /********************************************************************** * * Camera device definition * */ typedef struct camera2_device { /** * common.version must equal CAMERA_DEVICE_API_VERSION_2_0 to identify * this device as implementing version 2.0 of the camera device HAL. */ hw_device_t common; camera2_device_ops_t *ops; void *priv; } camera2_device_t; __END_DECLS #endif /* #ifdef ANDROID_INCLUDE_CAMERA2_H */ android-headers-23/21/hardware/camera3.h000066400000000000000000003642351264465411000200540ustar00rootroot00000000000000/* * 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_CAMERA3_H #define ANDROID_INCLUDE_CAMERA3_H #include #include "camera_common.h" /** * Camera device HAL 3.2 [ CAMERA_DEVICE_API_VERSION_3_2 ] * * This is the current recommended version of the camera device HAL. * * Supports the android.hardware.Camera API, and as of v3.2, the * android.hardware.camera2 API in LIMITED or FULL modes. * * Camera devices that support this version of the HAL must return * CAMERA_DEVICE_API_VERSION_3_2 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_2: * Camera modules that may contain version 3.2 devices must implement at * least version 2.2 of the camera module interface (as defined by * camera_module_t.common.module_api_version). * * <= CAMERA_DEVICE_API_VERSION_3_1: * Camera modules that may contain version 3.1 (or 3.0) devices must * implement at least version 2.0 of the camera module interface * (as defined by camera_module_t.common.module_api_version). * * See camera_common.h for more versioning details. * * Documentation index: * S1. Version history * S2. Startup and operation sequencing * S3. Operational modes * S4. 3A modes and state machines * S5. Cropping * S6. Error management * S7. Key Performance Indicator (KPI) glossary * S8. Sample Use Cases * S9. Notes on Controls and Metadata */ /** * S1. Version history: * * 1.0: Initial Android camera HAL (Android 4.0) [camera.h]: * * - Converted from C++ CameraHardwareInterface abstraction layer. * * - Supports android.hardware.Camera API. * * 2.0: Initial release of expanded-capability HAL (Android 4.2) [camera2.h]: * * - Sufficient for implementing existing android.hardware.Camera API. * * - Allows for ZSL queue in camera service layer * * - Not tested for any new features such manual capture control, Bayer RAW * capture, reprocessing of RAW data. * * 3.0: First revision of expanded-capability HAL: * * - Major version change since the ABI is completely different. No change to * the required hardware capabilities or operational model from 2.0. * * - Reworked input request and stream queue interfaces: Framework calls into * HAL with next request and stream buffers already dequeued. Sync framework * support is included, necessary for efficient implementations. * * - Moved triggers into requests, most notifications into results. * * - Consolidated all callbacks into framework into one structure, and all * setup methods into a single initialize() call. * * - Made stream configuration into a single call to simplify stream * management. Bidirectional streams replace STREAM_FROM_STREAM construct. * * - Limited mode semantics for older/limited hardware devices. * * 3.1: Minor revision of expanded-capability HAL: * * - configure_streams passes consumer usage flags to the HAL. * * - flush call to drop all in-flight requests/buffers as fast as possible. * * 3.2: Minor revision of expanded-capability HAL: * * - Deprecates get_metadata_vendor_tag_ops. Please use get_vendor_tag_ops * in camera_common.h instead. * * - register_stream_buffers deprecated. All gralloc buffers provided * by framework to HAL in process_capture_request may be new at any time. * * - add partial result support. process_capture_result may be called * multiple times with a subset of the available result before the full * result is available. * * - add manual template to camera3_request_template. The applications may * use this template to control the capture settings directly. * * - Rework the bidirectional and input stream specifications. * * - change the input buffer return path. The buffer is returned in * process_capture_result instead of process_capture_request. * */ /** * S2. Startup and general expected operation sequence: * * 1. Framework calls camera_module_t->common.open(), which returns a * hardware_device_t structure. * * 2. Framework inspects the hardware_device_t->version field, and instantiates * the appropriate handler for that version of the camera hardware device. In * case the version is CAMERA_DEVICE_API_VERSION_3_0, the device is cast to * a camera3_device_t. * * 3. Framework calls camera3_device_t->ops->initialize() with the framework * callback function pointers. This will only be called this one time after * open(), before any other functions in the ops structure are called. * * 4. The framework calls camera3_device_t->ops->configure_streams() with a list * of input/output streams to the HAL device. * * 5. <= CAMERA_DEVICE_API_VERSION_3_1: * * The framework allocates gralloc buffers and calls * camera3_device_t->ops->register_stream_buffers() for at least one of the * output streams listed in configure_streams. The same stream is registered * only once. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * camera3_device_t->ops->register_stream_buffers() is not called and must * be NULL. * * 6. The framework requests default settings for some number of use cases with * calls to camera3_device_t->ops->construct_default_request_settings(). This * may occur any time after step 3. * * 7. The framework constructs and sends the first capture request to the HAL, * with settings based on one of the sets of default settings, and with at * least one output stream, which has been registered earlier by the * framework. This is sent to the HAL with * camera3_device_t->ops->process_capture_request(). The HAL must block the * return of this call until it is ready for the next request to be sent. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * The buffer_handle_t provided in the camera3_stream_buffer_t array * in the camera3_capture_request_t may be new and never-before-seen * by the HAL on any given new request. * * 8. The framework continues to submit requests, and call * construct_default_request_settings to get default settings buffers for * other use cases. * * <= CAMERA_DEVICE_API_VERSION_3_1: * * The framework may call register_stream_buffers() at this time for * not-yet-registered streams. * * 9. When the capture of a request begins (sensor starts exposing for the * capture), the HAL calls camera3_callback_ops_t->notify() with the SHUTTER * event, including the frame number and the timestamp for start of exposure. * * <= CAMERA_DEVICE_API_VERSION_3_1: * * This notify call must be made before the first call to * process_capture_result() for that frame number. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * The camera3_callback_ops_t->notify() call with the SHUTTER event should * be made as early as possible since the framework will be unable to * deliver gralloc buffers to the application layer (for that frame) until * it has a valid timestamp for the start of exposure. * * Both partial metadata results and the gralloc buffers may be sent to the * framework at any time before or after the SHUTTER event. * * 10. After some pipeline delay, the HAL begins to return completed captures to * the framework with camera3_callback_ops_t->process_capture_result(). These * are returned in the same order as the requests were submitted. Multiple * requests can be in flight at once, depending on the pipeline depth of the * camera HAL device. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * Once a buffer is returned by process_capture_result as part of the * camera3_stream_buffer_t array, and the fence specified by release_fence * has been signaled (this is a no-op for -1 fences), the ownership of that * buffer is considered to be transferred back to the framework. After that, * the HAL must no longer retain that particular buffer, and the * framework may clean up the memory for it immediately. * * process_capture_result may be called multiple times for a single frame, * each time with a new disjoint piece of metadata and/or set of gralloc * buffers. The framework will accumulate these partial metadata results * into one result. * * In particular, it is legal for a process_capture_result to be called * simultaneously for both a frame N and a frame N+1 as long as the * above rule holds for gralloc buffers (both input and output). * * 11. After some time, the framework may stop submitting new requests, wait for * the existing captures to complete (all buffers filled, all results * returned), and then call configure_streams() again. This resets the camera * hardware and pipeline for a new set of input/output streams. Some streams * may be reused from the previous configuration; if these streams' buffers * had already been registered with the HAL, they will not be registered * again. The framework then continues from step 7, if at least one * registered output stream remains (otherwise, step 5 is required first). * * 12. Alternatively, the framework may call camera3_device_t->common->close() * to end the camera session. This may be called at any time when no other * calls from the framework are active, although the call may block until all * in-flight captures have completed (all results returned, all buffers * filled). After the close call returns, no more calls to the * camera3_callback_ops_t functions are allowed from the HAL. Once the * close() call is underway, the framework may not call any other HAL device * functions. * * 13. In case of an error or other asynchronous event, the HAL must call * camera3_callback_ops_t->notify() with the appropriate error/event * message. After returning from a fatal device-wide error notification, the * HAL should act as if close() had been called on it. However, the HAL must * either cancel or complete all outstanding captures before calling * notify(), so that once notify() is called with a fatal error, the * framework will not receive further callbacks from the device. Methods * besides close() should return -ENODEV or NULL after the notify() method * returns from a fatal error message. */ /** * S3. Operational modes: * * The camera 3 HAL device can implement one of two possible operational modes; * limited and full. Full support is expected from new higher-end * devices. Limited mode has hardware requirements roughly in line with those * for a camera HAL device v1 implementation, and is expected from older or * inexpensive devices. Full is a strict superset of limited, and they share the * same essential operational flow, as documented above. * * The HAL must indicate its level of support with the * android.info.supportedHardwareLevel static metadata entry, with 0 indicating * limited mode, and 1 indicating full mode support. * * Roughly speaking, limited-mode devices do not allow for application control * of capture settings (3A control only), high-rate capture of high-resolution * images, raw sensor readout, or support for YUV output streams above maximum * recording resolution (JPEG only for large images). * * ** Details of limited mode behavior: * * - Limited-mode devices do not need to implement accurate synchronization * between capture request settings and the actual image data * captured. Instead, changes to settings may take effect some time in the * future, and possibly not for the same output frame for each settings * entry. Rapid changes in settings may result in some settings never being * used for a capture. However, captures that include high-resolution output * buffers ( > 1080p ) have to use the settings as specified (but see below * for processing rate). * * - Limited-mode devices do not need to support most of the * settings/result/static info metadata. Specifically, only the following settings * are expected to be consumed or produced by a limited-mode HAL device: * * android.control.aeAntibandingMode (controls and dynamic) * android.control.aeExposureCompensation (controls and dynamic) * android.control.aeLock (controls and dynamic) * android.control.aeMode (controls and dynamic) * android.control.aeRegions (controls and dynamic) * android.control.aeTargetFpsRange (controls and dynamic) * android.control.aePrecaptureTrigger (controls and dynamic) * android.control.afMode (controls and dynamic) * android.control.afRegions (controls and dynamic) * android.control.awbLock (controls and dynamic) * android.control.awbMode (controls and dynamic) * android.control.awbRegions (controls and dynamic) * android.control.captureIntent (controls and dynamic) * android.control.effectMode (controls and dynamic) * android.control.mode (controls and dynamic) * android.control.sceneMode (controls and dynamic) * android.control.videoStabilizationMode (controls and dynamic) * android.control.aeAvailableAntibandingModes (static) * android.control.aeAvailableModes (static) * android.control.aeAvailableTargetFpsRanges (static) * android.control.aeCompensationRange (static) * android.control.aeCompensationStep (static) * android.control.afAvailableModes (static) * android.control.availableEffects (static) * android.control.availableSceneModes (static) * android.control.availableVideoStabilizationModes (static) * android.control.awbAvailableModes (static) * android.control.maxRegions (static) * android.control.sceneModeOverrides (static) * android.control.aeState (dynamic) * android.control.afState (dynamic) * android.control.awbState (dynamic) * * android.flash.mode (controls and dynamic) * android.flash.info.available (static) * * android.info.supportedHardwareLevel (static) * * android.jpeg.gpsCoordinates (controls and dynamic) * android.jpeg.gpsProcessingMethod (controls and dynamic) * android.jpeg.gpsTimestamp (controls and dynamic) * android.jpeg.orientation (controls and dynamic) * android.jpeg.quality (controls and dynamic) * android.jpeg.thumbnailQuality (controls and dynamic) * android.jpeg.thumbnailSize (controls and dynamic) * android.jpeg.availableThumbnailSizes (static) * android.jpeg.maxSize (static) * * android.lens.info.minimumFocusDistance (static) * * android.request.id (controls and dynamic) * * android.scaler.cropRegion (controls and dynamic) * android.scaler.availableStreamConfigurations (static) * android.scaler.availableMinFrameDurations (static) * android.scaler.availableStallDurations (static) * android.scaler.availableMaxDigitalZoom (static) * android.scaler.maxDigitalZoom (static) * android.scaler.croppingType (static) * * android.sensor.orientation (static) * android.sensor.timestamp (dynamic) * * android.statistics.faceDetectMode (controls and dynamic) * android.statistics.info.availableFaceDetectModes (static) * android.statistics.faceIds (dynamic) * android.statistics.faceLandmarks (dynamic) * android.statistics.faceRectangles (dynamic) * android.statistics.faceScores (dynamic) * * android.sync.frameNumber (dynamic) * android.sync.maxLatency (static) * * - Captures in limited mode that include high-resolution (> 1080p) output * buffers may block in process_capture_request() until all the output buffers * have been filled. A full-mode HAL device must process sequences of * high-resolution requests at the rate indicated in the static metadata for * that pixel format. The HAL must still call process_capture_result() to * provide the output; the framework must simply be prepared for * process_capture_request() to block until after process_capture_result() for * that request completes for high-resolution captures for limited-mode * devices. * * - Full-mode devices must support below additional capabilities: * - 30fps at maximum resolution is preferred, more than 20fps is required. * - Per frame control (android.sync.maxLatency == PER_FRAME_CONTROL). * - Sensor manual control metadata. See MANUAL_SENSOR defined in * android.request.availableCapabilities. * - Post-processing manual control metadata. See MANUAL_POST_PROCESSING defined * in android.request.availableCapabilities. * */ /** * S4. 3A modes and state machines: * * While the actual 3A algorithms are up to the HAL implementation, a high-level * state machine description is defined by the HAL interface, to allow the HAL * device and the framework to communicate about the current state of 3A, and to * trigger 3A events. * * When the device is opened, all the individual 3A states must be * STATE_INACTIVE. Stream configuration does not reset 3A. For example, locked * focus must be maintained across the configure() call. * * Triggering a 3A action involves simply setting the relevant trigger entry in * the settings for the next request to indicate start of trigger. For example, * the trigger for starting an autofocus scan is setting the entry * ANDROID_CONTROL_AF_TRIGGER to ANDROID_CONTROL_AF_TRIGGER_START for one * request, and cancelling an autofocus scan is triggered by setting * ANDROID_CONTROL_AF_TRIGGER to ANDROID_CONTRL_AF_TRIGGER_CANCEL. Otherwise, * the entry will not exist, or be set to ANDROID_CONTROL_AF_TRIGGER_IDLE. Each * request with a trigger entry set to a non-IDLE value will be treated as an * independent triggering event. * * At the top level, 3A is controlled by the ANDROID_CONTROL_MODE setting, which * selects between no 3A (ANDROID_CONTROL_MODE_OFF), normal AUTO mode * (ANDROID_CONTROL_MODE_AUTO), and using the scene mode setting * (ANDROID_CONTROL_USE_SCENE_MODE). * * - In OFF mode, each of the individual AE/AF/AWB modes are effectively OFF, * and none of the capture controls may be overridden by the 3A routines. * * - In AUTO mode, Auto-focus, auto-exposure, and auto-whitebalance all run * their own independent algorithms, and have their own mode, state, and * trigger metadata entries, as listed in the next section. * * - In USE_SCENE_MODE, the value of the ANDROID_CONTROL_SCENE_MODE entry must * be used to determine the behavior of 3A routines. In SCENE_MODEs other than * FACE_PRIORITY, the HAL must override the values of * ANDROId_CONTROL_AE/AWB/AF_MODE to be the mode it prefers for the selected * SCENE_MODE. For example, the HAL may prefer SCENE_MODE_NIGHT to use * CONTINUOUS_FOCUS AF mode. Any user selection of AE/AWB/AF_MODE when scene * must be ignored for these scene modes. * * - For SCENE_MODE_FACE_PRIORITY, the AE/AWB/AF_MODE controls work as in * ANDROID_CONTROL_MODE_AUTO, but the 3A routines must bias toward metering * and focusing on any detected faces in the scene. * * S4.1. Auto-focus settings and result entries: * * Main metadata entries: * * ANDROID_CONTROL_AF_MODE: Control for selecting the current autofocus * mode. Set by the framework in the request settings. * * AF_MODE_OFF: AF is disabled; the framework/app directly controls lens * position. * * AF_MODE_AUTO: Single-sweep autofocus. No lens movement unless AF is * triggered. * * AF_MODE_MACRO: Single-sweep up-close autofocus. No lens movement unless * AF is triggered. * * AF_MODE_CONTINUOUS_VIDEO: Smooth continuous focusing, for recording * video. Triggering immediately locks focus in current * position. Canceling resumes cotinuous focusing. * * AF_MODE_CONTINUOUS_PICTURE: Fast continuous focusing, for * zero-shutter-lag still capture. Triggering locks focus once currently * active sweep concludes. Canceling resumes continuous focusing. * * AF_MODE_EDOF: Advanced extended depth of field focusing. There is no * autofocus scan, so triggering one or canceling one has no effect. * Images are focused automatically by the HAL. * * ANDROID_CONTROL_AF_STATE: Dynamic metadata describing the current AF * algorithm state, reported by the HAL in the result metadata. * * AF_STATE_INACTIVE: No focusing has been done, or algorithm was * reset. Lens is not moving. Always the state for MODE_OFF or MODE_EDOF. * When the device is opened, it must start in this state. * * AF_STATE_PASSIVE_SCAN: A continuous focus algorithm is currently scanning * for good focus. The lens is moving. * * AF_STATE_PASSIVE_FOCUSED: A continuous focus algorithm believes it is * well focused. The lens is not moving. The HAL may spontaneously leave * this state. * * AF_STATE_PASSIVE_UNFOCUSED: A continuous focus algorithm believes it is * not well focused. The lens is not moving. The HAL may spontaneously * leave this state. * * AF_STATE_ACTIVE_SCAN: A scan triggered by the user is underway. * * AF_STATE_FOCUSED_LOCKED: The AF algorithm believes it is focused. The * lens is not moving. * * AF_STATE_NOT_FOCUSED_LOCKED: The AF algorithm has been unable to * focus. The lens is not moving. * * ANDROID_CONTROL_AF_TRIGGER: Control for starting an autofocus scan, the * meaning of which is mode- and state- dependent. Set by the framework in * the request settings. * * AF_TRIGGER_IDLE: No current trigger. * * AF_TRIGGER_START: Trigger start of AF scan. Effect is mode and state * dependent. * * AF_TRIGGER_CANCEL: Cancel current AF scan if any, and reset algorithm to * default. * * Additional metadata entries: * * ANDROID_CONTROL_AF_REGIONS: Control for selecting the regions of the FOV * that should be used to determine good focus. This applies to all AF * modes that scan for focus. Set by the framework in the request * settings. * * S4.2. Auto-exposure settings and result entries: * * Main metadata entries: * * ANDROID_CONTROL_AE_MODE: Control for selecting the current auto-exposure * mode. Set by the framework in the request settings. * * AE_MODE_OFF: Autoexposure is disabled; the user controls exposure, gain, * frame duration, and flash. * * AE_MODE_ON: Standard autoexposure, with flash control disabled. User may * set flash to fire or to torch mode. * * AE_MODE_ON_AUTO_FLASH: Standard autoexposure, with flash on at HAL's * discretion for precapture and still capture. User control of flash * disabled. * * AE_MODE_ON_ALWAYS_FLASH: Standard autoexposure, with flash always fired * for capture, and at HAL's discretion for precapture.. User control of * flash disabled. * * AE_MODE_ON_AUTO_FLASH_REDEYE: Standard autoexposure, with flash on at * HAL's discretion for precapture and still capture. Use a flash burst * at end of precapture sequence to reduce redeye in the final * picture. User control of flash disabled. * * ANDROID_CONTROL_AE_STATE: Dynamic metadata describing the current AE * algorithm state, reported by the HAL in the result metadata. * * AE_STATE_INACTIVE: Initial AE state after mode switch. When the device is * opened, it must start in this state. * * AE_STATE_SEARCHING: AE is not converged to a good value, and is adjusting * exposure parameters. * * AE_STATE_CONVERGED: AE has found good exposure values for the current * scene, and the exposure parameters are not changing. HAL may * spontaneously leave this state to search for better solution. * * AE_STATE_LOCKED: AE has been locked with the AE_LOCK control. Exposure * values are not changing. * * AE_STATE_FLASH_REQUIRED: The HAL has converged exposure, but believes * flash is required for a sufficiently bright picture. Used for * determining if a zero-shutter-lag frame can be used. * * AE_STATE_PRECAPTURE: The HAL is in the middle of a precapture * sequence. Depending on AE mode, this mode may involve firing the * flash for metering, or a burst of flash pulses for redeye reduction. * * ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER: Control for starting a metering * sequence before capturing a high-quality image. Set by the framework in * the request settings. * * PRECAPTURE_TRIGGER_IDLE: No current trigger. * * PRECAPTURE_TRIGGER_START: Start a precapture sequence. The HAL should * use the subsequent requests to measure good exposure/white balance * for an upcoming high-resolution capture. * * Additional metadata entries: * * ANDROID_CONTROL_AE_LOCK: Control for locking AE controls to their current * values * * ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION: Control for adjusting AE * algorithm target brightness point. * * ANDROID_CONTROL_AE_TARGET_FPS_RANGE: Control for selecting the target frame * rate range for the AE algorithm. The AE routine cannot change the frame * rate to be outside these bounds. * * ANDROID_CONTROL_AE_REGIONS: Control for selecting the regions of the FOV * that should be used to determine good exposure levels. This applies to * all AE modes besides OFF. * * S4.3. Auto-whitebalance settings and result entries: * * Main metadata entries: * * ANDROID_CONTROL_AWB_MODE: Control for selecting the current white-balance * mode. * * AWB_MODE_OFF: Auto-whitebalance is disabled. User controls color matrix. * * AWB_MODE_AUTO: Automatic white balance is enabled; 3A controls color * transform, possibly using more complex transforms than a simple * matrix. * * AWB_MODE_INCANDESCENT: Fixed white balance settings good for indoor * incandescent (tungsten) lighting, roughly 2700K. * * AWB_MODE_FLUORESCENT: Fixed white balance settings good for fluorescent * lighting, roughly 5000K. * * AWB_MODE_WARM_FLUORESCENT: Fixed white balance settings good for * fluorescent lighting, roughly 3000K. * * AWB_MODE_DAYLIGHT: Fixed white balance settings good for daylight, * roughly 5500K. * * AWB_MODE_CLOUDY_DAYLIGHT: Fixed white balance settings good for clouded * daylight, roughly 6500K. * * AWB_MODE_TWILIGHT: Fixed white balance settings good for * near-sunset/sunrise, roughly 15000K. * * AWB_MODE_SHADE: Fixed white balance settings good for areas indirectly * lit by the sun, roughly 7500K. * * ANDROID_CONTROL_AWB_STATE: Dynamic metadata describing the current AWB * algorithm state, reported by the HAL in the result metadata. * * AWB_STATE_INACTIVE: Initial AWB state after mode switch. When the device * is opened, it must start in this state. * * AWB_STATE_SEARCHING: AWB is not converged to a good value, and is * changing color adjustment parameters. * * AWB_STATE_CONVERGED: AWB has found good color adjustment values for the * current scene, and the parameters are not changing. HAL may * spontaneously leave this state to search for better solution. * * AWB_STATE_LOCKED: AWB has been locked with the AWB_LOCK control. Color * adjustment values are not changing. * * Additional metadata entries: * * ANDROID_CONTROL_AWB_LOCK: Control for locking AWB color adjustments to * their current values. * * ANDROID_CONTROL_AWB_REGIONS: Control for selecting the regions of the FOV * that should be used to determine good color balance. This applies only * to auto-WB mode. * * S4.4. General state machine transition notes * * Switching between AF, AE, or AWB modes always resets the algorithm's state * to INACTIVE. Similarly, switching between CONTROL_MODE or * CONTROL_SCENE_MODE if CONTROL_MODE == USE_SCENE_MODE resets all the * algorithm states to INACTIVE. * * The tables below are per-mode. * * S4.5. AF state machines * * when enabling AF or changing AF mode *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| Any | AF mode change| INACTIVE | | *+--------------------+---------------+--------------------+------------------+ * * mode = AF_MODE_OFF or AF_MODE_EDOF *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | | INACTIVE | Never changes | *+--------------------+---------------+--------------------+------------------+ * * mode = AF_MODE_AUTO or AF_MODE_MACRO *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | AF_TRIGGER | ACTIVE_SCAN | Start AF sweep | *| | | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| ACTIVE_SCAN | AF sweep done | FOCUSED_LOCKED | If AF successful | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| ACTIVE_SCAN | AF sweep done | NOT_FOCUSED_LOCKED | If AF successful | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| ACTIVE_SCAN | AF_CANCEL | INACTIVE | Cancel/reset AF | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Cancel/reset AF | *+--------------------+---------------+--------------------+------------------+ *| FOCUSED_LOCKED | AF_TRIGGER | ACTIVE_SCAN | Start new sweep | *| | | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| NOT_FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Cancel/reset AF | *+--------------------+---------------+--------------------+------------------+ *| NOT_FOCUSED_LOCKED | AF_TRIGGER | ACTIVE_SCAN | Start new sweep | *| | | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| All states | mode change | INACTIVE | | *+--------------------+---------------+--------------------+------------------+ * * mode = AF_MODE_CONTINUOUS_VIDEO *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | HAL initiates | PASSIVE_SCAN | Start AF scan | *| | new scan | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | AF_TRIGGER | NOT_FOCUSED_LOCKED | AF state query | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | HAL completes | PASSIVE_FOCUSED | End AF scan | *| | current scan | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | HAL fails | PASSIVE_UNFOCUSED | End AF scan | *| | current scan | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | AF_TRIGGER | FOCUSED_LOCKED | Immediate trans. | *| | | | if focus is good | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | AF_TRIGGER | NOT_FOCUSED_LOCKED | Immediate trans. | *| | | | if focus is bad | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | AF_CANCEL | INACTIVE | Reset lens | *| | | | position | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_FOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan | *| | new scan | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_UNFOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan | *| | new scan | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_FOCUSED | AF_TRIGGER | FOCUSED_LOCKED | Immediate trans. | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_UNFOCUSED | AF_TRIGGER | NOT_FOCUSED_LOCKED | Immediate trans. | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| FOCUSED_LOCKED | AF_TRIGGER | FOCUSED_LOCKED | No effect | *+--------------------+---------------+--------------------+------------------+ *| FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan | *+--------------------+---------------+--------------------+------------------+ *| NOT_FOCUSED_LOCKED | AF_TRIGGER | NOT_FOCUSED_LOCKED | No effect | *+--------------------+---------------+--------------------+------------------+ *| NOT_FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan | *+--------------------+---------------+--------------------+------------------+ * * mode = AF_MODE_CONTINUOUS_PICTURE *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | HAL initiates | PASSIVE_SCAN | Start AF scan | *| | new scan | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | AF_TRIGGER | NOT_FOCUSED_LOCKED | AF state query | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | HAL completes | PASSIVE_FOCUSED | End AF scan | *| | current scan | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | HAL fails | PASSIVE_UNFOCUSED | End AF scan | *| | current scan | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | AF_TRIGGER | FOCUSED_LOCKED | Eventual trans. | *| | | | once focus good | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | AF_TRIGGER | NOT_FOCUSED_LOCKED | Eventual trans. | *| | | | if cannot focus | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | AF_CANCEL | INACTIVE | Reset lens | *| | | | position | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_FOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan | *| | new scan | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_UNFOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan | *| | new scan | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_FOCUSED | AF_TRIGGER | FOCUSED_LOCKED | Immediate trans. | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_UNFOCUSED | AF_TRIGGER | NOT_FOCUSED_LOCKED | Immediate trans. | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| FOCUSED_LOCKED | AF_TRIGGER | FOCUSED_LOCKED | No effect | *+--------------------+---------------+--------------------+------------------+ *| FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan | *+--------------------+---------------+--------------------+------------------+ *| NOT_FOCUSED_LOCKED | AF_TRIGGER | NOT_FOCUSED_LOCKED | No effect | *+--------------------+---------------+--------------------+------------------+ *| NOT_FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan | *+--------------------+---------------+--------------------+------------------+ * * S4.6. AE and AWB state machines * * The AE and AWB state machines are mostly identical. AE has additional * FLASH_REQUIRED and PRECAPTURE states. So rows below that refer to those two * states should be ignored for the AWB state machine. * * when enabling AE/AWB or changing AE/AWB mode *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| Any | mode change | INACTIVE | | *+--------------------+---------------+--------------------+------------------+ * * mode = AE_MODE_OFF / AWB mode not AUTO *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | | INACTIVE | AE/AWB disabled | *+--------------------+---------------+--------------------+------------------+ * * mode = AE_MODE_ON_* / AWB_MODE_AUTO *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | HAL initiates | SEARCHING | | *| | AE/AWB scan | | | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | AE/AWB_LOCK | LOCKED | values locked | *| | on | | | *+--------------------+---------------+--------------------+------------------+ *| SEARCHING | HAL finishes | CONVERGED | good values, not | *| | AE/AWB scan | | changing | *+--------------------+---------------+--------------------+------------------+ *| SEARCHING | HAL finishes | FLASH_REQUIRED | converged but too| *| | AE scan | | dark w/o flash | *+--------------------+---------------+--------------------+------------------+ *| SEARCHING | AE/AWB_LOCK | LOCKED | values locked | *| | on | | | *+--------------------+---------------+--------------------+------------------+ *| CONVERGED | HAL initiates | SEARCHING | values locked | *| | AE/AWB scan | | | *+--------------------+---------------+--------------------+------------------+ *| CONVERGED | AE/AWB_LOCK | LOCKED | values locked | *| | on | | | *+--------------------+---------------+--------------------+------------------+ *| FLASH_REQUIRED | HAL initiates | SEARCHING | values locked | *| | AE/AWB scan | | | *+--------------------+---------------+--------------------+------------------+ *| FLASH_REQUIRED | AE/AWB_LOCK | LOCKED | values locked | *| | on | | | *+--------------------+---------------+--------------------+------------------+ *| LOCKED | AE/AWB_LOCK | SEARCHING | values not good | *| | off | | after unlock | *+--------------------+---------------+--------------------+------------------+ *| LOCKED | AE/AWB_LOCK | CONVERGED | values good | *| | off | | after unlock | *+--------------------+---------------+--------------------+------------------+ *| LOCKED | AE_LOCK | FLASH_REQUIRED | exposure good, | *| | off | | but too dark | *+--------------------+---------------+--------------------+------------------+ *| All AE states | PRECAPTURE_ | PRECAPTURE | Start precapture | *| | START | | sequence | *+--------------------+---------------+--------------------+------------------+ *| PRECAPTURE | Sequence done.| CONVERGED | Ready for high- | *| | AE_LOCK off | | quality capture | *+--------------------+---------------+--------------------+------------------+ *| PRECAPTURE | Sequence done.| LOCKED | Ready for high- | *| | AE_LOCK on | | quality capture | *+--------------------+---------------+--------------------+------------------+ * */ /** * S5. Cropping: * * Cropping of the full pixel array (for digital zoom and other use cases where * a smaller FOV is desirable) is communicated through the * ANDROID_SCALER_CROP_REGION setting. This is a per-request setting, and can * change on a per-request basis, which is critical for implementing smooth * digital zoom. * * The region is defined as a rectangle (x, y, width, height), with (x, y) * describing the top-left corner of the rectangle. The rectangle is defined on * the coordinate system of the sensor active pixel array, with (0,0) being the * top-left pixel of the active pixel array. Therefore, the width and height * cannot be larger than the dimensions reported in the * ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY static info field. The minimum allowed * width and height are reported by the HAL through the * ANDROID_SCALER_MAX_DIGITAL_ZOOM static info field, which describes the * maximum supported zoom factor. Therefore, the minimum crop region width and * height are: * * {width, height} = * { floor(ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY[0] / * ANDROID_SCALER_MAX_DIGITAL_ZOOM), * floor(ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY[1] / * ANDROID_SCALER_MAX_DIGITAL_ZOOM) } * * If the crop region needs to fulfill specific requirements (for example, it * needs to start on even coordinates, and its width/height needs to be even), * the HAL must do the necessary rounding and write out the final crop region * used in the output result metadata. Similarly, if the HAL implements video * stabilization, it must adjust the result crop region to describe the region * actually included in the output after video stabilization is applied. In * general, a camera-using application must be able to determine the field of * view it is receiving based on the crop region, the dimensions of the image * sensor, and the lens focal length. * * It is assumed that the cropping is applied after raw to other color space * conversion. Raw streams (RAW16 and RAW_OPAQUE) don't have this conversion stage, * and are not croppable. Therefore, the crop region must be ignored by the HAL * for raw streams. * * Since the crop region applies to all non-raw streams, which may have different aspect * ratios than the crop region, the exact sensor region used for each stream may * be smaller than the crop region. Specifically, each stream should maintain * square pixels and its aspect ratio by minimally further cropping the defined * crop region. If the stream's aspect ratio is wider than the crop region, the * stream should be further cropped vertically, and if the stream's aspect ratio * is narrower than the crop region, the stream should be further cropped * horizontally. * * In all cases, the stream crop must be centered within the full crop region, * and each stream is only either cropped horizontally or vertical relative to * the full crop region, never both. * * For example, if two streams are defined, a 640x480 stream (4:3 aspect), and a * 1280x720 stream (16:9 aspect), below demonstrates the expected output regions * for each stream for a few sample crop regions, on a hypothetical 3 MP (2000 x * 1500 pixel array) sensor. * * Crop region: (500, 375, 1000, 750) (4:3 aspect ratio) * * 640x480 stream crop: (500, 375, 1000, 750) (equal to crop region) * 1280x720 stream crop: (500, 469, 1000, 562) (marked with =) * * 0 1000 2000 * +---------+---------+---------+----------+ * | Active pixel array | * | | * | | * + +-------------------+ + 375 * | | | | * | O===================O | * | I 1280x720 stream I | * + I I + 750 * | I I | * | O===================O | * | | | | * + +-------------------+ + 1125 * | Crop region, 640x480 stream | * | | * | | * +---------+---------+---------+----------+ 1500 * * Crop region: (500, 375, 1333, 750) (16:9 aspect ratio) * * 640x480 stream crop: (666, 375, 1000, 750) (marked with =) * 1280x720 stream crop: (500, 375, 1333, 750) (equal to crop region) * * 0 1000 2000 * +---------+---------+---------+----------+ * | Active pixel array | * | | * | | * + +---O==================O---+ + 375 * | | I 640x480 stream I | | * | | I I | | * | | I I | | * + | I I | + 750 * | | I I | | * | | I I | | * | | I I | | * + +---O==================O---+ + 1125 * | Crop region, 1280x720 stream | * | | * | | * +---------+---------+---------+----------+ 1500 * * Crop region: (500, 375, 750, 750) (1:1 aspect ratio) * * 640x480 stream crop: (500, 469, 750, 562) (marked with =) * 1280x720 stream crop: (500, 543, 750, 414) (marged with #) * * 0 1000 2000 * +---------+---------+---------+----------+ * | Active pixel array | * | | * | | * + +--------------+ + 375 * | O==============O | * | ################ | * | # # | * + # # + 750 * | # # | * | ################ 1280x720 | * | O==============O 640x480 | * + +--------------+ + 1125 * | Crop region | * | | * | | * +---------+---------+---------+----------+ 1500 * * And a final example, a 1024x1024 square aspect ratio stream instead of the * 480p stream: * * Crop region: (500, 375, 1000, 750) (4:3 aspect ratio) * * 1024x1024 stream crop: (625, 375, 750, 750) (marked with #) * 1280x720 stream crop: (500, 469, 1000, 562) (marked with =) * * 0 1000 2000 * +---------+---------+---------+----------+ * | Active pixel array | * | | * | 1024x1024 stream | * + +--###############--+ + 375 * | | # # | | * | O===================O | * | I 1280x720 stream I | * + I I + 750 * | I I | * | O===================O | * | | # # | | * + +--###############--+ + 1125 * | Crop region | * | | * | | * +---------+---------+---------+----------+ 1500 * */ /** * S6. Error management: * * Camera HAL device ops functions that have a return value will all return * -ENODEV / NULL in case of a serious error. This means the device cannot * continue operation, and must be closed by the framework. Once this error is * returned by some method, or if notify() is called with ERROR_DEVICE, only * the close() method can be called successfully. All other methods will return * -ENODEV / NULL. * * If a device op is called in the wrong sequence, for example if the framework * calls configure_streams() is called before initialize(), the device must * return -ENOSYS from the call, and do nothing. * * Transient errors in image capture must be reported through notify() as follows: * * - The failure of an entire capture to occur must be reported by the HAL by * calling notify() with ERROR_REQUEST. Individual errors for the result * metadata or the output buffers must not be reported in this case. * * - If the metadata for a capture cannot be produced, but some image buffers * were filled, the HAL must call notify() with ERROR_RESULT. * * - If an output image buffer could not be filled, but either the metadata was * produced or some other buffers were filled, the HAL must call notify() with * ERROR_BUFFER for each failed buffer. * * In each of these transient failure cases, the HAL must still call * process_capture_result, with valid output and input (if an input buffer was * submitted) buffer_handle_t. If the result metadata could not be produced, it * should be NULL. If some buffers could not be filled, they must be returned with * process_capture_result in the error state, their release fences must be set to * the acquire fences passed by the framework, or -1 if they have been waited on by * the HAL already. * * Invalid input arguments result in -EINVAL from the appropriate methods. In * that case, the framework must act as if that call had never been made. * */ /** * S7. Key Performance Indicator (KPI) glossary: * * This includes some critical definitions that are used by KPI metrics. * * Pipeline Latency: * For a given capture request, the duration from the framework calling * process_capture_request to the HAL sending capture result and all buffers * back by process_capture_result call. To make the Pipeline Latency measure * independent of frame rate, it is measured by frame count. * * For example, when frame rate is 30 (fps), the frame duration (time interval * between adjacent frame capture time) is 33 (ms). * If it takes 5 frames for framework to get the result and buffers back for * a given request, then the Pipeline Latency is 5 (frames), instead of * 5 x 33 = 165 (ms). * * The Pipeline Latency is determined by android.request.pipelineDepth and * android.request.pipelineMaxDepth, see their definitions for more details. * */ /** * S8. Sample Use Cases: * * This includes some typical use case examples the camera HAL may support. * * S8.1 Zero Shutter Lag (ZSL) with CAMERA3_STREAM_INPUT stream. * * When Zero Shutter Lag (ZSL) is supported by the camera device, the INPUT stream * can be used for application/framework implemented ZSL use case. This kind of stream * will be used by the framework as follows: * * 1. Framework configures an opaque raw format output stream that is used to * produce the ZSL output buffers. The stream pixel format will be * HAL_PIXEL_FORMAT_RAW_OPAQUE. * * 2. Framework configures an opaque raw format input stream that is used to * send the reprocess ZSL buffers to the HAL. The stream pixel format will * also be HAL_PIXEL_FORMAT_RAW_OPAQUE. * * 3. Framework configures a YUV/JPEG output stream that is used to receive the * reprocessed data. The stream pixel format will be YCbCr_420/HAL_PIXEL_FORMAT_BLOB. * * 4. Framework picks a ZSL buffer from the output stream when a ZSL capture is * issued by the application, and sends the data back as an input buffer in a * reprocessing request, then sends to the HAL for reprocessing. * * 5. The HAL sends back the output JPEG result to framework. * * The HAL can select the actual raw buffer format and configure the ISP pipeline * appropriately based on the HAL_PIXEL_FORMAT_RAW_OPAQUE format. See this format * definition for more details. * * S8.2 Zero Shutter Lag (ZSL) with CAMERA3_STREAM_BIDIRECTIONAL stream. * * For this use case, the bidirectional stream will be used by the framework as follows: * * 1. The framework includes a buffer from this stream as output buffer in a * request as normal. * * 2. Once the HAL device returns a filled output buffer to the framework, * the framework may do one of two things with the filled buffer: * * 2. a. The framework uses the filled data, and returns the now-used buffer * to the stream queue for reuse. This behavior exactly matches the * OUTPUT type of stream. * * 2. b. The framework wants to reprocess the filled data, and uses the * buffer as an input buffer for a request. Once the HAL device has * used the reprocessing buffer, it then returns it to the * framework. The framework then returns the now-used buffer to the * stream queue for reuse. * * 3. The HAL device will be given the buffer again as an output buffer for * a request at some future point. * * For ZSL use case, the pixel format for bidirectional stream will be * HAL_PIXEL_FORMAT_RAW_OPAQUE or HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED if it * is listed in android.scaler.availableInputOutputFormatsMap. When * HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, the gralloc * usage flags for the consumer endpoint will be set to GRALLOC_USAGE_HW_CAMERA_ZSL. * A configuration stream list that has BIDIRECTIONAL stream used as input, will * usually also have a distinct OUTPUT stream to get the reprocessing data. For example, * for the ZSL use case, the stream list might be configured with the following: * * - A HAL_PIXEL_FORMAT_RAW_OPAQUE bidirectional stream is used * as input. * - And a HAL_PIXEL_FORMAT_BLOB (JPEG) output stream. * */ /** * S9. Notes on Controls and Metadata * * This section contains notes about the interpretation and usage of various metadata tags. * * S9.1 HIGH_QUALITY and FAST modes. * * Many camera post-processing blocks may be listed as having HIGH_QUALITY, * FAST, and OFF operating modes. These blocks will typically also have an * 'available modes' tag representing which of these operating modes are * available on a given device. The general policy regarding implementing * these modes is as follows: * * 1. Operating mode controls of hardware blocks that cannot be disabled * must not list OFF in their corresponding 'available modes' tags. * * 2. OFF will always be included in their corresponding 'available modes' * tag if it is possible to disable that hardware block. * * 3. FAST must always be included in the 'available modes' tags for all * post-processing blocks supported on the device. If a post-processing * block also has a slower and higher quality operating mode that does * not meet the framerate requirements for FAST mode, HIGH_QUALITY should * be included in the 'available modes' tag to represent this operating * mode. */ __BEGIN_DECLS struct camera3_device; /********************************************************************** * * Camera3 stream and stream buffer definitions. * * These structs and enums define the handles and contents of the input and * output streams connecting the HAL to various framework and application buffer * consumers. Each stream is backed by a gralloc buffer queue. * */ /** * camera3_stream_type_t: * * The type of the camera stream, which defines whether the camera HAL device is * the producer or the consumer for that stream, and how the buffers of the * stream relate to the other streams. */ typedef enum camera3_stream_type { /** * This stream is an output stream; the camera HAL device will be * responsible for filling buffers from this stream with newly captured or * reprocessed image data. */ CAMERA3_STREAM_OUTPUT = 0, /** * This stream is an input stream; the camera HAL device will be responsible * for reading buffers from this stream and sending them through the camera * processing pipeline, as if the buffer was a newly captured image from the * imager. * * The pixel format for input stream can be any format reported by * android.scaler.availableInputOutputFormatsMap. The pixel format of the * output stream that is used to produce the reprocessing data may be any * format reported by android.scaler.availableStreamConfigurations. The * supported input/output stream combinations depends the camera device * capabilities, see android.scaler.availableInputOutputFormatsMap for * stream map details. * * This kind of stream is generally used to reprocess data into higher * quality images (that otherwise would cause a frame rate performance * loss), or to do off-line reprocessing. * * A typical use case is Zero Shutter Lag (ZSL), see S8.1 for more details. * */ CAMERA3_STREAM_INPUT = 1, /** * This stream can be used for input and output. Typically, the stream is * used as an output stream, but occasionally one already-filled buffer may * be sent back to the HAL device for reprocessing. * * This kind of stream is meant generally for Zero Shutter Lag (ZSL) * features, where copying the captured image from the output buffer to the * reprocessing input buffer would be expensive. See S8.2 for more details. * * Note that the HAL will always be reprocessing data it produced. * */ CAMERA3_STREAM_BIDIRECTIONAL = 2, /** * Total number of framework-defined stream types */ CAMERA3_NUM_STREAM_TYPES } camera3_stream_type_t; /** * camera3_stream_t: * * A handle to a single camera input or output stream. A stream is defined by * the framework by its buffer resolution and format, and additionally by the * HAL with the gralloc usage flags and the maximum in-flight buffer count. * * The stream structures are owned by the framework, but pointers to a * camera3_stream passed into the HAL by configure_streams() are valid until the * end of the first subsequent configure_streams() call that _does not_ include * that camera3_stream as an argument, or until the end of the close() call. * * All camera3_stream framework-controlled members are immutable once the * camera3_stream is passed into configure_streams(). The HAL may only change * the HAL-controlled parameters during a configure_streams() call, except for * the contents of the private pointer. * * If a configure_streams() call returns a non-fatal error, all active streams * remain valid as if configure_streams() had not been called. * * The endpoint of the stream is not visible to the camera HAL device. * In DEVICE_API_VERSION_3_1, this was changed to share consumer usage flags * on streams where the camera is a producer (OUTPUT and BIDIRECTIONAL stream * types) see the usage field below. */ typedef struct camera3_stream { /***** * Set by framework before configure_streams() */ /** * The type of the stream, one of the camera3_stream_type_t values. */ int stream_type; /** * The width in pixels of the buffers in this stream */ uint32_t width; /** * The height in pixels of the buffers in this stream */ uint32_t height; /** * The pixel format for the buffers in this stream. Format is a value from * the HAL_PIXEL_FORMAT_* list in system/core/include/system/graphics.h, or * from device-specific headers. * * If HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, then the platform * gralloc module will select a format based on the usage flags provided by * the camera device and the other endpoint of the stream. * * <= CAMERA_DEVICE_API_VERSION_3_1: * * The camera HAL device must inspect the buffers handed to it in the * subsequent register_stream_buffers() call to obtain the * implementation-specific format details, if necessary. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * register_stream_buffers() won't be called by the framework, so the HAL * should configure the ISP and sensor pipeline based purely on the sizes, * usage flags, and formats for the configured streams. */ int format; /***** * Set by HAL during configure_streams(). */ /** * The gralloc usage flags for this stream, as needed by the HAL. The usage * flags are defined in gralloc.h (GRALLOC_USAGE_*), or in device-specific * headers. * * For output streams, these are the HAL's producer usage flags. For input * streams, these are the HAL's consumer usage flags. The usage flags from * the producer and the consumer will be combined together and then passed * to the platform gralloc HAL module for allocating the gralloc buffers for * each stream. * * Version information: * * == CAMERA_DEVICE_API_VERSION_3_0: * * No initial value guaranteed when passed via configure_streams(). * HAL may not use this field as input, and must write over this field * with its usage flags. * * >= CAMERA_DEVICE_API_VERSION_3_1: * * For stream_type OUTPUT and BIDIRECTIONAL, when passed via * configure_streams(), the initial value of this is the consumer's * usage flags. The HAL may use these consumer flags to decide stream * configuration. * For stream_type INPUT, when passed via configure_streams(), the initial * value of this is 0. * For all streams passed via configure_streams(), the HAL must write * over this field with its usage flags. */ uint32_t usage; /** * The maximum number of buffers the HAL device may need to have dequeued at * the same time. The HAL device may not have more buffers in-flight from * this stream than this value. */ uint32_t max_buffers; /** * A handle to HAL-private information for the stream. Will not be inspected * by the framework code. */ void *priv; } camera3_stream_t; /** * camera3_stream_configuration_t: * * A structure of stream definitions, used by configure_streams(). This * structure defines all the output streams and the reprocessing input * stream for the current camera use case. */ typedef struct camera3_stream_configuration { /** * The total number of streams requested by the framework. This includes * both input and output streams. The number of streams will be at least 1, * and there will be at least one output-capable stream. */ uint32_t num_streams; /** * An array of camera stream pointers, defining the input/output * configuration for the camera HAL device. * * At most one input-capable stream may be defined (INPUT or BIDIRECTIONAL) * in a single configuration. * * At least one output-capable stream must be defined (OUTPUT or * BIDIRECTIONAL). */ camera3_stream_t **streams; } camera3_stream_configuration_t; /** * camera3_buffer_status_t: * * The current status of a single stream buffer. */ typedef enum camera3_buffer_status { /** * The buffer is in a normal state, and can be used after waiting on its * sync fence. */ CAMERA3_BUFFER_STATUS_OK = 0, /** * The buffer does not contain valid data, and the data in it should not be * used. The sync fence must still be waited on before reusing the buffer. */ CAMERA3_BUFFER_STATUS_ERROR = 1 } camera3_buffer_status_t; /** * camera3_stream_buffer_t: * * A single buffer from a camera3 stream. It includes a handle to its parent * stream, the handle to the gralloc buffer itself, and sync fences * * The buffer does not specify whether it is to be used for input or output; * that is determined by its parent stream type and how the buffer is passed to * the HAL device. */ typedef struct camera3_stream_buffer { /** * The handle of the stream this buffer is associated with */ camera3_stream_t *stream; /** * The native handle to the buffer */ buffer_handle_t *buffer; /** * Current state of the buffer, one of the camera3_buffer_status_t * values. The framework will not pass buffers to the HAL that are in an * error state. In case a buffer could not be filled by the HAL, it must * have its status set to CAMERA3_BUFFER_STATUS_ERROR when returned to the * framework with process_capture_result(). */ int status; /** * The acquire sync fence for this buffer. The HAL must wait on this fence * fd before attempting to read from or write to this buffer. * * The framework may be set to -1 to indicate that no waiting is necessary * for this buffer. * * When the HAL returns an output buffer to the framework with * process_capture_result(), the acquire_fence must be set to -1. If the HAL * never waits on the acquire_fence due to an error in filling a buffer, * when calling process_capture_result() the HAL must set the release_fence * of the buffer to be the acquire_fence passed to it by the framework. This * will allow the framework to wait on the fence before reusing the buffer. * * For input buffers, the HAL must not change the acquire_fence field during * the process_capture_request() call. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * When the HAL returns an input buffer to the framework with * process_capture_result(), the acquire_fence must be set to -1. If the HAL * never waits on input buffer acquire fence due to an error, the sync * fences should be handled similarly to the way they are handled for output * buffers. */ int acquire_fence; /** * The release sync fence for this buffer. The HAL must set this fence when * returning buffers to the framework, or write -1 to indicate that no * waiting is required for this buffer. * * For the output buffers, the fences must be set in the output_buffers * array passed to process_capture_result(). * * <= CAMERA_DEVICE_API_VERSION_3_1: * * For the input buffer, the release fence must be set by the * process_capture_request() call. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * For the input buffer, the fences must be set in the input_buffer * passed to process_capture_result(). * * After signaling the release_fence for this buffer, the HAL * should not make any further attempts to access this buffer as the * ownership has been fully transferred back to the framework. * * If a fence of -1 was specified then the ownership of this buffer * is transferred back immediately upon the call of process_capture_result. */ int release_fence; } camera3_stream_buffer_t; /** * camera3_stream_buffer_set_t: * * The complete set of gralloc buffers for a stream. This structure is given to * register_stream_buffers() to allow the camera HAL device to register/map/etc * newly allocated stream buffers. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * Deprecated (and not used). In particular, * register_stream_buffers is also deprecated and will never be invoked. * */ typedef struct camera3_stream_buffer_set { /** * The stream handle for the stream these buffers belong to */ camera3_stream_t *stream; /** * The number of buffers in this stream. It is guaranteed to be at least * stream->max_buffers. */ uint32_t num_buffers; /** * The array of gralloc buffer handles for this stream. If the stream format * is set to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, the camera HAL device * should inspect the passed-in buffers to determine any platform-private * pixel format information. */ buffer_handle_t **buffers; } camera3_stream_buffer_set_t; /** * camera3_jpeg_blob: * * Transport header for compressed JPEG buffers in output streams. * * To capture JPEG images, a stream is created using the pixel format * HAL_PIXEL_FORMAT_BLOB. The buffer size for the stream is calculated by the * framework, based on the static metadata field android.jpeg.maxSize. Since * compressed JPEG images are of variable size, the HAL needs to include the * final size of the compressed image using this structure inside the output * stream buffer. The JPEG blob ID field must be set to CAMERA3_JPEG_BLOB_ID. * * Transport header should be at the end of the JPEG output stream buffer. That * means the jpeg_blob_id must start at byte[buffer_size - * sizeof(camera3_jpeg_blob)], where the buffer_size is the size of gralloc buffer. * Any HAL using this transport header must account for it in android.jpeg.maxSize * The JPEG data itself starts at the beginning of the buffer and should be * jpeg_size bytes long. */ typedef struct camera3_jpeg_blob { uint16_t jpeg_blob_id; uint32_t jpeg_size; } camera3_jpeg_blob_t; enum { CAMERA3_JPEG_BLOB_ID = 0x00FF }; /********************************************************************** * * Message definitions for the HAL notify() callback. * * These definitions are used for the HAL notify callback, to signal * asynchronous events from the HAL device to the Android framework. * */ /** * camera3_msg_type: * * Indicates the type of message sent, which specifies which member of the * message union is valid. * */ typedef enum camera3_msg_type { /** * An error has occurred. camera3_notify_msg.message.error contains the * error information. */ CAMERA3_MSG_ERROR = 1, /** * The exposure of a given request has * begun. camera3_notify_msg.message.shutter contains the information * the capture. */ CAMERA3_MSG_SHUTTER = 2, /** * Number of framework message types */ CAMERA3_NUM_MESSAGES } camera3_msg_type_t; /** * Defined error codes for CAMERA_MSG_ERROR */ typedef enum camera3_error_msg_code { /** * A serious failure occured. No further frames or buffer streams will * be produced by the device. Device should be treated as closed. The * client must reopen the device to use it again. The frame_number field * is unused. */ CAMERA3_MSG_ERROR_DEVICE = 1, /** * An error has occurred in processing a request. No output (metadata or * buffers) will be produced for this request. The frame_number field * specifies which request has been dropped. Subsequent requests are * unaffected, and the device remains operational. */ CAMERA3_MSG_ERROR_REQUEST = 2, /** * An error has occurred in producing an output result metadata buffer * for a request, but output stream buffers for it will still be * available. Subsequent requests are unaffected, and the device remains * operational. The frame_number field specifies the request for which * result metadata won't be available. */ CAMERA3_MSG_ERROR_RESULT = 3, /** * An error has occurred in placing an output buffer into a stream for a * request. The frame metadata and other buffers may still be * available. Subsequent requests are unaffected, and the device remains * operational. The frame_number field specifies the request for which the * buffer was dropped, and error_stream contains a pointer to the stream * that dropped the frame.u */ CAMERA3_MSG_ERROR_BUFFER = 4, /** * Number of error types */ CAMERA3_MSG_NUM_ERRORS } camera3_error_msg_code_t; /** * camera3_error_msg_t: * * Message contents for CAMERA3_MSG_ERROR */ typedef struct camera3_error_msg { /** * Frame number of the request the error applies to. 0 if the frame number * isn't applicable to the error. */ uint32_t frame_number; /** * Pointer to the stream that had a failure. NULL if the stream isn't * applicable to the error. */ camera3_stream_t *error_stream; /** * The code for this error; one of the CAMERA_MSG_ERROR enum values. */ int error_code; } camera3_error_msg_t; /** * camera3_shutter_msg_t: * * Message contents for CAMERA3_MSG_SHUTTER */ typedef struct camera3_shutter_msg { /** * Frame number of the request that has begun exposure */ uint32_t frame_number; /** * Timestamp for the start of capture. This must match the capture result * metadata's sensor exposure start timestamp. */ uint64_t timestamp; } camera3_shutter_msg_t; /** * camera3_notify_msg_t: * * The message structure sent to camera3_callback_ops_t.notify() */ typedef struct camera3_notify_msg { /** * The message type. One of camera3_notify_msg_type, or a private extension. */ int type; union { /** * Error message contents. Valid if type is CAMERA3_MSG_ERROR */ camera3_error_msg_t error; /** * Shutter message contents. Valid if type is CAMERA3_MSG_SHUTTER */ camera3_shutter_msg_t shutter; /** * Generic message contents. Used to ensure a minimum size for custom * message types. */ uint8_t generic[32]; } message; } camera3_notify_msg_t; /********************************************************************** * * Capture request/result definitions for the HAL process_capture_request() * method, and the process_capture_result() callback. * */ /** * camera3_request_template_t: * * Available template types for * camera3_device_ops.construct_default_request_settings() */ typedef enum camera3_request_template { /** * Standard camera preview operation with 3A on auto. */ CAMERA3_TEMPLATE_PREVIEW = 1, /** * Standard camera high-quality still capture with 3A and flash on auto. */ CAMERA3_TEMPLATE_STILL_CAPTURE = 2, /** * Standard video recording plus preview with 3A on auto, torch off. */ CAMERA3_TEMPLATE_VIDEO_RECORD = 3, /** * High-quality still capture while recording video. Application will * include preview, video record, and full-resolution YUV or JPEG streams in * request. Must not cause stuttering on video stream. 3A on auto. */ CAMERA3_TEMPLATE_VIDEO_SNAPSHOT = 4, /** * Zero-shutter-lag mode. Application will request preview and * full-resolution data for each frame, and reprocess it to JPEG when a * still image is requested by user. Settings should provide highest-quality * full-resolution images without compromising preview frame rate. 3A on * auto. */ CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG = 5, /** * A basic template for direct application control of capture * parameters. All automatic control is disabled (auto-exposure, auto-white * balance, auto-focus), and post-processing parameters are set to preview * quality. The manual capture parameters (exposure, sensitivity, etc.) * are set to reasonable defaults, but should be overridden by the * application depending on the intended use case. */ CAMERA3_TEMPLATE_MANUAL = 6, /* Total number of templates */ CAMERA3_TEMPLATE_COUNT, /** * First value for vendor-defined request templates */ CAMERA3_VENDOR_TEMPLATE_START = 0x40000000 } camera3_request_template_t; /** * camera3_capture_request_t: * * A single request for image capture/buffer reprocessing, sent to the Camera * HAL device by the framework in process_capture_request(). * * The request contains the settings to be used for this capture, and the set of * output buffers to write the resulting image data in. It may optionally * contain an input buffer, in which case the request is for reprocessing that * input buffer instead of capturing a new image with the camera sensor. The * capture is identified by the frame_number. * * In response, the camera HAL device must send a camera3_capture_result * structure asynchronously to the framework, using the process_capture_result() * callback. */ typedef struct camera3_capture_request { /** * The frame number is an incrementing integer set by the framework to * uniquely identify this capture. It needs to be returned in the result * call, and is also used to identify the request in asynchronous * notifications sent to camera3_callback_ops_t.notify(). */ uint32_t frame_number; /** * The settings buffer contains the capture and processing parameters for * the request. As a special case, a NULL settings buffer indicates that the * settings are identical to the most-recently submitted capture request. A * NULL buffer cannot be used as the first submitted request after a * configure_streams() call. */ const camera_metadata_t *settings; /** * The input stream buffer to use for this request, if any. * * If input_buffer is NULL, then the request is for a new capture from the * imager. If input_buffer is valid, the request is for reprocessing the * image contained in input_buffer. * * In the latter case, the HAL must set the release_fence of the * input_buffer to a valid sync fence, or to -1 if the HAL does not support * sync, before process_capture_request() returns. * * The HAL is required to wait on the acquire sync fence of the input buffer * before accessing it. * * <= CAMERA_DEVICE_API_VERSION_3_1: * * Any input buffer included here will have been registered with the HAL * through register_stream_buffers() before its inclusion in a request. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * The buffers will not have been pre-registered with the HAL. * Subsequent requests may reuse buffers, or provide entirely new buffers. */ camera3_stream_buffer_t *input_buffer; /** * The number of output buffers for this capture request. Must be at least * 1. */ uint32_t num_output_buffers; /** * An array of num_output_buffers stream buffers, to be filled with image * data from this capture/reprocess. The HAL must wait on the acquire fences * of each stream buffer before writing to them. * * The HAL takes ownership of the actual buffer_handle_t entries in * output_buffers; the framework does not access them until they are * returned in a camera3_capture_result_t. * * <= CAMERA_DEVICE_API_VERSION_3_1: * * All the buffers included here will have been registered with the HAL * through register_stream_buffers() before their inclusion in a request. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * Any or all of the buffers included here may be brand new in this * request (having never before seen by the HAL). */ const camera3_stream_buffer_t *output_buffers; } camera3_capture_request_t; /** * camera3_capture_result_t: * * The result of a single capture/reprocess by the camera HAL device. This is * sent to the framework asynchronously with process_capture_result(), in * response to a single capture request sent to the HAL with * process_capture_request(). Multiple process_capture_result() calls may be * performed by the HAL for each request. * * Each call, all with the same frame * number, may contain some subset of the output buffers, and/or the result * metadata. The metadata may only be provided once for a given frame number; * all other calls must set the result metadata to NULL. * * The result structure contains the output metadata from this capture, and the * set of output buffers that have been/will be filled for this capture. Each * output buffer may come with a release sync fence that the framework will wait * on before reading, in case the buffer has not yet been filled by the HAL. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * The metadata may be provided multiple times for a single frame number. The * framework will accumulate together the final result set by combining each * partial result together into the total result set. * * If an input buffer is given in a request, the HAL must return it in one of * the process_capture_result calls, and the call may be to just return the input * buffer, without metadata and output buffers; the sync fences must be handled * the same way they are done for output buffers. * * * Performance considerations: * * Applications will also receive these partial results immediately, so sending * partial results is a highly recommended performance optimization to avoid * the total pipeline latency before sending the results for what is known very * early on in the pipeline. * * A typical use case might be calculating the AF state halfway through the * pipeline; by sending the state back to the framework immediately, we get a * 50% performance increase and perceived responsiveness of the auto-focus. * */ typedef struct camera3_capture_result { /** * The frame number is an incrementing integer set by the framework in the * submitted request to uniquely identify this capture. It is also used to * identify the request in asynchronous notifications sent to * camera3_callback_ops_t.notify(). */ uint32_t frame_number; /** * The result metadata for this capture. This contains information about the * final capture parameters, the state of the capture and post-processing * hardware, the state of the 3A algorithms, if enabled, and the output of * any enabled statistics units. * * Only one call to process_capture_result() with a given frame_number may * include the result metadata. All other calls for the same frame_number * must set this to NULL. * * If there was an error producing the result metadata, result must be an * empty metadata buffer, and notify() must be called with ERROR_RESULT. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * Multiple calls to process_capture_result() with a given frame_number * may include the result metadata. * * Partial metadata submitted should not include any metadata key returned * in a previous partial result for a given frame. Each new partial result * for that frame must also set a distinct partial_result value. * * If notify has been called with ERROR_RESULT, all further partial * results for that frame are ignored by the framework. */ const camera_metadata_t *result; /** * The number of output buffers returned in this result structure. Must be * less than or equal to the matching capture request's count. If this is * less than the buffer count in the capture request, at least one more call * to process_capture_result with the same frame_number must be made, to * return the remaining output buffers to the framework. This may only be * zero if the structure includes valid result metadata or an input buffer * is returned in this result. */ uint32_t num_output_buffers; /** * The handles for the output stream buffers for this capture. They may not * yet be filled at the time the HAL calls process_capture_result(); the * framework will wait on the release sync fences provided by the HAL before * reading the buffers. * * The HAL must set the stream buffer's release sync fence to a valid sync * fd, or to -1 if the buffer has already been filled. * * If the HAL encounters an error while processing the buffer, and the * buffer is not filled, the buffer's status field must be set to * CAMERA3_BUFFER_STATUS_ERROR. If the HAL did not wait on the acquire fence * before encountering the error, the acquire fence should be copied into * the release fence, to allow the framework to wait on the fence before * reusing the buffer. * * The acquire fence must be set to -1 for all output buffers. If * num_output_buffers is zero, this may be NULL. In that case, at least one * more process_capture_result call must be made by the HAL to provide the * output buffers. * * When process_capture_result is called with a new buffer for a frame, * all previous frames' buffers for that corresponding stream must have been * already delivered (the fences need not have yet been signaled). * * >= CAMERA_DEVICE_API_VERSION_3_2: * * Gralloc buffers for a frame may be sent to framework before the * corresponding SHUTTER-notify. * * Performance considerations: * * Buffers delivered to the framework will not be dispatched to the * application layer until a start of exposure timestamp has been received * via a SHUTTER notify() call. It is highly recommended to * dispatch that call as early as possible. */ const camera3_stream_buffer_t *output_buffers; /** * >= CAMERA_DEVICE_API_VERSION_3_2: * * The handle for the input stream buffer for this capture. It may not * yet be consumed at the time the HAL calls process_capture_result(); the * framework will wait on the release sync fences provided by the HAL before * reusing the buffer. * * The HAL should handle the sync fences the same way they are done for * output_buffers. * * Only one input buffer is allowed to be sent per request. Similarly to * output buffers, the ordering of returned input buffers must be * maintained by the HAL. * * Performance considerations: * * The input buffer should be returned as early as possible. If the HAL * supports sync fences, it can call process_capture_result to hand it back * with sync fences being set appropriately. If the sync fences are not * supported, the buffer can only be returned when it is consumed, which * may take long time; the HAL may choose to copy this input buffer to make * the buffer return sooner. */ const camera3_stream_buffer_t *input_buffer; /** * >= CAMERA_DEVICE_API_VERSION_3_2: * * In order to take advantage of partial results, the HAL must set the * static metadata android.request.partialResultCount to the number of * partial results it will send for each frame. * * Each new capture result with a partial result must set * this field (partial_result) to a distinct inclusive value between * 1 and android.request.partialResultCount. * * HALs not wishing to take advantage of this feature must not * set an android.request.partialResultCount or partial_result to a value * other than 1. * * This value must be set to 0 when a capture result contains buffers only * and no metadata. */ uint32_t partial_result; } camera3_capture_result_t; /********************************************************************** * * Callback methods for the HAL to call into the framework. * * These methods are used to return metadata and image buffers for a completed * or failed captures, and to notify the framework of asynchronous events such * as errors. * * The framework will not call back into the HAL from within these callbacks, * and these calls will not block for extended periods. * */ typedef struct camera3_callback_ops { /** * process_capture_result: * * Send results from a completed capture to the framework. * process_capture_result() may be invoked multiple times by the HAL in * response to a single capture request. This allows, for example, the * metadata and low-resolution buffers to be returned in one call, and * post-processed JPEG buffers in a later call, once it is available. Each * call must include the frame number of the request it is returning * metadata or buffers for. * * A component (buffer or metadata) of the complete result may only be * included in one process_capture_result call. A buffer for each stream, * and the result metadata, must be returned by the HAL for each request in * one of the process_capture_result calls, even in case of errors producing * some of the output. A call to process_capture_result() with neither * output buffers or result metadata is not allowed. * * The order of returning metadata and buffers for a single result does not * matter, but buffers for a given stream must be returned in FIFO order. So * the buffer for request 5 for stream A must always be returned before the * buffer for request 6 for stream A. This also applies to the result * metadata; the metadata for request 5 must be returned before the metadata * for request 6. * * However, different streams are independent of each other, so it is * acceptable and expected that the buffer for request 5 for stream A may be * returned after the buffer for request 6 for stream B is. And it is * acceptable that the result metadata for request 6 for stream B is * returned before the buffer for request 5 for stream A is. * * The HAL retains ownership of result structure, which only needs to be * valid to access during this call. The framework will copy whatever it * needs before this call returns. * * The output buffers do not need to be filled yet; the framework will wait * on the stream buffer release sync fence before reading the buffer * data. Therefore, this method should be called by the HAL as soon as * possible, even if some or all of the output buffers are still in * being filled. The HAL must include valid release sync fences into each * output_buffers stream buffer entry, or -1 if that stream buffer is * already filled. * * If the result buffer cannot be constructed for a request, the HAL should * return an empty metadata buffer, but still provide the output buffers and * their sync fences. In addition, notify() must be called with an * ERROR_RESULT message. * * If an output buffer cannot be filled, its status field must be set to * STATUS_ERROR. In addition, notify() must be called with a ERROR_BUFFER * message. * * If the entire capture has failed, then this method still needs to be * called to return the output buffers to the framework. All the buffer * statuses should be STATUS_ERROR, and the result metadata should be an * empty buffer. In addition, notify() must be called with a ERROR_REQUEST * message. In this case, individual ERROR_RESULT/ERROR_BUFFER messages * should not be sent. * * Performance requirements: * * This is a non-blocking call. The framework will return this call in 5ms. * * The pipeline latency (see S7 for definition) should be less than or equal to * 4 frame intervals, and must be less than or equal to 8 frame intervals. * */ void (*process_capture_result)(const struct camera3_callback_ops *, const camera3_capture_result_t *result); /** * notify: * * Asynchronous notification callback from the HAL, fired for various * reasons. Only for information independent of frame capture, or that * require specific timing. The ownership of the message structure remains * with the HAL, and the msg only needs to be valid for the duration of this * call. * * Multiple threads may call notify() simultaneously. * * <= CAMERA_DEVICE_API_VERSION_3_1: * * The notification for the start of exposure for a given request must be * sent by the HAL before the first call to process_capture_result() for * that request is made. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * Buffers delivered to the framework will not be dispatched to the * application layer until a start of exposure timestamp has been received * via a SHUTTER notify() call. It is highly recommended to * dispatch this call as early as possible. * * ------------------------------------------------------------------------ * Performance requirements: * * This is a non-blocking call. The framework will return this call in 5ms. */ void (*notify)(const struct camera3_callback_ops *, const camera3_notify_msg_t *msg); } camera3_callback_ops_t; /********************************************************************** * * Camera device operations * */ typedef struct camera3_device_ops { /** * initialize: * * One-time initialization to pass framework callback function pointers to * the HAL. Will be called once after a successful open() call, before any * other functions are called on the camera3_device_ops structure. * * Performance requirements: * * This should be a non-blocking call. The HAL should return from this call * in 5ms, and must return from this call in 10ms. * * Return values: * * 0: On successful initialization * * -ENODEV: If initialization fails. Only close() can be called successfully * by the framework after this. */ int (*initialize)(const struct camera3_device *, const camera3_callback_ops_t *callback_ops); /********************************************************************** * Stream management */ /** * configure_streams: * * CAMERA_DEVICE_API_VERSION_3_0 only: * * Reset the HAL camera device processing pipeline and set up new input and * output streams. This call replaces any existing stream configuration with * the streams defined in the stream_list. This method will be called at * least once after initialize() before a request is submitted with * process_capture_request(). * * The stream_list must contain at least one output-capable stream, and may * not contain more than one input-capable stream. * * The stream_list may contain streams that are also in the currently-active * set of streams (from the previous call to configure_stream()). These * streams will already have valid values for usage, max_buffers, and the * private pointer. * * If such a stream has already had its buffers registered, * register_stream_buffers() will not be called again for the stream, and * buffers from the stream can be immediately included in input requests. * * If the HAL needs to change the stream configuration for an existing * stream due to the new configuration, it may rewrite the values of usage * and/or max_buffers during the configure call. * * The framework will detect such a change, and will then reallocate the * stream buffers, and call register_stream_buffers() again before using * buffers from that stream in a request. * * If a currently-active stream is not included in stream_list, the HAL may * safely remove any references to that stream. It will not be reused in a * later configure() call by the framework, and all the gralloc buffers for * it will be freed after the configure_streams() call returns. * * The stream_list structure is owned by the framework, and may not be * accessed once this call completes. The address of an individual * camera3_stream_t structure will remain valid for access by the HAL until * the end of the first configure_stream() call which no longer includes * that camera3_stream_t in the stream_list argument. The HAL may not change * values in the stream structure outside of the private pointer, except for * the usage and max_buffers members during the configure_streams() call * itself. * * If the stream is new, the usage, max_buffer, and private pointer fields * of the stream structure will all be set to 0. The HAL device must set * these fields before the configure_streams() call returns. These fields * are then used by the framework and the platform gralloc module to * allocate the gralloc buffers for each stream. * * Before such a new stream can have its buffers included in a capture * request, the framework will call register_stream_buffers() with that * stream. However, the framework is not required to register buffers for * _all_ streams before submitting a request. This allows for quick startup * of (for example) a preview stream, with allocation for other streams * happening later or concurrently. * * ------------------------------------------------------------------------ * CAMERA_DEVICE_API_VERSION_3_1 only: * * Reset the HAL camera device processing pipeline and set up new input and * output streams. This call replaces any existing stream configuration with * the streams defined in the stream_list. This method will be called at * least once after initialize() before a request is submitted with * process_capture_request(). * * The stream_list must contain at least one output-capable stream, and may * not contain more than one input-capable stream. * * The stream_list may contain streams that are also in the currently-active * set of streams (from the previous call to configure_stream()). These * streams will already have valid values for usage, max_buffers, and the * private pointer. * * If such a stream has already had its buffers registered, * register_stream_buffers() will not be called again for the stream, and * buffers from the stream can be immediately included in input requests. * * If the HAL needs to change the stream configuration for an existing * stream due to the new configuration, it may rewrite the values of usage * and/or max_buffers during the configure call. * * The framework will detect such a change, and will then reallocate the * stream buffers, and call register_stream_buffers() again before using * buffers from that stream in a request. * * If a currently-active stream is not included in stream_list, the HAL may * safely remove any references to that stream. It will not be reused in a * later configure() call by the framework, and all the gralloc buffers for * it will be freed after the configure_streams() call returns. * * The stream_list structure is owned by the framework, and may not be * accessed once this call completes. The address of an individual * camera3_stream_t structure will remain valid for access by the HAL until * the end of the first configure_stream() call which no longer includes * that camera3_stream_t in the stream_list argument. The HAL may not change * values in the stream structure outside of the private pointer, except for * the usage and max_buffers members during the configure_streams() call * itself. * * If the stream is new, max_buffer, and private pointer fields of the * stream structure will all be set to 0. The usage will be set to the * consumer usage flags. The HAL device must set these fields before the * configure_streams() call returns. These fields are then used by the * framework and the platform gralloc module to allocate the gralloc * buffers for each stream. * * Before such a new stream can have its buffers included in a capture * request, the framework will call register_stream_buffers() with that * stream. However, the framework is not required to register buffers for * _all_ streams before submitting a request. This allows for quick startup * of (for example) a preview stream, with allocation for other streams * happening later or concurrently. * * ------------------------------------------------------------------------ * >= CAMERA_DEVICE_API_VERSION_3_2: * * Reset the HAL camera device processing pipeline and set up new input and * output streams. This call replaces any existing stream configuration with * the streams defined in the stream_list. This method will be called at * least once after initialize() before a request is submitted with * process_capture_request(). * * The stream_list must contain at least one output-capable stream, and may * not contain more than one input-capable stream. * * The stream_list may contain streams that are also in the currently-active * set of streams (from the previous call to configure_stream()). These * streams will already have valid values for usage, max_buffers, and the * private pointer. * * If the HAL needs to change the stream configuration for an existing * stream due to the new configuration, it may rewrite the values of usage * and/or max_buffers during the configure call. * * The framework will detect such a change, and may then reallocate the * stream buffers before using buffers from that stream in a request. * * If a currently-active stream is not included in stream_list, the HAL may * safely remove any references to that stream. It will not be reused in a * later configure() call by the framework, and all the gralloc buffers for * it will be freed after the configure_streams() call returns. * * The stream_list structure is owned by the framework, and may not be * accessed once this call completes. The address of an individual * camera3_stream_t structure will remain valid for access by the HAL until * the end of the first configure_stream() call which no longer includes * that camera3_stream_t in the stream_list argument. The HAL may not change * values in the stream structure outside of the private pointer, except for * the usage and max_buffers members during the configure_streams() call * itself. * * If the stream is new, max_buffer, and private pointer fields of the * stream structure will all be set to 0. The usage will be set to the * consumer usage flags. The HAL device must set these fields before the * configure_streams() call returns. These fields are then used by the * framework and the platform gralloc module to allocate the gralloc * buffers for each stream. * * Newly allocated buffers may be included in a capture request at any time * by the framework. Once a gralloc buffer is returned to the framework * with process_capture_result (and its respective release_fence has been * signaled) the framework may free or reuse it at any time. * * ------------------------------------------------------------------------ * * Preconditions: * * The framework will only call this method when no captures are being * processed. That is, all results have been returned to the framework, and * all in-flight input and output buffers have been returned and their * release sync fences have been signaled by the HAL. The framework will not * submit new requests for capture while the configure_streams() call is * underway. * * Postconditions: * * The HAL device must configure itself to provide maximum possible output * frame rate given the sizes and formats of the output streams, as * documented in the camera device's static metadata. * * Performance requirements: * * This call is expected to be heavyweight and possibly take several hundred * milliseconds to complete, since it may require resetting and * reconfiguring the image sensor and the camera processing pipeline. * Nevertheless, the HAL device should attempt to minimize the * reconfiguration delay to minimize the user-visible pauses during * application operational mode changes (such as switching from still * capture to video recording). * * The HAL should return from this call in 500ms, and must return from this * call in 1000ms. * * Return values: * * 0: On successful stream configuration * * -EINVAL: If the requested stream configuration is invalid. Some examples * of invalid stream configurations include: * * - Including more than 1 input-capable stream (INPUT or * BIDIRECTIONAL) * * - Not including any output-capable streams (OUTPUT or * BIDIRECTIONAL) * * - Including streams with unsupported formats, or an unsupported * size for that format. * * - Including too many output streams of a certain format. * * Note that the framework submitting an invalid stream * configuration is not normal operation, since stream * configurations are checked before configure. An invalid * configuration means that a bug exists in the framework code, or * there is a mismatch between the HAL's static metadata and the * requirements on streams. * * -ENODEV: If there has been a fatal error and the device is no longer * operational. Only close() can be called successfully by the * framework after this error is returned. */ int (*configure_streams)(const struct camera3_device *, camera3_stream_configuration_t *stream_list); /** * register_stream_buffers: * * >= CAMERA_DEVICE_API_VERSION_3_2: * * DEPRECATED. This will not be called and must be set to NULL. * * <= CAMERA_DEVICE_API_VERSION_3_1: * * Register buffers for a given stream with the HAL device. This method is * called by the framework after a new stream is defined by * configure_streams, and before buffers from that stream are included in a * capture request. If the same stream is listed in a subsequent * configure_streams() call, register_stream_buffers will _not_ be called * again for that stream. * * The framework does not need to register buffers for all configured * streams before it submits the first capture request. This allows quick * startup for preview (or similar use cases) while other streams are still * being allocated. * * This method is intended to allow the HAL device to map or otherwise * prepare the buffers for later use. The buffers passed in will already be * locked for use. At the end of the call, all the buffers must be ready to * be returned to the stream. The buffer_set argument is only valid for the * duration of this call. * * If the stream format was set to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, * the camera HAL should inspect the passed-in buffers here to determine any * platform-private pixel format information. * * Performance requirements: * * This should be a non-blocking call. The HAL should return from this call * in 1ms, and must return from this call in 5ms. * * Return values: * * 0: On successful registration of the new stream buffers * * -EINVAL: If the stream_buffer_set does not refer to a valid active * stream, or if the buffers array is invalid. * * -ENOMEM: If there was a failure in registering the buffers. The framework * must consider all the stream buffers to be unregistered, and can * try to register again later. * * -ENODEV: If there is a fatal error, and the device is no longer * operational. Only close() can be called successfully by the * framework after this error is returned. */ int (*register_stream_buffers)(const struct camera3_device *, const camera3_stream_buffer_set_t *buffer_set); /********************************************************************** * Request creation and submission */ /** * construct_default_request_settings: * * Create capture settings for standard camera use cases. * * The device must return a settings buffer that is configured to meet the * requested use case, which must be one of the CAMERA3_TEMPLATE_* * enums. All request control fields must be included. * * The HAL retains ownership of this structure, but the pointer to the * structure must be valid until the device is closed. The framework and the * HAL may not modify the buffer once it is returned by this call. The same * buffer may be returned for subsequent calls for the same template, or for * other templates. * * Performance requirements: * * This should be a non-blocking call. The HAL should return from this call * in 1ms, and must return from this call in 5ms. * * Return values: * * Valid metadata: On successful creation of a default settings * buffer. * * NULL: In case of a fatal error. After this is returned, only * the close() method can be called successfully by the * framework. */ const camera_metadata_t* (*construct_default_request_settings)( const struct camera3_device *, int type); /** * process_capture_request: * * Send a new capture request to the HAL. The HAL should not return from * this call until it is ready to accept the next request to process. Only * one call to process_capture_request() will be made at a time by the * framework, and the calls will all be from the same thread. The next call * to process_capture_request() will be made as soon as a new request and * its associated buffers are available. In a normal preview scenario, this * means the function will be called again by the framework almost * instantly. * * The actual request processing is asynchronous, with the results of * capture being returned by the HAL through the process_capture_result() * call. This call requires the result metadata to be available, but output * buffers may simply provide sync fences to wait on. Multiple requests are * expected to be in flight at once, to maintain full output frame rate. * * The framework retains ownership of the request structure. It is only * guaranteed to be valid during this call. The HAL device must make copies * of the information it needs to retain for the capture processing. The HAL * is responsible for waiting on and closing the buffers' fences and * returning the buffer handles to the framework. * * The HAL must write the file descriptor for the input buffer's release * sync fence into input_buffer->release_fence, if input_buffer is not * NULL. If the HAL returns -1 for the input buffer release sync fence, the * framework is free to immediately reuse the input buffer. Otherwise, the * framework will wait on the sync fence before refilling and reusing the * input buffer. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * The input/output buffers provided by the framework in each request * may be brand new (having never before seen by the HAL). * * ------------------------------------------------------------------------ * Performance considerations: * * Handling a new buffer should be extremely lightweight and there should be * no frame rate degradation or frame jitter introduced. * * This call must return fast enough to ensure that the requested frame * rate can be sustained, especially for streaming cases (post-processing * quality settings set to FAST). The HAL should return this call in 1 * frame interval, and must return from this call in 4 frame intervals. * * Return values: * * 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 * 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 * stream buffers' fences and the buffer handles; the HAL should * not close the fences or return these buffers with * process_capture_result. * * -ENODEV: If the camera device has encountered a serious error. After this * error is returned, only the close() method can be successfully * called by the framework. * */ int (*process_capture_request)(const struct camera3_device *, camera3_capture_request_t *request); /********************************************************************** * Miscellaneous methods */ /** * get_metadata_vendor_tag_ops: * * Get methods to query for vendor extension metadata tag information. The * HAL should fill in all the vendor tag operation methods, or leave ops * unchanged if no vendor tags are defined. * * The definition of vendor_tag_query_ops_t can be found in * system/media/camera/include/system/camera_metadata.h. * * >= CAMERA_DEVICE_API_VERSION_3_2: * DEPRECATED. This function has been deprecated and should be set to * NULL by the HAL. Please implement get_vendor_tag_ops in camera_common.h * instead. */ void (*get_metadata_vendor_tag_ops)(const struct camera3_device*, vendor_tag_query_ops_t* ops); /** * dump: * * Print out debugging state for the camera device. This will be called by * the framework when the camera service is asked for a debug dump, which * happens when using the dumpsys tool, or when capturing a bugreport. * * 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 during camera operation. * Any synchronization primitives used (such as mutex locks or semaphores) * should be acquired with a timeout. */ void (*dump)(const struct camera3_device *, int fd); /** * flush: * * Flush all currently in-process captures and all buffers in the pipeline * on the given device. The framework will use this to dump all state as * quickly as possible in order to prepare for a configure_streams() call. * * No buffers are required to be successfully returned, so every buffer * held at the time of flush() (whether successfully filled or not) may be * returned with CAMERA3_BUFFER_STATUS_ERROR. Note the HAL is still allowed * to return valid (CAMERA3_BUFFER_STATUS_OK) buffers during this call, * provided they are successfully filled. * * All requests currently in the HAL are expected to be returned as soon as * possible. Not-in-process requests should return errors immediately. Any * interruptible hardware blocks should be stopped, and any uninterruptible * blocks should be waited on. * * More specifically, the HAL must follow below requirements for various cases: * * 1. For captures that are too late for the HAL to cancel/stop, and will be * completed normally by the HAL; i.e. the HAL can send shutter/notify and * process_capture_result and buffers as normal. * * 2. For pending requests that have not done any processing, the HAL must call notify * CAMERA3_MSG_ERROR_REQUEST, and return all the output buffers with * process_capture_result in the error state (CAMERA3_BUFFER_STATUS_ERROR). * The HAL must not place the release fence into an error state, instead, * the release fences must be set to the acquire fences passed by the framework, * or -1 if they have been waited on by the HAL already. This is also the path * to follow for any captures for which the HAL already called notify() with * CAMERA3_MSG_SHUTTER but won't be producing any metadata/valid buffers for. * After CAMERA3_MSG_ERROR_REQUEST, for a given frame, only process_capture_results with * buffers in CAMERA3_BUFFER_STATUS_ERROR are allowed. No further notifys or * process_capture_result with non-null metadata is allowed. * * 3. For partially completed pending requests that will not have all the output * buffers or perhaps missing metadata, the HAL should follow below: * * 3.1. Call notify with CAMERA3_MSG_ERROR_RESULT if some of the expected result * metadata (i.e. one or more partial metadata) won't be available for the capture. * * 3.2. Call notify with CAMERA3_MSG_ERROR_BUFFER for every buffer that won't * be produced for the capture. * * 3.3 Call notify with CAMERA3_MSG_SHUTTER with the capture timestamp before * any buffers/metadata are returned with process_capture_result. * * 3.4 For captures that will produce some results, the HAL must not call * CAMERA3_MSG_ERROR_REQUEST, since that indicates complete failure. * * 3.5. Valid buffers/metadata should be passed to the framework as normal. * * 3.6. Failed buffers should be returned to the framework as described for case 2. * But failed buffers do not have to follow the strict ordering valid buffers do, * and may be out-of-order with respect to valid buffers. For example, if buffers * A, B, C, D, E are sent, D and E are failed, then A, E, B, D, C is an acceptable * return order. * * 3.7. For fully-missing metadata, calling CAMERA3_MSG_ERROR_RESULT is sufficient, no * need to call process_capture_result with NULL metadata or equivalent. * * flush() should only return when there are no more outstanding buffers or * requests left in the HAL. The framework may call configure_streams (as * the HAL state is now quiesced) or may issue new requests. * * Note that it's sufficient to only support fully-succeeded and fully-failed result cases. * However, it is highly desirable to support the partial failure cases as well, as it * could help improve the flush call overall performance. * * Performance requirements: * * The HAL should return from this call in 100ms, and must return from this * call in 1000ms. And this call must not be blocked longer than pipeline * latency (see S7 for definition). * * Version information: * * only available if device version >= CAMERA_DEVICE_API_VERSION_3_1. * * Return values: * * 0: On a successful flush of the camera HAL. * * -EINVAL: If the input is malformed (the device is not valid). * * -ENODEV: If the camera device has encountered a serious error. After this * error is returned, only the close() method can be successfully * called by the framework. */ int (*flush)(const struct camera3_device *); /* reserved for future use */ void *reserved[8]; } camera3_device_ops_t; /********************************************************************** * * Camera device definition * */ typedef struct camera3_device { /** * common.version must equal CAMERA_DEVICE_API_VERSION_3_0 to identify this * device as implementing version 3.0 of the camera device HAL. * * Performance requirements: * * Camera open (common.module->common.methods->open) should return in 200ms, and must return * in 500ms. * Camera close (common.close) should return in 200ms, and must return in 500ms. * */ hw_device_t common; camera3_device_ops_t *ops; void *priv; } camera3_device_t; __END_DECLS #endif /* #ifdef ANDROID_INCLUDE_CAMERA3_H */ android-headers-23/21/hardware/camera_common.h000066400000000000000000000410351264465411000213270ustar00rootroot00000000000000/* * 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. */ // FIXME: add well-defined names for cameras #ifndef ANDROID_INCLUDE_CAMERA_COMMON_H #define ANDROID_INCLUDE_CAMERA_COMMON_H #include #include #include #include #include #include #include #include __BEGIN_DECLS /** * The id of this module */ #define CAMERA_HARDWARE_MODULE_ID "camera" /** * Module versioning information for the Camera hardware module, based on * camera_module_t.common.module_api_version. The two most significant hex * digits represent the major version, and the two least significant represent * the minor version. * ******************************************************************************* * Versions: 0.X - 1.X [CAMERA_MODULE_API_VERSION_1_0] * * Camera modules that report these version numbers implement the initial * camera module HAL interface. All camera devices openable through this * module support only version 1 of the camera device HAL. The device_version * and static_camera_characteristics fields of camera_info are not valid. Only * the android.hardware.Camera API can be supported by this module and its * devices. * ******************************************************************************* * Version: 2.0 [CAMERA_MODULE_API_VERSION_2_0] * * Camera modules that report this version number implement the second version * of the camera module HAL interface. Camera devices openable through this * module may support either version 1.0 or version 2.0 of the camera device * HAL interface. The device_version field of camera_info is always valid; the * static_camera_characteristics field of camera_info is valid if the * device_version field is 2.0 or higher. * ******************************************************************************* * Version: 2.1 [CAMERA_MODULE_API_VERSION_2_1] * * This camera module version adds support for asynchronous callbacks to the * framework from the camera HAL module, which is used to notify the framework * about changes to the camera module state. Modules that provide a valid * set_callbacks() method must report at least this version number. * ******************************************************************************* * Version: 2.2 [CAMERA_MODULE_API_VERSION_2_2] * * This camera module version adds vendor tag support from the module, and * deprecates the old vendor_tag_query_ops that were previously only * accessible with a device open. * ******************************************************************************* * Version: 2.3 [CAMERA_MODULE_API_VERSION_2_3] * * This camera module version adds open legacy camera HAL device support. * Framework can use it to open the camera device as lower device HAL version * HAL device if the same device can support multiple device API versions. * The standard hardware module open call (common.methods->open) continues * to open the camera device with the latest supported version, which is * also the version listed in camera_info_t.device_version. */ /** * Predefined macros for currently-defined version numbers */ /** * All module versions <= HARDWARE_MODULE_API_VERSION(1, 0xFF) must be treated * as CAMERA_MODULE_API_VERSION_1_0 */ #define CAMERA_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) #define CAMERA_MODULE_API_VERSION_2_0 HARDWARE_MODULE_API_VERSION(2, 0) #define CAMERA_MODULE_API_VERSION_2_1 HARDWARE_MODULE_API_VERSION(2, 1) #define CAMERA_MODULE_API_VERSION_2_2 HARDWARE_MODULE_API_VERSION(2, 2) #define CAMERA_MODULE_API_VERSION_2_3 HARDWARE_MODULE_API_VERSION(2, 3) #define CAMERA_MODULE_API_VERSION_CURRENT CAMERA_MODULE_API_VERSION_2_3 /** * All device versions <= HARDWARE_DEVICE_API_VERSION(1, 0xFF) must be treated * as CAMERA_DEVICE_API_VERSION_1_0 */ #define CAMERA_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) #define CAMERA_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 0) #define CAMERA_DEVICE_API_VERSION_2_1 HARDWARE_DEVICE_API_VERSION(2, 1) #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_2 HARDWARE_DEVICE_API_VERSION(3, 2) // Device version 3.2 is current, older HAL camera device versions are not // recommended for new devices. #define CAMERA_DEVICE_API_VERSION_CURRENT CAMERA_DEVICE_API_VERSION_3_2 /** * Defined in /system/media/camera/include/system/camera_metadata.h */ typedef struct camera_metadata camera_metadata_t; typedef struct camera_info { /** * The direction that the camera faces to. It should be CAMERA_FACING_BACK * or CAMERA_FACING_FRONT. * * Version information: * Valid in all camera_module versions */ int facing; /** * The orientation of the camera image. The value is the angle that the * camera image needs to be rotated clockwise so it shows correctly on the * display in its natural orientation. It should be 0, 90, 180, or 270. * * For example, suppose a device has a naturally tall screen. The * back-facing camera sensor is mounted in landscape. You are looking at the * screen. If the top side of the camera sensor is aligned with the right * edge of the screen in natural orientation, the value should be 90. If the * top side of a front-facing camera sensor is aligned with the right of the * screen, the value should be 270. * * Version information: * Valid in all camera_module versions */ int orientation; /** * The value of camera_device_t.common.version. * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_1_0: * * Not valid. Can be assumed to be CAMERA_DEVICE_API_VERSION_1_0. Do * not read this field. * * CAMERA_MODULE_API_VERSION_2_0 or higher: * * Always valid * */ uint32_t device_version; /** * The camera's fixed characteristics, which include all camera metadata in * the android.*.info.* sections. This should be a sorted metadata buffer, * and may not be modified or freed by the caller. The pointer should remain * valid for the lifetime of the camera module, and values in it may not * change after it is returned by get_camera_info(). * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_1_0: * * Not valid. Extra characteristics are not available. Do not read this * field. * * CAMERA_MODULE_API_VERSION_2_0 or higher: * * Valid if device_version >= CAMERA_DEVICE_API_VERSION_2_0. Do not read * otherwise. * */ const camera_metadata_t *static_camera_characteristics; } camera_info_t; /** * camera_device_status_t: * * The current status of the camera device, as provided by the HAL through the * camera_module_callbacks.camera_device_status_change() call. * * At module load time, the framework will assume all camera devices are in the * CAMERA_DEVICE_STATUS_PRESENT state. The HAL should invoke * camera_module_callbacks::camera_device_status_change to inform the framework * of any initially NOT_PRESENT devices. * * Allowed transitions: * PRESENT -> NOT_PRESENT * NOT_PRESENT -> ENUMERATING * NOT_PRESENT -> PRESENT * ENUMERATING -> PRESENT * ENUMERATING -> NOT_PRESENT */ typedef enum camera_device_status { /** * The camera device is not currently connected, and opening it will return * failure. Calls to get_camera_info must still succeed, and provide the * same information it would if the camera were connected */ CAMERA_DEVICE_STATUS_NOT_PRESENT = 0, /** * The camera device is connected, and opening it will succeed. The * information returned by get_camera_info cannot change due to this status * change. By default, the framework will assume all devices are in this * state. */ CAMERA_DEVICE_STATUS_PRESENT = 1, /** * The camera device is connected, but it is undergoing an enumeration and * so opening the device will return -EBUSY. Calls to get_camera_info * must still succeed, as if the camera was in the PRESENT status. */ CAMERA_DEVICE_STATUS_ENUMERATING = 2, } camera_device_status_t; /** * Callback functions for the camera HAL module to use to inform the framework * of changes to the camera subsystem. These are called only by HAL modules * implementing version CAMERA_MODULE_API_VERSION_2_1 or higher of the HAL * module API interface. */ typedef struct camera_module_callbacks { /** * camera_device_status_change: * * Callback to the framework to indicate that the state of a specific camera * device has changed. At module load time, the framework will assume all * camera devices are in the CAMERA_DEVICE_STATUS_PRESENT state. The HAL * must call this method to inform the framework of any initially * NOT_PRESENT devices. * * camera_module_callbacks: The instance of camera_module_callbacks_t passed * to the module with set_callbacks. * * camera_id: The ID of the camera device that has a new status. * * new_status: The new status code, one of the camera_device_status_t enums, * or a platform-specific status. * */ void (*camera_device_status_change)(const struct camera_module_callbacks*, int camera_id, int new_status); } camera_module_callbacks_t; typedef struct camera_module { /** * Common methods of the camera module. This *must* be the first member of * camera_module as users of this structure will cast a hw_module_t to * camera_module pointer in contexts where it's known the hw_module_t * references a camera_module. * * The return values for common.methods->open for camera_module are: * * 0: On a successful open of the camera device. * * -ENODEV: The camera device cannot be opened due to an internal * error. * * -EINVAL: The input arguments are invalid, i.e. the id is invalid, * and/or the module is invalid. * * -EBUSY: The camera device was already opened for this camera id * (by using this method or open_legacy), * regardless of the device HAL version it was opened as. * * -EUSERS: The maximal number of camera devices that can be * opened concurrently were opened already, either by * this method or the open_legacy method. * * All other return values from common.methods->open will be treated as * -ENODEV. */ hw_module_t common; /** * get_number_of_cameras: * * Returns the number of camera devices accessible through the camera * module. The camera devices are numbered 0 through N-1, where N is the * value returned by this call. The name of the camera device for open() is * simply the number converted to a string. That is, "0" for camera ID 0, * "1" for camera ID 1. * * The value here must be static, and cannot change after the first call to * this method */ int (*get_number_of_cameras)(void); /** * get_camera_info: * * Return the static camera information for a given camera device. This * information may not change for a camera device. * * Return values: * * 0: On a successful operation * * -ENODEV: The information cannot be provided due to an internal * error. * * -EINVAL: The input arguments are invalid, i.e. the id is invalid, * and/or the module is invalid. */ int (*get_camera_info)(int camera_id, struct camera_info *info); /** * set_callbacks: * * Provide callback function pointers to the HAL module to inform framework * of asynchronous camera module events. The framework will call this * function once after initial camera HAL module load, after the * get_number_of_cameras() method is called for the first time, and before * any other calls to the module. * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_1_0, CAMERA_MODULE_API_VERSION_2_0: * * Not provided by HAL module. Framework may not call this function. * * CAMERA_MODULE_API_VERSION_2_1: * * Valid to be called by the framework. * * Return values: * * 0: On a successful operation * * -ENODEV: The operation cannot be completed due to an internal * error. * * -EINVAL: The input arguments are invalid, i.e. the callbacks are * null */ int (*set_callbacks)(const camera_module_callbacks_t *callbacks); /** * get_vendor_tag_ops: * * Get methods to query for vendor extension metadata tag information. The * HAL should fill in all the vendor tag operation methods, or leave ops * unchanged if no vendor tags are defined. * * The vendor_tag_ops structure used here is defined in: * system/media/camera/include/system/vendor_tags.h * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1: * Not provided by HAL module. Framework may not call this function. * * CAMERA_MODULE_API_VERSION_2_2: * Valid to be called by the framework. */ void (*get_vendor_tag_ops)(vendor_tag_ops_t* ops); /** * open_legacy: * * Open a specific legacy camera HAL device if multiple device HAL API * versions are supported by this camera HAL module. For example, if the * camera module supports both CAMERA_DEVICE_API_VERSION_1_0 and * CAMERA_DEVICE_API_VERSION_3_2 device API for the same camera id, * framework can call this function to open the camera device as * CAMERA_DEVICE_API_VERSION_1_0 device. * * This is an optional method. A Camera HAL module does not need to support * more than one device HAL version per device, and such modules may return * -ENOSYS for all calls to this method. For all older HAL device API * versions that are not supported, it may return -EOPNOTSUPP. When above * cases occur, The normal open() method (common.methods->open) will be * used by the framework instead. * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2: * Not provided by HAL module. Framework will not call this function. * * CAMERA_MODULE_API_VERSION_2_3: * Valid to be called by the framework. * * Return values: * * 0: On a successful open of the camera device. * * -ENOSYS This method is not supported. * * -EOPNOTSUPP: The requested HAL version is not supported by this method. * * -EINVAL: The input arguments are invalid, i.e. the id is invalid, * and/or the module is invalid. * * -EBUSY: The camera device was already opened for this camera id * (by using this method or common.methods->open method), * regardless of the device HAL version it was opened as. * * -EUSERS: The maximal number of camera devices that can be * opened concurrently were opened already, either by * this method or common.methods->open method. */ int (*open_legacy)(const struct hw_module_t* module, const char* id, uint32_t halVersion, struct hw_device_t** device); /* reserved for future use */ void* reserved[7]; } camera_module_t; __END_DECLS #endif /* ANDROID_INCLUDE_CAMERA_COMMON_H */ android-headers-23/21/hardware/consumerir.h000066400000000000000000000067261264465411000207250ustar00rootroot00000000000000/* * 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_HARDWARE_CONSUMERIR_H #define ANDROID_INCLUDE_HARDWARE_CONSUMERIR_H #include #include #include #include #define CONSUMERIR_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) #define CONSUMERIR_HARDWARE_MODULE_ID "consumerir" #define CONSUMERIR_TRANSMITTER "transmitter" typedef struct consumerir_freq_range { int min; int max; } consumerir_freq_range_t; typedef struct consumerir_module { /** * Common methods of the consumer IR module. This *must* be the first member of * consumerir_module as users of this structure will cast a hw_module_t to * consumerir_module pointer in contexts where it's known the hw_module_t references a * consumerir_module. */ struct hw_module_t common; } consumerir_module_t; typedef struct consumerir_device { /** * Common methods of the consumer IR device. This *must* be the first member of * consumerir_device as users of this structure will cast a hw_device_t to * consumerir_device pointer in contexts where it's known the hw_device_t references a * consumerir_device. */ struct hw_device_t common; /* * (*transmit)() is called to by the ConsumerIrService to send an IR pattern * at a given carrier_freq. * * The pattern is alternating series of carrier on and off periods measured in * microseconds. The carrier should be turned off at the end of a transmit * even if there are and odd number of entries in the pattern array. * * This call should return when the transmit is complete or encounters an error. * * returns: 0 on success. A negative error code on error. */ int (*transmit)(struct consumerir_device *dev, int carrier_freq, const int pattern[], int pattern_len); /* * (*get_num_carrier_freqs)() is called by the ConsumerIrService to get the * number of carrier freqs to allocate space for, which is then filled by * a subsequent call to (*get_carrier_freqs)(). * * returns: the number of ranges on success. A negative error code on error. */ int (*get_num_carrier_freqs)(struct consumerir_device *dev); /* * (*get_carrier_freqs)() is called by the ConsumerIrService to enumerate * which frequencies the IR transmitter supports. The HAL implementation * should fill an array of consumerir_freq_range structs with the * appropriate values for the transmitter, up to len elements. * * returns: the number of ranges on success. A negative error code on error. */ int (*get_carrier_freqs)(struct consumerir_device *dev, size_t len, consumerir_freq_range_t *ranges); /* Reserved for future use. Must be NULL. */ void* reserved[8 - 3]; } consumerir_device_t; #endif /* ANDROID_INCLUDE_HARDWARE_CONSUMERIR_H */ android-headers-23/21/hardware/fb.h000066400000000000000000000126551264465411000171240ustar00rootroot00000000000000/* * 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_FB_INTERFACE_H #define ANDROID_FB_INTERFACE_H #include #include #include #include #include __BEGIN_DECLS #define GRALLOC_HARDWARE_FB0 "fb0" /*****************************************************************************/ /*****************************************************************************/ typedef struct framebuffer_device_t { /** * Common methods of the framebuffer device. This *must* be the first member of * framebuffer_device_t as users of this structure will cast a hw_device_t to * framebuffer_device_t pointer in contexts where it's known the hw_device_t references a * framebuffer_device_t. */ struct hw_device_t common; /* flags describing some attributes of the framebuffer */ const uint32_t flags; /* dimensions of the framebuffer in pixels */ const uint32_t width; const uint32_t height; /* frambuffer stride in pixels */ const int stride; /* framebuffer pixel format */ const int format; /* resolution of the framebuffer's display panel in pixel per inch*/ const float xdpi; const float ydpi; /* framebuffer's display panel refresh rate in frames per second */ const float fps; /* min swap interval supported by this framebuffer */ const int minSwapInterval; /* max swap interval supported by this framebuffer */ const int maxSwapInterval; /* Number of framebuffers supported*/ const int numFramebuffers; int reserved[7]; /* * requests a specific swap-interval (same definition than EGL) * * Returns 0 on success or -errno on error. */ int (*setSwapInterval)(struct framebuffer_device_t* window, int interval); /* * This hook is OPTIONAL. * * It is non NULL If the framebuffer driver supports "update-on-demand" * and the given rectangle is the area of the screen that gets * updated during (*post)(). * * This is useful on devices that are able to DMA only a portion of * the screen to the display panel, upon demand -- as opposed to * constantly refreshing the panel 60 times per second, for instance. * * Only the area defined by this rectangle is guaranteed to be valid, that * is, the driver is not allowed to post anything outside of this * rectangle. * * The rectangle evaluated during (*post)() and specifies which area * of the buffer passed in (*post)() shall to be posted. * * return -EINVAL if width or height <=0, or if left or top < 0 */ int (*setUpdateRect)(struct framebuffer_device_t* window, int left, int top, int width, int height); /* * Post to the display (display it on the screen) * The buffer must have been allocated with the * GRALLOC_USAGE_HW_FB usage flag. * buffer must be the same width and height as the display and must NOT * be locked. * * The buffer is shown during the next VSYNC. * * If the same buffer is posted again (possibly after some other buffer), * post() will block until the the first post is completed. * * Internally, post() is expected to lock the buffer so that a * subsequent call to gralloc_module_t::(*lock)() with USAGE_RENDER or * USAGE_*_WRITE will block until it is safe; that is typically once this * buffer is shown and another buffer has been posted. * * Returns 0 on success or -errno on error. */ int (*post)(struct framebuffer_device_t* dev, buffer_handle_t buffer); /* * The (*compositionComplete)() method must be called after the * compositor has finished issuing GL commands for client buffers. */ int (*compositionComplete)(struct framebuffer_device_t* dev); /* * This hook is OPTIONAL. * * If non NULL it will be caused by SurfaceFlinger on dumpsys */ void (*dump)(struct framebuffer_device_t* dev, char *buff, int buff_len); /* * (*enableScreen)() is used to either blank (enable=0) or * unblank (enable=1) the screen this framebuffer is attached to. * * Returns 0 on success or -errno on error. */ int (*enableScreen)(struct framebuffer_device_t* dev, int enable); void* reserved_proc[6]; } framebuffer_device_t; /** convenience API for opening and closing a supported device */ 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); } static inline int framebuffer_close(struct framebuffer_device_t* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_FB_INTERFACE_H android-headers-23/21/hardware/fingerprint.h000066400000000000000000000143451264465411000210620ustar00rootroot00000000000000/* * 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_HARDWARE_FINGERPRINT_H #define ANDROID_INCLUDE_HARDWARE_FINGERPRINT_H #define FINGERPRINT_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) #define FINGERPRINT_HARDWARE_MODULE_ID "fingerprint" typedef enum fingerprint_msg_type { FINGERPRINT_ERROR = -1, FINGERPRINT_ACQUIRED = 1, FINGERPRINT_PROCESSED = 2, FINGERPRINT_TEMPLATE_ENROLLING = 3, FINGERPRINT_TEMPLATE_REMOVED = 4 } fingerprint_msg_type_t; typedef enum fingerprint_error { FINGERPRINT_ERROR_HW_UNAVAILABLE = 1, FINGERPRINT_ERROR_UNABLE_TO_PROCESS = 2, FINGERPRINT_ERROR_TIMEOUT = 3, FINGERPRINT_ERROR_NO_SPACE = 4 /* No space available to store a template */ } fingerprint_error_t; typedef enum fingerprint_acquired_info { FINGERPRINT_ACQUIRED_GOOD = 0, FINGERPRINT_ACQUIRED_PARTIAL = 1, FINGERPRINT_ACQUIRED_INSUFFICIENT = 2, FINGERPRINT_ACQUIRED_IMAGER_DIRTY = 4, FINGERPRINT_ACQUIRED_TOO_SLOW = 8, FINGERPRINT_ACQUIRED_TOO_FAST = 16 } fingerprint_acquired_info_t; typedef struct fingerprint_enroll { uint32_t id; /* samples_remaining goes from N (no data collected, but N scans needed) * to 0 (no more data is needed to build a template). * The progress indication may be augmented by a bitmap encoded indication * of finger area that needs to be presented by the user. * Bit numbers mapped to physical location: * * distal * +-+-+-+ * |2|1|0| * |5|4|3| * medial |8|7|6| lateral * |b|a|9| * |e|d|c| * +-+-+-+ * proximal * */ uint16_t data_collected_bmp; uint16_t samples_remaining; } fingerprint_enroll_t; typedef struct fingerprint_removed { uint32_t id; } fingerprint_removed_t; typedef struct fingerprint_acquired { fingerprint_acquired_info_t acquired_info; /* information about the image */ } fingerprint_acquired_t; typedef struct fingerprint_processed { uint32_t id; /* 0 is a special id and means no match */ } fingerprint_processed_t; typedef struct fingerprint_msg { fingerprint_msg_type_t type; union { uint64_t raw; fingerprint_error_t error; fingerprint_enroll_t enroll; fingerprint_removed_t removed; fingerprint_acquired_t acquired; fingerprint_processed_t processed; } data; } fingerprint_msg_t; /* Callback function type */ typedef void (*fingerprint_notify_t)(fingerprint_msg_t msg); /* Synchronous operation */ typedef struct fingerprint_device { /** * Common methods of the fingerprint device. This *must* be the first member * of fingerprint_device as users of this structure will cast a hw_device_t * to fingerprint_device pointer in contexts where it's known * the hw_device_t references a fingerprint_device. */ struct hw_device_t common; /* * Fingerprint enroll request: * Switches the HAL state machine to collect and store a new fingerprint * template. Switches back as soon as enroll is complete * (fingerprint_msg.type == FINGERPRINT_TEMPLATE_ENROLLING && * fingerprint_msg.data.enroll.samples_remaining == 0) * or after timeout_sec seconds. * * Function return: 0 if enrollment process can be successfully started * -1 otherwise. A notify() function may be called * indicating the error condition. */ int (*enroll)(struct fingerprint_device *dev, uint32_t timeout_sec); /* * Cancel fingerprint enroll request: * Switches the HAL state machine back to accept a fingerprint scan mode. * (fingerprint_msg.type == FINGERPRINT_TEMPLATE_ENROLLING && * fingerprint_msg.data.enroll.samples_remaining == 0) * will indicate switch back to the scan mode. * * Function return: 0 if cancel request is accepted * -1 otherwise. */ int (*enroll_cancel)(struct fingerprint_device *dev); /* * Fingerprint remove request: * deletes a fingerprint template. * If the fingerprint id is 0 the entire template database will be removed. * notify() will be called for each template deleted with * fingerprint_msg.type == FINGERPRINT_TEMPLATE_REMOVED and * fingerprint_msg.data.removed.id indicating each template id removed. * * Function return: 0 if fingerprint template(s) can be successfully deleted * -1 otherwise. */ int (*remove)(struct fingerprint_device *dev, uint32_t fingerprint_id); /* * Set notification callback: * Registers a user function that would receive notifications from the HAL * The call will block if the HAL state machine is in busy state until HAL * leaves the busy state. * * Function return: 0 if callback function is successfuly registered * -1 otherwise. */ int (*set_notify)(struct fingerprint_device *dev, fingerprint_notify_t notify); /* * Client provided callback function to receive notifications. * Do not set by hand, use the function above instead. */ fingerprint_notify_t notify; /* Reserved for future use. Must be NULL. */ void* reserved[8 - 4]; } fingerprint_device_t; typedef struct fingerprint_module { /** * Common methods of the fingerprint module. This *must* be the first member * of fingerprint_module as users of this structure will cast a hw_module_t * to fingerprint_module pointer in contexts where it's known * the hw_module_t references a fingerprint_module. */ struct hw_module_t common; } fingerprint_module_t; #endif /* ANDROID_INCLUDE_HARDWARE_FINGERPRINT_H */ android-headers-23/21/hardware/fused_location.h000066400000000000000000000644501264465411000215330ustar00rootroot00000000000000/* * 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_HARDWARE_FUSED_LOCATION_H #define ANDROID_INCLUDE_HARDWARE_FUSED_LOCATION_H #include /** * This header file defines the interface of the Fused Location Provider. * Fused Location Provider is designed to fuse data from various sources * like GPS, Wifi, Cell, Sensors, Bluetooth etc to provide a fused location to the * upper layers. The advantage of doing fusion in hardware is power savings. * The goal is to do this without waking up the AP to get additional data. * The software implementation of FLP will decide when to use * the hardware fused location. Other location features like geofencing will * also be implemented using fusion in hardware. */ __BEGIN_DECLS #define FLP_HEADER_VERSION 1 #define FLP_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define FLP_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION_2(0, 1, FLP_HEADER_VERSION) /** * The id of this module */ #define FUSED_LOCATION_HARDWARE_MODULE_ID "flp" /** * Name for the FLP location interface */ #define FLP_LOCATION_INTERFACE "flp_location" /** * Name for the FLP location interface */ #define FLP_DIAGNOSTIC_INTERFACE "flp_diagnostic" /** * Name for the FLP_Geofencing interface. */ #define FLP_GEOFENCING_INTERFACE "flp_geofencing" /** * Name for the FLP_device context interface. */ #define FLP_DEVICE_CONTEXT_INTERFACE "flp_device_context" /** * Constants to indicate the various subsystems * that will be used. */ #define FLP_TECH_MASK_GNSS (1U<<0) #define FLP_TECH_MASK_WIFI (1U<<1) #define FLP_TECH_MASK_SENSORS (1U<<2) #define FLP_TECH_MASK_CELL (1U<<3) #define FLP_TECH_MASK_BLUETOOTH (1U<<4) /** * 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, * sometimes in high power mode, the system might need * a location callback every single time the location * fix has been obtained. This flag controls that option. * Its the responsibility of the upper layers (caller) to switch * it off, if it knows that the AP might go to sleep. * When this bit is on amidst a batching session, batching should * continue while location fixes are reported in real time. */ #define FLP_BATCH_CALLBACK_ON_LOCATION_FIX 0x0000002 /** Flags to indicate which values are valid in a FlpLocation. */ typedef uint16_t FlpLocationFlags; // IMPORTANT: Note that the following values must match // constants in the corresponding java file. /** FlpLocation has valid latitude and longitude. */ #define FLP_LOCATION_HAS_LAT_LONG (1U<<0) /** FlpLocation has valid altitude. */ #define FLP_LOCATION_HAS_ALTITUDE (1U<<1) /** FlpLocation has valid speed. */ #define FLP_LOCATION_HAS_SPEED (1U<<2) /** FlpLocation has valid bearing. */ #define FLP_LOCATION_HAS_BEARING (1U<<4) /** FlpLocation has valid accuracy. */ #define FLP_LOCATION_HAS_ACCURACY (1U<<8) typedef int64_t FlpUtcTime; /** Represents a location. */ typedef struct { /** set to sizeof(FlpLocation) */ size_t size; /** Flags associated with the location object. */ FlpLocationFlags flags; /** Represents latitude in degrees. */ double latitude; /** Represents longitude in degrees. */ double longitude; /** * Represents altitude in meters above the WGS 84 reference * ellipsoid. */ double altitude; /** Represents speed in meters per second. */ float speed; /** Represents heading in degrees. */ float bearing; /** Represents expected accuracy in meters. */ float accuracy; /** Timestamp for the location fix. */ FlpUtcTime timestamp; /** Sources used, will be Bitwise OR of the FLP_TECH_MASK bits. */ uint32_t sources_used; } FlpLocation; typedef enum { ASSOCIATE_JVM, DISASSOCIATE_JVM, } ThreadEvent; /** * Callback with location information. * Can only be called from a thread associated to JVM using set_thread_event_cb. * Parameters: * num_locations is the number of batched locations available. * location is the pointer to an array of pointers to location objects. */ typedef void (*flp_location_callback)(int32_t num_locations, FlpLocation** location); /** * Callback utility for acquiring a wakelock. * This can be used to prevent the CPU from suspending while handling FLP events. */ typedef void (*flp_acquire_wakelock)(); /** * Callback utility for releasing the FLP wakelock. */ typedef void (*flp_release_wakelock)(); /** * Callback for associating a thread that can call into the Java framework code. * This must be used to initialize any threads that report events up to the framework. * Return value: * FLP_RESULT_SUCCESS on success. * FLP_RESULT_ERROR if the association failed in the current thread. */ typedef int (*flp_set_thread_event)(ThreadEvent event); /** FLP callback structure. */ typedef struct { /** set to sizeof(FlpCallbacks) */ size_t size; flp_location_callback location_cb; flp_acquire_wakelock acquire_wakelock_cb; flp_release_wakelock release_wakelock_cb; flp_set_thread_event set_thread_event_cb; } FlpCallbacks; /** Options with the batching FLP APIs */ typedef struct { /** * Maximum power in mW that the underlying implementation * can use for this batching call. * If max_power_allocation_mW is 0, only fixes that are generated * at no additional cost of power shall be reported. */ double max_power_allocation_mW; /** Bitwise OR of the FLP_TECH_MASKS to use */ uint32_t sources_to_use; /** * FLP_BATCH_WAKEUP_ON_FIFO_FULL - If set the hardware * will wake up the AP when the buffer is full. If not set, the * hardware will drop the oldest location object. * * FLP_BATCH_CALLBACK_ON_LOCATION_FIX - If set the location * callback will be called every time there is a location fix. * Its the responsibility of the upper layers (caller) to switch * it off, if it knows that the AP might go to sleep. When this * bit is on amidst a batching session, batching should continue * while location fixes are reported in real time. * * Other flags to be bitwised ORed in the future. */ uint32_t flags; /** * Frequency with which location needs to be batched in nano * seconds. */ int64_t period_ns; } FlpBatchOptions; #define FLP_RESULT_SUCCESS 0 #define FLP_RESULT_ERROR -1 #define FLP_RESULT_INSUFFICIENT_MEMORY -2 #define FLP_RESULT_TOO_MANY_GEOFENCES -3 #define FLP_RESULT_ID_EXISTS -4 #define FLP_RESULT_ID_UNKNOWN -5 #define FLP_RESULT_INVALID_GEOFENCE_TRANSITION -6 /** * Represents the standard FLP interface. */ typedef struct { /** * set to sizeof(FlpLocationInterface) */ size_t size; /** * Opens the interface and provides the callback routines * to the implemenation of this interface. */ int (*init)(FlpCallbacks* callbacks ); /** * Return the batch size (in number of FlpLocation objects) * available in the hardware. Note, different HW implementations * may have different sample sizes. This shall return number * of samples defined in the format of FlpLocation. * This will be used by the upper layer, to decide on the batching * interval and whether the AP should be woken up or not. */ int (*get_batch_size)(); /** * Start batching locations. This API is primarily used when the AP is * asleep and the device can batch locations in the hardware. * flp_location_callback is used to return the locations. When the buffer * is full and FLP_BATCH_WAKEUP_ON_FIFO_FULL is used, the AP is woken up. * When the buffer is full and FLP_BATCH_WAKEUP_ON_FIFO_FULL is not set, * the oldest location object is dropped. In this case the AP will not be * woken up. The upper layer will use get_batched_location * API to explicitly ask for the location. * If FLP_BATCH_CALLBACK_ON_LOCATION_FIX is set, the implementation * will call the flp_location_callback every single time there is a location * fix. This overrides FLP_BATCH_WAKEUP_ON_FIFO_FULL flag setting. * It's the responsibility of the upper layers (caller) to switch * it off, if it knows that the AP might go to sleep. This is useful * for nagivational applications when the system is in high power mode. * Parameters: * id - Id for the request. * options - See FlpBatchOptions struct definition. * Return value: * FLP_RESULT_SUCCESS on success, FLP_RESULT_INSUFFICIENT_MEMORY, * FLP_RESULT_ID_EXISTS, FLP_RESULT_ERROR on failure. */ int (*start_batching)(int id, FlpBatchOptions* options); /** * Update FlpBatchOptions associated with a batching request. * When a batching operation is in progress and a batching option * such as FLP_BATCH_WAKEUP_ON_FIFO_FULL needs to be updated, this API * will be used. For instance, this can happen when the AP is awake and * the maps application is being used. * Parameters: * id - Id of an existing batch request. * new_options - Updated FlpBatchOptions * Return value: * FLP_RESULT_SUCCESS on success, FLP_RESULT_ID_UNKNOWN, * FLP_RESULT_ERROR on error. */ int (*update_batching_options)(int id, FlpBatchOptions* new_options); /** * Stop batching. * Parameters: * id - Id for the request. * Return Value: * FLP_RESULT_SUCCESS on success, FLP_RESULT_ID_UNKNOWN or * FLP_RESULT_ERROR on failure. */ int (*stop_batching)(int id); /** * Closes the interface. If any batch operations are in progress, * they should be stopped. */ void (*cleanup)(); /** * Get the fused location that was batched. * flp_location_callback is used to return the location. The location object * is dropped from the buffer only when the buffer is full. Do not remove it * from the buffer just because it has been returned using the callback. * In other words, when there is no new location object, two calls to * get_batched_location(1) should return the same location object. * Parameters: * last_n_locations - Number of locations to get. This can be one or many. * If the last_n_locations is 1, you get the latest location known to the * hardware. */ void (*get_batched_location)(int last_n_locations); /** * Injects current location from another location provider * latitude and longitude are measured in degrees * expected accuracy is measured in meters * Parameters: * location - The location object being injected. * Return value: FLP_RESULT_SUCCESS or FLP_RESULT_ERROR. */ int (*inject_location)(FlpLocation* location); /** * Get a pointer to extension information. */ const void* (*get_extension)(const char* name); } FlpLocationInterface; struct flp_device_t { struct hw_device_t common; /** * Get a handle to the FLP Interface. */ const FlpLocationInterface* (*get_flp_interface)(struct flp_device_t* dev); }; /** * Callback for reports diagnostic data into the Java framework code. */ typedef void (*report_data)(char* data, int length); /** * FLP diagnostic callback structure. * Currently, not used - but this for future extension. */ typedef struct { /** set to sizeof(FlpDiagnosticCallbacks) */ size_t size; flp_set_thread_event set_thread_event_cb; /** reports diagnostic data into the Java framework code */ report_data data_cb; } FlpDiagnosticCallbacks; /** Extended interface for diagnostic support. */ typedef struct { /** set to sizeof(FlpDiagnosticInterface) */ size_t size; /** * Opens the diagnostic interface and provides the callback routines * to the implemenation of this interface. */ void (*init)(FlpDiagnosticCallbacks* callbacks); /** * Injects diagnostic data into the FLP subsystem. * Return 0 on success, -1 on error. **/ int (*inject_data)(char* data, int length ); } FlpDiagnosticInterface; /** * Context setting information. * All these settings shall be injected to FLP HAL at FLP init time. * Following that, only the changed setting need to be re-injected * upon changes. */ #define FLP_DEVICE_CONTEXT_GPS_ENABLED (1U<<0) #define FLP_DEVICE_CONTEXT_AGPS_ENABLED (1U<<1) #define FLP_DEVICE_CONTEXT_NETWORK_POSITIONING_ENABLED (1U<<2) #define FLP_DEVICE_CONTEXT_WIFI_CONNECTIVITY_ENABLED (1U<<3) #define FLP_DEVICE_CONTEXT_WIFI_POSITIONING_ENABLED (1U<<4) #define FLP_DEVICE_CONTEXT_HW_NETWORK_POSITIONING_ENABLED (1U<<5) #define FLP_DEVICE_CONTEXT_AIRPLANE_MODE_ON (1U<<6) #define FLP_DEVICE_CONTEXT_DATA_ENABLED (1U<<7) #define FLP_DEVICE_CONTEXT_ROAMING_ENABLED (1U<<8) #define FLP_DEVICE_CONTEXT_CURRENTLY_ROAMING (1U<<9) #define FLP_DEVICE_CONTEXT_SENSOR_ENABLED (1U<<10) #define FLP_DEVICE_CONTEXT_BLUETOOTH_ENABLED (1U<<11) #define FLP_DEVICE_CONTEXT_CHARGER_ON (1U<<12) /** Extended interface for device context support. */ typedef struct { /** set to sizeof(FlpDeviceContextInterface) */ size_t size; /** * Injects debug data into the FLP subsystem. * Return 0 on success, -1 on error. **/ int (*inject_device_context)(uint32_t enabledMask); } FlpDeviceContextInterface; /** * There are 3 states associated with a Geofence: Inside, Outside, Unknown. * There are 3 transitions: ENTERED, EXITED, UNCERTAIN. * * An example state diagram with confidence level: 95% and Unknown time limit * set as 30 secs is shown below. (confidence level and Unknown time limit are * explained latter) * ____________________________ * | Unknown (30 secs) | * """""""""""""""""""""""""""" * ^ | | ^ * UNCERTAIN| |ENTERED EXITED| |UNCERTAIN * | v v | * ________ EXITED _________ * | Inside | -----------> | Outside | * | | <----------- | | * """""""" ENTERED """"""""" * * Inside state: We are 95% confident that the user is inside the geofence. * Outside state: We are 95% confident that the user is outside the geofence * Unknown state: Rest of the time. * * The Unknown state is better explained with an example: * * __________ * | c| * | ___ | _______ * | |a| | | b | * | """ | """"""" * | | * """""""""" * In the diagram above, "a" and "b" are 2 geofences and "c" is the accuracy * circle reported by the FLP subsystem. Now with regard to "b", the system is * confident that the user is outside. But with regard to "a" is not confident * whether it is inside or outside the geofence. If the accuracy remains the * same for a sufficient period of time, the UNCERTAIN transition would be * triggered with the state set to Unknown. If the accuracy improves later, an * appropriate transition should be triggered. This "sufficient period of time" * is defined by the parameter in the add_geofence_area API. * In other words, Unknown state can be interpreted as a state in which the * FLP subsystem isn't confident enough that the user is either inside or * outside the Geofence. It moves to Unknown state only after the expiry of the * timeout. * * The geofence callback needs to be triggered for the ENTERED and EXITED * transitions, when the FLP system is confident that the user has entered * (Inside state) or exited (Outside state) the Geofence. An implementation * which uses a value of 95% as the confidence is recommended. The callback * should be triggered only for the transitions requested by the * add_geofence_area call. * * Even though the diagram and explanation talks about states and transitions, * the callee is only interested in the transistions. The states are mentioned * here for illustrative purposes. * * Startup Scenario: When the device boots up, if an application adds geofences, * and then we get an accurate FLP location fix, it needs to trigger the * appropriate (ENTERED or EXITED) transition for every Geofence it knows about. * By default, all the Geofences will be in the Unknown state. * * When the FLP system is unavailable, flp_geofence_status_callback should be * called to inform the upper layers of the same. Similarly, when it becomes * available the callback should be called. This is a global state while the * UNKNOWN transition described above is per geofence. * */ #define FLP_GEOFENCE_TRANSITION_ENTERED (1L<<0) #define FLP_GEOFENCE_TRANSITION_EXITED (1L<<1) #define FLP_GEOFENCE_TRANSITION_UNCERTAIN (1L<<2) #define FLP_GEOFENCE_MONITOR_STATUS_UNAVAILABLE (1L<<0) #define FLP_GEOFENCE_MONITOR_STATUS_AVAILABLE (1L<<1) /** * The callback associated with the geofence. * Parameters: * geofence_id - The id associated with the add_geofence_area. * location - The current location as determined by the FLP subsystem. * transition - Can be one of FLP_GEOFENCE_TRANSITION_ENTERED, FLP_GEOFENCE_TRANSITION_EXITED, * FLP_GEOFENCE_TRANSITION_UNCERTAIN. * timestamp - Timestamp when the transition was detected; -1 if not available. * sources_used - Bitwise OR of FLP_TECH_MASK flags indicating which * subsystems were used. * * The callback should only be called when the caller is interested in that * particular transition. For instance, if the caller is interested only in * ENTERED transition, then the callback should NOT be called with the EXITED * transition. * * IMPORTANT: If a transition is triggered resulting in this callback, the * subsystem will wake up the application processor, if its in suspend state. */ typedef void (*flp_geofence_transition_callback) (int32_t geofence_id, FlpLocation* location, int32_t transition, FlpUtcTime timestamp, uint32_t sources_used); /** * The callback associated with the availablity of one the sources used for geofence * monitoring by the FLP sub-system For example, if the GPS system determines that it cannot * monitor geofences because of lack of reliability or unavailability of the GPS signals, * it will call this callback with FLP_GEOFENCE_MONITOR_STATUS_UNAVAILABLE parameter and the * source set to FLP_TECH_MASK_GNSS. * * Parameters: * status - FLP_GEOFENCE_MONITOR_STATUS_UNAVAILABLE or FLP_GEOFENCE_MONITOR_STATUS_AVAILABLE. * source - One of the FLP_TECH_MASKS * last_location - Last known location. */ typedef void (*flp_geofence_monitor_status_callback) (int32_t status, uint32_t source, FlpLocation* last_location); /** * The callback associated with the add_geofence call. * * Parameter: * geofence_id - Id of the geofence. * result - FLP_RESULT_SUCCESS * FLP_RESULT_ERROR_TOO_MANY_GEOFENCES - geofence limit has been reached. * FLP_RESULT_ID_EXISTS - geofence with id already exists * FLP_RESULT_INVALID_GEOFENCE_TRANSITION - the monitorTransition contains an * invalid transition * FLP_RESULT_ERROR - for other errors. */ typedef void (*flp_geofence_add_callback) (int32_t geofence_id, int32_t result); /** * The callback associated with the remove_geofence call. * * Parameter: * geofence_id - Id of the geofence. * result - FLP_RESULT_SUCCESS * FLP_RESULT_ID_UNKNOWN - for invalid id * FLP_RESULT_ERROR for others. */ typedef void (*flp_geofence_remove_callback) (int32_t geofence_id, int32_t result); /** * The callback associated with the pause_geofence call. * * Parameter: * geofence_id - Id of the geofence. * result - FLP_RESULT_SUCCESS * FLP_RESULT__ID_UNKNOWN - for invalid id * FLP_RESULT_INVALID_TRANSITION - * when monitor_transitions is invalid * FLP_RESULT_ERROR for others. */ typedef void (*flp_geofence_pause_callback) (int32_t geofence_id, int32_t result); /** * The callback associated with the resume_geofence call. * * Parameter: * geofence_id - Id of the geofence. * result - FLP_RESULT_SUCCESS * FLP_RESULT_ID_UNKNOWN - for invalid id * FLP_RESULT_ERROR for others. */ typedef void (*flp_geofence_resume_callback) (int32_t geofence_id, int32_t result); typedef struct { /** set to sizeof(FlpGeofenceCallbacks) */ size_t size; flp_geofence_transition_callback geofence_transition_callback; flp_geofence_monitor_status_callback geofence_status_callback; flp_geofence_add_callback geofence_add_callback; flp_geofence_remove_callback geofence_remove_callback; flp_geofence_pause_callback geofence_pause_callback; flp_geofence_resume_callback geofence_resume_callback; flp_set_thread_event set_thread_event_cb; } FlpGeofenceCallbacks; /** Type of geofence */ typedef enum { TYPE_CIRCLE = 0, } GeofenceType; /** Circular geofence is represented by lat / long / radius */ typedef struct { double latitude; double longitude; double radius_m; } GeofenceCircle; /** Represents the type of geofence and data */ typedef struct { GeofenceType type; union { GeofenceCircle circle; } geofence; } GeofenceData; /** Geofence Options */ typedef struct { /** * The current state of the geofence. For example, if * the system already knows that the user is inside the geofence, * this will be set to FLP_GEOFENCE_TRANSITION_ENTERED. In most cases, it * will be FLP_GEOFENCE_TRANSITION_UNCERTAIN. */ int last_transition; /** * Transitions to monitor. Bitwise OR of * FLP_GEOFENCE_TRANSITION_ENTERED, FLP_GEOFENCE_TRANSITION_EXITED and * FLP_GEOFENCE_TRANSITION_UNCERTAIN. */ int monitor_transitions; /** * Defines the best-effort description * of how soon should the callback be called when the transition * associated with the Geofence is triggered. For instance, if set * to 1000 millseconds with FLP_GEOFENCE_TRANSITION_ENTERED, the callback * should be called 1000 milliseconds within entering the geofence. * This parameter is defined in milliseconds. * NOTE: This is not to be confused with the rate that the GPS is * polled at. It is acceptable to dynamically vary the rate of * sampling the GPS for power-saving reasons; thus the rate of * sampling may be faster or slower than this. */ int notification_responsivenes_ms; /** * The time limit after which the UNCERTAIN transition * should be triggered. This paramter is defined in milliseconds. */ int unknown_timer_ms; /** * The sources to use for monitoring geofences. Its a BITWISE-OR * of FLP_TECH_MASK flags. */ uint32_t sources_to_use; } GeofenceOptions; /** Geofence struct */ typedef struct { int32_t geofence_id; GeofenceData* data; GeofenceOptions* options; } Geofence; /** Extended interface for FLP_Geofencing support */ typedef struct { /** set to sizeof(FlpGeofencingInterface) */ size_t size; /** * Opens the geofence interface and provides the callback routines * to the implemenation of this interface. */ void (*init)( FlpGeofenceCallbacks* callbacks ); /** * Add a list of geofences. * Parameters: * number_of_geofences - The number of geofences that needed to be added. * geofences - Pointer to array of pointers to Geofence structure. */ void (*add_geofences) (int32_t number_of_geofences, Geofence** geofences); /** * Pause monitoring a particular geofence. * Parameters: * geofence_id - The id for the geofence. */ void (*pause_geofence) (int32_t geofence_id); /** * Resume monitoring a particular geofence. * Parameters: * geofence_id - The id for the geofence. * monitor_transitions - Which transitions to monitor. Bitwise OR of * FLP_GEOFENCE_TRANSITION_ENTERED, FLP_GEOFENCE_TRANSITION_EXITED and * FLP_GEOFENCE_TRANSITION_UNCERTAIN. * This supersedes the value associated provided in the * add_geofence_area call. */ void (*resume_geofence) (int32_t geofence_id, int monitor_transitions); /** * Modify a particular geofence option. * Parameters: * geofence_id - The id for the geofence. * options - Various options associated with the geofence. See * GeofenceOptions structure for details. */ void (*modify_geofence_option) (int32_t geofence_id, GeofenceOptions* options); /** * Remove a list of geofences. After the function returns, no notifications * should be sent. * Parameter: * number_of_geofences - The number of geofences that needed to be added. * geofence_id - Pointer to array of geofence_ids to be removed. */ void (*remove_geofences) (int32_t number_of_geofences, int32_t* geofence_id); } FlpGeofencingInterface; __END_DECLS #endif /* ANDROID_INCLUDE_HARDWARE_FLP_H */ android-headers-23/21/hardware/gps.h000066400000000000000000001744531264465411000173330ustar00rootroot00000000000000/* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_HARDWARE_GPS_H #define ANDROID_INCLUDE_HARDWARE_GPS_H #include #include #include #include #include #include #include __BEGIN_DECLS /** * The id of this module */ #define GPS_HARDWARE_MODULE_ID "gps" /** Milliseconds since January 1, 1970 */ typedef int64_t GpsUtcTime; /** Maximum number of SVs for gps_sv_status_callback(). */ #define GPS_MAX_SVS 32 /** Maximum number of Measurements in gps_measurement_callback(). */ #define GPS_MAX_MEASUREMENT 32 /** 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. */ #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 0x0000001 /** GPS supports MS-Based AGPS mode */ #define GPS_CAPABILITY_MSB 0x0000002 /** GPS supports MS-Assisted AGPS mode */ #define GPS_CAPABILITY_MSA 0x0000004 /** GPS supports single-shot fixes */ #define GPS_CAPABILITY_SINGLE_SHOT 0x0000008 /** GPS supports on demand time injection */ #define GPS_CAPABILITY_ON_DEMAND_TIME 0x0000010 /** GPS supports Geofencing */ #define GPS_CAPABILITY_GEOFENCING 0x0000020 /** GPS supports Measurements */ #define GPS_CAPABILITY_MEASUREMENTS 0x0000040 /** GPS supports Navigation Messages */ #define GPS_CAPABILITY_NAV_MESSAGES 0x0000080 /** 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 */ #define GPS_NI_SHORT_STRING_MAXLEN 256 #define GPS_NI_LONG_STRING_MAXLEN 2048 /** * 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 #define AGPS_REF_LOCATION_TYPE_GSM_CELLID 1 #define AGPS_REF_LOCATION_TYPE_UMTS_CELLID 2 #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 /** * Flags to indicate what fields in GpsClock are valid. */ typedef uint16_t GpsClockFlags; /** A valid 'leap second' is stored in the data structure. */ #define GPS_CLOCK_HAS_LEAP_SECOND (1<<0) /** A valid 'time uncertainty' is stored in the data structure. */ #define GPS_CLOCK_HAS_TIME_UNCERTAINTY (1<<1) /** A valid 'full bias' is stored in the data structure. */ #define GPS_CLOCK_HAS_FULL_BIAS (1<<2) /** A valid 'bias' is stored in the data structure. */ #define GPS_CLOCK_HAS_BIAS (1<<3) /** A valid 'bias uncertainty' is stored in the data structure. */ #define GPS_CLOCK_HAS_BIAS_UNCERTAINTY (1<<4) /** A valid 'drift' is stored in the data structure. */ #define GPS_CLOCK_HAS_DRIFT (1<<5) /** A valid 'drift uncertainty' is stored in the data structure. */ #define GPS_CLOCK_HAS_DRIFT_UNCERTAINTY (1<<6) /** * Enumeration of the available values for the GPS Clock type. */ typedef uint8_t GpsClockType; /** The type is not available ot it is unknown. */ #define GPS_CLOCK_TYPE_UNKNOWN 0 /** The source of the time value reported by GPS clock is the local hardware clock. */ #define GPS_CLOCK_TYPE_LOCAL_HW_TIME 1 /** * The source of the time value reported by GPS clock is the GPS time derived from satellites * (epoch = Jan 6, 1980) */ #define GPS_CLOCK_TYPE_GPS_TIME 2 /** * Flags to indicate what fields in GpsMeasurement are valid. */ typedef uint32_t GpsMeasurementFlags; /** A valid 'snr' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_SNR (1<<0) /** A valid 'elevation' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_ELEVATION (1<<1) /** A valid 'elevation uncertainty' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_ELEVATION_UNCERTAINTY (1<<2) /** A valid 'azimuth' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_AZIMUTH (1<<3) /** A valid 'azimuth uncertainty' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_AZIMUTH_UNCERTAINTY (1<<4) /** A valid 'pseudorange' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_PSEUDORANGE (1<<5) /** A valid 'pseudorange uncertainty' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_PSEUDORANGE_UNCERTAINTY (1<<6) /** A valid 'code phase' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_CODE_PHASE (1<<7) /** A valid 'code phase uncertainty' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_CODE_PHASE_UNCERTAINTY (1<<8) /** A valid 'carrier frequency' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_CARRIER_FREQUENCY (1<<9) /** A valid 'carrier cycles' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_CARRIER_CYCLES (1<<10) /** A valid 'carrier phase' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_CARRIER_PHASE (1<<11) /** A valid 'carrier phase uncertainty' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY (1<<12) /** A valid 'bit number' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_BIT_NUMBER (1<<13) /** A valid 'time from last bit' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_TIME_FROM_LAST_BIT (1<<14) /** A valid 'doppler shift' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_DOPPLER_SHIFT (1<<15) /** A valid 'doppler shift uncertainty' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_DOPPLER_SHIFT_UNCERTAINTY (1<<16) /** A valid 'used in fix' flag is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_USED_IN_FIX (1<<17) /** * Enumeration of the available values for the GPS Measurement's loss of lock. */ typedef uint8_t GpsLossOfLock; /** The indicator is not available or it is unknown. */ #define GPS_LOSS_OF_LOCK_UNKNOWN 0 /** The measurement does not present any indication of loss of lock. */ #define GPS_LOSS_OF_LOCK_OK 1 /** Loss of lock between previous and current observation: cycle slip possible. */ #define GPS_LOSS_OF_LOCK_CYCLE_SLIP 2 /** * Enumeration of available values for the GPS Measurement's multipath indicator. */ typedef uint8_t GpsMultipathIndicator; /** The indicator is not available or unknown. */ #define GPS_MULTIPATH_INDICATOR_UNKNOWN 0 /** The measurement has been indicated to use multipath. */ #define GPS_MULTIPATH_INDICATOR_DETECTED 1 /** The measurement has been indicated Not to use multipath. */ #define GPS_MULTIPATH_INDICATOR_NOT_USED 2 /** * Flags indicating the GPS measurement state. */ typedef uint16_t GpsMeasurementState; #define GPS_MEASUREMENT_STATE_UNKNOWN 0 #define GPS_MEASUREMENT_STATE_CODE_LOCK (1<<0) #define GPS_MEASUREMENT_STATE_BIT_SYNC (1<<1) #define GPS_MEASUREMENT_STATE_SUBFRAME_SYNC (1<<2) #define GPS_MEASUREMENT_STATE_TOW_DECODED (1<<3) /** * Flags indicating the Accumulated Delta Range's states. */ typedef uint16_t GpsAccumulatedDeltaRangeState; #define GPS_ADR_STATE_UNKNOWN 0 #define GPS_ADR_STATE_VALID (1<<0) #define GPS_ADR_STATE_RESET (1<<1) #define GPS_ADR_STATE_CYCLE_SLIP (1<<2) /** * Enumeration of available values to indicate the available GPS Natigation message types. */ typedef uint8_t GpsNavigationMessageType; /** The message type is unknown. */ #define GPS_NAVIGATION_MESSAGE_TYPE_UNKNOWN 0 /** L1 C/A message contained in the structure. */ #define GPS_NAVIGATION_MESSAGE_TYPE_L1CA 1 /** L2-CNAV message contained in the structure. */ #define GPS_NAVIGATION_MESSAGE_TYPE_L2CNAV 2 /** L5-CNAV message contained in the structure. */ #define GPS_NAVIGATION_MESSAGE_TYPE_L5CNAV 3 /** CNAV-2 message contained in the structure. */ #define GPS_NAVIGATION_MESSAGE_TYPE_CNAV2 4 /** * Name for the GPS XTRA interface. */ #define GPS_XTRA_INTERFACE "gps-xtra" /** * Name for the GPS DEBUG interface. */ #define GPS_DEBUG_INTERFACE "gps-debug" /** * Name for the AGPS interface. */ #define AGPS_INTERFACE "agps" /** * Name of the Supl Certificate interface. */ #define SUPL_CERTIFICATE_INTERFACE "supl-certificate" /** * Name for NI interface */ #define GPS_NI_INTERFACE "gps-ni" /** * Name for the AGPS-RIL interface. */ #define AGPS_RIL_INTERFACE "agps_ril" /** * Name for the GPS_Geofencing interface. */ #define GPS_GEOFENCING_INTERFACE "gps_geofencing" /** * Name of the GPS Measurements interface. */ #define GPS_MEASUREMENT_INTERFACE "gps_measurement" /** * Name of the GPS navigation message interface. */ #define GPS_NAVIGATION_MESSAGE_INTERFACE "gps_navigation_message" /** * Name of the GNSS/GPS configuration interface. */ #define GNSS_CONFIGURATION_INTERFACE "gnss_configuration" /** Represents a location. */ typedef struct { /** set to sizeof(GpsLocation) */ size_t size; /** Contains GpsLocationFlags bits. */ uint16_t flags; /** Represents latitude in degrees. */ double latitude; /** Represents longitude in degrees. */ double longitude; /** Represents altitude in meters above the WGS 84 reference * ellipsoid. */ double altitude; /** Represents speed in meters per second. */ float speed; /** Represents heading in degrees. */ float bearing; /** Represents expected accuracy in meters. */ float accuracy; /** Timestamp for the location fix. */ GpsUtcTime timestamp; } GpsLocation; /** Represents the status. */ typedef struct { /** set to sizeof(GpsStatus) */ size_t size; GpsStatusValue status; } GpsStatus; /** Represents SV information. */ typedef struct { /** set to sizeof(GpsSvInfo) */ size_t size; /** Pseudo-random number for the SV. */ int prn; /** Signal to noise ratio. */ float snr; /** Elevation of SV in degrees. */ float elevation; /** Azimuth of SV in degrees. */ float azimuth; } GpsSvInfo; /** Represents SV status. */ typedef struct { /** set to sizeof(GpsSvStatus) */ size_t size; /** Number of SVs currently visible. */ int num_svs; /** Contains an array of SV information. */ GpsSvInfo sv_list[GPS_MAX_SVS]; /** Represents a bit mask indicating which SVs * have ephemeris data. */ uint32_t ephemeris_mask; /** Represents a bit mask indicating which SVs * have almanac data. */ uint32_t almanac_mask; /** * Represents a bit mask indicating which SVs * were used for computing the most recent position fix. */ uint32_t used_in_fix_mask; } GpsSvStatus; /* 2G and 3G */ /* In 3G lac is discarded */ typedef struct { uint16_t type; uint16_t mcc; uint16_t mnc; uint16_t lac; uint32_t cid; } AGpsRefLocationCellID; typedef struct { uint8_t mac[6]; } AGpsRefLocationMac; /** Represents ref locations */ typedef struct { uint16_t type; union { AGpsRefLocationCellID cellID; AGpsRefLocationMac mac; } u; } AGpsRefLocation; /** Callback with location information. * Can only be called from a thread created by create_thread_cb. */ typedef void (* gps_location_callback)(GpsLocation* location); /** Callback with status information. * Can only be called from a thread created by create_thread_cb. */ typedef void (* gps_status_callback)(GpsStatus* status); /** * Callback with SV status information. * Can only be called from a thread created by create_thread_cb. */ typedef void (* gps_sv_status_callback)(GpsSvStatus* sv_info); /** Callback for reporting NMEA sentences. * Can only be called from a thread created by create_thread_cb. */ typedef void (* gps_nmea_callback)(GpsUtcTime timestamp, const char* nmea, int length); /** Callback to inform framework of the GPS engine's capabilities. * Capability parameter is a bit field of GPS_CAPABILITY_* flags. */ typedef void (* gps_set_capabilities)(uint32_t capabilities); /** Callback utility for acquiring the GPS wakelock. * This can be used to prevent the CPU from suspending while handling GPS events. */ typedef void (* gps_acquire_wakelock)(); /** Callback utility for releasing the GPS wakelock. */ typedef void (* gps_release_wakelock)(); /** Callback for requesting NTP time */ typedef void (* gps_request_utc_time)(); /** Callback for creating a thread that can call into the Java framework code. * This must be used to create any threads that report events up to the framework. */ typedef pthread_t (* gps_create_thread)(const char* name, void (*start)(void *), void* arg); /** GPS callback structure. */ typedef struct { /** set to sizeof(GpsCallbacks) */ size_t size; gps_location_callback location_cb; gps_status_callback status_cb; gps_sv_status_callback sv_status_cb; gps_nmea_callback nmea_cb; gps_set_capabilities set_capabilities_cb; gps_acquire_wakelock acquire_wakelock_cb; gps_release_wakelock release_wakelock_cb; gps_create_thread create_thread_cb; gps_request_utc_time request_utc_time_cb; } GpsCallbacks; /** Represents the standard GPS interface. */ typedef struct { /** set to sizeof(GpsInterface) */ size_t size; /** * Opens the interface and provides the callback routines * to the implementation of this interface. */ int (*init)( GpsCallbacks* callbacks ); /** Starts navigating. */ int (*start)( void ); /** Stops navigating. */ int (*stop)( void ); /** Closes the interface. */ void (*cleanup)( void ); /** Injects the current time. */ int (*inject_time)(GpsUtcTime time, int64_t timeReference, int uncertainty); /** Injects current location from another location provider * (typically cell ID). * latitude and longitude are measured in degrees * expected accuracy is measured in meters */ int (*inject_location)(double latitude, double longitude, float accuracy); /** * Specifies that the next call to start will not use the * information defined in the flags. GPS_DELETE_ALL is passed for * a cold start. */ void (*delete_aiding_data)(GpsAidingData flags); /** * min_interval represents the time between fixes in milliseconds. * preferred_accuracy represents the requested fix accuracy in meters. * preferred_time represents the requested time to first fix in milliseconds. */ int (*set_position_mode)(GpsPositionMode mode, GpsPositionRecurrence recurrence, uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time); /** Get a pointer to extension information. */ const void* (*get_extension)(const char* name); } GpsInterface; /** Callback to request the client to download XTRA data. * The client should download XTRA data and inject it by calling inject_xtra_data(). * Can only be called from a thread created by create_thread_cb. */ typedef void (* gps_xtra_download_request)(); /** Callback structure for the XTRA interface. */ typedef struct { gps_xtra_download_request download_request_cb; gps_create_thread create_thread_cb; } GpsXtraCallbacks; /** Extended interface for XTRA support. */ typedef struct { /** set to sizeof(GpsXtraInterface) */ size_t size; /** * Opens the XTRA interface and provides the callback routines * to the implementation of this interface. */ int (*init)( GpsXtraCallbacks* callbacks ); /** Injects XTRA data into the GPS. */ int (*inject_xtra_data)( char* data, int length ); } GpsXtraInterface; /** Extended interface for DEBUG support. */ typedef struct { /** set to sizeof(GpsDebugInterface) */ size_t size; /** * This function should return any information that the native * implementation wishes to include in a bugreport. */ size_t (*get_internal_state)(char* buffer, size_t bufferSize); } GpsDebugInterface; /** Represents the status of AGPS. */ typedef struct { /** set to sizeof(AGpsStatus_v1) */ size_t size; AGpsType type; AGpsStatusValue status; } AGpsStatus_v1; /** Represents the status of AGPS augmented with a IPv4 address field. */ typedef struct { /** set to sizeof(AGpsStatus_v2) */ size_t size; AGpsType type; AGpsStatusValue status; uint32_t ipaddr; } AGpsStatus_v2; /* Represents the status of AGPS augmented to support IPv4 and IPv6. */ typedef struct { /** set to sizeof(AGpsStatus_v3) */ size_t size; AGpsType type; AGpsStatusValue status; /** * Must be set to a valid IPv4 address if the field 'addr' contains an IPv4 * address, or set to INADDR_NONE otherwise. */ uint32_t ipaddr; /** * Must contain the IPv4 (AF_INET) or IPv6 (AF_INET6) address to report. * Any other value of addr.ss_family will be rejected. * */ struct sockaddr_storage addr; } AGpsStatus_v3; typedef AGpsStatus_v3 AGpsStatus; /** Callback with AGPS status information. * Can only be called from a thread created by create_thread_cb. */ typedef void (* agps_status_callback)(AGpsStatus* status); /** Callback structure for the AGPS interface. */ typedef struct { agps_status_callback status_cb; gps_create_thread create_thread_cb; } AGpsCallbacks; /** Extended interface for AGPS support. */ typedef struct { /** set to sizeof(AGpsInterface_v1) */ size_t size; /** * Opens the AGPS interface and provides the callback routines * to the implementation of this interface. */ void (*init)( AGpsCallbacks* callbacks ); /** * Notifies that a data connection is available and sets * the name of the APN to be used for SUPL. */ int (*data_conn_open)( const char* apn ); /** * Notifies that the AGPS data connection has been closed. */ int (*data_conn_closed)(); /** * Notifies that a data connection is not available for AGPS. */ int (*data_conn_failed)(); /** * Sets the hostname and port for the AGPS server. */ int (*set_server)( AGpsType type, const char* hostname, int port ); } AGpsInterface_v1; /** * Extended interface for AGPS support, it is augmented to enable to pass * extra APN data. */ typedef struct { /** set to sizeof(AGpsInterface_v2) */ size_t size; /** * Opens the AGPS interface and provides the callback routines to the * implementation of this interface. */ void (*init)(AGpsCallbacks* callbacks); /** * Deprecated. * If the HAL supports AGpsInterface_v2 this API will not be used, see * data_conn_open_with_apn_ip_type for more information. */ int (*data_conn_open)(const char* apn); /** * Notifies that the AGPS data connection has been closed. */ int (*data_conn_closed)(); /** * Notifies that a data connection is not available for AGPS. */ int (*data_conn_failed)(); /** * Sets the hostname and port for the AGPS server. */ int (*set_server)(AGpsType type, const char* hostname, int port); /** * Notifies that a data connection is available and sets the name of the * APN, and its IP type, to be used for SUPL connections. */ int (*data_conn_open_with_apn_ip_type)( const char* apn, ApnIpType apnIpType); } AGpsInterface_v2; typedef AGpsInterface_v2 AGpsInterface; /** Error codes associated with certificate operations */ #define AGPS_CERTIFICATE_OPERATION_SUCCESS 0 #define AGPS_CERTIFICATE_ERROR_GENERIC -100 #define AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES -101 /** A data structure that represents an X.509 certificate using DER encoding */ typedef struct { size_t length; u_char* data; } DerEncodedCertificate; /** * A type definition for SHA1 Fingerprints used to identify X.509 Certificates * The Fingerprint is a digest of the DER Certificate that uniquely identifies it. */ typedef struct { u_char data[20]; } Sha1CertificateFingerprint; /** AGPS Interface to handle SUPL certificate operations */ typedef struct { /** set to sizeof(SuplCertificateInterface) */ size_t size; /** * Installs a set of Certificates used for SUPL connections to the AGPS server. * If needed the HAL should find out internally any certificates that need to be removed to * accommodate the certificates to install. * The certificates installed represent a full set of valid certificates needed to connect to * AGPS SUPL servers. * The list of certificates is required, and all must be available at the same time, when trying * to establish a connection with the AGPS Server. * * Parameters: * certificates - A pointer to an array of DER encoded certificates that are need to be * installed in the HAL. * length - The number of certificates to install. * Returns: * AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully * AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES if the HAL cannot store the number of * certificates attempted to be installed, the state of the certificates stored should * remain the same as before on this error case. * * IMPORTANT: * If needed the HAL should find out internally the set of certificates that need to be * removed to accommodate the certificates to install. */ int (*install_certificates) ( const DerEncodedCertificate* certificates, size_t length ); /** * Notifies the HAL that a list of certificates used for SUPL connections are revoked. It is * expected that the given set of certificates is removed from the internal store of the HAL. * * Parameters: * fingerprints - A pointer to an array of SHA1 Fingerprints to identify the set of * certificates to revoke. * length - The number of fingerprints provided. * Returns: * AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully. * * IMPORTANT: * If any of the certificates provided (through its fingerprint) is not known by the HAL, * it should be ignored and continue revoking/deleting the rest of them. */ int (*revoke_certificates) ( const Sha1CertificateFingerprint* fingerprints, size_t length ); } SuplCertificateInterface; /** Represents an NI request */ typedef struct { /** set to sizeof(GpsNiNotification) */ size_t size; /** * An ID generated by HAL to associate NI notifications and UI * responses */ int notification_id; /** * An NI type used to distinguish different categories of NI * events, such as GPS_NI_TYPE_VOICE, GPS_NI_TYPE_UMTS_SUPL, ... */ GpsNiType ni_type; /** * Notification/verification options, combinations of GpsNiNotifyFlags constants */ GpsNiNotifyFlags notify_flags; /** * Timeout period to wait for user response. * Set to 0 for no time out limit. */ int timeout; /** * Default response when time out. */ GpsUserResponseType default_response; /** * Requestor ID */ char requestor_id[GPS_NI_SHORT_STRING_MAXLEN]; /** * Notification message. It can also be used to store client_id in some cases */ char text[GPS_NI_LONG_STRING_MAXLEN]; /** * Client name decoding scheme */ GpsNiEncodingType requestor_id_encoding; /** * Client name decoding scheme */ GpsNiEncodingType text_encoding; /** * A pointer to extra data. Format: * key_1 = value_1 * key_2 = value_2 */ char extras[GPS_NI_LONG_STRING_MAXLEN]; } GpsNiNotification; /** Callback with NI notification. * Can only be called from a thread created by create_thread_cb. */ typedef void (*gps_ni_notify_callback)(GpsNiNotification *notification); /** GPS NI callback structure. */ typedef struct { /** * Sends the notification request from HAL to GPSLocationProvider. */ gps_ni_notify_callback notify_cb; gps_create_thread create_thread_cb; } GpsNiCallbacks; /** * Extended interface for Network-initiated (NI) support. */ typedef struct { /** set to sizeof(GpsNiInterface) */ size_t size; /** Registers the callbacks for HAL to use. */ void (*init) (GpsNiCallbacks *callbacks); /** Sends a response to HAL. */ void (*respond) (int notif_id, GpsUserResponseType user_response); } GpsNiInterface; struct gps_device_t { struct hw_device_t common; /** * Set the provided lights to the provided values. * * Returns: 0 on succes, error code on failure. */ 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) typedef void (*agps_ril_request_set_id)(uint32_t flags); typedef void (*agps_ril_request_ref_loc)(uint32_t flags); typedef struct { agps_ril_request_set_id request_setid; agps_ril_request_ref_loc request_refloc; gps_create_thread create_thread_cb; } AGpsRilCallbacks; /** Extended interface for AGPS_RIL support. */ typedef struct { /** set to sizeof(AGpsRilInterface) */ size_t size; /** * Opens the AGPS interface and provides the callback routines * to the implementation of this interface. */ void (*init)( AGpsRilCallbacks* callbacks ); /** * Sets the reference location. */ void (*set_ref_location) (const AGpsRefLocation *agps_reflocation, size_t sz_struct); /** * Sets the set ID. */ void (*set_set_id) (AGpsSetIDType type, const char* setid); /** * Send network initiated message. */ void (*ni_message) (uint8_t *msg, size_t len); /** * Notify GPS of network status changes. * These parameters match values in the android.net.NetworkInfo class. */ void (*update_network_state) (int connected, int type, int roaming, const char* extra_info); /** * Notify GPS of network status changes. * These parameters match values in the android.net.NetworkInfo class. */ void (*update_network_availability) (int avaiable, const char* apn); } AGpsRilInterface; /** * GPS Geofence. * There are 3 states associated with a Geofence: Inside, Outside, Unknown. * There are 3 transitions: ENTERED, EXITED, UNCERTAIN. * * An example state diagram with confidence level: 95% and Unknown time limit * set as 30 secs is shown below. (confidence level and Unknown time limit are * explained latter) * ____________________________ * | Unknown (30 secs) | * """""""""""""""""""""""""""" * ^ | | ^ * UNCERTAIN| |ENTERED EXITED| |UNCERTAIN * | v v | * ________ EXITED _________ * | Inside | -----------> | Outside | * | | <----------- | | * """""""" ENTERED """"""""" * * Inside state: We are 95% confident that the user is inside the geofence. * Outside state: We are 95% confident that the user is outside the geofence * Unknown state: Rest of the time. * * The Unknown state is better explained with an example: * * __________ * | c| * | ___ | _______ * | |a| | | b | * | """ | """"""" * | | * """""""""" * In the diagram above, "a" and "b" are 2 geofences and "c" is the accuracy * circle reported by the GPS subsystem. Now with regard to "b", the system is * confident that the user is outside. But with regard to "a" is not confident * whether it is inside or outside the geofence. If the accuracy remains the * same for a sufficient period of time, the UNCERTAIN transition would be * triggered with the state set to Unknown. If the accuracy improves later, an * appropriate transition should be triggered. This "sufficient period of time" * is defined by the parameter in the add_geofence_area API. * In other words, Unknown state can be interpreted as a state in which the * GPS subsystem isn't confident enough that the user is either inside or * outside the Geofence. It moves to Unknown state only after the expiry of the * timeout. * * The geofence callback needs to be triggered for the ENTERED and EXITED * transitions, when the GPS system is confident that the user has entered * (Inside state) or exited (Outside state) the Geofence. An implementation * which uses a value of 95% as the confidence is recommended. The callback * should be triggered only for the transitions requested by the * add_geofence_area call. * * Even though the diagram and explanation talks about states and transitions, * the callee is only interested in the transistions. The states are mentioned * here for illustrative purposes. * * Startup Scenario: When the device boots up, if an application adds geofences, * and then we get an accurate GPS location fix, it needs to trigger the * appropriate (ENTERED or EXITED) transition for every Geofence it knows about. * By default, all the Geofences will be in the Unknown state. * * When the GPS system is unavailable, gps_geofence_status_callback should be * called to inform the upper layers of the same. Similarly, when it becomes * available the callback should be called. This is a global state while the * UNKNOWN transition described above is per geofence. * * An important aspect to note is that users of this API (framework), will use * other subsystems like wifi, sensors, cell to handle Unknown case and * hopefully provide a definitive state transition to the third party * application. GPS Geofence will just be a signal indicating what the GPS * 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. * Parameters: * geofence_id - The id associated with the add_geofence_area. * location - The current GPS location. * transition - Can be one of GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED, * GPS_GEOFENCE_UNCERTAIN. * timestamp - Timestamp when the transition was detected. * * The callback should only be called when the caller is interested in that * particular transition. For instance, if the caller is interested only in * ENTERED transition, then the callback should NOT be called with the EXITED * transition. * * IMPORTANT: If a transition is triggered resulting in this callback, the GPS * subsystem will wake up the application processor, if its in suspend state. */ typedef void (*gps_geofence_transition_callback) (int32_t geofence_id, GpsLocation* location, int32_t transition, GpsUtcTime timestamp); /** * The callback associated with the availability of the GPS system for geofencing * monitoring. If the GPS system determines that it cannot monitor geofences * because of lack of reliability or unavailability of the GPS signals, it will * call this callback with GPS_GEOFENCE_UNAVAILABLE parameter. * * Parameters: * status - GPS_GEOFENCE_UNAVAILABLE or GPS_GEOFENCE_AVAILABLE. * last_location - Last known location. */ typedef void (*gps_geofence_status_callback) (int32_t status, GpsLocation* last_location); /** * The callback associated with the add_geofence call. * * Parameter: * geofence_id - Id of the geofence. * status - GPS_GEOFENCE_OPERATION_SUCCESS * GPS_GEOFENCE_ERROR_TOO_MANY_GEOFENCES - geofence limit has been reached. * GPS_GEOFENCE_ERROR_ID_EXISTS - geofence with id already exists * GPS_GEOFENCE_ERROR_INVALID_TRANSITION - the monitorTransition contains an * invalid transition * GPS_GEOFENCE_ERROR_GENERIC - for other errors. */ typedef void (*gps_geofence_add_callback) (int32_t geofence_id, int32_t status); /** * The callback associated with the remove_geofence call. * * Parameter: * geofence_id - Id of the geofence. * status - GPS_GEOFENCE_OPERATION_SUCCESS * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id * GPS_GEOFENCE_ERROR_GENERIC for others. */ typedef void (*gps_geofence_remove_callback) (int32_t geofence_id, int32_t status); /** * The callback associated with the pause_geofence call. * * Parameter: * geofence_id - Id of the geofence. * status - GPS_GEOFENCE_OPERATION_SUCCESS * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id * GPS_GEOFENCE_ERROR_INVALID_TRANSITION - * when monitor_transitions is invalid * GPS_GEOFENCE_ERROR_GENERIC for others. */ typedef void (*gps_geofence_pause_callback) (int32_t geofence_id, int32_t status); /** * The callback associated with the resume_geofence call. * * Parameter: * geofence_id - Id of the geofence. * status - GPS_GEOFENCE_OPERATION_SUCCESS * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id * GPS_GEOFENCE_ERROR_GENERIC for others. */ typedef void (*gps_geofence_resume_callback) (int32_t geofence_id, int32_t status); typedef struct { gps_geofence_transition_callback geofence_transition_callback; gps_geofence_status_callback geofence_status_callback; gps_geofence_add_callback geofence_add_callback; gps_geofence_remove_callback geofence_remove_callback; gps_geofence_pause_callback geofence_pause_callback; gps_geofence_resume_callback geofence_resume_callback; gps_create_thread create_thread_cb; } GpsGeofenceCallbacks; /** Extended interface for GPS_Geofencing support */ typedef struct { /** set to sizeof(GpsGeofencingInterface) */ size_t size; /** * Opens the geofence interface and provides the callback routines * to the implementation of this interface. */ void (*init)( GpsGeofenceCallbacks* callbacks ); /** * Add a geofence area. This api currently supports circular geofences. * Parameters: * geofence_id - The id for the geofence. If a geofence with this id * already exists, an error value (GPS_GEOFENCE_ERROR_ID_EXISTS) * should be returned. * latitude, longtitude, radius_meters - The lat, long and radius * (in meters) for the geofence * last_transition - The current state of the geofence. For example, if * the system already knows that the user is inside the geofence, * this will be set to GPS_GEOFENCE_ENTERED. In most cases, it * will be GPS_GEOFENCE_UNCERTAIN. * monitor_transition - Which transitions to monitor. Bitwise OR of * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and * GPS_GEOFENCE_UNCERTAIN. * notification_responsiveness_ms - Defines the best-effort description * of how soon should the callback be called when the transition * associated with the Geofence is triggered. For instance, if set * to 1000 millseconds with GPS_GEOFENCE_ENTERED, the callback * should be called 1000 milliseconds within entering the geofence. * This parameter is defined in milliseconds. * NOTE: This is not to be confused with the rate that the GPS is * polled at. It is acceptable to dynamically vary the rate of * sampling the GPS for power-saving reasons; thus the rate of * sampling may be faster or slower than this. * unknown_timer_ms - The time limit after which the UNCERTAIN transition * should be triggered. This parameter is defined in milliseconds. * See above for a detailed explanation. */ void (*add_geofence_area) (int32_t geofence_id, double latitude, double longitude, double radius_meters, int last_transition, int monitor_transitions, int notification_responsiveness_ms, int unknown_timer_ms); /** * Pause monitoring a particular geofence. * Parameters: * geofence_id - The id for the geofence. */ void (*pause_geofence) (int32_t geofence_id); /** * Resume monitoring a particular geofence. * Parameters: * geofence_id - The id for the geofence. * monitor_transitions - Which transitions to monitor. Bitwise OR of * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and * GPS_GEOFENCE_UNCERTAIN. * This supersedes the value associated provided in the * add_geofence_area call. */ void (*resume_geofence) (int32_t geofence_id, int monitor_transitions); /** * Remove a geofence area. After the function returns, no notifications * should be sent. * Parameter: * geofence_id - The id for the geofence. */ void (*remove_geofence_area) (int32_t geofence_id); } GpsGeofencingInterface; /** * Represents an estimate of the GPS clock time. */ typedef struct { /** set to sizeof(GpsClock) */ size_t size; /** A set of flags indicating the validity of the fields in this data structure. */ GpsClockFlags flags; /** * Leap second data. * The sign of the value is defined by the following equation: * utc_time_ns = time_ns + (full_bias_ns + bias_ns) - leap_second * 1,000,000,000 * * If the data is available 'flags' must contain GPS_CLOCK_HAS_LEAP_SECOND. */ int16_t leap_second; /** * Indicates the type of time reported by the 'time_ns' field. * This is a Mandatory field. */ GpsClockType type; /** * The GPS receiver internal clock value. This can be either the local hardware clock value * (GPS_CLOCK_TYPE_LOCAL_HW_TIME), or the current GPS time derived inside GPS receiver * (GPS_CLOCK_TYPE_GPS_TIME). The field 'type' defines the time reported. * * For local hardware clock, this value is expected to be monotonically increasing during * the reporting session. The real GPS time can be derived by compensating the 'full bias' * (when it is available) from this value. * * For GPS time, this value is expected to be the best estimation of current GPS time that GPS * receiver can achieve. Set the 'time uncertainty' appropriately when GPS time is specified. * * Sub-nanosecond accuracy can be provided by means of the 'bias' field. * The value contains the 'time uncertainty' in it. * * This is a Mandatory field. */ int64_t time_ns; /** * 1-Sigma uncertainty associated with the clock's time in nanoseconds. * The uncertainty is represented as an absolute (single sided) value. * * This value should be set if GPS_CLOCK_TYPE_GPS_TIME is set. * If the data is available 'flags' must contain GPS_CLOCK_HAS_TIME_UNCERTAINTY. */ double time_uncertainty_ns; /** * The difference between hardware clock ('time' field) inside GPS receiver and the true GPS * time since 0000Z, January 6, 1980, in nanoseconds. * This value is used if and only if GPS_CLOCK_TYPE_LOCAL_HW_TIME is set, and GPS receiver * has solved the clock for GPS time. * The caller is responsible for using the 'bias uncertainty' field for quality check. * * The sign of the value is defined by the following equation: * true time (GPS time) = time_ns + (full_bias_ns + bias_ns) * * This value contains the 'bias uncertainty' in it. * If the data is available 'flags' must contain GPS_CLOCK_HAS_FULL_BIAS. */ int64_t full_bias_ns; /** * Sub-nanosecond bias. * The value contains the 'bias uncertainty' in it. * * If the data is available 'flags' must contain GPS_CLOCK_HAS_BIAS. */ double bias_ns; /** * 1-Sigma uncertainty associated with the clock's bias in nanoseconds. * The uncertainty is represented as an absolute (single sided) value. * * If the data is available 'flags' must contain GPS_CLOCK_HAS_BIAS_UNCERTAINTY. */ double bias_uncertainty_ns; /** * The clock's drift in nanoseconds (per second). * A positive value means that the frequency is higher than the nominal frequency. * * The value contains the 'drift uncertainty' in it. * If the data is available 'flags' must contain GPS_CLOCK_HAS_DRIFT. */ double drift_nsps; /** * 1-Sigma uncertainty associated with the clock's drift in nanoseconds (per second). * The uncertainty is represented as an absolute (single sided) value. * * If the data is available 'flags' must contain GPS_CLOCK_HAS_DRIFT_UNCERTAINTY. */ double drift_uncertainty_nsps; } GpsClock; /** * Represents a GPS Measurement, it contains raw and computed information. */ typedef struct { /** set to sizeof(GpsMeasurement) */ size_t size; /** A set of flags indicating the validity of the fields in this data structure. */ GpsMeasurementFlags flags; /** * Pseudo-random number in the range of [1, 32] * This is a Mandatory value. */ int8_t prn; /** * Time offset at which the measurement was taken in nanoseconds. * The reference receiver's time is specified by GpsData::clock::time_ns and should be * interpreted in the same way as indicated by GpsClock::type. * * The sign of time_offset_ns is given by the following equation: * measurement time = GpsClock::time_ns + time_offset_ns * * It provides an individual time-stamp for the measurement, and allows sub-nanosecond accuracy. * This is a Mandatory value. */ double time_offset_ns; /** * Per satellite sync state. It represents the current sync state for the associated satellite. * Based on the sync state, the 'received GPS tow' field should be interpreted accordingly. * * This is a Mandatory value. */ GpsMeasurementState state; /** * Received GPS Time-of-Week at the measurement time, in nanoseconds. * The value is relative to the beginning of the current GPS week. * * Given the sync state of GPS receiver, per each satellite, valid range for this field can be: * Searching : [ 0 ] : GPS_MEASUREMENT_STATE_UNKNOWN * Ranging code lock : [ 0 1ms ] : GPS_MEASUREMENT_STATE_CODE_LOCK is set * Bit sync : [ 0 20ms ] : GPS_MEASUREMENT_STATE_BIT_SYNC is set * Subframe sync : [ 0 6ms ] : GPS_MEASUREMENT_STATE_SUBFRAME_SYNC is set * TOW decoded : [ 0 1week ] : GPS_MEASUREMENT_STATE_TOW_DECODED is set */ int64_t received_gps_tow_ns; /** * 1-Sigma uncertainty of the Received GPS Time-of-Week in nanoseconds. */ int64_t received_gps_tow_uncertainty_ns; /** * Carrier-to-noise density in dB-Hz, in the range [0, 63]. * It contains the measured C/N0 value for the signal at the antenna input. * * This is a Mandatory value. */ double c_n0_dbhz; /** * Pseudorange rate at the timestamp in m/s. * The value also includes the effects of the receiver clock frequency and satellite clock * frequency errors. * * The value includes the 'pseudorange rate uncertainty' in it. * A positive value indicates that the pseudorange is getting larger. * * This is a Mandatory value. */ double pseudorange_rate_mps; /** * 1-Sigma uncertainty of the pseudurange rate in m/s. * The uncertainty is represented as an absolute (single sided) value. * * This is a Mandatory value. */ double pseudorange_rate_uncertainty_mps; /** * Accumulated delta range's state. It indicates whether ADR is reset or there is a cycle slip * (indicating loss of lock). * * This is a Mandatory value. */ GpsAccumulatedDeltaRangeState accumulated_delta_range_state; /** * Accumulated delta range since the last channel reset in meters. * The data is available if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN. */ double accumulated_delta_range_m; /** * 1-Sigma uncertainty of the accumulated delta range in meters. * The data is available if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN. */ double accumulated_delta_range_uncertainty_m; /** * Best derived Pseudorange by the chip-set, in meters. * The value contains the 'pseudorange uncertainty' in it. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_PSEUDORANGE. */ double pseudorange_m; /** * 1-Sigma uncertainty of the pseudorange in meters. * The value contains the 'pseudorange' and 'clock' uncertainty in it. * The uncertainty is represented as an absolute (single sided) value. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_PSEUDORANGE_UNCERTAINTY. */ double pseudorange_uncertainty_m; /** * A fraction of the current C/A code cycle, in the range [0.0, 1023.0] * This value contains the time (in Chip units) since the last C/A code cycle (GPS Msec epoch). * * The reference frequency is given by the field 'carrier_frequency_hz'. * The value contains the 'code-phase uncertainty' in it. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CODE_PHASE. */ double code_phase_chips; /** * 1-Sigma uncertainty of the code-phase, in a fraction of chips. * The uncertainty is represented as an absolute (single sided) value. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CODE_PHASE_UNCERTAINTY. */ double code_phase_uncertainty_chips; /** * Carrier frequency at which codes and messages are modulated, it can be L1 or L2. * If the field is not set, the carrier frequency is assumed to be L1. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CARRIER_FREQUENCY. */ float carrier_frequency_hz; /** * The number of full carrier cycles between the satellite and the receiver. * The reference frequency is given by the field 'carrier_frequency_hz'. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CARRIER_CYCLES. */ int64_t carrier_cycles; /** * The RF phase detected by the receiver, in the range [0.0, 1.0]. * This is usually the fractional part of the complete carrier phase measurement. * * The reference frequency is given by the field 'carrier_frequency_hz'. * The value contains the 'carrier-phase uncertainty' in it. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CARRIER_PHASE. */ double carrier_phase; /** * 1-Sigma uncertainty of the carrier-phase. * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY. */ double carrier_phase_uncertainty; /** * An enumeration that indicates the 'loss of lock' state of the event. */ GpsLossOfLock loss_of_lock; /** * The number of GPS bits transmitted since Sat-Sun midnight (GPS week). * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_BIT_NUMBER. */ int32_t bit_number; /** * The elapsed time since the last received bit in milliseconds, in the range [0, 20] * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_TIME_FROM_LAST_BIT. */ int16_t time_from_last_bit_ms; /** * Doppler shift in Hz. * A positive value indicates that the SV is moving toward the receiver. * * The reference frequency is given by the field 'carrier_frequency_hz'. * The value contains the 'doppler shift uncertainty' in it. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_DOPPLER_SHIFT. */ double doppler_shift_hz; /** * 1-Sigma uncertainty of the doppler shift in Hz. * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_DOPPLER_SHIFT_UNCERTAINTY. */ double doppler_shift_uncertainty_hz; /** * An enumeration that indicates the 'multipath' state of the event. */ GpsMultipathIndicator multipath_indicator; /** * Signal-to-noise ratio in dB. * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_SNR. */ double snr_db; /** * Elevation in degrees, the valid range is [-90, 90]. * The value contains the 'elevation uncertainty' in it. * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_ELEVATION. */ double elevation_deg; /** * 1-Sigma uncertainty of the elevation in degrees, the valid range is [0, 90]. * The uncertainty is represented as the absolute (single sided) value. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_ELEVATION_UNCERTAINTY. */ double elevation_uncertainty_deg; /** * Azimuth in degrees, in the range [0, 360). * The value contains the 'azimuth uncertainty' in it. * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_AZIMUTH. * */ double azimuth_deg; /** * 1-Sigma uncertainty of the azimuth in degrees, the valid range is [0, 180]. * The uncertainty is represented as an absolute (single sided) value. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_AZIMUTH_UNCERTAINTY. */ double azimuth_uncertainty_deg; /** * Whether the GPS represented by the measurement was used for computing the most recent fix. * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_USED_IN_FIX. */ bool used_in_fix; } GpsMeasurement; /** Represents a reading of GPS measurements. */ typedef struct { /** set to sizeof(GpsData) */ size_t size; /** Number of measurements. */ size_t measurement_count; /** The array of measurements. */ GpsMeasurement measurements[GPS_MAX_MEASUREMENT]; /** The GPS clock time reading. */ GpsClock clock; } GpsData; /** * The callback for to report measurements from the HAL. * * Parameters: * data - A data structure containing the measurements. */ typedef void (*gps_measurement_callback) (GpsData* data); typedef struct { /** set to sizeof(GpsMeasurementCallbacks) */ size_t size; gps_measurement_callback 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. */ typedef struct { /** Set to sizeof(GpsMeasurementInterface) */ size_t size; /** * Initializes the interface and registers the callback routines with the HAL. * After a successful call to 'init' the HAL must begin to provide updates at its own phase. * * Status: * GPS_MEASUREMENT_OPERATION_SUCCESS * GPS_MEASUREMENT_ERROR_ALREADY_INIT - if a callback has already been registered without a * corresponding call to 'close' * GPS_MEASUREMENT_ERROR_GENERIC - if any other error occurred, it is expected that the HAL * will not generate any updates upon returning this error code. */ int (*init) (GpsMeasurementCallbacks* callbacks); /** * Stops updates from the HAL, and unregisters the callback routines. * After a call to stop, the previously registered callbacks must be considered invalid by the * HAL. * If stop is invoked without a previous 'init', this function should perform no work. */ void (*close) (); } GpsMeasurementInterface; /** Represents a GPS navigation message (or a fragment of it). */ typedef struct { /** set to sizeof(GpsNavigationMessage) */ size_t size; /** * Pseudo-random number in the range of [1, 32] * This is a Mandatory value. */ int8_t prn; /** * The type of message contained in the structure. * This is a Mandatory value. */ GpsNavigationMessageType type; /** * Message identifier. * It provides an index so the complete Navigation Message can be assembled. i.e. fo L1 C/A * subframe 4 and 5, this value corresponds to the 'frame id' of the navigation message. * Subframe 1, 2, 3 does not contain a 'frame id' and this value can be set to -1. */ int16_t message_id; /** * Sub-message identifier. * If required by the message 'type', this value contains a sub-index within the current * message (or frame) that is being transmitted. * i.e. for L1 C/A the submessage id corresponds to the sub-frame id of the navigation message. */ int16_t submessage_id; /** * The length of the data (in bytes) contained in the current message. * If this value is different from zero, 'data' must point to an array of the same size. * e.g. for L1 C/A the size of the sub-frame will be 40 bytes (10 words, 30 bits/word). * * This is a Mandatory value. */ size_t data_length; /** * The data of the reported GPS message. * The bytes (or words) specified using big endian format (MSB first). * * For L1 C/A, each subframe contains 10 30-bit GPS words. Each GPS word (30 bits) should be * fitted into the last 30 bits in a 4-byte word (skip B31 and B32), with MSB first. */ uint8_t* data; } GpsNavigationMessage; /** * The callback to report an available fragment of a GPS navigation messages from the HAL. * * Parameters: * message - The GPS navigation submessage/subframe representation. */ typedef void (*gps_navigation_message_callback) (GpsNavigationMessage* message); typedef struct { /** set to sizeof(GpsNavigationMessageCallbacks) */ size_t size; gps_navigation_message_callback 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. */ typedef struct { /** Set to sizeof(GpsNavigationMessageInterface) */ size_t size; /** * Initializes the interface and registers the callback routines with the HAL. * After a successful call to 'init' the HAL must begin to provide updates as they become * available. * * Status: * GPS_NAVIGATION_MESSAGE_OPERATION_SUCCESS * GPS_NAVIGATION_MESSAGE_ERROR_ALREADY_INIT - if a callback has already been registered * without a corresponding call to 'close'. * GPS_NAVIGATION_MESSAGE_ERROR_GENERIC - if any other error occurred, it is expected that * the HAL will not generate any updates upon returning this error code. */ int (*init) (GpsNavigationMessageCallbacks* callbacks); /** * Stops updates from the HAL, and unregisters the callback routines. * After a call to stop, the previously registered callbacks must be considered invalid by the * HAL. * If stop is invoked without a previous 'init', this function should perform no work. */ void (*close) (); } GpsNavigationMessageInterface; /** * Interface for passing GNSS configuration contents from platform to HAL. */ typedef struct { /** Set to sizeof(GnssConfigurationInterface) */ size_t size; /** * Deliver GNSS configuration contents to HAL. * Parameters: * config_data - a pointer to a char array which holds what usually is expected from file(/etc/gps.conf), i.e., a sequence of UTF8 strings separated by '\n'. * length - total number of UTF8 characters in configuraiton data. * * IMPORTANT: * GPS HAL should expect this function can be called multiple times. And it may be * called even when GpsLocationProvider is already constructed and enabled. GPS HAL * should maintain the existing requests for various callback regardless the change * in configuration data. */ void (*configuration_update) (const char* config_data, int32_t length); } GnssConfigurationInterface; __END_DECLS #endif /* ANDROID_INCLUDE_HARDWARE_GPS_H */ android-headers-23/21/hardware/gralloc.h000066400000000000000000000317171264465411000201600ustar00rootroot00000000000000/* * 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_GRALLOC_INTERFACE_H #define ANDROID_GRALLOC_INTERFACE_H #include #include #include #include #include #include #include #include #include __BEGIN_DECLS /** * Module versioning information for the Gralloc hardware module, based on * gralloc_module_t.common.module_api_version. * * Version History: * * GRALLOC_MODULE_API_VERSION_0_1: * Initial Gralloc hardware module API. * * GRALLOC_MODULE_API_VERSION_0_2: * Add support for flexible YCbCr format with (*lock_ycbcr)() method. * * GRALLOC_MODULE_API_VERSION_0_3: * Add support for fence passing to/from lock/unlock. */ #define GRALLOC_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define GRALLOC_MODULE_API_VERSION_0_2 HARDWARE_MODULE_API_VERSION(0, 2) #define GRALLOC_MODULE_API_VERSION_0_3 HARDWARE_MODULE_API_VERSION(0, 3) #define GRALLOC_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION(0, 1) /** * The id of this module */ #define GRALLOC_HARDWARE_MODULE_ID "gralloc" /** * Name of the graphics device to open */ #define GRALLOC_HARDWARE_GPU0 "gpu0" enum { /* buffer is never read in software */ GRALLOC_USAGE_SW_READ_NEVER = 0x00000000, /* buffer is rarely read in software */ GRALLOC_USAGE_SW_READ_RARELY = 0x00000002, /* buffer is often read in software */ GRALLOC_USAGE_SW_READ_OFTEN = 0x00000003, /* mask for the software read values */ GRALLOC_USAGE_SW_READ_MASK = 0x0000000F, /* buffer is never written in software */ GRALLOC_USAGE_SW_WRITE_NEVER = 0x00000000, /* buffer is rarely written in software */ GRALLOC_USAGE_SW_WRITE_RARELY = 0x00000020, /* buffer is often written in software */ GRALLOC_USAGE_SW_WRITE_OFTEN = 0x00000030, /* mask for the software write values */ GRALLOC_USAGE_SW_WRITE_MASK = 0x000000F0, /* buffer will be used as an OpenGL ES texture */ GRALLOC_USAGE_HW_TEXTURE = 0x00000100, /* buffer will be used as an OpenGL ES render target */ GRALLOC_USAGE_HW_RENDER = 0x00000200, /* buffer will be used by the 2D hardware blitter */ GRALLOC_USAGE_HW_2D = 0x00000400, /* buffer will be used by the HWComposer HAL module */ GRALLOC_USAGE_HW_COMPOSER = 0x00000800, /* buffer will be used with the framebuffer device */ GRALLOC_USAGE_HW_FB = 0x00001000, /* buffer will be used with the HW video encoder */ GRALLOC_USAGE_HW_VIDEO_ENCODER = 0x00010000, /* buffer will be written by the HW camera pipeline */ GRALLOC_USAGE_HW_CAMERA_WRITE = 0x00020000, /* buffer will be read by the HW camera pipeline */ GRALLOC_USAGE_HW_CAMERA_READ = 0x00040000, /* buffer will be used as part of zero-shutter-lag queue */ GRALLOC_USAGE_HW_CAMERA_ZSL = 0x00060000, /* mask for the camera access values */ GRALLOC_USAGE_HW_CAMERA_MASK = 0x00060000, /* mask for the software usage bit-mask */ GRALLOC_USAGE_HW_MASK = 0x00071F00, /* buffer will be used as a RenderScript Allocation */ GRALLOC_USAGE_RENDERSCRIPT = 0x00100000, /* buffer should be displayed full-screen on an external display when * possible */ GRALLOC_USAGE_EXTERNAL_DISP = 0x00002000, /* Must have a hardware-protected path to external display sink for * this buffer. If a hardware-protected path is not available, then * either don't composite only this buffer (preferred) to the * external sink, or (less desirable) do not route the entire * composition to the external sink. */ GRALLOC_USAGE_PROTECTED = 0x00004000, /* buffer may be used as a cursor */ GRALLOC_USAGE_CURSOR = 0x00008000, /* 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, }; /*****************************************************************************/ /** * 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 gralloc_module_t { struct hw_module_t common; /* * (*registerBuffer)() must be called before a buffer_handle_t that has not * been created with (*alloc_device_t::alloc)() can be used. * * This is intended to be used with buffer_handle_t's that have been * received in this process through IPC. * * This function checks that the handle is indeed a valid one and prepares * it for use with (*lock)() and (*unlock)(). * * It is not necessary to call (*registerBuffer)() on a handle created * with (*alloc_device_t::alloc)(). * * returns an error if this buffer_handle_t is not valid. */ int (*registerBuffer)(struct gralloc_module_t const* module, buffer_handle_t handle); /* * (*unregisterBuffer)() is called once this handle is no longer needed in * this process. After this call, it is an error to call (*lock)(), * (*unlock)(), or (*registerBuffer)(). * * This function doesn't close or free the handle itself; this is done * by other means, usually through libcutils's native_handle_close() and * native_handle_free(). * * It is an error to call (*unregisterBuffer)() on a buffer that wasn't * explicitly registered first. */ int (*unregisterBuffer)(struct gralloc_module_t const* module, buffer_handle_t handle); /* * The (*lock)() method is called before a buffer is accessed for the * specified usage. This call may block, for instance if the h/w needs * to finish rendering or if CPU caches need to be synchronized. * * The caller promises to modify only pixels in the area specified * by (l,t,w,h). * * The content of the buffer outside of the specified area is NOT modified * by this call. * * If usage specifies GRALLOC_USAGE_SW_*, vaddr is filled with the address * of the buffer in virtual memory. * * Note calling (*lock)() on HAL_PIXEL_FORMAT_YCbCr_*_888 buffers will fail * and return -EINVAL. These buffers must be locked with (*lock_ycbcr)() * instead. * * THREADING CONSIDERATIONS: * * It is legal for several different threads to lock a buffer from * read access, none of the threads are blocked. * * However, locking a buffer simultaneously for write or read/write is * undefined, but: * - shall not result in termination of the process * - shall not block the caller * It is acceptable to return an error or to leave the buffer's content * into an indeterminate state. * * If the buffer was created with a usage mask incompatible with the * requested usage flags here, -EINVAL is returned. * */ int (*lock)(struct gralloc_module_t const* module, buffer_handle_t handle, int usage, int l, int t, int w, int h, void** vaddr); /* * The (*unlock)() method must be called after all changes to the buffer * are completed. */ int (*unlock)(struct gralloc_module_t const* module, buffer_handle_t handle); /* reserved for future use */ int (*perform)(struct gralloc_module_t const* module, int operation, ... ); /* * The (*lock_ycbcr)() method is like the (*lock)() method, with the * difference that it fills a struct ycbcr with a description of the buffer * layout, and zeroes out the reserved fields. * * This will only work on buffers with HAL_PIXEL_FORMAT_YCbCr_*_888, and * will return -EINVAL on any other buffer formats. * * Added in GRALLOC_MODULE_API_VERSION_0_2. */ int (*lock_ycbcr)(struct gralloc_module_t const* module, buffer_handle_t handle, int usage, int l, int t, int w, int h, struct android_ycbcr *ycbcr); /* * The (*lockAsync)() method is like the (*lock)() method except * that the buffer's sync fence object is passed into the lock * call instead of requiring the caller to wait for completion. * * The gralloc implementation takes ownership of the fenceFd and * is responsible for closing it when no longer needed. * * Added in GRALLOC_MODULE_API_VERSION_0_3. */ int (*lockAsync)(struct gralloc_module_t const* module, buffer_handle_t handle, int usage, int l, int t, int w, int h, void** vaddr, int fenceFd); /* * The (*unlockAsync)() method is like the (*unlock)() method * except that a buffer sync fence object is returned from the * lock call, representing the completion of any pending work * performed by the gralloc implementation. * * The caller takes ownership of the fenceFd and is responsible * for closing it when no longer needed. * * Added in GRALLOC_MODULE_API_VERSION_0_3. */ int (*unlockAsync)(struct gralloc_module_t const* module, buffer_handle_t handle, int* fenceFd); /* * The (*lockAsync_ycbcr)() method is like the (*lock_ycbcr)() * method except that the buffer's sync fence object is passed * into the lock call instead of requiring the caller to wait for * completion. * * The gralloc implementation takes ownership of the fenceFd and * is responsible for closing it when no longer needed. * * Added in GRALLOC_MODULE_API_VERSION_0_3. */ int (*lockAsync_ycbcr)(struct gralloc_module_t const* module, buffer_handle_t handle, int usage, int l, int t, int w, int h, struct android_ycbcr *ycbcr, int fenceFd); /* reserved for future use */ void* reserved_proc[3]; } gralloc_module_t; /*****************************************************************************/ /** * Every device data structure must begin with hw_device_t * followed by module specific public methods and attributes. */ typedef struct alloc_device_t { struct hw_device_t common; /* * (*alloc)() Allocates a buffer in graphic memory with the requested * parameters and returns a buffer_handle_t and the stride in pixels to * allow the implementation to satisfy hardware constraints on the width * of a pixmap (eg: it may have to be multiple of 8 pixels). * The CALLER TAKES OWNERSHIP of the buffer_handle_t. * * If format is HAL_PIXEL_FORMAT_YCbCr_420_888, the returned stride must be * 0, since the actual strides are available from the android_ycbcr * structure. * * Returns 0 on success or -errno on error. */ int (*alloc)(struct alloc_device_t* dev, int w, int h, int format, int usage, buffer_handle_t* handle, int* stride); /* * (*free)() Frees a previously allocated buffer. * Behavior is undefined if the buffer is still mapped in any process, * but shall not result in termination of the program or security breaches * (allowing a process to get access to another process' buffers). * THIS FUNCTION TAKES OWNERSHIP of the buffer_handle_t which becomes * invalid after the call. * * Returns 0 on success or -errno on error. */ int (*free)(struct alloc_device_t* dev, buffer_handle_t handle); /* This hook is OPTIONAL. * * If non NULL it will be caused by SurfaceFlinger on dumpsys */ void (*dump)(struct alloc_device_t *dev, char *buff, int buff_len); void* reserved_proc[7]; } alloc_device_t; /** convenience API for opening and closing a supported device */ 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); } static inline int gralloc_close(struct alloc_device_t* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_GRALLOC_INTERFACE_H android-headers-23/21/hardware/hardware.h000066400000000000000000000173341264465411000203310ustar00rootroot00000000000000/* * 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_HARDWARE_H #define ANDROID_INCLUDE_HARDWARE_HARDWARE_H #include #include #include #include __BEGIN_DECLS /* * Value for the hw_module_t.tag field */ #define MAKE_TAG_CONSTANT(A,B,C,D) (((A) << 24) | ((B) << 16) | ((C) << 8) | (D)) #define HARDWARE_MODULE_TAG MAKE_TAG_CONSTANT('H', 'W', 'M', 'T') #define HARDWARE_DEVICE_TAG MAKE_TAG_CONSTANT('H', 'W', 'D', 'T') #define HARDWARE_MAKE_API_VERSION(maj,min) \ ((((maj) & 0xff) << 8) | ((min) & 0xff)) #define HARDWARE_MAKE_API_VERSION_2(maj,min,hdr) \ ((((maj) & 0xff) << 24) | (((min) & 0xff) << 16) | ((hdr) & 0xffff)) #define HARDWARE_API_VERSION_2_MAJ_MIN_MASK 0xffff0000 #define HARDWARE_API_VERSION_2_HEADER_MASK 0x0000ffff /* * The current HAL API version. * * All module implementations must set the hw_module_t.hal_api_version field * to this value when declaring the module with HAL_MODULE_INFO_SYM. * * Note that previous implementations have always set this field to 0. * Therefore, libhardware HAL API will always consider versions 0.0 and 1.0 * to be 100% binary compatible. * */ #define HARDWARE_HAL_API_VERSION HARDWARE_MAKE_API_VERSION(1, 0) /* * Helper macros for module implementors. * * The derived modules should provide convenience macros for supported * versions so that implementations can explicitly specify module/device * versions at definition time. * * Use this macro to set the hw_module_t.module_api_version field. */ #define HARDWARE_MODULE_API_VERSION(maj,min) HARDWARE_MAKE_API_VERSION(maj,min) #define HARDWARE_MODULE_API_VERSION_2(maj,min,hdr) HARDWARE_MAKE_API_VERSION_2(maj,min,hdr) /* * Use this macro to set the hw_device_t.version field */ #define HARDWARE_DEVICE_API_VERSION(maj,min) HARDWARE_MAKE_API_VERSION(maj,min) #define HARDWARE_DEVICE_API_VERSION_2(maj,min,hdr) HARDWARE_MAKE_API_VERSION_2(maj,min,hdr) struct hw_module_t; struct hw_module_methods_t; struct hw_device_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 hw_module_t { /** tag must be initialized to HARDWARE_MODULE_TAG */ uint32_t tag; /** * The API version of the implemented module. The module owner is * responsible for updating the version when a module interface has * changed. * * The derived modules such as gralloc and audio own and manage this field. * The module user must interpret the version field to decide whether or * not to inter-operate with the supplied module implementation. * For example, SurfaceFlinger is responsible for making sure that * it knows how to manage different versions of the gralloc-module API, * and AudioFlinger must know how to do the same for audio-module API. * * The module API version should include a major and a minor component. * For example, version 1.0 could be represented as 0x0100. This format * implies that versions 0x0100-0x01ff are all API-compatible. * * In the future, libhardware will expose a hw_get_module_version() * (or equivalent) function that will take minimum/maximum supported * versions as arguments and would be able to reject modules with * versions outside of the supplied range. */ uint16_t module_api_version; #define version_major module_api_version /** * version_major/version_minor defines are supplied here for temporary * source code compatibility. They will be removed in the next version. * ALL clients must convert to the new version format. */ /** * The API version of the HAL module interface. This is meant to * version the hw_module_t, hw_module_methods_t, and hw_device_t * structures and definitions. * * The HAL interface owns this field. Module users/implementations * must NOT rely on this value for version information. * * Presently, 0 is the only valid value. */ uint16_t hal_api_version; #define version_minor hal_api_version /** Identifier of module */ const char *id; /** Name of this module */ const char *name; /** Author/owner/implementor of the module */ const char *author; /** Modules methods */ struct hw_module_methods_t* methods; /** module's dso */ void* dso; #ifdef __LP64__ uint64_t reserved[32-7]; #else /** padding to 128 bytes, reserved for future use */ uint32_t reserved[32-7]; #endif } hw_module_t; typedef struct hw_module_methods_t { /** Open a specific device */ int (*open)(const struct hw_module_t* module, const char* id, struct hw_device_t** device); } hw_module_methods_t; /** * Every device data structure must begin with hw_device_t * followed by module specific public methods and attributes. */ typedef struct hw_device_t { /** tag must be initialized to HARDWARE_DEVICE_TAG */ uint32_t tag; /** * Version of the module-specific device API. This value is used by * the derived-module user to manage different device implementations. * * The module user is responsible for checking the module_api_version * and device version fields to ensure that the user is capable of * communicating with the specific module implementation. * * One module can support multiple devices with different versions. This * can be useful when a device interface changes in an incompatible way * but it is still necessary to support older implementations at the same * time. One such example is the Camera 2.0 API. * * This field is interpreted by the module user and is ignored by the * HAL interface itself. */ uint32_t version; /** reference to the module this device belongs to */ struct hw_module_t* module; /** padding reserved for future use */ #ifdef __LP64__ uint64_t reserved[12]; #else uint32_t reserved[12]; #endif /** Close this device */ int (*close)(struct hw_device_t* device); } hw_device_t; /** * Name of the hal_module_info */ #define HAL_MODULE_INFO_SYM HMI /** * Name of the hal_module_info as a string */ #define HAL_MODULE_INFO_SYM_AS_STR "HMI" /** * Get the module info associated with a module by id. * * @return: 0 == success, <0 == error and *module == NULL */ int hw_get_module(const char *id, const struct hw_module_t **module); /** * Get the module info associated with a module instance by class 'class_id' * and instance 'inst'. * * Some modules types necessitate multiple instances. For example audio supports * multiple concurrent interfaces and thus 'audio' is the module class * and 'primary' or 'a2dp' are module interfaces. This implies that the files * providing these modules would be named audio.primary..so and * audio.a2dp..so * * @return: 0 == success, <0 == error and *module == NULL */ int hw_get_module_by_class(const char *class_id, const char *inst, const struct hw_module_t **module); __END_DECLS #endif /* ANDROID_INCLUDE_HARDWARE_HARDWARE_H */ android-headers-23/21/hardware/hdmi_cec.h000066400000000000000000000335471264465411000202730ustar00rootroot00000000000000/* * 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_HARDWARE_HDMI_CEC_H #define ANDROID_INCLUDE_HARDWARE_HDMI_CEC_H #include #include #include __BEGIN_DECLS #define HDMI_CEC_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) #define HDMI_CEC_MODULE_API_VERSION_CURRENT HDMI_MODULE_API_VERSION_1_0 #define HDMI_CEC_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) #define HDMI_CEC_DEVICE_API_VERSION_CURRENT HDMI_DEVICE_API_VERSION_1_0 #define HDMI_CEC_HARDWARE_MODULE_ID "hdmi_cec" #define HDMI_CEC_HARDWARE_INTERFACE "hdmi_cec_hw_if" typedef enum cec_device_type { CEC_DEVICE_INACTIVE = -1, CEC_DEVICE_TV = 0, CEC_DEVICE_RECORDER = 1, CEC_DEVICE_RESERVED = 2, CEC_DEVICE_TUNER = 3, CEC_DEVICE_PLAYBACK = 4, CEC_DEVICE_AUDIO_SYSTEM = 5, CEC_DEVICE_MAX = CEC_DEVICE_AUDIO_SYSTEM } cec_device_type_t; typedef enum cec_logical_address { CEC_ADDR_TV = 0, CEC_ADDR_RECORDER_1 = 1, CEC_ADDR_RECORDER_2 = 2, CEC_ADDR_TUNER_1 = 3, CEC_ADDR_PLAYBACK_1 = 4, CEC_ADDR_AUDIO_SYSTEM = 5, CEC_ADDR_TUNER_2 = 6, CEC_ADDR_TUNER_3 = 7, CEC_ADDR_PLAYBACK_2 = 8, CEC_ADDR_RECORDER_3 = 9, CEC_ADDR_TUNER_4 = 10, CEC_ADDR_PLAYBACK_3 = 11, CEC_ADDR_RESERVED_1 = 12, CEC_ADDR_RESERVED_2 = 13, CEC_ADDR_FREE_USE = 14, CEC_ADDR_UNREGISTERED = 15, CEC_ADDR_BROADCAST = 15 } cec_logical_address_t; /* * HDMI CEC messages */ enum cec_message_type { CEC_MESSAGE_FEATURE_ABORT = 0x00, CEC_MESSAGE_IMAGE_VIEW_ON = 0x04, CEC_MESSAGE_TUNER_STEP_INCREMENT = 0x05, CEC_MESSAGE_TUNER_STEP_DECREMENT = 0x06, CEC_MESSAGE_TUNER_DEVICE_STATUS = 0x07, CEC_MESSAGE_GIVE_TUNER_DEVICE_STATUS = 0x08, CEC_MESSAGE_RECORD_ON = 0x09, CEC_MESSAGE_RECORD_STATUS = 0x0A, CEC_MESSAGE_RECORD_OFF = 0x0B, CEC_MESSAGE_TEXT_VIEW_ON = 0x0D, CEC_MESSAGE_RECORD_TV_SCREEN = 0x0F, CEC_MESSAGE_GIVE_DECK_STATUS = 0x1A, CEC_MESSAGE_DECK_STATUS = 0x1B, CEC_MESSAGE_SET_MENU_LANGUAGE = 0x32, CEC_MESSAGE_CLEAR_ANALOG_TIMER = 0x33, CEC_MESSAGE_SET_ANALOG_TIMER = 0x34, CEC_MESSAGE_TIMER_STATUS = 0x35, CEC_MESSAGE_STANDBY = 0x36, CEC_MESSAGE_PLAY = 0x41, CEC_MESSAGE_DECK_CONTROL = 0x42, CEC_MESSAGE_TIMER_CLEARED_STATUS = 0x043, CEC_MESSAGE_USER_CONTROL_PRESSED = 0x44, CEC_MESSAGE_USER_CONTROL_RELEASED = 0x45, CEC_MESSAGE_GIVE_OSD_NAME = 0x46, CEC_MESSAGE_SET_OSD_NAME = 0x47, CEC_MESSAGE_SET_OSD_STRING = 0x64, CEC_MESSAGE_SET_TIMER_PROGRAM_TITLE = 0x67, CEC_MESSAGE_SYSTEM_AUDIO_MODE_REQUEST = 0x70, CEC_MESSAGE_GIVE_AUDIO_STATUS = 0x71, CEC_MESSAGE_SET_SYSTEM_AUDIO_MODE = 0x72, CEC_MESSAGE_REPORT_AUDIO_STATUS = 0x7A, CEC_MESSAGE_GIVE_SYSTEM_AUDIO_MODE_STATUS = 0x7D, CEC_MESSAGE_SYSTEM_AUDIO_MODE_STATUS = 0x7E, CEC_MESSAGE_ROUTING_CHANGE = 0x80, CEC_MESSAGE_ROUTING_INFORMATION = 0x81, CEC_MESSAGE_ACTIVE_SOURCE = 0x82, CEC_MESSAGE_GIVE_PHYSICAL_ADDRESS = 0x83, CEC_MESSAGE_REPORT_PHYSICAL_ADDRESS = 0x84, CEC_MESSAGE_REQUEST_ACTIVE_SOURCE = 0x85, CEC_MESSAGE_SET_STREAM_PATH = 0x86, CEC_MESSAGE_DEVICE_VENDOR_ID = 0x87, CEC_MESSAGE_VENDOR_COMMAND = 0x89, CEC_MESSAGE_VENDOR_REMOTE_BUTTON_DOWN = 0x8A, CEC_MESSAGE_VENDOR_REMOTE_BUTTON_UP = 0x8B, CEC_MESSAGE_GIVE_DEVICE_VENDOR_ID = 0x8C, CEC_MESSAGE_MENU_REQUEST = 0x8D, CEC_MESSAGE_MENU_STATUS = 0x8E, CEC_MESSAGE_GIVE_DEVICE_POWER_STATUS = 0x8F, CEC_MESSAGE_REPORT_POWER_STATUS = 0x90, CEC_MESSAGE_GET_MENU_LANGUAGE = 0x91, CEC_MESSAGE_SELECT_ANALOG_SERVICE = 0x92, CEC_MESSAGE_SELECT_DIGITAL_SERVICE = 0x93, CEC_MESSAGE_SET_DIGITAL_TIMER = 0x97, CEC_MESSAGE_CLEAR_DIGITAL_TIMER = 0x99, CEC_MESSAGE_SET_AUDIO_RATE = 0x9A, CEC_MESSAGE_INACTIVE_SOURCE = 0x9D, CEC_MESSAGE_CEC_VERSION = 0x9E, CEC_MESSAGE_GET_CEC_VERSION = 0x9F, CEC_MESSAGE_VENDOR_COMMAND_WITH_ID = 0xA0, CEC_MESSAGE_CLEAR_EXTERNAL_TIMER = 0xA1, CEC_MESSAGE_SET_EXTERNAL_TIMER = 0xA2, CEC_MESSAGE_INITIATE_ARC = 0xC0, CEC_MESSAGE_REPORT_ARC_INITIATED = 0xC1, CEC_MESSAGE_REPORT_ARC_TERMINATED = 0xC2, CEC_MESSAGE_REQUEST_ARC_INITIATION = 0xC3, CEC_MESSAGE_REQUEST_ARC_TERMINATION = 0xC4, CEC_MESSAGE_TERMINATE_ARC = 0xC5, CEC_MESSAGE_ABORT = 0xFF }; /* * Operand description [Abort Reason] */ enum abort_reason { ABORT_UNRECOGNIZED_MODE = 0, ABORT_NOT_IN_CORRECT_MODE = 1, ABORT_CANNOT_PROVIDE_SOURCE = 2, ABORT_INVALID_OPERAND = 3, ABORT_REFUSED = 4, ABORT_UNABLE_TO_DETERMINE = 5 }; /* * HDMI event type. used for hdmi_event_t. */ enum { HDMI_EVENT_CEC_MESSAGE = 1, HDMI_EVENT_HOT_PLUG = 2, }; /* * HDMI hotplug event type. Used when the event * type is HDMI_EVENT_HOT_PLUG. */ enum { HDMI_NOT_CONNECTED = 0, HDMI_CONNECTED = 1 }; /* * error code used for send_message. */ enum { HDMI_RESULT_SUCCESS = 0, HDMI_RESULT_NACK = 1, /* not acknowledged */ HDMI_RESULT_BUSY = 2, /* bus is busy */ HDMI_RESULT_FAIL = 3, }; /* * HDMI port type. */ typedef enum hdmi_port_type { HDMI_INPUT = 0, HDMI_OUTPUT = 1 } hdmi_port_type_t; /* * Flags used for set_option() */ enum { /* When set to false, HAL does not wake up the system upon receiving * or . Used when user changes the TV * settings to disable the auto TV on functionality. * True by default. */ HDMI_OPTION_WAKEUP = 1, /* When set to false, all the CEC commands are discarded. Used when * user changes the TV settings to disable CEC functionality. * True by default. */ HDMI_OPTION_ENABLE_CEC = 2, /* Setting this flag to false means Android system will stop handling * CEC service and yield the control over to the microprocessor that is * powered on through the standby mode. When set to true, the system * will gain the control over, hence telling the microprocessor to stop * handling the cec commands. This is called when system goes * in and out of standby mode to notify the microprocessor that it should * start/stop handling CEC commands on behalf of the system. * False by default. */ HDMI_OPTION_SYSTEM_CEC_CONTROL = 3, }; /* * Maximum length in bytes of cec message body (exclude header block), * should not exceed 16 (spec CEC 6 Frame Description) */ #define CEC_MESSAGE_BODY_MAX_LENGTH 16 typedef struct cec_message { /* logical address of sender */ cec_logical_address_t initiator; /* logical address of receiver */ cec_logical_address_t destination; /* Length in bytes of body, range [0, CEC_MESSAGE_BODY_MAX_LENGTH] */ size_t length; unsigned char body[CEC_MESSAGE_BODY_MAX_LENGTH]; } cec_message_t; typedef struct hotplug_event { /* * true if the cable is connected; otherwise false. */ int connected; int port_id; } hotplug_event_t; typedef struct tx_status_event { int status; int opcode; /* CEC opcode */ } tx_status_event_t; /* * HDMI event generated from HAL. */ typedef struct hdmi_event { int type; struct hdmi_cec_device* dev; union { cec_message_t cec; hotplug_event_t hotplug; }; } hdmi_event_t; /* * HDMI port descriptor */ typedef struct hdmi_port_info { hdmi_port_type_t type; // Port ID should start from 1 which corresponds to HDMI "port 1". int port_id; int cec_supported; int arc_supported; uint16_t physical_address; } hdmi_port_info_t; /* * Callback function type that will be called by HAL implementation. * Services can not close/open the device in the callback. */ typedef void (*event_callback_t)(const hdmi_event_t* event, void* arg); typedef struct hdmi_cec_module { /** * Common methods of the HDMI CEC module. This *must* be the first member of * hdmi_cec_module as users of this structure will cast a hw_module_t to hdmi_cec_module * pointer in contexts where it's known the hw_module_t references a hdmi_cec_module. */ struct hw_module_t common; } hdmi_module_t; /* * HDMI-CEC HAL interface definition. */ typedef struct hdmi_cec_device { /** * Common methods of the HDMI CEC device. This *must* be the first member of * hdmi_cec_device as users of this structure will cast a hw_device_t to hdmi_cec_device * pointer in contexts where it's known the hw_device_t references a hdmi_cec_device. */ struct hw_device_t common; /* * (*add_logical_address)() passes the logical address that will be used * in this system. * * HAL may use it to configure the hardware so that the CEC commands addressed * the given logical address can be filtered in. This method can be called * as many times as necessary in order to support multiple logical devices. * addr should be in the range of valid logical addresses for the call * to succeed. * * Returns 0 on success or -errno on error. */ int (*add_logical_address)(const struct hdmi_cec_device* dev, cec_logical_address_t addr); /* * (*clear_logical_address)() tells HAL to reset all the logical addresses. * * It is used when the system doesn't need to process CEC command any more, * hence to tell HAL to stop receiving commands from the CEC bus, and change * the state back to the beginning. */ void (*clear_logical_address)(const struct hdmi_cec_device* dev); /* * (*get_physical_address)() returns the CEC physical address. The * address is written to addr. * * The physical address depends on the topology of the network formed * by connected HDMI devices. It is therefore likely to change if the cable * is plugged off and on again. It is advised to call get_physical_address * to get the updated address when hot plug event takes place. * * Returns 0 on success or -errno on error. */ int (*get_physical_address)(const struct hdmi_cec_device* dev, uint16_t* addr); /* * (*send_message)() transmits HDMI-CEC message to other HDMI device. * * The method should be designed to return in a certain amount of time not * hanging forever, which can happen if CEC signal line is pulled low for * some reason. HAL implementation should take the situation into account * so as not to wait forever for the message to get sent out. * * It should try retransmission at least once as specified in the standard. * * Returns error code. See HDMI_RESULT_SUCCESS, HDMI_RESULT_NACK, and * HDMI_RESULT_BUSY. */ int (*send_message)(const struct hdmi_cec_device* dev, const cec_message_t*); /* * (*register_event_callback)() registers a callback that HDMI-CEC HAL * can later use for incoming CEC messages or internal HDMI events. * When calling from C++, use the argument arg to pass the calling object. * It will be passed back when the callback is invoked so that the context * can be retrieved. */ void (*register_event_callback)(const struct hdmi_cec_device* dev, event_callback_t callback, void* arg); /* * (*get_version)() returns the CEC version supported by underlying hardware. */ void (*get_version)(const struct hdmi_cec_device* dev, int* version); /* * (*get_vendor_id)() returns the identifier of the vendor. It is * the 24-bit unique company ID obtained from the IEEE Registration * Authority Committee (RAC). */ void (*get_vendor_id)(const struct hdmi_cec_device* dev, uint32_t* vendor_id); /* * (*get_port_info)() returns the hdmi port information of underlying hardware. * info is the list of HDMI port information, and 'total' is the number of * HDMI ports in the system. */ void (*get_port_info)(const struct hdmi_cec_device* dev, struct hdmi_port_info* list[], int* total); /* * (*set_option)() passes flags controlling the way HDMI-CEC service works down * to HAL implementation. Those flags will be used in case the feature needs * update in HAL itself, firmware or microcontroller. */ void (*set_option)(const struct hdmi_cec_device* dev, int flag, int value); /* * (*set_audio_return_channel)() configures ARC circuit in the hardware logic * to start or stop the feature. Flag can be either 1 to start the feature * or 0 to stop it. * * Returns 0 on success or -errno on error. */ void (*set_audio_return_channel)(const struct hdmi_cec_device* dev, int flag); /* * (*is_connected)() returns the connection status of the specified port. * Returns HDMI_CONNECTED if a device is connected, otherwise HDMI_NOT_CONNECTED. * The HAL should watch for +5V power signal to determine the status. */ int (*is_connected)(const struct hdmi_cec_device* dev, int port_id); /* Reserved for future use to maximum 16 functions. Must be NULL. */ void* reserved[16 - 11]; } hdmi_cec_device_t; /** convenience API for opening and closing a 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); } static inline int hdmi_cec_close(struct hdmi_cec_device* device) { return device->common.close(&device->common); } __END_DECLS #endif /* ANDROID_INCLUDE_HARDWARE_HDMI_CEC_H */ android-headers-23/21/hardware/hwcomposer.h000066400000000000000000001031761264465411000207220ustar00rootroot00000000000000/* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H #define ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H #include #include #include #include #include #include __BEGIN_DECLS /*****************************************************************************/ /* for compatibility */ #define HWC_MODULE_API_VERSION HWC_MODULE_API_VERSION_0_1 #define HWC_DEVICE_API_VERSION HWC_DEVICE_API_VERSION_0_1 #define HWC_API_VERSION HWC_DEVICE_API_VERSION /*****************************************************************************/ /** * The id of this module */ #define HWC_HARDWARE_MODULE_ID "hwcomposer" /** * Name of the sensors device to open */ #define HWC_HARDWARE_COMPOSER "composer" typedef struct hwc_rect { int left; int top; int right; int bottom; } hwc_rect_t; typedef struct hwc_frect { float left; float top; float right; float bottom; } hwc_frect_t; typedef struct hwc_region { size_t numRects; hwc_rect_t const* rects; } hwc_region_t; typedef struct hwc_color { uint8_t r; uint8_t g; uint8_t b; uint8_t a; } hwc_color_t; typedef struct hwc_layer_1 { /* * compositionType is used to specify this layer's type and is set by either * the hardware composer implementation, or by the caller (see below). * * This field is always reset to HWC_BACKGROUND or HWC_FRAMEBUFFER * before (*prepare)() is called when the HWC_GEOMETRY_CHANGED flag is * also set, otherwise, this field is preserved between (*prepare)() * calls. * * HWC_BACKGROUND * Always set by the caller before calling (*prepare)(), this value * indicates this is a special "background" layer. The only valid field * is backgroundColor. * The HWC can toggle this value to HWC_FRAMEBUFFER to indicate it CANNOT * handle the background color. * * * HWC_FRAMEBUFFER_TARGET * Always set by the caller before calling (*prepare)(), this value * indicates this layer is the framebuffer surface used as the target of * OpenGL ES composition. If the HWC sets all other layers to HWC_OVERLAY * or HWC_BACKGROUND, then no OpenGL ES composition will be done, and * this layer should be ignored during set(). * * This flag (and the framebuffer surface layer) will only be used if the * HWC version is HWC_DEVICE_API_VERSION_1_1 or higher. In older versions, * the OpenGL ES target surface is communicated by the (dpy, sur) fields * in hwc_compositor_device_1_t. * * This value cannot be set by the HWC implementation. * * * HWC_FRAMEBUFFER * Set by the caller before calling (*prepare)() ONLY when the * HWC_GEOMETRY_CHANGED flag is also set. * * Set by the HWC implementation during (*prepare)(), this indicates * that the layer will be drawn into the framebuffer using OpenGL ES. * The HWC can toggle this value to HWC_OVERLAY to indicate it will * handle the layer. * * * HWC_OVERLAY * Set by the HWC implementation during (*prepare)(), this indicates * that the layer will be handled by the HWC (ie: it must not be * composited with OpenGL ES). * * * HWC_SIDEBAND * Set by the caller before calling (*prepare)(), this value indicates * the contents of this layer come from a sideband video stream. * * The h/w composer is responsible for receiving new image buffers from * the stream at the appropriate time (e.g. synchronized to a separate * audio stream), compositing them with the current contents of other * layers, and displaying the resulting image. This happens * independently of the normal prepare/set cycle. The prepare/set calls * only happen when other layers change, or when properties of the * sideband layer such as position or size change. * * If the h/w composer can't handle the layer as a sideband stream for * some reason (e.g. unsupported scaling/blending/rotation, or too many * sideband layers) it can set compositionType to HWC_FRAMEBUFFER in * (*prepare)(). However, doing so will result in the layer being shown * as a solid color since the platform is not currently able to composite * sideband layers with the GPU. This may be improved in future * versions of the platform. * * * HWC_CURSOR_OVERLAY * Set by the HWC implementation during (*prepare)(), this value * indicates the layer's composition will now be handled by the HWC. * Additionally, the client can now asynchronously update the on-screen * position of this layer using the setCursorPositionAsync() api. */ int32_t compositionType; /* * hints is bit mask set by the HWC implementation during (*prepare)(). * It is preserved between (*prepare)() calls, unless the * HWC_GEOMETRY_CHANGED flag is set, in which case it is reset to 0. * * see hwc_layer_t::hints */ uint32_t hints; /* see hwc_layer_t::flags */ uint32_t flags; union { /* color of the background. hwc_color_t.a is ignored */ hwc_color_t backgroundColor; struct { union { /* When compositionType is HWC_FRAMEBUFFER, HWC_OVERLAY, * HWC_FRAMEBUFFER_TARGET, this is the handle of the buffer to * compose. This handle is guaranteed to have been allocated * from gralloc using the GRALLOC_USAGE_HW_COMPOSER usage flag. * If the layer's handle is unchanged across two consecutive * prepare calls and the HWC_GEOMETRY_CHANGED flag is not set * for the second call then the HWComposer implementation may * assume that the contents of the buffer have not changed. */ buffer_handle_t handle; /* When compositionType is HWC_SIDEBAND, this is the handle * of the sideband video stream to compose. */ const native_handle_t* sidebandStream; }; /* transformation to apply to the buffer during composition */ uint32_t transform; /* blending to apply during composition */ int32_t blending; /* area of the source to consider, the origin is the top-left corner of * the buffer. As of HWC_DEVICE_API_VERSION_1_3, sourceRect uses floats. * If the h/w can't support a non-integer source crop rectangle, it should * punt to OpenGL ES composition. */ union { // crop rectangle in integer (pre HWC_DEVICE_API_VERSION_1_3) hwc_rect_t sourceCropi; hwc_rect_t sourceCrop; // just for source compatibility // crop rectangle in floats (as of HWC_DEVICE_API_VERSION_1_3) hwc_frect_t sourceCropf; }; /* where to composite the sourceCrop onto the display. The sourceCrop * is scaled using linear filtering to the displayFrame. The origin is the * top-left corner of the screen. */ hwc_rect_t displayFrame; /* visible region in screen space. The origin is the * top-left corner of the screen. * The visible region INCLUDES areas overlapped by a translucent layer. */ hwc_region_t visibleRegionScreen; /* Sync fence object that will be signaled when the buffer's * contents are available. May be -1 if the contents are already * available. This field is only valid during set(), and should be * ignored during prepare(). The set() call must not wait for the * fence to be signaled before returning, but the HWC must wait for * all buffers to be signaled before reading from them. * * HWC_FRAMEBUFFER layers will never have an acquire fence, since * reads from them are complete before the framebuffer is ready for * display. * * HWC_SIDEBAND layers will never have an acquire fence, since * synchronization is handled through implementation-defined * sideband mechanisms. * * The HWC takes ownership of the acquireFenceFd and is responsible * for closing it when no longer needed. */ int acquireFenceFd; /* During set() the HWC must set this field to a file descriptor for * a sync fence object that will signal after the HWC has finished * reading from the buffer. The field is ignored by prepare(). Each * layer should have a unique file descriptor, even if more than one * refer to the same underlying fence object; this allows each to be * closed independently. * * If buffer reads can complete at significantly different times, * then using independent fences is preferred. For example, if the * HWC handles some layers with a blit engine and others with * overlays, then the blit layers can be reused immediately after * the blit completes, but the overlay layers can't be reused until * a subsequent frame has been displayed. * * Since HWC doesn't read from HWC_FRAMEBUFFER layers, it shouldn't * produce a release fence for them. The releaseFenceFd will be -1 * for these layers when set() is called. * * Since HWC_SIDEBAND buffers don't pass through the HWC client, * the HWC shouldn't produce a release fence for them. The * releaseFenceFd will be -1 for these layers when set() is called. * * The HWC client taks ownership of the releaseFenceFd and is * responsible for closing it when no longer needed. */ int releaseFenceFd; /* * Availability: HWC_DEVICE_API_VERSION_1_2 * * Alpha value applied to the whole layer. The effective * value of each pixel is computed as: * * if (blending == HWC_BLENDING_PREMULT) * pixel.rgb = pixel.rgb * planeAlpha / 255 * pixel.a = pixel.a * planeAlpha / 255 * * Then blending proceeds as usual according to the "blending" * field above. * * NOTE: planeAlpha applies to YUV layers as well: * * pixel.rgb = yuv_to_rgb(pixel.yuv) * if (blending == HWC_BLENDING_PREMULT) * pixel.rgb = pixel.rgb * planeAlpha / 255 * pixel.a = planeAlpha * * * IMPLEMENTATION NOTE: * * If the source image doesn't have an alpha channel, then * the h/w can use the HWC_BLENDING_COVERAGE equations instead of * HWC_BLENDING_PREMULT and simply set the alpha channel to * planeAlpha. * * e.g.: * * if (blending == HWC_BLENDING_PREMULT) * blending = HWC_BLENDING_COVERAGE; * pixel.a = planeAlpha; * */ uint8_t planeAlpha; /* reserved for future use */ uint8_t _pad[3]; }; }; #ifdef __LP64__ /* * For 64-bit mode, this struct is 120 bytes (and 8-byte aligned), and needs * to be padded as such to maintain binary compatibility. */ uint8_t reserved[120 - 96]; #else /* * For 32-bit mode, this struct is 96 bytes, and needs to be padded as such * to maintain binary compatibility. */ uint8_t reserved[96 - 76]; #endif } hwc_layer_1_t; /* This represents a display, typically an EGLDisplay object */ typedef void* hwc_display_t; /* This represents a surface, typically an EGLSurface object */ typedef void* hwc_surface_t; /* * hwc_display_contents_1_t::flags values */ enum { /* * HWC_GEOMETRY_CHANGED is set by SurfaceFlinger to indicate that the list * passed to (*prepare)() has changed by more than just the buffer handles * and acquire fences. */ HWC_GEOMETRY_CHANGED = 0x00000001, }; /* * Description of the contents to output on a display. * * This is the top-level structure passed to the prepare and set calls to * negotiate and commit the composition of a display image. */ typedef struct hwc_display_contents_1 { /* File descriptor referring to a Sync HAL fence object which will signal * when this composition is retired. For a physical display, a composition * is retired when it has been replaced on-screen by a subsequent set. For * a virtual display, the composition is retired when the writes to * outputBuffer are complete and can be read. The fence object is created * and returned by the set call; this field will be -1 on entry to prepare * and set. SurfaceFlinger will close the returned file descriptor. */ int retireFenceFd; union { /* Fields only relevant for HWC_DEVICE_VERSION_1_0. */ struct { /* (dpy, sur) is the target of SurfaceFlinger's OpenGL ES * composition for HWC_DEVICE_VERSION_1_0. They aren't relevant to * prepare. The set call should commit this surface atomically to * the display along with any overlay layers. */ hwc_display_t dpy; hwc_surface_t sur; }; /* These fields are used for virtual displays when the h/w composer * version is at least HWC_DEVICE_VERSION_1_3. */ struct { /* outbuf is the buffer that receives the composed image for * virtual displays. Writes to the outbuf must wait until * outbufAcquireFenceFd signals. A fence that will signal when * writes to outbuf are complete should be returned in * retireFenceFd. * * This field is set before prepare(), so properties of the buffer * can be used to decide which layers can be handled by h/w * composer. * * If prepare() sets all layers to FRAMEBUFFER, then GLES * composition will happen directly to the output buffer. In this * case, both outbuf and the FRAMEBUFFER_TARGET layer's buffer will * be the same, and set() has no work to do besides managing fences. * * If the TARGET_FORCE_HWC_FOR_VIRTUAL_DISPLAYS board config * variable is defined (not the default), then this behavior is * changed: if all layers are marked for FRAMEBUFFER, GLES * composition will take place to a scratch framebuffer, and * h/w composer must copy it to the output buffer. This allows the * h/w composer to do format conversion if there are cases where * that is more desirable than doing it in the GLES driver or at the * virtual display consumer. * * If some or all layers are marked OVERLAY, then the framebuffer * and output buffer will be different. As with physical displays, * the framebuffer handle will not change between frames if all * layers are marked for OVERLAY. */ buffer_handle_t outbuf; /* File descriptor for a fence that will signal when outbuf is * ready to be written. The h/w composer is responsible for closing * this when no longer needed. * * Will be -1 whenever outbuf is NULL, or when the outbuf can be * written immediately. */ int outbufAcquireFenceFd; }; }; /* List of layers that will be composed on the display. The buffer handles * in the list will be unique. If numHwLayers is 0, all composition will be * performed by SurfaceFlinger. */ uint32_t flags; size_t numHwLayers; hwc_layer_1_t hwLayers[0]; } hwc_display_contents_1_t; /* see hwc_composer_device::registerProcs() * All of the callbacks are required and non-NULL unless otherwise noted. */ typedef struct hwc_procs { /* * (*invalidate)() triggers a screen refresh, in particular prepare and set * will be called shortly after this call is made. Note that there is * NO GUARANTEE that the screen refresh will happen after invalidate() * returns (in particular, it could happen before). * invalidate() is GUARANTEED TO NOT CALL BACK into the h/w composer HAL and * it is safe to call invalidate() from any of hwc_composer_device * hooks, unless noted otherwise. */ void (*invalidate)(const struct hwc_procs* procs); /* * (*vsync)() is called by the h/w composer HAL when a vsync event is * received and HWC_EVENT_VSYNC is enabled on a display * (see: hwc_event_control). * * the "disp" parameter indicates which display the vsync event is for. * the "timestamp" parameter is the system monotonic clock timestamp in * nanosecond of when the vsync event happened. * * vsync() is GUARANTEED TO NOT CALL BACK into the h/w composer HAL. * * It is expected that vsync() is called from a thread of at least * HAL_PRIORITY_URGENT_DISPLAY with as little latency as possible, * typically less than 0.5 ms. * * It is a (silent) error to have HWC_EVENT_VSYNC enabled when calling * hwc_composer_device.set(..., 0, 0, 0) (screen off). The implementation * can either stop or continue to process VSYNC events, but must not * crash or cause other problems. */ void (*vsync)(const struct hwc_procs* procs, int disp, int64_t timestamp); /* * (*hotplug)() is called by the h/w composer HAL when a display is * connected or disconnected. The PRIMARY display is always connected and * the hotplug callback should not be called for it. * * The disp parameter indicates which display type this event is for. * The connected parameter indicates whether the display has just been * connected (1) or disconnected (0). * * The hotplug() callback may call back into the h/w composer on the same * thread to query refresh rate and dpi for the display. Additionally, * other threads may be calling into the h/w composer while the callback * is in progress. * * The h/w composer must serialize calls to the hotplug callback; only * one thread may call it at a time. * * This callback will be NULL if the h/w composer is using * HWC_DEVICE_API_VERSION_1_0. */ void (*hotplug)(const struct hwc_procs* procs, int disp, int connected); } hwc_procs_t; /*****************************************************************************/ typedef struct hwc_module { /** * Common methods of the hardware composer module. This *must* be the first member of * hwc_module as users of this structure will cast a hw_module_t to * hwc_module pointer in contexts where it's known the hw_module_t references a * hwc_module. */ struct hw_module_t common; } hwc_module_t; typedef struct hwc_composer_device_1 { /** * Common methods of the hardware composer device. This *must* be the first member of * hwc_composer_device_1 as users of this structure will cast a hw_device_t to * hwc_composer_device_1 pointer in contexts where it's known the hw_device_t references a * hwc_composer_device_1. */ struct hw_device_t common; /* * (*prepare)() is called for each frame before composition and is used by * SurfaceFlinger to determine what composition steps the HWC can handle. * * (*prepare)() can be called more than once, the last call prevails. * * The HWC responds by setting the compositionType field in each layer to * either HWC_FRAMEBUFFER, HWC_OVERLAY, or HWC_CURSOR_OVERLAY. For the * HWC_FRAMEBUFFER type, composition for the layer is handled by * SurfaceFlinger with OpenGL ES. For the latter two overlay types, * the HWC will have to handle the layer's composition. compositionType * and hints are preserved between (*prepare)() calles unless the * HWC_GEOMETRY_CHANGED flag is set. * * (*prepare)() is called with HWC_GEOMETRY_CHANGED to indicate that the * list's geometry has changed, that is, when more than just the buffer's * handles have been updated. Typically this happens (but is not limited to) * when a window is added, removed, resized or moved. In this case * compositionType and hints are reset to their default value. * * For HWC 1.0, numDisplays will always be one, and displays[0] will be * non-NULL. * * For HWC 1.1, numDisplays will always be HWC_NUM_PHYSICAL_DISPLAY_TYPES. * Entries for unsupported or disabled/disconnected display types will be * NULL. * * In HWC 1.3, numDisplays may be up to HWC_NUM_DISPLAY_TYPES. The extra * entries correspond to enabled virtual displays, and will be non-NULL. * * returns: 0 on success. An negative error code on error. If an error is * returned, SurfaceFlinger will assume that none of the layer will be * handled by the HWC. */ int (*prepare)(struct hwc_composer_device_1 *dev, size_t numDisplays, hwc_display_contents_1_t** displays); /* * (*set)() is used in place of eglSwapBuffers(), and assumes the same * functionality, except it also commits the work list atomically with * the actual eglSwapBuffers(). * * The layer lists are guaranteed to be the same as the ones returned from * the last call to (*prepare)(). * * When this call returns the caller assumes that the displays will be * updated in the near future with the content of their work lists, without * artifacts during the transition from the previous frame. * * A display with zero layers indicates that the entire composition has * been handled by SurfaceFlinger with OpenGL ES. In this case, (*set)() * behaves just like eglSwapBuffers(). * * For HWC 1.0, numDisplays will always be one, and displays[0] will be * non-NULL. * * For HWC 1.1, numDisplays will always be HWC_NUM_PHYSICAL_DISPLAY_TYPES. * Entries for unsupported or disabled/disconnected display types will be * NULL. * * In HWC 1.3, numDisplays may be up to HWC_NUM_DISPLAY_TYPES. The extra * entries correspond to enabled virtual displays, and will be non-NULL. * * IMPORTANT NOTE: There is an implicit layer containing opaque black * pixels behind all the layers in the list. It is the responsibility of * the hwcomposer module to make sure black pixels are output (or blended * from). * * IMPORTANT NOTE: In the event of an error this call *MUST* still cause * any fences returned in the previous call to set to eventually become * signaled. The caller may have already issued wait commands on these * fences, and having set return without causing those fences to signal * will likely result in a deadlock. * * returns: 0 on success. A negative error code on error: * HWC_EGL_ERROR: eglGetError() will provide the proper error code (only * allowed prior to HWComposer 1.1) * Another code for non EGL errors. */ int (*set)(struct hwc_composer_device_1 *dev, size_t numDisplays, hwc_display_contents_1_t** displays); /* * eventControl(..., event, enabled) * Enables or disables h/w composer events for a display. * * eventControl can be called from any thread and takes effect * immediately. * * Supported events are: * HWC_EVENT_VSYNC * * returns -EINVAL if the "event" parameter is not one of the value above * or if the "enabled" parameter is not 0 or 1. */ int (*eventControl)(struct hwc_composer_device_1* dev, int disp, int event, int enabled); union { /* * For HWC 1.3 and earlier, the blank() interface is used. * * blank(..., blank) * Blanks or unblanks a display's screen. * * Turns the screen off when blank is nonzero, on when blank is zero. * Multiple sequential calls with the same blank value must be * supported. * The screen state transition must be be complete when the function * returns. * * returns 0 on success, negative on error. */ int (*blank)(struct hwc_composer_device_1* dev, int disp, int blank); /* * For HWC 1.4 and above, setPowerMode() will be used in place of * blank(). * * setPowerMode(..., mode) * Sets the display screen's power state. * * Refer to the documentation of the HWC_POWER_MODE_* constants * for information about each power mode. * * The functionality is similar to the blank() command in previous * versions of HWC, but with support for more power states. * * The display driver is expected to retain and restore the low power * state of the display while entering and exiting from suspend. * * Multiple sequential calls with the same mode value must be supported. * * The screen state transition must be be complete when the function * returns. * * returns 0 on success, negative on error. */ int (*setPowerMode)(struct hwc_composer_device_1* dev, int disp, int mode); }; /* * Used to retrieve information about the h/w composer * * Returns 0 on success or -errno on error. */ int (*query)(struct hwc_composer_device_1* dev, int what, int* value); /* * (*registerProcs)() registers callbacks that the h/w composer HAL can * later use. It will be called immediately after the composer device is * opened with non-NULL procs. It is FORBIDDEN to call any of the callbacks * from within registerProcs(). registerProcs() must save the hwc_procs_t * pointer which is needed when calling a registered callback. */ void (*registerProcs)(struct hwc_composer_device_1* dev, hwc_procs_t const* procs); /* * This field is OPTIONAL and can be NULL. * * If non NULL it will be called by SurfaceFlinger on dumpsys */ void (*dump)(struct hwc_composer_device_1* dev, char *buff, int buff_len); /* * (*getDisplayConfigs)() returns handles for the configurations available * on the connected display. These handles must remain valid as long as the * display is connected. * * Configuration handles are written to configs. The number of entries * allocated by the caller is passed in *numConfigs; getDisplayConfigs must * not try to write more than this number of config handles. On return, the * total number of configurations available for the display is returned in * *numConfigs. If *numConfigs is zero on entry, then configs may be NULL. * * Hardware composers implementing HWC_DEVICE_API_VERSION_1_3 or prior * shall choose one configuration to activate and report it as the first * entry in the returned list. Reporting the inactive configurations is not * required. * * HWC_DEVICE_API_VERSION_1_4 and later provide configuration management * through SurfaceFlinger, and hardware composers implementing these APIs * must also provide getActiveConfig and setActiveConfig. Hardware composers * implementing these API versions may choose not to activate any * configuration, leaving configuration selection to higher levels of the * framework. * * Returns 0 on success or a negative error code on error. If disp is a * hotpluggable display type and no display is connected, an error shall be * returned. * * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_1 and later. * It shall be NULL for previous versions. */ int (*getDisplayConfigs)(struct hwc_composer_device_1* dev, int disp, uint32_t* configs, size_t* numConfigs); /* * (*getDisplayAttributes)() returns attributes for a specific config of a * connected display. The config parameter is one of the config handles * returned by getDisplayConfigs. * * The list of attributes to return is provided in the attributes * parameter, terminated by HWC_DISPLAY_NO_ATTRIBUTE. The value for each * requested attribute is written in order to the values array. The * HWC_DISPLAY_NO_ATTRIBUTE attribute does not have a value, so the values * array will have one less value than the attributes array. * * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_1 and later. * It shall be NULL for previous versions. * * If disp is a hotpluggable display type and no display is connected, * or if config is not a valid configuration for the display, a negative * error code shall be returned. */ int (*getDisplayAttributes)(struct hwc_composer_device_1* dev, int disp, uint32_t config, const uint32_t* attributes, int32_t* values); /* * (*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. * * Returns the configuration index on success or -1 on error. * * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_4 and later. * It shall be NULL for previous versions. */ int (*getActiveConfig)(struct hwc_composer_device_1* dev, int disp); /* * (*setActiveConfig)() instructs the hardware composer to switch to the * display configuration at the given index in the list of configuration * handles returned by getDisplayConfigs. * * If this function returns without error, any subsequent calls to * getActiveConfig shall return the index set by this function until one * of the following occurs: * 1) Another successful call of this function * 2) The display is disconnected * * Returns 0 on success or a negative error code on error. If disp is a * hotpluggable display type and no display is connected, or if index is * outside of the range of hardware configurations returned by * getDisplayConfigs, an error shall be returned. * * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_4 and later. * It shall be NULL for previous versions. */ int (*setActiveConfig)(struct hwc_composer_device_1* dev, int disp, int index); /* * Asynchronously update the location of the cursor layer. * * Within the standard prepare()/set() composition loop, the client * (surfaceflinger) can request that a given layer uses dedicated cursor * composition hardware by specifiying the HWC_IS_CURSOR_LAYER flag. Only * one layer per display can have this flag set. If the layer is suitable * for the platform's cursor hardware, hwcomposer will return from prepare() * a composition type of HWC_CURSOR_OVERLAY for that layer. This indicates * not only that the client is not responsible for compositing that layer, * but also that the client can continue to update the position of that layer * after a call to set(). This can reduce the visible latency of mouse * movement to visible, on-screen cursor updates. Calls to * setCursorPositionAsync() may be made from a different thread doing the * prepare()/set() composition loop, but care must be taken to not interleave * calls of setCursorPositionAsync() between calls of set()/prepare(). * * Notes: * - Only one layer per display can be specified as a cursor layer with * HWC_IS_CURSOR_LAYER. * - hwcomposer will only return one layer per display as HWC_CURSOR_OVERLAY * - This returns 0 on success or -errno on error. * - This field is optional for HWC_DEVICE_API_VERSION_1_4 and later. It * should be null for previous versions. */ int (*setCursorPositionAsync)(struct hwc_composer_device_1 *dev, int disp, int x_pos, int y_pos); /* * Reserved for future use. Must be NULL. */ void* reserved_proc[1]; } hwc_composer_device_1_t; /** convenience API for opening and closing a device */ 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); } static inline int hwc_close_1(hwc_composer_device_1_t* device) { return device->common.close(&device->common); } /*****************************************************************************/ __END_DECLS #endif /* ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H */ android-headers-23/21/hardware/hwcomposer_defs.h000066400000000000000000000204741264465411000217220ustar00rootroot00000000000000/* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_DEFS_H #define ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_DEFS_H #include #include #include #include #include __BEGIN_DECLS /*****************************************************************************/ #define HWC_HEADER_VERSION 1 #define HWC_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define HWC_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION_2(1, 0, HWC_HEADER_VERSION) #define HWC_DEVICE_API_VERSION_1_1 HARDWARE_DEVICE_API_VERSION_2(1, 1, HWC_HEADER_VERSION) #define HWC_DEVICE_API_VERSION_1_2 HARDWARE_DEVICE_API_VERSION_2(1, 2, HWC_HEADER_VERSION) #define HWC_DEVICE_API_VERSION_1_3 HARDWARE_DEVICE_API_VERSION_2(1, 3, HWC_HEADER_VERSION) #define HWC_DEVICE_API_VERSION_1_4 HARDWARE_DEVICE_API_VERSION_2(1, 4, HWC_HEADER_VERSION) enum { /* hwc_composer_device_t::set failed in EGL */ HWC_EGL_ERROR = -1 }; /* * hwc_layer_t::hints values * Hints are set by the HAL and read by SurfaceFlinger */ enum { /* * HWC can set the HWC_HINT_TRIPLE_BUFFER hint to indicate to SurfaceFlinger * that it should triple buffer this layer. Typically HWC does this when * the layer will be unavailable for use for an extended period of time, * e.g. if the display will be fetching data directly from the layer and * the layer can not be modified until after the next set(). */ HWC_HINT_TRIPLE_BUFFER = 0x00000001, /* * HWC sets HWC_HINT_CLEAR_FB to tell SurfaceFlinger that it should clear the * framebuffer with transparent pixels where this layer would be. * SurfaceFlinger will only honor this flag when the layer has no blending * */ HWC_HINT_CLEAR_FB = 0x00000002 }; /* * hwc_layer_t::flags values * Flags are set by SurfaceFlinger and read by the HAL */ enum { /* * HWC_SKIP_LAYER is set by SurfaceFlnger 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). */ HWC_SKIP_LAYER = 0x00000001, /* * HWC_IS_CURSOR_LAYER is set by surfaceflinger to indicate that this * layer is being used as a cursor on this particular display, and that * surfaceflinger can potentially perform asynchronous position updates for * this layer. If a call to prepare() returns HWC_CURSOR_OVERLAY for the * composition type of this layer, then the hwcomposer will allow async * position updates to this layer via setCursorPositionAsync(). */ HWC_IS_CURSOR_LAYER = 0x00000002 }; /* * hwc_layer_t::compositionType values */ enum { /* this layer is to be drawn into the framebuffer by SurfaceFlinger */ HWC_FRAMEBUFFER = 0, /* this layer will be handled in the HWC */ HWC_OVERLAY = 1, /* this is the background layer. it's used to set the background color. * there is only a single background layer */ HWC_BACKGROUND = 2, /* this layer holds the result of compositing the HWC_FRAMEBUFFER layers. * Added in HWC_DEVICE_API_VERSION_1_1. */ HWC_FRAMEBUFFER_TARGET = 3, /* this layer's contents are taken from a sideband buffer stream. * Added in HWC_DEVICE_API_VERSION_1_4. */ HWC_SIDEBAND = 4, /* this layer's composition will be handled by hwcomposer by dedicated cursor overlay hardware. hwcomposer will also all async position updates of this layer outside of the normal prepare()/set() loop. Added in HWC_DEVICE_API_VERSION_1_4. */ HWC_CURSOR_OVERLAY = 5 }; /* * hwc_layer_t::blending values */ enum { /* no blending */ HWC_BLENDING_NONE = 0x0100, /* ONE / ONE_MINUS_SRC_ALPHA */ HWC_BLENDING_PREMULT = 0x0105, /* SRC_ALPHA / ONE_MINUS_SRC_ALPHA */ HWC_BLENDING_COVERAGE = 0x0405 }; /* * hwc_layer_t::transform values */ enum { /* flip source image horizontally */ HWC_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H, /* flip source image vertically */ HWC_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V, /* rotate source image 90 degrees clock-wise */ HWC_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90, /* rotate source image 180 degrees */ HWC_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180, /* rotate source image 270 degrees clock-wise */ HWC_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270, }; /* attributes queriable with query() */ enum { /* * Must return 1 if the background layer is supported, 0 otherwise. */ HWC_BACKGROUND_LAYER_SUPPORTED = 0, /* * Returns the vsync period in nanoseconds. * * This query is not used for HWC_DEVICE_API_VERSION_1_1 and later. * Instead, the per-display attribute HWC_DISPLAY_VSYNC_PERIOD is used. */ HWC_VSYNC_PERIOD = 1, /* * Availability: HWC_DEVICE_API_VERSION_1_1 * Returns a mask of supported display types. */ HWC_DISPLAY_TYPES_SUPPORTED = 2, }; /* display attributes returned by getDisplayAttributes() */ enum { /* Indicates the end of an attribute list */ HWC_DISPLAY_NO_ATTRIBUTE = 0, /* The vsync period in nanoseconds */ HWC_DISPLAY_VSYNC_PERIOD = 1, /* The number of pixels in the horizontal and vertical directions. */ HWC_DISPLAY_WIDTH = 2, HWC_DISPLAY_HEIGHT = 3, /* The number of pixels per thousand inches of this configuration. * * Scaling DPI by 1000 allows it to be stored in an int without losing * too much precision. * * If the DPI for a configuration is unavailable or the HWC implementation * considers it unreliable, it should set these attributes to zero. */ HWC_DISPLAY_DPI_X = 4, HWC_DISPLAY_DPI_Y = 5, }; /* Allowed events for hwc_methods::eventControl() */ enum { HWC_EVENT_VSYNC = 0 }; /* Display types and associated mask bits. */ enum { HWC_DISPLAY_PRIMARY = 0, HWC_DISPLAY_EXTERNAL = 1, // HDMI, DP, etc. HWC_DISPLAY_VIRTUAL = 2, HWC_NUM_PHYSICAL_DISPLAY_TYPES = 2, HWC_NUM_DISPLAY_TYPES = 3, }; enum { HWC_DISPLAY_PRIMARY_BIT = 1 << HWC_DISPLAY_PRIMARY, HWC_DISPLAY_EXTERNAL_BIT = 1 << HWC_DISPLAY_EXTERNAL, HWC_DISPLAY_VIRTUAL_BIT = 1 << HWC_DISPLAY_VIRTUAL, }; /* Display power modes */ enum { /* The display is turned off (blanked). */ HWC_POWER_MODE_OFF = 0, /* The display is turned on and configured in a low power state * that is suitable for presenting ambient information to the user, * possibly with lower fidelity than normal but greater efficiency. */ HWC_POWER_MODE_DOZE = 1, /* The display is turned on normally. */ HWC_POWER_MODE_NORMAL = 2, /* The display is configured as in HWC_POWER_MODE_DOZE but may * stop applying frame buffer updates from the graphics subsystem. * This power mode is effectively a hint from the doze dream to * tell the hardware that it is done drawing to the display for the * time being and that the display should remain on in a low power * state and continue showing its current contents indefinitely * until the mode changes. * * This mode may also be used as a signal to enable hardware-based doze * functionality. In this case, the doze dream is effectively * indicating that the hardware is free to take over the display * and manage it autonomously to implement low power always-on display * functionality. */ HWC_POWER_MODE_DOZE_SUSPEND = 3, }; /*****************************************************************************/ __END_DECLS #endif /* ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_DEFS_H */ android-headers-23/21/hardware/keymaster.h000066400000000000000000000211751264465411000205360ustar00rootroot00000000000000/* * 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 android-headers-23/21/hardware/lights.h000066400000000000000000000074721264465411000200300ustar00rootroot00000000000000/* * 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_LIGHTS_INTERFACE_H #define ANDROID_LIGHTS_INTERFACE_H #include #include #include #include __BEGIN_DECLS /** * The id of this module */ #define LIGHTS_HARDWARE_MODULE_ID "lights" /* * These light IDs correspond to logical lights, not physical. * So for example, if your INDICATOR light is in line with your * BUTTONS, it might make sense to also light the INDICATOR * light to a reasonable color when the BUTTONS are lit. */ #define LIGHT_ID_BACKLIGHT "backlight" #define LIGHT_ID_KEYBOARD "keyboard" #define LIGHT_ID_BUTTONS "buttons" #define LIGHT_ID_BATTERY "battery" #define LIGHT_ID_NOTIFICATIONS "notifications" #define LIGHT_ID_ATTENTION "attention" /* * These lights aren't currently supported by the higher * layers, but could be someday, so we have the constants * here now. */ #define LIGHT_ID_BLUETOOTH "bluetooth" #define LIGHT_ID_WIFI "wifi" /* ************************************************************************ * Flash modes for the flashMode field of light_state_t. */ #define LIGHT_FLASH_NONE 0 /** * To flash the light at a given rate, set flashMode to LIGHT_FLASH_TIMED, * and then flashOnMS should be set to the number of milliseconds to turn * the light on, followed by the number of milliseconds to turn the light * off. */ #define LIGHT_FLASH_TIMED 1 /** * To flash the light using hardware assist, set flashMode to * the hardware mode. */ #define LIGHT_FLASH_HARDWARE 2 /** * Light brightness is managed by a user setting. */ #define BRIGHTNESS_MODE_USER 0 /** * Light brightness is managed by a light sensor. */ #define BRIGHTNESS_MODE_SENSOR 1 /** * The parameters that can be set for a given light. * * Not all lights must support all parameters. If you * can do something backward-compatible, you should. */ struct light_state_t { /** * The color of the LED in ARGB. * * Do your best here. * - If your light can only do red or green, if they ask for blue, * you should do green. * - If you can only do a brightness ramp, then use this formula: * unsigned char brightness = ((77*((color>>16)&0x00ff)) * + (150*((color>>8)&0x00ff)) + (29*(color&0x00ff))) >> 8; * - If you can only do on or off, 0 is off, anything else is on. * * The high byte should be ignored. Callers will set it to 0xff (which * would correspond to 255 alpha). */ unsigned int color; /** * See the LIGHT_FLASH_* constants */ int flashMode; int flashOnMS; int flashOffMS; /** * Policy used by the framework to manage the light's brightness. * Currently the values are BRIGHTNESS_MODE_USER and BRIGHTNESS_MODE_SENSOR. */ int brightnessMode; }; struct light_device_t { struct hw_device_t common; /** * Set the provided lights to the provided values. * * Returns: 0 on succes, error code on failure. */ int (*set_light)(struct light_device_t* dev, struct light_state_t const* state); }; __END_DECLS #endif // ANDROID_LIGHTS_INTERFACE_H android-headers-23/21/hardware/local_time_hal.h000066400000000000000000000074111264465411000214630ustar00rootroot00000000000000/* * 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_LOCAL_TIME_HAL_INTERFACE_H #define ANDROID_LOCAL_TIME_HAL_INTERFACE_H #include #include __BEGIN_DECLS /** * The id of this module */ #define LOCAL_TIME_HARDWARE_MODULE_ID "local_time" /** * Name of the local time devices to open */ #define LOCAL_TIME_HARDWARE_INTERFACE "local_time_hw_if" /**********************************************************************/ /** * A structure used to collect low level sync data in a lab environment. Most * HAL implementations will never need this structure. */ struct local_time_debug_event { int64_t local_timesync_event_id; int64_t local_time; }; /** * 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. */ struct local_time_module { struct hw_module_t common; }; struct local_time_hw_device { /** * Common methods of the local time hardware device. This *must* be the first member of * local_time_hw_device as users of this structure will cast a hw_device_t to * local_time_hw_device pointer in contexts where it's known the hw_device_t references a * local_time_hw_device. */ struct hw_device_t common; /** * * Returns the current value of the system wide local time counter */ int64_t (*get_local_time)(struct local_time_hw_device* dev); /** * * Returns the nominal frequency (in hertz) of the system wide local time * counter */ uint64_t (*get_local_freq)(struct local_time_hw_device* dev); /** * * Sets the HW slew rate of oscillator which drives the system wide local * time counter. On success, platforms should return 0. Platforms which * do not support HW slew should leave this method set to NULL. * * Valid values for rate range from MIN_INT16 to MAX_INT16. Platform * implementations should attempt map this range linearly to the min/max * slew rate of their hardware. */ int (*set_local_slew)(struct local_time_hw_device* dev, int16_t rate); /** * * A method used to collect low level sync data in a lab environments. * Most HAL implementations will simply set this member to NULL, or return * -EINVAL to indicate that this functionality is not supported. * Production HALs should never support this method. */ int (*get_debug_log)(struct local_time_hw_device* dev, struct local_time_debug_event* records, int max_records); }; typedef struct local_time_hw_device local_time_hw_device_t; /** convenience API for opening and closing a supported device */ static inline int local_time_hw_device_open( const struct hw_module_t* module, struct local_time_hw_device** device) { return module->methods->open(module, LOCAL_TIME_HARDWARE_INTERFACE, (struct hw_device_t**)device); } static inline int local_time_hw_device_close(struct local_time_hw_device* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_LOCAL_TIME_INTERFACE_H android-headers-23/21/hardware/memtrack.h000066400000000000000000000140221264465411000203260ustar00rootroot00000000000000/* * 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_HARDWARE_MEMTRACK_H #define ANDROID_INCLUDE_HARDWARE_MEMTRACK_H #include #include #include #include __BEGIN_DECLS #define MEMTRACK_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) /** * The id of this module */ #define MEMTRACK_HARDWARE_MODULE_ID "memtrack" /* * The Memory Tracker HAL is designed to return information about device-specific * memory usage. The primary goal is to be able to track memory that is not * trackable in any other way, for example texture memory that is allocated by * a process, but not mapped in to that process' address space. * A secondary goal is to be able to categorize memory used by a process into * GL, graphics, etc. All memory sizes should be in real memory usage, * accounting for stride, bit depth, rounding up to page size, etc. * * A process collecting memory statistics will call getMemory for each * combination of pid and memory type. For each memory type that it recognizes * the HAL should fill out an array of memtrack_record structures breaking * down the statistics of that memory type as much as possible. For example, * getMemory(, MEMTRACK_TYPE_GL) might return: * { { 4096, ACCOUNTED | PRIVATE | SYSTEM }, * { 40960, UNACCOUNTED | PRIVATE | SYSTEM }, * { 8192, ACCOUNTED | PRIVATE | DEDICATED }, * { 8192, UNACCOUNTED | PRIVATE | DEDICATED } } * If the HAL could not differentiate between SYSTEM and DEDICATED memory, it * could return: * { { 12288, ACCOUNTED | PRIVATE }, * { 49152, UNACCOUNTED | PRIVATE } } * * Memory should not overlap between types. For example, a graphics buffer * that has been mapped into the GPU as a surface should show up when * MEMTRACK_TYPE_GRAPHICS is requested, and not when MEMTRACK_TYPE_GL * is requested. */ enum memtrack_type { MEMTRACK_TYPE_OTHER = 0, MEMTRACK_TYPE_GL = 1, MEMTRACK_TYPE_GRAPHICS = 2, MEMTRACK_TYPE_MULTIMEDIA = 3, MEMTRACK_TYPE_CAMERA = 4, MEMTRACK_NUM_TYPES, }; struct memtrack_record { size_t size_in_bytes; unsigned int flags; }; /** * Flags to differentiate memory that can already be accounted for in * /proc//smaps, * (Shared_Clean + Shared_Dirty + Private_Clean + Private_Dirty = Size). * In general, memory mapped in to a userspace process is accounted unless * it was mapped with remap_pfn_range. * Exactly one of these should be set. */ #define MEMTRACK_FLAG_SMAPS_ACCOUNTED (1 << 1) #define MEMTRACK_FLAG_SMAPS_UNACCOUNTED (1 << 2) /** * Flags to differentiate memory shared across multiple processes vs. memory * used by a single process. Only zero or one of these may be set in a record. * If none are set, record is assumed to count shared + private memory. */ #define MEMTRACK_FLAG_SHARED (1 << 3) #define MEMTRACK_FLAG_SHARED_PSS (1 << 4) /* shared / num_procesess */ #define MEMTRACK_FLAG_PRIVATE (1 << 5) /** * Flags to differentiate memory taken from the kernel's allocation pool vs. * memory that is dedicated to non-kernel allocations, for example a carveout * or separate video memory. Only zero or one of these may be set in a record. * If none are set, record is assumed to count system + dedicated memory. */ #define MEMTRACK_FLAG_SYSTEM (1 << 6) #define MEMTRACK_FLAG_DEDICATED (1 << 7) /** * Flags to differentiate memory accessible by the CPU in non-secure mode vs. * memory that is protected. Only zero or one of these may be set in a record. * If none are set, record is assumed to count secure + nonsecure memory. */ #define MEMTRACK_FLAG_NONSECURE (1 << 8) #define MEMTRACK_FLAG_SECURE (1 << 9) /** * 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 memtrack_module { struct hw_module_t common; /** * (*init)() performs memtrack management setup actions and is called * once before any calls to getMemory(). * Returns 0 on success, -errno on error. */ int (*init)(const struct memtrack_module *module); /** * (*getMemory)() expects an array of record objects and populates up to * *num_record structures with the sizes of memory plus associated flags for * that memory. It also updates *num_records with the total number of * records it could return if *num_records was large enough when passed in. * Returning records with size 0 is expected, the number of records should * not vary between calls to getMemory for the same memory type, even * for different pids. * * The caller will often call getMemory for a type and pid with * *num_records == 0 to determine how many records to allocate room for, * this case should be a fast-path in the HAL, returning a constant and * not querying any kernel files. If *num_records passed in is 0, * then records may be NULL. * * This function must be thread-safe, it may get called from multiple * threads at the same time. * * Returns 0 on success, -ENODEV if the type is not supported, -errno * on other errors. */ int (*getMemory)(const struct memtrack_module *module, pid_t pid, int type, struct memtrack_record *records, size_t *num_records); } memtrack_module_t; __END_DECLS #endif // ANDROID_INCLUDE_HARDWARE_MEMTRACK_H android-headers-23/21/hardware/nfc.h000066400000000000000000000234201264465411000172730ustar00rootroot00000000000000/* * Copyright (C) 2011, 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_NFC_HAL_INTERFACE_H #define ANDROID_NFC_HAL_INTERFACE_H #include #include #include #include #include __BEGIN_DECLS /* NFC device HAL for NCI-based NFC controllers. * * This HAL allows NCI silicon vendors to make use * of the core NCI stack in Android for their own silicon. * * The responibilities of the NCI HAL implementation * are as follows: * * - Implement the transport to the NFC controller * - Implement each of the HAL methods specified below as applicable to their silicon * - Pass up received NCI messages from the controller to the stack * * A simplified timeline of NCI HAL method calls: * 1) Core NCI stack calls open() * 2) Core NCI stack executes CORE_RESET and CORE_INIT through calls to write() * 3) Core NCI stack calls core_initialized() to allow HAL to do post-init configuration * 4) Core NCI stack calls pre_discover() to allow HAL to prepare for RF discovery * 5) Core NCI stack starts discovery through calls to write() * 6) Core NCI stack stops discovery through calls to write() (e.g. screen turns off) * 7) Core NCI stack calls pre_discover() to prepare for RF discovery (e.g. screen turned back on) * 8) Core NCI stack starts discovery through calls to write() * ... * ... * 9) Core NCI stack calls close() */ #define NFC_NCI_HARDWARE_MODULE_ID "nfc_nci" #define NFC_NCI_BCM2079X_HARDWARE_MODULE_ID "nfc_nci.bcm2079x" #define NFC_NCI_CONTROLLER "nci" /* * nfc_nci_module_t should contain module-specific parameters */ typedef struct nfc_nci_module_t { /** * Common methods of the NFC NCI module. This *must* be the first member of * nfc_nci_module_t as users of this structure will cast a hw_module_t to * nfc_nci_module_t pointer in contexts where it's known the hw_module_t references a * 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. */ typedef void (nfc_stack_callback_t) (nfc_event_t event, nfc_status_t event_status); /* * The callback passed in from the NFC stack that the HAL * can use to pass incomming data to the stack. */ typedef void (nfc_stack_data_callback_t) (uint16_t data_len, uint8_t* p_data); /* nfc_nci_device_t starts with a hw_device_t struct, * followed by device-specific methods and members. * * All methods in the NCI HAL are asynchronous. */ typedef struct nfc_nci_device { /** * Common methods of the NFC NCI device. This *must* be the first member of * nfc_nci_device_t as users of this structure will cast a hw_device_t to * nfc_nci_device_t pointer in contexts where it's known the hw_device_t references a * nfc_nci_device_t. */ struct hw_device_t common; /* * (*open)() Opens the NFC controller device and performs initialization. * This may include patch download and other vendor-specific initialization. * * If open completes successfully, the controller should be ready to perform * NCI initialization - ie accept CORE_RESET and subsequent commands through * the write() call. * * If open() returns 0, the NCI stack will wait for a HAL_NFC_OPEN_CPLT_EVT * before continuing. * * If open() returns any other value, the NCI stack will stop. * */ int (*open)(const struct nfc_nci_device *p_dev, nfc_stack_callback_t *p_cback, nfc_stack_data_callback_t *p_data_cback); /* * (*write)() Performs an NCI write. * * This method may queue writes and return immediately. The only * requirement is that the writes are executed in order. */ int (*write)(const struct nfc_nci_device *p_dev, uint16_t data_len, const uint8_t *p_data); /* * (*core_initialized)() is called after the CORE_INIT_RSP is received from the NFCC. * At this time, the HAL can do any chip-specific configuration. * * If core_initialized() returns 0, the NCI stack will wait for a HAL_NFC_POST_INIT_CPLT_EVT * before continuing. * * If core_initialized() returns any other value, the NCI stack will continue * immediately. */ int (*core_initialized)(const struct nfc_nci_device *p_dev, uint8_t* p_core_init_rsp_params); /* * (*pre_discover)() Is called every time before starting RF discovery. * It is a good place to do vendor-specific configuration that must be * performed every time RF discovery is about to be started. * * If pre_discover() returns 0, the NCI stack will wait for a HAL_NFC_PRE_DISCOVER_CPLT_EVT * before continuing. * * If pre_discover() returns any other value, the NCI stack will start * RF discovery immediately. */ int (*pre_discover)(const struct nfc_nci_device *p_dev); /* * (*close)() Closed the NFC controller. Should free all resources. */ int (*close)(const struct nfc_nci_device *p_dev); /* * (*control_granted)() Grant HAL the exclusive control to send NCI commands. * Called in response to HAL_REQUEST_CONTROL_EVT. * Must only be called when there are no NCI commands pending. * HAL_RELEASE_CONTROL_EVT will notify when HAL no longer needs exclusive control. */ int (*control_granted)(const struct nfc_nci_device *p_dev); /* * (*power_cycle)() Restart controller by power cyle; * HAL_OPEN_CPLT_EVT will notify when operation is complete. */ int (*power_cycle)(const struct nfc_nci_device *p_dev); } nfc_nci_device_t; /* * Convenience methods that the NFC stack can use to open * and close an NCI device */ static inline int nfc_nci_open(const struct hw_module_t* module, nfc_nci_device_t** dev) { return module->methods->open(module, NFC_NCI_CONTROLLER, (struct hw_device_t**) dev); } static inline int nfc_nci_close(nfc_nci_device_t* dev) { return dev->common.close(&dev->common); } /* * End NFC NCI HAL */ /* * This is a limited NFC HAL for NXP PN544-based devices. * This HAL as Android is moving to * an NCI-based NFC stack. * * All NCI-based NFC controllers should use the NFC-NCI * HAL instead. * Begin PN544 specific HAL */ #define NFC_HARDWARE_MODULE_ID "nfc" #define NFC_PN544_CONTROLLER "pn544" typedef struct nfc_module_t { /** * Common methods of the NFC NXP PN544 module. This *must* be the first member of * nfc_module_t as users of this structure will cast a hw_module_t to * nfc_module_t pointer in contexts where it's known the hw_module_t references a * nfc_module_t. */ struct hw_module_t common; } nfc_module_t; /* * PN544 linktypes. * UART * I2C * USB (uses UART DAL) */ typedef enum { PN544_LINK_TYPE_UART, PN544_LINK_TYPE_I2C, PN544_LINK_TYPE_USB, PN544_LINK_TYPE_INVALID, } nfc_pn544_linktype; typedef struct { /** * Common methods of the NFC NXP PN544 device. This *must* be the first member of * nfc_pn544_device_t as users of this structure will cast a hw_device_t to * nfc_pn544_device_t pointer in contexts where it's known the hw_device_t references a * nfc_pn544_device_t. */ struct hw_device_t common; /* The number of EEPROM registers to write */ uint32_t num_eeprom_settings; /* The actual EEPROM settings * For PN544, each EEPROM setting is a 4-byte entry, * of the format [0x00, addr_msb, addr_lsb, value]. */ uint8_t* eeprom_settings; /* The link type to which the PN544 is connected */ nfc_pn544_linktype linktype; /* The device node to which the PN544 is connected */ const char* device_node; /* On Crespo we had an I2C issue that would cause us to sometimes read * the I2C slave address (0x57) over the bus. libnfc contains * a hack to ignore this byte and try to read the length byte * again. * Set to 0 to disable the workaround, 1 to enable it. */ uint8_t enable_i2c_workaround; /* I2C slave address. Multiple I2C addresses are * possible for PN544 module. Configure address according to * board design. */ uint8_t i2c_device_address; } nfc_pn544_device_t; static inline int nfc_pn544_open(const struct hw_module_t* module, nfc_pn544_device_t** dev) { return module->methods->open(module, NFC_PN544_CONTROLLER, (struct hw_device_t**) dev); } static inline int nfc_pn544_close(nfc_pn544_device_t* dev) { return dev->common.close(&dev->common); } /* * End PN544 specific HAL */ __END_DECLS #endif // ANDROID_NFC_HAL_INTERFACE_H android-headers-23/21/hardware/nfc_tag.h000066400000000000000000000055471264465411000201400ustar00rootroot00000000000000/* * 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_NFC_TAG_HAL_INTERFACE_H #define ANDROID_NFC_TAG_HAL_INTERFACE_H #include #include __BEGIN_DECLS /* * HAL for programmable NFC tags. * */ #define NFC_TAG_HARDWARE_MODULE_ID "nfc_tag" #define NFC_TAG_ID "tag" typedef struct nfc_tag_module_t { /** * Common methods of the NFC tag module. This *must* be the first member of * nfc_tag_module_t as users of this structure will cast a hw_module_t to * nfc_tag_module_t pointer in contexts where it's known the hw_module_t references a * nfc_tag_module_t. */ struct hw_module_t common; } nfc_tag_module_t; typedef struct nfc_tag_device { /** * Common methods of the NFC tag device. This *must* be the first member of * nfc_tag_device_t as users of this structure will cast a hw_device_t to * nfc_tag_device_t pointer in contexts where it's known the hw_device_t references a * nfc_tag_device_t. */ struct hw_device_t common; /** * Initialize the NFC tag. * * The driver must: * * Set the static lock bytes to read only * * Configure the Capability Container to disable write acess * eg: 0xE1 0x10 0x0F * * This function is called once before any calls to setContent(). * * Return 0 on success or -errno on error. */ int (*init)(const struct nfc_tag_device *dev); /** * Set the NFC tag content. * * The driver must write in the data area of the tag starting at * byte 0 of block 4 and zero the rest of the data area. * * Returns 0 on success or -errno on error. */ int (*setContent)(const struct nfc_tag_device *dev, const uint8_t *data, size_t len); /** * Returns the memory size of the data area. */ int (*getMemorySize)(const struct nfc_tag_device *dev); } nfc_tag_device_t; static inline int nfc_tag_open(const struct hw_module_t* module, nfc_tag_device_t** dev) { return module->methods->open(module, NFC_TAG_ID, (struct hw_device_t**)dev); } static inline int nfc_tag_close(nfc_tag_device_t* dev) { return dev->common.close(&dev->common); } __END_DECLS #endif // ANDROID_NFC_TAG_HAL_INTERFACE_H android-headers-23/21/hardware/power.h000066400000000000000000000115501264465411000176620ustar00rootroot00000000000000/* * 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_HARDWARE_POWER_H #define ANDROID_INCLUDE_HARDWARE_POWER_H #include #include #include #include __BEGIN_DECLS #define POWER_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define POWER_MODULE_API_VERSION_0_2 HARDWARE_MODULE_API_VERSION(0, 2) /** * The id of this module */ #define POWER_HARDWARE_MODULE_ID "power" /* * Power hint identifiers passed to (*powerHint) */ typedef enum { POWER_HINT_VSYNC = 0x00000001, POWER_HINT_INTERACTION = 0x00000002, /* DO NOT USE POWER_HINT_VIDEO_ENCODE/_DECODE! They will be removed in * KLP. */ POWER_HINT_VIDEO_ENCODE = 0x00000003, POWER_HINT_VIDEO_DECODE = 0x00000004, POWER_HINT_LOW_POWER = 0x00000005 } power_hint_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 power_module { struct hw_module_t common; /* * (*init)() performs power management setup actions at runtime * startup, such as to set default cpufreq parameters. This is * called only by the Power HAL instance loaded by * PowerManagerService. */ void (*init)(struct power_module *module); /* * (*setInteractive)() performs power management actions upon the * system entering interactive state (that is, the system is awake * and ready for interaction, often with UI devices such as * display and touchscreen enabled) or non-interactive state (the * system appears asleep, display usually turned off). The * non-interactive state is usually entered after a period of * inactivity, in order to conserve battery power during * such inactive periods. * * Typical actions are to turn on or off devices and adjust * cpufreq parameters. This function may also call the * appropriate interfaces to allow the kernel to suspend the * system to low-power sleep state when entering non-interactive * state, and to disallow low-power suspend when the system is in * interactive state. When low-power suspend state is allowed, the * kernel may suspend the system whenever no wakelocks are held. * * on is non-zero when the system is transitioning to an * interactive / awake state, and zero when transitioning to a * non-interactive / asleep state. * * This function is called to enter non-interactive state after * turning off the screen (if present), and called to enter * interactive state prior to turning on the screen. */ void (*setInteractive)(struct power_module *module, int on); /* * (*powerHint) is called to pass hints on power requirements, which * may result in adjustment of power/performance parameters of the * cpufreq governor and other controls. The possible hints are: * * POWER_HINT_VSYNC * * Foreground app has started or stopped requesting a VSYNC pulse * from SurfaceFlinger. If the app has started requesting VSYNC * then CPU and GPU load is expected soon, and it may be appropriate * to raise speeds of CPU, memory bus, etc. The data parameter is * non-zero to indicate VSYNC pulse is now requested, or zero for * VSYNC pulse no longer requested. * * POWER_HINT_INTERACTION * * User is interacting with the device, for example, touchscreen * events are incoming. CPU and GPU load may be expected soon, * and it may be appropriate to raise speeds of CPU, memory bus, * etc. The data parameter is unused. * * POWER_HINT_LOW_POWER * * Low power mode is activated or deactivated. Low power mode * is intended to save battery at the cost of performance. The data * parameter is non-zero when low power mode is activated, and zero * when deactivated. * * A particular platform may choose to ignore any hint. * * availability: version 0.2 * */ void (*powerHint)(struct power_module *module, power_hint_t hint, void *data); } power_module_t; __END_DECLS #endif // ANDROID_INCLUDE_HARDWARE_POWER_H android-headers-23/21/hardware/qemu_pipe.h000066400000000000000000000054011264465411000205100ustar00rootroot00000000000000/* * 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 #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 */ android-headers-23/21/hardware/qemud.h000066400000000000000000000102441264465411000176400ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/hardware/sensors.h000066400000000000000000001110041264465411000202150ustar00rootroot00000000000000/* * 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_SENSORS_INTERFACE_H #define ANDROID_SENSORS_INTERFACE_H #include #include #include #include #include __BEGIN_DECLS /*****************************************************************************/ #define SENSORS_HEADER_VERSION 1 #define SENSORS_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define SENSORS_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION_2(0, 1, SENSORS_HEADER_VERSION) #define SENSORS_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION_2(1, 0, SENSORS_HEADER_VERSION) #define SENSORS_DEVICE_API_VERSION_1_1 HARDWARE_DEVICE_API_VERSION_2(1, 1, SENSORS_HEADER_VERSION) #define SENSORS_DEVICE_API_VERSION_1_2 HARDWARE_DEVICE_API_VERSION_2(1, 2, SENSORS_HEADER_VERSION) #define SENSORS_DEVICE_API_VERSION_1_3 HARDWARE_DEVICE_API_VERSION_2(1, 3, SENSORS_HEADER_VERSION) /** * Please see the Sensors section of source.android.com for an * introduction to and detailed descriptions of Android sensor types: * http://source.android.com/devices/sensors/index.html */ /** * The id of this module */ #define SENSORS_HARDWARE_MODULE_ID "sensors" /** * Name of the sensors device to open */ #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. */ #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" /** * Values returned by the accelerometer in various locations in the universe. * all values are in SI units (m/s^2) */ #define GRAVITY_SUN (275.0f) #define GRAVITY_EARTH (9.80665f) /** Maximum magnetic field on Earth's surface */ #define MAGNETIC_FIELD_EARTH_MAX (60.0f) /** 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 /** * sensor event data */ typedef struct { union { float v[3]; struct { float x; float y; float z; }; struct { float azimuth; float pitch; float roll; }; }; int8_t status; uint8_t reserved[3]; } sensors_vec_t; /** * uncalibrated gyroscope and magnetometer event data */ typedef struct { union { float uncalib[3]; struct { float x_uncalib; float y_uncalib; float z_uncalib; }; }; union { float bias[3]; struct { float x_bias; float y_bias; float z_bias; }; }; } uncalibrated_event_t; /** * Meta data event data */ typedef struct meta_data_event { int32_t what; int32_t sensor; } meta_data_event_t; /** * Heart rate event data */ typedef struct { // Heart rate in beats per minute. // Set to 0 when status is SENSOR_STATUS_UNRELIABLE or ..._NO_CONTACT float bpm; // Status of the sensor for this reading. Set to one SENSOR_STATUS_... // Note that this value should only be set for sensors that explicitly define // the meaning of this field. This field is not piped through the framework // for other sensors. int8_t status; } heart_rate_event_t; /** * Union of the various types of sensor data * that can be returned. */ typedef struct sensors_event_t { /* must be sizeof(struct sensors_event_t) */ int32_t version; /* sensor identifier */ int32_t sensor; /* sensor type */ int32_t type; /* reserved */ int32_t reserved0; /* time is in nanosecond */ int64_t timestamp; union { union { float data[16]; /* acceleration values are in meter per second per second (m/s^2) */ sensors_vec_t acceleration; /* magnetic vector values are in micro-Tesla (uT) */ sensors_vec_t magnetic; /* orientation values are in degrees */ sensors_vec_t orientation; /* gyroscope values are in rad/s */ sensors_vec_t gyro; /* temperature is in degrees centigrade (Celsius) */ float temperature; /* distance in centimeters */ float distance; /* light in SI lux units */ float light; /* pressure in hectopascal (hPa) */ float pressure; /* relative humidity in percent */ float relative_humidity; /* uncalibrated gyroscope values are in rad/s */ uncalibrated_event_t uncalibrated_gyro; /* uncalibrated magnetometer values are in micro-Teslas */ uncalibrated_event_t uncalibrated_magnetic; /* heart rate data containing value in bpm and status */ heart_rate_event_t heart_rate; /* this is a special event. see SENSOR_TYPE_META_DATA above. * sensors_meta_data_event_t events are all reported with a type of * SENSOR_TYPE_META_DATA. The handle is ignored and must be zero. */ meta_data_event_t meta_data; }; union { uint64_t data[8]; /* step-counter */ uint64_t step_counter; } u64; }; /* Reserved flags for internal use. Set to zero. */ uint32_t flags; uint32_t reserved1[3]; } sensors_event_t; /* see SENSOR_TYPE_META_DATA */ typedef sensors_event_t sensors_meta_data_event_t; struct sensor_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. */ struct sensors_module_t { struct hw_module_t common; /** * Enumerate all available sensors. The list is returned in "list". * @return number of sensors in the list */ int (*get_sensors_list)(struct sensors_module_t* module, struct sensor_t const** list); }; struct sensor_t { /* Name of this sensor. * All sensors of the same "type" must have a different "name". */ const char* name; /* vendor of the hardware part */ const char* vendor; /* version of the hardware part + driver. The value of this field * must increase when the driver is updated in a way that changes the * output of this sensor. This is important for fused sensors when the * fusion algorithm is updated. */ int version; /* handle that identifies this sensors. This handle is used to reference * this sensor throughout the HAL API. */ int handle; /* this sensor's type. */ int type; /* maximum range of this sensor's value in SI units */ float maxRange; /* smallest difference between two values reported by this sensor */ float resolution; /* rough estimate of this sensor's power consumption in mA */ float power; /* this value depends on the reporting mode: * * continuous: minimum sample period allowed in microseconds * on-change : 0 * one-shot :-1 * special : 0, unless otherwise noted */ int32_t minDelay; /* number of events reserved for this sensor in the batch mode FIFO. * If there is a dedicated FIFO for this sensor, then this is the * size of this FIFO. If the FIFO is shared with other sensors, * this is the size reserved for that sensor and it can be zero. */ uint32_t fifoReservedEventCount; /* maximum number of events of this sensor that could be batched. * This is especially relevant when the FIFO is shared between * several sensors; this value is then set to the size of that FIFO. */ 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. */ const char* stringType; /* permission required to see this sensor, register to it and receive data. * Set to "" if no permission is required. Some sensor types like the * heart rate monitor have a mandatory require_permission. * For sensors that always require a specific permission, like the heart * rate monitor, the android framework might overwrite this string * automatically. */ const char* requiredPermission; /* This value is defined only for continuous mode and on-change sensors. It is the delay between * two sensor events corresponding to the lowest frequency that this sensor supports. When lower * frequencies are requested through batch()/setDelay() the events will be generated at this * frequency instead. It can be used by the framework or applications to estimate when the batch * FIFO may be full. * * NOTE: 1) period_ns is in nanoseconds where as maxDelay/minDelay are in microseconds. * continuous, on-change: maximum sampling period allowed in microseconds. * one-shot, special : 0 * 2) maxDelay should always fit within a 32 bit signed integer. It is declared as 64 bit * on 64 bit architectures only for binary compatibility reasons. * Availability: SENSORS_DEVICE_API_VERSION_1_3 */ #ifdef __LP64__ int64_t maxDelay; #else int32_t maxDelay; #endif /* Flags for sensor. See SENSOR_FLAG_* above. Only the least significant 32 bits are used here. * It is declared as 64 bit on 64 bit architectures only for binary compatibility reasons. * Availability: SENSORS_DEVICE_API_VERSION_1_3 */ #ifdef __LP64__ uint64_t flags; #else uint32_t flags; #endif /* reserved fields, must be zero */ void* reserved[2]; }; /* * sensors_poll_device_t is used with SENSORS_DEVICE_API_VERSION_0_1 * and is present for backward binary and source compatibility. * See the Sensors HAL interface section for complete descriptions of the * following functions: * http://source.android.com/devices/sensors/index.html#hal */ struct sensors_poll_device_t { struct hw_device_t common; int (*activate)(struct sensors_poll_device_t *dev, int sensor_handle, int enabled); int (*setDelay)(struct sensors_poll_device_t *dev, int sensor_handle, int64_t sampling_period_ns); int (*poll)(struct sensors_poll_device_t *dev, sensors_event_t* data, int count); }; /* * struct sensors_poll_device_1 is used in HAL versions >= SENSORS_DEVICE_API_VERSION_1_0 */ typedef struct sensors_poll_device_1 { union { /* sensors_poll_device_1 is compatible with sensors_poll_device_t, * and can be down-cast to it */ struct sensors_poll_device_t v0; struct { struct hw_device_t common; /* Activate/de-activate one sensor. Return 0 on success, negative * * sensor_handle is the handle of the sensor to change. * enabled set to 1 to enable, or 0 to disable the sensor. * * Return 0 on success, negative errno code otherwise. */ int (*activate)(struct sensors_poll_device_t *dev, int sensor_handle, int enabled); /** * Set the events's period in nanoseconds for a given sensor. * If sampling_period_ns > max_delay it will be truncated to * max_delay and if sampling_period_ns < min_delay it will be * replaced by min_delay. */ int (*setDelay)(struct sensors_poll_device_t *dev, int sensor_handle, int64_t sampling_period_ns); /** * Returns an array of sensor data. */ int (*poll)(struct sensors_poll_device_t *dev, sensors_event_t* data, int count); }; }; /* * Sets a sensor’s parameters, including sampling frequency and maximum * report latency. This function can be called while the sensor is * activated, in which case it must not cause any sensor measurements to * be lost: transitioning from one sampling rate to the other cannot cause * lost events, nor can transitioning from a high maximum report latency to * a low maximum report latency. * See the Batching sensor results page for details: * http://source.android.com/devices/sensors/batching.html */ int (*batch)(struct sensors_poll_device_1* dev, int sensor_handle, int flags, int64_t sampling_period_ns, int64_t max_report_latency_ns); /* * Flush adds a META_DATA_FLUSH_COMPLETE event (sensors_event_meta_data_t) * to the end of the "batch mode" FIFO for the specified sensor and flushes * the FIFO. * If the FIFO is empty or if the sensor doesn't support batching (FIFO size zero), * it should return SUCCESS along with a trivial META_DATA_FLUSH_COMPLETE event added to the * event stream. This applies to all sensors other than one-shot sensors. * If the sensor is a one-shot sensor, flush must return -EINVAL and not generate * any flush complete metadata. * If the sensor is not active at the time flush() is called, flush() should return * -EINVAL. */ int (*flush)(struct sensors_poll_device_1* dev, int sensor_handle); void (*reserved_procs[8])(void); } sensors_poll_device_1_t; /** convenience API for opening and closing a device */ static inline int sensors_open(const struct hw_module_t* module, struct sensors_poll_device_t** device) { return module->methods->open(module, SENSORS_HARDWARE_POLL, (struct hw_device_t**)device); } static inline int sensors_close(struct sensors_poll_device_t* device) { return device->common.close(&device->common); } 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); } static inline int sensors_close_1(sensors_poll_device_1_t* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_SENSORS_INTERFACE_H android-headers-23/21/hardware/sound_trigger.h000066400000000000000000000115301264465411000213770ustar00rootroot00000000000000/* * 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. */ #include #include #include #ifndef ANDROID_SOUND_TRIGGER_HAL_H #define ANDROID_SOUND_TRIGGER_HAL_H __BEGIN_DECLS /** * The id of this module */ #define SOUND_TRIGGER_HARDWARE_MODULE_ID "sound_trigger" /** * Name of the audio devices to open */ #define SOUND_TRIGGER_HARDWARE_INTERFACE "sound_trigger_hw_if" #define SOUND_TRIGGER_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) #define SOUND_TRIGGER_MODULE_API_VERSION_CURRENT SOUND_TRIGGER_MODULE_API_VERSION_1_0 #define SOUND_TRIGGER_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) #define SOUND_TRIGGER_DEVICE_API_VERSION_CURRENT SOUND_TRIGGER_DEVICE_API_VERSION_1_0 /** * List of known sound trigger HAL modules. This is the base name of the sound_trigger HAL * library composed of the "sound_trigger." prefix, one of the base names below and * a suffix specific to the device. * e.g: sondtrigger.primary.goldfish.so or sound_trigger.primary.default.so */ #define SOUND_TRIGGER_HARDWARE_MODULE_ID_PRIMARY "primary" /** * 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. */ struct sound_trigger_module { struct hw_module_t common; }; typedef void (*recognition_callback_t)(struct sound_trigger_recognition_event *event, void *cookie); typedef void (*sound_model_callback_t)(struct sound_trigger_model_event *event, void *cookie); struct sound_trigger_hw_device { struct hw_device_t common; /* * Retrieve implementation properties. */ int (*get_properties)(const struct sound_trigger_hw_device *dev, struct sound_trigger_properties *properties); /* * Load a sound model. Once loaded, recognition of this model can be started and stopped. * Only one active recognition per model at a time. The SoundTrigger service will handle * concurrent recognition requests by different users/applications on the same model. * The implementation returns a unique handle used by other functions (unload_sound_model(), * start_recognition(), etc... */ int (*load_sound_model)(const struct sound_trigger_hw_device *dev, struct sound_trigger_sound_model *sound_model, sound_model_callback_t callback, void *cookie, sound_model_handle_t *handle); /* * Unload a sound model. A sound model can be unloaded to make room for a new one to overcome * implementation limitations. */ int (*unload_sound_model)(const struct sound_trigger_hw_device *dev, sound_model_handle_t handle); /* Start recognition on a given model. Only one recognition active at a time per model. * Once recognition succeeds of fails, the callback is called. * TODO: group recognition configuration parameters into one struct and add key phrase options. */ int (*start_recognition)(const struct sound_trigger_hw_device *dev, sound_model_handle_t sound_model_handle, const struct sound_trigger_recognition_config *config, recognition_callback_t callback, void *cookie); /* Stop recognition on a given model. * The implementation does not have to call the callback when stopped via this method. */ int (*stop_recognition)(const struct sound_trigger_hw_device *dev, sound_model_handle_t sound_model_handle); }; typedef struct sound_trigger_hw_device sound_trigger_hw_device_t; /** convenience API for opening and closing a supported device */ 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); } static inline int sound_trigger_hw_device_close(struct sound_trigger_hw_device* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_SOUND_TRIGGER_HAL_H android-headers-23/21/hardware/tv_input.h000066400000000000000000000254251264465411000204040ustar00rootroot00000000000000/* * Copyright 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_TV_INPUT_INTERFACE_H #define ANDROID_TV_INPUT_INTERFACE_H #include #include #include #include #include #include __BEGIN_DECLS /* * Module versioning information for the TV input hardware module, based on * tv_input_module_t.common.module_api_version. * * Version History: * * TV_INPUT_MODULE_API_VERSION_0_1: * Initial TV input hardware module API. * */ #define TV_INPUT_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define TV_INPUT_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION(0, 1) /* * The id of this module */ #define TV_INPUT_HARDWARE_MODULE_ID "tv_input" #define TV_INPUT_DEFAULT_DEVICE "default" /*****************************************************************************/ /* * 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 tv_input_module { struct hw_module_t common; } tv_input_module_t; /*****************************************************************************/ enum { /* Generic hardware. */ TV_INPUT_TYPE_OTHER_HARDWARE = 1, /* Tuner. (e.g. built-in terrestrial tuner) */ TV_INPUT_TYPE_TUNER = 2, TV_INPUT_TYPE_COMPOSITE = 3, TV_INPUT_TYPE_SVIDEO = 4, TV_INPUT_TYPE_SCART = 5, TV_INPUT_TYPE_COMPONENT = 6, TV_INPUT_TYPE_VGA = 7, TV_INPUT_TYPE_DVI = 8, /* Physical HDMI port. (e.g. HDMI 1) */ TV_INPUT_TYPE_HDMI = 9, TV_INPUT_TYPE_DISPLAY_PORT = 10, }; typedef uint32_t tv_input_type_t; typedef struct tv_input_device_info { /* Device ID */ int device_id; /* Type of physical TV input. */ tv_input_type_t type; union { struct { /* HDMI port ID number */ uint32_t port_id; } hdmi; /* TODO: add other type specific information. */ int32_t type_info_reserved[16]; }; /* TODO: Add capability if necessary. */ /* * Audio info * * audio_type == AUDIO_DEVICE_NONE if this input has no audio. */ audio_devices_t audio_type; const char* audio_address; int32_t reserved[16]; } tv_input_device_info_t; enum { /* * Hardware notifies the framework that a device is available. */ TV_INPUT_EVENT_DEVICE_AVAILABLE = 1, /* * Hardware notifies the framework that a device is unavailable. */ TV_INPUT_EVENT_DEVICE_UNAVAILABLE = 2, /* * Stream configurations are changed. Client should regard all open streams * at the specific device are closed, and should call * get_stream_configurations() again, opening some of them if necessary. */ TV_INPUT_EVENT_STREAM_CONFIGURATIONS_CHANGED = 3, /* * Hardware is done with capture request with the buffer. Client can assume * ownership of the buffer again. */ TV_INPUT_EVENT_CAPTURE_SUCCEEDED = 4, /* * Hardware met a failure while processing a capture request or client * canceled the request. Client can assume ownership of the buffer again. */ TV_INPUT_EVENT_CAPTURE_FAILED = 5, }; typedef uint32_t tv_input_event_type_t; typedef struct tv_input_capture_result { /* Device ID */ int device_id; /* Stream ID */ int stream_id; /* Sequence number of the request */ uint32_t seq; /* * The buffer passed to hardware in request_capture(). The content of * buffer is undefined (although buffer itself is valid) for * TV_INPUT_CAPTURE_FAILED event. */ buffer_handle_t buffer; /* * Error code for the request. -ECANCELED if request is cancelled; other * error codes are unknown errors. */ int error_code; } tv_input_capture_result_t; typedef struct tv_input_event { tv_input_event_type_t type; union { /* * TV_INPUT_EVENT_DEVICE_AVAILABLE: all fields are relevant * TV_INPUT_EVENT_DEVICE_UNAVAILABLE: only device_id is relevant * TV_INPUT_EVENT_STREAM_CONFIGURATIONS_CHANGED: only device_id is * relevant */ tv_input_device_info_t device_info; /* * TV_INPUT_EVENT_CAPTURE_SUCCEEDED: error_code is not relevant * TV_INPUT_EVENT_CAPTURE_FAILED: all fields are relevant */ tv_input_capture_result_t capture_result; }; } tv_input_event_t; typedef struct tv_input_callback_ops { /* * event contains the type of the event and additional data if necessary. * The event object is guaranteed to be valid only for the duration of the * call. * * data is an object supplied at device initialization, opaque to the * hardware.     */ void (*notify)(struct tv_input_device* dev, tv_input_event_t* event, void* data); } tv_input_callback_ops_t; enum { TV_STREAM_TYPE_INDEPENDENT_VIDEO_SOURCE = 1, TV_STREAM_TYPE_BUFFER_PRODUCER = 2, }; typedef uint32_t tv_stream_type_t; typedef struct tv_stream_config { /* * ID number of the stream. This value is used to identify the whole stream * configuration. */ int stream_id; /* Type of the stream */ tv_stream_type_t type; /* Max width/height of the stream. */ uint32_t max_video_width; uint32_t max_video_height; } tv_stream_config_t; typedef struct buffer_producer_stream { /* * IN/OUT: Width / height of the stream. Client may request for specific * size but hardware may change it. Client must allocate buffers with * specified width and height. */ uint32_t width; uint32_t height; /* OUT: Client must set this usage when allocating buffer. */ uint32_t usage; /* OUT: Client must allocate a buffer with this format. */ uint32_t format; } buffer_producer_stream_t; typedef struct tv_stream { /* IN: ID in the stream configuration */ int stream_id; /* OUT: Type of the stream (for convenience) */ tv_stream_type_t type; /* Data associated with the stream for client's use */ union { /* OUT: A native handle describing the sideband stream source */ native_handle_t* sideband_stream_source_handle; /* IN/OUT: Details are in buffer_producer_stream_t */ buffer_producer_stream_t buffer_producer; }; } tv_stream_t; /* * Every device data structure must begin with hw_device_t * followed by module specific public methods and attributes. */ typedef struct tv_input_device { struct hw_device_t common; /* * initialize: * * Provide callbacks to the device and start operation. At first, no device * is available and after initialize() completes, currently available * devices including static devices should notify via callback. * * Framework owns callbacks object. * * data is a framework-owned object which would be sent back to the * framework for each callback notifications. * * Return 0 on success. */ int (*initialize)(struct tv_input_device* dev, const tv_input_callback_ops_t* callback, void* data); /* * get_stream_configurations: * * Get stream configurations for a specific device. An input device may have * multiple configurations. * * The configs object is guaranteed to be valid only until the next call to * get_stream_configurations() or STREAM_CONFIGURATIONS_CHANGED event. * * Return 0 on success. */ int (*get_stream_configurations)(const struct tv_input_device* dev, int device_id, int* num_configurations, const tv_stream_config_t** configs); /* * open_stream: * * Open a stream with given stream ID. Caller owns stream object, and the * populated data is only valid until the stream is closed. * * Return 0 on success; -EBUSY if the client should close other streams to * open the stream; -EEXIST if the stream with the given ID is already open; * -EINVAL if device_id and/or stream_id are invalid; other non-zero value * denotes unknown error. */ int (*open_stream)(struct tv_input_device* dev, int device_id, tv_stream_t* stream); /* * close_stream: * * Close a stream to a device. data in tv_stream_t* object associated with * the stream_id is obsolete once this call finishes. * * Return 0 on success; -ENOENT if the stream is not open; -EINVAL if * device_id and/or stream_id are invalid. */ int (*close_stream)(struct tv_input_device* dev, int device_id, int stream_id); /* * request_capture: * * Request buffer capture for a stream. This is only valid for buffer * producer streams. The buffer should be created with size, format and * usage specified in the stream. Framework provides seq in an * increasing sequence per each stream. Hardware should provide the picture * in a chronological order according to seq. For example, if two * requests are being processed at the same time, the request with the * smaller seq should get an earlier frame. * * The framework releases the ownership of the buffer upon calling this * function. When the buffer is filled, hardware notifies the framework * via TV_INPUT_EVENT_CAPTURE_FINISHED callback, and the ownership is * transferred back to framework at that time. * * Return 0 on success; -ENOENT if the stream is not open; -EINVAL if * device_id and/or stream_id are invalid; -EWOULDBLOCK if HAL cannot take * additional requests until it releases a buffer. */ int (*request_capture)(struct tv_input_device* dev, int device_id, int stream_id, buffer_handle_t buffer, uint32_t seq); /* * cancel_capture: * * Cancel an ongoing capture. Hardware should release the buffer as soon as * possible via TV_INPUT_EVENT_CAPTURE_FAILED callback. * * Return 0 on success; -ENOENT if the stream is not open; -EINVAL if * device_id, stream_id, and/or seq are invalid. */ int (*cancel_capture)(struct tv_input_device* dev, int device_id, int stream_id, uint32_t seq); void* reserved[16]; } tv_input_device_t; __END_DECLS #endif // ANDROID_TV_INPUT_INTERFACE_H android-headers-23/21/hardware/vibrator.h000066400000000000000000000043751264465411000203650ustar00rootroot00000000000000/* * 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 _HARDWARE_VIBRATOR_H #define _HARDWARE_VIBRATOR_H #include __BEGIN_DECLS #define VIBRATOR_API_VERSION HARDWARE_MODULE_API_VERSION(1,0) /** * The id of this module */ #define VIBRATOR_HARDWARE_MODULE_ID "vibrator" /** * The id of the main vibrator device */ #define VIBRATOR_DEVICE_ID_MAIN "main_vibrator" struct vibrator_device; typedef struct vibrator_device { /** * Common methods of the vibrator device. This *must* be the first member of * vibrator_device as users of this structure will cast a hw_device_t to * vibrator_device pointer in contexts where it's known the hw_device_t references a * vibrator_device. */ struct hw_device_t common; /** Turn on vibrator * * What happens when this function is called while the the timeout of a * previous call has not expired is implementation dependent. * * @param timeout_ms number of milliseconds to vibrate * * @return 0 in case of success, negative errno code else */ int (*vibrator_on)(struct vibrator_device* vibradev, unsigned int timeout_ms); /** Turn off vibrator * * It is not guaranteed that the vibrator will be immediately stopped: the * behaviour is implementation dependent. * * @return 0 in case of success, negative errno code else */ int (*vibrator_off)(struct vibrator_device* vibradev); } vibrator_device_t; 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); } __END_DECLS #endif // _HARDWARE_VIBRATOR_H android-headers-23/21/hardware_legacy/000077500000000000000000000000001264465411000176775ustar00rootroot00000000000000android-headers-23/21/hardware_legacy/audio_policy_conf.h000066400000000000000000000037061264465411000235430ustar00rootroot00000000000000/* * 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_AUDIO_POLICY_CONF_H #define ANDROID_AUDIO_POLICY_CONF_H ///////////////////////////////////////////////// // Definitions for audio policy configuration file (audio_policy.conf) ///////////////////////////////////////////////// #define AUDIO_HARDWARE_MODULE_ID_MAX_LEN 32 #define AUDIO_POLICY_CONFIG_FILE "/system/etc/audio_policy.conf" #define AUDIO_POLICY_VENDOR_CONFIG_FILE "/vendor/etc/audio_policy.conf" // global configuration #define GLOBAL_CONFIG_TAG "global_configuration" #define ATTACHED_OUTPUT_DEVICES_TAG "attached_output_devices" #define DEFAULT_OUTPUT_DEVICE_TAG "default_output_device" #define ATTACHED_INPUT_DEVICES_TAG "attached_input_devices" #define SPEAKER_DRC_ENABLED_TAG "speaker_drc_enabled" // hw modules descriptions #define AUDIO_HW_MODULE_TAG "audio_hw_modules" #define OUTPUTS_TAG "outputs" #define INPUTS_TAG "inputs" #define SAMPLING_RATES_TAG "sampling_rates" #define FORMATS_TAG "formats" #define CHANNELS_TAG "channel_masks" #define DEVICES_TAG "devices" #define FLAGS_TAG "flags" #define DYNAMIC_VALUE_TAG "dynamic" // special value for "channel_masks", "sampling_rates" and // "formats" in outputs descriptors indicating that supported // values should be queried after opening the output. #endif // ANDROID_AUDIO_POLICY_CONF_H android-headers-23/21/hardware_legacy/vibrator.h000066400000000000000000000022321264465411000216770ustar00rootroot00000000000000/* * 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 android-headers-23/21/hardware_legacy/wifi.h000066400000000000000000000077041264465411000210160ustar00rootroot00000000000000/* * 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 _WIFI_H #define _WIFI_H #if __cplusplus extern "C" { #endif /** * Load the Wi-Fi driver. * * @return 0 on success, < 0 on failure. */ int wifi_load_driver(); /** * Unload the Wi-Fi driver. * * @return 0 on success, < 0 on failure. */ int wifi_unload_driver(); /** * Check if the Wi-Fi driver is loaded. * * @return 0 on success, < 0 on failure. */ 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 const char *wifi_get_fw_path(int fw_type); /** * Change the path to firmware for the wlan driver */ int wifi_change_fw_path(const char *fwpath); /** * Check and create if necessary initial entropy file */ #define WIFI_ENTROPY_FILE "/data/misc/wifi/entropy.bin" int ensure_entropy_file_exists(); #if __cplusplus }; // extern "C" #endif #endif // _WIFI_H android-headers-23/21/libnfc-nxp/000077500000000000000000000000001264465411000166165ustar00rootroot00000000000000android-headers-23/21/libnfc-nxp/nfc_custom_config_example.h000066400000000000000000000124361264465411000241750ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/nfc_osal_deferred_call.h000066400000000000000000000021511264465411000234050ustar00rootroot00000000000000#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); #endifandroid-headers-23/21/libnfc-nxp/phDal4Nfc.h000066400000000000000000000630601264465411000205370ustar00rootroot00000000000000/* * 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 android-headers-23/21/libnfc-nxp/phDal4Nfc_messageQueueLib.h000066400000000000000000000026601264465411000236760ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phDbgTrace.h000066400000000000000000000133441264465411000207770ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phDnldNfc.h000066400000000000000000000114311264465411000206270ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phFriNfc.h000066400000000000000000000133601264465411000204710ustar00rootroot00000000000000/* * 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__ */ android-headers-23/21/libnfc-nxp/phFriNfc_DesfireFormat.h000066400000000000000000000253751264465411000233140ustar00rootroot00000000000000/* * 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 android-headers-23/21/libnfc-nxp/phFriNfc_DesfireMap.h000066400000000000000000000344271264465411000225770ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phFriNfc_FelicaMap.h000066400000000000000000000340361264465411000223750ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phFriNfc_ISO15693Format.h000066400000000000000000000111301264465411000227550ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phFriNfc_ISO15693Map.h000066400000000000000000000243771264465411000222630ustar00rootroot00000000000000/* * * 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 */ android-headers-23/21/libnfc-nxp/phFriNfc_IntNdefMap.h000066400000000000000000000072241264465411000225400ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phFriNfc_Llcp.h000066400000000000000000000367111264465411000214500ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phFriNfc_LlcpMac.h000066400000000000000000000210611264465411000220610ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phFriNfc_LlcpMacNfcip.h000066400000000000000000000022321264465411000230400ustar00rootroot00000000000000/* * 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_LlcpMacNfcip.h * \brief NFC LLCP MAC Mapping for NFCIP. * * Project: NFC-FRI * */ #ifndef PHFRINFC_LLCPMACNFCIP_H #define PHFRINFC_LLCPMACNFCIP_H /*include files*/ #include #include #include #include /** * \name MAC Mapping for NFCIP * * File: \ref phFriNfc_LlcpMacNfcip.h * */ /** \defgroup grp_fri_nfc_llcp_macnfcip NFCIP MAC Mapping * * TODO * */ NFCSTATUS phFriNfc_LlcpMac_Nfcip_Register (phFriNfc_LlcpMac_t *LlcpMac); #endif /* PHFRINFC_LLCPMACNFCIP_H */ android-headers-23/21/libnfc-nxp/phFriNfc_LlcpTransport.h000066400000000000000000001155541264465411000233700ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phFriNfc_LlcpTransport_Connection.h000066400000000000000000000415061264465411000255420ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phFriNfc_LlcpTransport_Connectionless.h000066400000000000000000000136471264465411000264360ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phFriNfc_LlcpUtils.h000066400000000000000000000114131264465411000224610ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phFriNfc_MapTools.h000066400000000000000000000061721264465411000223120ustar00rootroot00000000000000/* * 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 android-headers-23/21/libnfc-nxp/phFriNfc_MifStdFormat.h000066400000000000000000000452731264465411000231200ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phFriNfc_MifULFormat.h000066400000000000000000000167131264465411000227030ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phFriNfc_MifareStdMap.h000066400000000000000000000563431264465411000230750ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phFriNfc_MifareULMap.h000066400000000000000000000373411264465411000226600ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phFriNfc_NdefMap.h000066400000000000000000001525511264465411000220710ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phFriNfc_NdefRecord.h000066400000000000000000000665561264465411000226030ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phFriNfc_NdefReg.h000066400000000000000000000543301264465411000220650ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phFriNfc_OvrHal.h000066400000000000000000000373351264465411000217540ustar00rootroot00000000000000/* * 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 android-headers-23/21/libnfc-nxp/phFriNfc_OvrHalCmd.h000066400000000000000000000256351264465411000224000ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phFriNfc_SmtCrdFmt.h000066400000000000000000000446671264465411000224320ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phFriNfc_TopazMap.h000066400000000000000000000754451264465411000223200ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phHal4Nfc.h000066400000000000000000001414511264465411000205440ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phHal4Nfc_Internal.h000066400000000000000000000307131264465411000223760ustar00rootroot00000000000000/* * 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 android-headers-23/21/libnfc-nxp/phHciNfc_AdminMgmt.h000066400000000000000000000167221264465411000224160ustar00rootroot00000000000000/* * 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 android-headers-23/21/libnfc-nxp/phHciNfc_CE_A.h000066400000000000000000000255241264465411000212700ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phHciNfc_CE_B.h000066400000000000000000000252721264465411000212710ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phHciNfc_DevMgmt.h000066400000000000000000000272201264465411000220770ustar00rootroot00000000000000/* * 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 android-headers-23/21/libnfc-nxp/phHciNfc_Emulation.h000066400000000000000000000132771264465411000225000ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phHciNfc_Felica.h000066400000000000000000000251121264465411000217150ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phHciNfc_Generic.h000066400000000000000000001241051264465411000221100ustar00rootroot00000000000000/* * 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 android-headers-23/21/libnfc-nxp/phHciNfc_IDMgmt.h000066400000000000000000000200761264465411000216570ustar00rootroot00000000000000/* * 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 android-headers-23/21/libnfc-nxp/phHciNfc_ISO15693.h000066400000000000000000000237231264465411000216020ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phHciNfc_Jewel.h000066400000000000000000000231221264465411000215770ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phHciNfc_LinkMgmt.h000066400000000000000000000127131264465411000222570ustar00rootroot00000000000000/* * 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 android-headers-23/21/libnfc-nxp/phHciNfc_NfcIPMgmt.h000066400000000000000000000667011264465411000223270ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phHciNfc_Pipe.h000066400000000000000000000231451264465411000214330ustar00rootroot00000000000000/* * 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 android-headers-23/21/libnfc-nxp/phHciNfc_PollingLoop.h000066400000000000000000000173671264465411000230050ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phHciNfc_RFReader.h000066400000000000000000000545371264465411000222010ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phHciNfc_RFReaderA.h000066400000000000000000000345311264465411000222720ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phHciNfc_RFReaderB.h000066400000000000000000000236401264465411000222720ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phHciNfc_SWP.h000066400000000000000000000301461264465411000212060ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phHciNfc_Sequence.h000066400000000000000000000364271264465411000223150ustar00rootroot00000000000000/* * 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 android-headers-23/21/libnfc-nxp/phHciNfc_WI.h000066400000000000000000000211351264465411000210520ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phLibNfc.h000066400000000000000000004736071264465411000204750ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phLibNfcStatus.h000066400000000000000000000050551264465411000216650ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phLibNfc_Internal.h000066400000000000000000000221571264465411000223170ustar00rootroot00000000000000/* * 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 android-headers-23/21/libnfc-nxp/phLibNfc_SE.h000066400000000000000000000047561264465411000210570ustar00rootroot00000000000000/* * 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 android-headers-23/21/libnfc-nxp/phLibNfc_discovery.h000066400000000000000000000017161264465411000225500ustar00rootroot00000000000000/* * 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 * * 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 ); #endif android-headers-23/21/libnfc-nxp/phLibNfc_initiator.h000066400000000000000000000031531264465411000225400ustar00rootroot00000000000000/* * 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 android-headers-23/21/libnfc-nxp/phLibNfc_ioctl.h000066400000000000000000000050111264465411000216430ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phLibNfc_ndef_raw.h000066400000000000000000000045331264465411000223260ustar00rootroot00000000000000/* * 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 android-headers-23/21/libnfc-nxp/phLlcNfc.h000066400000000000000000000131161264465411000204620ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phLlcNfc_DataTypes.h000066400000000000000000000472721264465411000224520ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phLlcNfc_Frame.h000066400000000000000000000360611264465411000216000ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phLlcNfc_Interface.h000066400000000000000000000142661264465411000224510ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phLlcNfc_Timer.h000066400000000000000000000135271264465411000216300ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phNfcCompId.h000066400000000000000000000145551264465411000211330ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phNfcConfig.h000066400000000000000000000314371264465411000211630ustar00rootroot00000000000000/* * 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*/ android-headers-23/21/libnfc-nxp/phNfcHalTypes.h000066400000000000000000001075141264465411000215070ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phNfcInterface.h000066400000000000000000000332641264465411000216560ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phNfcStatus.h000066400000000000000000000301521264465411000212320ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phNfcTypes.h000066400000000000000000001314201264465411000210530ustar00rootroot00000000000000/* * 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 */ android-headers-23/21/libnfc-nxp/phOsalNfc.h000066400000000000000000000146071264465411000206540ustar00rootroot00000000000000/* * 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, /** #else #ifdef __linux__ #include #else #include #endif #endif #endif /* PHOSALNFC_MSG_H */ android-headers-23/21/libnfc-nxp/phOsalNfc_Timer.h000066400000000000000000000164661264465411000220210ustar00rootroot00000000000000/* * 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_Timer.h * \brief Timer Implementation. * * Project: NFC-FRI 1.1 * * $Date: Mon Mar 16 20:30:44 2009 $ * $Author: ing01697 $ * $Revision: 1.19 $ * $Aliases: 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 PHOSALNFC_TIMER_H #define PHOSALNFC_TIMER_H /* -----------------Include files ---------------------------------------*/ #include #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 */ android-headers-23/21/linux/000077500000000000000000000000001264465411000157155ustar00rootroot00000000000000android-headers-23/21/linux/android_alarm.h000066400000000000000000000055421264465411000206700ustar00rootroot00000000000000/**************************************************************************** **************************************************************************** *** *** 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_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, ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP_MASK = /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 1U << ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP, ANDROID_ALARM_ELAPSED_REALTIME_MASK = 1U << ANDROID_ALARM_ELAPSED_REALTIME, ANDROID_ALARM_SYSTEMTIME_MASK = 1U << ANDROID_ALARM_SYSTEMTIME, /* 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 */ android-headers-23/21/linux/binder.h000066400000000000000000000171101264465411000173310ustar00rootroot00000000000000/**************************************************************************** **************************************************************************** *** *** 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 */ } __attribute__((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 android-headers-23/21/linux/sw_sync.h000066400000000000000000000030261264465411000175540ustar00rootroot00000000000000/**************************************************************************** **************************************************************************** *** *** 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_SW_SYNC_H #define _UAPI_LINUX_SW_SYNC_H #include struct sw_sync_create_fence_data { /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ __u32 value; char name[32]; __s32 fence; }; /* 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) #endif /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ android-headers-23/21/linux/sync.h000066400000000000000000000041441264465411000170450ustar00rootroot00000000000000/**************************************************************************** **************************************************************************** *** *** 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 */ android-headers-23/21/log/000077500000000000000000000000001264465411000153375ustar00rootroot00000000000000android-headers-23/21/log/event_tag_map.h000066400000000000000000000024171264465411000203250ustar00rootroot00000000000000/* * 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. */ #ifndef _LIBS_CUTILS_EVENTTAGMAP_H #define _LIBS_CUTILS_EVENTTAGMAP_H #ifdef __cplusplus extern "C" { #endif #define EVENT_TAG_MAP_FILE "/system/etc/event-log-tags" struct EventTagMap; typedef struct EventTagMap EventTagMap; /* * Open the specified file as an event log tag map. * * Returns NULL on failure. */ EventTagMap* android_openEventTagMap(const char* fileName); /* * Close the map. */ 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); #ifdef __cplusplus } #endif #endif /*_LIBS_CUTILS_EVENTTAGMAP_H*/ android-headers-23/21/log/log.h000066400000000000000000000365361264465411000163060ustar00rootroot00000000000000/* * Copyright (C) 2005-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. */ // // 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 #ifdef HAVE_PTHREADS #include #endif #include #include #include #include #include #include #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 * 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 // --------------------------------------------------------------------- /* * 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) #else #define ALOGV(...) __ALOGV(__VA_ARGS__) #endif #endif #define CONDITION(cond) (__builtin_expect((cond)!=0, 0)) #ifndef ALOGV_IF #if LOG_NDEBUG #define ALOGV_IF(cond, ...) ((void)0) #else #define ALOGV_IF(cond, ...) \ ( (CONDITION(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, ...) \ ( (CONDITION(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, ...) \ ( (CONDITION(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, ...) \ ( (CONDITION(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, ...) \ ( (CONDITION(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 // --------------------------------------------------------------------- /* * 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 #define CONDITION(cond) (__builtin_expect((cond)!=0, 0)) #ifndef SLOGV_IF #if LOG_NDEBUG #define SLOGV_IF(cond, ...) ((void)0) #else #define SLOGV_IF(cond, ...) \ ( (CONDITION(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, ...) \ ( (CONDITION(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, ...) \ ( (CONDITION(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__)) #endif #ifndef SLOGW_IF #define SLOGW_IF(cond, ...) \ ( (CONDITION(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__)) #endif #ifndef SLOGE_IF #define SLOGE_IF(cond, ...) \ ( (CONDITION(cond)) \ ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) \ : (void)0 ) #endif // --------------------------------------------------------------------- /* * 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 #define CONDITION(cond) (__builtin_expect((cond)!=0, 0)) #ifndef RLOGV_IF #if LOG_NDEBUG #define RLOGV_IF(cond, ...) ((void)0) #else #define RLOGV_IF(cond, ...) \ ( (CONDITION(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, ...) \ ( (CONDITION(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, ...) \ ( (CONDITION(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, ...) \ ( (CONDITION(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, ...) \ ( (CONDITION(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, ...) \ ( (CONDITION(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__) //#define ALOG_ASSERT(cond) LOG_FATAL_IF(!(cond), "Assertion failed: " #cond) #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 /* * 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. These must match up with the declarations in * java/android/android/util/EventLog.java. */ typedef enum { EVENT_TYPE_INT = 0, EVENT_TYPE_LONG = 1, EVENT_TYPE_STRING = 2, EVENT_TYPE_LIST = 3, } 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_STRING #define LOG_EVENT_STRING(_tag, _value) \ (void) __android_log_bswrite(_tag, _value); #endif /* TODO: something for LIST */ /* * =========================================================================== * * 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. */ #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 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) // TODO: remove these prototypes and their users #define android_testLog(prio, tag) (1) #define android_writevLog(vec,num) do{}while(0) #define android_write1Log(str,len) do{}while (0) #define android_setMinPriority(tag, prio) do{}while(0) //#define android_logToCallback(func) do{}while(0) #define android_logToFile(tag, file) (0) #define android_logToFd(tag, fd) (0) 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_MAX } log_id_t; #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 ; #ifdef __cplusplus } #endif #endif /* _LIBS_LOG_LOG_H */ android-headers-23/21/log/log_read.h000066400000000000000000000104001264465411000172570ustar00rootroot00000000000000/* * Copyright (C) 2013-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 _LIBS_LOG_LOG_READ_H #define _LIBS_LOG_LOG_READ_H #include #include /* struct log_time is a wire-format variant of struct timespec */ #define NS_PER_SEC 1000000000ULL #ifdef __cplusplus // 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); } // 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 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; } uint64_t nsec() const { return static_cast(tv_sec) * NS_PER_SEC + tv_nsec; } 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); } __attribute__((__packed__)); #else typedef struct log_time { uint32_t tv_sec; uint32_t tv_nsec; } __attribute__((__packed__)) log_time; #endif #endif /* define _LIBS_LOG_LOG_READ_H */ android-headers-23/21/log/logd.h000066400000000000000000000025421264465411000164400ustar00rootroot00000000000000/* * 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 */ #include #include #include #include #include #ifdef HAVE_PTHREADS #include #endif #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); #ifdef __cplusplus } #endif #endif /* _LOGD_H */ android-headers-23/21/log/logger.h000066400000000000000000000143461264465411000167770ustar00rootroot00000000000000/* ** ** 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 #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__)); /* * 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 4076 /* * 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_v3 entry; 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); 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 /* * 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 */ android-headers-23/21/log/logprint.h000066400000000000000000000072331264465411000173530ustar00rootroot00000000000000/* * Copyright (C) 2006 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 _LOGPRINT_H #define _LOGPRINT_H #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, } AndroidLogPrintFormat; typedef struct AndroidLogFormat_t AndroidLogFormat; typedef struct AndroidLogEntry_t { time_t tv_sec; long tv_nsec; android_LogPriority priority; int32_t pid; int32_t tid; const char * tag; size_t messageLen; const char * message; } AndroidLogEntry; AndroidLogFormat *android_log_format_new(); void android_log_format_free(AndroidLogFormat *p_format); void android_log_setPrintFormat(AndroidLogFormat *p_format, AndroidLogPrintFormat format); /** * Returns FORMAT_OFF on invalid string */ AndroidLogPrintFormat android_log_formatFromString(const char *s); /** * filterExpression: a single filter expression * eg "AT:d" * * returns 0 on success and -1 on invalid expression * * Assumes single threaded execution * */ int android_log_addFilterRule(AndroidLogFormat *p_format, const char *filterExpression); /** * filterString: a whitespace-separated set of filter expressions * eg "AT:d *:i" * * returns 0 on success and -1 on invalid expression * * Assumes single threaded execution * */ 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); /** * Splits a wire-format buffer into an AndroidLogEntry * entry allocated by caller. Pointers will point directly into buf * * 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); /** * Like android_log_processLogBuffer, but for binary logs. * * 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); /** * Formats a log message into a buffer * * Uses defaultBuffer if it can, otherwise malloc()'s a new buffer * If return value != defaultBuffer, caller must call free() * 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); /** * Either print or do not print log line, based on filter * * Assumes single threaded execution * */ int android_log_printLogLine( AndroidLogFormat *p_format, int fd, const AndroidLogEntry *entry); #ifdef __cplusplus } #endif #endif /*_LOGPRINT_H*/ android-headers-23/21/log/uio.h000066400000000000000000000022031264465411000163010ustar00rootroot00000000000000/* * Copyright (C) 2007-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. */ // // implementation of sys/uio.h for platforms that don't have it (Win32) // #ifndef _LIBS_CUTILS_UIO_H #define _LIBS_CUTILS_UIO_H #ifdef HAVE_SYS_UIO_H #include #else #ifdef __cplusplus extern "C" { #endif #include struct iovec { 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 ); #ifdef __cplusplus } #endif #endif /* !HAVE_SYS_UIO_H */ #endif /* _LIBS_UTILS_UIO_H */ android-headers-23/21/private/000077500000000000000000000000001264465411000162305ustar00rootroot00000000000000android-headers-23/21/private/android_filesystem_config.h000066400000000000000000000313731264465411000236210ustar00rootroot00000000000000/* * 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 used to define the properties of the filesystem ** images generated by build tools (mkbootfs and mkyaffs2image) and ** by the device side of adb. */ #ifndef _ANDROID_FILESYSTEM_CONFIG_H_ #define _ANDROID_FILESYSTEM_CONFIG_H_ #include #include #include #include #ifdef HAVE_ANDROID_OS #include #else #include "android_filesystem_capability.h" #endif /* 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_SHELL 2000 /* adb and debug shell user */ #define AID_CACHE 2001 /* cache access */ #define AID_DIAG 2002 /* access to diagnostic resources */ /* 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_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 /* first app user */ #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 /* offset for uid ranges for each user */ #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 */ #if !defined(EXCLUDE_FS_CONFIG_STRUCTURES) struct android_id_info { const char *name; unsigned aid; }; static const struct android_id_info android_ids[] = { { "root", AID_ROOT, }, { "system", AID_SYSTEM, }, { "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, }, { "shell", AID_SHELL, }, { "cache", AID_CACHE, }, { "diag", AID_DIAG, }, { "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, }, { "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. ** These rules are applied based on "first match", so they ** should start with the most specific path and work their ** way up to the root. */ static const struct fs_path_config android_dirs[] = { { 00770, AID_SYSTEM, AID_CACHE, 0, "cache" }, { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/app" }, { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/app-private" }, { 00771, AID_ROOT, AID_ROOT, 0, "data/dalvik-cache" }, { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/data" }, { 00771, AID_SHELL, AID_SHELL, 0, "data/local/tmp" }, { 00771, AID_SHELL, AID_SHELL, 0, "data/local" }, { 01771, AID_SYSTEM, AID_MISC, 0, "data/misc" }, { 00770, AID_DHCP, AID_DHCP, 0, "data/misc/dhcp" }, { 00771, AID_SHARED_RELRO, AID_SHARED_RELRO, 0, "data/misc/shared_relro" }, { 00775, AID_MEDIA_RW, AID_MEDIA_RW, 0, "data/media" }, { 00775, AID_MEDIA_RW, AID_MEDIA_RW, 0, "data/media/Music" }, { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data" }, { 00750, AID_ROOT, AID_SHELL, 0, "sbin" }, { 00755, AID_ROOT, AID_SHELL, 0, "system/bin" }, { 00755, AID_ROOT, AID_SHELL, 0, "system/vendor" }, { 00755, AID_ROOT, AID_SHELL, 0, "system/xbin" }, { 00755, AID_ROOT, AID_ROOT, 0, "system/etc/ppp" }, { 00755, AID_ROOT, AID_SHELL, 0, "vendor" }, { 00777, AID_ROOT, AID_ROOT, 0, "sdcard" }, { 00755, AID_ROOT, AID_ROOT, 0, 0 }, }; /* Rules for files. ** These rules are applied based on "first match", so they ** should start with the most specific path and work their ** way up to the root. Prefixes ending in * denotes wildcard ** and will allow partial matches. */ static const struct fs_path_config android_files[] = { { 00440, AID_ROOT, AID_SHELL, 0, "system/etc/init.goldfish.rc" }, { 00550, AID_ROOT, AID_SHELL, 0, "system/etc/init.goldfish.sh" }, { 00440, AID_ROOT, AID_SHELL, 0, "system/etc/init.trout.rc" }, { 00550, AID_ROOT, AID_SHELL, 0, "system/etc/init.ril" }, { 00550, AID_ROOT, AID_SHELL, 0, "system/etc/init.testmenu" }, { 00550, AID_DHCP, AID_SHELL, 0, "system/etc/dhcpcd/dhcpcd-run-hooks" }, { 00444, AID_RADIO, AID_AUDIO, 0, "system/etc/AudioPara4.csv" }, { 00555, AID_ROOT, AID_ROOT, 0, "system/etc/ppp/*" }, { 00555, AID_ROOT, AID_ROOT, 0, "system/etc/rc.*" }, { 00644, AID_SYSTEM, AID_SYSTEM, 0, "data/app/*" }, { 00644, AID_MEDIA_RW, AID_MEDIA_RW, 0, "data/media/*" }, { 00644, AID_SYSTEM, AID_SYSTEM, 0, "data/app-private/*" }, { 00644, AID_APP, AID_APP, 0, "data/data/*" }, { 00755, AID_ROOT, AID_ROOT, 0, "system/bin/ping" }, /* the following file is INTENTIONALLY set-gid and not set-uid. * Do not change. */ { 02750, AID_ROOT, AID_INET, 0, "system/bin/netcfg" }, /* the following five files are INTENTIONALLY set-uid, but they * are NOT included on user builds. */ { 04750, AID_ROOT, AID_SHELL, 0, "system/xbin/su" }, { 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/librank" }, { 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/procrank" }, { 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/procmem" }, { 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/tcpdump" }, { 04770, AID_ROOT, AID_RADIO, 0, "system/bin/pppd-ril" }, /* the following files have enhanced capabilities and ARE included in user builds. */ { 00750, AID_ROOT, AID_SHELL, (1 << CAP_SETUID) | (1 << CAP_SETGID), "system/bin/run-as" }, { 00750, AID_ROOT, AID_ROOT, 0, "system/bin/uncrypt" }, { 00750, AID_ROOT, AID_ROOT, 0, "system/bin/install-recovery.sh" }, { 00755, AID_ROOT, AID_SHELL, 0, "system/bin/*" }, { 00755, AID_ROOT, AID_ROOT, 0, "system/lib/valgrind/*" }, { 00755, AID_ROOT, AID_ROOT, 0, "system/lib64/valgrind/*" }, { 00755, AID_ROOT, AID_SHELL, 0, "system/xbin/*" }, { 00755, AID_ROOT, AID_SHELL, 0, "system/vendor/bin/*" }, { 00755, AID_ROOT, AID_SHELL, 0, "vendor/bin/*" }, { 00750, AID_ROOT, AID_SHELL, 0, "sbin/*" }, { 00755, AID_ROOT, AID_ROOT, 0, "bin/*" }, { 00750, AID_ROOT, AID_SHELL, 0, "init*" }, { 00750, AID_ROOT, AID_SHELL, 0, "sbin/fs_mgr" }, { 00640, AID_ROOT, AID_SHELL, 0, "fstab.*" }, { 00644, AID_ROOT, AID_ROOT, 0, 0 }, }; static inline void fs_config(const char *path, int dir, unsigned *uid, unsigned *gid, unsigned *mode, uint64_t *capabilities) { const struct fs_path_config *pc; int plen; if (path[0] == '/') { path++; } pc = dir ? android_dirs : android_files; plen = strlen(path); for(; pc->prefix; pc++){ int len = strlen(pc->prefix); if (dir) { if(plen < len) continue; if(!strncmp(pc->prefix, path, len)) break; continue; } /* If name ends in * then allow partial matches. */ if (pc->prefix[len -1] == '*') { if(!strncmp(pc->prefix, path, len - 1)) break; } else if (plen == len){ if(!strncmp(pc->prefix, path, len)) break; } } *uid = pc->uid; *gid = pc->gid; *mode = (*mode & (~07777)) | pc->mode; *capabilities = pc->capabilities; #if 0 fprintf(stderr,"< '%s' '%s' %d %d %o >\n", path, pc->prefix ? pc->prefix : "", *uid, *gid, *mode); #endif } #endif #endif android-headers-23/21/sync/000077500000000000000000000000001264465411000155325ustar00rootroot00000000000000android-headers-23/21/sync/sync.h000066400000000000000000000026551264465411000166670ustar00rootroot00000000000000/* * sync.h * * Copyright 2012 Google, Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __SYS_CORE_SYNC_H #define __SYS_CORE_SYNC_H #include #include __BEGIN_DECLS // XXX: These structs are copied from the header "linux/sync.h". struct sync_fence_info_data { uint32_t len; char name[32]; int32_t status; uint8_t pt_info[0]; }; struct sync_pt_info { uint32_t len; char obj_name[32]; char driver_name[32]; int32_t status; uint64_t timestamp_ns; uint8_t driver_data[0]; }; /* 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); void sync_fence_info_free(struct sync_fence_info_data *info); __END_DECLS #endif /* __SYS_CORE_SYNC_H */ android-headers-23/21/system/000077500000000000000000000000001264465411000161025ustar00rootroot00000000000000android-headers-23/21/system/audio.h000066400000000000000000001617761264465411000173760ustar00rootroot00000000000000/* * 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_AUDIO_CORE_H #define ANDROID_AUDIO_CORE_H #include #include #include #include #include #include __BEGIN_DECLS /* The enums were moved here mostly from * frameworks/base/include/media/AudioSystem.h */ /* 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, AUDIO_STREAM_CNT, AUDIO_STREAM_MAX = AUDIO_STREAM_CNT - 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_CNT, AUDIO_USAGE_MAX = AUDIO_USAGE_CNT - 1, } audio_usage_t; typedef uint32_t audio_flags_mask_t; /* Do not change these values without updating their counterparts * in frameworks/base/media/java/android/media/AudioAttributes.java */ enum { AUDIO_FLAG_AUDIBILITY_ENFORCED = 0x1, AUDIO_FLAG_SECURE = 0x2, AUDIO_FLAG_SCO = 0x4, AUDIO_FLAG_BEACON = 0x8, AUDIO_FLAG_HW_AV_SYNC = 0x10, AUDIO_FLAG_HW_HOTWORD = 0x20, }; /* 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_CNT, AUDIO_SOURCE_MAX = AUDIO_SOURCE_CNT - 1, 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 { audio_content_type_t content_type; audio_usage_t usage; audio_source_t source; audio_flags_mask_t flags; char tags[AUDIO_ATTRIBUTES_TAGS_MAX_SIZE]; /* UTF8 */ } audio_attributes_t; /* special audio session values * (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. */ AUDIO_SESSION_ALLOCATE = 0, } audio_session_t; /* a unique ID allocated by AudioFlinger for use as a audio_io_handle_t or audio_session_t */ typedef int audio_unique_id_t; #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 7.24 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 consists of a main format field (upper 8 bits) and a 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_MAIN_MASK = 0xFF000000UL, 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_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_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_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), // 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_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. * * audio_channel_mask_t is an opaque type and its internal layout should not * be assumed as it may change in the future. * Instead, always use the functions declared in this header to examine. * * These are the current representations: * * AUDIO_CHANNEL_REPRESENTATION_POSITION * is a channel mask representation for position assignment. * Each low-order bit corresponds to the spatial position of a transducer (output), * or interpretation of channel (input). * The user of a channel mask needs to know the context of whether it is for output or input. * The constants AUDIO_CHANNEL_OUT_* or AUDIO_CHANNEL_IN_* apply to the bits portion. * It is not permitted for no bits to be set. * * AUDIO_CHANNEL_REPRESENTATION_INDEX * is a channel mask representation for index assignment. * Each low-order bit corresponds to a selected channel. * There is no platform interpretation of the various bits. * There is no concept of output or input. * It is not permitted for no bits to be set. * * All other representations are reserved for future use. * * Warning: current representation distinguishes between input and output, but this will not the be * case in future revisions of the platform. Wherever there is an ambiguity between input and output * that is currently resolved by checking the channel mask, the implementer should look for ways to * fix it with additional information outside of the mask. */ 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 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); } /* 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) { // The right shift should be sufficient, but also "and" for safety in case mask is not 32 bits return (audio_channel_representation_t) ((channel >> AUDIO_CHANNEL_COUNT_MAX) & ((1 << AUDIO_CHANNEL_REPRESENTATION_LOG2) - 1)); } /* Returns true if the channel mask is valid, * or returns false for AUDIO_CHANNEL_NONE, AUDIO_CHANNEL_INVALID, and other invalid values. * This function is unable to determine whether a channel mask for position assignment * is invalid because an output mask has an invalid output bit set, * or because an input mask has an invalid input bit set. * All other APIs that take a channel mask assume that it is valid. */ static inline bool audio_channel_mask_is_valid(audio_channel_mask_t channel) { uint32_t bits = audio_channel_mask_get_bits(channel); audio_channel_representation_t representation = audio_channel_mask_get_representation(channel); switch (representation) { case AUDIO_CHANNEL_REPRESENTATION_POSITION: case AUDIO_CHANNEL_REPRESENTATION_INDEX: break; default: bits = 0; break; } return bits != 0; } /* Not part of public API */ static inline audio_channel_mask_t audio_channel_mask_from_representation_and_bits( audio_channel_representation_t representation, uint32_t bits) { return (audio_channel_mask_t) ((representation << AUDIO_CHANNEL_COUNT_MAX) | bits); } /* 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. */ enum { 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, AUDIO_IN_ACOUSTICS_AGC_ENABLE = 0x0001, AUDIO_IN_ACOUSTICS_AGC_DISABLE = 0, AUDIO_IN_ACOUSTICS_NS_ENABLE = 0x0002, AUDIO_IN_ACOUSTICS_NS_DISABLE = 0, AUDIO_IN_ACOUSTICS_TX_IIR_ENABLE = 0x0004, 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_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_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_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_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. */ 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_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. */ 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_flags_t; /* 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. */ typedef struct { uint16_t version; // version of the info structure uint16_t size; // total size of the structure including version and size uint32_t sample_rate; // sample rate in Hz audio_channel_mask_t channel_mask; // channel mask audio_format_t format; // audio format audio_stream_type_t stream_type; // stream type uint32_t bit_rate; // bit rate in bits per second int64_t duration_us; // duration in microseconds, -1 if unknown bool has_video; // true if stream is tied to a video stream bool is_streaming; // true if streaming, false if local playback } audio_offload_info_t; #define AUDIO_MAKE_OFFLOAD_INFO_VERSION(maj,min) \ ((((maj) & 0xff) << 8) | ((min) & 0xff)) #define AUDIO_OFFLOAD_INFO_VERSION_0_1 AUDIO_MAKE_OFFLOAD_INFO_VERSION(0, 1) #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 }; /* common audio stream configuration parameters * You should memset() the entire structure to zero before use to * ensure forward compatibility */ struct 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; }; 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 }, frame_count: 0, }; /* audio hw module handle functions or structures referencing a module */ typedef int audio_module_handle_t; /****************************** * Volume control *****************************/ /* 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; /* An audio_gain struct is a representation of a gain stage. * A gain stage is always attached to an audio port. */ struct audio_gain { audio_gain_mode_t mode; /* e.g. AUDIO_GAIN_MODE_JOINT */ audio_channel_mask_t channel_mask; /* channels which gain an be controlled. N/A if AUDIO_GAIN_MODE_CHANNELS is not supported */ int min_value; /* minimum gain value in millibels */ int max_value; /* maximum gain value in millibels */ int default_value; /* default gain value in millibels */ unsigned int step_value; /* gain step in millibels */ unsigned int min_ramp_ms; /* minimum ramp duration in ms */ unsigned int max_ramp_ms; /* maximum ramp duration in ms */ }; /* The gain configuration structure is used to get or set the gain values of a * given port */ struct audio_gain_config { int index; /* index of the corresponding audio_gain in the audio_port gains[] table */ audio_gain_mode_t mode; /* mode requested for this command */ audio_channel_mask_t channel_mask; /* channels which gain value follows. N/A in joint mode */ int values[sizeof(audio_channel_mask_t) * 8]; /* gain values in millibels for each channel ordered from LSb to MSb in channel mask. The number of values is 1 in joint mode or popcount(channel_mask) */ unsigned int ramp_duration_ms; /* ramp duration in ms */ }; /****************************** * Routing control *****************************/ /* Types defined here are used to describe an audio source or sink at internal * framework interfaces (audio policy, patch panel) or at the audio HAL. * Sink and sources are grouped in a concept of “audio port†representing an * 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 /* maximum audio device address length */ #define AUDIO_DEVICE_MAX_ADDRESS_LEN 32 /* extension for audio port configuration structure when the audio port is a * hardware device */ struct audio_port_config_device_ext { audio_module_handle_t hw_module; /* module the device is attached to */ audio_devices_t type; /* device type (e.g AUDIO_DEVICE_OUT_SPEAKER) */ char address[AUDIO_DEVICE_MAX_ADDRESS_LEN]; /* device address. "" if N/A */ }; /* extension for audio port configuration structure when the audio port is a * sub mix */ struct audio_port_config_mix_ext { audio_module_handle_t hw_module; /* module the stream is attached to */ audio_io_handle_t handle; /* I/O handle of the input/output stream */ union { //TODO: change use case for output streams: use strategy and mixer attributes audio_stream_type_t stream; audio_source_t source; } usecase; }; /* extension for audio port configuration structure when the audio port is an * audio session */ 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 { audio_port_handle_t id; /* port unique ID */ audio_port_role_t role; /* sink or source */ audio_port_type_t type; /* device, mix ... */ unsigned int config_mask; /* e.g AUDIO_PORT_CONFIG_ALL */ unsigned int sample_rate; /* sampling rate in Hz */ audio_channel_mask_t channel_mask; /* channel mask if applicable */ audio_format_t format; /* format if applicable */ struct audio_gain_config gain; /* gain to apply if applicable */ union { struct audio_port_config_device_ext device; /* device specific info */ struct audio_port_config_mix_ext mix; /* mix specific info */ struct audio_port_config_session_ext session; /* session specific info */ } ext; }; /* max number of sampling rates in audio port */ #define AUDIO_PORT_MAX_SAMPLING_RATES 16 /* max number of channel masks in audio port */ #define AUDIO_PORT_MAX_CHANNEL_MASKS 16 /* max number of audio formats in audio port */ #define AUDIO_PORT_MAX_FORMATS 16 /* max number of gain controls in audio port */ #define AUDIO_PORT_MAX_GAINS 16 /* extension for audio port structure when the audio port is a hardware device */ struct audio_port_device_ext { audio_module_handle_t hw_module; /* module the device is attached to */ audio_devices_t type; /* device type (e.g AUDIO_DEVICE_OUT_SPEAKER) */ 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 */ audio_io_handle_t handle; /* I/O handle of the input.output stream */ audio_mix_latency_class_t latency_class; /* latency class */ // other attributes: routing strategies }; /* extension for audio port structure when the audio port is an audio session */ struct audio_port_session_ext { audio_session_t session; /* audio session */ }; struct audio_port { audio_port_handle_t id; /* port unique ID */ audio_port_role_t role; /* sink or source */ audio_port_type_t type; /* device, mix ... */ unsigned int num_sample_rates; /* number of sampling rates in following array */ unsigned int sample_rates[AUDIO_PORT_MAX_SAMPLING_RATES]; unsigned int num_channel_masks; /* number of channel masks in following array */ audio_channel_mask_t channel_masks[AUDIO_PORT_MAX_CHANNEL_MASKS]; unsigned int num_formats; /* number of formats in following array */ audio_format_t formats[AUDIO_PORT_MAX_FORMATS]; unsigned int num_gains; /* number of gains in following array */ struct audio_gain gains[AUDIO_PORT_MAX_GAINS]; struct audio_port_config active_config; /* current audio port configuration */ union { struct audio_port_device_ext device; struct audio_port_mix_ext mix; struct audio_port_session_ext session; } ext; }; /* An audio patch represents a connection between one or more source ports and * one or more sink ports. Patches are connected and disconnected by audio policy manager or by * applications via framework APIs. * Each patch is identified by a handle at the interface used to create that patch. For instance, * when a patch is created by the audio HAL, the HAL allocates and returns a handle. * This handle is unique to a given audio HAL hardware module. * 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 int audio_patch_handle_t; #define AUDIO_PATCH_HANDLE_NONE 0 #define AUDIO_PATCH_PORTS_MAX 16 struct audio_patch { audio_patch_handle_t id; /* patch unique ID */ unsigned int num_sources; /* number of sources in following array */ struct audio_port_config sources[AUDIO_PATCH_PORTS_MAX]; unsigned int num_sinks; /* number of sinks in following array */ struct audio_port_config sinks[AUDIO_PATCH_PORTS_MAX]; }; /* a HW synchronization source returned by the audio HAL */ typedef uint32_t audio_hw_sync_t; /* an invalid HW synchronization source indicating an error */ #define AUDIO_HW_SYNC_INVALID 0 static inline bool audio_is_output_device(audio_devices_t device) { if (((device & AUDIO_DEVICE_BIT_IN) == 0) && (popcount(device) == 1) && ((device & ~AUDIO_DEVICE_OUT_ALL) == 0)) return true; else return false; } static inline bool audio_is_input_device(audio_devices_t device) { if ((device & AUDIO_DEVICE_BIT_IN) != 0) { device &= ~AUDIO_DEVICE_BIT_IN; if ((popcount(device) == 1) && ((device & ~AUDIO_DEVICE_IN_ALL) == 0)) return true; } return false; } static inline bool audio_is_output_devices(audio_devices_t device) { return (device & AUDIO_DEVICE_BIT_IN) == 0; } static inline bool audio_is_a2dp_in_device(audio_devices_t device) { if ((device & AUDIO_DEVICE_BIT_IN) != 0) { device &= ~AUDIO_DEVICE_BIT_IN; if ((popcount(device) == 1) && (device & AUDIO_DEVICE_IN_BLUETOOTH_A2DP)) return true; } return false; } static inline bool audio_is_a2dp_out_device(audio_devices_t device) { if ((popcount(device) == 1) && (device & AUDIO_DEVICE_OUT_ALL_A2DP)) return true; else return false; } // Deprecated - use audio_is_a2dp_out_device() instead static inline bool audio_is_a2dp_device(audio_devices_t device) { return audio_is_a2dp_out_device(device); } static inline bool audio_is_bluetooth_sco_device(audio_devices_t device) { if ((device & AUDIO_DEVICE_BIT_IN) == 0) { if ((popcount(device) == 1) && ((device & ~AUDIO_DEVICE_OUT_ALL_SCO) == 0)) return true; } else { device &= ~AUDIO_DEVICE_BIT_IN; if ((popcount(device) == 1) && ((device & ~AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET) == 0)) return true; } return false; } static inline bool audio_is_usb_out_device(audio_devices_t device) { return ((popcount(device) == 1) && (device & AUDIO_DEVICE_OUT_ALL_USB)); } static inline bool audio_is_usb_in_device(audio_devices_t device) { if ((device & AUDIO_DEVICE_BIT_IN) != 0) { device &= ~AUDIO_DEVICE_BIT_IN; if (popcount(device) == 1 && (device & AUDIO_DEVICE_IN_ALL_USB) != 0) return true; } return false; } /* OBSOLETE - use audio_is_usb_out_device() instead. */ static inline bool audio_is_usb_device(audio_devices_t device) { return audio_is_usb_out_device(device); } static inline bool audio_is_remote_submix_device(audio_devices_t device) { if ((device & AUDIO_DEVICE_OUT_REMOTE_SUBMIX) == AUDIO_DEVICE_OUT_REMOTE_SUBMIX || (device & AUDIO_DEVICE_IN_REMOTE_SUBMIX) == AUDIO_DEVICE_IN_REMOTE_SUBMIX) return true; else return false; } /* Returns true if: * representation is valid, and * there is at least one channel bit set which _could_ correspond to an input channel, and * there are no channel bits set which could _not_ correspond to an input channel. * Otherwise returns false. */ static inline bool audio_is_input_channel(audio_channel_mask_t channel) { uint32_t bits = audio_channel_mask_get_bits(channel); switch (audio_channel_mask_get_representation(channel)) { case AUDIO_CHANNEL_REPRESENTATION_POSITION: if (bits & ~AUDIO_CHANNEL_IN_ALL) { bits = 0; } // fall through case AUDIO_CHANNEL_REPRESENTATION_INDEX: return bits != 0; default: return false; } } /* Returns true if: * representation is valid, and * there is at least one channel bit set which _could_ correspond to an output channel, and * there are no channel bits set which could _not_ correspond to an output channel. * Otherwise returns false. */ static inline bool audio_is_output_channel(audio_channel_mask_t channel) { uint32_t bits = audio_channel_mask_get_bits(channel); switch (audio_channel_mask_get_representation(channel)) { case AUDIO_CHANNEL_REPRESENTATION_POSITION: if (bits & ~AUDIO_CHANNEL_OUT_ALL) { bits = 0; } // fall through case AUDIO_CHANNEL_REPRESENTATION_INDEX: return bits != 0; default: return false; } } /* Returns the number of channels from an input channel mask, * used in the context of audio input or recording. * If a channel bit is set which could _not_ correspond to an input channel, * it is excluded from the count. * Returns zero if the representation is invalid. */ static inline uint32_t audio_channel_count_from_in_mask(audio_channel_mask_t channel) { uint32_t bits = audio_channel_mask_get_bits(channel); switch (audio_channel_mask_get_representation(channel)) { case AUDIO_CHANNEL_REPRESENTATION_POSITION: // TODO: We can now merge with from_out_mask and remove anding bits &= AUDIO_CHANNEL_IN_ALL; // fall through case AUDIO_CHANNEL_REPRESENTATION_INDEX: return popcount(bits); default: return 0; } } /* Returns the number of channels from an output channel mask, * used in the context of audio output or playback. * If a channel bit is set which could _not_ correspond to an output channel, * it is excluded from the count. * Returns zero if the representation is invalid. */ static inline uint32_t audio_channel_count_from_out_mask(audio_channel_mask_t channel) { uint32_t bits = audio_channel_mask_get_bits(channel); switch (audio_channel_mask_get_representation(channel)) { case AUDIO_CHANNEL_REPRESENTATION_POSITION: // TODO: We can now merge with from_in_mask and remove anding bits &= AUDIO_CHANNEL_OUT_ALL; // fall through case AUDIO_CHANNEL_REPRESENTATION_INDEX: return popcount(bits); default: return 0; } } /* Derive an output channel mask for position assignment from a channel count. * This is to be used when the content channel mask is unknown. The 1, 2, 4, 5, 6, 7 and 8 channel * cases are mapped to the standard game/home-theater layouts, but note that 4 is mapped to quad, * and not stereo + FC + mono surround. A channel count of 3 is arbitrarily mapped to stereo + FC * for continuity with stereo. * Returns the matching channel mask, * or AUDIO_CHANNEL_NONE if the channel count is zero, * or AUDIO_CHANNEL_INVALID if the channel count exceeds that of the * configurations for which a default output channel mask is defined. */ static inline audio_channel_mask_t audio_channel_out_mask_from_count(uint32_t channel_count) { uint32_t bits; switch (channel_count) { case 0: return AUDIO_CHANNEL_NONE; case 1: bits = AUDIO_CHANNEL_OUT_MONO; break; case 2: bits = AUDIO_CHANNEL_OUT_STEREO; break; case 3: bits = AUDIO_CHANNEL_OUT_STEREO | AUDIO_CHANNEL_OUT_FRONT_CENTER; break; case 4: // 4.0 bits = AUDIO_CHANNEL_OUT_QUAD; break; case 5: // 5.0 bits = AUDIO_CHANNEL_OUT_QUAD | AUDIO_CHANNEL_OUT_FRONT_CENTER; break; case 6: // 5.1 bits = AUDIO_CHANNEL_OUT_5POINT1; break; case 7: // 6.1 bits = AUDIO_CHANNEL_OUT_5POINT1 | AUDIO_CHANNEL_OUT_BACK_CENTER; break; case 8: bits = AUDIO_CHANNEL_OUT_7POINT1; break; default: return AUDIO_CHANNEL_INVALID; } return audio_channel_mask_from_representation_and_bits( AUDIO_CHANNEL_REPRESENTATION_POSITION, bits); } /* Derive an input channel mask for position assignment from a channel count. * Currently handles only mono and stereo. * Returns the matching channel mask, * or AUDIO_CHANNEL_NONE if the channel count is zero, * or AUDIO_CHANNEL_INVALID if the channel count exceeds that of the * configurations for which a default input channel mask is defined. */ static inline audio_channel_mask_t audio_channel_in_mask_from_count(uint32_t channel_count) { uint32_t bits; switch (channel_count) { case 0: return AUDIO_CHANNEL_NONE; case 1: bits = AUDIO_CHANNEL_IN_MONO; break; case 2: bits = AUDIO_CHANNEL_IN_STEREO; break; default: return AUDIO_CHANNEL_INVALID; } return audio_channel_mask_from_representation_and_bits( AUDIO_CHANNEL_REPRESENTATION_POSITION, bits); } /* Derive a channel mask for index assignment from a channel count. * Returns the matching channel mask, * or AUDIO_CHANNEL_NONE if the channel count is zero, * or AUDIO_CHANNEL_INVALID if the channel count exceeds AUDIO_CHANNEL_COUNT_MAX. */ static inline audio_channel_mask_t audio_channel_mask_for_index_assignment_from_count( uint32_t channel_count) { if (channel_count == 0) { return AUDIO_CHANNEL_NONE; } if (channel_count > AUDIO_CHANNEL_COUNT_MAX) { return AUDIO_CHANNEL_INVALID; } uint32_t bits = (1 << channel_count) - 1; return audio_channel_mask_from_representation_and_bits( AUDIO_CHANNEL_REPRESENTATION_INDEX, bits); } static inline bool audio_is_valid_format(audio_format_t format) { switch (format & AUDIO_FORMAT_MAIN_MASK) { case AUDIO_FORMAT_PCM: switch (format) { case AUDIO_FORMAT_PCM_16_BIT: case AUDIO_FORMAT_PCM_8_BIT: case AUDIO_FORMAT_PCM_32_BIT: case AUDIO_FORMAT_PCM_8_24_BIT: case AUDIO_FORMAT_PCM_FLOAT: case AUDIO_FORMAT_PCM_24_BIT_PACKED: return true; default: return false; } /* not reached */ case AUDIO_FORMAT_MP3: case AUDIO_FORMAT_AMR_NB: case AUDIO_FORMAT_AMR_WB: case AUDIO_FORMAT_AAC: case AUDIO_FORMAT_HE_AAC_V1: case AUDIO_FORMAT_HE_AAC_V2: case AUDIO_FORMAT_VORBIS: case AUDIO_FORMAT_OPUS: case AUDIO_FORMAT_AC3: case AUDIO_FORMAT_E_AC3: return true; default: return false; } } static inline bool audio_is_linear_pcm(audio_format_t format) { return ((format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_PCM); } static inline size_t audio_bytes_per_sample(audio_format_t format) { size_t size = 0; switch (format) { case AUDIO_FORMAT_PCM_32_BIT: case AUDIO_FORMAT_PCM_8_24_BIT: size = sizeof(int32_t); break; case AUDIO_FORMAT_PCM_24_BIT_PACKED: size = sizeof(uint8_t) * 3; break; case AUDIO_FORMAT_PCM_16_BIT: size = sizeof(int16_t); break; case AUDIO_FORMAT_PCM_8_BIT: size = sizeof(uint8_t); break; case AUDIO_FORMAT_PCM_FLOAT: size = sizeof(float); break; default: break; } return size; } /* converts device address to string sent to audio HAL via set_parameters */ static char *audio_device_address_to_parameter(audio_devices_t device, const char *address) { const size_t kSize = AUDIO_DEVICE_MAX_ADDRESS_LEN + sizeof("a2dp_sink_address="); char param[kSize]; if (device & AUDIO_DEVICE_OUT_ALL_A2DP) snprintf(param, kSize, "%s=%s", "a2dp_sink_address", address); else if (device & AUDIO_DEVICE_OUT_REMOTE_SUBMIX) snprintf(param, kSize, "%s=%s", "mix", address); else snprintf(param, kSize, "%s", address); return strdup(param); } __END_DECLS #endif // ANDROID_AUDIO_CORE_H android-headers-23/21/system/audio_policy.h000066400000000000000000000057431264465411000207440ustar00rootroot00000000000000/* * 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_AUDIO_POLICY_CORE_H #define ANDROID_AUDIO_POLICY_CORE_H #include #include #include #include __BEGIN_DECLS /* The enums were moved here mostly from * frameworks/base/include/media/AudioSystem.h */ /* device categories used for audio_policy->set_force_use() */ typedef enum { AUDIO_POLICY_FORCE_NONE, AUDIO_POLICY_FORCE_SPEAKER, AUDIO_POLICY_FORCE_HEADPHONES, AUDIO_POLICY_FORCE_BT_SCO, AUDIO_POLICY_FORCE_BT_A2DP, AUDIO_POLICY_FORCE_WIRED_ACCESSORY, AUDIO_POLICY_FORCE_BT_CAR_DOCK, AUDIO_POLICY_FORCE_BT_DESK_DOCK, AUDIO_POLICY_FORCE_ANALOG_DOCK, AUDIO_POLICY_FORCE_DIGITAL_DOCK, 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_CFG_CNT, AUDIO_POLICY_FORCE_CFG_MAX = AUDIO_POLICY_FORCE_CFG_CNT - 1, AUDIO_POLICY_FORCE_DEFAULT = AUDIO_POLICY_FORCE_NONE, } audio_policy_forced_cfg_t; /* usages used for audio_policy->set_force_use() */ typedef enum { AUDIO_POLICY_FORCE_FOR_COMMUNICATION, AUDIO_POLICY_FORCE_FOR_MEDIA, AUDIO_POLICY_FORCE_FOR_RECORD, AUDIO_POLICY_FORCE_FOR_DOCK, AUDIO_POLICY_FORCE_FOR_SYSTEM, AUDIO_POLICY_FORCE_FOR_HDMI_SYSTEM_AUDIO, AUDIO_POLICY_FORCE_USE_CNT, AUDIO_POLICY_FORCE_USE_MAX = AUDIO_POLICY_FORCE_USE_CNT - 1, } audio_policy_force_use_t; /* device connection states used for audio_policy->set_device_connection_state() */ typedef enum { AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE, AUDIO_POLICY_DEVICE_STATE_AVAILABLE, AUDIO_POLICY_DEVICE_STATE_CNT, AUDIO_POLICY_DEVICE_STATE_MAX = AUDIO_POLICY_DEVICE_STATE_CNT - 1, } audio_policy_dev_state_t; typedef enum { /* Used to generate a tone to notify the user of a * notification/alarm/ringtone while they are in a call. */ AUDIO_POLICY_TONE_IN_CALL_NOTIFICATION = 0, AUDIO_POLICY_TONE_CNT, AUDIO_POLICY_TONE_MAX = AUDIO_POLICY_TONE_CNT - 1, } audio_policy_tone_t; static inline bool audio_is_low_visibility(audio_stream_type_t stream) { switch (stream) { case AUDIO_STREAM_SYSTEM: case AUDIO_STREAM_NOTIFICATION: case AUDIO_STREAM_RING: return true; default: return false; } } __END_DECLS #endif // ANDROID_AUDIO_POLICY_CORE_H android-headers-23/21/system/camera.h000066400000000000000000000246121264465411000175100ustar00rootroot00000000000000/* * 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 SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H #define SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H #include #include #include #include #include #include __BEGIN_DECLS /** * A set of bit masks for specifying how the received preview frames are * handled before the previewCallback() call. * * The least significant 3 bits of an "int" value are used for this purpose: * * ..... 0 0 0 * ^ ^ ^ * | | |---------> determine whether the callback is enabled or not * | |-----------> determine whether the callback is one-shot or not * |-------------> determine whether the frame is copied out or not * * WARNING: When a frame is sent directly without copying, it is the frame * receiver's responsiblity to make sure that the frame data won't get * corrupted by subsequent preview frames filled by the camera. This flag is * recommended only when copying out data brings significant performance price * and the handling/processing of the received frame data is always faster than * the preview frame rate so that data corruption won't occur. * * For instance, * 1. 0x00 disables the callback. In this case, copy out and one shot bits * are ignored. * 2. 0x01 enables a callback without copying out the received frames. A * typical use case is the Camcorder application to avoid making costly * frame copies. * 3. 0x05 is enabling a callback with frame copied out repeatedly. A typical * use case is the Camera application. * 4. 0x07 is enabling a callback with frame copied out only once. A typical * use case is the Barcode scanner application. */ enum { CAMERA_FRAME_CALLBACK_FLAG_ENABLE_MASK = 0x01, CAMERA_FRAME_CALLBACK_FLAG_ONE_SHOT_MASK = 0x02, CAMERA_FRAME_CALLBACK_FLAG_COPY_OUT_MASK = 0x04, /** Typical use cases */ CAMERA_FRAME_CALLBACK_FLAG_NOOP = 0x00, CAMERA_FRAME_CALLBACK_FLAG_CAMCORDER = 0x01, CAMERA_FRAME_CALLBACK_FLAG_CAMERA = 0x05, CAMERA_FRAME_CALLBACK_FLAG_BARCODE_SCANNER = 0x07 }; /** msgType in notifyCallback and dataCallback functions */ enum { CAMERA_MSG_ERROR = 0x0001, // notifyCallback CAMERA_MSG_SHUTTER = 0x0002, // notifyCallback CAMERA_MSG_FOCUS = 0x0004, // notifyCallback CAMERA_MSG_ZOOM = 0x0008, // notifyCallback CAMERA_MSG_PREVIEW_FRAME = 0x0010, // dataCallback CAMERA_MSG_VIDEO_FRAME = 0x0020, // data_timestamp_callback CAMERA_MSG_POSTVIEW_FRAME = 0x0040, // dataCallback CAMERA_MSG_RAW_IMAGE = 0x0080, // dataCallback CAMERA_MSG_COMPRESSED_IMAGE = 0x0100, // dataCallback CAMERA_MSG_RAW_IMAGE_NOTIFY = 0x0200, // dataCallback // Preview frame metadata. This can be combined with // CAMERA_MSG_PREVIEW_FRAME in dataCallback. For example, the apps can // request FRAME and METADATA. Or the apps can request only FRAME or only // METADATA. CAMERA_MSG_PREVIEW_METADATA = 0x0400, // dataCallback // Notify on autofocus start and stop. This is useful in continuous // autofocus - FOCUS_MODE_CONTINUOUS_VIDEO and FOCUS_MODE_CONTINUOUS_PICTURE. CAMERA_MSG_FOCUS_MOVE = 0x0800, // notifyCallback CAMERA_MSG_ALL_MSGS = 0xFFFF }; /** cmdType in sendCommand functions */ enum { CAMERA_CMD_START_SMOOTH_ZOOM = 1, CAMERA_CMD_STOP_SMOOTH_ZOOM = 2, /** * Set the clockwise rotation of preview display (setPreviewDisplay) in * degrees. This affects the preview frames and the picture displayed after * snapshot. This method is useful for portrait mode applications. Note * that preview display of front-facing cameras is flipped horizontally * before the rotation, that is, the image is reflected along the central * vertical axis of the camera sensor. So the users can see themselves as * looking into a mirror. * * This does not affect the order of byte array of * CAMERA_MSG_PREVIEW_FRAME, CAMERA_MSG_VIDEO_FRAME, * CAMERA_MSG_POSTVIEW_FRAME, CAMERA_MSG_RAW_IMAGE, or * CAMERA_MSG_COMPRESSED_IMAGE. This is allowed to be set during preview * since API level 14. */ CAMERA_CMD_SET_DISPLAY_ORIENTATION = 3, /** * cmdType to disable/enable shutter sound. In sendCommand passing arg1 = * 0 will disable, while passing arg1 = 1 will enable the shutter sound. */ CAMERA_CMD_ENABLE_SHUTTER_SOUND = 4, /* cmdType to play recording sound */ CAMERA_CMD_PLAY_RECORDING_SOUND = 5, /** * Start the face detection. This should be called after preview is started. * The camera will notify the listener of CAMERA_MSG_FACE and the detected * faces in the preview frame. The detected faces may be the same as the * previous ones. Apps should call CAMERA_CMD_STOP_FACE_DETECTION to stop * the face detection. This method is supported if CameraParameters * KEY_MAX_NUM_HW_DETECTED_FACES or KEY_MAX_NUM_SW_DETECTED_FACES is * bigger than 0. Hardware and software face detection should not be running * at the same time. If the face detection has started, apps should not send * this again. * * In hardware face detection mode, CameraParameters KEY_WHITE_BALANCE, * KEY_FOCUS_AREAS and KEY_METERING_AREAS have no effect. * * arg1 is the face detection type. It can be CAMERA_FACE_DETECTION_HW or * CAMERA_FACE_DETECTION_SW. If the type of face detection requested is not * supported, the HAL must return BAD_VALUE. */ CAMERA_CMD_START_FACE_DETECTION = 6, /** * Stop the face detection. */ CAMERA_CMD_STOP_FACE_DETECTION = 7, /** * Enable/disable focus move callback (CAMERA_MSG_FOCUS_MOVE). Passing * arg1 = 0 will disable, while passing arg1 = 1 will enable the callback. */ CAMERA_CMD_ENABLE_FOCUS_MOVE_MSG = 8, /** * Ping camera service to see if camera hardware is released. * * When any camera method returns error, the client can use ping command * to see if the camera has been taken away by other clients. If the result * is NO_ERROR, it means the camera hardware is not released. If the result * is not NO_ERROR, the camera has been released and the existing client * can silently finish itself or show a dialog. */ CAMERA_CMD_PING = 9, /** * Configure the number of video buffers used for recording. The intended * video buffer count for recording is passed as arg1, which must be * greater than 0. This command must be sent before recording is started. * This command returns INVALID_OPERATION error if it is sent after video * recording is started, or the command is not supported at all. This * command also returns a BAD_VALUE error if the intended video buffer * count is non-positive or too big to be realized. */ CAMERA_CMD_SET_VIDEO_BUFFER_COUNT = 10, }; /** camera fatal errors */ enum { CAMERA_ERROR_UNKNOWN = 1, /** * Camera was released because another client has connected to the camera. * The original 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_RELEASED = 2, CAMERA_ERROR_SERVER_DIED = 100 }; enum { /** The facing of the camera is opposite to that of the screen. */ CAMERA_FACING_BACK = 0, /** The facing of the camera is the same as that of the screen. */ CAMERA_FACING_FRONT = 1 }; enum { /** Hardware face detection. It does not use much CPU. */ CAMERA_FACE_DETECTION_HW = 0, /** * Software face detection. It uses some CPU. Applications must use * Camera.setPreviewTexture for preview in this mode. */ CAMERA_FACE_DETECTION_SW = 1 }; /** * The information of a face from camera face detection. */ typedef struct camera_face { /** * Bounds of the face [left, top, right, bottom]. (-1000, -1000) represents * the top-left of the camera field of view, and (1000, 1000) represents the * bottom-right of the field of view. The width and height cannot be 0 or * negative. This is supported by both hardware and software face detection. * * The direction is relative to the sensor orientation, that is, what the * sensor sees. The direction is not affected by the rotation or mirroring * of CAMERA_CMD_SET_DISPLAY_ORIENTATION. */ int32_t rect[4]; /** * The confidence level of the face. The range is 1 to 100. 100 is the * highest confidence. This is supported by both hardware and software * face detection. */ int32_t score; /** * An unique id per face while the face is visible to the tracker. If * the face leaves the field-of-view and comes back, it will get a new * id. If the value is 0, id is not supported. */ int32_t id; /** * The coordinates of the center of the left eye. The range is -1000 to * 1000. -2000, -2000 if this is not supported. */ int32_t left_eye[2]; /** * The coordinates of the center of the right eye. The range is -1000 to * 1000. -2000, -2000 if this is not supported. */ int32_t right_eye[2]; /** * The coordinates of the center of the mouth. The range is -1000 to 1000. * -2000, -2000 if this is not supported. */ int32_t mouth[2]; } camera_face_t; /** * The metadata of the frame data. */ typedef struct camera_frame_metadata { /** * The number of detected faces in the frame. */ int32_t number_of_faces; /** * An array of the detected faces. The length is number_of_faces. */ camera_face_t *faces; } camera_frame_metadata_t; __END_DECLS #endif /* SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H */ android-headers-23/21/system/graphics.h000066400000000000000000000434241264465411000200620ustar00rootroot00000000000000/* * 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 SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H #define SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H #include #ifdef __cplusplus extern "C" { #endif /* * If the HAL needs to create service threads to handle graphics related * tasks, these threads need to run at HAL_PRIORITY_URGENT_DISPLAY priority * if they can block the main rendering thread in any way. * * the priority of the current thread can be set with: * * #include * setpriority(PRIO_PROCESS, 0, HAL_PRIORITY_URGENT_DISPLAY); * */ #define HAL_PRIORITY_URGENT_DISPLAY (-8) /** * pixel format definitions */ enum { /* * "linear" color pixel formats: * * The pixel formats below contain sRGB data but are otherwise treated * as linear formats, i.e.: no special operation is 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, /* * sRGB color pixel formats: * * The red, green and blue components are stored in sRGB space, and converted * to linear space when read, using the standard sRGB to linear equation: * * Clinear = Csrgb / 12.92 for Csrgb <= 0.04045 * = (Csrgb + 0.055 / 1.055)^2.4 for Csrgb > 0.04045 * * When written the inverse transformation is performed: * * Csrgb = 12.92 * Clinear for Clinear <= 0.0031308 * = 1.055 * Clinear^(1/2.4) - 0.055 for Clinear > 0.0031308 * * * The alpha component, if present, is always stored in linear space and * is left unmodified when read or written. * */ HAL_PIXEL_FORMAT_sRGB_A_8888 = 0xC, HAL_PIXEL_FORMAT_sRGB_X_8888 = 0xD, /* * 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 * */ 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 * */ 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 * */ HAL_PIXEL_FORMAT_Y16 = 0x20363159, /* * Android RAW sensor format: * * This format is exposed outside of the camera HAL to applications. * * RAW_SENSOR 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 */ HAL_PIXEL_FORMAT_RAW16 = 0x20, HAL_PIXEL_FORMAT_RAW_SENSOR = 0x20, // TODO(rubenbrunk): Remove RAW_SENSOR. /* * 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 */ HAL_PIXEL_FORMAT_RAW10 = 0x25, /* * 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 */ 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. */ 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). * */ HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED = 0x22, /* * Android flexible YCbCr formats * * This format allows platforms to use an efficient YCbCr/YCrCb buffer * layout, while still describing the buffer layout in a way accessible to * the CPU in a device-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_HW_CAMERA_WRITE and 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. */ HAL_PIXEL_FORMAT_YCbCr_420_888 = 0x23, /* 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 }; /* * Structure for describing YCbCr formats for consumption by applications. * This is used with HAL_PIXEL_FORMAT_YCbCr_*_888. * * Buffer chroma subsampling is defined in the format. * e.g. HAL_PIXEL_FORMAT_YCbCr_420_888 has subsampling 4:2:0. * * Buffers must have a 8 bit depth. * * @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. * * @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. */ struct android_ycbcr { void *y; void *cb; void *cr; size_t ystride; size_t cstride; size_t chroma_step; /** reserved for future use, set to 0 by gralloc's (*lock_ycbcr)() */ uint32_t reserved[8]; }; /** * Transformation definitions * * IMPORTANT NOTE: * HAL_TRANSFORM_ROT_90 is applied CLOCKWISE and AFTER HAL_TRANSFORM_FLIP_{H|V}. * */ enum { /* 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, }; /** * Colorspace Definitions * ====================== * * Colorspace is the definition of how pixel values should be interpreted. * It includes primaries (including white point) and the transfer * characteristic function, which describes both gamma curve and numeric * range (within the bit depth). */ enum { /* * Arbitrary colorspace with manually defined characteristics. * Colorspace definition 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_COLORSPACE_ARBITRARY = 0x1, /* * 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 * * Transfer characteristic curve: * E = 1.099 * L ^ 0.45 - 0.099, 1.00 >= L >= 0.018 * E = 4.500 L, 0.018 > L >= 0 * L - luminance of image 0 <= L <= 1 for conventional colorimetry * E - corresponding electrical signal * * Primaries: x y * green 0.290 0.600 * blue 0.150 0.060 * red 0.640 0.330 * white (D65) 0.3127 0.3290 */ HAL_COLORSPACE_JFIF = 0x101, /* * ITU-R Recommendation 601 (BT.601) - 625-line * * Standard-definition television, 625 Lines (PAL) * * 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 * * Transfer characteristic curve: * E = 1.099 * L ^ 0.45 - 0.099, 1.00 >= L >= 0.018 * E = 4.500 L, 0.018 > L >= 0 * L - luminance of image 0 <= L <= 1 for conventional colorimetry * E - corresponding electrical signal * * Primaries: x y * green 0.290 0.600 * blue 0.150 0.060 * red 0.640 0.330 * white (D65) 0.3127 0.3290 */ HAL_COLORSPACE_BT601_625 = 0x102, /* * ITU-R Recommendation 601 (BT.601) - 525-line * * Standard-definition television, 525 Lines (NTSC) * * 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 * * Transfer characteristic curve: * E = 1.099 * L ^ 0.45 - 0.099, 1.00 >= L >= 0.018 * E = 4.500 L, 0.018 > L >= 0 * L - luminance of image 0 <= L <= 1 for conventional colorimetry * E - corresponding electrical signal * * Primaries: x y * green 0.310 0.595 * blue 0.155 0.070 * red 0.630 0.340 * white (D65) 0.3127 0.3290 */ HAL_COLORSPACE_BT601_525 = 0x103, /* * ITU-R Recommendation 709 (BT.709) * * High-definition television * * 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 * * Primaries: x y * green 0.300 0.600 * blue 0.150 0.060 * red 0.640 0.330 * white (D65) 0.3127 0.3290 */ HAL_COLORSPACE_BT709 = 0x104, }; #ifdef __cplusplus } #endif #endif /* SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H */ android-headers-23/21/system/sound_trigger.h000066400000000000000000000272561264465411000211420ustar00rootroot00000000000000/* * 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_SOUND_TRIGGER_H #define ANDROID_SOUND_TRIGGER_H #include #include #define SOUND_TRIGGER_MAX_STRING_LEN 64 /* max length of strings in properties or descriptor structs */ #define SOUND_TRIGGER_MAX_LOCALE_LEN 6 /* max length of locale string. e.g en_US */ #define SOUND_TRIGGER_MAX_USERS 10 /* max number of concurrent users */ #define SOUND_TRIGGER_MAX_PHRASES 10 /* max number of concurrent phrases */ typedef enum { SOUND_TRIGGER_STATE_NO_INIT = -1, /* The sound trigger service is not initialized */ SOUND_TRIGGER_STATE_ENABLED = 0, /* The sound trigger service is enabled */ SOUND_TRIGGER_STATE_DISABLED = 1 /* The sound trigger service is disabled */ } sound_trigger_service_state_t; #define RECOGNITION_MODE_VOICE_TRIGGER 0x1 /* simple voice trigger */ #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_STATUS_SUCCESS 0 #define RECOGNITION_STATUS_ABORT 1 #define RECOGNITION_STATUS_FAILURE 2 #define SOUND_MODEL_STATUS_UPDATED 0 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_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; /* * sound trigger implementation descriptor read by the framework via get_properties(). * Used by SoundTrigger service to report to applications and manage concurrency and policy. */ struct sound_trigger_properties { char implementor[SOUND_TRIGGER_MAX_STRING_LEN]; /* implementor name */ char description[SOUND_TRIGGER_MAX_STRING_LEN]; /* implementation description */ unsigned int version; /* implementation version */ sound_trigger_uuid_t uuid; /* unique implementation ID. Must change with version each version */ unsigned int max_sound_models; /* maximum number of concurrent sound models loaded */ unsigned int max_key_phrases; /* maximum number of key phrases */ unsigned int max_users; /* maximum number of concurrent users detected */ unsigned int recognition_modes; /* all supported modes. e.g RECOGNITION_MODE_VOICE_TRIGGER */ bool capture_transition; /* supports seamless transition from detection to capture */ unsigned int max_buffer_ms; /* maximum buffering capacity in ms if capture_transition is true*/ bool concurrent_capture; /* supports capture by other use cases while detection is active */ bool trigger_in_event; /* returns the trigger capture in event */ unsigned int power_consumption_mw; /* Rated power consumption when detection is active with TDB silence/sound/speech ratio */ }; typedef int sound_trigger_module_handle_t; struct sound_trigger_module_descriptor { sound_trigger_module_handle_t handle; struct sound_trigger_properties properties; }; typedef int sound_model_handle_t; /* * Generic 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 */ struct sound_trigger_sound_model { sound_trigger_sound_model_type_t type; /* model type. e.g. SOUND_MODEL_TYPE_KEYPHRASE */ sound_trigger_uuid_t uuid; /* unique sound model ID. */ sound_trigger_uuid_t vendor_uuid; /* unique vendor ID. Identifies the engine the sound model was build for */ unsigned int data_size; /* size of opaque model data */ unsigned int data_offset; /* offset of opaque data start from head of struct (e.g sizeof struct sound_trigger_sound_model) */ }; /* key phrase descriptor */ struct sound_trigger_phrase { unsigned int id; /* keyphrase ID */ unsigned int recognition_mode; /* recognition modes supported by this key phrase */ unsigned int num_users; /* number of users in the key phrase */ unsigned int users[SOUND_TRIGGER_MAX_USERS]; /* users ids: (not uid_t but sound trigger specific IDs */ char locale[SOUND_TRIGGER_MAX_LOCALE_LEN]; /* locale - JAVA Locale style (e.g. en_US) */ char text[SOUND_TRIGGER_MAX_STRING_LEN]; /* phrase text in UTF-8 format. */ }; /* * Specialized sound model for key phrase detection. * Proprietary representation of key phrases in binary data must match information indicated * by phrases field */ struct sound_trigger_phrase_sound_model { struct sound_trigger_sound_model common; unsigned int num_phrases; /* number of key phrases in model */ struct sound_trigger_phrase phrases[SOUND_TRIGGER_MAX_PHRASES]; }; /* * Generic recognition event sent via recognition callback */ struct 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. e.g. SOUND_MODEL_TYPE_KEYPHRASE */ sound_model_handle_t model; /* loaded sound model that triggered the event */ bool capture_available; /* it is possible to capture audio from this utterance buffered by the implementation */ int capture_session; /* audio session ID. framework use */ int capture_delay_ms; /* delay in ms between end of model detection and start of audio available for capture. A negative value is possible (e.g. if key phrase is also available for capture */ int capture_preamble_ms; /* duration in ms of audio captured before the start of the trigger. 0 if none. */ bool trigger_in_data; /* the opaque data is the capture of the trigger sound */ audio_config_t audio_config; /* audio format of either the trigger in event data or to use for capture of the rest of the utterance */ unsigned int data_size; /* size of opaque event data */ unsigned int data_offset; /* offset of opaque data start from start of this struct (e.g sizeof struct sound_trigger_phrase_recognition_event) */ }; /* * Confidence level for each user in struct sound_trigger_phrase_recognition_extra */ struct sound_trigger_confidence_level { unsigned int user_id; /* user ID */ unsigned int level; /* confidence level in percent (0 - 100). - min level for recognition configuration - detected level for recognition event */ }; /* * Specialized recognition event for key phrase detection */ struct sound_trigger_phrase_recognition_extra { unsigned int id; /* keyphrase ID */ unsigned int recognition_modes; /* recognition modes used for this keyphrase */ unsigned int confidence_level; /* confidence level for mode RECOGNITION_MODE_VOICE_TRIGGER */ unsigned int num_levels; /* number of user confidence levels */ struct sound_trigger_confidence_level levels[SOUND_TRIGGER_MAX_USERS]; }; struct sound_trigger_phrase_recognition_event { struct sound_trigger_recognition_event common; unsigned int num_phrases; struct sound_trigger_phrase_recognition_extra phrase_extras[SOUND_TRIGGER_MAX_PHRASES]; }; /* * configuration for sound trigger capture session passed to start_recognition() */ struct sound_trigger_recognition_config { audio_io_handle_t capture_handle; /* IO handle that will be used for capture. N/A if capture_requested is false */ audio_devices_t capture_device; /* input device requested for detection capture */ bool capture_requested; /* capture and buffer audio for this recognition instance */ unsigned int num_phrases; /* number of key phrases recognition extras */ struct sound_trigger_phrase_recognition_extra phrases[SOUND_TRIGGER_MAX_PHRASES]; /* configuration for each key phrase */ unsigned int data_size; /* size of opaque capture configuration data */ unsigned int data_offset; /* offset of opaque data start from start of this struct (e.g sizeof struct sound_trigger_recognition_config) */ }; /* * Event sent via load sound model callback */ struct sound_trigger_model_event { int status; /* sound model status e.g. SOUND_MODEL_STATUS_UPDATED */ sound_model_handle_t model; /* loaded sound model that triggered the event */ unsigned int data_size; /* size of event data if any. Size of updated sound model if status is SOUND_MODEL_STATUS_UPDATED */ unsigned int data_offset; /* offset of data start from start of this struct (e.g sizeof struct sound_trigger_model_event) */ }; #endif // ANDROID_SOUND_TRIGGER_H android-headers-23/21/system/thread_defs.h000066400000000000000000000050631264465411000205270ustar00rootroot00000000000000/* * 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_THREAD_DEFS_H #define ANDROID_THREAD_DEFS_H #include "graphics.h" #if defined(__cplusplus) extern "C" { #endif enum { /* * *********************************************** * ** Keep in sync with android.os.Process.java ** * *********************************************** * * This maps directly to the "nice" priorities we use in Android. * A thread priority should be chosen inverse-proportionally to * the amount of work the thread is expected to do. The more work * a thread will do, the less favorable priority it should get so that * it doesn't starve the system. Threads not behaving properly might * be "punished" by the kernel. * Use the levels below when appropriate. Intermediate values are * acceptable, preferably use the {MORE|LESS}_FAVORABLE constants below. */ ANDROID_PRIORITY_LOWEST = 19, /* use for background tasks */ ANDROID_PRIORITY_BACKGROUND = 10, /* most threads run at normal priority */ ANDROID_PRIORITY_NORMAL = 0, /* threads currently running a UI that the user is interacting with */ ANDROID_PRIORITY_FOREGROUND = -2, /* the main UI thread has a slightly more favorable priority */ ANDROID_PRIORITY_DISPLAY = -4, /* ui service treads might want to run at a urgent display (uncommon) */ ANDROID_PRIORITY_URGENT_DISPLAY = HAL_PRIORITY_URGENT_DISPLAY, /* all normal audio threads */ ANDROID_PRIORITY_AUDIO = -16, /* service audio threads (uncommon) */ ANDROID_PRIORITY_URGENT_AUDIO = -19, /* should never be used in practice. regular process might not * be allowed to use this level */ ANDROID_PRIORITY_HIGHEST = -20, ANDROID_PRIORITY_DEFAULT = ANDROID_PRIORITY_NORMAL, ANDROID_PRIORITY_MORE_FAVORABLE = -1, ANDROID_PRIORITY_LESS_FAVORABLE = +1, }; #if defined(__cplusplus) } #endif #endif /* ANDROID_THREAD_DEFS_H */ android-headers-23/21/system/window.h000066400000000000000000001051541264465411000175700ustar00rootroot00000000000000/* * 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 SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H #define SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H #include #include #include #include #include #include #include #include #ifndef __UNUSED #define __UNUSED __attribute__((__unused__)) #endif #ifndef __deprecated #define __deprecated __attribute__((__deprecated__)) #endif __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; // --------------------------------------------------------------------------- /* attributes queriable with query() */ enum { NATIVE_WINDOW_WIDTH = 0, 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, /* Check whether queueBuffer operations on the ANativeWindow send the buffer * to the window compositor. The query sets the returned 'value' argument * to 1 if the ANativeWindow DOES send queued buffers directly to the window * compositor and 0 if the buffers do not go directly to the window * compositor. * * This can be used to determine whether protected buffer content should be * sent to the ANativeWindow. Note, however, that a result of 1 does NOT * indicate that queued buffers will be protected from applications or users * capturing their contents. If that behavior is desired then some other * mechanism (e.g. the GRALLOC_USAGE_PROTECTED flag) should be used in * conjunction with this query. */ NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER = 4, /* Get the concrete type of a ANativeWindow. See below for the list of * possible return values. * * This query should not be used outside the Android framework and will * likely be removed in the near future. */ NATIVE_WINDOW_CONCRETE_TYPE = 5, /* * Default width and height of ANativeWindow buffers, these are the * dimensions of the window buffers irrespective of the * 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, /* * 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, /* * Boolean that indicates whether the consumer is running more than * one buffer behind the producer. */ NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND = 9, /* * 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, /** * Transformation that will by applied to buffers by the hwcomposer. * This must not be set or checked by producer endpoints, and will * disable the transform hint set in SurfaceFlinger (see * NATIVE_WINDOW_TRANSFORM_HINT). * * INTENDED USE: * Temporary - Please do not use this. This is intended only to be used * by the camera's LEGACY mode. * * In situations where a SurfaceFlinger client wishes to set a transform * that is not visible to the producer, and will always be applied in the * hardware composer, the client can set this flag with * native_window_set_buffers_sticky_transform. This can be used to rotate * and flip buffers consumed by hardware composer without actually changing * the aspect ratio of the buffers produced. */ NATIVE_WINDOW_STICKY_TRANSFORM = 11, }; /* Valid operations for the (*perform)() hook. * * Values marked as 'deprecated' are supported, but have been superceded by * other functionality. * * Values marked as 'private' should be considered private to the framework. * HAL implementation code with access to an ANativeWindow should not use these, * as it may not interact properly with the framework's use of the * 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, }; /* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */ enum { /* Buffers will be queued by EGL via eglSwapBuffers after being filled using * OpenGL ES. */ NATIVE_WINDOW_API_EGL = 1, /* Buffers will be queued after being filled using the CPU */ NATIVE_WINDOW_API_CPU = 2, /* Buffers will be queued by Stagefright after being filled by a video * decoder. The video decoder can either be a software or hardware decoder. */ NATIVE_WINDOW_API_MEDIA = 3, /* Buffers will be queued by the the camera HAL. */ NATIVE_WINDOW_API_CAMERA = 4, }; /* parameter for NATIVE_WINDOW_SET_BUFFERS_TRANSFORM */ enum { /* flip source image horizontally */ NATIVE_WINDOW_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H , /* flip source image vertically */ NATIVE_WINDOW_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V, /* rotate source image 90 degrees clock-wise, and is applied after TRANSFORM_FLIP_{H|V} */ NATIVE_WINDOW_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90, /* rotate source image 180 degrees */ NATIVE_WINDOW_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180, /* rotate source image 270 degrees clock-wise */ NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270, /* transforms source by the inverse transform of the screen it is displayed onto. This * transform is applied last */ NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY = 0x08 }; /* parameter for NATIVE_WINDOW_SET_SCALING_MODE */ enum { /* the window content is not updated (frozen) until a buffer of * the window size is received (enqueued) */ NATIVE_WINDOW_SCALING_MODE_FREEZE = 0, /* the buffer is scaled in both dimensions to match the window size */ NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW = 1, /* the buffer is scaled uniformly such that the smaller dimension * of the buffer matches the window size (cropping in the process) */ NATIVE_WINDOW_SCALING_MODE_SCALE_CROP = 2, /* the window is clipped to the size of the buffer's crop rectangle; pixels * outside the crop rectangle are treated as if they are completely * transparent. */ NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP = 3, }; /* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */ enum { NATIVE_WINDOW_FRAMEBUFFER = 0, /* FramebufferNativeWindow */ NATIVE_WINDOW_SURFACE = 1, /* Surface */ }; /* parameter for NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP * * Special timestamp value to indicate that timestamps should be auto-generated * by the native window when queueBuffer is called. This is equal to INT64_MIN, * defined directly to avoid problems with C99/C++ inclusion of stdint.h. */ static const int64_t NATIVE_WINDOW_TIMESTAMP_AUTO = (-9223372036854775807LL-1); struct ANativeWindow { #ifdef __cplusplus ANativeWindow() : flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0) { common.magic = ANDROID_NATIVE_WINDOW_MAGIC; common.version = sizeof(ANativeWindow); memset(common.reserved, 0, sizeof(common.reserved)); } /* Implement the methods that sp expects so that it can be used to automatically refcount ANativeWindow'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; /* flags describing some attributes of this surface or its updater */ const uint32_t flags; /* min swap interval supported by this updated */ const int minSwapInterval; /* max swap interval supported by this updated */ const int maxSwapInterval; /* horizontal and vertical resolution in DPI */ const float xdpi; const float ydpi; /* Some storage reserved for the OEM's driver. */ intptr_t oem[4]; /* * Set the swap interval for this surface. * * Returns 0 on success or -errno on error. */ int (*setSwapInterval)(struct ANativeWindow* window, int interval); /* * Hook called by EGL to acquire a buffer. After this call, the buffer * is not locked, so its content cannot be modified. 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. * * Returns 0 on success or -errno on error. * * XXX: This function is deprecated. It will continue to work for some * time for binary compatibility, but the new dequeueBuffer function that * outputs a fence file descriptor should be used in its place. */ int (*dequeueBuffer_DEPRECATED)(struct ANativeWindow* window, struct ANativeWindowBuffer** buffer); /* * hook called by EGL to lock a buffer. This MUST be called before modifying * the content of a buffer. The buffer must have been acquired with * dequeueBuffer first. * * Returns 0 on success or -errno on error. * * XXX: This function is deprecated. It will continue to work for some * time for binary compatibility, but it is essentially a no-op, and calls * to it should be removed. */ int (*lockBuffer_DEPRECATED)(struct ANativeWindow* window, struct ANativeWindowBuffer* buffer); /* * 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. * * Buffers MUST be queued in the same order than they were dequeued. * * Returns 0 on success or -errno on error. * * XXX: This function is deprecated. It will continue to work for some * time for binary compatibility, but the new queueBuffer function that * takes a fence file descriptor should be used in its place (pass a value * of -1 for the fence file descriptor if there is no valid one to pass). */ int (*queueBuffer_DEPRECATED)(struct ANativeWindow* window, struct ANativeWindowBuffer* buffer); /* * hook used to retrieve information about the native window. * * Returns 0 on success or -errno on error. */ int (*query)(const struct ANativeWindow* window, int what, int* value); /* * hook used to perform various operations on the surface. * (*perform)() is a generic mechanism to add functionality to * ANativeWindow while keeping backward binary compatibility. * * DO NOT CALL THIS HOOK DIRECTLY. Instead, use the helper functions * defined below. * * (*perform)() returns -ENOENT if the 'what' parameter is not supported * by the surface's implementation. * * The valid operations are: * NATIVE_WINDOW_SET_USAGE * NATIVE_WINDOW_CONNECT (deprecated) * NATIVE_WINDOW_DISCONNECT (deprecated) * NATIVE_WINDOW_SET_CROP (private) * NATIVE_WINDOW_SET_BUFFER_COUNT * NATIVE_WINDOW_SET_BUFFERS_GEOMETRY (deprecated) * NATIVE_WINDOW_SET_BUFFERS_TRANSFORM * NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP * NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS * NATIVE_WINDOW_SET_BUFFERS_FORMAT * NATIVE_WINDOW_SET_SCALING_MODE (private) * NATIVE_WINDOW_LOCK (private) * NATIVE_WINDOW_UNLOCK_AND_POST (private) * NATIVE_WINDOW_API_CONNECT (private) * NATIVE_WINDOW_API_DISCONNECT (private) * NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS (private) * NATIVE_WINDOW_SET_POST_TRANSFORM_CROP (private) * */ int (*perform)(struct ANativeWindow* window, int operation, ... ); /* * 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. * * XXX: This function is deprecated. It will continue to work for some * time for binary compatibility, but the new cancelBuffer function that * takes a fence file descriptor should be used in its place (pass a value * of -1 for the fence file descriptor if there is no valid one to pass). */ int (*cancelBuffer_DEPRECATED)(struct ANativeWindow* window, struct ANativeWindowBuffer* buffer); /* * 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 (*dequeueBuffer)(struct ANativeWindow* window, struct 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 (*queueBuffer)(struct ANativeWindow* window, struct 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 (*cancelBuffer)(struct ANativeWindow* window, struct ANativeWindowBuffer* buffer, int fenceFd); }; /* 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) * 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. * 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); } /* deprecated. Always returns 0. Don't call. */ static inline int native_window_connect( struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated; static inline int native_window_connect( struct ANativeWindow* window __UNUSED, int api __UNUSED) { return 0; } /* deprecated. Always returns 0. Don't call. */ static inline int native_window_disconnect( struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated; static inline int native_window_disconnect( struct ANativeWindow* window __UNUSED, int api __UNUSED) { return 0; } /* * native_window_set_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 * pre-transformed buffer 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_crop( struct ANativeWindow* window, android_native_rect_t const * 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. */ static inline int native_window_set_buffer_count( struct ANativeWindow* window, size_t bufferCount) { return window->perform(window, NATIVE_WINDOW_SET_BUFFER_COUNT, bufferCount); } /* * native_window_set_buffers_geometry(..., int w, int h, int format) * All buffers dequeued after this call will have the dimensions and format * specified. A successful call to this function has the same effect as calling * native_window_set_buffers_size and native_window_set_buffers_format. * * XXX: This function is deprecated. The native_window_set_buffers_dimensions * and native_window_set_buffers_format functions should be used instead. */ static inline int native_window_set_buffers_geometry( struct ANativeWindow* window, int w, int h, int format) __deprecated; static inline int native_window_set_buffers_geometry( struct ANativeWindow* window, int w, int h, int format) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY, w, h, format); } /* * native_window_set_buffers_dimensions(..., int w, int h) * 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. */ static inline int native_window_set_buffers_dimensions( struct ANativeWindow* window, int w, int h) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS, w, h); } /* * native_window_set_buffers_user_dimensions(..., int w, int h) * * Sets the user buffer size for the window, which overrides the * window's size. All buffers dequeued after this call will have the * dimensions specified unless overridden by * native_window_set_buffers_dimensions. 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, the * default buffer size will match the windows's size. * * Calling this function will reset the window crop to a NULL value, which * disables cropping of the buffers. */ static inline int native_window_set_buffers_user_dimensions( struct ANativeWindow* window, int w, int h) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS, w, h); } /* * native_window_set_buffers_format(..., int format) * All buffers dequeued after this call will have the format specified. * * If the specified format is 0, the default buffer format will be used. */ static inline int native_window_set_buffers_format( struct ANativeWindow* window, int format) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_FORMAT, format); } /* * native_window_set_buffers_transform(..., int transform) * All buffers queued after this call will be displayed transformed according * to the transform parameter specified. */ static inline int native_window_set_buffers_transform( struct ANativeWindow* window, int transform) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TRANSFORM, transform); } /* * native_window_set_buffers_sticky_transform(..., int transform) * All buffers queued after this call will be displayed transformed according * to the transform parameter specified applied on top of the regular buffer * transform. Setting this transform will disable the transform hint. * * Temporary - This is only intended to be used by the LEGACY camera mode, do * not use this for anything else. */ static inline int native_window_set_buffers_sticky_transform( struct ANativeWindow* window, int transform) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM, transform); } /* * native_window_set_buffers_timestamp(..., int64_t timestamp) * All buffers queued after this call will be associated with the timestamp * 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. */ static inline int native_window_set_buffers_timestamp( struct ANativeWindow* window, int64_t timestamp) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP, timestamp); } /* * native_window_set_scaling_mode(..., int mode) * All buffers queued after this call will be associated with the scaling mode * specified. */ static inline int native_window_set_scaling_mode( struct ANativeWindow* window, int mode) { return window->perform(window, NATIVE_WINDOW_SET_SCALING_MODE, mode); } /* * native_window_api_connect(..., int api) * connects an API to this window. only one API can be connected at a time. * Returns -EINVAL if for some reason the window cannot be connected, which * can happen if it's connected to some other API. */ static inline int native_window_api_connect( struct ANativeWindow* window, int api) { return window->perform(window, NATIVE_WINDOW_API_CONNECT, api); } /* * native_window_api_disconnect(..., int api) * disconnect the API from this window. * An error is returned if for instance the window wasn't connected in the * first place. */ static inline int native_window_api_disconnect( struct ANativeWindow* window, int api) { return window->perform(window, NATIVE_WINDOW_API_DISCONNECT, api); } /* * native_window_dequeue_buffer_and_wait(...) * Dequeue a buffer and wait on the fence associated with that buffer. The * buffer may safely be accessed immediately upon this function returning. An * error is returned if either of the dequeue or the wait operations fail. */ static inline int native_window_dequeue_buffer_and_wait(ANativeWindow *anw, struct ANativeWindowBuffer** anb) { return anw->dequeueBuffer_DEPRECATED(anw, anb); } /* * native_window_set_sideband_stream(..., native_handle_t*) * Attach a sideband buffer stream to a native window. */ static inline int native_window_set_sideband_stream( struct ANativeWindow* window, native_handle_t* sidebandHandle) { return window->perform(window, NATIVE_WINDOW_SET_SIDEBAND_STREAM, sidebandHandle); } __END_DECLS #endif /* SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H */ android-headers-23/22/000077500000000000000000000000001264465411000145575ustar00rootroot00000000000000android-headers-23/22/android-config.h000066400000000000000000000013371264465411000176170ustar00rootroot00000000000000#ifndef HYBRIS_CONFIG_H_ #define HYBRIS_CONFIG_H_ /* 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: COMMON_GLOBAL_CFLAGS += -DCAMERA_WITH_CITYID_PARAM device/samsung/smdk4412-common/BoardCommonConfig.mk: COMMON_GLOBAL_CFLAGS += -DEXYNOS4_ENHANCEMENTS This file allows those global configurations, which are not otherwise defined in the build headers, to be available in hybris builds. Typically it is generated at hardware adaptation time. The CONFIG GOES HERE line can be used by automation to modify this file. */ #include /* CONFIG GOES HERE */ #endif android-headers-23/22/android-version.h000066400000000000000000000003411264465411000200310ustar00rootroot00000000000000#ifndef ANDROID_VERSION_H_ #define ANDROID_VERSION_H_ #define ANDROID_VERSION_MAJOR 5 #define ANDROID_VERSION_MINOR 1 #define ANDROID_VERSION_PATCH 0 #define ANDROID_VERSION_PATCH2 1 #define ANDROID_VERSION_PATCH3 0 #endif android-headers-23/22/android/000077500000000000000000000000001264465411000161775ustar00rootroot00000000000000android-headers-23/22/android/log.h000066400000000000000000000101771264465411000171370ustar00rootroot00000000000000/* * 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_LOG_H #define _ANDROID_LOG_H /****************************************************************** * * IMPORTANT NOTICE: * * This file is part of Android's set of stable system headers * exposed by the Android NDK (Native Development Kit) since * platform release 1.5 * * Third-party source AND binary code relies on the definitions * here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES. * * - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES) * - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS * - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY * - 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. * * Each log message must have * - a priority * - a log tag * - some text * * The tag normally corresponds to the component that emits the log message, * and should be reasonably small. * * Log message text may be truncated to less than an implementation-specific * limit (e.g. 1023 characters max). * * 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. * * PLEASE USE LOGS WITH 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. * * - In release builds, only send log messages to account for exceptional * conditions. * * NOTE: These functions MUST be implemented by /system/lib/liblog.so */ #include #ifdef __cplusplus extern "C" { #endif /* * Android log priority values, in ascending priority order. */ 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 */ } android_LogPriority; /* * Send a simple string to the log. */ int __android_log_write(int prio, const char *tag, const char *text); /* * Send a formatted string to the log, used like printf(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))) #else __attribute__ ((format(printf, 3, 4))) #endif #else __attribute__ ((format(printf, 3, 4))) #endif #endif ; /* * A variant of __android_log_print() that takes a va_list to list * additional parameters. */ int __android_log_vprint(int prio, const char *tag, const char *fmt, va_list ap); /* * 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. */ void __android_log_assert(const char *cond, const char *tag, const char *fmt, ...) #if defined(__GNUC__) __attribute__ ((noreturn)) #ifdef __USE_MINGW_ANSI_STDIO #if __USE_MINGW_ANSI_STDIO __attribute__ ((format(gnu_printf, 3, 4))) #else __attribute__ ((format(printf, 3, 4))) #endif #else __attribute__ ((format(printf, 3, 4))) #endif #endif ; #ifdef __cplusplus } #endif #endif /* _ANDROID_LOG_H */ android-headers-23/22/cutils/000077500000000000000000000000001264465411000160625ustar00rootroot00000000000000android-headers-23/22/cutils/android_reboot.h000066400000000000000000000017551264465411000212350ustar00rootroot00000000000000/* * Copyright 2011, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __CUTILS_ANDROID_REBOOT_H__ #define __CUTILS_ANDROID_REBOOT_H__ __BEGIN_DECLS /* Commands */ #define ANDROID_RB_RESTART 0xDEAD0001 #define ANDROID_RB_POWEROFF 0xDEAD0002 #define ANDROID_RB_RESTART2 0xDEAD0003 /* Properties */ #define ANDROID_RB_PROPERTY "sys.powerctl" int android_reboot(int cmd, int flags, char *arg); __END_DECLS #endif /* __CUTILS_ANDROID_REBOOT_H__ */ android-headers-23/22/cutils/aref.h000066400000000000000000000025641264465411000171570ustar00rootroot00000000000000/* * 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_ android-headers-23/22/cutils/ashmem.h000066400000000000000000000021411264465411000175030ustar00rootroot00000000000000/* cutils/ashmem.h ** ** Copyright 2008 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 _CUTILS_ASHMEM_H #define _CUTILS_ASHMEM_H #include #ifdef __cplusplus extern "C" { #endif 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); int ashmem_unpin_region(int fd, size_t offset, size_t len); int ashmem_get_size_region(int fd); #ifdef __cplusplus } #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 */ android-headers-23/22/cutils/atomic-arm.h000066400000000000000000000116641264465411000202740ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/cutils/atomic-arm64.h000066400000000000000000000107341264465411000204430ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/cutils/atomic-inline.h000066400000000000000000000037721264465411000207740ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/cutils/atomic-mips.h000066400000000000000000000114111264465411000204530ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/cutils/atomic-mips64.h000066400000000000000000000112071264465411000206300ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/cutils/atomic-x86.h000066400000000000000000000075551264465411000201460ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/cutils/atomic-x86_64.h000066400000000000000000000107441264465411000204510ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/cutils/atomic.h000066400000000000000000000141361264465411000175140ustar00rootroot00000000000000/* * 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. */ #ifndef ANDROID_CUTILS_ATOMIC_H #define ANDROID_CUTILS_ATOMIC_H #include #include #ifdef __cplusplus extern "C" { #endif /* * A handful of basic atomic operations. * THESE ARE HERE FOR LEGACY REASONS ONLY. AVOID. * * PREFERRED ALTERNATIVES: * - Use C++/C/pthread locks/mutexes whenever there is not a * convincing reason to do otherwise. Note that very clever and * complicated, but correct, lock-free code is often slower than * using locks, especially where nontrivial data structures * are involved. * - C11 stdatomic.h. * - Where supported, C++11 std::atomic . * * PLEASE STOP READING HERE UNLESS YOU ARE TRYING TO UNDERSTAND * OR UPDATE OLD CODE. * * The "acquire" and "release" terms can be defined intuitively in terms * of the placement of memory barriers in a simple lock implementation: * - wait until compare-and-swap(lock-is-free --> lock-is-held) succeeds * - barrier * - [do work] * - barrier * - store(lock-is-free) * In very crude terms, the initial (acquire) barrier prevents any of the * "work" from happening before the lock is held, and the later (release) * barrier ensures that all of the work happens before the lock is released. * (Think of cached writes, cache read-ahead, and instruction reordering * around the CAS and store instructions.) * * The barriers must apply to both the compiler and the CPU. Note it is * legal for instructions that occur before an "acquire" barrier to be * moved down below it, and for instructions that occur after a "release" * barrier to be moved up above it. * * The ARM-driven implementation we use here is short on subtlety, * and actually requests a full barrier from the compiler and the CPU. * The only difference between acquire and release is in whether they * are issued before or after the atomic operation with which they * are associated. To ease the transition to C/C++ atomic intrinsics, * you should not rely on this, and instead assume that only the minimal * acquire/release protection is provided. * * NOTE: all int32_t* values are expected to be aligned on 32-bit boundaries. * If they are not, atomicity is not guaranteed. */ /* * Basic arithmetic and bitwise operations. These all provide a * barrier with "release" ordering, and return the previous value. * * These have the same characteristics (e.g. what happens on overflow) * as the equivalent non-atomic C operations. */ int32_t android_atomic_inc(volatile int32_t* addr); int32_t android_atomic_dec(volatile int32_t* addr); int32_t android_atomic_add(int32_t value, volatile int32_t* addr); int32_t android_atomic_and(int32_t value, volatile int32_t* addr); int32_t android_atomic_or(int32_t value, volatile int32_t* addr); /* * Perform an atomic load with "acquire" or "release" ordering. * * Note that the notion of a "release" ordering for a load does not * really fit into the C11 or C++11 memory model. The extra ordering * is normally observable only by code using memory_order_relaxed * atomics, or data races. In the rare cases in which such ordering * is called for, use memory_order_relaxed atomics and a leading * atomic_thread_fence (typically with memory_order_acquire, * not memory_order_release!) instead. If you do not understand * this comment, you are in the vast majority, and should not be * using release loads or replacing them with anything other than * locks or default sequentially consistent atomics. * * This is only necessary if you need the memory barrier. A 32-bit read * from a 32-bit aligned address is atomic on all supported platforms. */ int32_t android_atomic_acquire_load(volatile const int32_t* addr); int32_t android_atomic_release_load(volatile const int32_t* addr); /* * Perform an atomic store with "acquire" or "release" ordering. * * Note that the notion of a "acquire" ordering for a store does not * really fit into the C11 or C++11 memory model. The extra ordering * is normally observable only by code using memory_order_relaxed * atomics, or data races. In the rare cases in which such ordering * is called for, use memory_order_relaxed atomics and a trailing * atomic_thread_fence (typically with memory_order_release, * not memory_order_acquire!) instead. * * This is only necessary if you need the memory barrier. A 32-bit write * to a 32-bit aligned address is atomic on all supported platforms. */ void android_atomic_acquire_store(int32_t value, volatile int32_t* addr); void android_atomic_release_store(int32_t value, volatile int32_t* addr); /* * Compare-and-set operation with "acquire" or "release" ordering. * * This returns zero if the new value was successfully stored, which will * only happen when *addr == oldvalue. * * (The return value is inverted from implementations on other platforms, * but matches the ARM ldrex/strex result.) * * Implementations that use the release CAS in a loop may be less efficient * than possible, because we re-issue the memory barrier on each iteration. */ int android_atomic_acquire_cas(int32_t oldvalue, int32_t newvalue, volatile int32_t* addr); int android_atomic_release_cas(int32_t oldvalue, int32_t newvalue, volatile int32_t* addr); /* * Aliases for code using an older version of this header. These are now * deprecated and should not be used. The definitions will be removed * in a future release. */ #define android_atomic_write android_atomic_release_store #define android_atomic_cmpxchg android_atomic_release_cas #ifdef __cplusplus } // extern "C" #endif #endif // ANDROID_CUTILS_ATOMIC_H android-headers-23/22/cutils/bitops.h000066400000000000000000000057341264465411000175440ustar00rootroot00000000000000/* * 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 __CUTILS_BITOPS_H #define __CUTILS_BITOPS_H #include #include #include #include __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) { return __builtin_popcount(x); } static inline int popcountl(unsigned long x) { return __builtin_popcountl(x); } static inline int popcountll(unsigned long long x) { return __builtin_popcountll(x); } __END_DECLS #endif /* __CUTILS_BITOPS_H */ android-headers-23/22/cutils/compiler.h000066400000000000000000000025171264465411000200520ustar00rootroot00000000000000/* * 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_COMPILER_H #define ANDROID_CUTILS_COMPILER_H /* * helps the compiler's optimizer predicting branches */ #ifdef __cplusplus # define CC_LIKELY( exp ) (__builtin_expect( !!(exp), true )) # define CC_UNLIKELY( exp ) (__builtin_expect( !!(exp), false )) #else # define CC_LIKELY( exp ) (__builtin_expect( !!(exp), 1 )) # define CC_UNLIKELY( exp ) (__builtin_expect( !!(exp), 0 )) #endif /** * exports marked symbols * * if used on a C++ class declaration, this macro must be inserted * after the "class" keyword. For instance: * * template * class ANDROID_API Singleton { } */ #define ANDROID_API __attribute__((visibility("default"))) #endif // ANDROID_CUTILS_COMPILER_H android-headers-23/22/cutils/config_utils.h000066400000000000000000000033471264465411000207270ustar00rootroot00000000000000/* * Copyright (C) 2006 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_CONFIG_UTILS_H #define __CUTILS_CONFIG_UTILS_H #ifdef __cplusplus extern "C" { #endif typedef struct cnode cnode; struct cnode { cnode *next; cnode *first_child; cnode *last_child; const char *name; const char *value; }; /* parse a text string into a config node tree */ void config_load(cnode *root, char *data); /* parse a file into a config node tree */ void config_load_file(cnode *root, const char *fn); /* create a single config node */ cnode* config_node(const char *name, const char *value); /* locate a named child of a config node */ cnode* config_find(cnode *root, const char *name); /* look up a child by name and return the boolean value */ int config_bool(cnode *root, const char *name, int _default); /* look up a child by name and return the string value */ const char* config_str(cnode *root, const char *name, const char *_default); /* add a named child to a config node (or modify it if it already exists) */ void config_set(cnode *root, const char *name, const char *value); /* free a config node tree */ void config_free(cnode *root); #ifdef __cplusplus } #endif #endif android-headers-23/22/cutils/cpu_info.h000066400000000000000000000017761264465411000200500ustar00rootroot00000000000000/* * 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. */ #ifndef __CUTILS_CPU_INFO_H #define __CUTILS_CPU_INFO_H #ifdef __cplusplus extern "C" { #endif /* 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 } #endif #endif /* __CUTILS_CPU_INFO_H */ android-headers-23/22/cutils/debugger.h000066400000000000000000000053231264465411000200220ustar00rootroot00000000000000/* * 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 #ifdef __cplusplus extern "C" { #endif #define DEBUGGER32_SOCKET_NAME "android:debuggerd" #define DEBUGGER64_SOCKET_NAME "android:debuggerd64" #if defined(__LP64__) #define DEBUGGER_SOCKET_NAME DEBUGGER64_SOCKET_NAME #else #define DEBUGGER_SOCKET_NAME DEBUGGER32_SOCKET_NAME #endif 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; typedef struct { debugger_action_t action; pid_t tid; uintptr_t abort_msg_address; int32_t original_si_code; } debugger_msg_t; #if defined(__LP64__) // For a 64 bit process to contact the 32 bit debuggerd. typedef struct { debugger_action_t action; pid_t tid; uint32_t abort_msg_address; int32_t original_si_code; } debugger32_msg_t; #endif /* 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); #ifdef __cplusplus } #endif #endif /* __CUTILS_DEBUGGER_H */ android-headers-23/22/cutils/dir_hash.h000066400000000000000000000017051264465411000200170ustar00rootroot00000000000000/* * 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. */ typedef enum { SHA_1, } HashAlgorithm; int get_file_hash(HashAlgorithm algorithm, const char *path, char *output_string, size_t max_output_string); int get_recursive_hash_manifest(HashAlgorithm algorithm, const char *directory_path, char **output_string); android-headers-23/22/cutils/fs.h000066400000000000000000000041731264465411000166500ustar00rootroot00000000000000/* * 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_FS_H #define __CUTILS_FS_H #include #include /* * TEMP_FAILURE_RETRY is defined by some, but not all, versions of * . (Alas, it is not as standard as we'd hoped!) So, if it's * not already defined, then define it here. */ #ifndef TEMP_FAILURE_RETRY /* Used to retry syscalls that can return EINTR. */ #define TEMP_FAILURE_RETRY(exp) ({ \ typeof (exp) _rc; \ do { \ _rc = (exp); \ } while (_rc == -1 && errno == EINTR); \ _rc; }) #endif #ifdef __cplusplus extern "C" { #endif /* * Ensure that directory exists with given mode and owners. */ extern int fs_prepare_dir(const char* path, mode_t mode, uid_t uid, gid_t gid); /* * Read single plaintext integer from given file, correctly handling files * partially written with fs_write_atomic_int(). */ extern int fs_read_atomic_int(const char* path, int* value); /* * Write single plaintext integer to given file, creating backup while * in progress. */ extern int fs_write_atomic_int(const char* path, int value); /* * Ensure that all directories along given path exist, creating parent * directories as needed. Validates that given path is absolute and that * it contains no relative "." or ".." paths or symlinks. Last path segment * is treated as filename and ignored, unless the path ends with "/". */ extern int fs_mkdirs(const char* path, mode_t mode); #ifdef __cplusplus } #endif #endif /* __CUTILS_FS_H */ android-headers-23/22/cutils/hashmap.h000066400000000000000000000067551264465411000176710ustar00rootroot00000000000000/* * 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. */ /** * Hash map. */ #ifndef __HASHMAP_H #define __HASHMAP_H #include #include #ifdef __cplusplus extern "C" { #endif /** A hash map. */ typedef struct Hashmap Hashmap; /** * Creates a new hash map. Returns NULL if memory allocation fails. * * @param initialCapacity number of expected entries * @param hash function which hashes keys * @param equals function which compares keys for equality */ Hashmap* hashmapCreate(size_t initialCapacity, int (*hash)(void* key), bool (*equals)(void* keyA, void* keyB)); /** * Frees the hash map. Does not free the keys or values themselves. */ void hashmapFree(Hashmap* map); /** * Hashes the memory pointed to by key with the given size. Useful for * implementing hash functions. */ int hashmapHash(void* key, size_t keySize); /** * Puts value for the given key in the map. Returns pre-existing value if * any. * * If memory allocation fails, this function returns NULL, the map's size * does not increase, and errno is set to ENOMEM. */ void* hashmapPut(Hashmap* map, void* key, void* value); /** * Gets a value from the map. Returns NULL if no entry for the given key is * found or if the value itself is NULL. */ void* hashmapGet(Hashmap* map, void* key); /** * Returns true if the map contains an entry for the given key. */ bool hashmapContainsKey(Hashmap* map, void* key); /** * Gets the value for a key. If a value is not found, this function gets a * value and creates an entry using the given callback. * * If memory allocation fails, the callback is not called, this function * returns NULL, and errno is set to ENOMEM. */ void* hashmapMemoize(Hashmap* map, void* key, void* (*initialValue)(void* key, void* context), void* context); /** * Removes an entry from the map. Returns the removed value or NULL if no * entry was present. */ void* hashmapRemove(Hashmap* map, void* key); /** * Gets the number of entries in this map. */ size_t hashmapSize(Hashmap* map); /** * Invokes the given callback on each entry in the map. Stops iterating if * the callback returns false. */ void hashmapForEach(Hashmap* map, bool (*callback)(void* key, void* value, void* context), void* context); /** * Concurrency support. */ /** * Locks the hash map so only the current thread can access it. */ void hashmapLock(Hashmap* map); /** * Unlocks the hash map so other threads can access it. */ void hashmapUnlock(Hashmap* map); /** * Key utilities. */ /** * Hashes int keys. 'key' is a pointer to int. */ int hashmapIntHash(void* key); /** * Compares two int keys for equality. */ bool hashmapIntEquals(void* keyA, void* keyB); /** * For debugging. */ /** * Gets current capacity. */ size_t hashmapCurrentCapacity(Hashmap* map); /** * Counts the number of entry collisions. */ size_t hashmapCountCollisions(Hashmap* map); #ifdef __cplusplus } #endif #endif /* __HASHMAP_H */ android-headers-23/22/cutils/iosched_policy.h000066400000000000000000000020521264465411000212270ustar00rootroot00000000000000/* * 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. */ #ifndef __CUTILS_IOSCHED_POLICY_H #define __CUTILS_IOSCHED_POLICY_H #ifdef __cplusplus extern "C" { #endif typedef enum { IoSchedClass_NONE, IoSchedClass_RT, IoSchedClass_BE, IoSchedClass_IDLE, } IoSchedClass; extern int android_set_ioprio(int pid, IoSchedClass clazz, int ioprio); extern int android_get_ioprio(int pid, IoSchedClass *clazz, int *ioprio); #ifdef __cplusplus } #endif #endif /* __CUTILS_IOSCHED_POLICY_H */ android-headers-23/22/cutils/jstring.h000066400000000000000000000026551264465411000177230ustar00rootroot00000000000000/* * Copyright (C) 2006 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_STRING16_H #define __CUTILS_STRING16_H #include #include #ifdef __cplusplus extern "C" { #endif #if __STDC_VERSION__ < 201112L && __cplusplus < 201103L typedef uint16_t char16_t; #endif // otherwise char16_t is a keyword with the right semantics extern char * strndup16to8 (const char16_t* s, size_t n); extern size_t strnlen16to8 (const char16_t* s, size_t n); extern char * strncpy16to8 (char *dest, const char16_t*s, size_t n); extern char16_t * strdup8to16 (const char* s, size_t *out_len); extern size_t strlen8to16 (const char* utf8Str); extern char16_t * strcpy8to16 (char16_t *dest, const char*s, size_t *out_len); extern char16_t * strcpylen8to16 (char16_t *dest, const char*s, int length, size_t *out_len); #ifdef __cplusplus } #endif #endif /* __CUTILS_STRING16_H */ android-headers-23/22/cutils/klog.h000066400000000000000000000032021264465411000171640ustar00rootroot00000000000000/* * 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 _CUTILS_KLOG_H_ #define _CUTILS_KLOG_H_ #include #include __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))); void klog_vwrite(int level, const char *fmt, va_list ap); __END_DECLS #define KLOG_ERROR_LEVEL 3 #define KLOG_WARNING_LEVEL 4 #define KLOG_NOTICE_LEVEL 5 #define KLOG_INFO_LEVEL 6 #define KLOG_DEBUG_LEVEL 7 #define KLOG_ERROR(tag,x...) klog_write(KLOG_ERROR_LEVEL, "<3>" tag ": " x) #define KLOG_WARNING(tag,x...) klog_write(KLOG_WARNING_LEVEL, "<4>" tag ": " x) #define KLOG_NOTICE(tag,x...) klog_write(KLOG_NOTICE_LEVEL, "<5>" tag ": " x) #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 android-headers-23/22/cutils/list.h000066400000000000000000000042561264465411000172150ustar00rootroot00000000000000/* * Copyright (C) 2008-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_LIST_H_ #define _CUTILS_LIST_H_ #include #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ struct listnode { struct listnode *next; struct listnode *prev; }; #define node_to_item(node, container, member) \ (container *) (((char*) (node)) - offsetof(container, member)) #define list_declare(name) \ struct listnode name = { \ .next = &name, \ .prev = &name, \ } #define list_for_each(node, list) \ 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) #define list_for_each_safe(node, n, list) \ for (node = (list)->next, n = node->next; \ node != (list); \ node = n, n = node->next) static inline void list_init(struct listnode *node) { node->next = node; node->prev = node; } static inline void list_add_tail(struct listnode *head, struct listnode *item) { item->next = head; item->prev = head->prev; head->prev->next = item; head->prev = item; } static inline void list_add_head(struct listnode *head, struct listnode *item) { item->next = head->next; item->prev = head; head->next->prev = item; head->next = item; } static inline void list_remove(struct listnode *item) { item->next->prev = item->prev; item->prev->next = item->next; } #define list_empty(list) ((list) == (list)->next) #define list_head(list) ((list)->next) #define list_tail(list) ((list)->prev) #ifdef __cplusplus }; #endif /* __cplusplus */ #endif android-headers-23/22/cutils/log.h000066400000000000000000000000251264465411000170110ustar00rootroot00000000000000#include android-headers-23/22/cutils/memory.h000066400000000000000000000023411264465411000175430ustar00rootroot00000000000000/* * Copyright (C) 2006 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_MEMORY_H #define ANDROID_CUTILS_MEMORY_H #include #include #ifdef __cplusplus extern "C" { #endif /* size is given in bytes and must be multiple of 2 */ void android_memset16(uint16_t* dst, uint16_t value, size_t size); /* size is given in bytes and must be multiple of 4 */ void android_memset32(uint32_t* dst, uint32_t value, size_t size); #if !HAVE_STRLCPY /* Declaration of strlcpy() for platforms that don't already have it. */ size_t strlcpy(char *dst, const char *src, size_t size); #endif #ifdef __cplusplus } // extern "C" #endif #endif // ANDROID_CUTILS_MEMORY_H android-headers-23/22/cutils/misc.h000066400000000000000000000023401264465411000171650ustar00rootroot00000000000000/* * Copyright (C) 2006 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_MISC_H #define __CUTILS_MISC_H #ifdef __cplusplus extern "C" { #endif /* Load an entire file into a malloc'd chunk of memory * that is length_of_file + 1 (null terminator). If * sz is non-zero, return the size of the file via sz. * Returns 0 on failure. */ extern void *load_file(const char *fn, unsigned *sz); /* This is the range of UIDs (and GIDs) that are reserved * for assigning to applications. */ #define FIRST_APPLICATION_UID 10000 #define LAST_APPLICATION_UID 99999 #ifdef __cplusplus } #endif #endif /* __CUTILS_MISC_H */ android-headers-23/22/cutils/multiuser.h000066400000000000000000000021251264465411000202640ustar00rootroot00000000000000/* * 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_MULTIUSER_H #define __CUTILS_MULTIUSER_H #include #ifdef __cplusplus extern "C" { #endif // NOTE: keep in sync with android.os.UserId #define MULTIUSER_APP_PER_USER_RANGE 100000 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); #ifdef __cplusplus } #endif #endif /* __CUTILS_MULTIUSER_H */ android-headers-23/22/cutils/native_handle.h000066400000000000000000000035011264465411000210330ustar00rootroot00000000000000/* * 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 NATIVE_HANDLE_H_ #define NATIVE_HANDLE_H_ #ifdef __cplusplus extern "C" { #endif 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] */ int data[0]; /* numFds + numInts ints */ } native_handle_t; /* * native_handle_close * * closes the file descriptors contained in this native_handle_t * * return 0 on success, or a negative error code on failure * */ int native_handle_close(const native_handle_t* h); /* * native_handle_create * * creates a native_handle_t and initializes it. must be destroyed with * native_handle_delete(). * */ native_handle_t* native_handle_create(int numFds, int numInts); /* * native_handle_delete * * frees a native_handle_t allocated with native_handle_create(). * This ONLY frees the memory allocated for the native_handle_t, but doesn't * close the file descriptors; which can be achieved with native_handle_close(). * * return 0 on success, or a negative error code on failure * */ int native_handle_delete(native_handle_t* h); #ifdef __cplusplus } #endif #endif /* NATIVE_HANDLE_H_ */ android-headers-23/22/cutils/open_memstream.h000066400000000000000000000016471264465411000212560ustar00rootroot00000000000000/* * 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 __CUTILS_OPEN_MEMSTREAM_H__ #define __CUTILS_OPEN_MEMSTREAM_H__ #include #ifndef HAVE_OPEN_MEMSTREAM #ifdef __cplusplus extern "C" { #endif FILE* open_memstream(char** bufp, size_t* sizep); #ifdef __cplusplus } #endif #endif /*!HAVE_OPEN_MEMSTREAM*/ #endif /*__CUTILS_OPEN_MEMSTREAM_H__*/ android-headers-23/22/cutils/partition_utils.h000066400000000000000000000015271264465411000214710ustar00rootroot00000000000000/* * Copyright 2011, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __CUTILS_PARTITION_WIPED_H__ #define __CUTILS_PARTITION_WIPED_H__ __BEGIN_DECLS int partition_wiped(char *source); void erase_footer(const char *dev_path, long long size); __END_DECLS #endif /* __CUTILS_PARTITION_WIPED_H__ */ android-headers-23/22/cutils/process_name.h000066400000000000000000000020451264465411000207120ustar00rootroot00000000000000/* * 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. */ /** * Gives the current process a name. */ #ifndef __PROCESS_NAME_H #define __PROCESS_NAME_H #ifdef __cplusplus extern "C" { #endif /** * Sets the current process name. * * Warning: This leaks a string every time you call it. Use judiciously! */ void set_process_name(const char* process_name); /** Gets the current process name. */ const char* get_process_name(void); #ifdef __cplusplus } #endif #endif /* __PROCESS_NAME_H */ android-headers-23/22/cutils/properties.h000066400000000000000000000117451264465411000204370ustar00rootroot00000000000000/* * Copyright (C) 2006 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_PROPERTIES_H #define __CUTILS_PROPERTIES_H #include #include #include #include #ifdef __cplusplus extern "C" { #endif /* System properties are *small* name value pairs managed by the ** property service. If your data doesn't fit in the provided ** space it is not appropriate for a system property. ** ** WARNING: system/bionic/include/sys/system_properties.h also defines ** these, but with different names. (TODO: fix that) */ #define PROPERTY_KEY_MAX PROP_NAME_MAX #define PROPERTY_VALUE_MAX PROP_VALUE_MAX /* property_get: returns the length of the value which will never be ** greater than PROPERTY_VALUE_MAX - 1 and will always be zero terminated. ** (the length does not include the terminating zero). ** ** 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); /* property_get_bool: returns the value of key coerced into a ** boolean. If the property is not set, then the default value is returned. ** * The following is considered to be true (1): ** "1", "true", "y", "yes", "on" ** ** The following is considered to be false (0): ** "0", "false", "n", "no", "off" ** ** The conversion is whitespace-sensitive (e.g. " off" will not be false). ** ** If no property with this key is set (or the key is NULL) or the boolean ** conversion fails, the default value is returned. **/ int8_t property_get_bool(const char *key, int8_t default_value); /* property_get_int64: returns the value of key truncated and coerced into a ** int64_t. If the property is not set, then the default value is used. ** ** The numeric conversion is identical to strtoimax with the base inferred: ** - All digits up to the first non-digit characters are read ** - The longest consecutive prefix of digits is converted to a long ** ** Valid strings of digits are: ** - An optional sign character + or - ** - An optional prefix indicating the base (otherwise base 10 is assumed) ** -- 0 prefix is octal ** -- 0x / 0X prefix is hex ** ** Leading/trailing whitespace is ignored. Overflow/underflow will cause ** numeric conversion to fail. ** ** If no property with this key is set (or the key is NULL) or the numeric ** conversion fails, the default value is returned. **/ int64_t property_get_int64(const char *key, int64_t default_value); /* property_get_int32: returns the value of key truncated and coerced into an ** int32_t. If the property is not set, then the default value is used. ** ** The numeric conversion is identical to strtoimax with the base inferred: ** - All digits up to the first non-digit characters are read ** - The longest consecutive prefix of digits is converted to a long ** ** Valid strings of digits are: ** - An optional sign character + or - ** - An optional prefix indicating the base (otherwise base 10 is assumed) ** -- 0 prefix is octal ** -- 0x / 0X prefix is hex ** ** Leading/trailing whitespace is ignored. Overflow/underflow will cause ** numeric conversion to fail. ** ** If no property with this key is set (or the key is NULL) or the numeric ** conversion fails, the default value is returned. **/ 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); #if defined(__BIONIC_FORTIFY) 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"); __BIONIC_FORTIFY_INLINE int property_get(const char *key, char *value, const char *default_value) { size_t bos = __bos(value); if (bos < PROPERTY_VALUE_MAX) { __property_get_too_small_error(); } return __property_get_real(key, value, default_value); } #endif #ifdef HAVE_SYSTEM_PROPERTY_SERVER /* * We have an external property server instead of built-in libc support. * Used by the simulator. */ #define SYSTEM_PROPERTY_PIPE_NAME "/tmp/android-sysprop" enum { kSystemPropertyUnknown = 0, kSystemPropertyGet, kSystemPropertySet, kSystemPropertyList }; #endif /*HAVE_SYSTEM_PROPERTY_SERVER*/ #ifdef __cplusplus } #endif #endif android-headers-23/22/cutils/qtaguid.h000066400000000000000000000034501264465411000176730ustar00rootroot00000000000000/* * 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 __CUTILS_QTAGUID_H #define __CUTILS_QTAGUID_H #include #include #include #ifdef __cplusplus extern "C" { #endif /* * 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); /* * For the given uid, switch counter sets. * The kernel only keeps a limited number of sets. * 2 for now. */ 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 * then untagged. * The calling process can only operate on its own tags. * Unless it is part of the happy AID_NET_BW_ACCT group. * In which case it can clobber everything. */ extern int qtaguid_deleteTagData(int tag, uid_t uid); /* * Enable/disable qtaguid functionnality at a lower level. * When pacified, the kernel will accept commands but do nothing. */ extern int qtaguid_setPacifier(int on); #ifdef __cplusplus } #endif #endif /* __CUTILS_QTAG_UID_H */ android-headers-23/22/cutils/record_stream.h000066400000000000000000000022221264465411000210620ustar00rootroot00000000000000/* * Copyright (C) 2006 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. */ /* * A simple utility for reading fixed records out of a stream fd */ #ifndef _CUTILS_RECORD_STREAM_H #define _CUTILS_RECORD_STREAM_H #ifdef __cplusplus extern "C" { #endif typedef struct RecordStream RecordStream; extern RecordStream *record_stream_new(int fd, size_t maxRecordLen); extern void record_stream_free(RecordStream *p_rs); extern int record_stream_get_next (RecordStream *p_rs, void ** p_outRecord, size_t *p_outRecordLen); #ifdef __cplusplus } #endif #endif /*_CUTILS_RECORD_STREAM_H*/ android-headers-23/22/cutils/sched_policy.h000066400000000000000000000041301264465411000206760ustar00rootroot00000000000000/* * 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. */ #ifndef __CUTILS_SCHED_POLICY_H #define __CUTILS_SCHED_POLICY_H #ifdef __cplusplus extern "C" { #endif /* Keep in sync with THREAD_GROUP_* in frameworks/base/core/java/android/os/Process.java */ typedef enum { 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_CNT, SP_MAX = SP_CNT - 1, SP_SYSTEM_DEFAULT = SP_FOREGROUND, } SchedPolicy; /* Assign thread tid to the cgroup associated with the specified policy. * If the thread is a thread group leader, that is it's gettid() == getpid(), * then the other threads in the same thread group are _not_ affected. * On platforms which support gettid(), zero tid means current thread. * Return value: 0 for success, or -errno for error. */ extern int set_sched_policy(int tid, SchedPolicy policy); /* Return the policy associated with the cgroup of thread tid via policy pointer. * On platforms which support gettid(), zero tid means current thread. * Return value: 0 for success, or -1 for error and set errno. */ extern int get_sched_policy(int tid, SchedPolicy *policy); /* Return a displayable string corresponding to policy. * Return value: non-NULL NUL-terminated name of unspecified length; * the caller is responsible for displaying the useful part of the string. */ extern const char *get_sched_policy_name(SchedPolicy policy); #ifdef __cplusplus } #endif #endif /* __CUTILS_SCHED_POLICY_H */ android-headers-23/22/cutils/sockets.h000066400000000000000000000067651264465411000177240ustar00rootroot00000000000000/* * Copyright (C) 2006 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_SOCKETS_H #define __CUTILS_SOCKETS_H #include #include #include #include #ifdef HAVE_WINSOCK #include typedef int socklen_t; #elif HAVE_SYS_SOCKET_H #include #endif #define ANDROID_SOCKET_ENV_PREFIX "ANDROID_SOCKET_" #define ANDROID_SOCKET_DIR "/dev/socket" #ifdef __cplusplus extern "C" { #endif /* * 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] = ANDROID_SOCKET_ENV_PREFIX; const char *val; int fd; /* build our environment variable, counting cycles like a wolf ... */ #if HAVE_STRLCPY strlcpy(key + sizeof(ANDROID_SOCKET_ENV_PREFIX) - 1, name, sizeof(key) - sizeof(ANDROID_SOCKET_ENV_PREFIX)); #else /* for the host, which may lack the almightly strncpy ... */ strncpy(key + sizeof(ANDROID_SOCKET_ENV_PREFIX) - 1, name, sizeof(key) - sizeof(ANDROID_SOCKET_ENV_PREFIX)); key[sizeof(key)-1] = '\0'; #endif val = getenv(key); if (!val) return -1; errno = 0; fd = strtol(val, NULL, 10); if (errno) return -1; return fd; } /* * See also android.os.LocalSocketAddress.Namespace */ // Linux "abstract" (non-filesystem) namespace #define ANDROID_SOCKET_NAMESPACE_ABSTRACT 0 // Android "reserved" (/dev/socket) namespace #define ANDROID_SOCKET_NAMESPACE_RESERVED 1 // Normal filesystem namespace #define ANDROID_SOCKET_NAMESPACE_FILESYSTEM 2 extern int socket_loopback_client(int port, int type); extern int socket_network_client(const char *host, int port, int type); extern int socket_network_client_timeout(const char *host, int port, int type, int timeout); extern int socket_loopback_server(int port, int type); extern int socket_local_server(const char *name, int namespaceId, int type); extern int socket_local_server_bind(int s, const char *name, int namespaceId); extern int socket_local_client_connect(int fd, const char *name, int namespaceId, int type); extern int socket_local_client(const char *name, int namespaceId, int type); extern int socket_inaddr_any_server(int port, int type); /* * socket_peer_is_trusted - Takes a socket which is presumed to be a * connected local socket (e.g. AF_LOCAL) and returns whether the peer * (the userid that owns the process on the other end of that socket) * is one of the two trusted userids, root or shell. * * Note: This only works as advertised on the Android OS and always * just returns true when called on other operating systems. */ extern bool socket_peer_is_trusted(int fd); #ifdef __cplusplus } #endif #endif /* __CUTILS_SOCKETS_H */ android-headers-23/22/cutils/str_parms.h000066400000000000000000000041171264465411000202500ustar00rootroot00000000000000/* * 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 __CUTILS_STR_PARMS_H #define __CUTILS_STR_PARMS_H #include struct str_parms; struct str_parms *str_parms_create(void); struct str_parms *str_parms_create_str(const char *_string); void str_parms_destroy(struct str_parms *str_parms); void str_parms_del(struct str_parms *str_parms, const char *key); int str_parms_add_str(struct str_parms *str_parms, const char *key, const char *value); int str_parms_add_int(struct str_parms *str_parms, const char *key, int value); int str_parms_add_float(struct str_parms *str_parms, const char *key, float value); // Returns non-zero if the str_parms contains the specified key. int str_parms_has_key(struct str_parms *str_parms, const char *key); // Gets value associated with the specified key (if present), placing it in the buffer // pointed to by the out_val parameter. Returns the length of the returned string value. // If 'key' isn't in the parms, then return -ENOENT (-2) and leave 'out_val' untouched. int str_parms_get_str(struct str_parms *str_parms, const char *key, char *out_val, int len); int str_parms_get_int(struct str_parms *str_parms, const char *key, int *out_val); int str_parms_get_float(struct str_parms *str_parms, const char *key, float *out_val); char *str_parms_to_str(struct str_parms *str_parms); /* debug */ void str_parms_dump(struct str_parms *str_parms); #endif /* __CUTILS_STR_PARMS_H */ android-headers-23/22/cutils/threads.h000066400000000000000000000077331264465411000176770ustar00rootroot00000000000000/* * 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. */ #ifndef _LIBS_CUTILS_THREADS_H #define _LIBS_CUTILS_THREADS_H #ifdef __cplusplus extern "C" { #endif /***********************************************************************/ /***********************************************************************/ /***** *****/ /***** local thread storage *****/ /***** *****/ /***********************************************************************/ /***********************************************************************/ #ifdef HAVE_PTHREADS #include typedef struct { pthread_mutex_t lock; int has_tls; pthread_key_t tls; } thread_store_t; #define THREAD_STORE_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, 0, 0 } #elif defined HAVE_WIN32_THREADS #include typedef struct { int lock_init; int has_tls; DWORD tls; CRITICAL_SECTION lock; } thread_store_t; #define THREAD_STORE_INITIALIZER { 0, 0, 0, {0, 0, 0, 0, 0, 0} } #else # error "no thread_store_t implementation for your platform !!" #endif typedef void (*thread_store_destruct_t)(void* value); extern void* thread_store_get(thread_store_t* store); extern void thread_store_set(thread_store_t* store, void* value, thread_store_destruct_t destroy); /***********************************************************************/ /***********************************************************************/ /***** *****/ /***** mutexes *****/ /***** *****/ /***********************************************************************/ /***********************************************************************/ #ifdef HAVE_PTHREADS typedef pthread_mutex_t mutex_t; #define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER static __inline__ void mutex_lock(mutex_t* lock) { pthread_mutex_lock(lock); } static __inline__ void mutex_unlock(mutex_t* lock) { pthread_mutex_unlock(lock); } static __inline__ int mutex_init(mutex_t* lock) { return pthread_mutex_init(lock, NULL); } static __inline__ void mutex_destroy(mutex_t* lock) { pthread_mutex_destroy(lock); } #endif #ifdef HAVE_WIN32_THREADS typedef struct { int init; CRITICAL_SECTION lock[1]; } mutex_t; #define MUTEX_INITIALIZER { 0, {{ NULL, 0, 0, NULL, NULL, 0 }} } static __inline__ void mutex_lock(mutex_t* lock) { if (!lock->init) { lock->init = 1; InitializeCriticalSection( lock->lock ); lock->init = 2; } else while (lock->init != 2) Sleep(10); EnterCriticalSection(lock->lock); } static __inline__ void mutex_unlock(mutex_t* lock) { LeaveCriticalSection(lock->lock); } static __inline__ int mutex_init(mutex_t* lock) { InitializeCriticalSection(lock->lock); lock->init = 2; return 0; } static __inline__ void mutex_destroy(mutex_t* lock) { if (lock->init) { lock->init = 0; DeleteCriticalSection(lock->lock); } } #endif #ifdef __cplusplus } #endif #endif /* _LIBS_CUTILS_THREADS_H */ android-headers-23/22/cutils/trace.h000066400000000000000000000233471264465411000173420ustar00rootroot00000000000000/* * 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 _LIBS_CUTILS_TRACE_H #define _LIBS_CUTILS_TRACE_H #include #include #include #include #include #include #include #include #ifdef ANDROID_SMP #include #else #include #endif __BEGIN_DECLS /** * The ATRACE_TAG macro can be defined before including this header to trace * using one of the tags defined below. It must be defined to one of the * following ATRACE_TAG_* macros. The trace tag is used to filter tracing in * userland to avoid some of the runtime cost of tracing when it is not desired. * * Defining ATRACE_TAG to be ATRACE_TAG_ALWAYS will result in the tracing always * being enabled - this should ONLY be done for debug code, as userland tracing * has a performance cost even when the trace is not being recorded. Defining * ATRACE_TAG to be ATRACE_TAG_NEVER or leaving ATRACE_TAG undefined will result * in the tracing always being disabled. * * ATRACE_TAG_HAL should be bitwise ORed with the relevant tags for tracing * within a hardware module. For example a camera hardware module would set: * #define ATRACE_TAG (ATRACE_TAG_CAMERA | ATRACE_TAG_HAL) * * Keep these in sync with frameworks/base/core/java/android/os/Trace.java. */ #define ATRACE_TAG_NEVER 0 // This tag is never enabled. #define ATRACE_TAG_ALWAYS (1<<0) // This tag is always enabled. #define ATRACE_TAG_GRAPHICS (1<<1) #define ATRACE_TAG_INPUT (1<<2) #define ATRACE_TAG_VIEW (1<<3) #define ATRACE_TAG_WEBVIEW (1<<4) #define ATRACE_TAG_WINDOW_MANAGER (1<<5) #define ATRACE_TAG_ACTIVITY_MANAGER (1<<6) #define ATRACE_TAG_SYNC_MANAGER (1<<7) #define ATRACE_TAG_AUDIO (1<<8) #define ATRACE_TAG_VIDEO (1<<9) #define ATRACE_TAG_CAMERA (1<<10) #define ATRACE_TAG_HAL (1<<11) #define ATRACE_TAG_APP (1<<12) #define ATRACE_TAG_RESOURCES (1<<13) #define ATRACE_TAG_DALVIK (1<<14) #define ATRACE_TAG_RS (1<<15) #define ATRACE_TAG_BIONIC (1<<16) #define ATRACE_TAG_POWER (1<<17) #define ATRACE_TAG_LAST ATRACE_TAG_POWER // Reserved for initialization. #define ATRACE_TAG_NOT_READY (1LL<<63) #define ATRACE_TAG_VALID_MASK ((ATRACE_TAG_LAST - 1) | ATRACE_TAG_LAST) #ifndef ATRACE_TAG #define ATRACE_TAG ATRACE_TAG_NEVER #elif ATRACE_TAG > ATRACE_TAG_VALID_MASK #error ATRACE_TAG must be defined to be one of the tags defined in cutils/trace.h #endif #ifdef HAVE_ANDROID_OS /** * Maximum size of a message that can be logged to the trace buffer. * Note this message includes a tag, the pid, and the string given as the name. * Names should be kept short to get the most use of the trace buffer. */ #define ATRACE_MESSAGE_LENGTH 1024 /** * Opens the trace file for writing and reads the property for initial tags. * The atrace.tags.enableflags property sets the tags to trace. * This function should not be explicitly called, the first call to any normal * trace function will cause it to be run safely. */ void atrace_setup(); /** * If tracing is ready, set atrace_enabled_tags to the system property * debug.atrace.tags.enableflags. Can be used as a sysprop change callback. */ void atrace_update_tags(); /** * Set whether the process is debuggable. By default the process is not * considered debuggable. If the process is not debuggable then application- * level tracing is not allowed unless the ro.debuggable system property is * set to '1'. */ void atrace_set_debuggable(bool debuggable); /** * Set whether tracing is enabled for the current process. This is used to * prevent tracing within the Zygote process. */ void atrace_set_tracing_enabled(bool enabled); /** * Flag indicating whether setup has been completed, initialized to 0. * Nonzero indicates setup has completed. * Note: This does NOT indicate whether or not setup was successful. */ extern volatile int32_t atrace_is_ready; /** * Set of ATRACE_TAG flags to trace for, initialized to ATRACE_TAG_NOT_READY. * A value of zero indicates setup has failed. * Any other nonzero value indicates setup has succeeded, and tracing is on. */ extern uint64_t atrace_enabled_tags; /** * Handle to the kernel's trace buffer, initialized to -1. * Any other value indicates setup has succeeded, and is a valid fd for tracing. */ extern int atrace_marker_fd; /** * atrace_init readies the process for tracing by opening the trace_marker file. * Calling any trace function causes this to be run, so calling it is optional. * This can be explicitly run to avoid setup delay on first trace function. */ #define ATRACE_INIT() atrace_init() static inline void atrace_init() { if (CC_UNLIKELY(!android_atomic_acquire_load(&atrace_is_ready))) { atrace_setup(); } } /** * Get the mask of all tags currently enabled. * It can be used as a guard condition around more expensive trace calculations. * Every trace function calls this, which ensures atrace_init is run. */ #define ATRACE_GET_ENABLED_TAGS() atrace_get_enabled_tags() static inline uint64_t atrace_get_enabled_tags() { atrace_init(); return atrace_enabled_tags; } /** * Test if a given tag is currently enabled. * Returns nonzero if the tag is enabled, otherwise zero. * It can be used as a guard condition around more expensive trace calculations. */ #define ATRACE_ENABLED() atrace_is_tag_enabled(ATRACE_TAG) static inline uint64_t atrace_is_tag_enabled(uint64_t tag) { return atrace_get_enabled_tags() & tag; } /** * Trace the beginning of a context. name is used to identify the context. * This is often used to time function execution. */ #define ATRACE_BEGIN(name) atrace_begin(ATRACE_TAG, name) static inline void atrace_begin(uint64_t tag, const char* name) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { char buf[ATRACE_MESSAGE_LENGTH]; size_t len; len = snprintf(buf, ATRACE_MESSAGE_LENGTH, "B|%d|%s", getpid(), name); write(atrace_marker_fd, buf, len); } } /** * Trace the end of a context. * This should match up (and occur after) a corresponding ATRACE_BEGIN. */ #define ATRACE_END() atrace_end(ATRACE_TAG) 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); } } /** * Trace the beginning of an asynchronous event. Unlike ATRACE_BEGIN/ATRACE_END * contexts, asynchronous events do not need to be nested. The name describes * the event, and the cookie provides a unique identifier for distinguishing * simultaneous events. The name and cookie used to begin an event must be * used to end it. */ #define ATRACE_ASYNC_BEGIN(name, cookie) \ atrace_async_begin(ATRACE_TAG, name, cookie) static inline void atrace_async_begin(uint64_t tag, const char* name, int32_t cookie) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { char buf[ATRACE_MESSAGE_LENGTH]; size_t len; len = snprintf(buf, ATRACE_MESSAGE_LENGTH, "S|%d|%s|%" PRId32, getpid(), name, cookie); write(atrace_marker_fd, buf, len); } } /** * Trace the end of an asynchronous event. * This should have a corresponding ATRACE_ASYNC_BEGIN. */ #define ATRACE_ASYNC_END(name, cookie) atrace_async_end(ATRACE_TAG, name, cookie) static inline void atrace_async_end(uint64_t tag, const char* name, int32_t cookie) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { char buf[ATRACE_MESSAGE_LENGTH]; size_t len; len = snprintf(buf, ATRACE_MESSAGE_LENGTH, "F|%d|%s|%" PRId32, getpid(), name, cookie); write(atrace_marker_fd, buf, len); } } /** * Traces an integer counter value. name is used to identify the counter. * This can be used to track how a value changes over time. */ #define ATRACE_INT(name, value) atrace_int(ATRACE_TAG, name, value) static inline void atrace_int(uint64_t tag, const char* name, int32_t value) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { char buf[ATRACE_MESSAGE_LENGTH]; size_t len; len = snprintf(buf, ATRACE_MESSAGE_LENGTH, "C|%d|%s|%" PRId32, getpid(), name, value); write(atrace_marker_fd, buf, len); } } /** * Traces a 64-bit integer counter value. name is used to identify the * counter. This can be used to track how a value changes over time. */ #define ATRACE_INT64(name, value) atrace_int64(ATRACE_TAG, name, value) static inline void atrace_int64(uint64_t tag, const char* name, int64_t value) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { char buf[ATRACE_MESSAGE_LENGTH]; size_t len; len = snprintf(buf, ATRACE_MESSAGE_LENGTH, "C|%d|%s|%" PRId64, getpid(), name, value); write(atrace_marker_fd, buf, len); } } #else // not HAVE_ANDROID_OS #define ATRACE_INIT() #define ATRACE_GET_ENABLED_TAGS() #define ATRACE_ENABLED() 0 #define ATRACE_BEGIN(name) #define ATRACE_END() #define ATRACE_ASYNC_BEGIN(name, cookie) #define ATRACE_ASYNC_END(name, cookie) #define ATRACE_INT(name, value) #endif // not HAVE_ANDROID_OS __END_DECLS #endif // _LIBS_CUTILS_TRACE_H android-headers-23/22/cutils/uevent.h000066400000000000000000000020261264465411000175410ustar00rootroot00000000000000/* * 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 __CUTILS_UEVENT_H #define __CUTILS_UEVENT_H #include #include #ifdef __cplusplus extern "C" { #endif int uevent_open_socket(int buf_sz, bool passcred); ssize_t uevent_kernel_multicast_recv(int socket, void *buffer, size_t length); ssize_t uevent_kernel_multicast_uid_recv(int socket, void *buffer, size_t length, uid_t *uid); #ifdef __cplusplus } #endif #endif /* __CUTILS_UEVENT_H */ android-headers-23/22/hardware/000077500000000000000000000000001264465411000163545ustar00rootroot00000000000000android-headers-23/22/hardware/activity_recognition.h000066400000000000000000000242601264465411000227650ustar00rootroot00000000000000/* * 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. */ /* * Activity Recognition HAL. The goal is to provide low power, low latency, always-on activity * recognition implemented in hardware (i.e. these activity recognition algorithms/classifers * should NOT be run on the AP). By low power we mean that this may be activated 24/7 without * impacting the battery drain speed (goal in order of 1mW including the power for sensors). * This HAL does not specify the input sources that are used towards detecting these activities. * It has one monitor interface which can be used to batch activities for always-on * activity_recognition and if the latency is zero, the same interface can be used for low latency * detection. */ #ifndef ANDROID_ACTIVITY_RECOGNITION_INTERFACE_H #define ANDROID_ACTIVITY_RECOGNITION_INTERFACE_H #include __BEGIN_DECLS #define ACTIVITY_RECOGNITION_HEADER_VERSION 1 #define ACTIVITY_RECOGNITION_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION_2(0, 1, ACTIVITY_RECOGNITION_HEADER_VERSION) #define ACTIVITY_RECOGNITION_HARDWARE_MODULE_ID "activity_recognition" #define ACTIVITY_RECOGNITION_HARDWARE_INTERFACE "activity_recognition_hw_if" /* * Define types for various activities. Multiple activities may be active at the same time and * sometimes none of these activities may be active. * * Each activity has a corresponding type. Only activities that are defined here should use * android.activity_recognition.* prefix. OEM defined activities should not use this prefix. * Activity type of OEM-defined activities should start with the reverse domain name of the entity * defining the activity. * * When android introduces a new activity type that can potentially replace an OEM-defined activity * type, the OEM must use the official activity type on versions of the HAL that support this new * official activity type. * * Example (made up): Suppose Google's Glass team wants to detect nodding activity. * - Such an activity is not officially supported in android L * - Glass devices launching on L can implement a custom activity with * type = "com.google.glass.nodding" * - In M android release, if android decides to define ACITIVITY_TYPE_NODDING, those types * should replace the Glass-team-specific types in all future launches. * - When launching glass on the M release, Google should now use the official activity type * - This way, other applications can use this activity. */ #define ACTIVITY_TYPE_IN_VEHICLE "android.activity_recognition.in_vehicle" #define ACTIVITY_TYPE_ON_BICYCLE "android.activity_recognition.on_bicycle" #define ACTIVITY_TYPE_WALKING "android.activity_recognition.walking" #define ACTIVITY_TYPE_RUNNING "android.activity_recognition.running" #define ACTIVITY_TYPE_STILL "android.activity_recognition.still" #define ACTIVITY_TYPE_TILTING "android.activity_recognition.tilting" /* Values for activity_event.event_types. */ enum { /* * A flush_complete event which indicates that a flush() has been successfully completed. This * does not correspond to any activity/event. An event of this type should be added to the end * of a batch FIFO and it indicates that all the events in the batch FIFO have been successfully * reported to the framework. An event of this type should be generated only if flush() has been * explicitly called and if the FIFO is empty at the time flush() is called it should trivially * return a flush_complete_event to indicate that the FIFO is empty. * * A flush complete event should have the following parameters set. * activity_event_t.event_type = ACTIVITY_EVENT_FLUSH_COMPLETE * activity_event_t.activity = 0 * activity_event_t.timestamp = 0 * activity_event_t.reserved = 0 * See (*flush)() for more details. */ ACTIVITY_EVENT_FLUSH_COMPLETE = 0, /* Signifies entering an activity. */ ACTIVITY_EVENT_ENTER = 1, /* Signifies exiting an activity. */ ACTIVITY_EVENT_EXIT = 2 }; /* * Each event is a separate activity with event_type indicating whether this activity has started * or ended. Eg event: (event_type="enter", activity="ON_FOOT", timestamp) */ typedef struct activity_event { /* One of the ACTIVITY_EVENT_* constants defined above. */ uint32_t event_type; /* * Index of the activity in the list returned by get_supported_activities_list. If this event * is a flush complete event, this should be set to zero. */ uint32_t activity; /* Time at which the transition/event has occurred in nanoseconds using elapsedRealTimeNano. */ int64_t timestamp; /* Set to zero. */ int32_t reserved[4]; } activity_event_t; typedef struct activity_recognition_module { /** * Common methods of the activity recognition module. This *must* be the first member of * activity_recognition_module as users of this structure will cast a hw_module_t to * activity_recognition_module pointer in contexts where it's known the hw_module_t * references an activity_recognition_module. */ hw_module_t common; /* * List of all activities supported by this module including OEM defined activities. Each * activity is represented using a string defined above. Each string should be null terminated. * The index of the activity in this array is used as a "handle" for enabling/disabling and * event delivery. * Return value is the size of this list. */ int (*get_supported_activities_list)(struct activity_recognition_module* module, char const* const* *activity_list); } activity_recognition_module_t; struct activity_recognition_device; typedef struct activity_recognition_callback_procs { // Callback for activity_data. This is guaranteed to not invoke any HAL methods. // Memory allocated for the events can be reused after this method returns. // events - Array of activity_event_t s that are reported. // count - size of the array. void (*activity_callback)(const struct activity_recognition_callback_procs* procs, const activity_event_t* events, int count); } activity_recognition_callback_procs_t; typedef struct activity_recognition_device { /** * Common methods of the activity recognition device. This *must* be the first member of * activity_recognition_device as users of this structure will cast a hw_device_t to * activity_recognition_device pointer in contexts where it's known the hw_device_t * references an activity_recognition_device. */ hw_device_t common; /* * Sets the callback to invoke when there are events to report. This call overwrites the * previously registered callback (if any). */ void (*register_activity_callback)(const struct activity_recognition_device* dev, const activity_recognition_callback_procs_t* callback); /* * Activates monitoring of activity transitions. Activities need not be reported as soon as they * are detected. The detected activities are stored in a FIFO and reported in batches when the * "max_batch_report_latency" expires or when the batch FIFO is full. The implementation should * allow the AP to go into suspend mode while the activities are detected and stored in the * batch FIFO. Whenever events need to be reported (like when the FIFO is full or when the * max_batch_report_latency has expired for an activity, event pair), it should wake_up the AP * so that no events are lost. Activities are stored as transitions and they are allowed to * overlap with each other. Each (activity, event_type) pair can be activated or deactivated * independently of the other. The HAL implementation needs to keep track of which pairs are * currently active and needs to detect only those pairs. * * activity_handle - Index of the specific activity that needs to be detected in the list * returned by get_supported_activities_list. * event_type - Specific transition of the activity that needs to be detected. * max_batch_report_latency_ns - a transition can be delayed by at most * “max_batch_report_latency†nanoseconds. * Return 0 on success, negative errno code otherwise. */ int (*enable_activity_event)(const struct activity_recognition_device* dev, uint32_t activity_handle, uint32_t event_type, int64_t max_batch_report_latency_ns); /* * Disables detection of a specific (activity, event_type) pair. */ int (*disable_activity_event)(const struct activity_recognition_device* dev, uint32_t activity_handle, uint32_t event_type); /* * Flush all the batch FIFOs. Report all the activities that were stored in the FIFO so far as * if max_batch_report_latency had expired. This shouldn't change the latency in any way. Add * a flush_complete_event to indicate the end of the FIFO after all events are delivered. * See ACTIVITY_EVENT_FLUSH_COMPLETE for more details. * Return 0 on success, negative errno code otherwise. */ int (*flush)(const struct activity_recognition_device* dev); // Must be set to NULL. void (*reserved_procs[16 - 4])(void); } activity_recognition_device_t; static inline int activity_recognition_open(const hw_module_t* module, activity_recognition_device_t** device) { return module->methods->open(module, ACTIVITY_RECOGNITION_HARDWARE_INTERFACE, (hw_device_t**)device); } static inline int activity_recognition_close(activity_recognition_device_t* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_ACTIVITY_RECOGNITION_INTERFACE_H android-headers-23/22/hardware/audio.h000066400000000000000000000651231264465411000176350ustar00rootroot00000000000000/* * 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_AUDIO_HAL_INTERFACE_H #define ANDROID_AUDIO_HAL_INTERFACE_H #include #include #include #include #include #include #include #include __BEGIN_DECLS /** * The id of this module */ #define AUDIO_HARDWARE_MODULE_ID "audio" /** * Name of the audio devices to open */ #define AUDIO_HARDWARE_INTERFACE "audio_hw_if" /* Use version 0.1 to be compatible with first generation of audio hw module with version_major * hardcoded to 1. No audio module API change. */ #define AUDIO_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define AUDIO_MODULE_API_VERSION_CURRENT AUDIO_MODULE_API_VERSION_0_1 /* First generation of audio devices had version hardcoded to 0. all devices with versions < 1.0 * will be considered of first generation API. */ #define AUDIO_DEVICE_API_VERSION_0_0 HARDWARE_DEVICE_API_VERSION(0, 0) #define AUDIO_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) #define AUDIO_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 0) #define AUDIO_DEVICE_API_VERSION_3_0 HARDWARE_DEVICE_API_VERSION(3, 0) #define AUDIO_DEVICE_API_VERSION_CURRENT AUDIO_DEVICE_API_VERSION_3_0 /* 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" /**************************************/ /** * standard audio parameters that the HAL may need to handle */ /** * 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" #define AUDIO_PARAMETER_VALUE_TTY_VCO "tty_vco" #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 */ #define AUDIO_PARAMETER_KEY_HAC "HACSetting" #define AUDIO_PARAMETER_VALUE_HAC_ON "ON" #define AUDIO_PARAMETER_VALUE_HAC_OFF "OFF" /* A2DP sink address set by framework */ #define AUDIO_PARAMETER_A2DP_SINK_ADDRESS "a2dp_sink_address" /* 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" /* 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" /** * 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" /** * 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" /**************************************/ /* common audio stream parameters and operations */ struct audio_stream { /** * Return the sampling rate in Hz - eg. 44100. */ uint32_t (*get_sample_rate)(const struct audio_stream *stream); /* currently unused - use set_parameters with key * AUDIO_PARAMETER_STREAM_SAMPLING_RATE */ int (*set_sample_rate)(struct audio_stream *stream, uint32_t rate); /** * Return size of input/output buffer in bytes for this stream - eg. 4800. * It should be a multiple of the frame size. See also get_input_buffer_size. */ size_t (*get_buffer_size)(const struct audio_stream *stream); /** * Return the channel mask - * e.g. AUDIO_CHANNEL_OUT_STEREO or AUDIO_CHANNEL_IN_STEREO */ audio_channel_mask_t (*get_channels)(const struct audio_stream *stream); /** * Return the audio format - e.g. AUDIO_FORMAT_PCM_16_BIT */ audio_format_t (*get_format)(const struct audio_stream *stream); /* currently unused - use set_parameters with key * AUDIO_PARAMETER_STREAM_FORMAT */ int (*set_format)(struct audio_stream *stream, audio_format_t format); /** * Put the audio hardware input/output into standby mode. * Driver should exit from standby mode at the next I/O operation. * Returns 0 on success and <0 on failure. */ int (*standby)(struct audio_stream *stream); /** dump the state of the audio input/output device */ int (*dump)(const struct audio_stream *stream, int fd); /** Return the set of device(s) which this stream is connected to */ audio_devices_t (*get_device)(const struct audio_stream *stream); /** * Currently unused - set_device() corresponds to set_parameters() with key * AUDIO_PARAMETER_STREAM_ROUTING for both input and output. * AUDIO_PARAMETER_STREAM_INPUT_SOURCE is an additional information used by * input streams only. */ int (*set_device)(struct audio_stream *stream, audio_devices_t device); /** * set/get audio stream parameters. The function accepts a list of * parameter key value pairs in the form: key1=value1;key2=value2;... * * Some keys are reserved for standard parameters (See AudioParameter class) * * If the implementation does not accept a parameter change while * the output is active but the parameter is acceptable otherwise, it must * return -ENOSYS. * * The audio flinger will put the stream in standby and then change the * parameter value. */ int (*set_parameters)(struct audio_stream *stream, const char *kv_pairs); /* * Returns a pointer to a heap allocated string. The caller is responsible * for freeing the memory for it using free(). */ char * (*get_parameters)(const struct audio_stream *stream, const char *keys); int (*add_audio_effect)(const struct audio_stream *stream, effect_handle_t effect); int (*remove_audio_effect)(const struct audio_stream *stream, effect_handle_t effect); }; typedef struct audio_stream audio_stream_t; /* type of asynchronous write callback events. Mutually exclusive */ typedef enum { STREAM_CBK_EVENT_WRITE_READY, /* non blocking write completed */ STREAM_CBK_EVENT_DRAIN_READY /* drain completed */ } stream_callback_event_t; typedef int (*stream_callback_t)(stream_callback_event_t event, void *param, void *cookie); /* type of drain requested to audio_stream_out->drain(). Mutually exclusive */ typedef enum { AUDIO_DRAIN_ALL, /* drain() returns when all data has been played */ AUDIO_DRAIN_EARLY_NOTIFY /* drain() returns a short time before all data from the current track has been played to give time for gapless track switch */ } audio_drain_type_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 * as users of this structure will cast a audio_stream to audio_stream_out pointer in contexts * where it's known the audio_stream references an audio_stream_out. */ struct audio_stream common; /** * Return the audio hardware driver estimated latency in milliseconds. */ uint32_t (*get_latency)(const struct audio_stream_out *stream); /** * Use this method in situations where audio mixing is done in the * hardware. This method serves as a direct interface with hardware, * allowing you to directly set the volume as apposed to via the framework. * This method might produce multiple PCM outputs or hardware accelerated * codecs, such as MP3 or AAC. */ int (*set_volume)(struct audio_stream_out *stream, float left, float right); /** * Write audio buffer to driver. Returns number of bytes written, or a * negative status_t. If at least one frame was written successfully prior to the error, * it is suggested that the driver return that successful (short) byte count * and then return an error in the subsequent call. * * If set_callback() has previously been called to enable non-blocking mode * the write() is not allowed to block. It must write only the number of * bytes that currently fit in the driver/hardware buffer and then return * this byte count. If this is less than the requested write size the * callback function must be called when more space is available in the * driver/hardware buffer. */ ssize_t (*write)(struct audio_stream_out *stream, const void* buffer, size_t bytes); /* return the number of audio frames written by the audio dsp to DAC since * the output has exited standby */ int (*get_render_position)(const struct audio_stream_out *stream, uint32_t *dsp_frames); /** * get the local time at which the next write to the audio driver will be presented. * The units are microseconds, where the epoch is decided by the local audio HAL. */ int (*get_next_write_timestamp)(const struct audio_stream_out *stream, int64_t *timestamp); /** * set the callback function for notifying completion of non-blocking * write and drain. * Calling this function implies that all future write() and drain() * must be non-blocking and use the callback to signal completion. */ int (*set_callback)(struct audio_stream_out *stream, stream_callback_t callback, void *cookie); /** * Notifies to the audio driver to stop playback however the queued buffers are * retained by the hardware. Useful for implementing pause/resume. Empty implementation * if not supported however should be implemented for hardware with non-trivial * latency. In the pause state audio hardware could still be using power. User may * consider calling suspend after a timeout. * * Implementation of this function is mandatory for offloaded playback. */ int (*pause)(struct audio_stream_out* stream); /** * Notifies to the audio driver to resume playback following a pause. * Returns error if called without matching pause. * * Implementation of this function is mandatory for offloaded playback. */ int (*resume)(struct audio_stream_out* stream); /** * Requests notification when data buffered by the driver/hardware has * been played. If set_callback() has previously been called to enable * non-blocking mode, the drain() must not block, instead it should return * quickly and completion of the drain is notified through the callback. * If set_callback() has not been called, the drain() must block until * completion. * If type==AUDIO_DRAIN_ALL, the drain completes when all previously written * data has been played. * If type==AUDIO_DRAIN_EARLY_NOTIFY, the drain completes shortly before all * data for the current track has played to allow time for the framework * to perform a gapless track switch. * * Drain must return immediately on stop() and flush() call * * Implementation of this function is mandatory for offloaded playback. */ int (*drain)(struct audio_stream_out* stream, audio_drain_type_t type ); /** * Notifies to the audio driver to flush the queued data. Stream must already * be paused before calling flush(). * * Implementation of this function is mandatory for offloaded playback. */ int (*flush)(struct audio_stream_out* stream); /** * Return a recent count of the number of audio frames presented to an external observer. * This excludes frames which have been written but are still in the pipeline. * The count is not reset to zero when output enters standby. * Also returns the value of CLOCK_MONOTONIC as of this presentation count. * The returned count is expected to be 'recent', * but does not need to be the most recent possible value. * However, the associated time should correspond to whatever count is returned. * Example: assume that N+M frames have been presented, where M is a 'small' number. * Then it is permissible to return N instead of N+M, * and the timestamp should correspond to N rather than N+M. * The terms 'recent' and 'small' are not defined. * They reflect the quality of the implementation. * * 3.0 and higher only. */ int (*get_presentation_position)(const struct audio_stream_out *stream, uint64_t *frames, struct timespec *timestamp); }; typedef struct audio_stream_out audio_stream_out_t; struct audio_stream_in { /** * Common methods of the audio stream in. This *must* be the first member of audio_stream_in * as users of this structure will cast a audio_stream to audio_stream_in pointer in contexts * where it's known the audio_stream references an audio_stream_in. */ struct audio_stream common; /** set the input gain for the audio driver. This method is for * for future use */ int (*set_gain)(struct audio_stream_in *stream, float gain); /** Read audio buffer in from audio driver. Returns number of bytes read, or a * negative status_t. If at least one frame was read prior to the error, * read should return that byte count and then return an error in the subsequent call. */ ssize_t (*read)(struct audio_stream_in *stream, void* buffer, size_t bytes); /** * Return the amount of input frames lost in the audio driver since the * last call of this function. * Audio driver is expected to reset the value to 0 and restart counting * upon returning the current value by this function call. * Such loss typically occurs when the user space process is blocked * longer than the capacity of audio driver buffers. * * Unit: the number of input audio frames */ uint32_t (*get_input_frames_lost)(struct audio_stream_in *stream); }; typedef struct audio_stream_in audio_stream_in_t; /** * return the frame size (number of bytes per sample). * * Deprecated: use audio_stream_out_frame_size() or audio_stream_in_frame_size() instead. */ __attribute__((__deprecated__)) static inline size_t audio_stream_frame_size(const struct audio_stream *s) { size_t chan_samp_sz; audio_format_t format = s->get_format(s); if (audio_is_linear_pcm(format)) { chan_samp_sz = audio_bytes_per_sample(format); return popcount(s->get_channels(s)) * chan_samp_sz; } return sizeof(int8_t); } /** * return the frame size (number of bytes per sample) of an output stream. */ static inline size_t audio_stream_out_frame_size(const struct audio_stream_out *s) { size_t chan_samp_sz; audio_format_t format = s->common.get_format(&s->common); if (audio_is_linear_pcm(format)) { chan_samp_sz = audio_bytes_per_sample(format); return audio_channel_count_from_out_mask(s->common.get_channels(&s->common)) * chan_samp_sz; } return sizeof(int8_t); } /** * return the frame size (number of bytes per sample) of an input stream. */ static inline size_t audio_stream_in_frame_size(const struct audio_stream_in *s) { size_t chan_samp_sz; audio_format_t format = s->common.get_format(&s->common); if (audio_is_linear_pcm(format)) { chan_samp_sz = audio_bytes_per_sample(format); return audio_channel_count_from_in_mask(s->common.get_channels(&s->common)) * chan_samp_sz; } return sizeof(int8_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. */ struct audio_module { struct hw_module_t common; }; struct audio_hw_device { /** * Common methods of the audio device. This *must* be the first member of audio_hw_device * as users of this structure will cast a hw_device_t to audio_hw_device pointer in contexts * where it's known the hw_device_t references an audio_hw_device. */ struct hw_device_t common; /** * used by audio flinger to enumerate what devices are supported by * each audio_hw_device implementation. * * Return value is a bitmask of 1 or more values of audio_devices_t * * NOTE: audio HAL implementations starting with * AUDIO_DEVICE_API_VERSION_2_0 do not implement this function. * All supported devices should be listed in audio_policy.conf * file and the audio policy manager must choose the appropriate * audio module based on information in this file. */ uint32_t (*get_supported_devices)(const struct audio_hw_device *dev); /** * check to see if the audio hardware interface has been initialized. * returns 0 on success, -ENODEV on failure. */ int (*init_check)(const struct audio_hw_device *dev); /** set the audio volume of a voice call. Range is between 0.0 and 1.0 */ int (*set_voice_volume)(struct audio_hw_device *dev, float volume); /** * set the audio volume for all audio activities other than voice call. * Range between 0.0 and 1.0. If any value other than 0 is returned, * the software mixer will emulate this capability. */ int (*set_master_volume)(struct audio_hw_device *dev, float volume); /** * Get the current master volume value for the HAL, if the HAL supports * master volume control. AudioFlinger will query this value from the * primary audio HAL when the service starts and use the value for setting * the initial master volume across all HALs. HALs which do not support * this method may leave it set to NULL. */ int (*get_master_volume)(struct audio_hw_device *dev, float *volume); /** * set_mode is called when the audio mode changes. AUDIO_MODE_NORMAL mode * is for standard audio playback, AUDIO_MODE_RINGTONE when a ringtone is * playing, and AUDIO_MODE_IN_CALL when a call is in progress. */ int (*set_mode)(struct audio_hw_device *dev, audio_mode_t mode); /* mic mute */ int (*set_mic_mute)(struct audio_hw_device *dev, bool state); int (*get_mic_mute)(const struct audio_hw_device *dev, bool *state); /* set/get global audio parameters */ int (*set_parameters)(struct audio_hw_device *dev, const char *kv_pairs); /* * Returns a pointer to a heap allocated string. The caller is responsible * for freeing the memory for it using free(). */ char * (*get_parameters)(const struct audio_hw_device *dev, const char *keys); /* Returns audio input buffer size according to parameters passed or * 0 if one of the parameters is not supported. * See also get_buffer_size which is for a particular stream. */ size_t (*get_input_buffer_size)(const struct audio_hw_device *dev, const struct audio_config *config); /** This method creates and opens the audio hardware output stream. * The "address" parameter qualifies the "devices" audio device type if needed. * The format format depends on the device type: * - Bluetooth devices use the MAC address of the device in the form "00:11:22:AA:BB:CC" * - USB devices use the ALSA card and device numbers in the form "card=X;device=Y" * - Other devices may use a number or any other string. */ int (*open_output_stream)(struct audio_hw_device *dev, audio_io_handle_t handle, audio_devices_t devices, audio_output_flags_t flags, struct audio_config *config, struct audio_stream_out **stream_out, const char *address); void (*close_output_stream)(struct audio_hw_device *dev, struct audio_stream_out* stream_out); /** This method creates and opens the audio hardware input stream */ int (*open_input_stream)(struct audio_hw_device *dev, audio_io_handle_t handle, audio_devices_t devices, struct audio_config *config, struct audio_stream_in **stream_in, audio_input_flags_t flags, const char *address, audio_source_t source); void (*close_input_stream)(struct audio_hw_device *dev, struct audio_stream_in *stream_in); /** This method dumps the state of the audio hardware */ int (*dump)(const struct audio_hw_device *dev, int fd); /** * set the audio mute status for all audio activities. If any value other * than 0 is returned, the software mixer will emulate this capability. */ int (*set_master_mute)(struct audio_hw_device *dev, bool mute); /** * Get the current master mute status for the HAL, if the HAL supports * master mute control. AudioFlinger will query this value from the primary * audio HAL when the service starts and use the value for setting the * initial master mute across all HALs. HALs which do not support this * method may leave it set to NULL. */ int (*get_master_mute)(struct audio_hw_device *dev, bool *mute); /** * Routing control */ /* Creates an audio patch between several source and sink ports. * The handle is allocated by the HAL and should be unique for this * audio HAL module. */ int (*create_audio_patch)(struct audio_hw_device *dev, unsigned int num_sources, const struct audio_port_config *sources, unsigned int num_sinks, const struct audio_port_config *sinks, audio_patch_handle_t *handle); /* Release an audio patch */ int (*release_audio_patch)(struct audio_hw_device *dev, audio_patch_handle_t handle); /* Fills the list of supported attributes for a given audio port. * As input, "port" contains the information (type, role, address etc...) * needed by the HAL to identify the port. * As output, "port" contains possible attributes (sampling rates, formats, * channel masks, gain controllers...) for this port. */ int (*get_audio_port)(struct audio_hw_device *dev, struct audio_port *port); /* Set audio port configuration */ int (*set_audio_port_config)(struct audio_hw_device *dev, const struct audio_port_config *config); }; typedef struct audio_hw_device audio_hw_device_t; /** convenience API for opening and closing a supported device */ 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); } static inline int audio_hw_device_close(struct audio_hw_device* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_AUDIO_INTERFACE_H android-headers-23/22/hardware/audio_alsaops.h000066400000000000000000000061121264465411000213500ustar00rootroot00000000000000/* * 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. */ /* This file contains shared utility functions to handle the tinyalsa * implementation for Android internal audio, generally in the hardware layer. * Some routines may log a fatal error on failure, as noted. */ #ifndef ANDROID_AUDIO_ALSAOPS_H #define ANDROID_AUDIO_ALSAOPS_H #include #include #include __BEGIN_DECLS /* Converts audio_format to pcm_format. * Parameters: * format the audio_format_t to convert * * Logs a fatal error if format is not a valid convertible audio_format_t. */ static inline enum pcm_format pcm_format_from_audio_format(audio_format_t format) { switch (format) { #ifdef HAVE_BIG_ENDIAN case AUDIO_FORMAT_PCM_16_BIT: return PCM_FORMAT_S16_BE; case AUDIO_FORMAT_PCM_24_BIT_PACKED: return PCM_FORMAT_S24_3BE; case AUDIO_FORMAT_PCM_32_BIT: return PCM_FORMAT_S32_BE; case AUDIO_FORMAT_PCM_8_24_BIT: return PCM_FORMAT_S24_BE; #else case AUDIO_FORMAT_PCM_16_BIT: return PCM_FORMAT_S16_LE; case AUDIO_FORMAT_PCM_24_BIT_PACKED: return PCM_FORMAT_S24_3LE; case AUDIO_FORMAT_PCM_32_BIT: return PCM_FORMAT_S32_LE; case AUDIO_FORMAT_PCM_8_24_BIT: return PCM_FORMAT_S24_LE; #endif case AUDIO_FORMAT_PCM_FLOAT: /* there is no equivalent for float */ default: LOG_ALWAYS_FATAL("pcm_format_from_audio_format: invalid audio format %#x", format); return 0; } } /* Converts pcm_format to audio_format. * Parameters: * format the pcm_format to convert * * Logs a fatal error if format is not a valid convertible pcm_format. */ static inline audio_format_t audio_format_from_pcm_format(enum pcm_format format) { switch (format) { #ifdef HAVE_BIG_ENDIAN case PCM_FORMAT_S16_BE: return AUDIO_FORMAT_PCM_16_BIT; case PCM_FORMAT_S24_3BE: return AUDIO_FORMAT_PCM_24_BIT_PACKED; case PCM_FORMAT_S24_BE: return AUDIO_FORMAT_PCM_8_24_BIT; case PCM_FORMAT_S32_BE: return AUDIO_FORMAT_PCM_32_BIT; #else case PCM_FORMAT_S16_LE: return AUDIO_FORMAT_PCM_16_BIT; case PCM_FORMAT_S24_3LE: return AUDIO_FORMAT_PCM_24_BIT_PACKED; case PCM_FORMAT_S24_LE: return AUDIO_FORMAT_PCM_8_24_BIT; case PCM_FORMAT_S32_LE: return AUDIO_FORMAT_PCM_32_BIT; #endif default: LOG_ALWAYS_FATAL("audio_format_from_pcm_format: invalid pcm format %#x", format); return 0; } } __END_DECLS #endif /* ANDROID_AUDIO_ALSAOPS_H */ android-headers-23/22/hardware/audio_effect.h000066400000000000000000001476671264465411000211670ustar00rootroot00000000000000/* * 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_AUDIO_EFFECT_H #define ANDROID_AUDIO_EFFECT_H #include #include #include #include #include #include #include __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 // +---------------------------+-----------+----------------------------------- // 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) #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 ///////////////////////////////////////////////// // Effect control interface version 2.0 #define EFFECT_CONTROL_API_VERSION EFFECT_MAKE_API_VERSION(2,0) // Effect control interface structure: effect_interface_s // The effect control interface is exposed by each effect engine implementation. It consists of // a set of functions controlling the configuration, activation and process of the engine. // The functions are grouped in a structure of type effect_interface_s. // // Effect control interface handle: effect_handle_t // The effect_handle_t serves two purposes regarding the implementation of the effect engine: // - 1 it is the address of a pointer to an effect_interface_s structure where the functions // of the effect control API for a particular effect are located. // - 2 it is the address of the context of a particular effect instance. // A typical implementation in the effect library would define a structure as follows: // struct effect_module_s { // const struct effect_interface_s *itfe; // effect_config_t config; // effect_context_t context; // } // The implementation of EffectCreate() function would then allocate a structure of this // 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 { //////////////////////////////////////////////////////////////////////////////// // // Function: process // // Description: Effect process function. Takes input samples as specified // (count and location) in input buffer descriptor and output processed // samples as specified in output buffer descriptor. If the buffer descriptor // is not specified the function must use either the buffer or the // buffer provider function installed by the EFFECT_CMD_SET_CONFIG command. // The effect framework will call the process() function after the EFFECT_CMD_ENABLE // command is received and until the EFFECT_CMD_DISABLE is received. When the engine // receives the EFFECT_CMD_DISABLE command it should turn off the effect gracefully // and when done indicate that it is OK to stop calling the process() function by // returning the -ENODATA status. // // NOTE: the process() function implementation should be "real-time safe" that is // it should not perform blocking calls: malloc/free, sleep, read/write/open/close, // pthread_cond_wait/pthread_mutex_lock... // // Input: // self: handle to the effect interface this function // is called on. // inBuffer: buffer descriptor indicating where to read samples to process. // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG command. // // outBuffer: buffer descriptor indicating where to write processed samples. // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG command. // // Output: // returned value: 0 successful operation // -ENODATA the engine has finished the disable phase and the framework // can stop calling process() // -EINVAL invalid interface handle or // invalid input/output buffer description //////////////////////////////////////////////////////////////////////////////// int32_t (*process)(effect_handle_t self, audio_buffer_t *inBuffer, audio_buffer_t *outBuffer); //////////////////////////////////////////////////////////////////////////////// // // Function: command // // Description: Send a command and receive a response to/from effect engine. // // Input: // self: handle to the effect interface this function // is called on. // cmdCode: command code: the command can be a standardized command defined in // effect_command_e (see below) or a proprietary command. // cmdSize: size of command in bytes // pCmdData: pointer to command data // pReplyData: pointer to reply data // // Input/Output: // replySize: maximum size of reply data as input // actual size of reply data as output // // Output: // returned value: 0 successful operation // -EINVAL invalid interface handle or // invalid command/reply size or format according to command code // The return code should be restricted to indicate problems related to the this // API specification. Status related to the execution of a particular command should be // indicated as part of the reply field. // // *pReplyData updated with command response // //////////////////////////////////////////////////////////////////////////////// int32_t (*command)(effect_handle_t self, uint32_t cmdCode, uint32_t cmdSize, void *pCmdData, uint32_t *replySize, void *pReplyData); //////////////////////////////////////////////////////////////////////////////// // // Function: get_descriptor // // Description: Returns the effect descriptor // // Input: // self: handle to the effect interface this function // is called on. // // Input/Output: // pDescriptor: address where to return the effect descriptor. // // Output: // returned value: 0 successful operation. // -EINVAL invalid interface handle or invalid pDescriptor // *pDescriptor: updated with the effect descriptor. // //////////////////////////////////////////////////////////////////////////////// int32_t (*get_descriptor)(effect_handle_t self, effect_descriptor_t *pDescriptor); //////////////////////////////////////////////////////////////////////////////// // // Function: process_reverse // // Description: Process reverse stream function. This function is used to pass // a reference stream to the effect engine. If the engine does not need a reference // stream, this function pointer can be set to NULL. // This function would typically implemented by an Echo Canceler. // // Input: // self: handle to the effect interface this function // is called on. // inBuffer: buffer descriptor indicating where to read samples to process. // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG_REVERSE command. // // outBuffer: buffer descriptor indicating where to write processed samples. // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG_REVERSE command. // If the buffer and buffer provider in the configuration received by // EFFECT_CMD_SET_CONFIG_REVERSE are also NULL, do not return modified reverse // stream data // // Output: // returned value: 0 successful operation // -ENODATA the engine has finished the disable phase and the framework // can stop calling process_reverse() // -EINVAL invalid interface handle or // invalid input/output buffer description //////////////////////////////////////////////////////////////////////////////// int32_t (*process_reverse)(effect_handle_t self, audio_buffer_t *inBuffer, 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; // 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 ///////////////////////////////////////////////// // Effect library interface version 3.0 // Note that EffectsFactory.c only checks the major version component, so changes to the minor // number can only be used for fully backwards compatible changes #define EFFECT_LIBRARY_API_VERSION EFFECT_MAKE_API_VERSION(3,0) #define AUDIO_EFFECT_LIBRARY_TAG ((('A') << 24) | (('E') << 16) | (('L') << 8) | ('T')) // Every effect library must have a data structure named AUDIO_EFFECT_LIBRARY_INFO_SYM // and the fields of this data structure must begin with audio_effect_library_t typedef struct audio_effect_library_s { // tag must be initialized to AUDIO_EFFECT_LIBRARY_TAG uint32_t tag; // Version of the effect library API : 0xMMMMmmmm MMMM: Major, mmmm: minor uint32_t version; // Name of this library const char *name; // Author/owner/implementor of the library const char *implementor; //////////////////////////////////////////////////////////////////////////////// // // Function: create_effect // // Description: Creates an effect engine of the specified implementation uuid and // returns an effect control interface on this engine. The function will allocate the // resources for an instance of the requested effect engine and return // a handle on the effect control interface. // // Input: // uuid: pointer to the effect uuid. // sessionId: audio session to which this effect instance will be attached. All effects // created with the same session ID are connected in series and process the same signal // stream. Knowing that two effects are part of the same effect chain can help the // library implement some kind of optimizations. // ioId: identifies the output or input stream this effect is directed to at audio HAL. // For future use especially with tunneled HW accelerated effects // // Input/Output: // pHandle: address where to return the effect interface handle. // // Output: // returned value: 0 successful operation. // -ENODEV library failed to initialize // -EINVAL invalid pEffectUuid or pHandle // -ENOENT no effect with this uuid found // *pHandle: updated with the effect interface handle. // //////////////////////////////////////////////////////////////////////////////// int32_t (*create_effect)(const effect_uuid_t *uuid, int32_t sessionId, int32_t ioId, effect_handle_t *pHandle); //////////////////////////////////////////////////////////////////////////////// // // Function: release_effect // // Description: Releases the effect engine whose handle is given as argument. // All resources allocated to this particular instance of the effect are // released. // // Input: // handle: handle on the effect interface to be released. // // Output: // returned value: 0 successful operation. // -ENODEV library failed to initialize // -EINVAL invalid interface handle // //////////////////////////////////////////////////////////////////////////////// int32_t (*release_effect)(effect_handle_t handle); //////////////////////////////////////////////////////////////////////////////// // // Function: get_descriptor // // Description: Returns the descriptor of the effect engine which implementation UUID is // given as argument. // // Input/Output: // uuid: pointer to the effect uuid. // pDescriptor: address where to return the effect descriptor. // // Output: // returned value: 0 successful operation. // -ENODEV library failed to initialize // -EINVAL invalid pDescriptor or uuid // *pDescriptor: updated with the effect descriptor. // //////////////////////////////////////////////////////////////////////////////// int32_t (*get_descriptor)(const effect_uuid_t *uuid, effect_descriptor_t *pDescriptor); } audio_effect_library_t; // Name of the hal_module_info #define AUDIO_EFFECT_LIBRARY_INFO_SYM AELI // Name of the hal_module_info as a string #define AUDIO_EFFECT_LIBRARY_INFO_SYM_AS_STR "AELI" __END_DECLS #endif // ANDROID_AUDIO_EFFECT_H android-headers-23/22/hardware/audio_policy.h000066400000000000000000000452051264465411000212130ustar00rootroot00000000000000/* * 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_AUDIO_POLICY_INTERFACE_H #define ANDROID_AUDIO_POLICY_INTERFACE_H #include #include #include #include #include #include __BEGIN_DECLS /** * The id of this module */ #define AUDIO_POLICY_HARDWARE_MODULE_ID "audio_policy" /** * Name of the audio devices to open */ #define AUDIO_POLICY_INTERFACE "policy" /* ---------------------------------------------------------------------------- */ /* * The audio_policy and audio_policy_service_ops structs define the * communication interfaces between the platform specific audio policy manager * and Android generic audio policy manager. * The platform specific audio policy manager must implement methods of the * audio_policy struct. * This implementation makes use of the audio_policy_service_ops to control * the activity and configuration of audio input and output streams. * * The platform specific audio policy manager is in charge of the audio * routing and volume control policies for a given platform. * The main roles of this module are: * - keep track of current system state (removable device connections, phone * state, user requests...). * System state changes and user actions are notified to audio policy * manager with methods of the audio_policy. * * - process get_output() queries received when AudioTrack objects are * created: Those queries return a handler on an output that has been * selected, configured and opened by the audio policy manager and that * must be used by the AudioTrack when registering to the AudioFlinger * with the createTrack() method. * When the AudioTrack object is released, a release_output() query * is received and the audio policy manager can decide to close or * reconfigure the output depending on other streams using this output and * current system state. * * - similarly process get_input() and release_input() queries received from * AudioRecord objects and configure audio inputs. * - process volume control requests: the stream volume is converted from * an index value (received from UI) to a float value applicable to each * output as a function of platform specific settings and current output * route (destination device). It also make sure that streams are not * muted if not allowed (e.g. camera shutter sound in some countries). */ /* XXX: this should be defined OUTSIDE of frameworks/base */ struct effect_descriptor_s; struct audio_policy { /* * configuration functions */ /* indicate a change in device connection status */ int (*set_device_connection_state)(struct audio_policy *pol, audio_devices_t device, audio_policy_dev_state_t state, const char *device_address); /* retrieve a device connection status */ audio_policy_dev_state_t (*get_device_connection_state)( const struct audio_policy *pol, audio_devices_t device, const char *device_address); /* indicate a change in phone state. Valid phones states are defined * by audio_mode_t */ void (*set_phone_state)(struct audio_policy *pol, audio_mode_t state); /* deprecated, never called (was "indicate a change in ringer mode") */ void (*set_ringer_mode)(struct audio_policy *pol, uint32_t mode, uint32_t mask); /* force using a specific device category for the specified usage */ void (*set_force_use)(struct audio_policy *pol, audio_policy_force_use_t usage, audio_policy_forced_cfg_t config); /* retrieve current device category forced for a given usage */ audio_policy_forced_cfg_t (*get_force_use)(const struct audio_policy *pol, audio_policy_force_use_t usage); /* if can_mute is true, then audio streams that are marked ENFORCED_AUDIBLE * can still be muted. */ void (*set_can_mute_enforced_audible)(struct audio_policy *pol, bool can_mute); /* check proper initialization */ int (*init_check)(const struct audio_policy *pol); /* * Audio routing query functions */ /* request an output appropriate for playback of the supplied stream type and * parameters */ audio_io_handle_t (*get_output)(struct audio_policy *pol, audio_stream_type_t stream, uint32_t samplingRate, audio_format_t format, audio_channel_mask_t channelMask, audio_output_flags_t flags, const audio_offload_info_t *offloadInfo); /* indicates to the audio policy manager that the output starts being used * by corresponding stream. */ int (*start_output)(struct audio_policy *pol, audio_io_handle_t output, audio_stream_type_t stream, int session); /* indicates to the audio policy manager that the output stops being used * by corresponding stream. */ int (*stop_output)(struct audio_policy *pol, audio_io_handle_t output, audio_stream_type_t stream, int session); /* releases the output. */ void (*release_output)(struct audio_policy *pol, audio_io_handle_t output); /* request an input appropriate for record from the supplied device with * supplied parameters. */ audio_io_handle_t (*get_input)(struct audio_policy *pol, audio_source_t inputSource, uint32_t samplingRate, audio_format_t format, audio_channel_mask_t channelMask, audio_in_acoustics_t acoustics); /* indicates to the audio policy manager that the input starts being used */ int (*start_input)(struct audio_policy *pol, audio_io_handle_t input); /* indicates to the audio policy manager that the input stops being used. */ int (*stop_input)(struct audio_policy *pol, audio_io_handle_t input); /* releases the input. */ void (*release_input)(struct audio_policy *pol, audio_io_handle_t input); /* * volume control functions */ /* initialises stream volume conversion parameters by specifying volume * index range. The index range for each stream is defined by AudioService. */ void (*init_stream_volume)(struct audio_policy *pol, audio_stream_type_t stream, int index_min, int index_max); /* sets the new stream volume at a level corresponding to the supplied * index. The index is within the range specified by init_stream_volume() */ int (*set_stream_volume_index)(struct audio_policy *pol, audio_stream_type_t stream, int index); /* retrieve current volume index for the specified stream */ int (*get_stream_volume_index)(const struct audio_policy *pol, audio_stream_type_t stream, int *index); /* sets the new stream volume at a level corresponding to the supplied * index for the specified device. * The index is within the range specified by init_stream_volume() */ int (*set_stream_volume_index_for_device)(struct audio_policy *pol, audio_stream_type_t stream, int index, audio_devices_t device); /* retrieve current volume index for the specified stream for the specified device */ int (*get_stream_volume_index_for_device)(const struct audio_policy *pol, audio_stream_type_t stream, int *index, audio_devices_t device); /* return the strategy corresponding to a given stream type */ uint32_t (*get_strategy_for_stream)(const struct audio_policy *pol, audio_stream_type_t stream); /* return the enabled output devices for the given stream type */ audio_devices_t (*get_devices_for_stream)(const struct audio_policy *pol, audio_stream_type_t stream); /* Audio effect management */ audio_io_handle_t (*get_output_for_effect)(struct audio_policy *pol, const struct effect_descriptor_s *desc); int (*register_effect)(struct audio_policy *pol, const struct effect_descriptor_s *desc, audio_io_handle_t output, uint32_t strategy, int session, int id); int (*unregister_effect)(struct audio_policy *pol, int id); int (*set_effect_enabled)(struct audio_policy *pol, int id, bool enabled); bool (*is_stream_active)(const struct audio_policy *pol, audio_stream_type_t stream, uint32_t in_past_ms); bool (*is_stream_active_remotely)(const struct audio_policy *pol, audio_stream_type_t stream, uint32_t in_past_ms); bool (*is_source_active)(const struct audio_policy *pol, audio_source_t source); /* dump state */ int (*dump)(const struct audio_policy *pol, int fd); /* check if offload is possible for given sample rate, bitrate, duration, ... */ bool (*is_offload_supported)(const struct audio_policy *pol, const audio_offload_info_t *info); }; struct audio_policy_service_ops { /* * Audio output Control functions */ /* Opens an audio output with the requested parameters. * * The parameter values can indicate to use the default values in case the * audio policy manager has no specific requirements for the output being * opened. * * When the function returns, the parameter values reflect the actual * values used by the audio hardware output stream. * * The audio policy manager can check if the proposed parameters are * suitable or not and act accordingly. */ audio_io_handle_t (*open_output)(void *service, audio_devices_t *pDevices, uint32_t *pSamplingRate, audio_format_t *pFormat, audio_channel_mask_t *pChannelMask, uint32_t *pLatencyMs, audio_output_flags_t flags); /* creates a special output that is duplicated to the two outputs passed as * arguments. The duplication is performed by * a special mixer thread in the AudioFlinger. */ audio_io_handle_t (*open_duplicate_output)(void *service, audio_io_handle_t output1, audio_io_handle_t output2); /* closes the output stream */ int (*close_output)(void *service, audio_io_handle_t output); /* suspends the output. * * When an output is suspended, the corresponding audio hardware output * stream is placed in standby and the AudioTracks attached to the mixer * thread are still processed but the output mix is discarded. */ int (*suspend_output)(void *service, audio_io_handle_t output); /* restores a suspended output. */ int (*restore_output)(void *service, audio_io_handle_t output); /* */ /* Audio input Control functions */ /* */ /* opens an audio input * deprecated - new implementations should use open_input_on_module, * and the acoustics parameter is ignored */ audio_io_handle_t (*open_input)(void *service, audio_devices_t *pDevices, uint32_t *pSamplingRate, audio_format_t *pFormat, audio_channel_mask_t *pChannelMask, audio_in_acoustics_t acoustics); /* closes an audio input */ int (*close_input)(void *service, audio_io_handle_t input); /* */ /* misc control functions */ /* */ /* set a stream volume for a particular output. * * For the same user setting, a given stream type can have different * volumes for each output (destination device) it is attached to. */ int (*set_stream_volume)(void *service, audio_stream_type_t stream, float volume, audio_io_handle_t output, int delay_ms); /* invalidate a stream type, causing a reroute to an unspecified new output */ int (*invalidate_stream)(void *service, audio_stream_type_t stream); /* function enabling to send proprietary informations directly from audio * policy manager to audio hardware interface. */ void (*set_parameters)(void *service, audio_io_handle_t io_handle, const char *kv_pairs, int delay_ms); /* function enabling to receive proprietary informations directly from * audio hardware interface to audio policy manager. * * Returns a pointer to a heap allocated string. The caller is responsible * for freeing the memory for it using free(). */ char * (*get_parameters)(void *service, audio_io_handle_t io_handle, const char *keys); /* request the playback of a tone on the specified stream. * used for instance to replace notification sounds when playing over a * telephony device during a phone call. */ int (*start_tone)(void *service, audio_policy_tone_t tone, audio_stream_type_t stream); int (*stop_tone)(void *service); /* set down link audio volume. */ int (*set_voice_volume)(void *service, float volume, int delay_ms); /* move effect to the specified output */ int (*move_effects)(void *service, int session, audio_io_handle_t src_output, audio_io_handle_t dst_output); /* loads an audio hw module. * * The module name passed is the base name of the HW module library, e.g "primary" or "a2dp". * The function returns a handle on the module that will be used to specify a particular * module when calling open_output_on_module() or open_input_on_module() */ audio_module_handle_t (*load_hw_module)(void *service, const char *name); /* Opens an audio output on a particular HW module. * * Same as open_output() but specifying a specific HW module on which the output must be opened. */ audio_io_handle_t (*open_output_on_module)(void *service, audio_module_handle_t module, audio_devices_t *pDevices, uint32_t *pSamplingRate, audio_format_t *pFormat, audio_channel_mask_t *pChannelMask, uint32_t *pLatencyMs, audio_output_flags_t flags, const audio_offload_info_t *offloadInfo); /* Opens an audio input on a particular HW module. * * Same as open_input() but specifying a specific HW module on which the input must be opened. * Also removed deprecated acoustics parameter */ audio_io_handle_t (*open_input_on_module)(void *service, audio_module_handle_t module, audio_devices_t *pDevices, uint32_t *pSamplingRate, audio_format_t *pFormat, audio_channel_mask_t *pChannelMask); }; /**********************************************************************/ /** * 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 audio_policy_module { struct hw_module_t common; } audio_policy_module_t; struct audio_policy_device { /** * Common methods of the audio policy device. This *must* be the first member of * audio_policy_device as users of this structure will cast a hw_device_t to * audio_policy_device pointer in contexts where it's known the hw_device_t references an * audio_policy_device. */ struct hw_device_t common; int (*create_audio_policy)(const struct audio_policy_device *device, struct audio_policy_service_ops *aps_ops, void *service, struct audio_policy **ap); int (*destroy_audio_policy)(const struct audio_policy_device *device, struct audio_policy *ap); }; /** convenience API for opening and closing a supported device */ static inline int audio_policy_dev_open(const hw_module_t* module, struct audio_policy_device** device) { return module->methods->open(module, AUDIO_POLICY_INTERFACE, (hw_device_t**)device); } static inline int audio_policy_dev_close(struct audio_policy_device* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_AUDIO_POLICY_INTERFACE_H android-headers-23/22/hardware/bluetooth.h000066400000000000000000000442401264465411000205360ustar00rootroot00000000000000/* * 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_BLUETOOTH_H #define ANDROID_INCLUDE_BLUETOOTH_H #include #include #include #include #include __BEGIN_DECLS /** * The Bluetooth Hardware Module ID */ #define BT_HARDWARE_MODULE_ID "bluetooth" #define BT_STACK_MODULE_ID "bluetooth" #define BT_STACK_TEST_MODULE_ID "bluetooth_test" /* Bluetooth profile interface IDs */ #define BT_PROFILE_HANDSFREE_ID "handsfree" #define BT_PROFILE_HANDSFREE_CLIENT_ID "handsfree_client" #define BT_PROFILE_ADVANCED_AUDIO_ID "a2dp" #define BT_PROFILE_ADVANCED_AUDIO_SINK_ID "a2dp_sink" #define BT_PROFILE_HEALTH_ID "health" #define BT_PROFILE_SOCKETS_ID "socket" #define BT_PROFILE_HIDHOST_ID "hidhost" #define BT_PROFILE_PAN_ID "pan" #define BT_PROFILE_MAP_CLIENT_ID "map_client" #define BT_PROFILE_GATT_ID "gatt" #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 Device Name */ typedef struct { uint8_t name[249]; } __attribute__((packed))bt_bdname_t; /** Bluetooth Adapter Visibility Modes*/ typedef enum { BT_SCAN_MODE_NONE, BT_SCAN_MODE_CONNECTABLE, BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE } bt_scan_mode_t; /** Bluetooth Adapter State */ typedef enum { BT_STATE_OFF, BT_STATE_ON } bt_state_t; /** Bluetooth Error Status */ /** We need to build on this */ typedef enum { BT_STATUS_SUCCESS, BT_STATUS_FAIL, BT_STATUS_NOT_READY, BT_STATUS_NOMEM, BT_STATUS_BUSY, BT_STATUS_DONE, /* request already completed */ BT_STATUS_UNSUPPORTED, BT_STATUS_PARM_INVALID, BT_STATUS_UNHANDLED, BT_STATUS_AUTH_FAILURE, BT_STATUS_RMT_DEV_DOWN, BT_STATUS_AUTH_REJECTED } bt_status_t; /** Bluetooth PinKey Code */ typedef struct { uint8_t pin[16]; } __attribute__((packed))bt_pin_code_t; typedef struct { uint8_t status; uint8_t ctrl_state; /* stack reported state */ uint64_t tx_time; /* in ms */ uint64_t rx_time; /* in ms */ uint64_t idle_time; /* in ms */ uint64_t energy_used; /* a product of mA, V and ms */ } __attribute__((packed))bt_activity_energy_info; /** Bluetooth Adapter Discovery state */ typedef enum { BT_DISCOVERY_STOPPED, BT_DISCOVERY_STARTED } bt_discovery_state_t; /** Bluetooth ACL connection state */ typedef enum { BT_ACL_STATE_CONNECTED, 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; uint16_t channel; char name[256]; // what's the maximum length } bt_service_record_t; /** Bluetooth Remote Version info */ typedef struct { int version; int sub_ver; int manufacturer; } bt_remote_version_t; typedef struct { uint8_t local_privacy_enabled; uint8_t max_adv_instance; uint8_t rpa_offload_supported; uint8_t max_irk_list_size; uint8_t max_adv_filter_supported; uint8_t scan_result_storage_size_lobyte; uint8_t scan_result_storage_size_hibyte; uint8_t activity_energy_info_supported; }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, } bt_property_type_t; /** Bluetooth Adapter Property data structure */ typedef struct { bt_property_type_t type; int len; void *val; } bt_property_t; /** Bluetooth Device Type */ typedef enum { BT_DEVICE_DEVTYPE_BREDR = 0x1, BT_DEVICE_DEVTYPE_BLE, BT_DEVICE_DEVTYPE_DUAL } bt_device_type_t; /** Bluetooth Bond state */ typedef enum { BT_BOND_STATE_NONE, BT_BOND_STATE_BONDING, BT_BOND_STATE_BONDED } bt_bond_state_t; /** Bluetooth SSP Bonding Variant */ typedef enum { BT_SSP_VARIANT_PASSKEY_CONFIRMATION, BT_SSP_VARIANT_PASSKEY_ENTRY, BT_SSP_VARIANT_CONSENT, BT_SSP_VARIANT_PASSKEY_NOTIFICATION } bt_ssp_variant_t; #define BT_MAX_NUM_UUIDS 32 /** Bluetooth Interface callbacks */ /** Bluetooth Enable/Disable Callback. */ typedef void (*adapter_state_changed_callback)(bt_state_t state); /** GET/SET Adapter Properties callback */ /* TODO: For the GET/SET property APIs/callbacks, we may need a session * identifier to associate the call with the callback. This would be needed * whenever more than one simultaneous instance of the same adapter_type * is get/set. * * If this is going to be handled in the Java framework, then we do not need * to manage sessions here. */ typedef void (*adapter_properties_callback)(bt_status_t status, int num_properties, bt_property_t *properties); /** GET/SET Remote Device Properties callback */ /** TODO: For remote device properties, do not see a need to get/set * multiple properties - num_properties shall be 1 */ typedef void (*remote_device_properties_callback)(bt_status_t status, bt_bdaddr_t *bd_addr, int num_properties, bt_property_t *properties); /** New device discovered callback */ /** If EIR data is not present, then BD_NAME and RSSI shall be NULL and -1 * respectively */ typedef void (*device_found_callback)(int num_properties, bt_property_t *properties); /** Discovery state changed callback */ 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, bt_bdname_t *bd_name, uint32_t cod); /** Bluetooth SSP Request callback - Just Works & Numeric Comparison*/ /** pass_key - Shall be 0 for BT_SSP_PAIRING_VARIANT_CONSENT & * 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, bt_bdname_t *bd_name, uint32_t cod, bt_ssp_variant_t pairing_variant, uint32_t pass_key); /** 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, 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, bt_acl_state_t state); typedef enum { ASSOCIATE_JVM, DISASSOCIATE_JVM } bt_cb_thread_evt; /** Thread Associate/Disassociate JVM Callback */ /* Callback that is invoked by the callback thread to allow upper layer to attach/detach to/from * the JVM */ typedef void (*callback_thread_event)(bt_cb_thread_evt evt); /** Bluetooth Test Mode Callback */ /* 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); /* 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 */ typedef void (*le_test_mode_callback)(bt_status_t status, uint16_t num_packets); /** Callback invoked when energy details are obtained */ /* Ctrl_state-Current controller state-Active-1,scan-2,or idle-3 state as defined by HCI spec. * If the ctrl_state value is 0, it means the API call failed * Time values-In milliseconds as returned by the controller * Energy used-Value as returned by the controller * Status-Provides the status of the read_energy_info API call */ typedef void (*energy_info_callback)(bt_activity_energy_info *energy_info); /** TODO: Add callbacks for Link Up/Down and other generic * notifications/callbacks */ /** Bluetooth DM callback structure. */ typedef struct { /** set to sizeof(bt_callbacks_t) */ size_t size; adapter_state_changed_callback adapter_state_changed_cb; adapter_properties_callback adapter_properties_cb; remote_device_properties_callback remote_device_properties_cb; device_found_callback device_found_cb; discovery_state_changed_callback discovery_state_changed_cb; pin_request_callback pin_request_cb; ssp_request_callback ssp_request_cb; bond_state_changed_callback bond_state_changed_cb; acl_state_changed_callback acl_state_changed_cb; callback_thread_event thread_evt_cb; dut_mode_recv_callback dut_mode_recv_cb; le_test_mode_callback le_test_mode_cb; energy_info_callback energy_info_cb; } bt_callbacks_t; typedef void (*alarm_cb)(void *data); typedef bool (*set_wake_alarm_callout)(uint64_t delay_millis, bool should_wake, alarm_cb cb, void *data); typedef int (*acquire_wake_lock_callout)(const char *lock_name); typedef int (*release_wake_lock_callout)(const char *lock_name); /** The set of functions required by bluedroid to set wake alarms and * grab wake locks. This struct is passed into the stack through the * |set_os_callouts| function on |bt_interface_t|. */ typedef struct { /* set to sizeof(bt_os_callouts_t) */ size_t size; set_wake_alarm_callout set_wake_alarm; acquire_wake_lock_callout acquire_wake_lock; release_wake_lock_callout release_wake_lock; } bt_os_callouts_t; /** NOTE: By default, no profiles are initialized at the time of init/enable. * Whenever the application invokes the 'init' API of a profile, then one of * the following shall occur: * * 1.) If Bluetooth is not enabled, then the Bluetooth core shall mark the * profile as enabled. Subsequently, when the application invokes the * Bluetooth 'enable', as part of the enable sequence the profile that were * marked shall be enabled by calling appropriate stack APIs. The * 'adapter_properties_cb' shall return the list of UUIDs of the * enabled profiles. * * 2.) If Bluetooth is enabled, then the Bluetooth core shall invoke the stack * profile API to initialize the profile and trigger a * 'adapter_properties_cb' with the current list of UUIDs including the * newly added profile's UUID. * * The reverse shall occur whenever the profile 'cleanup' APIs are invoked */ /** Represents the standard Bluetooth DM interface. */ typedef struct { /** set to sizeof(bt_interface_t) */ size_t size; /** * Opens the interface and provides the callback routines * to the implemenation of this interface. */ int (*init)(bt_callbacks_t* callbacks ); /** Enable Bluetooth. */ int (*enable)(void); /** Disable Bluetooth. */ int (*disable)(void); /** Closes the interface. */ void (*cleanup)(void); /** Get all Bluetooth Adapter properties at init */ int (*get_adapter_properties)(void); /** Get Bluetooth Adapter property of 'type' */ int (*get_adapter_property)(bt_property_type_t type); /** 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 */ int (*set_adapter_property)(const bt_property_t *property); /** Get all Remote Device properties */ int (*get_remote_device_properties)(bt_bdaddr_t *remote_addr); /** Get Remote Device property of 'type' */ int (*get_remote_device_property)(bt_bdaddr_t *remote_addr, bt_property_type_t type); /** Set Remote Device property of 'type' */ int (*set_remote_device_property)(bt_bdaddr_t *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); /** Start SDP to get remote services */ int (*get_remote_services)(bt_bdaddr_t *remote_addr); /** Start Discovery */ int (*start_discovery)(void); /** Cancel Discovery */ int (*cancel_discovery)(void); /** Create Bluetooth Bonding */ int (*create_bond)(const bt_bdaddr_t *bd_addr, int transport); /** Remove Bond */ int (*remove_bond)(const bt_bdaddr_t *bd_addr); /** Cancel Bond */ int (*cancel_bond)(const bt_bdaddr_t *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); /** 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, uint8_t pin_len, bt_pin_code_t *pin_code); /** BT SSP Reply - Just Works, Numeric Comparison and Passkey * passkey shall be zero for BT_SSP_VARIANT_PASSKEY_COMPARISON & * 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, uint8_t accept, uint32_t passkey); /** Get Bluetooth profile interface */ const void* (*get_profile_interface) (const char *profile_id); /** Bluetooth Test Mode APIs - Bluetooth must be enabled for these APIs */ /* Configure DUT Mode - Use this mode to enter/exit DUT mode */ int (*dut_mode_configure)(uint8_t enable); /* 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); /** 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|. */ int (*set_os_callouts)(bt_os_callouts_t *callouts); /** Read Energy info details - return value indicates BT_STATUS_SUCCESS or BT_STATUS_NOT_READY * Success indicates that the VSC command was sent to controller */ int (*read_energy_info)(); } 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 */ android-headers-23/22/hardware/bt_av.h000066400000000000000000000063121264465411000176220ustar00rootroot00000000000000/* * 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 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); /** 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_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 ); /** 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 ); } btav_interface_t; __END_DECLS #endif /* ANDROID_INCLUDE_BT_AV_H */ android-headers-23/22/hardware/bt_gatt.h000066400000000000000000000032431264465411000201530ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/hardware/bt_gatt_client.h000066400000000000000000000426541264465411000215220ustar00rootroot00000000000000/* * 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" __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 { btgatt_srvc_id_t srvc_id; btgatt_gatt_id_t char_id; btgatt_gatt_id_t descr_id; 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; btgatt_srvc_id_t srvc_id; btgatt_gatt_id_t char_id; uint16_t len; uint8_t is_notify; } btgatt_notify_params_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 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); /** Reports GATT services on a remote device */ typedef void (*search_result_callback)( int conn_id, btgatt_srvc_id_t *srvc_id); /** GATT characteristic enumeration result callback */ typedef void (*get_characteristic_callback)(int conn_id, int status, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, int char_prop); /** GATT descriptor enumeration result callback */ typedef void (*get_descriptor_callback)(int conn_id, int status, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, btgatt_gatt_id_t *descr_id); /** GATT included service enumeration result callback */ typedef void (*get_included_service_callback)(int conn_id, int status, btgatt_srvc_id_t *srvc_id, btgatt_srvc_id_t *incl_srvc_id); /** Callback invoked in response to [de]register_for_notification */ typedef void (*register_for_notification_callback)(int conn_id, int registered, int status, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id); /** * 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, btgatt_write_params_t *p_data); /** 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, btgatt_write_params_t *p_data); /** 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)(int client_if, int filt_index, int addr_type, bt_bdaddr_t* bda, int adv_state); 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; search_result_callback search_result_cb; get_characteristic_callback get_characteristic_cb; get_descriptor_callback get_descriptor_cb; get_included_service_callback get_included_service_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; } 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 ); /** * Enumerate included services for a given service. * Set start_incl_srvc_id to NULL to get the first included service. */ bt_status_t (*get_included_service)( int conn_id, btgatt_srvc_id_t *srvc_id, btgatt_srvc_id_t *start_incl_srvc_id); /** * Enumerate characteristics for a given service. * Set start_char_id to NULL to get the first characteristic. */ bt_status_t (*get_characteristic)( int conn_id, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *start_char_id); /** * Enumerate descriptors for a given characteristic. * Set start_descr_id to NULL to get the first descriptor. */ bt_status_t (*get_descriptor)( int conn_id, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, btgatt_gatt_id_t *start_descr_id); /** Read a characteristic on a remote device */ bt_status_t (*read_characteristic)( int conn_id, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, int auth_req ); /** Write a remote characteristic */ bt_status_t (*write_characteristic)(int conn_id, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, 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, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, btgatt_gatt_id_t *descr_id, int auth_req); /** Write a remote descriptor for a given characteristic */ bt_status_t (*write_descriptor)( int conn_id, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, btgatt_gatt_id_t *descr_id, 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, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id); /** Deregister a previous request for notifications/indications */ bt_status_t (*deregister_for_notification)( int client_if, const bt_bdaddr_t *bd_addr, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id); /** 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)(int client_if, int action, int filt_index, int feat_seln, int list_logic_type, int filt_logic_type, int rssi_high_thres, int rssi_low_thres, int dely_mode, int found_timeout, int lost_timeout, int found_timeout_cnt); /** 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 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); } btgatt_client_interface_t; __END_DECLS #endif /* ANDROID_INCLUDE_BT_GATT_CLIENT_H */ android-headers-23/22/hardware/bt_gatt_server.h000066400000000000000000000173231264465411000215450ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/hardware/bt_gatt_types.h000066400000000000000000000026241264465411000214010ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/hardware/bt_hf.h000066400000000000000000000232571264465411000176200ustar00rootroot00000000000000/* * 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; /* 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); /** 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_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_CALL_ADDRTYPE_UNKNOWN = 0x81, BTHF_CALL_ADDRTYPE_INTERNATIONAL = 0x91 } bthf_call_addrtype_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 ); } bthf_interface_t; __END_DECLS #endif /* ANDROID_INCLUDE_BT_HF_H */ android-headers-23/22/hardware/bt_hf_client.h000066400000000000000000000320361264465411000211510ustar00rootroot00000000000000/* * 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); /** 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_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 */ android-headers-23/22/hardware/bt_hh.h000066400000000000000000000140561264465411000176170ustar00rootroot00000000000000/* * 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); /** 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 */ android-headers-23/22/hardware/bt_hl.h000066400000000000000000000071711264465411000176230ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/hardware/bt_mce.h000066400000000000000000000031211264465411000177530ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/hardware/bt_pan.h000066400000000000000000000055131264465411000177740ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/hardware/bt_rc.h000066400000000000000000000262671264465411000176330ustar00rootroot00000000000000/* * 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 7 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_event_id_t; typedef enum { BTRC_NOTIFICATION_TYPE_INTERIM = 0, BTRC_NOTIFICATION_TYPE_CHANGED = 1, } 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_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 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 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; } 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); /** Callback for play status request */ typedef void (* btrc_get_play_status_callback)(); /** Callback for list player application attributes (Shuffle, Repeat,...) */ typedef void (* btrc_list_player_app_attr_callback)(); /** Callback for list player application attributes (Shuffle, Repeat,...) */ typedef void (* btrc_list_player_app_values_callback)(btrc_player_attr_t attr_id); /** 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); /** 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); /** 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); /** Callback for setting the player application settings values */ typedef void (* btrc_set_player_app_value_callback) (btrc_player_settings_t *p_vals); /** 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); /** 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); /* 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); /** Callback for passthrough commands */ typedef void (* btrc_passthrough_cmd_callback) (int id, int key_state); /** BT-RC Target callback structure. */ 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_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 ); /** 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); /** 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)( int num_attr, btrc_player_attr_t *p_attrs); /** 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)( int num_val, uint8_t *p_vals); /** 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); /** 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); /** 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); /** 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); /** 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); /* 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); /* 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); /** Closes the interface. */ void (*cleanup)( void ); } btrc_interface_t; typedef void (* btrc_passthrough_rsp_callback) (int id, int key_state); typedef void (* btrc_connection_state_callback) (bool state, bt_bdaddr_t *bd_addr); /** BT-RC Controller callback structure. */ typedef struct { /** set to sizeof(BtRcCallbacks) */ size_t size; btrc_passthrough_rsp_callback passthrough_rsp_cb; btrc_connection_state_callback connection_state_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 ); /** Closes the interface. */ void (*cleanup)( void ); } btrc_ctrl_interface_t; __END_DECLS #endif /* ANDROID_INCLUDE_BT_RC_H */ android-headers-23/22/hardware/bt_sock.h000066400000000000000000000035171264465411000201570ustar00rootroot00000000000000/* * 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_SOCK_H #define ANDROID_INCLUDE_BT_SOCK_H __BEGIN_DECLS #define BTSOCK_FLAG_ENCRYPT 1 #define BTSOCK_FLAG_AUTH (1 << 1) typedef enum { BTSOCK_RFCOMM = 1, BTSOCK_SCO = 2, BTSOCK_L2CAP = 3 } btsock_type_t; /** Represents the standard BT SOCKET interface. */ typedef struct { short size; bt_bdaddr_t bd_addr; int channel; int status; } __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 */ bt_status_t (*listen)(btsock_type_t type, const char* service_name, const uint8_t* service_uuid, int channel, int* sock_fd, int flags); /* * 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 */ 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); } btsock_interface_t; __END_DECLS #endif /* ANDROID_INCLUDE_BT_SOCK_H */ android-headers-23/22/hardware/camera.h000066400000000000000000000257521264465411000177700ustar00rootroot00000000000000/* * Copyright (C) 2010-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_CAMERA_H #define ANDROID_INCLUDE_CAMERA_H #include "camera_common.h" /** * Camera device HAL, initial version [ CAMERA_DEVICE_API_VERSION_1_0 ] * * DEPRECATED. New devices should use Camera HAL v3.2 or newer. * * Supports the android.hardware.Camera API, and the android.hardware.camera2 * API in legacy mode only. * * Camera devices that support this version of the HAL must return a value in * the range HARDWARE_DEVICE_API_VERSION(0,0)-(1,FF) in * camera_device_t.common.version. CAMERA_DEVICE_API_VERSION_1_0 is the * recommended value. * * Camera modules that implement version 2.0 or higher of camera_module_t must * also return the value of camera_device_t.common.version in * camera_info_t.device_version. * * See camera_common.h for more details. */ __BEGIN_DECLS struct camera_memory; typedef void (*camera_release_memory)(struct camera_memory *mem); typedef struct camera_memory { void *data; size_t size; void *handle; camera_release_memory release; } camera_memory_t; typedef camera_memory_t* (*camera_request_memory)(int fd, size_t buf_size, unsigned int num_bufs, void *user); typedef void (*camera_notify_callback)(int32_t msg_type, int32_t ext1, int32_t ext2, void *user); typedef void (*camera_data_callback)(int32_t msg_type, const camera_memory_t *data, unsigned int index, camera_frame_metadata_t *metadata, void *user); typedef void (*camera_data_timestamp_callback)(int64_t timestamp, int32_t msg_type, const camera_memory_t *data, unsigned int index, void *user); #define HAL_CAMERA_PREVIEW_WINDOW_TAG 0xcafed00d typedef struct preview_stream_ops { int (*dequeue_buffer)(struct preview_stream_ops* w, buffer_handle_t** buffer, int *stride); int (*enqueue_buffer)(struct preview_stream_ops* w, buffer_handle_t* buffer); int (*cancel_buffer)(struct preview_stream_ops* w, buffer_handle_t* buffer); int (*set_buffer_count)(struct preview_stream_ops* w, int count); int (*set_buffers_geometry)(struct preview_stream_ops* pw, int w, int h, int format); int (*set_crop)(struct preview_stream_ops *w, int left, int top, int right, int bottom); int (*set_usage)(struct preview_stream_ops* w, int usage); int (*set_swap_interval)(struct preview_stream_ops *w, int interval); int (*get_min_undequeued_buffer_count)(const struct preview_stream_ops *w, int *count); int (*lock_buffer)(struct preview_stream_ops* w, buffer_handle_t* buffer); // Timestamps are measured in nanoseconds, and must be comparable // and monotonically increasing between two frames in the same // preview stream. They do not need to be comparable between // consecutive or parallel preview streams, cameras, or app runs. int (*set_timestamp)(struct preview_stream_ops *w, int64_t timestamp); } preview_stream_ops_t; struct camera_device; typedef struct camera_device_ops { /** Set the ANativeWindow to which preview frames are sent */ int (*set_preview_window)(struct camera_device *, struct preview_stream_ops *window); /** Set the notification and data callbacks */ void (*set_callbacks)(struct camera_device *, camera_notify_callback notify_cb, camera_data_callback data_cb, camera_data_timestamp_callback data_cb_timestamp, camera_request_memory get_memory, void *user); /** * The following three functions all take a msg_type, which is a bitmask of * the messages defined in include/ui/Camera.h */ /** * Enable a message, or set of messages. */ void (*enable_msg_type)(struct camera_device *, int32_t msg_type); /** * Disable a message, or a set of messages. * * Once received a call to disableMsgType(CAMERA_MSG_VIDEO_FRAME), camera * HAL should not rely on its client to call releaseRecordingFrame() to * release video recording frames sent out by the cameral HAL before and * after the disableMsgType(CAMERA_MSG_VIDEO_FRAME) call. Camera HAL * clients must not modify/access any video recording frame after calling * disableMsgType(CAMERA_MSG_VIDEO_FRAME). */ void (*disable_msg_type)(struct camera_device *, int32_t msg_type); /** * Query whether a message, or a set of messages, is enabled. Note that * this is operates as an AND, if any of the messages queried are off, this * will return false. */ int (*msg_type_enabled)(struct camera_device *, int32_t msg_type); /** * Start preview mode. */ int (*start_preview)(struct camera_device *); /** * Stop a previously started preview. */ void (*stop_preview)(struct camera_device *); /** * Returns true if preview is enabled. */ int (*preview_enabled)(struct camera_device *); /** * Request the camera HAL to store meta data or real YUV data in the video * buffers sent out via CAMERA_MSG_VIDEO_FRAME for a recording session. If * it is not called, the default camera HAL behavior is to store real YUV * data in the video buffers. * * This method should be called before startRecording() in order to be * effective. * * If meta data is stored in the video buffers, it is up to the receiver of * the video buffers to interpret the contents and to find the actual frame * data with the help of the meta data in the buffer. How this is done is * outside of the scope of this method. * * Some camera HALs may not support storing meta data in the video buffers, * but all camera HALs should support storing real YUV data in the video * buffers. If the camera HAL does not support storing the meta data in the * video buffers when it is requested to do do, INVALID_OPERATION must be * returned. It is very useful for the camera HAL to pass meta data rather * than the actual frame data directly to the video encoder, since the * amount of the uncompressed frame data can be very large if video size is * large. * * @param enable if true to instruct the camera HAL to store * meta data in the video buffers; false to instruct * the camera HAL to store real YUV data in the video * buffers. * * @return OK on success. */ int (*store_meta_data_in_buffers)(struct camera_device *, int enable); /** * Start record mode. When a record image is available, a * CAMERA_MSG_VIDEO_FRAME message is sent with the corresponding * frame. Every record frame must be released by a camera HAL client via * releaseRecordingFrame() before the client calls * disableMsgType(CAMERA_MSG_VIDEO_FRAME). After the client calls * disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's * responsibility to manage the life-cycle of the video recording frames, * and the client must not modify/access any video recording frames. */ int (*start_recording)(struct camera_device *); /** * Stop a previously started recording. */ void (*stop_recording)(struct camera_device *); /** * Returns true if recording is enabled. */ int (*recording_enabled)(struct camera_device *); /** * Release a record frame previously returned by CAMERA_MSG_VIDEO_FRAME. * * It is camera HAL client's responsibility to release video recording * frames sent out by the camera HAL before the camera HAL receives a call * to disableMsgType(CAMERA_MSG_VIDEO_FRAME). After it receives the call to * disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's * responsibility to manage the life-cycle of the video recording frames. */ void (*release_recording_frame)(struct camera_device *, const void *opaque); /** * Start auto focus, the notification callback routine is called with * CAMERA_MSG_FOCUS once when focusing is complete. autoFocus() will be * called again if another auto focus is needed. */ int (*auto_focus)(struct camera_device *); /** * Cancels auto-focus function. If the auto-focus is still in progress, * this function will cancel it. Whether the auto-focus is in progress or * not, this function will return the focus position to the default. If * the camera does not support auto-focus, this is a no-op. */ int (*cancel_auto_focus)(struct camera_device *); /** * Take a picture. */ int (*take_picture)(struct camera_device *); /** * Cancel a picture that was started with takePicture. Calling this method * when no picture is being taken is a no-op. */ int (*cancel_picture)(struct camera_device *); /** * Set the camera parameters. This returns BAD_VALUE if any parameter is * invalid or not supported. */ int (*set_parameters)(struct camera_device *, const char *parms); /** Retrieve the camera parameters. The buffer returned by the camera HAL must be returned back to it with put_parameters, if put_parameters is not NULL. */ char *(*get_parameters)(struct camera_device *); /** The camera HAL uses its own memory to pass us the parameters when we call get_parameters. Use this function to return the memory back to the camera HAL, if put_parameters is not NULL. If put_parameters is NULL, then you have to use free() to release the memory. */ void (*put_parameters)(struct camera_device *, char *); /** * Send command to camera driver. */ int (*send_command)(struct camera_device *, int32_t cmd, int32_t arg1, int32_t arg2); /** * Release the hardware resources owned by this object. Note that this is * *not* done in the destructor. */ void (*release)(struct camera_device *); /** * Dump state of the camera hardware */ int (*dump)(struct camera_device *, int fd); } camera_device_ops_t; typedef struct camera_device { /** * camera_device.common.version must be in the range * HARDWARE_DEVICE_API_VERSION(0,0)-(1,FF). CAMERA_DEVICE_API_VERSION_1_0 is * recommended. */ hw_device_t common; camera_device_ops_t *ops; void *priv; } camera_device_t; __END_DECLS #endif /* #ifdef ANDROID_INCLUDE_CAMERA_H */ android-headers-23/22/hardware/camera2.h000066400000000000000000001027521264465411000200460ustar00rootroot00000000000000/* * 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_CAMERA2_H #define ANDROID_INCLUDE_CAMERA2_H #include "camera_common.h" #include "system/camera_metadata.h" /** * Camera device HAL 2.1 [ CAMERA_DEVICE_API_VERSION_2_0, CAMERA_DEVICE_API_VERSION_2_1 ] * * DEPRECATED. New devices should use Camera HAL v3.2 or newer. * * Supports the android.hardware.Camera API, and the android.hardware.camera2 * API in legacy mode only. * * Camera devices that support this version of the HAL must return * CAMERA_DEVICE_API_VERSION_2_1 in camera_device_t.common.version and in * camera_info_t.device_version (from camera_module_t.get_camera_info). * * Camera modules that may contain version 2.x devices must implement at least * version 2.0 of the camera module interface (as defined by * camera_module_t.common.module_api_version). * * See camera_common.h for more versioning details. * * Version history: * * 2.0: CAMERA_DEVICE_API_VERSION_2_0. Initial release (Android 4.2): * - Sufficient for implementing existing android.hardware.Camera API. * - Allows for ZSL queue in camera service layer * - Not tested for any new features such manual capture control, * Bayer RAW capture, reprocessing of RAW data. * * 2.1: CAMERA_DEVICE_API_VERSION_2_1. Support per-device static metadata: * - Add get_instance_metadata() method to retrieve metadata that is fixed * after device open, but may be variable between open() calls. */ __BEGIN_DECLS struct camera2_device; /********************************************************************** * * Input/output stream buffer queue interface definitions * */ /** * Output image stream queue interface. A set of these methods is provided to * the HAL device in allocate_stream(), and are used to interact with the * gralloc buffer queue for that stream. They may not be called until after * allocate_stream returns. */ typedef struct camera2_stream_ops { /** * Get a buffer to fill from the queue. The size and format of the buffer * are fixed for a given stream (defined in allocate_stream), and the stride * should be queried from the platform gralloc module. The gralloc buffer * will have been allocated based on the usage flags provided by * allocate_stream, and will be locked for use. */ int (*dequeue_buffer)(const struct camera2_stream_ops* w, buffer_handle_t** buffer); /** * Push a filled buffer to the stream to be used by the consumer. * * The timestamp represents the time at start of exposure of the first row * of the image; it must be from a monotonic clock, and is measured in * nanoseconds. The timestamps do not need to be comparable between * different cameras, or consecutive instances of the same camera. However, * they must be comparable between streams from the same camera. If one * capture produces buffers for multiple streams, each stream must have the * same timestamp for that buffer, and that timestamp must match the * timestamp in the output frame metadata. */ int (*enqueue_buffer)(const struct camera2_stream_ops* w, int64_t timestamp, buffer_handle_t* buffer); /** * Return a buffer to the queue without marking it as filled. */ int (*cancel_buffer)(const struct camera2_stream_ops* w, buffer_handle_t* buffer); /** * Set the crop window for subsequently enqueued buffers. The parameters are * measured in pixels relative to the buffer width and height. */ int (*set_crop)(const struct camera2_stream_ops *w, int left, int top, int right, int bottom); } camera2_stream_ops_t; /** * Temporary definition during transition. * * These formats will be removed and replaced with * HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED. To maximize forward compatibility, * HAL implementations are strongly recommended to treat FORMAT_OPAQUE and * FORMAT_ZSL as equivalent to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, and * return HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED in the format_actual output * parameter of allocate_stream, allowing the gralloc module to select the * specific format based on the usage flags from the camera and the stream * consumer. */ enum { CAMERA2_HAL_PIXEL_FORMAT_OPAQUE = HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, CAMERA2_HAL_PIXEL_FORMAT_ZSL = -1 }; /** * Transport header for compressed JPEG buffers in output streams. * * To capture JPEG images, a stream is created using the pixel format * HAL_PIXEL_FORMAT_BLOB, and the static metadata field android.jpeg.maxSize is * used as the buffer size. Since compressed JPEG images are of variable size, * the HAL needs to include the final size of the compressed image using this * structure inside the output stream buffer. The JPEG blob ID field must be set * to CAMERA2_JPEG_BLOB_ID. * * Transport header should be at the end of the JPEG output stream buffer. That * means the jpeg_blob_id must start at byte[android.jpeg.maxSize - * sizeof(camera2_jpeg_blob)]. Any HAL using this transport header must * account for it in android.jpeg.maxSize. The JPEG data itself starts at * byte[0] and should be jpeg_size bytes long. */ typedef struct camera2_jpeg_blob { uint16_t jpeg_blob_id; uint32_t jpeg_size; }; enum { CAMERA2_JPEG_BLOB_ID = 0x00FF }; /** * Input reprocess stream queue management. A set of these methods is provided * to the HAL device in allocate_reprocess_stream(); they are used to interact * with the reprocess stream's input gralloc buffer queue. */ typedef struct camera2_stream_in_ops { /** * Get the next buffer of image data to reprocess. The width, height, and * format of the buffer is fixed in allocate_reprocess_stream(), and the * stride and other details should be queried from the platform gralloc * module as needed. The buffer will already be locked for use. */ int (*acquire_buffer)(const struct camera2_stream_in_ops *w, buffer_handle_t** buffer); /** * Return a used buffer to the buffer queue for reuse. */ int (*release_buffer)(const struct camera2_stream_in_ops *w, buffer_handle_t* buffer); } camera2_stream_in_ops_t; /********************************************************************** * * Metadata queue management, used for requests sent to HAL module, and for * frames produced by the HAL. * */ enum { CAMERA2_REQUEST_QUEUE_IS_BOTTOMLESS = -1 }; /** * Request input queue protocol: * * The framework holds the queue and its contents. At start, the queue is empty. * * 1. When the first metadata buffer is placed into the queue, the framework * signals the device by calling notify_request_queue_not_empty(). * * 2. After receiving notify_request_queue_not_empty, the device must call * dequeue() once it's ready to handle the next buffer. * * 3. Once the device has processed a buffer, and is ready for the next buffer, * it must call dequeue() again instead of waiting for a notification. If * there are no more buffers available, dequeue() will return NULL. After * this point, when a buffer becomes available, the framework must call * notify_request_queue_not_empty() again. If the device receives a NULL * return from dequeue, it does not need to query the queue again until a * notify_request_queue_not_empty() call is received from the source. * * 4. If the device calls buffer_count() and receives 0, this does not mean that * the framework will provide a notify_request_queue_not_empty() call. The * framework will only provide such a notification after the device has * received a NULL from dequeue, or on initial startup. * * 5. The dequeue() call in response to notify_request_queue_not_empty() may be * on the same thread as the notify_request_queue_not_empty() call, and may * be performed from within the notify call. * * 6. All dequeued request buffers must be returned to the framework by calling * free_request, including when errors occur, a device flush is requested, or * when the device is shutting down. */ typedef struct camera2_request_queue_src_ops { /** * Get the count of request buffers pending in the queue. May return * CAMERA2_REQUEST_QUEUE_IS_BOTTOMLESS if a repeating request (stream * request) is currently configured. Calling this method has no effect on * whether the notify_request_queue_not_empty() method will be called by the * framework. */ int (*request_count)(const struct camera2_request_queue_src_ops *q); /** * Get a metadata buffer from the framework. Returns OK if there is no * error. If the queue is empty, returns NULL in buffer. In that case, the * device must wait for a notify_request_queue_not_empty() message before * attempting to dequeue again. Buffers obtained in this way must be * returned to the framework with free_request(). */ int (*dequeue_request)(const struct camera2_request_queue_src_ops *q, camera_metadata_t **buffer); /** * Return a metadata buffer to the framework once it has been used, or if * an error or shutdown occurs. */ int (*free_request)(const struct camera2_request_queue_src_ops *q, camera_metadata_t *old_buffer); } camera2_request_queue_src_ops_t; /** * Frame output queue protocol: * * The framework holds the queue and its contents. At start, the queue is empty. * * 1. When the device is ready to fill an output metadata frame, it must dequeue * a metadata buffer of the required size. * * 2. It should then fill the metadata buffer, and place it on the frame queue * using enqueue_frame. The framework takes ownership of the frame. * * 3. In case of an error, a request to flush the pipeline, or shutdown, the * device must return any affected dequeued frames to the framework by * calling cancel_frame. */ typedef struct camera2_frame_queue_dst_ops { /** * Get an empty metadata buffer to fill from the framework. The new metadata * buffer will have room for entries number of metadata entries, plus * data_bytes worth of extra storage. Frames dequeued here must be returned * to the framework with either cancel_frame or enqueue_frame. */ int (*dequeue_frame)(const struct camera2_frame_queue_dst_ops *q, size_t entries, size_t data_bytes, camera_metadata_t **buffer); /** * Return a dequeued metadata buffer to the framework for reuse; do not mark it as * filled. Use when encountering errors, or flushing the internal request queue. */ int (*cancel_frame)(const struct camera2_frame_queue_dst_ops *q, camera_metadata_t *buffer); /** * Place a completed metadata frame on the frame output queue. */ int (*enqueue_frame)(const struct camera2_frame_queue_dst_ops *q, camera_metadata_t *buffer); } camera2_frame_queue_dst_ops_t; /********************************************************************** * * Notification callback and message definition, and trigger definitions * */ /** * Asynchronous notification callback from the HAL, fired for various * reasons. Only for information independent of frame capture, or that require * specific timing. The user pointer must be the same one that was passed to the * device in set_notify_callback(). */ typedef void (*camera2_notify_callback)(int32_t msg_type, int32_t ext1, int32_t ext2, int32_t ext3, void *user); /** * Possible message types for camera2_notify_callback */ enum { /** * An error has occurred. Argument ext1 contains the error code, and * ext2 and ext3 contain any error-specific information. */ CAMERA2_MSG_ERROR = 0x0001, /** * The exposure of a given request has begun. Argument ext1 contains the * frame number, and ext2 and ext3 contain the low-order and high-order * bytes of the timestamp for when exposure began. * (timestamp = (ext3 << 32 | ext2)) */ CAMERA2_MSG_SHUTTER = 0x0010, /** * The autofocus routine has changed state. Argument ext1 contains the new * state; the values are the same as those for the metadata field * android.control.afState. Ext2 contains the latest trigger ID passed to * trigger_action(CAMERA2_TRIGGER_AUTOFOCUS) or * trigger_action(CAMERA2_TRIGGER_CANCEL_AUTOFOCUS), or 0 if trigger has not * been called with either of those actions. */ CAMERA2_MSG_AUTOFOCUS = 0x0020, /** * The autoexposure routine has changed state. Argument ext1 contains the * new state; the values are the same as those for the metadata field * android.control.aeState. Ext2 contains the latest trigger ID value passed to * trigger_action(CAMERA2_TRIGGER_PRECAPTURE_METERING), or 0 if that method * has not been called. */ CAMERA2_MSG_AUTOEXPOSURE = 0x0021, /** * The auto-whitebalance routine has changed state. Argument ext1 contains * the new state; the values are the same as those for the metadata field * android.control.awbState. Ext2 contains the latest trigger ID passed to * trigger_action(CAMERA2_TRIGGER_PRECAPTURE_METERING), or 0 if that method * has not been called. */ CAMERA2_MSG_AUTOWB = 0x0022 }; /** * Error codes for CAMERA_MSG_ERROR */ enum { /** * A serious failure occured. Camera device may not work without reboot, and * no further frames or buffer streams will be produced by the * device. Device should be treated as closed. */ CAMERA2_MSG_ERROR_HARDWARE = 0x0001, /** * A serious failure occured. No further frames or buffer streams will be * produced by the device. Device should be treated as closed. The client * must reopen the device to use it again. */ CAMERA2_MSG_ERROR_DEVICE, /** * An error has occurred in processing a request. No output (metadata or * buffers) will be produced for this request. ext2 contains the frame * number of the request. Subsequent requests are unaffected, and the device * remains operational. */ CAMERA2_MSG_ERROR_REQUEST, /** * An error has occurred in producing an output frame metadata buffer for a * request, but image buffers for it will still be available. Subsequent * requests are unaffected, and the device remains operational. ext2 * contains the frame number of the request. */ CAMERA2_MSG_ERROR_FRAME, /** * An error has occurred in placing an output buffer into a stream for a * request. The frame metadata and other buffers may still be * available. Subsequent requests are unaffected, and the device remains * operational. ext2 contains the frame number of the request, and ext3 * contains the stream id. */ CAMERA2_MSG_ERROR_STREAM, /** * Number of error types */ CAMERA2_MSG_NUM_ERRORS }; /** * Possible trigger ids for trigger_action() */ enum { /** * Trigger an autofocus cycle. The effect of the trigger depends on the * autofocus mode in effect when the trigger is received, which is the mode * listed in the latest capture request to be dequeued by the HAL. If the * mode is OFF, EDOF, or FIXED, the trigger has no effect. In AUTO, MACRO, * or CONTINUOUS_* modes, see below for the expected behavior. The state of * the autofocus cycle can be tracked in android.control.afMode and the * corresponding notifications. * ** * In AUTO or MACRO mode, the AF state transitions (and notifications) * when calling with trigger ID = N with the previous ID being K are: * * Initial state Transitions * INACTIVE (K) -> ACTIVE_SCAN (N) -> AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * AF_FOCUSED (K) -> ACTIVE_SCAN (N) -> AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * AF_NOT_FOCUSED (K) -> ACTIVE_SCAN (N) -> AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * ACTIVE_SCAN (K) -> AF_FOCUSED(N) or AF_NOT_FOCUSED(N) * PASSIVE_SCAN (K) Not used in AUTO/MACRO mode * PASSIVE_FOCUSED (K) Not used in AUTO/MACRO mode * ** * In CONTINUOUS_PICTURE mode, triggering AF must lock the AF to the current * lens position and transition the AF state to either AF_FOCUSED or * NOT_FOCUSED. If a passive scan is underway, that scan must complete and * then lock the lens position and change AF state. TRIGGER_CANCEL_AUTOFOCUS * will allow the AF to restart its operation. * * Initial state Transitions * INACTIVE (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * PASSIVE_FOCUSED (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * PASSIVE_SCAN (K) -> AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * AF_FOCUSED (K) no effect except to change next notification ID to N * AF_NOT_FOCUSED (K) no effect except to change next notification ID to N * ** * In CONTINUOUS_VIDEO mode, triggering AF must lock the AF to the current * lens position and transition the AF state to either AF_FOCUSED or * NOT_FOCUSED. If a passive scan is underway, it must immediately halt, in * contrast with CONTINUOUS_PICTURE mode. TRIGGER_CANCEL_AUTOFOCUS will * allow the AF to restart its operation. * * Initial state Transitions * INACTIVE (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * PASSIVE_FOCUSED (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * PASSIVE_SCAN (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * AF_FOCUSED (K) no effect except to change next notification ID to N * AF_NOT_FOCUSED (K) no effect except to change next notification ID to N * * Ext1 is an ID that must be returned in subsequent auto-focus state change * notifications through camera2_notify_callback() and stored in * android.control.afTriggerId. */ CAMERA2_TRIGGER_AUTOFOCUS = 0x0001, /** * Send a cancel message to the autofocus algorithm. The effect of the * cancellation depends on the autofocus mode in effect when the trigger is * received, which is the mode listed in the latest capture request to be * dequeued by the HAL. If the AF mode is OFF or EDOF, the cancel has no * effect. For other modes, the lens should return to its default position, * any current autofocus scan must be canceled, and the AF state should be * set to INACTIVE. * * The state of the autofocus cycle can be tracked in android.control.afMode * and the corresponding notification. Continuous autofocus modes may resume * focusing operations thereafter exactly as if the camera had just been set * to a continuous AF mode. * * Ext1 is an ID that must be returned in subsequent auto-focus state change * notifications through camera2_notify_callback() and stored in * android.control.afTriggerId. */ CAMERA2_TRIGGER_CANCEL_AUTOFOCUS, /** * Trigger a pre-capture metering cycle, which may include firing the flash * to determine proper capture parameters. Typically, this trigger would be * fired for a half-depress of a camera shutter key, or before a snapshot * capture in general. The state of the metering cycle can be tracked in * android.control.aeMode and the corresponding notification. If the * auto-exposure mode is OFF, the trigger does nothing. * * Ext1 is an ID that must be returned in subsequent * auto-exposure/auto-white balance state change notifications through * camera2_notify_callback() and stored in android.control.aePrecaptureId. */ CAMERA2_TRIGGER_PRECAPTURE_METERING }; /** * Possible template types for construct_default_request() */ enum { /** * Standard camera preview operation with 3A on auto. */ CAMERA2_TEMPLATE_PREVIEW = 1, /** * Standard camera high-quality still capture with 3A and flash on auto. */ CAMERA2_TEMPLATE_STILL_CAPTURE, /** * Standard video recording plus preview with 3A on auto, torch off. */ CAMERA2_TEMPLATE_VIDEO_RECORD, /** * High-quality still capture while recording video. Application will * include preview, video record, and full-resolution YUV or JPEG streams in * request. Must not cause stuttering on video stream. 3A on auto. */ CAMERA2_TEMPLATE_VIDEO_SNAPSHOT, /** * Zero-shutter-lag mode. Application will request preview and * full-resolution data for each frame, and reprocess it to JPEG when a * still image is requested by user. Settings should provide highest-quality * full-resolution images without compromising preview frame rate. 3A on * auto. */ CAMERA2_TEMPLATE_ZERO_SHUTTER_LAG, /* Total number of templates */ CAMERA2_TEMPLATE_COUNT }; /********************************************************************** * * Camera device operations * */ typedef struct camera2_device_ops { /********************************************************************** * Request and frame queue setup and management methods */ /** * Pass in input request queue interface methods. */ int (*set_request_queue_src_ops)(const struct camera2_device *, const camera2_request_queue_src_ops_t *request_src_ops); /** * Notify device that the request queue is no longer empty. Must only be * called when the first buffer is added a new queue, or after the source * has returned NULL in response to a dequeue call. */ int (*notify_request_queue_not_empty)(const struct camera2_device *); /** * Pass in output frame queue interface methods */ int (*set_frame_queue_dst_ops)(const struct camera2_device *, const camera2_frame_queue_dst_ops_t *frame_dst_ops); /** * Number of camera requests being processed by the device at the moment * (captures/reprocesses that have had their request dequeued, but have not * yet been enqueued onto output pipeline(s) ). No streams may be released * by the framework until the in-progress count is 0. */ int (*get_in_progress_count)(const struct camera2_device *); /** * Flush all in-progress captures. This includes all dequeued requests * (regular or reprocessing) that have not yet placed any outputs into a * stream or the frame queue. Partially completed captures must be completed * normally. No new requests may be dequeued from the request queue until * the flush completes. */ int (*flush_captures_in_progress)(const struct camera2_device *); /** * Create a filled-in default request for standard camera use cases. * * The device must return a complete request that is configured to meet the * requested use case, which must be one of the CAMERA2_TEMPLATE_* * enums. All request control fields must be included, except for * android.request.outputStreams. * * The metadata buffer returned must be allocated with * allocate_camera_metadata. The framework takes ownership of the buffer. */ int (*construct_default_request)(const struct camera2_device *, int request_template, camera_metadata_t **request); /********************************************************************** * Stream management */ /** * allocate_stream: * * Allocate a new output stream for use, defined by the output buffer width, * height, target, and possibly the pixel format. Returns the new stream's * ID, gralloc usage flags, minimum queue buffer count, and possibly the * pixel format, on success. Error conditions: * * - Requesting a width/height/format combination not listed as * supported by the sensor's static characteristics * * - Asking for too many streams of a given format type (2 bayer raw * streams, for example). * * Input parameters: * * - width, height, format: Specification for the buffers to be sent through * this stream. Format is a value from the HAL_PIXEL_FORMAT_* list. If * HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, then the platform * gralloc module will select a format based on the usage flags provided * by the camera HAL and the consumer of the stream. The camera HAL should * inspect the buffers handed to it in the register_stream_buffers call to * obtain the implementation-specific format if necessary. * * - stream_ops: A structure of function pointers for obtaining and queuing * up buffers for this stream. The underlying stream will be configured * based on the usage and max_buffers outputs. The methods in this * structure may not be called until after allocate_stream returns. * * Output parameters: * * - stream_id: An unsigned integer identifying this stream. This value is * used in incoming requests to identify the stream, and in releasing the * stream. * * - usage: The gralloc usage mask needed by the HAL device for producing * the requested type of data. This is used in allocating new gralloc * buffers for the stream buffer queue. * * - max_buffers: The maximum number of buffers the HAL device may need to * have dequeued at the same time. The device may not dequeue more buffers * than this value at the same time. * */ int (*allocate_stream)( const struct camera2_device *, // inputs uint32_t width, uint32_t height, int format, const camera2_stream_ops_t *stream_ops, // outputs uint32_t *stream_id, uint32_t *format_actual, // IGNORED, will be removed uint32_t *usage, uint32_t *max_buffers); /** * Register buffers for a given stream. This is called after a successful * allocate_stream call, and before the first request referencing the stream * is enqueued. This method is intended to allow the HAL device to map or * otherwise prepare the buffers for later use. num_buffers is guaranteed to * be at least max_buffers (from allocate_stream), but may be larger. The * buffers will already be locked for use. At the end of the call, all the * buffers must be ready to be returned to the queue. If the stream format * was set to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, the camera HAL should * inspect the passed-in buffers here to determine any platform-private * pixel format information. */ int (*register_stream_buffers)( const struct camera2_device *, uint32_t stream_id, int num_buffers, buffer_handle_t *buffers); /** * Release a stream. Returns an error if called when get_in_progress_count * is non-zero, or if the stream id is invalid. */ int (*release_stream)( const struct camera2_device *, uint32_t stream_id); /** * allocate_reprocess_stream: * * Allocate a new input stream for use, defined by the output buffer width, * height, and the pixel format. Returns the new stream's ID, gralloc usage * flags, and required simultaneously acquirable buffer count, on * success. Error conditions: * * - Requesting a width/height/format combination not listed as * supported by the sensor's static characteristics * * - Asking for too many reprocessing streams to be configured at once. * * Input parameters: * * - width, height, format: Specification for the buffers to be sent through * this stream. Format must be a value from the HAL_PIXEL_FORMAT_* list. * * - reprocess_stream_ops: A structure of function pointers for acquiring * and releasing buffers for this stream. The underlying stream will be * configured based on the usage and max_buffers outputs. * * Output parameters: * * - stream_id: An unsigned integer identifying this stream. This value is * used in incoming requests to identify the stream, and in releasing the * stream. These ids are numbered separately from the input stream ids. * * - consumer_usage: The gralloc usage mask needed by the HAL device for * consuming the requested type of data. This is used in allocating new * gralloc buffers for the stream buffer queue. * * - max_buffers: The maximum number of buffers the HAL device may need to * have acquired at the same time. The device may not have more buffers * acquired at the same time than this value. * */ int (*allocate_reprocess_stream)(const struct camera2_device *, uint32_t width, uint32_t height, uint32_t format, const camera2_stream_in_ops_t *reprocess_stream_ops, // outputs uint32_t *stream_id, uint32_t *consumer_usage, uint32_t *max_buffers); /** * allocate_reprocess_stream_from_stream: * * Allocate a new input stream for use, which will use the buffers allocated * for an existing output stream. That is, after the HAL enqueues a buffer * onto the output stream, it may see that same buffer handed to it from * this input reprocessing stream. After the HAL releases the buffer back to * the reprocessing stream, it will be returned to the output queue for * reuse. * * Error conditions: * * - Using an output stream of unsuitable size/format for the basis of the * reprocessing stream. * * - Attempting to allocatee too many reprocessing streams at once. * * Input parameters: * * - output_stream_id: The ID of an existing output stream which has * a size and format suitable for reprocessing. * * - reprocess_stream_ops: A structure of function pointers for acquiring * and releasing buffers for this stream. The underlying stream will use * the same graphics buffer handles as the output stream uses. * * Output parameters: * * - stream_id: An unsigned integer identifying this stream. This value is * used in incoming requests to identify the stream, and in releasing the * stream. These ids are numbered separately from the input stream ids. * * The HAL client must always release the reprocessing stream before it * releases the output stream it is based on. * */ int (*allocate_reprocess_stream_from_stream)(const struct camera2_device *, uint32_t output_stream_id, const camera2_stream_in_ops_t *reprocess_stream_ops, // outputs uint32_t *stream_id); /** * Release a reprocessing stream. Returns an error if called when * get_in_progress_count is non-zero, or if the stream id is not * valid. */ int (*release_reprocess_stream)( const struct camera2_device *, uint32_t stream_id); /********************************************************************** * Miscellaneous methods */ /** * Trigger asynchronous activity. This is used for triggering special * behaviors of the camera 3A routines when they are in use. See the * documentation for CAMERA2_TRIGGER_* above for details of the trigger ids * and their arguments. */ int (*trigger_action)(const struct camera2_device *, uint32_t trigger_id, int32_t ext1, int32_t ext2); /** * Notification callback setup */ int (*set_notify_callback)(const struct camera2_device *, camera2_notify_callback notify_cb, void *user); /** * Get methods to query for vendor extension metadata tag infomation. May * set ops to NULL if no vendor extension tags are defined. */ int (*get_metadata_vendor_tag_ops)(const struct camera2_device*, vendor_tag_query_ops_t **ops); /** * Dump state of the camera hardware */ int (*dump)(const struct camera2_device *, int fd); /** * Get device-instance-specific metadata. This metadata must be constant for * a single instance of the camera device, but may be different between * open() calls. The returned camera_metadata pointer must be valid until * the device close() method is called. * * Version information: * * CAMERA_DEVICE_API_VERSION_2_0: * * Not available. Framework may not access this function pointer. * * CAMERA_DEVICE_API_VERSION_2_1: * * Valid. Can be called by the framework. * */ int (*get_instance_metadata)(const struct camera2_device *, camera_metadata **instance_metadata); } camera2_device_ops_t; /********************************************************************** * * Camera device definition * */ typedef struct camera2_device { /** * common.version must equal CAMERA_DEVICE_API_VERSION_2_0 to identify * this device as implementing version 2.0 of the camera device HAL. */ hw_device_t common; camera2_device_ops_t *ops; void *priv; } camera2_device_t; __END_DECLS #endif /* #ifdef ANDROID_INCLUDE_CAMERA2_H */ android-headers-23/22/hardware/camera3.h000066400000000000000000003613451264465411000200540ustar00rootroot00000000000000/* * 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_CAMERA3_H #define ANDROID_INCLUDE_CAMERA3_H #include #include "camera_common.h" /** * Camera device HAL 3.2 [ CAMERA_DEVICE_API_VERSION_3_2 ] * * This is the current recommended version of the camera device HAL. * * Supports the android.hardware.Camera API, and as of v3.2, the * android.hardware.camera2 API in LIMITED or FULL modes. * * Camera devices that support this version of the HAL must return * CAMERA_DEVICE_API_VERSION_3_2 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_2: * Camera modules that may contain version 3.2 devices must implement at * least version 2.2 of the camera module interface (as defined by * camera_module_t.common.module_api_version). * * <= CAMERA_DEVICE_API_VERSION_3_1: * Camera modules that may contain version 3.1 (or 3.0) devices must * implement at least version 2.0 of the camera module interface * (as defined by camera_module_t.common.module_api_version). * * See camera_common.h for more versioning details. * * Documentation index: * S1. Version history * S2. Startup and operation sequencing * S3. Operational modes * S4. 3A modes and state machines * S5. Cropping * S6. Error management * S7. Key Performance Indicator (KPI) glossary * S8. Sample Use Cases * S9. Notes on Controls and Metadata */ /** * S1. Version history: * * 1.0: Initial Android camera HAL (Android 4.0) [camera.h]: * * - Converted from C++ CameraHardwareInterface abstraction layer. * * - Supports android.hardware.Camera API. * * 2.0: Initial release of expanded-capability HAL (Android 4.2) [camera2.h]: * * - Sufficient for implementing existing android.hardware.Camera API. * * - Allows for ZSL queue in camera service layer * * - Not tested for any new features such manual capture control, Bayer RAW * capture, reprocessing of RAW data. * * 3.0: First revision of expanded-capability HAL: * * - Major version change since the ABI is completely different. No change to * the required hardware capabilities or operational model from 2.0. * * - Reworked input request and stream queue interfaces: Framework calls into * HAL with next request and stream buffers already dequeued. Sync framework * support is included, necessary for efficient implementations. * * - Moved triggers into requests, most notifications into results. * * - Consolidated all callbacks into framework into one structure, and all * setup methods into a single initialize() call. * * - Made stream configuration into a single call to simplify stream * management. Bidirectional streams replace STREAM_FROM_STREAM construct. * * - Limited mode semantics for older/limited hardware devices. * * 3.1: Minor revision of expanded-capability HAL: * * - configure_streams passes consumer usage flags to the HAL. * * - flush call to drop all in-flight requests/buffers as fast as possible. * * 3.2: Minor revision of expanded-capability HAL: * * - Deprecates get_metadata_vendor_tag_ops. Please use get_vendor_tag_ops * in camera_common.h instead. * * - register_stream_buffers deprecated. All gralloc buffers provided * by framework to HAL in process_capture_request may be new at any time. * * - add partial result support. process_capture_result may be called * multiple times with a subset of the available result before the full * result is available. * * - add manual template to camera3_request_template. The applications may * use this template to control the capture settings directly. * * - Rework the bidirectional and input stream specifications. * * - change the input buffer return path. The buffer is returned in * process_capture_result instead of process_capture_request. * */ /** * S2. Startup and general expected operation sequence: * * 1. Framework calls camera_module_t->common.open(), which returns a * hardware_device_t structure. * * 2. Framework inspects the hardware_device_t->version field, and instantiates * the appropriate handler for that version of the camera hardware device. In * case the version is CAMERA_DEVICE_API_VERSION_3_0, the device is cast to * a camera3_device_t. * * 3. Framework calls camera3_device_t->ops->initialize() with the framework * callback function pointers. This will only be called this one time after * open(), before any other functions in the ops structure are called. * * 4. The framework calls camera3_device_t->ops->configure_streams() with a list * of input/output streams to the HAL device. * * 5. <= CAMERA_DEVICE_API_VERSION_3_1: * * The framework allocates gralloc buffers and calls * camera3_device_t->ops->register_stream_buffers() for at least one of the * output streams listed in configure_streams. The same stream is registered * only once. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * camera3_device_t->ops->register_stream_buffers() is not called and must * be NULL. * * 6. The framework requests default settings for some number of use cases with * calls to camera3_device_t->ops->construct_default_request_settings(). This * may occur any time after step 3. * * 7. The framework constructs and sends the first capture request to the HAL, * with settings based on one of the sets of default settings, and with at * least one output stream, which has been registered earlier by the * framework. This is sent to the HAL with * camera3_device_t->ops->process_capture_request(). The HAL must block the * return of this call until it is ready for the next request to be sent. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * The buffer_handle_t provided in the camera3_stream_buffer_t array * in the camera3_capture_request_t may be new and never-before-seen * by the HAL on any given new request. * * 8. The framework continues to submit requests, and call * construct_default_request_settings to get default settings buffers for * other use cases. * * <= CAMERA_DEVICE_API_VERSION_3_1: * * The framework may call register_stream_buffers() at this time for * not-yet-registered streams. * * 9. When the capture of a request begins (sensor starts exposing for the * capture), the HAL calls camera3_callback_ops_t->notify() with the SHUTTER * event, including the frame number and the timestamp for start of exposure. * * <= CAMERA_DEVICE_API_VERSION_3_1: * * This notify call must be made before the first call to * process_capture_result() for that frame number. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * The camera3_callback_ops_t->notify() call with the SHUTTER event should * be made as early as possible since the framework will be unable to * deliver gralloc buffers to the application layer (for that frame) until * it has a valid timestamp for the start of exposure. * * Both partial metadata results and the gralloc buffers may be sent to the * framework at any time before or after the SHUTTER event. * * 10. After some pipeline delay, the HAL begins to return completed captures to * the framework with camera3_callback_ops_t->process_capture_result(). These * are returned in the same order as the requests were submitted. Multiple * requests can be in flight at once, depending on the pipeline depth of the * camera HAL device. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * Once a buffer is returned by process_capture_result as part of the * camera3_stream_buffer_t array, and the fence specified by release_fence * has been signaled (this is a no-op for -1 fences), the ownership of that * buffer is considered to be transferred back to the framework. After that, * the HAL must no longer retain that particular buffer, and the * framework may clean up the memory for it immediately. * * process_capture_result may be called multiple times for a single frame, * each time with a new disjoint piece of metadata and/or set of gralloc * buffers. The framework will accumulate these partial metadata results * into one result. * * In particular, it is legal for a process_capture_result to be called * simultaneously for both a frame N and a frame N+1 as long as the * above rule holds for gralloc buffers (both input and output). * * 11. After some time, the framework may stop submitting new requests, wait for * the existing captures to complete (all buffers filled, all results * returned), and then call configure_streams() again. This resets the camera * hardware and pipeline for a new set of input/output streams. Some streams * may be reused from the previous configuration; if these streams' buffers * had already been registered with the HAL, they will not be registered * again. The framework then continues from step 7, if at least one * registered output stream remains (otherwise, step 5 is required first). * * 12. Alternatively, the framework may call camera3_device_t->common->close() * to end the camera session. This may be called at any time when no other * calls from the framework are active, although the call may block until all * in-flight captures have completed (all results returned, all buffers * filled). After the close call returns, no more calls to the * camera3_callback_ops_t functions are allowed from the HAL. Once the * close() call is underway, the framework may not call any other HAL device * functions. * * 13. In case of an error or other asynchronous event, the HAL must call * camera3_callback_ops_t->notify() with the appropriate error/event * message. After returning from a fatal device-wide error notification, the * HAL should act as if close() had been called on it. However, the HAL must * either cancel or complete all outstanding captures before calling * notify(), so that once notify() is called with a fatal error, the * framework will not receive further callbacks from the device. Methods * besides close() should return -ENODEV or NULL after the notify() method * returns from a fatal error message. */ /** * S3. Operational modes: * * The camera 3 HAL device can implement one of two possible operational modes; * limited and full. Full support is expected from new higher-end * devices. Limited mode has hardware requirements roughly in line with those * for a camera HAL device v1 implementation, and is expected from older or * inexpensive devices. Full is a strict superset of limited, and they share the * same essential operational flow, as documented above. * * The HAL must indicate its level of support with the * android.info.supportedHardwareLevel static metadata entry, with 0 indicating * limited mode, and 1 indicating full mode support. * * Roughly speaking, limited-mode devices do not allow for application control * of capture settings (3A control only), high-rate capture of high-resolution * images, raw sensor readout, or support for YUV output streams above maximum * recording resolution (JPEG only for large images). * * ** Details of limited mode behavior: * * - Limited-mode devices do not need to implement accurate synchronization * between capture request settings and the actual image data * captured. Instead, changes to settings may take effect some time in the * future, and possibly not for the same output frame for each settings * entry. Rapid changes in settings may result in some settings never being * used for a capture. However, captures that include high-resolution output * buffers ( > 1080p ) have to use the settings as specified (but see below * for processing rate). * * - Limited-mode devices do not need to support most of the * settings/result/static info metadata. Specifically, only the following settings * are expected to be consumed or produced by a limited-mode HAL device: * * android.control.aeAntibandingMode (controls and dynamic) * android.control.aeExposureCompensation (controls and dynamic) * android.control.aeLock (controls and dynamic) * android.control.aeMode (controls and dynamic) * android.control.aeRegions (controls and dynamic) * android.control.aeTargetFpsRange (controls and dynamic) * android.control.aePrecaptureTrigger (controls and dynamic) * android.control.afMode (controls and dynamic) * android.control.afRegions (controls and dynamic) * android.control.awbLock (controls and dynamic) * android.control.awbMode (controls and dynamic) * android.control.awbRegions (controls and dynamic) * android.control.captureIntent (controls and dynamic) * android.control.effectMode (controls and dynamic) * android.control.mode (controls and dynamic) * android.control.sceneMode (controls and dynamic) * android.control.videoStabilizationMode (controls and dynamic) * android.control.aeAvailableAntibandingModes (static) * android.control.aeAvailableModes (static) * android.control.aeAvailableTargetFpsRanges (static) * android.control.aeCompensationRange (static) * android.control.aeCompensationStep (static) * android.control.afAvailableModes (static) * android.control.availableEffects (static) * android.control.availableSceneModes (static) * android.control.availableVideoStabilizationModes (static) * android.control.awbAvailableModes (static) * android.control.maxRegions (static) * android.control.sceneModeOverrides (static) * android.control.aeState (dynamic) * android.control.afState (dynamic) * android.control.awbState (dynamic) * * android.flash.mode (controls and dynamic) * android.flash.info.available (static) * * android.info.supportedHardwareLevel (static) * * android.jpeg.gpsCoordinates (controls and dynamic) * android.jpeg.gpsProcessingMethod (controls and dynamic) * android.jpeg.gpsTimestamp (controls and dynamic) * android.jpeg.orientation (controls and dynamic) * android.jpeg.quality (controls and dynamic) * android.jpeg.thumbnailQuality (controls and dynamic) * android.jpeg.thumbnailSize (controls and dynamic) * android.jpeg.availableThumbnailSizes (static) * android.jpeg.maxSize (static) * * android.lens.info.minimumFocusDistance (static) * * android.request.id (controls and dynamic) * * android.scaler.cropRegion (controls and dynamic) * android.scaler.availableStreamConfigurations (static) * android.scaler.availableMinFrameDurations (static) * android.scaler.availableStallDurations (static) * android.scaler.availableMaxDigitalZoom (static) * android.scaler.maxDigitalZoom (static) * android.scaler.croppingType (static) * * android.sensor.orientation (static) * android.sensor.timestamp (dynamic) * * android.statistics.faceDetectMode (controls and dynamic) * android.statistics.info.availableFaceDetectModes (static) * android.statistics.faceIds (dynamic) * android.statistics.faceLandmarks (dynamic) * android.statistics.faceRectangles (dynamic) * android.statistics.faceScores (dynamic) * * android.sync.frameNumber (dynamic) * android.sync.maxLatency (static) * * - Captures in limited mode that include high-resolution (> 1080p) output * buffers may block in process_capture_request() until all the output buffers * have been filled. A full-mode HAL device must process sequences of * high-resolution requests at the rate indicated in the static metadata for * that pixel format. The HAL must still call process_capture_result() to * provide the output; the framework must simply be prepared for * process_capture_request() to block until after process_capture_result() for * that request completes for high-resolution captures for limited-mode * devices. * * - Full-mode devices must support below additional capabilities: * - 30fps at maximum resolution is preferred, more than 20fps is required. * - Per frame control (android.sync.maxLatency == PER_FRAME_CONTROL). * - Sensor manual control metadata. See MANUAL_SENSOR defined in * android.request.availableCapabilities. * - Post-processing manual control metadata. See MANUAL_POST_PROCESSING defined * in android.request.availableCapabilities. * */ /** * S4. 3A modes and state machines: * * While the actual 3A algorithms are up to the HAL implementation, a high-level * state machine description is defined by the HAL interface, to allow the HAL * device and the framework to communicate about the current state of 3A, and to * trigger 3A events. * * When the device is opened, all the individual 3A states must be * STATE_INACTIVE. Stream configuration does not reset 3A. For example, locked * focus must be maintained across the configure() call. * * Triggering a 3A action involves simply setting the relevant trigger entry in * the settings for the next request to indicate start of trigger. For example, * the trigger for starting an autofocus scan is setting the entry * ANDROID_CONTROL_AF_TRIGGER to ANDROID_CONTROL_AF_TRIGGER_START for one * request, and cancelling an autofocus scan is triggered by setting * ANDROID_CONTROL_AF_TRIGGER to ANDROID_CONTRL_AF_TRIGGER_CANCEL. Otherwise, * the entry will not exist, or be set to ANDROID_CONTROL_AF_TRIGGER_IDLE. Each * request with a trigger entry set to a non-IDLE value will be treated as an * independent triggering event. * * At the top level, 3A is controlled by the ANDROID_CONTROL_MODE setting, which * selects between no 3A (ANDROID_CONTROL_MODE_OFF), normal AUTO mode * (ANDROID_CONTROL_MODE_AUTO), and using the scene mode setting * (ANDROID_CONTROL_USE_SCENE_MODE). * * - In OFF mode, each of the individual AE/AF/AWB modes are effectively OFF, * and none of the capture controls may be overridden by the 3A routines. * * - In AUTO mode, Auto-focus, auto-exposure, and auto-whitebalance all run * their own independent algorithms, and have their own mode, state, and * trigger metadata entries, as listed in the next section. * * - In USE_SCENE_MODE, the value of the ANDROID_CONTROL_SCENE_MODE entry must * be used to determine the behavior of 3A routines. In SCENE_MODEs other than * FACE_PRIORITY, the HAL must override the values of * ANDROId_CONTROL_AE/AWB/AF_MODE to be the mode it prefers for the selected * SCENE_MODE. For example, the HAL may prefer SCENE_MODE_NIGHT to use * CONTINUOUS_FOCUS AF mode. Any user selection of AE/AWB/AF_MODE when scene * must be ignored for these scene modes. * * - For SCENE_MODE_FACE_PRIORITY, the AE/AWB/AF_MODE controls work as in * ANDROID_CONTROL_MODE_AUTO, but the 3A routines must bias toward metering * and focusing on any detected faces in the scene. * * S4.1. Auto-focus settings and result entries: * * Main metadata entries: * * ANDROID_CONTROL_AF_MODE: Control for selecting the current autofocus * mode. Set by the framework in the request settings. * * AF_MODE_OFF: AF is disabled; the framework/app directly controls lens * position. * * AF_MODE_AUTO: Single-sweep autofocus. No lens movement unless AF is * triggered. * * AF_MODE_MACRO: Single-sweep up-close autofocus. No lens movement unless * AF is triggered. * * AF_MODE_CONTINUOUS_VIDEO: Smooth continuous focusing, for recording * video. Triggering immediately locks focus in current * position. Canceling resumes cotinuous focusing. * * AF_MODE_CONTINUOUS_PICTURE: Fast continuous focusing, for * zero-shutter-lag still capture. Triggering locks focus once currently * active sweep concludes. Canceling resumes continuous focusing. * * AF_MODE_EDOF: Advanced extended depth of field focusing. There is no * autofocus scan, so triggering one or canceling one has no effect. * Images are focused automatically by the HAL. * * ANDROID_CONTROL_AF_STATE: Dynamic metadata describing the current AF * algorithm state, reported by the HAL in the result metadata. * * AF_STATE_INACTIVE: No focusing has been done, or algorithm was * reset. Lens is not moving. Always the state for MODE_OFF or MODE_EDOF. * When the device is opened, it must start in this state. * * AF_STATE_PASSIVE_SCAN: A continuous focus algorithm is currently scanning * for good focus. The lens is moving. * * AF_STATE_PASSIVE_FOCUSED: A continuous focus algorithm believes it is * well focused. The lens is not moving. The HAL may spontaneously leave * this state. * * AF_STATE_PASSIVE_UNFOCUSED: A continuous focus algorithm believes it is * not well focused. The lens is not moving. The HAL may spontaneously * leave this state. * * AF_STATE_ACTIVE_SCAN: A scan triggered by the user is underway. * * AF_STATE_FOCUSED_LOCKED: The AF algorithm believes it is focused. The * lens is not moving. * * AF_STATE_NOT_FOCUSED_LOCKED: The AF algorithm has been unable to * focus. The lens is not moving. * * ANDROID_CONTROL_AF_TRIGGER: Control for starting an autofocus scan, the * meaning of which is mode- and state- dependent. Set by the framework in * the request settings. * * AF_TRIGGER_IDLE: No current trigger. * * AF_TRIGGER_START: Trigger start of AF scan. Effect is mode and state * dependent. * * AF_TRIGGER_CANCEL: Cancel current AF scan if any, and reset algorithm to * default. * * Additional metadata entries: * * ANDROID_CONTROL_AF_REGIONS: Control for selecting the regions of the FOV * that should be used to determine good focus. This applies to all AF * modes that scan for focus. Set by the framework in the request * settings. * * S4.2. Auto-exposure settings and result entries: * * Main metadata entries: * * ANDROID_CONTROL_AE_MODE: Control for selecting the current auto-exposure * mode. Set by the framework in the request settings. * * AE_MODE_OFF: Autoexposure is disabled; the user controls exposure, gain, * frame duration, and flash. * * AE_MODE_ON: Standard autoexposure, with flash control disabled. User may * set flash to fire or to torch mode. * * AE_MODE_ON_AUTO_FLASH: Standard autoexposure, with flash on at HAL's * discretion for precapture and still capture. User control of flash * disabled. * * AE_MODE_ON_ALWAYS_FLASH: Standard autoexposure, with flash always fired * for capture, and at HAL's discretion for precapture.. User control of * flash disabled. * * AE_MODE_ON_AUTO_FLASH_REDEYE: Standard autoexposure, with flash on at * HAL's discretion for precapture and still capture. Use a flash burst * at end of precapture sequence to reduce redeye in the final * picture. User control of flash disabled. * * ANDROID_CONTROL_AE_STATE: Dynamic metadata describing the current AE * algorithm state, reported by the HAL in the result metadata. * * AE_STATE_INACTIVE: Initial AE state after mode switch. When the device is * opened, it must start in this state. * * AE_STATE_SEARCHING: AE is not converged to a good value, and is adjusting * exposure parameters. * * AE_STATE_CONVERGED: AE has found good exposure values for the current * scene, and the exposure parameters are not changing. HAL may * spontaneously leave this state to search for better solution. * * AE_STATE_LOCKED: AE has been locked with the AE_LOCK control. Exposure * values are not changing. * * AE_STATE_FLASH_REQUIRED: The HAL has converged exposure, but believes * flash is required for a sufficiently bright picture. Used for * determining if a zero-shutter-lag frame can be used. * * AE_STATE_PRECAPTURE: The HAL is in the middle of a precapture * sequence. Depending on AE mode, this mode may involve firing the * flash for metering, or a burst of flash pulses for redeye reduction. * * ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER: Control for starting a metering * sequence before capturing a high-quality image. Set by the framework in * the request settings. * * PRECAPTURE_TRIGGER_IDLE: No current trigger. * * PRECAPTURE_TRIGGER_START: Start a precapture sequence. The HAL should * use the subsequent requests to measure good exposure/white balance * for an upcoming high-resolution capture. * * Additional metadata entries: * * ANDROID_CONTROL_AE_LOCK: Control for locking AE controls to their current * values * * ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION: Control for adjusting AE * algorithm target brightness point. * * ANDROID_CONTROL_AE_TARGET_FPS_RANGE: Control for selecting the target frame * rate range for the AE algorithm. The AE routine cannot change the frame * rate to be outside these bounds. * * ANDROID_CONTROL_AE_REGIONS: Control for selecting the regions of the FOV * that should be used to determine good exposure levels. This applies to * all AE modes besides OFF. * * S4.3. Auto-whitebalance settings and result entries: * * Main metadata entries: * * ANDROID_CONTROL_AWB_MODE: Control for selecting the current white-balance * mode. * * AWB_MODE_OFF: Auto-whitebalance is disabled. User controls color matrix. * * AWB_MODE_AUTO: Automatic white balance is enabled; 3A controls color * transform, possibly using more complex transforms than a simple * matrix. * * AWB_MODE_INCANDESCENT: Fixed white balance settings good for indoor * incandescent (tungsten) lighting, roughly 2700K. * * AWB_MODE_FLUORESCENT: Fixed white balance settings good for fluorescent * lighting, roughly 5000K. * * AWB_MODE_WARM_FLUORESCENT: Fixed white balance settings good for * fluorescent lighting, roughly 3000K. * * AWB_MODE_DAYLIGHT: Fixed white balance settings good for daylight, * roughly 5500K. * * AWB_MODE_CLOUDY_DAYLIGHT: Fixed white balance settings good for clouded * daylight, roughly 6500K. * * AWB_MODE_TWILIGHT: Fixed white balance settings good for * near-sunset/sunrise, roughly 15000K. * * AWB_MODE_SHADE: Fixed white balance settings good for areas indirectly * lit by the sun, roughly 7500K. * * ANDROID_CONTROL_AWB_STATE: Dynamic metadata describing the current AWB * algorithm state, reported by the HAL in the result metadata. * * AWB_STATE_INACTIVE: Initial AWB state after mode switch. When the device * is opened, it must start in this state. * * AWB_STATE_SEARCHING: AWB is not converged to a good value, and is * changing color adjustment parameters. * * AWB_STATE_CONVERGED: AWB has found good color adjustment values for the * current scene, and the parameters are not changing. HAL may * spontaneously leave this state to search for better solution. * * AWB_STATE_LOCKED: AWB has been locked with the AWB_LOCK control. Color * adjustment values are not changing. * * Additional metadata entries: * * ANDROID_CONTROL_AWB_LOCK: Control for locking AWB color adjustments to * their current values. * * ANDROID_CONTROL_AWB_REGIONS: Control for selecting the regions of the FOV * that should be used to determine good color balance. This applies only * to auto-WB mode. * * S4.4. General state machine transition notes * * Switching between AF, AE, or AWB modes always resets the algorithm's state * to INACTIVE. Similarly, switching between CONTROL_MODE or * CONTROL_SCENE_MODE if CONTROL_MODE == USE_SCENE_MODE resets all the * algorithm states to INACTIVE. * * The tables below are per-mode. * * S4.5. AF state machines * * when enabling AF or changing AF mode *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| Any | AF mode change| INACTIVE | | *+--------------------+---------------+--------------------+------------------+ * * mode = AF_MODE_OFF or AF_MODE_EDOF *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | | INACTIVE | Never changes | *+--------------------+---------------+--------------------+------------------+ * * mode = AF_MODE_AUTO or AF_MODE_MACRO *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | AF_TRIGGER | ACTIVE_SCAN | Start AF sweep | *| | | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| ACTIVE_SCAN | AF sweep done | FOCUSED_LOCKED | If AF successful | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| ACTIVE_SCAN | AF sweep done | NOT_FOCUSED_LOCKED | If AF successful | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| ACTIVE_SCAN | AF_CANCEL | INACTIVE | Cancel/reset AF | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Cancel/reset AF | *+--------------------+---------------+--------------------+------------------+ *| FOCUSED_LOCKED | AF_TRIGGER | ACTIVE_SCAN | Start new sweep | *| | | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| NOT_FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Cancel/reset AF | *+--------------------+---------------+--------------------+------------------+ *| NOT_FOCUSED_LOCKED | AF_TRIGGER | ACTIVE_SCAN | Start new sweep | *| | | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| All states | mode change | INACTIVE | | *+--------------------+---------------+--------------------+------------------+ * * mode = AF_MODE_CONTINUOUS_VIDEO *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | HAL initiates | PASSIVE_SCAN | Start AF scan | *| | new scan | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | AF_TRIGGER | NOT_FOCUSED_LOCKED | AF state query | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | HAL completes | PASSIVE_FOCUSED | End AF scan | *| | current scan | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | HAL fails | PASSIVE_UNFOCUSED | End AF scan | *| | current scan | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | AF_TRIGGER | FOCUSED_LOCKED | Immediate trans. | *| | | | if focus is good | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | AF_TRIGGER | NOT_FOCUSED_LOCKED | Immediate trans. | *| | | | if focus is bad | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | AF_CANCEL | INACTIVE | Reset lens | *| | | | position | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_FOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan | *| | new scan | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_UNFOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan | *| | new scan | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_FOCUSED | AF_TRIGGER | FOCUSED_LOCKED | Immediate trans. | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_UNFOCUSED | AF_TRIGGER | NOT_FOCUSED_LOCKED | Immediate trans. | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| FOCUSED_LOCKED | AF_TRIGGER | FOCUSED_LOCKED | No effect | *+--------------------+---------------+--------------------+------------------+ *| FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan | *+--------------------+---------------+--------------------+------------------+ *| NOT_FOCUSED_LOCKED | AF_TRIGGER | NOT_FOCUSED_LOCKED | No effect | *+--------------------+---------------+--------------------+------------------+ *| NOT_FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan | *+--------------------+---------------+--------------------+------------------+ * * mode = AF_MODE_CONTINUOUS_PICTURE *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | HAL initiates | PASSIVE_SCAN | Start AF scan | *| | new scan | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | AF_TRIGGER | NOT_FOCUSED_LOCKED | AF state query | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | HAL completes | PASSIVE_FOCUSED | End AF scan | *| | current scan | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | HAL fails | PASSIVE_UNFOCUSED | End AF scan | *| | current scan | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | AF_TRIGGER | FOCUSED_LOCKED | Eventual trans. | *| | | | once focus good | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | AF_TRIGGER | NOT_FOCUSED_LOCKED | Eventual trans. | *| | | | if cannot focus | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | AF_CANCEL | INACTIVE | Reset lens | *| | | | position | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_FOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan | *| | new scan | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_UNFOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan | *| | new scan | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_FOCUSED | AF_TRIGGER | FOCUSED_LOCKED | Immediate trans. | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_UNFOCUSED | AF_TRIGGER | NOT_FOCUSED_LOCKED | Immediate trans. | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| FOCUSED_LOCKED | AF_TRIGGER | FOCUSED_LOCKED | No effect | *+--------------------+---------------+--------------------+------------------+ *| FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan | *+--------------------+---------------+--------------------+------------------+ *| NOT_FOCUSED_LOCKED | AF_TRIGGER | NOT_FOCUSED_LOCKED | No effect | *+--------------------+---------------+--------------------+------------------+ *| NOT_FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan | *+--------------------+---------------+--------------------+------------------+ * * S4.6. AE and AWB state machines * * The AE and AWB state machines are mostly identical. AE has additional * FLASH_REQUIRED and PRECAPTURE states. So rows below that refer to those two * states should be ignored for the AWB state machine. * * when enabling AE/AWB or changing AE/AWB mode *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| Any | mode change | INACTIVE | | *+--------------------+---------------+--------------------+------------------+ * * mode = AE_MODE_OFF / AWB mode not AUTO *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | | INACTIVE | AE/AWB disabled | *+--------------------+---------------+--------------------+------------------+ * * mode = AE_MODE_ON_* / AWB_MODE_AUTO *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | HAL initiates | SEARCHING | | *| | AE/AWB scan | | | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | AE/AWB_LOCK | LOCKED | values locked | *| | on | | | *+--------------------+---------------+--------------------+------------------+ *| SEARCHING | HAL finishes | CONVERGED | good values, not | *| | AE/AWB scan | | changing | *+--------------------+---------------+--------------------+------------------+ *| SEARCHING | HAL finishes | FLASH_REQUIRED | converged but too| *| | AE scan | | dark w/o flash | *+--------------------+---------------+--------------------+------------------+ *| SEARCHING | AE/AWB_LOCK | LOCKED | values locked | *| | on | | | *+--------------------+---------------+--------------------+------------------+ *| CONVERGED | HAL initiates | SEARCHING | values locked | *| | AE/AWB scan | | | *+--------------------+---------------+--------------------+------------------+ *| CONVERGED | AE/AWB_LOCK | LOCKED | values locked | *| | on | | | *+--------------------+---------------+--------------------+------------------+ *| FLASH_REQUIRED | HAL initiates | SEARCHING | values locked | *| | AE/AWB scan | | | *+--------------------+---------------+--------------------+------------------+ *| FLASH_REQUIRED | AE/AWB_LOCK | LOCKED | values locked | *| | on | | | *+--------------------+---------------+--------------------+------------------+ *| LOCKED | AE/AWB_LOCK | SEARCHING | values not good | *| | off | | after unlock | *+--------------------+---------------+--------------------+------------------+ *| LOCKED | AE/AWB_LOCK | CONVERGED | values good | *| | off | | after unlock | *+--------------------+---------------+--------------------+------------------+ *| LOCKED | AE_LOCK | FLASH_REQUIRED | exposure good, | *| | off | | but too dark | *+--------------------+---------------+--------------------+------------------+ *| All AE states | PRECAPTURE_ | PRECAPTURE | Start precapture | *| | START | | sequence | *+--------------------+---------------+--------------------+------------------+ *| PRECAPTURE | Sequence done.| CONVERGED | Ready for high- | *| | AE_LOCK off | | quality capture | *+--------------------+---------------+--------------------+------------------+ *| PRECAPTURE | Sequence done.| LOCKED | Ready for high- | *| | AE_LOCK on | | quality capture | *+--------------------+---------------+--------------------+------------------+ * */ /** * S5. Cropping: * * Cropping of the full pixel array (for digital zoom and other use cases where * a smaller FOV is desirable) is communicated through the * ANDROID_SCALER_CROP_REGION setting. This is a per-request setting, and can * change on a per-request basis, which is critical for implementing smooth * digital zoom. * * The region is defined as a rectangle (x, y, width, height), with (x, y) * describing the top-left corner of the rectangle. The rectangle is defined on * the coordinate system of the sensor active pixel array, with (0,0) being the * top-left pixel of the active pixel array. Therefore, the width and height * cannot be larger than the dimensions reported in the * ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY static info field. The minimum allowed * width and height are reported by the HAL through the * ANDROID_SCALER_MAX_DIGITAL_ZOOM static info field, which describes the * maximum supported zoom factor. Therefore, the minimum crop region width and * height are: * * {width, height} = * { floor(ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY[0] / * ANDROID_SCALER_MAX_DIGITAL_ZOOM), * floor(ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY[1] / * ANDROID_SCALER_MAX_DIGITAL_ZOOM) } * * If the crop region needs to fulfill specific requirements (for example, it * needs to start on even coordinates, and its width/height needs to be even), * the HAL must do the necessary rounding and write out the final crop region * used in the output result metadata. Similarly, if the HAL implements video * stabilization, it must adjust the result crop region to describe the region * actually included in the output after video stabilization is applied. In * general, a camera-using application must be able to determine the field of * view it is receiving based on the crop region, the dimensions of the image * sensor, and the lens focal length. * * It is assumed that the cropping is applied after raw to other color space * conversion. Raw streams (RAW16 and RAW_OPAQUE) don't have this conversion stage, * and are not croppable. Therefore, the crop region must be ignored by the HAL * for raw streams. * * Since the crop region applies to all non-raw streams, which may have different aspect * ratios than the crop region, the exact sensor region used for each stream may * be smaller than the crop region. Specifically, each stream should maintain * square pixels and its aspect ratio by minimally further cropping the defined * crop region. If the stream's aspect ratio is wider than the crop region, the * stream should be further cropped vertically, and if the stream's aspect ratio * is narrower than the crop region, the stream should be further cropped * horizontally. * * In all cases, the stream crop must be centered within the full crop region, * and each stream is only either cropped horizontally or vertical relative to * the full crop region, never both. * * For example, if two streams are defined, a 640x480 stream (4:3 aspect), and a * 1280x720 stream (16:9 aspect), below demonstrates the expected output regions * for each stream for a few sample crop regions, on a hypothetical 3 MP (2000 x * 1500 pixel array) sensor. * * Crop region: (500, 375, 1000, 750) (4:3 aspect ratio) * * 640x480 stream crop: (500, 375, 1000, 750) (equal to crop region) * 1280x720 stream crop: (500, 469, 1000, 562) (marked with =) * * 0 1000 2000 * +---------+---------+---------+----------+ * | Active pixel array | * | | * | | * + +-------------------+ + 375 * | | | | * | O===================O | * | I 1280x720 stream I | * + I I + 750 * | I I | * | O===================O | * | | | | * + +-------------------+ + 1125 * | Crop region, 640x480 stream | * | | * | | * +---------+---------+---------+----------+ 1500 * * Crop region: (500, 375, 1333, 750) (16:9 aspect ratio) * * 640x480 stream crop: (666, 375, 1000, 750) (marked with =) * 1280x720 stream crop: (500, 375, 1333, 750) (equal to crop region) * * 0 1000 2000 * +---------+---------+---------+----------+ * | Active pixel array | * | | * | | * + +---O==================O---+ + 375 * | | I 640x480 stream I | | * | | I I | | * | | I I | | * + | I I | + 750 * | | I I | | * | | I I | | * | | I I | | * + +---O==================O---+ + 1125 * | Crop region, 1280x720 stream | * | | * | | * +---------+---------+---------+----------+ 1500 * * Crop region: (500, 375, 750, 750) (1:1 aspect ratio) * * 640x480 stream crop: (500, 469, 750, 562) (marked with =) * 1280x720 stream crop: (500, 543, 750, 414) (marged with #) * * 0 1000 2000 * +---------+---------+---------+----------+ * | Active pixel array | * | | * | | * + +--------------+ + 375 * | O==============O | * | ################ | * | # # | * + # # + 750 * | # # | * | ################ 1280x720 | * | O==============O 640x480 | * + +--------------+ + 1125 * | Crop region | * | | * | | * +---------+---------+---------+----------+ 1500 * * And a final example, a 1024x1024 square aspect ratio stream instead of the * 480p stream: * * Crop region: (500, 375, 1000, 750) (4:3 aspect ratio) * * 1024x1024 stream crop: (625, 375, 750, 750) (marked with #) * 1280x720 stream crop: (500, 469, 1000, 562) (marked with =) * * 0 1000 2000 * +---------+---------+---------+----------+ * | Active pixel array | * | | * | 1024x1024 stream | * + +--###############--+ + 375 * | | # # | | * | O===================O | * | I 1280x720 stream I | * + I I + 750 * | I I | * | O===================O | * | | # # | | * + +--###############--+ + 1125 * | Crop region | * | | * | | * +---------+---------+---------+----------+ 1500 * */ /** * S6. Error management: * * Camera HAL device ops functions that have a return value will all return * -ENODEV / NULL in case of a serious error. This means the device cannot * continue operation, and must be closed by the framework. Once this error is * returned by some method, or if notify() is called with ERROR_DEVICE, only * the close() method can be called successfully. All other methods will return * -ENODEV / NULL. * * If a device op is called in the wrong sequence, for example if the framework * calls configure_streams() is called before initialize(), the device must * return -ENOSYS from the call, and do nothing. * * Transient errors in image capture must be reported through notify() as follows: * * - The failure of an entire capture to occur must be reported by the HAL by * calling notify() with ERROR_REQUEST. Individual errors for the result * metadata or the output buffers must not be reported in this case. * * - If the metadata for a capture cannot be produced, but some image buffers * were filled, the HAL must call notify() with ERROR_RESULT. * * - If an output image buffer could not be filled, but either the metadata was * produced or some other buffers were filled, the HAL must call notify() with * ERROR_BUFFER for each failed buffer. * * In each of these transient failure cases, the HAL must still call * process_capture_result, with valid output and input (if an input buffer was * submitted) buffer_handle_t. If the result metadata could not be produced, it * should be NULL. If some buffers could not be filled, they must be returned with * process_capture_result in the error state, their release fences must be set to * the acquire fences passed by the framework, or -1 if they have been waited on by * the HAL already. * * Invalid input arguments result in -EINVAL from the appropriate methods. In * that case, the framework must act as if that call had never been made. * */ /** * S7. Key Performance Indicator (KPI) glossary: * * This includes some critical definitions that are used by KPI metrics. * * Pipeline Latency: * For a given capture request, the duration from the framework calling * process_capture_request to the HAL sending capture result and all buffers * back by process_capture_result call. To make the Pipeline Latency measure * independent of frame rate, it is measured by frame count. * * For example, when frame rate is 30 (fps), the frame duration (time interval * between adjacent frame capture time) is 33 (ms). * If it takes 5 frames for framework to get the result and buffers back for * a given request, then the Pipeline Latency is 5 (frames), instead of * 5 x 33 = 165 (ms). * * The Pipeline Latency is determined by android.request.pipelineDepth and * android.request.pipelineMaxDepth, see their definitions for more details. * */ /** * S8. Sample Use Cases: * * This includes some typical use case examples the camera HAL may support. * * S8.1 Zero Shutter Lag (ZSL) with CAMERA3_STREAM_BIDIRECTIONAL stream. * * For this use case, the bidirectional stream will be used by the framework as follows: * * 1. The framework includes a buffer from this stream as output buffer in a * request as normal. * * 2. Once the HAL device returns a filled output buffer to the framework, * the framework may do one of two things with the filled buffer: * * 2. a. The framework uses the filled data, and returns the now-used buffer * to the stream queue for reuse. This behavior exactly matches the * OUTPUT type of stream. * * 2. b. The framework wants to reprocess the filled data, and uses the * buffer as an input buffer for a request. Once the HAL device has * used the reprocessing buffer, it then returns it to the * framework. The framework then returns the now-used buffer to the * stream queue for reuse. * * 3. The HAL device will be given the buffer again as an output buffer for * a request at some future point. * * For ZSL use case, the pixel format for bidirectional stream will be * HAL_PIXEL_FORMAT_RAW_OPAQUE or HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED if it * is listed in android.scaler.availableInputOutputFormatsMap. When * HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, the gralloc * usage flags for the consumer endpoint will be set to GRALLOC_USAGE_HW_CAMERA_ZSL. * A configuration stream list that has BIDIRECTIONAL stream used as input, will * usually also have a distinct OUTPUT stream to get the reprocessing data. For example, * for the ZSL use case, the stream list might be configured with the following: * * - A HAL_PIXEL_FORMAT_RAW_OPAQUE bidirectional stream is used * as input. * - And a HAL_PIXEL_FORMAT_BLOB (JPEG) output stream. * */ /** * S9. Notes on Controls and Metadata * * This section contains notes about the interpretation and usage of various metadata tags. * * S9.1 HIGH_QUALITY and FAST modes. * * Many camera post-processing blocks may be listed as having HIGH_QUALITY, * FAST, and OFF operating modes. These blocks will typically also have an * 'available modes' tag representing which of these operating modes are * available on a given device. The general policy regarding implementing * these modes is as follows: * * 1. Operating mode controls of hardware blocks that cannot be disabled * must not list OFF in their corresponding 'available modes' tags. * * 2. OFF will always be included in their corresponding 'available modes' * tag if it is possible to disable that hardware block. * * 3. FAST must always be included in the 'available modes' tags for all * post-processing blocks supported on the device. If a post-processing * block also has a slower and higher quality operating mode that does * not meet the framerate requirements for FAST mode, HIGH_QUALITY should * be included in the 'available modes' tag to represent this operating * mode. */ __BEGIN_DECLS struct camera3_device; /********************************************************************** * * Camera3 stream and stream buffer definitions. * * These structs and enums define the handles and contents of the input and * output streams connecting the HAL to various framework and application buffer * consumers. Each stream is backed by a gralloc buffer queue. * */ /** * camera3_stream_type_t: * * The type of the camera stream, which defines whether the camera HAL device is * the producer or the consumer for that stream, and how the buffers of the * stream relate to the other streams. */ typedef enum camera3_stream_type { /** * This stream is an output stream; the camera HAL device will be * responsible for filling buffers from this stream with newly captured or * reprocessed image data. */ CAMERA3_STREAM_OUTPUT = 0, /** * This stream is an input stream; the camera HAL device will be responsible * for reading buffers from this stream and sending them through the camera * processing pipeline, as if the buffer was a newly captured image from the * imager. * * The pixel format for input stream can be any format reported by * android.scaler.availableInputOutputFormatsMap. The pixel format of the * output stream that is used to produce the reprocessing data may be any * format reported by android.scaler.availableStreamConfigurations. The * supported input/output stream combinations depends the camera device * capabilities, see android.scaler.availableInputOutputFormatsMap for * stream map details. * * This kind of stream is generally used to reprocess data into higher * quality images (that otherwise would cause a frame rate performance * loss), or to do off-line reprocessing. * */ CAMERA3_STREAM_INPUT = 1, /** * This stream can be used for input and output. Typically, the stream is * used as an output stream, but occasionally one already-filled buffer may * be sent back to the HAL device for reprocessing. * * This kind of stream is meant generally for Zero Shutter Lag (ZSL) * features, where copying the captured image from the output buffer to the * reprocessing input buffer would be expensive. See S8.1 for more details. * * Note that the HAL will always be reprocessing data it produced. * */ CAMERA3_STREAM_BIDIRECTIONAL = 2, /** * Total number of framework-defined stream types */ CAMERA3_NUM_STREAM_TYPES } camera3_stream_type_t; /** * camera3_stream_t: * * A handle to a single camera input or output stream. A stream is defined by * the framework by its buffer resolution and format, and additionally by the * HAL with the gralloc usage flags and the maximum in-flight buffer count. * * The stream structures are owned by the framework, but pointers to a * camera3_stream passed into the HAL by configure_streams() are valid until the * end of the first subsequent configure_streams() call that _does not_ include * that camera3_stream as an argument, or until the end of the close() call. * * All camera3_stream framework-controlled members are immutable once the * camera3_stream is passed into configure_streams(). The HAL may only change * the HAL-controlled parameters during a configure_streams() call, except for * the contents of the private pointer. * * If a configure_streams() call returns a non-fatal error, all active streams * remain valid as if configure_streams() had not been called. * * The endpoint of the stream is not visible to the camera HAL device. * In DEVICE_API_VERSION_3_1, this was changed to share consumer usage flags * on streams where the camera is a producer (OUTPUT and BIDIRECTIONAL stream * types) see the usage field below. */ typedef struct camera3_stream { /***** * Set by framework before configure_streams() */ /** * The type of the stream, one of the camera3_stream_type_t values. */ int stream_type; /** * The width in pixels of the buffers in this stream */ uint32_t width; /** * The height in pixels of the buffers in this stream */ uint32_t height; /** * The pixel format for the buffers in this stream. Format is a value from * the HAL_PIXEL_FORMAT_* list in system/core/include/system/graphics.h, or * from device-specific headers. * * If HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, then the platform * gralloc module will select a format based on the usage flags provided by * the camera device and the other endpoint of the stream. * * <= CAMERA_DEVICE_API_VERSION_3_1: * * The camera HAL device must inspect the buffers handed to it in the * subsequent register_stream_buffers() call to obtain the * implementation-specific format details, if necessary. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * register_stream_buffers() won't be called by the framework, so the HAL * should configure the ISP and sensor pipeline based purely on the sizes, * usage flags, and formats for the configured streams. */ int format; /***** * Set by HAL during configure_streams(). */ /** * The gralloc usage flags for this stream, as needed by the HAL. The usage * flags are defined in gralloc.h (GRALLOC_USAGE_*), or in device-specific * headers. * * For output streams, these are the HAL's producer usage flags. For input * streams, these are the HAL's consumer usage flags. The usage flags from * the producer and the consumer will be combined together and then passed * to the platform gralloc HAL module for allocating the gralloc buffers for * each stream. * * Version information: * * == CAMERA_DEVICE_API_VERSION_3_0: * * No initial value guaranteed when passed via configure_streams(). * HAL may not use this field as input, and must write over this field * with its usage flags. * * >= CAMERA_DEVICE_API_VERSION_3_1: * * For stream_type OUTPUT and BIDIRECTIONAL, when passed via * configure_streams(), the initial value of this is the consumer's * usage flags. The HAL may use these consumer flags to decide stream * configuration. * For stream_type INPUT, when passed via configure_streams(), the initial * value of this is 0. * For all streams passed via configure_streams(), the HAL must write * over this field with its usage flags. */ uint32_t usage; /** * The maximum number of buffers the HAL device may need to have dequeued at * the same time. The HAL device may not have more buffers in-flight from * this stream than this value. */ uint32_t max_buffers; /** * A handle to HAL-private information for the stream. Will not be inspected * by the framework code. */ void *priv; } camera3_stream_t; /** * camera3_stream_configuration_t: * * A structure of stream definitions, used by configure_streams(). This * structure defines all the output streams and the reprocessing input * stream for the current camera use case. */ typedef struct camera3_stream_configuration { /** * The total number of streams requested by the framework. This includes * both input and output streams. The number of streams will be at least 1, * and there will be at least one output-capable stream. */ uint32_t num_streams; /** * An array of camera stream pointers, defining the input/output * configuration for the camera HAL device. * * At most one input-capable stream may be defined (INPUT or BIDIRECTIONAL) * in a single configuration. * * At least one output-capable stream must be defined (OUTPUT or * BIDIRECTIONAL). */ camera3_stream_t **streams; } camera3_stream_configuration_t; /** * camera3_buffer_status_t: * * The current status of a single stream buffer. */ typedef enum camera3_buffer_status { /** * The buffer is in a normal state, and can be used after waiting on its * sync fence. */ CAMERA3_BUFFER_STATUS_OK = 0, /** * The buffer does not contain valid data, and the data in it should not be * used. The sync fence must still be waited on before reusing the buffer. */ CAMERA3_BUFFER_STATUS_ERROR = 1 } camera3_buffer_status_t; /** * camera3_stream_buffer_t: * * A single buffer from a camera3 stream. It includes a handle to its parent * stream, the handle to the gralloc buffer itself, and sync fences * * The buffer does not specify whether it is to be used for input or output; * that is determined by its parent stream type and how the buffer is passed to * the HAL device. */ typedef struct camera3_stream_buffer { /** * The handle of the stream this buffer is associated with */ camera3_stream_t *stream; /** * The native handle to the buffer */ buffer_handle_t *buffer; /** * Current state of the buffer, one of the camera3_buffer_status_t * values. The framework will not pass buffers to the HAL that are in an * error state. In case a buffer could not be filled by the HAL, it must * have its status set to CAMERA3_BUFFER_STATUS_ERROR when returned to the * framework with process_capture_result(). */ int status; /** * The acquire sync fence for this buffer. The HAL must wait on this fence * fd before attempting to read from or write to this buffer. * * The framework may be set to -1 to indicate that no waiting is necessary * for this buffer. * * When the HAL returns an output buffer to the framework with * process_capture_result(), the acquire_fence must be set to -1. If the HAL * never waits on the acquire_fence due to an error in filling a buffer, * when calling process_capture_result() the HAL must set the release_fence * of the buffer to be the acquire_fence passed to it by the framework. This * will allow the framework to wait on the fence before reusing the buffer. * * For input buffers, the HAL must not change the acquire_fence field during * the process_capture_request() call. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * When the HAL returns an input buffer to the framework with * process_capture_result(), the acquire_fence must be set to -1. If the HAL * never waits on input buffer acquire fence due to an error, the sync * fences should be handled similarly to the way they are handled for output * buffers. */ int acquire_fence; /** * The release sync fence for this buffer. The HAL must set this fence when * returning buffers to the framework, or write -1 to indicate that no * waiting is required for this buffer. * * For the output buffers, the fences must be set in the output_buffers * array passed to process_capture_result(). * * <= CAMERA_DEVICE_API_VERSION_3_1: * * For the input buffer, the release fence must be set by the * process_capture_request() call. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * For the input buffer, the fences must be set in the input_buffer * passed to process_capture_result(). * * After signaling the release_fence for this buffer, the HAL * should not make any further attempts to access this buffer as the * ownership has been fully transferred back to the framework. * * If a fence of -1 was specified then the ownership of this buffer * is transferred back immediately upon the call of process_capture_result. */ int release_fence; } camera3_stream_buffer_t; /** * camera3_stream_buffer_set_t: * * The complete set of gralloc buffers for a stream. This structure is given to * register_stream_buffers() to allow the camera HAL device to register/map/etc * newly allocated stream buffers. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * Deprecated (and not used). In particular, * register_stream_buffers is also deprecated and will never be invoked. * */ typedef struct camera3_stream_buffer_set { /** * The stream handle for the stream these buffers belong to */ camera3_stream_t *stream; /** * The number of buffers in this stream. It is guaranteed to be at least * stream->max_buffers. */ uint32_t num_buffers; /** * The array of gralloc buffer handles for this stream. If the stream format * is set to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, the camera HAL device * should inspect the passed-in buffers to determine any platform-private * pixel format information. */ buffer_handle_t **buffers; } camera3_stream_buffer_set_t; /** * camera3_jpeg_blob: * * Transport header for compressed JPEG buffers in output streams. * * To capture JPEG images, a stream is created using the pixel format * HAL_PIXEL_FORMAT_BLOB. The buffer size for the stream is calculated by the * framework, based on the static metadata field android.jpeg.maxSize. Since * compressed JPEG images are of variable size, the HAL needs to include the * final size of the compressed image using this structure inside the output * stream buffer. The JPEG blob ID field must be set to CAMERA3_JPEG_BLOB_ID. * * Transport header should be at the end of the JPEG output stream buffer. That * means the jpeg_blob_id must start at byte[buffer_size - * sizeof(camera3_jpeg_blob)], where the buffer_size is the size of gralloc buffer. * Any HAL using this transport header must account for it in android.jpeg.maxSize * The JPEG data itself starts at the beginning of the buffer and should be * jpeg_size bytes long. */ typedef struct camera3_jpeg_blob { uint16_t jpeg_blob_id; uint32_t jpeg_size; } camera3_jpeg_blob_t; enum { CAMERA3_JPEG_BLOB_ID = 0x00FF }; /********************************************************************** * * Message definitions for the HAL notify() callback. * * These definitions are used for the HAL notify callback, to signal * asynchronous events from the HAL device to the Android framework. * */ /** * camera3_msg_type: * * Indicates the type of message sent, which specifies which member of the * message union is valid. * */ typedef enum camera3_msg_type { /** * An error has occurred. camera3_notify_msg.message.error contains the * error information. */ CAMERA3_MSG_ERROR = 1, /** * The exposure of a given request has * begun. camera3_notify_msg.message.shutter contains the information * the capture. */ CAMERA3_MSG_SHUTTER = 2, /** * Number of framework message types */ CAMERA3_NUM_MESSAGES } camera3_msg_type_t; /** * Defined error codes for CAMERA_MSG_ERROR */ typedef enum camera3_error_msg_code { /** * A serious failure occured. No further frames or buffer streams will * be produced by the device. Device should be treated as closed. The * client must reopen the device to use it again. The frame_number field * is unused. */ CAMERA3_MSG_ERROR_DEVICE = 1, /** * An error has occurred in processing a request. No output (metadata or * buffers) will be produced for this request. The frame_number field * specifies which request has been dropped. Subsequent requests are * unaffected, and the device remains operational. */ CAMERA3_MSG_ERROR_REQUEST = 2, /** * An error has occurred in producing an output result metadata buffer * for a request, but output stream buffers for it will still be * available. Subsequent requests are unaffected, and the device remains * operational. The frame_number field specifies the request for which * result metadata won't be available. */ CAMERA3_MSG_ERROR_RESULT = 3, /** * An error has occurred in placing an output buffer into a stream for a * request. The frame metadata and other buffers may still be * available. Subsequent requests are unaffected, and the device remains * operational. The frame_number field specifies the request for which the * buffer was dropped, and error_stream contains a pointer to the stream * that dropped the frame.u */ CAMERA3_MSG_ERROR_BUFFER = 4, /** * Number of error types */ CAMERA3_MSG_NUM_ERRORS } camera3_error_msg_code_t; /** * camera3_error_msg_t: * * Message contents for CAMERA3_MSG_ERROR */ typedef struct camera3_error_msg { /** * Frame number of the request the error applies to. 0 if the frame number * isn't applicable to the error. */ uint32_t frame_number; /** * Pointer to the stream that had a failure. NULL if the stream isn't * applicable to the error. */ camera3_stream_t *error_stream; /** * The code for this error; one of the CAMERA_MSG_ERROR enum values. */ int error_code; } camera3_error_msg_t; /** * camera3_shutter_msg_t: * * Message contents for CAMERA3_MSG_SHUTTER */ typedef struct camera3_shutter_msg { /** * Frame number of the request that has begun exposure */ uint32_t frame_number; /** * Timestamp for the start of capture. This must match the capture result * metadata's sensor exposure start timestamp. */ uint64_t timestamp; } camera3_shutter_msg_t; /** * camera3_notify_msg_t: * * The message structure sent to camera3_callback_ops_t.notify() */ typedef struct camera3_notify_msg { /** * The message type. One of camera3_notify_msg_type, or a private extension. */ int type; union { /** * Error message contents. Valid if type is CAMERA3_MSG_ERROR */ camera3_error_msg_t error; /** * Shutter message contents. Valid if type is CAMERA3_MSG_SHUTTER */ camera3_shutter_msg_t shutter; /** * Generic message contents. Used to ensure a minimum size for custom * message types. */ uint8_t generic[32]; } message; } camera3_notify_msg_t; /********************************************************************** * * Capture request/result definitions for the HAL process_capture_request() * method, and the process_capture_result() callback. * */ /** * camera3_request_template_t: * * Available template types for * camera3_device_ops.construct_default_request_settings() */ typedef enum camera3_request_template { /** * Standard camera preview operation with 3A on auto. */ CAMERA3_TEMPLATE_PREVIEW = 1, /** * Standard camera high-quality still capture with 3A and flash on auto. */ CAMERA3_TEMPLATE_STILL_CAPTURE = 2, /** * Standard video recording plus preview with 3A on auto, torch off. */ CAMERA3_TEMPLATE_VIDEO_RECORD = 3, /** * High-quality still capture while recording video. Application will * include preview, video record, and full-resolution YUV or JPEG streams in * request. Must not cause stuttering on video stream. 3A on auto. */ CAMERA3_TEMPLATE_VIDEO_SNAPSHOT = 4, /** * Zero-shutter-lag mode. Application will request preview and * full-resolution data for each frame, and reprocess it to JPEG when a * still image is requested by user. Settings should provide highest-quality * full-resolution images without compromising preview frame rate. 3A on * auto. */ CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG = 5, /** * A basic template for direct application control of capture * parameters. All automatic control is disabled (auto-exposure, auto-white * balance, auto-focus), and post-processing parameters are set to preview * quality. The manual capture parameters (exposure, sensitivity, etc.) * are set to reasonable defaults, but should be overridden by the * application depending on the intended use case. */ CAMERA3_TEMPLATE_MANUAL = 6, /* Total number of templates */ CAMERA3_TEMPLATE_COUNT, /** * First value for vendor-defined request templates */ CAMERA3_VENDOR_TEMPLATE_START = 0x40000000 } camera3_request_template_t; /** * camera3_capture_request_t: * * A single request for image capture/buffer reprocessing, sent to the Camera * HAL device by the framework in process_capture_request(). * * The request contains the settings to be used for this capture, and the set of * output buffers to write the resulting image data in. It may optionally * contain an input buffer, in which case the request is for reprocessing that * input buffer instead of capturing a new image with the camera sensor. The * capture is identified by the frame_number. * * In response, the camera HAL device must send a camera3_capture_result * structure asynchronously to the framework, using the process_capture_result() * callback. */ typedef struct camera3_capture_request { /** * The frame number is an incrementing integer set by the framework to * uniquely identify this capture. It needs to be returned in the result * call, and is also used to identify the request in asynchronous * notifications sent to camera3_callback_ops_t.notify(). */ uint32_t frame_number; /** * The settings buffer contains the capture and processing parameters for * the request. As a special case, a NULL settings buffer indicates that the * settings are identical to the most-recently submitted capture request. A * NULL buffer cannot be used as the first submitted request after a * configure_streams() call. */ const camera_metadata_t *settings; /** * The input stream buffer to use for this request, if any. * * If input_buffer is NULL, then the request is for a new capture from the * imager. If input_buffer is valid, the request is for reprocessing the * image contained in input_buffer. * * In the latter case, the HAL must set the release_fence of the * input_buffer to a valid sync fence, or to -1 if the HAL does not support * sync, before process_capture_request() returns. * * The HAL is required to wait on the acquire sync fence of the input buffer * before accessing it. * * <= CAMERA_DEVICE_API_VERSION_3_1: * * Any input buffer included here will have been registered with the HAL * through register_stream_buffers() before its inclusion in a request. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * The buffers will not have been pre-registered with the HAL. * Subsequent requests may reuse buffers, or provide entirely new buffers. */ camera3_stream_buffer_t *input_buffer; /** * The number of output buffers for this capture request. Must be at least * 1. */ uint32_t num_output_buffers; /** * An array of num_output_buffers stream buffers, to be filled with image * data from this capture/reprocess. The HAL must wait on the acquire fences * of each stream buffer before writing to them. * * The HAL takes ownership of the actual buffer_handle_t entries in * output_buffers; the framework does not access them until they are * returned in a camera3_capture_result_t. * * <= CAMERA_DEVICE_API_VERSION_3_1: * * All the buffers included here will have been registered with the HAL * through register_stream_buffers() before their inclusion in a request. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * Any or all of the buffers included here may be brand new in this * request (having never before seen by the HAL). */ const camera3_stream_buffer_t *output_buffers; } camera3_capture_request_t; /** * camera3_capture_result_t: * * The result of a single capture/reprocess by the camera HAL device. This is * sent to the framework asynchronously with process_capture_result(), in * response to a single capture request sent to the HAL with * process_capture_request(). Multiple process_capture_result() calls may be * performed by the HAL for each request. * * Each call, all with the same frame * number, may contain some subset of the output buffers, and/or the result * metadata. The metadata may only be provided once for a given frame number; * all other calls must set the result metadata to NULL. * * The result structure contains the output metadata from this capture, and the * set of output buffers that have been/will be filled for this capture. Each * output buffer may come with a release sync fence that the framework will wait * on before reading, in case the buffer has not yet been filled by the HAL. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * The metadata may be provided multiple times for a single frame number. The * framework will accumulate together the final result set by combining each * partial result together into the total result set. * * If an input buffer is given in a request, the HAL must return it in one of * the process_capture_result calls, and the call may be to just return the input * buffer, without metadata and output buffers; the sync fences must be handled * the same way they are done for output buffers. * * * Performance considerations: * * Applications will also receive these partial results immediately, so sending * partial results is a highly recommended performance optimization to avoid * the total pipeline latency before sending the results for what is known very * early on in the pipeline. * * A typical use case might be calculating the AF state halfway through the * pipeline; by sending the state back to the framework immediately, we get a * 50% performance increase and perceived responsiveness of the auto-focus. * */ typedef struct camera3_capture_result { /** * The frame number is an incrementing integer set by the framework in the * submitted request to uniquely identify this capture. It is also used to * identify the request in asynchronous notifications sent to * camera3_callback_ops_t.notify(). */ uint32_t frame_number; /** * The result metadata for this capture. This contains information about the * final capture parameters, the state of the capture and post-processing * hardware, the state of the 3A algorithms, if enabled, and the output of * any enabled statistics units. * * Only one call to process_capture_result() with a given frame_number may * include the result metadata. All other calls for the same frame_number * must set this to NULL. * * If there was an error producing the result metadata, result must be an * empty metadata buffer, and notify() must be called with ERROR_RESULT. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * Multiple calls to process_capture_result() with a given frame_number * may include the result metadata. * * Partial metadata submitted should not include any metadata key returned * in a previous partial result for a given frame. Each new partial result * for that frame must also set a distinct partial_result value. * * If notify has been called with ERROR_RESULT, all further partial * results for that frame are ignored by the framework. */ const camera_metadata_t *result; /** * The number of output buffers returned in this result structure. Must be * less than or equal to the matching capture request's count. If this is * less than the buffer count in the capture request, at least one more call * to process_capture_result with the same frame_number must be made, to * return the remaining output buffers to the framework. This may only be * zero if the structure includes valid result metadata or an input buffer * is returned in this result. */ uint32_t num_output_buffers; /** * The handles for the output stream buffers for this capture. They may not * yet be filled at the time the HAL calls process_capture_result(); the * framework will wait on the release sync fences provided by the HAL before * reading the buffers. * * The HAL must set the stream buffer's release sync fence to a valid sync * fd, or to -1 if the buffer has already been filled. * * If the HAL encounters an error while processing the buffer, and the * buffer is not filled, the buffer's status field must be set to * CAMERA3_BUFFER_STATUS_ERROR. If the HAL did not wait on the acquire fence * before encountering the error, the acquire fence should be copied into * the release fence, to allow the framework to wait on the fence before * reusing the buffer. * * The acquire fence must be set to -1 for all output buffers. If * num_output_buffers is zero, this may be NULL. In that case, at least one * more process_capture_result call must be made by the HAL to provide the * output buffers. * * When process_capture_result is called with a new buffer for a frame, * all previous frames' buffers for that corresponding stream must have been * already delivered (the fences need not have yet been signaled). * * >= CAMERA_DEVICE_API_VERSION_3_2: * * Gralloc buffers for a frame may be sent to framework before the * corresponding SHUTTER-notify. * * Performance considerations: * * Buffers delivered to the framework will not be dispatched to the * application layer until a start of exposure timestamp has been received * via a SHUTTER notify() call. It is highly recommended to * dispatch that call as early as possible. */ const camera3_stream_buffer_t *output_buffers; /** * >= CAMERA_DEVICE_API_VERSION_3_2: * * The handle for the input stream buffer for this capture. It may not * yet be consumed at the time the HAL calls process_capture_result(); the * framework will wait on the release sync fences provided by the HAL before * reusing the buffer. * * The HAL should handle the sync fences the same way they are done for * output_buffers. * * Only one input buffer is allowed to be sent per request. Similarly to * output buffers, the ordering of returned input buffers must be * maintained by the HAL. * * Performance considerations: * * The input buffer should be returned as early as possible. If the HAL * supports sync fences, it can call process_capture_result to hand it back * with sync fences being set appropriately. If the sync fences are not * supported, the buffer can only be returned when it is consumed, which * may take long time; the HAL may choose to copy this input buffer to make * the buffer return sooner. */ const camera3_stream_buffer_t *input_buffer; /** * >= CAMERA_DEVICE_API_VERSION_3_2: * * In order to take advantage of partial results, the HAL must set the * static metadata android.request.partialResultCount to the number of * partial results it will send for each frame. * * Each new capture result with a partial result must set * this field (partial_result) to a distinct inclusive value between * 1 and android.request.partialResultCount. * * HALs not wishing to take advantage of this feature must not * set an android.request.partialResultCount or partial_result to a value * other than 1. * * This value must be set to 0 when a capture result contains buffers only * and no metadata. */ uint32_t partial_result; } camera3_capture_result_t; /********************************************************************** * * Callback methods for the HAL to call into the framework. * * These methods are used to return metadata and image buffers for a completed * or failed captures, and to notify the framework of asynchronous events such * as errors. * * The framework will not call back into the HAL from within these callbacks, * and these calls will not block for extended periods. * */ typedef struct camera3_callback_ops { /** * process_capture_result: * * Send results from a completed capture to the framework. * process_capture_result() may be invoked multiple times by the HAL in * response to a single capture request. This allows, for example, the * metadata and low-resolution buffers to be returned in one call, and * post-processed JPEG buffers in a later call, once it is available. Each * call must include the frame number of the request it is returning * metadata or buffers for. * * A component (buffer or metadata) of the complete result may only be * included in one process_capture_result call. A buffer for each stream, * and the result metadata, must be returned by the HAL for each request in * one of the process_capture_result calls, even in case of errors producing * some of the output. A call to process_capture_result() with neither * output buffers or result metadata is not allowed. * * The order of returning metadata and buffers for a single result does not * matter, but buffers for a given stream must be returned in FIFO order. So * the buffer for request 5 for stream A must always be returned before the * buffer for request 6 for stream A. This also applies to the result * metadata; the metadata for request 5 must be returned before the metadata * for request 6. * * However, different streams are independent of each other, so it is * acceptable and expected that the buffer for request 5 for stream A may be * returned after the buffer for request 6 for stream B is. And it is * acceptable that the result metadata for request 6 for stream B is * returned before the buffer for request 5 for stream A is. * * The HAL retains ownership of result structure, which only needs to be * valid to access during this call. The framework will copy whatever it * needs before this call returns. * * The output buffers do not need to be filled yet; the framework will wait * on the stream buffer release sync fence before reading the buffer * data. Therefore, this method should be called by the HAL as soon as * possible, even if some or all of the output buffers are still in * being filled. The HAL must include valid release sync fences into each * output_buffers stream buffer entry, or -1 if that stream buffer is * already filled. * * If the result buffer cannot be constructed for a request, the HAL should * return an empty metadata buffer, but still provide the output buffers and * their sync fences. In addition, notify() must be called with an * ERROR_RESULT message. * * If an output buffer cannot be filled, its status field must be set to * STATUS_ERROR. In addition, notify() must be called with a ERROR_BUFFER * message. * * If the entire capture has failed, then this method still needs to be * called to return the output buffers to the framework. All the buffer * statuses should be STATUS_ERROR, and the result metadata should be an * empty buffer. In addition, notify() must be called with a ERROR_REQUEST * message. In this case, individual ERROR_RESULT/ERROR_BUFFER messages * should not be sent. * * Performance requirements: * * This is a non-blocking call. The framework will return this call in 5ms. * * The pipeline latency (see S7 for definition) should be less than or equal to * 4 frame intervals, and must be less than or equal to 8 frame intervals. * */ void (*process_capture_result)(const struct camera3_callback_ops *, const camera3_capture_result_t *result); /** * notify: * * Asynchronous notification callback from the HAL, fired for various * reasons. Only for information independent of frame capture, or that * require specific timing. The ownership of the message structure remains * with the HAL, and the msg only needs to be valid for the duration of this * call. * * Multiple threads may call notify() simultaneously. * * <= CAMERA_DEVICE_API_VERSION_3_1: * * The notification for the start of exposure for a given request must be * sent by the HAL before the first call to process_capture_result() for * that request is made. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * Buffers delivered to the framework will not be dispatched to the * application layer until a start of exposure timestamp has been received * via a SHUTTER notify() call. It is highly recommended to * dispatch this call as early as possible. * * ------------------------------------------------------------------------ * Performance requirements: * * This is a non-blocking call. The framework will return this call in 5ms. */ void (*notify)(const struct camera3_callback_ops *, const camera3_notify_msg_t *msg); } camera3_callback_ops_t; /********************************************************************** * * Camera device operations * */ typedef struct camera3_device_ops { /** * initialize: * * One-time initialization to pass framework callback function pointers to * the HAL. Will be called once after a successful open() call, before any * other functions are called on the camera3_device_ops structure. * * Performance requirements: * * This should be a non-blocking call. The HAL should return from this call * in 5ms, and must return from this call in 10ms. * * Return values: * * 0: On successful initialization * * -ENODEV: If initialization fails. Only close() can be called successfully * by the framework after this. */ int (*initialize)(const struct camera3_device *, const camera3_callback_ops_t *callback_ops); /********************************************************************** * Stream management */ /** * configure_streams: * * CAMERA_DEVICE_API_VERSION_3_0 only: * * Reset the HAL camera device processing pipeline and set up new input and * output streams. This call replaces any existing stream configuration with * the streams defined in the stream_list. This method will be called at * least once after initialize() before a request is submitted with * process_capture_request(). * * The stream_list must contain at least one output-capable stream, and may * not contain more than one input-capable stream. * * The stream_list may contain streams that are also in the currently-active * set of streams (from the previous call to configure_stream()). These * streams will already have valid values for usage, max_buffers, and the * private pointer. * * If such a stream has already had its buffers registered, * register_stream_buffers() will not be called again for the stream, and * buffers from the stream can be immediately included in input requests. * * If the HAL needs to change the stream configuration for an existing * stream due to the new configuration, it may rewrite the values of usage * and/or max_buffers during the configure call. * * The framework will detect such a change, and will then reallocate the * stream buffers, and call register_stream_buffers() again before using * buffers from that stream in a request. * * If a currently-active stream is not included in stream_list, the HAL may * safely remove any references to that stream. It will not be reused in a * later configure() call by the framework, and all the gralloc buffers for * it will be freed after the configure_streams() call returns. * * The stream_list structure is owned by the framework, and may not be * accessed once this call completes. The address of an individual * camera3_stream_t structure will remain valid for access by the HAL until * the end of the first configure_stream() call which no longer includes * that camera3_stream_t in the stream_list argument. The HAL may not change * values in the stream structure outside of the private pointer, except for * the usage and max_buffers members during the configure_streams() call * itself. * * If the stream is new, the usage, max_buffer, and private pointer fields * of the stream structure will all be set to 0. The HAL device must set * these fields before the configure_streams() call returns. These fields * are then used by the framework and the platform gralloc module to * allocate the gralloc buffers for each stream. * * Before such a new stream can have its buffers included in a capture * request, the framework will call register_stream_buffers() with that * stream. However, the framework is not required to register buffers for * _all_ streams before submitting a request. This allows for quick startup * of (for example) a preview stream, with allocation for other streams * happening later or concurrently. * * ------------------------------------------------------------------------ * CAMERA_DEVICE_API_VERSION_3_1 only: * * Reset the HAL camera device processing pipeline and set up new input and * output streams. This call replaces any existing stream configuration with * the streams defined in the stream_list. This method will be called at * least once after initialize() before a request is submitted with * process_capture_request(). * * The stream_list must contain at least one output-capable stream, and may * not contain more than one input-capable stream. * * The stream_list may contain streams that are also in the currently-active * set of streams (from the previous call to configure_stream()). These * streams will already have valid values for usage, max_buffers, and the * private pointer. * * If such a stream has already had its buffers registered, * register_stream_buffers() will not be called again for the stream, and * buffers from the stream can be immediately included in input requests. * * If the HAL needs to change the stream configuration for an existing * stream due to the new configuration, it may rewrite the values of usage * and/or max_buffers during the configure call. * * The framework will detect such a change, and will then reallocate the * stream buffers, and call register_stream_buffers() again before using * buffers from that stream in a request. * * If a currently-active stream is not included in stream_list, the HAL may * safely remove any references to that stream. It will not be reused in a * later configure() call by the framework, and all the gralloc buffers for * it will be freed after the configure_streams() call returns. * * The stream_list structure is owned by the framework, and may not be * accessed once this call completes. The address of an individual * camera3_stream_t structure will remain valid for access by the HAL until * the end of the first configure_stream() call which no longer includes * that camera3_stream_t in the stream_list argument. The HAL may not change * values in the stream structure outside of the private pointer, except for * the usage and max_buffers members during the configure_streams() call * itself. * * If the stream is new, max_buffer, and private pointer fields of the * stream structure will all be set to 0. The usage will be set to the * consumer usage flags. The HAL device must set these fields before the * configure_streams() call returns. These fields are then used by the * framework and the platform gralloc module to allocate the gralloc * buffers for each stream. * * Before such a new stream can have its buffers included in a capture * request, the framework will call register_stream_buffers() with that * stream. However, the framework is not required to register buffers for * _all_ streams before submitting a request. This allows for quick startup * of (for example) a preview stream, with allocation for other streams * happening later or concurrently. * * ------------------------------------------------------------------------ * >= CAMERA_DEVICE_API_VERSION_3_2: * * Reset the HAL camera device processing pipeline and set up new input and * output streams. This call replaces any existing stream configuration with * the streams defined in the stream_list. This method will be called at * least once after initialize() before a request is submitted with * process_capture_request(). * * The stream_list must contain at least one output-capable stream, and may * not contain more than one input-capable stream. * * The stream_list may contain streams that are also in the currently-active * set of streams (from the previous call to configure_stream()). These * streams will already have valid values for usage, max_buffers, and the * private pointer. * * If the HAL needs to change the stream configuration for an existing * stream due to the new configuration, it may rewrite the values of usage * and/or max_buffers during the configure call. * * The framework will detect such a change, and may then reallocate the * stream buffers before using buffers from that stream in a request. * * If a currently-active stream is not included in stream_list, the HAL may * safely remove any references to that stream. It will not be reused in a * later configure() call by the framework, and all the gralloc buffers for * it will be freed after the configure_streams() call returns. * * The stream_list structure is owned by the framework, and may not be * accessed once this call completes. The address of an individual * camera3_stream_t structure will remain valid for access by the HAL until * the end of the first configure_stream() call which no longer includes * that camera3_stream_t in the stream_list argument. The HAL may not change * values in the stream structure outside of the private pointer, except for * the usage and max_buffers members during the configure_streams() call * itself. * * If the stream is new, max_buffer, and private pointer fields of the * stream structure will all be set to 0. The usage will be set to the * consumer usage flags. The HAL device must set these fields before the * configure_streams() call returns. These fields are then used by the * framework and the platform gralloc module to allocate the gralloc * buffers for each stream. * * Newly allocated buffers may be included in a capture request at any time * by the framework. Once a gralloc buffer is returned to the framework * with process_capture_result (and its respective release_fence has been * signaled) the framework may free or reuse it at any time. * * ------------------------------------------------------------------------ * * Preconditions: * * The framework will only call this method when no captures are being * processed. That is, all results have been returned to the framework, and * all in-flight input and output buffers have been returned and their * release sync fences have been signaled by the HAL. The framework will not * submit new requests for capture while the configure_streams() call is * underway. * * Postconditions: * * The HAL device must configure itself to provide maximum possible output * frame rate given the sizes and formats of the output streams, as * documented in the camera device's static metadata. * * Performance requirements: * * This call is expected to be heavyweight and possibly take several hundred * milliseconds to complete, since it may require resetting and * reconfiguring the image sensor and the camera processing pipeline. * Nevertheless, the HAL device should attempt to minimize the * reconfiguration delay to minimize the user-visible pauses during * application operational mode changes (such as switching from still * capture to video recording). * * The HAL should return from this call in 500ms, and must return from this * call in 1000ms. * * Return values: * * 0: On successful stream configuration * * -EINVAL: If the requested stream configuration is invalid. Some examples * of invalid stream configurations include: * * - Including more than 1 input-capable stream (INPUT or * BIDIRECTIONAL) * * - Not including any output-capable streams (OUTPUT or * BIDIRECTIONAL) * * - Including streams with unsupported formats, or an unsupported * size for that format. * * - Including too many output streams of a certain format. * * Note that the framework submitting an invalid stream * configuration is not normal operation, since stream * configurations are checked before configure. An invalid * configuration means that a bug exists in the framework code, or * there is a mismatch between the HAL's static metadata and the * requirements on streams. * * -ENODEV: If there has been a fatal error and the device is no longer * operational. Only close() can be called successfully by the * framework after this error is returned. */ int (*configure_streams)(const struct camera3_device *, camera3_stream_configuration_t *stream_list); /** * register_stream_buffers: * * >= CAMERA_DEVICE_API_VERSION_3_2: * * DEPRECATED. This will not be called and must be set to NULL. * * <= CAMERA_DEVICE_API_VERSION_3_1: * * Register buffers for a given stream with the HAL device. This method is * called by the framework after a new stream is defined by * configure_streams, and before buffers from that stream are included in a * capture request. If the same stream is listed in a subsequent * configure_streams() call, register_stream_buffers will _not_ be called * again for that stream. * * The framework does not need to register buffers for all configured * streams before it submits the first capture request. This allows quick * startup for preview (or similar use cases) while other streams are still * being allocated. * * This method is intended to allow the HAL device to map or otherwise * prepare the buffers for later use. The buffers passed in will already be * locked for use. At the end of the call, all the buffers must be ready to * be returned to the stream. The buffer_set argument is only valid for the * duration of this call. * * If the stream format was set to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, * the camera HAL should inspect the passed-in buffers here to determine any * platform-private pixel format information. * * Performance requirements: * * This should be a non-blocking call. The HAL should return from this call * in 1ms, and must return from this call in 5ms. * * Return values: * * 0: On successful registration of the new stream buffers * * -EINVAL: If the stream_buffer_set does not refer to a valid active * stream, or if the buffers array is invalid. * * -ENOMEM: If there was a failure in registering the buffers. The framework * must consider all the stream buffers to be unregistered, and can * try to register again later. * * -ENODEV: If there is a fatal error, and the device is no longer * operational. Only close() can be called successfully by the * framework after this error is returned. */ int (*register_stream_buffers)(const struct camera3_device *, const camera3_stream_buffer_set_t *buffer_set); /********************************************************************** * Request creation and submission */ /** * construct_default_request_settings: * * Create capture settings for standard camera use cases. * * The device must return a settings buffer that is configured to meet the * requested use case, which must be one of the CAMERA3_TEMPLATE_* * enums. All request control fields must be included. * * The HAL retains ownership of this structure, but the pointer to the * structure must be valid until the device is closed. The framework and the * HAL may not modify the buffer once it is returned by this call. The same * buffer may be returned for subsequent calls for the same template, or for * other templates. * * Performance requirements: * * This should be a non-blocking call. The HAL should return from this call * in 1ms, and must return from this call in 5ms. * * Return values: * * Valid metadata: On successful creation of a default settings * buffer. * * NULL: In case of a fatal error. After this is returned, only * the close() method can be called successfully by the * framework. */ const camera_metadata_t* (*construct_default_request_settings)( const struct camera3_device *, int type); /** * process_capture_request: * * Send a new capture request to the HAL. The HAL should not return from * this call until it is ready to accept the next request to process. Only * one call to process_capture_request() will be made at a time by the * framework, and the calls will all be from the same thread. The next call * to process_capture_request() will be made as soon as a new request and * its associated buffers are available. In a normal preview scenario, this * means the function will be called again by the framework almost * instantly. * * The actual request processing is asynchronous, with the results of * capture being returned by the HAL through the process_capture_result() * call. This call requires the result metadata to be available, but output * buffers may simply provide sync fences to wait on. Multiple requests are * expected to be in flight at once, to maintain full output frame rate. * * The framework retains ownership of the request structure. It is only * guaranteed to be valid during this call. The HAL device must make copies * of the information it needs to retain for the capture processing. The HAL * is responsible for waiting on and closing the buffers' fences and * returning the buffer handles to the framework. * * The HAL must write the file descriptor for the input buffer's release * sync fence into input_buffer->release_fence, if input_buffer is not * NULL. If the HAL returns -1 for the input buffer release sync fence, the * framework is free to immediately reuse the input buffer. Otherwise, the * framework will wait on the sync fence before refilling and reusing the * input buffer. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * The input/output buffers provided by the framework in each request * may be brand new (having never before seen by the HAL). * * ------------------------------------------------------------------------ * Performance considerations: * * Handling a new buffer should be extremely lightweight and there should be * no frame rate degradation or frame jitter introduced. * * This call must return fast enough to ensure that the requested frame * rate can be sustained, especially for streaming cases (post-processing * quality settings set to FAST). The HAL should return this call in 1 * frame interval, and must return from this call in 4 frame intervals. * * Return values: * * 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 * 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 * stream buffers' fences and the buffer handles; the HAL should * not close the fences or return these buffers with * process_capture_result. * * -ENODEV: If the camera device has encountered a serious error. After this * error is returned, only the close() method can be successfully * called by the framework. * */ int (*process_capture_request)(const struct camera3_device *, camera3_capture_request_t *request); /********************************************************************** * Miscellaneous methods */ /** * get_metadata_vendor_tag_ops: * * Get methods to query for vendor extension metadata tag information. The * HAL should fill in all the vendor tag operation methods, or leave ops * unchanged if no vendor tags are defined. * * The definition of vendor_tag_query_ops_t can be found in * system/media/camera/include/system/camera_metadata.h. * * >= CAMERA_DEVICE_API_VERSION_3_2: * DEPRECATED. This function has been deprecated and should be set to * NULL by the HAL. Please implement get_vendor_tag_ops in camera_common.h * instead. */ void (*get_metadata_vendor_tag_ops)(const struct camera3_device*, vendor_tag_query_ops_t* ops); /** * dump: * * Print out debugging state for the camera device. This will be called by * the framework when the camera service is asked for a debug dump, which * happens when using the dumpsys tool, or when capturing a bugreport. * * 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 during camera operation. * Any synchronization primitives used (such as mutex locks or semaphores) * should be acquired with a timeout. */ void (*dump)(const struct camera3_device *, int fd); /** * flush: * * Flush all currently in-process captures and all buffers in the pipeline * on the given device. The framework will use this to dump all state as * quickly as possible in order to prepare for a configure_streams() call. * * No buffers are required to be successfully returned, so every buffer * held at the time of flush() (whether successfully filled or not) may be * returned with CAMERA3_BUFFER_STATUS_ERROR. Note the HAL is still allowed * to return valid (CAMERA3_BUFFER_STATUS_OK) buffers during this call, * provided they are successfully filled. * * All requests currently in the HAL are expected to be returned as soon as * possible. Not-in-process requests should return errors immediately. Any * interruptible hardware blocks should be stopped, and any uninterruptible * blocks should be waited on. * * More specifically, the HAL must follow below requirements for various cases: * * 1. For captures that are too late for the HAL to cancel/stop, and will be * completed normally by the HAL; i.e. the HAL can send shutter/notify and * process_capture_result and buffers as normal. * * 2. For pending requests that have not done any processing, the HAL must call notify * CAMERA3_MSG_ERROR_REQUEST, and return all the output buffers with * process_capture_result in the error state (CAMERA3_BUFFER_STATUS_ERROR). * The HAL must not place the release fence into an error state, instead, * the release fences must be set to the acquire fences passed by the framework, * or -1 if they have been waited on by the HAL already. This is also the path * to follow for any captures for which the HAL already called notify() with * CAMERA3_MSG_SHUTTER but won't be producing any metadata/valid buffers for. * After CAMERA3_MSG_ERROR_REQUEST, for a given frame, only process_capture_results with * buffers in CAMERA3_BUFFER_STATUS_ERROR are allowed. No further notifys or * process_capture_result with non-null metadata is allowed. * * 3. For partially completed pending requests that will not have all the output * buffers or perhaps missing metadata, the HAL should follow below: * * 3.1. Call notify with CAMERA3_MSG_ERROR_RESULT if some of the expected result * metadata (i.e. one or more partial metadata) won't be available for the capture. * * 3.2. Call notify with CAMERA3_MSG_ERROR_BUFFER for every buffer that won't * be produced for the capture. * * 3.3 Call notify with CAMERA3_MSG_SHUTTER with the capture timestamp before * any buffers/metadata are returned with process_capture_result. * * 3.4 For captures that will produce some results, the HAL must not call * CAMERA3_MSG_ERROR_REQUEST, since that indicates complete failure. * * 3.5. Valid buffers/metadata should be passed to the framework as normal. * * 3.6. Failed buffers should be returned to the framework as described for case 2. * But failed buffers do not have to follow the strict ordering valid buffers do, * and may be out-of-order with respect to valid buffers. For example, if buffers * A, B, C, D, E are sent, D and E are failed, then A, E, B, D, C is an acceptable * return order. * * 3.7. For fully-missing metadata, calling CAMERA3_MSG_ERROR_RESULT is sufficient, no * need to call process_capture_result with NULL metadata or equivalent. * * flush() should only return when there are no more outstanding buffers or * requests left in the HAL. The framework may call configure_streams (as * the HAL state is now quiesced) or may issue new requests. * * Note that it's sufficient to only support fully-succeeded and fully-failed result cases. * However, it is highly desirable to support the partial failure cases as well, as it * could help improve the flush call overall performance. * * Performance requirements: * * The HAL should return from this call in 100ms, and must return from this * call in 1000ms. And this call must not be blocked longer than pipeline * latency (see S7 for definition). * * Version information: * * only available if device version >= CAMERA_DEVICE_API_VERSION_3_1. * * Return values: * * 0: On a successful flush of the camera HAL. * * -EINVAL: If the input is malformed (the device is not valid). * * -ENODEV: If the camera device has encountered a serious error. After this * error is returned, only the close() method can be successfully * called by the framework. */ int (*flush)(const struct camera3_device *); /* reserved for future use */ void *reserved[8]; } camera3_device_ops_t; /********************************************************************** * * Camera device definition * */ typedef struct camera3_device { /** * common.version must equal CAMERA_DEVICE_API_VERSION_3_0 to identify this * device as implementing version 3.0 of the camera device HAL. * * Performance requirements: * * Camera open (common.module->common.methods->open) should return in 200ms, and must return * in 500ms. * Camera close (common.close) should return in 200ms, and must return in 500ms. * */ hw_device_t common; camera3_device_ops_t *ops; void *priv; } camera3_device_t; __END_DECLS #endif /* #ifdef ANDROID_INCLUDE_CAMERA3_H */ android-headers-23/22/hardware/camera_common.h000066400000000000000000000410351264465411000213300ustar00rootroot00000000000000/* * 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. */ // FIXME: add well-defined names for cameras #ifndef ANDROID_INCLUDE_CAMERA_COMMON_H #define ANDROID_INCLUDE_CAMERA_COMMON_H #include #include #include #include #include #include #include #include __BEGIN_DECLS /** * The id of this module */ #define CAMERA_HARDWARE_MODULE_ID "camera" /** * Module versioning information for the Camera hardware module, based on * camera_module_t.common.module_api_version. The two most significant hex * digits represent the major version, and the two least significant represent * the minor version. * ******************************************************************************* * Versions: 0.X - 1.X [CAMERA_MODULE_API_VERSION_1_0] * * Camera modules that report these version numbers implement the initial * camera module HAL interface. All camera devices openable through this * module support only version 1 of the camera device HAL. The device_version * and static_camera_characteristics fields of camera_info are not valid. Only * the android.hardware.Camera API can be supported by this module and its * devices. * ******************************************************************************* * Version: 2.0 [CAMERA_MODULE_API_VERSION_2_0] * * Camera modules that report this version number implement the second version * of the camera module HAL interface. Camera devices openable through this * module may support either version 1.0 or version 2.0 of the camera device * HAL interface. The device_version field of camera_info is always valid; the * static_camera_characteristics field of camera_info is valid if the * device_version field is 2.0 or higher. * ******************************************************************************* * Version: 2.1 [CAMERA_MODULE_API_VERSION_2_1] * * This camera module version adds support for asynchronous callbacks to the * framework from the camera HAL module, which is used to notify the framework * about changes to the camera module state. Modules that provide a valid * set_callbacks() method must report at least this version number. * ******************************************************************************* * Version: 2.2 [CAMERA_MODULE_API_VERSION_2_2] * * This camera module version adds vendor tag support from the module, and * deprecates the old vendor_tag_query_ops that were previously only * accessible with a device open. * ******************************************************************************* * Version: 2.3 [CAMERA_MODULE_API_VERSION_2_3] * * This camera module version adds open legacy camera HAL device support. * Framework can use it to open the camera device as lower device HAL version * HAL device if the same device can support multiple device API versions. * The standard hardware module open call (common.methods->open) continues * to open the camera device with the latest supported version, which is * also the version listed in camera_info_t.device_version. */ /** * Predefined macros for currently-defined version numbers */ /** * All module versions <= HARDWARE_MODULE_API_VERSION(1, 0xFF) must be treated * as CAMERA_MODULE_API_VERSION_1_0 */ #define CAMERA_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) #define CAMERA_MODULE_API_VERSION_2_0 HARDWARE_MODULE_API_VERSION(2, 0) #define CAMERA_MODULE_API_VERSION_2_1 HARDWARE_MODULE_API_VERSION(2, 1) #define CAMERA_MODULE_API_VERSION_2_2 HARDWARE_MODULE_API_VERSION(2, 2) #define CAMERA_MODULE_API_VERSION_2_3 HARDWARE_MODULE_API_VERSION(2, 3) #define CAMERA_MODULE_API_VERSION_CURRENT CAMERA_MODULE_API_VERSION_2_3 /** * All device versions <= HARDWARE_DEVICE_API_VERSION(1, 0xFF) must be treated * as CAMERA_DEVICE_API_VERSION_1_0 */ #define CAMERA_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) #define CAMERA_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 0) #define CAMERA_DEVICE_API_VERSION_2_1 HARDWARE_DEVICE_API_VERSION(2, 1) #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_2 HARDWARE_DEVICE_API_VERSION(3, 2) // Device version 3.2 is current, older HAL camera device versions are not // recommended for new devices. #define CAMERA_DEVICE_API_VERSION_CURRENT CAMERA_DEVICE_API_VERSION_3_2 /** * Defined in /system/media/camera/include/system/camera_metadata.h */ typedef struct camera_metadata camera_metadata_t; typedef struct camera_info { /** * The direction that the camera faces to. It should be CAMERA_FACING_BACK * or CAMERA_FACING_FRONT. * * Version information: * Valid in all camera_module versions */ int facing; /** * The orientation of the camera image. The value is the angle that the * camera image needs to be rotated clockwise so it shows correctly on the * display in its natural orientation. It should be 0, 90, 180, or 270. * * For example, suppose a device has a naturally tall screen. The * back-facing camera sensor is mounted in landscape. You are looking at the * screen. If the top side of the camera sensor is aligned with the right * edge of the screen in natural orientation, the value should be 90. If the * top side of a front-facing camera sensor is aligned with the right of the * screen, the value should be 270. * * Version information: * Valid in all camera_module versions */ int orientation; /** * The value of camera_device_t.common.version. * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_1_0: * * Not valid. Can be assumed to be CAMERA_DEVICE_API_VERSION_1_0. Do * not read this field. * * CAMERA_MODULE_API_VERSION_2_0 or higher: * * Always valid * */ uint32_t device_version; /** * The camera's fixed characteristics, which include all camera metadata in * the android.*.info.* sections. This should be a sorted metadata buffer, * and may not be modified or freed by the caller. The pointer should remain * valid for the lifetime of the camera module, and values in it may not * change after it is returned by get_camera_info(). * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_1_0: * * Not valid. Extra characteristics are not available. Do not read this * field. * * CAMERA_MODULE_API_VERSION_2_0 or higher: * * Valid if device_version >= CAMERA_DEVICE_API_VERSION_2_0. Do not read * otherwise. * */ const camera_metadata_t *static_camera_characteristics; } camera_info_t; /** * camera_device_status_t: * * The current status of the camera device, as provided by the HAL through the * camera_module_callbacks.camera_device_status_change() call. * * At module load time, the framework will assume all camera devices are in the * CAMERA_DEVICE_STATUS_PRESENT state. The HAL should invoke * camera_module_callbacks::camera_device_status_change to inform the framework * of any initially NOT_PRESENT devices. * * Allowed transitions: * PRESENT -> NOT_PRESENT * NOT_PRESENT -> ENUMERATING * NOT_PRESENT -> PRESENT * ENUMERATING -> PRESENT * ENUMERATING -> NOT_PRESENT */ typedef enum camera_device_status { /** * The camera device is not currently connected, and opening it will return * failure. Calls to get_camera_info must still succeed, and provide the * same information it would if the camera were connected */ CAMERA_DEVICE_STATUS_NOT_PRESENT = 0, /** * The camera device is connected, and opening it will succeed. The * information returned by get_camera_info cannot change due to this status * change. By default, the framework will assume all devices are in this * state. */ CAMERA_DEVICE_STATUS_PRESENT = 1, /** * The camera device is connected, but it is undergoing an enumeration and * so opening the device will return -EBUSY. Calls to get_camera_info * must still succeed, as if the camera was in the PRESENT status. */ CAMERA_DEVICE_STATUS_ENUMERATING = 2, } camera_device_status_t; /** * Callback functions for the camera HAL module to use to inform the framework * of changes to the camera subsystem. These are called only by HAL modules * implementing version CAMERA_MODULE_API_VERSION_2_1 or higher of the HAL * module API interface. */ typedef struct camera_module_callbacks { /** * camera_device_status_change: * * Callback to the framework to indicate that the state of a specific camera * device has changed. At module load time, the framework will assume all * camera devices are in the CAMERA_DEVICE_STATUS_PRESENT state. The HAL * must call this method to inform the framework of any initially * NOT_PRESENT devices. * * camera_module_callbacks: The instance of camera_module_callbacks_t passed * to the module with set_callbacks. * * camera_id: The ID of the camera device that has a new status. * * new_status: The new status code, one of the camera_device_status_t enums, * or a platform-specific status. * */ void (*camera_device_status_change)(const struct camera_module_callbacks*, int camera_id, int new_status); } camera_module_callbacks_t; typedef struct camera_module { /** * Common methods of the camera module. This *must* be the first member of * camera_module as users of this structure will cast a hw_module_t to * camera_module pointer in contexts where it's known the hw_module_t * references a camera_module. * * The return values for common.methods->open for camera_module are: * * 0: On a successful open of the camera device. * * -ENODEV: The camera device cannot be opened due to an internal * error. * * -EINVAL: The input arguments are invalid, i.e. the id is invalid, * and/or the module is invalid. * * -EBUSY: The camera device was already opened for this camera id * (by using this method or open_legacy), * regardless of the device HAL version it was opened as. * * -EUSERS: The maximal number of camera devices that can be * opened concurrently were opened already, either by * this method or the open_legacy method. * * All other return values from common.methods->open will be treated as * -ENODEV. */ hw_module_t common; /** * get_number_of_cameras: * * Returns the number of camera devices accessible through the camera * module. The camera devices are numbered 0 through N-1, where N is the * value returned by this call. The name of the camera device for open() is * simply the number converted to a string. That is, "0" for camera ID 0, * "1" for camera ID 1. * * The value here must be static, and cannot change after the first call to * this method */ int (*get_number_of_cameras)(void); /** * get_camera_info: * * Return the static camera information for a given camera device. This * information may not change for a camera device. * * Return values: * * 0: On a successful operation * * -ENODEV: The information cannot be provided due to an internal * error. * * -EINVAL: The input arguments are invalid, i.e. the id is invalid, * and/or the module is invalid. */ int (*get_camera_info)(int camera_id, struct camera_info *info); /** * set_callbacks: * * Provide callback function pointers to the HAL module to inform framework * of asynchronous camera module events. The framework will call this * function once after initial camera HAL module load, after the * get_number_of_cameras() method is called for the first time, and before * any other calls to the module. * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_1_0, CAMERA_MODULE_API_VERSION_2_0: * * Not provided by HAL module. Framework may not call this function. * * CAMERA_MODULE_API_VERSION_2_1: * * Valid to be called by the framework. * * Return values: * * 0: On a successful operation * * -ENODEV: The operation cannot be completed due to an internal * error. * * -EINVAL: The input arguments are invalid, i.e. the callbacks are * null */ int (*set_callbacks)(const camera_module_callbacks_t *callbacks); /** * get_vendor_tag_ops: * * Get methods to query for vendor extension metadata tag information. The * HAL should fill in all the vendor tag operation methods, or leave ops * unchanged if no vendor tags are defined. * * The vendor_tag_ops structure used here is defined in: * system/media/camera/include/system/vendor_tags.h * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1: * Not provided by HAL module. Framework may not call this function. * * CAMERA_MODULE_API_VERSION_2_2: * Valid to be called by the framework. */ void (*get_vendor_tag_ops)(vendor_tag_ops_t* ops); /** * open_legacy: * * Open a specific legacy camera HAL device if multiple device HAL API * versions are supported by this camera HAL module. For example, if the * camera module supports both CAMERA_DEVICE_API_VERSION_1_0 and * CAMERA_DEVICE_API_VERSION_3_2 device API for the same camera id, * framework can call this function to open the camera device as * CAMERA_DEVICE_API_VERSION_1_0 device. * * This is an optional method. A Camera HAL module does not need to support * more than one device HAL version per device, and such modules may return * -ENOSYS for all calls to this method. For all older HAL device API * versions that are not supported, it may return -EOPNOTSUPP. When above * cases occur, The normal open() method (common.methods->open) will be * used by the framework instead. * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2: * Not provided by HAL module. Framework will not call this function. * * CAMERA_MODULE_API_VERSION_2_3: * Valid to be called by the framework. * * Return values: * * 0: On a successful open of the camera device. * * -ENOSYS This method is not supported. * * -EOPNOTSUPP: The requested HAL version is not supported by this method. * * -EINVAL: The input arguments are invalid, i.e. the id is invalid, * and/or the module is invalid. * * -EBUSY: The camera device was already opened for this camera id * (by using this method or common.methods->open method), * regardless of the device HAL version it was opened as. * * -EUSERS: The maximal number of camera devices that can be * opened concurrently were opened already, either by * this method or common.methods->open method. */ int (*open_legacy)(const struct hw_module_t* module, const char* id, uint32_t halVersion, struct hw_device_t** device); /* reserved for future use */ void* reserved[7]; } camera_module_t; __END_DECLS #endif /* ANDROID_INCLUDE_CAMERA_COMMON_H */ android-headers-23/22/hardware/consumerir.h000066400000000000000000000067261264465411000207260ustar00rootroot00000000000000/* * 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_HARDWARE_CONSUMERIR_H #define ANDROID_INCLUDE_HARDWARE_CONSUMERIR_H #include #include #include #include #define CONSUMERIR_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) #define CONSUMERIR_HARDWARE_MODULE_ID "consumerir" #define CONSUMERIR_TRANSMITTER "transmitter" typedef struct consumerir_freq_range { int min; int max; } consumerir_freq_range_t; typedef struct consumerir_module { /** * Common methods of the consumer IR module. This *must* be the first member of * consumerir_module as users of this structure will cast a hw_module_t to * consumerir_module pointer in contexts where it's known the hw_module_t references a * consumerir_module. */ struct hw_module_t common; } consumerir_module_t; typedef struct consumerir_device { /** * Common methods of the consumer IR device. This *must* be the first member of * consumerir_device as users of this structure will cast a hw_device_t to * consumerir_device pointer in contexts where it's known the hw_device_t references a * consumerir_device. */ struct hw_device_t common; /* * (*transmit)() is called to by the ConsumerIrService to send an IR pattern * at a given carrier_freq. * * The pattern is alternating series of carrier on and off periods measured in * microseconds. The carrier should be turned off at the end of a transmit * even if there are and odd number of entries in the pattern array. * * This call should return when the transmit is complete or encounters an error. * * returns: 0 on success. A negative error code on error. */ int (*transmit)(struct consumerir_device *dev, int carrier_freq, const int pattern[], int pattern_len); /* * (*get_num_carrier_freqs)() is called by the ConsumerIrService to get the * number of carrier freqs to allocate space for, which is then filled by * a subsequent call to (*get_carrier_freqs)(). * * returns: the number of ranges on success. A negative error code on error. */ int (*get_num_carrier_freqs)(struct consumerir_device *dev); /* * (*get_carrier_freqs)() is called by the ConsumerIrService to enumerate * which frequencies the IR transmitter supports. The HAL implementation * should fill an array of consumerir_freq_range structs with the * appropriate values for the transmitter, up to len elements. * * returns: the number of ranges on success. A negative error code on error. */ int (*get_carrier_freqs)(struct consumerir_device *dev, size_t len, consumerir_freq_range_t *ranges); /* Reserved for future use. Must be NULL. */ void* reserved[8 - 3]; } consumerir_device_t; #endif /* ANDROID_INCLUDE_HARDWARE_CONSUMERIR_H */ android-headers-23/22/hardware/fb.h000066400000000000000000000126551264465411000171250ustar00rootroot00000000000000/* * 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_FB_INTERFACE_H #define ANDROID_FB_INTERFACE_H #include #include #include #include #include __BEGIN_DECLS #define GRALLOC_HARDWARE_FB0 "fb0" /*****************************************************************************/ /*****************************************************************************/ typedef struct framebuffer_device_t { /** * Common methods of the framebuffer device. This *must* be the first member of * framebuffer_device_t as users of this structure will cast a hw_device_t to * framebuffer_device_t pointer in contexts where it's known the hw_device_t references a * framebuffer_device_t. */ struct hw_device_t common; /* flags describing some attributes of the framebuffer */ const uint32_t flags; /* dimensions of the framebuffer in pixels */ const uint32_t width; const uint32_t height; /* frambuffer stride in pixels */ const int stride; /* framebuffer pixel format */ const int format; /* resolution of the framebuffer's display panel in pixel per inch*/ const float xdpi; const float ydpi; /* framebuffer's display panel refresh rate in frames per second */ const float fps; /* min swap interval supported by this framebuffer */ const int minSwapInterval; /* max swap interval supported by this framebuffer */ const int maxSwapInterval; /* Number of framebuffers supported*/ const int numFramebuffers; int reserved[7]; /* * requests a specific swap-interval (same definition than EGL) * * Returns 0 on success or -errno on error. */ int (*setSwapInterval)(struct framebuffer_device_t* window, int interval); /* * This hook is OPTIONAL. * * It is non NULL If the framebuffer driver supports "update-on-demand" * and the given rectangle is the area of the screen that gets * updated during (*post)(). * * This is useful on devices that are able to DMA only a portion of * the screen to the display panel, upon demand -- as opposed to * constantly refreshing the panel 60 times per second, for instance. * * Only the area defined by this rectangle is guaranteed to be valid, that * is, the driver is not allowed to post anything outside of this * rectangle. * * The rectangle evaluated during (*post)() and specifies which area * of the buffer passed in (*post)() shall to be posted. * * return -EINVAL if width or height <=0, or if left or top < 0 */ int (*setUpdateRect)(struct framebuffer_device_t* window, int left, int top, int width, int height); /* * Post to the display (display it on the screen) * The buffer must have been allocated with the * GRALLOC_USAGE_HW_FB usage flag. * buffer must be the same width and height as the display and must NOT * be locked. * * The buffer is shown during the next VSYNC. * * If the same buffer is posted again (possibly after some other buffer), * post() will block until the the first post is completed. * * Internally, post() is expected to lock the buffer so that a * subsequent call to gralloc_module_t::(*lock)() with USAGE_RENDER or * USAGE_*_WRITE will block until it is safe; that is typically once this * buffer is shown and another buffer has been posted. * * Returns 0 on success or -errno on error. */ int (*post)(struct framebuffer_device_t* dev, buffer_handle_t buffer); /* * The (*compositionComplete)() method must be called after the * compositor has finished issuing GL commands for client buffers. */ int (*compositionComplete)(struct framebuffer_device_t* dev); /* * This hook is OPTIONAL. * * If non NULL it will be caused by SurfaceFlinger on dumpsys */ void (*dump)(struct framebuffer_device_t* dev, char *buff, int buff_len); /* * (*enableScreen)() is used to either blank (enable=0) or * unblank (enable=1) the screen this framebuffer is attached to. * * Returns 0 on success or -errno on error. */ int (*enableScreen)(struct framebuffer_device_t* dev, int enable); void* reserved_proc[6]; } framebuffer_device_t; /** convenience API for opening and closing a supported device */ 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); } static inline int framebuffer_close(struct framebuffer_device_t* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_FB_INTERFACE_H android-headers-23/22/hardware/fingerprint.h000066400000000000000000000143451264465411000210630ustar00rootroot00000000000000/* * 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_HARDWARE_FINGERPRINT_H #define ANDROID_INCLUDE_HARDWARE_FINGERPRINT_H #define FINGERPRINT_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) #define FINGERPRINT_HARDWARE_MODULE_ID "fingerprint" typedef enum fingerprint_msg_type { FINGERPRINT_ERROR = -1, FINGERPRINT_ACQUIRED = 1, FINGERPRINT_PROCESSED = 2, FINGERPRINT_TEMPLATE_ENROLLING = 3, FINGERPRINT_TEMPLATE_REMOVED = 4 } fingerprint_msg_type_t; typedef enum fingerprint_error { FINGERPRINT_ERROR_HW_UNAVAILABLE = 1, FINGERPRINT_ERROR_UNABLE_TO_PROCESS = 2, FINGERPRINT_ERROR_TIMEOUT = 3, FINGERPRINT_ERROR_NO_SPACE = 4 /* No space available to store a template */ } fingerprint_error_t; typedef enum fingerprint_acquired_info { FINGERPRINT_ACQUIRED_GOOD = 0, FINGERPRINT_ACQUIRED_PARTIAL = 1, FINGERPRINT_ACQUIRED_INSUFFICIENT = 2, FINGERPRINT_ACQUIRED_IMAGER_DIRTY = 4, FINGERPRINT_ACQUIRED_TOO_SLOW = 8, FINGERPRINT_ACQUIRED_TOO_FAST = 16 } fingerprint_acquired_info_t; typedef struct fingerprint_enroll { uint32_t id; /* samples_remaining goes from N (no data collected, but N scans needed) * to 0 (no more data is needed to build a template). * The progress indication may be augmented by a bitmap encoded indication * of finger area that needs to be presented by the user. * Bit numbers mapped to physical location: * * distal * +-+-+-+ * |2|1|0| * |5|4|3| * medial |8|7|6| lateral * |b|a|9| * |e|d|c| * +-+-+-+ * proximal * */ uint16_t data_collected_bmp; uint16_t samples_remaining; } fingerprint_enroll_t; typedef struct fingerprint_removed { uint32_t id; } fingerprint_removed_t; typedef struct fingerprint_acquired { fingerprint_acquired_info_t acquired_info; /* information about the image */ } fingerprint_acquired_t; typedef struct fingerprint_processed { uint32_t id; /* 0 is a special id and means no match */ } fingerprint_processed_t; typedef struct fingerprint_msg { fingerprint_msg_type_t type; union { uint64_t raw; fingerprint_error_t error; fingerprint_enroll_t enroll; fingerprint_removed_t removed; fingerprint_acquired_t acquired; fingerprint_processed_t processed; } data; } fingerprint_msg_t; /* Callback function type */ typedef void (*fingerprint_notify_t)(fingerprint_msg_t msg); /* Synchronous operation */ typedef struct fingerprint_device { /** * Common methods of the fingerprint device. This *must* be the first member * of fingerprint_device as users of this structure will cast a hw_device_t * to fingerprint_device pointer in contexts where it's known * the hw_device_t references a fingerprint_device. */ struct hw_device_t common; /* * Fingerprint enroll request: * Switches the HAL state machine to collect and store a new fingerprint * template. Switches back as soon as enroll is complete * (fingerprint_msg.type == FINGERPRINT_TEMPLATE_ENROLLING && * fingerprint_msg.data.enroll.samples_remaining == 0) * or after timeout_sec seconds. * * Function return: 0 if enrollment process can be successfully started * -1 otherwise. A notify() function may be called * indicating the error condition. */ int (*enroll)(struct fingerprint_device *dev, uint32_t timeout_sec); /* * Cancel fingerprint enroll request: * Switches the HAL state machine back to accept a fingerprint scan mode. * (fingerprint_msg.type == FINGERPRINT_TEMPLATE_ENROLLING && * fingerprint_msg.data.enroll.samples_remaining == 0) * will indicate switch back to the scan mode. * * Function return: 0 if cancel request is accepted * -1 otherwise. */ int (*enroll_cancel)(struct fingerprint_device *dev); /* * Fingerprint remove request: * deletes a fingerprint template. * If the fingerprint id is 0 the entire template database will be removed. * notify() will be called for each template deleted with * fingerprint_msg.type == FINGERPRINT_TEMPLATE_REMOVED and * fingerprint_msg.data.removed.id indicating each template id removed. * * Function return: 0 if fingerprint template(s) can be successfully deleted * -1 otherwise. */ int (*remove)(struct fingerprint_device *dev, uint32_t fingerprint_id); /* * Set notification callback: * Registers a user function that would receive notifications from the HAL * The call will block if the HAL state machine is in busy state until HAL * leaves the busy state. * * Function return: 0 if callback function is successfuly registered * -1 otherwise. */ int (*set_notify)(struct fingerprint_device *dev, fingerprint_notify_t notify); /* * Client provided callback function to receive notifications. * Do not set by hand, use the function above instead. */ fingerprint_notify_t notify; /* Reserved for future use. Must be NULL. */ void* reserved[8 - 4]; } fingerprint_device_t; typedef struct fingerprint_module { /** * Common methods of the fingerprint module. This *must* be the first member * of fingerprint_module as users of this structure will cast a hw_module_t * to fingerprint_module pointer in contexts where it's known * the hw_module_t references a fingerprint_module. */ struct hw_module_t common; } fingerprint_module_t; #endif /* ANDROID_INCLUDE_HARDWARE_FINGERPRINT_H */ android-headers-23/22/hardware/fused_location.h000066400000000000000000000644501264465411000215340ustar00rootroot00000000000000/* * 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_HARDWARE_FUSED_LOCATION_H #define ANDROID_INCLUDE_HARDWARE_FUSED_LOCATION_H #include /** * This header file defines the interface of the Fused Location Provider. * Fused Location Provider is designed to fuse data from various sources * like GPS, Wifi, Cell, Sensors, Bluetooth etc to provide a fused location to the * upper layers. The advantage of doing fusion in hardware is power savings. * The goal is to do this without waking up the AP to get additional data. * The software implementation of FLP will decide when to use * the hardware fused location. Other location features like geofencing will * also be implemented using fusion in hardware. */ __BEGIN_DECLS #define FLP_HEADER_VERSION 1 #define FLP_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define FLP_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION_2(0, 1, FLP_HEADER_VERSION) /** * The id of this module */ #define FUSED_LOCATION_HARDWARE_MODULE_ID "flp" /** * Name for the FLP location interface */ #define FLP_LOCATION_INTERFACE "flp_location" /** * Name for the FLP location interface */ #define FLP_DIAGNOSTIC_INTERFACE "flp_diagnostic" /** * Name for the FLP_Geofencing interface. */ #define FLP_GEOFENCING_INTERFACE "flp_geofencing" /** * Name for the FLP_device context interface. */ #define FLP_DEVICE_CONTEXT_INTERFACE "flp_device_context" /** * Constants to indicate the various subsystems * that will be used. */ #define FLP_TECH_MASK_GNSS (1U<<0) #define FLP_TECH_MASK_WIFI (1U<<1) #define FLP_TECH_MASK_SENSORS (1U<<2) #define FLP_TECH_MASK_CELL (1U<<3) #define FLP_TECH_MASK_BLUETOOTH (1U<<4) /** * 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, * sometimes in high power mode, the system might need * a location callback every single time the location * fix has been obtained. This flag controls that option. * Its the responsibility of the upper layers (caller) to switch * it off, if it knows that the AP might go to sleep. * When this bit is on amidst a batching session, batching should * continue while location fixes are reported in real time. */ #define FLP_BATCH_CALLBACK_ON_LOCATION_FIX 0x0000002 /** Flags to indicate which values are valid in a FlpLocation. */ typedef uint16_t FlpLocationFlags; // IMPORTANT: Note that the following values must match // constants in the corresponding java file. /** FlpLocation has valid latitude and longitude. */ #define FLP_LOCATION_HAS_LAT_LONG (1U<<0) /** FlpLocation has valid altitude. */ #define FLP_LOCATION_HAS_ALTITUDE (1U<<1) /** FlpLocation has valid speed. */ #define FLP_LOCATION_HAS_SPEED (1U<<2) /** FlpLocation has valid bearing. */ #define FLP_LOCATION_HAS_BEARING (1U<<4) /** FlpLocation has valid accuracy. */ #define FLP_LOCATION_HAS_ACCURACY (1U<<8) typedef int64_t FlpUtcTime; /** Represents a location. */ typedef struct { /** set to sizeof(FlpLocation) */ size_t size; /** Flags associated with the location object. */ FlpLocationFlags flags; /** Represents latitude in degrees. */ double latitude; /** Represents longitude in degrees. */ double longitude; /** * Represents altitude in meters above the WGS 84 reference * ellipsoid. */ double altitude; /** Represents speed in meters per second. */ float speed; /** Represents heading in degrees. */ float bearing; /** Represents expected accuracy in meters. */ float accuracy; /** Timestamp for the location fix. */ FlpUtcTime timestamp; /** Sources used, will be Bitwise OR of the FLP_TECH_MASK bits. */ uint32_t sources_used; } FlpLocation; typedef enum { ASSOCIATE_JVM, DISASSOCIATE_JVM, } ThreadEvent; /** * Callback with location information. * Can only be called from a thread associated to JVM using set_thread_event_cb. * Parameters: * num_locations is the number of batched locations available. * location is the pointer to an array of pointers to location objects. */ typedef void (*flp_location_callback)(int32_t num_locations, FlpLocation** location); /** * Callback utility for acquiring a wakelock. * This can be used to prevent the CPU from suspending while handling FLP events. */ typedef void (*flp_acquire_wakelock)(); /** * Callback utility for releasing the FLP wakelock. */ typedef void (*flp_release_wakelock)(); /** * Callback for associating a thread that can call into the Java framework code. * This must be used to initialize any threads that report events up to the framework. * Return value: * FLP_RESULT_SUCCESS on success. * FLP_RESULT_ERROR if the association failed in the current thread. */ typedef int (*flp_set_thread_event)(ThreadEvent event); /** FLP callback structure. */ typedef struct { /** set to sizeof(FlpCallbacks) */ size_t size; flp_location_callback location_cb; flp_acquire_wakelock acquire_wakelock_cb; flp_release_wakelock release_wakelock_cb; flp_set_thread_event set_thread_event_cb; } FlpCallbacks; /** Options with the batching FLP APIs */ typedef struct { /** * Maximum power in mW that the underlying implementation * can use for this batching call. * If max_power_allocation_mW is 0, only fixes that are generated * at no additional cost of power shall be reported. */ double max_power_allocation_mW; /** Bitwise OR of the FLP_TECH_MASKS to use */ uint32_t sources_to_use; /** * FLP_BATCH_WAKEUP_ON_FIFO_FULL - If set the hardware * will wake up the AP when the buffer is full. If not set, the * hardware will drop the oldest location object. * * FLP_BATCH_CALLBACK_ON_LOCATION_FIX - If set the location * callback will be called every time there is a location fix. * Its the responsibility of the upper layers (caller) to switch * it off, if it knows that the AP might go to sleep. When this * bit is on amidst a batching session, batching should continue * while location fixes are reported in real time. * * Other flags to be bitwised ORed in the future. */ uint32_t flags; /** * Frequency with which location needs to be batched in nano * seconds. */ int64_t period_ns; } FlpBatchOptions; #define FLP_RESULT_SUCCESS 0 #define FLP_RESULT_ERROR -1 #define FLP_RESULT_INSUFFICIENT_MEMORY -2 #define FLP_RESULT_TOO_MANY_GEOFENCES -3 #define FLP_RESULT_ID_EXISTS -4 #define FLP_RESULT_ID_UNKNOWN -5 #define FLP_RESULT_INVALID_GEOFENCE_TRANSITION -6 /** * Represents the standard FLP interface. */ typedef struct { /** * set to sizeof(FlpLocationInterface) */ size_t size; /** * Opens the interface and provides the callback routines * to the implemenation of this interface. */ int (*init)(FlpCallbacks* callbacks ); /** * Return the batch size (in number of FlpLocation objects) * available in the hardware. Note, different HW implementations * may have different sample sizes. This shall return number * of samples defined in the format of FlpLocation. * This will be used by the upper layer, to decide on the batching * interval and whether the AP should be woken up or not. */ int (*get_batch_size)(); /** * Start batching locations. This API is primarily used when the AP is * asleep and the device can batch locations in the hardware. * flp_location_callback is used to return the locations. When the buffer * is full and FLP_BATCH_WAKEUP_ON_FIFO_FULL is used, the AP is woken up. * When the buffer is full and FLP_BATCH_WAKEUP_ON_FIFO_FULL is not set, * the oldest location object is dropped. In this case the AP will not be * woken up. The upper layer will use get_batched_location * API to explicitly ask for the location. * If FLP_BATCH_CALLBACK_ON_LOCATION_FIX is set, the implementation * will call the flp_location_callback every single time there is a location * fix. This overrides FLP_BATCH_WAKEUP_ON_FIFO_FULL flag setting. * It's the responsibility of the upper layers (caller) to switch * it off, if it knows that the AP might go to sleep. This is useful * for nagivational applications when the system is in high power mode. * Parameters: * id - Id for the request. * options - See FlpBatchOptions struct definition. * Return value: * FLP_RESULT_SUCCESS on success, FLP_RESULT_INSUFFICIENT_MEMORY, * FLP_RESULT_ID_EXISTS, FLP_RESULT_ERROR on failure. */ int (*start_batching)(int id, FlpBatchOptions* options); /** * Update FlpBatchOptions associated with a batching request. * When a batching operation is in progress and a batching option * such as FLP_BATCH_WAKEUP_ON_FIFO_FULL needs to be updated, this API * will be used. For instance, this can happen when the AP is awake and * the maps application is being used. * Parameters: * id - Id of an existing batch request. * new_options - Updated FlpBatchOptions * Return value: * FLP_RESULT_SUCCESS on success, FLP_RESULT_ID_UNKNOWN, * FLP_RESULT_ERROR on error. */ int (*update_batching_options)(int id, FlpBatchOptions* new_options); /** * Stop batching. * Parameters: * id - Id for the request. * Return Value: * FLP_RESULT_SUCCESS on success, FLP_RESULT_ID_UNKNOWN or * FLP_RESULT_ERROR on failure. */ int (*stop_batching)(int id); /** * Closes the interface. If any batch operations are in progress, * they should be stopped. */ void (*cleanup)(); /** * Get the fused location that was batched. * flp_location_callback is used to return the location. The location object * is dropped from the buffer only when the buffer is full. Do not remove it * from the buffer just because it has been returned using the callback. * In other words, when there is no new location object, two calls to * get_batched_location(1) should return the same location object. * Parameters: * last_n_locations - Number of locations to get. This can be one or many. * If the last_n_locations is 1, you get the latest location known to the * hardware. */ void (*get_batched_location)(int last_n_locations); /** * Injects current location from another location provider * latitude and longitude are measured in degrees * expected accuracy is measured in meters * Parameters: * location - The location object being injected. * Return value: FLP_RESULT_SUCCESS or FLP_RESULT_ERROR. */ int (*inject_location)(FlpLocation* location); /** * Get a pointer to extension information. */ const void* (*get_extension)(const char* name); } FlpLocationInterface; struct flp_device_t { struct hw_device_t common; /** * Get a handle to the FLP Interface. */ const FlpLocationInterface* (*get_flp_interface)(struct flp_device_t* dev); }; /** * Callback for reports diagnostic data into the Java framework code. */ typedef void (*report_data)(char* data, int length); /** * FLP diagnostic callback structure. * Currently, not used - but this for future extension. */ typedef struct { /** set to sizeof(FlpDiagnosticCallbacks) */ size_t size; flp_set_thread_event set_thread_event_cb; /** reports diagnostic data into the Java framework code */ report_data data_cb; } FlpDiagnosticCallbacks; /** Extended interface for diagnostic support. */ typedef struct { /** set to sizeof(FlpDiagnosticInterface) */ size_t size; /** * Opens the diagnostic interface and provides the callback routines * to the implemenation of this interface. */ void (*init)(FlpDiagnosticCallbacks* callbacks); /** * Injects diagnostic data into the FLP subsystem. * Return 0 on success, -1 on error. **/ int (*inject_data)(char* data, int length ); } FlpDiagnosticInterface; /** * Context setting information. * All these settings shall be injected to FLP HAL at FLP init time. * Following that, only the changed setting need to be re-injected * upon changes. */ #define FLP_DEVICE_CONTEXT_GPS_ENABLED (1U<<0) #define FLP_DEVICE_CONTEXT_AGPS_ENABLED (1U<<1) #define FLP_DEVICE_CONTEXT_NETWORK_POSITIONING_ENABLED (1U<<2) #define FLP_DEVICE_CONTEXT_WIFI_CONNECTIVITY_ENABLED (1U<<3) #define FLP_DEVICE_CONTEXT_WIFI_POSITIONING_ENABLED (1U<<4) #define FLP_DEVICE_CONTEXT_HW_NETWORK_POSITIONING_ENABLED (1U<<5) #define FLP_DEVICE_CONTEXT_AIRPLANE_MODE_ON (1U<<6) #define FLP_DEVICE_CONTEXT_DATA_ENABLED (1U<<7) #define FLP_DEVICE_CONTEXT_ROAMING_ENABLED (1U<<8) #define FLP_DEVICE_CONTEXT_CURRENTLY_ROAMING (1U<<9) #define FLP_DEVICE_CONTEXT_SENSOR_ENABLED (1U<<10) #define FLP_DEVICE_CONTEXT_BLUETOOTH_ENABLED (1U<<11) #define FLP_DEVICE_CONTEXT_CHARGER_ON (1U<<12) /** Extended interface for device context support. */ typedef struct { /** set to sizeof(FlpDeviceContextInterface) */ size_t size; /** * Injects debug data into the FLP subsystem. * Return 0 on success, -1 on error. **/ int (*inject_device_context)(uint32_t enabledMask); } FlpDeviceContextInterface; /** * There are 3 states associated with a Geofence: Inside, Outside, Unknown. * There are 3 transitions: ENTERED, EXITED, UNCERTAIN. * * An example state diagram with confidence level: 95% and Unknown time limit * set as 30 secs is shown below. (confidence level and Unknown time limit are * explained latter) * ____________________________ * | Unknown (30 secs) | * """""""""""""""""""""""""""" * ^ | | ^ * UNCERTAIN| |ENTERED EXITED| |UNCERTAIN * | v v | * ________ EXITED _________ * | Inside | -----------> | Outside | * | | <----------- | | * """""""" ENTERED """"""""" * * Inside state: We are 95% confident that the user is inside the geofence. * Outside state: We are 95% confident that the user is outside the geofence * Unknown state: Rest of the time. * * The Unknown state is better explained with an example: * * __________ * | c| * | ___ | _______ * | |a| | | b | * | """ | """"""" * | | * """""""""" * In the diagram above, "a" and "b" are 2 geofences and "c" is the accuracy * circle reported by the FLP subsystem. Now with regard to "b", the system is * confident that the user is outside. But with regard to "a" is not confident * whether it is inside or outside the geofence. If the accuracy remains the * same for a sufficient period of time, the UNCERTAIN transition would be * triggered with the state set to Unknown. If the accuracy improves later, an * appropriate transition should be triggered. This "sufficient period of time" * is defined by the parameter in the add_geofence_area API. * In other words, Unknown state can be interpreted as a state in which the * FLP subsystem isn't confident enough that the user is either inside or * outside the Geofence. It moves to Unknown state only after the expiry of the * timeout. * * The geofence callback needs to be triggered for the ENTERED and EXITED * transitions, when the FLP system is confident that the user has entered * (Inside state) or exited (Outside state) the Geofence. An implementation * which uses a value of 95% as the confidence is recommended. The callback * should be triggered only for the transitions requested by the * add_geofence_area call. * * Even though the diagram and explanation talks about states and transitions, * the callee is only interested in the transistions. The states are mentioned * here for illustrative purposes. * * Startup Scenario: When the device boots up, if an application adds geofences, * and then we get an accurate FLP location fix, it needs to trigger the * appropriate (ENTERED or EXITED) transition for every Geofence it knows about. * By default, all the Geofences will be in the Unknown state. * * When the FLP system is unavailable, flp_geofence_status_callback should be * called to inform the upper layers of the same. Similarly, when it becomes * available the callback should be called. This is a global state while the * UNKNOWN transition described above is per geofence. * */ #define FLP_GEOFENCE_TRANSITION_ENTERED (1L<<0) #define FLP_GEOFENCE_TRANSITION_EXITED (1L<<1) #define FLP_GEOFENCE_TRANSITION_UNCERTAIN (1L<<2) #define FLP_GEOFENCE_MONITOR_STATUS_UNAVAILABLE (1L<<0) #define FLP_GEOFENCE_MONITOR_STATUS_AVAILABLE (1L<<1) /** * The callback associated with the geofence. * Parameters: * geofence_id - The id associated with the add_geofence_area. * location - The current location as determined by the FLP subsystem. * transition - Can be one of FLP_GEOFENCE_TRANSITION_ENTERED, FLP_GEOFENCE_TRANSITION_EXITED, * FLP_GEOFENCE_TRANSITION_UNCERTAIN. * timestamp - Timestamp when the transition was detected; -1 if not available. * sources_used - Bitwise OR of FLP_TECH_MASK flags indicating which * subsystems were used. * * The callback should only be called when the caller is interested in that * particular transition. For instance, if the caller is interested only in * ENTERED transition, then the callback should NOT be called with the EXITED * transition. * * IMPORTANT: If a transition is triggered resulting in this callback, the * subsystem will wake up the application processor, if its in suspend state. */ typedef void (*flp_geofence_transition_callback) (int32_t geofence_id, FlpLocation* location, int32_t transition, FlpUtcTime timestamp, uint32_t sources_used); /** * The callback associated with the availablity of one the sources used for geofence * monitoring by the FLP sub-system For example, if the GPS system determines that it cannot * monitor geofences because of lack of reliability or unavailability of the GPS signals, * it will call this callback with FLP_GEOFENCE_MONITOR_STATUS_UNAVAILABLE parameter and the * source set to FLP_TECH_MASK_GNSS. * * Parameters: * status - FLP_GEOFENCE_MONITOR_STATUS_UNAVAILABLE or FLP_GEOFENCE_MONITOR_STATUS_AVAILABLE. * source - One of the FLP_TECH_MASKS * last_location - Last known location. */ typedef void (*flp_geofence_monitor_status_callback) (int32_t status, uint32_t source, FlpLocation* last_location); /** * The callback associated with the add_geofence call. * * Parameter: * geofence_id - Id of the geofence. * result - FLP_RESULT_SUCCESS * FLP_RESULT_ERROR_TOO_MANY_GEOFENCES - geofence limit has been reached. * FLP_RESULT_ID_EXISTS - geofence with id already exists * FLP_RESULT_INVALID_GEOFENCE_TRANSITION - the monitorTransition contains an * invalid transition * FLP_RESULT_ERROR - for other errors. */ typedef void (*flp_geofence_add_callback) (int32_t geofence_id, int32_t result); /** * The callback associated with the remove_geofence call. * * Parameter: * geofence_id - Id of the geofence. * result - FLP_RESULT_SUCCESS * FLP_RESULT_ID_UNKNOWN - for invalid id * FLP_RESULT_ERROR for others. */ typedef void (*flp_geofence_remove_callback) (int32_t geofence_id, int32_t result); /** * The callback associated with the pause_geofence call. * * Parameter: * geofence_id - Id of the geofence. * result - FLP_RESULT_SUCCESS * FLP_RESULT__ID_UNKNOWN - for invalid id * FLP_RESULT_INVALID_TRANSITION - * when monitor_transitions is invalid * FLP_RESULT_ERROR for others. */ typedef void (*flp_geofence_pause_callback) (int32_t geofence_id, int32_t result); /** * The callback associated with the resume_geofence call. * * Parameter: * geofence_id - Id of the geofence. * result - FLP_RESULT_SUCCESS * FLP_RESULT_ID_UNKNOWN - for invalid id * FLP_RESULT_ERROR for others. */ typedef void (*flp_geofence_resume_callback) (int32_t geofence_id, int32_t result); typedef struct { /** set to sizeof(FlpGeofenceCallbacks) */ size_t size; flp_geofence_transition_callback geofence_transition_callback; flp_geofence_monitor_status_callback geofence_status_callback; flp_geofence_add_callback geofence_add_callback; flp_geofence_remove_callback geofence_remove_callback; flp_geofence_pause_callback geofence_pause_callback; flp_geofence_resume_callback geofence_resume_callback; flp_set_thread_event set_thread_event_cb; } FlpGeofenceCallbacks; /** Type of geofence */ typedef enum { TYPE_CIRCLE = 0, } GeofenceType; /** Circular geofence is represented by lat / long / radius */ typedef struct { double latitude; double longitude; double radius_m; } GeofenceCircle; /** Represents the type of geofence and data */ typedef struct { GeofenceType type; union { GeofenceCircle circle; } geofence; } GeofenceData; /** Geofence Options */ typedef struct { /** * The current state of the geofence. For example, if * the system already knows that the user is inside the geofence, * this will be set to FLP_GEOFENCE_TRANSITION_ENTERED. In most cases, it * will be FLP_GEOFENCE_TRANSITION_UNCERTAIN. */ int last_transition; /** * Transitions to monitor. Bitwise OR of * FLP_GEOFENCE_TRANSITION_ENTERED, FLP_GEOFENCE_TRANSITION_EXITED and * FLP_GEOFENCE_TRANSITION_UNCERTAIN. */ int monitor_transitions; /** * Defines the best-effort description * of how soon should the callback be called when the transition * associated with the Geofence is triggered. For instance, if set * to 1000 millseconds with FLP_GEOFENCE_TRANSITION_ENTERED, the callback * should be called 1000 milliseconds within entering the geofence. * This parameter is defined in milliseconds. * NOTE: This is not to be confused with the rate that the GPS is * polled at. It is acceptable to dynamically vary the rate of * sampling the GPS for power-saving reasons; thus the rate of * sampling may be faster or slower than this. */ int notification_responsivenes_ms; /** * The time limit after which the UNCERTAIN transition * should be triggered. This paramter is defined in milliseconds. */ int unknown_timer_ms; /** * The sources to use for monitoring geofences. Its a BITWISE-OR * of FLP_TECH_MASK flags. */ uint32_t sources_to_use; } GeofenceOptions; /** Geofence struct */ typedef struct { int32_t geofence_id; GeofenceData* data; GeofenceOptions* options; } Geofence; /** Extended interface for FLP_Geofencing support */ typedef struct { /** set to sizeof(FlpGeofencingInterface) */ size_t size; /** * Opens the geofence interface and provides the callback routines * to the implemenation of this interface. */ void (*init)( FlpGeofenceCallbacks* callbacks ); /** * Add a list of geofences. * Parameters: * number_of_geofences - The number of geofences that needed to be added. * geofences - Pointer to array of pointers to Geofence structure. */ void (*add_geofences) (int32_t number_of_geofences, Geofence** geofences); /** * Pause monitoring a particular geofence. * Parameters: * geofence_id - The id for the geofence. */ void (*pause_geofence) (int32_t geofence_id); /** * Resume monitoring a particular geofence. * Parameters: * geofence_id - The id for the geofence. * monitor_transitions - Which transitions to monitor. Bitwise OR of * FLP_GEOFENCE_TRANSITION_ENTERED, FLP_GEOFENCE_TRANSITION_EXITED and * FLP_GEOFENCE_TRANSITION_UNCERTAIN. * This supersedes the value associated provided in the * add_geofence_area call. */ void (*resume_geofence) (int32_t geofence_id, int monitor_transitions); /** * Modify a particular geofence option. * Parameters: * geofence_id - The id for the geofence. * options - Various options associated with the geofence. See * GeofenceOptions structure for details. */ void (*modify_geofence_option) (int32_t geofence_id, GeofenceOptions* options); /** * Remove a list of geofences. After the function returns, no notifications * should be sent. * Parameter: * number_of_geofences - The number of geofences that needed to be added. * geofence_id - Pointer to array of geofence_ids to be removed. */ void (*remove_geofences) (int32_t number_of_geofences, int32_t* geofence_id); } FlpGeofencingInterface; __END_DECLS #endif /* ANDROID_INCLUDE_HARDWARE_FLP_H */ android-headers-23/22/hardware/gps.h000066400000000000000000001775311264465411000173340ustar00rootroot00000000000000/* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_HARDWARE_GPS_H #define ANDROID_INCLUDE_HARDWARE_GPS_H #include #include #include #include #include #include #include __BEGIN_DECLS /** * The id of this module */ #define GPS_HARDWARE_MODULE_ID "gps" /** Milliseconds since January 1, 1970 */ typedef int64_t GpsUtcTime; /** Maximum number of SVs for gps_sv_status_callback(). */ #define GPS_MAX_SVS 32 /** Maximum number of Measurements in gps_measurement_callback(). */ #define GPS_MAX_MEASUREMENT 32 /** 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. */ #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 0x0000001 /** GPS supports MS-Based AGPS mode */ #define GPS_CAPABILITY_MSB 0x0000002 /** GPS supports MS-Assisted AGPS mode */ #define GPS_CAPABILITY_MSA 0x0000004 /** GPS supports single-shot fixes */ #define GPS_CAPABILITY_SINGLE_SHOT 0x0000008 /** GPS supports on demand time injection */ #define GPS_CAPABILITY_ON_DEMAND_TIME 0x0000010 /** GPS supports Geofencing */ #define GPS_CAPABILITY_GEOFENCING 0x0000020 /** GPS supports Measurements */ #define GPS_CAPABILITY_MEASUREMENTS 0x0000040 /** GPS supports Navigation Messages */ #define GPS_CAPABILITY_NAV_MESSAGES 0x0000080 /** 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 */ #define GPS_NI_SHORT_STRING_MAXLEN 256 #define GPS_NI_LONG_STRING_MAXLEN 2048 /** * 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 #define AGPS_REF_LOCATION_TYPE_GSM_CELLID 1 #define AGPS_REF_LOCATION_TYPE_UMTS_CELLID 2 #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 /** * Flags to indicate what fields in GpsClock are valid. */ typedef uint16_t GpsClockFlags; /** A valid 'leap second' is stored in the data structure. */ #define GPS_CLOCK_HAS_LEAP_SECOND (1<<0) /** A valid 'time uncertainty' is stored in the data structure. */ #define GPS_CLOCK_HAS_TIME_UNCERTAINTY (1<<1) /** A valid 'full bias' is stored in the data structure. */ #define GPS_CLOCK_HAS_FULL_BIAS (1<<2) /** A valid 'bias' is stored in the data structure. */ #define GPS_CLOCK_HAS_BIAS (1<<3) /** A valid 'bias uncertainty' is stored in the data structure. */ #define GPS_CLOCK_HAS_BIAS_UNCERTAINTY (1<<4) /** A valid 'drift' is stored in the data structure. */ #define GPS_CLOCK_HAS_DRIFT (1<<5) /** A valid 'drift uncertainty' is stored in the data structure. */ #define GPS_CLOCK_HAS_DRIFT_UNCERTAINTY (1<<6) /** * Enumeration of the available values for the GPS Clock type. */ typedef uint8_t GpsClockType; /** The type is not available ot it is unknown. */ #define GPS_CLOCK_TYPE_UNKNOWN 0 /** The source of the time value reported by GPS clock is the local hardware clock. */ #define GPS_CLOCK_TYPE_LOCAL_HW_TIME 1 /** * The source of the time value reported by GPS clock is the GPS time derived from satellites * (epoch = Jan 6, 1980) */ #define GPS_CLOCK_TYPE_GPS_TIME 2 /** * Flags to indicate what fields in GpsMeasurement are valid. */ typedef uint32_t GpsMeasurementFlags; /** A valid 'snr' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_SNR (1<<0) /** A valid 'elevation' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_ELEVATION (1<<1) /** A valid 'elevation uncertainty' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_ELEVATION_UNCERTAINTY (1<<2) /** A valid 'azimuth' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_AZIMUTH (1<<3) /** A valid 'azimuth uncertainty' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_AZIMUTH_UNCERTAINTY (1<<4) /** A valid 'pseudorange' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_PSEUDORANGE (1<<5) /** A valid 'pseudorange uncertainty' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_PSEUDORANGE_UNCERTAINTY (1<<6) /** A valid 'code phase' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_CODE_PHASE (1<<7) /** A valid 'code phase uncertainty' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_CODE_PHASE_UNCERTAINTY (1<<8) /** A valid 'carrier frequency' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_CARRIER_FREQUENCY (1<<9) /** A valid 'carrier cycles' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_CARRIER_CYCLES (1<<10) /** A valid 'carrier phase' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_CARRIER_PHASE (1<<11) /** A valid 'carrier phase uncertainty' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY (1<<12) /** A valid 'bit number' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_BIT_NUMBER (1<<13) /** A valid 'time from last bit' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_TIME_FROM_LAST_BIT (1<<14) /** A valid 'doppler shift' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_DOPPLER_SHIFT (1<<15) /** A valid 'doppler shift uncertainty' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_DOPPLER_SHIFT_UNCERTAINTY (1<<16) /** A valid 'used in fix' flag is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_USED_IN_FIX (1<<17) /** * Enumeration of the available values for the GPS Measurement's loss of lock. */ typedef uint8_t GpsLossOfLock; /** The indicator is not available or it is unknown. */ #define GPS_LOSS_OF_LOCK_UNKNOWN 0 /** The measurement does not present any indication of loss of lock. */ #define GPS_LOSS_OF_LOCK_OK 1 /** Loss of lock between previous and current observation: cycle slip possible. */ #define GPS_LOSS_OF_LOCK_CYCLE_SLIP 2 /** * Enumeration of available values for the GPS Measurement's multipath indicator. */ typedef uint8_t GpsMultipathIndicator; /** The indicator is not available or unknown. */ #define GPS_MULTIPATH_INDICATOR_UNKNOWN 0 /** The measurement has been indicated to use multipath. */ #define GPS_MULTIPATH_INDICATOR_DETECTED 1 /** The measurement has been indicated Not to use multipath. */ #define GPS_MULTIPATH_INDICATOR_NOT_USED 2 /** * Flags indicating the GPS measurement state. * The expected behavior here is for GPS HAL to set all the flags that applies. For * example, if the state for a satellite is only C/A code locked and bit synchronized, * and there is still millisecond ambiguity, the state should be set as: * GPS_MEASUREMENT_STATE_CODE_LOCK|GPS_MEASUREMENT_STATE_BIT_SYNC|GPS_MEASUREMENT_STATE_MSEC_AMBIGUOUS * If GPS is still searching for a satellite, the corresponding state should be set to * GPS_MEASUREMENT_STATE_UNKNOWN(0). */ typedef uint16_t GpsMeasurementState; #define GPS_MEASUREMENT_STATE_UNKNOWN 0 #define GPS_MEASUREMENT_STATE_CODE_LOCK (1<<0) #define GPS_MEASUREMENT_STATE_BIT_SYNC (1<<1) #define GPS_MEASUREMENT_STATE_SUBFRAME_SYNC (1<<2) #define GPS_MEASUREMENT_STATE_TOW_DECODED (1<<3) #define GPS_MEASUREMENT_STATE_MSEC_AMBIGUOUS (1<<4) /** * Flags indicating the Accumulated Delta Range's states. */ typedef uint16_t GpsAccumulatedDeltaRangeState; #define GPS_ADR_STATE_UNKNOWN 0 #define GPS_ADR_STATE_VALID (1<<0) #define GPS_ADR_STATE_RESET (1<<1) #define GPS_ADR_STATE_CYCLE_SLIP (1<<2) /** * Enumeration of available values to indicate the available GPS Navigation message types. */ typedef uint8_t GpsNavigationMessageType; /** The message type is unknown. */ #define GPS_NAVIGATION_MESSAGE_TYPE_UNKNOWN 0 /** L1 C/A message contained in the structure. */ #define GPS_NAVIGATION_MESSAGE_TYPE_L1CA 1 /** L2-CNAV message contained in the structure. */ #define GPS_NAVIGATION_MESSAGE_TYPE_L2CNAV 2 /** L5-CNAV message contained in the structure. */ #define GPS_NAVIGATION_MESSAGE_TYPE_L5CNAV 3 /** CNAV-2 message contained in the structure. */ #define GPS_NAVIGATION_MESSAGE_TYPE_CNAV2 4 /** * Status of Navigation Message * When a message is received properly without any parity error in its navigation words, the * status should be set to NAV_MESSAGE_STATUS_PARITY_PASSED. But if a message is received * with words that failed parity check, but GPS is able to correct those words, the status * should be set to NAV_MESSAGE_STATUS_PARITY_REBUILT. * No need to send any navigation message that contains words with parity error and cannot be * corrected. */ typedef uint16_t NavigationMessageStatus; #define NAV_MESSAGE_STATUS_UNKONW 0 #define NAV_MESSAGE_STATUS_PARITY_PASSED (1<<0) #define NAV_MESSAGE_STATUS_PARITY_REBUILT (1<<1) /** * Name for the GPS XTRA interface. */ #define GPS_XTRA_INTERFACE "gps-xtra" /** * Name for the GPS DEBUG interface. */ #define GPS_DEBUG_INTERFACE "gps-debug" /** * Name for the AGPS interface. */ #define AGPS_INTERFACE "agps" /** * Name of the Supl Certificate interface. */ #define SUPL_CERTIFICATE_INTERFACE "supl-certificate" /** * Name for NI interface */ #define GPS_NI_INTERFACE "gps-ni" /** * Name for the AGPS-RIL interface. */ #define AGPS_RIL_INTERFACE "agps_ril" /** * Name for the GPS_Geofencing interface. */ #define GPS_GEOFENCING_INTERFACE "gps_geofencing" /** * Name of the GPS Measurements interface. */ #define GPS_MEASUREMENT_INTERFACE "gps_measurement" /** * Name of the GPS navigation message interface. */ #define GPS_NAVIGATION_MESSAGE_INTERFACE "gps_navigation_message" /** * Name of the GNSS/GPS configuration interface. */ #define GNSS_CONFIGURATION_INTERFACE "gnss_configuration" /** Represents a location. */ typedef struct { /** set to sizeof(GpsLocation) */ size_t size; /** Contains GpsLocationFlags bits. */ uint16_t flags; /** Represents latitude in degrees. */ double latitude; /** Represents longitude in degrees. */ double longitude; /** Represents altitude in meters above the WGS 84 reference * ellipsoid. */ double altitude; /** Represents speed in meters per second. */ float speed; /** Represents heading in degrees. */ float bearing; /** Represents expected accuracy in meters. */ float accuracy; /** Timestamp for the location fix. */ GpsUtcTime timestamp; } GpsLocation; /** Represents the status. */ typedef struct { /** set to sizeof(GpsStatus) */ size_t size; GpsStatusValue status; } GpsStatus; /** Represents SV information. */ typedef struct { /** set to sizeof(GpsSvInfo) */ size_t size; /** Pseudo-random number for the SV. */ int prn; /** Signal to noise ratio. */ float snr; /** Elevation of SV in degrees. */ float elevation; /** Azimuth of SV in degrees. */ float azimuth; } GpsSvInfo; /** Represents SV status. */ typedef struct { /** set to sizeof(GpsSvStatus) */ size_t size; /** Number of SVs currently visible. */ int num_svs; /** Contains an array of SV information. */ GpsSvInfo sv_list[GPS_MAX_SVS]; /** Represents a bit mask indicating which SVs * have ephemeris data. */ uint32_t ephemeris_mask; /** Represents a bit mask indicating which SVs * have almanac data. */ uint32_t almanac_mask; /** * Represents a bit mask indicating which SVs * were used for computing the most recent position fix. */ uint32_t used_in_fix_mask; } GpsSvStatus; /* 2G and 3G */ /* In 3G lac is discarded */ typedef struct { uint16_t type; uint16_t mcc; uint16_t mnc; uint16_t lac; uint32_t cid; } AGpsRefLocationCellID; typedef struct { uint8_t mac[6]; } AGpsRefLocationMac; /** Represents ref locations */ typedef struct { uint16_t type; union { AGpsRefLocationCellID cellID; AGpsRefLocationMac mac; } u; } AGpsRefLocation; /** Callback with location information. * Can only be called from a thread created by create_thread_cb. */ typedef void (* gps_location_callback)(GpsLocation* location); /** Callback with status information. * Can only be called from a thread created by create_thread_cb. */ typedef void (* gps_status_callback)(GpsStatus* status); /** * Callback with SV status information. * Can only be called from a thread created by create_thread_cb. */ typedef void (* gps_sv_status_callback)(GpsSvStatus* sv_info); /** Callback for reporting NMEA sentences. * Can only be called from a thread created by create_thread_cb. */ typedef void (* gps_nmea_callback)(GpsUtcTime timestamp, const char* nmea, int length); /** Callback to inform framework of the GPS engine's capabilities. * Capability parameter is a bit field of GPS_CAPABILITY_* flags. */ typedef void (* gps_set_capabilities)(uint32_t capabilities); /** Callback utility for acquiring the GPS wakelock. * This can be used to prevent the CPU from suspending while handling GPS events. */ typedef void (* gps_acquire_wakelock)(); /** Callback utility for releasing the GPS wakelock. */ typedef void (* gps_release_wakelock)(); /** Callback for requesting NTP time */ typedef void (* gps_request_utc_time)(); /** Callback for creating a thread that can call into the Java framework code. * This must be used to create any threads that report events up to the framework. */ typedef pthread_t (* gps_create_thread)(const char* name, void (*start)(void *), void* arg); /** GPS callback structure. */ typedef struct { /** set to sizeof(GpsCallbacks) */ size_t size; gps_location_callback location_cb; gps_status_callback status_cb; gps_sv_status_callback sv_status_cb; gps_nmea_callback nmea_cb; gps_set_capabilities set_capabilities_cb; gps_acquire_wakelock acquire_wakelock_cb; gps_release_wakelock release_wakelock_cb; gps_create_thread create_thread_cb; gps_request_utc_time request_utc_time_cb; } GpsCallbacks; /** Represents the standard GPS interface. */ typedef struct { /** set to sizeof(GpsInterface) */ size_t size; /** * Opens the interface and provides the callback routines * to the implementation of this interface. */ int (*init)( GpsCallbacks* callbacks ); /** Starts navigating. */ int (*start)( void ); /** Stops navigating. */ int (*stop)( void ); /** Closes the interface. */ void (*cleanup)( void ); /** Injects the current time. */ int (*inject_time)(GpsUtcTime time, int64_t timeReference, int uncertainty); /** Injects current location from another location provider * (typically cell ID). * latitude and longitude are measured in degrees * expected accuracy is measured in meters */ int (*inject_location)(double latitude, double longitude, float accuracy); /** * Specifies that the next call to start will not use the * information defined in the flags. GPS_DELETE_ALL is passed for * a cold start. */ void (*delete_aiding_data)(GpsAidingData flags); /** * min_interval represents the time between fixes in milliseconds. * preferred_accuracy represents the requested fix accuracy in meters. * preferred_time represents the requested time to first fix in milliseconds. */ int (*set_position_mode)(GpsPositionMode mode, GpsPositionRecurrence recurrence, uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time); /** Get a pointer to extension information. */ const void* (*get_extension)(const char* name); } GpsInterface; /** Callback to request the client to download XTRA data. * The client should download XTRA data and inject it by calling inject_xtra_data(). * Can only be called from a thread created by create_thread_cb. */ typedef void (* gps_xtra_download_request)(); /** Callback structure for the XTRA interface. */ typedef struct { gps_xtra_download_request download_request_cb; gps_create_thread create_thread_cb; } GpsXtraCallbacks; /** Extended interface for XTRA support. */ typedef struct { /** set to sizeof(GpsXtraInterface) */ size_t size; /** * Opens the XTRA interface and provides the callback routines * to the implementation of this interface. */ int (*init)( GpsXtraCallbacks* callbacks ); /** Injects XTRA data into the GPS. */ int (*inject_xtra_data)( char* data, int length ); } GpsXtraInterface; /** Extended interface for DEBUG support. */ typedef struct { /** set to sizeof(GpsDebugInterface) */ size_t size; /** * This function should return any information that the native * implementation wishes to include in a bugreport. */ size_t (*get_internal_state)(char* buffer, size_t bufferSize); } GpsDebugInterface; /** Represents the status of AGPS. */ typedef struct { /** set to sizeof(AGpsStatus_v1) */ size_t size; AGpsType type; AGpsStatusValue status; } AGpsStatus_v1; /** Represents the status of AGPS augmented with a IPv4 address field. */ typedef struct { /** set to sizeof(AGpsStatus_v2) */ size_t size; AGpsType type; AGpsStatusValue status; uint32_t ipaddr; } AGpsStatus_v2; /* Represents the status of AGPS augmented to support IPv4 and IPv6. */ typedef struct { /** set to sizeof(AGpsStatus_v3) */ size_t size; AGpsType type; AGpsStatusValue status; /** * Must be set to a valid IPv4 address if the field 'addr' contains an IPv4 * address, or set to INADDR_NONE otherwise. */ uint32_t ipaddr; /** * Must contain the IPv4 (AF_INET) or IPv6 (AF_INET6) address to report. * Any other value of addr.ss_family will be rejected. * */ struct sockaddr_storage addr; } AGpsStatus_v3; typedef AGpsStatus_v3 AGpsStatus; /** Callback with AGPS status information. * Can only be called from a thread created by create_thread_cb. */ typedef void (* agps_status_callback)(AGpsStatus* status); /** Callback structure for the AGPS interface. */ typedef struct { agps_status_callback status_cb; gps_create_thread create_thread_cb; } AGpsCallbacks; /** Extended interface for AGPS support. */ typedef struct { /** set to sizeof(AGpsInterface_v1) */ size_t size; /** * Opens the AGPS interface and provides the callback routines * to the implementation of this interface. */ void (*init)( AGpsCallbacks* callbacks ); /** * Notifies that a data connection is available and sets * the name of the APN to be used for SUPL. */ int (*data_conn_open)( const char* apn ); /** * Notifies that the AGPS data connection has been closed. */ int (*data_conn_closed)(); /** * Notifies that a data connection is not available for AGPS. */ int (*data_conn_failed)(); /** * Sets the hostname and port for the AGPS server. */ int (*set_server)( AGpsType type, const char* hostname, int port ); } AGpsInterface_v1; /** * Extended interface for AGPS support, it is augmented to enable to pass * extra APN data. */ typedef struct { /** set to sizeof(AGpsInterface_v2) */ size_t size; /** * Opens the AGPS interface and provides the callback routines to the * implementation of this interface. */ void (*init)(AGpsCallbacks* callbacks); /** * Deprecated. * If the HAL supports AGpsInterface_v2 this API will not be used, see * data_conn_open_with_apn_ip_type for more information. */ int (*data_conn_open)(const char* apn); /** * Notifies that the AGPS data connection has been closed. */ int (*data_conn_closed)(); /** * Notifies that a data connection is not available for AGPS. */ int (*data_conn_failed)(); /** * Sets the hostname and port for the AGPS server. */ int (*set_server)(AGpsType type, const char* hostname, int port); /** * Notifies that a data connection is available and sets the name of the * APN, and its IP type, to be used for SUPL connections. */ int (*data_conn_open_with_apn_ip_type)( const char* apn, ApnIpType apnIpType); } AGpsInterface_v2; typedef AGpsInterface_v2 AGpsInterface; /** Error codes associated with certificate operations */ #define AGPS_CERTIFICATE_OPERATION_SUCCESS 0 #define AGPS_CERTIFICATE_ERROR_GENERIC -100 #define AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES -101 /** A data structure that represents an X.509 certificate using DER encoding */ typedef struct { size_t length; u_char* data; } DerEncodedCertificate; /** * A type definition for SHA1 Fingerprints used to identify X.509 Certificates * The Fingerprint is a digest of the DER Certificate that uniquely identifies it. */ typedef struct { u_char data[20]; } Sha1CertificateFingerprint; /** AGPS Interface to handle SUPL certificate operations */ typedef struct { /** set to sizeof(SuplCertificateInterface) */ size_t size; /** * Installs a set of Certificates used for SUPL connections to the AGPS server. * If needed the HAL should find out internally any certificates that need to be removed to * accommodate the certificates to install. * The certificates installed represent a full set of valid certificates needed to connect to * AGPS SUPL servers. * The list of certificates is required, and all must be available at the same time, when trying * to establish a connection with the AGPS Server. * * Parameters: * certificates - A pointer to an array of DER encoded certificates that are need to be * installed in the HAL. * length - The number of certificates to install. * Returns: * AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully * AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES if the HAL cannot store the number of * certificates attempted to be installed, the state of the certificates stored should * remain the same as before on this error case. * * IMPORTANT: * If needed the HAL should find out internally the set of certificates that need to be * removed to accommodate the certificates to install. */ int (*install_certificates) ( const DerEncodedCertificate* certificates, size_t length ); /** * Notifies the HAL that a list of certificates used for SUPL connections are revoked. It is * expected that the given set of certificates is removed from the internal store of the HAL. * * Parameters: * fingerprints - A pointer to an array of SHA1 Fingerprints to identify the set of * certificates to revoke. * length - The number of fingerprints provided. * Returns: * AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully. * * IMPORTANT: * If any of the certificates provided (through its fingerprint) is not known by the HAL, * it should be ignored and continue revoking/deleting the rest of them. */ int (*revoke_certificates) ( const Sha1CertificateFingerprint* fingerprints, size_t length ); } SuplCertificateInterface; /** Represents an NI request */ typedef struct { /** set to sizeof(GpsNiNotification) */ size_t size; /** * An ID generated by HAL to associate NI notifications and UI * responses */ int notification_id; /** * An NI type used to distinguish different categories of NI * events, such as GPS_NI_TYPE_VOICE, GPS_NI_TYPE_UMTS_SUPL, ... */ GpsNiType ni_type; /** * Notification/verification options, combinations of GpsNiNotifyFlags constants */ GpsNiNotifyFlags notify_flags; /** * Timeout period to wait for user response. * Set to 0 for no time out limit. */ int timeout; /** * Default response when time out. */ GpsUserResponseType default_response; /** * Requestor ID */ char requestor_id[GPS_NI_SHORT_STRING_MAXLEN]; /** * Notification message. It can also be used to store client_id in some cases */ char text[GPS_NI_LONG_STRING_MAXLEN]; /** * Client name decoding scheme */ GpsNiEncodingType requestor_id_encoding; /** * Client name decoding scheme */ GpsNiEncodingType text_encoding; /** * A pointer to extra data. Format: * key_1 = value_1 * key_2 = value_2 */ char extras[GPS_NI_LONG_STRING_MAXLEN]; } GpsNiNotification; /** Callback with NI notification. * Can only be called from a thread created by create_thread_cb. */ typedef void (*gps_ni_notify_callback)(GpsNiNotification *notification); /** GPS NI callback structure. */ typedef struct { /** * Sends the notification request from HAL to GPSLocationProvider. */ gps_ni_notify_callback notify_cb; gps_create_thread create_thread_cb; } GpsNiCallbacks; /** * Extended interface for Network-initiated (NI) support. */ typedef struct { /** set to sizeof(GpsNiInterface) */ size_t size; /** Registers the callbacks for HAL to use. */ void (*init) (GpsNiCallbacks *callbacks); /** Sends a response to HAL. */ void (*respond) (int notif_id, GpsUserResponseType user_response); } GpsNiInterface; struct gps_device_t { struct hw_device_t common; /** * Set the provided lights to the provided values. * * Returns: 0 on succes, error code on failure. */ 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) typedef void (*agps_ril_request_set_id)(uint32_t flags); typedef void (*agps_ril_request_ref_loc)(uint32_t flags); typedef struct { agps_ril_request_set_id request_setid; agps_ril_request_ref_loc request_refloc; gps_create_thread create_thread_cb; } AGpsRilCallbacks; /** Extended interface for AGPS_RIL support. */ typedef struct { /** set to sizeof(AGpsRilInterface) */ size_t size; /** * Opens the AGPS interface and provides the callback routines * to the implementation of this interface. */ void (*init)( AGpsRilCallbacks* callbacks ); /** * Sets the reference location. */ void (*set_ref_location) (const AGpsRefLocation *agps_reflocation, size_t sz_struct); /** * Sets the set ID. */ void (*set_set_id) (AGpsSetIDType type, const char* setid); /** * Send network initiated message. */ void (*ni_message) (uint8_t *msg, size_t len); /** * Notify GPS of network status changes. * These parameters match values in the android.net.NetworkInfo class. */ void (*update_network_state) (int connected, int type, int roaming, const char* extra_info); /** * Notify GPS of network status changes. * These parameters match values in the android.net.NetworkInfo class. */ void (*update_network_availability) (int avaiable, const char* apn); } AGpsRilInterface; /** * GPS Geofence. * There are 3 states associated with a Geofence: Inside, Outside, Unknown. * There are 3 transitions: ENTERED, EXITED, UNCERTAIN. * * An example state diagram with confidence level: 95% and Unknown time limit * set as 30 secs is shown below. (confidence level and Unknown time limit are * explained latter) * ____________________________ * | Unknown (30 secs) | * """""""""""""""""""""""""""" * ^ | | ^ * UNCERTAIN| |ENTERED EXITED| |UNCERTAIN * | v v | * ________ EXITED _________ * | Inside | -----------> | Outside | * | | <----------- | | * """""""" ENTERED """"""""" * * Inside state: We are 95% confident that the user is inside the geofence. * Outside state: We are 95% confident that the user is outside the geofence * Unknown state: Rest of the time. * * The Unknown state is better explained with an example: * * __________ * | c| * | ___ | _______ * | |a| | | b | * | """ | """"""" * | | * """""""""" * In the diagram above, "a" and "b" are 2 geofences and "c" is the accuracy * circle reported by the GPS subsystem. Now with regard to "b", the system is * confident that the user is outside. But with regard to "a" is not confident * whether it is inside or outside the geofence. If the accuracy remains the * same for a sufficient period of time, the UNCERTAIN transition would be * triggered with the state set to Unknown. If the accuracy improves later, an * appropriate transition should be triggered. This "sufficient period of time" * is defined by the parameter in the add_geofence_area API. * In other words, Unknown state can be interpreted as a state in which the * GPS subsystem isn't confident enough that the user is either inside or * outside the Geofence. It moves to Unknown state only after the expiry of the * timeout. * * The geofence callback needs to be triggered for the ENTERED and EXITED * transitions, when the GPS system is confident that the user has entered * (Inside state) or exited (Outside state) the Geofence. An implementation * which uses a value of 95% as the confidence is recommended. The callback * should be triggered only for the transitions requested by the * add_geofence_area call. * * Even though the diagram and explanation talks about states and transitions, * the callee is only interested in the transistions. The states are mentioned * here for illustrative purposes. * * Startup Scenario: When the device boots up, if an application adds geofences, * and then we get an accurate GPS location fix, it needs to trigger the * appropriate (ENTERED or EXITED) transition for every Geofence it knows about. * By default, all the Geofences will be in the Unknown state. * * When the GPS system is unavailable, gps_geofence_status_callback should be * called to inform the upper layers of the same. Similarly, when it becomes * available the callback should be called. This is a global state while the * UNKNOWN transition described above is per geofence. * * An important aspect to note is that users of this API (framework), will use * other subsystems like wifi, sensors, cell to handle Unknown case and * hopefully provide a definitive state transition to the third party * application. GPS Geofence will just be a signal indicating what the GPS * 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. * Parameters: * geofence_id - The id associated with the add_geofence_area. * location - The current GPS location. * transition - Can be one of GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED, * GPS_GEOFENCE_UNCERTAIN. * timestamp - Timestamp when the transition was detected. * * The callback should only be called when the caller is interested in that * particular transition. For instance, if the caller is interested only in * ENTERED transition, then the callback should NOT be called with the EXITED * transition. * * IMPORTANT: If a transition is triggered resulting in this callback, the GPS * subsystem will wake up the application processor, if its in suspend state. */ typedef void (*gps_geofence_transition_callback) (int32_t geofence_id, GpsLocation* location, int32_t transition, GpsUtcTime timestamp); /** * The callback associated with the availability of the GPS system for geofencing * monitoring. If the GPS system determines that it cannot monitor geofences * because of lack of reliability or unavailability of the GPS signals, it will * call this callback with GPS_GEOFENCE_UNAVAILABLE parameter. * * Parameters: * status - GPS_GEOFENCE_UNAVAILABLE or GPS_GEOFENCE_AVAILABLE. * last_location - Last known location. */ typedef void (*gps_geofence_status_callback) (int32_t status, GpsLocation* last_location); /** * The callback associated with the add_geofence call. * * Parameter: * geofence_id - Id of the geofence. * status - GPS_GEOFENCE_OPERATION_SUCCESS * GPS_GEOFENCE_ERROR_TOO_MANY_GEOFENCES - geofence limit has been reached. * GPS_GEOFENCE_ERROR_ID_EXISTS - geofence with id already exists * GPS_GEOFENCE_ERROR_INVALID_TRANSITION - the monitorTransition contains an * invalid transition * GPS_GEOFENCE_ERROR_GENERIC - for other errors. */ typedef void (*gps_geofence_add_callback) (int32_t geofence_id, int32_t status); /** * The callback associated with the remove_geofence call. * * Parameter: * geofence_id - Id of the geofence. * status - GPS_GEOFENCE_OPERATION_SUCCESS * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id * GPS_GEOFENCE_ERROR_GENERIC for others. */ typedef void (*gps_geofence_remove_callback) (int32_t geofence_id, int32_t status); /** * The callback associated with the pause_geofence call. * * Parameter: * geofence_id - Id of the geofence. * status - GPS_GEOFENCE_OPERATION_SUCCESS * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id * GPS_GEOFENCE_ERROR_INVALID_TRANSITION - * when monitor_transitions is invalid * GPS_GEOFENCE_ERROR_GENERIC for others. */ typedef void (*gps_geofence_pause_callback) (int32_t geofence_id, int32_t status); /** * The callback associated with the resume_geofence call. * * Parameter: * geofence_id - Id of the geofence. * status - GPS_GEOFENCE_OPERATION_SUCCESS * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id * GPS_GEOFENCE_ERROR_GENERIC for others. */ typedef void (*gps_geofence_resume_callback) (int32_t geofence_id, int32_t status); typedef struct { gps_geofence_transition_callback geofence_transition_callback; gps_geofence_status_callback geofence_status_callback; gps_geofence_add_callback geofence_add_callback; gps_geofence_remove_callback geofence_remove_callback; gps_geofence_pause_callback geofence_pause_callback; gps_geofence_resume_callback geofence_resume_callback; gps_create_thread create_thread_cb; } GpsGeofenceCallbacks; /** Extended interface for GPS_Geofencing support */ typedef struct { /** set to sizeof(GpsGeofencingInterface) */ size_t size; /** * Opens the geofence interface and provides the callback routines * to the implementation of this interface. */ void (*init)( GpsGeofenceCallbacks* callbacks ); /** * Add a geofence area. This api currently supports circular geofences. * Parameters: * geofence_id - The id for the geofence. If a geofence with this id * already exists, an error value (GPS_GEOFENCE_ERROR_ID_EXISTS) * should be returned. * latitude, longtitude, radius_meters - The lat, long and radius * (in meters) for the geofence * last_transition - The current state of the geofence. For example, if * the system already knows that the user is inside the geofence, * this will be set to GPS_GEOFENCE_ENTERED. In most cases, it * will be GPS_GEOFENCE_UNCERTAIN. * monitor_transition - Which transitions to monitor. Bitwise OR of * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and * GPS_GEOFENCE_UNCERTAIN. * notification_responsiveness_ms - Defines the best-effort description * of how soon should the callback be called when the transition * associated with the Geofence is triggered. For instance, if set * to 1000 millseconds with GPS_GEOFENCE_ENTERED, the callback * should be called 1000 milliseconds within entering the geofence. * This parameter is defined in milliseconds. * NOTE: This is not to be confused with the rate that the GPS is * polled at. It is acceptable to dynamically vary the rate of * sampling the GPS for power-saving reasons; thus the rate of * sampling may be faster or slower than this. * unknown_timer_ms - The time limit after which the UNCERTAIN transition * should be triggered. This parameter is defined in milliseconds. * See above for a detailed explanation. */ void (*add_geofence_area) (int32_t geofence_id, double latitude, double longitude, double radius_meters, int last_transition, int monitor_transitions, int notification_responsiveness_ms, int unknown_timer_ms); /** * Pause monitoring a particular geofence. * Parameters: * geofence_id - The id for the geofence. */ void (*pause_geofence) (int32_t geofence_id); /** * Resume monitoring a particular geofence. * Parameters: * geofence_id - The id for the geofence. * monitor_transitions - Which transitions to monitor. Bitwise OR of * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and * GPS_GEOFENCE_UNCERTAIN. * This supersedes the value associated provided in the * add_geofence_area call. */ void (*resume_geofence) (int32_t geofence_id, int monitor_transitions); /** * Remove a geofence area. After the function returns, no notifications * should be sent. * Parameter: * geofence_id - The id for the geofence. */ void (*remove_geofence_area) (int32_t geofence_id); } GpsGeofencingInterface; /** * Represents an estimate of the GPS clock time. */ typedef struct { /** set to sizeof(GpsClock) */ size_t size; /** A set of flags indicating the validity of the fields in this data structure. */ GpsClockFlags flags; /** * Leap second data. * The sign of the value is defined by the following equation: * utc_time_ns = time_ns + (full_bias_ns + bias_ns) - leap_second * 1,000,000,000 * * If the data is available 'flags' must contain GPS_CLOCK_HAS_LEAP_SECOND. */ int16_t leap_second; /** * Indicates the type of time reported by the 'time_ns' field. * This is a Mandatory field. */ GpsClockType type; /** * The GPS receiver internal clock value. This can be either the local hardware clock value * (GPS_CLOCK_TYPE_LOCAL_HW_TIME), or the current GPS time derived inside GPS receiver * (GPS_CLOCK_TYPE_GPS_TIME). The field 'type' defines the time reported. * * For local hardware clock, this value is expected to be monotonically increasing during * the reporting session. The real GPS time can be derived by compensating the 'full bias' * (when it is available) from this value. * * For GPS time, this value is expected to be the best estimation of current GPS time that GPS * receiver can achieve. Set the 'time uncertainty' appropriately when GPS time is specified. * * Sub-nanosecond accuracy can be provided by means of the 'bias' field. * The value contains the 'time uncertainty' in it. * * This is a Mandatory field. */ int64_t time_ns; /** * 1-Sigma uncertainty associated with the clock's time in nanoseconds. * The uncertainty is represented as an absolute (single sided) value. * * This value should be set if GPS_CLOCK_TYPE_GPS_TIME is set. * If the data is available 'flags' must contain GPS_CLOCK_HAS_TIME_UNCERTAINTY. */ double time_uncertainty_ns; /** * The difference between hardware clock ('time' field) inside GPS receiver and the true GPS * time since 0000Z, January 6, 1980, in nanoseconds. * This value is used if and only if GPS_CLOCK_TYPE_LOCAL_HW_TIME is set, and GPS receiver * has solved the clock for GPS time. * The caller is responsible for using the 'bias uncertainty' field for quality check. * * The sign of the value is defined by the following equation: * true time (GPS time) = time_ns + (full_bias_ns + bias_ns) * * This value contains the 'bias uncertainty' in it. * If the data is available 'flags' must contain GPS_CLOCK_HAS_FULL_BIAS. */ int64_t full_bias_ns; /** * Sub-nanosecond bias. * The value contains the 'bias uncertainty' in it. * * If the data is available 'flags' must contain GPS_CLOCK_HAS_BIAS. */ double bias_ns; /** * 1-Sigma uncertainty associated with the clock's bias in nanoseconds. * The uncertainty is represented as an absolute (single sided) value. * * If the data is available 'flags' must contain GPS_CLOCK_HAS_BIAS_UNCERTAINTY. */ double bias_uncertainty_ns; /** * The clock's drift in nanoseconds (per second). * A positive value means that the frequency is higher than the nominal frequency. * * The value contains the 'drift uncertainty' in it. * If the data is available 'flags' must contain GPS_CLOCK_HAS_DRIFT. */ double drift_nsps; /** * 1-Sigma uncertainty associated with the clock's drift in nanoseconds (per second). * The uncertainty is represented as an absolute (single sided) value. * * If the data is available 'flags' must contain GPS_CLOCK_HAS_DRIFT_UNCERTAINTY. */ double drift_uncertainty_nsps; } GpsClock; /** * Represents a GPS Measurement, it contains raw and computed information. */ typedef struct { /** set to sizeof(GpsMeasurement) */ size_t size; /** A set of flags indicating the validity of the fields in this data structure. */ GpsMeasurementFlags flags; /** * Pseudo-random number in the range of [1, 32] * This is a Mandatory value. */ int8_t prn; /** * Time offset at which the measurement was taken in nanoseconds. * The reference receiver's time is specified by GpsData::clock::time_ns and should be * interpreted in the same way as indicated by GpsClock::type. * * The sign of time_offset_ns is given by the following equation: * measurement time = GpsClock::time_ns + time_offset_ns * * It provides an individual time-stamp for the measurement, and allows sub-nanosecond accuracy. * This is a Mandatory value. */ double time_offset_ns; /** * Per satellite sync state. It represents the current sync state for the associated satellite. * Based on the sync state, the 'received GPS tow' field should be interpreted accordingly. * * This is a Mandatory value. */ GpsMeasurementState state; /** * Received GPS Time-of-Week at the measurement time, in nanoseconds. * The value is relative to the beginning of the current GPS week. * * Given the highest sync state that can be achieved, per each satellite, valid range for * this field can be: * Searching : [ 0 ] : GPS_MEASUREMENT_STATE_UNKNOWN * C/A code lock : [ 0 1ms ] : GPS_MEASUREMENT_STATE_CODE_LOCK is set * Bit sync : [ 0 20ms ] : GPS_MEASUREMENT_STATE_BIT_SYNC is set * Subframe sync : [ 0 6s ] : GPS_MEASUREMENT_STATE_SUBFRAME_SYNC is set * TOW decoded : [ 0 1week ] : GPS_MEASUREMENT_STATE_TOW_DECODED is set * * However, if there is any ambiguity in integer millisecond, * GPS_MEASUREMENT_STATE_MSEC_AMBIGUOUS should be set accordingly, in the 'state' field. */ int64_t received_gps_tow_ns; /** * 1-Sigma uncertainty of the Received GPS Time-of-Week in nanoseconds. */ int64_t received_gps_tow_uncertainty_ns; /** * Carrier-to-noise density in dB-Hz, in the range [0, 63]. * It contains the measured C/N0 value for the signal at the antenna input. * * This is a Mandatory value. */ double c_n0_dbhz; /** * Pseudorange rate at the timestamp in m/s. * The value also includes the effects of the receiver clock frequency and satellite clock * frequency errors. * * The value includes the 'pseudorange rate uncertainty' in it. * A positive value indicates that the pseudorange is getting larger. * * This is a Mandatory value. */ double pseudorange_rate_mps; /** * 1-Sigma uncertainty of the pseudurange rate in m/s. * The uncertainty is represented as an absolute (single sided) value. * * This is a Mandatory value. */ double pseudorange_rate_uncertainty_mps; /** * Accumulated delta range's state. It indicates whether ADR is reset or there is a cycle slip * (indicating loss of lock). * * This is a Mandatory value. */ GpsAccumulatedDeltaRangeState accumulated_delta_range_state; /** * Accumulated delta range since the last channel reset in meters. * The data is available if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN. */ double accumulated_delta_range_m; /** * 1-Sigma uncertainty of the accumulated delta range in meters. * The data is available if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN. */ double accumulated_delta_range_uncertainty_m; /** * Best derived Pseudorange by the chip-set, in meters. * The value contains the 'pseudorange uncertainty' in it. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_PSEUDORANGE. */ double pseudorange_m; /** * 1-Sigma uncertainty of the pseudorange in meters. * The value contains the 'pseudorange' and 'clock' uncertainty in it. * The uncertainty is represented as an absolute (single sided) value. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_PSEUDORANGE_UNCERTAINTY. */ double pseudorange_uncertainty_m; /** * A fraction of the current C/A code cycle, in the range [0.0, 1023.0] * This value contains the time (in Chip units) since the last C/A code cycle (GPS Msec epoch). * * The reference frequency is given by the field 'carrier_frequency_hz'. * The value contains the 'code-phase uncertainty' in it. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CODE_PHASE. */ double code_phase_chips; /** * 1-Sigma uncertainty of the code-phase, in a fraction of chips. * The uncertainty is represented as an absolute (single sided) value. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CODE_PHASE_UNCERTAINTY. */ double code_phase_uncertainty_chips; /** * Carrier frequency at which codes and messages are modulated, it can be L1 or L2. * If the field is not set, the carrier frequency is assumed to be L1. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CARRIER_FREQUENCY. */ float carrier_frequency_hz; /** * The number of full carrier cycles between the satellite and the receiver. * The reference frequency is given by the field 'carrier_frequency_hz'. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CARRIER_CYCLES. */ int64_t carrier_cycles; /** * The RF phase detected by the receiver, in the range [0.0, 1.0]. * This is usually the fractional part of the complete carrier phase measurement. * * The reference frequency is given by the field 'carrier_frequency_hz'. * The value contains the 'carrier-phase uncertainty' in it. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CARRIER_PHASE. */ double carrier_phase; /** * 1-Sigma uncertainty of the carrier-phase. * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY. */ double carrier_phase_uncertainty; /** * An enumeration that indicates the 'loss of lock' state of the event. */ GpsLossOfLock loss_of_lock; /** * The number of GPS bits transmitted since Sat-Sun midnight (GPS week). * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_BIT_NUMBER. */ int32_t bit_number; /** * The elapsed time since the last received bit in milliseconds, in the range [0, 20] * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_TIME_FROM_LAST_BIT. */ int16_t time_from_last_bit_ms; /** * Doppler shift in Hz. * A positive value indicates that the SV is moving toward the receiver. * * The reference frequency is given by the field 'carrier_frequency_hz'. * The value contains the 'doppler shift uncertainty' in it. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_DOPPLER_SHIFT. */ double doppler_shift_hz; /** * 1-Sigma uncertainty of the doppler shift in Hz. * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_DOPPLER_SHIFT_UNCERTAINTY. */ double doppler_shift_uncertainty_hz; /** * An enumeration that indicates the 'multipath' state of the event. */ GpsMultipathIndicator multipath_indicator; /** * Signal-to-noise ratio in dB. * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_SNR. */ double snr_db; /** * Elevation in degrees, the valid range is [-90, 90]. * The value contains the 'elevation uncertainty' in it. * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_ELEVATION. */ double elevation_deg; /** * 1-Sigma uncertainty of the elevation in degrees, the valid range is [0, 90]. * The uncertainty is represented as the absolute (single sided) value. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_ELEVATION_UNCERTAINTY. */ double elevation_uncertainty_deg; /** * Azimuth in degrees, in the range [0, 360). * The value contains the 'azimuth uncertainty' in it. * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_AZIMUTH. * */ double azimuth_deg; /** * 1-Sigma uncertainty of the azimuth in degrees, the valid range is [0, 180]. * The uncertainty is represented as an absolute (single sided) value. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_AZIMUTH_UNCERTAINTY. */ double azimuth_uncertainty_deg; /** * Whether the GPS represented by the measurement was used for computing the most recent fix. * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_USED_IN_FIX. */ bool used_in_fix; } GpsMeasurement; /** Represents a reading of GPS measurements. */ typedef struct { /** set to sizeof(GpsData) */ size_t size; /** Number of measurements. */ size_t measurement_count; /** The array of measurements. */ GpsMeasurement measurements[GPS_MAX_MEASUREMENT]; /** The GPS clock time reading. */ GpsClock clock; } GpsData; /** * The callback for to report measurements from the HAL. * * Parameters: * data - A data structure containing the measurements. */ typedef void (*gps_measurement_callback) (GpsData* data); typedef struct { /** set to sizeof(GpsMeasurementCallbacks) */ size_t size; gps_measurement_callback 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. */ typedef struct { /** Set to sizeof(GpsMeasurementInterface) */ size_t size; /** * Initializes the interface and registers the callback routines with the HAL. * After a successful call to 'init' the HAL must begin to provide updates at its own phase. * * Status: * GPS_MEASUREMENT_OPERATION_SUCCESS * GPS_MEASUREMENT_ERROR_ALREADY_INIT - if a callback has already been registered without a * corresponding call to 'close' * GPS_MEASUREMENT_ERROR_GENERIC - if any other error occurred, it is expected that the HAL * will not generate any updates upon returning this error code. */ int (*init) (GpsMeasurementCallbacks* callbacks); /** * Stops updates from the HAL, and unregisters the callback routines. * After a call to stop, the previously registered callbacks must be considered invalid by the * HAL. * If stop is invoked without a previous 'init', this function should perform no work. */ void (*close) (); } GpsMeasurementInterface; /** Represents a GPS navigation message (or a fragment of it). */ typedef struct { /** set to sizeof(GpsNavigationMessage) */ size_t size; /** * Pseudo-random number in the range of [1, 32] * This is a Mandatory value. */ int8_t prn; /** * The type of message contained in the structure. * This is a Mandatory value. */ GpsNavigationMessageType type; /** * The status of the received navigation message. * No need to send any navigation message that contains words with parity error and cannot be * corrected. */ NavigationMessageStatus status; /** * Message identifier. * It provides an index so the complete Navigation Message can be assembled. i.e. fo L1 C/A * subframe 4 and 5, this value corresponds to the 'frame id' of the navigation message. * Subframe 1, 2, 3 does not contain a 'frame id' and this value can be set to -1. */ int16_t message_id; /** * Sub-message identifier. * If required by the message 'type', this value contains a sub-index within the current * message (or frame) that is being transmitted. * i.e. for L1 C/A the submessage id corresponds to the sub-frame id of the navigation message. */ int16_t submessage_id; /** * The length of the data (in bytes) contained in the current message. * If this value is different from zero, 'data' must point to an array of the same size. * e.g. for L1 C/A the size of the sub-frame will be 40 bytes (10 words, 30 bits/word). * * This is a Mandatory value. */ size_t data_length; /** * The data of the reported GPS message. * The bytes (or words) specified using big endian format (MSB first). * * For L1 C/A, each subframe contains 10 30-bit GPS words. Each GPS word (30 bits) should be * fitted into the last 30 bits in a 4-byte word (skip B31 and B32), with MSB first. */ uint8_t* data; } GpsNavigationMessage; /** * The callback to report an available fragment of a GPS navigation messages from the HAL. * * Parameters: * message - The GPS navigation submessage/subframe representation. */ typedef void (*gps_navigation_message_callback) (GpsNavigationMessage* message); typedef struct { /** set to sizeof(GpsNavigationMessageCallbacks) */ size_t size; gps_navigation_message_callback 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. */ typedef struct { /** Set to sizeof(GpsNavigationMessageInterface) */ size_t size; /** * Initializes the interface and registers the callback routines with the HAL. * After a successful call to 'init' the HAL must begin to provide updates as they become * available. * * Status: * GPS_NAVIGATION_MESSAGE_OPERATION_SUCCESS * GPS_NAVIGATION_MESSAGE_ERROR_ALREADY_INIT - if a callback has already been registered * without a corresponding call to 'close'. * GPS_NAVIGATION_MESSAGE_ERROR_GENERIC - if any other error occurred, it is expected that * the HAL will not generate any updates upon returning this error code. */ int (*init) (GpsNavigationMessageCallbacks* callbacks); /** * Stops updates from the HAL, and unregisters the callback routines. * After a call to stop, the previously registered callbacks must be considered invalid by the * HAL. * If stop is invoked without a previous 'init', this function should perform no work. */ void (*close) (); } GpsNavigationMessageInterface; /** * Interface for passing GNSS configuration contents from platform to HAL. */ typedef struct { /** Set to sizeof(GnssConfigurationInterface) */ size_t size; /** * Deliver GNSS configuration contents to HAL. * Parameters: * config_data - a pointer to a char array which holds what usually is expected from file(/etc/gps.conf), i.e., a sequence of UTF8 strings separated by '\n'. * length - total number of UTF8 characters in configuraiton data. * * IMPORTANT: * GPS HAL should expect this function can be called multiple times. And it may be * called even when GpsLocationProvider is already constructed and enabled. GPS HAL * should maintain the existing requests for various callback regardless the change * in configuration data. */ void (*configuration_update) (const char* config_data, int32_t length); } GnssConfigurationInterface; __END_DECLS #endif /* ANDROID_INCLUDE_HARDWARE_GPS_H */ android-headers-23/22/hardware/gralloc.h000066400000000000000000000326451264465411000201620ustar00rootroot00000000000000/* * 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_GRALLOC_INTERFACE_H #define ANDROID_GRALLOC_INTERFACE_H #include #include #include #include #include #include #include #include #include __BEGIN_DECLS /** * Module versioning information for the Gralloc hardware module, based on * gralloc_module_t.common.module_api_version. * * Version History: * * GRALLOC_MODULE_API_VERSION_0_1: * Initial Gralloc hardware module API. * * GRALLOC_MODULE_API_VERSION_0_2: * Add support for flexible YCbCr format with (*lock_ycbcr)() method. * * GRALLOC_MODULE_API_VERSION_0_3: * Add support for fence passing to/from lock/unlock. */ #define GRALLOC_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define GRALLOC_MODULE_API_VERSION_0_2 HARDWARE_MODULE_API_VERSION(0, 2) #define GRALLOC_MODULE_API_VERSION_0_3 HARDWARE_MODULE_API_VERSION(0, 3) #define GRALLOC_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION(0, 1) /** * The id of this module */ #define GRALLOC_HARDWARE_MODULE_ID "gralloc" /** * Name of the graphics device to open */ #define GRALLOC_HARDWARE_GPU0 "gpu0" enum { /* buffer is never read in software */ GRALLOC_USAGE_SW_READ_NEVER = 0x00000000, /* buffer is rarely read in software */ GRALLOC_USAGE_SW_READ_RARELY = 0x00000002, /* buffer is often read in software */ GRALLOC_USAGE_SW_READ_OFTEN = 0x00000003, /* mask for the software read values */ GRALLOC_USAGE_SW_READ_MASK = 0x0000000F, /* buffer is never written in software */ GRALLOC_USAGE_SW_WRITE_NEVER = 0x00000000, /* buffer is rarely written in software */ GRALLOC_USAGE_SW_WRITE_RARELY = 0x00000020, /* buffer is often written in software */ GRALLOC_USAGE_SW_WRITE_OFTEN = 0x00000030, /* mask for the software write values */ GRALLOC_USAGE_SW_WRITE_MASK = 0x000000F0, /* buffer will be used as an OpenGL ES texture */ GRALLOC_USAGE_HW_TEXTURE = 0x00000100, /* buffer will be used as an OpenGL ES render target */ GRALLOC_USAGE_HW_RENDER = 0x00000200, /* buffer will be used by the 2D hardware blitter */ GRALLOC_USAGE_HW_2D = 0x00000400, /* buffer will be used by the HWComposer HAL module */ GRALLOC_USAGE_HW_COMPOSER = 0x00000800, /* buffer will be used with the framebuffer device */ GRALLOC_USAGE_HW_FB = 0x00001000, /* buffer will be used with the HW video encoder */ GRALLOC_USAGE_HW_VIDEO_ENCODER = 0x00010000, /* buffer will be written by the HW camera pipeline */ GRALLOC_USAGE_HW_CAMERA_WRITE = 0x00020000, /* buffer will be read by the HW camera pipeline */ GRALLOC_USAGE_HW_CAMERA_READ = 0x00040000, /* buffer will be used as part of zero-shutter-lag queue */ GRALLOC_USAGE_HW_CAMERA_ZSL = 0x00060000, /* mask for the camera access values */ GRALLOC_USAGE_HW_CAMERA_MASK = 0x00060000, /* mask for the software usage bit-mask */ GRALLOC_USAGE_HW_MASK = 0x00071F00, /* buffer will be used as a RenderScript Allocation */ GRALLOC_USAGE_RENDERSCRIPT = 0x00100000, /* buffer should be displayed full-screen on an external display when * possible */ GRALLOC_USAGE_EXTERNAL_DISP = 0x00002000, /* Must have a hardware-protected path to external display sink for * this buffer. If a hardware-protected path is not available, then * either don't composite only this buffer (preferred) to the * external sink, or (less desirable) do not route the entire * composition to the external sink. */ GRALLOC_USAGE_PROTECTED = 0x00004000, /* buffer may be used as a cursor */ GRALLOC_USAGE_CURSOR = 0x00008000, /* 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, }; /*****************************************************************************/ /** * 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 gralloc_module_t { struct hw_module_t common; /* * (*registerBuffer)() must be called before a buffer_handle_t that has not * been created with (*alloc_device_t::alloc)() can be used. * * This is intended to be used with buffer_handle_t's that have been * received in this process through IPC. * * This function checks that the handle is indeed a valid one and prepares * it for use with (*lock)() and (*unlock)(). * * It is not necessary to call (*registerBuffer)() on a handle created * with (*alloc_device_t::alloc)(). * * returns an error if this buffer_handle_t is not valid. */ int (*registerBuffer)(struct gralloc_module_t const* module, buffer_handle_t handle); /* * (*unregisterBuffer)() is called once this handle is no longer needed in * this process. After this call, it is an error to call (*lock)(), * (*unlock)(), or (*registerBuffer)(). * * This function doesn't close or free the handle itself; this is done * by other means, usually through libcutils's native_handle_close() and * native_handle_free(). * * It is an error to call (*unregisterBuffer)() on a buffer that wasn't * explicitly registered first. */ int (*unregisterBuffer)(struct gralloc_module_t const* module, buffer_handle_t handle); /* * The (*lock)() method is called before a buffer is accessed for the * specified usage. This call may block, for instance if the h/w needs * to finish rendering or if CPU caches need to be synchronized. * * The caller promises to modify only pixels in the area specified * by (l,t,w,h). * * The content of the buffer outside of the specified area is NOT modified * by this call. * * If usage specifies GRALLOC_USAGE_SW_*, vaddr is filled with the address * of the buffer in virtual memory. * * Note calling (*lock)() on HAL_PIXEL_FORMAT_YCbCr_*_888 buffers will fail * and return -EINVAL. These buffers must be locked with (*lock_ycbcr)() * instead. * * THREADING CONSIDERATIONS: * * It is legal for several different threads to lock a buffer from * read access, none of the threads are blocked. * * However, locking a buffer simultaneously for write or read/write is * undefined, but: * - shall not result in termination of the process * - shall not block the caller * It is acceptable to return an error or to leave the buffer's content * into an indeterminate state. * * If the buffer was created with a usage mask incompatible with the * requested usage flags here, -EINVAL is returned. * */ int (*lock)(struct gralloc_module_t const* module, buffer_handle_t handle, int usage, int l, int t, int w, int h, void** vaddr); /* * The (*unlock)() method must be called after all changes to the buffer * are completed. */ int (*unlock)(struct gralloc_module_t const* module, buffer_handle_t handle); /* reserved for future use */ int (*perform)(struct gralloc_module_t const* module, int operation, ... ); /* * The (*lock_ycbcr)() method is like the (*lock)() method, with the * difference that it fills a struct ycbcr with a description of the buffer * layout, and zeroes out the reserved fields. * * If the buffer format is not compatible with a flexible YUV format (e.g. * the buffer layout cannot be represented with the ycbcr struct), it * will return -EINVAL. * * This method must work on buffers with HAL_PIXEL_FORMAT_YCbCr_*_888 * if supported by the device, as well as with any other format that is * requested by the multimedia codecs when they are configured with a * flexible-YUV-compatible color-format with android native buffers. * * Note that this method may also be called on buffers of other formats, * including non-YUV formats. * * Added in GRALLOC_MODULE_API_VERSION_0_2. */ int (*lock_ycbcr)(struct gralloc_module_t const* module, buffer_handle_t handle, int usage, int l, int t, int w, int h, struct android_ycbcr *ycbcr); /* * The (*lockAsync)() method is like the (*lock)() method except * that the buffer's sync fence object is passed into the lock * call instead of requiring the caller to wait for completion. * * The gralloc implementation takes ownership of the fenceFd and * is responsible for closing it when no longer needed. * * Added in GRALLOC_MODULE_API_VERSION_0_3. */ int (*lockAsync)(struct gralloc_module_t const* module, buffer_handle_t handle, int usage, int l, int t, int w, int h, void** vaddr, int fenceFd); /* * The (*unlockAsync)() method is like the (*unlock)() method * except that a buffer sync fence object is returned from the * lock call, representing the completion of any pending work * performed by the gralloc implementation. * * The caller takes ownership of the fenceFd and is responsible * for closing it when no longer needed. * * Added in GRALLOC_MODULE_API_VERSION_0_3. */ int (*unlockAsync)(struct gralloc_module_t const* module, buffer_handle_t handle, int* fenceFd); /* * The (*lockAsync_ycbcr)() method is like the (*lock_ycbcr)() * method except that the buffer's sync fence object is passed * into the lock call instead of requiring the caller to wait for * completion. * * The gralloc implementation takes ownership of the fenceFd and * is responsible for closing it when no longer needed. * * Added in GRALLOC_MODULE_API_VERSION_0_3. */ int (*lockAsync_ycbcr)(struct gralloc_module_t const* module, buffer_handle_t handle, int usage, int l, int t, int w, int h, struct android_ycbcr *ycbcr, int fenceFd); /* reserved for future use */ void* reserved_proc[3]; } gralloc_module_t; /*****************************************************************************/ /** * Every device data structure must begin with hw_device_t * followed by module specific public methods and attributes. */ typedef struct alloc_device_t { struct hw_device_t common; /* * (*alloc)() Allocates a buffer in graphic memory with the requested * parameters and returns a buffer_handle_t and the stride in pixels to * allow the implementation to satisfy hardware constraints on the width * of a pixmap (eg: it may have to be multiple of 8 pixels). * The CALLER TAKES OWNERSHIP of the buffer_handle_t. * * If format is HAL_PIXEL_FORMAT_YCbCr_420_888, the returned stride must be * 0, since the actual strides are available from the android_ycbcr * structure. * * Returns 0 on success or -errno on error. */ int (*alloc)(struct alloc_device_t* dev, int w, int h, int format, int usage, buffer_handle_t* handle, int* stride); /* * (*free)() Frees a previously allocated buffer. * Behavior is undefined if the buffer is still mapped in any process, * but shall not result in termination of the program or security breaches * (allowing a process to get access to another process' buffers). * THIS FUNCTION TAKES OWNERSHIP of the buffer_handle_t which becomes * invalid after the call. * * Returns 0 on success or -errno on error. */ int (*free)(struct alloc_device_t* dev, buffer_handle_t handle); /* This hook is OPTIONAL. * * If non NULL it will be caused by SurfaceFlinger on dumpsys */ void (*dump)(struct alloc_device_t *dev, char *buff, int buff_len); void* reserved_proc[7]; } alloc_device_t; /** convenience API for opening and closing a supported device */ 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); } static inline int gralloc_close(struct alloc_device_t* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_GRALLOC_INTERFACE_H android-headers-23/22/hardware/hardware.h000066400000000000000000000173341264465411000203320ustar00rootroot00000000000000/* * 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_HARDWARE_H #define ANDROID_INCLUDE_HARDWARE_HARDWARE_H #include #include #include #include __BEGIN_DECLS /* * Value for the hw_module_t.tag field */ #define MAKE_TAG_CONSTANT(A,B,C,D) (((A) << 24) | ((B) << 16) | ((C) << 8) | (D)) #define HARDWARE_MODULE_TAG MAKE_TAG_CONSTANT('H', 'W', 'M', 'T') #define HARDWARE_DEVICE_TAG MAKE_TAG_CONSTANT('H', 'W', 'D', 'T') #define HARDWARE_MAKE_API_VERSION(maj,min) \ ((((maj) & 0xff) << 8) | ((min) & 0xff)) #define HARDWARE_MAKE_API_VERSION_2(maj,min,hdr) \ ((((maj) & 0xff) << 24) | (((min) & 0xff) << 16) | ((hdr) & 0xffff)) #define HARDWARE_API_VERSION_2_MAJ_MIN_MASK 0xffff0000 #define HARDWARE_API_VERSION_2_HEADER_MASK 0x0000ffff /* * The current HAL API version. * * All module implementations must set the hw_module_t.hal_api_version field * to this value when declaring the module with HAL_MODULE_INFO_SYM. * * Note that previous implementations have always set this field to 0. * Therefore, libhardware HAL API will always consider versions 0.0 and 1.0 * to be 100% binary compatible. * */ #define HARDWARE_HAL_API_VERSION HARDWARE_MAKE_API_VERSION(1, 0) /* * Helper macros for module implementors. * * The derived modules should provide convenience macros for supported * versions so that implementations can explicitly specify module/device * versions at definition time. * * Use this macro to set the hw_module_t.module_api_version field. */ #define HARDWARE_MODULE_API_VERSION(maj,min) HARDWARE_MAKE_API_VERSION(maj,min) #define HARDWARE_MODULE_API_VERSION_2(maj,min,hdr) HARDWARE_MAKE_API_VERSION_2(maj,min,hdr) /* * Use this macro to set the hw_device_t.version field */ #define HARDWARE_DEVICE_API_VERSION(maj,min) HARDWARE_MAKE_API_VERSION(maj,min) #define HARDWARE_DEVICE_API_VERSION_2(maj,min,hdr) HARDWARE_MAKE_API_VERSION_2(maj,min,hdr) struct hw_module_t; struct hw_module_methods_t; struct hw_device_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 hw_module_t { /** tag must be initialized to HARDWARE_MODULE_TAG */ uint32_t tag; /** * The API version of the implemented module. The module owner is * responsible for updating the version when a module interface has * changed. * * The derived modules such as gralloc and audio own and manage this field. * The module user must interpret the version field to decide whether or * not to inter-operate with the supplied module implementation. * For example, SurfaceFlinger is responsible for making sure that * it knows how to manage different versions of the gralloc-module API, * and AudioFlinger must know how to do the same for audio-module API. * * The module API version should include a major and a minor component. * For example, version 1.0 could be represented as 0x0100. This format * implies that versions 0x0100-0x01ff are all API-compatible. * * In the future, libhardware will expose a hw_get_module_version() * (or equivalent) function that will take minimum/maximum supported * versions as arguments and would be able to reject modules with * versions outside of the supplied range. */ uint16_t module_api_version; #define version_major module_api_version /** * version_major/version_minor defines are supplied here for temporary * source code compatibility. They will be removed in the next version. * ALL clients must convert to the new version format. */ /** * The API version of the HAL module interface. This is meant to * version the hw_module_t, hw_module_methods_t, and hw_device_t * structures and definitions. * * The HAL interface owns this field. Module users/implementations * must NOT rely on this value for version information. * * Presently, 0 is the only valid value. */ uint16_t hal_api_version; #define version_minor hal_api_version /** Identifier of module */ const char *id; /** Name of this module */ const char *name; /** Author/owner/implementor of the module */ const char *author; /** Modules methods */ struct hw_module_methods_t* methods; /** module's dso */ void* dso; #ifdef __LP64__ uint64_t reserved[32-7]; #else /** padding to 128 bytes, reserved for future use */ uint32_t reserved[32-7]; #endif } hw_module_t; typedef struct hw_module_methods_t { /** Open a specific device */ int (*open)(const struct hw_module_t* module, const char* id, struct hw_device_t** device); } hw_module_methods_t; /** * Every device data structure must begin with hw_device_t * followed by module specific public methods and attributes. */ typedef struct hw_device_t { /** tag must be initialized to HARDWARE_DEVICE_TAG */ uint32_t tag; /** * Version of the module-specific device API. This value is used by * the derived-module user to manage different device implementations. * * The module user is responsible for checking the module_api_version * and device version fields to ensure that the user is capable of * communicating with the specific module implementation. * * One module can support multiple devices with different versions. This * can be useful when a device interface changes in an incompatible way * but it is still necessary to support older implementations at the same * time. One such example is the Camera 2.0 API. * * This field is interpreted by the module user and is ignored by the * HAL interface itself. */ uint32_t version; /** reference to the module this device belongs to */ struct hw_module_t* module; /** padding reserved for future use */ #ifdef __LP64__ uint64_t reserved[12]; #else uint32_t reserved[12]; #endif /** Close this device */ int (*close)(struct hw_device_t* device); } hw_device_t; /** * Name of the hal_module_info */ #define HAL_MODULE_INFO_SYM HMI /** * Name of the hal_module_info as a string */ #define HAL_MODULE_INFO_SYM_AS_STR "HMI" /** * Get the module info associated with a module by id. * * @return: 0 == success, <0 == error and *module == NULL */ int hw_get_module(const char *id, const struct hw_module_t **module); /** * Get the module info associated with a module instance by class 'class_id' * and instance 'inst'. * * Some modules types necessitate multiple instances. For example audio supports * multiple concurrent interfaces and thus 'audio' is the module class * and 'primary' or 'a2dp' are module interfaces. This implies that the files * providing these modules would be named audio.primary..so and * audio.a2dp..so * * @return: 0 == success, <0 == error and *module == NULL */ int hw_get_module_by_class(const char *class_id, const char *inst, const struct hw_module_t **module); __END_DECLS #endif /* ANDROID_INCLUDE_HARDWARE_HARDWARE_H */ android-headers-23/22/hardware/hdmi_cec.h000066400000000000000000000343121264465411000202630ustar00rootroot00000000000000/* * 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_HARDWARE_HDMI_CEC_H #define ANDROID_INCLUDE_HARDWARE_HDMI_CEC_H #include #include #include __BEGIN_DECLS #define HDMI_CEC_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) #define HDMI_CEC_MODULE_API_VERSION_CURRENT HDMI_MODULE_API_VERSION_1_0 #define HDMI_CEC_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) #define HDMI_CEC_DEVICE_API_VERSION_CURRENT HDMI_DEVICE_API_VERSION_1_0 #define HDMI_CEC_HARDWARE_MODULE_ID "hdmi_cec" #define HDMI_CEC_HARDWARE_INTERFACE "hdmi_cec_hw_if" typedef enum cec_device_type { CEC_DEVICE_INACTIVE = -1, CEC_DEVICE_TV = 0, CEC_DEVICE_RECORDER = 1, CEC_DEVICE_RESERVED = 2, CEC_DEVICE_TUNER = 3, CEC_DEVICE_PLAYBACK = 4, CEC_DEVICE_AUDIO_SYSTEM = 5, CEC_DEVICE_MAX = CEC_DEVICE_AUDIO_SYSTEM } cec_device_type_t; typedef enum cec_logical_address { CEC_ADDR_TV = 0, CEC_ADDR_RECORDER_1 = 1, CEC_ADDR_RECORDER_2 = 2, CEC_ADDR_TUNER_1 = 3, CEC_ADDR_PLAYBACK_1 = 4, CEC_ADDR_AUDIO_SYSTEM = 5, CEC_ADDR_TUNER_2 = 6, CEC_ADDR_TUNER_3 = 7, CEC_ADDR_PLAYBACK_2 = 8, CEC_ADDR_RECORDER_3 = 9, CEC_ADDR_TUNER_4 = 10, CEC_ADDR_PLAYBACK_3 = 11, CEC_ADDR_RESERVED_1 = 12, CEC_ADDR_RESERVED_2 = 13, CEC_ADDR_FREE_USE = 14, CEC_ADDR_UNREGISTERED = 15, CEC_ADDR_BROADCAST = 15 } cec_logical_address_t; /* * HDMI CEC messages */ enum cec_message_type { CEC_MESSAGE_FEATURE_ABORT = 0x00, CEC_MESSAGE_IMAGE_VIEW_ON = 0x04, CEC_MESSAGE_TUNER_STEP_INCREMENT = 0x05, CEC_MESSAGE_TUNER_STEP_DECREMENT = 0x06, CEC_MESSAGE_TUNER_DEVICE_STATUS = 0x07, CEC_MESSAGE_GIVE_TUNER_DEVICE_STATUS = 0x08, CEC_MESSAGE_RECORD_ON = 0x09, CEC_MESSAGE_RECORD_STATUS = 0x0A, CEC_MESSAGE_RECORD_OFF = 0x0B, CEC_MESSAGE_TEXT_VIEW_ON = 0x0D, CEC_MESSAGE_RECORD_TV_SCREEN = 0x0F, CEC_MESSAGE_GIVE_DECK_STATUS = 0x1A, CEC_MESSAGE_DECK_STATUS = 0x1B, CEC_MESSAGE_SET_MENU_LANGUAGE = 0x32, CEC_MESSAGE_CLEAR_ANALOG_TIMER = 0x33, CEC_MESSAGE_SET_ANALOG_TIMER = 0x34, CEC_MESSAGE_TIMER_STATUS = 0x35, CEC_MESSAGE_STANDBY = 0x36, CEC_MESSAGE_PLAY = 0x41, CEC_MESSAGE_DECK_CONTROL = 0x42, CEC_MESSAGE_TIMER_CLEARED_STATUS = 0x043, CEC_MESSAGE_USER_CONTROL_PRESSED = 0x44, CEC_MESSAGE_USER_CONTROL_RELEASED = 0x45, CEC_MESSAGE_GIVE_OSD_NAME = 0x46, CEC_MESSAGE_SET_OSD_NAME = 0x47, CEC_MESSAGE_SET_OSD_STRING = 0x64, CEC_MESSAGE_SET_TIMER_PROGRAM_TITLE = 0x67, CEC_MESSAGE_SYSTEM_AUDIO_MODE_REQUEST = 0x70, CEC_MESSAGE_GIVE_AUDIO_STATUS = 0x71, CEC_MESSAGE_SET_SYSTEM_AUDIO_MODE = 0x72, CEC_MESSAGE_REPORT_AUDIO_STATUS = 0x7A, CEC_MESSAGE_GIVE_SYSTEM_AUDIO_MODE_STATUS = 0x7D, CEC_MESSAGE_SYSTEM_AUDIO_MODE_STATUS = 0x7E, CEC_MESSAGE_ROUTING_CHANGE = 0x80, CEC_MESSAGE_ROUTING_INFORMATION = 0x81, CEC_MESSAGE_ACTIVE_SOURCE = 0x82, CEC_MESSAGE_GIVE_PHYSICAL_ADDRESS = 0x83, CEC_MESSAGE_REPORT_PHYSICAL_ADDRESS = 0x84, CEC_MESSAGE_REQUEST_ACTIVE_SOURCE = 0x85, CEC_MESSAGE_SET_STREAM_PATH = 0x86, CEC_MESSAGE_DEVICE_VENDOR_ID = 0x87, CEC_MESSAGE_VENDOR_COMMAND = 0x89, CEC_MESSAGE_VENDOR_REMOTE_BUTTON_DOWN = 0x8A, CEC_MESSAGE_VENDOR_REMOTE_BUTTON_UP = 0x8B, CEC_MESSAGE_GIVE_DEVICE_VENDOR_ID = 0x8C, CEC_MESSAGE_MENU_REQUEST = 0x8D, CEC_MESSAGE_MENU_STATUS = 0x8E, CEC_MESSAGE_GIVE_DEVICE_POWER_STATUS = 0x8F, CEC_MESSAGE_REPORT_POWER_STATUS = 0x90, CEC_MESSAGE_GET_MENU_LANGUAGE = 0x91, CEC_MESSAGE_SELECT_ANALOG_SERVICE = 0x92, CEC_MESSAGE_SELECT_DIGITAL_SERVICE = 0x93, CEC_MESSAGE_SET_DIGITAL_TIMER = 0x97, CEC_MESSAGE_CLEAR_DIGITAL_TIMER = 0x99, CEC_MESSAGE_SET_AUDIO_RATE = 0x9A, CEC_MESSAGE_INACTIVE_SOURCE = 0x9D, CEC_MESSAGE_CEC_VERSION = 0x9E, CEC_MESSAGE_GET_CEC_VERSION = 0x9F, CEC_MESSAGE_VENDOR_COMMAND_WITH_ID = 0xA0, CEC_MESSAGE_CLEAR_EXTERNAL_TIMER = 0xA1, CEC_MESSAGE_SET_EXTERNAL_TIMER = 0xA2, CEC_MESSAGE_INITIATE_ARC = 0xC0, CEC_MESSAGE_REPORT_ARC_INITIATED = 0xC1, CEC_MESSAGE_REPORT_ARC_TERMINATED = 0xC2, CEC_MESSAGE_REQUEST_ARC_INITIATION = 0xC3, CEC_MESSAGE_REQUEST_ARC_TERMINATION = 0xC4, CEC_MESSAGE_TERMINATE_ARC = 0xC5, CEC_MESSAGE_ABORT = 0xFF }; /* * Operand description [Abort Reason] */ enum abort_reason { ABORT_UNRECOGNIZED_MODE = 0, ABORT_NOT_IN_CORRECT_MODE = 1, ABORT_CANNOT_PROVIDE_SOURCE = 2, ABORT_INVALID_OPERAND = 3, ABORT_REFUSED = 4, ABORT_UNABLE_TO_DETERMINE = 5 }; /* * HDMI event type. used for hdmi_event_t. */ enum { HDMI_EVENT_CEC_MESSAGE = 1, HDMI_EVENT_HOT_PLUG = 2, }; /* * HDMI hotplug event type. Used when the event * type is HDMI_EVENT_HOT_PLUG. */ enum { HDMI_NOT_CONNECTED = 0, HDMI_CONNECTED = 1 }; /* * error code used for send_message. */ enum { HDMI_RESULT_SUCCESS = 0, HDMI_RESULT_NACK = 1, /* not acknowledged */ HDMI_RESULT_BUSY = 2, /* bus is busy */ HDMI_RESULT_FAIL = 3, }; /* * HDMI port type. */ typedef enum hdmi_port_type { HDMI_INPUT = 0, HDMI_OUTPUT = 1 } hdmi_port_type_t; /* * Flags used for set_option() */ enum { /* When set to false, HAL does not wake up the system upon receiving * or . Used when user changes the TV * settings to disable the auto TV on functionality. * True by default. */ HDMI_OPTION_WAKEUP = 1, /* When set to false, all the CEC commands are discarded. Used when * user changes the TV settings to disable CEC functionality. * True by default. */ HDMI_OPTION_ENABLE_CEC = 2, /* Setting this flag to false means Android system will stop handling * CEC service and yield the control over to the microprocessor that is * powered on through the standby mode. When set to true, the system * will gain the control over, hence telling the microprocessor to stop * handling the cec commands. This is called when system goes * in and out of standby mode to notify the microprocessor that it should * start/stop handling CEC commands on behalf of the system. * False by default. */ HDMI_OPTION_SYSTEM_CEC_CONTROL = 3, /* Option 4 not used */ /* Passes the updated language information of Android system. * Contains 3-byte ASCII code as defined in ISO/FDIS 639-2. Can be * used for HAL to respond to while in standby mode. * English(eng), for example, is converted to 0x656e67. */ HDMI_OPTION_SET_LANG = 5, }; /* * Maximum length in bytes of cec message body (exclude header block), * should not exceed 16 (spec CEC 6 Frame Description) */ #define CEC_MESSAGE_BODY_MAX_LENGTH 16 typedef struct cec_message { /* logical address of sender */ cec_logical_address_t initiator; /* logical address of receiver */ cec_logical_address_t destination; /* Length in bytes of body, range [0, CEC_MESSAGE_BODY_MAX_LENGTH] */ size_t length; unsigned char body[CEC_MESSAGE_BODY_MAX_LENGTH]; } cec_message_t; typedef struct hotplug_event { /* * true if the cable is connected; otherwise false. */ int connected; int port_id; } hotplug_event_t; typedef struct tx_status_event { int status; int opcode; /* CEC opcode */ } tx_status_event_t; /* * HDMI event generated from HAL. */ typedef struct hdmi_event { int type; struct hdmi_cec_device* dev; union { cec_message_t cec; hotplug_event_t hotplug; }; } hdmi_event_t; /* * HDMI port descriptor */ typedef struct hdmi_port_info { hdmi_port_type_t type; // Port ID should start from 1 which corresponds to HDMI "port 1". int port_id; int cec_supported; int arc_supported; uint16_t physical_address; } hdmi_port_info_t; /* * Callback function type that will be called by HAL implementation. * Services can not close/open the device in the callback. */ typedef void (*event_callback_t)(const hdmi_event_t* event, void* arg); typedef struct hdmi_cec_module { /** * Common methods of the HDMI CEC module. This *must* be the first member of * hdmi_cec_module as users of this structure will cast a hw_module_t to hdmi_cec_module * pointer in contexts where it's known the hw_module_t references a hdmi_cec_module. */ struct hw_module_t common; } hdmi_module_t; /* * HDMI-CEC HAL interface definition. */ typedef struct hdmi_cec_device { /** * Common methods of the HDMI CEC device. This *must* be the first member of * hdmi_cec_device as users of this structure will cast a hw_device_t to hdmi_cec_device * pointer in contexts where it's known the hw_device_t references a hdmi_cec_device. */ struct hw_device_t common; /* * (*add_logical_address)() passes the logical address that will be used * in this system. * * HAL may use it to configure the hardware so that the CEC commands addressed * the given logical address can be filtered in. This method can be called * as many times as necessary in order to support multiple logical devices. * addr should be in the range of valid logical addresses for the call * to succeed. * * Returns 0 on success or -errno on error. */ int (*add_logical_address)(const struct hdmi_cec_device* dev, cec_logical_address_t addr); /* * (*clear_logical_address)() tells HAL to reset all the logical addresses. * * It is used when the system doesn't need to process CEC command any more, * hence to tell HAL to stop receiving commands from the CEC bus, and change * the state back to the beginning. */ void (*clear_logical_address)(const struct hdmi_cec_device* dev); /* * (*get_physical_address)() returns the CEC physical address. The * address is written to addr. * * The physical address depends on the topology of the network formed * by connected HDMI devices. It is therefore likely to change if the cable * is plugged off and on again. It is advised to call get_physical_address * to get the updated address when hot plug event takes place. * * Returns 0 on success or -errno on error. */ int (*get_physical_address)(const struct hdmi_cec_device* dev, uint16_t* addr); /* * (*send_message)() transmits HDMI-CEC message to other HDMI device. * * The method should be designed to return in a certain amount of time not * hanging forever, which can happen if CEC signal line is pulled low for * some reason. HAL implementation should take the situation into account * so as not to wait forever for the message to get sent out. * * It should try retransmission at least once as specified in the standard. * * Returns error code. See HDMI_RESULT_SUCCESS, HDMI_RESULT_NACK, and * HDMI_RESULT_BUSY. */ int (*send_message)(const struct hdmi_cec_device* dev, const cec_message_t*); /* * (*register_event_callback)() registers a callback that HDMI-CEC HAL * can later use for incoming CEC messages or internal HDMI events. * When calling from C++, use the argument arg to pass the calling object. * It will be passed back when the callback is invoked so that the context * can be retrieved. */ void (*register_event_callback)(const struct hdmi_cec_device* dev, event_callback_t callback, void* arg); /* * (*get_version)() returns the CEC version supported by underlying hardware. */ void (*get_version)(const struct hdmi_cec_device* dev, int* version); /* * (*get_vendor_id)() returns the identifier of the vendor. It is * the 24-bit unique company ID obtained from the IEEE Registration * Authority Committee (RAC). */ void (*get_vendor_id)(const struct hdmi_cec_device* dev, uint32_t* vendor_id); /* * (*get_port_info)() returns the hdmi port information of underlying hardware. * info is the list of HDMI port information, and 'total' is the number of * HDMI ports in the system. */ void (*get_port_info)(const struct hdmi_cec_device* dev, struct hdmi_port_info* list[], int* total); /* * (*set_option)() passes flags controlling the way HDMI-CEC service works down * to HAL implementation. Those flags will be used in case the feature needs * update in HAL itself, firmware or microcontroller. */ void (*set_option)(const struct hdmi_cec_device* dev, int flag, int value); /* * (*set_audio_return_channel)() configures ARC circuit in the hardware logic * to start or stop the feature. Flag can be either 1 to start the feature * or 0 to stop it. * * Returns 0 on success or -errno on error. */ void (*set_audio_return_channel)(const struct hdmi_cec_device* dev, int port_id, int flag); /* * (*is_connected)() returns the connection status of the specified port. * Returns HDMI_CONNECTED if a device is connected, otherwise HDMI_NOT_CONNECTED. * The HAL should watch for +5V power signal to determine the status. */ int (*is_connected)(const struct hdmi_cec_device* dev, int port_id); /* Reserved for future use to maximum 16 functions. Must be NULL. */ void* reserved[16 - 11]; } hdmi_cec_device_t; /** convenience API for opening and closing a 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); } static inline int hdmi_cec_close(struct hdmi_cec_device* device) { return device->common.close(&device->common); } __END_DECLS #endif /* ANDROID_INCLUDE_HARDWARE_HDMI_CEC_H */ android-headers-23/22/hardware/hwcomposer.h000066400000000000000000001031761264465411000207230ustar00rootroot00000000000000/* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H #define ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H #include #include #include #include #include #include __BEGIN_DECLS /*****************************************************************************/ /* for compatibility */ #define HWC_MODULE_API_VERSION HWC_MODULE_API_VERSION_0_1 #define HWC_DEVICE_API_VERSION HWC_DEVICE_API_VERSION_0_1 #define HWC_API_VERSION HWC_DEVICE_API_VERSION /*****************************************************************************/ /** * The id of this module */ #define HWC_HARDWARE_MODULE_ID "hwcomposer" /** * Name of the sensors device to open */ #define HWC_HARDWARE_COMPOSER "composer" typedef struct hwc_rect { int left; int top; int right; int bottom; } hwc_rect_t; typedef struct hwc_frect { float left; float top; float right; float bottom; } hwc_frect_t; typedef struct hwc_region { size_t numRects; hwc_rect_t const* rects; } hwc_region_t; typedef struct hwc_color { uint8_t r; uint8_t g; uint8_t b; uint8_t a; } hwc_color_t; typedef struct hwc_layer_1 { /* * compositionType is used to specify this layer's type and is set by either * the hardware composer implementation, or by the caller (see below). * * This field is always reset to HWC_BACKGROUND or HWC_FRAMEBUFFER * before (*prepare)() is called when the HWC_GEOMETRY_CHANGED flag is * also set, otherwise, this field is preserved between (*prepare)() * calls. * * HWC_BACKGROUND * Always set by the caller before calling (*prepare)(), this value * indicates this is a special "background" layer. The only valid field * is backgroundColor. * The HWC can toggle this value to HWC_FRAMEBUFFER to indicate it CANNOT * handle the background color. * * * HWC_FRAMEBUFFER_TARGET * Always set by the caller before calling (*prepare)(), this value * indicates this layer is the framebuffer surface used as the target of * OpenGL ES composition. If the HWC sets all other layers to HWC_OVERLAY * or HWC_BACKGROUND, then no OpenGL ES composition will be done, and * this layer should be ignored during set(). * * This flag (and the framebuffer surface layer) will only be used if the * HWC version is HWC_DEVICE_API_VERSION_1_1 or higher. In older versions, * the OpenGL ES target surface is communicated by the (dpy, sur) fields * in hwc_compositor_device_1_t. * * This value cannot be set by the HWC implementation. * * * HWC_FRAMEBUFFER * Set by the caller before calling (*prepare)() ONLY when the * HWC_GEOMETRY_CHANGED flag is also set. * * Set by the HWC implementation during (*prepare)(), this indicates * that the layer will be drawn into the framebuffer using OpenGL ES. * The HWC can toggle this value to HWC_OVERLAY to indicate it will * handle the layer. * * * HWC_OVERLAY * Set by the HWC implementation during (*prepare)(), this indicates * that the layer will be handled by the HWC (ie: it must not be * composited with OpenGL ES). * * * HWC_SIDEBAND * Set by the caller before calling (*prepare)(), this value indicates * the contents of this layer come from a sideband video stream. * * The h/w composer is responsible for receiving new image buffers from * the stream at the appropriate time (e.g. synchronized to a separate * audio stream), compositing them with the current contents of other * layers, and displaying the resulting image. This happens * independently of the normal prepare/set cycle. The prepare/set calls * only happen when other layers change, or when properties of the * sideband layer such as position or size change. * * If the h/w composer can't handle the layer as a sideband stream for * some reason (e.g. unsupported scaling/blending/rotation, or too many * sideband layers) it can set compositionType to HWC_FRAMEBUFFER in * (*prepare)(). However, doing so will result in the layer being shown * as a solid color since the platform is not currently able to composite * sideband layers with the GPU. This may be improved in future * versions of the platform. * * * HWC_CURSOR_OVERLAY * Set by the HWC implementation during (*prepare)(), this value * indicates the layer's composition will now be handled by the HWC. * Additionally, the client can now asynchronously update the on-screen * position of this layer using the setCursorPositionAsync() api. */ int32_t compositionType; /* * hints is bit mask set by the HWC implementation during (*prepare)(). * It is preserved between (*prepare)() calls, unless the * HWC_GEOMETRY_CHANGED flag is set, in which case it is reset to 0. * * see hwc_layer_t::hints */ uint32_t hints; /* see hwc_layer_t::flags */ uint32_t flags; union { /* color of the background. hwc_color_t.a is ignored */ hwc_color_t backgroundColor; struct { union { /* When compositionType is HWC_FRAMEBUFFER, HWC_OVERLAY, * HWC_FRAMEBUFFER_TARGET, this is the handle of the buffer to * compose. This handle is guaranteed to have been allocated * from gralloc using the GRALLOC_USAGE_HW_COMPOSER usage flag. * If the layer's handle is unchanged across two consecutive * prepare calls and the HWC_GEOMETRY_CHANGED flag is not set * for the second call then the HWComposer implementation may * assume that the contents of the buffer have not changed. */ buffer_handle_t handle; /* When compositionType is HWC_SIDEBAND, this is the handle * of the sideband video stream to compose. */ const native_handle_t* sidebandStream; }; /* transformation to apply to the buffer during composition */ uint32_t transform; /* blending to apply during composition */ int32_t blending; /* area of the source to consider, the origin is the top-left corner of * the buffer. As of HWC_DEVICE_API_VERSION_1_3, sourceRect uses floats. * If the h/w can't support a non-integer source crop rectangle, it should * punt to OpenGL ES composition. */ union { // crop rectangle in integer (pre HWC_DEVICE_API_VERSION_1_3) hwc_rect_t sourceCropi; hwc_rect_t sourceCrop; // just for source compatibility // crop rectangle in floats (as of HWC_DEVICE_API_VERSION_1_3) hwc_frect_t sourceCropf; }; /* where to composite the sourceCrop onto the display. The sourceCrop * is scaled using linear filtering to the displayFrame. The origin is the * top-left corner of the screen. */ hwc_rect_t displayFrame; /* visible region in screen space. The origin is the * top-left corner of the screen. * The visible region INCLUDES areas overlapped by a translucent layer. */ hwc_region_t visibleRegionScreen; /* Sync fence object that will be signaled when the buffer's * contents are available. May be -1 if the contents are already * available. This field is only valid during set(), and should be * ignored during prepare(). The set() call must not wait for the * fence to be signaled before returning, but the HWC must wait for * all buffers to be signaled before reading from them. * * HWC_FRAMEBUFFER layers will never have an acquire fence, since * reads from them are complete before the framebuffer is ready for * display. * * HWC_SIDEBAND layers will never have an acquire fence, since * synchronization is handled through implementation-defined * sideband mechanisms. * * The HWC takes ownership of the acquireFenceFd and is responsible * for closing it when no longer needed. */ int acquireFenceFd; /* During set() the HWC must set this field to a file descriptor for * a sync fence object that will signal after the HWC has finished * reading from the buffer. The field is ignored by prepare(). Each * layer should have a unique file descriptor, even if more than one * refer to the same underlying fence object; this allows each to be * closed independently. * * If buffer reads can complete at significantly different times, * then using independent fences is preferred. For example, if the * HWC handles some layers with a blit engine and others with * overlays, then the blit layers can be reused immediately after * the blit completes, but the overlay layers can't be reused until * a subsequent frame has been displayed. * * Since HWC doesn't read from HWC_FRAMEBUFFER layers, it shouldn't * produce a release fence for them. The releaseFenceFd will be -1 * for these layers when set() is called. * * Since HWC_SIDEBAND buffers don't pass through the HWC client, * the HWC shouldn't produce a release fence for them. The * releaseFenceFd will be -1 for these layers when set() is called. * * The HWC client taks ownership of the releaseFenceFd and is * responsible for closing it when no longer needed. */ int releaseFenceFd; /* * Availability: HWC_DEVICE_API_VERSION_1_2 * * Alpha value applied to the whole layer. The effective * value of each pixel is computed as: * * if (blending == HWC_BLENDING_PREMULT) * pixel.rgb = pixel.rgb * planeAlpha / 255 * pixel.a = pixel.a * planeAlpha / 255 * * Then blending proceeds as usual according to the "blending" * field above. * * NOTE: planeAlpha applies to YUV layers as well: * * pixel.rgb = yuv_to_rgb(pixel.yuv) * if (blending == HWC_BLENDING_PREMULT) * pixel.rgb = pixel.rgb * planeAlpha / 255 * pixel.a = planeAlpha * * * IMPLEMENTATION NOTE: * * If the source image doesn't have an alpha channel, then * the h/w can use the HWC_BLENDING_COVERAGE equations instead of * HWC_BLENDING_PREMULT and simply set the alpha channel to * planeAlpha. * * e.g.: * * if (blending == HWC_BLENDING_PREMULT) * blending = HWC_BLENDING_COVERAGE; * pixel.a = planeAlpha; * */ uint8_t planeAlpha; /* reserved for future use */ uint8_t _pad[3]; }; }; #ifdef __LP64__ /* * For 64-bit mode, this struct is 120 bytes (and 8-byte aligned), and needs * to be padded as such to maintain binary compatibility. */ uint8_t reserved[120 - 96]; #else /* * For 32-bit mode, this struct is 96 bytes, and needs to be padded as such * to maintain binary compatibility. */ uint8_t reserved[96 - 76]; #endif } hwc_layer_1_t; /* This represents a display, typically an EGLDisplay object */ typedef void* hwc_display_t; /* This represents a surface, typically an EGLSurface object */ typedef void* hwc_surface_t; /* * hwc_display_contents_1_t::flags values */ enum { /* * HWC_GEOMETRY_CHANGED is set by SurfaceFlinger to indicate that the list * passed to (*prepare)() has changed by more than just the buffer handles * and acquire fences. */ HWC_GEOMETRY_CHANGED = 0x00000001, }; /* * Description of the contents to output on a display. * * This is the top-level structure passed to the prepare and set calls to * negotiate and commit the composition of a display image. */ typedef struct hwc_display_contents_1 { /* File descriptor referring to a Sync HAL fence object which will signal * when this composition is retired. For a physical display, a composition * is retired when it has been replaced on-screen by a subsequent set. For * a virtual display, the composition is retired when the writes to * outputBuffer are complete and can be read. The fence object is created * and returned by the set call; this field will be -1 on entry to prepare * and set. SurfaceFlinger will close the returned file descriptor. */ int retireFenceFd; union { /* Fields only relevant for HWC_DEVICE_VERSION_1_0. */ struct { /* (dpy, sur) is the target of SurfaceFlinger's OpenGL ES * composition for HWC_DEVICE_VERSION_1_0. They aren't relevant to * prepare. The set call should commit this surface atomically to * the display along with any overlay layers. */ hwc_display_t dpy; hwc_surface_t sur; }; /* These fields are used for virtual displays when the h/w composer * version is at least HWC_DEVICE_VERSION_1_3. */ struct { /* outbuf is the buffer that receives the composed image for * virtual displays. Writes to the outbuf must wait until * outbufAcquireFenceFd signals. A fence that will signal when * writes to outbuf are complete should be returned in * retireFenceFd. * * This field is set before prepare(), so properties of the buffer * can be used to decide which layers can be handled by h/w * composer. * * If prepare() sets all layers to FRAMEBUFFER, then GLES * composition will happen directly to the output buffer. In this * case, both outbuf and the FRAMEBUFFER_TARGET layer's buffer will * be the same, and set() has no work to do besides managing fences. * * If the TARGET_FORCE_HWC_FOR_VIRTUAL_DISPLAYS board config * variable is defined (not the default), then this behavior is * changed: if all layers are marked for FRAMEBUFFER, GLES * composition will take place to a scratch framebuffer, and * h/w composer must copy it to the output buffer. This allows the * h/w composer to do format conversion if there are cases where * that is more desirable than doing it in the GLES driver or at the * virtual display consumer. * * If some or all layers are marked OVERLAY, then the framebuffer * and output buffer will be different. As with physical displays, * the framebuffer handle will not change between frames if all * layers are marked for OVERLAY. */ buffer_handle_t outbuf; /* File descriptor for a fence that will signal when outbuf is * ready to be written. The h/w composer is responsible for closing * this when no longer needed. * * Will be -1 whenever outbuf is NULL, or when the outbuf can be * written immediately. */ int outbufAcquireFenceFd; }; }; /* List of layers that will be composed on the display. The buffer handles * in the list will be unique. If numHwLayers is 0, all composition will be * performed by SurfaceFlinger. */ uint32_t flags; size_t numHwLayers; hwc_layer_1_t hwLayers[0]; } hwc_display_contents_1_t; /* see hwc_composer_device::registerProcs() * All of the callbacks are required and non-NULL unless otherwise noted. */ typedef struct hwc_procs { /* * (*invalidate)() triggers a screen refresh, in particular prepare and set * will be called shortly after this call is made. Note that there is * NO GUARANTEE that the screen refresh will happen after invalidate() * returns (in particular, it could happen before). * invalidate() is GUARANTEED TO NOT CALL BACK into the h/w composer HAL and * it is safe to call invalidate() from any of hwc_composer_device * hooks, unless noted otherwise. */ void (*invalidate)(const struct hwc_procs* procs); /* * (*vsync)() is called by the h/w composer HAL when a vsync event is * received and HWC_EVENT_VSYNC is enabled on a display * (see: hwc_event_control). * * the "disp" parameter indicates which display the vsync event is for. * the "timestamp" parameter is the system monotonic clock timestamp in * nanosecond of when the vsync event happened. * * vsync() is GUARANTEED TO NOT CALL BACK into the h/w composer HAL. * * It is expected that vsync() is called from a thread of at least * HAL_PRIORITY_URGENT_DISPLAY with as little latency as possible, * typically less than 0.5 ms. * * It is a (silent) error to have HWC_EVENT_VSYNC enabled when calling * hwc_composer_device.set(..., 0, 0, 0) (screen off). The implementation * can either stop or continue to process VSYNC events, but must not * crash or cause other problems. */ void (*vsync)(const struct hwc_procs* procs, int disp, int64_t timestamp); /* * (*hotplug)() is called by the h/w composer HAL when a display is * connected or disconnected. The PRIMARY display is always connected and * the hotplug callback should not be called for it. * * The disp parameter indicates which display type this event is for. * The connected parameter indicates whether the display has just been * connected (1) or disconnected (0). * * The hotplug() callback may call back into the h/w composer on the same * thread to query refresh rate and dpi for the display. Additionally, * other threads may be calling into the h/w composer while the callback * is in progress. * * The h/w composer must serialize calls to the hotplug callback; only * one thread may call it at a time. * * This callback will be NULL if the h/w composer is using * HWC_DEVICE_API_VERSION_1_0. */ void (*hotplug)(const struct hwc_procs* procs, int disp, int connected); } hwc_procs_t; /*****************************************************************************/ typedef struct hwc_module { /** * Common methods of the hardware composer module. This *must* be the first member of * hwc_module as users of this structure will cast a hw_module_t to * hwc_module pointer in contexts where it's known the hw_module_t references a * hwc_module. */ struct hw_module_t common; } hwc_module_t; typedef struct hwc_composer_device_1 { /** * Common methods of the hardware composer device. This *must* be the first member of * hwc_composer_device_1 as users of this structure will cast a hw_device_t to * hwc_composer_device_1 pointer in contexts where it's known the hw_device_t references a * hwc_composer_device_1. */ struct hw_device_t common; /* * (*prepare)() is called for each frame before composition and is used by * SurfaceFlinger to determine what composition steps the HWC can handle. * * (*prepare)() can be called more than once, the last call prevails. * * The HWC responds by setting the compositionType field in each layer to * either HWC_FRAMEBUFFER, HWC_OVERLAY, or HWC_CURSOR_OVERLAY. For the * HWC_FRAMEBUFFER type, composition for the layer is handled by * SurfaceFlinger with OpenGL ES. For the latter two overlay types, * the HWC will have to handle the layer's composition. compositionType * and hints are preserved between (*prepare)() calles unless the * HWC_GEOMETRY_CHANGED flag is set. * * (*prepare)() is called with HWC_GEOMETRY_CHANGED to indicate that the * list's geometry has changed, that is, when more than just the buffer's * handles have been updated. Typically this happens (but is not limited to) * when a window is added, removed, resized or moved. In this case * compositionType and hints are reset to their default value. * * For HWC 1.0, numDisplays will always be one, and displays[0] will be * non-NULL. * * For HWC 1.1, numDisplays will always be HWC_NUM_PHYSICAL_DISPLAY_TYPES. * Entries for unsupported or disabled/disconnected display types will be * NULL. * * In HWC 1.3, numDisplays may be up to HWC_NUM_DISPLAY_TYPES. The extra * entries correspond to enabled virtual displays, and will be non-NULL. * * returns: 0 on success. An negative error code on error. If an error is * returned, SurfaceFlinger will assume that none of the layer will be * handled by the HWC. */ int (*prepare)(struct hwc_composer_device_1 *dev, size_t numDisplays, hwc_display_contents_1_t** displays); /* * (*set)() is used in place of eglSwapBuffers(), and assumes the same * functionality, except it also commits the work list atomically with * the actual eglSwapBuffers(). * * The layer lists are guaranteed to be the same as the ones returned from * the last call to (*prepare)(). * * When this call returns the caller assumes that the displays will be * updated in the near future with the content of their work lists, without * artifacts during the transition from the previous frame. * * A display with zero layers indicates that the entire composition has * been handled by SurfaceFlinger with OpenGL ES. In this case, (*set)() * behaves just like eglSwapBuffers(). * * For HWC 1.0, numDisplays will always be one, and displays[0] will be * non-NULL. * * For HWC 1.1, numDisplays will always be HWC_NUM_PHYSICAL_DISPLAY_TYPES. * Entries for unsupported or disabled/disconnected display types will be * NULL. * * In HWC 1.3, numDisplays may be up to HWC_NUM_DISPLAY_TYPES. The extra * entries correspond to enabled virtual displays, and will be non-NULL. * * IMPORTANT NOTE: There is an implicit layer containing opaque black * pixels behind all the layers in the list. It is the responsibility of * the hwcomposer module to make sure black pixels are output (or blended * from). * * IMPORTANT NOTE: In the event of an error this call *MUST* still cause * any fences returned in the previous call to set to eventually become * signaled. The caller may have already issued wait commands on these * fences, and having set return without causing those fences to signal * will likely result in a deadlock. * * returns: 0 on success. A negative error code on error: * HWC_EGL_ERROR: eglGetError() will provide the proper error code (only * allowed prior to HWComposer 1.1) * Another code for non EGL errors. */ int (*set)(struct hwc_composer_device_1 *dev, size_t numDisplays, hwc_display_contents_1_t** displays); /* * eventControl(..., event, enabled) * Enables or disables h/w composer events for a display. * * eventControl can be called from any thread and takes effect * immediately. * * Supported events are: * HWC_EVENT_VSYNC * * returns -EINVAL if the "event" parameter is not one of the value above * or if the "enabled" parameter is not 0 or 1. */ int (*eventControl)(struct hwc_composer_device_1* dev, int disp, int event, int enabled); union { /* * For HWC 1.3 and earlier, the blank() interface is used. * * blank(..., blank) * Blanks or unblanks a display's screen. * * Turns the screen off when blank is nonzero, on when blank is zero. * Multiple sequential calls with the same blank value must be * supported. * The screen state transition must be be complete when the function * returns. * * returns 0 on success, negative on error. */ int (*blank)(struct hwc_composer_device_1* dev, int disp, int blank); /* * For HWC 1.4 and above, setPowerMode() will be used in place of * blank(). * * setPowerMode(..., mode) * Sets the display screen's power state. * * Refer to the documentation of the HWC_POWER_MODE_* constants * for information about each power mode. * * The functionality is similar to the blank() command in previous * versions of HWC, but with support for more power states. * * The display driver is expected to retain and restore the low power * state of the display while entering and exiting from suspend. * * Multiple sequential calls with the same mode value must be supported. * * The screen state transition must be be complete when the function * returns. * * returns 0 on success, negative on error. */ int (*setPowerMode)(struct hwc_composer_device_1* dev, int disp, int mode); }; /* * Used to retrieve information about the h/w composer * * Returns 0 on success or -errno on error. */ int (*query)(struct hwc_composer_device_1* dev, int what, int* value); /* * (*registerProcs)() registers callbacks that the h/w composer HAL can * later use. It will be called immediately after the composer device is * opened with non-NULL procs. It is FORBIDDEN to call any of the callbacks * from within registerProcs(). registerProcs() must save the hwc_procs_t * pointer which is needed when calling a registered callback. */ void (*registerProcs)(struct hwc_composer_device_1* dev, hwc_procs_t const* procs); /* * This field is OPTIONAL and can be NULL. * * If non NULL it will be called by SurfaceFlinger on dumpsys */ void (*dump)(struct hwc_composer_device_1* dev, char *buff, int buff_len); /* * (*getDisplayConfigs)() returns handles for the configurations available * on the connected display. These handles must remain valid as long as the * display is connected. * * Configuration handles are written to configs. The number of entries * allocated by the caller is passed in *numConfigs; getDisplayConfigs must * not try to write more than this number of config handles. On return, the * total number of configurations available for the display is returned in * *numConfigs. If *numConfigs is zero on entry, then configs may be NULL. * * Hardware composers implementing HWC_DEVICE_API_VERSION_1_3 or prior * shall choose one configuration to activate and report it as the first * entry in the returned list. Reporting the inactive configurations is not * required. * * HWC_DEVICE_API_VERSION_1_4 and later provide configuration management * through SurfaceFlinger, and hardware composers implementing these APIs * must also provide getActiveConfig and setActiveConfig. Hardware composers * implementing these API versions may choose not to activate any * configuration, leaving configuration selection to higher levels of the * framework. * * Returns 0 on success or a negative error code on error. If disp is a * hotpluggable display type and no display is connected, an error shall be * returned. * * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_1 and later. * It shall be NULL for previous versions. */ int (*getDisplayConfigs)(struct hwc_composer_device_1* dev, int disp, uint32_t* configs, size_t* numConfigs); /* * (*getDisplayAttributes)() returns attributes for a specific config of a * connected display. The config parameter is one of the config handles * returned by getDisplayConfigs. * * The list of attributes to return is provided in the attributes * parameter, terminated by HWC_DISPLAY_NO_ATTRIBUTE. The value for each * requested attribute is written in order to the values array. The * HWC_DISPLAY_NO_ATTRIBUTE attribute does not have a value, so the values * array will have one less value than the attributes array. * * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_1 and later. * It shall be NULL for previous versions. * * If disp is a hotpluggable display type and no display is connected, * or if config is not a valid configuration for the display, a negative * error code shall be returned. */ int (*getDisplayAttributes)(struct hwc_composer_device_1* dev, int disp, uint32_t config, const uint32_t* attributes, int32_t* values); /* * (*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. * * Returns the configuration index on success or -1 on error. * * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_4 and later. * It shall be NULL for previous versions. */ int (*getActiveConfig)(struct hwc_composer_device_1* dev, int disp); /* * (*setActiveConfig)() instructs the hardware composer to switch to the * display configuration at the given index in the list of configuration * handles returned by getDisplayConfigs. * * If this function returns without error, any subsequent calls to * getActiveConfig shall return the index set by this function until one * of the following occurs: * 1) Another successful call of this function * 2) The display is disconnected * * Returns 0 on success or a negative error code on error. If disp is a * hotpluggable display type and no display is connected, or if index is * outside of the range of hardware configurations returned by * getDisplayConfigs, an error shall be returned. * * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_4 and later. * It shall be NULL for previous versions. */ int (*setActiveConfig)(struct hwc_composer_device_1* dev, int disp, int index); /* * Asynchronously update the location of the cursor layer. * * Within the standard prepare()/set() composition loop, the client * (surfaceflinger) can request that a given layer uses dedicated cursor * composition hardware by specifiying the HWC_IS_CURSOR_LAYER flag. Only * one layer per display can have this flag set. If the layer is suitable * for the platform's cursor hardware, hwcomposer will return from prepare() * a composition type of HWC_CURSOR_OVERLAY for that layer. This indicates * not only that the client is not responsible for compositing that layer, * but also that the client can continue to update the position of that layer * after a call to set(). This can reduce the visible latency of mouse * movement to visible, on-screen cursor updates. Calls to * setCursorPositionAsync() may be made from a different thread doing the * prepare()/set() composition loop, but care must be taken to not interleave * calls of setCursorPositionAsync() between calls of set()/prepare(). * * Notes: * - Only one layer per display can be specified as a cursor layer with * HWC_IS_CURSOR_LAYER. * - hwcomposer will only return one layer per display as HWC_CURSOR_OVERLAY * - This returns 0 on success or -errno on error. * - This field is optional for HWC_DEVICE_API_VERSION_1_4 and later. It * should be null for previous versions. */ int (*setCursorPositionAsync)(struct hwc_composer_device_1 *dev, int disp, int x_pos, int y_pos); /* * Reserved for future use. Must be NULL. */ void* reserved_proc[1]; } hwc_composer_device_1_t; /** convenience API for opening and closing a device */ 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); } static inline int hwc_close_1(hwc_composer_device_1_t* device) { return device->common.close(&device->common); } /*****************************************************************************/ __END_DECLS #endif /* ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H */ android-headers-23/22/hardware/hwcomposer_defs.h000066400000000000000000000204741264465411000217230ustar00rootroot00000000000000/* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_DEFS_H #define ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_DEFS_H #include #include #include #include #include __BEGIN_DECLS /*****************************************************************************/ #define HWC_HEADER_VERSION 1 #define HWC_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define HWC_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION_2(1, 0, HWC_HEADER_VERSION) #define HWC_DEVICE_API_VERSION_1_1 HARDWARE_DEVICE_API_VERSION_2(1, 1, HWC_HEADER_VERSION) #define HWC_DEVICE_API_VERSION_1_2 HARDWARE_DEVICE_API_VERSION_2(1, 2, HWC_HEADER_VERSION) #define HWC_DEVICE_API_VERSION_1_3 HARDWARE_DEVICE_API_VERSION_2(1, 3, HWC_HEADER_VERSION) #define HWC_DEVICE_API_VERSION_1_4 HARDWARE_DEVICE_API_VERSION_2(1, 4, HWC_HEADER_VERSION) enum { /* hwc_composer_device_t::set failed in EGL */ HWC_EGL_ERROR = -1 }; /* * hwc_layer_t::hints values * Hints are set by the HAL and read by SurfaceFlinger */ enum { /* * HWC can set the HWC_HINT_TRIPLE_BUFFER hint to indicate to SurfaceFlinger * that it should triple buffer this layer. Typically HWC does this when * the layer will be unavailable for use for an extended period of time, * e.g. if the display will be fetching data directly from the layer and * the layer can not be modified until after the next set(). */ HWC_HINT_TRIPLE_BUFFER = 0x00000001, /* * HWC sets HWC_HINT_CLEAR_FB to tell SurfaceFlinger that it should clear the * framebuffer with transparent pixels where this layer would be. * SurfaceFlinger will only honor this flag when the layer has no blending * */ HWC_HINT_CLEAR_FB = 0x00000002 }; /* * hwc_layer_t::flags values * Flags are set by SurfaceFlinger and read by the HAL */ enum { /* * HWC_SKIP_LAYER is set by SurfaceFlnger 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). */ HWC_SKIP_LAYER = 0x00000001, /* * HWC_IS_CURSOR_LAYER is set by surfaceflinger to indicate that this * layer is being used as a cursor on this particular display, and that * surfaceflinger can potentially perform asynchronous position updates for * this layer. If a call to prepare() returns HWC_CURSOR_OVERLAY for the * composition type of this layer, then the hwcomposer will allow async * position updates to this layer via setCursorPositionAsync(). */ HWC_IS_CURSOR_LAYER = 0x00000002 }; /* * hwc_layer_t::compositionType values */ enum { /* this layer is to be drawn into the framebuffer by SurfaceFlinger */ HWC_FRAMEBUFFER = 0, /* this layer will be handled in the HWC */ HWC_OVERLAY = 1, /* this is the background layer. it's used to set the background color. * there is only a single background layer */ HWC_BACKGROUND = 2, /* this layer holds the result of compositing the HWC_FRAMEBUFFER layers. * Added in HWC_DEVICE_API_VERSION_1_1. */ HWC_FRAMEBUFFER_TARGET = 3, /* this layer's contents are taken from a sideband buffer stream. * Added in HWC_DEVICE_API_VERSION_1_4. */ HWC_SIDEBAND = 4, /* this layer's composition will be handled by hwcomposer by dedicated cursor overlay hardware. hwcomposer will also all async position updates of this layer outside of the normal prepare()/set() loop. Added in HWC_DEVICE_API_VERSION_1_4. */ HWC_CURSOR_OVERLAY = 5 }; /* * hwc_layer_t::blending values */ enum { /* no blending */ HWC_BLENDING_NONE = 0x0100, /* ONE / ONE_MINUS_SRC_ALPHA */ HWC_BLENDING_PREMULT = 0x0105, /* SRC_ALPHA / ONE_MINUS_SRC_ALPHA */ HWC_BLENDING_COVERAGE = 0x0405 }; /* * hwc_layer_t::transform values */ enum { /* flip source image horizontally */ HWC_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H, /* flip source image vertically */ HWC_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V, /* rotate source image 90 degrees clock-wise */ HWC_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90, /* rotate source image 180 degrees */ HWC_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180, /* rotate source image 270 degrees clock-wise */ HWC_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270, }; /* attributes queriable with query() */ enum { /* * Must return 1 if the background layer is supported, 0 otherwise. */ HWC_BACKGROUND_LAYER_SUPPORTED = 0, /* * Returns the vsync period in nanoseconds. * * This query is not used for HWC_DEVICE_API_VERSION_1_1 and later. * Instead, the per-display attribute HWC_DISPLAY_VSYNC_PERIOD is used. */ HWC_VSYNC_PERIOD = 1, /* * Availability: HWC_DEVICE_API_VERSION_1_1 * Returns a mask of supported display types. */ HWC_DISPLAY_TYPES_SUPPORTED = 2, }; /* display attributes returned by getDisplayAttributes() */ enum { /* Indicates the end of an attribute list */ HWC_DISPLAY_NO_ATTRIBUTE = 0, /* The vsync period in nanoseconds */ HWC_DISPLAY_VSYNC_PERIOD = 1, /* The number of pixels in the horizontal and vertical directions. */ HWC_DISPLAY_WIDTH = 2, HWC_DISPLAY_HEIGHT = 3, /* The number of pixels per thousand inches of this configuration. * * Scaling DPI by 1000 allows it to be stored in an int without losing * too much precision. * * If the DPI for a configuration is unavailable or the HWC implementation * considers it unreliable, it should set these attributes to zero. */ HWC_DISPLAY_DPI_X = 4, HWC_DISPLAY_DPI_Y = 5, }; /* Allowed events for hwc_methods::eventControl() */ enum { HWC_EVENT_VSYNC = 0 }; /* Display types and associated mask bits. */ enum { HWC_DISPLAY_PRIMARY = 0, HWC_DISPLAY_EXTERNAL = 1, // HDMI, DP, etc. HWC_DISPLAY_VIRTUAL = 2, HWC_NUM_PHYSICAL_DISPLAY_TYPES = 2, HWC_NUM_DISPLAY_TYPES = 3, }; enum { HWC_DISPLAY_PRIMARY_BIT = 1 << HWC_DISPLAY_PRIMARY, HWC_DISPLAY_EXTERNAL_BIT = 1 << HWC_DISPLAY_EXTERNAL, HWC_DISPLAY_VIRTUAL_BIT = 1 << HWC_DISPLAY_VIRTUAL, }; /* Display power modes */ enum { /* The display is turned off (blanked). */ HWC_POWER_MODE_OFF = 0, /* The display is turned on and configured in a low power state * that is suitable for presenting ambient information to the user, * possibly with lower fidelity than normal but greater efficiency. */ HWC_POWER_MODE_DOZE = 1, /* The display is turned on normally. */ HWC_POWER_MODE_NORMAL = 2, /* The display is configured as in HWC_POWER_MODE_DOZE but may * stop applying frame buffer updates from the graphics subsystem. * This power mode is effectively a hint from the doze dream to * tell the hardware that it is done drawing to the display for the * time being and that the display should remain on in a low power * state and continue showing its current contents indefinitely * until the mode changes. * * This mode may also be used as a signal to enable hardware-based doze * functionality. In this case, the doze dream is effectively * indicating that the hardware is free to take over the display * and manage it autonomously to implement low power always-on display * functionality. */ HWC_POWER_MODE_DOZE_SUSPEND = 3, }; /*****************************************************************************/ __END_DECLS #endif /* ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_DEFS_H */ android-headers-23/22/hardware/keymaster.h000066400000000000000000000211751264465411000205370ustar00rootroot00000000000000/* * 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 android-headers-23/22/hardware/lights.h000066400000000000000000000074721264465411000200310ustar00rootroot00000000000000/* * 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_LIGHTS_INTERFACE_H #define ANDROID_LIGHTS_INTERFACE_H #include #include #include #include __BEGIN_DECLS /** * The id of this module */ #define LIGHTS_HARDWARE_MODULE_ID "lights" /* * These light IDs correspond to logical lights, not physical. * So for example, if your INDICATOR light is in line with your * BUTTONS, it might make sense to also light the INDICATOR * light to a reasonable color when the BUTTONS are lit. */ #define LIGHT_ID_BACKLIGHT "backlight" #define LIGHT_ID_KEYBOARD "keyboard" #define LIGHT_ID_BUTTONS "buttons" #define LIGHT_ID_BATTERY "battery" #define LIGHT_ID_NOTIFICATIONS "notifications" #define LIGHT_ID_ATTENTION "attention" /* * These lights aren't currently supported by the higher * layers, but could be someday, so we have the constants * here now. */ #define LIGHT_ID_BLUETOOTH "bluetooth" #define LIGHT_ID_WIFI "wifi" /* ************************************************************************ * Flash modes for the flashMode field of light_state_t. */ #define LIGHT_FLASH_NONE 0 /** * To flash the light at a given rate, set flashMode to LIGHT_FLASH_TIMED, * and then flashOnMS should be set to the number of milliseconds to turn * the light on, followed by the number of milliseconds to turn the light * off. */ #define LIGHT_FLASH_TIMED 1 /** * To flash the light using hardware assist, set flashMode to * the hardware mode. */ #define LIGHT_FLASH_HARDWARE 2 /** * Light brightness is managed by a user setting. */ #define BRIGHTNESS_MODE_USER 0 /** * Light brightness is managed by a light sensor. */ #define BRIGHTNESS_MODE_SENSOR 1 /** * The parameters that can be set for a given light. * * Not all lights must support all parameters. If you * can do something backward-compatible, you should. */ struct light_state_t { /** * The color of the LED in ARGB. * * Do your best here. * - If your light can only do red or green, if they ask for blue, * you should do green. * - If you can only do a brightness ramp, then use this formula: * unsigned char brightness = ((77*((color>>16)&0x00ff)) * + (150*((color>>8)&0x00ff)) + (29*(color&0x00ff))) >> 8; * - If you can only do on or off, 0 is off, anything else is on. * * The high byte should be ignored. Callers will set it to 0xff (which * would correspond to 255 alpha). */ unsigned int color; /** * See the LIGHT_FLASH_* constants */ int flashMode; int flashOnMS; int flashOffMS; /** * Policy used by the framework to manage the light's brightness. * Currently the values are BRIGHTNESS_MODE_USER and BRIGHTNESS_MODE_SENSOR. */ int brightnessMode; }; struct light_device_t { struct hw_device_t common; /** * Set the provided lights to the provided values. * * Returns: 0 on succes, error code on failure. */ int (*set_light)(struct light_device_t* dev, struct light_state_t const* state); }; __END_DECLS #endif // ANDROID_LIGHTS_INTERFACE_H android-headers-23/22/hardware/local_time_hal.h000066400000000000000000000074111264465411000214640ustar00rootroot00000000000000/* * 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_LOCAL_TIME_HAL_INTERFACE_H #define ANDROID_LOCAL_TIME_HAL_INTERFACE_H #include #include __BEGIN_DECLS /** * The id of this module */ #define LOCAL_TIME_HARDWARE_MODULE_ID "local_time" /** * Name of the local time devices to open */ #define LOCAL_TIME_HARDWARE_INTERFACE "local_time_hw_if" /**********************************************************************/ /** * A structure used to collect low level sync data in a lab environment. Most * HAL implementations will never need this structure. */ struct local_time_debug_event { int64_t local_timesync_event_id; int64_t local_time; }; /** * 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. */ struct local_time_module { struct hw_module_t common; }; struct local_time_hw_device { /** * Common methods of the local time hardware device. This *must* be the first member of * local_time_hw_device as users of this structure will cast a hw_device_t to * local_time_hw_device pointer in contexts where it's known the hw_device_t references a * local_time_hw_device. */ struct hw_device_t common; /** * * Returns the current value of the system wide local time counter */ int64_t (*get_local_time)(struct local_time_hw_device* dev); /** * * Returns the nominal frequency (in hertz) of the system wide local time * counter */ uint64_t (*get_local_freq)(struct local_time_hw_device* dev); /** * * Sets the HW slew rate of oscillator which drives the system wide local * time counter. On success, platforms should return 0. Platforms which * do not support HW slew should leave this method set to NULL. * * Valid values for rate range from MIN_INT16 to MAX_INT16. Platform * implementations should attempt map this range linearly to the min/max * slew rate of their hardware. */ int (*set_local_slew)(struct local_time_hw_device* dev, int16_t rate); /** * * A method used to collect low level sync data in a lab environments. * Most HAL implementations will simply set this member to NULL, or return * -EINVAL to indicate that this functionality is not supported. * Production HALs should never support this method. */ int (*get_debug_log)(struct local_time_hw_device* dev, struct local_time_debug_event* records, int max_records); }; typedef struct local_time_hw_device local_time_hw_device_t; /** convenience API for opening and closing a supported device */ static inline int local_time_hw_device_open( const struct hw_module_t* module, struct local_time_hw_device** device) { return module->methods->open(module, LOCAL_TIME_HARDWARE_INTERFACE, (struct hw_device_t**)device); } static inline int local_time_hw_device_close(struct local_time_hw_device* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_LOCAL_TIME_INTERFACE_H android-headers-23/22/hardware/memtrack.h000066400000000000000000000140221264465411000203270ustar00rootroot00000000000000/* * 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_HARDWARE_MEMTRACK_H #define ANDROID_INCLUDE_HARDWARE_MEMTRACK_H #include #include #include #include __BEGIN_DECLS #define MEMTRACK_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) /** * The id of this module */ #define MEMTRACK_HARDWARE_MODULE_ID "memtrack" /* * The Memory Tracker HAL is designed to return information about device-specific * memory usage. The primary goal is to be able to track memory that is not * trackable in any other way, for example texture memory that is allocated by * a process, but not mapped in to that process' address space. * A secondary goal is to be able to categorize memory used by a process into * GL, graphics, etc. All memory sizes should be in real memory usage, * accounting for stride, bit depth, rounding up to page size, etc. * * A process collecting memory statistics will call getMemory for each * combination of pid and memory type. For each memory type that it recognizes * the HAL should fill out an array of memtrack_record structures breaking * down the statistics of that memory type as much as possible. For example, * getMemory(, MEMTRACK_TYPE_GL) might return: * { { 4096, ACCOUNTED | PRIVATE | SYSTEM }, * { 40960, UNACCOUNTED | PRIVATE | SYSTEM }, * { 8192, ACCOUNTED | PRIVATE | DEDICATED }, * { 8192, UNACCOUNTED | PRIVATE | DEDICATED } } * If the HAL could not differentiate between SYSTEM and DEDICATED memory, it * could return: * { { 12288, ACCOUNTED | PRIVATE }, * { 49152, UNACCOUNTED | PRIVATE } } * * Memory should not overlap between types. For example, a graphics buffer * that has been mapped into the GPU as a surface should show up when * MEMTRACK_TYPE_GRAPHICS is requested, and not when MEMTRACK_TYPE_GL * is requested. */ enum memtrack_type { MEMTRACK_TYPE_OTHER = 0, MEMTRACK_TYPE_GL = 1, MEMTRACK_TYPE_GRAPHICS = 2, MEMTRACK_TYPE_MULTIMEDIA = 3, MEMTRACK_TYPE_CAMERA = 4, MEMTRACK_NUM_TYPES, }; struct memtrack_record { size_t size_in_bytes; unsigned int flags; }; /** * Flags to differentiate memory that can already be accounted for in * /proc//smaps, * (Shared_Clean + Shared_Dirty + Private_Clean + Private_Dirty = Size). * In general, memory mapped in to a userspace process is accounted unless * it was mapped with remap_pfn_range. * Exactly one of these should be set. */ #define MEMTRACK_FLAG_SMAPS_ACCOUNTED (1 << 1) #define MEMTRACK_FLAG_SMAPS_UNACCOUNTED (1 << 2) /** * Flags to differentiate memory shared across multiple processes vs. memory * used by a single process. Only zero or one of these may be set in a record. * If none are set, record is assumed to count shared + private memory. */ #define MEMTRACK_FLAG_SHARED (1 << 3) #define MEMTRACK_FLAG_SHARED_PSS (1 << 4) /* shared / num_procesess */ #define MEMTRACK_FLAG_PRIVATE (1 << 5) /** * Flags to differentiate memory taken from the kernel's allocation pool vs. * memory that is dedicated to non-kernel allocations, for example a carveout * or separate video memory. Only zero or one of these may be set in a record. * If none are set, record is assumed to count system + dedicated memory. */ #define MEMTRACK_FLAG_SYSTEM (1 << 6) #define MEMTRACK_FLAG_DEDICATED (1 << 7) /** * Flags to differentiate memory accessible by the CPU in non-secure mode vs. * memory that is protected. Only zero or one of these may be set in a record. * If none are set, record is assumed to count secure + nonsecure memory. */ #define MEMTRACK_FLAG_NONSECURE (1 << 8) #define MEMTRACK_FLAG_SECURE (1 << 9) /** * 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 memtrack_module { struct hw_module_t common; /** * (*init)() performs memtrack management setup actions and is called * once before any calls to getMemory(). * Returns 0 on success, -errno on error. */ int (*init)(const struct memtrack_module *module); /** * (*getMemory)() expects an array of record objects and populates up to * *num_record structures with the sizes of memory plus associated flags for * that memory. It also updates *num_records with the total number of * records it could return if *num_records was large enough when passed in. * Returning records with size 0 is expected, the number of records should * not vary between calls to getMemory for the same memory type, even * for different pids. * * The caller will often call getMemory for a type and pid with * *num_records == 0 to determine how many records to allocate room for, * this case should be a fast-path in the HAL, returning a constant and * not querying any kernel files. If *num_records passed in is 0, * then records may be NULL. * * This function must be thread-safe, it may get called from multiple * threads at the same time. * * Returns 0 on success, -ENODEV if the type is not supported, -errno * on other errors. */ int (*getMemory)(const struct memtrack_module *module, pid_t pid, int type, struct memtrack_record *records, size_t *num_records); } memtrack_module_t; __END_DECLS #endif // ANDROID_INCLUDE_HARDWARE_MEMTRACK_H android-headers-23/22/hardware/nfc.h000066400000000000000000000234201264465411000172740ustar00rootroot00000000000000/* * Copyright (C) 2011, 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_NFC_HAL_INTERFACE_H #define ANDROID_NFC_HAL_INTERFACE_H #include #include #include #include #include __BEGIN_DECLS /* NFC device HAL for NCI-based NFC controllers. * * This HAL allows NCI silicon vendors to make use * of the core NCI stack in Android for their own silicon. * * The responibilities of the NCI HAL implementation * are as follows: * * - Implement the transport to the NFC controller * - Implement each of the HAL methods specified below as applicable to their silicon * - Pass up received NCI messages from the controller to the stack * * A simplified timeline of NCI HAL method calls: * 1) Core NCI stack calls open() * 2) Core NCI stack executes CORE_RESET and CORE_INIT through calls to write() * 3) Core NCI stack calls core_initialized() to allow HAL to do post-init configuration * 4) Core NCI stack calls pre_discover() to allow HAL to prepare for RF discovery * 5) Core NCI stack starts discovery through calls to write() * 6) Core NCI stack stops discovery through calls to write() (e.g. screen turns off) * 7) Core NCI stack calls pre_discover() to prepare for RF discovery (e.g. screen turned back on) * 8) Core NCI stack starts discovery through calls to write() * ... * ... * 9) Core NCI stack calls close() */ #define NFC_NCI_HARDWARE_MODULE_ID "nfc_nci" #define NFC_NCI_BCM2079X_HARDWARE_MODULE_ID "nfc_nci.bcm2079x" #define NFC_NCI_CONTROLLER "nci" /* * nfc_nci_module_t should contain module-specific parameters */ typedef struct nfc_nci_module_t { /** * Common methods of the NFC NCI module. This *must* be the first member of * nfc_nci_module_t as users of this structure will cast a hw_module_t to * nfc_nci_module_t pointer in contexts where it's known the hw_module_t references a * 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. */ typedef void (nfc_stack_callback_t) (nfc_event_t event, nfc_status_t event_status); /* * The callback passed in from the NFC stack that the HAL * can use to pass incomming data to the stack. */ typedef void (nfc_stack_data_callback_t) (uint16_t data_len, uint8_t* p_data); /* nfc_nci_device_t starts with a hw_device_t struct, * followed by device-specific methods and members. * * All methods in the NCI HAL are asynchronous. */ typedef struct nfc_nci_device { /** * Common methods of the NFC NCI device. This *must* be the first member of * nfc_nci_device_t as users of this structure will cast a hw_device_t to * nfc_nci_device_t pointer in contexts where it's known the hw_device_t references a * nfc_nci_device_t. */ struct hw_device_t common; /* * (*open)() Opens the NFC controller device and performs initialization. * This may include patch download and other vendor-specific initialization. * * If open completes successfully, the controller should be ready to perform * NCI initialization - ie accept CORE_RESET and subsequent commands through * the write() call. * * If open() returns 0, the NCI stack will wait for a HAL_NFC_OPEN_CPLT_EVT * before continuing. * * If open() returns any other value, the NCI stack will stop. * */ int (*open)(const struct nfc_nci_device *p_dev, nfc_stack_callback_t *p_cback, nfc_stack_data_callback_t *p_data_cback); /* * (*write)() Performs an NCI write. * * This method may queue writes and return immediately. The only * requirement is that the writes are executed in order. */ int (*write)(const struct nfc_nci_device *p_dev, uint16_t data_len, const uint8_t *p_data); /* * (*core_initialized)() is called after the CORE_INIT_RSP is received from the NFCC. * At this time, the HAL can do any chip-specific configuration. * * If core_initialized() returns 0, the NCI stack will wait for a HAL_NFC_POST_INIT_CPLT_EVT * before continuing. * * If core_initialized() returns any other value, the NCI stack will continue * immediately. */ int (*core_initialized)(const struct nfc_nci_device *p_dev, uint8_t* p_core_init_rsp_params); /* * (*pre_discover)() Is called every time before starting RF discovery. * It is a good place to do vendor-specific configuration that must be * performed every time RF discovery is about to be started. * * If pre_discover() returns 0, the NCI stack will wait for a HAL_NFC_PRE_DISCOVER_CPLT_EVT * before continuing. * * If pre_discover() returns any other value, the NCI stack will start * RF discovery immediately. */ int (*pre_discover)(const struct nfc_nci_device *p_dev); /* * (*close)() Closed the NFC controller. Should free all resources. */ int (*close)(const struct nfc_nci_device *p_dev); /* * (*control_granted)() Grant HAL the exclusive control to send NCI commands. * Called in response to HAL_REQUEST_CONTROL_EVT. * Must only be called when there are no NCI commands pending. * HAL_RELEASE_CONTROL_EVT will notify when HAL no longer needs exclusive control. */ int (*control_granted)(const struct nfc_nci_device *p_dev); /* * (*power_cycle)() Restart controller by power cyle; * HAL_OPEN_CPLT_EVT will notify when operation is complete. */ int (*power_cycle)(const struct nfc_nci_device *p_dev); } nfc_nci_device_t; /* * Convenience methods that the NFC stack can use to open * and close an NCI device */ static inline int nfc_nci_open(const struct hw_module_t* module, nfc_nci_device_t** dev) { return module->methods->open(module, NFC_NCI_CONTROLLER, (struct hw_device_t**) dev); } static inline int nfc_nci_close(nfc_nci_device_t* dev) { return dev->common.close(&dev->common); } /* * End NFC NCI HAL */ /* * This is a limited NFC HAL for NXP PN544-based devices. * This HAL as Android is moving to * an NCI-based NFC stack. * * All NCI-based NFC controllers should use the NFC-NCI * HAL instead. * Begin PN544 specific HAL */ #define NFC_HARDWARE_MODULE_ID "nfc" #define NFC_PN544_CONTROLLER "pn544" typedef struct nfc_module_t { /** * Common methods of the NFC NXP PN544 module. This *must* be the first member of * nfc_module_t as users of this structure will cast a hw_module_t to * nfc_module_t pointer in contexts where it's known the hw_module_t references a * nfc_module_t. */ struct hw_module_t common; } nfc_module_t; /* * PN544 linktypes. * UART * I2C * USB (uses UART DAL) */ typedef enum { PN544_LINK_TYPE_UART, PN544_LINK_TYPE_I2C, PN544_LINK_TYPE_USB, PN544_LINK_TYPE_INVALID, } nfc_pn544_linktype; typedef struct { /** * Common methods of the NFC NXP PN544 device. This *must* be the first member of * nfc_pn544_device_t as users of this structure will cast a hw_device_t to * nfc_pn544_device_t pointer in contexts where it's known the hw_device_t references a * nfc_pn544_device_t. */ struct hw_device_t common; /* The number of EEPROM registers to write */ uint32_t num_eeprom_settings; /* The actual EEPROM settings * For PN544, each EEPROM setting is a 4-byte entry, * of the format [0x00, addr_msb, addr_lsb, value]. */ uint8_t* eeprom_settings; /* The link type to which the PN544 is connected */ nfc_pn544_linktype linktype; /* The device node to which the PN544 is connected */ const char* device_node; /* On Crespo we had an I2C issue that would cause us to sometimes read * the I2C slave address (0x57) over the bus. libnfc contains * a hack to ignore this byte and try to read the length byte * again. * Set to 0 to disable the workaround, 1 to enable it. */ uint8_t enable_i2c_workaround; /* I2C slave address. Multiple I2C addresses are * possible for PN544 module. Configure address according to * board design. */ uint8_t i2c_device_address; } nfc_pn544_device_t; static inline int nfc_pn544_open(const struct hw_module_t* module, nfc_pn544_device_t** dev) { return module->methods->open(module, NFC_PN544_CONTROLLER, (struct hw_device_t**) dev); } static inline int nfc_pn544_close(nfc_pn544_device_t* dev) { return dev->common.close(&dev->common); } /* * End PN544 specific HAL */ __END_DECLS #endif // ANDROID_NFC_HAL_INTERFACE_H android-headers-23/22/hardware/nfc_tag.h000066400000000000000000000055471264465411000201410ustar00rootroot00000000000000/* * 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_NFC_TAG_HAL_INTERFACE_H #define ANDROID_NFC_TAG_HAL_INTERFACE_H #include #include __BEGIN_DECLS /* * HAL for programmable NFC tags. * */ #define NFC_TAG_HARDWARE_MODULE_ID "nfc_tag" #define NFC_TAG_ID "tag" typedef struct nfc_tag_module_t { /** * Common methods of the NFC tag module. This *must* be the first member of * nfc_tag_module_t as users of this structure will cast a hw_module_t to * nfc_tag_module_t pointer in contexts where it's known the hw_module_t references a * nfc_tag_module_t. */ struct hw_module_t common; } nfc_tag_module_t; typedef struct nfc_tag_device { /** * Common methods of the NFC tag device. This *must* be the first member of * nfc_tag_device_t as users of this structure will cast a hw_device_t to * nfc_tag_device_t pointer in contexts where it's known the hw_device_t references a * nfc_tag_device_t. */ struct hw_device_t common; /** * Initialize the NFC tag. * * The driver must: * * Set the static lock bytes to read only * * Configure the Capability Container to disable write acess * eg: 0xE1 0x10 0x0F * * This function is called once before any calls to setContent(). * * Return 0 on success or -errno on error. */ int (*init)(const struct nfc_tag_device *dev); /** * Set the NFC tag content. * * The driver must write in the data area of the tag starting at * byte 0 of block 4 and zero the rest of the data area. * * Returns 0 on success or -errno on error. */ int (*setContent)(const struct nfc_tag_device *dev, const uint8_t *data, size_t len); /** * Returns the memory size of the data area. */ int (*getMemorySize)(const struct nfc_tag_device *dev); } nfc_tag_device_t; static inline int nfc_tag_open(const struct hw_module_t* module, nfc_tag_device_t** dev) { return module->methods->open(module, NFC_TAG_ID, (struct hw_device_t**)dev); } static inline int nfc_tag_close(nfc_tag_device_t* dev) { return dev->common.close(&dev->common); } __END_DECLS #endif // ANDROID_NFC_TAG_HAL_INTERFACE_H android-headers-23/22/hardware/power.h000066400000000000000000000127071264465411000176700ustar00rootroot00000000000000/* * 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_HARDWARE_POWER_H #define ANDROID_INCLUDE_HARDWARE_POWER_H #include #include #include #include __BEGIN_DECLS #define POWER_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define POWER_MODULE_API_VERSION_0_2 HARDWARE_MODULE_API_VERSION(0, 2) #define POWER_MODULE_API_VERSION_0_3 HARDWARE_MODULE_API_VERSION(0, 3) /** * The id of this module */ #define POWER_HARDWARE_MODULE_ID "power" /* * Power hint identifiers passed to (*powerHint) */ typedef enum { POWER_HINT_VSYNC = 0x00000001, POWER_HINT_INTERACTION = 0x00000002, /* DO NOT USE POWER_HINT_VIDEO_ENCODE/_DECODE! They will be removed in * KLP. */ POWER_HINT_VIDEO_ENCODE = 0x00000003, POWER_HINT_VIDEO_DECODE = 0x00000004, POWER_HINT_LOW_POWER = 0x00000005 } power_hint_t; typedef enum { POWER_FEATURE_DOUBLE_TAP_TO_WAKE = 0x00000001 } feature_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 power_module { struct hw_module_t common; /* * (*init)() performs power management setup actions at runtime * startup, such as to set default cpufreq parameters. This is * called only by the Power HAL instance loaded by * PowerManagerService. */ void (*init)(struct power_module *module); /* * (*setInteractive)() performs power management actions upon the * system entering interactive state (that is, the system is awake * and ready for interaction, often with UI devices such as * display and touchscreen enabled) or non-interactive state (the * system appears asleep, display usually turned off). The * non-interactive state is usually entered after a period of * inactivity, in order to conserve battery power during * such inactive periods. * * Typical actions are to turn on or off devices and adjust * cpufreq parameters. This function may also call the * appropriate interfaces to allow the kernel to suspend the * system to low-power sleep state when entering non-interactive * state, and to disallow low-power suspend when the system is in * interactive state. When low-power suspend state is allowed, the * kernel may suspend the system whenever no wakelocks are held. * * on is non-zero when the system is transitioning to an * interactive / awake state, and zero when transitioning to a * non-interactive / asleep state. * * This function is called to enter non-interactive state after * turning off the screen (if present), and called to enter * interactive state prior to turning on the screen. */ void (*setInteractive)(struct power_module *module, int on); /* * (*powerHint) is called to pass hints on power requirements, which * may result in adjustment of power/performance parameters of the * cpufreq governor and other controls. The possible hints are: * * POWER_HINT_VSYNC * * Foreground app has started or stopped requesting a VSYNC pulse * from SurfaceFlinger. If the app has started requesting VSYNC * then CPU and GPU load is expected soon, and it may be appropriate * to raise speeds of CPU, memory bus, etc. The data parameter is * non-zero to indicate VSYNC pulse is now requested, or zero for * VSYNC pulse no longer requested. * * POWER_HINT_INTERACTION * * User is interacting with the device, for example, touchscreen * events are incoming. CPU and GPU load may be expected soon, * and it may be appropriate to raise speeds of CPU, memory bus, * etc. The data parameter is unused. * * POWER_HINT_LOW_POWER * * Low power mode is activated or deactivated. Low power mode * is intended to save battery at the cost of performance. The data * parameter is non-zero when low power mode is activated, and zero * when deactivated. * * A particular platform may choose to ignore any hint. * * availability: version 0.2 * */ void (*powerHint)(struct power_module *module, power_hint_t hint, void *data); /* * (*setFeature) is called to turn on or off a particular feature * depending on the state parameter. The possible features are: * * FEATURE_DOUBLE_TAP_TO_WAKE * * Enabling/Disabling this feature will allow/disallow the system * to wake up by tapping the screen twice. * * availability: version 0.3 * */ void (*setFeature)(struct power_module *module, feature_t feature, int state); } power_module_t; __END_DECLS #endif // ANDROID_INCLUDE_HARDWARE_POWER_H android-headers-23/22/hardware/qemu_pipe.h000066400000000000000000000054011264465411000205110ustar00rootroot00000000000000/* * 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 #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 */ android-headers-23/22/hardware/qemud.h000066400000000000000000000102441264465411000176410ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/hardware/sensors.h000066400000000000000000001110041264465411000202160ustar00rootroot00000000000000/* * 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_SENSORS_INTERFACE_H #define ANDROID_SENSORS_INTERFACE_H #include #include #include #include #include __BEGIN_DECLS /*****************************************************************************/ #define SENSORS_HEADER_VERSION 1 #define SENSORS_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define SENSORS_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION_2(0, 1, SENSORS_HEADER_VERSION) #define SENSORS_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION_2(1, 0, SENSORS_HEADER_VERSION) #define SENSORS_DEVICE_API_VERSION_1_1 HARDWARE_DEVICE_API_VERSION_2(1, 1, SENSORS_HEADER_VERSION) #define SENSORS_DEVICE_API_VERSION_1_2 HARDWARE_DEVICE_API_VERSION_2(1, 2, SENSORS_HEADER_VERSION) #define SENSORS_DEVICE_API_VERSION_1_3 HARDWARE_DEVICE_API_VERSION_2(1, 3, SENSORS_HEADER_VERSION) /** * Please see the Sensors section of source.android.com for an * introduction to and detailed descriptions of Android sensor types: * http://source.android.com/devices/sensors/index.html */ /** * The id of this module */ #define SENSORS_HARDWARE_MODULE_ID "sensors" /** * Name of the sensors device to open */ #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. */ #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" /** * Values returned by the accelerometer in various locations in the universe. * all values are in SI units (m/s^2) */ #define GRAVITY_SUN (275.0f) #define GRAVITY_EARTH (9.80665f) /** Maximum magnetic field on Earth's surface */ #define MAGNETIC_FIELD_EARTH_MAX (60.0f) /** 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 /** * sensor event data */ typedef struct { union { float v[3]; struct { float x; float y; float z; }; struct { float azimuth; float pitch; float roll; }; }; int8_t status; uint8_t reserved[3]; } sensors_vec_t; /** * uncalibrated gyroscope and magnetometer event data */ typedef struct { union { float uncalib[3]; struct { float x_uncalib; float y_uncalib; float z_uncalib; }; }; union { float bias[3]; struct { float x_bias; float y_bias; float z_bias; }; }; } uncalibrated_event_t; /** * Meta data event data */ typedef struct meta_data_event { int32_t what; int32_t sensor; } meta_data_event_t; /** * Heart rate event data */ typedef struct { // Heart rate in beats per minute. // Set to 0 when status is SENSOR_STATUS_UNRELIABLE or ..._NO_CONTACT float bpm; // Status of the sensor for this reading. Set to one SENSOR_STATUS_... // Note that this value should only be set for sensors that explicitly define // the meaning of this field. This field is not piped through the framework // for other sensors. int8_t status; } heart_rate_event_t; /** * Union of the various types of sensor data * that can be returned. */ typedef struct sensors_event_t { /* must be sizeof(struct sensors_event_t) */ int32_t version; /* sensor identifier */ int32_t sensor; /* sensor type */ int32_t type; /* reserved */ int32_t reserved0; /* time is in nanosecond */ int64_t timestamp; union { union { float data[16]; /* acceleration values are in meter per second per second (m/s^2) */ sensors_vec_t acceleration; /* magnetic vector values are in micro-Tesla (uT) */ sensors_vec_t magnetic; /* orientation values are in degrees */ sensors_vec_t orientation; /* gyroscope values are in rad/s */ sensors_vec_t gyro; /* temperature is in degrees centigrade (Celsius) */ float temperature; /* distance in centimeters */ float distance; /* light in SI lux units */ float light; /* pressure in hectopascal (hPa) */ float pressure; /* relative humidity in percent */ float relative_humidity; /* uncalibrated gyroscope values are in rad/s */ uncalibrated_event_t uncalibrated_gyro; /* uncalibrated magnetometer values are in micro-Teslas */ uncalibrated_event_t uncalibrated_magnetic; /* heart rate data containing value in bpm and status */ heart_rate_event_t heart_rate; /* this is a special event. see SENSOR_TYPE_META_DATA above. * sensors_meta_data_event_t events are all reported with a type of * SENSOR_TYPE_META_DATA. The handle is ignored and must be zero. */ meta_data_event_t meta_data; }; union { uint64_t data[8]; /* step-counter */ uint64_t step_counter; } u64; }; /* Reserved flags for internal use. Set to zero. */ uint32_t flags; uint32_t reserved1[3]; } sensors_event_t; /* see SENSOR_TYPE_META_DATA */ typedef sensors_event_t sensors_meta_data_event_t; struct sensor_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. */ struct sensors_module_t { struct hw_module_t common; /** * Enumerate all available sensors. The list is returned in "list". * @return number of sensors in the list */ int (*get_sensors_list)(struct sensors_module_t* module, struct sensor_t const** list); }; struct sensor_t { /* Name of this sensor. * All sensors of the same "type" must have a different "name". */ const char* name; /* vendor of the hardware part */ const char* vendor; /* version of the hardware part + driver. The value of this field * must increase when the driver is updated in a way that changes the * output of this sensor. This is important for fused sensors when the * fusion algorithm is updated. */ int version; /* handle that identifies this sensors. This handle is used to reference * this sensor throughout the HAL API. */ int handle; /* this sensor's type. */ int type; /* maximum range of this sensor's value in SI units */ float maxRange; /* smallest difference between two values reported by this sensor */ float resolution; /* rough estimate of this sensor's power consumption in mA */ float power; /* this value depends on the reporting mode: * * continuous: minimum sample period allowed in microseconds * on-change : 0 * one-shot :-1 * special : 0, unless otherwise noted */ int32_t minDelay; /* number of events reserved for this sensor in the batch mode FIFO. * If there is a dedicated FIFO for this sensor, then this is the * size of this FIFO. If the FIFO is shared with other sensors, * this is the size reserved for that sensor and it can be zero. */ uint32_t fifoReservedEventCount; /* maximum number of events of this sensor that could be batched. * This is especially relevant when the FIFO is shared between * several sensors; this value is then set to the size of that FIFO. */ 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. */ const char* stringType; /* permission required to see this sensor, register to it and receive data. * Set to "" if no permission is required. Some sensor types like the * heart rate monitor have a mandatory require_permission. * For sensors that always require a specific permission, like the heart * rate monitor, the android framework might overwrite this string * automatically. */ const char* requiredPermission; /* This value is defined only for continuous mode and on-change sensors. It is the delay between * two sensor events corresponding to the lowest frequency that this sensor supports. When lower * frequencies are requested through batch()/setDelay() the events will be generated at this * frequency instead. It can be used by the framework or applications to estimate when the batch * FIFO may be full. * * NOTE: 1) period_ns is in nanoseconds where as maxDelay/minDelay are in microseconds. * continuous, on-change: maximum sampling period allowed in microseconds. * one-shot, special : 0 * 2) maxDelay should always fit within a 32 bit signed integer. It is declared as 64 bit * on 64 bit architectures only for binary compatibility reasons. * Availability: SENSORS_DEVICE_API_VERSION_1_3 */ #ifdef __LP64__ int64_t maxDelay; #else int32_t maxDelay; #endif /* Flags for sensor. See SENSOR_FLAG_* above. Only the least significant 32 bits are used here. * It is declared as 64 bit on 64 bit architectures only for binary compatibility reasons. * Availability: SENSORS_DEVICE_API_VERSION_1_3 */ #ifdef __LP64__ uint64_t flags; #else uint32_t flags; #endif /* reserved fields, must be zero */ void* reserved[2]; }; /* * sensors_poll_device_t is used with SENSORS_DEVICE_API_VERSION_0_1 * and is present for backward binary and source compatibility. * See the Sensors HAL interface section for complete descriptions of the * following functions: * http://source.android.com/devices/sensors/index.html#hal */ struct sensors_poll_device_t { struct hw_device_t common; int (*activate)(struct sensors_poll_device_t *dev, int sensor_handle, int enabled); int (*setDelay)(struct sensors_poll_device_t *dev, int sensor_handle, int64_t sampling_period_ns); int (*poll)(struct sensors_poll_device_t *dev, sensors_event_t* data, int count); }; /* * struct sensors_poll_device_1 is used in HAL versions >= SENSORS_DEVICE_API_VERSION_1_0 */ typedef struct sensors_poll_device_1 { union { /* sensors_poll_device_1 is compatible with sensors_poll_device_t, * and can be down-cast to it */ struct sensors_poll_device_t v0; struct { struct hw_device_t common; /* Activate/de-activate one sensor. Return 0 on success, negative * * sensor_handle is the handle of the sensor to change. * enabled set to 1 to enable, or 0 to disable the sensor. * * Return 0 on success, negative errno code otherwise. */ int (*activate)(struct sensors_poll_device_t *dev, int sensor_handle, int enabled); /** * Set the events's period in nanoseconds for a given sensor. * If sampling_period_ns > max_delay it will be truncated to * max_delay and if sampling_period_ns < min_delay it will be * replaced by min_delay. */ int (*setDelay)(struct sensors_poll_device_t *dev, int sensor_handle, int64_t sampling_period_ns); /** * Returns an array of sensor data. */ int (*poll)(struct sensors_poll_device_t *dev, sensors_event_t* data, int count); }; }; /* * Sets a sensor’s parameters, including sampling frequency and maximum * report latency. This function can be called while the sensor is * activated, in which case it must not cause any sensor measurements to * be lost: transitioning from one sampling rate to the other cannot cause * lost events, nor can transitioning from a high maximum report latency to * a low maximum report latency. * See the Batching sensor results page for details: * http://source.android.com/devices/sensors/batching.html */ int (*batch)(struct sensors_poll_device_1* dev, int sensor_handle, int flags, int64_t sampling_period_ns, int64_t max_report_latency_ns); /* * Flush adds a META_DATA_FLUSH_COMPLETE event (sensors_event_meta_data_t) * to the end of the "batch mode" FIFO for the specified sensor and flushes * the FIFO. * If the FIFO is empty or if the sensor doesn't support batching (FIFO size zero), * it should return SUCCESS along with a trivial META_DATA_FLUSH_COMPLETE event added to the * event stream. This applies to all sensors other than one-shot sensors. * If the sensor is a one-shot sensor, flush must return -EINVAL and not generate * any flush complete metadata. * If the sensor is not active at the time flush() is called, flush() should return * -EINVAL. */ int (*flush)(struct sensors_poll_device_1* dev, int sensor_handle); void (*reserved_procs[8])(void); } sensors_poll_device_1_t; /** convenience API for opening and closing a device */ static inline int sensors_open(const struct hw_module_t* module, struct sensors_poll_device_t** device) { return module->methods->open(module, SENSORS_HARDWARE_POLL, (struct hw_device_t**)device); } static inline int sensors_close(struct sensors_poll_device_t* device) { return device->common.close(&device->common); } 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); } static inline int sensors_close_1(sensors_poll_device_1_t* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_SENSORS_INTERFACE_H android-headers-23/22/hardware/sound_trigger.h000066400000000000000000000115301264465411000214000ustar00rootroot00000000000000/* * 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. */ #include #include #include #ifndef ANDROID_SOUND_TRIGGER_HAL_H #define ANDROID_SOUND_TRIGGER_HAL_H __BEGIN_DECLS /** * The id of this module */ #define SOUND_TRIGGER_HARDWARE_MODULE_ID "sound_trigger" /** * Name of the audio devices to open */ #define SOUND_TRIGGER_HARDWARE_INTERFACE "sound_trigger_hw_if" #define SOUND_TRIGGER_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) #define SOUND_TRIGGER_MODULE_API_VERSION_CURRENT SOUND_TRIGGER_MODULE_API_VERSION_1_0 #define SOUND_TRIGGER_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) #define SOUND_TRIGGER_DEVICE_API_VERSION_CURRENT SOUND_TRIGGER_DEVICE_API_VERSION_1_0 /** * List of known sound trigger HAL modules. This is the base name of the sound_trigger HAL * library composed of the "sound_trigger." prefix, one of the base names below and * a suffix specific to the device. * e.g: sondtrigger.primary.goldfish.so or sound_trigger.primary.default.so */ #define SOUND_TRIGGER_HARDWARE_MODULE_ID_PRIMARY "primary" /** * 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. */ struct sound_trigger_module { struct hw_module_t common; }; typedef void (*recognition_callback_t)(struct sound_trigger_recognition_event *event, void *cookie); typedef void (*sound_model_callback_t)(struct sound_trigger_model_event *event, void *cookie); struct sound_trigger_hw_device { struct hw_device_t common; /* * Retrieve implementation properties. */ int (*get_properties)(const struct sound_trigger_hw_device *dev, struct sound_trigger_properties *properties); /* * Load a sound model. Once loaded, recognition of this model can be started and stopped. * Only one active recognition per model at a time. The SoundTrigger service will handle * concurrent recognition requests by different users/applications on the same model. * The implementation returns a unique handle used by other functions (unload_sound_model(), * start_recognition(), etc... */ int (*load_sound_model)(const struct sound_trigger_hw_device *dev, struct sound_trigger_sound_model *sound_model, sound_model_callback_t callback, void *cookie, sound_model_handle_t *handle); /* * Unload a sound model. A sound model can be unloaded to make room for a new one to overcome * implementation limitations. */ int (*unload_sound_model)(const struct sound_trigger_hw_device *dev, sound_model_handle_t handle); /* Start recognition on a given model. Only one recognition active at a time per model. * Once recognition succeeds of fails, the callback is called. * TODO: group recognition configuration parameters into one struct and add key phrase options. */ int (*start_recognition)(const struct sound_trigger_hw_device *dev, sound_model_handle_t sound_model_handle, const struct sound_trigger_recognition_config *config, recognition_callback_t callback, void *cookie); /* Stop recognition on a given model. * The implementation does not have to call the callback when stopped via this method. */ int (*stop_recognition)(const struct sound_trigger_hw_device *dev, sound_model_handle_t sound_model_handle); }; typedef struct sound_trigger_hw_device sound_trigger_hw_device_t; /** convenience API for opening and closing a supported device */ 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); } static inline int sound_trigger_hw_device_close(struct sound_trigger_hw_device* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_SOUND_TRIGGER_HAL_H android-headers-23/22/hardware/tv_input.h000066400000000000000000000326621264465411000204060ustar00rootroot00000000000000/* * Copyright 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_TV_INPUT_INTERFACE_H #define ANDROID_TV_INPUT_INTERFACE_H #include #include #include #include #include #include __BEGIN_DECLS /* * Module versioning information for the TV input hardware module, based on * tv_input_module_t.common.module_api_version. * * Version History: * * TV_INPUT_MODULE_API_VERSION_0_1: * Initial TV input hardware module API. * */ #define TV_INPUT_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define TV_INPUT_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION(0, 1) /* * The id of this module */ #define TV_INPUT_HARDWARE_MODULE_ID "tv_input" #define TV_INPUT_DEFAULT_DEVICE "default" /*****************************************************************************/ /* * 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 tv_input_module { struct hw_module_t common; } tv_input_module_t; /*****************************************************************************/ enum { /* Generic hardware. */ TV_INPUT_TYPE_OTHER_HARDWARE = 1, /* Tuner. (e.g. built-in terrestrial tuner) */ TV_INPUT_TYPE_TUNER = 2, TV_INPUT_TYPE_COMPOSITE = 3, TV_INPUT_TYPE_SVIDEO = 4, TV_INPUT_TYPE_SCART = 5, TV_INPUT_TYPE_COMPONENT = 6, TV_INPUT_TYPE_VGA = 7, TV_INPUT_TYPE_DVI = 8, /* Physical HDMI port. (e.g. HDMI 1) */ TV_INPUT_TYPE_HDMI = 9, TV_INPUT_TYPE_DISPLAY_PORT = 10, }; typedef uint32_t tv_input_type_t; typedef struct tv_input_device_info { /* Device ID */ int device_id; /* Type of physical TV input. */ tv_input_type_t type; union { struct { /* HDMI port ID number */ uint32_t port_id; } hdmi; /* TODO: add other type specific information. */ int32_t type_info_reserved[16]; }; /* TODO: Add capability if necessary. */ /* * Audio info * * audio_type == AUDIO_DEVICE_NONE if this input has no audio. */ audio_devices_t audio_type; const char* audio_address; int32_t reserved[16]; } tv_input_device_info_t; /* See tv_input_event_t for more details. */ enum { /* * Hardware notifies the framework that a device is available. * * Note that DEVICE_AVAILABLE and DEVICE_UNAVAILABLE events do not represent * hotplug events (i.e. plugging cable into or out of the physical port). * These events notify the framework whether the port is available or not. * For a concrete example, when a user plugs in or pulls out the HDMI cable * from a HDMI port, it does not generate DEVICE_AVAILABLE and/or * DEVICE_UNAVAILABLE events. However, if a user inserts a pluggable USB * tuner into the Android device, it will generate a DEVICE_AVAILABLE event * and when the port is removed, it should generate a DEVICE_UNAVAILABLE * event. * * For hotplug events, please see STREAM_CONFIGURATION_CHANGED for more * details. * * HAL implementation should register devices by using this event when the * device boots up. The framework will recognize device reported via this * event only. In addition, the implementation could use this event to * notify the framework that a removable TV input device (such as USB tuner * as stated in the example above) is attached. */ TV_INPUT_EVENT_DEVICE_AVAILABLE = 1, /* * Hardware notifies the framework that a device is unavailable. * * HAL implementation should generate this event when a device registered * by TV_INPUT_EVENT_DEVICE_AVAILABLE is no longer available. For example, * the event can indicate that a USB tuner is plugged out from the Android * device. * * Note that this event is not for indicating cable plugged out of the port; * for that purpose, the implementation should use * STREAM_CONFIGURATION_CHANGED event. This event represents the port itself * being no longer available. */ TV_INPUT_EVENT_DEVICE_UNAVAILABLE = 2, /* * Stream configurations are changed. Client should regard all open streams * at the specific device are closed, and should call * get_stream_configurations() again, opening some of them if necessary. * * HAL implementation should generate this event when the available stream * configurations change for any reason. A typical use case of this event * would be to notify the framework that the input signal has changed * resolution, or that the cable is plugged out so that the number of * available streams is 0. * * The implementation may use this event to indicate hotplug status of the * port. the framework regards input devices with no available streams as * disconnected, so the implementation can generate this event with no * available streams to indicate that this device is disconnected, and vice * versa. */ TV_INPUT_EVENT_STREAM_CONFIGURATIONS_CHANGED = 3, /* * Hardware is done with capture request with the buffer. Client can assume * ownership of the buffer again. * * HAL implementation should generate this event after request_capture() if * it succeeded. The event shall have the buffer with the captured image. */ TV_INPUT_EVENT_CAPTURE_SUCCEEDED = 4, /* * Hardware met a failure while processing a capture request or client * canceled the request. Client can assume ownership of the buffer again. * * The event is similar to TV_INPUT_EVENT_CAPTURE_SUCCEEDED, but HAL * implementation generates this event upon a failure to process * request_capture(), or a request cancellation. */ TV_INPUT_EVENT_CAPTURE_FAILED = 5, }; typedef uint32_t tv_input_event_type_t; typedef struct tv_input_capture_result { /* Device ID */ int device_id; /* Stream ID */ int stream_id; /* Sequence number of the request */ uint32_t seq; /* * The buffer passed to hardware in request_capture(). The content of * buffer is undefined (although buffer itself is valid) for * TV_INPUT_CAPTURE_FAILED event. */ buffer_handle_t buffer; /* * Error code for the request. -ECANCELED if request is cancelled; other * error codes are unknown errors. */ int error_code; } tv_input_capture_result_t; typedef struct tv_input_event { tv_input_event_type_t type; union { /* * TV_INPUT_EVENT_DEVICE_AVAILABLE: all fields are relevant * TV_INPUT_EVENT_DEVICE_UNAVAILABLE: only device_id is relevant * TV_INPUT_EVENT_STREAM_CONFIGURATIONS_CHANGED: only device_id is * relevant */ tv_input_device_info_t device_info; /* * TV_INPUT_EVENT_CAPTURE_SUCCEEDED: error_code is not relevant * TV_INPUT_EVENT_CAPTURE_FAILED: all fields are relevant */ tv_input_capture_result_t capture_result; }; } tv_input_event_t; typedef struct tv_input_callback_ops { /* * event contains the type of the event and additional data if necessary. * The event object is guaranteed to be valid only for the duration of the * call. * * data is an object supplied at device initialization, opaque to the * hardware.     */ void (*notify)(struct tv_input_device* dev, tv_input_event_t* event, void* data); } tv_input_callback_ops_t; enum { TV_STREAM_TYPE_INDEPENDENT_VIDEO_SOURCE = 1, TV_STREAM_TYPE_BUFFER_PRODUCER = 2, }; typedef uint32_t tv_stream_type_t; typedef struct tv_stream_config { /* * ID number of the stream. This value is used to identify the whole stream * configuration. */ int stream_id; /* Type of the stream */ tv_stream_type_t type; /* Max width/height of the stream. */ uint32_t max_video_width; uint32_t max_video_height; } tv_stream_config_t; typedef struct buffer_producer_stream { /* * IN/OUT: Width / height of the stream. Client may request for specific * size but hardware may change it. Client must allocate buffers with * specified width and height. */ uint32_t width; uint32_t height; /* OUT: Client must set this usage when allocating buffer. */ uint32_t usage; /* OUT: Client must allocate a buffer with this format. */ uint32_t format; } buffer_producer_stream_t; typedef struct tv_stream { /* IN: ID in the stream configuration */ int stream_id; /* OUT: Type of the stream (for convenience) */ tv_stream_type_t type; /* Data associated with the stream for client's use */ union { /* OUT: A native handle describing the sideband stream source */ native_handle_t* sideband_stream_source_handle; /* IN/OUT: Details are in buffer_producer_stream_t */ buffer_producer_stream_t buffer_producer; }; } tv_stream_t; /* * Every device data structure must begin with hw_device_t * followed by module specific public methods and attributes. */ typedef struct tv_input_device { struct hw_device_t common; /* * initialize: * * Provide callbacks to the device and start operation. At first, no device * is available and after initialize() completes, currently available * devices including static devices should notify via callback. * * Framework owns callbacks object. * * data is a framework-owned object which would be sent back to the * framework for each callback notifications. * * Return 0 on success. */ int (*initialize)(struct tv_input_device* dev, const tv_input_callback_ops_t* callback, void* data); /* * get_stream_configurations: * * Get stream configurations for a specific device. An input device may have * multiple configurations. * * The configs object is guaranteed to be valid only until the next call to * get_stream_configurations() or STREAM_CONFIGURATIONS_CHANGED event. * * Return 0 on success. */ int (*get_stream_configurations)(const struct tv_input_device* dev, int device_id, int* num_configurations, const tv_stream_config_t** configs); /* * open_stream: * * Open a stream with given stream ID. Caller owns stream object, and the * populated data is only valid until the stream is closed. * * Return 0 on success; -EBUSY if the client should close other streams to * open the stream; -EEXIST if the stream with the given ID is already open; * -EINVAL if device_id and/or stream_id are invalid; other non-zero value * denotes unknown error. */ int (*open_stream)(struct tv_input_device* dev, int device_id, tv_stream_t* stream); /* * close_stream: * * Close a stream to a device. data in tv_stream_t* object associated with * the stream_id is obsolete once this call finishes. * * Return 0 on success; -ENOENT if the stream is not open; -EINVAL if * device_id and/or stream_id are invalid. */ int (*close_stream)(struct tv_input_device* dev, int device_id, int stream_id); /* * request_capture: * * Request buffer capture for a stream. This is only valid for buffer * producer streams. The buffer should be created with size, format and * usage specified in the stream. Framework provides seq in an * increasing sequence per each stream. Hardware should provide the picture * in a chronological order according to seq. For example, if two * requests are being processed at the same time, the request with the * smaller seq should get an earlier frame. * * The framework releases the ownership of the buffer upon calling this * function. When the buffer is filled, hardware notifies the framework * via TV_INPUT_EVENT_CAPTURE_FINISHED callback, and the ownership is * transferred back to framework at that time. * * Return 0 on success; -ENOENT if the stream is not open; -EINVAL if * device_id and/or stream_id are invalid; -EWOULDBLOCK if HAL cannot take * additional requests until it releases a buffer. */ int (*request_capture)(struct tv_input_device* dev, int device_id, int stream_id, buffer_handle_t buffer, uint32_t seq); /* * cancel_capture: * * Cancel an ongoing capture. Hardware should release the buffer as soon as * possible via TV_INPUT_EVENT_CAPTURE_FAILED callback. * * Return 0 on success; -ENOENT if the stream is not open; -EINVAL if * device_id, stream_id, and/or seq are invalid. */ int (*cancel_capture)(struct tv_input_device* dev, int device_id, int stream_id, uint32_t seq); void* reserved[16]; } tv_input_device_t; __END_DECLS #endif // ANDROID_TV_INPUT_INTERFACE_H android-headers-23/22/hardware/vibrator.h000066400000000000000000000043751264465411000203660ustar00rootroot00000000000000/* * 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 _HARDWARE_VIBRATOR_H #define _HARDWARE_VIBRATOR_H #include __BEGIN_DECLS #define VIBRATOR_API_VERSION HARDWARE_MODULE_API_VERSION(1,0) /** * The id of this module */ #define VIBRATOR_HARDWARE_MODULE_ID "vibrator" /** * The id of the main vibrator device */ #define VIBRATOR_DEVICE_ID_MAIN "main_vibrator" struct vibrator_device; typedef struct vibrator_device { /** * Common methods of the vibrator device. This *must* be the first member of * vibrator_device as users of this structure will cast a hw_device_t to * vibrator_device pointer in contexts where it's known the hw_device_t references a * vibrator_device. */ struct hw_device_t common; /** Turn on vibrator * * What happens when this function is called while the the timeout of a * previous call has not expired is implementation dependent. * * @param timeout_ms number of milliseconds to vibrate * * @return 0 in case of success, negative errno code else */ int (*vibrator_on)(struct vibrator_device* vibradev, unsigned int timeout_ms); /** Turn off vibrator * * It is not guaranteed that the vibrator will be immediately stopped: the * behaviour is implementation dependent. * * @return 0 in case of success, negative errno code else */ int (*vibrator_off)(struct vibrator_device* vibradev); } vibrator_device_t; 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); } __END_DECLS #endif // _HARDWARE_VIBRATOR_H android-headers-23/22/hardware_legacy/000077500000000000000000000000001264465411000177005ustar00rootroot00000000000000android-headers-23/22/hardware_legacy/audio_policy_conf.h000066400000000000000000000037061264465411000235440ustar00rootroot00000000000000/* * 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_AUDIO_POLICY_CONF_H #define ANDROID_AUDIO_POLICY_CONF_H ///////////////////////////////////////////////// // Definitions for audio policy configuration file (audio_policy.conf) ///////////////////////////////////////////////// #define AUDIO_HARDWARE_MODULE_ID_MAX_LEN 32 #define AUDIO_POLICY_CONFIG_FILE "/system/etc/audio_policy.conf" #define AUDIO_POLICY_VENDOR_CONFIG_FILE "/vendor/etc/audio_policy.conf" // global configuration #define GLOBAL_CONFIG_TAG "global_configuration" #define ATTACHED_OUTPUT_DEVICES_TAG "attached_output_devices" #define DEFAULT_OUTPUT_DEVICE_TAG "default_output_device" #define ATTACHED_INPUT_DEVICES_TAG "attached_input_devices" #define SPEAKER_DRC_ENABLED_TAG "speaker_drc_enabled" // hw modules descriptions #define AUDIO_HW_MODULE_TAG "audio_hw_modules" #define OUTPUTS_TAG "outputs" #define INPUTS_TAG "inputs" #define SAMPLING_RATES_TAG "sampling_rates" #define FORMATS_TAG "formats" #define CHANNELS_TAG "channel_masks" #define DEVICES_TAG "devices" #define FLAGS_TAG "flags" #define DYNAMIC_VALUE_TAG "dynamic" // special value for "channel_masks", "sampling_rates" and // "formats" in outputs descriptors indicating that supported // values should be queried after opening the output. #endif // ANDROID_AUDIO_POLICY_CONF_H android-headers-23/22/hardware_legacy/vibrator.h000066400000000000000000000022321264465411000217000ustar00rootroot00000000000000/* * 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 android-headers-23/22/hardware_legacy/wifi.h000066400000000000000000000077041264465411000210170ustar00rootroot00000000000000/* * 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 _WIFI_H #define _WIFI_H #if __cplusplus extern "C" { #endif /** * Load the Wi-Fi driver. * * @return 0 on success, < 0 on failure. */ int wifi_load_driver(); /** * Unload the Wi-Fi driver. * * @return 0 on success, < 0 on failure. */ int wifi_unload_driver(); /** * Check if the Wi-Fi driver is loaded. * * @return 0 on success, < 0 on failure. */ 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 const char *wifi_get_fw_path(int fw_type); /** * Change the path to firmware for the wlan driver */ int wifi_change_fw_path(const char *fwpath); /** * Check and create if necessary initial entropy file */ #define WIFI_ENTROPY_FILE "/data/misc/wifi/entropy.bin" int ensure_entropy_file_exists(); #if __cplusplus }; // extern "C" #endif #endif // _WIFI_H android-headers-23/22/libnfc-nxp/000077500000000000000000000000001264465411000166175ustar00rootroot00000000000000android-headers-23/22/libnfc-nxp/nfc_custom_config_example.h000066400000000000000000000124361264465411000241760ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/nfc_osal_deferred_call.h000066400000000000000000000021511264465411000234060ustar00rootroot00000000000000#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); #endifandroid-headers-23/22/libnfc-nxp/phDal4Nfc.h000066400000000000000000000630601264465411000205400ustar00rootroot00000000000000/* * 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 android-headers-23/22/libnfc-nxp/phDal4Nfc_messageQueueLib.h000066400000000000000000000026601264465411000236770ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phDbgTrace.h000066400000000000000000000133441264465411000210000ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phDnldNfc.h000066400000000000000000000114311264465411000206300ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phFriNfc.h000066400000000000000000000133601264465411000204720ustar00rootroot00000000000000/* * 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__ */ android-headers-23/22/libnfc-nxp/phFriNfc_DesfireFormat.h000066400000000000000000000253751264465411000233150ustar00rootroot00000000000000/* * 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 android-headers-23/22/libnfc-nxp/phFriNfc_DesfireMap.h000066400000000000000000000344271264465411000226000ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phFriNfc_FelicaMap.h000066400000000000000000000340361264465411000223760ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phFriNfc_ISO15693Format.h000066400000000000000000000111301264465411000227560ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phFriNfc_ISO15693Map.h000066400000000000000000000243771264465411000222640ustar00rootroot00000000000000/* * * 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 */ android-headers-23/22/libnfc-nxp/phFriNfc_IntNdefMap.h000066400000000000000000000072241264465411000225410ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phFriNfc_Llcp.h000066400000000000000000000367111264465411000214510ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phFriNfc_LlcpMac.h000066400000000000000000000210611264465411000220620ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phFriNfc_LlcpMacNfcip.h000066400000000000000000000022321264465411000230410ustar00rootroot00000000000000/* * 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_LlcpMacNfcip.h * \brief NFC LLCP MAC Mapping for NFCIP. * * Project: NFC-FRI * */ #ifndef PHFRINFC_LLCPMACNFCIP_H #define PHFRINFC_LLCPMACNFCIP_H /*include files*/ #include #include #include #include /** * \name MAC Mapping for NFCIP * * File: \ref phFriNfc_LlcpMacNfcip.h * */ /** \defgroup grp_fri_nfc_llcp_macnfcip NFCIP MAC Mapping * * TODO * */ NFCSTATUS phFriNfc_LlcpMac_Nfcip_Register (phFriNfc_LlcpMac_t *LlcpMac); #endif /* PHFRINFC_LLCPMACNFCIP_H */ android-headers-23/22/libnfc-nxp/phFriNfc_LlcpTransport.h000066400000000000000000001155541264465411000233710ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phFriNfc_LlcpTransport_Connection.h000066400000000000000000000415061264465411000255430ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phFriNfc_LlcpTransport_Connectionless.h000066400000000000000000000136471264465411000264370ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phFriNfc_LlcpUtils.h000066400000000000000000000114131264465411000224620ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phFriNfc_MapTools.h000066400000000000000000000061721264465411000223130ustar00rootroot00000000000000/* * 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 android-headers-23/22/libnfc-nxp/phFriNfc_MifStdFormat.h000066400000000000000000000452731264465411000231210ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phFriNfc_MifULFormat.h000066400000000000000000000167131264465411000227040ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phFriNfc_MifareStdMap.h000066400000000000000000000563431264465411000230760ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phFriNfc_MifareULMap.h000066400000000000000000000373411264465411000226610ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phFriNfc_NdefMap.h000066400000000000000000001525511264465411000220720ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phFriNfc_NdefRecord.h000066400000000000000000000665561264465411000226040ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phFriNfc_NdefReg.h000066400000000000000000000543301264465411000220660ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phFriNfc_OvrHal.h000066400000000000000000000373351264465411000217550ustar00rootroot00000000000000/* * 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 android-headers-23/22/libnfc-nxp/phFriNfc_OvrHalCmd.h000066400000000000000000000256351264465411000224010ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phFriNfc_SmtCrdFmt.h000066400000000000000000000446671264465411000224330ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phFriNfc_TopazMap.h000066400000000000000000000754451264465411000223210ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phHal4Nfc.h000066400000000000000000001414511264465411000205450ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phHal4Nfc_Internal.h000066400000000000000000000307131264465411000223770ustar00rootroot00000000000000/* * 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 android-headers-23/22/libnfc-nxp/phHciNfc_AdminMgmt.h000066400000000000000000000167221264465411000224170ustar00rootroot00000000000000/* * 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 android-headers-23/22/libnfc-nxp/phHciNfc_CE_A.h000066400000000000000000000255241264465411000212710ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phHciNfc_CE_B.h000066400000000000000000000252721264465411000212720ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phHciNfc_DevMgmt.h000066400000000000000000000272201264465411000221000ustar00rootroot00000000000000/* * 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 android-headers-23/22/libnfc-nxp/phHciNfc_Emulation.h000066400000000000000000000132771264465411000225010ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phHciNfc_Felica.h000066400000000000000000000251121264465411000217160ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phHciNfc_Generic.h000066400000000000000000001241051264465411000221110ustar00rootroot00000000000000/* * 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 android-headers-23/22/libnfc-nxp/phHciNfc_IDMgmt.h000066400000000000000000000200761264465411000216600ustar00rootroot00000000000000/* * 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 android-headers-23/22/libnfc-nxp/phHciNfc_ISO15693.h000066400000000000000000000237231264465411000216030ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phHciNfc_Jewel.h000066400000000000000000000231221264465411000216000ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phHciNfc_LinkMgmt.h000066400000000000000000000127131264465411000222600ustar00rootroot00000000000000/* * 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 android-headers-23/22/libnfc-nxp/phHciNfc_NfcIPMgmt.h000066400000000000000000000667011264465411000223300ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phHciNfc_Pipe.h000066400000000000000000000231451264465411000214340ustar00rootroot00000000000000/* * 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 android-headers-23/22/libnfc-nxp/phHciNfc_PollingLoop.h000066400000000000000000000173671264465411000230060ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phHciNfc_RFReader.h000066400000000000000000000545371264465411000222020ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phHciNfc_RFReaderA.h000066400000000000000000000345311264465411000222730ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phHciNfc_RFReaderB.h000066400000000000000000000236401264465411000222730ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phHciNfc_SWP.h000066400000000000000000000301461264465411000212070ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phHciNfc_Sequence.h000066400000000000000000000364271264465411000223160ustar00rootroot00000000000000/* * 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 android-headers-23/22/libnfc-nxp/phHciNfc_WI.h000066400000000000000000000211351264465411000210530ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phLibNfc.h000066400000000000000000004736071264465411000204760ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phLibNfcStatus.h000066400000000000000000000050551264465411000216660ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phLibNfc_Internal.h000066400000000000000000000221571264465411000223200ustar00rootroot00000000000000/* * 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 android-headers-23/22/libnfc-nxp/phLibNfc_SE.h000066400000000000000000000047561264465411000210600ustar00rootroot00000000000000/* * 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 android-headers-23/22/libnfc-nxp/phLibNfc_discovery.h000066400000000000000000000017161264465411000225510ustar00rootroot00000000000000/* * 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 * * 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 ); #endif android-headers-23/22/libnfc-nxp/phLibNfc_initiator.h000066400000000000000000000031531264465411000225410ustar00rootroot00000000000000/* * 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 android-headers-23/22/libnfc-nxp/phLibNfc_ioctl.h000066400000000000000000000050111264465411000216440ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phLibNfc_ndef_raw.h000066400000000000000000000045331264465411000223270ustar00rootroot00000000000000/* * 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 android-headers-23/22/libnfc-nxp/phLlcNfc.h000066400000000000000000000131161264465411000204630ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phLlcNfc_DataTypes.h000066400000000000000000000472721264465411000224530ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phLlcNfc_Frame.h000066400000000000000000000360611264465411000216010ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phLlcNfc_Interface.h000066400000000000000000000142661264465411000224520ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phLlcNfc_Timer.h000066400000000000000000000135271264465411000216310ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phNfcCompId.h000066400000000000000000000145551264465411000211340ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phNfcConfig.h000066400000000000000000000314371264465411000211640ustar00rootroot00000000000000/* * 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*/ android-headers-23/22/libnfc-nxp/phNfcHalTypes.h000066400000000000000000001075141264465411000215100ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phNfcInterface.h000066400000000000000000000332641264465411000216570ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phNfcStatus.h000066400000000000000000000301521264465411000212330ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phNfcTypes.h000066400000000000000000001314201264465411000210540ustar00rootroot00000000000000/* * 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 */ android-headers-23/22/libnfc-nxp/phOsalNfc.h000066400000000000000000000146071264465411000206550ustar00rootroot00000000000000/* * 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, /** #else #ifdef __linux__ #include #else #include #endif #endif #endif /* PHOSALNFC_MSG_H */ android-headers-23/22/libnfc-nxp/phOsalNfc_Timer.h000066400000000000000000000164661264465411000220220ustar00rootroot00000000000000/* * 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_Timer.h * \brief Timer Implementation. * * Project: NFC-FRI 1.1 * * $Date: Mon Mar 16 20:30:44 2009 $ * $Author: ing01697 $ * $Revision: 1.19 $ * $Aliases: 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 PHOSALNFC_TIMER_H #define PHOSALNFC_TIMER_H /* -----------------Include files ---------------------------------------*/ #include #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 */ android-headers-23/22/linux/000077500000000000000000000000001264465411000157165ustar00rootroot00000000000000android-headers-23/22/linux/android_alarm.h000066400000000000000000000055421264465411000206710ustar00rootroot00000000000000/**************************************************************************** **************************************************************************** *** *** 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_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, ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP_MASK = /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 1U << ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP, ANDROID_ALARM_ELAPSED_REALTIME_MASK = 1U << ANDROID_ALARM_ELAPSED_REALTIME, ANDROID_ALARM_SYSTEMTIME_MASK = 1U << ANDROID_ALARM_SYSTEMTIME, /* 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 */ android-headers-23/22/linux/binder.h000066400000000000000000000171101264465411000173320ustar00rootroot00000000000000/**************************************************************************** **************************************************************************** *** *** 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 */ } __attribute__((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 android-headers-23/22/linux/sw_sync.h000066400000000000000000000030261264465411000175550ustar00rootroot00000000000000/**************************************************************************** **************************************************************************** *** *** 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_SW_SYNC_H #define _UAPI_LINUX_SW_SYNC_H #include struct sw_sync_create_fence_data { /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ __u32 value; char name[32]; __s32 fence; }; /* 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) #endif /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ android-headers-23/22/linux/sync.h000066400000000000000000000041441264465411000170460ustar00rootroot00000000000000/**************************************************************************** **************************************************************************** *** *** 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 */ android-headers-23/22/log/000077500000000000000000000000001264465411000153405ustar00rootroot00000000000000android-headers-23/22/log/event_tag_map.h000066400000000000000000000024171264465411000203260ustar00rootroot00000000000000/* * 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. */ #ifndef _LIBS_CUTILS_EVENTTAGMAP_H #define _LIBS_CUTILS_EVENTTAGMAP_H #ifdef __cplusplus extern "C" { #endif #define EVENT_TAG_MAP_FILE "/system/etc/event-log-tags" struct EventTagMap; typedef struct EventTagMap EventTagMap; /* * Open the specified file as an event log tag map. * * Returns NULL on failure. */ EventTagMap* android_openEventTagMap(const char* fileName); /* * Close the map. */ 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); #ifdef __cplusplus } #endif #endif /*_LIBS_CUTILS_EVENTTAGMAP_H*/ android-headers-23/22/log/log.h000066400000000000000000000365361264465411000163070ustar00rootroot00000000000000/* * Copyright (C) 2005-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. */ // // 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 #ifdef HAVE_PTHREADS #include #endif #include #include #include #include #include #include #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 * 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 // --------------------------------------------------------------------- /* * 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) #else #define ALOGV(...) __ALOGV(__VA_ARGS__) #endif #endif #define CONDITION(cond) (__builtin_expect((cond)!=0, 0)) #ifndef ALOGV_IF #if LOG_NDEBUG #define ALOGV_IF(cond, ...) ((void)0) #else #define ALOGV_IF(cond, ...) \ ( (CONDITION(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, ...) \ ( (CONDITION(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, ...) \ ( (CONDITION(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, ...) \ ( (CONDITION(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, ...) \ ( (CONDITION(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 // --------------------------------------------------------------------- /* * 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 #define CONDITION(cond) (__builtin_expect((cond)!=0, 0)) #ifndef SLOGV_IF #if LOG_NDEBUG #define SLOGV_IF(cond, ...) ((void)0) #else #define SLOGV_IF(cond, ...) \ ( (CONDITION(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, ...) \ ( (CONDITION(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, ...) \ ( (CONDITION(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__)) #endif #ifndef SLOGW_IF #define SLOGW_IF(cond, ...) \ ( (CONDITION(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__)) #endif #ifndef SLOGE_IF #define SLOGE_IF(cond, ...) \ ( (CONDITION(cond)) \ ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) \ : (void)0 ) #endif // --------------------------------------------------------------------- /* * 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 #define CONDITION(cond) (__builtin_expect((cond)!=0, 0)) #ifndef RLOGV_IF #if LOG_NDEBUG #define RLOGV_IF(cond, ...) ((void)0) #else #define RLOGV_IF(cond, ...) \ ( (CONDITION(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, ...) \ ( (CONDITION(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, ...) \ ( (CONDITION(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, ...) \ ( (CONDITION(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, ...) \ ( (CONDITION(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, ...) \ ( (CONDITION(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__) //#define ALOG_ASSERT(cond) LOG_FATAL_IF(!(cond), "Assertion failed: " #cond) #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 /* * 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. These must match up with the declarations in * java/android/android/util/EventLog.java. */ typedef enum { EVENT_TYPE_INT = 0, EVENT_TYPE_LONG = 1, EVENT_TYPE_STRING = 2, EVENT_TYPE_LIST = 3, } 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_STRING #define LOG_EVENT_STRING(_tag, _value) \ (void) __android_log_bswrite(_tag, _value); #endif /* TODO: something for LIST */ /* * =========================================================================== * * 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. */ #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 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) // TODO: remove these prototypes and their users #define android_testLog(prio, tag) (1) #define android_writevLog(vec,num) do{}while(0) #define android_write1Log(str,len) do{}while (0) #define android_setMinPriority(tag, prio) do{}while(0) //#define android_logToCallback(func) do{}while(0) #define android_logToFile(tag, file) (0) #define android_logToFd(tag, fd) (0) 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_MAX } log_id_t; #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 ; #ifdef __cplusplus } #endif #endif /* _LIBS_LOG_LOG_H */ android-headers-23/22/log/log_read.h000066400000000000000000000104001264465411000172600ustar00rootroot00000000000000/* * Copyright (C) 2013-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 _LIBS_LOG_LOG_READ_H #define _LIBS_LOG_LOG_READ_H #include #include /* struct log_time is a wire-format variant of struct timespec */ #define NS_PER_SEC 1000000000ULL #ifdef __cplusplus // 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); } // 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 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; } uint64_t nsec() const { return static_cast(tv_sec) * NS_PER_SEC + tv_nsec; } 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); } __attribute__((__packed__)); #else typedef struct log_time { uint32_t tv_sec; uint32_t tv_nsec; } __attribute__((__packed__)) log_time; #endif #endif /* define _LIBS_LOG_LOG_READ_H */ android-headers-23/22/log/logd.h000066400000000000000000000025421264465411000164410ustar00rootroot00000000000000/* * 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 */ #include #include #include #include #include #ifdef HAVE_PTHREADS #include #endif #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); #ifdef __cplusplus } #endif #endif /* _LOGD_H */ android-headers-23/22/log/logger.h000066400000000000000000000143461264465411000170000ustar00rootroot00000000000000/* ** ** 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 #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__)); /* * 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 4076 /* * 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_v3 entry; 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); 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 /* * 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 */ android-headers-23/22/log/logprint.h000066400000000000000000000072331264465411000173540ustar00rootroot00000000000000/* * Copyright (C) 2006 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 _LOGPRINT_H #define _LOGPRINT_H #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, } AndroidLogPrintFormat; typedef struct AndroidLogFormat_t AndroidLogFormat; typedef struct AndroidLogEntry_t { time_t tv_sec; long tv_nsec; android_LogPriority priority; int32_t pid; int32_t tid; const char * tag; size_t messageLen; const char * message; } AndroidLogEntry; AndroidLogFormat *android_log_format_new(); void android_log_format_free(AndroidLogFormat *p_format); void android_log_setPrintFormat(AndroidLogFormat *p_format, AndroidLogPrintFormat format); /** * Returns FORMAT_OFF on invalid string */ AndroidLogPrintFormat android_log_formatFromString(const char *s); /** * filterExpression: a single filter expression * eg "AT:d" * * returns 0 on success and -1 on invalid expression * * Assumes single threaded execution * */ int android_log_addFilterRule(AndroidLogFormat *p_format, const char *filterExpression); /** * filterString: a whitespace-separated set of filter expressions * eg "AT:d *:i" * * returns 0 on success and -1 on invalid expression * * Assumes single threaded execution * */ 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); /** * Splits a wire-format buffer into an AndroidLogEntry * entry allocated by caller. Pointers will point directly into buf * * 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); /** * Like android_log_processLogBuffer, but for binary logs. * * 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); /** * Formats a log message into a buffer * * Uses defaultBuffer if it can, otherwise malloc()'s a new buffer * If return value != defaultBuffer, caller must call free() * 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); /** * Either print or do not print log line, based on filter * * Assumes single threaded execution * */ int android_log_printLogLine( AndroidLogFormat *p_format, int fd, const AndroidLogEntry *entry); #ifdef __cplusplus } #endif #endif /*_LOGPRINT_H*/ android-headers-23/22/log/uio.h000066400000000000000000000022031264465411000163020ustar00rootroot00000000000000/* * Copyright (C) 2007-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. */ // // implementation of sys/uio.h for platforms that don't have it (Win32) // #ifndef _LIBS_CUTILS_UIO_H #define _LIBS_CUTILS_UIO_H #ifdef HAVE_SYS_UIO_H #include #else #ifdef __cplusplus extern "C" { #endif #include struct iovec { 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 ); #ifdef __cplusplus } #endif #endif /* !HAVE_SYS_UIO_H */ #endif /* _LIBS_UTILS_UIO_H */ android-headers-23/22/private/000077500000000000000000000000001264465411000162315ustar00rootroot00000000000000android-headers-23/22/private/android_filesystem_config.h000066400000000000000000000312641264465411000236210ustar00rootroot00000000000000/* * 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 used to define the properties of the filesystem ** images generated by build tools (mkbootfs and mkyaffs2image) and ** by the device side of adb. */ #ifndef _ANDROID_FILESYSTEM_CONFIG_H_ #define _ANDROID_FILESYSTEM_CONFIG_H_ #include #include #include #include #ifdef HAVE_ANDROID_OS #include #else #include "android_filesystem_capability.h" #endif /* 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_SHELL 2000 /* adb and debug shell user */ #define AID_CACHE 2001 /* cache access */ #define AID_DIAG 2002 /* access to diagnostic resources */ /* 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_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 /* first app user */ #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 /* offset for uid ranges for each user */ #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 */ #if !defined(EXCLUDE_FS_CONFIG_STRUCTURES) struct android_id_info { const char *name; unsigned aid; }; static const struct android_id_info android_ids[] = { { "root", AID_ROOT, }, { "system", AID_SYSTEM, }, { "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, }, { "shell", AID_SHELL, }, { "cache", AID_CACHE, }, { "diag", AID_DIAG, }, { "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, }, { "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. ** These rules are applied based on "first match", so they ** should start with the most specific path and work their ** way up to the root. */ static const struct fs_path_config android_dirs[] = { { 00770, AID_SYSTEM, AID_CACHE, 0, "cache" }, { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/app" }, { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/app-private" }, { 00771, AID_ROOT, AID_ROOT, 0, "data/dalvik-cache" }, { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/data" }, { 00771, AID_SHELL, AID_SHELL, 0, "data/local/tmp" }, { 00771, AID_SHELL, AID_SHELL, 0, "data/local" }, { 01771, AID_SYSTEM, AID_MISC, 0, "data/misc" }, { 00770, AID_DHCP, AID_DHCP, 0, "data/misc/dhcp" }, { 00771, AID_SHARED_RELRO, AID_SHARED_RELRO, 0, "data/misc/shared_relro" }, { 00775, AID_MEDIA_RW, AID_MEDIA_RW, 0, "data/media" }, { 00775, AID_MEDIA_RW, AID_MEDIA_RW, 0, "data/media/Music" }, { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data" }, { 00750, AID_ROOT, AID_SHELL, 0, "sbin" }, { 00755, AID_ROOT, AID_SHELL, 0, "system/bin" }, { 00755, AID_ROOT, AID_SHELL, 0, "system/vendor" }, { 00755, AID_ROOT, AID_SHELL, 0, "system/xbin" }, { 00755, AID_ROOT, AID_ROOT, 0, "system/etc/ppp" }, { 00755, AID_ROOT, AID_SHELL, 0, "vendor" }, { 00777, AID_ROOT, AID_ROOT, 0, "sdcard" }, { 00755, AID_ROOT, AID_ROOT, 0, 0 }, }; /* Rules for files. ** These rules are applied based on "first match", so they ** should start with the most specific path and work their ** way up to the root. Prefixes ending in * denotes wildcard ** and will allow partial matches. */ static const struct fs_path_config android_files[] = { { 00440, AID_ROOT, AID_SHELL, 0, "system/etc/init.goldfish.rc" }, { 00550, AID_ROOT, AID_SHELL, 0, "system/etc/init.goldfish.sh" }, { 00440, AID_ROOT, AID_SHELL, 0, "system/etc/init.trout.rc" }, { 00550, AID_ROOT, AID_SHELL, 0, "system/etc/init.ril" }, { 00550, AID_ROOT, AID_SHELL, 0, "system/etc/init.testmenu" }, { 00550, AID_DHCP, AID_SHELL, 0, "system/etc/dhcpcd/dhcpcd-run-hooks" }, { 00444, AID_RADIO, AID_AUDIO, 0, "system/etc/AudioPara4.csv" }, { 00555, AID_ROOT, AID_ROOT, 0, "system/etc/ppp/*" }, { 00555, AID_ROOT, AID_ROOT, 0, "system/etc/rc.*" }, { 00644, AID_SYSTEM, AID_SYSTEM, 0, "data/app/*" }, { 00644, AID_MEDIA_RW, AID_MEDIA_RW, 0, "data/media/*" }, { 00644, AID_SYSTEM, AID_SYSTEM, 0, "data/app-private/*" }, { 00644, AID_APP, AID_APP, 0, "data/data/*" }, { 00755, AID_ROOT, AID_ROOT, 0, "system/bin/ping" }, /* the following file is INTENTIONALLY set-gid and not set-uid. * Do not change. */ { 02750, AID_ROOT, AID_INET, 0, "system/bin/netcfg" }, /* the following five files are INTENTIONALLY set-uid, but they * are NOT included on user builds. */ { 04750, AID_ROOT, AID_SHELL, 0, "system/xbin/su" }, { 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/librank" }, { 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/procrank" }, { 06755, AID_ROOT, AID_ROOT, 0, "system/xbin/procmem" }, { 04770, AID_ROOT, AID_RADIO, 0, "system/bin/pppd-ril" }, /* the following files have enhanced capabilities and ARE included in user builds. */ { 00750, AID_ROOT, AID_SHELL, (1 << CAP_SETUID) | (1 << CAP_SETGID), "system/bin/run-as" }, { 00750, AID_ROOT, AID_ROOT, 0, "system/bin/uncrypt" }, { 00750, AID_ROOT, AID_ROOT, 0, "system/bin/install-recovery.sh" }, { 00755, AID_ROOT, AID_SHELL, 0, "system/bin/*" }, { 00755, AID_ROOT, AID_ROOT, 0, "system/lib/valgrind/*" }, { 00755, AID_ROOT, AID_ROOT, 0, "system/lib64/valgrind/*" }, { 00755, AID_ROOT, AID_SHELL, 0, "system/xbin/*" }, { 00755, AID_ROOT, AID_SHELL, 0, "system/vendor/bin/*" }, { 00755, AID_ROOT, AID_SHELL, 0, "vendor/bin/*" }, { 00750, AID_ROOT, AID_SHELL, 0, "sbin/*" }, { 00755, AID_ROOT, AID_ROOT, 0, "bin/*" }, { 00750, AID_ROOT, AID_SHELL, 0, "init*" }, { 00750, AID_ROOT, AID_SHELL, 0, "sbin/fs_mgr" }, { 00640, AID_ROOT, AID_SHELL, 0, "fstab.*" }, { 00644, AID_ROOT, AID_ROOT, 0, 0 }, }; static inline void fs_config(const char *path, int dir, unsigned *uid, unsigned *gid, unsigned *mode, uint64_t *capabilities) { const struct fs_path_config *pc; int plen; if (path[0] == '/') { path++; } pc = dir ? android_dirs : android_files; plen = strlen(path); for(; pc->prefix; pc++){ int len = strlen(pc->prefix); if (dir) { if(plen < len) continue; if(!strncmp(pc->prefix, path, len)) break; continue; } /* If name ends in * then allow partial matches. */ if (pc->prefix[len -1] == '*') { if(!strncmp(pc->prefix, path, len - 1)) break; } else if (plen == len){ if(!strncmp(pc->prefix, path, len)) break; } } *uid = pc->uid; *gid = pc->gid; *mode = (*mode & (~07777)) | pc->mode; *capabilities = pc->capabilities; #if 0 fprintf(stderr,"< '%s' '%s' %d %d %o >\n", path, pc->prefix ? pc->prefix : "", *uid, *gid, *mode); #endif } #endif #endif android-headers-23/22/sync/000077500000000000000000000000001264465411000155335ustar00rootroot00000000000000android-headers-23/22/sync/sync.h000066400000000000000000000026551264465411000166700ustar00rootroot00000000000000/* * sync.h * * Copyright 2012 Google, Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __SYS_CORE_SYNC_H #define __SYS_CORE_SYNC_H #include #include __BEGIN_DECLS // XXX: These structs are copied from the header "linux/sync.h". struct sync_fence_info_data { uint32_t len; char name[32]; int32_t status; uint8_t pt_info[0]; }; struct sync_pt_info { uint32_t len; char obj_name[32]; char driver_name[32]; int32_t status; uint64_t timestamp_ns; uint8_t driver_data[0]; }; /* 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); void sync_fence_info_free(struct sync_fence_info_data *info); __END_DECLS #endif /* __SYS_CORE_SYNC_H */ android-headers-23/22/system/000077500000000000000000000000001264465411000161035ustar00rootroot00000000000000android-headers-23/22/system/audio.h000066400000000000000000001630611264465411000173640ustar00rootroot00000000000000/* * 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_AUDIO_CORE_H #define ANDROID_AUDIO_CORE_H #include #include #include #include #include #include __BEGIN_DECLS /* The enums were moved here mostly from * frameworks/base/include/media/AudioSystem.h */ /* 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_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; /* Do not change these values without updating their counterparts * in frameworks/base/media/java/android/media/AudioAttributes.java */ enum { AUDIO_FLAG_AUDIBILITY_ENFORCED = 0x1, AUDIO_FLAG_SECURE = 0x2, AUDIO_FLAG_SCO = 0x4, AUDIO_FLAG_BEACON = 0x8, AUDIO_FLAG_HW_AV_SYNC = 0x10, AUDIO_FLAG_HW_HOTWORD = 0x20, }; /* 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_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 { audio_content_type_t content_type; audio_usage_t usage; audio_source_t source; audio_flags_mask_t flags; char tags[AUDIO_ATTRIBUTES_TAGS_MAX_SIZE]; /* UTF8 */ } audio_attributes_t; /* special audio session values * (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. */ AUDIO_SESSION_ALLOCATE = 0, } audio_session_t; /* a unique ID allocated by AudioFlinger for use as a audio_io_handle_t or audio_session_t */ typedef int audio_unique_id_t; #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 7.24 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 consists of a main format field (upper 8 bits) and a 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_MAIN_MASK = 0xFF000000UL, 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_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_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_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), // 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_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. * * audio_channel_mask_t is an opaque type and its internal layout should not * be assumed as it may change in the future. * Instead, always use the functions declared in this header to examine. * * These are the current representations: * * AUDIO_CHANNEL_REPRESENTATION_POSITION * is a channel mask representation for position assignment. * Each low-order bit corresponds to the spatial position of a transducer (output), * or interpretation of channel (input). * The user of a channel mask needs to know the context of whether it is for output or input. * The constants AUDIO_CHANNEL_OUT_* or AUDIO_CHANNEL_IN_* apply to the bits portion. * It is not permitted for no bits to be set. * * AUDIO_CHANNEL_REPRESENTATION_INDEX * is a channel mask representation for index assignment. * Each low-order bit corresponds to a selected channel. * There is no platform interpretation of the various bits. * There is no concept of output or input. * It is not permitted for no bits to be set. * * All other representations are reserved for future use. * * Warning: current representation distinguishes between input and output, but this will not the be * case in future revisions of the platform. Wherever there is an ambiguity between input and output * that is currently resolved by checking the channel mask, the implementer should look for ways to * fix it with additional information outside of the mask. */ 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 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); } /* 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) { // The right shift should be sufficient, but also "and" for safety in case mask is not 32 bits return (audio_channel_representation_t) ((channel >> AUDIO_CHANNEL_COUNT_MAX) & ((1 << AUDIO_CHANNEL_REPRESENTATION_LOG2) - 1)); } /* Returns true if the channel mask is valid, * or returns false for AUDIO_CHANNEL_NONE, AUDIO_CHANNEL_INVALID, and other invalid values. * This function is unable to determine whether a channel mask for position assignment * is invalid because an output mask has an invalid output bit set, * or because an input mask has an invalid input bit set. * All other APIs that take a channel mask assume that it is valid. */ static inline bool audio_channel_mask_is_valid(audio_channel_mask_t channel) { uint32_t bits = audio_channel_mask_get_bits(channel); audio_channel_representation_t representation = audio_channel_mask_get_representation(channel); switch (representation) { case AUDIO_CHANNEL_REPRESENTATION_POSITION: case AUDIO_CHANNEL_REPRESENTATION_INDEX: break; default: bits = 0; break; } return bits != 0; } /* Not part of public API */ static inline audio_channel_mask_t audio_channel_mask_from_representation_and_bits( audio_channel_representation_t representation, uint32_t bits) { return (audio_channel_mask_t) ((representation << AUDIO_CHANNEL_COUNT_MAX) | bits); } /* 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. */ enum { 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, AUDIO_IN_ACOUSTICS_AGC_ENABLE = 0x0001, AUDIO_IN_ACOUSTICS_AGC_DISABLE = 0, AUDIO_IN_ACOUSTICS_NS_ENABLE = 0x0002, AUDIO_IN_ACOUSTICS_NS_DISABLE = 0, AUDIO_IN_ACOUSTICS_TX_IIR_ENABLE = 0x0004, 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_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_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_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_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. */ 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_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. */ 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_flags_t; /* 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. */ typedef struct { uint16_t version; // version of the info structure uint16_t size; // total size of the structure including version and size uint32_t sample_rate; // sample rate in Hz audio_channel_mask_t channel_mask; // channel mask audio_format_t format; // audio format audio_stream_type_t stream_type; // stream type uint32_t bit_rate; // bit rate in bits per second int64_t duration_us; // duration in microseconds, -1 if unknown bool has_video; // true if stream is tied to a video stream bool is_streaming; // true if streaming, false if local playback } audio_offload_info_t; #define AUDIO_MAKE_OFFLOAD_INFO_VERSION(maj,min) \ ((((maj) & 0xff) << 8) | ((min) & 0xff)) #define AUDIO_OFFLOAD_INFO_VERSION_0_1 AUDIO_MAKE_OFFLOAD_INFO_VERSION(0, 1) #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 }; /* common audio stream configuration parameters * You should memset() the entire structure to zero before use to * ensure forward compatibility */ struct 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; }; 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 }, frame_count: 0, }; /* audio hw module handle functions or structures referencing a module */ typedef int audio_module_handle_t; /****************************** * Volume control *****************************/ /* 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; /* An audio_gain struct is a representation of a gain stage. * A gain stage is always attached to an audio port. */ struct audio_gain { audio_gain_mode_t mode; /* e.g. AUDIO_GAIN_MODE_JOINT */ audio_channel_mask_t channel_mask; /* channels which gain an be controlled. N/A if AUDIO_GAIN_MODE_CHANNELS is not supported */ int min_value; /* minimum gain value in millibels */ int max_value; /* maximum gain value in millibels */ int default_value; /* default gain value in millibels */ unsigned int step_value; /* gain step in millibels */ unsigned int min_ramp_ms; /* minimum ramp duration in ms */ unsigned int max_ramp_ms; /* maximum ramp duration in ms */ }; /* The gain configuration structure is used to get or set the gain values of a * given port */ struct audio_gain_config { int index; /* index of the corresponding audio_gain in the audio_port gains[] table */ audio_gain_mode_t mode; /* mode requested for this command */ audio_channel_mask_t channel_mask; /* channels which gain value follows. N/A in joint mode */ int values[sizeof(audio_channel_mask_t) * 8]; /* gain values in millibels for each channel ordered from LSb to MSb in channel mask. The number of values is 1 in joint mode or popcount(channel_mask) */ unsigned int ramp_duration_ms; /* ramp duration in ms */ }; /****************************** * Routing control *****************************/ /* Types defined here are used to describe an audio source or sink at internal * framework interfaces (audio policy, patch panel) or at the audio HAL. * Sink and sources are grouped in a concept of “audio port†representing an * 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 /* maximum audio device address length */ #define AUDIO_DEVICE_MAX_ADDRESS_LEN 32 /* extension for audio port configuration structure when the audio port is a * hardware device */ struct audio_port_config_device_ext { audio_module_handle_t hw_module; /* module the device is attached to */ audio_devices_t type; /* device type (e.g AUDIO_DEVICE_OUT_SPEAKER) */ char address[AUDIO_DEVICE_MAX_ADDRESS_LEN]; /* device address. "" if N/A */ }; /* extension for audio port configuration structure when the audio port is a * sub mix */ struct audio_port_config_mix_ext { audio_module_handle_t hw_module; /* module the stream is attached to */ audio_io_handle_t handle; /* I/O handle of the input/output stream */ union { //TODO: change use case for output streams: use strategy and mixer attributes audio_stream_type_t stream; audio_source_t source; } usecase; }; /* extension for audio port configuration structure when the audio port is an * audio session */ 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 { audio_port_handle_t id; /* port unique ID */ audio_port_role_t role; /* sink or source */ audio_port_type_t type; /* device, mix ... */ unsigned int config_mask; /* e.g AUDIO_PORT_CONFIG_ALL */ unsigned int sample_rate; /* sampling rate in Hz */ audio_channel_mask_t channel_mask; /* channel mask if applicable */ audio_format_t format; /* format if applicable */ struct audio_gain_config gain; /* gain to apply if applicable */ union { struct audio_port_config_device_ext device; /* device specific info */ struct audio_port_config_mix_ext mix; /* mix specific info */ struct audio_port_config_session_ext session; /* session specific info */ } ext; }; /* max number of sampling rates in audio port */ #define AUDIO_PORT_MAX_SAMPLING_RATES 16 /* max number of channel masks in audio port */ #define AUDIO_PORT_MAX_CHANNEL_MASKS 16 /* max number of audio formats in audio port */ #define AUDIO_PORT_MAX_FORMATS 16 /* max number of gain controls in audio port */ #define AUDIO_PORT_MAX_GAINS 16 /* extension for audio port structure when the audio port is a hardware device */ struct audio_port_device_ext { audio_module_handle_t hw_module; /* module the device is attached to */ audio_devices_t type; /* device type (e.g AUDIO_DEVICE_OUT_SPEAKER) */ 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 */ audio_io_handle_t handle; /* I/O handle of the input.output stream */ audio_mix_latency_class_t latency_class; /* latency class */ // other attributes: routing strategies }; /* extension for audio port structure when the audio port is an audio session */ struct audio_port_session_ext { audio_session_t session; /* audio session */ }; struct audio_port { audio_port_handle_t id; /* port unique ID */ audio_port_role_t role; /* sink or source */ audio_port_type_t type; /* device, mix ... */ unsigned int num_sample_rates; /* number of sampling rates in following array */ unsigned int sample_rates[AUDIO_PORT_MAX_SAMPLING_RATES]; unsigned int num_channel_masks; /* number of channel masks in following array */ audio_channel_mask_t channel_masks[AUDIO_PORT_MAX_CHANNEL_MASKS]; unsigned int num_formats; /* number of formats in following array */ audio_format_t formats[AUDIO_PORT_MAX_FORMATS]; unsigned int num_gains; /* number of gains in following array */ struct audio_gain gains[AUDIO_PORT_MAX_GAINS]; struct audio_port_config active_config; /* current audio port configuration */ union { struct audio_port_device_ext device; struct audio_port_mix_ext mix; struct audio_port_session_ext session; } ext; }; /* An audio patch represents a connection between one or more source ports and * one or more sink ports. Patches are connected and disconnected by audio policy manager or by * applications via framework APIs. * Each patch is identified by a handle at the interface used to create that patch. For instance, * when a patch is created by the audio HAL, the HAL allocates and returns a handle. * This handle is unique to a given audio HAL hardware module. * 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 int audio_patch_handle_t; #define AUDIO_PATCH_HANDLE_NONE 0 #define AUDIO_PATCH_PORTS_MAX 16 struct audio_patch { audio_patch_handle_t id; /* patch unique ID */ unsigned int num_sources; /* number of sources in following array */ struct audio_port_config sources[AUDIO_PATCH_PORTS_MAX]; unsigned int num_sinks; /* number of sinks in following array */ struct audio_port_config sinks[AUDIO_PATCH_PORTS_MAX]; }; /* a HW synchronization source returned by the audio HAL */ typedef uint32_t audio_hw_sync_t; /* an invalid HW synchronization source indicating an error */ #define AUDIO_HW_SYNC_INVALID 0 static inline bool audio_is_output_device(audio_devices_t device) { if (((device & AUDIO_DEVICE_BIT_IN) == 0) && (popcount(device) == 1) && ((device & ~AUDIO_DEVICE_OUT_ALL) == 0)) return true; else return false; } static inline bool audio_is_input_device(audio_devices_t device) { if ((device & AUDIO_DEVICE_BIT_IN) != 0) { device &= ~AUDIO_DEVICE_BIT_IN; if ((popcount(device) == 1) && ((device & ~AUDIO_DEVICE_IN_ALL) == 0)) return true; } return false; } static inline bool audio_is_output_devices(audio_devices_t device) { return (device & AUDIO_DEVICE_BIT_IN) == 0; } static inline bool audio_is_a2dp_in_device(audio_devices_t device) { if ((device & AUDIO_DEVICE_BIT_IN) != 0) { device &= ~AUDIO_DEVICE_BIT_IN; if ((popcount(device) == 1) && (device & AUDIO_DEVICE_IN_BLUETOOTH_A2DP)) return true; } return false; } static inline bool audio_is_a2dp_out_device(audio_devices_t device) { if ((popcount(device) == 1) && (device & AUDIO_DEVICE_OUT_ALL_A2DP)) return true; else return false; } // Deprecated - use audio_is_a2dp_out_device() instead static inline bool audio_is_a2dp_device(audio_devices_t device) { return audio_is_a2dp_out_device(device); } static inline bool audio_is_bluetooth_sco_device(audio_devices_t device) { if ((device & AUDIO_DEVICE_BIT_IN) == 0) { if ((popcount(device) == 1) && ((device & ~AUDIO_DEVICE_OUT_ALL_SCO) == 0)) return true; } else { device &= ~AUDIO_DEVICE_BIT_IN; if ((popcount(device) == 1) && ((device & ~AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET) == 0)) return true; } return false; } static inline bool audio_is_usb_out_device(audio_devices_t device) { return ((popcount(device) == 1) && (device & AUDIO_DEVICE_OUT_ALL_USB)); } static inline bool audio_is_usb_in_device(audio_devices_t device) { if ((device & AUDIO_DEVICE_BIT_IN) != 0) { device &= ~AUDIO_DEVICE_BIT_IN; if (popcount(device) == 1 && (device & AUDIO_DEVICE_IN_ALL_USB) != 0) return true; } return false; } /* OBSOLETE - use audio_is_usb_out_device() instead. */ static inline bool audio_is_usb_device(audio_devices_t device) { return audio_is_usb_out_device(device); } static inline bool audio_is_remote_submix_device(audio_devices_t device) { if ((device & AUDIO_DEVICE_OUT_REMOTE_SUBMIX) == AUDIO_DEVICE_OUT_REMOTE_SUBMIX || (device & AUDIO_DEVICE_IN_REMOTE_SUBMIX) == AUDIO_DEVICE_IN_REMOTE_SUBMIX) return true; else return false; } /* Returns true if: * representation is valid, and * there is at least one channel bit set which _could_ correspond to an input channel, and * there are no channel bits set which could _not_ correspond to an input channel. * Otherwise returns false. */ static inline bool audio_is_input_channel(audio_channel_mask_t channel) { uint32_t bits = audio_channel_mask_get_bits(channel); switch (audio_channel_mask_get_representation(channel)) { case AUDIO_CHANNEL_REPRESENTATION_POSITION: if (bits & ~AUDIO_CHANNEL_IN_ALL) { bits = 0; } // fall through case AUDIO_CHANNEL_REPRESENTATION_INDEX: return bits != 0; default: return false; } } /* Returns true if: * representation is valid, and * there is at least one channel bit set which _could_ correspond to an output channel, and * there are no channel bits set which could _not_ correspond to an output channel. * Otherwise returns false. */ static inline bool audio_is_output_channel(audio_channel_mask_t channel) { uint32_t bits = audio_channel_mask_get_bits(channel); switch (audio_channel_mask_get_representation(channel)) { case AUDIO_CHANNEL_REPRESENTATION_POSITION: if (bits & ~AUDIO_CHANNEL_OUT_ALL) { bits = 0; } // fall through case AUDIO_CHANNEL_REPRESENTATION_INDEX: return bits != 0; default: return false; } } /* Returns the number of channels from an input channel mask, * used in the context of audio input or recording. * If a channel bit is set which could _not_ correspond to an input channel, * it is excluded from the count. * Returns zero if the representation is invalid. */ static inline uint32_t audio_channel_count_from_in_mask(audio_channel_mask_t channel) { uint32_t bits = audio_channel_mask_get_bits(channel); switch (audio_channel_mask_get_representation(channel)) { case AUDIO_CHANNEL_REPRESENTATION_POSITION: // TODO: We can now merge with from_out_mask and remove anding bits &= AUDIO_CHANNEL_IN_ALL; // fall through case AUDIO_CHANNEL_REPRESENTATION_INDEX: return popcount(bits); default: return 0; } } /* Returns the number of channels from an output channel mask, * used in the context of audio output or playback. * If a channel bit is set which could _not_ correspond to an output channel, * it is excluded from the count. * Returns zero if the representation is invalid. */ static inline uint32_t audio_channel_count_from_out_mask(audio_channel_mask_t channel) { uint32_t bits = audio_channel_mask_get_bits(channel); switch (audio_channel_mask_get_representation(channel)) { case AUDIO_CHANNEL_REPRESENTATION_POSITION: // TODO: We can now merge with from_in_mask and remove anding bits &= AUDIO_CHANNEL_OUT_ALL; // fall through case AUDIO_CHANNEL_REPRESENTATION_INDEX: return popcount(bits); default: return 0; } } /* Derive an output channel mask for position assignment from a channel count. * This is to be used when the content channel mask is unknown. The 1, 2, 4, 5, 6, 7 and 8 channel * cases are mapped to the standard game/home-theater layouts, but note that 4 is mapped to quad, * and not stereo + FC + mono surround. A channel count of 3 is arbitrarily mapped to stereo + FC * for continuity with stereo. * Returns the matching channel mask, * or AUDIO_CHANNEL_NONE if the channel count is zero, * or AUDIO_CHANNEL_INVALID if the channel count exceeds that of the * configurations for which a default output channel mask is defined. */ static inline audio_channel_mask_t audio_channel_out_mask_from_count(uint32_t channel_count) { uint32_t bits; switch (channel_count) { case 0: return AUDIO_CHANNEL_NONE; case 1: bits = AUDIO_CHANNEL_OUT_MONO; break; case 2: bits = AUDIO_CHANNEL_OUT_STEREO; break; case 3: bits = AUDIO_CHANNEL_OUT_STEREO | AUDIO_CHANNEL_OUT_FRONT_CENTER; break; case 4: // 4.0 bits = AUDIO_CHANNEL_OUT_QUAD; break; case 5: // 5.0 bits = AUDIO_CHANNEL_OUT_QUAD | AUDIO_CHANNEL_OUT_FRONT_CENTER; break; case 6: // 5.1 bits = AUDIO_CHANNEL_OUT_5POINT1; break; case 7: // 6.1 bits = AUDIO_CHANNEL_OUT_5POINT1 | AUDIO_CHANNEL_OUT_BACK_CENTER; break; case 8: bits = AUDIO_CHANNEL_OUT_7POINT1; break; default: return AUDIO_CHANNEL_INVALID; } return audio_channel_mask_from_representation_and_bits( AUDIO_CHANNEL_REPRESENTATION_POSITION, bits); } /* Derive an input channel mask for position assignment from a channel count. * Currently handles only mono and stereo. * Returns the matching channel mask, * or AUDIO_CHANNEL_NONE if the channel count is zero, * or AUDIO_CHANNEL_INVALID if the channel count exceeds that of the * configurations for which a default input channel mask is defined. */ static inline audio_channel_mask_t audio_channel_in_mask_from_count(uint32_t channel_count) { uint32_t bits; switch (channel_count) { case 0: return AUDIO_CHANNEL_NONE; case 1: bits = AUDIO_CHANNEL_IN_MONO; break; case 2: bits = AUDIO_CHANNEL_IN_STEREO; break; default: return AUDIO_CHANNEL_INVALID; } return audio_channel_mask_from_representation_and_bits( AUDIO_CHANNEL_REPRESENTATION_POSITION, bits); } /* Derive a channel mask for index assignment from a channel count. * Returns the matching channel mask, * or AUDIO_CHANNEL_NONE if the channel count is zero, * or AUDIO_CHANNEL_INVALID if the channel count exceeds AUDIO_CHANNEL_COUNT_MAX. */ static inline audio_channel_mask_t audio_channel_mask_for_index_assignment_from_count( uint32_t channel_count) { if (channel_count == 0) { return AUDIO_CHANNEL_NONE; } if (channel_count > AUDIO_CHANNEL_COUNT_MAX) { return AUDIO_CHANNEL_INVALID; } uint32_t bits = (1 << channel_count) - 1; return audio_channel_mask_from_representation_and_bits( AUDIO_CHANNEL_REPRESENTATION_INDEX, bits); } static inline bool audio_is_valid_format(audio_format_t format) { switch (format & AUDIO_FORMAT_MAIN_MASK) { case AUDIO_FORMAT_PCM: switch (format) { case AUDIO_FORMAT_PCM_16_BIT: case AUDIO_FORMAT_PCM_8_BIT: case AUDIO_FORMAT_PCM_32_BIT: case AUDIO_FORMAT_PCM_8_24_BIT: case AUDIO_FORMAT_PCM_FLOAT: case AUDIO_FORMAT_PCM_24_BIT_PACKED: return true; default: return false; } /* not reached */ case AUDIO_FORMAT_MP3: case AUDIO_FORMAT_AMR_NB: case AUDIO_FORMAT_AMR_WB: case AUDIO_FORMAT_AAC: case AUDIO_FORMAT_HE_AAC_V1: case AUDIO_FORMAT_HE_AAC_V2: case AUDIO_FORMAT_VORBIS: case AUDIO_FORMAT_OPUS: case AUDIO_FORMAT_AC3: case AUDIO_FORMAT_E_AC3: return true; default: return false; } } static inline bool audio_is_linear_pcm(audio_format_t format) { return ((format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_PCM); } static inline size_t audio_bytes_per_sample(audio_format_t format) { size_t size = 0; switch (format) { case AUDIO_FORMAT_PCM_32_BIT: case AUDIO_FORMAT_PCM_8_24_BIT: size = sizeof(int32_t); break; case AUDIO_FORMAT_PCM_24_BIT_PACKED: size = sizeof(uint8_t) * 3; break; case AUDIO_FORMAT_PCM_16_BIT: size = sizeof(int16_t); break; case AUDIO_FORMAT_PCM_8_BIT: size = sizeof(uint8_t); break; case AUDIO_FORMAT_PCM_FLOAT: size = sizeof(float); break; default: break; } return size; } /* converts device address to string sent to audio HAL via set_parameters */ static char *audio_device_address_to_parameter(audio_devices_t device, const char *address) { const size_t kSize = AUDIO_DEVICE_MAX_ADDRESS_LEN + sizeof("a2dp_sink_address="); char param[kSize]; if (device & AUDIO_DEVICE_OUT_ALL_A2DP) snprintf(param, kSize, "%s=%s", "a2dp_sink_address", address); else if (device & AUDIO_DEVICE_OUT_REMOTE_SUBMIX) snprintf(param, kSize, "%s=%s", "mix", address); else snprintf(param, kSize, "%s", address); return strdup(param); } __END_DECLS #endif // ANDROID_AUDIO_CORE_H android-headers-23/22/system/audio_policy.h000066400000000000000000000057431264465411000207450ustar00rootroot00000000000000/* * 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_AUDIO_POLICY_CORE_H #define ANDROID_AUDIO_POLICY_CORE_H #include #include #include #include __BEGIN_DECLS /* The enums were moved here mostly from * frameworks/base/include/media/AudioSystem.h */ /* device categories used for audio_policy->set_force_use() */ typedef enum { AUDIO_POLICY_FORCE_NONE, AUDIO_POLICY_FORCE_SPEAKER, AUDIO_POLICY_FORCE_HEADPHONES, AUDIO_POLICY_FORCE_BT_SCO, AUDIO_POLICY_FORCE_BT_A2DP, AUDIO_POLICY_FORCE_WIRED_ACCESSORY, AUDIO_POLICY_FORCE_BT_CAR_DOCK, AUDIO_POLICY_FORCE_BT_DESK_DOCK, AUDIO_POLICY_FORCE_ANALOG_DOCK, AUDIO_POLICY_FORCE_DIGITAL_DOCK, 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_CFG_CNT, AUDIO_POLICY_FORCE_CFG_MAX = AUDIO_POLICY_FORCE_CFG_CNT - 1, AUDIO_POLICY_FORCE_DEFAULT = AUDIO_POLICY_FORCE_NONE, } audio_policy_forced_cfg_t; /* usages used for audio_policy->set_force_use() */ typedef enum { AUDIO_POLICY_FORCE_FOR_COMMUNICATION, AUDIO_POLICY_FORCE_FOR_MEDIA, AUDIO_POLICY_FORCE_FOR_RECORD, AUDIO_POLICY_FORCE_FOR_DOCK, AUDIO_POLICY_FORCE_FOR_SYSTEM, AUDIO_POLICY_FORCE_FOR_HDMI_SYSTEM_AUDIO, AUDIO_POLICY_FORCE_USE_CNT, AUDIO_POLICY_FORCE_USE_MAX = AUDIO_POLICY_FORCE_USE_CNT - 1, } audio_policy_force_use_t; /* device connection states used for audio_policy->set_device_connection_state() */ typedef enum { AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE, AUDIO_POLICY_DEVICE_STATE_AVAILABLE, AUDIO_POLICY_DEVICE_STATE_CNT, AUDIO_POLICY_DEVICE_STATE_MAX = AUDIO_POLICY_DEVICE_STATE_CNT - 1, } audio_policy_dev_state_t; typedef enum { /* Used to generate a tone to notify the user of a * notification/alarm/ringtone while they are in a call. */ AUDIO_POLICY_TONE_IN_CALL_NOTIFICATION = 0, AUDIO_POLICY_TONE_CNT, AUDIO_POLICY_TONE_MAX = AUDIO_POLICY_TONE_CNT - 1, } audio_policy_tone_t; static inline bool audio_is_low_visibility(audio_stream_type_t stream) { switch (stream) { case AUDIO_STREAM_SYSTEM: case AUDIO_STREAM_NOTIFICATION: case AUDIO_STREAM_RING: return true; default: return false; } } __END_DECLS #endif // ANDROID_AUDIO_POLICY_CORE_H android-headers-23/22/system/camera.h000066400000000000000000000246121264465411000175110ustar00rootroot00000000000000/* * 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 SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H #define SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H #include #include #include #include #include #include __BEGIN_DECLS /** * A set of bit masks for specifying how the received preview frames are * handled before the previewCallback() call. * * The least significant 3 bits of an "int" value are used for this purpose: * * ..... 0 0 0 * ^ ^ ^ * | | |---------> determine whether the callback is enabled or not * | |-----------> determine whether the callback is one-shot or not * |-------------> determine whether the frame is copied out or not * * WARNING: When a frame is sent directly without copying, it is the frame * receiver's responsiblity to make sure that the frame data won't get * corrupted by subsequent preview frames filled by the camera. This flag is * recommended only when copying out data brings significant performance price * and the handling/processing of the received frame data is always faster than * the preview frame rate so that data corruption won't occur. * * For instance, * 1. 0x00 disables the callback. In this case, copy out and one shot bits * are ignored. * 2. 0x01 enables a callback without copying out the received frames. A * typical use case is the Camcorder application to avoid making costly * frame copies. * 3. 0x05 is enabling a callback with frame copied out repeatedly. A typical * use case is the Camera application. * 4. 0x07 is enabling a callback with frame copied out only once. A typical * use case is the Barcode scanner application. */ enum { CAMERA_FRAME_CALLBACK_FLAG_ENABLE_MASK = 0x01, CAMERA_FRAME_CALLBACK_FLAG_ONE_SHOT_MASK = 0x02, CAMERA_FRAME_CALLBACK_FLAG_COPY_OUT_MASK = 0x04, /** Typical use cases */ CAMERA_FRAME_CALLBACK_FLAG_NOOP = 0x00, CAMERA_FRAME_CALLBACK_FLAG_CAMCORDER = 0x01, CAMERA_FRAME_CALLBACK_FLAG_CAMERA = 0x05, CAMERA_FRAME_CALLBACK_FLAG_BARCODE_SCANNER = 0x07 }; /** msgType in notifyCallback and dataCallback functions */ enum { CAMERA_MSG_ERROR = 0x0001, // notifyCallback CAMERA_MSG_SHUTTER = 0x0002, // notifyCallback CAMERA_MSG_FOCUS = 0x0004, // notifyCallback CAMERA_MSG_ZOOM = 0x0008, // notifyCallback CAMERA_MSG_PREVIEW_FRAME = 0x0010, // dataCallback CAMERA_MSG_VIDEO_FRAME = 0x0020, // data_timestamp_callback CAMERA_MSG_POSTVIEW_FRAME = 0x0040, // dataCallback CAMERA_MSG_RAW_IMAGE = 0x0080, // dataCallback CAMERA_MSG_COMPRESSED_IMAGE = 0x0100, // dataCallback CAMERA_MSG_RAW_IMAGE_NOTIFY = 0x0200, // dataCallback // Preview frame metadata. This can be combined with // CAMERA_MSG_PREVIEW_FRAME in dataCallback. For example, the apps can // request FRAME and METADATA. Or the apps can request only FRAME or only // METADATA. CAMERA_MSG_PREVIEW_METADATA = 0x0400, // dataCallback // Notify on autofocus start and stop. This is useful in continuous // autofocus - FOCUS_MODE_CONTINUOUS_VIDEO and FOCUS_MODE_CONTINUOUS_PICTURE. CAMERA_MSG_FOCUS_MOVE = 0x0800, // notifyCallback CAMERA_MSG_ALL_MSGS = 0xFFFF }; /** cmdType in sendCommand functions */ enum { CAMERA_CMD_START_SMOOTH_ZOOM = 1, CAMERA_CMD_STOP_SMOOTH_ZOOM = 2, /** * Set the clockwise rotation of preview display (setPreviewDisplay) in * degrees. This affects the preview frames and the picture displayed after * snapshot. This method is useful for portrait mode applications. Note * that preview display of front-facing cameras is flipped horizontally * before the rotation, that is, the image is reflected along the central * vertical axis of the camera sensor. So the users can see themselves as * looking into a mirror. * * This does not affect the order of byte array of * CAMERA_MSG_PREVIEW_FRAME, CAMERA_MSG_VIDEO_FRAME, * CAMERA_MSG_POSTVIEW_FRAME, CAMERA_MSG_RAW_IMAGE, or * CAMERA_MSG_COMPRESSED_IMAGE. This is allowed to be set during preview * since API level 14. */ CAMERA_CMD_SET_DISPLAY_ORIENTATION = 3, /** * cmdType to disable/enable shutter sound. In sendCommand passing arg1 = * 0 will disable, while passing arg1 = 1 will enable the shutter sound. */ CAMERA_CMD_ENABLE_SHUTTER_SOUND = 4, /* cmdType to play recording sound */ CAMERA_CMD_PLAY_RECORDING_SOUND = 5, /** * Start the face detection. This should be called after preview is started. * The camera will notify the listener of CAMERA_MSG_FACE and the detected * faces in the preview frame. The detected faces may be the same as the * previous ones. Apps should call CAMERA_CMD_STOP_FACE_DETECTION to stop * the face detection. This method is supported if CameraParameters * KEY_MAX_NUM_HW_DETECTED_FACES or KEY_MAX_NUM_SW_DETECTED_FACES is * bigger than 0. Hardware and software face detection should not be running * at the same time. If the face detection has started, apps should not send * this again. * * In hardware face detection mode, CameraParameters KEY_WHITE_BALANCE, * KEY_FOCUS_AREAS and KEY_METERING_AREAS have no effect. * * arg1 is the face detection type. It can be CAMERA_FACE_DETECTION_HW or * CAMERA_FACE_DETECTION_SW. If the type of face detection requested is not * supported, the HAL must return BAD_VALUE. */ CAMERA_CMD_START_FACE_DETECTION = 6, /** * Stop the face detection. */ CAMERA_CMD_STOP_FACE_DETECTION = 7, /** * Enable/disable focus move callback (CAMERA_MSG_FOCUS_MOVE). Passing * arg1 = 0 will disable, while passing arg1 = 1 will enable the callback. */ CAMERA_CMD_ENABLE_FOCUS_MOVE_MSG = 8, /** * Ping camera service to see if camera hardware is released. * * When any camera method returns error, the client can use ping command * to see if the camera has been taken away by other clients. If the result * is NO_ERROR, it means the camera hardware is not released. If the result * is not NO_ERROR, the camera has been released and the existing client * can silently finish itself or show a dialog. */ CAMERA_CMD_PING = 9, /** * Configure the number of video buffers used for recording. The intended * video buffer count for recording is passed as arg1, which must be * greater than 0. This command must be sent before recording is started. * This command returns INVALID_OPERATION error if it is sent after video * recording is started, or the command is not supported at all. This * command also returns a BAD_VALUE error if the intended video buffer * count is non-positive or too big to be realized. */ CAMERA_CMD_SET_VIDEO_BUFFER_COUNT = 10, }; /** camera fatal errors */ enum { CAMERA_ERROR_UNKNOWN = 1, /** * Camera was released because another client has connected to the camera. * The original 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_RELEASED = 2, CAMERA_ERROR_SERVER_DIED = 100 }; enum { /** The facing of the camera is opposite to that of the screen. */ CAMERA_FACING_BACK = 0, /** The facing of the camera is the same as that of the screen. */ CAMERA_FACING_FRONT = 1 }; enum { /** Hardware face detection. It does not use much CPU. */ CAMERA_FACE_DETECTION_HW = 0, /** * Software face detection. It uses some CPU. Applications must use * Camera.setPreviewTexture for preview in this mode. */ CAMERA_FACE_DETECTION_SW = 1 }; /** * The information of a face from camera face detection. */ typedef struct camera_face { /** * Bounds of the face [left, top, right, bottom]. (-1000, -1000) represents * the top-left of the camera field of view, and (1000, 1000) represents the * bottom-right of the field of view. The width and height cannot be 0 or * negative. This is supported by both hardware and software face detection. * * The direction is relative to the sensor orientation, that is, what the * sensor sees. The direction is not affected by the rotation or mirroring * of CAMERA_CMD_SET_DISPLAY_ORIENTATION. */ int32_t rect[4]; /** * The confidence level of the face. The range is 1 to 100. 100 is the * highest confidence. This is supported by both hardware and software * face detection. */ int32_t score; /** * An unique id per face while the face is visible to the tracker. If * the face leaves the field-of-view and comes back, it will get a new * id. If the value is 0, id is not supported. */ int32_t id; /** * The coordinates of the center of the left eye. The range is -1000 to * 1000. -2000, -2000 if this is not supported. */ int32_t left_eye[2]; /** * The coordinates of the center of the right eye. The range is -1000 to * 1000. -2000, -2000 if this is not supported. */ int32_t right_eye[2]; /** * The coordinates of the center of the mouth. The range is -1000 to 1000. * -2000, -2000 if this is not supported. */ int32_t mouth[2]; } camera_face_t; /** * The metadata of the frame data. */ typedef struct camera_frame_metadata { /** * The number of detected faces in the frame. */ int32_t number_of_faces; /** * An array of the detected faces. The length is number_of_faces. */ camera_face_t *faces; } camera_frame_metadata_t; __END_DECLS #endif /* SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H */ android-headers-23/22/system/graphics.h000066400000000000000000000434241264465411000200630ustar00rootroot00000000000000/* * 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 SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H #define SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H #include #ifdef __cplusplus extern "C" { #endif /* * If the HAL needs to create service threads to handle graphics related * tasks, these threads need to run at HAL_PRIORITY_URGENT_DISPLAY priority * if they can block the main rendering thread in any way. * * the priority of the current thread can be set with: * * #include * setpriority(PRIO_PROCESS, 0, HAL_PRIORITY_URGENT_DISPLAY); * */ #define HAL_PRIORITY_URGENT_DISPLAY (-8) /** * pixel format definitions */ enum { /* * "linear" color pixel formats: * * The pixel formats below contain sRGB data but are otherwise treated * as linear formats, i.e.: no special operation is 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, /* * sRGB color pixel formats: * * The red, green and blue components are stored in sRGB space, and converted * to linear space when read, using the standard sRGB to linear equation: * * Clinear = Csrgb / 12.92 for Csrgb <= 0.04045 * = (Csrgb + 0.055 / 1.055)^2.4 for Csrgb > 0.04045 * * When written the inverse transformation is performed: * * Csrgb = 12.92 * Clinear for Clinear <= 0.0031308 * = 1.055 * Clinear^(1/2.4) - 0.055 for Clinear > 0.0031308 * * * The alpha component, if present, is always stored in linear space and * is left unmodified when read or written. * */ HAL_PIXEL_FORMAT_sRGB_A_8888 = 0xC, HAL_PIXEL_FORMAT_sRGB_X_8888 = 0xD, /* * 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 * */ 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 * */ 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 * */ HAL_PIXEL_FORMAT_Y16 = 0x20363159, /* * Android RAW sensor format: * * This format is exposed outside of the camera HAL to applications. * * RAW_SENSOR 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 */ HAL_PIXEL_FORMAT_RAW16 = 0x20, HAL_PIXEL_FORMAT_RAW_SENSOR = 0x20, // TODO(rubenbrunk): Remove RAW_SENSOR. /* * 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 */ HAL_PIXEL_FORMAT_RAW10 = 0x25, /* * 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 */ 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. */ 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). * */ HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED = 0x22, /* * Android flexible YCbCr formats * * This format allows platforms to use an efficient YCbCr/YCrCb buffer * layout, while still describing the buffer layout in a way accessible to * the CPU in a device-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_HW_CAMERA_WRITE and 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. */ HAL_PIXEL_FORMAT_YCbCr_420_888 = 0x23, /* 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 }; /* * Structure for describing YCbCr formats for consumption by applications. * This is used with HAL_PIXEL_FORMAT_YCbCr_*_888. * * Buffer chroma subsampling is defined in the format. * e.g. HAL_PIXEL_FORMAT_YCbCr_420_888 has subsampling 4:2:0. * * Buffers must have a 8 bit depth. * * @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. * * @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. */ struct android_ycbcr { void *y; void *cb; void *cr; size_t ystride; size_t cstride; size_t chroma_step; /** reserved for future use, set to 0 by gralloc's (*lock_ycbcr)() */ uint32_t reserved[8]; }; /** * Transformation definitions * * IMPORTANT NOTE: * HAL_TRANSFORM_ROT_90 is applied CLOCKWISE and AFTER HAL_TRANSFORM_FLIP_{H|V}. * */ enum { /* 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, }; /** * Colorspace Definitions * ====================== * * Colorspace is the definition of how pixel values should be interpreted. * It includes primaries (including white point) and the transfer * characteristic function, which describes both gamma curve and numeric * range (within the bit depth). */ enum { /* * Arbitrary colorspace with manually defined characteristics. * Colorspace definition 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_COLORSPACE_ARBITRARY = 0x1, /* * 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 * * Transfer characteristic curve: * E = 1.099 * L ^ 0.45 - 0.099, 1.00 >= L >= 0.018 * E = 4.500 L, 0.018 > L >= 0 * L - luminance of image 0 <= L <= 1 for conventional colorimetry * E - corresponding electrical signal * * Primaries: x y * green 0.290 0.600 * blue 0.150 0.060 * red 0.640 0.330 * white (D65) 0.3127 0.3290 */ HAL_COLORSPACE_JFIF = 0x101, /* * ITU-R Recommendation 601 (BT.601) - 625-line * * Standard-definition television, 625 Lines (PAL) * * 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 * * Transfer characteristic curve: * E = 1.099 * L ^ 0.45 - 0.099, 1.00 >= L >= 0.018 * E = 4.500 L, 0.018 > L >= 0 * L - luminance of image 0 <= L <= 1 for conventional colorimetry * E - corresponding electrical signal * * Primaries: x y * green 0.290 0.600 * blue 0.150 0.060 * red 0.640 0.330 * white (D65) 0.3127 0.3290 */ HAL_COLORSPACE_BT601_625 = 0x102, /* * ITU-R Recommendation 601 (BT.601) - 525-line * * Standard-definition television, 525 Lines (NTSC) * * 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 * * Transfer characteristic curve: * E = 1.099 * L ^ 0.45 - 0.099, 1.00 >= L >= 0.018 * E = 4.500 L, 0.018 > L >= 0 * L - luminance of image 0 <= L <= 1 for conventional colorimetry * E - corresponding electrical signal * * Primaries: x y * green 0.310 0.595 * blue 0.155 0.070 * red 0.630 0.340 * white (D65) 0.3127 0.3290 */ HAL_COLORSPACE_BT601_525 = 0x103, /* * ITU-R Recommendation 709 (BT.709) * * High-definition television * * 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 * * Primaries: x y * green 0.300 0.600 * blue 0.150 0.060 * red 0.640 0.330 * white (D65) 0.3127 0.3290 */ HAL_COLORSPACE_BT709 = 0x104, }; #ifdef __cplusplus } #endif #endif /* SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H */ android-headers-23/22/system/sound_trigger.h000066400000000000000000000272561264465411000211430ustar00rootroot00000000000000/* * 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_SOUND_TRIGGER_H #define ANDROID_SOUND_TRIGGER_H #include #include #define SOUND_TRIGGER_MAX_STRING_LEN 64 /* max length of strings in properties or descriptor structs */ #define SOUND_TRIGGER_MAX_LOCALE_LEN 6 /* max length of locale string. e.g en_US */ #define SOUND_TRIGGER_MAX_USERS 10 /* max number of concurrent users */ #define SOUND_TRIGGER_MAX_PHRASES 10 /* max number of concurrent phrases */ typedef enum { SOUND_TRIGGER_STATE_NO_INIT = -1, /* The sound trigger service is not initialized */ SOUND_TRIGGER_STATE_ENABLED = 0, /* The sound trigger service is enabled */ SOUND_TRIGGER_STATE_DISABLED = 1 /* The sound trigger service is disabled */ } sound_trigger_service_state_t; #define RECOGNITION_MODE_VOICE_TRIGGER 0x1 /* simple voice trigger */ #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_STATUS_SUCCESS 0 #define RECOGNITION_STATUS_ABORT 1 #define RECOGNITION_STATUS_FAILURE 2 #define SOUND_MODEL_STATUS_UPDATED 0 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_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; /* * sound trigger implementation descriptor read by the framework via get_properties(). * Used by SoundTrigger service to report to applications and manage concurrency and policy. */ struct sound_trigger_properties { char implementor[SOUND_TRIGGER_MAX_STRING_LEN]; /* implementor name */ char description[SOUND_TRIGGER_MAX_STRING_LEN]; /* implementation description */ unsigned int version; /* implementation version */ sound_trigger_uuid_t uuid; /* unique implementation ID. Must change with version each version */ unsigned int max_sound_models; /* maximum number of concurrent sound models loaded */ unsigned int max_key_phrases; /* maximum number of key phrases */ unsigned int max_users; /* maximum number of concurrent users detected */ unsigned int recognition_modes; /* all supported modes. e.g RECOGNITION_MODE_VOICE_TRIGGER */ bool capture_transition; /* supports seamless transition from detection to capture */ unsigned int max_buffer_ms; /* maximum buffering capacity in ms if capture_transition is true*/ bool concurrent_capture; /* supports capture by other use cases while detection is active */ bool trigger_in_event; /* returns the trigger capture in event */ unsigned int power_consumption_mw; /* Rated power consumption when detection is active with TDB silence/sound/speech ratio */ }; typedef int sound_trigger_module_handle_t; struct sound_trigger_module_descriptor { sound_trigger_module_handle_t handle; struct sound_trigger_properties properties; }; typedef int sound_model_handle_t; /* * Generic 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 */ struct sound_trigger_sound_model { sound_trigger_sound_model_type_t type; /* model type. e.g. SOUND_MODEL_TYPE_KEYPHRASE */ sound_trigger_uuid_t uuid; /* unique sound model ID. */ sound_trigger_uuid_t vendor_uuid; /* unique vendor ID. Identifies the engine the sound model was build for */ unsigned int data_size; /* size of opaque model data */ unsigned int data_offset; /* offset of opaque data start from head of struct (e.g sizeof struct sound_trigger_sound_model) */ }; /* key phrase descriptor */ struct sound_trigger_phrase { unsigned int id; /* keyphrase ID */ unsigned int recognition_mode; /* recognition modes supported by this key phrase */ unsigned int num_users; /* number of users in the key phrase */ unsigned int users[SOUND_TRIGGER_MAX_USERS]; /* users ids: (not uid_t but sound trigger specific IDs */ char locale[SOUND_TRIGGER_MAX_LOCALE_LEN]; /* locale - JAVA Locale style (e.g. en_US) */ char text[SOUND_TRIGGER_MAX_STRING_LEN]; /* phrase text in UTF-8 format. */ }; /* * Specialized sound model for key phrase detection. * Proprietary representation of key phrases in binary data must match information indicated * by phrases field */ struct sound_trigger_phrase_sound_model { struct sound_trigger_sound_model common; unsigned int num_phrases; /* number of key phrases in model */ struct sound_trigger_phrase phrases[SOUND_TRIGGER_MAX_PHRASES]; }; /* * Generic recognition event sent via recognition callback */ struct 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. e.g. SOUND_MODEL_TYPE_KEYPHRASE */ sound_model_handle_t model; /* loaded sound model that triggered the event */ bool capture_available; /* it is possible to capture audio from this utterance buffered by the implementation */ int capture_session; /* audio session ID. framework use */ int capture_delay_ms; /* delay in ms between end of model detection and start of audio available for capture. A negative value is possible (e.g. if key phrase is also available for capture */ int capture_preamble_ms; /* duration in ms of audio captured before the start of the trigger. 0 if none. */ bool trigger_in_data; /* the opaque data is the capture of the trigger sound */ audio_config_t audio_config; /* audio format of either the trigger in event data or to use for capture of the rest of the utterance */ unsigned int data_size; /* size of opaque event data */ unsigned int data_offset; /* offset of opaque data start from start of this struct (e.g sizeof struct sound_trigger_phrase_recognition_event) */ }; /* * Confidence level for each user in struct sound_trigger_phrase_recognition_extra */ struct sound_trigger_confidence_level { unsigned int user_id; /* user ID */ unsigned int level; /* confidence level in percent (0 - 100). - min level for recognition configuration - detected level for recognition event */ }; /* * Specialized recognition event for key phrase detection */ struct sound_trigger_phrase_recognition_extra { unsigned int id; /* keyphrase ID */ unsigned int recognition_modes; /* recognition modes used for this keyphrase */ unsigned int confidence_level; /* confidence level for mode RECOGNITION_MODE_VOICE_TRIGGER */ unsigned int num_levels; /* number of user confidence levels */ struct sound_trigger_confidence_level levels[SOUND_TRIGGER_MAX_USERS]; }; struct sound_trigger_phrase_recognition_event { struct sound_trigger_recognition_event common; unsigned int num_phrases; struct sound_trigger_phrase_recognition_extra phrase_extras[SOUND_TRIGGER_MAX_PHRASES]; }; /* * configuration for sound trigger capture session passed to start_recognition() */ struct sound_trigger_recognition_config { audio_io_handle_t capture_handle; /* IO handle that will be used for capture. N/A if capture_requested is false */ audio_devices_t capture_device; /* input device requested for detection capture */ bool capture_requested; /* capture and buffer audio for this recognition instance */ unsigned int num_phrases; /* number of key phrases recognition extras */ struct sound_trigger_phrase_recognition_extra phrases[SOUND_TRIGGER_MAX_PHRASES]; /* configuration for each key phrase */ unsigned int data_size; /* size of opaque capture configuration data */ unsigned int data_offset; /* offset of opaque data start from start of this struct (e.g sizeof struct sound_trigger_recognition_config) */ }; /* * Event sent via load sound model callback */ struct sound_trigger_model_event { int status; /* sound model status e.g. SOUND_MODEL_STATUS_UPDATED */ sound_model_handle_t model; /* loaded sound model that triggered the event */ unsigned int data_size; /* size of event data if any. Size of updated sound model if status is SOUND_MODEL_STATUS_UPDATED */ unsigned int data_offset; /* offset of data start from start of this struct (e.g sizeof struct sound_trigger_model_event) */ }; #endif // ANDROID_SOUND_TRIGGER_H android-headers-23/22/system/thread_defs.h000066400000000000000000000050631264465411000205300ustar00rootroot00000000000000/* * 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_THREAD_DEFS_H #define ANDROID_THREAD_DEFS_H #include "graphics.h" #if defined(__cplusplus) extern "C" { #endif enum { /* * *********************************************** * ** Keep in sync with android.os.Process.java ** * *********************************************** * * This maps directly to the "nice" priorities we use in Android. * A thread priority should be chosen inverse-proportionally to * the amount of work the thread is expected to do. The more work * a thread will do, the less favorable priority it should get so that * it doesn't starve the system. Threads not behaving properly might * be "punished" by the kernel. * Use the levels below when appropriate. Intermediate values are * acceptable, preferably use the {MORE|LESS}_FAVORABLE constants below. */ ANDROID_PRIORITY_LOWEST = 19, /* use for background tasks */ ANDROID_PRIORITY_BACKGROUND = 10, /* most threads run at normal priority */ ANDROID_PRIORITY_NORMAL = 0, /* threads currently running a UI that the user is interacting with */ ANDROID_PRIORITY_FOREGROUND = -2, /* the main UI thread has a slightly more favorable priority */ ANDROID_PRIORITY_DISPLAY = -4, /* ui service treads might want to run at a urgent display (uncommon) */ ANDROID_PRIORITY_URGENT_DISPLAY = HAL_PRIORITY_URGENT_DISPLAY, /* all normal audio threads */ ANDROID_PRIORITY_AUDIO = -16, /* service audio threads (uncommon) */ ANDROID_PRIORITY_URGENT_AUDIO = -19, /* should never be used in practice. regular process might not * be allowed to use this level */ ANDROID_PRIORITY_HIGHEST = -20, ANDROID_PRIORITY_DEFAULT = ANDROID_PRIORITY_NORMAL, ANDROID_PRIORITY_MORE_FAVORABLE = -1, ANDROID_PRIORITY_LESS_FAVORABLE = +1, }; #if defined(__cplusplus) } #endif #endif /* ANDROID_THREAD_DEFS_H */ android-headers-23/22/system/window.h000066400000000000000000001051541264465411000175710ustar00rootroot00000000000000/* * 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 SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H #define SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H #include #include #include #include #include #include #include #include #ifndef __UNUSED #define __UNUSED __attribute__((__unused__)) #endif #ifndef __deprecated #define __deprecated __attribute__((__deprecated__)) #endif __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; // --------------------------------------------------------------------------- /* attributes queriable with query() */ enum { NATIVE_WINDOW_WIDTH = 0, 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, /* Check whether queueBuffer operations on the ANativeWindow send the buffer * to the window compositor. The query sets the returned 'value' argument * to 1 if the ANativeWindow DOES send queued buffers directly to the window * compositor and 0 if the buffers do not go directly to the window * compositor. * * This can be used to determine whether protected buffer content should be * sent to the ANativeWindow. Note, however, that a result of 1 does NOT * indicate that queued buffers will be protected from applications or users * capturing their contents. If that behavior is desired then some other * mechanism (e.g. the GRALLOC_USAGE_PROTECTED flag) should be used in * conjunction with this query. */ NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER = 4, /* Get the concrete type of a ANativeWindow. See below for the list of * possible return values. * * This query should not be used outside the Android framework and will * likely be removed in the near future. */ NATIVE_WINDOW_CONCRETE_TYPE = 5, /* * Default width and height of ANativeWindow buffers, these are the * dimensions of the window buffers irrespective of the * 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, /* * 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, /* * Boolean that indicates whether the consumer is running more than * one buffer behind the producer. */ NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND = 9, /* * 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, /** * Transformation that will by applied to buffers by the hwcomposer. * This must not be set or checked by producer endpoints, and will * disable the transform hint set in SurfaceFlinger (see * NATIVE_WINDOW_TRANSFORM_HINT). * * INTENDED USE: * Temporary - Please do not use this. This is intended only to be used * by the camera's LEGACY mode. * * In situations where a SurfaceFlinger client wishes to set a transform * that is not visible to the producer, and will always be applied in the * hardware composer, the client can set this flag with * native_window_set_buffers_sticky_transform. This can be used to rotate * and flip buffers consumed by hardware composer without actually changing * the aspect ratio of the buffers produced. */ NATIVE_WINDOW_STICKY_TRANSFORM = 11, }; /* Valid operations for the (*perform)() hook. * * Values marked as 'deprecated' are supported, but have been superceded by * other functionality. * * Values marked as 'private' should be considered private to the framework. * HAL implementation code with access to an ANativeWindow should not use these, * as it may not interact properly with the framework's use of the * 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, }; /* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */ enum { /* Buffers will be queued by EGL via eglSwapBuffers after being filled using * OpenGL ES. */ NATIVE_WINDOW_API_EGL = 1, /* Buffers will be queued after being filled using the CPU */ NATIVE_WINDOW_API_CPU = 2, /* Buffers will be queued by Stagefright after being filled by a video * decoder. The video decoder can either be a software or hardware decoder. */ NATIVE_WINDOW_API_MEDIA = 3, /* Buffers will be queued by the the camera HAL. */ NATIVE_WINDOW_API_CAMERA = 4, }; /* parameter for NATIVE_WINDOW_SET_BUFFERS_TRANSFORM */ enum { /* flip source image horizontally */ NATIVE_WINDOW_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H , /* flip source image vertically */ NATIVE_WINDOW_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V, /* rotate source image 90 degrees clock-wise, and is applied after TRANSFORM_FLIP_{H|V} */ NATIVE_WINDOW_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90, /* rotate source image 180 degrees */ NATIVE_WINDOW_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180, /* rotate source image 270 degrees clock-wise */ NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270, /* transforms source by the inverse transform of the screen it is displayed onto. This * transform is applied last */ NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY = 0x08 }; /* parameter for NATIVE_WINDOW_SET_SCALING_MODE */ enum { /* the window content is not updated (frozen) until a buffer of * the window size is received (enqueued) */ NATIVE_WINDOW_SCALING_MODE_FREEZE = 0, /* the buffer is scaled in both dimensions to match the window size */ NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW = 1, /* the buffer is scaled uniformly such that the smaller dimension * of the buffer matches the window size (cropping in the process) */ NATIVE_WINDOW_SCALING_MODE_SCALE_CROP = 2, /* the window is clipped to the size of the buffer's crop rectangle; pixels * outside the crop rectangle are treated as if they are completely * transparent. */ NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP = 3, }; /* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */ enum { NATIVE_WINDOW_FRAMEBUFFER = 0, /* FramebufferNativeWindow */ NATIVE_WINDOW_SURFACE = 1, /* Surface */ }; /* parameter for NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP * * Special timestamp value to indicate that timestamps should be auto-generated * by the native window when queueBuffer is called. This is equal to INT64_MIN, * defined directly to avoid problems with C99/C++ inclusion of stdint.h. */ static const int64_t NATIVE_WINDOW_TIMESTAMP_AUTO = (-9223372036854775807LL-1); struct ANativeWindow { #ifdef __cplusplus ANativeWindow() : flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0) { common.magic = ANDROID_NATIVE_WINDOW_MAGIC; common.version = sizeof(ANativeWindow); memset(common.reserved, 0, sizeof(common.reserved)); } /* Implement the methods that sp expects so that it can be used to automatically refcount ANativeWindow'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; /* flags describing some attributes of this surface or its updater */ const uint32_t flags; /* min swap interval supported by this updated */ const int minSwapInterval; /* max swap interval supported by this updated */ const int maxSwapInterval; /* horizontal and vertical resolution in DPI */ const float xdpi; const float ydpi; /* Some storage reserved for the OEM's driver. */ intptr_t oem[4]; /* * Set the swap interval for this surface. * * Returns 0 on success or -errno on error. */ int (*setSwapInterval)(struct ANativeWindow* window, int interval); /* * Hook called by EGL to acquire a buffer. After this call, the buffer * is not locked, so its content cannot be modified. 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. * * Returns 0 on success or -errno on error. * * XXX: This function is deprecated. It will continue to work for some * time for binary compatibility, but the new dequeueBuffer function that * outputs a fence file descriptor should be used in its place. */ int (*dequeueBuffer_DEPRECATED)(struct ANativeWindow* window, struct ANativeWindowBuffer** buffer); /* * hook called by EGL to lock a buffer. This MUST be called before modifying * the content of a buffer. The buffer must have been acquired with * dequeueBuffer first. * * Returns 0 on success or -errno on error. * * XXX: This function is deprecated. It will continue to work for some * time for binary compatibility, but it is essentially a no-op, and calls * to it should be removed. */ int (*lockBuffer_DEPRECATED)(struct ANativeWindow* window, struct ANativeWindowBuffer* buffer); /* * 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. * * Buffers MUST be queued in the same order than they were dequeued. * * Returns 0 on success or -errno on error. * * XXX: This function is deprecated. It will continue to work for some * time for binary compatibility, but the new queueBuffer function that * takes a fence file descriptor should be used in its place (pass a value * of -1 for the fence file descriptor if there is no valid one to pass). */ int (*queueBuffer_DEPRECATED)(struct ANativeWindow* window, struct ANativeWindowBuffer* buffer); /* * hook used to retrieve information about the native window. * * Returns 0 on success or -errno on error. */ int (*query)(const struct ANativeWindow* window, int what, int* value); /* * hook used to perform various operations on the surface. * (*perform)() is a generic mechanism to add functionality to * ANativeWindow while keeping backward binary compatibility. * * DO NOT CALL THIS HOOK DIRECTLY. Instead, use the helper functions * defined below. * * (*perform)() returns -ENOENT if the 'what' parameter is not supported * by the surface's implementation. * * The valid operations are: * NATIVE_WINDOW_SET_USAGE * NATIVE_WINDOW_CONNECT (deprecated) * NATIVE_WINDOW_DISCONNECT (deprecated) * NATIVE_WINDOW_SET_CROP (private) * NATIVE_WINDOW_SET_BUFFER_COUNT * NATIVE_WINDOW_SET_BUFFERS_GEOMETRY (deprecated) * NATIVE_WINDOW_SET_BUFFERS_TRANSFORM * NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP * NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS * NATIVE_WINDOW_SET_BUFFERS_FORMAT * NATIVE_WINDOW_SET_SCALING_MODE (private) * NATIVE_WINDOW_LOCK (private) * NATIVE_WINDOW_UNLOCK_AND_POST (private) * NATIVE_WINDOW_API_CONNECT (private) * NATIVE_WINDOW_API_DISCONNECT (private) * NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS (private) * NATIVE_WINDOW_SET_POST_TRANSFORM_CROP (private) * */ int (*perform)(struct ANativeWindow* window, int operation, ... ); /* * 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. * * XXX: This function is deprecated. It will continue to work for some * time for binary compatibility, but the new cancelBuffer function that * takes a fence file descriptor should be used in its place (pass a value * of -1 for the fence file descriptor if there is no valid one to pass). */ int (*cancelBuffer_DEPRECATED)(struct ANativeWindow* window, struct ANativeWindowBuffer* buffer); /* * 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 (*dequeueBuffer)(struct ANativeWindow* window, struct 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 (*queueBuffer)(struct ANativeWindow* window, struct 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 (*cancelBuffer)(struct ANativeWindow* window, struct ANativeWindowBuffer* buffer, int fenceFd); }; /* 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) * 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. * 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); } /* deprecated. Always returns 0. Don't call. */ static inline int native_window_connect( struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated; static inline int native_window_connect( struct ANativeWindow* window __UNUSED, int api __UNUSED) { return 0; } /* deprecated. Always returns 0. Don't call. */ static inline int native_window_disconnect( struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated; static inline int native_window_disconnect( struct ANativeWindow* window __UNUSED, int api __UNUSED) { return 0; } /* * native_window_set_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 * pre-transformed buffer 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_crop( struct ANativeWindow* window, android_native_rect_t const * 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. */ static inline int native_window_set_buffer_count( struct ANativeWindow* window, size_t bufferCount) { return window->perform(window, NATIVE_WINDOW_SET_BUFFER_COUNT, bufferCount); } /* * native_window_set_buffers_geometry(..., int w, int h, int format) * All buffers dequeued after this call will have the dimensions and format * specified. A successful call to this function has the same effect as calling * native_window_set_buffers_size and native_window_set_buffers_format. * * XXX: This function is deprecated. The native_window_set_buffers_dimensions * and native_window_set_buffers_format functions should be used instead. */ static inline int native_window_set_buffers_geometry( struct ANativeWindow* window, int w, int h, int format) __deprecated; static inline int native_window_set_buffers_geometry( struct ANativeWindow* window, int w, int h, int format) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY, w, h, format); } /* * native_window_set_buffers_dimensions(..., int w, int h) * 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. */ static inline int native_window_set_buffers_dimensions( struct ANativeWindow* window, int w, int h) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS, w, h); } /* * native_window_set_buffers_user_dimensions(..., int w, int h) * * Sets the user buffer size for the window, which overrides the * window's size. All buffers dequeued after this call will have the * dimensions specified unless overridden by * native_window_set_buffers_dimensions. 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, the * default buffer size will match the windows's size. * * Calling this function will reset the window crop to a NULL value, which * disables cropping of the buffers. */ static inline int native_window_set_buffers_user_dimensions( struct ANativeWindow* window, int w, int h) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS, w, h); } /* * native_window_set_buffers_format(..., int format) * All buffers dequeued after this call will have the format specified. * * If the specified format is 0, the default buffer format will be used. */ static inline int native_window_set_buffers_format( struct ANativeWindow* window, int format) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_FORMAT, format); } /* * native_window_set_buffers_transform(..., int transform) * All buffers queued after this call will be displayed transformed according * to the transform parameter specified. */ static inline int native_window_set_buffers_transform( struct ANativeWindow* window, int transform) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TRANSFORM, transform); } /* * native_window_set_buffers_sticky_transform(..., int transform) * All buffers queued after this call will be displayed transformed according * to the transform parameter specified applied on top of the regular buffer * transform. Setting this transform will disable the transform hint. * * Temporary - This is only intended to be used by the LEGACY camera mode, do * not use this for anything else. */ static inline int native_window_set_buffers_sticky_transform( struct ANativeWindow* window, int transform) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM, transform); } /* * native_window_set_buffers_timestamp(..., int64_t timestamp) * All buffers queued after this call will be associated with the timestamp * 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. */ static inline int native_window_set_buffers_timestamp( struct ANativeWindow* window, int64_t timestamp) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP, timestamp); } /* * native_window_set_scaling_mode(..., int mode) * All buffers queued after this call will be associated with the scaling mode * specified. */ static inline int native_window_set_scaling_mode( struct ANativeWindow* window, int mode) { return window->perform(window, NATIVE_WINDOW_SET_SCALING_MODE, mode); } /* * native_window_api_connect(..., int api) * connects an API to this window. only one API can be connected at a time. * Returns -EINVAL if for some reason the window cannot be connected, which * can happen if it's connected to some other API. */ static inline int native_window_api_connect( struct ANativeWindow* window, int api) { return window->perform(window, NATIVE_WINDOW_API_CONNECT, api); } /* * native_window_api_disconnect(..., int api) * disconnect the API from this window. * An error is returned if for instance the window wasn't connected in the * first place. */ static inline int native_window_api_disconnect( struct ANativeWindow* window, int api) { return window->perform(window, NATIVE_WINDOW_API_DISCONNECT, api); } /* * native_window_dequeue_buffer_and_wait(...) * Dequeue a buffer and wait on the fence associated with that buffer. The * buffer may safely be accessed immediately upon this function returning. An * error is returned if either of the dequeue or the wait operations fail. */ static inline int native_window_dequeue_buffer_and_wait(ANativeWindow *anw, struct ANativeWindowBuffer** anb) { return anw->dequeueBuffer_DEPRECATED(anw, anb); } /* * native_window_set_sideband_stream(..., native_handle_t*) * Attach a sideband buffer stream to a native window. */ static inline int native_window_set_sideband_stream( struct ANativeWindow* window, native_handle_t* sidebandHandle) { return window->perform(window, NATIVE_WINDOW_SET_SIDEBAND_STREAM, sidebandHandle); } __END_DECLS #endif /* SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H */ android-headers-23/23/000077500000000000000000000000001264465411000145605ustar00rootroot00000000000000android-headers-23/23/android-config.h000066400000000000000000000013371264465411000176200ustar00rootroot00000000000000#ifndef HYBRIS_CONFIG_H_ #define HYBRIS_CONFIG_H_ /* 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: COMMON_GLOBAL_CFLAGS += -DCAMERA_WITH_CITYID_PARAM device/samsung/smdk4412-common/BoardCommonConfig.mk: COMMON_GLOBAL_CFLAGS += -DEXYNOS4_ENHANCEMENTS This file allows those global configurations, which are not otherwise defined in the build headers, to be available in hybris builds. Typically it is generated at hardware adaptation time. The CONFIG GOES HERE line can be used by automation to modify this file. */ #include /* CONFIG GOES HERE */ #endif android-headers-23/23/android-version.h000066400000000000000000000003411264465411000200320ustar00rootroot00000000000000#ifndef ANDROID_VERSION_H_ #define ANDROID_VERSION_H_ #define ANDROID_VERSION_MAJOR 6 #define ANDROID_VERSION_MINOR 0 #define ANDROID_VERSION_PATCH 0 #define ANDROID_VERSION_PATCH2 1 #define ANDROID_VERSION_PATCH3 0 #endif android-headers-23/23/android/000077500000000000000000000000001264465411000162005ustar00rootroot00000000000000android-headers-23/23/android/log.h000066400000000000000000000101771264465411000171400ustar00rootroot00000000000000/* * 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_LOG_H #define _ANDROID_LOG_H /****************************************************************** * * IMPORTANT NOTICE: * * This file is part of Android's set of stable system headers * exposed by the Android NDK (Native Development Kit) since * platform release 1.5 * * Third-party source AND binary code relies on the definitions * here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES. * * - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES) * - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS * - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY * - 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. * * Each log message must have * - a priority * - a log tag * - some text * * The tag normally corresponds to the component that emits the log message, * and should be reasonably small. * * Log message text may be truncated to less than an implementation-specific * limit (e.g. 1023 characters max). * * 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. * * PLEASE USE LOGS WITH 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. * * - In release builds, only send log messages to account for exceptional * conditions. * * NOTE: These functions MUST be implemented by /system/lib/liblog.so */ #include #ifdef __cplusplus extern "C" { #endif /* * Android log priority values, in ascending priority order. */ 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 */ } android_LogPriority; /* * Send a simple string to the log. */ int __android_log_write(int prio, const char *tag, const char *text); /* * Send a formatted string to the log, used like printf(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))) #else __attribute__ ((format(printf, 3, 4))) #endif #else __attribute__ ((format(printf, 3, 4))) #endif #endif ; /* * A variant of __android_log_print() that takes a va_list to list * additional parameters. */ int __android_log_vprint(int prio, const char *tag, const char *fmt, va_list ap); /* * 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. */ void __android_log_assert(const char *cond, const char *tag, const char *fmt, ...) #if defined(__GNUC__) __attribute__ ((noreturn)) #ifdef __USE_MINGW_ANSI_STDIO #if __USE_MINGW_ANSI_STDIO __attribute__ ((format(gnu_printf, 3, 4))) #else __attribute__ ((format(printf, 3, 4))) #endif #else __attribute__ ((format(printf, 3, 4))) #endif #endif ; #ifdef __cplusplus } #endif #endif /* _ANDROID_LOG_H */ android-headers-23/23/cutils/000077500000000000000000000000001264465411000160635ustar00rootroot00000000000000android-headers-23/23/cutils/android_reboot.h000066400000000000000000000017631264465411000212350ustar00rootroot00000000000000/* * Copyright 2011, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __CUTILS_ANDROID_REBOOT_H__ #define __CUTILS_ANDROID_REBOOT_H__ __BEGIN_DECLS /* Commands */ #define ANDROID_RB_RESTART 0xDEAD0001 #define ANDROID_RB_POWEROFF 0xDEAD0002 #define ANDROID_RB_RESTART2 0xDEAD0003 /* Properties */ #define ANDROID_RB_PROPERTY "sys.powerctl" int android_reboot(int cmd, int flags, const char *arg); __END_DECLS #endif /* __CUTILS_ANDROID_REBOOT_H__ */ android-headers-23/23/cutils/aref.h000066400000000000000000000024621264465411000171550ustar00rootroot00000000000000/* * 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 #include __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_ android-headers-23/23/cutils/ashmem.h000066400000000000000000000021411264465411000175040ustar00rootroot00000000000000/* cutils/ashmem.h ** ** Copyright 2008 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 _CUTILS_ASHMEM_H #define _CUTILS_ASHMEM_H #include #ifdef __cplusplus extern "C" { #endif 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); int ashmem_unpin_region(int fd, size_t offset, size_t len); int ashmem_get_size_region(int fd); #ifdef __cplusplus } #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 */ android-headers-23/23/cutils/atomic.h000066400000000000000000000217461264465411000175220ustar00rootroot00000000000000/* * 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. */ #ifndef ANDROID_CUTILS_ATOMIC_H #define ANDROID_CUTILS_ATOMIC_H #include #include #include #ifndef ANDROID_ATOMIC_INLINE #define ANDROID_ATOMIC_INLINE static inline #endif /* * A handful of basic atomic operations. * THESE ARE HERE FOR LEGACY REASONS ONLY. AVOID. * * PREFERRED ALTERNATIVES: * - Use C++/C/pthread locks/mutexes whenever there is not a * convincing reason to do otherwise. Note that very clever and * complicated, but correct, lock-free code is often slower than * using locks, especially where nontrivial data structures * are involved. * - C11 stdatomic.h. * - Where supported, C++11 std::atomic . * * PLEASE STOP READING HERE UNLESS YOU ARE TRYING TO UNDERSTAND * OR UPDATE OLD CODE. * * The "acquire" and "release" terms can be defined intuitively in terms * of the placement of memory barriers in a simple lock implementation: * - wait until compare-and-swap(lock-is-free --> lock-is-held) succeeds * - barrier * - [do work] * - barrier * - store(lock-is-free) * In very crude terms, the initial (acquire) barrier prevents any of the * "work" from happening before the lock is held, and the later (release) * barrier ensures that all of the work happens before the lock is released. * (Think of cached writes, cache read-ahead, and instruction reordering * around the CAS and store instructions.) * * The barriers must apply to both the compiler and the CPU. Note it is * legal for instructions that occur before an "acquire" barrier to be * moved down below it, and for instructions that occur after a "release" * barrier to be moved up above it. * * The ARM-driven implementation we use here is short on subtlety, * and actually requests a full barrier from the compiler and the CPU. * The only difference between acquire and release is in whether they * are issued before or after the atomic operation with which they * are associated. To ease the transition to C/C++ atomic intrinsics, * you should not rely on this, and instead assume that only the minimal * acquire/release protection is provided. * * NOTE: all int32_t* values are expected to be aligned on 32-bit boundaries. * If they are not, atomicity is not guaranteed. */ /* * Basic arithmetic and bitwise operations. These all provide a * barrier with "release" ordering, and return the previous value. * * These have the same characteristics (e.g. what happens on overflow) * as the equivalent non-atomic C operations. */ ANDROID_ATOMIC_INLINE int32_t android_atomic_inc(volatile int32_t* addr) { volatile atomic_int_least32_t* a = (volatile 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); } ANDROID_ATOMIC_INLINE int32_t android_atomic_dec(volatile int32_t* addr) { volatile atomic_int_least32_t* a = (volatile 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; 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; 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; return atomic_fetch_or_explicit(a, value, memory_order_release); } /* * Perform an atomic load with "acquire" or "release" ordering. * * Note that the notion of a "release" ordering for a load does not * really fit into the C11 or C++11 memory model. The extra ordering * is normally observable only by code using memory_order_relaxed * atomics, or data races. In the rare cases in which such ordering * is called for, use memory_order_relaxed atomics and a leading * atomic_thread_fence (typically with memory_order_acquire, * not memory_order_release!) instead. If you do not understand * this comment, you are in the vast majority, and should not be * using release loads or replacing them with anything other than * locks or default sequentially consistent atomics. */ 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; 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; 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 */ /* abusing this API in strange ways, e.g. by using it as a fence. */ /* Thus we are conservative until we can get rid of remaining */ /* clients (and this function). */ return atomic_load_explicit(a, memory_order_relaxed); } /* * Perform an atomic store with "acquire" or "release" ordering. * * Note that the notion of an "acquire" ordering for a store does not * really fit into the C11 or C++11 memory model. The extra ordering * is normally observable only by code using memory_order_relaxed * atomics, or data races. In the rare cases in which such ordering * is called for, use memory_order_relaxed atomics and a trailing * atomic_thread_fence (typically with memory_order_release, * not memory_order_acquire!) instead. */ 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; atomic_store_explicit(a, value, memory_order_relaxed); atomic_thread_fence(memory_order_seq_cst); /* Again overly conservative to accomodate weird clients. */ } 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; atomic_store_explicit(a, value, memory_order_release); } /* * Compare-and-set operation with "acquire" or "release" ordering. * * This returns zero if the new value was successfully stored, which will * only happen when *addr == oldvalue. * * (The return value is inverted from implementations on other platforms, * but matches the ARM ldrex/strex result.) * * Implementations that use the release CAS in a loop may be less efficient * than possible, because we re-issue the memory barrier on each iteration. */ 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( a, &oldvalue, newvalue, 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( a, &oldvalue, newvalue, memory_order_release, memory_order_relaxed)); } /* * Fence primitives. */ ANDROID_ATOMIC_INLINE void android_compiler_barrier(void) { __asm__ __volatile__ ("" : : : "memory"); /* Could probably also be: */ /* atomic_signal_fence(memory_order_seq_cst); */ } ANDROID_ATOMIC_INLINE void android_memory_barrier(void) { atomic_thread_fence(memory_order_seq_cst); } /* * Aliases for code using an older version of this header. These are now * deprecated and should not be used. The definitions will be removed * in a future release. */ #define android_atomic_write android_atomic_release_store #define android_atomic_cmpxchg android_atomic_release_cas #endif // ANDROID_CUTILS_ATOMIC_H android-headers-23/23/cutils/bitops.h000066400000000000000000000057341264465411000175450ustar00rootroot00000000000000/* * 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 __CUTILS_BITOPS_H #define __CUTILS_BITOPS_H #include #include #include #include __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) { return __builtin_popcount(x); } static inline int popcountl(unsigned long x) { return __builtin_popcountl(x); } static inline int popcountll(unsigned long long x) { return __builtin_popcountll(x); } __END_DECLS #endif /* __CUTILS_BITOPS_H */ android-headers-23/23/cutils/compiler.h000066400000000000000000000025171264465411000200530ustar00rootroot00000000000000/* * 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_COMPILER_H #define ANDROID_CUTILS_COMPILER_H /* * helps the compiler's optimizer predicting branches */ #ifdef __cplusplus # define CC_LIKELY( exp ) (__builtin_expect( !!(exp), true )) # define CC_UNLIKELY( exp ) (__builtin_expect( !!(exp), false )) #else # define CC_LIKELY( exp ) (__builtin_expect( !!(exp), 1 )) # define CC_UNLIKELY( exp ) (__builtin_expect( !!(exp), 0 )) #endif /** * exports marked symbols * * if used on a C++ class declaration, this macro must be inserted * after the "class" keyword. For instance: * * template * class ANDROID_API Singleton { } */ #define ANDROID_API __attribute__((visibility("default"))) #endif // ANDROID_CUTILS_COMPILER_H android-headers-23/23/cutils/config_utils.h000066400000000000000000000033471264465411000207300ustar00rootroot00000000000000/* * Copyright (C) 2006 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_CONFIG_UTILS_H #define __CUTILS_CONFIG_UTILS_H #ifdef __cplusplus extern "C" { #endif typedef struct cnode cnode; struct cnode { cnode *next; cnode *first_child; cnode *last_child; const char *name; const char *value; }; /* parse a text string into a config node tree */ void config_load(cnode *root, char *data); /* parse a file into a config node tree */ void config_load_file(cnode *root, const char *fn); /* create a single config node */ cnode* config_node(const char *name, const char *value); /* locate a named child of a config node */ cnode* config_find(cnode *root, const char *name); /* look up a child by name and return the boolean value */ int config_bool(cnode *root, const char *name, int _default); /* look up a child by name and return the string value */ const char* config_str(cnode *root, const char *name, const char *_default); /* add a named child to a config node (or modify it if it already exists) */ void config_set(cnode *root, const char *name, const char *value); /* free a config node tree */ void config_free(cnode *root); #ifdef __cplusplus } #endif #endif android-headers-23/23/cutils/debugger.h000066400000000000000000000051511264465411000200220ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/cutils/fs.h000066400000000000000000000041731264465411000166510ustar00rootroot00000000000000/* * 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_FS_H #define __CUTILS_FS_H #include #include /* * TEMP_FAILURE_RETRY is defined by some, but not all, versions of * . (Alas, it is not as standard as we'd hoped!) So, if it's * not already defined, then define it here. */ #ifndef TEMP_FAILURE_RETRY /* Used to retry syscalls that can return EINTR. */ #define TEMP_FAILURE_RETRY(exp) ({ \ typeof (exp) _rc; \ do { \ _rc = (exp); \ } while (_rc == -1 && errno == EINTR); \ _rc; }) #endif #ifdef __cplusplus extern "C" { #endif /* * Ensure that directory exists with given mode and owners. */ extern int fs_prepare_dir(const char* path, mode_t mode, uid_t uid, gid_t gid); /* * Read single plaintext integer from given file, correctly handling files * partially written with fs_write_atomic_int(). */ extern int fs_read_atomic_int(const char* path, int* value); /* * Write single plaintext integer to given file, creating backup while * in progress. */ extern int fs_write_atomic_int(const char* path, int value); /* * Ensure that all directories along given path exist, creating parent * directories as needed. Validates that given path is absolute and that * it contains no relative "." or ".." paths or symlinks. Last path segment * is treated as filename and ignored, unless the path ends with "/". */ extern int fs_mkdirs(const char* path, mode_t mode); #ifdef __cplusplus } #endif #endif /* __CUTILS_FS_H */ android-headers-23/23/cutils/hashmap.h000066400000000000000000000067551264465411000176720ustar00rootroot00000000000000/* * 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. */ /** * Hash map. */ #ifndef __HASHMAP_H #define __HASHMAP_H #include #include #ifdef __cplusplus extern "C" { #endif /** A hash map. */ typedef struct Hashmap Hashmap; /** * Creates a new hash map. Returns NULL if memory allocation fails. * * @param initialCapacity number of expected entries * @param hash function which hashes keys * @param equals function which compares keys for equality */ Hashmap* hashmapCreate(size_t initialCapacity, int (*hash)(void* key), bool (*equals)(void* keyA, void* keyB)); /** * Frees the hash map. Does not free the keys or values themselves. */ void hashmapFree(Hashmap* map); /** * Hashes the memory pointed to by key with the given size. Useful for * implementing hash functions. */ int hashmapHash(void* key, size_t keySize); /** * Puts value for the given key in the map. Returns pre-existing value if * any. * * If memory allocation fails, this function returns NULL, the map's size * does not increase, and errno is set to ENOMEM. */ void* hashmapPut(Hashmap* map, void* key, void* value); /** * Gets a value from the map. Returns NULL if no entry for the given key is * found or if the value itself is NULL. */ void* hashmapGet(Hashmap* map, void* key); /** * Returns true if the map contains an entry for the given key. */ bool hashmapContainsKey(Hashmap* map, void* key); /** * Gets the value for a key. If a value is not found, this function gets a * value and creates an entry using the given callback. * * If memory allocation fails, the callback is not called, this function * returns NULL, and errno is set to ENOMEM. */ void* hashmapMemoize(Hashmap* map, void* key, void* (*initialValue)(void* key, void* context), void* context); /** * Removes an entry from the map. Returns the removed value or NULL if no * entry was present. */ void* hashmapRemove(Hashmap* map, void* key); /** * Gets the number of entries in this map. */ size_t hashmapSize(Hashmap* map); /** * Invokes the given callback on each entry in the map. Stops iterating if * the callback returns false. */ void hashmapForEach(Hashmap* map, bool (*callback)(void* key, void* value, void* context), void* context); /** * Concurrency support. */ /** * Locks the hash map so only the current thread can access it. */ void hashmapLock(Hashmap* map); /** * Unlocks the hash map so other threads can access it. */ void hashmapUnlock(Hashmap* map); /** * Key utilities. */ /** * Hashes int keys. 'key' is a pointer to int. */ int hashmapIntHash(void* key); /** * Compares two int keys for equality. */ bool hashmapIntEquals(void* keyA, void* keyB); /** * For debugging. */ /** * Gets current capacity. */ size_t hashmapCurrentCapacity(Hashmap* map); /** * Counts the number of entry collisions. */ size_t hashmapCountCollisions(Hashmap* map); #ifdef __cplusplus } #endif #endif /* __HASHMAP_H */ android-headers-23/23/cutils/iosched_policy.h000066400000000000000000000020521264465411000212300ustar00rootroot00000000000000/* * 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. */ #ifndef __CUTILS_IOSCHED_POLICY_H #define __CUTILS_IOSCHED_POLICY_H #ifdef __cplusplus extern "C" { #endif typedef enum { IoSchedClass_NONE, IoSchedClass_RT, IoSchedClass_BE, IoSchedClass_IDLE, } IoSchedClass; extern int android_set_ioprio(int pid, IoSchedClass clazz, int ioprio); extern int android_get_ioprio(int pid, IoSchedClass *clazz, int *ioprio); #ifdef __cplusplus } #endif #endif /* __CUTILS_IOSCHED_POLICY_H */ android-headers-23/23/cutils/jstring.h000066400000000000000000000026551264465411000177240ustar00rootroot00000000000000/* * Copyright (C) 2006 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_STRING16_H #define __CUTILS_STRING16_H #include #include #ifdef __cplusplus extern "C" { #endif #if __STDC_VERSION__ < 201112L && __cplusplus < 201103L typedef uint16_t char16_t; #endif // otherwise char16_t is a keyword with the right semantics extern char * strndup16to8 (const char16_t* s, size_t n); extern size_t strnlen16to8 (const char16_t* s, size_t n); extern char * strncpy16to8 (char *dest, const char16_t*s, size_t n); extern char16_t * strdup8to16 (const char* s, size_t *out_len); extern size_t strlen8to16 (const char* utf8Str); extern char16_t * strcpy8to16 (char16_t *dest, const char*s, size_t *out_len); extern char16_t * strcpylen8to16 (char16_t *dest, const char*s, int length, size_t *out_len); #ifdef __cplusplus } #endif #endif /* __CUTILS_STRING16_H */ android-headers-23/23/cutils/klog.h000066400000000000000000000032431264465411000171720ustar00rootroot00000000000000/* * 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 _CUTILS_KLOG_H_ #define _CUTILS_KLOG_H_ #include #include #include __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))); void klog_writev(int level, const struct iovec* iov, int iov_count); __END_DECLS #define KLOG_ERROR_LEVEL 3 #define KLOG_WARNING_LEVEL 4 #define KLOG_NOTICE_LEVEL 5 #define KLOG_INFO_LEVEL 6 #define KLOG_DEBUG_LEVEL 7 #define KLOG_ERROR(tag,x...) klog_write(KLOG_ERROR_LEVEL, "<3>" tag ": " x) #define KLOG_WARNING(tag,x...) klog_write(KLOG_WARNING_LEVEL, "<4>" tag ": " x) #define KLOG_NOTICE(tag,x...) klog_write(KLOG_NOTICE_LEVEL, "<5>" tag ": " x) #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 android-headers-23/23/cutils/list.h000066400000000000000000000042561264465411000172160ustar00rootroot00000000000000/* * Copyright (C) 2008-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_LIST_H_ #define _CUTILS_LIST_H_ #include #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ struct listnode { struct listnode *next; struct listnode *prev; }; #define node_to_item(node, container, member) \ (container *) (((char*) (node)) - offsetof(container, member)) #define list_declare(name) \ struct listnode name = { \ .next = &name, \ .prev = &name, \ } #define list_for_each(node, list) \ 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) #define list_for_each_safe(node, n, list) \ for (node = (list)->next, n = node->next; \ node != (list); \ node = n, n = node->next) static inline void list_init(struct listnode *node) { node->next = node; node->prev = node; } static inline void list_add_tail(struct listnode *head, struct listnode *item) { item->next = head; item->prev = head->prev; head->prev->next = item; head->prev = item; } static inline void list_add_head(struct listnode *head, struct listnode *item) { item->next = head->next; item->prev = head; head->next->prev = item; head->next = item; } static inline void list_remove(struct listnode *item) { item->next->prev = item->prev; item->prev->next = item->next; } #define list_empty(list) ((list) == (list)->next) #define list_head(list) ((list)->next) #define list_tail(list) ((list)->prev) #ifdef __cplusplus }; #endif /* __cplusplus */ #endif android-headers-23/23/cutils/log.h000066400000000000000000000000251264465411000170120ustar00rootroot00000000000000#include android-headers-23/23/cutils/memory.h000066400000000000000000000023711264465411000175470ustar00rootroot00000000000000/* * Copyright (C) 2006 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_MEMORY_H #define ANDROID_CUTILS_MEMORY_H #include #include #ifdef __cplusplus extern "C" { #endif /* size is given in bytes and must be multiple of 2 */ void android_memset16(uint16_t* dst, uint16_t value, size_t size); /* size is given in bytes and must be multiple of 4 */ void android_memset32(uint32_t* dst, uint32_t value, size_t size); #if defined(__GLIBC__) || defined(_WIN32) /* Declaration of strlcpy() for platforms that don't already have it. */ size_t strlcpy(char *dst, const char *src, size_t size); #endif #ifdef __cplusplus } // extern "C" #endif #endif // ANDROID_CUTILS_MEMORY_H android-headers-23/23/cutils/misc.h000066400000000000000000000023401264465411000171660ustar00rootroot00000000000000/* * Copyright (C) 2006 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_MISC_H #define __CUTILS_MISC_H #ifdef __cplusplus extern "C" { #endif /* Load an entire file into a malloc'd chunk of memory * that is length_of_file + 1 (null terminator). If * sz is non-zero, return the size of the file via sz. * Returns 0 on failure. */ extern void *load_file(const char *fn, unsigned *sz); /* This is the range of UIDs (and GIDs) that are reserved * for assigning to applications. */ #define FIRST_APPLICATION_UID 10000 #define LAST_APPLICATION_UID 99999 #ifdef __cplusplus } #endif #endif /* __CUTILS_MISC_H */ android-headers-23/23/cutils/multiuser.h000066400000000000000000000021251264465411000202650ustar00rootroot00000000000000/* * 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_MULTIUSER_H #define __CUTILS_MULTIUSER_H #include #ifdef __cplusplus extern "C" { #endif // NOTE: keep in sync with android.os.UserId #define MULTIUSER_APP_PER_USER_RANGE 100000 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); #ifdef __cplusplus } #endif #endif /* __CUTILS_MULTIUSER_H */ android-headers-23/23/cutils/native_handle.h000066400000000000000000000035011264465411000210340ustar00rootroot00000000000000/* * 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 NATIVE_HANDLE_H_ #define NATIVE_HANDLE_H_ #ifdef __cplusplus extern "C" { #endif 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] */ int data[0]; /* numFds + numInts ints */ } native_handle_t; /* * native_handle_close * * closes the file descriptors contained in this native_handle_t * * return 0 on success, or a negative error code on failure * */ int native_handle_close(const native_handle_t* h); /* * native_handle_create * * creates a native_handle_t and initializes it. must be destroyed with * native_handle_delete(). * */ native_handle_t* native_handle_create(int numFds, int numInts); /* * native_handle_delete * * frees a native_handle_t allocated with native_handle_create(). * This ONLY frees the memory allocated for the native_handle_t, but doesn't * close the file descriptors; which can be achieved with native_handle_close(). * * return 0 on success, or a negative error code on failure * */ int native_handle_delete(native_handle_t* h); #ifdef __cplusplus } #endif #endif /* NATIVE_HANDLE_H_ */ android-headers-23/23/cutils/open_memstream.h000066400000000000000000000016311264465411000212500ustar00rootroot00000000000000/* * 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 __CUTILS_OPEN_MEMSTREAM_H__ #define __CUTILS_OPEN_MEMSTREAM_H__ #include #if defined(__APPLE__) #ifdef __cplusplus extern "C" { #endif FILE* open_memstream(char** bufp, size_t* sizep); #ifdef __cplusplus } #endif #endif /* __APPLE__ */ #endif /*__CUTILS_OPEN_MEMSTREAM_H__*/ android-headers-23/23/cutils/partition_utils.h000066400000000000000000000014361264465411000214710ustar00rootroot00000000000000/* * Copyright 2011, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __CUTILS_PARTITION_WIPED_H__ #define __CUTILS_PARTITION_WIPED_H__ __BEGIN_DECLS int partition_wiped(char *source); __END_DECLS #endif /* __CUTILS_PARTITION_WIPED_H__ */ android-headers-23/23/cutils/process_name.h000066400000000000000000000020451264465411000207130ustar00rootroot00000000000000/* * 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. */ /** * Gives the current process a name. */ #ifndef __PROCESS_NAME_H #define __PROCESS_NAME_H #ifdef __cplusplus extern "C" { #endif /** * Sets the current process name. * * Warning: This leaks a string every time you call it. Use judiciously! */ void set_process_name(const char* process_name); /** Gets the current process name. */ const char* get_process_name(void); #ifdef __cplusplus } #endif #endif /* __PROCESS_NAME_H */ android-headers-23/23/cutils/properties.h000066400000000000000000000111751264465411000204350ustar00rootroot00000000000000/* * Copyright (C) 2006 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_PROPERTIES_H #define __CUTILS_PROPERTIES_H #include #include #include #include #ifdef __cplusplus extern "C" { #endif /* System properties are *small* name value pairs managed by the ** property service. If your data doesn't fit in the provided ** space it is not appropriate for a system property. ** ** WARNING: system/bionic/include/sys/system_properties.h also defines ** these, but with different names. (TODO: fix that) */ #define PROPERTY_KEY_MAX PROP_NAME_MAX #define PROPERTY_VALUE_MAX PROP_VALUE_MAX /* property_get: returns the length of the value which will never be ** greater than PROPERTY_VALUE_MAX - 1 and will always be zero terminated. ** (the length does not include the terminating zero). ** ** 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); /* property_get_bool: returns the value of key coerced into a ** boolean. If the property is not set, then the default value is returned. ** * The following is considered to be true (1): ** "1", "true", "y", "yes", "on" ** ** The following is considered to be false (0): ** "0", "false", "n", "no", "off" ** ** The conversion is whitespace-sensitive (e.g. " off" will not be false). ** ** If no property with this key is set (or the key is NULL) or the boolean ** conversion fails, the default value is returned. **/ int8_t property_get_bool(const char *key, int8_t default_value); /* property_get_int64: returns the value of key truncated and coerced into a ** int64_t. If the property is not set, then the default value is used. ** ** The numeric conversion is identical to strtoimax with the base inferred: ** - All digits up to the first non-digit characters are read ** - The longest consecutive prefix of digits is converted to a long ** ** Valid strings of digits are: ** - An optional sign character + or - ** - An optional prefix indicating the base (otherwise base 10 is assumed) ** -- 0 prefix is octal ** -- 0x / 0X prefix is hex ** ** Leading/trailing whitespace is ignored. Overflow/underflow will cause ** numeric conversion to fail. ** ** If no property with this key is set (or the key is NULL) or the numeric ** conversion fails, the default value is returned. **/ int64_t property_get_int64(const char *key, int64_t default_value); /* property_get_int32: returns the value of key truncated and coerced into an ** int32_t. If the property is not set, then the default value is used. ** ** The numeric conversion is identical to strtoimax with the base inferred: ** - All digits up to the first non-digit characters are read ** - The longest consecutive prefix of digits is converted to a long ** ** Valid strings of digits are: ** - An optional sign character + or - ** - An optional prefix indicating the base (otherwise base 10 is assumed) ** -- 0 prefix is octal ** -- 0x / 0X prefix is hex ** ** Leading/trailing whitespace is ignored. Overflow/underflow will cause ** numeric conversion to fail. ** ** If no property with this key is set (or the key is NULL) or the numeric ** conversion fails, the default value is returned. **/ 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); #if defined(__BIONIC_FORTIFY) 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"); __BIONIC_FORTIFY_INLINE int property_get(const char *key, char *value, const char *default_value) { size_t bos = __bos(value); if (bos < PROPERTY_VALUE_MAX) { __property_get_too_small_error(); } return __property_get_real(key, value, default_value); } #endif #ifdef __cplusplus } #endif #endif android-headers-23/23/cutils/qtaguid.h000066400000000000000000000034501264465411000176740ustar00rootroot00000000000000/* * 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 __CUTILS_QTAGUID_H #define __CUTILS_QTAGUID_H #include #include #include #ifdef __cplusplus extern "C" { #endif /* * 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); /* * For the given uid, switch counter sets. * The kernel only keeps a limited number of sets. * 2 for now. */ 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 * then untagged. * The calling process can only operate on its own tags. * Unless it is part of the happy AID_NET_BW_ACCT group. * In which case it can clobber everything. */ extern int qtaguid_deleteTagData(int tag, uid_t uid); /* * Enable/disable qtaguid functionnality at a lower level. * When pacified, the kernel will accept commands but do nothing. */ extern int qtaguid_setPacifier(int on); #ifdef __cplusplus } #endif #endif /* __CUTILS_QTAG_UID_H */ android-headers-23/23/cutils/record_stream.h000066400000000000000000000022221264465411000210630ustar00rootroot00000000000000/* * Copyright (C) 2006 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. */ /* * A simple utility for reading fixed records out of a stream fd */ #ifndef _CUTILS_RECORD_STREAM_H #define _CUTILS_RECORD_STREAM_H #ifdef __cplusplus extern "C" { #endif typedef struct RecordStream RecordStream; extern RecordStream *record_stream_new(int fd, size_t maxRecordLen); extern void record_stream_free(RecordStream *p_rs); extern int record_stream_get_next (RecordStream *p_rs, void ** p_outRecord, size_t *p_outRecordLen); #ifdef __cplusplus } #endif #endif /*_CUTILS_RECORD_STREAM_H*/ android-headers-23/23/cutils/sched_policy.h000066400000000000000000000042241264465411000207030ustar00rootroot00000000000000/* * 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. */ #ifndef __CUTILS_SCHED_POLICY_H #define __CUTILS_SCHED_POLICY_H #ifdef __cplusplus extern "C" { #endif /* Keep in sync with THREAD_GROUP_* in frameworks/base/core/java/android/os/Process.java */ typedef enum { 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_CNT, SP_MAX = SP_CNT - 1, SP_SYSTEM_DEFAULT = SP_FOREGROUND, } SchedPolicy; extern int set_cpuset_policy(int tid, SchedPolicy policy); /* Assign thread tid to the cgroup associated with the specified policy. * If the thread is a thread group leader, that is it's gettid() == getpid(), * then the other threads in the same thread group are _not_ affected. * On platforms which support gettid(), zero tid means current thread. * Return value: 0 for success, or -errno for error. */ extern int set_sched_policy(int tid, SchedPolicy policy); /* Return the policy associated with the cgroup of thread tid via policy pointer. * On platforms which support gettid(), zero tid means current thread. * Return value: 0 for success, or -1 for error and set errno. */ extern int get_sched_policy(int tid, SchedPolicy *policy); /* Return a displayable string corresponding to policy. * Return value: non-NULL NUL-terminated name of unspecified length; * the caller is responsible for displaying the useful part of the string. */ extern const char *get_sched_policy_name(SchedPolicy policy); #ifdef __cplusplus } #endif #endif /* __CUTILS_SCHED_POLICY_H */ android-headers-23/23/cutils/sockets.h000066400000000000000000000061711264465411000177140ustar00rootroot00000000000000/* * Copyright (C) 2006 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_SOCKETS_H #define __CUTILS_SOCKETS_H #include #include #include #include #include #ifdef HAVE_WINSOCK #include typedef int socklen_t; #else #include #endif #define ANDROID_SOCKET_ENV_PREFIX "ANDROID_SOCKET_" #define ANDROID_SOCKET_DIR "/dev/socket" #ifdef __cplusplus extern "C" { #endif /* * 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; } /* * See also android.os.LocalSocketAddress.Namespace */ // Linux "abstract" (non-filesystem) namespace #define ANDROID_SOCKET_NAMESPACE_ABSTRACT 0 // Android "reserved" (/dev/socket) namespace #define ANDROID_SOCKET_NAMESPACE_RESERVED 1 // Normal filesystem namespace #define ANDROID_SOCKET_NAMESPACE_FILESYSTEM 2 extern int socket_loopback_client(int port, int type); extern int socket_network_client(const char *host, int port, int type); extern int socket_network_client_timeout(const char *host, int port, int type, int timeout); extern int socket_loopback_server(int port, int type); extern int socket_local_server(const char *name, int namespaceId, int type); extern int socket_local_server_bind(int s, const char *name, int namespaceId); extern int socket_local_client_connect(int fd, const char *name, int namespaceId, int type); extern int socket_local_client(const char *name, int namespaceId, int type); extern int socket_inaddr_any_server(int port, int type); /* * socket_peer_is_trusted - Takes a socket which is presumed to be a * connected local socket (e.g. AF_LOCAL) and returns whether the peer * (the userid that owns the process on the other end of that socket) * is one of the two trusted userids, root or shell. * * Note: This only works as advertised on the Android OS and always * just returns true when called on other operating systems. */ extern bool socket_peer_is_trusted(int fd); #ifdef __cplusplus } #endif #endif /* __CUTILS_SOCKETS_H */ android-headers-23/23/cutils/str_parms.h000066400000000000000000000042021264465411000202440ustar00rootroot00000000000000/* * 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 __CUTILS_STR_PARMS_H #define __CUTILS_STR_PARMS_H #include #include __BEGIN_DECLS struct str_parms; struct str_parms *str_parms_create(void); struct str_parms *str_parms_create_str(const char *_string); void str_parms_destroy(struct str_parms *str_parms); void str_parms_del(struct str_parms *str_parms, const char *key); int str_parms_add_str(struct str_parms *str_parms, const char *key, const char *value); int str_parms_add_int(struct str_parms *str_parms, const char *key, int value); int str_parms_add_float(struct str_parms *str_parms, const char *key, float value); // Returns non-zero if the str_parms contains the specified key. int str_parms_has_key(struct str_parms *str_parms, const char *key); // Gets value associated with the specified key (if present), placing it in the buffer // pointed to by the out_val parameter. Returns the length of the returned string value. // If 'key' isn't in the parms, then return -ENOENT (-2) and leave 'out_val' untouched. int str_parms_get_str(struct str_parms *str_parms, const char *key, char *out_val, int len); int str_parms_get_int(struct str_parms *str_parms, const char *key, int *out_val); int str_parms_get_float(struct str_parms *str_parms, const char *key, float *out_val); char *str_parms_to_str(struct str_parms *str_parms); /* debug */ void str_parms_dump(struct str_parms *str_parms); __END_DECLS #endif /* __CUTILS_STR_PARMS_H */ android-headers-23/23/cutils/threads.h000066400000000000000000000077721264465411000177030ustar00rootroot00000000000000/* * 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. */ #ifndef _LIBS_CUTILS_THREADS_H #define _LIBS_CUTILS_THREADS_H #include #if !defined(_WIN32) #include #else #include #endif #ifdef __cplusplus extern "C" { #endif /***********************************************************************/ /***********************************************************************/ /***** *****/ /***** local thread storage *****/ /***** *****/ /***********************************************************************/ /***********************************************************************/ extern pid_t gettid(); #if !defined(_WIN32) typedef struct { pthread_mutex_t lock; int has_tls; pthread_key_t tls; } thread_store_t; #define THREAD_STORE_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, 0, 0 } #else // !defined(_WIN32) typedef struct { int lock_init; int has_tls; DWORD tls; CRITICAL_SECTION lock; } thread_store_t; #define THREAD_STORE_INITIALIZER { 0, 0, 0, {0, 0, 0, 0, 0, 0} } #endif // !defined(_WIN32) typedef void (*thread_store_destruct_t)(void* value); extern void* thread_store_get(thread_store_t* store); extern void thread_store_set(thread_store_t* store, void* value, thread_store_destruct_t destroy); /***********************************************************************/ /***********************************************************************/ /***** *****/ /***** mutexes *****/ /***** *****/ /***********************************************************************/ /***********************************************************************/ #if !defined(_WIN32) typedef pthread_mutex_t mutex_t; #define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER static __inline__ void mutex_lock(mutex_t* lock) { pthread_mutex_lock(lock); } static __inline__ void mutex_unlock(mutex_t* lock) { pthread_mutex_unlock(lock); } static __inline__ int mutex_init(mutex_t* lock) { return pthread_mutex_init(lock, NULL); } static __inline__ void mutex_destroy(mutex_t* lock) { pthread_mutex_destroy(lock); } #else // !defined(_WIN32) typedef struct { int init; CRITICAL_SECTION lock[1]; } mutex_t; #define MUTEX_INITIALIZER { 0, {{ NULL, 0, 0, NULL, NULL, 0 }} } static __inline__ void mutex_lock(mutex_t* lock) { if (!lock->init) { lock->init = 1; InitializeCriticalSection( lock->lock ); lock->init = 2; } else while (lock->init != 2) Sleep(10); EnterCriticalSection(lock->lock); } static __inline__ void mutex_unlock(mutex_t* lock) { LeaveCriticalSection(lock->lock); } static __inline__ int mutex_init(mutex_t* lock) { InitializeCriticalSection(lock->lock); lock->init = 2; return 0; } static __inline__ void mutex_destroy(mutex_t* lock) { if (lock->init) { lock->init = 0; DeleteCriticalSection(lock->lock); } } #endif // !defined(_WIN32) #ifdef __cplusplus } #endif #endif /* _LIBS_CUTILS_THREADS_H */ android-headers-23/23/cutils/trace.h000066400000000000000000000210201264465411000173250ustar00rootroot00000000000000/* * 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 _LIBS_CUTILS_TRACE_H #define _LIBS_CUTILS_TRACE_H #include #include #include #include #include #include #include #include #include __BEGIN_DECLS /** * The ATRACE_TAG macro can be defined before including this header to trace * using one of the tags defined below. It must be defined to one of the * following ATRACE_TAG_* macros. The trace tag is used to filter tracing in * userland to avoid some of the runtime cost of tracing when it is not desired. * * Defining ATRACE_TAG to be ATRACE_TAG_ALWAYS will result in the tracing always * being enabled - this should ONLY be done for debug code, as userland tracing * has a performance cost even when the trace is not being recorded. Defining * ATRACE_TAG to be ATRACE_TAG_NEVER or leaving ATRACE_TAG undefined will result * in the tracing always being disabled. * * ATRACE_TAG_HAL should be bitwise ORed with the relevant tags for tracing * within a hardware module. For example a camera hardware module would set: * #define ATRACE_TAG (ATRACE_TAG_CAMERA | ATRACE_TAG_HAL) * * Keep these in sync with frameworks/base/core/java/android/os/Trace.java. */ #define ATRACE_TAG_NEVER 0 // This tag is never enabled. #define ATRACE_TAG_ALWAYS (1<<0) // This tag is always enabled. #define ATRACE_TAG_GRAPHICS (1<<1) #define ATRACE_TAG_INPUT (1<<2) #define ATRACE_TAG_VIEW (1<<3) #define ATRACE_TAG_WEBVIEW (1<<4) #define ATRACE_TAG_WINDOW_MANAGER (1<<5) #define ATRACE_TAG_ACTIVITY_MANAGER (1<<6) #define ATRACE_TAG_SYNC_MANAGER (1<<7) #define ATRACE_TAG_AUDIO (1<<8) #define ATRACE_TAG_VIDEO (1<<9) #define ATRACE_TAG_CAMERA (1<<10) #define ATRACE_TAG_HAL (1<<11) #define ATRACE_TAG_APP (1<<12) #define ATRACE_TAG_RESOURCES (1<<13) #define ATRACE_TAG_DALVIK (1<<14) #define ATRACE_TAG_RS (1<<15) #define ATRACE_TAG_BIONIC (1<<16) #define ATRACE_TAG_POWER (1<<17) #define ATRACE_TAG_LAST ATRACE_TAG_POWER // Reserved for initialization. #define ATRACE_TAG_NOT_READY (1LL<<63) #define ATRACE_TAG_VALID_MASK ((ATRACE_TAG_LAST - 1) | ATRACE_TAG_LAST) #ifndef ATRACE_TAG #define ATRACE_TAG ATRACE_TAG_NEVER #elif ATRACE_TAG > ATRACE_TAG_VALID_MASK #error ATRACE_TAG must be defined to be one of the tags defined in cutils/trace.h #endif /** * Opens the trace file for writing and reads the property for initial tags. * The atrace.tags.enableflags property sets the tags to trace. * This function should not be explicitly called, the first call to any normal * trace function will cause it to be run safely. */ void atrace_setup(); /** * If tracing is ready, set atrace_enabled_tags to the system property * debug.atrace.tags.enableflags. Can be used as a sysprop change callback. */ void atrace_update_tags(); /** * Set whether the process is debuggable. By default the process is not * considered debuggable. If the process is not debuggable then application- * level tracing is not allowed unless the ro.debuggable system property is * set to '1'. */ void atrace_set_debuggable(bool debuggable); /** * Set whether tracing is enabled for the current process. This is used to * prevent tracing within the Zygote process. */ void atrace_set_tracing_enabled(bool enabled); /** * Flag indicating whether setup has been completed, initialized to 0. * Nonzero indicates setup has completed. * Note: This does NOT indicate whether or not setup was successful. */ extern atomic_bool atrace_is_ready; /** * Set of ATRACE_TAG flags to trace for, initialized to ATRACE_TAG_NOT_READY. * A value of zero indicates setup has failed. * Any other nonzero value indicates setup has succeeded, and tracing is on. */ extern uint64_t atrace_enabled_tags; /** * Handle to the kernel's trace buffer, initialized to -1. * Any other value indicates setup has succeeded, and is a valid fd for tracing. */ extern int atrace_marker_fd; /** * atrace_init readies the process for tracing by opening the trace_marker file. * Calling any trace function causes this to be run, so calling it is optional. * This can be explicitly run to avoid setup delay on first trace function. */ #define ATRACE_INIT() atrace_init() static inline void atrace_init() { if (CC_UNLIKELY(!atomic_load_explicit(&atrace_is_ready, memory_order_acquire))) { atrace_setup(); } } /** * Get the mask of all tags currently enabled. * It can be used as a guard condition around more expensive trace calculations. * Every trace function calls this, which ensures atrace_init is run. */ #define ATRACE_GET_ENABLED_TAGS() atrace_get_enabled_tags() static inline uint64_t atrace_get_enabled_tags() { atrace_init(); return atrace_enabled_tags; } /** * Test if a given tag is currently enabled. * Returns nonzero if the tag is enabled, otherwise zero. * It can be used as a guard condition around more expensive trace calculations. */ #define ATRACE_ENABLED() atrace_is_tag_enabled(ATRACE_TAG) static inline uint64_t atrace_is_tag_enabled(uint64_t tag) { return atrace_get_enabled_tags() & tag; } /** * Trace the beginning of a context. name is used to identify the context. * This is often used to time function execution. */ #define ATRACE_BEGIN(name) atrace_begin(ATRACE_TAG, name) static inline void atrace_begin(uint64_t tag, const char* name) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { void atrace_begin_body(const char*); atrace_begin_body(name); } } /** * Trace the end of a context. * This should match up (and occur after) a corresponding ATRACE_BEGIN. */ #define ATRACE_END() atrace_end(ATRACE_TAG) 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); } } /** * Trace the beginning of an asynchronous event. Unlike ATRACE_BEGIN/ATRACE_END * contexts, asynchronous events do not need to be nested. The name describes * the event, and the cookie provides a unique identifier for distinguishing * simultaneous events. The name and cookie used to begin an event must be * used to end it. */ #define ATRACE_ASYNC_BEGIN(name, cookie) \ atrace_async_begin(ATRACE_TAG, name, cookie) static inline void atrace_async_begin(uint64_t tag, const char* name, int32_t cookie) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { void atrace_async_begin_body(const char*, int32_t); atrace_async_begin_body(name, cookie); } } /** * Trace the end of an asynchronous event. * This should have a corresponding ATRACE_ASYNC_BEGIN. */ #define ATRACE_ASYNC_END(name, cookie) atrace_async_end(ATRACE_TAG, name, cookie) static inline void atrace_async_end(uint64_t tag, const char* name, int32_t cookie) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { void atrace_async_end_body(const char*, int32_t); atrace_async_end_body(name, cookie); } } /** * Traces an integer counter value. name is used to identify the counter. * This can be used to track how a value changes over time. */ #define ATRACE_INT(name, value) atrace_int(ATRACE_TAG, name, value) static inline void atrace_int(uint64_t tag, const char* name, int32_t value) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { void atrace_int_body(const char*, int32_t); atrace_int_body(name, value); } } /** * Traces a 64-bit integer counter value. name is used to identify the * counter. This can be used to track how a value changes over time. */ #define ATRACE_INT64(name, value) atrace_int64(ATRACE_TAG, name, value) static inline void atrace_int64(uint64_t tag, const char* name, int64_t value) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { void atrace_int64_body(const char*, int64_t); atrace_int64_body(name, value); } } __END_DECLS #endif // _LIBS_CUTILS_TRACE_H android-headers-23/23/cutils/uevent.h000066400000000000000000000021731264465411000175450ustar00rootroot00000000000000/* * 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 __CUTILS_UEVENT_H #define __CUTILS_UEVENT_H #include #include #ifdef __cplusplus extern "C" { #endif int uevent_open_socket(int buf_sz, bool passcred); ssize_t uevent_kernel_multicast_recv(int socket, void *buffer, size_t length); ssize_t uevent_kernel_multicast_uid_recv(int socket, void *buffer, size_t length, uid_t *uid); ssize_t uevent_kernel_recv(int socket, void *buffer, size_t length, bool require_group, uid_t *uid); #ifdef __cplusplus } #endif #endif /* __CUTILS_UEVENT_H */ android-headers-23/23/hardware/000077500000000000000000000000001264465411000163555ustar00rootroot00000000000000android-headers-23/23/hardware/activity_recognition.h000066400000000000000000000242601264465411000227660ustar00rootroot00000000000000/* * 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. */ /* * Activity Recognition HAL. The goal is to provide low power, low latency, always-on activity * recognition implemented in hardware (i.e. these activity recognition algorithms/classifers * should NOT be run on the AP). By low power we mean that this may be activated 24/7 without * impacting the battery drain speed (goal in order of 1mW including the power for sensors). * This HAL does not specify the input sources that are used towards detecting these activities. * It has one monitor interface which can be used to batch activities for always-on * activity_recognition and if the latency is zero, the same interface can be used for low latency * detection. */ #ifndef ANDROID_ACTIVITY_RECOGNITION_INTERFACE_H #define ANDROID_ACTIVITY_RECOGNITION_INTERFACE_H #include __BEGIN_DECLS #define ACTIVITY_RECOGNITION_HEADER_VERSION 1 #define ACTIVITY_RECOGNITION_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION_2(0, 1, ACTIVITY_RECOGNITION_HEADER_VERSION) #define ACTIVITY_RECOGNITION_HARDWARE_MODULE_ID "activity_recognition" #define ACTIVITY_RECOGNITION_HARDWARE_INTERFACE "activity_recognition_hw_if" /* * Define types for various activities. Multiple activities may be active at the same time and * sometimes none of these activities may be active. * * Each activity has a corresponding type. Only activities that are defined here should use * android.activity_recognition.* prefix. OEM defined activities should not use this prefix. * Activity type of OEM-defined activities should start with the reverse domain name of the entity * defining the activity. * * When android introduces a new activity type that can potentially replace an OEM-defined activity * type, the OEM must use the official activity type on versions of the HAL that support this new * official activity type. * * Example (made up): Suppose Google's Glass team wants to detect nodding activity. * - Such an activity is not officially supported in android L * - Glass devices launching on L can implement a custom activity with * type = "com.google.glass.nodding" * - In M android release, if android decides to define ACITIVITY_TYPE_NODDING, those types * should replace the Glass-team-specific types in all future launches. * - When launching glass on the M release, Google should now use the official activity type * - This way, other applications can use this activity. */ #define ACTIVITY_TYPE_IN_VEHICLE "android.activity_recognition.in_vehicle" #define ACTIVITY_TYPE_ON_BICYCLE "android.activity_recognition.on_bicycle" #define ACTIVITY_TYPE_WALKING "android.activity_recognition.walking" #define ACTIVITY_TYPE_RUNNING "android.activity_recognition.running" #define ACTIVITY_TYPE_STILL "android.activity_recognition.still" #define ACTIVITY_TYPE_TILTING "android.activity_recognition.tilting" /* Values for activity_event.event_types. */ enum { /* * A flush_complete event which indicates that a flush() has been successfully completed. This * does not correspond to any activity/event. An event of this type should be added to the end * of a batch FIFO and it indicates that all the events in the batch FIFO have been successfully * reported to the framework. An event of this type should be generated only if flush() has been * explicitly called and if the FIFO is empty at the time flush() is called it should trivially * return a flush_complete_event to indicate that the FIFO is empty. * * A flush complete event should have the following parameters set. * activity_event_t.event_type = ACTIVITY_EVENT_FLUSH_COMPLETE * activity_event_t.activity = 0 * activity_event_t.timestamp = 0 * activity_event_t.reserved = 0 * See (*flush)() for more details. */ ACTIVITY_EVENT_FLUSH_COMPLETE = 0, /* Signifies entering an activity. */ ACTIVITY_EVENT_ENTER = 1, /* Signifies exiting an activity. */ ACTIVITY_EVENT_EXIT = 2 }; /* * Each event is a separate activity with event_type indicating whether this activity has started * or ended. Eg event: (event_type="enter", activity="ON_FOOT", timestamp) */ typedef struct activity_event { /* One of the ACTIVITY_EVENT_* constants defined above. */ uint32_t event_type; /* * Index of the activity in the list returned by get_supported_activities_list. If this event * is a flush complete event, this should be set to zero. */ uint32_t activity; /* Time at which the transition/event has occurred in nanoseconds using elapsedRealTimeNano. */ int64_t timestamp; /* Set to zero. */ int32_t reserved[4]; } activity_event_t; typedef struct activity_recognition_module { /** * Common methods of the activity recognition module. This *must* be the first member of * activity_recognition_module as users of this structure will cast a hw_module_t to * activity_recognition_module pointer in contexts where it's known the hw_module_t * references an activity_recognition_module. */ hw_module_t common; /* * List of all activities supported by this module including OEM defined activities. Each * activity is represented using a string defined above. Each string should be null terminated. * The index of the activity in this array is used as a "handle" for enabling/disabling and * event delivery. * Return value is the size of this list. */ int (*get_supported_activities_list)(struct activity_recognition_module* module, char const* const* *activity_list); } activity_recognition_module_t; struct activity_recognition_device; typedef struct activity_recognition_callback_procs { // Callback for activity_data. This is guaranteed to not invoke any HAL methods. // Memory allocated for the events can be reused after this method returns. // events - Array of activity_event_t s that are reported. // count - size of the array. void (*activity_callback)(const struct activity_recognition_callback_procs* procs, const activity_event_t* events, int count); } activity_recognition_callback_procs_t; typedef struct activity_recognition_device { /** * Common methods of the activity recognition device. This *must* be the first member of * activity_recognition_device as users of this structure will cast a hw_device_t to * activity_recognition_device pointer in contexts where it's known the hw_device_t * references an activity_recognition_device. */ hw_device_t common; /* * Sets the callback to invoke when there are events to report. This call overwrites the * previously registered callback (if any). */ void (*register_activity_callback)(const struct activity_recognition_device* dev, const activity_recognition_callback_procs_t* callback); /* * Activates monitoring of activity transitions. Activities need not be reported as soon as they * are detected. The detected activities are stored in a FIFO and reported in batches when the * "max_batch_report_latency" expires or when the batch FIFO is full. The implementation should * allow the AP to go into suspend mode while the activities are detected and stored in the * batch FIFO. Whenever events need to be reported (like when the FIFO is full or when the * max_batch_report_latency has expired for an activity, event pair), it should wake_up the AP * so that no events are lost. Activities are stored as transitions and they are allowed to * overlap with each other. Each (activity, event_type) pair can be activated or deactivated * independently of the other. The HAL implementation needs to keep track of which pairs are * currently active and needs to detect only those pairs. * * activity_handle - Index of the specific activity that needs to be detected in the list * returned by get_supported_activities_list. * event_type - Specific transition of the activity that needs to be detected. * max_batch_report_latency_ns - a transition can be delayed by at most * “max_batch_report_latency†nanoseconds. * Return 0 on success, negative errno code otherwise. */ int (*enable_activity_event)(const struct activity_recognition_device* dev, uint32_t activity_handle, uint32_t event_type, int64_t max_batch_report_latency_ns); /* * Disables detection of a specific (activity, event_type) pair. */ int (*disable_activity_event)(const struct activity_recognition_device* dev, uint32_t activity_handle, uint32_t event_type); /* * Flush all the batch FIFOs. Report all the activities that were stored in the FIFO so far as * if max_batch_report_latency had expired. This shouldn't change the latency in any way. Add * a flush_complete_event to indicate the end of the FIFO after all events are delivered. * See ACTIVITY_EVENT_FLUSH_COMPLETE for more details. * Return 0 on success, negative errno code otherwise. */ int (*flush)(const struct activity_recognition_device* dev); // Must be set to NULL. void (*reserved_procs[16 - 4])(void); } activity_recognition_device_t; static inline int activity_recognition_open(const hw_module_t* module, activity_recognition_device_t** device) { return module->methods->open(module, ACTIVITY_RECOGNITION_HARDWARE_INTERFACE, (hw_device_t**)device); } static inline int activity_recognition_close(activity_recognition_device_t* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_ACTIVITY_RECOGNITION_INTERFACE_H android-headers-23/23/hardware/audio.h000066400000000000000000000651231264465411000176360ustar00rootroot00000000000000/* * 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_AUDIO_HAL_INTERFACE_H #define ANDROID_AUDIO_HAL_INTERFACE_H #include #include #include #include #include #include #include #include __BEGIN_DECLS /** * The id of this module */ #define AUDIO_HARDWARE_MODULE_ID "audio" /** * Name of the audio devices to open */ #define AUDIO_HARDWARE_INTERFACE "audio_hw_if" /* Use version 0.1 to be compatible with first generation of audio hw module with version_major * hardcoded to 1. No audio module API change. */ #define AUDIO_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define AUDIO_MODULE_API_VERSION_CURRENT AUDIO_MODULE_API_VERSION_0_1 /* First generation of audio devices had version hardcoded to 0. all devices with versions < 1.0 * will be considered of first generation API. */ #define AUDIO_DEVICE_API_VERSION_0_0 HARDWARE_DEVICE_API_VERSION(0, 0) #define AUDIO_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) #define AUDIO_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 0) #define AUDIO_DEVICE_API_VERSION_3_0 HARDWARE_DEVICE_API_VERSION(3, 0) #define AUDIO_DEVICE_API_VERSION_CURRENT AUDIO_DEVICE_API_VERSION_3_0 /* 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" /**************************************/ /** * standard audio parameters that the HAL may need to handle */ /** * 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" #define AUDIO_PARAMETER_VALUE_TTY_VCO "tty_vco" #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 */ #define AUDIO_PARAMETER_KEY_HAC "HACSetting" #define AUDIO_PARAMETER_VALUE_HAC_ON "ON" #define AUDIO_PARAMETER_VALUE_HAC_OFF "OFF" /* A2DP sink address set by framework */ #define AUDIO_PARAMETER_A2DP_SINK_ADDRESS "a2dp_sink_address" /* 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" /* 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" /** * 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" /** * 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" /**************************************/ /* common audio stream parameters and operations */ struct audio_stream { /** * Return the sampling rate in Hz - eg. 44100. */ uint32_t (*get_sample_rate)(const struct audio_stream *stream); /* currently unused - use set_parameters with key * AUDIO_PARAMETER_STREAM_SAMPLING_RATE */ int (*set_sample_rate)(struct audio_stream *stream, uint32_t rate); /** * Return size of input/output buffer in bytes for this stream - eg. 4800. * It should be a multiple of the frame size. See also get_input_buffer_size. */ size_t (*get_buffer_size)(const struct audio_stream *stream); /** * Return the channel mask - * e.g. AUDIO_CHANNEL_OUT_STEREO or AUDIO_CHANNEL_IN_STEREO */ audio_channel_mask_t (*get_channels)(const struct audio_stream *stream); /** * Return the audio format - e.g. AUDIO_FORMAT_PCM_16_BIT */ audio_format_t (*get_format)(const struct audio_stream *stream); /* currently unused - use set_parameters with key * AUDIO_PARAMETER_STREAM_FORMAT */ int (*set_format)(struct audio_stream *stream, audio_format_t format); /** * Put the audio hardware input/output into standby mode. * Driver should exit from standby mode at the next I/O operation. * Returns 0 on success and <0 on failure. */ int (*standby)(struct audio_stream *stream); /** dump the state of the audio input/output device */ int (*dump)(const struct audio_stream *stream, int fd); /** Return the set of device(s) which this stream is connected to */ audio_devices_t (*get_device)(const struct audio_stream *stream); /** * Currently unused - set_device() corresponds to set_parameters() with key * AUDIO_PARAMETER_STREAM_ROUTING for both input and output. * AUDIO_PARAMETER_STREAM_INPUT_SOURCE is an additional information used by * input streams only. */ int (*set_device)(struct audio_stream *stream, audio_devices_t device); /** * set/get audio stream parameters. The function accepts a list of * parameter key value pairs in the form: key1=value1;key2=value2;... * * Some keys are reserved for standard parameters (See AudioParameter class) * * If the implementation does not accept a parameter change while * the output is active but the parameter is acceptable otherwise, it must * return -ENOSYS. * * The audio flinger will put the stream in standby and then change the * parameter value. */ int (*set_parameters)(struct audio_stream *stream, const char *kv_pairs); /* * Returns a pointer to a heap allocated string. The caller is responsible * for freeing the memory for it using free(). */ char * (*get_parameters)(const struct audio_stream *stream, const char *keys); int (*add_audio_effect)(const struct audio_stream *stream, effect_handle_t effect); int (*remove_audio_effect)(const struct audio_stream *stream, effect_handle_t effect); }; typedef struct audio_stream audio_stream_t; /* type of asynchronous write callback events. Mutually exclusive */ typedef enum { STREAM_CBK_EVENT_WRITE_READY, /* non blocking write completed */ STREAM_CBK_EVENT_DRAIN_READY /* drain completed */ } stream_callback_event_t; typedef int (*stream_callback_t)(stream_callback_event_t event, void *param, void *cookie); /* type of drain requested to audio_stream_out->drain(). Mutually exclusive */ typedef enum { AUDIO_DRAIN_ALL, /* drain() returns when all data has been played */ AUDIO_DRAIN_EARLY_NOTIFY /* drain() returns a short time before all data from the current track has been played to give time for gapless track switch */ } audio_drain_type_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 * as users of this structure will cast a audio_stream to audio_stream_out pointer in contexts * where it's known the audio_stream references an audio_stream_out. */ struct audio_stream common; /** * Return the audio hardware driver estimated latency in milliseconds. */ uint32_t (*get_latency)(const struct audio_stream_out *stream); /** * Use this method in situations where audio mixing is done in the * hardware. This method serves as a direct interface with hardware, * allowing you to directly set the volume as apposed to via the framework. * This method might produce multiple PCM outputs or hardware accelerated * codecs, such as MP3 or AAC. */ int (*set_volume)(struct audio_stream_out *stream, float left, float right); /** * Write audio buffer to driver. Returns number of bytes written, or a * negative status_t. If at least one frame was written successfully prior to the error, * it is suggested that the driver return that successful (short) byte count * and then return an error in the subsequent call. * * If set_callback() has previously been called to enable non-blocking mode * the write() is not allowed to block. It must write only the number of * bytes that currently fit in the driver/hardware buffer and then return * this byte count. If this is less than the requested write size the * callback function must be called when more space is available in the * driver/hardware buffer. */ ssize_t (*write)(struct audio_stream_out *stream, const void* buffer, size_t bytes); /* return the number of audio frames written by the audio dsp to DAC since * the output has exited standby */ int (*get_render_position)(const struct audio_stream_out *stream, uint32_t *dsp_frames); /** * get the local time at which the next write to the audio driver will be presented. * The units are microseconds, where the epoch is decided by the local audio HAL. */ int (*get_next_write_timestamp)(const struct audio_stream_out *stream, int64_t *timestamp); /** * set the callback function for notifying completion of non-blocking * write and drain. * Calling this function implies that all future write() and drain() * must be non-blocking and use the callback to signal completion. */ int (*set_callback)(struct audio_stream_out *stream, stream_callback_t callback, void *cookie); /** * Notifies to the audio driver to stop playback however the queued buffers are * retained by the hardware. Useful for implementing pause/resume. Empty implementation * if not supported however should be implemented for hardware with non-trivial * latency. In the pause state audio hardware could still be using power. User may * consider calling suspend after a timeout. * * Implementation of this function is mandatory for offloaded playback. */ int (*pause)(struct audio_stream_out* stream); /** * Notifies to the audio driver to resume playback following a pause. * Returns error if called without matching pause. * * Implementation of this function is mandatory for offloaded playback. */ int (*resume)(struct audio_stream_out* stream); /** * Requests notification when data buffered by the driver/hardware has * been played. If set_callback() has previously been called to enable * non-blocking mode, the drain() must not block, instead it should return * quickly and completion of the drain is notified through the callback. * If set_callback() has not been called, the drain() must block until * completion. * If type==AUDIO_DRAIN_ALL, the drain completes when all previously written * data has been played. * If type==AUDIO_DRAIN_EARLY_NOTIFY, the drain completes shortly before all * data for the current track has played to allow time for the framework * to perform a gapless track switch. * * Drain must return immediately on stop() and flush() call * * Implementation of this function is mandatory for offloaded playback. */ int (*drain)(struct audio_stream_out* stream, audio_drain_type_t type ); /** * Notifies to the audio driver to flush the queued data. Stream must already * be paused before calling flush(). * * Implementation of this function is mandatory for offloaded playback. */ int (*flush)(struct audio_stream_out* stream); /** * Return a recent count of the number of audio frames presented to an external observer. * This excludes frames which have been written but are still in the pipeline. * The count is not reset to zero when output enters standby. * Also returns the value of CLOCK_MONOTONIC as of this presentation count. * The returned count is expected to be 'recent', * but does not need to be the most recent possible value. * However, the associated time should correspond to whatever count is returned. * Example: assume that N+M frames have been presented, where M is a 'small' number. * Then it is permissible to return N instead of N+M, * and the timestamp should correspond to N rather than N+M. * The terms 'recent' and 'small' are not defined. * They reflect the quality of the implementation. * * 3.0 and higher only. */ int (*get_presentation_position)(const struct audio_stream_out *stream, uint64_t *frames, struct timespec *timestamp); }; typedef struct audio_stream_out audio_stream_out_t; struct audio_stream_in { /** * Common methods of the audio stream in. This *must* be the first member of audio_stream_in * as users of this structure will cast a audio_stream to audio_stream_in pointer in contexts * where it's known the audio_stream references an audio_stream_in. */ struct audio_stream common; /** set the input gain for the audio driver. This method is for * for future use */ int (*set_gain)(struct audio_stream_in *stream, float gain); /** Read audio buffer in from audio driver. Returns number of bytes read, or a * negative status_t. If at least one frame was read prior to the error, * read should return that byte count and then return an error in the subsequent call. */ ssize_t (*read)(struct audio_stream_in *stream, void* buffer, size_t bytes); /** * Return the amount of input frames lost in the audio driver since the * last call of this function. * Audio driver is expected to reset the value to 0 and restart counting * upon returning the current value by this function call. * Such loss typically occurs when the user space process is blocked * longer than the capacity of audio driver buffers. * * Unit: the number of input audio frames */ uint32_t (*get_input_frames_lost)(struct audio_stream_in *stream); }; typedef struct audio_stream_in audio_stream_in_t; /** * return the frame size (number of bytes per sample). * * Deprecated: use audio_stream_out_frame_size() or audio_stream_in_frame_size() instead. */ __attribute__((__deprecated__)) static inline size_t audio_stream_frame_size(const struct audio_stream *s) { size_t chan_samp_sz; audio_format_t format = s->get_format(s); if (audio_is_linear_pcm(format)) { chan_samp_sz = audio_bytes_per_sample(format); return popcount(s->get_channels(s)) * chan_samp_sz; } return sizeof(int8_t); } /** * return the frame size (number of bytes per sample) of an output stream. */ static inline size_t audio_stream_out_frame_size(const struct audio_stream_out *s) { size_t chan_samp_sz; audio_format_t format = s->common.get_format(&s->common); if (audio_is_linear_pcm(format)) { chan_samp_sz = audio_bytes_per_sample(format); return audio_channel_count_from_out_mask(s->common.get_channels(&s->common)) * chan_samp_sz; } return sizeof(int8_t); } /** * return the frame size (number of bytes per sample) of an input stream. */ static inline size_t audio_stream_in_frame_size(const struct audio_stream_in *s) { size_t chan_samp_sz; audio_format_t format = s->common.get_format(&s->common); if (audio_is_linear_pcm(format)) { chan_samp_sz = audio_bytes_per_sample(format); return audio_channel_count_from_in_mask(s->common.get_channels(&s->common)) * chan_samp_sz; } return sizeof(int8_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. */ struct audio_module { struct hw_module_t common; }; struct audio_hw_device { /** * Common methods of the audio device. This *must* be the first member of audio_hw_device * as users of this structure will cast a hw_device_t to audio_hw_device pointer in contexts * where it's known the hw_device_t references an audio_hw_device. */ struct hw_device_t common; /** * used by audio flinger to enumerate what devices are supported by * each audio_hw_device implementation. * * Return value is a bitmask of 1 or more values of audio_devices_t * * NOTE: audio HAL implementations starting with * AUDIO_DEVICE_API_VERSION_2_0 do not implement this function. * All supported devices should be listed in audio_policy.conf * file and the audio policy manager must choose the appropriate * audio module based on information in this file. */ uint32_t (*get_supported_devices)(const struct audio_hw_device *dev); /** * check to see if the audio hardware interface has been initialized. * returns 0 on success, -ENODEV on failure. */ int (*init_check)(const struct audio_hw_device *dev); /** set the audio volume of a voice call. Range is between 0.0 and 1.0 */ int (*set_voice_volume)(struct audio_hw_device *dev, float volume); /** * set the audio volume for all audio activities other than voice call. * Range between 0.0 and 1.0. If any value other than 0 is returned, * the software mixer will emulate this capability. */ int (*set_master_volume)(struct audio_hw_device *dev, float volume); /** * Get the current master volume value for the HAL, if the HAL supports * master volume control. AudioFlinger will query this value from the * primary audio HAL when the service starts and use the value for setting * the initial master volume across all HALs. HALs which do not support * this method may leave it set to NULL. */ int (*get_master_volume)(struct audio_hw_device *dev, float *volume); /** * set_mode is called when the audio mode changes. AUDIO_MODE_NORMAL mode * is for standard audio playback, AUDIO_MODE_RINGTONE when a ringtone is * playing, and AUDIO_MODE_IN_CALL when a call is in progress. */ int (*set_mode)(struct audio_hw_device *dev, audio_mode_t mode); /* mic mute */ int (*set_mic_mute)(struct audio_hw_device *dev, bool state); int (*get_mic_mute)(const struct audio_hw_device *dev, bool *state); /* set/get global audio parameters */ int (*set_parameters)(struct audio_hw_device *dev, const char *kv_pairs); /* * Returns a pointer to a heap allocated string. The caller is responsible * for freeing the memory for it using free(). */ char * (*get_parameters)(const struct audio_hw_device *dev, const char *keys); /* Returns audio input buffer size according to parameters passed or * 0 if one of the parameters is not supported. * See also get_buffer_size which is for a particular stream. */ size_t (*get_input_buffer_size)(const struct audio_hw_device *dev, const struct audio_config *config); /** This method creates and opens the audio hardware output stream. * The "address" parameter qualifies the "devices" audio device type if needed. * The format format depends on the device type: * - Bluetooth devices use the MAC address of the device in the form "00:11:22:AA:BB:CC" * - USB devices use the ALSA card and device numbers in the form "card=X;device=Y" * - Other devices may use a number or any other string. */ int (*open_output_stream)(struct audio_hw_device *dev, audio_io_handle_t handle, audio_devices_t devices, audio_output_flags_t flags, struct audio_config *config, struct audio_stream_out **stream_out, const char *address); void (*close_output_stream)(struct audio_hw_device *dev, struct audio_stream_out* stream_out); /** This method creates and opens the audio hardware input stream */ int (*open_input_stream)(struct audio_hw_device *dev, audio_io_handle_t handle, audio_devices_t devices, struct audio_config *config, struct audio_stream_in **stream_in, audio_input_flags_t flags, const char *address, audio_source_t source); void (*close_input_stream)(struct audio_hw_device *dev, struct audio_stream_in *stream_in); /** This method dumps the state of the audio hardware */ int (*dump)(const struct audio_hw_device *dev, int fd); /** * set the audio mute status for all audio activities. If any value other * than 0 is returned, the software mixer will emulate this capability. */ int (*set_master_mute)(struct audio_hw_device *dev, bool mute); /** * Get the current master mute status for the HAL, if the HAL supports * master mute control. AudioFlinger will query this value from the primary * audio HAL when the service starts and use the value for setting the * initial master mute across all HALs. HALs which do not support this * method may leave it set to NULL. */ int (*get_master_mute)(struct audio_hw_device *dev, bool *mute); /** * Routing control */ /* Creates an audio patch between several source and sink ports. * The handle is allocated by the HAL and should be unique for this * audio HAL module. */ int (*create_audio_patch)(struct audio_hw_device *dev, unsigned int num_sources, const struct audio_port_config *sources, unsigned int num_sinks, const struct audio_port_config *sinks, audio_patch_handle_t *handle); /* Release an audio patch */ int (*release_audio_patch)(struct audio_hw_device *dev, audio_patch_handle_t handle); /* Fills the list of supported attributes for a given audio port. * As input, "port" contains the information (type, role, address etc...) * needed by the HAL to identify the port. * As output, "port" contains possible attributes (sampling rates, formats, * channel masks, gain controllers...) for this port. */ int (*get_audio_port)(struct audio_hw_device *dev, struct audio_port *port); /* Set audio port configuration */ int (*set_audio_port_config)(struct audio_hw_device *dev, const struct audio_port_config *config); }; typedef struct audio_hw_device audio_hw_device_t; /** convenience API for opening and closing a supported device */ 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); } static inline int audio_hw_device_close(struct audio_hw_device* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_AUDIO_INTERFACE_H android-headers-23/23/hardware/audio_alsaops.h000066400000000000000000000061121264465411000213510ustar00rootroot00000000000000/* * 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. */ /* This file contains shared utility functions to handle the tinyalsa * implementation for Android internal audio, generally in the hardware layer. * Some routines may log a fatal error on failure, as noted. */ #ifndef ANDROID_AUDIO_ALSAOPS_H #define ANDROID_AUDIO_ALSAOPS_H #include #include #include __BEGIN_DECLS /* Converts audio_format to pcm_format. * Parameters: * format the audio_format_t to convert * * Logs a fatal error if format is not a valid convertible audio_format_t. */ static inline enum pcm_format pcm_format_from_audio_format(audio_format_t format) { switch (format) { #ifdef HAVE_BIG_ENDIAN case AUDIO_FORMAT_PCM_16_BIT: return PCM_FORMAT_S16_BE; case AUDIO_FORMAT_PCM_24_BIT_PACKED: return PCM_FORMAT_S24_3BE; case AUDIO_FORMAT_PCM_32_BIT: return PCM_FORMAT_S32_BE; case AUDIO_FORMAT_PCM_8_24_BIT: return PCM_FORMAT_S24_BE; #else case AUDIO_FORMAT_PCM_16_BIT: return PCM_FORMAT_S16_LE; case AUDIO_FORMAT_PCM_24_BIT_PACKED: return PCM_FORMAT_S24_3LE; case AUDIO_FORMAT_PCM_32_BIT: return PCM_FORMAT_S32_LE; case AUDIO_FORMAT_PCM_8_24_BIT: return PCM_FORMAT_S24_LE; #endif case AUDIO_FORMAT_PCM_FLOAT: /* there is no equivalent for float */ default: LOG_ALWAYS_FATAL("pcm_format_from_audio_format: invalid audio format %#x", format); return 0; } } /* Converts pcm_format to audio_format. * Parameters: * format the pcm_format to convert * * Logs a fatal error if format is not a valid convertible pcm_format. */ static inline audio_format_t audio_format_from_pcm_format(enum pcm_format format) { switch (format) { #ifdef HAVE_BIG_ENDIAN case PCM_FORMAT_S16_BE: return AUDIO_FORMAT_PCM_16_BIT; case PCM_FORMAT_S24_3BE: return AUDIO_FORMAT_PCM_24_BIT_PACKED; case PCM_FORMAT_S24_BE: return AUDIO_FORMAT_PCM_8_24_BIT; case PCM_FORMAT_S32_BE: return AUDIO_FORMAT_PCM_32_BIT; #else case PCM_FORMAT_S16_LE: return AUDIO_FORMAT_PCM_16_BIT; case PCM_FORMAT_S24_3LE: return AUDIO_FORMAT_PCM_24_BIT_PACKED; case PCM_FORMAT_S24_LE: return AUDIO_FORMAT_PCM_8_24_BIT; case PCM_FORMAT_S32_LE: return AUDIO_FORMAT_PCM_32_BIT; #endif default: LOG_ALWAYS_FATAL("audio_format_from_pcm_format: invalid pcm format %#x", format); return 0; } } __END_DECLS #endif /* ANDROID_AUDIO_ALSAOPS_H */ android-headers-23/23/hardware/audio_effect.h000066400000000000000000001477571264465411000211700ustar00rootroot00000000000000/* * 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_AUDIO_EFFECT_H #define ANDROID_AUDIO_EFFECT_H #include #include #include #include #include #include #include __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 // +---------------------------+-----------+----------------------------------- // 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) #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 ///////////////////////////////////////////////// // Effect control interface version 2.0 #define EFFECT_CONTROL_API_VERSION EFFECT_MAKE_API_VERSION(2,0) // Effect control interface structure: effect_interface_s // The effect control interface is exposed by each effect engine implementation. It consists of // a set of functions controlling the configuration, activation and process of the engine. // The functions are grouped in a structure of type effect_interface_s. // // Effect control interface handle: effect_handle_t // The effect_handle_t serves two purposes regarding the implementation of the effect engine: // - 1 it is the address of a pointer to an effect_interface_s structure where the functions // of the effect control API for a particular effect are located. // - 2 it is the address of the context of a particular effect instance. // A typical implementation in the effect library would define a structure as follows: // struct effect_module_s { // const struct effect_interface_s *itfe; // effect_config_t config; // effect_context_t context; // } // The implementation of EffectCreate() function would then allocate a structure of this // 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 { //////////////////////////////////////////////////////////////////////////////// // // Function: process // // Description: Effect process function. Takes input samples as specified // (count and location) in input buffer descriptor and output processed // samples as specified in output buffer descriptor. If the buffer descriptor // is not specified the function must use either the buffer or the // buffer provider function installed by the EFFECT_CMD_SET_CONFIG command. // The effect framework will call the process() function after the EFFECT_CMD_ENABLE // command is received and until the EFFECT_CMD_DISABLE is received. When the engine // receives the EFFECT_CMD_DISABLE command it should turn off the effect gracefully // and when done indicate that it is OK to stop calling the process() function by // returning the -ENODATA status. // // NOTE: the process() function implementation should be "real-time safe" that is // it should not perform blocking calls: malloc/free, sleep, read/write/open/close, // pthread_cond_wait/pthread_mutex_lock... // // Input: // self: handle to the effect interface this function // is called on. // inBuffer: buffer descriptor indicating where to read samples to process. // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG command. // // outBuffer: buffer descriptor indicating where to write processed samples. // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG command. // // Output: // returned value: 0 successful operation // -ENODATA the engine has finished the disable phase and the framework // can stop calling process() // -EINVAL invalid interface handle or // invalid input/output buffer description //////////////////////////////////////////////////////////////////////////////// int32_t (*process)(effect_handle_t self, audio_buffer_t *inBuffer, audio_buffer_t *outBuffer); //////////////////////////////////////////////////////////////////////////////// // // Function: command // // Description: Send a command and receive a response to/from effect engine. // // Input: // self: handle to the effect interface this function // is called on. // cmdCode: command code: the command can be a standardized command defined in // effect_command_e (see below) or a proprietary command. // cmdSize: size of command in bytes // pCmdData: pointer to command data // pReplyData: pointer to reply data // // Input/Output: // replySize: maximum size of reply data as input // actual size of reply data as output // // Output: // returned value: 0 successful operation // -EINVAL invalid interface handle or // invalid command/reply size or format according to // command code // The return code should be restricted to indicate problems related to this API // specification. Status related to the execution of a particular command should be // indicated as part of the reply field. // // *pReplyData updated with command response // //////////////////////////////////////////////////////////////////////////////// int32_t (*command)(effect_handle_t self, uint32_t cmdCode, uint32_t cmdSize, void *pCmdData, uint32_t *replySize, void *pReplyData); //////////////////////////////////////////////////////////////////////////////// // // Function: get_descriptor // // Description: Returns the effect descriptor // // Input: // self: handle to the effect interface this function // is called on. // // Input/Output: // pDescriptor: address where to return the effect descriptor. // // Output: // returned value: 0 successful operation. // -EINVAL invalid interface handle or invalid pDescriptor // *pDescriptor: updated with the effect descriptor. // //////////////////////////////////////////////////////////////////////////////// int32_t (*get_descriptor)(effect_handle_t self, effect_descriptor_t *pDescriptor); //////////////////////////////////////////////////////////////////////////////// // // Function: process_reverse // // Description: Process reverse stream function. This function is used to pass // a reference stream to the effect engine. If the engine does not need a reference // stream, this function pointer can be set to NULL. // This function would typically implemented by an Echo Canceler. // // Input: // self: handle to the effect interface this function // is called on. // inBuffer: buffer descriptor indicating where to read samples to process. // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG_REVERSE command. // // outBuffer: buffer descriptor indicating where to write processed samples. // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG_REVERSE command. // If the buffer and buffer provider in the configuration received by // EFFECT_CMD_SET_CONFIG_REVERSE are also NULL, do not return modified reverse // stream data // // Output: // returned value: 0 successful operation // -ENODATA the engine has finished the disable phase and the framework // can stop calling process_reverse() // -EINVAL invalid interface handle or // invalid input/output buffer description //////////////////////////////////////////////////////////////////////////////// int32_t (*process_reverse)(effect_handle_t self, audio_buffer_t *inBuffer, 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; // 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 ///////////////////////////////////////////////// // Effect library interface version 3.0 // Note that EffectsFactory.c only checks the major version component, so changes to the minor // number can only be used for fully backwards compatible changes #define EFFECT_LIBRARY_API_VERSION EFFECT_MAKE_API_VERSION(3,0) #define AUDIO_EFFECT_LIBRARY_TAG ((('A') << 24) | (('E') << 16) | (('L') << 8) | ('T')) // Every effect library must have a data structure named AUDIO_EFFECT_LIBRARY_INFO_SYM // and the fields of this data structure must begin with audio_effect_library_t typedef struct audio_effect_library_s { // tag must be initialized to AUDIO_EFFECT_LIBRARY_TAG uint32_t tag; // Version of the effect library API : 0xMMMMmmmm MMMM: Major, mmmm: minor uint32_t version; // Name of this library const char *name; // Author/owner/implementor of the library const char *implementor; //////////////////////////////////////////////////////////////////////////////// // // Function: create_effect // // Description: Creates an effect engine of the specified implementation uuid and // returns an effect control interface on this engine. The function will allocate the // resources for an instance of the requested effect engine and return // a handle on the effect control interface. // // Input: // uuid: pointer to the effect uuid. // sessionId: audio session to which this effect instance will be attached. // All effects created with the same session ID are connected in series and process // the same signal stream. Knowing that two effects are part of the same effect // chain can help the library implement some kind of optimizations. // ioId: identifies the output or input stream this effect is directed to in // audio HAL. // For future use especially with tunneled HW accelerated effects // // Input/Output: // pHandle: address where to return the effect interface handle. // // Output: // returned value: 0 successful operation. // -ENODEV library failed to initialize // -EINVAL invalid pEffectUuid or pHandle // -ENOENT no effect with this uuid found // *pHandle: updated with the effect interface handle. // //////////////////////////////////////////////////////////////////////////////// int32_t (*create_effect)(const effect_uuid_t *uuid, int32_t sessionId, int32_t ioId, effect_handle_t *pHandle); //////////////////////////////////////////////////////////////////////////////// // // Function: release_effect // // Description: Releases the effect engine whose handle is given as argument. // All resources allocated to this particular instance of the effect are // released. // // Input: // handle: handle on the effect interface to be released. // // Output: // returned value: 0 successful operation. // -ENODEV library failed to initialize // -EINVAL invalid interface handle // //////////////////////////////////////////////////////////////////////////////// int32_t (*release_effect)(effect_handle_t handle); //////////////////////////////////////////////////////////////////////////////// // // Function: get_descriptor // // Description: Returns the descriptor of the effect engine which implementation UUID is // given as argument. // // Input/Output: // uuid: pointer to the effect uuid. // pDescriptor: address where to return the effect descriptor. // // Output: // returned value: 0 successful operation. // -ENODEV library failed to initialize // -EINVAL invalid pDescriptor or uuid // *pDescriptor: updated with the effect descriptor. // //////////////////////////////////////////////////////////////////////////////// int32_t (*get_descriptor)(const effect_uuid_t *uuid, effect_descriptor_t *pDescriptor); } audio_effect_library_t; // Name of the hal_module_info #define AUDIO_EFFECT_LIBRARY_INFO_SYM AELI // Name of the hal_module_info as a string #define AUDIO_EFFECT_LIBRARY_INFO_SYM_AS_STR "AELI" __END_DECLS #endif // ANDROID_AUDIO_EFFECT_H android-headers-23/23/hardware/audio_policy.h000066400000000000000000000452051264465411000212140ustar00rootroot00000000000000/* * 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_AUDIO_POLICY_INTERFACE_H #define ANDROID_AUDIO_POLICY_INTERFACE_H #include #include #include #include #include #include __BEGIN_DECLS /** * The id of this module */ #define AUDIO_POLICY_HARDWARE_MODULE_ID "audio_policy" /** * Name of the audio devices to open */ #define AUDIO_POLICY_INTERFACE "policy" /* ---------------------------------------------------------------------------- */ /* * The audio_policy and audio_policy_service_ops structs define the * communication interfaces between the platform specific audio policy manager * and Android generic audio policy manager. * The platform specific audio policy manager must implement methods of the * audio_policy struct. * This implementation makes use of the audio_policy_service_ops to control * the activity and configuration of audio input and output streams. * * The platform specific audio policy manager is in charge of the audio * routing and volume control policies for a given platform. * The main roles of this module are: * - keep track of current system state (removable device connections, phone * state, user requests...). * System state changes and user actions are notified to audio policy * manager with methods of the audio_policy. * * - process get_output() queries received when AudioTrack objects are * created: Those queries return a handler on an output that has been * selected, configured and opened by the audio policy manager and that * must be used by the AudioTrack when registering to the AudioFlinger * with the createTrack() method. * When the AudioTrack object is released, a release_output() query * is received and the audio policy manager can decide to close or * reconfigure the output depending on other streams using this output and * current system state. * * - similarly process get_input() and release_input() queries received from * AudioRecord objects and configure audio inputs. * - process volume control requests: the stream volume is converted from * an index value (received from UI) to a float value applicable to each * output as a function of platform specific settings and current output * route (destination device). It also make sure that streams are not * muted if not allowed (e.g. camera shutter sound in some countries). */ /* XXX: this should be defined OUTSIDE of frameworks/base */ struct effect_descriptor_s; struct audio_policy { /* * configuration functions */ /* indicate a change in device connection status */ int (*set_device_connection_state)(struct audio_policy *pol, audio_devices_t device, audio_policy_dev_state_t state, const char *device_address); /* retrieve a device connection status */ audio_policy_dev_state_t (*get_device_connection_state)( const struct audio_policy *pol, audio_devices_t device, const char *device_address); /* indicate a change in phone state. Valid phones states are defined * by audio_mode_t */ void (*set_phone_state)(struct audio_policy *pol, audio_mode_t state); /* deprecated, never called (was "indicate a change in ringer mode") */ void (*set_ringer_mode)(struct audio_policy *pol, uint32_t mode, uint32_t mask); /* force using a specific device category for the specified usage */ void (*set_force_use)(struct audio_policy *pol, audio_policy_force_use_t usage, audio_policy_forced_cfg_t config); /* retrieve current device category forced for a given usage */ audio_policy_forced_cfg_t (*get_force_use)(const struct audio_policy *pol, audio_policy_force_use_t usage); /* if can_mute is true, then audio streams that are marked ENFORCED_AUDIBLE * can still be muted. */ void (*set_can_mute_enforced_audible)(struct audio_policy *pol, bool can_mute); /* check proper initialization */ int (*init_check)(const struct audio_policy *pol); /* * Audio routing query functions */ /* request an output appropriate for playback of the supplied stream type and * parameters */ audio_io_handle_t (*get_output)(struct audio_policy *pol, audio_stream_type_t stream, uint32_t samplingRate, audio_format_t format, audio_channel_mask_t channelMask, audio_output_flags_t flags, const audio_offload_info_t *offloadInfo); /* indicates to the audio policy manager that the output starts being used * by corresponding stream. */ int (*start_output)(struct audio_policy *pol, audio_io_handle_t output, audio_stream_type_t stream, int session); /* indicates to the audio policy manager that the output stops being used * by corresponding stream. */ int (*stop_output)(struct audio_policy *pol, audio_io_handle_t output, audio_stream_type_t stream, int session); /* releases the output. */ void (*release_output)(struct audio_policy *pol, audio_io_handle_t output); /* request an input appropriate for record from the supplied device with * supplied parameters. */ audio_io_handle_t (*get_input)(struct audio_policy *pol, audio_source_t inputSource, uint32_t samplingRate, audio_format_t format, audio_channel_mask_t channelMask, audio_in_acoustics_t acoustics); /* indicates to the audio policy manager that the input starts being used */ int (*start_input)(struct audio_policy *pol, audio_io_handle_t input); /* indicates to the audio policy manager that the input stops being used. */ int (*stop_input)(struct audio_policy *pol, audio_io_handle_t input); /* releases the input. */ void (*release_input)(struct audio_policy *pol, audio_io_handle_t input); /* * volume control functions */ /* initialises stream volume conversion parameters by specifying volume * index range. The index range for each stream is defined by AudioService. */ void (*init_stream_volume)(struct audio_policy *pol, audio_stream_type_t stream, int index_min, int index_max); /* sets the new stream volume at a level corresponding to the supplied * index. The index is within the range specified by init_stream_volume() */ int (*set_stream_volume_index)(struct audio_policy *pol, audio_stream_type_t stream, int index); /* retrieve current volume index for the specified stream */ int (*get_stream_volume_index)(const struct audio_policy *pol, audio_stream_type_t stream, int *index); /* sets the new stream volume at a level corresponding to the supplied * index for the specified device. * The index is within the range specified by init_stream_volume() */ int (*set_stream_volume_index_for_device)(struct audio_policy *pol, audio_stream_type_t stream, int index, audio_devices_t device); /* retrieve current volume index for the specified stream for the specified device */ int (*get_stream_volume_index_for_device)(const struct audio_policy *pol, audio_stream_type_t stream, int *index, audio_devices_t device); /* return the strategy corresponding to a given stream type */ uint32_t (*get_strategy_for_stream)(const struct audio_policy *pol, audio_stream_type_t stream); /* return the enabled output devices for the given stream type */ audio_devices_t (*get_devices_for_stream)(const struct audio_policy *pol, audio_stream_type_t stream); /* Audio effect management */ audio_io_handle_t (*get_output_for_effect)(struct audio_policy *pol, const struct effect_descriptor_s *desc); int (*register_effect)(struct audio_policy *pol, const struct effect_descriptor_s *desc, audio_io_handle_t output, uint32_t strategy, int session, int id); int (*unregister_effect)(struct audio_policy *pol, int id); int (*set_effect_enabled)(struct audio_policy *pol, int id, bool enabled); bool (*is_stream_active)(const struct audio_policy *pol, audio_stream_type_t stream, uint32_t in_past_ms); bool (*is_stream_active_remotely)(const struct audio_policy *pol, audio_stream_type_t stream, uint32_t in_past_ms); bool (*is_source_active)(const struct audio_policy *pol, audio_source_t source); /* dump state */ int (*dump)(const struct audio_policy *pol, int fd); /* check if offload is possible for given sample rate, bitrate, duration, ... */ bool (*is_offload_supported)(const struct audio_policy *pol, const audio_offload_info_t *info); }; struct audio_policy_service_ops { /* * Audio output Control functions */ /* Opens an audio output with the requested parameters. * * The parameter values can indicate to use the default values in case the * audio policy manager has no specific requirements for the output being * opened. * * When the function returns, the parameter values reflect the actual * values used by the audio hardware output stream. * * The audio policy manager can check if the proposed parameters are * suitable or not and act accordingly. */ audio_io_handle_t (*open_output)(void *service, audio_devices_t *pDevices, uint32_t *pSamplingRate, audio_format_t *pFormat, audio_channel_mask_t *pChannelMask, uint32_t *pLatencyMs, audio_output_flags_t flags); /* creates a special output that is duplicated to the two outputs passed as * arguments. The duplication is performed by * a special mixer thread in the AudioFlinger. */ audio_io_handle_t (*open_duplicate_output)(void *service, audio_io_handle_t output1, audio_io_handle_t output2); /* closes the output stream */ int (*close_output)(void *service, audio_io_handle_t output); /* suspends the output. * * When an output is suspended, the corresponding audio hardware output * stream is placed in standby and the AudioTracks attached to the mixer * thread are still processed but the output mix is discarded. */ int (*suspend_output)(void *service, audio_io_handle_t output); /* restores a suspended output. */ int (*restore_output)(void *service, audio_io_handle_t output); /* */ /* Audio input Control functions */ /* */ /* opens an audio input * deprecated - new implementations should use open_input_on_module, * and the acoustics parameter is ignored */ audio_io_handle_t (*open_input)(void *service, audio_devices_t *pDevices, uint32_t *pSamplingRate, audio_format_t *pFormat, audio_channel_mask_t *pChannelMask, audio_in_acoustics_t acoustics); /* closes an audio input */ int (*close_input)(void *service, audio_io_handle_t input); /* */ /* misc control functions */ /* */ /* set a stream volume for a particular output. * * For the same user setting, a given stream type can have different * volumes for each output (destination device) it is attached to. */ int (*set_stream_volume)(void *service, audio_stream_type_t stream, float volume, audio_io_handle_t output, int delay_ms); /* invalidate a stream type, causing a reroute to an unspecified new output */ int (*invalidate_stream)(void *service, audio_stream_type_t stream); /* function enabling to send proprietary informations directly from audio * policy manager to audio hardware interface. */ void (*set_parameters)(void *service, audio_io_handle_t io_handle, const char *kv_pairs, int delay_ms); /* function enabling to receive proprietary informations directly from * audio hardware interface to audio policy manager. * * Returns a pointer to a heap allocated string. The caller is responsible * for freeing the memory for it using free(). */ char * (*get_parameters)(void *service, audio_io_handle_t io_handle, const char *keys); /* request the playback of a tone on the specified stream. * used for instance to replace notification sounds when playing over a * telephony device during a phone call. */ int (*start_tone)(void *service, audio_policy_tone_t tone, audio_stream_type_t stream); int (*stop_tone)(void *service); /* set down link audio volume. */ int (*set_voice_volume)(void *service, float volume, int delay_ms); /* move effect to the specified output */ int (*move_effects)(void *service, int session, audio_io_handle_t src_output, audio_io_handle_t dst_output); /* loads an audio hw module. * * The module name passed is the base name of the HW module library, e.g "primary" or "a2dp". * The function returns a handle on the module that will be used to specify a particular * module when calling open_output_on_module() or open_input_on_module() */ audio_module_handle_t (*load_hw_module)(void *service, const char *name); /* Opens an audio output on a particular HW module. * * Same as open_output() but specifying a specific HW module on which the output must be opened. */ audio_io_handle_t (*open_output_on_module)(void *service, audio_module_handle_t module, audio_devices_t *pDevices, uint32_t *pSamplingRate, audio_format_t *pFormat, audio_channel_mask_t *pChannelMask, uint32_t *pLatencyMs, audio_output_flags_t flags, const audio_offload_info_t *offloadInfo); /* Opens an audio input on a particular HW module. * * Same as open_input() but specifying a specific HW module on which the input must be opened. * Also removed deprecated acoustics parameter */ audio_io_handle_t (*open_input_on_module)(void *service, audio_module_handle_t module, audio_devices_t *pDevices, uint32_t *pSamplingRate, audio_format_t *pFormat, audio_channel_mask_t *pChannelMask); }; /**********************************************************************/ /** * 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 audio_policy_module { struct hw_module_t common; } audio_policy_module_t; struct audio_policy_device { /** * Common methods of the audio policy device. This *must* be the first member of * audio_policy_device as users of this structure will cast a hw_device_t to * audio_policy_device pointer in contexts where it's known the hw_device_t references an * audio_policy_device. */ struct hw_device_t common; int (*create_audio_policy)(const struct audio_policy_device *device, struct audio_policy_service_ops *aps_ops, void *service, struct audio_policy **ap); int (*destroy_audio_policy)(const struct audio_policy_device *device, struct audio_policy *ap); }; /** convenience API for opening and closing a supported device */ static inline int audio_policy_dev_open(const hw_module_t* module, struct audio_policy_device** device) { return module->methods->open(module, AUDIO_POLICY_INTERFACE, (hw_device_t**)device); } static inline int audio_policy_dev_close(struct audio_policy_device* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_AUDIO_POLICY_INTERFACE_H android-headers-23/23/hardware/bluetooth.h000066400000000000000000000450771264465411000205500ustar00rootroot00000000000000/* * 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_BLUETOOTH_H #define ANDROID_INCLUDE_BLUETOOTH_H #include #include #include #include #include __BEGIN_DECLS /** * The Bluetooth Hardware Module ID */ #define BT_HARDWARE_MODULE_ID "bluetooth" #define BT_STACK_MODULE_ID "bluetooth" #define BT_STACK_TEST_MODULE_ID "bluetooth_test" /* Bluetooth profile interface IDs */ #define BT_PROFILE_HANDSFREE_ID "handsfree" #define BT_PROFILE_HANDSFREE_CLIENT_ID "handsfree_client" #define BT_PROFILE_ADVANCED_AUDIO_ID "a2dp" #define BT_PROFILE_ADVANCED_AUDIO_SINK_ID "a2dp_sink" #define BT_PROFILE_HEALTH_ID "health" #define BT_PROFILE_SOCKETS_ID "socket" #define BT_PROFILE_HIDHOST_ID "hidhost" #define BT_PROFILE_PAN_ID "pan" #define BT_PROFILE_MAP_CLIENT_ID "map_client" #define BT_PROFILE_SDP_CLIENT_ID "sdp" #define BT_PROFILE_GATT_ID "gatt" #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 Device Name */ typedef struct { uint8_t name[249]; } __attribute__((packed))bt_bdname_t; /** Bluetooth Adapter Visibility Modes*/ typedef enum { BT_SCAN_MODE_NONE, BT_SCAN_MODE_CONNECTABLE, BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE } bt_scan_mode_t; /** Bluetooth Adapter State */ typedef enum { BT_STATE_OFF, BT_STATE_ON } bt_state_t; /** Bluetooth Error Status */ /** We need to build on this */ typedef enum { BT_STATUS_SUCCESS, BT_STATUS_FAIL, BT_STATUS_NOT_READY, BT_STATUS_NOMEM, BT_STATUS_BUSY, BT_STATUS_DONE, /* request already completed */ BT_STATUS_UNSUPPORTED, BT_STATUS_PARM_INVALID, BT_STATUS_UNHANDLED, BT_STATUS_AUTH_FAILURE, BT_STATUS_RMT_DEV_DOWN, BT_STATUS_AUTH_REJECTED } bt_status_t; /** Bluetooth PinKey Code */ typedef struct { uint8_t pin[16]; } __attribute__((packed))bt_pin_code_t; typedef struct { uint8_t status; uint8_t ctrl_state; /* stack reported state */ uint64_t tx_time; /* in ms */ uint64_t rx_time; /* in ms */ uint64_t idle_time; /* in ms */ uint64_t energy_used; /* a product of mA, V and ms */ } __attribute__((packed))bt_activity_energy_info; /** Bluetooth Adapter Discovery state */ typedef enum { BT_DISCOVERY_STOPPED, BT_DISCOVERY_STARTED } bt_discovery_state_t; /** Bluetooth ACL connection state */ typedef enum { BT_ACL_STATE_CONNECTED, 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; uint16_t channel; char name[256]; // what's the maximum length } bt_service_record_t; /** Bluetooth Remote Version info */ typedef struct { int version; int sub_ver; int manufacturer; } bt_remote_version_t; typedef struct { uint16_t version_supported; uint8_t local_privacy_enabled; uint8_t max_adv_instance; uint8_t rpa_offload_supported; uint8_t max_irk_list_size; uint8_t max_adv_filter_supported; uint8_t activity_energy_info_supported; uint16_t scan_result_storage_size; uint16_t total_trackable_advertisers; bool extended_scan_support; bool debug_logging_supported; }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, } bt_property_type_t; /** Bluetooth Adapter Property data structure */ typedef struct { bt_property_type_t type; int len; void *val; } bt_property_t; /** Bluetooth Device Type */ typedef enum { BT_DEVICE_DEVTYPE_BREDR = 0x1, BT_DEVICE_DEVTYPE_BLE, BT_DEVICE_DEVTYPE_DUAL } bt_device_type_t; /** Bluetooth Bond state */ typedef enum { BT_BOND_STATE_NONE, BT_BOND_STATE_BONDING, BT_BOND_STATE_BONDED } bt_bond_state_t; /** Bluetooth SSP Bonding Variant */ typedef enum { BT_SSP_VARIANT_PASSKEY_CONFIRMATION, BT_SSP_VARIANT_PASSKEY_ENTRY, BT_SSP_VARIANT_CONSENT, BT_SSP_VARIANT_PASSKEY_NOTIFICATION } bt_ssp_variant_t; #define BT_MAX_NUM_UUIDS 32 /** Bluetooth Interface callbacks */ /** Bluetooth Enable/Disable Callback. */ typedef void (*adapter_state_changed_callback)(bt_state_t state); /** GET/SET Adapter Properties callback */ /* TODO: For the GET/SET property APIs/callbacks, we may need a session * identifier to associate the call with the callback. This would be needed * whenever more than one simultaneous instance of the same adapter_type * is get/set. * * If this is going to be handled in the Java framework, then we do not need * to manage sessions here. */ typedef void (*adapter_properties_callback)(bt_status_t status, int num_properties, bt_property_t *properties); /** GET/SET Remote Device Properties callback */ /** TODO: For remote device properties, do not see a need to get/set * multiple properties - num_properties shall be 1 */ typedef void (*remote_device_properties_callback)(bt_status_t status, bt_bdaddr_t *bd_addr, int num_properties, bt_property_t *properties); /** New device discovered callback */ /** If EIR data is not present, then BD_NAME and RSSI shall be NULL and -1 * respectively */ typedef void (*device_found_callback)(int num_properties, bt_property_t *properties); /** Discovery state changed callback */ 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, bt_bdname_t *bd_name, uint32_t cod, bool min_16_digit); /** Bluetooth SSP Request callback - Just Works & Numeric Comparison*/ /** pass_key - Shall be 0 for BT_SSP_PAIRING_VARIANT_CONSENT & * 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, bt_bdname_t *bd_name, uint32_t cod, bt_ssp_variant_t pairing_variant, uint32_t pass_key); /** 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, 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, bt_acl_state_t state); typedef enum { ASSOCIATE_JVM, DISASSOCIATE_JVM } bt_cb_thread_evt; /** Thread Associate/Disassociate JVM Callback */ /* Callback that is invoked by the callback thread to allow upper layer to attach/detach to/from * the JVM */ typedef void (*callback_thread_event)(bt_cb_thread_evt evt); /** Bluetooth Test Mode Callback */ /* 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); /* 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 */ typedef void (*le_test_mode_callback)(bt_status_t status, uint16_t num_packets); /** Callback invoked when energy details are obtained */ /* Ctrl_state-Current controller state-Active-1,scan-2,or idle-3 state as defined by HCI spec. * If the ctrl_state value is 0, it means the API call failed * Time values-In milliseconds as returned by the controller * Energy used-Value as returned by the controller * Status-Provides the status of the read_energy_info API call */ typedef void (*energy_info_callback)(bt_activity_energy_info *energy_info); /** TODO: Add callbacks for Link Up/Down and other generic * notifications/callbacks */ /** Bluetooth DM callback structure. */ typedef struct { /** set to sizeof(bt_callbacks_t) */ size_t size; adapter_state_changed_callback adapter_state_changed_cb; adapter_properties_callback adapter_properties_cb; remote_device_properties_callback remote_device_properties_cb; device_found_callback device_found_cb; discovery_state_changed_callback discovery_state_changed_cb; pin_request_callback pin_request_cb; ssp_request_callback ssp_request_cb; bond_state_changed_callback bond_state_changed_cb; acl_state_changed_callback acl_state_changed_cb; callback_thread_event thread_evt_cb; dut_mode_recv_callback dut_mode_recv_cb; le_test_mode_callback le_test_mode_cb; energy_info_callback energy_info_cb; } bt_callbacks_t; typedef void (*alarm_cb)(void *data); typedef bool (*set_wake_alarm_callout)(uint64_t delay_millis, bool should_wake, alarm_cb cb, void *data); typedef int (*acquire_wake_lock_callout)(const char *lock_name); typedef int (*release_wake_lock_callout)(const char *lock_name); /** The set of functions required by bluedroid to set wake alarms and * grab wake locks. This struct is passed into the stack through the * |set_os_callouts| function on |bt_interface_t|. */ typedef struct { /* set to sizeof(bt_os_callouts_t) */ size_t size; set_wake_alarm_callout set_wake_alarm; acquire_wake_lock_callout acquire_wake_lock; release_wake_lock_callout release_wake_lock; } bt_os_callouts_t; /** NOTE: By default, no profiles are initialized at the time of init/enable. * Whenever the application invokes the 'init' API of a profile, then one of * the following shall occur: * * 1.) If Bluetooth is not enabled, then the Bluetooth core shall mark the * profile as enabled. Subsequently, when the application invokes the * Bluetooth 'enable', as part of the enable sequence the profile that were * marked shall be enabled by calling appropriate stack APIs. The * 'adapter_properties_cb' shall return the list of UUIDs of the * enabled profiles. * * 2.) If Bluetooth is enabled, then the Bluetooth core shall invoke the stack * profile API to initialize the profile and trigger a * 'adapter_properties_cb' with the current list of UUIDs including the * newly added profile's UUID. * * The reverse shall occur whenever the profile 'cleanup' APIs are invoked */ /** Represents the standard Bluetooth DM interface. */ typedef struct { /** set to sizeof(bt_interface_t) */ size_t size; /** * Opens the interface and provides the callback routines * to the implemenation of this interface. */ int (*init)(bt_callbacks_t* callbacks ); /** Enable Bluetooth. */ int (*enable)(void); /** Disable Bluetooth. */ int (*disable)(void); /** Closes the interface. */ void (*cleanup)(void); /** Get all Bluetooth Adapter properties at init */ int (*get_adapter_properties)(void); /** Get Bluetooth Adapter property of 'type' */ int (*get_adapter_property)(bt_property_type_t type); /** 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 */ int (*set_adapter_property)(const bt_property_t *property); /** Get all Remote Device properties */ int (*get_remote_device_properties)(bt_bdaddr_t *remote_addr); /** Get Remote Device property of 'type' */ int (*get_remote_device_property)(bt_bdaddr_t *remote_addr, bt_property_type_t type); /** Set Remote Device property of 'type' */ int (*set_remote_device_property)(bt_bdaddr_t *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); /** Start SDP to get remote services */ int (*get_remote_services)(bt_bdaddr_t *remote_addr); /** Start Discovery */ int (*start_discovery)(void); /** Cancel Discovery */ int (*cancel_discovery)(void); /** Create Bluetooth Bonding */ int (*create_bond)(const bt_bdaddr_t *bd_addr, int transport); /** Remove Bond */ int (*remove_bond)(const bt_bdaddr_t *bd_addr); /** Cancel Bond */ int (*cancel_bond)(const bt_bdaddr_t *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); /** 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, uint8_t pin_len, bt_pin_code_t *pin_code); /** BT SSP Reply - Just Works, Numeric Comparison and Passkey * passkey shall be zero for BT_SSP_VARIANT_PASSKEY_COMPARISON & * 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, uint8_t accept, uint32_t passkey); /** Get Bluetooth profile interface */ const void* (*get_profile_interface) (const char *profile_id); /** Bluetooth Test Mode APIs - Bluetooth must be enabled for these APIs */ /* Configure DUT Mode - Use this mode to enter/exit DUT mode */ int (*dut_mode_configure)(uint8_t enable); /* 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); /** 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|. */ int (*set_os_callouts)(bt_os_callouts_t *callouts); /** Read Energy info details - return value indicates BT_STATUS_SUCCESS or BT_STATUS_NOT_READY * Success indicates that the VSC command was sent to controller */ int (*read_energy_info)(); /** * Native support for dumpsys function * Function is synchronous and |fd| is owned by caller. */ void (*dump)(int fd); /** * Clear /data/misc/bt_config.conf and erase all stored connections */ int (*config_clear)(void); } 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 */ android-headers-23/23/hardware/bt_av.h000066400000000000000000000063121264465411000176230ustar00rootroot00000000000000/* * 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 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); /** 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_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 ); /** 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 ); } btav_interface_t; __END_DECLS #endif /* ANDROID_INCLUDE_BT_AV_H */ android-headers-23/23/hardware/bt_common_types.h000066400000000000000000000026431264465411000217340ustar00rootroot00000000000000/* * 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; #endif /* ANDROID_INCLUDE_BT_COMMON_TYPES_H */ android-headers-23/23/hardware/bt_gatt.h000066400000000000000000000032431264465411000201540ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/hardware/bt_gatt_client.h000066400000000000000000000457471264465411000215310ustar00rootroot00000000000000/* * 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 { btgatt_srvc_id_t srvc_id; btgatt_gatt_id_t char_id; btgatt_gatt_id_t descr_id; 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; btgatt_srvc_id_t srvc_id; btgatt_gatt_id_t char_id; 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); /** Reports GATT services on a remote device */ typedef void (*search_result_callback)( int conn_id, btgatt_srvc_id_t *srvc_id); /** GATT characteristic enumeration result callback */ typedef void (*get_characteristic_callback)(int conn_id, int status, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, int char_prop); /** GATT descriptor enumeration result callback */ typedef void (*get_descriptor_callback)(int conn_id, int status, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, btgatt_gatt_id_t *descr_id); /** GATT included service enumeration result callback */ typedef void (*get_included_service_callback)(int conn_id, int status, btgatt_srvc_id_t *srvc_id, btgatt_srvc_id_t *incl_srvc_id); /** Callback invoked in response to [de]register_for_notification */ typedef void (*register_for_notification_callback)(int conn_id, int registered, int status, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id); /** * 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, btgatt_write_params_t *p_data); /** 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, btgatt_write_params_t *p_data); /** 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); 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; search_result_callback search_result_cb; get_characteristic_callback get_characteristic_cb; get_descriptor_callback get_descriptor_cb; get_included_service_callback get_included_service_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; } 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 ); /** * Enumerate included services for a given service. * Set start_incl_srvc_id to NULL to get the first included service. */ bt_status_t (*get_included_service)( int conn_id, btgatt_srvc_id_t *srvc_id, btgatt_srvc_id_t *start_incl_srvc_id); /** * Enumerate characteristics for a given service. * Set start_char_id to NULL to get the first characteristic. */ bt_status_t (*get_characteristic)( int conn_id, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *start_char_id); /** * Enumerate descriptors for a given characteristic. * Set start_descr_id to NULL to get the first descriptor. */ bt_status_t (*get_descriptor)( int conn_id, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, btgatt_gatt_id_t *start_descr_id); /** Read a characteristic on a remote device */ bt_status_t (*read_characteristic)( int conn_id, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, int auth_req ); /** Write a remote characteristic */ bt_status_t (*write_characteristic)(int conn_id, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, 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, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, btgatt_gatt_id_t *descr_id, int auth_req); /** Write a remote descriptor for a given characteristic */ bt_status_t (*write_descriptor)( int conn_id, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, btgatt_gatt_id_t *descr_id, 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, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id); /** Deregister a previous request for notifications/indications */ bt_status_t (*deregister_for_notification)( int client_if, const bt_bdaddr_t *bd_addr, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id); /** 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); } btgatt_client_interface_t; __END_DECLS #endif /* ANDROID_INCLUDE_BT_GATT_CLIENT_H */ android-headers-23/23/hardware/bt_gatt_server.h000066400000000000000000000173231264465411000215460ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/hardware/bt_gatt_types.h000066400000000000000000000026241264465411000214020ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/hardware/bt_hf.h000066400000000000000000000232571264465411000176210ustar00rootroot00000000000000/* * 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; /* 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); /** 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_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_CALL_ADDRTYPE_UNKNOWN = 0x81, BTHF_CALL_ADDRTYPE_INTERNATIONAL = 0x91 } bthf_call_addrtype_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 ); } bthf_interface_t; __END_DECLS #endif /* ANDROID_INCLUDE_BT_HF_H */ android-headers-23/23/hardware/bt_hf_client.h000066400000000000000000000320361264465411000211520ustar00rootroot00000000000000/* * 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); /** 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_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 */ android-headers-23/23/hardware/bt_hh.h000066400000000000000000000140561264465411000176200ustar00rootroot00000000000000/* * 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); /** 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 */ android-headers-23/23/hardware/bt_hl.h000066400000000000000000000071711264465411000176240ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/hardware/bt_mce.h000066400000000000000000000031211264465411000177540ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/hardware/bt_pan.h000066400000000000000000000055131264465411000177750ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/hardware/bt_rc.h000066400000000000000000000262671264465411000176340ustar00rootroot00000000000000/* * 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 7 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_event_id_t; typedef enum { BTRC_NOTIFICATION_TYPE_INTERIM = 0, BTRC_NOTIFICATION_TYPE_CHANGED = 1, } 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_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 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 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; } 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); /** Callback for play status request */ typedef void (* btrc_get_play_status_callback)(); /** Callback for list player application attributes (Shuffle, Repeat,...) */ typedef void (* btrc_list_player_app_attr_callback)(); /** Callback for list player application attributes (Shuffle, Repeat,...) */ typedef void (* btrc_list_player_app_values_callback)(btrc_player_attr_t attr_id); /** 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); /** 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); /** 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); /** Callback for setting the player application settings values */ typedef void (* btrc_set_player_app_value_callback) (btrc_player_settings_t *p_vals); /** 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); /** 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); /* 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); /** Callback for passthrough commands */ typedef void (* btrc_passthrough_cmd_callback) (int id, int key_state); /** BT-RC Target callback structure. */ 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_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 ); /** 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); /** 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)( int num_attr, btrc_player_attr_t *p_attrs); /** 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)( int num_val, uint8_t *p_vals); /** 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); /** 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); /** 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); /** 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); /** 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); /* 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); /* 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); /** Closes the interface. */ void (*cleanup)( void ); } btrc_interface_t; typedef void (* btrc_passthrough_rsp_callback) (int id, int key_state); typedef void (* btrc_connection_state_callback) (bool state, bt_bdaddr_t *bd_addr); /** BT-RC Controller callback structure. */ typedef struct { /** set to sizeof(BtRcCallbacks) */ size_t size; btrc_passthrough_rsp_callback passthrough_rsp_cb; btrc_connection_state_callback connection_state_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 ); /** Closes the interface. */ void (*cleanup)( void ); } btrc_ctrl_interface_t; __END_DECLS #endif /* ANDROID_INCLUDE_BT_RC_H */ android-headers-23/23/hardware/bt_sdp.h000066400000000000000000000114231264465411000200020ustar00rootroot00000000000000/* * 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 android-headers-23/23/hardware/bt_sock.h000066400000000000000000000045631264465411000201620ustar00rootroot00000000000000/* * 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; /** 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. */ bt_status_t (*listen)(btsock_type_t type, const char* service_name, const uint8_t* service_uuid, int channel, int* sock_fd, int flags); /** * 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 */ 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); } btsock_interface_t; __END_DECLS android-headers-23/23/hardware/camera.h000066400000000000000000000257521264465411000177710ustar00rootroot00000000000000/* * Copyright (C) 2010-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_CAMERA_H #define ANDROID_INCLUDE_CAMERA_H #include "camera_common.h" /** * Camera device HAL, initial version [ CAMERA_DEVICE_API_VERSION_1_0 ] * * DEPRECATED. New devices should use Camera HAL v3.2 or newer. * * Supports the android.hardware.Camera API, and the android.hardware.camera2 * API in legacy mode only. * * Camera devices that support this version of the HAL must return a value in * the range HARDWARE_DEVICE_API_VERSION(0,0)-(1,FF) in * camera_device_t.common.version. CAMERA_DEVICE_API_VERSION_1_0 is the * recommended value. * * Camera modules that implement version 2.0 or higher of camera_module_t must * also return the value of camera_device_t.common.version in * camera_info_t.device_version. * * See camera_common.h for more details. */ __BEGIN_DECLS struct camera_memory; typedef void (*camera_release_memory)(struct camera_memory *mem); typedef struct camera_memory { void *data; size_t size; void *handle; camera_release_memory release; } camera_memory_t; typedef camera_memory_t* (*camera_request_memory)(int fd, size_t buf_size, unsigned int num_bufs, void *user); typedef void (*camera_notify_callback)(int32_t msg_type, int32_t ext1, int32_t ext2, void *user); typedef void (*camera_data_callback)(int32_t msg_type, const camera_memory_t *data, unsigned int index, camera_frame_metadata_t *metadata, void *user); typedef void (*camera_data_timestamp_callback)(int64_t timestamp, int32_t msg_type, const camera_memory_t *data, unsigned int index, void *user); #define HAL_CAMERA_PREVIEW_WINDOW_TAG 0xcafed00d typedef struct preview_stream_ops { int (*dequeue_buffer)(struct preview_stream_ops* w, buffer_handle_t** buffer, int *stride); int (*enqueue_buffer)(struct preview_stream_ops* w, buffer_handle_t* buffer); int (*cancel_buffer)(struct preview_stream_ops* w, buffer_handle_t* buffer); int (*set_buffer_count)(struct preview_stream_ops* w, int count); int (*set_buffers_geometry)(struct preview_stream_ops* pw, int w, int h, int format); int (*set_crop)(struct preview_stream_ops *w, int left, int top, int right, int bottom); int (*set_usage)(struct preview_stream_ops* w, int usage); int (*set_swap_interval)(struct preview_stream_ops *w, int interval); int (*get_min_undequeued_buffer_count)(const struct preview_stream_ops *w, int *count); int (*lock_buffer)(struct preview_stream_ops* w, buffer_handle_t* buffer); // Timestamps are measured in nanoseconds, and must be comparable // and monotonically increasing between two frames in the same // preview stream. They do not need to be comparable between // consecutive or parallel preview streams, cameras, or app runs. int (*set_timestamp)(struct preview_stream_ops *w, int64_t timestamp); } preview_stream_ops_t; struct camera_device; typedef struct camera_device_ops { /** Set the ANativeWindow to which preview frames are sent */ int (*set_preview_window)(struct camera_device *, struct preview_stream_ops *window); /** Set the notification and data callbacks */ void (*set_callbacks)(struct camera_device *, camera_notify_callback notify_cb, camera_data_callback data_cb, camera_data_timestamp_callback data_cb_timestamp, camera_request_memory get_memory, void *user); /** * The following three functions all take a msg_type, which is a bitmask of * the messages defined in include/ui/Camera.h */ /** * Enable a message, or set of messages. */ void (*enable_msg_type)(struct camera_device *, int32_t msg_type); /** * Disable a message, or a set of messages. * * Once received a call to disableMsgType(CAMERA_MSG_VIDEO_FRAME), camera * HAL should not rely on its client to call releaseRecordingFrame() to * release video recording frames sent out by the cameral HAL before and * after the disableMsgType(CAMERA_MSG_VIDEO_FRAME) call. Camera HAL * clients must not modify/access any video recording frame after calling * disableMsgType(CAMERA_MSG_VIDEO_FRAME). */ void (*disable_msg_type)(struct camera_device *, int32_t msg_type); /** * Query whether a message, or a set of messages, is enabled. Note that * this is operates as an AND, if any of the messages queried are off, this * will return false. */ int (*msg_type_enabled)(struct camera_device *, int32_t msg_type); /** * Start preview mode. */ int (*start_preview)(struct camera_device *); /** * Stop a previously started preview. */ void (*stop_preview)(struct camera_device *); /** * Returns true if preview is enabled. */ int (*preview_enabled)(struct camera_device *); /** * Request the camera HAL to store meta data or real YUV data in the video * buffers sent out via CAMERA_MSG_VIDEO_FRAME for a recording session. If * it is not called, the default camera HAL behavior is to store real YUV * data in the video buffers. * * This method should be called before startRecording() in order to be * effective. * * If meta data is stored in the video buffers, it is up to the receiver of * the video buffers to interpret the contents and to find the actual frame * data with the help of the meta data in the buffer. How this is done is * outside of the scope of this method. * * Some camera HALs may not support storing meta data in the video buffers, * but all camera HALs should support storing real YUV data in the video * buffers. If the camera HAL does not support storing the meta data in the * video buffers when it is requested to do do, INVALID_OPERATION must be * returned. It is very useful for the camera HAL to pass meta data rather * than the actual frame data directly to the video encoder, since the * amount of the uncompressed frame data can be very large if video size is * large. * * @param enable if true to instruct the camera HAL to store * meta data in the video buffers; false to instruct * the camera HAL to store real YUV data in the video * buffers. * * @return OK on success. */ int (*store_meta_data_in_buffers)(struct camera_device *, int enable); /** * Start record mode. When a record image is available, a * CAMERA_MSG_VIDEO_FRAME message is sent with the corresponding * frame. Every record frame must be released by a camera HAL client via * releaseRecordingFrame() before the client calls * disableMsgType(CAMERA_MSG_VIDEO_FRAME). After the client calls * disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's * responsibility to manage the life-cycle of the video recording frames, * and the client must not modify/access any video recording frames. */ int (*start_recording)(struct camera_device *); /** * Stop a previously started recording. */ void (*stop_recording)(struct camera_device *); /** * Returns true if recording is enabled. */ int (*recording_enabled)(struct camera_device *); /** * Release a record frame previously returned by CAMERA_MSG_VIDEO_FRAME. * * It is camera HAL client's responsibility to release video recording * frames sent out by the camera HAL before the camera HAL receives a call * to disableMsgType(CAMERA_MSG_VIDEO_FRAME). After it receives the call to * disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's * responsibility to manage the life-cycle of the video recording frames. */ void (*release_recording_frame)(struct camera_device *, const void *opaque); /** * Start auto focus, the notification callback routine is called with * CAMERA_MSG_FOCUS once when focusing is complete. autoFocus() will be * called again if another auto focus is needed. */ int (*auto_focus)(struct camera_device *); /** * Cancels auto-focus function. If the auto-focus is still in progress, * this function will cancel it. Whether the auto-focus is in progress or * not, this function will return the focus position to the default. If * the camera does not support auto-focus, this is a no-op. */ int (*cancel_auto_focus)(struct camera_device *); /** * Take a picture. */ int (*take_picture)(struct camera_device *); /** * Cancel a picture that was started with takePicture. Calling this method * when no picture is being taken is a no-op. */ int (*cancel_picture)(struct camera_device *); /** * Set the camera parameters. This returns BAD_VALUE if any parameter is * invalid or not supported. */ int (*set_parameters)(struct camera_device *, const char *parms); /** Retrieve the camera parameters. The buffer returned by the camera HAL must be returned back to it with put_parameters, if put_parameters is not NULL. */ char *(*get_parameters)(struct camera_device *); /** The camera HAL uses its own memory to pass us the parameters when we call get_parameters. Use this function to return the memory back to the camera HAL, if put_parameters is not NULL. If put_parameters is NULL, then you have to use free() to release the memory. */ void (*put_parameters)(struct camera_device *, char *); /** * Send command to camera driver. */ int (*send_command)(struct camera_device *, int32_t cmd, int32_t arg1, int32_t arg2); /** * Release the hardware resources owned by this object. Note that this is * *not* done in the destructor. */ void (*release)(struct camera_device *); /** * Dump state of the camera hardware */ int (*dump)(struct camera_device *, int fd); } camera_device_ops_t; typedef struct camera_device { /** * camera_device.common.version must be in the range * HARDWARE_DEVICE_API_VERSION(0,0)-(1,FF). CAMERA_DEVICE_API_VERSION_1_0 is * recommended. */ hw_device_t common; camera_device_ops_t *ops; void *priv; } camera_device_t; __END_DECLS #endif /* #ifdef ANDROID_INCLUDE_CAMERA_H */ android-headers-23/23/hardware/camera2.h000066400000000000000000001027521264465411000200470ustar00rootroot00000000000000/* * 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_CAMERA2_H #define ANDROID_INCLUDE_CAMERA2_H #include "camera_common.h" #include "system/camera_metadata.h" /** * Camera device HAL 2.1 [ CAMERA_DEVICE_API_VERSION_2_0, CAMERA_DEVICE_API_VERSION_2_1 ] * * DEPRECATED. New devices should use Camera HAL v3.2 or newer. * * Supports the android.hardware.Camera API, and the android.hardware.camera2 * API in legacy mode only. * * Camera devices that support this version of the HAL must return * CAMERA_DEVICE_API_VERSION_2_1 in camera_device_t.common.version and in * camera_info_t.device_version (from camera_module_t.get_camera_info). * * Camera modules that may contain version 2.x devices must implement at least * version 2.0 of the camera module interface (as defined by * camera_module_t.common.module_api_version). * * See camera_common.h for more versioning details. * * Version history: * * 2.0: CAMERA_DEVICE_API_VERSION_2_0. Initial release (Android 4.2): * - Sufficient for implementing existing android.hardware.Camera API. * - Allows for ZSL queue in camera service layer * - Not tested for any new features such manual capture control, * Bayer RAW capture, reprocessing of RAW data. * * 2.1: CAMERA_DEVICE_API_VERSION_2_1. Support per-device static metadata: * - Add get_instance_metadata() method to retrieve metadata that is fixed * after device open, but may be variable between open() calls. */ __BEGIN_DECLS struct camera2_device; /********************************************************************** * * Input/output stream buffer queue interface definitions * */ /** * Output image stream queue interface. A set of these methods is provided to * the HAL device in allocate_stream(), and are used to interact with the * gralloc buffer queue for that stream. They may not be called until after * allocate_stream returns. */ typedef struct camera2_stream_ops { /** * Get a buffer to fill from the queue. The size and format of the buffer * are fixed for a given stream (defined in allocate_stream), and the stride * should be queried from the platform gralloc module. The gralloc buffer * will have been allocated based on the usage flags provided by * allocate_stream, and will be locked for use. */ int (*dequeue_buffer)(const struct camera2_stream_ops* w, buffer_handle_t** buffer); /** * Push a filled buffer to the stream to be used by the consumer. * * The timestamp represents the time at start of exposure of the first row * of the image; it must be from a monotonic clock, and is measured in * nanoseconds. The timestamps do not need to be comparable between * different cameras, or consecutive instances of the same camera. However, * they must be comparable between streams from the same camera. If one * capture produces buffers for multiple streams, each stream must have the * same timestamp for that buffer, and that timestamp must match the * timestamp in the output frame metadata. */ int (*enqueue_buffer)(const struct camera2_stream_ops* w, int64_t timestamp, buffer_handle_t* buffer); /** * Return a buffer to the queue without marking it as filled. */ int (*cancel_buffer)(const struct camera2_stream_ops* w, buffer_handle_t* buffer); /** * Set the crop window for subsequently enqueued buffers. The parameters are * measured in pixels relative to the buffer width and height. */ int (*set_crop)(const struct camera2_stream_ops *w, int left, int top, int right, int bottom); } camera2_stream_ops_t; /** * Temporary definition during transition. * * These formats will be removed and replaced with * HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED. To maximize forward compatibility, * HAL implementations are strongly recommended to treat FORMAT_OPAQUE and * FORMAT_ZSL as equivalent to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, and * return HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED in the format_actual output * parameter of allocate_stream, allowing the gralloc module to select the * specific format based on the usage flags from the camera and the stream * consumer. */ enum { CAMERA2_HAL_PIXEL_FORMAT_OPAQUE = HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, CAMERA2_HAL_PIXEL_FORMAT_ZSL = -1 }; /** * Transport header for compressed JPEG buffers in output streams. * * To capture JPEG images, a stream is created using the pixel format * HAL_PIXEL_FORMAT_BLOB, and the static metadata field android.jpeg.maxSize is * used as the buffer size. Since compressed JPEG images are of variable size, * the HAL needs to include the final size of the compressed image using this * structure inside the output stream buffer. The JPEG blob ID field must be set * to CAMERA2_JPEG_BLOB_ID. * * Transport header should be at the end of the JPEG output stream buffer. That * means the jpeg_blob_id must start at byte[android.jpeg.maxSize - * sizeof(camera2_jpeg_blob)]. Any HAL using this transport header must * account for it in android.jpeg.maxSize. The JPEG data itself starts at * byte[0] and should be jpeg_size bytes long. */ typedef struct camera2_jpeg_blob { uint16_t jpeg_blob_id; uint32_t jpeg_size; }; enum { CAMERA2_JPEG_BLOB_ID = 0x00FF }; /** * Input reprocess stream queue management. A set of these methods is provided * to the HAL device in allocate_reprocess_stream(); they are used to interact * with the reprocess stream's input gralloc buffer queue. */ typedef struct camera2_stream_in_ops { /** * Get the next buffer of image data to reprocess. The width, height, and * format of the buffer is fixed in allocate_reprocess_stream(), and the * stride and other details should be queried from the platform gralloc * module as needed. The buffer will already be locked for use. */ int (*acquire_buffer)(const struct camera2_stream_in_ops *w, buffer_handle_t** buffer); /** * Return a used buffer to the buffer queue for reuse. */ int (*release_buffer)(const struct camera2_stream_in_ops *w, buffer_handle_t* buffer); } camera2_stream_in_ops_t; /********************************************************************** * * Metadata queue management, used for requests sent to HAL module, and for * frames produced by the HAL. * */ enum { CAMERA2_REQUEST_QUEUE_IS_BOTTOMLESS = -1 }; /** * Request input queue protocol: * * The framework holds the queue and its contents. At start, the queue is empty. * * 1. When the first metadata buffer is placed into the queue, the framework * signals the device by calling notify_request_queue_not_empty(). * * 2. After receiving notify_request_queue_not_empty, the device must call * dequeue() once it's ready to handle the next buffer. * * 3. Once the device has processed a buffer, and is ready for the next buffer, * it must call dequeue() again instead of waiting for a notification. If * there are no more buffers available, dequeue() will return NULL. After * this point, when a buffer becomes available, the framework must call * notify_request_queue_not_empty() again. If the device receives a NULL * return from dequeue, it does not need to query the queue again until a * notify_request_queue_not_empty() call is received from the source. * * 4. If the device calls buffer_count() and receives 0, this does not mean that * the framework will provide a notify_request_queue_not_empty() call. The * framework will only provide such a notification after the device has * received a NULL from dequeue, or on initial startup. * * 5. The dequeue() call in response to notify_request_queue_not_empty() may be * on the same thread as the notify_request_queue_not_empty() call, and may * be performed from within the notify call. * * 6. All dequeued request buffers must be returned to the framework by calling * free_request, including when errors occur, a device flush is requested, or * when the device is shutting down. */ typedef struct camera2_request_queue_src_ops { /** * Get the count of request buffers pending in the queue. May return * CAMERA2_REQUEST_QUEUE_IS_BOTTOMLESS if a repeating request (stream * request) is currently configured. Calling this method has no effect on * whether the notify_request_queue_not_empty() method will be called by the * framework. */ int (*request_count)(const struct camera2_request_queue_src_ops *q); /** * Get a metadata buffer from the framework. Returns OK if there is no * error. If the queue is empty, returns NULL in buffer. In that case, the * device must wait for a notify_request_queue_not_empty() message before * attempting to dequeue again. Buffers obtained in this way must be * returned to the framework with free_request(). */ int (*dequeue_request)(const struct camera2_request_queue_src_ops *q, camera_metadata_t **buffer); /** * Return a metadata buffer to the framework once it has been used, or if * an error or shutdown occurs. */ int (*free_request)(const struct camera2_request_queue_src_ops *q, camera_metadata_t *old_buffer); } camera2_request_queue_src_ops_t; /** * Frame output queue protocol: * * The framework holds the queue and its contents. At start, the queue is empty. * * 1. When the device is ready to fill an output metadata frame, it must dequeue * a metadata buffer of the required size. * * 2. It should then fill the metadata buffer, and place it on the frame queue * using enqueue_frame. The framework takes ownership of the frame. * * 3. In case of an error, a request to flush the pipeline, or shutdown, the * device must return any affected dequeued frames to the framework by * calling cancel_frame. */ typedef struct camera2_frame_queue_dst_ops { /** * Get an empty metadata buffer to fill from the framework. The new metadata * buffer will have room for entries number of metadata entries, plus * data_bytes worth of extra storage. Frames dequeued here must be returned * to the framework with either cancel_frame or enqueue_frame. */ int (*dequeue_frame)(const struct camera2_frame_queue_dst_ops *q, size_t entries, size_t data_bytes, camera_metadata_t **buffer); /** * Return a dequeued metadata buffer to the framework for reuse; do not mark it as * filled. Use when encountering errors, or flushing the internal request queue. */ int (*cancel_frame)(const struct camera2_frame_queue_dst_ops *q, camera_metadata_t *buffer); /** * Place a completed metadata frame on the frame output queue. */ int (*enqueue_frame)(const struct camera2_frame_queue_dst_ops *q, camera_metadata_t *buffer); } camera2_frame_queue_dst_ops_t; /********************************************************************** * * Notification callback and message definition, and trigger definitions * */ /** * Asynchronous notification callback from the HAL, fired for various * reasons. Only for information independent of frame capture, or that require * specific timing. The user pointer must be the same one that was passed to the * device in set_notify_callback(). */ typedef void (*camera2_notify_callback)(int32_t msg_type, int32_t ext1, int32_t ext2, int32_t ext3, void *user); /** * Possible message types for camera2_notify_callback */ enum { /** * An error has occurred. Argument ext1 contains the error code, and * ext2 and ext3 contain any error-specific information. */ CAMERA2_MSG_ERROR = 0x0001, /** * The exposure of a given request has begun. Argument ext1 contains the * frame number, and ext2 and ext3 contain the low-order and high-order * bytes of the timestamp for when exposure began. * (timestamp = (ext3 << 32 | ext2)) */ CAMERA2_MSG_SHUTTER = 0x0010, /** * The autofocus routine has changed state. Argument ext1 contains the new * state; the values are the same as those for the metadata field * android.control.afState. Ext2 contains the latest trigger ID passed to * trigger_action(CAMERA2_TRIGGER_AUTOFOCUS) or * trigger_action(CAMERA2_TRIGGER_CANCEL_AUTOFOCUS), or 0 if trigger has not * been called with either of those actions. */ CAMERA2_MSG_AUTOFOCUS = 0x0020, /** * The autoexposure routine has changed state. Argument ext1 contains the * new state; the values are the same as those for the metadata field * android.control.aeState. Ext2 contains the latest trigger ID value passed to * trigger_action(CAMERA2_TRIGGER_PRECAPTURE_METERING), or 0 if that method * has not been called. */ CAMERA2_MSG_AUTOEXPOSURE = 0x0021, /** * The auto-whitebalance routine has changed state. Argument ext1 contains * the new state; the values are the same as those for the metadata field * android.control.awbState. Ext2 contains the latest trigger ID passed to * trigger_action(CAMERA2_TRIGGER_PRECAPTURE_METERING), or 0 if that method * has not been called. */ CAMERA2_MSG_AUTOWB = 0x0022 }; /** * Error codes for CAMERA_MSG_ERROR */ enum { /** * A serious failure occured. Camera device may not work without reboot, and * no further frames or buffer streams will be produced by the * device. Device should be treated as closed. */ CAMERA2_MSG_ERROR_HARDWARE = 0x0001, /** * A serious failure occured. No further frames or buffer streams will be * produced by the device. Device should be treated as closed. The client * must reopen the device to use it again. */ CAMERA2_MSG_ERROR_DEVICE, /** * An error has occurred in processing a request. No output (metadata or * buffers) will be produced for this request. ext2 contains the frame * number of the request. Subsequent requests are unaffected, and the device * remains operational. */ CAMERA2_MSG_ERROR_REQUEST, /** * An error has occurred in producing an output frame metadata buffer for a * request, but image buffers for it will still be available. Subsequent * requests are unaffected, and the device remains operational. ext2 * contains the frame number of the request. */ CAMERA2_MSG_ERROR_FRAME, /** * An error has occurred in placing an output buffer into a stream for a * request. The frame metadata and other buffers may still be * available. Subsequent requests are unaffected, and the device remains * operational. ext2 contains the frame number of the request, and ext3 * contains the stream id. */ CAMERA2_MSG_ERROR_STREAM, /** * Number of error types */ CAMERA2_MSG_NUM_ERRORS }; /** * Possible trigger ids for trigger_action() */ enum { /** * Trigger an autofocus cycle. The effect of the trigger depends on the * autofocus mode in effect when the trigger is received, which is the mode * listed in the latest capture request to be dequeued by the HAL. If the * mode is OFF, EDOF, or FIXED, the trigger has no effect. In AUTO, MACRO, * or CONTINUOUS_* modes, see below for the expected behavior. The state of * the autofocus cycle can be tracked in android.control.afMode and the * corresponding notifications. * ** * In AUTO or MACRO mode, the AF state transitions (and notifications) * when calling with trigger ID = N with the previous ID being K are: * * Initial state Transitions * INACTIVE (K) -> ACTIVE_SCAN (N) -> AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * AF_FOCUSED (K) -> ACTIVE_SCAN (N) -> AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * AF_NOT_FOCUSED (K) -> ACTIVE_SCAN (N) -> AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * ACTIVE_SCAN (K) -> AF_FOCUSED(N) or AF_NOT_FOCUSED(N) * PASSIVE_SCAN (K) Not used in AUTO/MACRO mode * PASSIVE_FOCUSED (K) Not used in AUTO/MACRO mode * ** * In CONTINUOUS_PICTURE mode, triggering AF must lock the AF to the current * lens position and transition the AF state to either AF_FOCUSED or * NOT_FOCUSED. If a passive scan is underway, that scan must complete and * then lock the lens position and change AF state. TRIGGER_CANCEL_AUTOFOCUS * will allow the AF to restart its operation. * * Initial state Transitions * INACTIVE (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * PASSIVE_FOCUSED (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * PASSIVE_SCAN (K) -> AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * AF_FOCUSED (K) no effect except to change next notification ID to N * AF_NOT_FOCUSED (K) no effect except to change next notification ID to N * ** * In CONTINUOUS_VIDEO mode, triggering AF must lock the AF to the current * lens position and transition the AF state to either AF_FOCUSED or * NOT_FOCUSED. If a passive scan is underway, it must immediately halt, in * contrast with CONTINUOUS_PICTURE mode. TRIGGER_CANCEL_AUTOFOCUS will * allow the AF to restart its operation. * * Initial state Transitions * INACTIVE (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * PASSIVE_FOCUSED (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * PASSIVE_SCAN (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * AF_FOCUSED (K) no effect except to change next notification ID to N * AF_NOT_FOCUSED (K) no effect except to change next notification ID to N * * Ext1 is an ID that must be returned in subsequent auto-focus state change * notifications through camera2_notify_callback() and stored in * android.control.afTriggerId. */ CAMERA2_TRIGGER_AUTOFOCUS = 0x0001, /** * Send a cancel message to the autofocus algorithm. The effect of the * cancellation depends on the autofocus mode in effect when the trigger is * received, which is the mode listed in the latest capture request to be * dequeued by the HAL. If the AF mode is OFF or EDOF, the cancel has no * effect. For other modes, the lens should return to its default position, * any current autofocus scan must be canceled, and the AF state should be * set to INACTIVE. * * The state of the autofocus cycle can be tracked in android.control.afMode * and the corresponding notification. Continuous autofocus modes may resume * focusing operations thereafter exactly as if the camera had just been set * to a continuous AF mode. * * Ext1 is an ID that must be returned in subsequent auto-focus state change * notifications through camera2_notify_callback() and stored in * android.control.afTriggerId. */ CAMERA2_TRIGGER_CANCEL_AUTOFOCUS, /** * Trigger a pre-capture metering cycle, which may include firing the flash * to determine proper capture parameters. Typically, this trigger would be * fired for a half-depress of a camera shutter key, or before a snapshot * capture in general. The state of the metering cycle can be tracked in * android.control.aeMode and the corresponding notification. If the * auto-exposure mode is OFF, the trigger does nothing. * * Ext1 is an ID that must be returned in subsequent * auto-exposure/auto-white balance state change notifications through * camera2_notify_callback() and stored in android.control.aePrecaptureId. */ CAMERA2_TRIGGER_PRECAPTURE_METERING }; /** * Possible template types for construct_default_request() */ enum { /** * Standard camera preview operation with 3A on auto. */ CAMERA2_TEMPLATE_PREVIEW = 1, /** * Standard camera high-quality still capture with 3A and flash on auto. */ CAMERA2_TEMPLATE_STILL_CAPTURE, /** * Standard video recording plus preview with 3A on auto, torch off. */ CAMERA2_TEMPLATE_VIDEO_RECORD, /** * High-quality still capture while recording video. Application will * include preview, video record, and full-resolution YUV or JPEG streams in * request. Must not cause stuttering on video stream. 3A on auto. */ CAMERA2_TEMPLATE_VIDEO_SNAPSHOT, /** * Zero-shutter-lag mode. Application will request preview and * full-resolution data for each frame, and reprocess it to JPEG when a * still image is requested by user. Settings should provide highest-quality * full-resolution images without compromising preview frame rate. 3A on * auto. */ CAMERA2_TEMPLATE_ZERO_SHUTTER_LAG, /* Total number of templates */ CAMERA2_TEMPLATE_COUNT }; /********************************************************************** * * Camera device operations * */ typedef struct camera2_device_ops { /********************************************************************** * Request and frame queue setup and management methods */ /** * Pass in input request queue interface methods. */ int (*set_request_queue_src_ops)(const struct camera2_device *, const camera2_request_queue_src_ops_t *request_src_ops); /** * Notify device that the request queue is no longer empty. Must only be * called when the first buffer is added a new queue, or after the source * has returned NULL in response to a dequeue call. */ int (*notify_request_queue_not_empty)(const struct camera2_device *); /** * Pass in output frame queue interface methods */ int (*set_frame_queue_dst_ops)(const struct camera2_device *, const camera2_frame_queue_dst_ops_t *frame_dst_ops); /** * Number of camera requests being processed by the device at the moment * (captures/reprocesses that have had their request dequeued, but have not * yet been enqueued onto output pipeline(s) ). No streams may be released * by the framework until the in-progress count is 0. */ int (*get_in_progress_count)(const struct camera2_device *); /** * Flush all in-progress captures. This includes all dequeued requests * (regular or reprocessing) that have not yet placed any outputs into a * stream or the frame queue. Partially completed captures must be completed * normally. No new requests may be dequeued from the request queue until * the flush completes. */ int (*flush_captures_in_progress)(const struct camera2_device *); /** * Create a filled-in default request for standard camera use cases. * * The device must return a complete request that is configured to meet the * requested use case, which must be one of the CAMERA2_TEMPLATE_* * enums. All request control fields must be included, except for * android.request.outputStreams. * * The metadata buffer returned must be allocated with * allocate_camera_metadata. The framework takes ownership of the buffer. */ int (*construct_default_request)(const struct camera2_device *, int request_template, camera_metadata_t **request); /********************************************************************** * Stream management */ /** * allocate_stream: * * Allocate a new output stream for use, defined by the output buffer width, * height, target, and possibly the pixel format. Returns the new stream's * ID, gralloc usage flags, minimum queue buffer count, and possibly the * pixel format, on success. Error conditions: * * - Requesting a width/height/format combination not listed as * supported by the sensor's static characteristics * * - Asking for too many streams of a given format type (2 bayer raw * streams, for example). * * Input parameters: * * - width, height, format: Specification for the buffers to be sent through * this stream. Format is a value from the HAL_PIXEL_FORMAT_* list. If * HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, then the platform * gralloc module will select a format based on the usage flags provided * by the camera HAL and the consumer of the stream. The camera HAL should * inspect the buffers handed to it in the register_stream_buffers call to * obtain the implementation-specific format if necessary. * * - stream_ops: A structure of function pointers for obtaining and queuing * up buffers for this stream. The underlying stream will be configured * based on the usage and max_buffers outputs. The methods in this * structure may not be called until after allocate_stream returns. * * Output parameters: * * - stream_id: An unsigned integer identifying this stream. This value is * used in incoming requests to identify the stream, and in releasing the * stream. * * - usage: The gralloc usage mask needed by the HAL device for producing * the requested type of data. This is used in allocating new gralloc * buffers for the stream buffer queue. * * - max_buffers: The maximum number of buffers the HAL device may need to * have dequeued at the same time. The device may not dequeue more buffers * than this value at the same time. * */ int (*allocate_stream)( const struct camera2_device *, // inputs uint32_t width, uint32_t height, int format, const camera2_stream_ops_t *stream_ops, // outputs uint32_t *stream_id, uint32_t *format_actual, // IGNORED, will be removed uint32_t *usage, uint32_t *max_buffers); /** * Register buffers for a given stream. This is called after a successful * allocate_stream call, and before the first request referencing the stream * is enqueued. This method is intended to allow the HAL device to map or * otherwise prepare the buffers for later use. num_buffers is guaranteed to * be at least max_buffers (from allocate_stream), but may be larger. The * buffers will already be locked for use. At the end of the call, all the * buffers must be ready to be returned to the queue. If the stream format * was set to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, the camera HAL should * inspect the passed-in buffers here to determine any platform-private * pixel format information. */ int (*register_stream_buffers)( const struct camera2_device *, uint32_t stream_id, int num_buffers, buffer_handle_t *buffers); /** * Release a stream. Returns an error if called when get_in_progress_count * is non-zero, or if the stream id is invalid. */ int (*release_stream)( const struct camera2_device *, uint32_t stream_id); /** * allocate_reprocess_stream: * * Allocate a new input stream for use, defined by the output buffer width, * height, and the pixel format. Returns the new stream's ID, gralloc usage * flags, and required simultaneously acquirable buffer count, on * success. Error conditions: * * - Requesting a width/height/format combination not listed as * supported by the sensor's static characteristics * * - Asking for too many reprocessing streams to be configured at once. * * Input parameters: * * - width, height, format: Specification for the buffers to be sent through * this stream. Format must be a value from the HAL_PIXEL_FORMAT_* list. * * - reprocess_stream_ops: A structure of function pointers for acquiring * and releasing buffers for this stream. The underlying stream will be * configured based on the usage and max_buffers outputs. * * Output parameters: * * - stream_id: An unsigned integer identifying this stream. This value is * used in incoming requests to identify the stream, and in releasing the * stream. These ids are numbered separately from the input stream ids. * * - consumer_usage: The gralloc usage mask needed by the HAL device for * consuming the requested type of data. This is used in allocating new * gralloc buffers for the stream buffer queue. * * - max_buffers: The maximum number of buffers the HAL device may need to * have acquired at the same time. The device may not have more buffers * acquired at the same time than this value. * */ int (*allocate_reprocess_stream)(const struct camera2_device *, uint32_t width, uint32_t height, uint32_t format, const camera2_stream_in_ops_t *reprocess_stream_ops, // outputs uint32_t *stream_id, uint32_t *consumer_usage, uint32_t *max_buffers); /** * allocate_reprocess_stream_from_stream: * * Allocate a new input stream for use, which will use the buffers allocated * for an existing output stream. That is, after the HAL enqueues a buffer * onto the output stream, it may see that same buffer handed to it from * this input reprocessing stream. After the HAL releases the buffer back to * the reprocessing stream, it will be returned to the output queue for * reuse. * * Error conditions: * * - Using an output stream of unsuitable size/format for the basis of the * reprocessing stream. * * - Attempting to allocatee too many reprocessing streams at once. * * Input parameters: * * - output_stream_id: The ID of an existing output stream which has * a size and format suitable for reprocessing. * * - reprocess_stream_ops: A structure of function pointers for acquiring * and releasing buffers for this stream. The underlying stream will use * the same graphics buffer handles as the output stream uses. * * Output parameters: * * - stream_id: An unsigned integer identifying this stream. This value is * used in incoming requests to identify the stream, and in releasing the * stream. These ids are numbered separately from the input stream ids. * * The HAL client must always release the reprocessing stream before it * releases the output stream it is based on. * */ int (*allocate_reprocess_stream_from_stream)(const struct camera2_device *, uint32_t output_stream_id, const camera2_stream_in_ops_t *reprocess_stream_ops, // outputs uint32_t *stream_id); /** * Release a reprocessing stream. Returns an error if called when * get_in_progress_count is non-zero, or if the stream id is not * valid. */ int (*release_reprocess_stream)( const struct camera2_device *, uint32_t stream_id); /********************************************************************** * Miscellaneous methods */ /** * Trigger asynchronous activity. This is used for triggering special * behaviors of the camera 3A routines when they are in use. See the * documentation for CAMERA2_TRIGGER_* above for details of the trigger ids * and their arguments. */ int (*trigger_action)(const struct camera2_device *, uint32_t trigger_id, int32_t ext1, int32_t ext2); /** * Notification callback setup */ int (*set_notify_callback)(const struct camera2_device *, camera2_notify_callback notify_cb, void *user); /** * Get methods to query for vendor extension metadata tag infomation. May * set ops to NULL if no vendor extension tags are defined. */ int (*get_metadata_vendor_tag_ops)(const struct camera2_device*, vendor_tag_query_ops_t **ops); /** * Dump state of the camera hardware */ int (*dump)(const struct camera2_device *, int fd); /** * Get device-instance-specific metadata. This metadata must be constant for * a single instance of the camera device, but may be different between * open() calls. The returned camera_metadata pointer must be valid until * the device close() method is called. * * Version information: * * CAMERA_DEVICE_API_VERSION_2_0: * * Not available. Framework may not access this function pointer. * * CAMERA_DEVICE_API_VERSION_2_1: * * Valid. Can be called by the framework. * */ int (*get_instance_metadata)(const struct camera2_device *, camera_metadata **instance_metadata); } camera2_device_ops_t; /********************************************************************** * * Camera device definition * */ typedef struct camera2_device { /** * common.version must equal CAMERA_DEVICE_API_VERSION_2_0 to identify * this device as implementing version 2.0 of the camera device HAL. */ hw_device_t common; camera2_device_ops_t *ops; void *priv; } camera2_device_t; __END_DECLS #endif /* #ifdef ANDROID_INCLUDE_CAMERA2_H */ android-headers-23/23/hardware/camera3.h000066400000000000000000004275351264465411000200610ustar00rootroot00000000000000/* * 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_CAMERA3_H #define ANDROID_INCLUDE_CAMERA3_H #include #include "camera_common.h" /** * Camera device HAL 3.3 [ CAMERA_DEVICE_API_VERSION_3_3 ] * * This is the current recommended version of the camera device HAL. * * Supports the android.hardware.Camera API, and as of v3.2, the * android.hardware.camera2 API in LIMITED or FULL modes. * * Camera devices that support this version of the HAL must return * CAMERA_DEVICE_API_VERSION_3_3 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: * Camera modules that may contain version 3.3 devices must implement at * least version 2.2 of the camera module interface (as defined by * camera_module_t.common.module_api_version). * * CAMERA_DEVICE_API_VERSION_3_2: * Camera modules that may contain version 3.2 devices must implement at * least version 2.2 of the camera module interface (as defined by * camera_module_t.common.module_api_version). * * <= CAMERA_DEVICE_API_VERSION_3_1: * Camera modules that may contain version 3.1 (or 3.0) devices must * implement at least version 2.0 of the camera module interface * (as defined by camera_module_t.common.module_api_version). * * See camera_common.h for more versioning details. * * Documentation index: * S1. Version history * S2. Startup and operation sequencing * S3. Operational modes * S4. 3A modes and state machines * S5. Cropping * S6. Error management * S7. Key Performance Indicator (KPI) glossary * S8. Sample Use Cases * S9. Notes on Controls and Metadata * S10. Reprocessing flow and controls */ /** * S1. Version history: * * 1.0: Initial Android camera HAL (Android 4.0) [camera.h]: * * - Converted from C++ CameraHardwareInterface abstraction layer. * * - Supports android.hardware.Camera API. * * 2.0: Initial release of expanded-capability HAL (Android 4.2) [camera2.h]: * * - Sufficient for implementing existing android.hardware.Camera API. * * - Allows for ZSL queue in camera service layer * * - Not tested for any new features such manual capture control, Bayer RAW * capture, reprocessing of RAW data. * * 3.0: First revision of expanded-capability HAL: * * - Major version change since the ABI is completely different. No change to * the required hardware capabilities or operational model from 2.0. * * - Reworked input request and stream queue interfaces: Framework calls into * HAL with next request and stream buffers already dequeued. Sync framework * support is included, necessary for efficient implementations. * * - Moved triggers into requests, most notifications into results. * * - Consolidated all callbacks into framework into one structure, and all * setup methods into a single initialize() call. * * - Made stream configuration into a single call to simplify stream * management. Bidirectional streams replace STREAM_FROM_STREAM construct. * * - Limited mode semantics for older/limited hardware devices. * * 3.1: Minor revision of expanded-capability HAL: * * - configure_streams passes consumer usage flags to the HAL. * * - flush call to drop all in-flight requests/buffers as fast as possible. * * 3.2: Minor revision of expanded-capability HAL: * * - Deprecates get_metadata_vendor_tag_ops. Please use get_vendor_tag_ops * in camera_common.h instead. * * - register_stream_buffers deprecated. All gralloc buffers provided * by framework to HAL in process_capture_request may be new at any time. * * - add partial result support. process_capture_result may be called * multiple times with a subset of the available result before the full * result is available. * * - add manual template to camera3_request_template. The applications may * use this template to control the capture settings directly. * * - Rework the bidirectional and input stream specifications. * * - change the input buffer return path. The buffer is returned in * process_capture_result instead of process_capture_request. * * 3.3: Minor revision of expanded-capability HAL: * * - OPAQUE and YUV reprocessing API updates. * * - Basic support for depth output buffers. * * - Addition of data_space field to camera3_stream_t. * * - Addition of rotation field to camera3_stream_t. * * - Addition of camera3 stream configuration operation mode to camera3_stream_configuration_t * */ /** * S2. Startup and general expected operation sequence: * * 1. Framework calls camera_module_t->common.open(), which returns a * hardware_device_t structure. * * 2. Framework inspects the hardware_device_t->version field, and instantiates * the appropriate handler for that version of the camera hardware device. In * case the version is CAMERA_DEVICE_API_VERSION_3_0, the device is cast to * a camera3_device_t. * * 3. Framework calls camera3_device_t->ops->initialize() with the framework * callback function pointers. This will only be called this one time after * open(), before any other functions in the ops structure are called. * * 4. The framework calls camera3_device_t->ops->configure_streams() with a list * of input/output streams to the HAL device. * * 5. <= CAMERA_DEVICE_API_VERSION_3_1: * * The framework allocates gralloc buffers and calls * camera3_device_t->ops->register_stream_buffers() for at least one of the * output streams listed in configure_streams. The same stream is registered * only once. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * camera3_device_t->ops->register_stream_buffers() is not called and must * be NULL. * * 6. The framework requests default settings for some number of use cases with * calls to camera3_device_t->ops->construct_default_request_settings(). This * may occur any time after step 3. * * 7. The framework constructs and sends the first capture request to the HAL, * with settings based on one of the sets of default settings, and with at * least one output stream, which has been registered earlier by the * framework. This is sent to the HAL with * camera3_device_t->ops->process_capture_request(). The HAL must block the * return of this call until it is ready for the next request to be sent. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * The buffer_handle_t provided in the camera3_stream_buffer_t array * in the camera3_capture_request_t may be new and never-before-seen * by the HAL on any given new request. * * 8. The framework continues to submit requests, and call * construct_default_request_settings to get default settings buffers for * other use cases. * * <= CAMERA_DEVICE_API_VERSION_3_1: * * The framework may call register_stream_buffers() at this time for * not-yet-registered streams. * * 9. When the capture of a request begins (sensor starts exposing for the * capture) or processing a reprocess request begins, the HAL * calls camera3_callback_ops_t->notify() with the SHUTTER event, including * the frame number and the timestamp for start of exposure. For a reprocess * request, the timestamp must be the start of exposure of the input image * which can be looked up with android.sensor.timestamp from * camera3_capture_request_t.settings when process_capture_request() is * called. * * <= CAMERA_DEVICE_API_VERSION_3_1: * * This notify call must be made before the first call to * process_capture_result() for that frame number. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * The camera3_callback_ops_t->notify() call with the SHUTTER event should * be made as early as possible since the framework will be unable to * deliver gralloc buffers to the application layer (for that frame) until * it has a valid timestamp for the start of exposure (or the input image's * start of exposure for a reprocess request). * * Both partial metadata results and the gralloc buffers may be sent to the * framework at any time before or after the SHUTTER event. * * 10. After some pipeline delay, the HAL begins to return completed captures to * the framework with camera3_callback_ops_t->process_capture_result(). These * are returned in the same order as the requests were submitted. Multiple * requests can be in flight at once, depending on the pipeline depth of the * camera HAL device. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * Once a buffer is returned by process_capture_result as part of the * camera3_stream_buffer_t array, and the fence specified by release_fence * has been signaled (this is a no-op for -1 fences), the ownership of that * buffer is considered to be transferred back to the framework. After that, * the HAL must no longer retain that particular buffer, and the * framework may clean up the memory for it immediately. * * process_capture_result may be called multiple times for a single frame, * each time with a new disjoint piece of metadata and/or set of gralloc * buffers. The framework will accumulate these partial metadata results * into one result. * * In particular, it is legal for a process_capture_result to be called * simultaneously for both a frame N and a frame N+1 as long as the * above rule holds for gralloc buffers (both input and output). * * 11. After some time, the framework may stop submitting new requests, wait for * the existing captures to complete (all buffers filled, all results * returned), and then call configure_streams() again. This resets the camera * hardware and pipeline for a new set of input/output streams. Some streams * may be reused from the previous configuration; if these streams' buffers * had already been registered with the HAL, they will not be registered * again. The framework then continues from step 7, if at least one * registered output stream remains (otherwise, step 5 is required first). * * 12. Alternatively, the framework may call camera3_device_t->common->close() * to end the camera session. This may be called at any time when no other * calls from the framework are active, although the call may block until all * in-flight captures have completed (all results returned, all buffers * filled). After the close call returns, no more calls to the * camera3_callback_ops_t functions are allowed from the HAL. Once the * close() call is underway, the framework may not call any other HAL device * functions. * * 13. In case of an error or other asynchronous event, the HAL must call * camera3_callback_ops_t->notify() with the appropriate error/event * message. After returning from a fatal device-wide error notification, the * HAL should act as if close() had been called on it. However, the HAL must * either cancel or complete all outstanding captures before calling * notify(), so that once notify() is called with a fatal error, the * framework will not receive further callbacks from the device. Methods * besides close() should return -ENODEV or NULL after the notify() method * returns from a fatal error message. */ /** * S3. Operational modes: * * The camera 3 HAL device can implement one of two possible operational modes; * limited and full. Full support is expected from new higher-end * devices. Limited mode has hardware requirements roughly in line with those * for a camera HAL device v1 implementation, and is expected from older or * inexpensive devices. Full is a strict superset of limited, and they share the * same essential operational flow, as documented above. * * The HAL must indicate its level of support with the * android.info.supportedHardwareLevel static metadata entry, with 0 indicating * limited mode, and 1 indicating full mode support. * * Roughly speaking, limited-mode devices do not allow for application control * of capture settings (3A control only), high-rate capture of high-resolution * images, raw sensor readout, or support for YUV output streams above maximum * recording resolution (JPEG only for large images). * * ** Details of limited mode behavior: * * - Limited-mode devices do not need to implement accurate synchronization * between capture request settings and the actual image data * captured. Instead, changes to settings may take effect some time in the * future, and possibly not for the same output frame for each settings * entry. Rapid changes in settings may result in some settings never being * used for a capture. However, captures that include high-resolution output * buffers ( > 1080p ) have to use the settings as specified (but see below * for processing rate). * * - Limited-mode devices do not need to support most of the * settings/result/static info metadata. Specifically, only the following settings * are expected to be consumed or produced by a limited-mode HAL device: * * android.control.aeAntibandingMode (controls and dynamic) * android.control.aeExposureCompensation (controls and dynamic) * android.control.aeLock (controls and dynamic) * android.control.aeMode (controls and dynamic) * android.control.aeRegions (controls and dynamic) * android.control.aeTargetFpsRange (controls and dynamic) * android.control.aePrecaptureTrigger (controls and dynamic) * android.control.afMode (controls and dynamic) * android.control.afRegions (controls and dynamic) * android.control.awbLock (controls and dynamic) * android.control.awbMode (controls and dynamic) * android.control.awbRegions (controls and dynamic) * android.control.captureIntent (controls and dynamic) * android.control.effectMode (controls and dynamic) * android.control.mode (controls and dynamic) * android.control.sceneMode (controls and dynamic) * android.control.videoStabilizationMode (controls and dynamic) * android.control.aeAvailableAntibandingModes (static) * android.control.aeAvailableModes (static) * android.control.aeAvailableTargetFpsRanges (static) * android.control.aeCompensationRange (static) * android.control.aeCompensationStep (static) * android.control.afAvailableModes (static) * android.control.availableEffects (static) * android.control.availableSceneModes (static) * android.control.availableVideoStabilizationModes (static) * android.control.awbAvailableModes (static) * android.control.maxRegions (static) * android.control.sceneModeOverrides (static) * android.control.aeState (dynamic) * android.control.afState (dynamic) * android.control.awbState (dynamic) * * android.flash.mode (controls and dynamic) * android.flash.info.available (static) * * android.info.supportedHardwareLevel (static) * * android.jpeg.gpsCoordinates (controls and dynamic) * android.jpeg.gpsProcessingMethod (controls and dynamic) * android.jpeg.gpsTimestamp (controls and dynamic) * android.jpeg.orientation (controls and dynamic) * android.jpeg.quality (controls and dynamic) * android.jpeg.thumbnailQuality (controls and dynamic) * android.jpeg.thumbnailSize (controls and dynamic) * android.jpeg.availableThumbnailSizes (static) * android.jpeg.maxSize (static) * * android.lens.info.minimumFocusDistance (static) * * android.request.id (controls and dynamic) * * android.scaler.cropRegion (controls and dynamic) * android.scaler.availableStreamConfigurations (static) * android.scaler.availableMinFrameDurations (static) * android.scaler.availableStallDurations (static) * android.scaler.availableMaxDigitalZoom (static) * android.scaler.maxDigitalZoom (static) * android.scaler.croppingType (static) * * android.sensor.orientation (static) * android.sensor.timestamp (dynamic) * * android.statistics.faceDetectMode (controls and dynamic) * android.statistics.info.availableFaceDetectModes (static) * android.statistics.faceIds (dynamic) * android.statistics.faceLandmarks (dynamic) * android.statistics.faceRectangles (dynamic) * android.statistics.faceScores (dynamic) * * android.sync.frameNumber (dynamic) * android.sync.maxLatency (static) * * - Captures in limited mode that include high-resolution (> 1080p) output * buffers may block in process_capture_request() until all the output buffers * have been filled. A full-mode HAL device must process sequences of * high-resolution requests at the rate indicated in the static metadata for * that pixel format. The HAL must still call process_capture_result() to * provide the output; the framework must simply be prepared for * process_capture_request() to block until after process_capture_result() for * that request completes for high-resolution captures for limited-mode * devices. * * - Full-mode devices must support below additional capabilities: * - 30fps at maximum resolution is preferred, more than 20fps is required. * - Per frame control (android.sync.maxLatency == PER_FRAME_CONTROL). * - Sensor manual control metadata. See MANUAL_SENSOR defined in * android.request.availableCapabilities. * - Post-processing manual control metadata. See MANUAL_POST_PROCESSING defined * in android.request.availableCapabilities. * */ /** * S4. 3A modes and state machines: * * While the actual 3A algorithms are up to the HAL implementation, a high-level * state machine description is defined by the HAL interface, to allow the HAL * device and the framework to communicate about the current state of 3A, and to * trigger 3A events. * * When the device is opened, all the individual 3A states must be * STATE_INACTIVE. Stream configuration does not reset 3A. For example, locked * focus must be maintained across the configure() call. * * Triggering a 3A action involves simply setting the relevant trigger entry in * the settings for the next request to indicate start of trigger. For example, * the trigger for starting an autofocus scan is setting the entry * ANDROID_CONTROL_AF_TRIGGER to ANDROID_CONTROL_AF_TRIGGER_START for one * request, and cancelling an autofocus scan is triggered by setting * ANDROID_CONTROL_AF_TRIGGER to ANDROID_CONTRL_AF_TRIGGER_CANCEL. Otherwise, * the entry will not exist, or be set to ANDROID_CONTROL_AF_TRIGGER_IDLE. Each * request with a trigger entry set to a non-IDLE value will be treated as an * independent triggering event. * * At the top level, 3A is controlled by the ANDROID_CONTROL_MODE setting, which * selects between no 3A (ANDROID_CONTROL_MODE_OFF), normal AUTO mode * (ANDROID_CONTROL_MODE_AUTO), and using the scene mode setting * (ANDROID_CONTROL_USE_SCENE_MODE). * * - In OFF mode, each of the individual AE/AF/AWB modes are effectively OFF, * and none of the capture controls may be overridden by the 3A routines. * * - In AUTO mode, Auto-focus, auto-exposure, and auto-whitebalance all run * their own independent algorithms, and have their own mode, state, and * trigger metadata entries, as listed in the next section. * * - In USE_SCENE_MODE, the value of the ANDROID_CONTROL_SCENE_MODE entry must * be used to determine the behavior of 3A routines. In SCENE_MODEs other than * FACE_PRIORITY, the HAL must override the values of * ANDROId_CONTROL_AE/AWB/AF_MODE to be the mode it prefers for the selected * SCENE_MODE. For example, the HAL may prefer SCENE_MODE_NIGHT to use * CONTINUOUS_FOCUS AF mode. Any user selection of AE/AWB/AF_MODE when scene * must be ignored for these scene modes. * * - For SCENE_MODE_FACE_PRIORITY, the AE/AWB/AF_MODE controls work as in * ANDROID_CONTROL_MODE_AUTO, but the 3A routines must bias toward metering * and focusing on any detected faces in the scene. * * S4.1. Auto-focus settings and result entries: * * Main metadata entries: * * ANDROID_CONTROL_AF_MODE: Control for selecting the current autofocus * mode. Set by the framework in the request settings. * * AF_MODE_OFF: AF is disabled; the framework/app directly controls lens * position. * * AF_MODE_AUTO: Single-sweep autofocus. No lens movement unless AF is * triggered. * * AF_MODE_MACRO: Single-sweep up-close autofocus. No lens movement unless * AF is triggered. * * AF_MODE_CONTINUOUS_VIDEO: Smooth continuous focusing, for recording * video. Triggering immediately locks focus in current * position. Canceling resumes cotinuous focusing. * * AF_MODE_CONTINUOUS_PICTURE: Fast continuous focusing, for * zero-shutter-lag still capture. Triggering locks focus once currently * active sweep concludes. Canceling resumes continuous focusing. * * AF_MODE_EDOF: Advanced extended depth of field focusing. There is no * autofocus scan, so triggering one or canceling one has no effect. * Images are focused automatically by the HAL. * * ANDROID_CONTROL_AF_STATE: Dynamic metadata describing the current AF * algorithm state, reported by the HAL in the result metadata. * * AF_STATE_INACTIVE: No focusing has been done, or algorithm was * reset. Lens is not moving. Always the state for MODE_OFF or MODE_EDOF. * When the device is opened, it must start in this state. * * AF_STATE_PASSIVE_SCAN: A continuous focus algorithm is currently scanning * for good focus. The lens is moving. * * AF_STATE_PASSIVE_FOCUSED: A continuous focus algorithm believes it is * well focused. The lens is not moving. The HAL may spontaneously leave * this state. * * AF_STATE_PASSIVE_UNFOCUSED: A continuous focus algorithm believes it is * not well focused. The lens is not moving. The HAL may spontaneously * leave this state. * * AF_STATE_ACTIVE_SCAN: A scan triggered by the user is underway. * * AF_STATE_FOCUSED_LOCKED: The AF algorithm believes it is focused. The * lens is not moving. * * AF_STATE_NOT_FOCUSED_LOCKED: The AF algorithm has been unable to * focus. The lens is not moving. * * ANDROID_CONTROL_AF_TRIGGER: Control for starting an autofocus scan, the * meaning of which is mode- and state- dependent. Set by the framework in * the request settings. * * AF_TRIGGER_IDLE: No current trigger. * * AF_TRIGGER_START: Trigger start of AF scan. Effect is mode and state * dependent. * * AF_TRIGGER_CANCEL: Cancel current AF scan if any, and reset algorithm to * default. * * Additional metadata entries: * * ANDROID_CONTROL_AF_REGIONS: Control for selecting the regions of the FOV * that should be used to determine good focus. This applies to all AF * modes that scan for focus. Set by the framework in the request * settings. * * S4.2. Auto-exposure settings and result entries: * * Main metadata entries: * * ANDROID_CONTROL_AE_MODE: Control for selecting the current auto-exposure * mode. Set by the framework in the request settings. * * AE_MODE_OFF: Autoexposure is disabled; the user controls exposure, gain, * frame duration, and flash. * * AE_MODE_ON: Standard autoexposure, with flash control disabled. User may * set flash to fire or to torch mode. * * AE_MODE_ON_AUTO_FLASH: Standard autoexposure, with flash on at HAL's * discretion for precapture and still capture. User control of flash * disabled. * * AE_MODE_ON_ALWAYS_FLASH: Standard autoexposure, with flash always fired * for capture, and at HAL's discretion for precapture.. User control of * flash disabled. * * AE_MODE_ON_AUTO_FLASH_REDEYE: Standard autoexposure, with flash on at * HAL's discretion for precapture and still capture. Use a flash burst * at end of precapture sequence to reduce redeye in the final * picture. User control of flash disabled. * * ANDROID_CONTROL_AE_STATE: Dynamic metadata describing the current AE * algorithm state, reported by the HAL in the result metadata. * * AE_STATE_INACTIVE: Initial AE state after mode switch. When the device is * opened, it must start in this state. * * AE_STATE_SEARCHING: AE is not converged to a good value, and is adjusting * exposure parameters. * * AE_STATE_CONVERGED: AE has found good exposure values for the current * scene, and the exposure parameters are not changing. HAL may * spontaneously leave this state to search for better solution. * * AE_STATE_LOCKED: AE has been locked with the AE_LOCK control. Exposure * values are not changing. * * AE_STATE_FLASH_REQUIRED: The HAL has converged exposure, but believes * flash is required for a sufficiently bright picture. Used for * determining if a zero-shutter-lag frame can be used. * * AE_STATE_PRECAPTURE: The HAL is in the middle of a precapture * sequence. Depending on AE mode, this mode may involve firing the * flash for metering, or a burst of flash pulses for redeye reduction. * * ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER: Control for starting a metering * sequence before capturing a high-quality image. Set by the framework in * the request settings. * * PRECAPTURE_TRIGGER_IDLE: No current trigger. * * PRECAPTURE_TRIGGER_START: Start a precapture sequence. The HAL should * use the subsequent requests to measure good exposure/white balance * for an upcoming high-resolution capture. * * Additional metadata entries: * * ANDROID_CONTROL_AE_LOCK: Control for locking AE controls to their current * values * * ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION: Control for adjusting AE * algorithm target brightness point. * * ANDROID_CONTROL_AE_TARGET_FPS_RANGE: Control for selecting the target frame * rate range for the AE algorithm. The AE routine cannot change the frame * rate to be outside these bounds. * * ANDROID_CONTROL_AE_REGIONS: Control for selecting the regions of the FOV * that should be used to determine good exposure levels. This applies to * all AE modes besides OFF. * * S4.3. Auto-whitebalance settings and result entries: * * Main metadata entries: * * ANDROID_CONTROL_AWB_MODE: Control for selecting the current white-balance * mode. * * AWB_MODE_OFF: Auto-whitebalance is disabled. User controls color matrix. * * AWB_MODE_AUTO: Automatic white balance is enabled; 3A controls color * transform, possibly using more complex transforms than a simple * matrix. * * AWB_MODE_INCANDESCENT: Fixed white balance settings good for indoor * incandescent (tungsten) lighting, roughly 2700K. * * AWB_MODE_FLUORESCENT: Fixed white balance settings good for fluorescent * lighting, roughly 5000K. * * AWB_MODE_WARM_FLUORESCENT: Fixed white balance settings good for * fluorescent lighting, roughly 3000K. * * AWB_MODE_DAYLIGHT: Fixed white balance settings good for daylight, * roughly 5500K. * * AWB_MODE_CLOUDY_DAYLIGHT: Fixed white balance settings good for clouded * daylight, roughly 6500K. * * AWB_MODE_TWILIGHT: Fixed white balance settings good for * near-sunset/sunrise, roughly 15000K. * * AWB_MODE_SHADE: Fixed white balance settings good for areas indirectly * lit by the sun, roughly 7500K. * * ANDROID_CONTROL_AWB_STATE: Dynamic metadata describing the current AWB * algorithm state, reported by the HAL in the result metadata. * * AWB_STATE_INACTIVE: Initial AWB state after mode switch. When the device * is opened, it must start in this state. * * AWB_STATE_SEARCHING: AWB is not converged to a good value, and is * changing color adjustment parameters. * * AWB_STATE_CONVERGED: AWB has found good color adjustment values for the * current scene, and the parameters are not changing. HAL may * spontaneously leave this state to search for better solution. * * AWB_STATE_LOCKED: AWB has been locked with the AWB_LOCK control. Color * adjustment values are not changing. * * Additional metadata entries: * * ANDROID_CONTROL_AWB_LOCK: Control for locking AWB color adjustments to * their current values. * * ANDROID_CONTROL_AWB_REGIONS: Control for selecting the regions of the FOV * that should be used to determine good color balance. This applies only * to auto-WB mode. * * S4.4. General state machine transition notes * * Switching between AF, AE, or AWB modes always resets the algorithm's state * to INACTIVE. Similarly, switching between CONTROL_MODE or * CONTROL_SCENE_MODE if CONTROL_MODE == USE_SCENE_MODE resets all the * algorithm states to INACTIVE. * * The tables below are per-mode. * * S4.5. AF state machines * * when enabling AF or changing AF mode *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| Any | AF mode change| INACTIVE | | *+--------------------+---------------+--------------------+------------------+ * * mode = AF_MODE_OFF or AF_MODE_EDOF *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | | INACTIVE | Never changes | *+--------------------+---------------+--------------------+------------------+ * * mode = AF_MODE_AUTO or AF_MODE_MACRO *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | AF_TRIGGER | ACTIVE_SCAN | Start AF sweep | *| | | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| ACTIVE_SCAN | AF sweep done | FOCUSED_LOCKED | If AF successful | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| ACTIVE_SCAN | AF sweep done | NOT_FOCUSED_LOCKED | If AF successful | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| ACTIVE_SCAN | AF_CANCEL | INACTIVE | Cancel/reset AF | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Cancel/reset AF | *+--------------------+---------------+--------------------+------------------+ *| FOCUSED_LOCKED | AF_TRIGGER | ACTIVE_SCAN | Start new sweep | *| | | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| NOT_FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Cancel/reset AF | *+--------------------+---------------+--------------------+------------------+ *| NOT_FOCUSED_LOCKED | AF_TRIGGER | ACTIVE_SCAN | Start new sweep | *| | | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| All states | mode change | INACTIVE | | *+--------------------+---------------+--------------------+------------------+ * * mode = AF_MODE_CONTINUOUS_VIDEO *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | HAL initiates | PASSIVE_SCAN | Start AF scan | *| | new scan | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | AF_TRIGGER | NOT_FOCUSED_LOCKED | AF state query | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | HAL completes | PASSIVE_FOCUSED | End AF scan | *| | current scan | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | HAL fails | PASSIVE_UNFOCUSED | End AF scan | *| | current scan | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | AF_TRIGGER | FOCUSED_LOCKED | Immediate trans. | *| | | | if focus is good | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | AF_TRIGGER | NOT_FOCUSED_LOCKED | Immediate trans. | *| | | | if focus is bad | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | AF_CANCEL | INACTIVE | Reset lens | *| | | | position | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_FOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan | *| | new scan | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_UNFOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan | *| | new scan | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_FOCUSED | AF_TRIGGER | FOCUSED_LOCKED | Immediate trans. | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_UNFOCUSED | AF_TRIGGER | NOT_FOCUSED_LOCKED | Immediate trans. | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| FOCUSED_LOCKED | AF_TRIGGER | FOCUSED_LOCKED | No effect | *+--------------------+---------------+--------------------+------------------+ *| FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan | *+--------------------+---------------+--------------------+------------------+ *| NOT_FOCUSED_LOCKED | AF_TRIGGER | NOT_FOCUSED_LOCKED | No effect | *+--------------------+---------------+--------------------+------------------+ *| NOT_FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan | *+--------------------+---------------+--------------------+------------------+ * * mode = AF_MODE_CONTINUOUS_PICTURE *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | HAL initiates | PASSIVE_SCAN | Start AF scan | *| | new scan | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | AF_TRIGGER | NOT_FOCUSED_LOCKED | AF state query | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | HAL completes | PASSIVE_FOCUSED | End AF scan | *| | current scan | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | HAL fails | PASSIVE_UNFOCUSED | End AF scan | *| | current scan | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | AF_TRIGGER | FOCUSED_LOCKED | Eventual trans. | *| | | | once focus good | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | AF_TRIGGER | NOT_FOCUSED_LOCKED | Eventual trans. | *| | | | if cannot focus | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | AF_CANCEL | INACTIVE | Reset lens | *| | | | position | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_FOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan | *| | new scan | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_UNFOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan | *| | new scan | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_FOCUSED | AF_TRIGGER | FOCUSED_LOCKED | Immediate trans. | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_UNFOCUSED | AF_TRIGGER | NOT_FOCUSED_LOCKED | Immediate trans. | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| FOCUSED_LOCKED | AF_TRIGGER | FOCUSED_LOCKED | No effect | *+--------------------+---------------+--------------------+------------------+ *| FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan | *+--------------------+---------------+--------------------+------------------+ *| NOT_FOCUSED_LOCKED | AF_TRIGGER | NOT_FOCUSED_LOCKED | No effect | *+--------------------+---------------+--------------------+------------------+ *| NOT_FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan | *+--------------------+---------------+--------------------+------------------+ * * S4.6. AE and AWB state machines * * The AE and AWB state machines are mostly identical. AE has additional * FLASH_REQUIRED and PRECAPTURE states. So rows below that refer to those two * states should be ignored for the AWB state machine. * * when enabling AE/AWB or changing AE/AWB mode *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| Any | mode change | INACTIVE | | *+--------------------+---------------+--------------------+------------------+ * * mode = AE_MODE_OFF / AWB mode not AUTO *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | | INACTIVE | AE/AWB disabled | *+--------------------+---------------+--------------------+------------------+ * * mode = AE_MODE_ON_* / AWB_MODE_AUTO *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | HAL initiates | SEARCHING | | *| | AE/AWB scan | | | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | AE/AWB_LOCK | LOCKED | values locked | *| | on | | | *+--------------------+---------------+--------------------+------------------+ *| SEARCHING | HAL finishes | CONVERGED | good values, not | *| | AE/AWB scan | | changing | *+--------------------+---------------+--------------------+------------------+ *| SEARCHING | HAL finishes | FLASH_REQUIRED | converged but too| *| | AE scan | | dark w/o flash | *+--------------------+---------------+--------------------+------------------+ *| SEARCHING | AE/AWB_LOCK | LOCKED | values locked | *| | on | | | *+--------------------+---------------+--------------------+------------------+ *| CONVERGED | HAL initiates | SEARCHING | values locked | *| | AE/AWB scan | | | *+--------------------+---------------+--------------------+------------------+ *| CONVERGED | AE/AWB_LOCK | LOCKED | values locked | *| | on | | | *+--------------------+---------------+--------------------+------------------+ *| FLASH_REQUIRED | HAL initiates | SEARCHING | values locked | *| | AE/AWB scan | | | *+--------------------+---------------+--------------------+------------------+ *| FLASH_REQUIRED | AE/AWB_LOCK | LOCKED | values locked | *| | on | | | *+--------------------+---------------+--------------------+------------------+ *| LOCKED | AE/AWB_LOCK | SEARCHING | values not good | *| | off | | after unlock | *+--------------------+---------------+--------------------+------------------+ *| LOCKED | AE/AWB_LOCK | CONVERGED | values good | *| | off | | after unlock | *+--------------------+---------------+--------------------+------------------+ *| LOCKED | AE_LOCK | FLASH_REQUIRED | exposure good, | *| | off | | but too dark | *+--------------------+---------------+--------------------+------------------+ *| All AE states | PRECAPTURE_ | PRECAPTURE | Start precapture | *| | START | | sequence | *+--------------------+---------------+--------------------+------------------+ *| PRECAPTURE | Sequence done.| CONVERGED | Ready for high- | *| | AE_LOCK off | | quality capture | *+--------------------+---------------+--------------------+------------------+ *| PRECAPTURE | Sequence done.| LOCKED | Ready for high- | *| | AE_LOCK on | | quality capture | *+--------------------+---------------+--------------------+------------------+ * */ /** * S5. Cropping: * * Cropping of the full pixel array (for digital zoom and other use cases where * a smaller FOV is desirable) is communicated through the * ANDROID_SCALER_CROP_REGION setting. This is a per-request setting, and can * change on a per-request basis, which is critical for implementing smooth * digital zoom. * * The region is defined as a rectangle (x, y, width, height), with (x, y) * describing the top-left corner of the rectangle. The rectangle is defined on * the coordinate system of the sensor active pixel array, with (0,0) being the * top-left pixel of the active pixel array. Therefore, the width and height * cannot be larger than the dimensions reported in the * ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY static info field. The minimum allowed * width and height are reported by the HAL through the * ANDROID_SCALER_MAX_DIGITAL_ZOOM static info field, which describes the * maximum supported zoom factor. Therefore, the minimum crop region width and * height are: * * {width, height} = * { floor(ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY[0] / * ANDROID_SCALER_MAX_DIGITAL_ZOOM), * floor(ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY[1] / * ANDROID_SCALER_MAX_DIGITAL_ZOOM) } * * If the crop region needs to fulfill specific requirements (for example, it * needs to start on even coordinates, and its width/height needs to be even), * the HAL must do the necessary rounding and write out the final crop region * used in the output result metadata. Similarly, if the HAL implements video * stabilization, it must adjust the result crop region to describe the region * actually included in the output after video stabilization is applied. In * general, a camera-using application must be able to determine the field of * view it is receiving based on the crop region, the dimensions of the image * sensor, and the lens focal length. * * It is assumed that the cropping is applied after raw to other color space * conversion. Raw streams (RAW16 and RAW_OPAQUE) don't have this conversion stage, * and are not croppable. Therefore, the crop region must be ignored by the HAL * for raw streams. * * Since the crop region applies to all non-raw streams, which may have different aspect * ratios than the crop region, the exact sensor region used for each stream may * be smaller than the crop region. Specifically, each stream should maintain * square pixels and its aspect ratio by minimally further cropping the defined * crop region. If the stream's aspect ratio is wider than the crop region, the * stream should be further cropped vertically, and if the stream's aspect ratio * is narrower than the crop region, the stream should be further cropped * horizontally. * * In all cases, the stream crop must be centered within the full crop region, * and each stream is only either cropped horizontally or vertical relative to * the full crop region, never both. * * For example, if two streams are defined, a 640x480 stream (4:3 aspect), and a * 1280x720 stream (16:9 aspect), below demonstrates the expected output regions * for each stream for a few sample crop regions, on a hypothetical 3 MP (2000 x * 1500 pixel array) sensor. * * Crop region: (500, 375, 1000, 750) (4:3 aspect ratio) * * 640x480 stream crop: (500, 375, 1000, 750) (equal to crop region) * 1280x720 stream crop: (500, 469, 1000, 562) (marked with =) * * 0 1000 2000 * +---------+---------+---------+----------+ * | Active pixel array | * | | * | | * + +-------------------+ + 375 * | | | | * | O===================O | * | I 1280x720 stream I | * + I I + 750 * | I I | * | O===================O | * | | | | * + +-------------------+ + 1125 * | Crop region, 640x480 stream | * | | * | | * +---------+---------+---------+----------+ 1500 * * Crop region: (500, 375, 1333, 750) (16:9 aspect ratio) * * 640x480 stream crop: (666, 375, 1000, 750) (marked with =) * 1280x720 stream crop: (500, 375, 1333, 750) (equal to crop region) * * 0 1000 2000 * +---------+---------+---------+----------+ * | Active pixel array | * | | * | | * + +---O==================O---+ + 375 * | | I 640x480 stream I | | * | | I I | | * | | I I | | * + | I I | + 750 * | | I I | | * | | I I | | * | | I I | | * + +---O==================O---+ + 1125 * | Crop region, 1280x720 stream | * | | * | | * +---------+---------+---------+----------+ 1500 * * Crop region: (500, 375, 750, 750) (1:1 aspect ratio) * * 640x480 stream crop: (500, 469, 750, 562) (marked with =) * 1280x720 stream crop: (500, 543, 750, 414) (marged with #) * * 0 1000 2000 * +---------+---------+---------+----------+ * | Active pixel array | * | | * | | * + +--------------+ + 375 * | O==============O | * | ################ | * | # # | * + # # + 750 * | # # | * | ################ 1280x720 | * | O==============O 640x480 | * + +--------------+ + 1125 * | Crop region | * | | * | | * +---------+---------+---------+----------+ 1500 * * And a final example, a 1024x1024 square aspect ratio stream instead of the * 480p stream: * * Crop region: (500, 375, 1000, 750) (4:3 aspect ratio) * * 1024x1024 stream crop: (625, 375, 750, 750) (marked with #) * 1280x720 stream crop: (500, 469, 1000, 562) (marked with =) * * 0 1000 2000 * +---------+---------+---------+----------+ * | Active pixel array | * | | * | 1024x1024 stream | * + +--###############--+ + 375 * | | # # | | * | O===================O | * | I 1280x720 stream I | * + I I + 750 * | I I | * | O===================O | * | | # # | | * + +--###############--+ + 1125 * | Crop region | * | | * | | * +---------+---------+---------+----------+ 1500 * */ /** * S6. Error management: * * Camera HAL device ops functions that have a return value will all return * -ENODEV / NULL in case of a serious error. This means the device cannot * continue operation, and must be closed by the framework. Once this error is * returned by some method, or if notify() is called with ERROR_DEVICE, only * the close() method can be called successfully. All other methods will return * -ENODEV / NULL. * * If a device op is called in the wrong sequence, for example if the framework * calls configure_streams() is called before initialize(), the device must * return -ENOSYS from the call, and do nothing. * * Transient errors in image capture must be reported through notify() as follows: * * - The failure of an entire capture to occur must be reported by the HAL by * calling notify() with ERROR_REQUEST. Individual errors for the result * metadata or the output buffers must not be reported in this case. * * - If the metadata for a capture cannot be produced, but some image buffers * were filled, the HAL must call notify() with ERROR_RESULT. * * - If an output image buffer could not be filled, but either the metadata was * produced or some other buffers were filled, the HAL must call notify() with * ERROR_BUFFER for each failed buffer. * * In each of these transient failure cases, the HAL must still call * process_capture_result, with valid output and input (if an input buffer was * submitted) buffer_handle_t. If the result metadata could not be produced, it * should be NULL. If some buffers could not be filled, they must be returned with * process_capture_result in the error state, their release fences must be set to * the acquire fences passed by the framework, or -1 if they have been waited on by * the HAL already. * * Invalid input arguments result in -EINVAL from the appropriate methods. In * that case, the framework must act as if that call had never been made. * */ /** * S7. Key Performance Indicator (KPI) glossary: * * This includes some critical definitions that are used by KPI metrics. * * Pipeline Latency: * For a given capture request, the duration from the framework calling * process_capture_request to the HAL sending capture result and all buffers * back by process_capture_result call. To make the Pipeline Latency measure * independent of frame rate, it is measured by frame count. * * For example, when frame rate is 30 (fps), the frame duration (time interval * between adjacent frame capture time) is 33 (ms). * If it takes 5 frames for framework to get the result and buffers back for * a given request, then the Pipeline Latency is 5 (frames), instead of * 5 x 33 = 165 (ms). * * The Pipeline Latency is determined by android.request.pipelineDepth and * android.request.pipelineMaxDepth, see their definitions for more details. * */ /** * S8. Sample Use Cases: * * This includes some typical use case examples the camera HAL may support. * * S8.1 Zero Shutter Lag (ZSL) with CAMERA3_STREAM_BIDIRECTIONAL stream. * * For this use case, the bidirectional stream will be used by the framework as follows: * * 1. The framework includes a buffer from this stream as output buffer in a * request as normal. * * 2. Once the HAL device returns a filled output buffer to the framework, * the framework may do one of two things with the filled buffer: * * 2. a. The framework uses the filled data, and returns the now-used buffer * to the stream queue for reuse. This behavior exactly matches the * OUTPUT type of stream. * * 2. b. The framework wants to reprocess the filled data, and uses the * buffer as an input buffer for a request. Once the HAL device has * used the reprocessing buffer, it then returns it to the * framework. The framework then returns the now-used buffer to the * stream queue for reuse. * * 3. The HAL device will be given the buffer again as an output buffer for * a request at some future point. * * For ZSL use case, the pixel format for bidirectional stream will be * HAL_PIXEL_FORMAT_RAW_OPAQUE or HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED if it * is listed in android.scaler.availableInputOutputFormatsMap. When * HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, the gralloc * usage flags for the consumer endpoint will be set to GRALLOC_USAGE_HW_CAMERA_ZSL. * A configuration stream list that has BIDIRECTIONAL stream used as input, will * usually also have a distinct OUTPUT stream to get the reprocessing data. For example, * for the ZSL use case, the stream list might be configured with the following: * * - A HAL_PIXEL_FORMAT_RAW_OPAQUE bidirectional stream is used * as input. * - And a HAL_PIXEL_FORMAT_BLOB (JPEG) output stream. * * S8.2 ZSL (OPAQUE) reprocessing with CAMERA3_STREAM_INPUT stream. * * CAMERA_DEVICE_API_VERSION_3_3: * When OPAQUE_REPROCESSING capability is supported by the camera device, the INPUT stream * can be used for application/framework implemented use case like Zero Shutter Lag (ZSL). * This kind of stream will be used by the framework as follows: * * 1. Application/framework configures an opaque (RAW or YUV based) format output stream that is * used to produce the ZSL output buffers. The stream pixel format will be * HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED. * * 2. Application/framework configures an opaque format input stream that is used to * send the reprocessing ZSL buffers to the HAL. The stream pixel format will * also be HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED. * * 3. Application/framework configures a YUV/JPEG output stream that is used to receive the * reprocessed data. The stream pixel format will be YCbCr_420/HAL_PIXEL_FORMAT_BLOB. * * 4. Application/framework picks a ZSL buffer from the ZSL output stream when a ZSL capture is * issued by the application, and sends the data back as an input buffer in a * reprocessing request, then sends to the HAL for reprocessing. * * 5. The HAL sends back the output YUV/JPEG result to framework. * * The HAL can select the actual opaque buffer format and configure the ISP pipeline * appropriately based on the HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED format and * the gralloc usage flag GRALLOC_USAGE_HW_CAMERA_ZSL. * S8.3 YUV reprocessing with CAMERA3_STREAM_INPUT stream. * * When YUV reprocessing is supported by the HAL, the INPUT stream * can be used for the YUV reprocessing use cases like lucky-shot and image fusion. * This kind of stream will be used by the framework as follows: * * 1. Application/framework configures an YCbCr_420 format output stream that is * used to produce the output buffers. * * 2. Application/framework configures an YCbCr_420 format input stream that is used to * send the reprocessing YUV buffers to the HAL. * * 3. Application/framework configures a YUV/JPEG output stream that is used to receive the * reprocessed data. The stream pixel format will be YCbCr_420/HAL_PIXEL_FORMAT_BLOB. * * 4. Application/framework processes the output buffers (could be as simple as picking * an output buffer directly) from the output stream when a capture is issued, and sends * the data back as an input buffer in a reprocessing request, then sends to the HAL * for reprocessing. * * 5. The HAL sends back the output YUV/JPEG result to framework. * */ /** * S9. Notes on Controls and Metadata * * This section contains notes about the interpretation and usage of various metadata tags. * * S9.1 HIGH_QUALITY and FAST modes. * * Many camera post-processing blocks may be listed as having HIGH_QUALITY, * FAST, and OFF operating modes. These blocks will typically also have an * 'available modes' tag representing which of these operating modes are * available on a given device. The general policy regarding implementing * these modes is as follows: * * 1. Operating mode controls of hardware blocks that cannot be disabled * must not list OFF in their corresponding 'available modes' tags. * * 2. OFF will always be included in their corresponding 'available modes' * tag if it is possible to disable that hardware block. * * 3. FAST must always be included in the 'available modes' tags for all * post-processing blocks supported on the device. If a post-processing * block also has a slower and higher quality operating mode that does * not meet the framerate requirements for FAST mode, HIGH_QUALITY should * be included in the 'available modes' tag to represent this operating * mode. */ /** * S10. Reprocessing flow and controls * * This section describes the OPAQUE and YUV reprocessing flow and controls. OPAQUE reprocessing * uses an opaque format that is not directly application-visible, and the application can * only select some of the output buffers and send back to HAL for reprocessing, while YUV * reprocessing gives the application opportunity to process the buffers before reprocessing. * * S8 gives the stream configurations for the typical reprocessing uses cases, * this section specifies the buffer flow and controls in more details. * * S10.1 OPAQUE (typically for ZSL use case) reprocessing flow and controls * * For OPAQUE reprocessing (e.g. ZSL) use case, after the application creates the specific * output and input streams, runtime buffer flow and controls are specified as below: * * 1. Application starts output streaming by sending repeating requests for output * opaque buffers and preview. The buffers are held by an application * maintained circular buffer. The requests are based on CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG * capture template, which should have all necessary settings that guarantee output * frame rate is not slowed down relative to sensor output frame rate. * * 2. When a capture is issued, the application selects one output buffer based * on application buffer selection logic, e.g. good AE and AF statistics etc. * Application then creates an reprocess request based on the capture result associated * with this selected buffer. The selected output buffer is now added to this reprocess * request as an input buffer, the output buffer of this reprocess request should be * either JPEG output buffer or YUV output buffer, or both, depending on the application * choice. * * 3. Application then alters the reprocess settings to get best image quality. The HAL must * support and only support below controls if the HAL support OPAQUE_REPROCESSING capability: * - android.jpeg.* (if JPEG buffer is included as one of the output) * - android.noiseReduction.mode (change to HIGH_QUALITY if it is supported) * - android.edge.mode (change to HIGH_QUALITY if it is supported) * All other controls must be ignored by the HAL. * 4. HAL processed the input buffer and return the output buffers in the capture results * as normal. * * S10.2 YUV reprocessing flow and controls * * The YUV reprocessing buffer flow is similar as OPAQUE reprocessing, with below difference: * * 1. Application may want to have finer granularity control of the intermediate YUV images * (before reprocessing). For example, application may choose * - android.noiseReduction.mode == MINIMAL * to make sure the no YUV domain noise reduction has applied to the output YUV buffers, * then it can do its own advanced noise reduction on them. For OPAQUE reprocessing case, this * doesn't matter, as long as the final reprocessed image has the best quality. * 2. Application may modify the YUV output buffer data. For example, for image fusion use * case, where multiple output images are merged together to improve the signal-to-noise * ratio (SNR). The input buffer may be generated from multiple buffers by the application. * To avoid excessive amount of noise reduction and insufficient amount of edge enhancement * being applied to the input buffer, the application can hint the HAL how much effective * exposure time improvement has been done by the application, then the HAL can adjust the * noise reduction and edge enhancement paramters to get best reprocessed image quality. * Below tag can be used for this purpose: * - android.reprocess.effectiveExposureFactor * The value would be exposure time increase factor applied to the original output image, * for example, if there are N image merged, the exposure time increase factor would be up * to sqrt(N). See this tag spec for more details. * * S10.3 Reprocessing pipeline characteristics * * Reprocessing pipeline has below different characteristics comparing with normal output * pipeline: * * 1. The reprocessing result can be returned ahead of the pending normal output results. But * the FIFO ordering must be maintained for all reprocessing results. For example, there are * below requests (A stands for output requests, B stands for reprocessing requests) * being processed by the HAL: * A1, A2, A3, A4, B1, A5, B2, A6... * result of B1 can be returned before A1-A4, but result of B2 must be returned after B1. * 2. Single input rule: For a given reprocessing request, all output buffers must be from the * input buffer, rather than sensor output. For example, if a reprocess request include both * JPEG and preview buffers, all output buffers must be produced from the input buffer * included by the reprocessing request, rather than sensor. The HAL must not output preview * buffers from sensor, while output JPEG buffer from the input buffer. * 3. Input buffer will be from camera output directly (ZSL case) or indirectly(image fusion * case). For the case where buffer is modified, the size will remain same. The HAL can * notify CAMERA3_MSG_ERROR_REQUEST if buffer from unknown source is sent. * 4. Result as reprocessing request: The HAL can expect that a reprocessing request is a copy * of one of the output results with minor allowed setting changes. The HAL can notify * CAMERA3_MSG_ERROR_REQUEST if a request from unknown source is issued. * 5. Output buffers may not be used as inputs across the configure stream boundary, This is * because an opaque stream like the ZSL output stream may have different actual image size * inside of the ZSL buffer to save power and bandwidth for smaller resolution JPEG capture. * The HAL may notify CAMERA3_MSG_ERROR_REQUEST if this case occurs. * 6. HAL Reprocess requests error reporting during flush should follow the same rule specified * by flush() method. * */ __BEGIN_DECLS struct camera3_device; /********************************************************************** * * Camera3 stream and stream buffer definitions. * * These structs and enums define the handles and contents of the input and * output streams connecting the HAL to various framework and application buffer * consumers. Each stream is backed by a gralloc buffer queue. * */ /** * camera3_stream_type_t: * * The type of the camera stream, which defines whether the camera HAL device is * the producer or the consumer for that stream, and how the buffers of the * stream relate to the other streams. */ typedef enum camera3_stream_type { /** * This stream is an output stream; the camera HAL device will be * responsible for filling buffers from this stream with newly captured or * reprocessed image data. */ CAMERA3_STREAM_OUTPUT = 0, /** * This stream is an input stream; the camera HAL device will be responsible * for reading buffers from this stream and sending them through the camera * processing pipeline, as if the buffer was a newly captured image from the * imager. * * The pixel format for input stream can be any format reported by * android.scaler.availableInputOutputFormatsMap. The pixel format of the * output stream that is used to produce the reprocessing data may be any * format reported by android.scaler.availableStreamConfigurations. The * supported input/output stream combinations depends the camera device * capabilities, see android.scaler.availableInputOutputFormatsMap for * stream map details. * * This kind of stream is generally used to reprocess data into higher * quality images (that otherwise would cause a frame rate performance * loss), or to do off-line reprocessing. * * CAMERA_DEVICE_API_VERSION_3_3: * The typical use cases are OPAQUE (typically ZSL) and YUV reprocessing, * see S8.2, S8.3 and S10 for more details. */ CAMERA3_STREAM_INPUT = 1, /** * This stream can be used for input and output. Typically, the stream is * used as an output stream, but occasionally one already-filled buffer may * be sent back to the HAL device for reprocessing. * * This kind of stream is meant generally for Zero Shutter Lag (ZSL) * features, where copying the captured image from the output buffer to the * reprocessing input buffer would be expensive. See S8.1 for more details. * * Note that the HAL will always be reprocessing data it produced. * */ CAMERA3_STREAM_BIDIRECTIONAL = 2, /** * Total number of framework-defined stream types */ CAMERA3_NUM_STREAM_TYPES } camera3_stream_type_t; /** * camera3_stream_rotation_t: * * The required counterclockwise rotation of camera stream. */ typedef enum camera3_stream_rotation { /* No rotation */ CAMERA3_STREAM_ROTATION_0 = 0, /* Rotate by 90 degree counterclockwise */ CAMERA3_STREAM_ROTATION_90 = 1, /* Rotate by 180 degree counterclockwise */ CAMERA3_STREAM_ROTATION_180 = 2, /* Rotate by 270 degree counterclockwise */ CAMERA3_STREAM_ROTATION_270 = 3 } camera3_stream_rotation_t; /** * camera3_stream_configuration_mode_t: * * This defines the general operation mode for the HAL (for a given stream configuration), where * modes besides NORMAL have different semantics, and usually limit the generality of the API in * exchange for higher performance in some particular area. */ typedef enum camera3_stream_configuration_mode { /** * Normal stream configuration operation mode. This is the default camera operation mode, * where all semantics of HAL APIs and metadata controls apply. */ CAMERA3_STREAM_CONFIGURATION_NORMAL_MODE = 0, /** * Special constrained high speed operation mode for devices that can not support high * speed output in NORMAL mode. All streams in this configuration are operating at high speed * mode and have different characteristics and limitations to achieve high speed output. * The NORMAL mode can still be used for high speed output if the HAL can support high speed * output while satisfying all the semantics of HAL APIs and metadata controls. It is * recommended for the HAL to support high speed output in NORMAL mode (by advertising the high * speed FPS ranges in android.control.aeAvailableTargetFpsRanges) if possible. * * This mode has below limitations/requirements: * * 1. The HAL must support up to 2 streams with sizes reported by * android.control.availableHighSpeedVideoConfigurations. * 2. In this mode, the HAL is expected to output up to 120fps or higher. This mode must * support the targeted FPS range and size configurations reported by * android.control.availableHighSpeedVideoConfigurations. * 3. The HAL must support HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED output stream format. * 4. To achieve efficient high speed streaming, the HAL may have to aggregate * multiple frames together and send to camera device for processing where the request * controls are same for all the frames in this batch (batch mode). The HAL must support * max batch size and the max batch size requirements defined by * android.control.availableHighSpeedVideoConfigurations. * 5. In this mode, the HAL must override aeMode, awbMode, and afMode to ON, ON, and * CONTINUOUS_VIDEO, respectively. All post-processing block mode controls must be * overridden to be FAST. Therefore, no manual control of capture and post-processing * parameters is possible. All other controls operate the same as when * android.control.mode == AUTO. This means that all other android.control.* fields * must continue to work, such as * * android.control.aeTargetFpsRange * android.control.aeExposureCompensation * android.control.aeLock * android.control.awbLock * android.control.effectMode * android.control.aeRegions * android.control.afRegions * android.control.awbRegions * android.control.afTrigger * android.control.aePrecaptureTrigger * * Outside of android.control.*, the following controls must work: * * android.flash.mode (TORCH mode only, automatic flash for still capture will not work * since aeMode is ON) * android.lens.opticalStabilizationMode (if it is supported) * android.scaler.cropRegion * android.statistics.faceDetectMode (if it is supported) * * For more details about high speed stream requirements, see * android.control.availableHighSpeedVideoConfigurations and CONSTRAINED_HIGH_SPEED_VIDEO * capability defined in android.request.availableCapabilities. * * This mode only needs to be supported by HALs that include CONSTRAINED_HIGH_SPEED_VIDEO in * the android.request.availableCapabilities static metadata. */ CAMERA3_STREAM_CONFIGURATION_CONSTRAINED_HIGH_SPEED_MODE = 1, /** * First value for vendor-defined stream configuration modes. */ CAMERA3_VENDOR_STREAM_CONFIGURATION_MODE_START = 0x8000 } camera3_stream_configuration_mode_t; /** * camera3_stream_t: * * A handle to a single camera input or output stream. A stream is defined by * the framework by its buffer resolution and format, and additionally by the * HAL with the gralloc usage flags and the maximum in-flight buffer count. * * The stream structures are owned by the framework, but pointers to a * camera3_stream passed into the HAL by configure_streams() are valid until the * end of the first subsequent configure_streams() call that _does not_ include * that camera3_stream as an argument, or until the end of the close() call. * * All camera3_stream framework-controlled members are immutable once the * camera3_stream is passed into configure_streams(). The HAL may only change * the HAL-controlled parameters during a configure_streams() call, except for * the contents of the private pointer. * * If a configure_streams() call returns a non-fatal error, all active streams * remain valid as if configure_streams() had not been called. * * The endpoint of the stream is not visible to the camera HAL device. * In DEVICE_API_VERSION_3_1, this was changed to share consumer usage flags * on streams where the camera is a producer (OUTPUT and BIDIRECTIONAL stream * types) see the usage field below. */ typedef struct camera3_stream { /***** * Set by framework before configure_streams() */ /** * The type of the stream, one of the camera3_stream_type_t values. */ int stream_type; /** * The width in pixels of the buffers in this stream */ uint32_t width; /** * The height in pixels of the buffers in this stream */ uint32_t height; /** * The pixel format for the buffers in this stream. Format is a value from * the HAL_PIXEL_FORMAT_* list in system/core/include/system/graphics.h, or * from device-specific headers. * * If HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, then the platform * gralloc module will select a format based on the usage flags provided by * the camera device and the other endpoint of the stream. * * <= CAMERA_DEVICE_API_VERSION_3_1: * * The camera HAL device must inspect the buffers handed to it in the * subsequent register_stream_buffers() call to obtain the * implementation-specific format details, if necessary. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * register_stream_buffers() won't be called by the framework, so the HAL * should configure the ISP and sensor pipeline based purely on the sizes, * usage flags, and formats for the configured streams. */ int format; /***** * Set by HAL during configure_streams(). */ /** * The gralloc usage flags for this stream, as needed by the HAL. The usage * flags are defined in gralloc.h (GRALLOC_USAGE_*), or in device-specific * headers. * * For output streams, these are the HAL's producer usage flags. For input * streams, these are the HAL's consumer usage flags. The usage flags from * the producer and the consumer will be combined together and then passed * to the platform gralloc HAL module for allocating the gralloc buffers for * each stream. * * Version information: * * == CAMERA_DEVICE_API_VERSION_3_0: * * No initial value guaranteed when passed via configure_streams(). * HAL may not use this field as input, and must write over this field * with its usage flags. * * >= CAMERA_DEVICE_API_VERSION_3_1: * * For stream_type OUTPUT and BIDIRECTIONAL, when passed via * configure_streams(), the initial value of this is the consumer's * usage flags. The HAL may use these consumer flags to decide stream * configuration. * For stream_type INPUT, when passed via configure_streams(), the initial * value of this is 0. * For all streams passed via configure_streams(), the HAL must write * over this field with its usage flags. */ uint32_t usage; /** * The maximum number of buffers the HAL device may need to have dequeued at * the same time. The HAL device may not have more buffers in-flight from * this stream than this value. */ uint32_t max_buffers; /** * A handle to HAL-private information for the stream. Will not be inspected * by the framework code. */ void *priv; /** * A field that describes the contents of the buffer. The format and buffer * dimensions define the memory layout and structure of the stream buffers, * while dataSpace defines the meaning of the data within the buffer. * * For most formats, dataSpace defines the color space of the image data. * In addition, for some formats, dataSpace indicates whether image- or * depth-based data is requested. See system/core/include/system/graphics.h * for details of formats and valid dataSpace values for each format. * * Version information: * * < CAMERA_DEVICE_API_VERSION_3_3: * * Not defined and should not be accessed. dataSpace should be assumed to * be HAL_DATASPACE_UNKNOWN, and the appropriate color space, etc, should * be determined from the usage flags and the format. * * >= CAMERA_DEVICE_API_VERSION_3_3: * * Always set by the camera service. HAL must use this dataSpace to * configure the stream to the correct colorspace, or to select between * color and depth outputs if supported. */ android_dataspace_t data_space; /** * The required output rotation of the stream, one of * the camera3_stream_rotation_t values. This must be inspected by HAL along * with stream width and height. For example, if the rotation is 90 degree * and the stream width and height is 720 and 1280 respectively, camera service * will supply buffers of size 720x1280, and HAL should capture a 1280x720 image * and rotate the image by 90 degree counterclockwise. The rotation field is * no-op when the stream type is input. Camera HAL must ignore the rotation * field for an input stream. * * <= CAMERA_DEVICE_API_VERSION_3_2: * * Not defined and must not be accessed. HAL must not apply any rotation * on output images. * * >= CAMERA_DEVICE_API_VERSION_3_3: * * Always set by camera service. HAL must inspect this field during stream * configuration and returns -EINVAL if HAL cannot perform such rotation. * HAL must always support CAMERA3_STREAM_ROTATION_0, so a * configure_streams() call must not fail for unsupported rotation if * rotation field of all streams is CAMERA3_STREAM_ROTATION_0. * */ int rotation; /* reserved for future use */ void *reserved[7]; } camera3_stream_t; /** * camera3_stream_configuration_t: * * A structure of stream definitions, used by configure_streams(). This * structure defines all the output streams and the reprocessing input * stream for the current camera use case. */ typedef struct camera3_stream_configuration { /** * The total number of streams requested by the framework. This includes * both input and output streams. The number of streams will be at least 1, * and there will be at least one output-capable stream. */ uint32_t num_streams; /** * An array of camera stream pointers, defining the input/output * configuration for the camera HAL device. * * At most one input-capable stream may be defined (INPUT or BIDIRECTIONAL) * in a single configuration. * * At least one output-capable stream must be defined (OUTPUT or * BIDIRECTIONAL). */ camera3_stream_t **streams; /** * >= CAMERA_DEVICE_API_VERSION_3_3: * * The operation mode of streams in this configuration, one of the value defined in * camera3_stream_configuration_mode_t. * The HAL can use this mode as an indicator to set the stream property (e.g., * camera3_stream->max_buffers) appropriately. For example, if the configuration is * CAMERA3_STREAM_CONFIGURATION_CONSTRAINED_HIGH_SPEED_MODE, the HAL may want to set aside more * buffers for batch mode operation (see android.control.availableHighSpeedVideoConfigurations * for batch mode definition). * */ uint32_t operation_mode; } camera3_stream_configuration_t; /** * camera3_buffer_status_t: * * The current status of a single stream buffer. */ typedef enum camera3_buffer_status { /** * The buffer is in a normal state, and can be used after waiting on its * sync fence. */ CAMERA3_BUFFER_STATUS_OK = 0, /** * The buffer does not contain valid data, and the data in it should not be * used. The sync fence must still be waited on before reusing the buffer. */ CAMERA3_BUFFER_STATUS_ERROR = 1 } camera3_buffer_status_t; /** * camera3_stream_buffer_t: * * A single buffer from a camera3 stream. It includes a handle to its parent * stream, the handle to the gralloc buffer itself, and sync fences * * The buffer does not specify whether it is to be used for input or output; * that is determined by its parent stream type and how the buffer is passed to * the HAL device. */ typedef struct camera3_stream_buffer { /** * The handle of the stream this buffer is associated with */ camera3_stream_t *stream; /** * The native handle to the buffer */ buffer_handle_t *buffer; /** * Current state of the buffer, one of the camera3_buffer_status_t * values. The framework will not pass buffers to the HAL that are in an * error state. In case a buffer could not be filled by the HAL, it must * have its status set to CAMERA3_BUFFER_STATUS_ERROR when returned to the * framework with process_capture_result(). */ int status; /** * The acquire sync fence for this buffer. The HAL must wait on this fence * fd before attempting to read from or write to this buffer. * * The framework may be set to -1 to indicate that no waiting is necessary * for this buffer. * * When the HAL returns an output buffer to the framework with * process_capture_result(), the acquire_fence must be set to -1. If the HAL * never waits on the acquire_fence due to an error in filling a buffer, * when calling process_capture_result() the HAL must set the release_fence * of the buffer to be the acquire_fence passed to it by the framework. This * will allow the framework to wait on the fence before reusing the buffer. * * For input buffers, the HAL must not change the acquire_fence field during * the process_capture_request() call. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * When the HAL returns an input buffer to the framework with * process_capture_result(), the acquire_fence must be set to -1. If the HAL * never waits on input buffer acquire fence due to an error, the sync * fences should be handled similarly to the way they are handled for output * buffers. */ int acquire_fence; /** * The release sync fence for this buffer. The HAL must set this fence when * returning buffers to the framework, or write -1 to indicate that no * waiting is required for this buffer. * * For the output buffers, the fences must be set in the output_buffers * array passed to process_capture_result(). * * <= CAMERA_DEVICE_API_VERSION_3_1: * * For the input buffer, the release fence must be set by the * process_capture_request() call. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * For the input buffer, the fences must be set in the input_buffer * passed to process_capture_result(). * * After signaling the release_fence for this buffer, the HAL * should not make any further attempts to access this buffer as the * ownership has been fully transferred back to the framework. * * If a fence of -1 was specified then the ownership of this buffer * is transferred back immediately upon the call of process_capture_result. */ int release_fence; } camera3_stream_buffer_t; /** * camera3_stream_buffer_set_t: * * The complete set of gralloc buffers for a stream. This structure is given to * register_stream_buffers() to allow the camera HAL device to register/map/etc * newly allocated stream buffers. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * Deprecated (and not used). In particular, * register_stream_buffers is also deprecated and will never be invoked. * */ typedef struct camera3_stream_buffer_set { /** * The stream handle for the stream these buffers belong to */ camera3_stream_t *stream; /** * The number of buffers in this stream. It is guaranteed to be at least * stream->max_buffers. */ uint32_t num_buffers; /** * The array of gralloc buffer handles for this stream. If the stream format * is set to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, the camera HAL device * should inspect the passed-in buffers to determine any platform-private * pixel format information. */ buffer_handle_t **buffers; } camera3_stream_buffer_set_t; /** * camera3_jpeg_blob: * * Transport header for compressed JPEG buffers in output streams. * * To capture JPEG images, a stream is created using the pixel format * HAL_PIXEL_FORMAT_BLOB. The buffer size for the stream is calculated by the * framework, based on the static metadata field android.jpeg.maxSize. Since * compressed JPEG images are of variable size, the HAL needs to include the * final size of the compressed image using this structure inside the output * stream buffer. The JPEG blob ID field must be set to CAMERA3_JPEG_BLOB_ID. * * Transport header should be at the end of the JPEG output stream buffer. That * means the jpeg_blob_id must start at byte[buffer_size - * sizeof(camera3_jpeg_blob)], where the buffer_size is the size of gralloc buffer. * Any HAL using this transport header must account for it in android.jpeg.maxSize * The JPEG data itself starts at the beginning of the buffer and should be * jpeg_size bytes long. */ typedef struct camera3_jpeg_blob { uint16_t jpeg_blob_id; uint32_t jpeg_size; } camera3_jpeg_blob_t; enum { CAMERA3_JPEG_BLOB_ID = 0x00FF }; /********************************************************************** * * Message definitions for the HAL notify() callback. * * These definitions are used for the HAL notify callback, to signal * asynchronous events from the HAL device to the Android framework. * */ /** * camera3_msg_type: * * Indicates the type of message sent, which specifies which member of the * message union is valid. * */ typedef enum camera3_msg_type { /** * An error has occurred. camera3_notify_msg.message.error contains the * error information. */ CAMERA3_MSG_ERROR = 1, /** * The exposure of a given request or processing a reprocess request has * begun. camera3_notify_msg.message.shutter contains the information * the capture. */ CAMERA3_MSG_SHUTTER = 2, /** * Number of framework message types */ CAMERA3_NUM_MESSAGES } camera3_msg_type_t; /** * Defined error codes for CAMERA_MSG_ERROR */ typedef enum camera3_error_msg_code { /** * A serious failure occured. No further frames or buffer streams will * be produced by the device. Device should be treated as closed. The * client must reopen the device to use it again. The frame_number field * is unused. */ CAMERA3_MSG_ERROR_DEVICE = 1, /** * An error has occurred in processing a request. No output (metadata or * buffers) will be produced for this request. The frame_number field * specifies which request has been dropped. Subsequent requests are * unaffected, and the device remains operational. */ CAMERA3_MSG_ERROR_REQUEST = 2, /** * An error has occurred in producing an output result metadata buffer * for a request, but output stream buffers for it will still be * available. Subsequent requests are unaffected, and the device remains * operational. The frame_number field specifies the request for which * result metadata won't be available. */ CAMERA3_MSG_ERROR_RESULT = 3, /** * An error has occurred in placing an output buffer into a stream for a * request. The frame metadata and other buffers may still be * available. Subsequent requests are unaffected, and the device remains * operational. The frame_number field specifies the request for which the * buffer was dropped, and error_stream contains a pointer to the stream * that dropped the frame.u */ CAMERA3_MSG_ERROR_BUFFER = 4, /** * Number of error types */ CAMERA3_MSG_NUM_ERRORS } camera3_error_msg_code_t; /** * camera3_error_msg_t: * * Message contents for CAMERA3_MSG_ERROR */ typedef struct camera3_error_msg { /** * Frame number of the request the error applies to. 0 if the frame number * isn't applicable to the error. */ uint32_t frame_number; /** * Pointer to the stream that had a failure. NULL if the stream isn't * applicable to the error. */ camera3_stream_t *error_stream; /** * The code for this error; one of the CAMERA_MSG_ERROR enum values. */ int error_code; } camera3_error_msg_t; /** * camera3_shutter_msg_t: * * Message contents for CAMERA3_MSG_SHUTTER */ typedef struct camera3_shutter_msg { /** * Frame number of the request that has begun exposure or reprocessing. */ uint32_t frame_number; /** * Timestamp for the start of capture. For a reprocess request, this must * be input image's start of capture. This must match the capture result * metadata's sensor exposure start timestamp. */ uint64_t timestamp; } camera3_shutter_msg_t; /** * camera3_notify_msg_t: * * The message structure sent to camera3_callback_ops_t.notify() */ typedef struct camera3_notify_msg { /** * The message type. One of camera3_notify_msg_type, or a private extension. */ int type; union { /** * Error message contents. Valid if type is CAMERA3_MSG_ERROR */ camera3_error_msg_t error; /** * Shutter message contents. Valid if type is CAMERA3_MSG_SHUTTER */ camera3_shutter_msg_t shutter; /** * Generic message contents. Used to ensure a minimum size for custom * message types. */ uint8_t generic[32]; } message; } camera3_notify_msg_t; /********************************************************************** * * Capture request/result definitions for the HAL process_capture_request() * method, and the process_capture_result() callback. * */ /** * camera3_request_template_t: * * Available template types for * camera3_device_ops.construct_default_request_settings() */ typedef enum camera3_request_template { /** * Standard camera preview operation with 3A on auto. */ CAMERA3_TEMPLATE_PREVIEW = 1, /** * Standard camera high-quality still capture with 3A and flash on auto. */ CAMERA3_TEMPLATE_STILL_CAPTURE = 2, /** * Standard video recording plus preview with 3A on auto, torch off. */ CAMERA3_TEMPLATE_VIDEO_RECORD = 3, /** * High-quality still capture while recording video. Application will * include preview, video record, and full-resolution YUV or JPEG streams in * request. Must not cause stuttering on video stream. 3A on auto. */ CAMERA3_TEMPLATE_VIDEO_SNAPSHOT = 4, /** * Zero-shutter-lag mode. Application will request preview and * full-resolution data for each frame, and reprocess it to JPEG when a * still image is requested by user. Settings should provide highest-quality * full-resolution images without compromising preview frame rate. 3A on * auto. */ CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG = 5, /** * A basic template for direct application control of capture * parameters. All automatic control is disabled (auto-exposure, auto-white * balance, auto-focus), and post-processing parameters are set to preview * quality. The manual capture parameters (exposure, sensitivity, etc.) * are set to reasonable defaults, but should be overridden by the * application depending on the intended use case. */ CAMERA3_TEMPLATE_MANUAL = 6, /* Total number of templates */ CAMERA3_TEMPLATE_COUNT, /** * First value for vendor-defined request templates */ CAMERA3_VENDOR_TEMPLATE_START = 0x40000000 } camera3_request_template_t; /** * camera3_capture_request_t: * * A single request for image capture/buffer reprocessing, sent to the Camera * HAL device by the framework in process_capture_request(). * * The request contains the settings to be used for this capture, and the set of * output buffers to write the resulting image data in. It may optionally * contain an input buffer, in which case the request is for reprocessing that * input buffer instead of capturing a new image with the camera sensor. The * capture is identified by the frame_number. * * In response, the camera HAL device must send a camera3_capture_result * structure asynchronously to the framework, using the process_capture_result() * callback. */ typedef struct camera3_capture_request { /** * The frame number is an incrementing integer set by the framework to * uniquely identify this capture. It needs to be returned in the result * call, and is also used to identify the request in asynchronous * notifications sent to camera3_callback_ops_t.notify(). */ uint32_t frame_number; /** * The settings buffer contains the capture and processing parameters for * the request. As a special case, a NULL settings buffer indicates that the * settings are identical to the most-recently submitted capture request. A * NULL buffer cannot be used as the first submitted request after a * configure_streams() call. */ const camera_metadata_t *settings; /** * The input stream buffer to use for this request, if any. * * If input_buffer is NULL, then the request is for a new capture from the * imager. If input_buffer is valid, the request is for reprocessing the * image contained in input_buffer. * * In the latter case, the HAL must set the release_fence of the * input_buffer to a valid sync fence, or to -1 if the HAL does not support * sync, before process_capture_request() returns. * * The HAL is required to wait on the acquire sync fence of the input buffer * before accessing it. * * <= CAMERA_DEVICE_API_VERSION_3_1: * * Any input buffer included here will have been registered with the HAL * through register_stream_buffers() before its inclusion in a request. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * The buffers will not have been pre-registered with the HAL. * Subsequent requests may reuse buffers, or provide entirely new buffers. */ camera3_stream_buffer_t *input_buffer; /** * The number of output buffers for this capture request. Must be at least * 1. */ uint32_t num_output_buffers; /** * An array of num_output_buffers stream buffers, to be filled with image * data from this capture/reprocess. The HAL must wait on the acquire fences * of each stream buffer before writing to them. * * The HAL takes ownership of the actual buffer_handle_t entries in * output_buffers; the framework does not access them until they are * returned in a camera3_capture_result_t. * * <= CAMERA_DEVICE_API_VERSION_3_1: * * All the buffers included here will have been registered with the HAL * through register_stream_buffers() before their inclusion in a request. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * Any or all of the buffers included here may be brand new in this * request (having never before seen by the HAL). */ const camera3_stream_buffer_t *output_buffers; } camera3_capture_request_t; /** * camera3_capture_result_t: * * The result of a single capture/reprocess by the camera HAL device. This is * sent to the framework asynchronously with process_capture_result(), in * response to a single capture request sent to the HAL with * process_capture_request(). Multiple process_capture_result() calls may be * performed by the HAL for each request. * * Each call, all with the same frame * number, may contain some subset of the output buffers, and/or the result * metadata. The metadata may only be provided once for a given frame number; * all other calls must set the result metadata to NULL. * * The result structure contains the output metadata from this capture, and the * set of output buffers that have been/will be filled for this capture. Each * output buffer may come with a release sync fence that the framework will wait * on before reading, in case the buffer has not yet been filled by the HAL. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * The metadata may be provided multiple times for a single frame number. The * framework will accumulate together the final result set by combining each * partial result together into the total result set. * * If an input buffer is given in a request, the HAL must return it in one of * the process_capture_result calls, and the call may be to just return the input * buffer, without metadata and output buffers; the sync fences must be handled * the same way they are done for output buffers. * * * Performance considerations: * * Applications will also receive these partial results immediately, so sending * partial results is a highly recommended performance optimization to avoid * the total pipeline latency before sending the results for what is known very * early on in the pipeline. * * A typical use case might be calculating the AF state halfway through the * pipeline; by sending the state back to the framework immediately, we get a * 50% performance increase and perceived responsiveness of the auto-focus. * */ typedef struct camera3_capture_result { /** * The frame number is an incrementing integer set by the framework in the * submitted request to uniquely identify this capture. It is also used to * identify the request in asynchronous notifications sent to * camera3_callback_ops_t.notify(). */ uint32_t frame_number; /** * The result metadata for this capture. This contains information about the * final capture parameters, the state of the capture and post-processing * hardware, the state of the 3A algorithms, if enabled, and the output of * any enabled statistics units. * * Only one call to process_capture_result() with a given frame_number may * include the result metadata. All other calls for the same frame_number * must set this to NULL. * * If there was an error producing the result metadata, result must be an * empty metadata buffer, and notify() must be called with ERROR_RESULT. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * Multiple calls to process_capture_result() with a given frame_number * may include the result metadata. * * Partial metadata submitted should not include any metadata key returned * in a previous partial result for a given frame. Each new partial result * for that frame must also set a distinct partial_result value. * * If notify has been called with ERROR_RESULT, all further partial * results for that frame are ignored by the framework. */ const camera_metadata_t *result; /** * The number of output buffers returned in this result structure. Must be * less than or equal to the matching capture request's count. If this is * less than the buffer count in the capture request, at least one more call * to process_capture_result with the same frame_number must be made, to * return the remaining output buffers to the framework. This may only be * zero if the structure includes valid result metadata or an input buffer * is returned in this result. */ uint32_t num_output_buffers; /** * The handles for the output stream buffers for this capture. They may not * yet be filled at the time the HAL calls process_capture_result(); the * framework will wait on the release sync fences provided by the HAL before * reading the buffers. * * The HAL must set the stream buffer's release sync fence to a valid sync * fd, or to -1 if the buffer has already been filled. * * If the HAL encounters an error while processing the buffer, and the * buffer is not filled, the buffer's status field must be set to * CAMERA3_BUFFER_STATUS_ERROR. If the HAL did not wait on the acquire fence * before encountering the error, the acquire fence should be copied into * the release fence, to allow the framework to wait on the fence before * reusing the buffer. * * The acquire fence must be set to -1 for all output buffers. If * num_output_buffers is zero, this may be NULL. In that case, at least one * more process_capture_result call must be made by the HAL to provide the * output buffers. * * When process_capture_result is called with a new buffer for a frame, * all previous frames' buffers for that corresponding stream must have been * already delivered (the fences need not have yet been signaled). * * >= CAMERA_DEVICE_API_VERSION_3_2: * * Gralloc buffers for a frame may be sent to framework before the * corresponding SHUTTER-notify. * * Performance considerations: * * Buffers delivered to the framework will not be dispatched to the * application layer until a start of exposure timestamp has been received * via a SHUTTER notify() call. It is highly recommended to * dispatch that call as early as possible. */ const camera3_stream_buffer_t *output_buffers; /** * >= CAMERA_DEVICE_API_VERSION_3_2: * * The handle for the input stream buffer for this capture. It may not * yet be consumed at the time the HAL calls process_capture_result(); the * framework will wait on the release sync fences provided by the HAL before * reusing the buffer. * * The HAL should handle the sync fences the same way they are done for * output_buffers. * * Only one input buffer is allowed to be sent per request. Similarly to * output buffers, the ordering of returned input buffers must be * maintained by the HAL. * * Performance considerations: * * The input buffer should be returned as early as possible. If the HAL * supports sync fences, it can call process_capture_result to hand it back * with sync fences being set appropriately. If the sync fences are not * supported, the buffer can only be returned when it is consumed, which * may take long time; the HAL may choose to copy this input buffer to make * the buffer return sooner. */ const camera3_stream_buffer_t *input_buffer; /** * >= CAMERA_DEVICE_API_VERSION_3_2: * * In order to take advantage of partial results, the HAL must set the * static metadata android.request.partialResultCount to the number of * partial results it will send for each frame. * * Each new capture result with a partial result must set * this field (partial_result) to a distinct inclusive value between * 1 and android.request.partialResultCount. * * HALs not wishing to take advantage of this feature must not * set an android.request.partialResultCount or partial_result to a value * other than 1. * * This value must be set to 0 when a capture result contains buffers only * and no metadata. */ uint32_t partial_result; } camera3_capture_result_t; /********************************************************************** * * Callback methods for the HAL to call into the framework. * * These methods are used to return metadata and image buffers for a completed * or failed captures, and to notify the framework of asynchronous events such * as errors. * * The framework will not call back into the HAL from within these callbacks, * and these calls will not block for extended periods. * */ typedef struct camera3_callback_ops { /** * process_capture_result: * * Send results from a completed capture to the framework. * process_capture_result() may be invoked multiple times by the HAL in * response to a single capture request. This allows, for example, the * metadata and low-resolution buffers to be returned in one call, and * post-processed JPEG buffers in a later call, once it is available. Each * call must include the frame number of the request it is returning * metadata or buffers for. * * A component (buffer or metadata) of the complete result may only be * included in one process_capture_result call. A buffer for each stream, * and the result metadata, must be returned by the HAL for each request in * one of the process_capture_result calls, even in case of errors producing * some of the output. A call to process_capture_result() with neither * output buffers or result metadata is not allowed. * * The order of returning metadata and buffers for a single result does not * matter, but buffers for a given stream must be returned in FIFO order. So * the buffer for request 5 for stream A must always be returned before the * buffer for request 6 for stream A. This also applies to the result * metadata; the metadata for request 5 must be returned before the metadata * for request 6. * * However, different streams are independent of each other, so it is * acceptable and expected that the buffer for request 5 for stream A may be * returned after the buffer for request 6 for stream B is. And it is * acceptable that the result metadata for request 6 for stream B is * returned before the buffer for request 5 for stream A is. * * The HAL retains ownership of result structure, which only needs to be * valid to access during this call. The framework will copy whatever it * needs before this call returns. * * The output buffers do not need to be filled yet; the framework will wait * on the stream buffer release sync fence before reading the buffer * data. Therefore, this method should be called by the HAL as soon as * possible, even if some or all of the output buffers are still in * being filled. The HAL must include valid release sync fences into each * output_buffers stream buffer entry, or -1 if that stream buffer is * already filled. * * If the result buffer cannot be constructed for a request, the HAL should * return an empty metadata buffer, but still provide the output buffers and * their sync fences. In addition, notify() must be called with an * ERROR_RESULT message. * * If an output buffer cannot be filled, its status field must be set to * STATUS_ERROR. In addition, notify() must be called with a ERROR_BUFFER * message. * * If the entire capture has failed, then this method still needs to be * called to return the output buffers to the framework. All the buffer * statuses should be STATUS_ERROR, and the result metadata should be an * empty buffer. In addition, notify() must be called with a ERROR_REQUEST * message. In this case, individual ERROR_RESULT/ERROR_BUFFER messages * should not be sent. * * Performance requirements: * * This is a non-blocking call. The framework will return this call in 5ms. * * The pipeline latency (see S7 for definition) should be less than or equal to * 4 frame intervals, and must be less than or equal to 8 frame intervals. * */ void (*process_capture_result)(const struct camera3_callback_ops *, const camera3_capture_result_t *result); /** * notify: * * Asynchronous notification callback from the HAL, fired for various * reasons. Only for information independent of frame capture, or that * require specific timing. The ownership of the message structure remains * with the HAL, and the msg only needs to be valid for the duration of this * call. * * Multiple threads may call notify() simultaneously. * * <= CAMERA_DEVICE_API_VERSION_3_1: * * The notification for the start of exposure for a given request must be * sent by the HAL before the first call to process_capture_result() for * that request is made. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * Buffers delivered to the framework will not be dispatched to the * application layer until a start of exposure timestamp (or input image's * start of exposure timestamp for a reprocess request) has been received * via a SHUTTER notify() call. It is highly recommended to dispatch this * call as early as possible. * * ------------------------------------------------------------------------ * Performance requirements: * * This is a non-blocking call. The framework will return this call in 5ms. */ void (*notify)(const struct camera3_callback_ops *, const camera3_notify_msg_t *msg); } camera3_callback_ops_t; /********************************************************************** * * Camera device operations * */ typedef struct camera3_device_ops { /** * initialize: * * One-time initialization to pass framework callback function pointers to * the HAL. Will be called once after a successful open() call, before any * other functions are called on the camera3_device_ops structure. * * Performance requirements: * * This should be a non-blocking call. The HAL should return from this call * in 5ms, and must return from this call in 10ms. * * Return values: * * 0: On successful initialization * * -ENODEV: If initialization fails. Only close() can be called successfully * by the framework after this. */ int (*initialize)(const struct camera3_device *, const camera3_callback_ops_t *callback_ops); /********************************************************************** * Stream management */ /** * configure_streams: * * CAMERA_DEVICE_API_VERSION_3_0 only: * * Reset the HAL camera device processing pipeline and set up new input and * output streams. This call replaces any existing stream configuration with * the streams defined in the stream_list. This method will be called at * least once after initialize() before a request is submitted with * process_capture_request(). * * The stream_list must contain at least one output-capable stream, and may * not contain more than one input-capable stream. * * The stream_list may contain streams that are also in the currently-active * set of streams (from the previous call to configure_stream()). These * streams will already have valid values for usage, max_buffers, and the * private pointer. * * If such a stream has already had its buffers registered, * register_stream_buffers() will not be called again for the stream, and * buffers from the stream can be immediately included in input requests. * * If the HAL needs to change the stream configuration for an existing * stream due to the new configuration, it may rewrite the values of usage * and/or max_buffers during the configure call. * * The framework will detect such a change, and will then reallocate the * stream buffers, and call register_stream_buffers() again before using * buffers from that stream in a request. * * If a currently-active stream is not included in stream_list, the HAL may * safely remove any references to that stream. It will not be reused in a * later configure() call by the framework, and all the gralloc buffers for * it will be freed after the configure_streams() call returns. * * The stream_list structure is owned by the framework, and may not be * accessed once this call completes. The address of an individual * camera3_stream_t structure will remain valid for access by the HAL until * the end of the first configure_stream() call which no longer includes * that camera3_stream_t in the stream_list argument. The HAL may not change * values in the stream structure outside of the private pointer, except for * the usage and max_buffers members during the configure_streams() call * itself. * * If the stream is new, the usage, max_buffer, and private pointer fields * of the stream structure will all be set to 0. The HAL device must set * these fields before the configure_streams() call returns. These fields * are then used by the framework and the platform gralloc module to * allocate the gralloc buffers for each stream. * * Before such a new stream can have its buffers included in a capture * request, the framework will call register_stream_buffers() with that * stream. However, the framework is not required to register buffers for * _all_ streams before submitting a request. This allows for quick startup * of (for example) a preview stream, with allocation for other streams * happening later or concurrently. * * ------------------------------------------------------------------------ * CAMERA_DEVICE_API_VERSION_3_1 only: * * Reset the HAL camera device processing pipeline and set up new input and * output streams. This call replaces any existing stream configuration with * the streams defined in the stream_list. This method will be called at * least once after initialize() before a request is submitted with * process_capture_request(). * * The stream_list must contain at least one output-capable stream, and may * not contain more than one input-capable stream. * * The stream_list may contain streams that are also in the currently-active * set of streams (from the previous call to configure_stream()). These * streams will already have valid values for usage, max_buffers, and the * private pointer. * * If such a stream has already had its buffers registered, * register_stream_buffers() will not be called again for the stream, and * buffers from the stream can be immediately included in input requests. * * If the HAL needs to change the stream configuration for an existing * stream due to the new configuration, it may rewrite the values of usage * and/or max_buffers during the configure call. * * The framework will detect such a change, and will then reallocate the * stream buffers, and call register_stream_buffers() again before using * buffers from that stream in a request. * * If a currently-active stream is not included in stream_list, the HAL may * safely remove any references to that stream. It will not be reused in a * later configure() call by the framework, and all the gralloc buffers for * it will be freed after the configure_streams() call returns. * * The stream_list structure is owned by the framework, and may not be * accessed once this call completes. The address of an individual * camera3_stream_t structure will remain valid for access by the HAL until * the end of the first configure_stream() call which no longer includes * that camera3_stream_t in the stream_list argument. The HAL may not change * values in the stream structure outside of the private pointer, except for * the usage and max_buffers members during the configure_streams() call * itself. * * If the stream is new, max_buffer, and private pointer fields of the * stream structure will all be set to 0. The usage will be set to the * consumer usage flags. The HAL device must set these fields before the * configure_streams() call returns. These fields are then used by the * framework and the platform gralloc module to allocate the gralloc * buffers for each stream. * * Before such a new stream can have its buffers included in a capture * request, the framework will call register_stream_buffers() with that * stream. However, the framework is not required to register buffers for * _all_ streams before submitting a request. This allows for quick startup * of (for example) a preview stream, with allocation for other streams * happening later or concurrently. * * ------------------------------------------------------------------------ * >= CAMERA_DEVICE_API_VERSION_3_2: * * Reset the HAL camera device processing pipeline and set up new input and * output streams. This call replaces any existing stream configuration with * the streams defined in the stream_list. This method will be called at * least once after initialize() before a request is submitted with * process_capture_request(). * * The stream_list must contain at least one output-capable stream, and may * not contain more than one input-capable stream. * * The stream_list may contain streams that are also in the currently-active * set of streams (from the previous call to configure_stream()). These * streams will already have valid values for usage, max_buffers, and the * private pointer. * * If the HAL needs to change the stream configuration for an existing * stream due to the new configuration, it may rewrite the values of usage * and/or max_buffers during the configure call. * * The framework will detect such a change, and may then reallocate the * stream buffers before using buffers from that stream in a request. * * If a currently-active stream is not included in stream_list, the HAL may * safely remove any references to that stream. It will not be reused in a * later configure() call by the framework, and all the gralloc buffers for * it will be freed after the configure_streams() call returns. * * The stream_list structure is owned by the framework, and may not be * accessed once this call completes. The address of an individual * camera3_stream_t structure will remain valid for access by the HAL until * the end of the first configure_stream() call which no longer includes * that camera3_stream_t in the stream_list argument. The HAL may not change * values in the stream structure outside of the private pointer, except for * the usage and max_buffers members during the configure_streams() call * itself. * * If the stream is new, max_buffer, and private pointer fields of the * stream structure will all be set to 0. The usage will be set to the * consumer usage flags. The HAL device must set these fields before the * configure_streams() call returns. These fields are then used by the * framework and the platform gralloc module to allocate the gralloc * buffers for each stream. * * Newly allocated buffers may be included in a capture request at any time * by the framework. Once a gralloc buffer is returned to the framework * with process_capture_result (and its respective release_fence has been * signaled) the framework may free or reuse it at any time. * * ------------------------------------------------------------------------ * * Preconditions: * * The framework will only call this method when no captures are being * processed. That is, all results have been returned to the framework, and * all in-flight input and output buffers have been returned and their * release sync fences have been signaled by the HAL. The framework will not * submit new requests for capture while the configure_streams() call is * underway. * * Postconditions: * * The HAL device must configure itself to provide maximum possible output * frame rate given the sizes and formats of the output streams, as * documented in the camera device's static metadata. * * Performance requirements: * * This call is expected to be heavyweight and possibly take several hundred * milliseconds to complete, since it may require resetting and * reconfiguring the image sensor and the camera processing pipeline. * Nevertheless, the HAL device should attempt to minimize the * reconfiguration delay to minimize the user-visible pauses during * application operational mode changes (such as switching from still * capture to video recording). * * The HAL should return from this call in 500ms, and must return from this * call in 1000ms. * * Return values: * * 0: On successful stream configuration * * -EINVAL: If the requested stream configuration is invalid. Some examples * of invalid stream configurations include: * * - Including more than 1 input-capable stream (INPUT or * BIDIRECTIONAL) * * - Not including any output-capable streams (OUTPUT or * BIDIRECTIONAL) * * - Including streams with unsupported formats, or an unsupported * size for that format. * * - Including too many output streams of a certain format. * * - Unsupported rotation configuration (only applies to * devices with version >= CAMERA_DEVICE_API_VERSION_3_3) * * - Stream sizes/formats don't satisfy the * camera3_stream_configuration_t->operation_mode requirements for non-NORMAL mode, * or the requested operation_mode is not supported by the HAL. * (only applies to devices with version >= CAMERA_DEVICE_API_VERSION_3_3) * * Note that the framework submitting an invalid stream * configuration is not normal operation, since stream * configurations are checked before configure. An invalid * configuration means that a bug exists in the framework code, or * there is a mismatch between the HAL's static metadata and the * requirements on streams. * * -ENODEV: If there has been a fatal error and the device is no longer * operational. Only close() can be called successfully by the * framework after this error is returned. */ int (*configure_streams)(const struct camera3_device *, camera3_stream_configuration_t *stream_list); /** * register_stream_buffers: * * >= CAMERA_DEVICE_API_VERSION_3_2: * * DEPRECATED. This will not be called and must be set to NULL. * * <= CAMERA_DEVICE_API_VERSION_3_1: * * Register buffers for a given stream with the HAL device. This method is * called by the framework after a new stream is defined by * configure_streams, and before buffers from that stream are included in a * capture request. If the same stream is listed in a subsequent * configure_streams() call, register_stream_buffers will _not_ be called * again for that stream. * * The framework does not need to register buffers for all configured * streams before it submits the first capture request. This allows quick * startup for preview (or similar use cases) while other streams are still * being allocated. * * This method is intended to allow the HAL device to map or otherwise * prepare the buffers for later use. The buffers passed in will already be * locked for use. At the end of the call, all the buffers must be ready to * be returned to the stream. The buffer_set argument is only valid for the * duration of this call. * * If the stream format was set to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, * the camera HAL should inspect the passed-in buffers here to determine any * platform-private pixel format information. * * Performance requirements: * * This should be a non-blocking call. The HAL should return from this call * in 1ms, and must return from this call in 5ms. * * Return values: * * 0: On successful registration of the new stream buffers * * -EINVAL: If the stream_buffer_set does not refer to a valid active * stream, or if the buffers array is invalid. * * -ENOMEM: If there was a failure in registering the buffers. The framework * must consider all the stream buffers to be unregistered, and can * try to register again later. * * -ENODEV: If there is a fatal error, and the device is no longer * operational. Only close() can be called successfully by the * framework after this error is returned. */ int (*register_stream_buffers)(const struct camera3_device *, const camera3_stream_buffer_set_t *buffer_set); /********************************************************************** * Request creation and submission */ /** * construct_default_request_settings: * * Create capture settings for standard camera use cases. * * The device must return a settings buffer that is configured to meet the * requested use case, which must be one of the CAMERA3_TEMPLATE_* * enums. All request control fields must be included. * * The HAL retains ownership of this structure, but the pointer to the * structure must be valid until the device is closed. The framework and the * HAL may not modify the buffer once it is returned by this call. The same * buffer may be returned for subsequent calls for the same template, or for * other templates. * * Performance requirements: * * This should be a non-blocking call. The HAL should return from this call * in 1ms, and must return from this call in 5ms. * * Return values: * * Valid metadata: On successful creation of a default settings * buffer. * * NULL: In case of a fatal error. After this is returned, only * the close() method can be called successfully by the * framework. */ const camera_metadata_t* (*construct_default_request_settings)( const struct camera3_device *, int type); /** * process_capture_request: * * Send a new capture request to the HAL. The HAL should not return from * this call until it is ready to accept the next request to process. Only * one call to process_capture_request() will be made at a time by the * framework, and the calls will all be from the same thread. The next call * to process_capture_request() will be made as soon as a new request and * its associated buffers are available. In a normal preview scenario, this * means the function will be called again by the framework almost * instantly. * * The actual request processing is asynchronous, with the results of * capture being returned by the HAL through the process_capture_result() * call. This call requires the result metadata to be available, but output * buffers may simply provide sync fences to wait on. Multiple requests are * expected to be in flight at once, to maintain full output frame rate. * * The framework retains ownership of the request structure. It is only * guaranteed to be valid during this call. The HAL device must make copies * of the information it needs to retain for the capture processing. The HAL * is responsible for waiting on and closing the buffers' fences and * returning the buffer handles to the framework. * * The HAL must write the file descriptor for the input buffer's release * sync fence into input_buffer->release_fence, if input_buffer is not * NULL. If the HAL returns -1 for the input buffer release sync fence, the * framework is free to immediately reuse the input buffer. Otherwise, the * framework will wait on the sync fence before refilling and reusing the * input buffer. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * The input/output buffers provided by the framework in each request * may be brand new (having never before seen by the HAL). * * ------------------------------------------------------------------------ * Performance considerations: * * Handling a new buffer should be extremely lightweight and there should be * no frame rate degradation or frame jitter introduced. * * This call must return fast enough to ensure that the requested frame * rate can be sustained, especially for streaming cases (post-processing * quality settings set to FAST). The HAL should return this call in 1 * frame interval, and must return from this call in 4 frame intervals. * * Return values: * * 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 * 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 * stream buffers' fences and the buffer handles; the HAL should * not close the fences or return these buffers with * process_capture_result. * * -ENODEV: If the camera device has encountered a serious error. After this * error is returned, only the close() method can be successfully * called by the framework. * */ int (*process_capture_request)(const struct camera3_device *, camera3_capture_request_t *request); /********************************************************************** * Miscellaneous methods */ /** * get_metadata_vendor_tag_ops: * * Get methods to query for vendor extension metadata tag information. The * HAL should fill in all the vendor tag operation methods, or leave ops * unchanged if no vendor tags are defined. * * The definition of vendor_tag_query_ops_t can be found in * system/media/camera/include/system/camera_metadata.h. * * >= CAMERA_DEVICE_API_VERSION_3_2: * DEPRECATED. This function has been deprecated and should be set to * NULL by the HAL. Please implement get_vendor_tag_ops in camera_common.h * instead. */ void (*get_metadata_vendor_tag_ops)(const struct camera3_device*, vendor_tag_query_ops_t* ops); /** * dump: * * Print out debugging state for the camera device. This will be called by * the framework when the camera service is asked for a debug dump, which * happens when using the dumpsys tool, or when capturing a bugreport. * * 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 during camera operation. * Any synchronization primitives used (such as mutex locks or semaphores) * should be acquired with a timeout. */ void (*dump)(const struct camera3_device *, int fd); /** * flush: * * Flush all currently in-process captures and all buffers in the pipeline * on the given device. The framework will use this to dump all state as * quickly as possible in order to prepare for a configure_streams() call. * * No buffers are required to be successfully returned, so every buffer * held at the time of flush() (whether successfully filled or not) may be * returned with CAMERA3_BUFFER_STATUS_ERROR. Note the HAL is still allowed * to return valid (CAMERA3_BUFFER_STATUS_OK) buffers during this call, * provided they are successfully filled. * * All requests currently in the HAL are expected to be returned as soon as * possible. Not-in-process requests should return errors immediately. Any * interruptible hardware blocks should be stopped, and any uninterruptible * blocks should be waited on. * * flush() may be called concurrently to process_capture_request(), with the expectation that * process_capture_request will return quickly and the request submitted in that * process_capture_request call is treated like all other in-flight requests. Due to * concurrency issues, it is possible that from the HAL's point of view, a * process_capture_request() call may be started after flush has been invoked but has not * returned yet. If such a call happens before flush() returns, the HAL should treat the new * capture request like other in-flight pending requests (see #4 below). * * More specifically, the HAL must follow below requirements for various cases: * * 1. For captures that are too late for the HAL to cancel/stop, and will be * completed normally by the HAL; i.e. the HAL can send shutter/notify and * process_capture_result and buffers as normal. * * 2. For pending requests that have not done any processing, the HAL must call notify * CAMERA3_MSG_ERROR_REQUEST, and return all the output buffers with * process_capture_result in the error state (CAMERA3_BUFFER_STATUS_ERROR). * The HAL must not place the release fence into an error state, instead, * the release fences must be set to the acquire fences passed by the framework, * or -1 if they have been waited on by the HAL already. This is also the path * to follow for any captures for which the HAL already called notify() with * CAMERA3_MSG_SHUTTER but won't be producing any metadata/valid buffers for. * After CAMERA3_MSG_ERROR_REQUEST, for a given frame, only process_capture_results with * buffers in CAMERA3_BUFFER_STATUS_ERROR are allowed. No further notifys or * process_capture_result with non-null metadata is allowed. * * 3. For partially completed pending requests that will not have all the output * buffers or perhaps missing metadata, the HAL should follow below: * * 3.1. Call notify with CAMERA3_MSG_ERROR_RESULT if some of the expected result * metadata (i.e. one or more partial metadata) won't be available for the capture. * * 3.2. Call notify with CAMERA3_MSG_ERROR_BUFFER for every buffer that won't * be produced for the capture. * * 3.3 Call notify with CAMERA3_MSG_SHUTTER with the capture timestamp before * any buffers/metadata are returned with process_capture_result. * * 3.4 For captures that will produce some results, the HAL must not call * CAMERA3_MSG_ERROR_REQUEST, since that indicates complete failure. * * 3.5. Valid buffers/metadata should be passed to the framework as normal. * * 3.6. Failed buffers should be returned to the framework as described for case 2. * But failed buffers do not have to follow the strict ordering valid buffers do, * and may be out-of-order with respect to valid buffers. For example, if buffers * A, B, C, D, E are sent, D and E are failed, then A, E, B, D, C is an acceptable * return order. * * 3.7. For fully-missing metadata, calling CAMERA3_MSG_ERROR_RESULT is sufficient, no * need to call process_capture_result with NULL metadata or equivalent. * * 4. If a flush() is invoked while a process_capture_request() invocation is active, that * process call should return as soon as possible. In addition, if a process_capture_request() * call is made after flush() has been invoked but before flush() has returned, the * capture request provided by the late process_capture_request call should be treated like * a pending request in case #2 above. * * flush() should only return when there are no more outstanding buffers or * requests left in the HAL. The framework may call configure_streams (as * the HAL state is now quiesced) or may issue new requests. * * Note that it's sufficient to only support fully-succeeded and fully-failed result cases. * However, it is highly desirable to support the partial failure cases as well, as it * could help improve the flush call overall performance. * * Performance requirements: * * The HAL should return from this call in 100ms, and must return from this * call in 1000ms. And this call must not be blocked longer than pipeline * latency (see S7 for definition). * * Version information: * * only available if device version >= CAMERA_DEVICE_API_VERSION_3_1. * * Return values: * * 0: On a successful flush of the camera HAL. * * -EINVAL: If the input is malformed (the device is not valid). * * -ENODEV: If the camera device has encountered a serious error. After this * error is returned, only the close() method can be successfully * called by the framework. */ int (*flush)(const struct camera3_device *); /* reserved for future use */ void *reserved[8]; } camera3_device_ops_t; /********************************************************************** * * Camera device definition * */ typedef struct camera3_device { /** * common.version must equal CAMERA_DEVICE_API_VERSION_3_0 to identify this * device as implementing version 3.0 of the camera device HAL. * * Performance requirements: * * Camera open (common.module->common.methods->open) should return in 200ms, and must return * in 500ms. * Camera close (common.close) should return in 200ms, and must return in 500ms. * */ hw_device_t common; camera3_device_ops_t *ops; void *priv; } camera3_device_t; __END_DECLS #endif /* #ifdef ANDROID_INCLUDE_CAMERA3_H */ android-headers-23/23/hardware/camera_common.h000066400000000000000000001141621264465411000213330ustar00rootroot00000000000000/* * 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. */ // FIXME: add well-defined names for cameras #ifndef ANDROID_INCLUDE_CAMERA_COMMON_H #define ANDROID_INCLUDE_CAMERA_COMMON_H #include #include #include #include #include #include #include #include #include __BEGIN_DECLS /** * The id of this module */ #define CAMERA_HARDWARE_MODULE_ID "camera" /** * Module versioning information for the Camera hardware module, based on * camera_module_t.common.module_api_version. The two most significant hex * digits represent the major version, and the two least significant represent * the minor version. * ******************************************************************************* * Versions: 0.X - 1.X [CAMERA_MODULE_API_VERSION_1_0] * * Camera modules that report these version numbers implement the initial * camera module HAL interface. All camera devices openable through this * module support only version 1 of the camera device HAL. The device_version * and static_camera_characteristics fields of camera_info are not valid. Only * the android.hardware.Camera API can be supported by this module and its * devices. * ******************************************************************************* * Version: 2.0 [CAMERA_MODULE_API_VERSION_2_0] * * Camera modules that report this version number implement the second version * of the camera module HAL interface. Camera devices openable through this * module may support either version 1.0 or version 2.0 of the camera device * HAL interface. The device_version field of camera_info is always valid; the * static_camera_characteristics field of camera_info is valid if the * device_version field is 2.0 or higher. * ******************************************************************************* * Version: 2.1 [CAMERA_MODULE_API_VERSION_2_1] * * This camera module version adds support for asynchronous callbacks to the * framework from the camera HAL module, which is used to notify the framework * about changes to the camera module state. Modules that provide a valid * set_callbacks() method must report at least this version number. * ******************************************************************************* * Version: 2.2 [CAMERA_MODULE_API_VERSION_2_2] * * This camera module version adds vendor tag support from the module, and * deprecates the old vendor_tag_query_ops that were previously only * accessible with a device open. * ******************************************************************************* * Version: 2.3 [CAMERA_MODULE_API_VERSION_2_3] * * This camera module version adds open legacy camera HAL device support. * Framework can use it to open the camera device as lower device HAL version * HAL device if the same device can support multiple device API versions. * The standard hardware module open call (common.methods->open) continues * to open the camera device with the latest supported version, which is * also the version listed in camera_info_t.device_version. * ******************************************************************************* * Version: 2.4 [CAMERA_MODULE_API_VERSION_2_4] * * This camera module version adds below API changes: * * 1. Torch mode support. The framework can use it to turn on torch mode for * any camera device that has a flash unit, without opening a camera device. The * camera device has a higher priority accessing the flash unit than the camera * module; opening a camera device will turn off the torch if it had been enabled * through the module interface. When there are any resource conflicts, such as * open() is called to open a camera device, the camera HAL module must notify the * framework through the torch mode status callback that the torch mode has been * turned off. * * 2. External camera (e.g. USB hot-plug camera) support. The API updates specify that * the camera static info is only available when camera is connected and ready to * use for external hot-plug cameras. Calls to get static info will be invalid * calls when camera status is not CAMERA_DEVICE_STATUS_PRESENT. The frameworks * will only count on device status change callbacks to manage the available external * camera list. * * 3. Camera arbitration hints. This module version adds support for explicitly * indicating the number of camera devices that can be simultaneously opened and used. * To specify valid combinations of devices, the resource_cost and conflicting_devices * fields should always be set in the camera_info structure returned by the * get_camera_info call. * * 4. Module initialization method. This will be called by the camera service * right after the HAL module is loaded, to allow for one-time initialization * of the HAL. It is called before any other module methods are invoked. */ /** * Predefined macros for currently-defined version numbers */ /** * All module versions <= HARDWARE_MODULE_API_VERSION(1, 0xFF) must be treated * as CAMERA_MODULE_API_VERSION_1_0 */ #define CAMERA_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) #define CAMERA_MODULE_API_VERSION_2_0 HARDWARE_MODULE_API_VERSION(2, 0) #define CAMERA_MODULE_API_VERSION_2_1 HARDWARE_MODULE_API_VERSION(2, 1) #define CAMERA_MODULE_API_VERSION_2_2 HARDWARE_MODULE_API_VERSION(2, 2) #define CAMERA_MODULE_API_VERSION_2_3 HARDWARE_MODULE_API_VERSION(2, 3) #define CAMERA_MODULE_API_VERSION_2_4 HARDWARE_MODULE_API_VERSION(2, 4) #define CAMERA_MODULE_API_VERSION_CURRENT CAMERA_MODULE_API_VERSION_2_4 /** * All device versions <= HARDWARE_DEVICE_API_VERSION(1, 0xFF) must be treated * as CAMERA_DEVICE_API_VERSION_1_0 */ #define CAMERA_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) #define CAMERA_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 0) #define CAMERA_DEVICE_API_VERSION_2_1 HARDWARE_DEVICE_API_VERSION(2, 1) #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_2 HARDWARE_DEVICE_API_VERSION(3, 2) #define CAMERA_DEVICE_API_VERSION_3_3 HARDWARE_DEVICE_API_VERSION(3, 3) // Device version 3.3 is current, older HAL camera device versions are not // recommended for new devices. #define CAMERA_DEVICE_API_VERSION_CURRENT CAMERA_DEVICE_API_VERSION_3_3 /** * Defined in /system/media/camera/include/system/camera_metadata.h */ typedef struct camera_metadata camera_metadata_t; typedef struct camera_info { /** * The direction that the camera faces to. See system/core/include/system/camera.h * for camera facing definitions. * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_2_3 or lower: * * It should be CAMERA_FACING_BACK or CAMERA_FACING_FRONT. * * CAMERA_MODULE_API_VERSION_2_4 or higher: * * It should be CAMERA_FACING_BACK, CAMERA_FACING_FRONT or * CAMERA_FACING_EXTERNAL. */ int facing; /** * The orientation of the camera image. The value is the angle that the * camera image needs to be rotated clockwise so it shows correctly on the * display in its natural orientation. It should be 0, 90, 180, or 270. * * For example, suppose a device has a naturally tall screen. The * back-facing camera sensor is mounted in landscape. You are looking at the * screen. If the top side of the camera sensor is aligned with the right * edge of the screen in natural orientation, the value should be 90. If the * top side of a front-facing camera sensor is aligned with the right of the * screen, the value should be 270. * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_2_3 or lower: * * Valid in all camera_module versions. * * CAMERA_MODULE_API_VERSION_2_4 or higher: * * Valid if camera facing is CAMERA_FACING_BACK or CAMERA_FACING_FRONT, * not valid if camera facing is CAMERA_FACING_EXTERNAL. */ int orientation; /** * The value of camera_device_t.common.version. * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_1_0: * * Not valid. Can be assumed to be CAMERA_DEVICE_API_VERSION_1_0. Do * not read this field. * * CAMERA_MODULE_API_VERSION_2_0 or higher: * * Always valid * */ uint32_t device_version; /** * The camera's fixed characteristics, which include all static camera metadata * specified in system/media/camera/docs/docs.html. This should be a sorted metadata * buffer, and may not be modified or freed by the caller. The pointer should remain * valid for the lifetime of the camera module, and values in it may not * change after it is returned by get_camera_info(). * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_1_0: * * Not valid. Extra characteristics are not available. Do not read this * field. * * CAMERA_MODULE_API_VERSION_2_0 or higher: * * Valid if device_version >= CAMERA_DEVICE_API_VERSION_2_0. Do not read * otherwise. * */ const camera_metadata_t *static_camera_characteristics; /** * The total resource "cost" of using this camera, represented as an integer * value in the range [0, 100] where 100 represents total usage of the shared * resource that is the limiting bottleneck of the camera subsystem. This may * be a very rough estimate, and is used as a hint to the camera service to * determine when to disallow multiple applications from simultaneously * opening different cameras advertised by the camera service. * * The camera service must be able to simultaneously open and use any * combination of camera devices exposed by the HAL where the sum of * the resource costs of these cameras is <= 100. For determining cost, * each camera device must be assumed to be configured and operating at * the maximally resource-consuming framerate and stream size settings * available in the configuration settings exposed for that device through * the camera metadata. * * The camera service may still attempt to simultaneously open combinations * of camera devices with a total resource cost > 100. This may succeed or * fail. If this succeeds, combinations of configurations that are not * supported due to resource constraints from having multiple open devices * should fail during the configure calls. If the total resource cost is * <= 100, open and configure should never fail for any stream configuration * settings or other device capabilities that would normally succeed for a * device when it is the only open camera device. * * This field will be used to determine whether background applications are * allowed to use this camera device while other applications are using other * camera devices. Note: multiple applications will never be allowed by the * camera service to simultaneously open the same camera device. * * Example use cases: * * Ex. 1: Camera Device 0 = Back Camera * Camera Device 1 = Front Camera * - Using both camera devices causes a large framerate slowdown due to * limited ISP bandwidth. * * Configuration: * * Camera Device 0 - resource_cost = 51 * conflicting_devices = null * Camera Device 1 - resource_cost = 51 * conflicting_devices = null * * Result: * * Since the sum of the resource costs is > 100, if a higher-priority * application has either device open, no lower-priority applications will be * allowed by the camera service to open either device. If a lower-priority * application is using a device that a higher-priority subsequently attempts * to open, the lower-priority application will be forced to disconnect the * the device. * * If the highest-priority application chooses, it may still attempt to open * both devices (since these devices are not listed as conflicting in the * conflicting_devices fields), but usage of these devices may fail in the * open or configure calls. * * Ex. 2: Camera Device 0 = Left Back Camera * Camera Device 1 = Right Back Camera * Camera Device 2 = Combined stereo camera using both right and left * back camera sensors used by devices 0, and 1 * Camera Device 3 = Front Camera * - Due to do hardware constraints, up to two cameras may be open at once. The * combined stereo camera may never be used at the same time as either of the * two back camera devices (device 0, 1), and typically requires too much * bandwidth to use at the same time as the front camera (device 3). * * Configuration: * * Camera Device 0 - resource_cost = 50 * conflicting_devices = { 2 } * Camera Device 1 - resource_cost = 50 * conflicting_devices = { 2 } * Camera Device 2 - resource_cost = 100 * conflicting_devices = { 0, 1 } * Camera Device 3 - resource_cost = 50 * conflicting_devices = null * * Result: * * Based on the conflicting_devices fields, the camera service guarantees that * the following sets of open devices will never be allowed: { 1, 2 }, { 0, 2 }. * * Based on the resource_cost fields, if a high-priority foreground application * is using camera device 0, a background application would be allowed to open * camera device 1 or 3 (but would be forced to disconnect it again if the * foreground application opened another device). * * The highest priority application may still attempt to simultaneously open * devices 0, 2, and 3, but the HAL may fail in open or configure calls for * this combination. * * Ex. 3: Camera Device 0 = Back Camera * Camera Device 1 = Front Camera * Camera Device 2 = Low-power Front Camera that uses the same * sensor as device 1, but only exposes image stream * resolutions that can be used in low-power mode * - Using both front cameras (device 1, 2) at the same time is impossible due * a shared physical sensor. Using the back and "high-power" front camera * (device 1) may be impossible for some stream configurations due to hardware * limitations, but the "low-power" front camera option may always be used as * it has special dedicated hardware. * * Configuration: * * Camera Device 0 - resource_cost = 100 * conflicting_devices = null * Camera Device 1 - resource_cost = 100 * conflicting_devices = { 2 } * Camera Device 2 - resource_cost = 0 * conflicting_devices = { 1 } * Result: * * Based on the conflicting_devices fields, the camera service guarantees that * the following sets of open devices will never be allowed: { 1, 2 }. * * Based on the resource_cost fields, only the highest priority application * may attempt to open both device 0 and 1 at the same time. If a higher-priority * application is not using device 1 or 2, a low-priority background application * may open device 2 (but will be forced to disconnect it if a higher-priority * application subsequently opens device 1 or 2). * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_2_3 or lower: * * Not valid. Can be assumed to be 100. Do not read this field. * * CAMERA_MODULE_API_VERSION_2_4 or higher: * * Always valid. */ int resource_cost; /** * An array of camera device IDs represented as NULL-terminated strings * indicating other devices that cannot be simultaneously opened while this * camera device is in use. * * This field is intended to be used to indicate that this camera device * is a composite of several other camera devices, or otherwise has * hardware dependencies that prohibit simultaneous usage. If there are no * dependencies, a NULL may be returned in this field to indicate this. * * The camera service will never simultaneously open any of the devices * in this list while this camera device is open. * * The strings pointed to in this field will not be cleaned up by the camera * service, and must remain while this device is plugged in. * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_2_3 or lower: * * Not valid. Can be assumed to be NULL. Do not read this field. * * CAMERA_MODULE_API_VERSION_2_4 or higher: * * Always valid. */ char** conflicting_devices; /** * The length of the array given in the conflicting_devices field. * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_2_3 or lower: * * Not valid. Can be assumed to be 0. Do not read this field. * * CAMERA_MODULE_API_VERSION_2_4 or higher: * * Always valid. */ size_t conflicting_devices_length; } camera_info_t; /** * camera_device_status_t: * * The current status of the camera device, as provided by the HAL through the * camera_module_callbacks.camera_device_status_change() call. * * At module load time, the framework will assume all camera devices are in the * CAMERA_DEVICE_STATUS_PRESENT state. The HAL should invoke * camera_module_callbacks::camera_device_status_change to inform the framework * of any initially NOT_PRESENT devices. * * Allowed transitions: * PRESENT -> NOT_PRESENT * NOT_PRESENT -> ENUMERATING * NOT_PRESENT -> PRESENT * ENUMERATING -> PRESENT * ENUMERATING -> NOT_PRESENT */ typedef enum camera_device_status { /** * The camera device is not currently connected, and opening it will return * failure. * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_2_3 or lower: * * Calls to get_camera_info must still succeed, and provide the same information * it would if the camera were connected. * * CAMERA_MODULE_API_VERSION_2_4: * * The camera device at this status must return -EINVAL for get_camera_info call, * as the device is not connected. */ CAMERA_DEVICE_STATUS_NOT_PRESENT = 0, /** * The camera device is connected, and opening it will succeed. * * CAMERA_MODULE_API_VERSION_2_3 or lower: * * The information returned by get_camera_info cannot change due to this status * change. By default, the framework will assume all devices are in this state. * * CAMERA_MODULE_API_VERSION_2_4: * * The information returned by get_camera_info will become valid after a device's * status changes to this. By default, the framework will assume all devices are in * this state. */ CAMERA_DEVICE_STATUS_PRESENT = 1, /** * The camera device is connected, but it is undergoing an enumeration and * so opening the device will return -EBUSY. * * CAMERA_MODULE_API_VERSION_2_3 or lower: * * Calls to get_camera_info must still succeed, as if the camera was in the * PRESENT status. * * CAMERA_MODULE_API_VERSION_2_4: * * The camera device at this status must return -EINVAL for get_camera_info for call, * as the device is not ready. */ CAMERA_DEVICE_STATUS_ENUMERATING = 2, } camera_device_status_t; /** * torch_mode_status_t: * * The current status of the torch mode, as provided by the HAL through the * camera_module_callbacks.torch_mode_status_change() call. * * The torch mode status of a camera device is applicable only when the camera * device is present. The framework will not call set_torch_mode() to turn on * torch mode of a camera device if the camera device is not present. At module * load time, the framework will assume torch modes are in the * TORCH_MODE_STATUS_AVAILABLE_OFF state if the camera device is present and * android.flash.info.available is reported as true via get_camera_info() call. * * The behaviors of the camera HAL module that the framework expects in the * following situations when a camera device's status changes: * 1. A previously-disconnected camera device becomes connected. * After camera_module_callbacks::camera_device_status_change() is invoked * to inform the framework that the camera device is present, the framework * will assume the camera device's torch mode is in * TORCH_MODE_STATUS_AVAILABLE_OFF state. The camera HAL module does not need * to invoke camera_module_callbacks::torch_mode_status_change() unless the * flash unit is unavailable to use by set_torch_mode(). * * 2. A previously-connected camera becomes disconnected. * After camera_module_callbacks::camera_device_status_change() is invoked * to inform the framework that the camera device is not present, the * framework will not call set_torch_mode() for the disconnected camera * device until its flash unit becomes available again. The camera HAL * module does not need to invoke * camera_module_callbacks::torch_mode_status_change() separately to inform * that the flash unit has become unavailable. * * 3. open() is called to open a camera device. * The camera HAL module must invoke * camera_module_callbacks::torch_mode_status_change() for all flash units * that have entered TORCH_MODE_STATUS_NOT_AVAILABLE state and can not be * turned on by calling set_torch_mode() anymore due to this open() call. * open() must not trigger TORCH_MODE_STATUS_AVAILABLE_OFF before * TORCH_MODE_STATUS_NOT_AVAILABLE for all flash units that have become * unavailable. * * 4. close() is called to close a camera device. * The camera HAL module must invoke * camera_module_callbacks::torch_mode_status_change() for all flash units * that have entered TORCH_MODE_STATUS_AVAILABLE_OFF state and can be turned * on by calling set_torch_mode() again because of enough resources freed * up by this close() call. * * Note that the framework calling set_torch_mode() successfully must trigger * TORCH_MODE_STATUS_AVAILABLE_OFF or TORCH_MODE_STATUS_AVAILABLE_ON callback * for the given camera device. Additionally it must trigger * TORCH_MODE_STATUS_AVAILABLE_OFF callbacks for other previously-on torch * modes if HAL cannot keep multiple torch modes on simultaneously. */ typedef enum torch_mode_status { /** * The flash unit is no longer available and the torch mode can not be * turned on by calling set_torch_mode(). If the torch mode is on, it * will be turned off by HAL before HAL calls torch_mode_status_change(). */ TORCH_MODE_STATUS_NOT_AVAILABLE = 0, /** * A torch mode has become off and available to be turned on via * set_torch_mode(). This may happen in the following * cases: * 1. After the resources to turn on the torch mode have become available. * 2. After set_torch_mode() is called to turn off the torch mode. * 3. After the framework turned on the torch mode of some other camera * device and HAL had to turn off the torch modes of any camera devices * that were previously on. */ TORCH_MODE_STATUS_AVAILABLE_OFF = 1, /** * A torch mode has become on and available to be turned off via * set_torch_mode(). This can happen only after set_torch_mode() is called * to turn on the torch mode. */ TORCH_MODE_STATUS_AVAILABLE_ON = 2, } torch_mode_status_t; /** * Callback functions for the camera HAL module to use to inform the framework * of changes to the camera subsystem. * * Version information (based on camera_module_t.common.module_api_version): * * Each callback is called only by HAL modules implementing the indicated * version or higher of the HAL module API interface. * * CAMERA_MODULE_API_VERSION_2_1: * camera_device_status_change() * * CAMERA_MODULE_API_VERSION_2_4: * torch_mode_status_change() */ typedef struct camera_module_callbacks { /** * camera_device_status_change: * * Callback to the framework to indicate that the state of a specific camera * device has changed. At module load time, the framework will assume all * camera devices are in the CAMERA_DEVICE_STATUS_PRESENT state. The HAL * must call this method to inform the framework of any initially * NOT_PRESENT devices. * * This callback is added for CAMERA_MODULE_API_VERSION_2_1. * * camera_module_callbacks: The instance of camera_module_callbacks_t passed * to the module with set_callbacks. * * camera_id: The ID of the camera device that has a new status. * * new_status: The new status code, one of the camera_device_status_t enums, * or a platform-specific status. * */ void (*camera_device_status_change)(const struct camera_module_callbacks*, int camera_id, int new_status); /** * torch_mode_status_change: * * Callback to the framework to indicate that the state of the torch mode * of the flash unit associated with a specific camera device has changed. * At module load time, the framework will assume the torch modes are in * the TORCH_MODE_STATUS_AVAILABLE_OFF state if android.flash.info.available * is reported as true via get_camera_info() call. * * This callback is added for CAMERA_MODULE_API_VERSION_2_4. * * camera_module_callbacks: The instance of camera_module_callbacks_t * passed to the module with set_callbacks. * * camera_id: The ID of camera device whose flash unit has a new torch mode * status. * * new_status: The new status code, one of the torch_mode_status_t enums. */ void (*torch_mode_status_change)(const struct camera_module_callbacks*, const char* camera_id, int new_status); } camera_module_callbacks_t; typedef struct camera_module { /** * Common methods of the camera module. This *must* be the first member of * camera_module as users of this structure will cast a hw_module_t to * camera_module pointer in contexts where it's known the hw_module_t * references a camera_module. * * The return values for common.methods->open for camera_module are: * * 0: On a successful open of the camera device. * * -ENODEV: The camera device cannot be opened due to an internal * error. * * -EINVAL: The input arguments are invalid, i.e. the id is invalid, * and/or the module is invalid. * * -EBUSY: The camera device was already opened for this camera id * (by using this method or open_legacy), * regardless of the device HAL version it was opened as. * * -EUSERS: The maximal number of camera devices that can be * opened concurrently were opened already, either by * this method or the open_legacy method. * * All other return values from common.methods->open will be treated as * -ENODEV. */ hw_module_t common; /** * get_number_of_cameras: * * Returns the number of camera devices accessible through the camera * module. The camera devices are numbered 0 through N-1, where N is the * value returned by this call. The name of the camera device for open() is * simply the number converted to a string. That is, "0" for camera ID 0, * "1" for camera ID 1. * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_2_3 or lower: * * The value here must be static, and cannot change after the first call * to this method. * * CAMERA_MODULE_API_VERSION_2_4 or higher: * * The value here must be static, and must count only built-in cameras, * which have CAMERA_FACING_BACK or CAMERA_FACING_FRONT camera facing values * (camera_info.facing). The HAL must not include the external cameras * (camera_info.facing == CAMERA_FACING_EXTERNAL) into the return value * of this call. Frameworks will use camera_device_status_change callback * to manage number of external cameras. */ int (*get_number_of_cameras)(void); /** * get_camera_info: * * Return the static camera information for a given camera device. This * information may not change for a camera device. * * Return values: * * 0: On a successful operation * * -ENODEV: The information cannot be provided due to an internal * error. * * -EINVAL: The input arguments are invalid, i.e. the id is invalid, * and/or the module is invalid. * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_2_4 or higher: * * When a camera is disconnected, its camera id becomes invalid. Calling this * this method with this invalid camera id will get -EINVAL and NULL camera * static metadata (camera_info.static_camera_characteristics). */ int (*get_camera_info)(int camera_id, struct camera_info *info); /** * set_callbacks: * * Provide callback function pointers to the HAL module to inform framework * of asynchronous camera module events. The framework will call this * function once after initial camera HAL module load, after the * get_number_of_cameras() method is called for the first time, and before * any other calls to the module. * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_1_0, CAMERA_MODULE_API_VERSION_2_0: * * Not provided by HAL module. Framework may not call this function. * * CAMERA_MODULE_API_VERSION_2_1: * * Valid to be called by the framework. * * Return values: * * 0: On a successful operation * * -ENODEV: The operation cannot be completed due to an internal * error. * * -EINVAL: The input arguments are invalid, i.e. the callbacks are * null */ int (*set_callbacks)(const camera_module_callbacks_t *callbacks); /** * get_vendor_tag_ops: * * Get methods to query for vendor extension metadata tag information. The * HAL should fill in all the vendor tag operation methods, or leave ops * unchanged if no vendor tags are defined. * * The vendor_tag_ops structure used here is defined in: * system/media/camera/include/system/vendor_tags.h * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1: * Not provided by HAL module. Framework may not call this function. * * CAMERA_MODULE_API_VERSION_2_2: * Valid to be called by the framework. */ void (*get_vendor_tag_ops)(vendor_tag_ops_t* ops); /** * open_legacy: * * Open a specific legacy camera HAL device if multiple device HAL API * versions are supported by this camera HAL module. For example, if the * camera module supports both CAMERA_DEVICE_API_VERSION_1_0 and * CAMERA_DEVICE_API_VERSION_3_2 device API for the same camera id, * framework can call this function to open the camera device as * CAMERA_DEVICE_API_VERSION_1_0 device. * * This is an optional method. A Camera HAL module does not need to support * more than one device HAL version per device, and such modules may return * -ENOSYS for all calls to this method. For all older HAL device API * versions that are not supported, it may return -EOPNOTSUPP. When above * cases occur, The normal open() method (common.methods->open) will be * used by the framework instead. * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2: * Not provided by HAL module. Framework will not call this function. * * CAMERA_MODULE_API_VERSION_2_3: * Valid to be called by the framework. * * Return values: * * 0: On a successful open of the camera device. * * -ENOSYS This method is not supported. * * -EOPNOTSUPP: The requested HAL version is not supported by this method. * * -EINVAL: The input arguments are invalid, i.e. the id is invalid, * and/or the module is invalid. * * -EBUSY: The camera device was already opened for this camera id * (by using this method or common.methods->open method), * regardless of the device HAL version it was opened as. * * -EUSERS: The maximal number of camera devices that can be * opened concurrently were opened already, either by * this method or common.methods->open method. */ int (*open_legacy)(const struct hw_module_t* module, const char* id, uint32_t halVersion, struct hw_device_t** device); /** * set_torch_mode: * * Turn on or off the torch mode of the flash unit associated with a given * camera ID. If the operation is successful, HAL must notify the framework * torch state by invoking * camera_module_callbacks.torch_mode_status_change() with the new state. * * The camera device has a higher priority accessing the flash unit. When * there are any resource conflicts, such as open() is called to open a * camera device, HAL module must notify the framework through * camera_module_callbacks.torch_mode_status_change() that the * torch mode has been turned off and the torch mode state has become * TORCH_MODE_STATUS_NOT_AVAILABLE. When resources to turn on torch mode * become available again, HAL module must notify the framework through * camera_module_callbacks.torch_mode_status_change() that the torch mode * state has become TORCH_MODE_STATUS_AVAILABLE_OFF for set_torch_mode() to * be called. * * When the framework calls set_torch_mode() to turn on the torch mode of a * flash unit, if HAL cannot keep multiple torch modes on simultaneously, * HAL should turn off the torch mode that was turned on by * a previous set_torch_mode() call and notify the framework that the torch * mode state of that flash unit has become TORCH_MODE_STATUS_AVAILABLE_OFF. * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2/2_3: * Not provided by HAL module. Framework will not call this function. * * CAMERA_MODULE_API_VERSION_2_4: * Valid to be called by the framework. * * Return values: * * 0: On a successful operation. * * -ENOSYS: The camera device does not support this operation. It is * returned if and only if android.flash.info.available is * false. * * -EBUSY: The camera device is already in use. * * -EUSERS: The resources needed to turn on the torch mode are not * available, typically because other camera devices are * holding the resources to make using the flash unit not * possible. * * -EINVAL: camera_id is invalid. * */ int (*set_torch_mode)(const char* camera_id, bool enabled); /** * init: * * This method is called by the camera service before any other methods * are invoked, right after the camera HAL library has been successfully * loaded. It may be left as NULL by the HAL module, if no initialization * in needed. * * It can be used by HAL implementations to perform initialization and * other one-time operations. * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2/2_3: * Not provided by HAL module. Framework will not call this function. * * CAMERA_MODULE_API_VERSION_2_4: * If not NULL, will always be called by the framework once after the HAL * module is loaded, before any other HAL module method is called. * * Return values: * * 0: On a successful operation. * * -ENODEV: Initialization cannot be completed due to an internal * error. The HAL must be assumed to be in a nonfunctional * state. * */ int (*init)(); /* reserved for future use */ void* reserved[5]; } camera_module_t; __END_DECLS #endif /* ANDROID_INCLUDE_CAMERA_COMMON_H */ android-headers-23/23/hardware/consumerir.h000066400000000000000000000067261264465411000207270ustar00rootroot00000000000000/* * 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_HARDWARE_CONSUMERIR_H #define ANDROID_INCLUDE_HARDWARE_CONSUMERIR_H #include #include #include #include #define CONSUMERIR_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) #define CONSUMERIR_HARDWARE_MODULE_ID "consumerir" #define CONSUMERIR_TRANSMITTER "transmitter" typedef struct consumerir_freq_range { int min; int max; } consumerir_freq_range_t; typedef struct consumerir_module { /** * Common methods of the consumer IR module. This *must* be the first member of * consumerir_module as users of this structure will cast a hw_module_t to * consumerir_module pointer in contexts where it's known the hw_module_t references a * consumerir_module. */ struct hw_module_t common; } consumerir_module_t; typedef struct consumerir_device { /** * Common methods of the consumer IR device. This *must* be the first member of * consumerir_device as users of this structure will cast a hw_device_t to * consumerir_device pointer in contexts where it's known the hw_device_t references a * consumerir_device. */ struct hw_device_t common; /* * (*transmit)() is called to by the ConsumerIrService to send an IR pattern * at a given carrier_freq. * * The pattern is alternating series of carrier on and off periods measured in * microseconds. The carrier should be turned off at the end of a transmit * even if there are and odd number of entries in the pattern array. * * This call should return when the transmit is complete or encounters an error. * * returns: 0 on success. A negative error code on error. */ int (*transmit)(struct consumerir_device *dev, int carrier_freq, const int pattern[], int pattern_len); /* * (*get_num_carrier_freqs)() is called by the ConsumerIrService to get the * number of carrier freqs to allocate space for, which is then filled by * a subsequent call to (*get_carrier_freqs)(). * * returns: the number of ranges on success. A negative error code on error. */ int (*get_num_carrier_freqs)(struct consumerir_device *dev); /* * (*get_carrier_freqs)() is called by the ConsumerIrService to enumerate * which frequencies the IR transmitter supports. The HAL implementation * should fill an array of consumerir_freq_range structs with the * appropriate values for the transmitter, up to len elements. * * returns: the number of ranges on success. A negative error code on error. */ int (*get_carrier_freqs)(struct consumerir_device *dev, size_t len, consumerir_freq_range_t *ranges); /* Reserved for future use. Must be NULL. */ void* reserved[8 - 3]; } consumerir_device_t; #endif /* ANDROID_INCLUDE_HARDWARE_CONSUMERIR_H */ android-headers-23/23/hardware/fb.h000066400000000000000000000126551264465411000171260ustar00rootroot00000000000000/* * 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_FB_INTERFACE_H #define ANDROID_FB_INTERFACE_H #include #include #include #include #include __BEGIN_DECLS #define GRALLOC_HARDWARE_FB0 "fb0" /*****************************************************************************/ /*****************************************************************************/ typedef struct framebuffer_device_t { /** * Common methods of the framebuffer device. This *must* be the first member of * framebuffer_device_t as users of this structure will cast a hw_device_t to * framebuffer_device_t pointer in contexts where it's known the hw_device_t references a * framebuffer_device_t. */ struct hw_device_t common; /* flags describing some attributes of the framebuffer */ const uint32_t flags; /* dimensions of the framebuffer in pixels */ const uint32_t width; const uint32_t height; /* frambuffer stride in pixels */ const int stride; /* framebuffer pixel format */ const int format; /* resolution of the framebuffer's display panel in pixel per inch*/ const float xdpi; const float ydpi; /* framebuffer's display panel refresh rate in frames per second */ const float fps; /* min swap interval supported by this framebuffer */ const int minSwapInterval; /* max swap interval supported by this framebuffer */ const int maxSwapInterval; /* Number of framebuffers supported*/ const int numFramebuffers; int reserved[7]; /* * requests a specific swap-interval (same definition than EGL) * * Returns 0 on success or -errno on error. */ int (*setSwapInterval)(struct framebuffer_device_t* window, int interval); /* * This hook is OPTIONAL. * * It is non NULL If the framebuffer driver supports "update-on-demand" * and the given rectangle is the area of the screen that gets * updated during (*post)(). * * This is useful on devices that are able to DMA only a portion of * the screen to the display panel, upon demand -- as opposed to * constantly refreshing the panel 60 times per second, for instance. * * Only the area defined by this rectangle is guaranteed to be valid, that * is, the driver is not allowed to post anything outside of this * rectangle. * * The rectangle evaluated during (*post)() and specifies which area * of the buffer passed in (*post)() shall to be posted. * * return -EINVAL if width or height <=0, or if left or top < 0 */ int (*setUpdateRect)(struct framebuffer_device_t* window, int left, int top, int width, int height); /* * Post to the display (display it on the screen) * The buffer must have been allocated with the * GRALLOC_USAGE_HW_FB usage flag. * buffer must be the same width and height as the display and must NOT * be locked. * * The buffer is shown during the next VSYNC. * * If the same buffer is posted again (possibly after some other buffer), * post() will block until the the first post is completed. * * Internally, post() is expected to lock the buffer so that a * subsequent call to gralloc_module_t::(*lock)() with USAGE_RENDER or * USAGE_*_WRITE will block until it is safe; that is typically once this * buffer is shown and another buffer has been posted. * * Returns 0 on success or -errno on error. */ int (*post)(struct framebuffer_device_t* dev, buffer_handle_t buffer); /* * The (*compositionComplete)() method must be called after the * compositor has finished issuing GL commands for client buffers. */ int (*compositionComplete)(struct framebuffer_device_t* dev); /* * This hook is OPTIONAL. * * If non NULL it will be caused by SurfaceFlinger on dumpsys */ void (*dump)(struct framebuffer_device_t* dev, char *buff, int buff_len); /* * (*enableScreen)() is used to either blank (enable=0) or * unblank (enable=1) the screen this framebuffer is attached to. * * Returns 0 on success or -errno on error. */ int (*enableScreen)(struct framebuffer_device_t* dev, int enable); void* reserved_proc[6]; } framebuffer_device_t; /** convenience API for opening and closing a supported device */ 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); } static inline int framebuffer_close(struct framebuffer_device_t* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_FB_INTERFACE_H android-headers-23/23/hardware/fingerprint.h000066400000000000000000000272721264465411000210670ustar00rootroot00000000000000/* * 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_HARDWARE_FINGERPRINT_H #define ANDROID_INCLUDE_HARDWARE_FINGERPRINT_H #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_HARDWARE_MODULE_ID "fingerprint" typedef enum fingerprint_msg_type { FINGERPRINT_ERROR = -1, FINGERPRINT_ACQUIRED = 1, FINGERPRINT_TEMPLATE_ENROLLING = 3, FINGERPRINT_TEMPLATE_REMOVED = 4, FINGERPRINT_AUTHENTICATED = 5 } fingerprint_msg_type_t; /* * Fingerprint errors are meant to tell the framework to terminate the current operation and ask * for the user to correct the situation. These will almost always result in messaging and user * interaction to correct the problem. * * For example, FINGERPRINT_ERROR_CANCELED should follow any acquisition message that results in * a situation where the current operation can't continue without user interaction. For example, * if the sensor is dirty during enrollment and no further enrollment progress can be made, * send FINGERPRINT_ACQUIRED_IMAGER_DIRTY followed by FINGERPRINT_ERROR_CANCELED. */ typedef enum fingerprint_error { FINGERPRINT_ERROR_HW_UNAVAILABLE = 1, /* The hardware has an error that can't be resolved. */ FINGERPRINT_ERROR_UNABLE_TO_PROCESS = 2, /* Bad data; operation can't continue */ FINGERPRINT_ERROR_TIMEOUT = 3, /* The operation has timed out waiting for user input. */ 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_VENDOR_BASE = 1000 /* vendor-specific error messages start here */ } fingerprint_error_t; /* * Fingerprint acquisition info is meant as feedback for the current operation. Anything but * FINGERPRINT_ACQUIRED_GOOD will be shown to the user as feedback on how to take action on the * current operation. For example, FINGERPRINT_ACQUIRED_IMAGER_DIRTY can be used to tell the user * to clean the sensor. If this will cause the current operation to fail, an additional * FINGERPRINT_ERROR_CANCELED can be sent to stop the operation in progress (e.g. enrollment). * In general, these messages will result in a "Try again" message. */ typedef enum fingerprint_acquired_info { FINGERPRINT_ACQUIRED_GOOD = 0, FINGERPRINT_ACQUIRED_PARTIAL = 1, /* sensor needs more data, i.e. longer swipe. */ FINGERPRINT_ACQUIRED_INSUFFICIENT = 2, /* image doesn't contain enough detail for recognition*/ 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_VENDOR_BASE = 1000 /* vendor-specific acquisition messages start here */ } fingerprint_acquired_info_t; typedef struct fingerprint_finger_id { uint32_t gid; uint32_t fid; } fingerprint_finger_id_t; typedef struct fingerprint_enroll { fingerprint_finger_id_t finger; /* samples_remaining goes from N (no data collected, but N scans needed) * to 0 (no more data is needed to build a template). */ uint32_t samples_remaining; uint64_t msg; /* Vendor specific message. Used for user guidance */ } fingerprint_enroll_t; typedef struct fingerprint_removed { fingerprint_finger_id_t finger; } fingerprint_removed_t; typedef struct fingerprint_acquired { fingerprint_acquired_info_t acquired_info; /* information about the image */ } fingerprint_acquired_t; typedef struct fingerprint_authenticated { fingerprint_finger_id_t finger; hw_auth_token_t hat; } fingerprint_authenticated_t; typedef struct fingerprint_msg { fingerprint_msg_type_t type; union { fingerprint_error_t error; fingerprint_enroll_t enroll; fingerprint_removed_t removed; fingerprint_acquired_t acquired; fingerprint_authenticated_t authenticated; } data; } fingerprint_msg_t; /* Callback function type */ typedef void (*fingerprint_notify_t)(const fingerprint_msg_t *msg); /* Synchronous operation */ typedef struct fingerprint_device { /** * Common methods of the fingerprint device. This *must* be the first member * of fingerprint_device as users of this structure will cast a hw_device_t * to fingerprint_device pointer in contexts where it's known * the hw_device_t references a fingerprint_device. */ struct hw_device_t common; /* * Client provided callback function to receive notifications. * Do not set by hand, use the function above instead. */ fingerprint_notify_t notify; /* * Set notification callback: * Registers a user function that would receive notifications from the HAL * The call will block if the HAL state machine is in busy state until HAL * leaves the busy state. * * Function return: 0 if callback function is successfuly registered * or a negative number in case of error, generally from the errno.h set. */ int (*set_notify)(struct fingerprint_device *dev, fingerprint_notify_t notify); /* * Fingerprint pre-enroll enroll request: * Generates a unique token to upper layers to indicate the start of an enrollment transaction. * This token will be wrapped by security for verification and passed to enroll() for * verification before enrollment will be allowed. This is to ensure adding a new fingerprint * template was preceded by some kind of credential confirmation (e.g. device password). * * Function return: 0 if function failed * otherwise, a uint64_t of token */ uint64_t (*pre_enroll)(struct fingerprint_device *dev); /* * Fingerprint enroll request: * Switches the HAL state machine to collect and store a new fingerprint * template. Switches back as soon as enroll is complete * (fingerprint_msg.type == FINGERPRINT_TEMPLATE_ENROLLING && * fingerprint_msg.data.enroll.samples_remaining == 0) * or after timeout_sec seconds. * The fingerprint template will be assigned to the group gid. User has a choice * to supply the gid or set it to 0 in which case a unique group id will be generated. * * Function return: 0 if enrollment process can be successfully started * or a negative number in case of error, generally from the errno.h set. * A notify() function may be called indicating the error condition. */ int (*enroll)(struct fingerprint_device *dev, const hw_auth_token_t *hat, uint32_t gid, uint32_t timeout_sec); /* * Finishes the enroll operation and invalidates the pre_enroll() generated challenge. * This will be called at the end of a multi-finger enrollment session to indicate * that no more fingers will be added. * * Function return: 0 if the request is accepted * or a negative number in case of error, generally from the errno.h set. */ int (*post_enroll)(struct fingerprint_device *dev); /* * get_authenticator_id: * Returns a token associated with the current fingerprint set. This value will * change whenever a new fingerprint is enrolled, thus creating a new fingerprint * set. * * Function return: current authenticator id or 0 if function failed. */ uint64_t (*get_authenticator_id)(struct fingerprint_device *dev); /* * Cancel pending enroll or authenticate, sending FINGERPRINT_ERROR_CANCELED * to all running clients. Switches the HAL state machine back to the idle state. * Unlike enroll_done() doesn't invalidate the pre_enroll() challenge. * * Function return: 0 if cancel request is accepted * or a negative number in case of error, generally from the errno.h set. */ int (*cancel)(struct fingerprint_device *dev); /* * Enumerate all the fingerprint templates found in the directory set by * set_active_group() * This is a synchronous call. The function takes: * - A pointer to an array of fingerprint_finger_id_t. * - The size of the array provided, in fingerprint_finger_id_t elements. * Max_size is a bi-directional parameter and returns the actual number * of elements copied to the caller supplied array. * In the absence of errors the function returns the total number of templates * in the user directory. * If the caller has no good guess on the size of the array he should call this * function witn *max_size == 0 and use the return value for the array allocation. * The caller of this function has a complete list of the templates when *max_size * is the same as the function return. * * Function return: Total number of fingerprint templates in the current storage directory. * or a negative number in case of error, generally from the errno.h set. */ int (*enumerate)(struct fingerprint_device *dev, fingerprint_finger_id_t *results, uint32_t *max_size); /* * Fingerprint remove request: * Deletes a fingerprint template. * Works only within a 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.id indicating the template id removed. * * 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. */ int (*remove)(struct fingerprint_device *dev, uint32_t gid, uint32_t fid); /* * Restricts the HAL operation to a set of fingerprints belonging to a * group provided. * The caller must provide a path to a storage location within the user's * data directory. * * Function return: 0 on success * or a negative number in case of error, generally from the errno.h set. */ int (*set_active_group)(struct fingerprint_device *dev, uint32_t gid, const char *store_path); /* * Authenticates an operation identifed by operation_id * * Function return: 0 on success * or a negative number in case of error, generally from the errno.h set. */ int (*authenticate)(struct fingerprint_device *dev, uint64_t operation_id, uint32_t gid); /* Reserved for backward binary compatibility */ void *reserved[4]; } fingerprint_device_t; typedef struct fingerprint_module { /** * Common methods of the fingerprint module. This *must* be the first member * of fingerprint_module as users of this structure will cast a hw_module_t * to fingerprint_module pointer in contexts where it's known * the hw_module_t references a fingerprint_module. */ struct hw_module_t common; } fingerprint_module_t; #endif /* ANDROID_INCLUDE_HARDWARE_FINGERPRINT_H */ android-headers-23/23/hardware/fused_location.h000066400000000000000000000743671264465411000215450ustar00rootroot00000000000000/* * 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_HARDWARE_FUSED_LOCATION_H #define ANDROID_INCLUDE_HARDWARE_FUSED_LOCATION_H #include /** * This header file defines the interface of the Fused Location Provider. * Fused Location Provider is designed to fuse data from various sources * like GPS, Wifi, Cell, Sensors, Bluetooth etc to provide a fused location to the * upper layers. The advantage of doing fusion in hardware is power savings. * The goal is to do this without waking up the AP to get additional data. * The software implementation of FLP will decide when to use * the hardware fused location. Other location features like geofencing will * also be implemented using fusion in hardware. */ __BEGIN_DECLS #define FLP_HEADER_VERSION 1 #define FLP_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define FLP_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION_2(0, 1, FLP_HEADER_VERSION) /** * The id of this module */ #define FUSED_LOCATION_HARDWARE_MODULE_ID "flp" /** * Name for the FLP location interface */ #define FLP_LOCATION_INTERFACE "flp_location" /** * Name for the FLP location interface */ #define FLP_DIAGNOSTIC_INTERFACE "flp_diagnostic" /** * Name for the FLP_Geofencing interface. */ #define FLP_GEOFENCING_INTERFACE "flp_geofencing" /** * Name for the FLP_device context interface. */ #define FLP_DEVICE_CONTEXT_INTERFACE "flp_device_context" /** * Constants to indicate the various subsystems * that will be used. */ #define FLP_TECH_MASK_GNSS (1U<<0) #define FLP_TECH_MASK_WIFI (1U<<1) #define FLP_TECH_MASK_SENSORS (1U<<2) #define FLP_TECH_MASK_CELL (1U<<3) #define FLP_TECH_MASK_BLUETOOTH (1U<<4) /** * Set when your implementation can produce GNNS-derived locations, * for use with flp_capabilities_callback. * * GNNS is a required capability for a particular feature to be used * (batching or geofencing). If not supported that particular feature * won't be used by the upper layer. */ #define CAPABILITY_GNSS (1U<<0) /** * Set when your implementation can produce WiFi-derived locations, for * use with flp_capabilities_callback. */ #define CAPABILITY_WIFI (1U<<1) /** * Set when your implementation can produce cell-derived locations, for * use with flp_capabilities_callback. */ #define CAPABILITY_CELL (1U<<3) /** * Status to return in flp_status_callback when your implementation transitions * from being unsuccessful in determining location to being successful. */ #define FLP_STATUS_LOCATION_AVAILABLE 0 /** * Status to return in flp_status_callback when your implementation transitions * from being successful in determining location to being unsuccessful. */ #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, * sometimes in high power mode, the system might need * a location callback every single time the location * fix has been obtained. This flag controls that option. * Its the responsibility of the upper layers (caller) to switch * it off, if it knows that the AP might go to sleep. * When this bit is on amidst a batching session, batching should * continue while location fixes are reported in real time. */ #define FLP_BATCH_CALLBACK_ON_LOCATION_FIX 0x0000002 /** Flags to indicate which values are valid in a FlpLocation. */ typedef uint16_t FlpLocationFlags; // IMPORTANT: Note that the following values must match // constants in the corresponding java file. /** FlpLocation has valid latitude and longitude. */ #define FLP_LOCATION_HAS_LAT_LONG (1U<<0) /** FlpLocation has valid altitude. */ #define FLP_LOCATION_HAS_ALTITUDE (1U<<1) /** FlpLocation has valid speed. */ #define FLP_LOCATION_HAS_SPEED (1U<<2) /** FlpLocation has valid bearing. */ #define FLP_LOCATION_HAS_BEARING (1U<<4) /** FlpLocation has valid accuracy. */ #define FLP_LOCATION_HAS_ACCURACY (1U<<8) typedef int64_t FlpUtcTime; /** Represents a location. */ typedef struct { /** set to sizeof(FlpLocation) */ size_t size; /** Flags associated with the location object. */ FlpLocationFlags flags; /** Represents latitude in degrees. */ double latitude; /** Represents longitude in degrees. */ double longitude; /** * Represents altitude in meters above the WGS 84 reference * ellipsoid. */ double altitude; /** Represents speed in meters per second. */ float speed; /** Represents heading in degrees. */ float bearing; /** Represents expected accuracy in meters. */ float accuracy; /** Timestamp for the location fix. */ FlpUtcTime timestamp; /** Sources used, will be Bitwise OR of the FLP_TECH_MASK bits. */ uint32_t sources_used; } FlpLocation; typedef enum { ASSOCIATE_JVM, DISASSOCIATE_JVM, } ThreadEvent; /** * Callback with location information. * Can only be called from a thread associated to JVM using set_thread_event_cb. * Parameters: * num_locations is the number of batched locations available. * location is the pointer to an array of pointers to location objects. */ typedef void (*flp_location_callback)(int32_t num_locations, FlpLocation** location); /** * Callback utility for acquiring a wakelock. * This can be used to prevent the CPU from suspending while handling FLP events. */ typedef void (*flp_acquire_wakelock)(); /** * Callback utility for releasing the FLP wakelock. */ typedef void (*flp_release_wakelock)(); /** * Callback for associating a thread that can call into the Java framework code. * This must be used to initialize any threads that report events up to the framework. * Return value: * FLP_RESULT_SUCCESS on success. * FLP_RESULT_ERROR if the association failed in the current thread. */ typedef int (*flp_set_thread_event)(ThreadEvent event); /** * Callback for technologies supported by this implementation. * * Parameters: capabilities is a bitmask of FLP_CAPABILITY_* values describing * which features your implementation supports. You should support * CAPABILITY_GNSS at a minimum for your implementation to be utilized. You can * return 0 in FlpGeofenceCallbacks to indicate you don't support geofencing, * or 0 in FlpCallbacks to indicate you don't support location batching. */ typedef void (*flp_capabilities_callback)(int capabilities); /** * Callback with status information on the ability to compute location. * To avoid waking up the application processor you should only send * changes in status (you shouldn't call this method twice in a row * with the same status value). As a guideline you should not call this * more frequently then the requested batch period set with period_ns * in FlpBatchOptions. For example if period_ns is set to 5 minutes and * the status changes many times in that interval, you should only report * one status change every 5 minutes. * * Parameters: * status is one of FLP_STATUS_LOCATION_AVAILABLE * or FLP_STATUS_LOCATION_UNAVAILABLE. */ typedef void (*flp_status_callback)(int32_t status); /** FLP callback structure. */ typedef struct { /** set to sizeof(FlpCallbacks) */ size_t size; flp_location_callback location_cb; flp_acquire_wakelock acquire_wakelock_cb; flp_release_wakelock release_wakelock_cb; flp_set_thread_event set_thread_event_cb; flp_capabilities_callback flp_capabilities_cb; flp_status_callback flp_status_cb; } FlpCallbacks; /** Options with the batching FLP APIs */ typedef struct { /** * Maximum power in mW that the underlying implementation * can use for this batching call. * If max_power_allocation_mW is 0, only fixes that are generated * at no additional cost of power shall be reported. */ double max_power_allocation_mW; /** Bitwise OR of the FLP_TECH_MASKS to use */ uint32_t sources_to_use; /** * FLP_BATCH_WAKEUP_ON_FIFO_FULL - If set the hardware * will wake up the AP when the buffer is full. If not set, the * hardware will drop the oldest location object. * * FLP_BATCH_CALLBACK_ON_LOCATION_FIX - If set the location * callback will be called every time there is a location fix. * Its the responsibility of the upper layers (caller) to switch * it off, if it knows that the AP might go to sleep. When this * bit is on amidst a batching session, batching should continue * while location fixes are reported in real time. * * Other flags to be bitwised ORed in the future. */ uint32_t flags; /** * Frequency with which location needs to be batched in nano * seconds. */ int64_t period_ns; /** * The smallest displacement between reported locations in meters. * * If set to 0, then you should report locations at the requested * interval even if the device is stationary. If positive, you * can use this parameter as a hint to save power (e.g. throttling * location period if the user hasn't traveled close to the displacement * threshold). Even small positive values can be interpreted to mean * that you don't have to compute location when the device is stationary. * * There is no need to filter location delivery based on this parameter. * Locations can be delivered even if they have a displacement smaller than * requested. This parameter can safely be ignored at the cost of potential * power savings. */ float smallest_displacement_meters; } FlpBatchOptions; #define FLP_RESULT_SUCCESS 0 #define FLP_RESULT_ERROR -1 #define FLP_RESULT_INSUFFICIENT_MEMORY -2 #define FLP_RESULT_TOO_MANY_GEOFENCES -3 #define FLP_RESULT_ID_EXISTS -4 #define FLP_RESULT_ID_UNKNOWN -5 #define FLP_RESULT_INVALID_GEOFENCE_TRANSITION -6 /** * Represents the standard FLP interface. */ typedef struct { /** * set to sizeof(FlpLocationInterface) */ size_t size; /** * Opens the interface and provides the callback routines * to the implementation of this interface. Once called you should respond * by calling the flp_capabilities_callback in FlpCallbacks to * specify the capabilities that your implementation supports. */ int (*init)(FlpCallbacks* callbacks ); /** * Return the batch size (in number of FlpLocation objects) * available in the hardware. Note, different HW implementations * may have different sample sizes. This shall return number * of samples defined in the format of FlpLocation. * This will be used by the upper layer, to decide on the batching * interval and whether the AP should be woken up or not. */ int (*get_batch_size)(); /** * Start batching locations. This API is primarily used when the AP is * asleep and the device can batch locations in the hardware. * flp_location_callback is used to return the locations. When the buffer * is full and FLP_BATCH_WAKEUP_ON_FIFO_FULL is used, the AP is woken up. * When the buffer is full and FLP_BATCH_WAKEUP_ON_FIFO_FULL is not set, * the oldest location object is dropped. In this case the AP will not be * woken up. The upper layer will use get_batched_location * API to explicitly ask for the location. * If FLP_BATCH_CALLBACK_ON_LOCATION_FIX is set, the implementation * will call the flp_location_callback every single time there is a location * fix. This overrides FLP_BATCH_WAKEUP_ON_FIFO_FULL flag setting. * It's the responsibility of the upper layers (caller) to switch * it off, if it knows that the AP might go to sleep. This is useful * for nagivational applications when the system is in high power mode. * Parameters: * id - Id for the request. * options - See FlpBatchOptions struct definition. * Return value: * FLP_RESULT_SUCCESS on success, FLP_RESULT_INSUFFICIENT_MEMORY, * FLP_RESULT_ID_EXISTS, FLP_RESULT_ERROR on failure. */ int (*start_batching)(int id, FlpBatchOptions* options); /** * Update FlpBatchOptions associated with a batching request. * When a batching operation is in progress and a batching option * such as FLP_BATCH_WAKEUP_ON_FIFO_FULL needs to be updated, this API * will be used. For instance, this can happen when the AP is awake and * the maps application is being used. * Parameters: * id - Id of an existing batch request. * new_options - Updated FlpBatchOptions * Return value: * FLP_RESULT_SUCCESS on success, FLP_RESULT_ID_UNKNOWN, * FLP_RESULT_ERROR on error. */ int (*update_batching_options)(int id, FlpBatchOptions* new_options); /** * Stop batching. * Parameters: * id - Id for the request. * Return Value: * FLP_RESULT_SUCCESS on success, FLP_RESULT_ID_UNKNOWN or * FLP_RESULT_ERROR on failure. */ int (*stop_batching)(int id); /** * Closes the interface. If any batch operations are in progress, * they should be stopped. */ void (*cleanup)(); /** * Get the fused location that was batched. * flp_location_callback is used to return the location. The location object * is dropped from the buffer only when the buffer is full. Do not remove it * from the buffer just because it has been returned using the callback. * In other words, when there is no new location object, two calls to * get_batched_location(1) should return the same location object. * Parameters: * last_n_locations - Number of locations to get. This can be one or many. * If the last_n_locations is 1, you get the latest location known to the * hardware. */ void (*get_batched_location)(int last_n_locations); /** * Injects current location from another location provider * latitude and longitude are measured in degrees * expected accuracy is measured in meters * Parameters: * location - The location object being injected. * Return value: FLP_RESULT_SUCCESS or FLP_RESULT_ERROR. */ int (*inject_location)(FlpLocation* location); /** * Get a pointer to extension information. */ const void* (*get_extension)(const char* name); /** * Retrieve all batched locations currently stored and clear the buffer. * flp_location_callback MUST be called in response, even if there are * no locations to flush (in which case num_locations should be 0). * Subsequent calls to get_batched_location or flush_batched_locations * should not return any of the locations returned in this call. */ void (*flush_batched_locations)(); } FlpLocationInterface; struct flp_device_t { struct hw_device_t common; /** * Get a handle to the FLP Interface. */ const FlpLocationInterface* (*get_flp_interface)(struct flp_device_t* dev); }; /** * Callback for reports diagnostic data into the Java framework code. */ typedef void (*report_data)(char* data, int length); /** * FLP diagnostic callback structure. * Currently, not used - but this for future extension. */ typedef struct { /** set to sizeof(FlpDiagnosticCallbacks) */ size_t size; flp_set_thread_event set_thread_event_cb; /** reports diagnostic data into the Java framework code */ report_data data_cb; } FlpDiagnosticCallbacks; /** Extended interface for diagnostic support. */ typedef struct { /** set to sizeof(FlpDiagnosticInterface) */ size_t size; /** * Opens the diagnostic interface and provides the callback routines * to the implemenation of this interface. */ void (*init)(FlpDiagnosticCallbacks* callbacks); /** * Injects diagnostic data into the FLP subsystem. * Return 0 on success, -1 on error. **/ int (*inject_data)(char* data, int length ); } FlpDiagnosticInterface; /** * Context setting information. * All these settings shall be injected to FLP HAL at FLP init time. * Following that, only the changed setting need to be re-injected * upon changes. */ #define FLP_DEVICE_CONTEXT_GPS_ENABLED (1U<<0) #define FLP_DEVICE_CONTEXT_AGPS_ENABLED (1U<<1) #define FLP_DEVICE_CONTEXT_NETWORK_POSITIONING_ENABLED (1U<<2) #define FLP_DEVICE_CONTEXT_WIFI_CONNECTIVITY_ENABLED (1U<<3) #define FLP_DEVICE_CONTEXT_WIFI_POSITIONING_ENABLED (1U<<4) #define FLP_DEVICE_CONTEXT_HW_NETWORK_POSITIONING_ENABLED (1U<<5) #define FLP_DEVICE_CONTEXT_AIRPLANE_MODE_ON (1U<<6) #define FLP_DEVICE_CONTEXT_DATA_ENABLED (1U<<7) #define FLP_DEVICE_CONTEXT_ROAMING_ENABLED (1U<<8) #define FLP_DEVICE_CONTEXT_CURRENTLY_ROAMING (1U<<9) #define FLP_DEVICE_CONTEXT_SENSOR_ENABLED (1U<<10) #define FLP_DEVICE_CONTEXT_BLUETOOTH_ENABLED (1U<<11) #define FLP_DEVICE_CONTEXT_CHARGER_ON (1U<<12) /** Extended interface for device context support. */ typedef struct { /** set to sizeof(FlpDeviceContextInterface) */ size_t size; /** * Injects debug data into the FLP subsystem. * Return 0 on success, -1 on error. **/ int (*inject_device_context)(uint32_t enabledMask); } FlpDeviceContextInterface; /** * There are 3 states associated with a Geofence: Inside, Outside, Unknown. * There are 3 transitions: ENTERED, EXITED, UNCERTAIN. * * An example state diagram with confidence level: 95% and Unknown time limit * set as 30 secs is shown below. (confidence level and Unknown time limit are * explained latter) * ____________________________ * | Unknown (30 secs) | * """""""""""""""""""""""""""" * ^ | | ^ * UNCERTAIN| |ENTERED EXITED| |UNCERTAIN * | v v | * ________ EXITED _________ * | Inside | -----------> | Outside | * | | <----------- | | * """""""" ENTERED """"""""" * * Inside state: We are 95% confident that the user is inside the geofence. * Outside state: We are 95% confident that the user is outside the geofence * Unknown state: Rest of the time. * * The Unknown state is better explained with an example: * * __________ * | c| * | ___ | _______ * | |a| | | b | * | """ | """"""" * | | * """""""""" * In the diagram above, "a" and "b" are 2 geofences and "c" is the accuracy * circle reported by the FLP subsystem. Now with regard to "b", the system is * confident that the user is outside. But with regard to "a" is not confident * whether it is inside or outside the geofence. If the accuracy remains the * same for a sufficient period of time, the UNCERTAIN transition would be * triggered with the state set to Unknown. If the accuracy improves later, an * appropriate transition should be triggered. This "sufficient period of time" * is defined by the parameter in the add_geofence_area API. * In other words, Unknown state can be interpreted as a state in which the * FLP subsystem isn't confident enough that the user is either inside or * outside the Geofence. It moves to Unknown state only after the expiry of the * timeout. * * The geofence callback needs to be triggered for the ENTERED and EXITED * transitions, when the FLP system is confident that the user has entered * (Inside state) or exited (Outside state) the Geofence. An implementation * which uses a value of 95% as the confidence is recommended. The callback * should be triggered only for the transitions requested by the * add_geofence_area call. * * Even though the diagram and explanation talks about states and transitions, * the callee is only interested in the transistions. The states are mentioned * here for illustrative purposes. * * Startup Scenario: When the device boots up, if an application adds geofences, * and then we get an accurate FLP location fix, it needs to trigger the * appropriate (ENTERED or EXITED) transition for every Geofence it knows about. * By default, all the Geofences will be in the Unknown state. * * When the FLP system is unavailable, flp_geofence_status_callback should be * called to inform the upper layers of the same. Similarly, when it becomes * available the callback should be called. This is a global state while the * UNKNOWN transition described above is per geofence. * */ #define FLP_GEOFENCE_TRANSITION_ENTERED (1L<<0) #define FLP_GEOFENCE_TRANSITION_EXITED (1L<<1) #define FLP_GEOFENCE_TRANSITION_UNCERTAIN (1L<<2) #define FLP_GEOFENCE_MONITOR_STATUS_UNAVAILABLE (1L<<0) #define FLP_GEOFENCE_MONITOR_STATUS_AVAILABLE (1L<<1) /** * The callback associated with the geofence. * Parameters: * geofence_id - The id associated with the add_geofence_area. * location - The current location as determined by the FLP subsystem. * transition - Can be one of FLP_GEOFENCE_TRANSITION_ENTERED, FLP_GEOFENCE_TRANSITION_EXITED, * FLP_GEOFENCE_TRANSITION_UNCERTAIN. * timestamp - Timestamp when the transition was detected; -1 if not available. * sources_used - Bitwise OR of FLP_TECH_MASK flags indicating which * subsystems were used. * * The callback should only be called when the caller is interested in that * particular transition. For instance, if the caller is interested only in * ENTERED transition, then the callback should NOT be called with the EXITED * transition. * * IMPORTANT: If a transition is triggered resulting in this callback, the * subsystem will wake up the application processor, if its in suspend state. */ typedef void (*flp_geofence_transition_callback) (int32_t geofence_id, FlpLocation* location, int32_t transition, FlpUtcTime timestamp, uint32_t sources_used); /** * The callback associated with the availablity of one the sources used for geofence * monitoring by the FLP sub-system For example, if the GPS system determines that it cannot * monitor geofences because of lack of reliability or unavailability of the GPS signals, * it will call this callback with FLP_GEOFENCE_MONITOR_STATUS_UNAVAILABLE parameter and the * source set to FLP_TECH_MASK_GNSS. * * Parameters: * status - FLP_GEOFENCE_MONITOR_STATUS_UNAVAILABLE or FLP_GEOFENCE_MONITOR_STATUS_AVAILABLE. * source - One of the FLP_TECH_MASKS * last_location - Last known location. */ typedef void (*flp_geofence_monitor_status_callback) (int32_t status, uint32_t source, FlpLocation* last_location); /** * The callback associated with the add_geofence call. * * Parameter: * geofence_id - Id of the geofence. * result - FLP_RESULT_SUCCESS * FLP_RESULT_ERROR_TOO_MANY_GEOFENCES - geofence limit has been reached. * FLP_RESULT_ID_EXISTS - geofence with id already exists * FLP_RESULT_INVALID_GEOFENCE_TRANSITION - the monitorTransition contains an * invalid transition * FLP_RESULT_ERROR - for other errors. */ typedef void (*flp_geofence_add_callback) (int32_t geofence_id, int32_t result); /** * The callback associated with the remove_geofence call. * * Parameter: * geofence_id - Id of the geofence. * result - FLP_RESULT_SUCCESS * FLP_RESULT_ID_UNKNOWN - for invalid id * FLP_RESULT_ERROR for others. */ typedef void (*flp_geofence_remove_callback) (int32_t geofence_id, int32_t result); /** * The callback associated with the pause_geofence call. * * Parameter: * geofence_id - Id of the geofence. * result - FLP_RESULT_SUCCESS * FLP_RESULT__ID_UNKNOWN - for invalid id * FLP_RESULT_INVALID_TRANSITION - * when monitor_transitions is invalid * FLP_RESULT_ERROR for others. */ typedef void (*flp_geofence_pause_callback) (int32_t geofence_id, int32_t result); /** * The callback associated with the resume_geofence call. * * Parameter: * geofence_id - Id of the geofence. * result - FLP_RESULT_SUCCESS * FLP_RESULT_ID_UNKNOWN - for invalid id * FLP_RESULT_ERROR for others. */ typedef void (*flp_geofence_resume_callback) (int32_t geofence_id, int32_t result); typedef struct { /** set to sizeof(FlpGeofenceCallbacks) */ size_t size; flp_geofence_transition_callback geofence_transition_callback; flp_geofence_monitor_status_callback geofence_status_callback; flp_geofence_add_callback geofence_add_callback; flp_geofence_remove_callback geofence_remove_callback; flp_geofence_pause_callback geofence_pause_callback; flp_geofence_resume_callback geofence_resume_callback; flp_set_thread_event set_thread_event_cb; flp_capabilities_callback flp_capabilities_cb; } FlpGeofenceCallbacks; /** Type of geofence */ typedef enum { TYPE_CIRCLE = 0, } GeofenceType; /** Circular geofence is represented by lat / long / radius */ typedef struct { double latitude; double longitude; double radius_m; } GeofenceCircle; /** Represents the type of geofence and data */ typedef struct { GeofenceType type; union { GeofenceCircle circle; } geofence; } GeofenceData; /** Geofence Options */ typedef struct { /** * The current state of the geofence. For example, if * the system already knows that the user is inside the geofence, * this will be set to FLP_GEOFENCE_TRANSITION_ENTERED. In most cases, it * will be FLP_GEOFENCE_TRANSITION_UNCERTAIN. */ int last_transition; /** * Transitions to monitor. Bitwise OR of * FLP_GEOFENCE_TRANSITION_ENTERED, FLP_GEOFENCE_TRANSITION_EXITED and * FLP_GEOFENCE_TRANSITION_UNCERTAIN. */ int monitor_transitions; /** * Defines the best-effort description * of how soon should the callback be called when the transition * associated with the Geofence is triggered. For instance, if set * to 1000 millseconds with FLP_GEOFENCE_TRANSITION_ENTERED, the callback * should be called 1000 milliseconds within entering the geofence. * This parameter is defined in milliseconds. * NOTE: This is not to be confused with the rate that the GPS is * polled at. It is acceptable to dynamically vary the rate of * sampling the GPS for power-saving reasons; thus the rate of * sampling may be faster or slower than this. */ int notification_responsivenes_ms; /** * The time limit after which the UNCERTAIN transition * should be triggered. This paramter is defined in milliseconds. */ int unknown_timer_ms; /** * The sources to use for monitoring geofences. Its a BITWISE-OR * of FLP_TECH_MASK flags. */ uint32_t sources_to_use; } GeofenceOptions; /** Geofence struct */ typedef struct { int32_t geofence_id; GeofenceData* data; GeofenceOptions* options; } Geofence; /** Extended interface for FLP_Geofencing support */ typedef struct { /** set to sizeof(FlpGeofencingInterface) */ size_t size; /** * Opens the geofence interface and provides the callback routines * to the implemenation of this interface. Once called you should respond * by calling the flp_capabilities_callback in FlpGeofenceCallbacks to * specify the capabilities that your implementation supports. */ void (*init)( FlpGeofenceCallbacks* callbacks ); /** * Add a list of geofences. * Parameters: * number_of_geofences - The number of geofences that needed to be added. * geofences - Pointer to array of pointers to Geofence structure. */ void (*add_geofences) (int32_t number_of_geofences, Geofence** geofences); /** * Pause monitoring a particular geofence. * Parameters: * geofence_id - The id for the geofence. */ void (*pause_geofence) (int32_t geofence_id); /** * Resume monitoring a particular geofence. * Parameters: * geofence_id - The id for the geofence. * monitor_transitions - Which transitions to monitor. Bitwise OR of * FLP_GEOFENCE_TRANSITION_ENTERED, FLP_GEOFENCE_TRANSITION_EXITED and * FLP_GEOFENCE_TRANSITION_UNCERTAIN. * This supersedes the value associated provided in the * add_geofence_area call. */ void (*resume_geofence) (int32_t geofence_id, int monitor_transitions); /** * Modify a particular geofence option. * Parameters: * geofence_id - The id for the geofence. * options - Various options associated with the geofence. See * GeofenceOptions structure for details. */ void (*modify_geofence_option) (int32_t geofence_id, GeofenceOptions* options); /** * Remove a list of geofences. After the function returns, no notifications * should be sent. * Parameter: * number_of_geofences - The number of geofences that needed to be added. * geofence_id - Pointer to array of geofence_ids to be removed. */ void (*remove_geofences) (int32_t number_of_geofences, int32_t* geofence_id); } FlpGeofencingInterface; __END_DECLS #endif /* ANDROID_INCLUDE_HARDWARE_FLP_H */ android-headers-23/23/hardware/gatekeeper.h000066400000000000000000000175131264465411000206510ustar00rootroot00000000000000/* * 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_HARDWARE_GATEKEEPER_H #define ANDROID_HARDWARE_GATEKEEPER_H #include #include #include __BEGIN_DECLS #define GATEKEEPER_HARDWARE_MODULE_ID "gatekeeper" #define GATEKEEPER_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define HARDWARE_GATEKEEPER "gatekeeper" struct gatekeeper_module { /** * Comon methods of the gatekeeper module. This *must* be the first member of * gatekeeper_module as users of this structure will cast a hw_module_t to * a gatekeeper_module pointer in the appropriate context. */ hw_module_t common; }; struct gatekeeper_device { /** * Common methods of the gatekeeper device. As above, this must be the first * member of keymaster_device. */ hw_device_t common; /** * Enrolls desired_password, which should be derived from a user selected pin or password, * with the authentication factor private key used only for enrolling authentication * factor data. * * If there was already a password enrolled, it should be provided in * current_password_handle, along with the current password in current_password * that should validate against current_password_handle. * * Parameters: * - dev: pointer to gatekeeper_device acquired via calls to gatekeeper_open * - uid: the Android user identifier * * - current_password_handle: the currently enrolled password handle the user * wants to replace. May be null if there's no currently enrolled password. * - current_password_handle_length: the length in bytes of the buffer pointed * at by current_password_handle. Must be 0 if current_password_handle is NULL. * * - current_password: the user's current password in plain text. If presented, * it MUST verify against current_password_handle. * - current_password_length: the size in bytes of the buffer pointed at by * current_password. Must be 0 if the current_password is NULL. * * - desired_password: the new password the user wishes to enroll in plain-text. * Cannot be NULL. * - desired_password_length: the length in bytes of the buffer pointed at by * desired_password. * * - enrolled_password_handle: on success, a buffer will be allocated with the * new password handle referencing the password provided in desired_password. * This buffer can be used on subsequent calls to enroll or verify. * The caller is responsible for deallocating this buffer via a call to delete[] * - enrolled_password_handle_length: pointer to the length in bytes of the buffer allocated * by this function and pointed to by *enrolled_password_handle_length. * * Returns: * - 0 on success * - An error code < 0 on failure, or * - A timeout value T > 0 if the call should not be re-attempted until T milliseconds * have elapsed. * * On error, enrolled_password_handle will not be allocated. */ int (*enroll)(const struct gatekeeper_device *dev, uint32_t uid, const uint8_t *current_password_handle, uint32_t current_password_handle_length, const uint8_t *current_password, uint32_t current_password_length, const uint8_t *desired_password, uint32_t desired_password_length, uint8_t **enrolled_password_handle, uint32_t *enrolled_password_handle_length); /** * Verifies provided_password matches enrolled_password_handle. * * Implementations of this module may retain the result of this call * to attest to the recency of authentication. * * On success, writes the address of a verification token to auth_token, * usable to attest password verification to other trusted services. Clients * may pass NULL for this value. * * Parameters: * - dev: pointer to gatekeeper_device acquired via calls to gatekeeper_open * - uid: the Android user identifier * * - challenge: An optional challenge to authenticate against, or 0. Used when a separate * authenticator requests password verification, or for transactional * password authentication. * * - enrolled_password_handle: the currently enrolled password handle that the * user wishes to verify against. * - enrolled_password_handle_length: the length in bytes of the buffer pointed * to by enrolled_password_handle * * - provided_password: the plaintext password to be verified against the * enrolled_password_handle * - provided_password_length: the length in bytes of the buffer pointed to by * provided_password * * - auth_token: on success, a buffer containing the authentication token * resulting from this verification is assigned to *auth_token. The caller * is responsible for deallocating this memory via a call to delete[] * - auth_token_length: on success, the length in bytes of the authentication * token assigned to *auth_token will be assigned to *auth_token_length * * - request_reenroll: a request to the upper layers to re-enroll the verified * password due to a version change. Not set if verification fails. * * Returns: * - 0 on success * - An error code < 0 on failure, or * - A timeout value T > 0 if the call should not be re-attempted until T milliseconds * have elapsed. * On error, auth token will not be allocated */ int (*verify)(const struct gatekeeper_device *dev, uint32_t uid, uint64_t challenge, const uint8_t *enrolled_password_handle, uint32_t enrolled_password_handle_length, const uint8_t *provided_password, uint32_t provided_password_length, uint8_t **auth_token, uint32_t *auth_token_length, bool *request_reenroll); /* * Deletes the enrolled_password_handle associated wth the uid. Once deleted * the user cannot be verified anymore. * This function is optional and should be set to NULL if it is not implemented. * * Parameters * - dev: pointer to gatekeeper_device acquired via calls to gatekeeper_open * - uid: the Android user identifier * * Returns: * - 0 on success * - An error code < 0 on failure */ int (*delete_user)(const struct gatekeeper_device *dev, uint32_t uid); /* * Deletes all the enrolled_password_handles for all uid's. Once called, * no users will be enrolled on the device. * This function is optional and should be set to NULL if it is not implemented. * * Parameters * - dev: pointer to gatekeeper_device acquired via calls to gatekeeper_open * * Returns: * - 0 on success * - An error code < 0 on failure */ int (*delete_all_users)(const struct gatekeeper_device *dev); }; typedef struct gatekeeper_device gatekeeper_device_t; static inline int gatekeeper_open(const struct hw_module_t *module, gatekeeper_device_t **device) { return module->methods->open(module, HARDWARE_GATEKEEPER, (struct hw_device_t **) device); } static inline int gatekeeper_close(gatekeeper_device_t *device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_HARDWARE_GATEKEEPER_H android-headers-23/23/hardware/gps.h000066400000000000000000002043741264465411000173310ustar00rootroot00000000000000/* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_HARDWARE_GPS_H #define ANDROID_INCLUDE_HARDWARE_GPS_H #include #include #include #include #include #include #include __BEGIN_DECLS /** * The id of this module */ #define GPS_HARDWARE_MODULE_ID "gps" /** Milliseconds since January 1, 1970 */ typedef int64_t GpsUtcTime; /** Maximum number of SVs for gps_sv_status_callback(). */ #define GPS_MAX_SVS 32 /** Maximum number of Measurements in gps_measurement_callback(). */ #define GPS_MAX_MEASUREMENT 32 /** 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_BASE 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 0x0000001 /** GPS supports MS-Based AGPS mode */ #define GPS_CAPABILITY_MSB 0x0000002 /** GPS supports MS-Assisted AGPS mode */ #define GPS_CAPABILITY_MSA 0x0000004 /** GPS supports single-shot fixes */ #define GPS_CAPABILITY_SINGLE_SHOT 0x0000008 /** GPS supports on demand time injection */ #define GPS_CAPABILITY_ON_DEMAND_TIME 0x0000010 /** GPS supports Geofencing */ #define GPS_CAPABILITY_GEOFENCING 0x0000020 /** GPS supports Measurements */ #define GPS_CAPABILITY_MEASUREMENTS 0x0000040 /** GPS supports Navigation Messages */ #define GPS_CAPABILITY_NAV_MESSAGES 0x0000080 /** 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 */ #define GPS_NI_SHORT_STRING_MAXLEN 256 #define GPS_NI_LONG_STRING_MAXLEN 2048 /** * 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 #define AGPS_REF_LOCATION_TYPE_GSM_CELLID 1 #define AGPS_REF_LOCATION_TYPE_UMTS_CELLID 2 #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 /** * Flags to indicate what fields in GpsClock are valid. */ typedef uint16_t GpsClockFlags; /** A valid 'leap second' is stored in the data structure. */ #define GPS_CLOCK_HAS_LEAP_SECOND (1<<0) /** A valid 'time uncertainty' is stored in the data structure. */ #define GPS_CLOCK_HAS_TIME_UNCERTAINTY (1<<1) /** A valid 'full bias' is stored in the data structure. */ #define GPS_CLOCK_HAS_FULL_BIAS (1<<2) /** A valid 'bias' is stored in the data structure. */ #define GPS_CLOCK_HAS_BIAS (1<<3) /** A valid 'bias uncertainty' is stored in the data structure. */ #define GPS_CLOCK_HAS_BIAS_UNCERTAINTY (1<<4) /** A valid 'drift' is stored in the data structure. */ #define GPS_CLOCK_HAS_DRIFT (1<<5) /** A valid 'drift uncertainty' is stored in the data structure. */ #define GPS_CLOCK_HAS_DRIFT_UNCERTAINTY (1<<6) /** * Enumeration of the available values for the GPS Clock type. */ typedef uint8_t GpsClockType; /** The type is not available ot it is unknown. */ #define GPS_CLOCK_TYPE_UNKNOWN 0 /** The source of the time value reported by GPS clock is the local hardware clock. */ #define GPS_CLOCK_TYPE_LOCAL_HW_TIME 1 /** * The source of the time value reported by GPS clock is the GPS time derived from satellites * (epoch = Jan 6, 1980) */ #define GPS_CLOCK_TYPE_GPS_TIME 2 /** * Flags to indicate what fields in GpsMeasurement are valid. */ typedef uint32_t GpsMeasurementFlags; /** A valid 'snr' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_SNR (1<<0) /** A valid 'elevation' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_ELEVATION (1<<1) /** A valid 'elevation uncertainty' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_ELEVATION_UNCERTAINTY (1<<2) /** A valid 'azimuth' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_AZIMUTH (1<<3) /** A valid 'azimuth uncertainty' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_AZIMUTH_UNCERTAINTY (1<<4) /** A valid 'pseudorange' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_PSEUDORANGE (1<<5) /** A valid 'pseudorange uncertainty' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_PSEUDORANGE_UNCERTAINTY (1<<6) /** A valid 'code phase' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_CODE_PHASE (1<<7) /** A valid 'code phase uncertainty' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_CODE_PHASE_UNCERTAINTY (1<<8) /** A valid 'carrier frequency' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_CARRIER_FREQUENCY (1<<9) /** A valid 'carrier cycles' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_CARRIER_CYCLES (1<<10) /** A valid 'carrier phase' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_CARRIER_PHASE (1<<11) /** A valid 'carrier phase uncertainty' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY (1<<12) /** A valid 'bit number' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_BIT_NUMBER (1<<13) /** A valid 'time from last bit' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_TIME_FROM_LAST_BIT (1<<14) /** A valid 'doppler shift' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_DOPPLER_SHIFT (1<<15) /** A valid 'doppler shift uncertainty' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_DOPPLER_SHIFT_UNCERTAINTY (1<<16) /** A valid 'used in fix' flag is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_USED_IN_FIX (1<<17) /** The value of 'pseudorange rate' is uncorrected. */ #define GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE (1<<18) /** * Enumeration of the available values for the GPS Measurement's loss of lock. */ typedef uint8_t GpsLossOfLock; /** The indicator is not available or it is unknown. */ #define GPS_LOSS_OF_LOCK_UNKNOWN 0 /** The measurement does not present any indication of loss of lock. */ #define GPS_LOSS_OF_LOCK_OK 1 /** Loss of lock between previous and current observation: cycle slip possible. */ #define GPS_LOSS_OF_LOCK_CYCLE_SLIP 2 /** * Enumeration of available values for the GPS Measurement's multipath indicator. */ typedef uint8_t GpsMultipathIndicator; /** The indicator is not available or unknown. */ #define GPS_MULTIPATH_INDICATOR_UNKNOWN 0 /** The measurement has been indicated to use multipath. */ #define GPS_MULTIPATH_INDICATOR_DETECTED 1 /** The measurement has been indicated Not to use multipath. */ #define GPS_MULTIPATH_INDICATOR_NOT_USED 2 /** * Flags indicating the GPS measurement state. * The expected behavior here is for GPS HAL to set all the flags that applies. For * example, if the state for a satellite is only C/A code locked and bit synchronized, * and there is still millisecond ambiguity, the state should be set as: * GPS_MEASUREMENT_STATE_CODE_LOCK|GPS_MEASUREMENT_STATE_BIT_SYNC|GPS_MEASUREMENT_STATE_MSEC_AMBIGUOUS * If GPS is still searching for a satellite, the corresponding state should be set to * GPS_MEASUREMENT_STATE_UNKNOWN(0). */ typedef uint16_t GpsMeasurementState; #define GPS_MEASUREMENT_STATE_UNKNOWN 0 #define GPS_MEASUREMENT_STATE_CODE_LOCK (1<<0) #define GPS_MEASUREMENT_STATE_BIT_SYNC (1<<1) #define GPS_MEASUREMENT_STATE_SUBFRAME_SYNC (1<<2) #define GPS_MEASUREMENT_STATE_TOW_DECODED (1<<3) #define GPS_MEASUREMENT_STATE_MSEC_AMBIGUOUS (1<<4) /** * Flags indicating the Accumulated Delta Range's states. */ typedef uint16_t GpsAccumulatedDeltaRangeState; #define GPS_ADR_STATE_UNKNOWN 0 #define GPS_ADR_STATE_VALID (1<<0) #define GPS_ADR_STATE_RESET (1<<1) #define GPS_ADR_STATE_CYCLE_SLIP (1<<2) /** * Enumeration of available values to indicate the available GPS Navigation message types. */ typedef uint8_t GpsNavigationMessageType; /** The message type is unknown. */ #define GPS_NAVIGATION_MESSAGE_TYPE_UNKNOWN 0 /** L1 C/A message contained in the structure. */ #define GPS_NAVIGATION_MESSAGE_TYPE_L1CA 1 /** L2-CNAV message contained in the structure. */ #define GPS_NAVIGATION_MESSAGE_TYPE_L2CNAV 2 /** L5-CNAV message contained in the structure. */ #define GPS_NAVIGATION_MESSAGE_TYPE_L5CNAV 3 /** CNAV-2 message contained in the structure. */ #define GPS_NAVIGATION_MESSAGE_TYPE_CNAV2 4 /** * Status of Navigation Message * When a message is received properly without any parity error in its navigation words, the * status should be set to NAV_MESSAGE_STATUS_PARITY_PASSED. But if a message is received * with words that failed parity check, but GPS is able to correct those words, the status * should be set to NAV_MESSAGE_STATUS_PARITY_REBUILT. * No need to send any navigation message that contains words with parity error and cannot be * corrected. */ typedef uint16_t NavigationMessageStatus; #define NAV_MESSAGE_STATUS_UNKONW 0 #define NAV_MESSAGE_STATUS_PARITY_PASSED (1<<0) #define NAV_MESSAGE_STATUS_PARITY_REBUILT (1<<1) /** * Name for the GPS XTRA interface. */ #define GPS_XTRA_INTERFACE "gps-xtra" /** * Name for the GPS DEBUG interface. */ #define GPS_DEBUG_INTERFACE "gps-debug" /** * Name for the AGPS interface. */ #define AGPS_INTERFACE "agps" /** * Name of the Supl Certificate interface. */ #define SUPL_CERTIFICATE_INTERFACE "supl-certificate" /** * Name for NI interface */ #define GPS_NI_INTERFACE "gps-ni" /** * Name for the AGPS-RIL interface. */ #define AGPS_RIL_INTERFACE "agps_ril" /** * Name for the GPS_Geofencing interface. */ #define GPS_GEOFENCING_INTERFACE "gps_geofencing" /** * Name of the GPS Measurements interface. */ #define GPS_MEASUREMENT_INTERFACE "gps_measurement" /** * Name of the GPS navigation message interface. */ #define GPS_NAVIGATION_MESSAGE_INTERFACE "gps_navigation_message" /** * Name of the GNSS/GPS configuration interface. */ #define GNSS_CONFIGURATION_INTERFACE "gnss_configuration" /** Represents a location. */ typedef struct { /** set to sizeof(GpsLocation) */ size_t size; /** Contains GpsLocationFlags bits. */ uint16_t flags; /** Represents latitude in degrees. */ double latitude; /** Represents longitude in degrees. */ double longitude; /** Represents altitude in meters above the WGS 84 reference * ellipsoid. */ double altitude; /** Represents speed in meters per second. */ float speed; /** Represents heading in degrees. */ float bearing; /** Represents expected accuracy in meters. */ float accuracy; /** Timestamp for the location fix. */ GpsUtcTime timestamp; } GpsLocation; /** Represents the status. */ typedef struct { /** set to sizeof(GpsStatus) */ size_t size; GpsStatusValue status; } GpsStatus; /** Represents SV information. */ typedef struct { /** set to sizeof(GpsSvInfo) */ size_t size; /** Pseudo-random number for the SV. */ int prn; /** Signal to noise ratio. */ float snr; /** Elevation of SV in degrees. */ float elevation; /** Azimuth of SV in degrees. */ float azimuth; } GpsSvInfo; /** Represents SV status. */ typedef struct { /** set to sizeof(GpsSvStatus) */ size_t size; /** Number of SVs currently visible. */ int num_svs; /** Contains an array of SV information. */ GpsSvInfo sv_list[GPS_MAX_SVS]; /** Represents a bit mask indicating which SVs * have ephemeris data. */ uint32_t ephemeris_mask; /** Represents a bit mask indicating which SVs * have almanac data. */ uint32_t almanac_mask; /** * Represents a bit mask indicating which SVs * were used for computing the most recent position fix. */ uint32_t used_in_fix_mask; } GpsSvStatus; /* 2G and 3G */ /* In 3G lac is discarded */ typedef struct { uint16_t type; uint16_t mcc; uint16_t mnc; uint16_t lac; uint32_t cid; } AGpsRefLocationCellID; typedef struct { uint8_t mac[6]; } AGpsRefLocationMac; /** Represents ref locations */ typedef struct { uint16_t type; union { AGpsRefLocationCellID cellID; AGpsRefLocationMac mac; } u; } AGpsRefLocation; /** Callback with location information. * Can only be called from a thread created by create_thread_cb. */ typedef void (* gps_location_callback)(GpsLocation* location); /** Callback with status information. * Can only be called from a thread created by create_thread_cb. */ typedef void (* gps_status_callback)(GpsStatus* status); /** * Callback with SV status information. * Can only be called from a thread created by create_thread_cb. */ typedef void (* gps_sv_status_callback)(GpsSvStatus* sv_info); /** Callback for reporting NMEA sentences. * Can only be called from a thread created by create_thread_cb. */ typedef void (* gps_nmea_callback)(GpsUtcTime timestamp, const char* nmea, int length); /** Callback to inform framework of the GPS engine's capabilities. * Capability parameter is a bit field of GPS_CAPABILITY_* flags. */ typedef void (* gps_set_capabilities)(uint32_t capabilities); /** Callback utility for acquiring the GPS wakelock. * This can be used to prevent the CPU from suspending while handling GPS events. */ typedef void (* gps_acquire_wakelock)(); /** Callback utility for releasing the GPS wakelock. */ typedef void (* gps_release_wakelock)(); /** Callback for requesting NTP time */ typedef void (* gps_request_utc_time)(); /** Callback for creating a thread that can call into the Java framework code. * This must be used to create any threads that report events up to the framework. */ typedef pthread_t (* gps_create_thread)(const char* name, void (*start)(void *), void* arg); /** GPS callback structure. */ typedef struct { /** set to sizeof(GpsCallbacks) */ size_t size; gps_location_callback location_cb; gps_status_callback status_cb; gps_sv_status_callback sv_status_cb; gps_nmea_callback nmea_cb; gps_set_capabilities set_capabilities_cb; gps_acquire_wakelock acquire_wakelock_cb; gps_release_wakelock release_wakelock_cb; gps_create_thread create_thread_cb; gps_request_utc_time request_utc_time_cb; } GpsCallbacks; /** Represents the standard GPS interface. */ typedef struct { /** set to sizeof(GpsInterface) */ size_t size; /** * Opens the interface and provides the callback routines * to the implementation of this interface. */ int (*init)( GpsCallbacks* callbacks ); /** Starts navigating. */ int (*start)( void ); /** Stops navigating. */ int (*stop)( void ); /** Closes the interface. */ void (*cleanup)( void ); /** Injects the current time. */ int (*inject_time)(GpsUtcTime time, int64_t timeReference, int uncertainty); /** Injects current location from another location provider * (typically cell ID). * latitude and longitude are measured in degrees * expected accuracy is measured in meters */ int (*inject_location)(double latitude, double longitude, float accuracy); /** * Specifies that the next call to start will not use the * information defined in the flags. GPS_DELETE_ALL is passed for * a cold start. */ void (*delete_aiding_data)(GpsAidingData flags); /** * min_interval represents the time between fixes in milliseconds. * preferred_accuracy represents the requested fix accuracy in meters. * preferred_time represents the requested time to first fix in milliseconds. * * 'mode' parameter should be one of GPS_POSITION_MODE_MS_BASE * or GPS_POSITION_MODE_STANDALONE. * It is allowed by the platform (and it is recommended) to fallback to * GPS_POSITION_MODE_MS_BASE if GPS_POSITION_MODE_MS_ASSISTED is passed in, and * GPS_POSITION_MODE_MS_BASED is supported. */ int (*set_position_mode)(GpsPositionMode mode, GpsPositionRecurrence recurrence, uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time); /** Get a pointer to extension information. */ const void* (*get_extension)(const char* name); } GpsInterface; /** Callback to request the client to download XTRA data. * The client should download XTRA data and inject it by calling inject_xtra_data(). * Can only be called from a thread created by create_thread_cb. */ typedef void (* gps_xtra_download_request)(); /** Callback structure for the XTRA interface. */ typedef struct { gps_xtra_download_request download_request_cb; gps_create_thread create_thread_cb; } GpsXtraCallbacks; /** Extended interface for XTRA support. */ typedef struct { /** set to sizeof(GpsXtraInterface) */ size_t size; /** * Opens the XTRA interface and provides the callback routines * to the implementation of this interface. */ int (*init)( GpsXtraCallbacks* callbacks ); /** Injects XTRA data into the GPS. */ int (*inject_xtra_data)( char* data, int length ); } GpsXtraInterface; /** Extended interface for DEBUG support. */ typedef struct { /** set to sizeof(GpsDebugInterface) */ size_t size; /** * This function should return any information that the native * implementation wishes to include in a bugreport. */ size_t (*get_internal_state)(char* buffer, size_t bufferSize); } GpsDebugInterface; #pragma pack(push,4) // We need to keep the alignment of this data structure to 4-bytes, to ensure that in 64-bit // environments the size of this legacy definition does not collide with _v2. Implementations should // be using _v2 and _v3, so it's OK to pay the 'unaligned' penalty in 64-bit if an old // implementation is still in use. /** Represents the status of AGPS. */ typedef struct { /** set to sizeof(AGpsStatus_v1) */ size_t size; AGpsType type; AGpsStatusValue status; } AGpsStatus_v1; #pragma pack(pop) /** Represents the status of AGPS augmented with a IPv4 address field. */ typedef struct { /** set to sizeof(AGpsStatus_v2) */ size_t size; AGpsType type; AGpsStatusValue status; uint32_t ipaddr; } AGpsStatus_v2; /* Represents the status of AGPS augmented to support IPv4 and IPv6. */ typedef struct { /** set to sizeof(AGpsStatus_v3) */ size_t size; AGpsType type; AGpsStatusValue status; /** * Must be set to a valid IPv4 address if the field 'addr' contains an IPv4 * address, or set to INADDR_NONE otherwise. */ uint32_t ipaddr; /** * Must contain the IPv4 (AF_INET) or IPv6 (AF_INET6) address to report. * Any other value of addr.ss_family will be rejected. * */ struct sockaddr_storage addr; } AGpsStatus_v3; typedef AGpsStatus_v3 AGpsStatus; /** Callback with AGPS status information. * Can only be called from a thread created by create_thread_cb. */ typedef void (* agps_status_callback)(AGpsStatus* status); /** Callback structure for the AGPS interface. */ typedef struct { agps_status_callback status_cb; gps_create_thread create_thread_cb; } AGpsCallbacks; /** Extended interface for AGPS support. */ typedef struct { /** set to sizeof(AGpsInterface_v1) */ size_t size; /** * Opens the AGPS interface and provides the callback routines * to the implementation of this interface. */ void (*init)( AGpsCallbacks* callbacks ); /** * Notifies that a data connection is available and sets * the name of the APN to be used for SUPL. */ int (*data_conn_open)( const char* apn ); /** * Notifies that the AGPS data connection has been closed. */ int (*data_conn_closed)(); /** * Notifies that a data connection is not available for AGPS. */ int (*data_conn_failed)(); /** * Sets the hostname and port for the AGPS server. */ int (*set_server)( AGpsType type, const char* hostname, int port ); } AGpsInterface_v1; /** * Extended interface for AGPS support, it is augmented to enable to pass * extra APN data. */ typedef struct { /** set to sizeof(AGpsInterface_v2) */ size_t size; /** * Opens the AGPS interface and provides the callback routines to the * implementation of this interface. */ void (*init)(AGpsCallbacks* callbacks); /** * Deprecated. * If the HAL supports AGpsInterface_v2 this API will not be used, see * data_conn_open_with_apn_ip_type for more information. */ int (*data_conn_open)(const char* apn); /** * Notifies that the AGPS data connection has been closed. */ int (*data_conn_closed)(); /** * Notifies that a data connection is not available for AGPS. */ int (*data_conn_failed)(); /** * Sets the hostname and port for the AGPS server. */ int (*set_server)(AGpsType type, const char* hostname, int port); /** * Notifies that a data connection is available and sets the name of the * APN, and its IP type, to be used for SUPL connections. */ int (*data_conn_open_with_apn_ip_type)( const char* apn, ApnIpType apnIpType); } AGpsInterface_v2; typedef AGpsInterface_v2 AGpsInterface; /** Error codes associated with certificate operations */ #define AGPS_CERTIFICATE_OPERATION_SUCCESS 0 #define AGPS_CERTIFICATE_ERROR_GENERIC -100 #define AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES -101 /** A data structure that represents an X.509 certificate using DER encoding */ typedef struct { size_t length; u_char* data; } DerEncodedCertificate; /** * A type definition for SHA1 Fingerprints used to identify X.509 Certificates * The Fingerprint is a digest of the DER Certificate that uniquely identifies it. */ typedef struct { u_char data[20]; } Sha1CertificateFingerprint; /** AGPS Interface to handle SUPL certificate operations */ typedef struct { /** set to sizeof(SuplCertificateInterface) */ size_t size; /** * Installs a set of Certificates used for SUPL connections to the AGPS server. * If needed the HAL should find out internally any certificates that need to be removed to * accommodate the certificates to install. * The certificates installed represent a full set of valid certificates needed to connect to * AGPS SUPL servers. * The list of certificates is required, and all must be available at the same time, when trying * to establish a connection with the AGPS Server. * * Parameters: * certificates - A pointer to an array of DER encoded certificates that are need to be * installed in the HAL. * length - The number of certificates to install. * Returns: * AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully * AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES if the HAL cannot store the number of * certificates attempted to be installed, the state of the certificates stored should * remain the same as before on this error case. * * IMPORTANT: * If needed the HAL should find out internally the set of certificates that need to be * removed to accommodate the certificates to install. */ int (*install_certificates) ( const DerEncodedCertificate* certificates, size_t length ); /** * Notifies the HAL that a list of certificates used for SUPL connections are revoked. It is * expected that the given set of certificates is removed from the internal store of the HAL. * * Parameters: * fingerprints - A pointer to an array of SHA1 Fingerprints to identify the set of * certificates to revoke. * length - The number of fingerprints provided. * Returns: * AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully. * * IMPORTANT: * If any of the certificates provided (through its fingerprint) is not known by the HAL, * it should be ignored and continue revoking/deleting the rest of them. */ int (*revoke_certificates) ( const Sha1CertificateFingerprint* fingerprints, size_t length ); } SuplCertificateInterface; /** Represents an NI request */ typedef struct { /** set to sizeof(GpsNiNotification) */ size_t size; /** * An ID generated by HAL to associate NI notifications and UI * responses */ int notification_id; /** * An NI type used to distinguish different categories of NI * events, such as GPS_NI_TYPE_VOICE, GPS_NI_TYPE_UMTS_SUPL, ... */ GpsNiType ni_type; /** * Notification/verification options, combinations of GpsNiNotifyFlags constants */ GpsNiNotifyFlags notify_flags; /** * Timeout period to wait for user response. * Set to 0 for no time out limit. */ int timeout; /** * Default response when time out. */ GpsUserResponseType default_response; /** * Requestor ID */ char requestor_id[GPS_NI_SHORT_STRING_MAXLEN]; /** * Notification message. It can also be used to store client_id in some cases */ char text[GPS_NI_LONG_STRING_MAXLEN]; /** * Client name decoding scheme */ GpsNiEncodingType requestor_id_encoding; /** * Client name decoding scheme */ GpsNiEncodingType text_encoding; /** * A pointer to extra data. Format: * key_1 = value_1 * key_2 = value_2 */ char extras[GPS_NI_LONG_STRING_MAXLEN]; } GpsNiNotification; /** Callback with NI notification. * Can only be called from a thread created by create_thread_cb. */ typedef void (*gps_ni_notify_callback)(GpsNiNotification *notification); /** GPS NI callback structure. */ typedef struct { /** * Sends the notification request from HAL to GPSLocationProvider. */ gps_ni_notify_callback notify_cb; gps_create_thread create_thread_cb; } GpsNiCallbacks; /** * Extended interface for Network-initiated (NI) support. */ typedef struct { /** set to sizeof(GpsNiInterface) */ size_t size; /** Registers the callbacks for HAL to use. */ void (*init) (GpsNiCallbacks *callbacks); /** Sends a response to HAL. */ void (*respond) (int notif_id, GpsUserResponseType user_response); } GpsNiInterface; struct gps_device_t { struct hw_device_t common; /** * Set the provided lights to the provided values. * * Returns: 0 on succes, error code on failure. */ 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) typedef void (*agps_ril_request_set_id)(uint32_t flags); typedef void (*agps_ril_request_ref_loc)(uint32_t flags); typedef struct { agps_ril_request_set_id request_setid; agps_ril_request_ref_loc request_refloc; gps_create_thread create_thread_cb; } AGpsRilCallbacks; /** Extended interface for AGPS_RIL support. */ typedef struct { /** set to sizeof(AGpsRilInterface) */ size_t size; /** * Opens the AGPS interface and provides the callback routines * to the implementation of this interface. */ void (*init)( AGpsRilCallbacks* callbacks ); /** * Sets the reference location. */ void (*set_ref_location) (const AGpsRefLocation *agps_reflocation, size_t sz_struct); /** * Sets the set ID. */ void (*set_set_id) (AGpsSetIDType type, const char* setid); /** * Send network initiated message. */ void (*ni_message) (uint8_t *msg, size_t len); /** * Notify GPS of network status changes. * These parameters match values in the android.net.NetworkInfo class. */ void (*update_network_state) (int connected, int type, int roaming, const char* extra_info); /** * Notify GPS of network status changes. * These parameters match values in the android.net.NetworkInfo class. */ void (*update_network_availability) (int avaiable, const char* apn); } AGpsRilInterface; /** * GPS Geofence. * There are 3 states associated with a Geofence: Inside, Outside, Unknown. * There are 3 transitions: ENTERED, EXITED, UNCERTAIN. * * An example state diagram with confidence level: 95% and Unknown time limit * set as 30 secs is shown below. (confidence level and Unknown time limit are * explained latter) * ____________________________ * | Unknown (30 secs) | * """""""""""""""""""""""""""" * ^ | | ^ * UNCERTAIN| |ENTERED EXITED| |UNCERTAIN * | v v | * ________ EXITED _________ * | Inside | -----------> | Outside | * | | <----------- | | * """""""" ENTERED """"""""" * * Inside state: We are 95% confident that the user is inside the geofence. * Outside state: We are 95% confident that the user is outside the geofence * Unknown state: Rest of the time. * * The Unknown state is better explained with an example: * * __________ * | c| * | ___ | _______ * | |a| | | b | * | """ | """"""" * | | * """""""""" * In the diagram above, "a" and "b" are 2 geofences and "c" is the accuracy * circle reported by the GPS subsystem. Now with regard to "b", the system is * confident that the user is outside. But with regard to "a" is not confident * whether it is inside or outside the geofence. If the accuracy remains the * same for a sufficient period of time, the UNCERTAIN transition would be * triggered with the state set to Unknown. If the accuracy improves later, an * appropriate transition should be triggered. This "sufficient period of time" * is defined by the parameter in the add_geofence_area API. * In other words, Unknown state can be interpreted as a state in which the * GPS subsystem isn't confident enough that the user is either inside or * outside the Geofence. It moves to Unknown state only after the expiry of the * timeout. * * The geofence callback needs to be triggered for the ENTERED and EXITED * transitions, when the GPS system is confident that the user has entered * (Inside state) or exited (Outside state) the Geofence. An implementation * which uses a value of 95% as the confidence is recommended. The callback * should be triggered only for the transitions requested by the * add_geofence_area call. * * Even though the diagram and explanation talks about states and transitions, * the callee is only interested in the transistions. The states are mentioned * here for illustrative purposes. * * Startup Scenario: When the device boots up, if an application adds geofences, * and then we get an accurate GPS location fix, it needs to trigger the * appropriate (ENTERED or EXITED) transition for every Geofence it knows about. * By default, all the Geofences will be in the Unknown state. * * When the GPS system is unavailable, gps_geofence_status_callback should be * called to inform the upper layers of the same. Similarly, when it becomes * available the callback should be called. This is a global state while the * UNKNOWN transition described above is per geofence. * * An important aspect to note is that users of this API (framework), will use * other subsystems like wifi, sensors, cell to handle Unknown case and * hopefully provide a definitive state transition to the third party * application. GPS Geofence will just be a signal indicating what the GPS * 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. * Parameters: * geofence_id - The id associated with the add_geofence_area. * location - The current GPS location. * transition - Can be one of GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED, * GPS_GEOFENCE_UNCERTAIN. * timestamp - Timestamp when the transition was detected. * * The callback should only be called when the caller is interested in that * particular transition. For instance, if the caller is interested only in * ENTERED transition, then the callback should NOT be called with the EXITED * transition. * * IMPORTANT: If a transition is triggered resulting in this callback, the GPS * subsystem will wake up the application processor, if its in suspend state. */ typedef void (*gps_geofence_transition_callback) (int32_t geofence_id, GpsLocation* location, int32_t transition, GpsUtcTime timestamp); /** * The callback associated with the availability of the GPS system for geofencing * monitoring. If the GPS system determines that it cannot monitor geofences * because of lack of reliability or unavailability of the GPS signals, it will * call this callback with GPS_GEOFENCE_UNAVAILABLE parameter. * * Parameters: * status - GPS_GEOFENCE_UNAVAILABLE or GPS_GEOFENCE_AVAILABLE. * last_location - Last known location. */ typedef void (*gps_geofence_status_callback) (int32_t status, GpsLocation* last_location); /** * The callback associated with the add_geofence call. * * Parameter: * geofence_id - Id of the geofence. * status - GPS_GEOFENCE_OPERATION_SUCCESS * GPS_GEOFENCE_ERROR_TOO_MANY_GEOFENCES - geofence limit has been reached. * GPS_GEOFENCE_ERROR_ID_EXISTS - geofence with id already exists * GPS_GEOFENCE_ERROR_INVALID_TRANSITION - the monitorTransition contains an * invalid transition * GPS_GEOFENCE_ERROR_GENERIC - for other errors. */ typedef void (*gps_geofence_add_callback) (int32_t geofence_id, int32_t status); /** * The callback associated with the remove_geofence call. * * Parameter: * geofence_id - Id of the geofence. * status - GPS_GEOFENCE_OPERATION_SUCCESS * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id * GPS_GEOFENCE_ERROR_GENERIC for others. */ typedef void (*gps_geofence_remove_callback) (int32_t geofence_id, int32_t status); /** * The callback associated with the pause_geofence call. * * Parameter: * geofence_id - Id of the geofence. * status - GPS_GEOFENCE_OPERATION_SUCCESS * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id * GPS_GEOFENCE_ERROR_INVALID_TRANSITION - * when monitor_transitions is invalid * GPS_GEOFENCE_ERROR_GENERIC for others. */ typedef void (*gps_geofence_pause_callback) (int32_t geofence_id, int32_t status); /** * The callback associated with the resume_geofence call. * * Parameter: * geofence_id - Id of the geofence. * status - GPS_GEOFENCE_OPERATION_SUCCESS * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id * GPS_GEOFENCE_ERROR_GENERIC for others. */ typedef void (*gps_geofence_resume_callback) (int32_t geofence_id, int32_t status); typedef struct { gps_geofence_transition_callback geofence_transition_callback; gps_geofence_status_callback geofence_status_callback; gps_geofence_add_callback geofence_add_callback; gps_geofence_remove_callback geofence_remove_callback; gps_geofence_pause_callback geofence_pause_callback; gps_geofence_resume_callback geofence_resume_callback; gps_create_thread create_thread_cb; } GpsGeofenceCallbacks; /** Extended interface for GPS_Geofencing support */ typedef struct { /** set to sizeof(GpsGeofencingInterface) */ size_t size; /** * Opens the geofence interface and provides the callback routines * to the implementation of this interface. */ void (*init)( GpsGeofenceCallbacks* callbacks ); /** * Add a geofence area. This api currently supports circular geofences. * Parameters: * geofence_id - The id for the geofence. If a geofence with this id * already exists, an error value (GPS_GEOFENCE_ERROR_ID_EXISTS) * should be returned. * latitude, longtitude, radius_meters - The lat, long and radius * (in meters) for the geofence * last_transition - The current state of the geofence. For example, if * the system already knows that the user is inside the geofence, * this will be set to GPS_GEOFENCE_ENTERED. In most cases, it * will be GPS_GEOFENCE_UNCERTAIN. * monitor_transition - Which transitions to monitor. Bitwise OR of * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and * GPS_GEOFENCE_UNCERTAIN. * notification_responsiveness_ms - Defines the best-effort description * of how soon should the callback be called when the transition * associated with the Geofence is triggered. For instance, if set * to 1000 millseconds with GPS_GEOFENCE_ENTERED, the callback * should be called 1000 milliseconds within entering the geofence. * This parameter is defined in milliseconds. * NOTE: This is not to be confused with the rate that the GPS is * polled at. It is acceptable to dynamically vary the rate of * sampling the GPS for power-saving reasons; thus the rate of * sampling may be faster or slower than this. * unknown_timer_ms - The time limit after which the UNCERTAIN transition * should be triggered. This parameter is defined in milliseconds. * See above for a detailed explanation. */ void (*add_geofence_area) (int32_t geofence_id, double latitude, double longitude, double radius_meters, int last_transition, int monitor_transitions, int notification_responsiveness_ms, int unknown_timer_ms); /** * Pause monitoring a particular geofence. * Parameters: * geofence_id - The id for the geofence. */ void (*pause_geofence) (int32_t geofence_id); /** * Resume monitoring a particular geofence. * Parameters: * geofence_id - The id for the geofence. * monitor_transitions - Which transitions to monitor. Bitwise OR of * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and * GPS_GEOFENCE_UNCERTAIN. * This supersedes the value associated provided in the * add_geofence_area call. */ void (*resume_geofence) (int32_t geofence_id, int monitor_transitions); /** * Remove a geofence area. After the function returns, no notifications * should be sent. * Parameter: * geofence_id - The id for the geofence. */ void (*remove_geofence_area) (int32_t geofence_id); } GpsGeofencingInterface; /** * Represents an estimate of the GPS clock time. */ typedef struct { /** set to sizeof(GpsClock) */ size_t size; /** A set of flags indicating the validity of the fields in this data structure. */ GpsClockFlags flags; /** * Leap second data. * The sign of the value is defined by the following equation: * utc_time_ns = time_ns + (full_bias_ns + bias_ns) - leap_second * 1,000,000,000 * * If the data is available 'flags' must contain GPS_CLOCK_HAS_LEAP_SECOND. */ int16_t leap_second; /** * Indicates the type of time reported by the 'time_ns' field. * This is a Mandatory field. */ GpsClockType type; /** * The GPS receiver internal clock value. This can be either the local hardware clock value * (GPS_CLOCK_TYPE_LOCAL_HW_TIME), or the current GPS time derived inside GPS receiver * (GPS_CLOCK_TYPE_GPS_TIME). The field 'type' defines the time reported. * * For local hardware clock, this value is expected to be monotonically increasing during * the reporting session. The real GPS time can be derived by compensating the 'full bias' * (when it is available) from this value. * * For GPS time, this value is expected to be the best estimation of current GPS time that GPS * receiver can achieve. Set the 'time uncertainty' appropriately when GPS time is specified. * * Sub-nanosecond accuracy can be provided by means of the 'bias' field. * The value contains the 'time uncertainty' in it. * * This is a Mandatory field. */ int64_t time_ns; /** * 1-Sigma uncertainty associated with the clock's time in nanoseconds. * The uncertainty is represented as an absolute (single sided) value. * * This value should be set if GPS_CLOCK_TYPE_GPS_TIME is set. * If the data is available 'flags' must contain GPS_CLOCK_HAS_TIME_UNCERTAINTY. */ double time_uncertainty_ns; /** * The difference between hardware clock ('time' field) inside GPS receiver and the true GPS * time since 0000Z, January 6, 1980, in nanoseconds. * This value is used if and only if GPS_CLOCK_TYPE_LOCAL_HW_TIME is set, and GPS receiver * has solved the clock for GPS time. * The caller is responsible for using the 'bias uncertainty' field for quality check. * * The sign of the value is defined by the following equation: * true time (GPS time) = time_ns + (full_bias_ns + bias_ns) * * This value contains the 'bias uncertainty' in it. * If the data is available 'flags' must contain GPS_CLOCK_HAS_FULL_BIAS. */ int64_t full_bias_ns; /** * Sub-nanosecond bias. * The value contains the 'bias uncertainty' in it. * * If the data is available 'flags' must contain GPS_CLOCK_HAS_BIAS. */ double bias_ns; /** * 1-Sigma uncertainty associated with the clock's bias in nanoseconds. * The uncertainty is represented as an absolute (single sided) value. * * If the data is available 'flags' must contain GPS_CLOCK_HAS_BIAS_UNCERTAINTY. */ double bias_uncertainty_ns; /** * The clock's drift in nanoseconds (per second). * A positive value means that the frequency is higher than the nominal frequency. * * The value contains the 'drift uncertainty' in it. * If the data is available 'flags' must contain GPS_CLOCK_HAS_DRIFT. * * If GpsMeasurement's 'flags' field contains GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE, * it is encouraged that this field is also provided. */ double drift_nsps; /** * 1-Sigma uncertainty associated with the clock's drift in nanoseconds (per second). * The uncertainty is represented as an absolute (single sided) value. * * If the data is available 'flags' must contain GPS_CLOCK_HAS_DRIFT_UNCERTAINTY. */ double drift_uncertainty_nsps; } GpsClock; /** * Represents a GPS Measurement, it contains raw and computed information. */ typedef struct { /** set to sizeof(GpsMeasurement) */ size_t size; /** A set of flags indicating the validity of the fields in this data structure. */ GpsMeasurementFlags flags; /** * Pseudo-random number in the range of [1, 32] * This is a Mandatory value. */ int8_t prn; /** * Time offset at which the measurement was taken in nanoseconds. * The reference receiver's time is specified by GpsData::clock::time_ns and should be * interpreted in the same way as indicated by GpsClock::type. * * The sign of time_offset_ns is given by the following equation: * measurement time = GpsClock::time_ns + time_offset_ns * * It provides an individual time-stamp for the measurement, and allows sub-nanosecond accuracy. * This is a Mandatory value. */ double time_offset_ns; /** * Per satellite sync state. It represents the current sync state for the associated satellite. * Based on the sync state, the 'received GPS tow' field should be interpreted accordingly. * * This is a Mandatory value. */ GpsMeasurementState state; /** * Received GPS Time-of-Week at the measurement time, in nanoseconds. * The value is relative to the beginning of the current GPS week. * * Given the highest sync state that can be achieved, per each satellite, valid range for * this field can be: * Searching : [ 0 ] : GPS_MEASUREMENT_STATE_UNKNOWN * C/A code lock : [ 0 1ms ] : GPS_MEASUREMENT_STATE_CODE_LOCK is set * Bit sync : [ 0 20ms ] : GPS_MEASUREMENT_STATE_BIT_SYNC is set * Subframe sync : [ 0 6s ] : GPS_MEASUREMENT_STATE_SUBFRAME_SYNC is set * TOW decoded : [ 0 1week ] : GPS_MEASUREMENT_STATE_TOW_DECODED is set * * However, if there is any ambiguity in integer millisecond, * GPS_MEASUREMENT_STATE_MSEC_AMBIGUOUS should be set accordingly, in the 'state' field. * * This value must be populated if 'state' != GPS_MEASUREMENT_STATE_UNKNOWN. */ int64_t received_gps_tow_ns; /** * 1-Sigma uncertainty of the Received GPS Time-of-Week in nanoseconds. * * This value must be populated if 'state' != GPS_MEASUREMENT_STATE_UNKNOWN. */ int64_t received_gps_tow_uncertainty_ns; /** * Carrier-to-noise density in dB-Hz, in the range [0, 63]. * It contains the measured C/N0 value for the signal at the antenna input. * * This is a Mandatory value. */ double c_n0_dbhz; /** * Pseudorange rate at the timestamp in m/s. * The correction of a given Pseudorange Rate value includes corrections for receiver and * satellite clock frequency errors. * * If GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE is set in 'flags' field, this field must * be populated with the 'uncorrected' reading. * If GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE is not set in 'flags' field, this field * must be populated with the 'corrected' reading. This is the default behavior. * * It is encouraged to provide the 'uncorrected' 'pseudorange rate', and provide GpsClock's * 'drift' field as well. * * The value includes the 'pseudorange rate uncertainty' in it. * A positive 'uncorrected' value indicates that the SV is moving away from the receiver. * * The sign of the 'uncorrected' 'pseudorange rate' and its relation to the sign of 'doppler * shift' is given by the equation: * pseudorange rate = -k * doppler shift (where k is a constant) * * This is a Mandatory value. */ double pseudorange_rate_mps; /** * 1-Sigma uncertainty of the pseudurange rate in m/s. * The uncertainty is represented as an absolute (single sided) value. * * This is a Mandatory value. */ double pseudorange_rate_uncertainty_mps; /** * Accumulated delta range's state. It indicates whether ADR is reset or there is a cycle slip * (indicating loss of lock). * * This is a Mandatory value. */ GpsAccumulatedDeltaRangeState accumulated_delta_range_state; /** * Accumulated delta range since the last channel reset in meters. * A positive value indicates that the SV is moving away from the receiver. * * The sign of the 'accumulated delta range' and its relation to the sign of 'carrier phase' * is given by the equation: * accumulated delta range = -k * carrier phase (where k is a constant) * * This value must be populated if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN. * However, it is expected that the data is only accurate when: * 'accumulated delta range state' == GPS_ADR_STATE_VALID. */ double accumulated_delta_range_m; /** * 1-Sigma uncertainty of the accumulated delta range in meters. * This value must be populated if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN. */ double accumulated_delta_range_uncertainty_m; /** * Best derived Pseudorange by the chip-set, in meters. * The value contains the 'pseudorange uncertainty' in it. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_PSEUDORANGE. */ double pseudorange_m; /** * 1-Sigma uncertainty of the pseudorange in meters. * The value contains the 'pseudorange' and 'clock' uncertainty in it. * The uncertainty is represented as an absolute (single sided) value. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_PSEUDORANGE_UNCERTAINTY. */ double pseudorange_uncertainty_m; /** * A fraction of the current C/A code cycle, in the range [0.0, 1023.0] * This value contains the time (in Chip units) since the last C/A code cycle (GPS Msec epoch). * * The reference frequency is given by the field 'carrier_frequency_hz'. * The value contains the 'code-phase uncertainty' in it. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CODE_PHASE. */ double code_phase_chips; /** * 1-Sigma uncertainty of the code-phase, in a fraction of chips. * The uncertainty is represented as an absolute (single sided) value. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CODE_PHASE_UNCERTAINTY. */ double code_phase_uncertainty_chips; /** * Carrier frequency at which codes and messages are modulated, it can be L1 or L2. * If the field is not set, the carrier frequency is assumed to be L1. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CARRIER_FREQUENCY. */ float carrier_frequency_hz; /** * The number of full carrier cycles between the satellite and the receiver. * The reference frequency is given by the field 'carrier_frequency_hz'. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CARRIER_CYCLES. */ int64_t carrier_cycles; /** * The RF phase detected by the receiver, in the range [0.0, 1.0]. * This is usually the fractional part of the complete carrier phase measurement. * * The reference frequency is given by the field 'carrier_frequency_hz'. * The value contains the 'carrier-phase uncertainty' in it. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CARRIER_PHASE. */ double carrier_phase; /** * 1-Sigma uncertainty of the carrier-phase. * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY. */ double carrier_phase_uncertainty; /** * An enumeration that indicates the 'loss of lock' state of the event. */ GpsLossOfLock loss_of_lock; /** * The number of GPS bits transmitted since Sat-Sun midnight (GPS week). * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_BIT_NUMBER. */ int32_t bit_number; /** * The elapsed time since the last received bit in milliseconds, in the range [0, 20] * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_TIME_FROM_LAST_BIT. */ int16_t time_from_last_bit_ms; /** * Doppler shift in Hz. * A positive value indicates that the SV is moving toward the receiver. * * The reference frequency is given by the field 'carrier_frequency_hz'. * The value contains the 'doppler shift uncertainty' in it. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_DOPPLER_SHIFT. */ double doppler_shift_hz; /** * 1-Sigma uncertainty of the doppler shift in Hz. * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_DOPPLER_SHIFT_UNCERTAINTY. */ double doppler_shift_uncertainty_hz; /** * An enumeration that indicates the 'multipath' state of the event. */ GpsMultipathIndicator multipath_indicator; /** * Signal-to-noise ratio in dB. * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_SNR. */ double snr_db; /** * Elevation in degrees, the valid range is [-90, 90]. * The value contains the 'elevation uncertainty' in it. * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_ELEVATION. */ double elevation_deg; /** * 1-Sigma uncertainty of the elevation in degrees, the valid range is [0, 90]. * The uncertainty is represented as the absolute (single sided) value. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_ELEVATION_UNCERTAINTY. */ double elevation_uncertainty_deg; /** * Azimuth in degrees, in the range [0, 360). * The value contains the 'azimuth uncertainty' in it. * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_AZIMUTH. * */ double azimuth_deg; /** * 1-Sigma uncertainty of the azimuth in degrees, the valid range is [0, 180]. * The uncertainty is represented as an absolute (single sided) value. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_AZIMUTH_UNCERTAINTY. */ double azimuth_uncertainty_deg; /** * Whether the GPS represented by the measurement was used for computing the most recent fix. * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_USED_IN_FIX. */ bool used_in_fix; } GpsMeasurement; /** Represents a reading of GPS measurements. */ typedef struct { /** set to sizeof(GpsData) */ size_t size; /** Number of measurements. */ size_t measurement_count; /** The array of measurements. */ GpsMeasurement measurements[GPS_MAX_MEASUREMENT]; /** The GPS clock time reading. */ GpsClock clock; } GpsData; /** * The callback for to report measurements from the HAL. * * Parameters: * data - A data structure containing the measurements. */ typedef void (*gps_measurement_callback) (GpsData* data); typedef struct { /** set to sizeof(GpsMeasurementCallbacks) */ size_t size; gps_measurement_callback 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. */ typedef struct { /** Set to sizeof(GpsMeasurementInterface) */ size_t size; /** * Initializes the interface and registers the callback routines with the HAL. * After a successful call to 'init' the HAL must begin to provide updates at its own phase. * * Status: * GPS_MEASUREMENT_OPERATION_SUCCESS * GPS_MEASUREMENT_ERROR_ALREADY_INIT - if a callback has already been registered without a * corresponding call to 'close' * GPS_MEASUREMENT_ERROR_GENERIC - if any other error occurred, it is expected that the HAL * will not generate any updates upon returning this error code. */ int (*init) (GpsMeasurementCallbacks* callbacks); /** * Stops updates from the HAL, and unregisters the callback routines. * After a call to stop, the previously registered callbacks must be considered invalid by the * HAL. * If stop is invoked without a previous 'init', this function should perform no work. */ void (*close) (); } GpsMeasurementInterface; /** Represents a GPS navigation message (or a fragment of it). */ typedef struct { /** set to sizeof(GpsNavigationMessage) */ size_t size; /** * Pseudo-random number in the range of [1, 32] * This is a Mandatory value. */ int8_t prn; /** * The type of message contained in the structure. * This is a Mandatory value. */ GpsNavigationMessageType type; /** * The status of the received navigation message. * No need to send any navigation message that contains words with parity error and cannot be * corrected. */ NavigationMessageStatus status; /** * Message identifier. * It provides an index so the complete Navigation Message can be assembled. i.e. fo L1 C/A * subframe 4 and 5, this value corresponds to the 'frame id' of the navigation message. * Subframe 1, 2, 3 does not contain a 'frame id' and this value can be set to -1. */ int16_t message_id; /** * Sub-message identifier. * If required by the message 'type', this value contains a sub-index within the current * message (or frame) that is being transmitted. * i.e. for L1 C/A the submessage id corresponds to the sub-frame id of the navigation message. */ int16_t submessage_id; /** * The length of the data (in bytes) contained in the current message. * If this value is different from zero, 'data' must point to an array of the same size. * e.g. for L1 C/A the size of the sub-frame will be 40 bytes (10 words, 30 bits/word). * * This is a Mandatory value. */ size_t data_length; /** * The data of the reported GPS message. * The bytes (or words) specified using big endian format (MSB first). * * For L1 C/A, each subframe contains 10 30-bit GPS words. Each GPS word (30 bits) should be * fitted into the last 30 bits in a 4-byte word (skip B31 and B32), with MSB first. */ uint8_t* data; } GpsNavigationMessage; /** * The callback to report an available fragment of a GPS navigation messages from the HAL. * * Parameters: * message - The GPS navigation submessage/subframe representation. */ typedef void (*gps_navigation_message_callback) (GpsNavigationMessage* message); typedef struct { /** set to sizeof(GpsNavigationMessageCallbacks) */ size_t size; gps_navigation_message_callback 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. */ typedef struct { /** Set to sizeof(GpsNavigationMessageInterface) */ size_t size; /** * Initializes the interface and registers the callback routines with the HAL. * After a successful call to 'init' the HAL must begin to provide updates as they become * available. * * Status: * GPS_NAVIGATION_MESSAGE_OPERATION_SUCCESS * GPS_NAVIGATION_MESSAGE_ERROR_ALREADY_INIT - if a callback has already been registered * without a corresponding call to 'close'. * GPS_NAVIGATION_MESSAGE_ERROR_GENERIC - if any other error occurred, it is expected that * the HAL will not generate any updates upon returning this error code. */ int (*init) (GpsNavigationMessageCallbacks* callbacks); /** * Stops updates from the HAL, and unregisters the callback routines. * After a call to stop, the previously registered callbacks must be considered invalid by the * HAL. * If stop is invoked without a previous 'init', this function should perform no work. */ void (*close) (); } GpsNavigationMessageInterface; /** * Interface for passing GNSS configuration contents from platform to HAL. */ typedef struct { /** Set to sizeof(GnssConfigurationInterface) */ size_t size; /** * Deliver GNSS configuration contents to HAL. * Parameters: * config_data - a pointer to a char array which holds what usually is expected from file(/etc/gps.conf), i.e., a sequence of UTF8 strings separated by '\n'. * length - total number of UTF8 characters in configuraiton data. * * IMPORTANT: * GPS HAL should expect this function can be called multiple times. And it may be * called even when GpsLocationProvider is already constructed and enabled. GPS HAL * should maintain the existing requests for various callback regardless the change * in configuration data. */ void (*configuration_update) (const char* config_data, int32_t length); } GnssConfigurationInterface; __END_DECLS #endif /* ANDROID_INCLUDE_HARDWARE_GPS_H */ android-headers-23/23/hardware/gralloc.h000066400000000000000000000337251264465411000201630ustar00rootroot00000000000000/* * 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_GRALLOC_INTERFACE_H #define ANDROID_GRALLOC_INTERFACE_H #include #include #include #include #include #include #include #include #include __BEGIN_DECLS /** * Module versioning information for the Gralloc hardware module, based on * gralloc_module_t.common.module_api_version. * * Version History: * * GRALLOC_MODULE_API_VERSION_0_1: * Initial Gralloc hardware module API. * * GRALLOC_MODULE_API_VERSION_0_2: * Add support for flexible YCbCr format with (*lock_ycbcr)() method. * * GRALLOC_MODULE_API_VERSION_0_3: * Add support for fence passing to/from lock/unlock. */ #define GRALLOC_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define GRALLOC_MODULE_API_VERSION_0_2 HARDWARE_MODULE_API_VERSION(0, 2) #define GRALLOC_MODULE_API_VERSION_0_3 HARDWARE_MODULE_API_VERSION(0, 3) #define GRALLOC_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION(0, 1) /** * The id of this module */ #define GRALLOC_HARDWARE_MODULE_ID "gralloc" /** * Name of the graphics device to open */ #define GRALLOC_HARDWARE_GPU0 "gpu0" enum { /* buffer is never read in software */ GRALLOC_USAGE_SW_READ_NEVER = 0x00000000, /* buffer is rarely read in software */ GRALLOC_USAGE_SW_READ_RARELY = 0x00000002, /* buffer is often read in software */ GRALLOC_USAGE_SW_READ_OFTEN = 0x00000003, /* mask for the software read values */ GRALLOC_USAGE_SW_READ_MASK = 0x0000000F, /* buffer is never written in software */ GRALLOC_USAGE_SW_WRITE_NEVER = 0x00000000, /* buffer is rarely written in software */ GRALLOC_USAGE_SW_WRITE_RARELY = 0x00000020, /* buffer is often written in software */ GRALLOC_USAGE_SW_WRITE_OFTEN = 0x00000030, /* mask for the software write values */ GRALLOC_USAGE_SW_WRITE_MASK = 0x000000F0, /* buffer will be used as an OpenGL ES texture */ GRALLOC_USAGE_HW_TEXTURE = 0x00000100, /* buffer will be used as an OpenGL ES render target */ GRALLOC_USAGE_HW_RENDER = 0x00000200, /* buffer will be used by the 2D hardware blitter */ GRALLOC_USAGE_HW_2D = 0x00000400, /* buffer will be used by the HWComposer HAL module */ GRALLOC_USAGE_HW_COMPOSER = 0x00000800, /* buffer will be used with the framebuffer device */ GRALLOC_USAGE_HW_FB = 0x00001000, /* buffer should be displayed full-screen on an external display when * possible */ GRALLOC_USAGE_EXTERNAL_DISP = 0x00002000, /* Must have a hardware-protected path to external display sink for * this buffer. If a hardware-protected path is not available, then * either don't composite only this buffer (preferred) to the * external sink, or (less desirable) do not route the entire * composition to the external sink. */ GRALLOC_USAGE_PROTECTED = 0x00004000, /* buffer may be used as a cursor */ GRALLOC_USAGE_CURSOR = 0x00008000, /* buffer will be used with the HW video encoder */ GRALLOC_USAGE_HW_VIDEO_ENCODER = 0x00010000, /* buffer will be written by the HW camera pipeline */ GRALLOC_USAGE_HW_CAMERA_WRITE = 0x00020000, /* buffer will be read by the HW camera pipeline */ GRALLOC_USAGE_HW_CAMERA_READ = 0x00040000, /* buffer will be used as part of zero-shutter-lag queue */ GRALLOC_USAGE_HW_CAMERA_ZSL = 0x00060000, /* mask for the camera access values */ GRALLOC_USAGE_HW_CAMERA_MASK = 0x00060000, /* mask for the software usage bit-mask */ GRALLOC_USAGE_HW_MASK = 0x00071F00, /* buffer will be used as a RenderScript Allocation */ GRALLOC_USAGE_RENDERSCRIPT = 0x00100000, /* 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, /* 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 * gralloc modules. */ 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, }; /*****************************************************************************/ /** * 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 gralloc_module_t { struct hw_module_t common; /* * (*registerBuffer)() must be called before a buffer_handle_t that has not * been created with (*alloc_device_t::alloc)() can be used. * * This is intended to be used with buffer_handle_t's that have been * received in this process through IPC. * * This function checks that the handle is indeed a valid one and prepares * it for use with (*lock)() and (*unlock)(). * * It is not necessary to call (*registerBuffer)() on a handle created * with (*alloc_device_t::alloc)(). * * returns an error if this buffer_handle_t is not valid. */ int (*registerBuffer)(struct gralloc_module_t const* module, buffer_handle_t handle); /* * (*unregisterBuffer)() is called once this handle is no longer needed in * this process. After this call, it is an error to call (*lock)(), * (*unlock)(), or (*registerBuffer)(). * * This function doesn't close or free the handle itself; this is done * by other means, usually through libcutils's native_handle_close() and * native_handle_free(). * * It is an error to call (*unregisterBuffer)() on a buffer that wasn't * explicitly registered first. */ int (*unregisterBuffer)(struct gralloc_module_t const* module, buffer_handle_t handle); /* * The (*lock)() method is called before a buffer is accessed for the * specified usage. This call may block, for instance if the h/w needs * to finish rendering or if CPU caches need to be synchronized. * * The caller promises to modify only pixels in the area specified * by (l,t,w,h). * * The content of the buffer outside of the specified area is NOT modified * by this call. * * If usage specifies GRALLOC_USAGE_SW_*, vaddr is filled with the address * of the buffer in virtual memory. * * Note calling (*lock)() on HAL_PIXEL_FORMAT_YCbCr_*_888 buffers will fail * and return -EINVAL. These buffers must be locked with (*lock_ycbcr)() * instead. * * THREADING CONSIDERATIONS: * * It is legal for several different threads to lock a buffer from * read access, none of the threads are blocked. * * However, locking a buffer simultaneously for write or read/write is * undefined, but: * - shall not result in termination of the process * - shall not block the caller * It is acceptable to return an error or to leave the buffer's content * into an indeterminate state. * * If the buffer was created with a usage mask incompatible with the * requested usage flags here, -EINVAL is returned. * */ int (*lock)(struct gralloc_module_t const* module, buffer_handle_t handle, int usage, int l, int t, int w, int h, void** vaddr); /* * The (*unlock)() method must be called after all changes to the buffer * are completed. */ int (*unlock)(struct gralloc_module_t const* module, buffer_handle_t handle); /* reserved for future use */ int (*perform)(struct gralloc_module_t const* module, int operation, ... ); /* * The (*lock_ycbcr)() method is like the (*lock)() method, with the * difference that it fills a struct ycbcr with a description of the buffer * layout, and zeroes out the reserved fields. * * If the buffer format is not compatible with a flexible YUV format (e.g. * the buffer layout cannot be represented with the ycbcr struct), it * will return -EINVAL. * * This method must work on buffers with HAL_PIXEL_FORMAT_YCbCr_*_888 * if supported by the device, as well as with any other format that is * requested by the multimedia codecs when they are configured with a * flexible-YUV-compatible color-format with android native buffers. * * Note that this method may also be called on buffers of other formats, * including non-YUV formats. * * Added in GRALLOC_MODULE_API_VERSION_0_2. */ int (*lock_ycbcr)(struct gralloc_module_t const* module, buffer_handle_t handle, int usage, int l, int t, int w, int h, struct android_ycbcr *ycbcr); /* * The (*lockAsync)() method is like the (*lock)() method except * that the buffer's sync fence object is passed into the lock * call instead of requiring the caller to wait for completion. * * The gralloc implementation takes ownership of the fenceFd and * is responsible for closing it when no longer needed. * * Added in GRALLOC_MODULE_API_VERSION_0_3. */ int (*lockAsync)(struct gralloc_module_t const* module, buffer_handle_t handle, int usage, int l, int t, int w, int h, void** vaddr, int fenceFd); /* * The (*unlockAsync)() method is like the (*unlock)() method * except that a buffer sync fence object is returned from the * lock call, representing the completion of any pending work * performed by the gralloc implementation. * * The caller takes ownership of the fenceFd and is responsible * for closing it when no longer needed. * * Added in GRALLOC_MODULE_API_VERSION_0_3. */ int (*unlockAsync)(struct gralloc_module_t const* module, buffer_handle_t handle, int* fenceFd); /* * The (*lockAsync_ycbcr)() method is like the (*lock_ycbcr)() * method except that the buffer's sync fence object is passed * into the lock call instead of requiring the caller to wait for * completion. * * The gralloc implementation takes ownership of the fenceFd and * is responsible for closing it when no longer needed. * * Added in GRALLOC_MODULE_API_VERSION_0_3. */ int (*lockAsync_ycbcr)(struct gralloc_module_t const* module, buffer_handle_t handle, int usage, int l, int t, int w, int h, struct android_ycbcr *ycbcr, int fenceFd); /* reserved for future use */ void* reserved_proc[3]; } gralloc_module_t; /*****************************************************************************/ /** * Every device data structure must begin with hw_device_t * followed by module specific public methods and attributes. */ typedef struct alloc_device_t { struct hw_device_t common; /* * (*alloc)() Allocates a buffer in graphic memory with the requested * parameters and returns a buffer_handle_t and the stride in pixels to * allow the implementation to satisfy hardware constraints on the width * of a pixmap (eg: it may have to be multiple of 8 pixels). * The CALLER TAKES OWNERSHIP of the buffer_handle_t. * * If format is HAL_PIXEL_FORMAT_YCbCr_420_888, the returned stride must be * 0, since the actual strides are available from the android_ycbcr * structure. * * Returns 0 on success or -errno on error. */ int (*alloc)(struct alloc_device_t* dev, int w, int h, int format, int usage, buffer_handle_t* handle, int* stride); /* * (*free)() Frees a previously allocated buffer. * Behavior is undefined if the buffer is still mapped in any process, * but shall not result in termination of the program or security breaches * (allowing a process to get access to another process' buffers). * THIS FUNCTION TAKES OWNERSHIP of the buffer_handle_t which becomes * invalid after the call. * * Returns 0 on success or -errno on error. */ int (*free)(struct alloc_device_t* dev, buffer_handle_t handle); /* This hook is OPTIONAL. * * If non NULL it will be caused by SurfaceFlinger on dumpsys */ void (*dump)(struct alloc_device_t *dev, char *buff, int buff_len); void* reserved_proc[7]; } alloc_device_t; /** convenience API for opening and closing a supported device */ 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); } static inline int gralloc_close(struct alloc_device_t* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_GRALLOC_INTERFACE_H android-headers-23/23/hardware/hardware.h000066400000000000000000000173341264465411000203330ustar00rootroot00000000000000/* * 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_HARDWARE_H #define ANDROID_INCLUDE_HARDWARE_HARDWARE_H #include #include #include #include __BEGIN_DECLS /* * Value for the hw_module_t.tag field */ #define MAKE_TAG_CONSTANT(A,B,C,D) (((A) << 24) | ((B) << 16) | ((C) << 8) | (D)) #define HARDWARE_MODULE_TAG MAKE_TAG_CONSTANT('H', 'W', 'M', 'T') #define HARDWARE_DEVICE_TAG MAKE_TAG_CONSTANT('H', 'W', 'D', 'T') #define HARDWARE_MAKE_API_VERSION(maj,min) \ ((((maj) & 0xff) << 8) | ((min) & 0xff)) #define HARDWARE_MAKE_API_VERSION_2(maj,min,hdr) \ ((((maj) & 0xff) << 24) | (((min) & 0xff) << 16) | ((hdr) & 0xffff)) #define HARDWARE_API_VERSION_2_MAJ_MIN_MASK 0xffff0000 #define HARDWARE_API_VERSION_2_HEADER_MASK 0x0000ffff /* * The current HAL API version. * * All module implementations must set the hw_module_t.hal_api_version field * to this value when declaring the module with HAL_MODULE_INFO_SYM. * * Note that previous implementations have always set this field to 0. * Therefore, libhardware HAL API will always consider versions 0.0 and 1.0 * to be 100% binary compatible. * */ #define HARDWARE_HAL_API_VERSION HARDWARE_MAKE_API_VERSION(1, 0) /* * Helper macros for module implementors. * * The derived modules should provide convenience macros for supported * versions so that implementations can explicitly specify module/device * versions at definition time. * * Use this macro to set the hw_module_t.module_api_version field. */ #define HARDWARE_MODULE_API_VERSION(maj,min) HARDWARE_MAKE_API_VERSION(maj,min) #define HARDWARE_MODULE_API_VERSION_2(maj,min,hdr) HARDWARE_MAKE_API_VERSION_2(maj,min,hdr) /* * Use this macro to set the hw_device_t.version field */ #define HARDWARE_DEVICE_API_VERSION(maj,min) HARDWARE_MAKE_API_VERSION(maj,min) #define HARDWARE_DEVICE_API_VERSION_2(maj,min,hdr) HARDWARE_MAKE_API_VERSION_2(maj,min,hdr) struct hw_module_t; struct hw_module_methods_t; struct hw_device_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 hw_module_t { /** tag must be initialized to HARDWARE_MODULE_TAG */ uint32_t tag; /** * The API version of the implemented module. The module owner is * responsible for updating the version when a module interface has * changed. * * The derived modules such as gralloc and audio own and manage this field. * The module user must interpret the version field to decide whether or * not to inter-operate with the supplied module implementation. * For example, SurfaceFlinger is responsible for making sure that * it knows how to manage different versions of the gralloc-module API, * and AudioFlinger must know how to do the same for audio-module API. * * The module API version should include a major and a minor component. * For example, version 1.0 could be represented as 0x0100. This format * implies that versions 0x0100-0x01ff are all API-compatible. * * In the future, libhardware will expose a hw_get_module_version() * (or equivalent) function that will take minimum/maximum supported * versions as arguments and would be able to reject modules with * versions outside of the supplied range. */ uint16_t module_api_version; #define version_major module_api_version /** * version_major/version_minor defines are supplied here for temporary * source code compatibility. They will be removed in the next version. * ALL clients must convert to the new version format. */ /** * The API version of the HAL module interface. This is meant to * version the hw_module_t, hw_module_methods_t, and hw_device_t * structures and definitions. * * The HAL interface owns this field. Module users/implementations * must NOT rely on this value for version information. * * Presently, 0 is the only valid value. */ uint16_t hal_api_version; #define version_minor hal_api_version /** Identifier of module */ const char *id; /** Name of this module */ const char *name; /** Author/owner/implementor of the module */ const char *author; /** Modules methods */ struct hw_module_methods_t* methods; /** module's dso */ void* dso; #ifdef __LP64__ uint64_t reserved[32-7]; #else /** padding to 128 bytes, reserved for future use */ uint32_t reserved[32-7]; #endif } hw_module_t; typedef struct hw_module_methods_t { /** Open a specific device */ int (*open)(const struct hw_module_t* module, const char* id, struct hw_device_t** device); } hw_module_methods_t; /** * Every device data structure must begin with hw_device_t * followed by module specific public methods and attributes. */ typedef struct hw_device_t { /** tag must be initialized to HARDWARE_DEVICE_TAG */ uint32_t tag; /** * Version of the module-specific device API. This value is used by * the derived-module user to manage different device implementations. * * The module user is responsible for checking the module_api_version * and device version fields to ensure that the user is capable of * communicating with the specific module implementation. * * One module can support multiple devices with different versions. This * can be useful when a device interface changes in an incompatible way * but it is still necessary to support older implementations at the same * time. One such example is the Camera 2.0 API. * * This field is interpreted by the module user and is ignored by the * HAL interface itself. */ uint32_t version; /** reference to the module this device belongs to */ struct hw_module_t* module; /** padding reserved for future use */ #ifdef __LP64__ uint64_t reserved[12]; #else uint32_t reserved[12]; #endif /** Close this device */ int (*close)(struct hw_device_t* device); } hw_device_t; /** * Name of the hal_module_info */ #define HAL_MODULE_INFO_SYM HMI /** * Name of the hal_module_info as a string */ #define HAL_MODULE_INFO_SYM_AS_STR "HMI" /** * Get the module info associated with a module by id. * * @return: 0 == success, <0 == error and *module == NULL */ int hw_get_module(const char *id, const struct hw_module_t **module); /** * Get the module info associated with a module instance by class 'class_id' * and instance 'inst'. * * Some modules types necessitate multiple instances. For example audio supports * multiple concurrent interfaces and thus 'audio' is the module class * and 'primary' or 'a2dp' are module interfaces. This implies that the files * providing these modules would be named audio.primary..so and * audio.a2dp..so * * @return: 0 == success, <0 == error and *module == NULL */ int hw_get_module_by_class(const char *class_id, const char *inst, const struct hw_module_t **module); __END_DECLS #endif /* ANDROID_INCLUDE_HARDWARE_HARDWARE_H */ android-headers-23/23/hardware/hdmi_cec.h000066400000000000000000000343121264465411000202640ustar00rootroot00000000000000/* * 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_HARDWARE_HDMI_CEC_H #define ANDROID_INCLUDE_HARDWARE_HDMI_CEC_H #include #include #include __BEGIN_DECLS #define HDMI_CEC_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) #define HDMI_CEC_MODULE_API_VERSION_CURRENT HDMI_MODULE_API_VERSION_1_0 #define HDMI_CEC_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) #define HDMI_CEC_DEVICE_API_VERSION_CURRENT HDMI_DEVICE_API_VERSION_1_0 #define HDMI_CEC_HARDWARE_MODULE_ID "hdmi_cec" #define HDMI_CEC_HARDWARE_INTERFACE "hdmi_cec_hw_if" typedef enum cec_device_type { CEC_DEVICE_INACTIVE = -1, CEC_DEVICE_TV = 0, CEC_DEVICE_RECORDER = 1, CEC_DEVICE_RESERVED = 2, CEC_DEVICE_TUNER = 3, CEC_DEVICE_PLAYBACK = 4, CEC_DEVICE_AUDIO_SYSTEM = 5, CEC_DEVICE_MAX = CEC_DEVICE_AUDIO_SYSTEM } cec_device_type_t; typedef enum cec_logical_address { CEC_ADDR_TV = 0, CEC_ADDR_RECORDER_1 = 1, CEC_ADDR_RECORDER_2 = 2, CEC_ADDR_TUNER_1 = 3, CEC_ADDR_PLAYBACK_1 = 4, CEC_ADDR_AUDIO_SYSTEM = 5, CEC_ADDR_TUNER_2 = 6, CEC_ADDR_TUNER_3 = 7, CEC_ADDR_PLAYBACK_2 = 8, CEC_ADDR_RECORDER_3 = 9, CEC_ADDR_TUNER_4 = 10, CEC_ADDR_PLAYBACK_3 = 11, CEC_ADDR_RESERVED_1 = 12, CEC_ADDR_RESERVED_2 = 13, CEC_ADDR_FREE_USE = 14, CEC_ADDR_UNREGISTERED = 15, CEC_ADDR_BROADCAST = 15 } cec_logical_address_t; /* * HDMI CEC messages */ enum cec_message_type { CEC_MESSAGE_FEATURE_ABORT = 0x00, CEC_MESSAGE_IMAGE_VIEW_ON = 0x04, CEC_MESSAGE_TUNER_STEP_INCREMENT = 0x05, CEC_MESSAGE_TUNER_STEP_DECREMENT = 0x06, CEC_MESSAGE_TUNER_DEVICE_STATUS = 0x07, CEC_MESSAGE_GIVE_TUNER_DEVICE_STATUS = 0x08, CEC_MESSAGE_RECORD_ON = 0x09, CEC_MESSAGE_RECORD_STATUS = 0x0A, CEC_MESSAGE_RECORD_OFF = 0x0B, CEC_MESSAGE_TEXT_VIEW_ON = 0x0D, CEC_MESSAGE_RECORD_TV_SCREEN = 0x0F, CEC_MESSAGE_GIVE_DECK_STATUS = 0x1A, CEC_MESSAGE_DECK_STATUS = 0x1B, CEC_MESSAGE_SET_MENU_LANGUAGE = 0x32, CEC_MESSAGE_CLEAR_ANALOG_TIMER = 0x33, CEC_MESSAGE_SET_ANALOG_TIMER = 0x34, CEC_MESSAGE_TIMER_STATUS = 0x35, CEC_MESSAGE_STANDBY = 0x36, CEC_MESSAGE_PLAY = 0x41, CEC_MESSAGE_DECK_CONTROL = 0x42, CEC_MESSAGE_TIMER_CLEARED_STATUS = 0x043, CEC_MESSAGE_USER_CONTROL_PRESSED = 0x44, CEC_MESSAGE_USER_CONTROL_RELEASED = 0x45, CEC_MESSAGE_GIVE_OSD_NAME = 0x46, CEC_MESSAGE_SET_OSD_NAME = 0x47, CEC_MESSAGE_SET_OSD_STRING = 0x64, CEC_MESSAGE_SET_TIMER_PROGRAM_TITLE = 0x67, CEC_MESSAGE_SYSTEM_AUDIO_MODE_REQUEST = 0x70, CEC_MESSAGE_GIVE_AUDIO_STATUS = 0x71, CEC_MESSAGE_SET_SYSTEM_AUDIO_MODE = 0x72, CEC_MESSAGE_REPORT_AUDIO_STATUS = 0x7A, CEC_MESSAGE_GIVE_SYSTEM_AUDIO_MODE_STATUS = 0x7D, CEC_MESSAGE_SYSTEM_AUDIO_MODE_STATUS = 0x7E, CEC_MESSAGE_ROUTING_CHANGE = 0x80, CEC_MESSAGE_ROUTING_INFORMATION = 0x81, CEC_MESSAGE_ACTIVE_SOURCE = 0x82, CEC_MESSAGE_GIVE_PHYSICAL_ADDRESS = 0x83, CEC_MESSAGE_REPORT_PHYSICAL_ADDRESS = 0x84, CEC_MESSAGE_REQUEST_ACTIVE_SOURCE = 0x85, CEC_MESSAGE_SET_STREAM_PATH = 0x86, CEC_MESSAGE_DEVICE_VENDOR_ID = 0x87, CEC_MESSAGE_VENDOR_COMMAND = 0x89, CEC_MESSAGE_VENDOR_REMOTE_BUTTON_DOWN = 0x8A, CEC_MESSAGE_VENDOR_REMOTE_BUTTON_UP = 0x8B, CEC_MESSAGE_GIVE_DEVICE_VENDOR_ID = 0x8C, CEC_MESSAGE_MENU_REQUEST = 0x8D, CEC_MESSAGE_MENU_STATUS = 0x8E, CEC_MESSAGE_GIVE_DEVICE_POWER_STATUS = 0x8F, CEC_MESSAGE_REPORT_POWER_STATUS = 0x90, CEC_MESSAGE_GET_MENU_LANGUAGE = 0x91, CEC_MESSAGE_SELECT_ANALOG_SERVICE = 0x92, CEC_MESSAGE_SELECT_DIGITAL_SERVICE = 0x93, CEC_MESSAGE_SET_DIGITAL_TIMER = 0x97, CEC_MESSAGE_CLEAR_DIGITAL_TIMER = 0x99, CEC_MESSAGE_SET_AUDIO_RATE = 0x9A, CEC_MESSAGE_INACTIVE_SOURCE = 0x9D, CEC_MESSAGE_CEC_VERSION = 0x9E, CEC_MESSAGE_GET_CEC_VERSION = 0x9F, CEC_MESSAGE_VENDOR_COMMAND_WITH_ID = 0xA0, CEC_MESSAGE_CLEAR_EXTERNAL_TIMER = 0xA1, CEC_MESSAGE_SET_EXTERNAL_TIMER = 0xA2, CEC_MESSAGE_INITIATE_ARC = 0xC0, CEC_MESSAGE_REPORT_ARC_INITIATED = 0xC1, CEC_MESSAGE_REPORT_ARC_TERMINATED = 0xC2, CEC_MESSAGE_REQUEST_ARC_INITIATION = 0xC3, CEC_MESSAGE_REQUEST_ARC_TERMINATION = 0xC4, CEC_MESSAGE_TERMINATE_ARC = 0xC5, CEC_MESSAGE_ABORT = 0xFF }; /* * Operand description [Abort Reason] */ enum abort_reason { ABORT_UNRECOGNIZED_MODE = 0, ABORT_NOT_IN_CORRECT_MODE = 1, ABORT_CANNOT_PROVIDE_SOURCE = 2, ABORT_INVALID_OPERAND = 3, ABORT_REFUSED = 4, ABORT_UNABLE_TO_DETERMINE = 5 }; /* * HDMI event type. used for hdmi_event_t. */ enum { HDMI_EVENT_CEC_MESSAGE = 1, HDMI_EVENT_HOT_PLUG = 2, }; /* * HDMI hotplug event type. Used when the event * type is HDMI_EVENT_HOT_PLUG. */ enum { HDMI_NOT_CONNECTED = 0, HDMI_CONNECTED = 1 }; /* * error code used for send_message. */ enum { HDMI_RESULT_SUCCESS = 0, HDMI_RESULT_NACK = 1, /* not acknowledged */ HDMI_RESULT_BUSY = 2, /* bus is busy */ HDMI_RESULT_FAIL = 3, }; /* * HDMI port type. */ typedef enum hdmi_port_type { HDMI_INPUT = 0, HDMI_OUTPUT = 1 } hdmi_port_type_t; /* * Flags used for set_option() */ enum { /* When set to false, HAL does not wake up the system upon receiving * or . Used when user changes the TV * settings to disable the auto TV on functionality. * True by default. */ HDMI_OPTION_WAKEUP = 1, /* When set to false, all the CEC commands are discarded. Used when * user changes the TV settings to disable CEC functionality. * True by default. */ HDMI_OPTION_ENABLE_CEC = 2, /* Setting this flag to false means Android system will stop handling * CEC service and yield the control over to the microprocessor that is * powered on through the standby mode. When set to true, the system * will gain the control over, hence telling the microprocessor to stop * handling the cec commands. This is called when system goes * in and out of standby mode to notify the microprocessor that it should * start/stop handling CEC commands on behalf of the system. * False by default. */ HDMI_OPTION_SYSTEM_CEC_CONTROL = 3, /* Option 4 not used */ /* Passes the updated language information of Android system. * Contains 3-byte ASCII code as defined in ISO/FDIS 639-2. Can be * used for HAL to respond to while in standby mode. * English(eng), for example, is converted to 0x656e67. */ HDMI_OPTION_SET_LANG = 5, }; /* * Maximum length in bytes of cec message body (exclude header block), * should not exceed 16 (spec CEC 6 Frame Description) */ #define CEC_MESSAGE_BODY_MAX_LENGTH 16 typedef struct cec_message { /* logical address of sender */ cec_logical_address_t initiator; /* logical address of receiver */ cec_logical_address_t destination; /* Length in bytes of body, range [0, CEC_MESSAGE_BODY_MAX_LENGTH] */ size_t length; unsigned char body[CEC_MESSAGE_BODY_MAX_LENGTH]; } cec_message_t; typedef struct hotplug_event { /* * true if the cable is connected; otherwise false. */ int connected; int port_id; } hotplug_event_t; typedef struct tx_status_event { int status; int opcode; /* CEC opcode */ } tx_status_event_t; /* * HDMI event generated from HAL. */ typedef struct hdmi_event { int type; struct hdmi_cec_device* dev; union { cec_message_t cec; hotplug_event_t hotplug; }; } hdmi_event_t; /* * HDMI port descriptor */ typedef struct hdmi_port_info { hdmi_port_type_t type; // Port ID should start from 1 which corresponds to HDMI "port 1". int port_id; int cec_supported; int arc_supported; uint16_t physical_address; } hdmi_port_info_t; /* * Callback function type that will be called by HAL implementation. * Services can not close/open the device in the callback. */ typedef void (*event_callback_t)(const hdmi_event_t* event, void* arg); typedef struct hdmi_cec_module { /** * Common methods of the HDMI CEC module. This *must* be the first member of * hdmi_cec_module as users of this structure will cast a hw_module_t to hdmi_cec_module * pointer in contexts where it's known the hw_module_t references a hdmi_cec_module. */ struct hw_module_t common; } hdmi_module_t; /* * HDMI-CEC HAL interface definition. */ typedef struct hdmi_cec_device { /** * Common methods of the HDMI CEC device. This *must* be the first member of * hdmi_cec_device as users of this structure will cast a hw_device_t to hdmi_cec_device * pointer in contexts where it's known the hw_device_t references a hdmi_cec_device. */ struct hw_device_t common; /* * (*add_logical_address)() passes the logical address that will be used * in this system. * * HAL may use it to configure the hardware so that the CEC commands addressed * the given logical address can be filtered in. This method can be called * as many times as necessary in order to support multiple logical devices. * addr should be in the range of valid logical addresses for the call * to succeed. * * Returns 0 on success or -errno on error. */ int (*add_logical_address)(const struct hdmi_cec_device* dev, cec_logical_address_t addr); /* * (*clear_logical_address)() tells HAL to reset all the logical addresses. * * It is used when the system doesn't need to process CEC command any more, * hence to tell HAL to stop receiving commands from the CEC bus, and change * the state back to the beginning. */ void (*clear_logical_address)(const struct hdmi_cec_device* dev); /* * (*get_physical_address)() returns the CEC physical address. The * address is written to addr. * * The physical address depends on the topology of the network formed * by connected HDMI devices. It is therefore likely to change if the cable * is plugged off and on again. It is advised to call get_physical_address * to get the updated address when hot plug event takes place. * * Returns 0 on success or -errno on error. */ int (*get_physical_address)(const struct hdmi_cec_device* dev, uint16_t* addr); /* * (*send_message)() transmits HDMI-CEC message to other HDMI device. * * The method should be designed to return in a certain amount of time not * hanging forever, which can happen if CEC signal line is pulled low for * some reason. HAL implementation should take the situation into account * so as not to wait forever for the message to get sent out. * * It should try retransmission at least once as specified in the standard. * * Returns error code. See HDMI_RESULT_SUCCESS, HDMI_RESULT_NACK, and * HDMI_RESULT_BUSY. */ int (*send_message)(const struct hdmi_cec_device* dev, const cec_message_t*); /* * (*register_event_callback)() registers a callback that HDMI-CEC HAL * can later use for incoming CEC messages or internal HDMI events. * When calling from C++, use the argument arg to pass the calling object. * It will be passed back when the callback is invoked so that the context * can be retrieved. */ void (*register_event_callback)(const struct hdmi_cec_device* dev, event_callback_t callback, void* arg); /* * (*get_version)() returns the CEC version supported by underlying hardware. */ void (*get_version)(const struct hdmi_cec_device* dev, int* version); /* * (*get_vendor_id)() returns the identifier of the vendor. It is * the 24-bit unique company ID obtained from the IEEE Registration * Authority Committee (RAC). */ void (*get_vendor_id)(const struct hdmi_cec_device* dev, uint32_t* vendor_id); /* * (*get_port_info)() returns the hdmi port information of underlying hardware. * info is the list of HDMI port information, and 'total' is the number of * HDMI ports in the system. */ void (*get_port_info)(const struct hdmi_cec_device* dev, struct hdmi_port_info* list[], int* total); /* * (*set_option)() passes flags controlling the way HDMI-CEC service works down * to HAL implementation. Those flags will be used in case the feature needs * update in HAL itself, firmware or microcontroller. */ void (*set_option)(const struct hdmi_cec_device* dev, int flag, int value); /* * (*set_audio_return_channel)() configures ARC circuit in the hardware logic * to start or stop the feature. Flag can be either 1 to start the feature * or 0 to stop it. * * Returns 0 on success or -errno on error. */ void (*set_audio_return_channel)(const struct hdmi_cec_device* dev, int port_id, int flag); /* * (*is_connected)() returns the connection status of the specified port. * Returns HDMI_CONNECTED if a device is connected, otherwise HDMI_NOT_CONNECTED. * The HAL should watch for +5V power signal to determine the status. */ int (*is_connected)(const struct hdmi_cec_device* dev, int port_id); /* Reserved for future use to maximum 16 functions. Must be NULL. */ void* reserved[16 - 11]; } hdmi_cec_device_t; /** convenience API for opening and closing a 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); } static inline int hdmi_cec_close(struct hdmi_cec_device* device) { return device->common.close(&device->common); } __END_DECLS #endif /* ANDROID_INCLUDE_HARDWARE_HDMI_CEC_H */ android-headers-23/23/hardware/hw_auth_token.h000066400000000000000000000031651264465411000213720ustar00rootroot00000000000000/* * 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. */ #include #ifndef ANDROID_HARDWARE_HW_AUTH_TOKEN_H #define ANDROID_HARDWARE_HW_AUTH_TOKEN_H #ifdef __cplusplus extern "C" { #endif // __cplusplus const uint8_t HW_AUTH_TOKEN_VERSION = 0; typedef enum { HW_AUTH_NONE = 0, HW_AUTH_PASSWORD = 1 << 0, HW_AUTH_FINGERPRINT = 1 << 1, // Additional entries should be powers of 2. HW_AUTH_ANY = UINT32_MAX, } hw_authenticator_type_t; /** * Data format for an authentication record used to prove successful authentication. */ typedef struct __attribute__((__packed__)) { uint8_t version; // Current version is 0 uint64_t challenge; uint64_t user_id; // secure user ID, not Android user ID uint64_t authenticator_id; // secure authenticator ID uint32_t authenticator_type; // hw_authenticator_type_t, in network order uint64_t timestamp; // in network order uint8_t hmac[32]; } hw_auth_token_t; #ifdef __cplusplus } // extern "C" #endif // __cplusplus #endif // ANDROID_HARDWARE_HW_AUTH_TOKEN_H android-headers-23/23/hardware/hwcomposer.h000066400000000000000000001051011264465411000207120ustar00rootroot00000000000000/* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H #define ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H #include #include #include #include #include #include __BEGIN_DECLS /*****************************************************************************/ /* for compatibility */ #define HWC_MODULE_API_VERSION HWC_MODULE_API_VERSION_0_1 #define HWC_DEVICE_API_VERSION HWC_DEVICE_API_VERSION_0_1 #define HWC_API_VERSION HWC_DEVICE_API_VERSION /*****************************************************************************/ /** * The id of this module */ #define HWC_HARDWARE_MODULE_ID "hwcomposer" /** * Name of the sensors device to open */ #define HWC_HARDWARE_COMPOSER "composer" typedef struct hwc_rect { int left; int top; int right; int bottom; } hwc_rect_t; typedef struct hwc_frect { float left; float top; float right; float bottom; } hwc_frect_t; typedef struct hwc_region { size_t numRects; hwc_rect_t const* rects; } hwc_region_t; typedef struct hwc_color { uint8_t r; uint8_t g; uint8_t b; uint8_t a; } hwc_color_t; typedef struct hwc_layer_1 { /* * compositionType is used to specify this layer's type and is set by either * the hardware composer implementation, or by the caller (see below). * * This field is always reset to HWC_BACKGROUND or HWC_FRAMEBUFFER * before (*prepare)() is called when the HWC_GEOMETRY_CHANGED flag is * also set, otherwise, this field is preserved between (*prepare)() * calls. * * HWC_BACKGROUND * Always set by the caller before calling (*prepare)(), this value * indicates this is a special "background" layer. The only valid field * is backgroundColor. * The HWC can toggle this value to HWC_FRAMEBUFFER to indicate it CANNOT * handle the background color. * * * HWC_FRAMEBUFFER_TARGET * Always set by the caller before calling (*prepare)(), this value * indicates this layer is the framebuffer surface used as the target of * OpenGL ES composition. If the HWC sets all other layers to HWC_OVERLAY * or HWC_BACKGROUND, then no OpenGL ES composition will be done, and * this layer should be ignored during set(). * * This flag (and the framebuffer surface layer) will only be used if the * HWC version is HWC_DEVICE_API_VERSION_1_1 or higher. In older versions, * the OpenGL ES target surface is communicated by the (dpy, sur) fields * in hwc_compositor_device_1_t. * * This value cannot be set by the HWC implementation. * * * HWC_FRAMEBUFFER * Set by the caller before calling (*prepare)() ONLY when the * HWC_GEOMETRY_CHANGED flag is also set. * * Set by the HWC implementation during (*prepare)(), this indicates * that the layer will be drawn into the framebuffer using OpenGL ES. * The HWC can toggle this value to HWC_OVERLAY to indicate it will * handle the layer. * * * HWC_OVERLAY * Set by the HWC implementation during (*prepare)(), this indicates * that the layer will be handled by the HWC (ie: it must not be * composited with OpenGL ES). * * * HWC_SIDEBAND * Set by the caller before calling (*prepare)(), this value indicates * the contents of this layer come from a sideband video stream. * * The h/w composer is responsible for receiving new image buffers from * the stream at the appropriate time (e.g. synchronized to a separate * audio stream), compositing them with the current contents of other * layers, and displaying the resulting image. This happens * independently of the normal prepare/set cycle. The prepare/set calls * only happen when other layers change, or when properties of the * sideband layer such as position or size change. * * If the h/w composer can't handle the layer as a sideband stream for * some reason (e.g. unsupported scaling/blending/rotation, or too many * sideband layers) it can set compositionType to HWC_FRAMEBUFFER in * (*prepare)(). However, doing so will result in the layer being shown * as a solid color since the platform is not currently able to composite * sideband layers with the GPU. This may be improved in future * versions of the platform. * * * HWC_CURSOR_OVERLAY * Set by the HWC implementation during (*prepare)(), this value * indicates the layer's composition will now be handled by the HWC. * Additionally, the client can now asynchronously update the on-screen * position of this layer using the setCursorPositionAsync() api. */ int32_t compositionType; /* * hints is bit mask set by the HWC implementation during (*prepare)(). * It is preserved between (*prepare)() calls, unless the * HWC_GEOMETRY_CHANGED flag is set, in which case it is reset to 0. * * see hwc_layer_t::hints */ uint32_t hints; /* see hwc_layer_t::flags */ uint32_t flags; union { /* color of the background. hwc_color_t.a is ignored */ hwc_color_t backgroundColor; struct { union { /* When compositionType is HWC_FRAMEBUFFER, HWC_OVERLAY, * HWC_FRAMEBUFFER_TARGET, this is the handle of the buffer to * compose. This handle is guaranteed to have been allocated * from gralloc using the GRALLOC_USAGE_HW_COMPOSER usage flag. * If the layer's handle is unchanged across two consecutive * prepare calls and the HWC_GEOMETRY_CHANGED flag is not set * for the second call then the HWComposer implementation may * assume that the contents of the buffer have not changed. */ buffer_handle_t handle; /* When compositionType is HWC_SIDEBAND, this is the handle * of the sideband video stream to compose. */ const native_handle_t* sidebandStream; }; /* transformation to apply to the buffer during composition */ uint32_t transform; /* blending to apply during composition */ int32_t blending; /* area of the source to consider, the origin is the top-left corner of * the buffer. As of HWC_DEVICE_API_VERSION_1_3, sourceRect uses floats. * If the h/w can't support a non-integer source crop rectangle, it should * punt to OpenGL ES composition. */ union { // crop rectangle in integer (pre HWC_DEVICE_API_VERSION_1_3) hwc_rect_t sourceCropi; hwc_rect_t sourceCrop; // just for source compatibility // crop rectangle in floats (as of HWC_DEVICE_API_VERSION_1_3) hwc_frect_t sourceCropf; }; /* where to composite the sourceCrop onto the display. The sourceCrop * is scaled using linear filtering to the displayFrame. The origin is the * top-left corner of the screen. */ hwc_rect_t displayFrame; /* visible region in screen space. The origin is the * top-left corner of the screen. * The visible region INCLUDES areas overlapped by a translucent layer. */ hwc_region_t visibleRegionScreen; /* Sync fence object that will be signaled when the buffer's * contents are available. May be -1 if the contents are already * available. This field is only valid during set(), and should be * ignored during prepare(). The set() call must not wait for the * fence to be signaled before returning, but the HWC must wait for * all buffers to be signaled before reading from them. * * HWC_FRAMEBUFFER layers will never have an acquire fence, since * reads from them are complete before the framebuffer is ready for * display. * * HWC_SIDEBAND layers will never have an acquire fence, since * synchronization is handled through implementation-defined * sideband mechanisms. * * The HWC takes ownership of the acquireFenceFd and is responsible * for closing it when no longer needed. */ int acquireFenceFd; /* During set() the HWC must set this field to a file descriptor for * a sync fence object that will signal after the HWC has finished * reading from the buffer. The field is ignored by prepare(). Each * layer should have a unique file descriptor, even if more than one * refer to the same underlying fence object; this allows each to be * closed independently. * * If buffer reads can complete at significantly different times, * then using independent fences is preferred. For example, if the * HWC handles some layers with a blit engine and others with * overlays, then the blit layers can be reused immediately after * the blit completes, but the overlay layers can't be reused until * a subsequent frame has been displayed. * * Since HWC doesn't read from HWC_FRAMEBUFFER layers, it shouldn't * produce a release fence for them. The releaseFenceFd will be -1 * for these layers when set() is called. * * Since HWC_SIDEBAND buffers don't pass through the HWC client, * the HWC shouldn't produce a release fence for them. The * releaseFenceFd will be -1 for these layers when set() is called. * * The HWC client taks ownership of the releaseFenceFd and is * responsible for closing it when no longer needed. */ int releaseFenceFd; /* * Availability: HWC_DEVICE_API_VERSION_1_2 * * Alpha value applied to the whole layer. The effective * value of each pixel is computed as: * * if (blending == HWC_BLENDING_PREMULT) * pixel.rgb = pixel.rgb * planeAlpha / 255 * pixel.a = pixel.a * planeAlpha / 255 * * Then blending proceeds as usual according to the "blending" * field above. * * NOTE: planeAlpha applies to YUV layers as well: * * pixel.rgb = yuv_to_rgb(pixel.yuv) * if (blending == HWC_BLENDING_PREMULT) * pixel.rgb = pixel.rgb * planeAlpha / 255 * pixel.a = planeAlpha * * * IMPLEMENTATION NOTE: * * If the source image doesn't have an alpha channel, then * the h/w can use the HWC_BLENDING_COVERAGE equations instead of * HWC_BLENDING_PREMULT and simply set the alpha channel to * planeAlpha. * * e.g.: * * if (blending == HWC_BLENDING_PREMULT) * blending = HWC_BLENDING_COVERAGE; * pixel.a = planeAlpha; * */ uint8_t planeAlpha; /* Pad to 32 bits */ uint8_t _pad[3]; /* * Availability: HWC_DEVICE_API_VERSION_1_5 * * This defines the region of the source buffer that has been * modified since the last frame. * * If surfaceDamage.numRects > 0, then it may be assumed that any * portion of the source buffer not covered by one of the rects has * not been modified this frame. If surfaceDamage.numRects == 0, * then the whole source buffer must be treated as if it had been * modified. * * If the layer's contents are not modified relative to the prior * prepare/set cycle, surfaceDamage will contain exactly one empty * rect ([0, 0, 0, 0]). * * The damage rects are relative to the pre-transformed buffer, and * their origin is the top-left corner. */ hwc_region_t surfaceDamage; }; }; #ifdef __LP64__ /* * For 64-bit mode, this struct is 120 bytes (and 8-byte aligned), and needs * to be padded as such to maintain binary compatibility. */ uint8_t reserved[120 - 112]; #else /* * For 32-bit mode, this struct is 96 bytes, and needs to be padded as such * to maintain binary compatibility. */ uint8_t reserved[96 - 84]; #endif } hwc_layer_1_t; /* This represents a display, typically an EGLDisplay object */ typedef void* hwc_display_t; /* This represents a surface, typically an EGLSurface object */ typedef void* hwc_surface_t; /* * hwc_display_contents_1_t::flags values */ enum { /* * HWC_GEOMETRY_CHANGED is set by SurfaceFlinger to indicate that the list * passed to (*prepare)() has changed by more than just the buffer handles * and acquire fences. */ HWC_GEOMETRY_CHANGED = 0x00000001, }; /* * Description of the contents to output on a display. * * This is the top-level structure passed to the prepare and set calls to * negotiate and commit the composition of a display image. */ typedef struct hwc_display_contents_1 { /* File descriptor referring to a Sync HAL fence object which will signal * when this composition is retired. For a physical display, a composition * is retired when it has been replaced on-screen by a subsequent set. For * a virtual display, the composition is retired when the writes to * outputBuffer are complete and can be read. The fence object is created * and returned by the set call; this field will be -1 on entry to prepare * and set. SurfaceFlinger will close the returned file descriptor. */ int retireFenceFd; union { /* Fields only relevant for HWC_DEVICE_VERSION_1_0. */ struct { /* (dpy, sur) is the target of SurfaceFlinger's OpenGL ES * composition for HWC_DEVICE_VERSION_1_0. They aren't relevant to * prepare. The set call should commit this surface atomically to * the display along with any overlay layers. */ hwc_display_t dpy; hwc_surface_t sur; }; /* These fields are used for virtual displays when the h/w composer * version is at least HWC_DEVICE_VERSION_1_3. */ struct { /* outbuf is the buffer that receives the composed image for * virtual displays. Writes to the outbuf must wait until * outbufAcquireFenceFd signals. A fence that will signal when * writes to outbuf are complete should be returned in * retireFenceFd. * * This field is set before prepare(), so properties of the buffer * can be used to decide which layers can be handled by h/w * composer. * * If prepare() sets all layers to FRAMEBUFFER, then GLES * composition will happen directly to the output buffer. In this * case, both outbuf and the FRAMEBUFFER_TARGET layer's buffer will * be the same, and set() has no work to do besides managing fences. * * If the TARGET_FORCE_HWC_FOR_VIRTUAL_DISPLAYS board config * variable is defined (not the default), then this behavior is * changed: if all layers are marked for FRAMEBUFFER, GLES * composition will take place to a scratch framebuffer, and * h/w composer must copy it to the output buffer. This allows the * h/w composer to do format conversion if there are cases where * that is more desirable than doing it in the GLES driver or at the * virtual display consumer. * * If some or all layers are marked OVERLAY, then the framebuffer * and output buffer will be different. As with physical displays, * the framebuffer handle will not change between frames if all * layers are marked for OVERLAY. */ buffer_handle_t outbuf; /* File descriptor for a fence that will signal when outbuf is * ready to be written. The h/w composer is responsible for closing * this when no longer needed. * * Will be -1 whenever outbuf is NULL, or when the outbuf can be * written immediately. */ int outbufAcquireFenceFd; }; }; /* List of layers that will be composed on the display. The buffer handles * in the list will be unique. If numHwLayers is 0, all composition will be * performed by SurfaceFlinger. */ uint32_t flags; size_t numHwLayers; hwc_layer_1_t hwLayers[0]; } hwc_display_contents_1_t; /* see hwc_composer_device::registerProcs() * All of the callbacks are required and non-NULL unless otherwise noted. */ typedef struct hwc_procs { /* * (*invalidate)() triggers a screen refresh, in particular prepare and set * will be called shortly after this call is made. Note that there is * NO GUARANTEE that the screen refresh will happen after invalidate() * returns (in particular, it could happen before). * invalidate() is GUARANTEED TO NOT CALL BACK into the h/w composer HAL and * it is safe to call invalidate() from any of hwc_composer_device * hooks, unless noted otherwise. */ void (*invalidate)(const struct hwc_procs* procs); /* * (*vsync)() is called by the h/w composer HAL when a vsync event is * received and HWC_EVENT_VSYNC is enabled on a display * (see: hwc_event_control). * * the "disp" parameter indicates which display the vsync event is for. * the "timestamp" parameter is the system monotonic clock timestamp in * nanosecond of when the vsync event happened. * * vsync() is GUARANTEED TO NOT CALL BACK into the h/w composer HAL. * * It is expected that vsync() is called from a thread of at least * HAL_PRIORITY_URGENT_DISPLAY with as little latency as possible, * typically less than 0.5 ms. * * It is a (silent) error to have HWC_EVENT_VSYNC enabled when calling * hwc_composer_device.set(..., 0, 0, 0) (screen off). The implementation * can either stop or continue to process VSYNC events, but must not * crash or cause other problems. */ void (*vsync)(const struct hwc_procs* procs, int disp, int64_t timestamp); /* * (*hotplug)() is called by the h/w composer HAL when a display is * connected or disconnected. The PRIMARY display is always connected and * the hotplug callback should not be called for it. * * The disp parameter indicates which display type this event is for. * The connected parameter indicates whether the display has just been * connected (1) or disconnected (0). * * The hotplug() callback may call back into the h/w composer on the same * thread to query refresh rate and dpi for the display. Additionally, * other threads may be calling into the h/w composer while the callback * is in progress. * * The h/w composer must serialize calls to the hotplug callback; only * one thread may call it at a time. * * This callback will be NULL if the h/w composer is using * HWC_DEVICE_API_VERSION_1_0. */ void (*hotplug)(const struct hwc_procs* procs, int disp, int connected); } hwc_procs_t; /*****************************************************************************/ typedef struct hwc_module { /** * Common methods of the hardware composer module. This *must* be the first member of * hwc_module as users of this structure will cast a hw_module_t to * hwc_module pointer in contexts where it's known the hw_module_t references a * hwc_module. */ struct hw_module_t common; } hwc_module_t; typedef struct hwc_composer_device_1 { /** * Common methods of the hardware composer device. This *must* be the first member of * hwc_composer_device_1 as users of this structure will cast a hw_device_t to * hwc_composer_device_1 pointer in contexts where it's known the hw_device_t references a * hwc_composer_device_1. */ struct hw_device_t common; /* * (*prepare)() is called for each frame before composition and is used by * SurfaceFlinger to determine what composition steps the HWC can handle. * * (*prepare)() can be called more than once, the last call prevails. * * The HWC responds by setting the compositionType field in each layer to * either HWC_FRAMEBUFFER, HWC_OVERLAY, or HWC_CURSOR_OVERLAY. For the * HWC_FRAMEBUFFER type, composition for the layer is handled by * SurfaceFlinger with OpenGL ES. For the latter two overlay types, * the HWC will have to handle the layer's composition. compositionType * and hints are preserved between (*prepare)() calles unless the * HWC_GEOMETRY_CHANGED flag is set. * * (*prepare)() is called with HWC_GEOMETRY_CHANGED to indicate that the * list's geometry has changed, that is, when more than just the buffer's * handles have been updated. Typically this happens (but is not limited to) * when a window is added, removed, resized or moved. In this case * compositionType and hints are reset to their default value. * * For HWC 1.0, numDisplays will always be one, and displays[0] will be * non-NULL. * * For HWC 1.1, numDisplays will always be HWC_NUM_PHYSICAL_DISPLAY_TYPES. * Entries for unsupported or disabled/disconnected display types will be * NULL. * * In HWC 1.3, numDisplays may be up to HWC_NUM_DISPLAY_TYPES. The extra * entries correspond to enabled virtual displays, and will be non-NULL. * * returns: 0 on success. An negative error code on error. If an error is * returned, SurfaceFlinger will assume that none of the layer will be * handled by the HWC. */ int (*prepare)(struct hwc_composer_device_1 *dev, size_t numDisplays, hwc_display_contents_1_t** displays); /* * (*set)() is used in place of eglSwapBuffers(), and assumes the same * functionality, except it also commits the work list atomically with * the actual eglSwapBuffers(). * * The layer lists are guaranteed to be the same as the ones returned from * the last call to (*prepare)(). * * When this call returns the caller assumes that the displays will be * updated in the near future with the content of their work lists, without * artifacts during the transition from the previous frame. * * A display with zero layers indicates that the entire composition has * been handled by SurfaceFlinger with OpenGL ES. In this case, (*set)() * behaves just like eglSwapBuffers(). * * For HWC 1.0, numDisplays will always be one, and displays[0] will be * non-NULL. * * For HWC 1.1, numDisplays will always be HWC_NUM_PHYSICAL_DISPLAY_TYPES. * Entries for unsupported or disabled/disconnected display types will be * NULL. * * In HWC 1.3, numDisplays may be up to HWC_NUM_DISPLAY_TYPES. The extra * entries correspond to enabled virtual displays, and will be non-NULL. * * IMPORTANT NOTE: There is an implicit layer containing opaque black * pixels behind all the layers in the list. It is the responsibility of * the hwcomposer module to make sure black pixels are output (or blended * from). * * IMPORTANT NOTE: In the event of an error this call *MUST* still cause * any fences returned in the previous call to set to eventually become * signaled. The caller may have already issued wait commands on these * fences, and having set return without causing those fences to signal * will likely result in a deadlock. * * returns: 0 on success. A negative error code on error: * HWC_EGL_ERROR: eglGetError() will provide the proper error code (only * allowed prior to HWComposer 1.1) * Another code for non EGL errors. */ int (*set)(struct hwc_composer_device_1 *dev, size_t numDisplays, hwc_display_contents_1_t** displays); /* * eventControl(..., event, enabled) * Enables or disables h/w composer events for a display. * * eventControl can be called from any thread and takes effect * immediately. * * Supported events are: * HWC_EVENT_VSYNC * * returns -EINVAL if the "event" parameter is not one of the value above * or if the "enabled" parameter is not 0 or 1. */ int (*eventControl)(struct hwc_composer_device_1* dev, int disp, int event, int enabled); union { /* * For HWC 1.3 and earlier, the blank() interface is used. * * blank(..., blank) * Blanks or unblanks a display's screen. * * Turns the screen off when blank is nonzero, on when blank is zero. * Multiple sequential calls with the same blank value must be * supported. * The screen state transition must be be complete when the function * returns. * * returns 0 on success, negative on error. */ int (*blank)(struct hwc_composer_device_1* dev, int disp, int blank); /* * For HWC 1.4 and above, setPowerMode() will be used in place of * blank(). * * setPowerMode(..., mode) * Sets the display screen's power state. * * Refer to the documentation of the HWC_POWER_MODE_* constants * for information about each power mode. * * The functionality is similar to the blank() command in previous * versions of HWC, but with support for more power states. * * The display driver is expected to retain and restore the low power * state of the display while entering and exiting from suspend. * * Multiple sequential calls with the same mode value must be supported. * * The screen state transition must be be complete when the function * returns. * * returns 0 on success, negative on error. */ int (*setPowerMode)(struct hwc_composer_device_1* dev, int disp, int mode); }; /* * Used to retrieve information about the h/w composer * * Returns 0 on success or -errno on error. */ int (*query)(struct hwc_composer_device_1* dev, int what, int* value); /* * (*registerProcs)() registers callbacks that the h/w composer HAL can * later use. It will be called immediately after the composer device is * opened with non-NULL procs. It is FORBIDDEN to call any of the callbacks * from within registerProcs(). registerProcs() must save the hwc_procs_t * pointer which is needed when calling a registered callback. */ void (*registerProcs)(struct hwc_composer_device_1* dev, hwc_procs_t const* procs); /* * This field is OPTIONAL and can be NULL. * * If non NULL it will be called by SurfaceFlinger on dumpsys */ void (*dump)(struct hwc_composer_device_1* dev, char *buff, int buff_len); /* * (*getDisplayConfigs)() returns handles for the configurations available * on the connected display. These handles must remain valid as long as the * display is connected. * * Configuration handles are written to configs. The number of entries * allocated by the caller is passed in *numConfigs; getDisplayConfigs must * not try to write more than this number of config handles. On return, the * total number of configurations available for the display is returned in * *numConfigs. If *numConfigs is zero on entry, then configs may be NULL. * * Hardware composers implementing HWC_DEVICE_API_VERSION_1_3 or prior * shall choose one configuration to activate and report it as the first * entry in the returned list. Reporting the inactive configurations is not * required. * * HWC_DEVICE_API_VERSION_1_4 and later provide configuration management * through SurfaceFlinger, and hardware composers implementing these APIs * must also provide getActiveConfig and setActiveConfig. Hardware composers * implementing these API versions may choose not to activate any * configuration, leaving configuration selection to higher levels of the * framework. * * Returns 0 on success or a negative error code on error. If disp is a * hotpluggable display type and no display is connected, an error shall be * returned. * * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_1 and later. * It shall be NULL for previous versions. */ int (*getDisplayConfigs)(struct hwc_composer_device_1* dev, int disp, uint32_t* configs, size_t* numConfigs); /* * (*getDisplayAttributes)() returns attributes for a specific config of a * connected display. The config parameter is one of the config handles * returned by getDisplayConfigs. * * The list of attributes to return is provided in the attributes * parameter, terminated by HWC_DISPLAY_NO_ATTRIBUTE. The value for each * requested attribute is written in order to the values array. The * HWC_DISPLAY_NO_ATTRIBUTE attribute does not have a value, so the values * array will have one less value than the attributes array. * * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_1 and later. * It shall be NULL for previous versions. * * If disp is a hotpluggable display type and no display is connected, * or if config is not a valid configuration for the display, a negative * error code shall be returned. */ int (*getDisplayAttributes)(struct hwc_composer_device_1* dev, int disp, uint32_t config, const uint32_t* attributes, int32_t* values); /* * (*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. * * Returns the configuration index on success or -1 on error. * * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_4 and later. * It shall be NULL for previous versions. */ int (*getActiveConfig)(struct hwc_composer_device_1* dev, int disp); /* * (*setActiveConfig)() instructs the hardware composer to switch to the * display configuration at the given index in the list of configuration * handles returned by getDisplayConfigs. * * If this function returns without error, any subsequent calls to * getActiveConfig shall return the index set by this function until one * of the following occurs: * 1) Another successful call of this function * 2) The display is disconnected * * Returns 0 on success or a negative error code on error. If disp is a * hotpluggable display type and no display is connected, or if index is * outside of the range of hardware configurations returned by * getDisplayConfigs, an error shall be returned. * * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_4 and later. * It shall be NULL for previous versions. */ int (*setActiveConfig)(struct hwc_composer_device_1* dev, int disp, int index); /* * Asynchronously update the location of the cursor layer. * * Within the standard prepare()/set() composition loop, the client * (surfaceflinger) can request that a given layer uses dedicated cursor * composition hardware by specifiying the HWC_IS_CURSOR_LAYER flag. Only * one layer per display can have this flag set. If the layer is suitable * for the platform's cursor hardware, hwcomposer will return from prepare() * a composition type of HWC_CURSOR_OVERLAY for that layer. This indicates * not only that the client is not responsible for compositing that layer, * but also that the client can continue to update the position of that layer * after a call to set(). This can reduce the visible latency of mouse * movement to visible, on-screen cursor updates. Calls to * setCursorPositionAsync() may be made from a different thread doing the * prepare()/set() composition loop, but care must be taken to not interleave * calls of setCursorPositionAsync() between calls of set()/prepare(). * * Notes: * - Only one layer per display can be specified as a cursor layer with * HWC_IS_CURSOR_LAYER. * - hwcomposer will only return one layer per display as HWC_CURSOR_OVERLAY * - This returns 0 on success or -errno on error. * - This field is optional for HWC_DEVICE_API_VERSION_1_4 and later. It * should be null for previous versions. */ int (*setCursorPositionAsync)(struct hwc_composer_device_1 *dev, int disp, int x_pos, int y_pos); /* * Reserved for future use. Must be NULL. */ void* reserved_proc[1]; } hwc_composer_device_1_t; /** convenience API for opening and closing a device */ 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); } static inline int hwc_close_1(hwc_composer_device_1_t* device) { return device->common.close(&device->common); } /*****************************************************************************/ __END_DECLS #endif /* ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H */ android-headers-23/23/hardware/hwcomposer_defs.h000066400000000000000000000206301264465411000217160ustar00rootroot00000000000000/* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_DEFS_H #define ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_DEFS_H #include #include #include #include #include __BEGIN_DECLS /*****************************************************************************/ #define HWC_HEADER_VERSION 1 #define HWC_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define HWC_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION_2(1, 0, HWC_HEADER_VERSION) #define HWC_DEVICE_API_VERSION_1_1 HARDWARE_DEVICE_API_VERSION_2(1, 1, HWC_HEADER_VERSION) #define HWC_DEVICE_API_VERSION_1_2 HARDWARE_DEVICE_API_VERSION_2(1, 2, HWC_HEADER_VERSION) #define HWC_DEVICE_API_VERSION_1_3 HARDWARE_DEVICE_API_VERSION_2(1, 3, HWC_HEADER_VERSION) #define HWC_DEVICE_API_VERSION_1_4 HARDWARE_DEVICE_API_VERSION_2(1, 4, HWC_HEADER_VERSION) #define HWC_DEVICE_API_VERSION_1_5 HARDWARE_DEVICE_API_VERSION_2(1, 5, HWC_HEADER_VERSION) enum { /* hwc_composer_device_t::set failed in EGL */ HWC_EGL_ERROR = -1 }; /* * hwc_layer_t::hints values * Hints are set by the HAL and read by SurfaceFlinger */ enum { /* * HWC can set the HWC_HINT_TRIPLE_BUFFER hint to indicate to SurfaceFlinger * that it should triple buffer this layer. Typically HWC does this when * the layer will be unavailable for use for an extended period of time, * e.g. if the display will be fetching data directly from the layer and * the layer can not be modified until after the next set(). */ HWC_HINT_TRIPLE_BUFFER = 0x00000001, /* * HWC sets HWC_HINT_CLEAR_FB to tell SurfaceFlinger that it should clear the * framebuffer with transparent pixels where this layer would be. * SurfaceFlinger will only honor this flag when the layer has no blending * */ HWC_HINT_CLEAR_FB = 0x00000002 }; /* * hwc_layer_t::flags values * Flags are set by SurfaceFlinger and read by the HAL */ enum { /* * HWC_SKIP_LAYER is set by SurfaceFlnger 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). */ HWC_SKIP_LAYER = 0x00000001, /* * HWC_IS_CURSOR_LAYER is set by surfaceflinger to indicate that this * layer is being used as a cursor on this particular display, and that * surfaceflinger can potentially perform asynchronous position updates for * this layer. If a call to prepare() returns HWC_CURSOR_OVERLAY for the * composition type of this layer, then the hwcomposer will allow async * position updates to this layer via setCursorPositionAsync(). */ HWC_IS_CURSOR_LAYER = 0x00000002 }; /* * hwc_layer_t::compositionType values */ enum { /* this layer is to be drawn into the framebuffer by SurfaceFlinger */ HWC_FRAMEBUFFER = 0, /* this layer will be handled in the HWC */ HWC_OVERLAY = 1, /* this is the background layer. it's used to set the background color. * there is only a single background layer */ HWC_BACKGROUND = 2, /* this layer holds the result of compositing the HWC_FRAMEBUFFER layers. * Added in HWC_DEVICE_API_VERSION_1_1. */ HWC_FRAMEBUFFER_TARGET = 3, /* this layer's contents are taken from a sideband buffer stream. * Added in HWC_DEVICE_API_VERSION_1_4. */ HWC_SIDEBAND = 4, /* this layer's composition will be handled by hwcomposer by dedicated cursor overlay hardware. hwcomposer will also all async position updates of this layer outside of the normal prepare()/set() loop. Added in HWC_DEVICE_API_VERSION_1_4. */ HWC_CURSOR_OVERLAY = 5 }; /* * hwc_layer_t::blending values */ enum { /* no blending */ HWC_BLENDING_NONE = 0x0100, /* ONE / ONE_MINUS_SRC_ALPHA */ HWC_BLENDING_PREMULT = 0x0105, /* SRC_ALPHA / ONE_MINUS_SRC_ALPHA */ HWC_BLENDING_COVERAGE = 0x0405 }; /* * hwc_layer_t::transform values */ enum { /* flip source image horizontally */ HWC_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H, /* flip source image vertically */ HWC_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V, /* rotate source image 90 degrees clock-wise */ HWC_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90, /* rotate source image 180 degrees */ HWC_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180, /* rotate source image 270 degrees clock-wise */ HWC_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270, }; /* attributes queriable with query() */ enum { /* * Must return 1 if the background layer is supported, 0 otherwise. */ HWC_BACKGROUND_LAYER_SUPPORTED = 0, /* * Returns the vsync period in nanoseconds. * * This query is not used for HWC_DEVICE_API_VERSION_1_1 and later. * Instead, the per-display attribute HWC_DISPLAY_VSYNC_PERIOD is used. */ HWC_VSYNC_PERIOD = 1, /* * Availability: HWC_DEVICE_API_VERSION_1_1 * Returns a mask of supported display types. */ HWC_DISPLAY_TYPES_SUPPORTED = 2, }; /* display attributes returned by getDisplayAttributes() */ enum { /* Indicates the end of an attribute list */ HWC_DISPLAY_NO_ATTRIBUTE = 0, /* The vsync period in nanoseconds */ HWC_DISPLAY_VSYNC_PERIOD = 1, /* The number of pixels in the horizontal and vertical directions. */ HWC_DISPLAY_WIDTH = 2, HWC_DISPLAY_HEIGHT = 3, /* The number of pixels per thousand inches of this configuration. * * Scaling DPI by 1000 allows it to be stored in an int without losing * too much precision. * * If the DPI for a configuration is unavailable or the HWC implementation * considers it unreliable, it should set these attributes to zero. */ HWC_DISPLAY_DPI_X = 4, HWC_DISPLAY_DPI_Y = 5, }; /* Allowed events for hwc_methods::eventControl() */ enum { HWC_EVENT_VSYNC = 0 }; /* Display types and associated mask bits. */ enum { HWC_DISPLAY_PRIMARY = 0, HWC_DISPLAY_EXTERNAL = 1, // HDMI, DP, etc. HWC_DISPLAY_VIRTUAL = 2, HWC_NUM_PHYSICAL_DISPLAY_TYPES = 2, HWC_NUM_DISPLAY_TYPES = 3, }; enum { HWC_DISPLAY_PRIMARY_BIT = 1 << HWC_DISPLAY_PRIMARY, HWC_DISPLAY_EXTERNAL_BIT = 1 << HWC_DISPLAY_EXTERNAL, HWC_DISPLAY_VIRTUAL_BIT = 1 << HWC_DISPLAY_VIRTUAL, }; /* Display power modes */ enum { /* The display is turned off (blanked). */ HWC_POWER_MODE_OFF = 0, /* The display is turned on and configured in a low power state * that is suitable for presenting ambient information to the user, * possibly with lower fidelity than normal but greater efficiency. */ HWC_POWER_MODE_DOZE = 1, /* The display is turned on normally. */ HWC_POWER_MODE_NORMAL = 2, /* The display is configured as in HWC_POWER_MODE_DOZE but may * stop applying frame buffer updates from the graphics subsystem. * This power mode is effectively a hint from the doze dream to * tell the hardware that it is done drawing to the display for the * time being and that the display should remain on in a low power * state and continue showing its current contents indefinitely * until the mode changes. * * This mode may also be used as a signal to enable hardware-based doze * functionality. In this case, the doze dream is effectively * indicating that the hardware is free to take over the display * and manage it autonomously to implement low power always-on display * functionality. */ HWC_POWER_MODE_DOZE_SUSPEND = 3, }; /*****************************************************************************/ __END_DECLS #endif /* ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_DEFS_H */ android-headers-23/23/hardware/input.h000066400000000000000000000457241264465411000177010ustar00rootroot00000000000000/* * 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_INCLUDE_HARDWARE_INPUT_H #define ANDROID_INCLUDE_HARDWARE_INPUT_H #include #include __BEGIN_DECLS #define INPUT_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) #define INPUT_HARDWARE_MODULE_ID "input" #define INPUT_INSTANCE_EVDEV "evdev" typedef enum input_bus { INPUT_BUS_BT, INPUT_BUS_USB, INPUT_BUS_SERIAL, INPUT_BUS_BUILTIN } input_bus_t; typedef struct input_host input_host_t; typedef struct input_device_handle input_device_handle_t; typedef struct input_device_identifier input_device_identifier_t; typedef struct input_device_definition input_device_definition_t; typedef struct input_report_definition input_report_definition_t; typedef struct input_report input_report_t; typedef struct input_collection input_collection_t; typedef struct input_property_map input_property_map_t; typedef struct input_property input_property_t; typedef enum { // keycodes INPUT_USAGE_KEYCODE_UNKNOWN, INPUT_USAGE_KEYCODE_SOFT_LEFT, INPUT_USAGE_KEYCODE_SOFT_RIGHT, INPUT_USAGE_KEYCODE_HOME, INPUT_USAGE_KEYCODE_BACK, INPUT_USAGE_KEYCODE_CALL, INPUT_USAGE_KEYCODE_ENDCALL, INPUT_USAGE_KEYCODE_0, INPUT_USAGE_KEYCODE_1, INPUT_USAGE_KEYCODE_2, INPUT_USAGE_KEYCODE_3, INPUT_USAGE_KEYCODE_4, INPUT_USAGE_KEYCODE_5, INPUT_USAGE_KEYCODE_6, INPUT_USAGE_KEYCODE_7, INPUT_USAGE_KEYCODE_8, INPUT_USAGE_KEYCODE_9, INPUT_USAGE_KEYCODE_STAR, INPUT_USAGE_KEYCODE_POUND, INPUT_USAGE_KEYCODE_DPAD_UP, INPUT_USAGE_KEYCODE_DPAD_DOWN, INPUT_USAGE_KEYCODE_DPAD_LEFT, INPUT_USAGE_KEYCODE_DPAD_RIGHT, INPUT_USAGE_KEYCODE_DPAD_CENTER, INPUT_USAGE_KEYCODE_VOLUME_UP, INPUT_USAGE_KEYCODE_VOLUME_DOWN, INPUT_USAGE_KEYCODE_POWER, INPUT_USAGE_KEYCODE_CAMERA, INPUT_USAGE_KEYCODE_CLEAR, INPUT_USAGE_KEYCODE_A, INPUT_USAGE_KEYCODE_B, INPUT_USAGE_KEYCODE_C, INPUT_USAGE_KEYCODE_D, INPUT_USAGE_KEYCODE_E, INPUT_USAGE_KEYCODE_F, INPUT_USAGE_KEYCODE_G, INPUT_USAGE_KEYCODE_H, INPUT_USAGE_KEYCODE_I, INPUT_USAGE_KEYCODE_J, INPUT_USAGE_KEYCODE_K, INPUT_USAGE_KEYCODE_L, INPUT_USAGE_KEYCODE_M, INPUT_USAGE_KEYCODE_N, INPUT_USAGE_KEYCODE_O, INPUT_USAGE_KEYCODE_P, INPUT_USAGE_KEYCODE_Q, INPUT_USAGE_KEYCODE_R, INPUT_USAGE_KEYCODE_S, INPUT_USAGE_KEYCODE_T, INPUT_USAGE_KEYCODE_U, INPUT_USAGE_KEYCODE_V, INPUT_USAGE_KEYCODE_W, INPUT_USAGE_KEYCODE_X, INPUT_USAGE_KEYCODE_Y, INPUT_USAGE_KEYCODE_Z, INPUT_USAGE_KEYCODE_COMMA, INPUT_USAGE_KEYCODE_PERIOD, INPUT_USAGE_KEYCODE_ALT_LEFT, INPUT_USAGE_KEYCODE_ALT_RIGHT, INPUT_USAGE_KEYCODE_SHIFT_LEFT, INPUT_USAGE_KEYCODE_SHIFT_RIGHT, INPUT_USAGE_KEYCODE_TAB, INPUT_USAGE_KEYCODE_SPACE, INPUT_USAGE_KEYCODE_SYM, INPUT_USAGE_KEYCODE_EXPLORER, INPUT_USAGE_KEYCODE_ENVELOPE, INPUT_USAGE_KEYCODE_ENTER, INPUT_USAGE_KEYCODE_DEL, INPUT_USAGE_KEYCODE_GRAVE, INPUT_USAGE_KEYCODE_MINUS, INPUT_USAGE_KEYCODE_EQUALS, INPUT_USAGE_KEYCODE_LEFT_BRACKET, INPUT_USAGE_KEYCODE_RIGHT_BRACKET, INPUT_USAGE_KEYCODE_BACKSLASH, INPUT_USAGE_KEYCODE_SEMICOLON, INPUT_USAGE_KEYCODE_APOSTROPHE, INPUT_USAGE_KEYCODE_SLASH, INPUT_USAGE_KEYCODE_AT, INPUT_USAGE_KEYCODE_NUM, INPUT_USAGE_KEYCODE_HEADSETHOOK, INPUT_USAGE_KEYCODE_FOCUS, // *Camera* focus INPUT_USAGE_KEYCODE_PLUS, INPUT_USAGE_KEYCODE_MENU, INPUT_USAGE_KEYCODE_NOTIFICATION, INPUT_USAGE_KEYCODE_SEARCH, INPUT_USAGE_KEYCODE_MEDIA_PLAY_PAUSE, INPUT_USAGE_KEYCODE_MEDIA_STOP, INPUT_USAGE_KEYCODE_MEDIA_NEXT, INPUT_USAGE_KEYCODE_MEDIA_PREVIOUS, INPUT_USAGE_KEYCODE_MEDIA_REWIND, INPUT_USAGE_KEYCODE_MEDIA_FAST_FORWARD, INPUT_USAGE_KEYCODE_MUTE, INPUT_USAGE_KEYCODE_PAGE_UP, INPUT_USAGE_KEYCODE_PAGE_DOWN, INPUT_USAGE_KEYCODE_PICTSYMBOLS, INPUT_USAGE_KEYCODE_SWITCH_CHARSET, INPUT_USAGE_KEYCODE_BUTTON_A, INPUT_USAGE_KEYCODE_BUTTON_B, INPUT_USAGE_KEYCODE_BUTTON_C, INPUT_USAGE_KEYCODE_BUTTON_X, INPUT_USAGE_KEYCODE_BUTTON_Y, INPUT_USAGE_KEYCODE_BUTTON_Z, INPUT_USAGE_KEYCODE_BUTTON_L1, INPUT_USAGE_KEYCODE_BUTTON_R1, INPUT_USAGE_KEYCODE_BUTTON_L2, INPUT_USAGE_KEYCODE_BUTTON_R2, INPUT_USAGE_KEYCODE_BUTTON_THUMBL, INPUT_USAGE_KEYCODE_BUTTON_THUMBR, INPUT_USAGE_KEYCODE_BUTTON_START, INPUT_USAGE_KEYCODE_BUTTON_SELECT, INPUT_USAGE_KEYCODE_BUTTON_MODE, INPUT_USAGE_KEYCODE_ESCAPE, INPUT_USAGE_KEYCODE_FORWARD_DEL, INPUT_USAGE_KEYCODE_CTRL_LEFT, INPUT_USAGE_KEYCODE_CTRL_RIGHT, INPUT_USAGE_KEYCODE_CAPS_LOCK, INPUT_USAGE_KEYCODE_SCROLL_LOCK, INPUT_USAGE_KEYCODE_META_LEFT, INPUT_USAGE_KEYCODE_META_RIGHT, INPUT_USAGE_KEYCODE_FUNCTION, INPUT_USAGE_KEYCODE_SYSRQ, INPUT_USAGE_KEYCODE_BREAK, INPUT_USAGE_KEYCODE_MOVE_HOME, INPUT_USAGE_KEYCODE_MOVE_END, INPUT_USAGE_KEYCODE_INSERT, INPUT_USAGE_KEYCODE_FORWARD, INPUT_USAGE_KEYCODE_MEDIA_PLAY, INPUT_USAGE_KEYCODE_MEDIA_PAUSE, INPUT_USAGE_KEYCODE_MEDIA_CLOSE, INPUT_USAGE_KEYCODE_MEDIA_EJECT, INPUT_USAGE_KEYCODE_MEDIA_RECORD, INPUT_USAGE_KEYCODE_F1, INPUT_USAGE_KEYCODE_F2, INPUT_USAGE_KEYCODE_F3, INPUT_USAGE_KEYCODE_F4, INPUT_USAGE_KEYCODE_F5, INPUT_USAGE_KEYCODE_F6, INPUT_USAGE_KEYCODE_F7, INPUT_USAGE_KEYCODE_F8, INPUT_USAGE_KEYCODE_F9, INPUT_USAGE_KEYCODE_F10, INPUT_USAGE_KEYCODE_F11, INPUT_USAGE_KEYCODE_F12, INPUT_USAGE_KEYCODE_NUM_LOCK, INPUT_USAGE_KEYCODE_NUMPAD_0, INPUT_USAGE_KEYCODE_NUMPAD_1, INPUT_USAGE_KEYCODE_NUMPAD_2, INPUT_USAGE_KEYCODE_NUMPAD_3, INPUT_USAGE_KEYCODE_NUMPAD_4, INPUT_USAGE_KEYCODE_NUMPAD_5, INPUT_USAGE_KEYCODE_NUMPAD_6, INPUT_USAGE_KEYCODE_NUMPAD_7, INPUT_USAGE_KEYCODE_NUMPAD_8, INPUT_USAGE_KEYCODE_NUMPAD_9, INPUT_USAGE_KEYCODE_NUMPAD_DIVIDE, INPUT_USAGE_KEYCODE_NUMPAD_MULTIPLY, INPUT_USAGE_KEYCODE_NUMPAD_SUBTRACT, INPUT_USAGE_KEYCODE_NUMPAD_ADD, INPUT_USAGE_KEYCODE_NUMPAD_DOT, INPUT_USAGE_KEYCODE_NUMPAD_COMMA, INPUT_USAGE_KEYCODE_NUMPAD_ENTER, INPUT_USAGE_KEYCODE_NUMPAD_EQUALS, INPUT_USAGE_KEYCODE_NUMPAD_LEFT_PAREN, INPUT_USAGE_KEYCODE_NUMPAD_RIGHT_PAREN, INPUT_USAGE_KEYCODE_VOLUME_MUTE, INPUT_USAGE_KEYCODE_INFO, INPUT_USAGE_KEYCODE_CHANNEL_UP, INPUT_USAGE_KEYCODE_CHANNEL_DOWN, INPUT_USAGE_KEYCODE_ZOOM_IN, INPUT_USAGE_KEYCODE_ZOOM_OUT, INPUT_USAGE_KEYCODE_TV, INPUT_USAGE_KEYCODE_WINDOW, INPUT_USAGE_KEYCODE_GUIDE, INPUT_USAGE_KEYCODE_DVR, INPUT_USAGE_KEYCODE_BOOKMARK, INPUT_USAGE_KEYCODE_CAPTIONS, INPUT_USAGE_KEYCODE_SETTINGS, INPUT_USAGE_KEYCODE_TV_POWER, INPUT_USAGE_KEYCODE_TV_INPUT, INPUT_USAGE_KEYCODE_STB_POWER, INPUT_USAGE_KEYCODE_STB_INPUT, INPUT_USAGE_KEYCODE_AVR_POWER, INPUT_USAGE_KEYCODE_AVR_INPUT, INPUT_USAGE_KEYCODE_PROG_RED, INPUT_USAGE_KEYCODE_PROG_GREEN, INPUT_USAGE_KEYCODE_PROG_YELLOW, INPUT_USAGE_KEYCODE_PROG_BLUE, INPUT_USAGE_KEYCODE_APP_SWITCH, INPUT_USAGE_KEYCODE_BUTTON_1, INPUT_USAGE_KEYCODE_BUTTON_2, INPUT_USAGE_KEYCODE_BUTTON_3, INPUT_USAGE_KEYCODE_BUTTON_4, INPUT_USAGE_KEYCODE_BUTTON_5, INPUT_USAGE_KEYCODE_BUTTON_6, INPUT_USAGE_KEYCODE_BUTTON_7, INPUT_USAGE_KEYCODE_BUTTON_8, INPUT_USAGE_KEYCODE_BUTTON_9, INPUT_USAGE_KEYCODE_BUTTON_10, INPUT_USAGE_KEYCODE_BUTTON_11, INPUT_USAGE_KEYCODE_BUTTON_12, INPUT_USAGE_KEYCODE_BUTTON_13, INPUT_USAGE_KEYCODE_BUTTON_14, INPUT_USAGE_KEYCODE_BUTTON_15, INPUT_USAGE_KEYCODE_BUTTON_16, INPUT_USAGE_KEYCODE_LANGUAGE_SWITCH, INPUT_USAGE_KEYCODE_MANNER_MODE, INPUT_USAGE_KEYCODE_3D_MODE, INPUT_USAGE_KEYCODE_CONTACTS, INPUT_USAGE_KEYCODE_CALENDAR, INPUT_USAGE_KEYCODE_MUSIC, INPUT_USAGE_KEYCODE_CALCULATOR, INPUT_USAGE_KEYCODE_ZENKAKU_HANKAKU, INPUT_USAGE_KEYCODE_EISU, INPUT_USAGE_KEYCODE_MUHENKAN, INPUT_USAGE_KEYCODE_HENKAN, INPUT_USAGE_KEYCODE_KATAKANA_HIRAGANA, INPUT_USAGE_KEYCODE_YEN, INPUT_USAGE_KEYCODE_RO, INPUT_USAGE_KEYCODE_KANA, INPUT_USAGE_KEYCODE_ASSIST, INPUT_USAGE_KEYCODE_BRIGHTNESS_DOWN, INPUT_USAGE_KEYCODE_BRIGHTNESS_UP, INPUT_USAGE_KEYCODE_MEDIA_AUDIO_TRACK, INPUT_USAGE_KEYCODE_SLEEP, INPUT_USAGE_KEYCODE_WAKEUP, INPUT_USAGE_KEYCODE_PAIRING, INPUT_USAGE_KEYCODE_MEDIA_TOP_MENU, INPUT_USAGE_KEYCODE_11, INPUT_USAGE_KEYCODE_12, INPUT_USAGE_KEYCODE_LAST_CHANNEL, INPUT_USAGE_KEYCODE_TV_DATA_SERVICE, INPUT_USAGE_KEYCODE_VOICE_ASSIST, INPUT_USAGE_KEYCODE_TV_RADIO_SERVICE, INPUT_USAGE_KEYCODE_TV_TELETEXT, INPUT_USAGE_KEYCODE_TV_NUMBER_ENTRY, INPUT_USAGE_KEYCODE_TV_TERRESTRIAL_ANALOG, INPUT_USAGE_KEYCODE_TV_TERRESTRIAL_DIGITAL, INPUT_USAGE_KEYCODE_TV_SATELLITE, INPUT_USAGE_KEYCODE_TV_SATELLITE_BS, INPUT_USAGE_KEYCODE_TV_SATELLITE_CS, INPUT_USAGE_KEYCODE_TV_SATELLITE_SERVICE, INPUT_USAGE_KEYCODE_TV_NETWORK, INPUT_USAGE_KEYCODE_TV_ANTENNA_CABLE, INPUT_USAGE_KEYCODE_TV_INPUT_HDMI_1, INPUT_USAGE_KEYCODE_TV_INPUT_HDMI_2, INPUT_USAGE_KEYCODE_TV_INPUT_HDMI_3, INPUT_USAGE_KEYCODE_TV_INPUT_HDMI_4, INPUT_USAGE_KEYCODE_TV_INPUT_COMPOSITE_1, INPUT_USAGE_KEYCODE_TV_INPUT_COMPOSITE_2, INPUT_USAGE_KEYCODE_TV_INPUT_COMPONENT_1, INPUT_USAGE_KEYCODE_TV_INPUT_COMPONENT_2, INPUT_USAGE_KEYCODE_TV_INPUT_VGA_1, INPUT_USAGE_KEYCODE_TV_AUDIO_DESCRIPTION, INPUT_USAGE_KEYCODE_TV_AUDIO_DESCRIPTION_MIX_UP, INPUT_USAGE_KEYCODE_TV_AUDIO_DESCRIPTION_MIX_DOWN, INPUT_USAGE_KEYCODE_TV_ZOOM_MODE, INPUT_USAGE_KEYCODE_TV_CONTENTS_MENU, INPUT_USAGE_KEYCODE_TV_MEDIA_CONTEXT_MENU, INPUT_USAGE_KEYCODE_TV_TIMER_PROGRAMMING, INPUT_USAGE_KEYCODE_HELP, // axes INPUT_USAGE_AXIS_X, INPUT_USAGE_AXIS_Y, INPUT_USAGE_AXIS_PRESSURE, INPUT_USAGE_AXIS_SIZE, INPUT_USAGE_AXIS_TOUCH_MAJOR, INPUT_USAGE_AXIS_TOUCH_MINOR, INPUT_USAGE_AXIS_TOOL_MAJOR, INPUT_USAGE_AXIS_TOOL_MINOR, INPUT_USAGE_AXIS_ORIENTATION, INPUT_USAGE_AXIS_VSCROLL, INPUT_USAGE_AXIS_HSCROLL, INPUT_USAGE_AXIS_Z, INPUT_USAGE_AXIS_RX, INPUT_USAGE_AXIS_RY, INPUT_USAGE_AXIS_RZ, INPUT_USAGE_AXIS_HAT_X, INPUT_USAGE_AXIS_HAT_Y, INPUT_USAGE_AXIS_LTRIGGER, INPUT_USAGE_AXIS_RTRIGGER, INPUT_USAGE_AXIS_THROTTLE, INPUT_USAGE_AXIS_RUDDER, INPUT_USAGE_AXIS_WHEEL, INPUT_USAGE_AXIS_GAS, INPUT_USAGE_AXIS_BRAKE, INPUT_USAGE_AXIS_DISTANCE, INPUT_USAGE_AXIS_TILT, INPUT_USAGE_AXIS_GENERIC_1, INPUT_USAGE_AXIS_GENERIC_2, INPUT_USAGE_AXIS_GENERIC_3, INPUT_USAGE_AXIS_GENERIC_4, INPUT_USAGE_AXIS_GENERIC_5, INPUT_USAGE_AXIS_GENERIC_6, INPUT_USAGE_AXIS_GENERIC_7, INPUT_USAGE_AXIS_GENERIC_8, INPUT_USAGE_AXIS_GENERIC_9, INPUT_USAGE_AXIS_GENERIC_10, INPUT_USAGE_AXIS_GENERIC_11, INPUT_USAGE_AXIS_GENERIC_12, INPUT_USAGE_AXIS_GENERIC_13, INPUT_USAGE_AXIS_GENERIC_14, INPUT_USAGE_AXIS_GENERIC_15, INPUT_USAGE_AXIS_GENERIC_16, // leds INPUT_USAGE_LED_NUM_LOCK, INPUT_USAGE_LED_CAPS_LOCK, INPUT_USAGE_LED_SCROLL_LOCK, INPUT_USAGE_LED_COMPOSE, INPUT_USAGE_LED_KANA, INPUT_USAGE_LED_SLEEP, INPUT_USAGE_LED_SUSPEND, INPUT_USAGE_LED_MUTE, INPUT_USAGE_LED_MISC, INPUT_USAGE_LED_MAIL, INPUT_USAGE_LED_CHARGING, INPUT_USAGE_LED_CONTROLLER_1, INPUT_USAGE_LED_CONTROLLER_2, INPUT_USAGE_LED_CONTROLLER_3, INPUT_USAGE_LED_CONTROLLER_4, } input_usage_t; typedef enum { INPUT_COLLECTION_ID_TOUCH, INPUT_COLLECTION_ID_KEYBOARD, INPUT_COLLECTION_ID_MOUSE, INPUT_COLLECTION_ID_TOUCHPAD, // etc } input_collection_id_t; typedef struct input_message input_message_t; typedef struct input_host_callbacks { /** * Creates a device identifier with the given properties. * The unique ID should be a string that precisely identifies a given piece of hardware. For * example, an input device connected via Bluetooth could use its MAC address as its unique ID. */ input_device_identifier_t* (*create_device_identifier)(input_host_t* host, const char* name, int32_t product_id, int32_t vendor_id, input_bus_t bus, const char* unique_id); /** * Allocates the device definition which will describe the input capabilities of a device. A * device definition may be used to register as many devices as desired. */ input_device_definition_t* (*create_device_definition)(input_host_t* host); /** * Allocate either an input report, which the HAL will use to tell the host of incoming input * events, or an output report, which the host will use to tell the HAL of desired state * changes (e.g. setting an LED). */ input_report_definition_t* (*create_input_report_definition)(input_host_t* host); input_report_definition_t* (*create_output_report_definition)(input_host_t* host); /** * Append the report to the given input device. */ void (*input_device_definition_add_report)(input_host_t* host, input_device_definition_t* d, input_report_definition_t* r); /** * Add a collection with the given arity and ID. A collection describes a set * of logically grouped properties such as the X and Y coordinates of a single finger touch or * the set of keys on a keyboard. The arity declares how many repeated instances of this * collection will appear in whatever report it is attached to. The ID describes the type of * grouping being represented by the collection. For example, a touchscreen capable of * reporting up to 2 fingers simultaneously might have a collection with the X and Y * coordinates, an arity of 2, and an ID of INPUT_COLLECTION_USAGE_TOUCHSCREEN. Any given ID * may only be present once for a given report. */ void (*input_report_definition_add_collection)(input_host_t* host, input_report_definition_t* report, input_collection_id_t id, int32_t arity); /** * Declare an int usage with the given properties. The report and collection defines where the * usage is being declared. */ void (*input_report_definition_declare_usage_int)(input_host_t* host, input_report_definition_t* report, input_collection_id_t id, input_usage_t usage, int32_t min, int32_t max, float resolution); /** * Declare a set of boolean usages with the given properties. The report and collection * defines where the usages are being declared. */ void (*input_report_definition_declare_usages_bool)(input_host_t* host, input_report_definition_t* report, input_collection_id_t id, input_usage_t* usage, size_t usage_count); /** * Register a given input device definition. This notifies the host that an input device has * been connected and gives a description of all its capabilities. */ input_device_handle_t* (*register_device)(input_host_t* host, input_device_identifier_t* id, input_device_definition_t* d); /** Unregister the given device */ void (*unregister_device)(input_host_t* host, input_device_handle_t* handle); /** * Allocate a report that will contain all of the state as described by the given report. */ input_report_t* (*input_allocate_report)(input_host_t* host, input_report_definition_t* r); /** * Add an int usage value to a report. */ void (*input_report_set_usage_int)(input_host_t* host, input_report_t* r, input_collection_id_t id, input_usage_t usage, int32_t value, int32_t arity_index); /** * Add a boolean usage value to a report. */ void (*input_report_set_usage_bool)(input_host_t* host, input_report_t* r, input_collection_id_t id, input_usage_t usage, bool value, int32_t arity_index); void (*report_event)(input_host_t* host, input_device_handle_t* d, input_report_t* report); /** * Retrieve the set of properties for the device. The returned * input_property_map_t* may be used to query specific properties via the * input_get_device_property callback. */ input_property_map_t* (*input_get_device_property_map)(input_host_t* host, input_device_identifier_t* id); /** * Retrieve a property for the device with the given key. Returns NULL if * the key does not exist, or an input_property_t* that must be freed using * input_free_device_property(). Using an input_property_t after the * corresponding input_property_map_t is freed is undefined. */ input_property_t* (*input_get_device_property)(input_host_t* host, input_property_map_t* map, const char* key); /** * Get the key for the input property. Returns NULL if the property is NULL. * The returned const char* is owned by the input_property_t. */ const char* (*input_get_property_key)(input_host_t* host, input_property_t* property); /** * Get the value for the input property. Returns NULL if the property is * NULL. The returned const char* is owned by the input_property_t. */ const char* (*input_get_property_value)(input_host_t* host, input_property_t* property); /** * Frees the input_property_t*. */ void (*input_free_device_property)(input_host_t* host, input_property_t* property); /** * Frees the input_property_map_t*. */ void (*input_free_device_property_map)(input_host_t* host, input_property_map_t* map); } input_host_callbacks_t; typedef struct input_module input_module_t; struct input_module { /** * Common methods of the input module. This *must* be the first member * of input_module as users of this structure will cast a hw_module_t * to input_module pointer in contexts where it's known * the hw_module_t references a input_module. */ struct hw_module_t common; /** * Initialize the module with host callbacks. At this point the HAL should start up whatever * infrastructure it needs to in order to process input events. */ void (*init)(const input_module_t* module, input_host_t* host, input_host_callbacks_t cb); /** * Sends an output report with a new set of state the host would like the given device to * assume. */ void (*notify_report)(const input_module_t* module, input_report_t* report); }; static inline int input_open(const struct hw_module_t** module, const char* type) { return hw_get_module_by_class(INPUT_HARDWARE_MODULE_ID, type, module); } __END_DECLS #endif /* ANDROID_INCLUDE_HARDWARE_INPUT_H */ android-headers-23/23/hardware/keymaster0.h000066400000000000000000000117471264465411000206240ustar00rootroot00000000000000/* * 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_0_H #define ANDROID_HARDWARE_KEYMASTER_0_H #include __BEGIN_DECLS /** * Keymaster0 device definition. */ struct keymaster0_device { /** * Common methods of the keymaster device. This *must* be the first member of * keymaster0_device as users of this structure will cast a hw_device_t to * keymaster0_device pointer in contexts where it's known the hw_device_t references a * keymaster0_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 keymaster0_device::flags in keymaster_common.h */ 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 keymaster0_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 keymaster0_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 keymaster0_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 keymaster0_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 keymaster0_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 keymaster0_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 keymaster0_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 keymaster0_device keymaster0_device_t; /* Convenience API for opening and closing keymaster devices */ 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); return rc; } static inline int keymaster0_close(keymaster0_device_t* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_HARDWARE_KEYMASTER_0_H android-headers-23/23/hardware/keymaster1.h000066400000000000000000000632421264465411000206220ustar00rootroot00000000000000/* * 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_HARDWARE_KEYMASTER1_H #define ANDROID_HARDWARE_KEYMASTER1_H #include #include __BEGIN_DECLS /** * Keymaster1 device definition */ struct keymaster1_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 keymaster0_devices::flags in keymaster_common.h */ uint32_t flags; void* context; /** * \deprecated 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 keymaster1_device* dev, const keymaster_keypair_t key_type, const void* key_params, uint8_t** key_blob, size_t* key_blob_length); /** * \deprecated 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 keymaster1_device* dev, const uint8_t* key, const size_t key_length, uint8_t** key_blob, size_t* key_blob_length); /** * \deprecated 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 keymaster1_device* dev, const uint8_t* key_blob, const size_t key_blob_length, uint8_t** x509_data, size_t* x509_data_length); /** * \deprecated 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 keymaster1_device* dev, const uint8_t* key_blob, const size_t key_blob_length); /** * \deprecated 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 keymaster1_device* dev); /** * \deprecated 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 keymaster1_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); /** * \deprecated 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 keymaster1_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); /** * Gets algorithms supported. * * \param[in] dev The keymaster device structure. * * \param[out] algorithms Array of algorithms supported. The caller takes ownership of the * array and must free() it. * * \param[out] algorithms_length Length of \p algorithms. */ keymaster_error_t (*get_supported_algorithms)(const struct keymaster1_device* dev, keymaster_algorithm_t** algorithms, size_t* algorithms_length); /** * Gets the block modes supported for the specified algorithm. * * \param[in] dev The keymaster device structure. * * \param[in] algorithm The algorithm for which supported modes will be returned. * * \param[out] modes Array of modes supported. The caller takes ownership of the array and must * free() it. * * \param[out] modes_length Length of \p modes. */ keymaster_error_t (*get_supported_block_modes)(const struct keymaster1_device* dev, keymaster_algorithm_t algorithm, keymaster_purpose_t purpose, keymaster_block_mode_t** modes, size_t* modes_length); /** * Gets the padding modes supported for the specified algorithm. Caller assumes ownership of * the allocated array. * * \param[in] dev The keymaster device structure. * * \param[in] algorithm The algorithm for which supported padding modes will be returned. * * \param[out] modes Array of padding modes supported. The caller takes ownership of the array * and must free() it. * * \param[out] modes_length Length of \p modes. */ keymaster_error_t (*get_supported_padding_modes)(const struct keymaster1_device* dev, keymaster_algorithm_t algorithm, keymaster_purpose_t purpose, keymaster_padding_t** modes, size_t* modes_length); /** * Gets the digests supported for the specified algorithm. Caller assumes ownership of the * allocated array. * * \param[in] dev The keymaster device structure. * * \param[in] algorithm The algorithm for which supported digests will be returned. * * \param[out] digests Array of digests supported. The caller takes ownership of the array and * must free() it. * * \param[out] digests_length Length of \p digests. */ keymaster_error_t (*get_supported_digests)(const struct keymaster1_device* dev, keymaster_algorithm_t algorithm, keymaster_purpose_t purpose, keymaster_digest_t** digests, size_t* digests_length); /** * Gets the key import formats supported for keys of the specified algorithm. Caller assumes * ownership of the allocated array. * * \param[in] dev The keymaster device structure. * * \param[in] algorithm The algorithm for which supported formats will be returned. * * \param[out] formats Array of formats supported. The caller takes ownership of the array and * must free() it. * * \param[out] formats_length Length of \p formats. */ keymaster_error_t (*get_supported_import_formats)(const struct keymaster1_device* dev, keymaster_algorithm_t algorithm, keymaster_key_format_t** formats, size_t* formats_length); /** * Gets the key export formats supported for keys of the specified algorithm. Caller assumes * ownership of the allocated array. * * \param[in] dev The keymaster device structure. * * \param[in] algorithm The algorithm for which supported formats will be returned. * * \param[out] formats Array of formats supported. The caller takes ownership of the array and * must free() it. * * \param[out] formats_length Length of \p formats. */ keymaster_error_t (*get_supported_export_formats)(const struct keymaster1_device* dev, keymaster_algorithm_t algorithm, keymaster_key_format_t** formats, size_t* formats_length); /** * Adds entropy to the RNG used by keymaster. Entropy added through this method is guaranteed * not to be the only source of entropy used, and the mixing function is required to be secure, * in the sense that if the RNG is seeded (from any source) with any data the attacker cannot * predict (or control), then the RNG output is indistinguishable from random. Thus, if the * entropy from any source is good, the output will be good. * * \param[in] dev The keymaster device structure. * * \param[in] data Random data to be mixed in. * * \param[in] data_length Length of \p data. */ keymaster_error_t (*add_rng_entropy)(const struct keymaster1_device* dev, const uint8_t* data, size_t data_length); /** * Generates a key, or key pair, returning a key blob and/or a description of the key. * * Key generation parameters are defined as keymaster tag/value pairs, provided in \p params. * See keymaster_tag_t for the full list. Some values that are always required for generation * of useful keys are: * * - KM_TAG_ALGORITHM; * - KM_TAG_PURPOSE; and * - (KM_TAG_USER_SECURE_ID and KM_TAG_USER_AUTH_TYPE) or KM_TAG_NO_AUTH_REQUIRED. * * KM_TAG_AUTH_TIMEOUT should generally be specified unless KM_TAG_NO_AUTH_REQUIRED is present, * or the user will have to authenticate for every use. * * KM_TAG_BLOCK_MODE, KM_TAG_PADDING, KM_TAG_MAC_LENGTH and KM_TAG_DIGEST must be specified for * algorithms that require them. * * The following tags may not be specified; their values will be provided by the implementation. * * - KM_TAG_ORIGIN, * - KM_TAG_ROLLBACK_RESISTANT, * - KM_TAG_CREATION_DATETIME * * \param[in] dev The keymaster device structure. * * \param[in] params Array of key generation parameters. * * \param[in] params_count Length of \p params. * * \param[out] key_blob returns the generated key. \p key_blob must not be NULL. The caller * assumes ownership key_blob->key_material and must free() it. * * \param[out] characteristics returns the characteristics of the key that was, generated, if * non-NULL. If non-NULL, the caller assumes ownership and must deallocate with * keymaster_free_characteristics(). Note that KM_TAG_ROOT_OF_TRUST, KM_TAG_APPLICATION_ID and * KM_TAG_APPLICATION_DATA are never returned. */ keymaster_error_t (*generate_key)(const struct keymaster1_device* dev, const keymaster_key_param_set_t* params, keymaster_key_blob_t* key_blob, keymaster_key_characteristics_t** characteristics); /** * Returns the characteristics of the specified key, or KM_ERROR_INVALID_KEY_BLOB if the * key_blob is invalid (implementations must fully validate the integrity of the key). * client_id and app_data must be the ID and data provided when the key was generated or * imported, or empty if KM_TAG_APPLICATION_ID and/or KM_TAG_APPLICATION_DATA were not provided * during generation. Those values are not included in the returned characteristics. The * caller assumes ownership of the allocated characteristics object, which must be deallocated * with keymaster_free_characteristics(). * * Note that KM_TAG_ROOT_OF_TRUST, KM_TAG_APPLICATION_ID and KM_TAG_APPLICATION_DATA are never * returned. * * \param[in] dev The keymaster device structure. * * \param[in] key_blob The key to retreive characteristics from. * * \param[in] client_id The client ID data, or NULL if none associated. * * \param[in] app_id The app data, or NULL if none associated. * * \param[out] characteristics The key characteristics. */ keymaster_error_t (*get_key_characteristics)(const struct keymaster1_device* dev, const keymaster_key_blob_t* key_blob, const keymaster_blob_t* client_id, const keymaster_blob_t* app_data, keymaster_key_characteristics_t** characteristics); /** * Imports a key, or key pair, returning a key blob and/or a description of the key. * * Most key import parameters are defined as keymaster tag/value pairs, provided in "params". * See keymaster_tag_t for the full list. Values that are always required for import of useful * keys are: * * - KM_TAG_ALGORITHM; * - KM_TAG_PURPOSE; and * - (KM_TAG_USER_SECURE_ID and KM_TAG_USER_AUTH_TYPE) or KM_TAG_NO_AUTH_REQUIRED. * * KM_TAG_AUTH_TIMEOUT should generally be specified. If unspecified, the user will have to * authenticate for every use. * * The following tags will take default values if unspecified: * * - KM_TAG_KEY_SIZE will default to the size of the key provided. * - KM_TAG_RSA_PUBLIC_EXPONENT will default to the value in the key provided (for RSA keys) * * The following tags may not be specified; their values will be provided by the implementation. * * - KM_TAG_ORIGIN, * - KM_TAG_ROLLBACK_RESISTANT, * - KM_TAG_CREATION_DATETIME * * \param[in] dev The keymaster device structure. * * \param[in] params Parameters defining the imported key. * * \param[in] params_count The number of entries in \p params. * * \param[in] key_format specifies the format of the key data in key_data. * * \param[out] key_blob Used to return the opaque key blob. Must be non-NULL. The caller * assumes ownership of the contained key_material. * * \param[out] characteristics Used to return the characteristics of the imported key. May be * NULL, in which case no characteristics will be returned. If non-NULL, the caller assumes * ownership and must deallocate with keymaster_free_characteristics(). Note that * KM_TAG_ROOT_OF_TRUST, KM_TAG_APPLICATION_ID and * KM_TAG_APPLICATION_DATA are never returned. */ keymaster_error_t (*import_key)(const struct keymaster1_device* dev, const keymaster_key_param_set_t* params, keymaster_key_format_t key_format, const keymaster_blob_t* key_data, keymaster_key_blob_t* key_blob, keymaster_key_characteristics_t** characteristics); /** * Exports a public key, returning a byte array in the specified format. * * \param[in] dev The keymaster device structure. * * \param[in] export_format The format to be used for exporting the key. * * \param[in] key_to_export The key to export. * * \param[out] export_data The exported key material. The caller assumes ownership. * * \param[out] export_data_length The length of \p export_data. */ keymaster_error_t (*export_key)(const struct keymaster1_device* dev, keymaster_key_format_t export_format, const keymaster_key_blob_t* key_to_export, const keymaster_blob_t* client_id, const keymaster_blob_t* app_data, keymaster_blob_t* export_data); /** * Deletes the key, or key pair, associated with the key blob. After calling this function it * will be impossible to use the key for any other operations. May be applied to keys from * foreign roots of trust (keys not usable under the current root of trust). * * This function is optional and should be set to NULL if it is not implemented. * * \param[in] dev The keymaster device structure. * * \param[in] key The key to be deleted. */ keymaster_error_t (*delete_key)(const struct keymaster1_device* dev, const keymaster_key_blob_t* key); /** * Deletes all keys in the hardware keystore. Used when keystore is reset completely. After * calling this function it will be impossible to use any previously generated or imported key * blobs for any operations. * * This function is optional and should be set to NULL if it is not implemented. * * \param[in] dev The keymaster device structure. */ keymaster_error_t (*delete_all_keys)(const struct keymaster1_device* dev); /** * Begins a cryptographic operation using the specified key. If all is well, begin() will * return KM_ERROR_OK and create an operation handle which must be passed to subsequent calls to * update(), finish() or abort(). * * It is critical that each call to begin() be paired with a subsequent call to finish() or * abort(), to allow the keymaster implementation to clean up any internal operation state. * Failure to do this may leak internal state space or other internal resources and may * eventually cause begin() to return KM_ERROR_TOO_MANY_OPERATIONS when it runs out of space for * operations. Any result other than KM_ERROR_OK from begin(), update() or finish() implicitly * aborts the operation, in which case abort() need not be called (and will return * KM_ERROR_INVALID_OPERATION_HANDLE if called). * * \param[in] dev The keymaster device structure. * * \param[in] purpose The purpose of the operation, one of KM_PURPOSE_ENCRYPT, * KM_PURPOSE_DECRYPT, KM_PURPOSE_SIGN or KM_PURPOSE_VERIFY. Note that for AEAD modes, * encryption and decryption imply signing and verification, respectively, but should be * specified as KM_PURPOSE_ENCRYPT and KM_PURPOSE_DECRYPT. * * \param[in] key The key to be used for the operation. \p key must have a purpose compatible * with \p purpose and all of its usage requirements must be satisfied, or begin() will return * an appropriate error code. * * \param[in] in_params Additional parameters for the operation. This is typically used to * provide authentication data, with KM_TAG_AUTH_TOKEN. If KM_TAG_APPLICATION_ID or * KM_TAG_APPLICATION_DATA were provided during generation, they must be provided here, or the * operation will fail with KM_ERROR_INVALID_KEY_BLOB. For operations that require a nonce or * IV, on keys that were generated with KM_TAG_CALLER_NONCE, in_params may contain a tag * KM_TAG_NONCE. For AEAD operations KM_TAG_CHUNK_SIZE is specified here. * * \param[out] out_params Output parameters. Used to return additional data from the operation * initialization, notably to return the IV or nonce from operations that generate an IV or * nonce. The caller takes ownership of the output parameters array and must free it with * keymaster_free_param_set(). out_params may be set to NULL if no output parameters are * expected. If out_params is NULL, and output paramaters are generated, begin() will return * KM_ERROR_OUTPUT_PARAMETER_NULL. * * \param[out] operation_handle The newly-created operation handle which must be passed to * update(), finish() or abort(). If operation_handle is NULL, begin() will return * KM_ERROR_OUTPUT_PARAMETER_NULL. */ keymaster_error_t (*begin)(const struct keymaster1_device* dev, keymaster_purpose_t purpose, const keymaster_key_blob_t* key, const keymaster_key_param_set_t* in_params, keymaster_key_param_set_t* out_params, keymaster_operation_handle_t* operation_handle); /** * Provides data to, and possibly receives output from, an ongoing cryptographic operation begun * with begin(). * * If operation_handle is invalid, update() will return KM_ERROR_INVALID_OPERATION_HANDLE. * * update() may not consume all of the data provided in the data buffer. update() will return * the amount consumed in *data_consumed. The caller should provide the unconsumed data in a * subsequent call. * * \param[in] dev The keymaster device structure. * * \param[in] operation_handle The operation handle returned by begin(). * * \param[in] in_params Additional parameters for the operation. For AEAD modes, this is used * to specify KM_TAG_ADDITIONAL_DATA. Note that additional data may be provided in multiple * calls to update(), but only until input data has been provided. * * \param[in] input Data to be processed, per the parameters established in the call to begin(). * Note that update() may or may not consume all of the data provided. See \p input_consumed. * * \param[out] input_consumed Amount of data that was consumed by update(). If this is less * than the amount provided, the caller should provide the remainder in a subsequent call to * update(). * * \param[out] out_params Output parameters. Used to return additional data from the operation * The caller takes ownership of the output parameters array and must free it with * keymaster_free_param_set(). out_params may be set to NULL if no output parameters are * expected. If out_params is NULL, and output paramaters are generated, begin() will return * KM_ERROR_OUTPUT_PARAMETER_NULL. * * \param[out] output The output data, if any. The caller assumes ownership of the allocated * buffer. output must not be NULL. * * Note that update() may not provide any output, in which case output->data_length will be * zero, and output->data may be either NULL or zero-length (so the caller should always free() * it). */ keymaster_error_t (*update)(const struct keymaster1_device* dev, keymaster_operation_handle_t operation_handle, const keymaster_key_param_set_t* in_params, const keymaster_blob_t* input, size_t* input_consumed, keymaster_key_param_set_t* out_params, keymaster_blob_t* output); /** * Finalizes a cryptographic operation begun with begin() and invalidates \p operation_handle. * * \param[in] dev The keymaster device structure. * * \param[in] operation_handle The operation handle returned by begin(). This handle will be * invalidated. * * \param[in] params Additional parameters for the operation. For AEAD modes, this is used to * specify KM_TAG_ADDITIONAL_DATA, but only if no input data was provided to update(). * * \param[in] signature The signature to be verified if the purpose specified in the begin() * call was KM_PURPOSE_VERIFY. * * \param[out] output The output data, if any. The caller assumes ownership of the allocated * buffer. * * If the operation being finished is a signature verification or an AEAD-mode decryption and * verification fails then finish() will return KM_ERROR_VERIFICATION_FAILED. */ keymaster_error_t (*finish)(const struct keymaster1_device* dev, keymaster_operation_handle_t operation_handle, const keymaster_key_param_set_t* in_params, const keymaster_blob_t* signature, keymaster_key_param_set_t* out_params, keymaster_blob_t* output); /** * Aborts a cryptographic operation begun with begin(), freeing all internal resources and * invalidating \p operation_handle. */ keymaster_error_t (*abort)(const struct keymaster1_device* dev, keymaster_operation_handle_t operation_handle); }; 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); } static inline int keymaster1_close(keymaster1_device_t* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_HARDWARE_KEYMASTER1_H android-headers-23/23/hardware/keymaster_common.h000066400000000000000000000115331264465411000221050ustar00rootroot00000000000000/* * 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_HARDWARE_KEYMASTER_COMMON_H #define ANDROID_HARDWARE_KEYMASTER_COMMON_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. */ /** * Keymaster 0.X module version provide the same APIs, but later versions add more options * for algorithms and flags. */ #define KEYMASTER_MODULE_API_VERSION_0_2 HARDWARE_MODULE_API_VERSION(0, 2) #define KEYMASTER_DEVICE_API_VERSION_0_2 HARDWARE_DEVICE_API_VERSION(0, 2) #define KEYMASTER_MODULE_API_VERSION_0_3 HARDWARE_MODULE_API_VERSION(0, 3) #define KEYMASTER_DEVICE_API_VERSION_0_3 HARDWARE_DEVICE_API_VERSION(0, 3) /** * Keymaster 1.0 module version provides a completely different API, incompatible with 0.X. */ #define KEYMASTER_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) #define KEYMASTER_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) 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; /* There are no keystore module methods other than the common ones. */ }; /** * Flags for keymaster0_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, }; /** * 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_algorithm_t; /** * Type of padding used for RSA operations. */ typedef enum { PADDING_NONE, } keymaster_rsa_padding_t; typedef struct { keymaster_digest_algorithm_t digest_type; } keymaster_dsa_sign_params_t; typedef struct { keymaster_digest_algorithm_t digest_type; } keymaster_ec_sign_params_t; typedef struct { keymaster_digest_algorithm_t digest_type; keymaster_rsa_padding_t padding_type; } keymaster_rsa_sign_params_t; __END_DECLS #endif // ANDROID_HARDWARE_KEYMASTER_COMMON_H android-headers-23/23/hardware/keymaster_defs.h000066400000000000000000000502551264465411000215420ustar00rootroot00000000000000/* * 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_HARDWARE_KEYMASTER_DEFS_H #define ANDROID_HARDWARE_KEYMASTER_DEFS_H #include #include #include #ifdef __cplusplus extern "C" { #endif // __cplusplus /** * Authorization tags each have an associated type. This enumeration facilitates tagging each with * a type, by using the high four bits (of an implied 32-bit unsigned enum value) to specify up to * 16 data types. These values are ORed with tag IDs to generate the final tag ID values. */ typedef enum { KM_INVALID = 0 << 28, /* Invalid type, used to designate a tag as uninitialized */ KM_ENUM = 1 << 28, KM_ENUM_REP = 2 << 28, /* Repeatable enumeration value. */ KM_UINT = 3 << 28, KM_UINT_REP = 4 << 28, /* Repeatable integer value */ KM_ULONG = 5 << 28, KM_DATE = 6 << 28, KM_BOOL = 7 << 28, KM_BIGNUM = 8 << 28, KM_BYTES = 9 << 28, KM_ULONG_REP = 10 << 28, /* Repeatable long value */ } keymaster_tag_type_t; typedef enum { KM_TAG_INVALID = KM_INVALID | 0, /* * Tags that must be semantically enforced by hardware and software implementations. */ /* Crypto parameters */ KM_TAG_PURPOSE = KM_ENUM_REP | 1, /* keymaster_purpose_t. */ KM_TAG_ALGORITHM = KM_ENUM | 2, /* keymaster_algorithm_t. */ KM_TAG_KEY_SIZE = KM_UINT | 3, /* Key size in bits. */ KM_TAG_BLOCK_MODE = KM_ENUM_REP | 4, /* keymaster_block_mode_t. */ KM_TAG_DIGEST = KM_ENUM_REP | 5, /* keymaster_digest_t. */ KM_TAG_PADDING = KM_ENUM_REP | 6, /* keymaster_padding_t. */ KM_TAG_CALLER_NONCE = KM_BOOL | 7, /* Allow caller to specify nonce or IV. */ KM_TAG_MIN_MAC_LENGTH = KM_UINT | 8, /* Minimum length of MAC or AEAD authentication tag in * bits. */ /* Algorithm-specific. */ KM_TAG_RSA_PUBLIC_EXPONENT = KM_ULONG | 200, /* Other hardware-enforced. */ KM_TAG_BLOB_USAGE_REQUIREMENTS = KM_ENUM | 301, /* keymaster_key_blob_usage_requirements_t */ KM_TAG_BOOTLOADER_ONLY = KM_BOOL | 302, /* Usable only by bootloader */ /* * Tags that should be semantically enforced by hardware if possible and will otherwise be * enforced by software (keystore). */ /* Key validity period */ KM_TAG_ACTIVE_DATETIME = KM_DATE | 400, /* Start of validity */ KM_TAG_ORIGINATION_EXPIRE_DATETIME = KM_DATE | 401, /* Date when new "messages" should no longer be created. */ KM_TAG_USAGE_EXPIRE_DATETIME = KM_DATE | 402, /* Date when existing "messages" should no longer be trusted. */ KM_TAG_MIN_SECONDS_BETWEEN_OPS = KM_UINT | 403, /* Minimum elapsed time between cryptographic operations with the key. */ KM_TAG_MAX_USES_PER_BOOT = KM_UINT | 404, /* Number of times the key can be used per boot. */ /* User authentication */ KM_TAG_ALL_USERS = KM_BOOL | 500, /* Reserved for future use -- ignore */ KM_TAG_USER_ID = KM_UINT | 501, /* Reserved for future use -- ignore */ KM_TAG_USER_SECURE_ID = KM_ULONG_REP | 502, /* Secure ID of authorized user or authenticator(s). Disallowed if KM_TAG_ALL_USERS or KM_TAG_NO_AUTH_REQUIRED is present. */ KM_TAG_NO_AUTH_REQUIRED = KM_BOOL | 503, /* If key is usable without authentication. */ KM_TAG_USER_AUTH_TYPE = KM_ENUM | 504, /* Bitmask of authenticator types allowed when * KM_TAG_USER_SECURE_ID contains a secure user ID, * rather than a secure authenticator ID. Defined in * hw_authenticator_type_t in hw_auth_token.h. */ KM_TAG_AUTH_TIMEOUT = KM_UINT | 505, /* Required freshness of user authentication for private/secret key operations, in seconds. Public key operations require no authentication. If absent, authentication is required for every use. Authentication state is lost when the device is powered off. */ /* Application access control */ KM_TAG_ALL_APPLICATIONS = KM_BOOL | 600, /* Reserved for future use -- ignore */ KM_TAG_APPLICATION_ID = KM_BYTES | 601, /* Reserved for fugure use -- ignore */ /* * Semantically unenforceable tags, either because they have no specific meaning or because * they're informational only. */ KM_TAG_APPLICATION_DATA = KM_BYTES | 700, /* Data provided by authorized application. */ KM_TAG_CREATION_DATETIME = KM_DATE | 701, /* Key creation time */ KM_TAG_ORIGIN = KM_ENUM | 702, /* keymaster_key_origin_t. */ KM_TAG_ROLLBACK_RESISTANT = KM_BOOL | 703, /* Whether key is rollback-resistant. */ KM_TAG_ROOT_OF_TRUST = KM_BYTES | 704, /* Root of trust ID. */ /* 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. */ KM_TAG_NONCE = KM_BYTES | 1001, /* Nonce or Initialization Vector */ KM_TAG_AUTH_TOKEN = KM_BYTES | 1002, /* Authentication token that proves secure user authentication has been performed. Structure defined in hw_auth_token_t in hw_auth_token.h. */ KM_TAG_MAC_LENGTH = KM_UINT | 1003, /* MAC or AEAD authentication tag length in bits. */ } keymaster_tag_t; /** * Algorithms that may be provided by keymaster implementations. Those that must be provided by all * implementations are tagged as "required". */ typedef enum { /* Asymmetric algorithms. */ KM_ALGORITHM_RSA = 1, // KM_ALGORITHM_DSA = 2, -- Removed, do not re-use value 2. KM_ALGORITHM_EC = 3, /* Block ciphers algorithms */ KM_ALGORITHM_AES = 32, /* MAC algorithms */ KM_ALGORITHM_HMAC = 128, } keymaster_algorithm_t; /** * Symmetric block cipher modes provided by keymaster implementations. */ typedef enum { /* Unauthenticated modes, usable only for encryption/decryption and not generally recommended * except for compatibility with existing other protocols. */ KM_MODE_ECB = 1, KM_MODE_CBC = 2, KM_MODE_CTR = 3, /* Authenticated modes, usable for encryption/decryption and signing/verification. Recommended * over unauthenticated modes for all purposes. */ KM_MODE_GCM = 32, } keymaster_block_mode_t; /** * Padding modes that may be applied to plaintext for encryption operations. This list includes * padding modes for both symmetric and asymmetric algorithms. Note that implementations should not * provide all possible combinations of algorithm and padding, only the * cryptographically-appropriate pairs. */ typedef enum { KM_PAD_NONE = 1, /* deprecated */ KM_PAD_RSA_OAEP = 2, KM_PAD_RSA_PSS = 3, KM_PAD_RSA_PKCS1_1_5_ENCRYPT = 4, KM_PAD_RSA_PKCS1_1_5_SIGN = 5, KM_PAD_PKCS7 = 64, } keymaster_padding_t; /** * Digests provided by keymaster implementations. */ typedef enum { KM_DIGEST_NONE = 0, KM_DIGEST_MD5 = 1, /* Optional, may not be implemented in hardware, will be handled in software * if needed. */ KM_DIGEST_SHA1 = 2, KM_DIGEST_SHA_2_224 = 3, KM_DIGEST_SHA_2_256 = 4, KM_DIGEST_SHA_2_384 = 5, KM_DIGEST_SHA_2_512 = 6, } keymaster_digest_t; /** * The origin of a key (or pair), i.e. where it was generated. Note that KM_TAG_ORIGIN can be found * in either the hardware-enforced or software-enforced list for a key, indicating whether the key * is hardware or software-based. Specifically, a key with KM_ORIGIN_GENERATED in the * hardware-enforced list is guaranteed never to have existed outide the secure hardware. */ typedef enum { KM_ORIGIN_GENERATED = 0, /* Generated in keymaster */ KM_ORIGIN_IMPORTED = 2, /* Imported, origin unknown */ KM_ORIGIN_UNKNOWN = 3, /* Keymaster did not record origin. This value can only be seen on * keys in a keymaster0 implementation. The keymaster0 adapter uses * this value to document the fact that it is unkown whether the key * was generated inside or imported into keymaster. */ } keymaster_key_origin_t; /** * Usability requirements of key blobs. This defines what system functionality must be available * for the key to function. For example, key "blobs" which are actually handles referencing * encrypted key material stored in the file system cannot be used until the file system is * available, and should have BLOB_REQUIRES_FILE_SYSTEM. Other requirements entries will be added * as needed for implementations. This type is new in 0_4. */ typedef enum { KM_BLOB_STANDALONE = 0, KM_BLOB_REQUIRES_FILE_SYSTEM = 1, } keymaster_key_blob_usage_requirements_t; /** * Possible purposes of a key (or pair). This type is new in 0_4. */ typedef enum { KM_PURPOSE_ENCRYPT = 0, KM_PURPOSE_DECRYPT = 1, KM_PURPOSE_SIGN = 2, KM_PURPOSE_VERIFY = 3, } keymaster_purpose_t; typedef struct { const uint8_t* data; size_t data_length; } keymaster_blob_t; typedef struct { keymaster_tag_t tag; union { uint32_t enumerated; /* KM_ENUM and KM_ENUM_REP */ bool boolean; /* KM_BOOL */ uint32_t integer; /* KM_INT and KM_INT_REP */ uint64_t long_integer; /* KM_LONG */ uint64_t date_time; /* KM_DATE */ keymaster_blob_t blob; /* KM_BIGNUM and KM_BYTES*/ }; } keymaster_key_param_t; typedef struct { keymaster_key_param_t* params; /* may be NULL if length == 0 */ size_t length; } keymaster_key_param_set_t; /** * Parameters that define a key's characteristics, including authorized modes of usage and access * control restrictions. The parameters are divided into two categories, those that are enforced by * secure hardware, and those that are not. For a software-only keymaster implementation the * enforced array must NULL. Hardware implementations must enforce everything in the enforced * array. */ typedef struct { keymaster_key_param_set_t hw_enforced; keymaster_key_param_set_t sw_enforced; } keymaster_key_characteristics_t; typedef struct { const uint8_t* key_material; size_t key_material_size; } keymaster_key_blob_t; /** * Formats for key import and export. At present, only asymmetric key import/export is supported. * In the future this list will expand greatly to accommodate asymmetric key import/export. */ typedef enum { KM_KEY_FORMAT_X509 = 0, /* for public key export */ KM_KEY_FORMAT_PKCS8 = 1, /* for asymmetric key pair import */ KM_KEY_FORMAT_RAW = 3, /* for symmetric key import */ } keymaster_key_format_t; /** * The keymaster operation API consists of begin, update, finish and abort. This is the type of the * handle used to tie the sequence of calls together. A 64-bit value is used because it's important * that handles not be predictable. Implementations must use strong random numbers for handle * values. */ typedef uint64_t keymaster_operation_handle_t; typedef enum { KM_ERROR_OK = 0, KM_ERROR_ROOT_OF_TRUST_ALREADY_SET = -1, KM_ERROR_UNSUPPORTED_PURPOSE = -2, KM_ERROR_INCOMPATIBLE_PURPOSE = -3, KM_ERROR_UNSUPPORTED_ALGORITHM = -4, KM_ERROR_INCOMPATIBLE_ALGORITHM = -5, KM_ERROR_UNSUPPORTED_KEY_SIZE = -6, KM_ERROR_UNSUPPORTED_BLOCK_MODE = -7, KM_ERROR_INCOMPATIBLE_BLOCK_MODE = -8, KM_ERROR_UNSUPPORTED_MAC_LENGTH = -9, KM_ERROR_UNSUPPORTED_PADDING_MODE = -10, KM_ERROR_INCOMPATIBLE_PADDING_MODE = -11, KM_ERROR_UNSUPPORTED_DIGEST = -12, KM_ERROR_INCOMPATIBLE_DIGEST = -13, KM_ERROR_INVALID_EXPIRATION_TIME = -14, KM_ERROR_INVALID_USER_ID = -15, KM_ERROR_INVALID_AUTHORIZATION_TIMEOUT = -16, KM_ERROR_UNSUPPORTED_KEY_FORMAT = -17, KM_ERROR_INCOMPATIBLE_KEY_FORMAT = -18, KM_ERROR_UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM = -19, /* For PKCS8 & PKCS12 */ KM_ERROR_UNSUPPORTED_KEY_VERIFICATION_ALGORITHM = -20, /* For PKCS8 & PKCS12 */ KM_ERROR_INVALID_INPUT_LENGTH = -21, KM_ERROR_KEY_EXPORT_OPTIONS_INVALID = -22, KM_ERROR_DELEGATION_NOT_ALLOWED = -23, KM_ERROR_KEY_NOT_YET_VALID = -24, KM_ERROR_KEY_EXPIRED = -25, KM_ERROR_KEY_USER_NOT_AUTHENTICATED = -26, KM_ERROR_OUTPUT_PARAMETER_NULL = -27, KM_ERROR_INVALID_OPERATION_HANDLE = -28, KM_ERROR_INSUFFICIENT_BUFFER_SPACE = -29, KM_ERROR_VERIFICATION_FAILED = -30, KM_ERROR_TOO_MANY_OPERATIONS = -31, KM_ERROR_UNEXPECTED_NULL_POINTER = -32, KM_ERROR_INVALID_KEY_BLOB = -33, KM_ERROR_IMPORTED_KEY_NOT_ENCRYPTED = -34, KM_ERROR_IMPORTED_KEY_DECRYPTION_FAILED = -35, KM_ERROR_IMPORTED_KEY_NOT_SIGNED = -36, KM_ERROR_IMPORTED_KEY_VERIFICATION_FAILED = -37, KM_ERROR_INVALID_ARGUMENT = -38, KM_ERROR_UNSUPPORTED_TAG = -39, KM_ERROR_INVALID_TAG = -40, KM_ERROR_MEMORY_ALLOCATION_FAILED = -41, KM_ERROR_IMPORT_PARAMETER_MISMATCH = -44, KM_ERROR_SECURE_HW_ACCESS_DENIED = -45, KM_ERROR_OPERATION_CANCELLED = -46, KM_ERROR_CONCURRENT_ACCESS_CONFLICT = -47, KM_ERROR_SECURE_HW_BUSY = -48, KM_ERROR_SECURE_HW_COMMUNICATION_FAILED = -49, KM_ERROR_UNSUPPORTED_EC_FIELD = -50, KM_ERROR_MISSING_NONCE = -51, KM_ERROR_INVALID_NONCE = -52, KM_ERROR_MISSING_MAC_LENGTH = -53, KM_ERROR_KEY_RATE_LIMIT_EXCEEDED = -54, KM_ERROR_CALLER_NONCE_PROHIBITED = -55, KM_ERROR_KEY_MAX_OPS_EXCEEDED = -56, KM_ERROR_INVALID_MAC_LENGTH = -57, KM_ERROR_MISSING_MIN_MAC_LENGTH = -58, KM_ERROR_UNSUPPORTED_MIN_MAC_LENGTH = -59, KM_ERROR_UNIMPLEMENTED = -100, KM_ERROR_VERSION_MISMATCH = -101, /* Additional error codes may be added by implementations, but implementers should coordinate * with Google to avoid code collision. */ KM_ERROR_UNKNOWN_ERROR = -1000, } keymaster_error_t; /* Convenience functions for manipulating keymaster tag types */ static inline keymaster_tag_type_t keymaster_tag_get_type(keymaster_tag_t tag) { return (keymaster_tag_type_t)(tag & (0xF << 28)); } static inline uint32_t keymaster_tag_mask_type(keymaster_tag_t tag) { return tag & 0x0FFFFFFF; } static inline bool keymaster_tag_type_repeatable(keymaster_tag_type_t type) { switch (type) { case KM_UINT_REP: case KM_ENUM_REP: return true; default: return false; } } static inline bool keymaster_tag_repeatable(keymaster_tag_t tag) { return keymaster_tag_type_repeatable(keymaster_tag_get_type(tag)); } /* Convenience functions for manipulating keymaster_key_param_t structs */ inline keymaster_key_param_t keymaster_param_enum(keymaster_tag_t tag, uint32_t value) { // assert(keymaster_tag_get_type(tag) == KM_ENUM || keymaster_tag_get_type(tag) == KM_ENUM_REP); keymaster_key_param_t param; memset(¶m, 0, sizeof(param)); param.tag = tag; param.enumerated = value; return param; } inline keymaster_key_param_t keymaster_param_int(keymaster_tag_t tag, uint32_t value) { // assert(keymaster_tag_get_type(tag) == KM_INT || keymaster_tag_get_type(tag) == KM_INT_REP); keymaster_key_param_t param; memset(¶m, 0, sizeof(param)); param.tag = tag; param.integer = value; return param; } inline keymaster_key_param_t keymaster_param_long(keymaster_tag_t tag, uint64_t value) { // assert(keymaster_tag_get_type(tag) == KM_LONG); keymaster_key_param_t param; memset(¶m, 0, sizeof(param)); param.tag = tag; param.long_integer = value; return param; } inline keymaster_key_param_t keymaster_param_blob(keymaster_tag_t tag, const uint8_t* bytes, size_t bytes_len) { // assert(keymaster_tag_get_type(tag) == KM_BYTES || keymaster_tag_get_type(tag) == KM_BIGNUM); keymaster_key_param_t param; memset(¶m, 0, sizeof(param)); param.tag = tag; param.blob.data = (uint8_t*)bytes; param.blob.data_length = bytes_len; return param; } inline keymaster_key_param_t keymaster_param_bool(keymaster_tag_t tag) { // assert(keymaster_tag_get_type(tag) == KM_BOOL); keymaster_key_param_t param; memset(¶m, 0, sizeof(param)); param.tag = tag; param.boolean = true; return param; } inline keymaster_key_param_t keymaster_param_date(keymaster_tag_t tag, uint64_t value) { // assert(keymaster_tag_get_type(tag) == KM_DATE); keymaster_key_param_t param; memset(¶m, 0, sizeof(param)); param.tag = tag; param.date_time = value; return param; } #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); if (retval != 0) return retval; switch (keymaster_tag_get_type(a->tag)) { case KM_INVALID: case KM_BOOL: return 0; case KM_ENUM: case KM_ENUM_REP: return KEYMASTER_SIMPLE_COMPARE(a->enumerated, b->enumerated); case KM_UINT: case KM_UINT_REP: return KEYMASTER_SIMPLE_COMPARE(a->integer, b->integer); case KM_ULONG: case KM_ULONG_REP: return KEYMASTER_SIMPLE_COMPARE(a->long_integer, b->long_integer); case KM_DATE: return KEYMASTER_SIMPLE_COMPARE(a->date_time, b->date_time); case KM_BIGNUM: case KM_BYTES: // Handle the empty cases. if (a->blob.data_length != 0 && b->blob.data_length == 0) return -1; if (a->blob.data_length == 0 && b->blob.data_length == 0) return 0; if (a->blob.data_length == 0 && b->blob.data_length > 0) return 1; retval = memcmp(a->blob.data, b->blob.data, a->blob.data_length < b->blob.data_length ? a->blob.data_length : b->blob.data_length); if (retval != 0) return retval; else if (a->blob.data_length != b->blob.data_length) { // Equal up to the common length; longer one is larger. if (a->blob.data_length < b->blob.data_length) return -1; if (a->blob.data_length > b->blob.data_length) return 1; }; } return 0; } #undef KEYMASTER_SIMPLE_COMPARE inline void keymaster_free_param_values(keymaster_key_param_t* param, size_t param_count) { while (param_count-- > 0) { switch (keymaster_tag_get_type(param->tag)) { case KM_BIGNUM: case KM_BYTES: free((void*)param->blob.data); param->blob.data = NULL; break; default: // NOP break; } ++param; } } inline void keymaster_free_param_set(keymaster_key_param_set_t* set) { if (set) { keymaster_free_param_values(set->params, set->length); free(set->params); set->params = NULL; } } inline void keymaster_free_characteristics(keymaster_key_characteristics_t* characteristics) { if (characteristics) { keymaster_free_param_set(&characteristics->hw_enforced); keymaster_free_param_set(&characteristics->sw_enforced); } } #ifdef __cplusplus } // extern "C" #endif // __cplusplus #endif // ANDROID_HARDWARE_KEYMASTER_DEFS_H android-headers-23/23/hardware/lights.h000066400000000000000000000074721264465411000200320ustar00rootroot00000000000000/* * 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_LIGHTS_INTERFACE_H #define ANDROID_LIGHTS_INTERFACE_H #include #include #include #include __BEGIN_DECLS /** * The id of this module */ #define LIGHTS_HARDWARE_MODULE_ID "lights" /* * These light IDs correspond to logical lights, not physical. * So for example, if your INDICATOR light is in line with your * BUTTONS, it might make sense to also light the INDICATOR * light to a reasonable color when the BUTTONS are lit. */ #define LIGHT_ID_BACKLIGHT "backlight" #define LIGHT_ID_KEYBOARD "keyboard" #define LIGHT_ID_BUTTONS "buttons" #define LIGHT_ID_BATTERY "battery" #define LIGHT_ID_NOTIFICATIONS "notifications" #define LIGHT_ID_ATTENTION "attention" /* * These lights aren't currently supported by the higher * layers, but could be someday, so we have the constants * here now. */ #define LIGHT_ID_BLUETOOTH "bluetooth" #define LIGHT_ID_WIFI "wifi" /* ************************************************************************ * Flash modes for the flashMode field of light_state_t. */ #define LIGHT_FLASH_NONE 0 /** * To flash the light at a given rate, set flashMode to LIGHT_FLASH_TIMED, * and then flashOnMS should be set to the number of milliseconds to turn * the light on, followed by the number of milliseconds to turn the light * off. */ #define LIGHT_FLASH_TIMED 1 /** * To flash the light using hardware assist, set flashMode to * the hardware mode. */ #define LIGHT_FLASH_HARDWARE 2 /** * Light brightness is managed by a user setting. */ #define BRIGHTNESS_MODE_USER 0 /** * Light brightness is managed by a light sensor. */ #define BRIGHTNESS_MODE_SENSOR 1 /** * The parameters that can be set for a given light. * * Not all lights must support all parameters. If you * can do something backward-compatible, you should. */ struct light_state_t { /** * The color of the LED in ARGB. * * Do your best here. * - If your light can only do red or green, if they ask for blue, * you should do green. * - If you can only do a brightness ramp, then use this formula: * unsigned char brightness = ((77*((color>>16)&0x00ff)) * + (150*((color>>8)&0x00ff)) + (29*(color&0x00ff))) >> 8; * - If you can only do on or off, 0 is off, anything else is on. * * The high byte should be ignored. Callers will set it to 0xff (which * would correspond to 255 alpha). */ unsigned int color; /** * See the LIGHT_FLASH_* constants */ int flashMode; int flashOnMS; int flashOffMS; /** * Policy used by the framework to manage the light's brightness. * Currently the values are BRIGHTNESS_MODE_USER and BRIGHTNESS_MODE_SENSOR. */ int brightnessMode; }; struct light_device_t { struct hw_device_t common; /** * Set the provided lights to the provided values. * * Returns: 0 on succes, error code on failure. */ int (*set_light)(struct light_device_t* dev, struct light_state_t const* state); }; __END_DECLS #endif // ANDROID_LIGHTS_INTERFACE_H android-headers-23/23/hardware/local_time_hal.h000066400000000000000000000074111264465411000214650ustar00rootroot00000000000000/* * 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_LOCAL_TIME_HAL_INTERFACE_H #define ANDROID_LOCAL_TIME_HAL_INTERFACE_H #include #include __BEGIN_DECLS /** * The id of this module */ #define LOCAL_TIME_HARDWARE_MODULE_ID "local_time" /** * Name of the local time devices to open */ #define LOCAL_TIME_HARDWARE_INTERFACE "local_time_hw_if" /**********************************************************************/ /** * A structure used to collect low level sync data in a lab environment. Most * HAL implementations will never need this structure. */ struct local_time_debug_event { int64_t local_timesync_event_id; int64_t local_time; }; /** * 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. */ struct local_time_module { struct hw_module_t common; }; struct local_time_hw_device { /** * Common methods of the local time hardware device. This *must* be the first member of * local_time_hw_device as users of this structure will cast a hw_device_t to * local_time_hw_device pointer in contexts where it's known the hw_device_t references a * local_time_hw_device. */ struct hw_device_t common; /** * * Returns the current value of the system wide local time counter */ int64_t (*get_local_time)(struct local_time_hw_device* dev); /** * * Returns the nominal frequency (in hertz) of the system wide local time * counter */ uint64_t (*get_local_freq)(struct local_time_hw_device* dev); /** * * Sets the HW slew rate of oscillator which drives the system wide local * time counter. On success, platforms should return 0. Platforms which * do not support HW slew should leave this method set to NULL. * * Valid values for rate range from MIN_INT16 to MAX_INT16. Platform * implementations should attempt map this range linearly to the min/max * slew rate of their hardware. */ int (*set_local_slew)(struct local_time_hw_device* dev, int16_t rate); /** * * A method used to collect low level sync data in a lab environments. * Most HAL implementations will simply set this member to NULL, or return * -EINVAL to indicate that this functionality is not supported. * Production HALs should never support this method. */ int (*get_debug_log)(struct local_time_hw_device* dev, struct local_time_debug_event* records, int max_records); }; typedef struct local_time_hw_device local_time_hw_device_t; /** convenience API for opening and closing a supported device */ static inline int local_time_hw_device_open( const struct hw_module_t* module, struct local_time_hw_device** device) { return module->methods->open(module, LOCAL_TIME_HARDWARE_INTERFACE, (struct hw_device_t**)device); } static inline int local_time_hw_device_close(struct local_time_hw_device* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_LOCAL_TIME_INTERFACE_H android-headers-23/23/hardware/memtrack.h000066400000000000000000000140221264465411000203300ustar00rootroot00000000000000/* * 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_HARDWARE_MEMTRACK_H #define ANDROID_INCLUDE_HARDWARE_MEMTRACK_H #include #include #include #include __BEGIN_DECLS #define MEMTRACK_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) /** * The id of this module */ #define MEMTRACK_HARDWARE_MODULE_ID "memtrack" /* * The Memory Tracker HAL is designed to return information about device-specific * memory usage. The primary goal is to be able to track memory that is not * trackable in any other way, for example texture memory that is allocated by * a process, but not mapped in to that process' address space. * A secondary goal is to be able to categorize memory used by a process into * GL, graphics, etc. All memory sizes should be in real memory usage, * accounting for stride, bit depth, rounding up to page size, etc. * * A process collecting memory statistics will call getMemory for each * combination of pid and memory type. For each memory type that it recognizes * the HAL should fill out an array of memtrack_record structures breaking * down the statistics of that memory type as much as possible. For example, * getMemory(, MEMTRACK_TYPE_GL) might return: * { { 4096, ACCOUNTED | PRIVATE | SYSTEM }, * { 40960, UNACCOUNTED | PRIVATE | SYSTEM }, * { 8192, ACCOUNTED | PRIVATE | DEDICATED }, * { 8192, UNACCOUNTED | PRIVATE | DEDICATED } } * If the HAL could not differentiate between SYSTEM and DEDICATED memory, it * could return: * { { 12288, ACCOUNTED | PRIVATE }, * { 49152, UNACCOUNTED | PRIVATE } } * * Memory should not overlap between types. For example, a graphics buffer * that has been mapped into the GPU as a surface should show up when * MEMTRACK_TYPE_GRAPHICS is requested, and not when MEMTRACK_TYPE_GL * is requested. */ enum memtrack_type { MEMTRACK_TYPE_OTHER = 0, MEMTRACK_TYPE_GL = 1, MEMTRACK_TYPE_GRAPHICS = 2, MEMTRACK_TYPE_MULTIMEDIA = 3, MEMTRACK_TYPE_CAMERA = 4, MEMTRACK_NUM_TYPES, }; struct memtrack_record { size_t size_in_bytes; unsigned int flags; }; /** * Flags to differentiate memory that can already be accounted for in * /proc//smaps, * (Shared_Clean + Shared_Dirty + Private_Clean + Private_Dirty = Size). * In general, memory mapped in to a userspace process is accounted unless * it was mapped with remap_pfn_range. * Exactly one of these should be set. */ #define MEMTRACK_FLAG_SMAPS_ACCOUNTED (1 << 1) #define MEMTRACK_FLAG_SMAPS_UNACCOUNTED (1 << 2) /** * Flags to differentiate memory shared across multiple processes vs. memory * used by a single process. Only zero or one of these may be set in a record. * If none are set, record is assumed to count shared + private memory. */ #define MEMTRACK_FLAG_SHARED (1 << 3) #define MEMTRACK_FLAG_SHARED_PSS (1 << 4) /* shared / num_procesess */ #define MEMTRACK_FLAG_PRIVATE (1 << 5) /** * Flags to differentiate memory taken from the kernel's allocation pool vs. * memory that is dedicated to non-kernel allocations, for example a carveout * or separate video memory. Only zero or one of these may be set in a record. * If none are set, record is assumed to count system + dedicated memory. */ #define MEMTRACK_FLAG_SYSTEM (1 << 6) #define MEMTRACK_FLAG_DEDICATED (1 << 7) /** * Flags to differentiate memory accessible by the CPU in non-secure mode vs. * memory that is protected. Only zero or one of these may be set in a record. * If none are set, record is assumed to count secure + nonsecure memory. */ #define MEMTRACK_FLAG_NONSECURE (1 << 8) #define MEMTRACK_FLAG_SECURE (1 << 9) /** * 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 memtrack_module { struct hw_module_t common; /** * (*init)() performs memtrack management setup actions and is called * once before any calls to getMemory(). * Returns 0 on success, -errno on error. */ int (*init)(const struct memtrack_module *module); /** * (*getMemory)() expects an array of record objects and populates up to * *num_record structures with the sizes of memory plus associated flags for * that memory. It also updates *num_records with the total number of * records it could return if *num_records was large enough when passed in. * Returning records with size 0 is expected, the number of records should * not vary between calls to getMemory for the same memory type, even * for different pids. * * The caller will often call getMemory for a type and pid with * *num_records == 0 to determine how many records to allocate room for, * this case should be a fast-path in the HAL, returning a constant and * not querying any kernel files. If *num_records passed in is 0, * then records may be NULL. * * This function must be thread-safe, it may get called from multiple * threads at the same time. * * Returns 0 on success, -ENODEV if the type is not supported, -errno * on other errors. */ int (*getMemory)(const struct memtrack_module *module, pid_t pid, int type, struct memtrack_record *records, size_t *num_records); } memtrack_module_t; __END_DECLS #endif // ANDROID_INCLUDE_HARDWARE_MEMTRACK_H android-headers-23/23/hardware/nfc.h000066400000000000000000000234201264465411000172750ustar00rootroot00000000000000/* * Copyright (C) 2011, 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_NFC_HAL_INTERFACE_H #define ANDROID_NFC_HAL_INTERFACE_H #include #include #include #include #include __BEGIN_DECLS /* NFC device HAL for NCI-based NFC controllers. * * This HAL allows NCI silicon vendors to make use * of the core NCI stack in Android for their own silicon. * * The responibilities of the NCI HAL implementation * are as follows: * * - Implement the transport to the NFC controller * - Implement each of the HAL methods specified below as applicable to their silicon * - Pass up received NCI messages from the controller to the stack * * A simplified timeline of NCI HAL method calls: * 1) Core NCI stack calls open() * 2) Core NCI stack executes CORE_RESET and CORE_INIT through calls to write() * 3) Core NCI stack calls core_initialized() to allow HAL to do post-init configuration * 4) Core NCI stack calls pre_discover() to allow HAL to prepare for RF discovery * 5) Core NCI stack starts discovery through calls to write() * 6) Core NCI stack stops discovery through calls to write() (e.g. screen turns off) * 7) Core NCI stack calls pre_discover() to prepare for RF discovery (e.g. screen turned back on) * 8) Core NCI stack starts discovery through calls to write() * ... * ... * 9) Core NCI stack calls close() */ #define NFC_NCI_HARDWARE_MODULE_ID "nfc_nci" #define NFC_NCI_BCM2079X_HARDWARE_MODULE_ID "nfc_nci.bcm2079x" #define NFC_NCI_CONTROLLER "nci" /* * nfc_nci_module_t should contain module-specific parameters */ typedef struct nfc_nci_module_t { /** * Common methods of the NFC NCI module. This *must* be the first member of * nfc_nci_module_t as users of this structure will cast a hw_module_t to * nfc_nci_module_t pointer in contexts where it's known the hw_module_t references a * 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. */ typedef void (nfc_stack_callback_t) (nfc_event_t event, nfc_status_t event_status); /* * The callback passed in from the NFC stack that the HAL * can use to pass incomming data to the stack. */ typedef void (nfc_stack_data_callback_t) (uint16_t data_len, uint8_t* p_data); /* nfc_nci_device_t starts with a hw_device_t struct, * followed by device-specific methods and members. * * All methods in the NCI HAL are asynchronous. */ typedef struct nfc_nci_device { /** * Common methods of the NFC NCI device. This *must* be the first member of * nfc_nci_device_t as users of this structure will cast a hw_device_t to * nfc_nci_device_t pointer in contexts where it's known the hw_device_t references a * nfc_nci_device_t. */ struct hw_device_t common; /* * (*open)() Opens the NFC controller device and performs initialization. * This may include patch download and other vendor-specific initialization. * * If open completes successfully, the controller should be ready to perform * NCI initialization - ie accept CORE_RESET and subsequent commands through * the write() call. * * If open() returns 0, the NCI stack will wait for a HAL_NFC_OPEN_CPLT_EVT * before continuing. * * If open() returns any other value, the NCI stack will stop. * */ int (*open)(const struct nfc_nci_device *p_dev, nfc_stack_callback_t *p_cback, nfc_stack_data_callback_t *p_data_cback); /* * (*write)() Performs an NCI write. * * This method may queue writes and return immediately. The only * requirement is that the writes are executed in order. */ int (*write)(const struct nfc_nci_device *p_dev, uint16_t data_len, const uint8_t *p_data); /* * (*core_initialized)() is called after the CORE_INIT_RSP is received from the NFCC. * At this time, the HAL can do any chip-specific configuration. * * If core_initialized() returns 0, the NCI stack will wait for a HAL_NFC_POST_INIT_CPLT_EVT * before continuing. * * If core_initialized() returns any other value, the NCI stack will continue * immediately. */ int (*core_initialized)(const struct nfc_nci_device *p_dev, uint8_t* p_core_init_rsp_params); /* * (*pre_discover)() Is called every time before starting RF discovery. * It is a good place to do vendor-specific configuration that must be * performed every time RF discovery is about to be started. * * If pre_discover() returns 0, the NCI stack will wait for a HAL_NFC_PRE_DISCOVER_CPLT_EVT * before continuing. * * If pre_discover() returns any other value, the NCI stack will start * RF discovery immediately. */ int (*pre_discover)(const struct nfc_nci_device *p_dev); /* * (*close)() Closed the NFC controller. Should free all resources. */ int (*close)(const struct nfc_nci_device *p_dev); /* * (*control_granted)() Grant HAL the exclusive control to send NCI commands. * Called in response to HAL_REQUEST_CONTROL_EVT. * Must only be called when there are no NCI commands pending. * HAL_RELEASE_CONTROL_EVT will notify when HAL no longer needs exclusive control. */ int (*control_granted)(const struct nfc_nci_device *p_dev); /* * (*power_cycle)() Restart controller by power cyle; * HAL_OPEN_CPLT_EVT will notify when operation is complete. */ int (*power_cycle)(const struct nfc_nci_device *p_dev); } nfc_nci_device_t; /* * Convenience methods that the NFC stack can use to open * and close an NCI device */ static inline int nfc_nci_open(const struct hw_module_t* module, nfc_nci_device_t** dev) { return module->methods->open(module, NFC_NCI_CONTROLLER, (struct hw_device_t**) dev); } static inline int nfc_nci_close(nfc_nci_device_t* dev) { return dev->common.close(&dev->common); } /* * End NFC NCI HAL */ /* * This is a limited NFC HAL for NXP PN544-based devices. * This HAL as Android is moving to * an NCI-based NFC stack. * * All NCI-based NFC controllers should use the NFC-NCI * HAL instead. * Begin PN544 specific HAL */ #define NFC_HARDWARE_MODULE_ID "nfc" #define NFC_PN544_CONTROLLER "pn544" typedef struct nfc_module_t { /** * Common methods of the NFC NXP PN544 module. This *must* be the first member of * nfc_module_t as users of this structure will cast a hw_module_t to * nfc_module_t pointer in contexts where it's known the hw_module_t references a * nfc_module_t. */ struct hw_module_t common; } nfc_module_t; /* * PN544 linktypes. * UART * I2C * USB (uses UART DAL) */ typedef enum { PN544_LINK_TYPE_UART, PN544_LINK_TYPE_I2C, PN544_LINK_TYPE_USB, PN544_LINK_TYPE_INVALID, } nfc_pn544_linktype; typedef struct { /** * Common methods of the NFC NXP PN544 device. This *must* be the first member of * nfc_pn544_device_t as users of this structure will cast a hw_device_t to * nfc_pn544_device_t pointer in contexts where it's known the hw_device_t references a * nfc_pn544_device_t. */ struct hw_device_t common; /* The number of EEPROM registers to write */ uint32_t num_eeprom_settings; /* The actual EEPROM settings * For PN544, each EEPROM setting is a 4-byte entry, * of the format [0x00, addr_msb, addr_lsb, value]. */ uint8_t* eeprom_settings; /* The link type to which the PN544 is connected */ nfc_pn544_linktype linktype; /* The device node to which the PN544 is connected */ const char* device_node; /* On Crespo we had an I2C issue that would cause us to sometimes read * the I2C slave address (0x57) over the bus. libnfc contains * a hack to ignore this byte and try to read the length byte * again. * Set to 0 to disable the workaround, 1 to enable it. */ uint8_t enable_i2c_workaround; /* I2C slave address. Multiple I2C addresses are * possible for PN544 module. Configure address according to * board design. */ uint8_t i2c_device_address; } nfc_pn544_device_t; static inline int nfc_pn544_open(const struct hw_module_t* module, nfc_pn544_device_t** dev) { return module->methods->open(module, NFC_PN544_CONTROLLER, (struct hw_device_t**) dev); } static inline int nfc_pn544_close(nfc_pn544_device_t* dev) { return dev->common.close(&dev->common); } /* * End PN544 specific HAL */ __END_DECLS #endif // ANDROID_NFC_HAL_INTERFACE_H android-headers-23/23/hardware/nfc_tag.h000066400000000000000000000055471264465411000201420ustar00rootroot00000000000000/* * 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_NFC_TAG_HAL_INTERFACE_H #define ANDROID_NFC_TAG_HAL_INTERFACE_H #include #include __BEGIN_DECLS /* * HAL for programmable NFC tags. * */ #define NFC_TAG_HARDWARE_MODULE_ID "nfc_tag" #define NFC_TAG_ID "tag" typedef struct nfc_tag_module_t { /** * Common methods of the NFC tag module. This *must* be the first member of * nfc_tag_module_t as users of this structure will cast a hw_module_t to * nfc_tag_module_t pointer in contexts where it's known the hw_module_t references a * nfc_tag_module_t. */ struct hw_module_t common; } nfc_tag_module_t; typedef struct nfc_tag_device { /** * Common methods of the NFC tag device. This *must* be the first member of * nfc_tag_device_t as users of this structure will cast a hw_device_t to * nfc_tag_device_t pointer in contexts where it's known the hw_device_t references a * nfc_tag_device_t. */ struct hw_device_t common; /** * Initialize the NFC tag. * * The driver must: * * Set the static lock bytes to read only * * Configure the Capability Container to disable write acess * eg: 0xE1 0x10 0x0F * * This function is called once before any calls to setContent(). * * Return 0 on success or -errno on error. */ int (*init)(const struct nfc_tag_device *dev); /** * Set the NFC tag content. * * The driver must write in the data area of the tag starting at * byte 0 of block 4 and zero the rest of the data area. * * Returns 0 on success or -errno on error. */ int (*setContent)(const struct nfc_tag_device *dev, const uint8_t *data, size_t len); /** * Returns the memory size of the data area. */ int (*getMemorySize)(const struct nfc_tag_device *dev); } nfc_tag_device_t; static inline int nfc_tag_open(const struct hw_module_t* module, nfc_tag_device_t** dev) { return module->methods->open(module, NFC_TAG_ID, (struct hw_device_t**)dev); } static inline int nfc_tag_close(nfc_tag_device_t* dev) { return dev->common.close(&dev->common); } __END_DECLS #endif // ANDROID_NFC_TAG_HAL_INTERFACE_H android-headers-23/23/hardware/power.h000066400000000000000000000127071264465411000176710ustar00rootroot00000000000000/* * 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_HARDWARE_POWER_H #define ANDROID_INCLUDE_HARDWARE_POWER_H #include #include #include #include __BEGIN_DECLS #define POWER_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define POWER_MODULE_API_VERSION_0_2 HARDWARE_MODULE_API_VERSION(0, 2) #define POWER_MODULE_API_VERSION_0_3 HARDWARE_MODULE_API_VERSION(0, 3) /** * The id of this module */ #define POWER_HARDWARE_MODULE_ID "power" /* * Power hint identifiers passed to (*powerHint) */ typedef enum { POWER_HINT_VSYNC = 0x00000001, POWER_HINT_INTERACTION = 0x00000002, /* DO NOT USE POWER_HINT_VIDEO_ENCODE/_DECODE! They will be removed in * KLP. */ POWER_HINT_VIDEO_ENCODE = 0x00000003, POWER_HINT_VIDEO_DECODE = 0x00000004, POWER_HINT_LOW_POWER = 0x00000005 } power_hint_t; typedef enum { POWER_FEATURE_DOUBLE_TAP_TO_WAKE = 0x00000001 } feature_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 power_module { struct hw_module_t common; /* * (*init)() performs power management setup actions at runtime * startup, such as to set default cpufreq parameters. This is * called only by the Power HAL instance loaded by * PowerManagerService. */ void (*init)(struct power_module *module); /* * (*setInteractive)() performs power management actions upon the * system entering interactive state (that is, the system is awake * and ready for interaction, often with UI devices such as * display and touchscreen enabled) or non-interactive state (the * system appears asleep, display usually turned off). The * non-interactive state is usually entered after a period of * inactivity, in order to conserve battery power during * such inactive periods. * * Typical actions are to turn on or off devices and adjust * cpufreq parameters. This function may also call the * appropriate interfaces to allow the kernel to suspend the * system to low-power sleep state when entering non-interactive * state, and to disallow low-power suspend when the system is in * interactive state. When low-power suspend state is allowed, the * kernel may suspend the system whenever no wakelocks are held. * * on is non-zero when the system is transitioning to an * interactive / awake state, and zero when transitioning to a * non-interactive / asleep state. * * This function is called to enter non-interactive state after * turning off the screen (if present), and called to enter * interactive state prior to turning on the screen. */ void (*setInteractive)(struct power_module *module, int on); /* * (*powerHint) is called to pass hints on power requirements, which * may result in adjustment of power/performance parameters of the * cpufreq governor and other controls. The possible hints are: * * POWER_HINT_VSYNC * * Foreground app has started or stopped requesting a VSYNC pulse * from SurfaceFlinger. If the app has started requesting VSYNC * then CPU and GPU load is expected soon, and it may be appropriate * to raise speeds of CPU, memory bus, etc. The data parameter is * non-zero to indicate VSYNC pulse is now requested, or zero for * VSYNC pulse no longer requested. * * POWER_HINT_INTERACTION * * User is interacting with the device, for example, touchscreen * events are incoming. CPU and GPU load may be expected soon, * and it may be appropriate to raise speeds of CPU, memory bus, * etc. The data parameter is unused. * * POWER_HINT_LOW_POWER * * Low power mode is activated or deactivated. Low power mode * is intended to save battery at the cost of performance. The data * parameter is non-zero when low power mode is activated, and zero * when deactivated. * * A particular platform may choose to ignore any hint. * * availability: version 0.2 * */ void (*powerHint)(struct power_module *module, power_hint_t hint, void *data); /* * (*setFeature) is called to turn on or off a particular feature * depending on the state parameter. The possible features are: * * FEATURE_DOUBLE_TAP_TO_WAKE * * Enabling/Disabling this feature will allow/disallow the system * to wake up by tapping the screen twice. * * availability: version 0.3 * */ void (*setFeature)(struct power_module *module, feature_t feature, int state); } power_module_t; __END_DECLS #endif // ANDROID_INCLUDE_HARDWARE_POWER_H android-headers-23/23/hardware/qemu_pipe.h000066400000000000000000000054251264465411000205200ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/hardware/qemud.h000066400000000000000000000102441264465411000176420ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/hardware/radio.h000066400000000000000000000245671264465411000176420ustar00rootroot00000000000000/* * 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. */ #include #include #ifndef ANDROID_RADIO_HAL_H #define ANDROID_RADIO_HAL_H __BEGIN_DECLS /** * The id of this module */ #define RADIO_HARDWARE_MODULE_ID "radio" /** * Name of the audio devices to open */ #define RADIO_HARDWARE_DEVICE "radio_hw_device" #define RADIO_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) #define RADIO_MODULE_API_VERSION_CURRENT RADIO_MODULE_API_VERSION_1_0 #define RADIO_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) #define RADIO_DEVICE_API_VERSION_CURRENT RADIO_DEVICE_API_VERSION_1_0 /** * List of known radio HAL modules. This is the base name of the radio HAL * library composed of the "radio." prefix, one of the base names below and * a suffix specific to the device. * E.g: radio.fm.default.so */ #define RADIO_HARDWARE_MODULE_ID_FM "fm" /* corresponds to RADIO_CLASS_AM_FM */ #define RADIO_HARDWARE_MODULE_ID_SAT "sat" /* corresponds to RADIO_CLASS_SAT */ #define RADIO_HARDWARE_MODULE_ID_DT "dt" /* corresponds to RADIO_CLASS_DT */ /** * 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. */ struct radio_module { struct hw_module_t common; }; /* * Callback function called by the HAL when one of the following occurs: * - event RADIO_EVENT_HW_FAILURE: radio chip of driver failure requiring * closing and reopening of the tuner interface. * - event RADIO_EVENT_CONFIG: new configuration applied in response to open_tuner(), * or set_configuration(). The event status is 0 (no error) if the configuration has been applied, * -EINVAL is not or -ETIMEDOUT in case of time out. * - event RADIO_EVENT_TUNED: tune locked on new station/frequency following scan(), * step(), tune() or auto AF switching. The event status is 0 (no error) if in tune, * -EINVAL is not tuned and data in radio_program_info is not valid or -ETIMEDOUT if scan() * timed out. * - event RADIO_EVENT_TA: at the beginning and end of traffic announcement if current * configuration enables TA. * - event RADIO_EVENT_AF: after automatic switching to alternate frequency if current * configuration enables AF switching. * - event RADIO_EVENT_ANTENNA: when the antenna is connected or disconnected. * - event RADIO_EVENT_METADATA: when new meta data are received from the tuned station. * The callback MUST NOT be called synchronously while executing a HAL function but from * a separate thread. */ typedef void (*radio_callback_t)(radio_hal_event_t *event, void *cookie); /* control interface for a radio tuner */ struct radio_tuner { /* * Apply current radio band configuration (band, range, channel spacing ...). * * arguments: * - config: the band configuration to apply * * returns: * 0 if configuration could be applied * -EINVAL if configuration requested is invalid * * Automatically cancels pending scan, step or tune. * * Callback function with event RADIO_EVENT_CONFIG MUST be called once the * configuration is applied or a failure occurs or after a time out. */ int (*set_configuration)(const struct radio_tuner *tuner, const radio_hal_band_config_t *config); /* * Retrieve current radio band configuration. * * arguments: * - config: where to return the band configuration * * returns: * 0 if valid configuration is returned * -EINVAL if invalid arguments are passed */ int (*get_configuration)(const struct radio_tuner *tuner, radio_hal_band_config_t *config); /* * Start scanning up to next valid station. * Must be called when a valid configuration has been applied. * * arguments: * - direction: RADIO_DIRECTION_UP or RADIO_DIRECTION_DOWN * - skip_sub_channel: valid for HD radio or digital radios only: ignore sub channels * (e.g SPS for HD radio). * * returns: * 0 if scan successfully started * -ENOSYS if called out of sequence * -ENODEV if another error occurs * * Automatically cancels pending scan, step or tune. * * Callback function with event RADIO_EVENT_TUNED MUST be called once * locked on a station or after a time out or full frequency scan if * no station found. The event status should indicate if a valid station * is tuned or not. */ int (*scan)(const struct radio_tuner *tuner, radio_direction_t direction, bool skip_sub_channel); /* * Move one channel spacing up or down. * Must be called when a valid configuration has been applied. * * arguments: * - direction: RADIO_DIRECTION_UP or RADIO_DIRECTION_DOWN * - skip_sub_channel: valid for HD radio or digital radios only: ignore sub channels * (e.g SPS for HD radio). * * returns: * 0 if step successfully started * -ENOSYS if called out of sequence * -ENODEV if another error occurs * * Automatically cancels pending scan, step or tune. * * Callback function with event RADIO_EVENT_TUNED MUST be called once * step completed or after a time out. The event status should indicate * if a valid station is tuned or not. */ int (*step)(const struct radio_tuner *tuner, radio_direction_t direction, bool skip_sub_channel); /* * Tune to specified frequency. * Must be called when a valid configuration has been applied. * * arguments: * - channel: channel to tune to. A frequency in kHz for AM/FM/HD Radio bands. * - sub_channel: valid for HD radio or digital radios only: (e.g SPS number for HD radio). * * returns: * 0 if tune successfully started * -ENOSYS if called out of sequence * -EINVAL if invalid arguments are passed * -ENODEV if another error occurs * * Automatically cancels pending scan, step or tune. * * Callback function with event RADIO_EVENT_TUNED MUST be called once * tuned or after a time out. The event status should indicate * if a valid station is tuned or not. */ int (*tune)(const struct radio_tuner *tuner, unsigned int channel, unsigned int sub_channel); /* * Cancel a scan, step or tune operation. * Must be called while a scan, step or tune operation is pending * (callback not yet sent). * * returns: * 0 if successful * -ENOSYS if called out of sequence * -ENODEV if another error occurs * * The callback is not sent. */ int (*cancel)(const struct radio_tuner *tuner); /* * Retrieve current station information. * * arguments: * - info: where to return the program info. * If info->metadata is NULL. no meta data should be returned. * If meta data must be returned, they should be added to or cloned to * info->metadata, not passed from a newly created meta data buffer. * * returns: * 0 if tuned and information available * -EINVAL if invalid arguments are passed * -ENODEV if another error occurs */ int (*get_program_information)(const struct radio_tuner *tuner, radio_program_info_t *info); }; struct radio_hw_device { struct hw_device_t common; /* * Retrieve implementation properties. * * arguments: * - properties: where to return the module properties * * returns: * 0 if no error * -EINVAL if invalid arguments are passed */ int (*get_properties)(const struct radio_hw_device *dev, radio_hal_properties_t *properties); /* * Open a tuner interface for the requested configuration. * If no other tuner is opened, this will activate the radio module. * * arguments: * - config: the band configuration to apply * - audio: this tuner will be used for live radio listening and should be connected to * the radio audio source. * - callback: the event callback * - cookie: the cookie to pass when calling the callback * - tuner: where to return the tuner interface * * returns: * 0 if HW was powered up and configuration could be applied * -EINVAL if configuration requested is invalid * -ENOSYS if called out of sequence * * Callback function with event RADIO_EVENT_CONFIG MUST be called once the * configuration is applied or a failure occurs or after a time out. */ int (*open_tuner)(const struct radio_hw_device *dev, const radio_hal_band_config_t *config, bool audio, radio_callback_t callback, void *cookie, const struct radio_tuner **tuner); /* * Close a tuner interface. * If the last tuner is closed, the radio module is deactivated. * * arguments: * - tuner: the tuner interface to close * * returns: * 0 if powered down successfully. * -EINVAL if an invalid argument is passed * -ENOSYS if called out of sequence */ int (*close_tuner)(const struct radio_hw_device *dev, const struct radio_tuner *tuner); }; typedef struct radio_hw_device radio_hw_device_t; /** convenience API for opening and closing a supported device */ 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); } static inline int radio_hw_device_close(const struct radio_hw_device* device) { return device->common.close((struct hw_device_t *)&device->common); } __END_DECLS #endif // ANDROID_RADIO_HAL_H android-headers-23/23/hardware/sensors.h000066400000000000000000001163211264465411000202260ustar00rootroot00000000000000/* * 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_SENSORS_INTERFACE_H #define ANDROID_SENSORS_INTERFACE_H #include #include #include #include #include __BEGIN_DECLS /*****************************************************************************/ #define SENSORS_HEADER_VERSION 1 #define SENSORS_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define SENSORS_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION_2(0, 1, SENSORS_HEADER_VERSION) #define SENSORS_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION_2(1, 0, SENSORS_HEADER_VERSION) #define SENSORS_DEVICE_API_VERSION_1_1 HARDWARE_DEVICE_API_VERSION_2(1, 1, SENSORS_HEADER_VERSION) #define SENSORS_DEVICE_API_VERSION_1_2 HARDWARE_DEVICE_API_VERSION_2(1, 2, SENSORS_HEADER_VERSION) #define SENSORS_DEVICE_API_VERSION_1_3 HARDWARE_DEVICE_API_VERSION_2(1, 3, SENSORS_HEADER_VERSION) #define SENSORS_DEVICE_API_VERSION_1_4 HARDWARE_DEVICE_API_VERSION_2(1, 4, SENSORS_HEADER_VERSION) /** * Please see the Sensors section of source.android.com for an * introduction to and detailed descriptions of Android sensor types: * http://source.android.com/devices/sensors/index.html */ /** * The id of this module */ #define SENSORS_HARDWARE_MODULE_ID "sensors" /** * Name of the sensors device to open */ #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. */ #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" /** * Values returned by the accelerometer in various locations in the universe. * all values are in SI units (m/s^2) */ #define GRAVITY_SUN (275.0f) #define GRAVITY_EARTH (9.80665f) /** Maximum magnetic field on Earth's surface */ #define MAGNETIC_FIELD_EARTH_MAX (60.0f) /** 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 /** * sensor event data */ typedef struct { union { float v[3]; struct { float x; float y; float z; }; struct { float azimuth; float pitch; float roll; }; }; int8_t status; uint8_t reserved[3]; } sensors_vec_t; /** * uncalibrated gyroscope and magnetometer event data */ typedef struct { union { float uncalib[3]; struct { float x_uncalib; float y_uncalib; float z_uncalib; }; }; union { float bias[3]; struct { float x_bias; float y_bias; float z_bias; }; }; } uncalibrated_event_t; /** * Meta data event data */ typedef struct meta_data_event { int32_t what; int32_t sensor; } meta_data_event_t; /** * Heart rate event data */ typedef struct { // Heart rate in beats per minute. // Set to 0 when status is SENSOR_STATUS_UNRELIABLE or ..._NO_CONTACT float bpm; // Status of the sensor for this reading. Set to one SENSOR_STATUS_... // Note that this value should only be set for sensors that explicitly define // the meaning of this field. This field is not piped through the framework // for other sensors. int8_t status; } heart_rate_event_t; /** * Union of the various types of sensor data * that can be returned. */ typedef struct sensors_event_t { /* must be sizeof(struct sensors_event_t) */ int32_t version; /* sensor identifier */ int32_t sensor; /* sensor type */ int32_t type; /* reserved */ int32_t reserved0; /* time is in nanosecond */ int64_t timestamp; union { union { float data[16]; /* acceleration values are in meter per second per second (m/s^2) */ sensors_vec_t acceleration; /* magnetic vector values are in micro-Tesla (uT) */ sensors_vec_t magnetic; /* orientation values are in degrees */ sensors_vec_t orientation; /* gyroscope values are in rad/s */ sensors_vec_t gyro; /* temperature is in degrees centigrade (Celsius) */ float temperature; /* distance in centimeters */ float distance; /* light in SI lux units */ float light; /* pressure in hectopascal (hPa) */ float pressure; /* relative humidity in percent */ float relative_humidity; /* uncalibrated gyroscope values are in rad/s */ uncalibrated_event_t uncalibrated_gyro; /* uncalibrated magnetometer values are in micro-Teslas */ uncalibrated_event_t uncalibrated_magnetic; /* heart rate data containing value in bpm and status */ heart_rate_event_t heart_rate; /* this is a special event. see SENSOR_TYPE_META_DATA above. * sensors_meta_data_event_t events are all reported with a type of * SENSOR_TYPE_META_DATA. The handle is ignored and must be zero. */ meta_data_event_t meta_data; }; union { uint64_t data[8]; /* step-counter */ uint64_t step_counter; } u64; }; /* Reserved flags for internal use. Set to zero. */ uint32_t flags; uint32_t reserved1[3]; } sensors_event_t; /* see SENSOR_TYPE_META_DATA */ typedef sensors_event_t sensors_meta_data_event_t; struct sensor_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. */ struct sensors_module_t { struct hw_module_t common; /** * Enumerate all available sensors. The list is returned in "list". * @return number of sensors in the list */ int (*get_sensors_list)(struct sensors_module_t* module, struct sensor_t const** list); /** * Place the module in a specific mode. The following modes are defined * * 0 - Normal operation. Default state of the module. * 1 - Loopback mode. Data is injected for the the supported * sensors by the sensor service in this mode. * @return 0 on success * -EINVAL if requested mode is not supported * -EPERM if operation is not allowed */ int (*set_operation_mode)(unsigned int mode); }; struct sensor_t { /* Name of this sensor. * All sensors of the same "type" must have a different "name". */ const char* name; /* vendor of the hardware part */ const char* vendor; /* version of the hardware part + driver. The value of this field * must increase when the driver is updated in a way that changes the * output of this sensor. This is important for fused sensors when the * fusion algorithm is updated. */ int version; /* handle that identifies this sensors. This handle is used to reference * this sensor throughout the HAL API. */ int handle; /* this sensor's type. */ int type; /* maximum range of this sensor's value in SI units */ float maxRange; /* smallest difference between two values reported by this sensor */ float resolution; /* rough estimate of this sensor's power consumption in mA */ float power; /* this value depends on the reporting mode: * * continuous: minimum sample period allowed in microseconds * on-change : 0 * one-shot :-1 * special : 0, unless otherwise noted */ int32_t minDelay; /* number of events reserved for this sensor in the batch mode FIFO. * If there is a dedicated FIFO for this sensor, then this is the * size of this FIFO. If the FIFO is shared with other sensors, * this is the size reserved for that sensor and it can be zero. */ uint32_t fifoReservedEventCount; /* maximum number of events of this sensor that could be batched. * This is especially relevant when the FIFO is shared between * several sensors; this value is then set to the size of that FIFO. */ 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. */ const char* stringType; /* permission required to see this sensor, register to it and receive data. * Set to "" if no permission is required. Some sensor types like the * heart rate monitor have a mandatory require_permission. * For sensors that always require a specific permission, like the heart * rate monitor, the android framework might overwrite this string * automatically. */ const char* requiredPermission; /* This value is defined only for continuous mode and on-change sensors. It is the delay between * two sensor events corresponding to the lowest frequency that this sensor supports. When lower * frequencies are requested through batch()/setDelay() the events will be generated at this * frequency instead. It can be used by the framework or applications to estimate when the batch * FIFO may be full. * * NOTE: 1) period_ns is in nanoseconds where as maxDelay/minDelay are in microseconds. * continuous, on-change: maximum sampling period allowed in microseconds. * one-shot, special : 0 * 2) maxDelay should always fit within a 32 bit signed integer. It is declared as 64 bit * on 64 bit architectures only for binary compatibility reasons. * Availability: SENSORS_DEVICE_API_VERSION_1_3 */ #ifdef __LP64__ int64_t maxDelay; #else int32_t maxDelay; #endif /* Flags for sensor. See SENSOR_FLAG_* above. Only the least significant 32 bits are used here. * It is declared as 64 bit on 64 bit architectures only for binary compatibility reasons. * Availability: SENSORS_DEVICE_API_VERSION_1_3 */ #ifdef __LP64__ uint64_t flags; #else uint32_t flags; #endif /* reserved fields, must be zero */ void* reserved[2]; }; /* * sensors_poll_device_t is used with SENSORS_DEVICE_API_VERSION_0_1 * and is present for backward binary and source compatibility. * See the Sensors HAL interface section for complete descriptions of the * following functions: * http://source.android.com/devices/sensors/index.html#hal */ struct sensors_poll_device_t { struct hw_device_t common; int (*activate)(struct sensors_poll_device_t *dev, int sensor_handle, int enabled); int (*setDelay)(struct sensors_poll_device_t *dev, int sensor_handle, int64_t sampling_period_ns); int (*poll)(struct sensors_poll_device_t *dev, sensors_event_t* data, int count); }; /* * struct sensors_poll_device_1 is used in HAL versions >= SENSORS_DEVICE_API_VERSION_1_0 */ typedef struct sensors_poll_device_1 { union { /* sensors_poll_device_1 is compatible with sensors_poll_device_t, * and can be down-cast to it */ struct sensors_poll_device_t v0; struct { struct hw_device_t common; /* Activate/de-activate one sensor. Return 0 on success, negative * * sensor_handle is the handle of the sensor to change. * enabled set to 1 to enable, or 0 to disable the sensor. * * Return 0 on success, negative errno code otherwise. */ int (*activate)(struct sensors_poll_device_t *dev, int sensor_handle, int enabled); /** * Set the events's period in nanoseconds for a given sensor. * If sampling_period_ns > max_delay it will be truncated to * max_delay and if sampling_period_ns < min_delay it will be * replaced by min_delay. */ int (*setDelay)(struct sensors_poll_device_t *dev, int sensor_handle, int64_t sampling_period_ns); /** * Returns an array of sensor data. */ int (*poll)(struct sensors_poll_device_t *dev, sensors_event_t* data, int count); }; }; /* * Sets a sensor’s parameters, including sampling frequency and maximum * report latency. This function can be called while the sensor is * activated, in which case it must not cause any sensor measurements to * be lost: transitioning from one sampling rate to the other cannot cause * lost events, nor can transitioning from a high maximum report latency to * a low maximum report latency. * See the Batching sensor results page for details: * http://source.android.com/devices/sensors/batching.html */ int (*batch)(struct sensors_poll_device_1* dev, int sensor_handle, int flags, int64_t sampling_period_ns, int64_t max_report_latency_ns); /* * Flush adds a META_DATA_FLUSH_COMPLETE event (sensors_event_meta_data_t) * to the end of the "batch mode" FIFO for the specified sensor and flushes * the FIFO. * If the FIFO is empty or if the sensor doesn't support batching (FIFO size zero), * it should return SUCCESS along with a trivial META_DATA_FLUSH_COMPLETE event added to the * event stream. This applies to all sensors other than one-shot sensors. * If the sensor is a one-shot sensor, flush must return -EINVAL and not generate * any flush complete metadata. * If the sensor is not active at the time flush() is called, flush() should return * -EINVAL. */ int (*flush)(struct sensors_poll_device_1* dev, int sensor_handle); /* * Inject a single sensor sample to be to this device. * data points to the sensor event to be injected * @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); } sensors_poll_device_1_t; /** convenience API for opening and closing a device */ static inline int sensors_open(const struct hw_module_t* module, struct sensors_poll_device_t** device) { return module->methods->open(module, SENSORS_HARDWARE_POLL, (struct hw_device_t**)device); } static inline int sensors_close(struct sensors_poll_device_t* device) { return device->common.close(&device->common); } 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); } static inline int sensors_close_1(sensors_poll_device_1_t* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_SENSORS_INTERFACE_H android-headers-23/23/hardware/sound_trigger.h000066400000000000000000000115301264465411000214010ustar00rootroot00000000000000/* * 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. */ #include #include #include #ifndef ANDROID_SOUND_TRIGGER_HAL_H #define ANDROID_SOUND_TRIGGER_HAL_H __BEGIN_DECLS /** * The id of this module */ #define SOUND_TRIGGER_HARDWARE_MODULE_ID "sound_trigger" /** * Name of the audio devices to open */ #define SOUND_TRIGGER_HARDWARE_INTERFACE "sound_trigger_hw_if" #define SOUND_TRIGGER_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) #define SOUND_TRIGGER_MODULE_API_VERSION_CURRENT SOUND_TRIGGER_MODULE_API_VERSION_1_0 #define SOUND_TRIGGER_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) #define SOUND_TRIGGER_DEVICE_API_VERSION_CURRENT SOUND_TRIGGER_DEVICE_API_VERSION_1_0 /** * List of known sound trigger HAL modules. This is the base name of the sound_trigger HAL * library composed of the "sound_trigger." prefix, one of the base names below and * a suffix specific to the device. * e.g: sondtrigger.primary.goldfish.so or sound_trigger.primary.default.so */ #define SOUND_TRIGGER_HARDWARE_MODULE_ID_PRIMARY "primary" /** * 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. */ struct sound_trigger_module { struct hw_module_t common; }; typedef void (*recognition_callback_t)(struct sound_trigger_recognition_event *event, void *cookie); typedef void (*sound_model_callback_t)(struct sound_trigger_model_event *event, void *cookie); struct sound_trigger_hw_device { struct hw_device_t common; /* * Retrieve implementation properties. */ int (*get_properties)(const struct sound_trigger_hw_device *dev, struct sound_trigger_properties *properties); /* * Load a sound model. Once loaded, recognition of this model can be started and stopped. * Only one active recognition per model at a time. The SoundTrigger service will handle * concurrent recognition requests by different users/applications on the same model. * The implementation returns a unique handle used by other functions (unload_sound_model(), * start_recognition(), etc... */ int (*load_sound_model)(const struct sound_trigger_hw_device *dev, struct sound_trigger_sound_model *sound_model, sound_model_callback_t callback, void *cookie, sound_model_handle_t *handle); /* * Unload a sound model. A sound model can be unloaded to make room for a new one to overcome * implementation limitations. */ int (*unload_sound_model)(const struct sound_trigger_hw_device *dev, sound_model_handle_t handle); /* Start recognition on a given model. Only one recognition active at a time per model. * Once recognition succeeds of fails, the callback is called. * TODO: group recognition configuration parameters into one struct and add key phrase options. */ int (*start_recognition)(const struct sound_trigger_hw_device *dev, sound_model_handle_t sound_model_handle, const struct sound_trigger_recognition_config *config, recognition_callback_t callback, void *cookie); /* Stop recognition on a given model. * The implementation does not have to call the callback when stopped via this method. */ int (*stop_recognition)(const struct sound_trigger_hw_device *dev, sound_model_handle_t sound_model_handle); }; typedef struct sound_trigger_hw_device sound_trigger_hw_device_t; /** convenience API for opening and closing a supported device */ 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); } static inline int sound_trigger_hw_device_close(struct sound_trigger_hw_device* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_SOUND_TRIGGER_HAL_H android-headers-23/23/hardware/tv_input.h000066400000000000000000000326621264465411000204070ustar00rootroot00000000000000/* * Copyright 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_TV_INPUT_INTERFACE_H #define ANDROID_TV_INPUT_INTERFACE_H #include #include #include #include #include #include __BEGIN_DECLS /* * Module versioning information for the TV input hardware module, based on * tv_input_module_t.common.module_api_version. * * Version History: * * TV_INPUT_MODULE_API_VERSION_0_1: * Initial TV input hardware module API. * */ #define TV_INPUT_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define TV_INPUT_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION(0, 1) /* * The id of this module */ #define TV_INPUT_HARDWARE_MODULE_ID "tv_input" #define TV_INPUT_DEFAULT_DEVICE "default" /*****************************************************************************/ /* * 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 tv_input_module { struct hw_module_t common; } tv_input_module_t; /*****************************************************************************/ enum { /* Generic hardware. */ TV_INPUT_TYPE_OTHER_HARDWARE = 1, /* Tuner. (e.g. built-in terrestrial tuner) */ TV_INPUT_TYPE_TUNER = 2, TV_INPUT_TYPE_COMPOSITE = 3, TV_INPUT_TYPE_SVIDEO = 4, TV_INPUT_TYPE_SCART = 5, TV_INPUT_TYPE_COMPONENT = 6, TV_INPUT_TYPE_VGA = 7, TV_INPUT_TYPE_DVI = 8, /* Physical HDMI port. (e.g. HDMI 1) */ TV_INPUT_TYPE_HDMI = 9, TV_INPUT_TYPE_DISPLAY_PORT = 10, }; typedef uint32_t tv_input_type_t; typedef struct tv_input_device_info { /* Device ID */ int device_id; /* Type of physical TV input. */ tv_input_type_t type; union { struct { /* HDMI port ID number */ uint32_t port_id; } hdmi; /* TODO: add other type specific information. */ int32_t type_info_reserved[16]; }; /* TODO: Add capability if necessary. */ /* * Audio info * * audio_type == AUDIO_DEVICE_NONE if this input has no audio. */ audio_devices_t audio_type; const char* audio_address; int32_t reserved[16]; } tv_input_device_info_t; /* See tv_input_event_t for more details. */ enum { /* * Hardware notifies the framework that a device is available. * * Note that DEVICE_AVAILABLE and DEVICE_UNAVAILABLE events do not represent * hotplug events (i.e. plugging cable into or out of the physical port). * These events notify the framework whether the port is available or not. * For a concrete example, when a user plugs in or pulls out the HDMI cable * from a HDMI port, it does not generate DEVICE_AVAILABLE and/or * DEVICE_UNAVAILABLE events. However, if a user inserts a pluggable USB * tuner into the Android device, it will generate a DEVICE_AVAILABLE event * and when the port is removed, it should generate a DEVICE_UNAVAILABLE * event. * * For hotplug events, please see STREAM_CONFIGURATION_CHANGED for more * details. * * HAL implementation should register devices by using this event when the * device boots up. The framework will recognize device reported via this * event only. In addition, the implementation could use this event to * notify the framework that a removable TV input device (such as USB tuner * as stated in the example above) is attached. */ TV_INPUT_EVENT_DEVICE_AVAILABLE = 1, /* * Hardware notifies the framework that a device is unavailable. * * HAL implementation should generate this event when a device registered * by TV_INPUT_EVENT_DEVICE_AVAILABLE is no longer available. For example, * the event can indicate that a USB tuner is plugged out from the Android * device. * * Note that this event is not for indicating cable plugged out of the port; * for that purpose, the implementation should use * STREAM_CONFIGURATION_CHANGED event. This event represents the port itself * being no longer available. */ TV_INPUT_EVENT_DEVICE_UNAVAILABLE = 2, /* * Stream configurations are changed. Client should regard all open streams * at the specific device are closed, and should call * get_stream_configurations() again, opening some of them if necessary. * * HAL implementation should generate this event when the available stream * configurations change for any reason. A typical use case of this event * would be to notify the framework that the input signal has changed * resolution, or that the cable is plugged out so that the number of * available streams is 0. * * The implementation may use this event to indicate hotplug status of the * port. the framework regards input devices with no available streams as * disconnected, so the implementation can generate this event with no * available streams to indicate that this device is disconnected, and vice * versa. */ TV_INPUT_EVENT_STREAM_CONFIGURATIONS_CHANGED = 3, /* * Hardware is done with capture request with the buffer. Client can assume * ownership of the buffer again. * * HAL implementation should generate this event after request_capture() if * it succeeded. The event shall have the buffer with the captured image. */ TV_INPUT_EVENT_CAPTURE_SUCCEEDED = 4, /* * Hardware met a failure while processing a capture request or client * canceled the request. Client can assume ownership of the buffer again. * * The event is similar to TV_INPUT_EVENT_CAPTURE_SUCCEEDED, but HAL * implementation generates this event upon a failure to process * request_capture(), or a request cancellation. */ TV_INPUT_EVENT_CAPTURE_FAILED = 5, }; typedef uint32_t tv_input_event_type_t; typedef struct tv_input_capture_result { /* Device ID */ int device_id; /* Stream ID */ int stream_id; /* Sequence number of the request */ uint32_t seq; /* * The buffer passed to hardware in request_capture(). The content of * buffer is undefined (although buffer itself is valid) for * TV_INPUT_CAPTURE_FAILED event. */ buffer_handle_t buffer; /* * Error code for the request. -ECANCELED if request is cancelled; other * error codes are unknown errors. */ int error_code; } tv_input_capture_result_t; typedef struct tv_input_event { tv_input_event_type_t type; union { /* * TV_INPUT_EVENT_DEVICE_AVAILABLE: all fields are relevant * TV_INPUT_EVENT_DEVICE_UNAVAILABLE: only device_id is relevant * TV_INPUT_EVENT_STREAM_CONFIGURATIONS_CHANGED: only device_id is * relevant */ tv_input_device_info_t device_info; /* * TV_INPUT_EVENT_CAPTURE_SUCCEEDED: error_code is not relevant * TV_INPUT_EVENT_CAPTURE_FAILED: all fields are relevant */ tv_input_capture_result_t capture_result; }; } tv_input_event_t; typedef struct tv_input_callback_ops { /* * event contains the type of the event and additional data if necessary. * The event object is guaranteed to be valid only for the duration of the * call. * * data is an object supplied at device initialization, opaque to the * hardware.     */ void (*notify)(struct tv_input_device* dev, tv_input_event_t* event, void* data); } tv_input_callback_ops_t; enum { TV_STREAM_TYPE_INDEPENDENT_VIDEO_SOURCE = 1, TV_STREAM_TYPE_BUFFER_PRODUCER = 2, }; typedef uint32_t tv_stream_type_t; typedef struct tv_stream_config { /* * ID number of the stream. This value is used to identify the whole stream * configuration. */ int stream_id; /* Type of the stream */ tv_stream_type_t type; /* Max width/height of the stream. */ uint32_t max_video_width; uint32_t max_video_height; } tv_stream_config_t; typedef struct buffer_producer_stream { /* * IN/OUT: Width / height of the stream. Client may request for specific * size but hardware may change it. Client must allocate buffers with * specified width and height. */ uint32_t width; uint32_t height; /* OUT: Client must set this usage when allocating buffer. */ uint32_t usage; /* OUT: Client must allocate a buffer with this format. */ uint32_t format; } buffer_producer_stream_t; typedef struct tv_stream { /* IN: ID in the stream configuration */ int stream_id; /* OUT: Type of the stream (for convenience) */ tv_stream_type_t type; /* Data associated with the stream for client's use */ union { /* OUT: A native handle describing the sideband stream source */ native_handle_t* sideband_stream_source_handle; /* IN/OUT: Details are in buffer_producer_stream_t */ buffer_producer_stream_t buffer_producer; }; } tv_stream_t; /* * Every device data structure must begin with hw_device_t * followed by module specific public methods and attributes. */ typedef struct tv_input_device { struct hw_device_t common; /* * initialize: * * Provide callbacks to the device and start operation. At first, no device * is available and after initialize() completes, currently available * devices including static devices should notify via callback. * * Framework owns callbacks object. * * data is a framework-owned object which would be sent back to the * framework for each callback notifications. * * Return 0 on success. */ int (*initialize)(struct tv_input_device* dev, const tv_input_callback_ops_t* callback, void* data); /* * get_stream_configurations: * * Get stream configurations for a specific device. An input device may have * multiple configurations. * * The configs object is guaranteed to be valid only until the next call to * get_stream_configurations() or STREAM_CONFIGURATIONS_CHANGED event. * * Return 0 on success. */ int (*get_stream_configurations)(const struct tv_input_device* dev, int device_id, int* num_configurations, const tv_stream_config_t** configs); /* * open_stream: * * Open a stream with given stream ID. Caller owns stream object, and the * populated data is only valid until the stream is closed. * * Return 0 on success; -EBUSY if the client should close other streams to * open the stream; -EEXIST if the stream with the given ID is already open; * -EINVAL if device_id and/or stream_id are invalid; other non-zero value * denotes unknown error. */ int (*open_stream)(struct tv_input_device* dev, int device_id, tv_stream_t* stream); /* * close_stream: * * Close a stream to a device. data in tv_stream_t* object associated with * the stream_id is obsolete once this call finishes. * * Return 0 on success; -ENOENT if the stream is not open; -EINVAL if * device_id and/or stream_id are invalid. */ int (*close_stream)(struct tv_input_device* dev, int device_id, int stream_id); /* * request_capture: * * Request buffer capture for a stream. This is only valid for buffer * producer streams. The buffer should be created with size, format and * usage specified in the stream. Framework provides seq in an * increasing sequence per each stream. Hardware should provide the picture * in a chronological order according to seq. For example, if two * requests are being processed at the same time, the request with the * smaller seq should get an earlier frame. * * The framework releases the ownership of the buffer upon calling this * function. When the buffer is filled, hardware notifies the framework * via TV_INPUT_EVENT_CAPTURE_FINISHED callback, and the ownership is * transferred back to framework at that time. * * Return 0 on success; -ENOENT if the stream is not open; -EINVAL if * device_id and/or stream_id are invalid; -EWOULDBLOCK if HAL cannot take * additional requests until it releases a buffer. */ int (*request_capture)(struct tv_input_device* dev, int device_id, int stream_id, buffer_handle_t buffer, uint32_t seq); /* * cancel_capture: * * Cancel an ongoing capture. Hardware should release the buffer as soon as * possible via TV_INPUT_EVENT_CAPTURE_FAILED callback. * * Return 0 on success; -ENOENT if the stream is not open; -EINVAL if * device_id, stream_id, and/or seq are invalid. */ int (*cancel_capture)(struct tv_input_device* dev, int device_id, int stream_id, uint32_t seq); void* reserved[16]; } tv_input_device_t; __END_DECLS #endif // ANDROID_TV_INPUT_INTERFACE_H android-headers-23/23/hardware/vibrator.h000066400000000000000000000043751264465411000203670ustar00rootroot00000000000000/* * 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 _HARDWARE_VIBRATOR_H #define _HARDWARE_VIBRATOR_H #include __BEGIN_DECLS #define VIBRATOR_API_VERSION HARDWARE_MODULE_API_VERSION(1,0) /** * The id of this module */ #define VIBRATOR_HARDWARE_MODULE_ID "vibrator" /** * The id of the main vibrator device */ #define VIBRATOR_DEVICE_ID_MAIN "main_vibrator" struct vibrator_device; typedef struct vibrator_device { /** * Common methods of the vibrator device. This *must* be the first member of * vibrator_device as users of this structure will cast a hw_device_t to * vibrator_device pointer in contexts where it's known the hw_device_t references a * vibrator_device. */ struct hw_device_t common; /** Turn on vibrator * * What happens when this function is called while the the timeout of a * previous call has not expired is implementation dependent. * * @param timeout_ms number of milliseconds to vibrate * * @return 0 in case of success, negative errno code else */ int (*vibrator_on)(struct vibrator_device* vibradev, unsigned int timeout_ms); /** Turn off vibrator * * It is not guaranteed that the vibrator will be immediately stopped: the * behaviour is implementation dependent. * * @return 0 in case of success, negative errno code else */ int (*vibrator_off)(struct vibrator_device* vibradev); } vibrator_device_t; 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); } __END_DECLS #endif // _HARDWARE_VIBRATOR_H android-headers-23/23/hardware_legacy/000077500000000000000000000000001264465411000177015ustar00rootroot00000000000000android-headers-23/23/hardware_legacy/audio_policy_conf.h000066400000000000000000000037061264465411000235450ustar00rootroot00000000000000/* * 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_AUDIO_POLICY_CONF_H #define ANDROID_AUDIO_POLICY_CONF_H ///////////////////////////////////////////////// // Definitions for audio policy configuration file (audio_policy.conf) ///////////////////////////////////////////////// #define AUDIO_HARDWARE_MODULE_ID_MAX_LEN 32 #define AUDIO_POLICY_CONFIG_FILE "/system/etc/audio_policy.conf" #define AUDIO_POLICY_VENDOR_CONFIG_FILE "/vendor/etc/audio_policy.conf" // global configuration #define GLOBAL_CONFIG_TAG "global_configuration" #define ATTACHED_OUTPUT_DEVICES_TAG "attached_output_devices" #define DEFAULT_OUTPUT_DEVICE_TAG "default_output_device" #define ATTACHED_INPUT_DEVICES_TAG "attached_input_devices" #define SPEAKER_DRC_ENABLED_TAG "speaker_drc_enabled" // hw modules descriptions #define AUDIO_HW_MODULE_TAG "audio_hw_modules" #define OUTPUTS_TAG "outputs" #define INPUTS_TAG "inputs" #define SAMPLING_RATES_TAG "sampling_rates" #define FORMATS_TAG "formats" #define CHANNELS_TAG "channel_masks" #define DEVICES_TAG "devices" #define FLAGS_TAG "flags" #define DYNAMIC_VALUE_TAG "dynamic" // special value for "channel_masks", "sampling_rates" and // "formats" in outputs descriptors indicating that supported // values should be queried after opening the output. #endif // ANDROID_AUDIO_POLICY_CONF_H android-headers-23/23/hardware_legacy/vibrator.h000066400000000000000000000022321264465411000217010ustar00rootroot00000000000000/* * 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 android-headers-23/23/hardware_legacy/wifi.h000066400000000000000000000077521264465411000210230ustar00rootroot00000000000000/* * 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 _WIFI_H #define _WIFI_H #if __cplusplus extern "C" { #endif /** * Load the Wi-Fi driver. * * @return 0 on success, < 0 on failure. */ int wifi_load_driver(); /** * Unload the Wi-Fi driver. * * @return 0 on success, < 0 on failure. */ int wifi_unload_driver(); /** * Check if the Wi-Fi driver is loaded. * Check if the Wi-Fi driver is loaded. * @return 0 on success, < 0 on failure. */ 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 const char *wifi_get_fw_path(int fw_type); /** * Change the path to firmware for the wlan driver */ int wifi_change_fw_path(const char *fwpath); /** * Check and create if necessary initial entropy file */ #define WIFI_ENTROPY_FILE "/data/misc/wifi/entropy.bin" int ensure_entropy_file_exists(); #if __cplusplus }; // extern "C" #endif #endif // _WIFI_H android-headers-23/23/libnfc-nxp/000077500000000000000000000000001264465411000166205ustar00rootroot00000000000000android-headers-23/23/libnfc-nxp/nfc_custom_config_example.h000066400000000000000000000124361264465411000241770ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/nfc_osal_deferred_call.h000066400000000000000000000021511264465411000234070ustar00rootroot00000000000000#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); #endifandroid-headers-23/23/libnfc-nxp/phDal4Nfc.h000066400000000000000000000630601264465411000205410ustar00rootroot00000000000000/* * 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 android-headers-23/23/libnfc-nxp/phDal4Nfc_messageQueueLib.h000066400000000000000000000026601264465411000237000ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phDbgTrace.h000066400000000000000000000133441264465411000210010ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phDnldNfc.h000066400000000000000000000114311264465411000206310ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phFriNfc.h000066400000000000000000000133601264465411000204730ustar00rootroot00000000000000/* * 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__ */ android-headers-23/23/libnfc-nxp/phFriNfc_DesfireFormat.h000066400000000000000000000253751264465411000233160ustar00rootroot00000000000000/* * 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 android-headers-23/23/libnfc-nxp/phFriNfc_DesfireMap.h000066400000000000000000000344271264465411000226010ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phFriNfc_FelicaMap.h000066400000000000000000000340361264465411000223770ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phFriNfc_ISO15693Format.h000066400000000000000000000111301264465411000227570ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phFriNfc_ISO15693Map.h000066400000000000000000000243771264465411000222650ustar00rootroot00000000000000/* * * 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 */ android-headers-23/23/libnfc-nxp/phFriNfc_IntNdefMap.h000066400000000000000000000072241264465411000225420ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phFriNfc_Llcp.h000066400000000000000000000367111264465411000214520ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phFriNfc_LlcpMac.h000066400000000000000000000210611264465411000220630ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phFriNfc_LlcpMacNfcip.h000066400000000000000000000022321264465411000230420ustar00rootroot00000000000000/* * 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_LlcpMacNfcip.h * \brief NFC LLCP MAC Mapping for NFCIP. * * Project: NFC-FRI * */ #ifndef PHFRINFC_LLCPMACNFCIP_H #define PHFRINFC_LLCPMACNFCIP_H /*include files*/ #include #include #include #include /** * \name MAC Mapping for NFCIP * * File: \ref phFriNfc_LlcpMacNfcip.h * */ /** \defgroup grp_fri_nfc_llcp_macnfcip NFCIP MAC Mapping * * TODO * */ NFCSTATUS phFriNfc_LlcpMac_Nfcip_Register (phFriNfc_LlcpMac_t *LlcpMac); #endif /* PHFRINFC_LLCPMACNFCIP_H */ android-headers-23/23/libnfc-nxp/phFriNfc_LlcpTransport.h000066400000000000000000001155541264465411000233720ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phFriNfc_LlcpTransport_Connection.h000066400000000000000000000415061264465411000255440ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phFriNfc_LlcpTransport_Connectionless.h000066400000000000000000000136471264465411000264400ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phFriNfc_LlcpUtils.h000066400000000000000000000114131264465411000224630ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phFriNfc_MapTools.h000066400000000000000000000061721264465411000223140ustar00rootroot00000000000000/* * 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 android-headers-23/23/libnfc-nxp/phFriNfc_MifStdFormat.h000066400000000000000000000452731264465411000231220ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phFriNfc_MifULFormat.h000066400000000000000000000167131264465411000227050ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phFriNfc_MifareStdMap.h000066400000000000000000000563431264465411000230770ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phFriNfc_MifareULMap.h000066400000000000000000000373411264465411000226620ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phFriNfc_NdefMap.h000066400000000000000000001525511264465411000220730ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phFriNfc_NdefRecord.h000066400000000000000000000665561264465411000226050ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phFriNfc_NdefReg.h000066400000000000000000000543301264465411000220670ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phFriNfc_OvrHal.h000066400000000000000000000373351264465411000217560ustar00rootroot00000000000000/* * 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 android-headers-23/23/libnfc-nxp/phFriNfc_OvrHalCmd.h000066400000000000000000000256351264465411000224020ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phFriNfc_SmtCrdFmt.h000066400000000000000000000446671264465411000224340ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phFriNfc_TopazMap.h000066400000000000000000000754451264465411000223220ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phHal4Nfc.h000066400000000000000000001414511264465411000205460ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phHal4Nfc_Internal.h000066400000000000000000000307131264465411000224000ustar00rootroot00000000000000/* * 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 android-headers-23/23/libnfc-nxp/phHciNfc_AdminMgmt.h000066400000000000000000000167221264465411000224200ustar00rootroot00000000000000/* * 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 android-headers-23/23/libnfc-nxp/phHciNfc_CE_A.h000066400000000000000000000255241264465411000212720ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phHciNfc_CE_B.h000066400000000000000000000252721264465411000212730ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phHciNfc_DevMgmt.h000066400000000000000000000272201264465411000221010ustar00rootroot00000000000000/* * 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 android-headers-23/23/libnfc-nxp/phHciNfc_Emulation.h000066400000000000000000000132771264465411000225020ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phHciNfc_Felica.h000066400000000000000000000251121264465411000217170ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phHciNfc_Generic.h000066400000000000000000001241051264465411000221120ustar00rootroot00000000000000/* * 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 android-headers-23/23/libnfc-nxp/phHciNfc_IDMgmt.h000066400000000000000000000200761264465411000216610ustar00rootroot00000000000000/* * 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 android-headers-23/23/libnfc-nxp/phHciNfc_ISO15693.h000066400000000000000000000237231264465411000216040ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phHciNfc_Jewel.h000066400000000000000000000231221264465411000216010ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phHciNfc_LinkMgmt.h000066400000000000000000000127131264465411000222610ustar00rootroot00000000000000/* * 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 android-headers-23/23/libnfc-nxp/phHciNfc_NfcIPMgmt.h000066400000000000000000000667011264465411000223310ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phHciNfc_Pipe.h000066400000000000000000000231451264465411000214350ustar00rootroot00000000000000/* * 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 android-headers-23/23/libnfc-nxp/phHciNfc_PollingLoop.h000066400000000000000000000173671264465411000230070ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phHciNfc_RFReader.h000066400000000000000000000545371264465411000222030ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phHciNfc_RFReaderA.h000066400000000000000000000345311264465411000222740ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phHciNfc_RFReaderB.h000066400000000000000000000236401264465411000222740ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phHciNfc_SWP.h000066400000000000000000000301461264465411000212100ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phHciNfc_Sequence.h000066400000000000000000000364271264465411000223170ustar00rootroot00000000000000/* * 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 android-headers-23/23/libnfc-nxp/phHciNfc_WI.h000066400000000000000000000211351264465411000210540ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phLibNfc.h000066400000000000000000004736071264465411000204770ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phLibNfcStatus.h000066400000000000000000000050551264465411000216670ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phLibNfc_Internal.h000066400000000000000000000221571264465411000223210ustar00rootroot00000000000000/* * 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 android-headers-23/23/libnfc-nxp/phLibNfc_SE.h000066400000000000000000000047561264465411000210610ustar00rootroot00000000000000/* * 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 android-headers-23/23/libnfc-nxp/phLibNfc_discovery.h000066400000000000000000000017161264465411000225520ustar00rootroot00000000000000/* * 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 * * 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 ); #endif android-headers-23/23/libnfc-nxp/phLibNfc_initiator.h000066400000000000000000000031531264465411000225420ustar00rootroot00000000000000/* * 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 android-headers-23/23/libnfc-nxp/phLibNfc_ioctl.h000066400000000000000000000050111264465411000216450ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phLibNfc_ndef_raw.h000066400000000000000000000045331264465411000223300ustar00rootroot00000000000000/* * 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 android-headers-23/23/libnfc-nxp/phLlcNfc.h000066400000000000000000000131161264465411000204640ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phLlcNfc_DataTypes.h000066400000000000000000000472721264465411000224540ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phLlcNfc_Frame.h000066400000000000000000000360611264465411000216020ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phLlcNfc_Interface.h000066400000000000000000000142661264465411000224530ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phLlcNfc_Timer.h000066400000000000000000000135271264465411000216320ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phNfcCompId.h000066400000000000000000000145551264465411000211350ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phNfcConfig.h000066400000000000000000000314371264465411000211650ustar00rootroot00000000000000/* * 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*/ android-headers-23/23/libnfc-nxp/phNfcHalTypes.h000066400000000000000000001075141264465411000215110ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phNfcInterface.h000066400000000000000000000332641264465411000216600ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phNfcStatus.h000066400000000000000000000301521264465411000212340ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phNfcTypes.h000066400000000000000000001314201264465411000210550ustar00rootroot00000000000000/* * 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 */ android-headers-23/23/libnfc-nxp/phOsalNfc.h000066400000000000000000000146071264465411000206560ustar00rootroot00000000000000/* * 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, /** #else #ifdef __linux__ #include #else #include #endif #endif #endif /* PHOSALNFC_MSG_H */ android-headers-23/23/libnfc-nxp/phOsalNfc_Timer.h000066400000000000000000000164661264465411000220230ustar00rootroot00000000000000/* * 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_Timer.h * \brief Timer Implementation. * * Project: NFC-FRI 1.1 * * $Date: Mon Mar 16 20:30:44 2009 $ * $Author: ing01697 $ * $Revision: 1.19 $ * $Aliases: 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 PHOSALNFC_TIMER_H #define PHOSALNFC_TIMER_H /* -----------------Include files ---------------------------------------*/ #include #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 */ android-headers-23/23/linux/000077500000000000000000000000001264465411000157175ustar00rootroot00000000000000android-headers-23/23/linux/android_alarm.h000066400000000000000000000054371264465411000206750ustar00rootroot00000000000000/**************************************************************************** **************************************************************************** *** *** 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_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, ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP_MASK = 1U << ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP, /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ ANDROID_ALARM_ELAPSED_REALTIME_MASK = 1U << ANDROID_ALARM_ELAPSED_REALTIME, ANDROID_ALARM_SYSTEMTIME_MASK = 1U << ANDROID_ALARM_SYSTEMTIME, ANDROID_ALARM_TIME_CHANGE_MASK = 1U << 16 }; /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ #define ANDROID_ALARM_CLEAR(type) _IO('a', 0 | ((type) << 4)) #define ANDROID_ALARM_WAIT _IO('a', 1) #define ALARM_IOW(c,type,size) _IOW('a', (c) | ((type) << 4), size) #define ANDROID_ALARM_SET(type) ALARM_IOW(2, type, struct timespec) /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ #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) #define ANDROID_ALARM_SET_RTC _IOW('a', 5, struct timespec) #define ANDROID_ALARM_BASE_CMD(cmd) (cmd & ~(_IOC(0, 0, 0xf0, 0))) /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ #define ANDROID_ALARM_IOCTL_TO_TYPE(cmd) (_IOC_NR(cmd) >> 4) #endif android-headers-23/23/linux/binder.h000066400000000000000000000172471264465411000173460ustar00rootroot00000000000000/**************************************************************************** **************************************************************************** *** *** 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 android-headers-23/23/linux/sw_sync.h000066400000000000000000000030301264465411000175510ustar00rootroot00000000000000/**************************************************************************** **************************************************************************** *** *** 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_SW_SYNC_H #define _UAPI_LINUX_SW_SYNC_H #include struct sw_sync_create_fence_data { /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ __u32 value; char name[32]; __s32 fence; }; /* 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) #endif /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ android-headers-23/23/linux/sync.h000066400000000000000000000041601264465411000170450ustar00rootroot00000000000000/**************************************************************************** **************************************************************************** *** *** 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 */ android-headers-23/23/log/000077500000000000000000000000001264465411000153415ustar00rootroot00000000000000android-headers-23/23/log/event_tag_map.h000066400000000000000000000024171264465411000203270ustar00rootroot00000000000000/* * 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. */ #ifndef _LIBS_CUTILS_EVENTTAGMAP_H #define _LIBS_CUTILS_EVENTTAGMAP_H #ifdef __cplusplus extern "C" { #endif #define EVENT_TAG_MAP_FILE "/system/etc/event-log-tags" struct EventTagMap; typedef struct EventTagMap EventTagMap; /* * Open the specified file as an event log tag map. * * Returns NULL on failure. */ EventTagMap* android_openEventTagMap(const char* fileName); /* * Close the map. */ 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); #ifdef __cplusplus } #endif #endif /*_LIBS_CUTILS_EVENTTAGMAP_H*/ android-headers-23/23/log/log.h000066400000000000000000000423451264465411000163030ustar00rootroot00000000000000/* * Copyright (C) 2005-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. */ // // 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 #include #include #include #include #include #include #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 * 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. */ #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) #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 // --------------------------------------------------------------------- /* * 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) #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__)) #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__)) #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 */ // --------------------------------------------------------------------- /* * 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) #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 ) #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__) //#define ALOG_ASSERT(cond) LOG_FATAL_IF(!(cond), "Assertion failed: " #cond) #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 /* * 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. These must match up with the declarations in * java/android/android/util/EventLog.java. */ typedef enum { EVENT_TYPE_INT = 0, EVENT_TYPE_LONG = 1, 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 /* TODO: something for LIST */ /* * =========================================================================== * * 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. */ #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 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) /* * 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 // TODO: remove these prototypes and their users #define android_writevLog(vec,num) do{}while(0) #define android_write1Log(str,len) do{}while (0) #define android_setMinPriority(tag, prio) do{}while(0) //#define android_logToCallback(func) do{}while(0) #define android_logToFile(tag, file) (0) #define android_logToFd(tag, fd) (0) 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_KERNEL = 5, #endif LOG_ID_MAX } log_id_t; #define sizeof_log_id_t sizeof(typeof_log_id_t) #define typeof_log_id_t unsigned char /* * Use the per-tag properties "log.tag." to generate a runtime * result of non-zero to expose a log. */ int __android_log_is_loggable(int prio, const char *tag, int def); /* * 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 ; #ifdef __cplusplus } #endif #endif /* _LIBS_LOG_LOG_H */ android-headers-23/23/log/log_read.h000066400000000000000000000111101264465411000172600ustar00rootroot00000000000000/* * Copyright (C) 2013-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 _LIBS_LOG_LOG_READ_H #define _LIBS_LOG_LOG_READ_H #include #include /* struct log_time is a wire-format variant of struct timespec */ #define NS_PER_SEC 1000000000ULL #ifdef __cplusplus // 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); } // 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; } // 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; } log_time operator+= (const log_time &T); log_time operator+ (const log_time &T) const { log_time local(*this); return local += T; } uint64_t nsec() const { return static_cast(tv_sec) * NS_PER_SEC + tv_nsec; } 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); } __attribute__((__packed__)); #else typedef struct log_time { uint32_t tv_sec; uint32_t tv_nsec; } __attribute__((__packed__)) log_time; #endif #endif /* define _LIBS_LOG_LOG_READ_H */ android-headers-23/23/log/logd.h000066400000000000000000000025431264465411000164430ustar00rootroot00000000000000/* * 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); #ifdef __cplusplus } #endif #endif /* _LOGD_H */ android-headers-23/23/log/logger.h000066400000000000000000000147161264465411000170020ustar00rootroot00000000000000/* ** ** 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 #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__)); /* * 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 4076 /* * 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_v3 entry; 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_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 /* * 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 */ android-headers-23/23/log/logprint.h000066400000000000000000000077511264465411000173620ustar00rootroot00000000000000/* * Copyright (C) 2006 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 _LOGPRINT_H #define _LOGPRINT_H #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 three 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 */ } AndroidLogPrintFormat; typedef struct AndroidLogFormat_t AndroidLogFormat; typedef struct AndroidLogEntry_t { time_t tv_sec; long tv_nsec; android_LogPriority priority; int32_t pid; int32_t tid; const char * tag; size_t messageLen; const char * message; } AndroidLogEntry; AndroidLogFormat *android_log_format_new(); 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); /** * Returns FORMAT_OFF on invalid string */ AndroidLogPrintFormat android_log_formatFromString(const char *s); /** * filterExpression: a single filter expression * eg "AT:d" * * returns 0 on success and -1 on invalid expression * * Assumes single threaded execution * */ int android_log_addFilterRule(AndroidLogFormat *p_format, const char *filterExpression); /** * filterString: a whitespace-separated set of filter expressions * eg "AT:d *:i" * * returns 0 on success and -1 on invalid expression * * Assumes single threaded execution * */ 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); /** * Splits a wire-format buffer into an AndroidLogEntry * entry allocated by caller. Pointers will point directly into buf * * 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); /** * Like android_log_processLogBuffer, but for binary logs. * * 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); /** * Formats a log message into a buffer * * Uses defaultBuffer if it can, otherwise malloc()'s a new buffer * If return value != defaultBuffer, caller must call free() * 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); /** * Either print or do not print log line, based on filter * * Assumes single threaded execution * */ int android_log_printLogLine( AndroidLogFormat *p_format, int fd, const AndroidLogEntry *entry); #ifdef __cplusplus } #endif #endif /*_LOGPRINT_H*/ android-headers-23/23/log/uio.h000066400000000000000000000021211264465411000163020ustar00rootroot00000000000000/* * Copyright (C) 2007-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 _LIBS_CUTILS_UIO_H #define _LIBS_CUTILS_UIO_H #if !defined(_WIN32) #include #else #ifdef __cplusplus extern "C" { #endif // // Implementation of sys/uio.h for Win32. // #include struct iovec { 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 ); #ifdef __cplusplus } #endif #endif #endif /* _LIBS_UTILS_UIO_H */ android-headers-23/23/private/000077500000000000000000000000001264465411000162325ustar00rootroot00000000000000android-headers-23/23/private/android_filesystem_config.h000066400000000000000000000204301264465411000236130ustar00rootroot00000000000000/* * 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 used to define the properties of the filesystem ** images generated by build tools (mkbootfs and mkyaffs2image) and ** by the device side of adb. */ #ifndef _ANDROID_FILESYSTEM_CONFIG_H_ #define _ANDROID_FILESYSTEM_CONFIG_H_ #include #include #include #ifdef HAVE_ANDROID_OS #include #else #include "android_filesystem_capability.h" #endif /* 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_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_NET_BT_STACK 3008 /* bluetooth: access config files */ #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 /* first app user */ #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 /* offset for uid ranges for each user */ #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 */ #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 */ struct android_id_info { const char *name; unsigned aid; }; static const struct android_id_info android_ids[] = { { "root", AID_ROOT, }, { "system", AID_SYSTEM, }, { "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, }, { "shell", AID_SHELL, }, { "cache", AID_CACHE, }, { "diag", AID_DIAG, }, { "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, }, { "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 */ __BEGIN_DECLS /* * 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 */ 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 android-headers-23/23/sync/000077500000000000000000000000001264465411000155345ustar00rootroot00000000000000android-headers-23/23/sync/sync.h000066400000000000000000000026551264465411000166710ustar00rootroot00000000000000/* * sync.h * * Copyright 2012 Google, Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __SYS_CORE_SYNC_H #define __SYS_CORE_SYNC_H #include #include __BEGIN_DECLS // XXX: These structs are copied from the header "linux/sync.h". struct sync_fence_info_data { uint32_t len; char name[32]; int32_t status; uint8_t pt_info[0]; }; struct sync_pt_info { uint32_t len; char obj_name[32]; char driver_name[32]; int32_t status; uint64_t timestamp_ns; uint8_t driver_data[0]; }; /* 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); void sync_fence_info_free(struct sync_fence_info_data *info); __END_DECLS #endif /* __SYS_CORE_SYNC_H */ android-headers-23/23/system/000077500000000000000000000000001264465411000161045ustar00rootroot00000000000000android-headers-23/23/system/audio.h000066400000000000000000001714671264465411000173760ustar00rootroot00000000000000/* * 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_AUDIO_CORE_H #define ANDROID_AUDIO_CORE_H #include #include #include #include #include #include __BEGIN_DECLS /* The enums were moved here mostly from * frameworks/base/include/media/AudioSystem.h */ /* 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_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; /* Do not change these values without updating their counterparts * in frameworks/base/media/java/android/media/AudioAttributes.java */ enum { AUDIO_FLAG_AUDIBILITY_ENFORCED = 0x1, AUDIO_FLAG_SECURE = 0x2, AUDIO_FLAG_SCO = 0x4, AUDIO_FLAG_BEACON = 0x8, AUDIO_FLAG_HW_AV_SYNC = 0x10, AUDIO_FLAG_HW_HOTWORD = 0x20, AUDIO_FLAG_BYPASS_INTERRUPTION_POLICY = 0x40, AUDIO_FLAG_BYPASS_MUTE = 0x80, }; /* 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_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 { audio_content_type_t content_type; audio_usage_t usage; audio_source_t source; audio_flags_mask_t flags; char tags[AUDIO_ATTRIBUTES_TAGS_MAX_SIZE]; /* UTF8 */ } audio_attributes_t; /* special audio session values * (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. */ AUDIO_SESSION_ALLOCATE = 0, } audio_session_t; /* a unique ID allocated by AudioFlinger for use as a audio_io_handle_t or audio_session_t */ typedef int audio_unique_id_t; #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 consists of a main format field (upper 8 bits) and a 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, AUDIO_FORMAT_MAIN_MASK = 0xFF000000UL, 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_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_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_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), // 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_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. * * audio_channel_mask_t is an opaque type and its internal layout should not * be assumed as it may change in the future. * Instead, always use the functions declared in this header to examine. * * These are the current representations: * * AUDIO_CHANNEL_REPRESENTATION_POSITION * is a channel mask representation for position assignment. * Each low-order bit corresponds to the spatial position of a transducer (output), * or interpretation of channel (input). * The user of a channel mask needs to know the context of whether it is for output or input. * The constants AUDIO_CHANNEL_OUT_* or AUDIO_CHANNEL_IN_* apply to the bits portion. * It is not permitted for no bits to be set. * * AUDIO_CHANNEL_REPRESENTATION_INDEX * is a channel mask representation for index assignment. * Each low-order bit corresponds to a selected channel. * There is no platform interpretation of the various bits. * There is no concept of output or input. * It is not permitted for no bits to be set. * * All other representations are reserved for future use. * * Warning: current representation distinguishes between input and output, but this will not the be * case in future revisions of the platform. Wherever there is an ambiguity between input and output * that is currently resolved by checking the channel mask, the implementer should look for ways to * fix it with additional information outside of the mask. */ 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); } /* 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) { // The right shift should be sufficient, but also "and" for safety in case mask is not 32 bits return (audio_channel_representation_t) ((channel >> AUDIO_CHANNEL_COUNT_MAX) & ((1 << AUDIO_CHANNEL_REPRESENTATION_LOG2) - 1)); } /* Returns true if the channel mask is valid, * or returns false for AUDIO_CHANNEL_NONE, AUDIO_CHANNEL_INVALID, and other invalid values. * This function is unable to determine whether a channel mask for position assignment * is invalid because an output mask has an invalid output bit set, * or because an input mask has an invalid input bit set. * All other APIs that take a channel mask assume that it is valid. */ static inline bool audio_channel_mask_is_valid(audio_channel_mask_t channel) { uint32_t bits = audio_channel_mask_get_bits(channel); audio_channel_representation_t representation = audio_channel_mask_get_representation(channel); switch (representation) { case AUDIO_CHANNEL_REPRESENTATION_POSITION: case AUDIO_CHANNEL_REPRESENTATION_INDEX: break; default: bits = 0; break; } return bits != 0; } /* Not part of public API */ static inline audio_channel_mask_t audio_channel_mask_from_representation_and_bits( audio_channel_representation_t representation, uint32_t bits) { return (audio_channel_mask_t) ((representation << AUDIO_CHANNEL_COUNT_MAX) | bits); } /* 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. */ enum { 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, AUDIO_IN_ACOUSTICS_AGC_ENABLE = 0x0001, AUDIO_IN_ACOUSTICS_AGC_DISABLE = 0, AUDIO_IN_ACOUSTICS_NS_ENABLE = 0x0002, AUDIO_IN_ACOUSTICS_NS_DISABLE = 0, AUDIO_IN_ACOUSTICS_TX_IIR_ENABLE = 0x0004, 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_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_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_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_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. */ 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_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. */ 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; /* 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. */ typedef struct { uint16_t version; // version of the info structure uint16_t size; // total size of the structure including version and size uint32_t sample_rate; // sample rate in Hz audio_channel_mask_t channel_mask; // channel mask audio_format_t format; // audio format audio_stream_type_t stream_type; // stream type uint32_t bit_rate; // bit rate in bits per second int64_t duration_us; // duration in microseconds, -1 if unknown bool has_video; // true if stream is tied to a video stream bool is_streaming; // true if streaming, false if local playback } audio_offload_info_t; #define AUDIO_MAKE_OFFLOAD_INFO_VERSION(maj,min) \ ((((maj) & 0xff) << 8) | ((min) & 0xff)) #define AUDIO_OFFLOAD_INFO_VERSION_0_1 AUDIO_MAKE_OFFLOAD_INFO_VERSION(0, 1) #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 }; /* common audio stream configuration parameters * You should memset() the entire structure to zero before use to * ensure forward compatibility */ struct 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; }; 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 }, frame_count: 0, }; /* audio hw module handle functions or structures referencing a module */ typedef int audio_module_handle_t; /****************************** * Volume control *****************************/ /* 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; /* An audio_gain struct is a representation of a gain stage. * A gain stage is always attached to an audio port. */ struct audio_gain { audio_gain_mode_t mode; /* e.g. AUDIO_GAIN_MODE_JOINT */ audio_channel_mask_t channel_mask; /* channels which gain an be controlled. N/A if AUDIO_GAIN_MODE_CHANNELS is not supported */ int min_value; /* minimum gain value in millibels */ int max_value; /* maximum gain value in millibels */ int default_value; /* default gain value in millibels */ unsigned int step_value; /* gain step in millibels */ unsigned int min_ramp_ms; /* minimum ramp duration in ms */ unsigned int max_ramp_ms; /* maximum ramp duration in ms */ }; /* The gain configuration structure is used to get or set the gain values of a * given port */ struct audio_gain_config { int index; /* index of the corresponding audio_gain in the audio_port gains[] table */ audio_gain_mode_t mode; /* mode requested for this command */ audio_channel_mask_t channel_mask; /* channels which gain value follows. N/A in joint mode */ // note this "8" is not FCC_8, so it won't need to be changed for > 8 channels int values[sizeof(audio_channel_mask_t) * 8]; /* gain values in millibels for each channel ordered from LSb to MSb in channel mask. The number of values is 1 in joint mode or popcount(channel_mask) */ unsigned int ramp_duration_ms; /* ramp duration in ms */ }; /****************************** * Routing control *****************************/ /* Types defined here are used to describe an audio source or sink at internal * framework interfaces (audio policy, patch panel) or at the audio HAL. * Sink and sources are grouped in a concept of “audio port†representing an * 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 /* maximum audio device address length */ #define AUDIO_DEVICE_MAX_ADDRESS_LEN 32 /* extension for audio port configuration structure when the audio port is a * hardware device */ struct audio_port_config_device_ext { audio_module_handle_t hw_module; /* module the device is attached to */ audio_devices_t type; /* device type (e.g AUDIO_DEVICE_OUT_SPEAKER) */ char address[AUDIO_DEVICE_MAX_ADDRESS_LEN]; /* device address. "" if N/A */ }; /* extension for audio port configuration structure when the audio port is a * sub mix */ struct audio_port_config_mix_ext { audio_module_handle_t hw_module; /* module the stream is attached to */ audio_io_handle_t handle; /* I/O handle of the input/output stream */ union { //TODO: change use case for output streams: use strategy and mixer attributes audio_stream_type_t stream; audio_source_t source; } usecase; }; /* extension for audio port configuration structure when the audio port is an * audio session */ 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 { audio_port_handle_t id; /* port unique ID */ audio_port_role_t role; /* sink or source */ audio_port_type_t type; /* device, mix ... */ unsigned int config_mask; /* e.g AUDIO_PORT_CONFIG_ALL */ unsigned int sample_rate; /* sampling rate in Hz */ audio_channel_mask_t channel_mask; /* channel mask if applicable */ audio_format_t format; /* format if applicable */ struct audio_gain_config gain; /* gain to apply if applicable */ union { struct audio_port_config_device_ext device; /* device specific info */ struct audio_port_config_mix_ext mix; /* mix specific info */ struct audio_port_config_session_ext session; /* session specific info */ } ext; }; /* max number of sampling rates in audio port */ #define AUDIO_PORT_MAX_SAMPLING_RATES 16 /* max number of channel masks in audio port */ #define AUDIO_PORT_MAX_CHANNEL_MASKS 16 /* max number of audio formats in audio port */ #define AUDIO_PORT_MAX_FORMATS 16 /* max number of gain controls in audio port */ #define AUDIO_PORT_MAX_GAINS 16 /* extension for audio port structure when the audio port is a hardware device */ struct audio_port_device_ext { audio_module_handle_t hw_module; /* module the device is attached to */ audio_devices_t type; /* device type (e.g AUDIO_DEVICE_OUT_SPEAKER) */ 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 */ audio_io_handle_t handle; /* I/O handle of the input.output stream */ audio_mix_latency_class_t latency_class; /* latency class */ // other attributes: routing strategies }; /* extension for audio port structure when the audio port is an audio session */ struct audio_port_session_ext { audio_session_t session; /* audio session */ }; struct audio_port { audio_port_handle_t id; /* port unique ID */ audio_port_role_t role; /* sink or source */ audio_port_type_t type; /* device, mix ... */ char name[AUDIO_PORT_MAX_NAME_LEN]; unsigned int num_sample_rates; /* number of sampling rates in following array */ unsigned int sample_rates[AUDIO_PORT_MAX_SAMPLING_RATES]; unsigned int num_channel_masks; /* number of channel masks in following array */ audio_channel_mask_t channel_masks[AUDIO_PORT_MAX_CHANNEL_MASKS]; unsigned int num_formats; /* number of formats in following array */ audio_format_t formats[AUDIO_PORT_MAX_FORMATS]; unsigned int num_gains; /* number of gains in following array */ struct audio_gain gains[AUDIO_PORT_MAX_GAINS]; struct audio_port_config active_config; /* current audio port configuration */ union { struct audio_port_device_ext device; struct audio_port_mix_ext mix; struct audio_port_session_ext session; } ext; }; /* An audio patch represents a connection between one or more source ports and * one or more sink ports. Patches are connected and disconnected by audio policy manager or by * applications via framework APIs. * Each patch is identified by a handle at the interface used to create that patch. For instance, * when a patch is created by the audio HAL, the HAL allocates and returns a handle. * This handle is unique to a given audio HAL hardware module. * 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 int audio_patch_handle_t; #define AUDIO_PATCH_HANDLE_NONE 0 #define AUDIO_PATCH_PORTS_MAX 16 struct audio_patch { audio_patch_handle_t id; /* patch unique ID */ unsigned int num_sources; /* number of sources in following array */ struct audio_port_config sources[AUDIO_PATCH_PORTS_MAX]; unsigned int num_sinks; /* number of sinks in following array */ struct audio_port_config sinks[AUDIO_PATCH_PORTS_MAX]; }; /* a HW synchronization source returned by the audio HAL */ typedef uint32_t audio_hw_sync_t; /* an invalid HW synchronization source indicating an error */ #define AUDIO_HW_SYNC_INVALID 0 static inline bool audio_is_output_device(audio_devices_t device) { if (((device & AUDIO_DEVICE_BIT_IN) == 0) && (popcount(device) == 1) && ((device & ~AUDIO_DEVICE_OUT_ALL) == 0)) return true; else return false; } static inline bool audio_is_input_device(audio_devices_t device) { if ((device & AUDIO_DEVICE_BIT_IN) != 0) { device &= ~AUDIO_DEVICE_BIT_IN; if ((popcount(device) == 1) && ((device & ~AUDIO_DEVICE_IN_ALL) == 0)) return true; } return false; } static inline bool audio_is_output_devices(audio_devices_t device) { return (device & AUDIO_DEVICE_BIT_IN) == 0; } static inline bool audio_is_a2dp_in_device(audio_devices_t device) { if ((device & AUDIO_DEVICE_BIT_IN) != 0) { device &= ~AUDIO_DEVICE_BIT_IN; if ((popcount(device) == 1) && (device & AUDIO_DEVICE_IN_BLUETOOTH_A2DP)) return true; } return false; } static inline bool audio_is_a2dp_out_device(audio_devices_t device) { if ((popcount(device) == 1) && (device & AUDIO_DEVICE_OUT_ALL_A2DP)) return true; else return false; } // Deprecated - use audio_is_a2dp_out_device() instead static inline bool audio_is_a2dp_device(audio_devices_t device) { return audio_is_a2dp_out_device(device); } static inline bool audio_is_bluetooth_sco_device(audio_devices_t device) { if ((device & AUDIO_DEVICE_BIT_IN) == 0) { if ((popcount(device) == 1) && ((device & ~AUDIO_DEVICE_OUT_ALL_SCO) == 0)) return true; } else { device &= ~AUDIO_DEVICE_BIT_IN; if ((popcount(device) == 1) && ((device & ~AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET) == 0)) return true; } return false; } static inline bool audio_is_usb_out_device(audio_devices_t device) { return ((popcount(device) == 1) && (device & AUDIO_DEVICE_OUT_ALL_USB)); } static inline bool audio_is_usb_in_device(audio_devices_t device) { if ((device & AUDIO_DEVICE_BIT_IN) != 0) { device &= ~AUDIO_DEVICE_BIT_IN; if (popcount(device) == 1 && (device & AUDIO_DEVICE_IN_ALL_USB) != 0) return true; } return false; } /* OBSOLETE - use audio_is_usb_out_device() instead. */ static inline bool audio_is_usb_device(audio_devices_t device) { return audio_is_usb_out_device(device); } static inline bool audio_is_remote_submix_device(audio_devices_t device) { if ((audio_is_output_devices(device) && (device & AUDIO_DEVICE_OUT_REMOTE_SUBMIX) == AUDIO_DEVICE_OUT_REMOTE_SUBMIX) || (!audio_is_output_devices(device) && (device & AUDIO_DEVICE_IN_REMOTE_SUBMIX) == AUDIO_DEVICE_IN_REMOTE_SUBMIX)) return true; else return false; } /* Returns true if: * representation is valid, and * there is at least one channel bit set which _could_ correspond to an input channel, and * there are no channel bits set which could _not_ correspond to an input channel. * Otherwise returns false. */ static inline bool audio_is_input_channel(audio_channel_mask_t channel) { uint32_t bits = audio_channel_mask_get_bits(channel); switch (audio_channel_mask_get_representation(channel)) { case AUDIO_CHANNEL_REPRESENTATION_POSITION: if (bits & ~AUDIO_CHANNEL_IN_ALL) { bits = 0; } // fall through case AUDIO_CHANNEL_REPRESENTATION_INDEX: return bits != 0; default: return false; } } /* Returns true if: * representation is valid, and * there is at least one channel bit set which _could_ correspond to an output channel, and * there are no channel bits set which could _not_ correspond to an output channel. * Otherwise returns false. */ static inline bool audio_is_output_channel(audio_channel_mask_t channel) { uint32_t bits = audio_channel_mask_get_bits(channel); switch (audio_channel_mask_get_representation(channel)) { case AUDIO_CHANNEL_REPRESENTATION_POSITION: if (bits & ~AUDIO_CHANNEL_OUT_ALL) { bits = 0; } // fall through case AUDIO_CHANNEL_REPRESENTATION_INDEX: return bits != 0; default: return false; } } /* Returns the number of channels from an input channel mask, * used in the context of audio input or recording. * If a channel bit is set which could _not_ correspond to an input channel, * it is excluded from the count. * Returns zero if the representation is invalid. */ static inline uint32_t audio_channel_count_from_in_mask(audio_channel_mask_t channel) { uint32_t bits = audio_channel_mask_get_bits(channel); switch (audio_channel_mask_get_representation(channel)) { case AUDIO_CHANNEL_REPRESENTATION_POSITION: // TODO: We can now merge with from_out_mask and remove anding bits &= AUDIO_CHANNEL_IN_ALL; // fall through case AUDIO_CHANNEL_REPRESENTATION_INDEX: return popcount(bits); default: return 0; } } /* Returns the number of channels from an output channel mask, * used in the context of audio output or playback. * If a channel bit is set which could _not_ correspond to an output channel, * it is excluded from the count. * Returns zero if the representation is invalid. */ static inline uint32_t audio_channel_count_from_out_mask(audio_channel_mask_t channel) { uint32_t bits = audio_channel_mask_get_bits(channel); switch (audio_channel_mask_get_representation(channel)) { case AUDIO_CHANNEL_REPRESENTATION_POSITION: // TODO: We can now merge with from_in_mask and remove anding bits &= AUDIO_CHANNEL_OUT_ALL; // fall through case AUDIO_CHANNEL_REPRESENTATION_INDEX: return popcount(bits); default: return 0; } } /* Derive a channel mask for index assignment from a channel count. * Returns the matching channel mask, * or AUDIO_CHANNEL_NONE if the channel count is zero, * or AUDIO_CHANNEL_INVALID if the channel count exceeds AUDIO_CHANNEL_COUNT_MAX. */ static inline audio_channel_mask_t audio_channel_mask_for_index_assignment_from_count( uint32_t channel_count) { if (channel_count == 0) { return AUDIO_CHANNEL_NONE; } if (channel_count > AUDIO_CHANNEL_COUNT_MAX) { return AUDIO_CHANNEL_INVALID; } uint32_t bits = (1 << channel_count) - 1; return audio_channel_mask_from_representation_and_bits( AUDIO_CHANNEL_REPRESENTATION_INDEX, bits); } /* Derive an output channel mask for position assignment from a channel count. * This is to be used when the content channel mask is unknown. The 1, 2, 4, 5, 6, 7 and 8 channel * cases are mapped to the standard game/home-theater layouts, but note that 4 is mapped to quad, * and not stereo + FC + mono surround. A channel count of 3 is arbitrarily mapped to stereo + FC * for continuity with stereo. * Returns the matching channel mask, * or AUDIO_CHANNEL_NONE if the channel count is zero, * or AUDIO_CHANNEL_INVALID if the channel count exceeds that of the * configurations for which a default output channel mask is defined. */ static inline audio_channel_mask_t audio_channel_out_mask_from_count(uint32_t channel_count) { uint32_t bits; switch (channel_count) { case 0: return AUDIO_CHANNEL_NONE; case 1: bits = AUDIO_CHANNEL_OUT_MONO; break; case 2: bits = AUDIO_CHANNEL_OUT_STEREO; break; case 3: bits = AUDIO_CHANNEL_OUT_STEREO | AUDIO_CHANNEL_OUT_FRONT_CENTER; break; case 4: // 4.0 bits = AUDIO_CHANNEL_OUT_QUAD; break; case 5: // 5.0 bits = AUDIO_CHANNEL_OUT_QUAD | AUDIO_CHANNEL_OUT_FRONT_CENTER; break; case 6: // 5.1 bits = AUDIO_CHANNEL_OUT_5POINT1; break; case 7: // 6.1 bits = AUDIO_CHANNEL_OUT_5POINT1 | AUDIO_CHANNEL_OUT_BACK_CENTER; break; case 8: bits = AUDIO_CHANNEL_OUT_7POINT1; break; // FIXME FCC_8 default: return AUDIO_CHANNEL_INVALID; } return audio_channel_mask_from_representation_and_bits( AUDIO_CHANNEL_REPRESENTATION_POSITION, bits); } /* Derive a default input channel mask from a channel count. * Assumes a position mask for mono and stereo, or an index mask for channel counts > 2. * Returns the matching channel mask, * or AUDIO_CHANNEL_NONE if the channel count is zero, * or AUDIO_CHANNEL_INVALID if the channel count exceeds that of the * configurations for which a default input channel mask is defined. */ static inline audio_channel_mask_t audio_channel_in_mask_from_count(uint32_t channel_count) { uint32_t bits; switch (channel_count) { case 0: return AUDIO_CHANNEL_NONE; case 1: bits = AUDIO_CHANNEL_IN_MONO; break; case 2: bits = AUDIO_CHANNEL_IN_STEREO; break; case 3: case 4: case 5: case 6: case 7: case 8: // FIXME FCC_8 return audio_channel_mask_for_index_assignment_from_count(channel_count); default: return AUDIO_CHANNEL_INVALID; } return audio_channel_mask_from_representation_and_bits( AUDIO_CHANNEL_REPRESENTATION_POSITION, bits); } static inline bool audio_is_valid_format(audio_format_t format) { switch (format & AUDIO_FORMAT_MAIN_MASK) { case AUDIO_FORMAT_PCM: switch (format) { case AUDIO_FORMAT_PCM_16_BIT: case AUDIO_FORMAT_PCM_8_BIT: case AUDIO_FORMAT_PCM_32_BIT: case AUDIO_FORMAT_PCM_8_24_BIT: case AUDIO_FORMAT_PCM_FLOAT: case AUDIO_FORMAT_PCM_24_BIT_PACKED: return true; default: return false; } /* not reached */ case AUDIO_FORMAT_MP3: case AUDIO_FORMAT_AMR_NB: case AUDIO_FORMAT_AMR_WB: case AUDIO_FORMAT_AAC: case AUDIO_FORMAT_HE_AAC_V1: case AUDIO_FORMAT_HE_AAC_V2: case AUDIO_FORMAT_VORBIS: case AUDIO_FORMAT_OPUS: case AUDIO_FORMAT_AC3: case AUDIO_FORMAT_E_AC3: case AUDIO_FORMAT_DTS: case AUDIO_FORMAT_DTS_HD: return true; default: return false; } } static inline bool audio_is_linear_pcm(audio_format_t format) { return ((format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_PCM); } static inline size_t audio_bytes_per_sample(audio_format_t format) { size_t size = 0; switch (format) { case AUDIO_FORMAT_PCM_32_BIT: case AUDIO_FORMAT_PCM_8_24_BIT: size = sizeof(int32_t); break; case AUDIO_FORMAT_PCM_24_BIT_PACKED: size = sizeof(uint8_t) * 3; break; case AUDIO_FORMAT_PCM_16_BIT: size = sizeof(int16_t); break; case AUDIO_FORMAT_PCM_8_BIT: size = sizeof(uint8_t); break; case AUDIO_FORMAT_PCM_FLOAT: size = sizeof(float); break; default: break; } return size; } /* 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) { const size_t kSize = AUDIO_DEVICE_MAX_ADDRESS_LEN + sizeof("a2dp_sink_address="); char param[kSize]; if (device & AUDIO_DEVICE_OUT_ALL_A2DP) snprintf(param, kSize, "%s=%s", "a2dp_sink_address", address); else if (device & AUDIO_DEVICE_OUT_REMOTE_SUBMIX) snprintf(param, kSize, "%s=%s", "mix", address); else snprintf(param, kSize, "%s", address); return strdup(param); } static inline bool audio_device_is_digital(audio_devices_t device) { if ((device & AUDIO_DEVICE_BIT_IN) != 0) { // input return (~AUDIO_DEVICE_BIT_IN & device & (AUDIO_DEVICE_IN_ALL_USB | AUDIO_DEVICE_IN_HDMI | AUDIO_DEVICE_IN_SPDIF | AUDIO_DEVICE_IN_IP)) != 0; } else { // output return (device & (AUDIO_DEVICE_OUT_ALL_USB | AUDIO_DEVICE_OUT_HDMI | AUDIO_DEVICE_OUT_HDMI_ARC | AUDIO_DEVICE_OUT_SPDIF | AUDIO_DEVICE_OUT_IP)) != 0; } } __END_DECLS #endif // ANDROID_AUDIO_CORE_H android-headers-23/23/system/audio_policy.h000066400000000000000000000057431264465411000207460ustar00rootroot00000000000000/* * 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_AUDIO_POLICY_CORE_H #define ANDROID_AUDIO_POLICY_CORE_H #include #include #include #include __BEGIN_DECLS /* The enums were moved here mostly from * frameworks/base/include/media/AudioSystem.h */ /* device categories used for audio_policy->set_force_use() */ typedef enum { AUDIO_POLICY_FORCE_NONE, AUDIO_POLICY_FORCE_SPEAKER, AUDIO_POLICY_FORCE_HEADPHONES, AUDIO_POLICY_FORCE_BT_SCO, AUDIO_POLICY_FORCE_BT_A2DP, AUDIO_POLICY_FORCE_WIRED_ACCESSORY, AUDIO_POLICY_FORCE_BT_CAR_DOCK, AUDIO_POLICY_FORCE_BT_DESK_DOCK, AUDIO_POLICY_FORCE_ANALOG_DOCK, AUDIO_POLICY_FORCE_DIGITAL_DOCK, 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_CFG_CNT, AUDIO_POLICY_FORCE_CFG_MAX = AUDIO_POLICY_FORCE_CFG_CNT - 1, AUDIO_POLICY_FORCE_DEFAULT = AUDIO_POLICY_FORCE_NONE, } audio_policy_forced_cfg_t; /* usages used for audio_policy->set_force_use() */ typedef enum { AUDIO_POLICY_FORCE_FOR_COMMUNICATION, AUDIO_POLICY_FORCE_FOR_MEDIA, AUDIO_POLICY_FORCE_FOR_RECORD, AUDIO_POLICY_FORCE_FOR_DOCK, AUDIO_POLICY_FORCE_FOR_SYSTEM, AUDIO_POLICY_FORCE_FOR_HDMI_SYSTEM_AUDIO, AUDIO_POLICY_FORCE_USE_CNT, AUDIO_POLICY_FORCE_USE_MAX = AUDIO_POLICY_FORCE_USE_CNT - 1, } audio_policy_force_use_t; /* device connection states used for audio_policy->set_device_connection_state() */ typedef enum { AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE, AUDIO_POLICY_DEVICE_STATE_AVAILABLE, AUDIO_POLICY_DEVICE_STATE_CNT, AUDIO_POLICY_DEVICE_STATE_MAX = AUDIO_POLICY_DEVICE_STATE_CNT - 1, } audio_policy_dev_state_t; typedef enum { /* Used to generate a tone to notify the user of a * notification/alarm/ringtone while they are in a call. */ AUDIO_POLICY_TONE_IN_CALL_NOTIFICATION = 0, AUDIO_POLICY_TONE_CNT, AUDIO_POLICY_TONE_MAX = AUDIO_POLICY_TONE_CNT - 1, } audio_policy_tone_t; static inline bool audio_is_low_visibility(audio_stream_type_t stream) { switch (stream) { case AUDIO_STREAM_SYSTEM: case AUDIO_STREAM_NOTIFICATION: case AUDIO_STREAM_RING: return true; default: return false; } } __END_DECLS #endif // ANDROID_AUDIO_POLICY_CORE_H android-headers-23/23/system/camera.h000066400000000000000000000265201264465411000175120ustar00rootroot00000000000000/* * 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 SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H #define SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H #include #include #include #include #include #include __BEGIN_DECLS /** * A set of bit masks for specifying how the received preview frames are * handled before the previewCallback() call. * * The least significant 3 bits of an "int" value are used for this purpose: * * ..... 0 0 0 * ^ ^ ^ * | | |---------> determine whether the callback is enabled or not * | |-----------> determine whether the callback is one-shot or not * |-------------> determine whether the frame is copied out or not * * WARNING: When a frame is sent directly without copying, it is the frame * receiver's responsiblity to make sure that the frame data won't get * corrupted by subsequent preview frames filled by the camera. This flag is * recommended only when copying out data brings significant performance price * and the handling/processing of the received frame data is always faster than * the preview frame rate so that data corruption won't occur. * * For instance, * 1. 0x00 disables the callback. In this case, copy out and one shot bits * are ignored. * 2. 0x01 enables a callback without copying out the received frames. A * typical use case is the Camcorder application to avoid making costly * frame copies. * 3. 0x05 is enabling a callback with frame copied out repeatedly. A typical * use case is the Camera application. * 4. 0x07 is enabling a callback with frame copied out only once. A typical * use case is the Barcode scanner application. */ enum { CAMERA_FRAME_CALLBACK_FLAG_ENABLE_MASK = 0x01, CAMERA_FRAME_CALLBACK_FLAG_ONE_SHOT_MASK = 0x02, CAMERA_FRAME_CALLBACK_FLAG_COPY_OUT_MASK = 0x04, /** Typical use cases */ CAMERA_FRAME_CALLBACK_FLAG_NOOP = 0x00, CAMERA_FRAME_CALLBACK_FLAG_CAMCORDER = 0x01, CAMERA_FRAME_CALLBACK_FLAG_CAMERA = 0x05, CAMERA_FRAME_CALLBACK_FLAG_BARCODE_SCANNER = 0x07 }; /** msgType in notifyCallback and dataCallback functions */ enum { CAMERA_MSG_ERROR = 0x0001, // notifyCallback CAMERA_MSG_SHUTTER = 0x0002, // notifyCallback CAMERA_MSG_FOCUS = 0x0004, // notifyCallback CAMERA_MSG_ZOOM = 0x0008, // notifyCallback CAMERA_MSG_PREVIEW_FRAME = 0x0010, // dataCallback CAMERA_MSG_VIDEO_FRAME = 0x0020, // data_timestamp_callback CAMERA_MSG_POSTVIEW_FRAME = 0x0040, // dataCallback CAMERA_MSG_RAW_IMAGE = 0x0080, // dataCallback CAMERA_MSG_COMPRESSED_IMAGE = 0x0100, // dataCallback CAMERA_MSG_RAW_IMAGE_NOTIFY = 0x0200, // dataCallback // Preview frame metadata. This can be combined with // CAMERA_MSG_PREVIEW_FRAME in dataCallback. For example, the apps can // request FRAME and METADATA. Or the apps can request only FRAME or only // METADATA. CAMERA_MSG_PREVIEW_METADATA = 0x0400, // dataCallback // Notify on autofocus start and stop. This is useful in continuous // autofocus - FOCUS_MODE_CONTINUOUS_VIDEO and FOCUS_MODE_CONTINUOUS_PICTURE. CAMERA_MSG_FOCUS_MOVE = 0x0800, // notifyCallback CAMERA_MSG_ALL_MSGS = 0xFFFF }; /** cmdType in sendCommand functions */ enum { CAMERA_CMD_START_SMOOTH_ZOOM = 1, CAMERA_CMD_STOP_SMOOTH_ZOOM = 2, /** * Set the clockwise rotation of preview display (setPreviewDisplay) in * degrees. This affects the preview frames and the picture displayed after * snapshot. This method is useful for portrait mode applications. Note * that preview display of front-facing cameras is flipped horizontally * before the rotation, that is, the image is reflected along the central * vertical axis of the camera sensor. So the users can see themselves as * looking into a mirror. * * This does not affect the order of byte array of * CAMERA_MSG_PREVIEW_FRAME, CAMERA_MSG_VIDEO_FRAME, * CAMERA_MSG_POSTVIEW_FRAME, CAMERA_MSG_RAW_IMAGE, or * CAMERA_MSG_COMPRESSED_IMAGE. This is allowed to be set during preview * since API level 14. */ CAMERA_CMD_SET_DISPLAY_ORIENTATION = 3, /** * cmdType to disable/enable shutter sound. In sendCommand passing arg1 = * 0 will disable, while passing arg1 = 1 will enable the shutter sound. */ CAMERA_CMD_ENABLE_SHUTTER_SOUND = 4, /* cmdType to play recording sound */ CAMERA_CMD_PLAY_RECORDING_SOUND = 5, /** * Start the face detection. This should be called after preview is started. * The camera will notify the listener of CAMERA_MSG_FACE and the detected * faces in the preview frame. The detected faces may be the same as the * previous ones. Apps should call CAMERA_CMD_STOP_FACE_DETECTION to stop * the face detection. This method is supported if CameraParameters * KEY_MAX_NUM_HW_DETECTED_FACES or KEY_MAX_NUM_SW_DETECTED_FACES is * bigger than 0. Hardware and software face detection should not be running * at the same time. If the face detection has started, apps should not send * this again. * * In hardware face detection mode, CameraParameters KEY_WHITE_BALANCE, * KEY_FOCUS_AREAS and KEY_METERING_AREAS have no effect. * * arg1 is the face detection type. It can be CAMERA_FACE_DETECTION_HW or * CAMERA_FACE_DETECTION_SW. If the type of face detection requested is not * supported, the HAL must return BAD_VALUE. */ CAMERA_CMD_START_FACE_DETECTION = 6, /** * Stop the face detection. */ CAMERA_CMD_STOP_FACE_DETECTION = 7, /** * Enable/disable focus move callback (CAMERA_MSG_FOCUS_MOVE). Passing * arg1 = 0 will disable, while passing arg1 = 1 will enable the callback. */ CAMERA_CMD_ENABLE_FOCUS_MOVE_MSG = 8, /** * Ping camera service to see if camera hardware is released. * * When any camera method returns error, the client can use ping command * to see if the camera has been taken away by other clients. If the result * is NO_ERROR, it means the camera hardware is not released. If the result * is not NO_ERROR, the camera has been released and the existing client * can silently finish itself or show a dialog. */ CAMERA_CMD_PING = 9, /** * Configure the number of video buffers used for recording. The intended * video buffer count for recording is passed as arg1, which must be * greater than 0. This command must be sent before recording is started. * This command returns INVALID_OPERATION error if it is sent after video * recording is started, or the command is not supported at all. This * command also returns a BAD_VALUE error if the intended video buffer * count is non-positive or too big to be realized. */ CAMERA_CMD_SET_VIDEO_BUFFER_COUNT = 10, /** * Configure an explicit format to use for video recording metadata mode. * This can be used to switch the format from the * default IMPLEMENTATION_DEFINED gralloc format to some other * device-supported format, and the default dataspace from the BT_709 color * space to some other device-supported dataspace. arg1 is the HAL pixel * format, and arg2 is the HAL dataSpace. This command returns * INVALID_OPERATION error if it is sent after video recording is started, * or the command is not supported at all. * * If the gralloc format is set to a format other than * IMPLEMENTATION_DEFINED, then HALv3 devices will use gralloc usage flags * of SW_READ_OFTEN. */ CAMERA_CMD_SET_VIDEO_FORMAT = 11 }; /** camera fatal errors */ enum { CAMERA_ERROR_UNKNOWN = 1, /** * Camera was released because another client has connected to the camera. * The original 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_RELEASED = 2, CAMERA_ERROR_SERVER_DIED = 100 }; enum { /** The facing of the camera is opposite to that of the screen. */ CAMERA_FACING_BACK = 0, /** The facing of the camera is the same as that of the screen. */ CAMERA_FACING_FRONT = 1, /** * The facing of the camera is not fixed relative to the screen. * The cameras with this facing are external cameras, e.g. USB cameras. */ CAMERA_FACING_EXTERNAL = 2 }; enum { /** Hardware face detection. It does not use much CPU. */ CAMERA_FACE_DETECTION_HW = 0, /** * Software face detection. It uses some CPU. Applications must use * Camera.setPreviewTexture for preview in this mode. */ CAMERA_FACE_DETECTION_SW = 1 }; /** * The information of a face from camera face detection. */ typedef struct camera_face { /** * Bounds of the face [left, top, right, bottom]. (-1000, -1000) represents * the top-left of the camera field of view, and (1000, 1000) represents the * bottom-right of the field of view. The width and height cannot be 0 or * negative. This is supported by both hardware and software face detection. * * The direction is relative to the sensor orientation, that is, what the * sensor sees. The direction is not affected by the rotation or mirroring * of CAMERA_CMD_SET_DISPLAY_ORIENTATION. */ int32_t rect[4]; /** * The confidence level of the face. The range is 1 to 100. 100 is the * highest confidence. This is supported by both hardware and software * face detection. */ int32_t score; /** * An unique id per face while the face is visible to the tracker. If * the face leaves the field-of-view and comes back, it will get a new * id. If the value is 0, id is not supported. */ int32_t id; /** * The coordinates of the center of the left eye. The range is -1000 to * 1000. -2000, -2000 if this is not supported. */ int32_t left_eye[2]; /** * The coordinates of the center of the right eye. The range is -1000 to * 1000. -2000, -2000 if this is not supported. */ int32_t right_eye[2]; /** * The coordinates of the center of the mouth. The range is -1000 to 1000. * -2000, -2000 if this is not supported. */ int32_t mouth[2]; } camera_face_t; /** * The metadata of the frame data. */ typedef struct camera_frame_metadata { /** * The number of detected faces in the frame. */ int32_t number_of_faces; /** * An array of the detected faces. The length is number_of_faces. */ camera_face_t *faces; } camera_frame_metadata_t; __END_DECLS #endif /* SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H */ android-headers-23/23/system/graphics.h000066400000000000000000000701751264465411000200670ustar00rootroot00000000000000/* * 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 SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H #define SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H #include #ifdef __cplusplus extern "C" { #endif /* * If the HAL needs to create service threads to handle graphics related * tasks, these threads need to run at HAL_PRIORITY_URGENT_DISPLAY priority * if they can block the main rendering thread in any way. * * the priority of the current thread can be set with: * * #include * setpriority(PRIO_PROCESS, 0, HAL_PRIORITY_URGENT_DISPLAY); * */ #define HAL_PRIORITY_URGENT_DISPLAY (-8) /** * pixel format definitions */ enum { /* * "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 }; /* * Structure for describing YCbCr formats for consumption by applications. * This is used with HAL_PIXEL_FORMAT_YCbCr_*_888. * * Buffer chroma subsampling is defined in the format. * e.g. HAL_PIXEL_FORMAT_YCbCr_420_888 has subsampling 4:2:0. * * Buffers must have a 8 bit depth. * * @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. * * @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. */ struct android_ycbcr { void *y; void *cb; void *cr; size_t ystride; size_t cstride; size_t chroma_step; /** reserved for future use, set to 0 by gralloc's (*lock_ycbcr)() */ uint32_t reserved[8]; }; /** * Structure used to define depth point clouds for format HAL_PIXEL_FORMAT_BLOB * with dataSpace value of HAL_DATASPACE_DEPTH. * When locking a native buffer of the above format and dataSpace value, * the vaddr pointer can be cast to this structure. * * A variable-length list of (x,y,z, confidence) 3D points, as floats. (x, y, * z) represents a measured point's position, with the coordinate system defined * by the data source. Confidence represents the estimated likelihood that this * 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 * * @xyz_points is the flexible array of floating-point values. * It contains (num_points) * 4 floats. * * For example: * android_depth_points d = get_depth_buffer(); * struct { * float x; float y; float z; float confidence; * } firstPoint, lastPoint; * * firstPoint.x = d.xyzc_points[0]; * firstPoint.y = d.xyzc_points[1]; * firstPoint.z = d.xyzc_points[2]; * firstPoint.confidence = d.xyzc_points[3]; * lastPoint.x = d.xyzc_points[(d.num_points - 1) * 4 + 0]; * lastPoint.y = d.xyzc_points[(d.num_points - 1) * 4 + 1]; * lastPoint.z = d.xyzc_points[(d.num_points - 1) * 4 + 2]; * lastPoint.confidence = d.xyzc_points[(d.num_points - 1) * 4 + 3]; */ struct android_depth_points { uint32_t num_points; /** reserved for future use, set to 0 by gralloc's (*lock)() */ uint32_t reserved[8]; float xyzc_points[]; }; /** * Transformation definitions * * IMPORTANT NOTE: * HAL_TRANSFORM_ROT_90 is applied CLOCKWISE and AFTER HAL_TRANSFORM_FLIP_{H|V}. * */ enum { /* 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, }; /** * 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. */ 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, /* * RGB 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). */ /* * 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, /* * sRGB gamma encoding: * * The red, green and blue components are stored in sRGB space, and * converted to linear space when read, using the standard sRGB to linear * equation: * * Clinear = Csrgb / 12.92 for Csrgb <= 0.04045 * = (Csrgb + 0.055 / 1.055)^2.4 for Csrgb > 0.04045 * * When written the inverse transformation is performed: * * Csrgb = 12.92 * Clinear for Clinear <= 0.0031308 * = 1.055 * Clinear^(1/2.4) - 0.055 for Clinear > 0.0031308 * * * The alpha component, if present, is always stored in linear space and * is left unmodified when read or written. * * 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 = 0x201, /* * 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 * * Transfer characteristic curve: * E = 1.099 * L ^ 0.45 - 0.099, 1.00 >= L >= 0.018 * E = 4.500 L, 0.018 > L >= 0 * L - luminance of image 0 <= L <= 1 for conventional colorimetry * E - corresponding electrical signal * * Primaries: x y * green 0.290 0.600 * blue 0.150 0.060 * red 0.640 0.330 * white (D65) 0.3127 0.3290 */ HAL_DATASPACE_JFIF = 0x101, /* * ITU-R Recommendation 601 (BT.601) - 625-line * * Standard-definition television, 625 Lines (PAL) * * 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 * * Transfer characteristic curve: * E = 1.099 * L ^ 0.45 - 0.099, 1.00 >= L >= 0.018 * E = 4.500 L, 0.018 > L >= 0 * L - luminance of image 0 <= L <= 1 for conventional colorimetry * E - corresponding electrical signal * * Primaries: x y * green 0.290 0.600 * blue 0.150 0.060 * red 0.640 0.330 * white (D65) 0.3127 0.3290 */ HAL_DATASPACE_BT601_625 = 0x102, /* * ITU-R Recommendation 601 (BT.601) - 525-line * * Standard-definition television, 525 Lines (NTSC) * * 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 * * Transfer characteristic curve: * E = 1.099 * L ^ 0.45 - 0.099, 1.00 >= L >= 0.018 * E = 4.500 L, 0.018 > L >= 0 * L - luminance of image 0 <= L <= 1 for conventional colorimetry * E - corresponding electrical signal * * Primaries: x y * green 0.310 0.595 * blue 0.155 0.070 * red 0.630 0.340 * white (D65) 0.3127 0.3290 */ HAL_DATASPACE_BT601_525 = 0x103, /* * ITU-R Recommendation 709 (BT.709) * * High-definition television * * 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 * * Primaries: x y * green 0.300 0.600 * blue 0.150 0.060 * red 0.640 0.330 * white (D65) 0.3127 0.3290 */ HAL_DATASPACE_BT709 = 0x104, /* * 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; #ifdef __cplusplus } #endif #endif /* SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H */ android-headers-23/23/system/radio.h000066400000000000000000000234151264465411000173600ustar00rootroot00000000000000/* * 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_H #define ANDROID_RADIO_H #include #include #include #include #include #define RADIO_NUM_BANDS_MAX 16 #define RADIO_NUM_SPACINGS_MAX 16 #define RADIO_STRING_LEN_MAX 128 /* * Radio hardware module class. A given radio hardware module HAL is of one class * only. The platform can not have more than one hardware module of each class. * Current version of the framework only supports RADIO_CLASS_AM_FM. */ typedef enum { RADIO_CLASS_AM_FM = 0, /* FM (including HD radio) and AM */ RADIO_CLASS_SAT = 1, /* Satellite Radio */ RADIO_CLASS_DT = 2, /* Digital Radio (DAB) */ } radio_class_t; /* value for field "type" of radio band described in struct radio_hal_band_config */ typedef enum { RADIO_BAND_AM = 0, /* Amplitude Modulation band: LW, MW, SW */ RADIO_BAND_FM = 1, /* Frequency Modulation band: FM */ RADIO_BAND_FM_HD = 2, /* FM HD Radio / DRM (IBOC) */ RADIO_BAND_AM_HD = 3, /* AM HD Radio / DRM (IBOC) */ } radio_band_t; /* RDS variant implemented. A struct radio_hal_fm_band_config can list none or several. */ enum { RADIO_RDS_NONE = 0x0, RADIO_RDS_WORLD = 0x01, RADIO_RDS_US = 0x02, }; typedef unsigned int radio_rds_t; /* FM deemphasis variant implemented. A struct radio_hal_fm_band_config can list one or more. */ enum { RADIO_DEEMPHASIS_50 = 0x1, RADIO_DEEMPHASIS_75 = 0x2, }; typedef unsigned int radio_deemphasis_t; /* Region a particular radio band configuration corresponds to. Not used at the HAL. * Derived by the framework when converting the band descriptors retrieved from the HAL to * individual band descriptors for each supported region. */ typedef enum { RADIO_REGION_NONE = -1, RADIO_REGION_ITU_1 = 0, RADIO_REGION_ITU_2 = 1, RADIO_REGION_OIRT = 2, RADIO_REGION_JAPAN = 3, RADIO_REGION_KOREA = 4, } radio_region_t; /* scanning direction for scan() and step() tuner APIs */ typedef enum { RADIO_DIRECTION_UP, RADIO_DIRECTION_DOWN } radio_direction_t; /* unique handle allocated to a radio module */ typedef unsigned int 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; /* Additional attributes for an FM band configuration */ typedef struct radio_hal_fm_band_config { radio_deemphasis_t deemphasis; /* deemphasis variant */ bool stereo; /* stereo supported */ radio_rds_t rds; /* RDS variants supported */ bool ta; /* Traffic Announcement supported */ bool af; /* Alternate Frequency supported */ } radio_hal_fm_band_config_t; /* Additional attributes for an AM band configuration */ typedef struct radio_hal_am_band_config { bool stereo; /* stereo supported */ } radio_hal_am_band_config_t; /* Radio band configuration. Describes a given band supported by the radio module. * The HAL can expose only one band per type with the the maximum range supported and all options. * THe framework will derive the actual regions were this module can operate and expose separate * band configurations for applications to chose from. */ 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]; union { radio_hal_fm_band_config_t fm; radio_hal_am_band_config_t am; }; } radio_hal_band_config_t; /* Used internally by the framework to represent a band for s specific region */ typedef struct radio_band_config { radio_region_t region; radio_hal_band_config_t band; } radio_band_config_t; /* Exposes properties of a given hardware radio module. * NOTE: current framework implementation supports only one audio source (num_audio_sources = 1). * The source corresponds to AUDIO_DEVICE_IN_FM_TUNER. * If more than one tuner is supported (num_tuners > 1), only one can be connected to the audio * source. */ typedef struct radio_hal_properties { radio_class_t class_id; /* Class of this module. E.g RADIO_CLASS_AM_FM */ char implementor[RADIO_STRING_LEN_MAX]; /* implementor name */ 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 */ bool supports_capture; /* the hardware supports capture of audio source audio HAL */ unsigned int num_bands; /* number of band descriptors */ radio_hal_band_config_t bands[RADIO_NUM_BANDS_MAX]; /* band descriptors */ } radio_hal_properties_t; /* Used internally by the framework. Same information as in struct radio_hal_properties plus a * unique handle and one band configuration per region. */ typedef struct radio_properties { radio_handle_t handle; radio_class_t class_id; char implementor[RADIO_STRING_LEN_MAX]; 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; bool supports_capture; unsigned int num_bands; radio_band_config_t bands[RADIO_NUM_BANDS_MAX]; } radio_properties_t; /* Radio program information. Returned by the HAL with event RADIO_EVENT_TUNED. * 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) */ 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 ...) */ } radio_program_info_t; /* Events sent to the framework via the HAL callback. An event can notify the completion of an * asynchronous command (configuration, tune, scan ...) or a spontaneous change (antenna connection, * failure, AF switching, meta data reception... */ enum { RADIO_EVENT_HW_FAILURE = 0, /* hardware module failure. Requires reopening the tuner */ RADIO_EVENT_CONFIG = 1, /* configuration change completed */ RADIO_EVENT_ANTENNA = 2, /* Antenna connected, disconnected */ RADIO_EVENT_TUNED = 3, /* tune, step, scan completed */ RADIO_EVENT_METADATA = 4, /* New meta data received */ RADIO_EVENT_TA = 5, /* Traffic announcement start or stop */ RADIO_EVENT_AF_SWITCH = 6, /* Switch to Alternate Frequency */ // begin framework only events RADIO_EVENT_CONTROL = 100, /* loss/gain of tuner control */ RADIO_EVENT_SERVER_DIED = 101, /* radio service died */ }; 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 */ union { bool on; /* RADIO_EVENT_ANTENNA, RADIO_EVENT_TA */ radio_hal_band_config_t config; /* RADIO_EVENT_CONFIG */ radio_program_info_t info; /* RADIO_EVENT_TUNED, RADIO_EVENT_AF_SWITCH */ radio_metadata_t *metadata; /* RADIO_EVENT_METADATA */ }; } radio_hal_event_t; /* Used internally by the framework. Same information as in struct radio_hal_event */ typedef struct radio_event { radio_event_type_t type; int 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 */ }; } radio_event_t; static radio_rds_t radio_rds_for_region(bool rds, radio_region_t region) { if (!rds) return RADIO_RDS_NONE; switch(region) { case RADIO_REGION_ITU_1: case RADIO_REGION_OIRT: case RADIO_REGION_JAPAN: case RADIO_REGION_KOREA: return RADIO_RDS_WORLD; case RADIO_REGION_ITU_2: return RADIO_RDS_US; default: return RADIO_REGION_NONE; } } static radio_deemphasis_t radio_demephasis_for_region(radio_region_t region) { switch(region) { case RADIO_REGION_KOREA: case RADIO_REGION_ITU_2: return RADIO_DEEMPHASIS_75; case RADIO_REGION_ITU_1: case RADIO_REGION_OIRT: case RADIO_REGION_JAPAN: default: return RADIO_DEEMPHASIS_50; } } #endif // ANDROID_RADIO_H android-headers-23/23/system/sound_trigger.h000066400000000000000000000272561264465411000211440ustar00rootroot00000000000000/* * 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_SOUND_TRIGGER_H #define ANDROID_SOUND_TRIGGER_H #include #include #define SOUND_TRIGGER_MAX_STRING_LEN 64 /* max length of strings in properties or descriptor structs */ #define SOUND_TRIGGER_MAX_LOCALE_LEN 6 /* max length of locale string. e.g en_US */ #define SOUND_TRIGGER_MAX_USERS 10 /* max number of concurrent users */ #define SOUND_TRIGGER_MAX_PHRASES 10 /* max number of concurrent phrases */ typedef enum { SOUND_TRIGGER_STATE_NO_INIT = -1, /* The sound trigger service is not initialized */ SOUND_TRIGGER_STATE_ENABLED = 0, /* The sound trigger service is enabled */ SOUND_TRIGGER_STATE_DISABLED = 1 /* The sound trigger service is disabled */ } sound_trigger_service_state_t; #define RECOGNITION_MODE_VOICE_TRIGGER 0x1 /* simple voice trigger */ #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_STATUS_SUCCESS 0 #define RECOGNITION_STATUS_ABORT 1 #define RECOGNITION_STATUS_FAILURE 2 #define SOUND_MODEL_STATUS_UPDATED 0 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_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; /* * sound trigger implementation descriptor read by the framework via get_properties(). * Used by SoundTrigger service to report to applications and manage concurrency and policy. */ struct sound_trigger_properties { char implementor[SOUND_TRIGGER_MAX_STRING_LEN]; /* implementor name */ char description[SOUND_TRIGGER_MAX_STRING_LEN]; /* implementation description */ unsigned int version; /* implementation version */ sound_trigger_uuid_t uuid; /* unique implementation ID. Must change with version each version */ unsigned int max_sound_models; /* maximum number of concurrent sound models loaded */ unsigned int max_key_phrases; /* maximum number of key phrases */ unsigned int max_users; /* maximum number of concurrent users detected */ unsigned int recognition_modes; /* all supported modes. e.g RECOGNITION_MODE_VOICE_TRIGGER */ bool capture_transition; /* supports seamless transition from detection to capture */ unsigned int max_buffer_ms; /* maximum buffering capacity in ms if capture_transition is true*/ bool concurrent_capture; /* supports capture by other use cases while detection is active */ bool trigger_in_event; /* returns the trigger capture in event */ unsigned int power_consumption_mw; /* Rated power consumption when detection is active with TDB silence/sound/speech ratio */ }; typedef int sound_trigger_module_handle_t; struct sound_trigger_module_descriptor { sound_trigger_module_handle_t handle; struct sound_trigger_properties properties; }; typedef int sound_model_handle_t; /* * Generic 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 */ struct sound_trigger_sound_model { sound_trigger_sound_model_type_t type; /* model type. e.g. SOUND_MODEL_TYPE_KEYPHRASE */ sound_trigger_uuid_t uuid; /* unique sound model ID. */ sound_trigger_uuid_t vendor_uuid; /* unique vendor ID. Identifies the engine the sound model was build for */ unsigned int data_size; /* size of opaque model data */ unsigned int data_offset; /* offset of opaque data start from head of struct (e.g sizeof struct sound_trigger_sound_model) */ }; /* key phrase descriptor */ struct sound_trigger_phrase { unsigned int id; /* keyphrase ID */ unsigned int recognition_mode; /* recognition modes supported by this key phrase */ unsigned int num_users; /* number of users in the key phrase */ unsigned int users[SOUND_TRIGGER_MAX_USERS]; /* users ids: (not uid_t but sound trigger specific IDs */ char locale[SOUND_TRIGGER_MAX_LOCALE_LEN]; /* locale - JAVA Locale style (e.g. en_US) */ char text[SOUND_TRIGGER_MAX_STRING_LEN]; /* phrase text in UTF-8 format. */ }; /* * Specialized sound model for key phrase detection. * Proprietary representation of key phrases in binary data must match information indicated * by phrases field */ struct sound_trigger_phrase_sound_model { struct sound_trigger_sound_model common; unsigned int num_phrases; /* number of key phrases in model */ struct sound_trigger_phrase phrases[SOUND_TRIGGER_MAX_PHRASES]; }; /* * Generic recognition event sent via recognition callback */ struct 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. e.g. SOUND_MODEL_TYPE_KEYPHRASE */ sound_model_handle_t model; /* loaded sound model that triggered the event */ bool capture_available; /* it is possible to capture audio from this utterance buffered by the implementation */ int capture_session; /* audio session ID. framework use */ int capture_delay_ms; /* delay in ms between end of model detection and start of audio available for capture. A negative value is possible (e.g. if key phrase is also available for capture */ int capture_preamble_ms; /* duration in ms of audio captured before the start of the trigger. 0 if none. */ bool trigger_in_data; /* the opaque data is the capture of the trigger sound */ audio_config_t audio_config; /* audio format of either the trigger in event data or to use for capture of the rest of the utterance */ unsigned int data_size; /* size of opaque event data */ unsigned int data_offset; /* offset of opaque data start from start of this struct (e.g sizeof struct sound_trigger_phrase_recognition_event) */ }; /* * Confidence level for each user in struct sound_trigger_phrase_recognition_extra */ struct sound_trigger_confidence_level { unsigned int user_id; /* user ID */ unsigned int level; /* confidence level in percent (0 - 100). - min level for recognition configuration - detected level for recognition event */ }; /* * Specialized recognition event for key phrase detection */ struct sound_trigger_phrase_recognition_extra { unsigned int id; /* keyphrase ID */ unsigned int recognition_modes; /* recognition modes used for this keyphrase */ unsigned int confidence_level; /* confidence level for mode RECOGNITION_MODE_VOICE_TRIGGER */ unsigned int num_levels; /* number of user confidence levels */ struct sound_trigger_confidence_level levels[SOUND_TRIGGER_MAX_USERS]; }; struct sound_trigger_phrase_recognition_event { struct sound_trigger_recognition_event common; unsigned int num_phrases; struct sound_trigger_phrase_recognition_extra phrase_extras[SOUND_TRIGGER_MAX_PHRASES]; }; /* * configuration for sound trigger capture session passed to start_recognition() */ struct sound_trigger_recognition_config { audio_io_handle_t capture_handle; /* IO handle that will be used for capture. N/A if capture_requested is false */ audio_devices_t capture_device; /* input device requested for detection capture */ bool capture_requested; /* capture and buffer audio for this recognition instance */ unsigned int num_phrases; /* number of key phrases recognition extras */ struct sound_trigger_phrase_recognition_extra phrases[SOUND_TRIGGER_MAX_PHRASES]; /* configuration for each key phrase */ unsigned int data_size; /* size of opaque capture configuration data */ unsigned int data_offset; /* offset of opaque data start from start of this struct (e.g sizeof struct sound_trigger_recognition_config) */ }; /* * Event sent via load sound model callback */ struct sound_trigger_model_event { int status; /* sound model status e.g. SOUND_MODEL_STATUS_UPDATED */ sound_model_handle_t model; /* loaded sound model that triggered the event */ unsigned int data_size; /* size of event data if any. Size of updated sound model if status is SOUND_MODEL_STATUS_UPDATED */ unsigned int data_offset; /* offset of data start from start of this struct (e.g sizeof struct sound_trigger_model_event) */ }; #endif // ANDROID_SOUND_TRIGGER_H android-headers-23/23/system/thread_defs.h000066400000000000000000000050631264465411000205310ustar00rootroot00000000000000/* * 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_THREAD_DEFS_H #define ANDROID_THREAD_DEFS_H #include "graphics.h" #if defined(__cplusplus) extern "C" { #endif enum { /* * *********************************************** * ** Keep in sync with android.os.Process.java ** * *********************************************** * * This maps directly to the "nice" priorities we use in Android. * A thread priority should be chosen inverse-proportionally to * the amount of work the thread is expected to do. The more work * a thread will do, the less favorable priority it should get so that * it doesn't starve the system. Threads not behaving properly might * be "punished" by the kernel. * Use the levels below when appropriate. Intermediate values are * acceptable, preferably use the {MORE|LESS}_FAVORABLE constants below. */ ANDROID_PRIORITY_LOWEST = 19, /* use for background tasks */ ANDROID_PRIORITY_BACKGROUND = 10, /* most threads run at normal priority */ ANDROID_PRIORITY_NORMAL = 0, /* threads currently running a UI that the user is interacting with */ ANDROID_PRIORITY_FOREGROUND = -2, /* the main UI thread has a slightly more favorable priority */ ANDROID_PRIORITY_DISPLAY = -4, /* ui service treads might want to run at a urgent display (uncommon) */ ANDROID_PRIORITY_URGENT_DISPLAY = HAL_PRIORITY_URGENT_DISPLAY, /* all normal audio threads */ ANDROID_PRIORITY_AUDIO = -16, /* service audio threads (uncommon) */ ANDROID_PRIORITY_URGENT_AUDIO = -19, /* should never be used in practice. regular process might not * be allowed to use this level */ ANDROID_PRIORITY_HIGHEST = -20, ANDROID_PRIORITY_DEFAULT = ANDROID_PRIORITY_NORMAL, ANDROID_PRIORITY_MORE_FAVORABLE = -1, ANDROID_PRIORITY_LESS_FAVORABLE = +1, }; #if defined(__cplusplus) } #endif #endif /* ANDROID_THREAD_DEFS_H */ android-headers-23/23/system/window.h000066400000000000000000001105141264465411000175660ustar00rootroot00000000000000/* * 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 SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H #define SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H #include #include #include #include #include #include #include #include #ifndef __UNUSED #define __UNUSED __attribute__((__unused__)) #endif #ifndef __deprecated #define __deprecated __attribute__((__deprecated__)) #endif __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; // --------------------------------------------------------------------------- /* attributes queriable with query() */ enum { NATIVE_WINDOW_WIDTH = 0, 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, /* Check whether queueBuffer operations on the ANativeWindow send the buffer * to the window compositor. The query sets the returned 'value' argument * to 1 if the ANativeWindow DOES send queued buffers directly to the window * compositor and 0 if the buffers do not go directly to the window * compositor. * * This can be used to determine whether protected buffer content should be * sent to the ANativeWindow. Note, however, that a result of 1 does NOT * indicate that queued buffers will be protected from applications or users * capturing their contents. If that behavior is desired then some other * mechanism (e.g. the GRALLOC_USAGE_PROTECTED flag) should be used in * conjunction with this query. */ NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER = 4, /* Get the concrete type of a ANativeWindow. See below for the list of * possible return values. * * This query should not be used outside the Android framework and will * likely be removed in the near future. */ NATIVE_WINDOW_CONCRETE_TYPE = 5, /* * Default width and height of ANativeWindow buffers, these are the * dimensions of the window buffers irrespective of the * 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, /* * 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, /* * Boolean that indicates whether the consumer is running more than * one buffer behind the producer. */ NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND = 9, /* * 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, /** * Transformation that will by applied to buffers by the hwcomposer. * This must not be set or checked by producer endpoints, and will * disable the transform hint set in SurfaceFlinger (see * NATIVE_WINDOW_TRANSFORM_HINT). * * INTENDED USE: * Temporary - Please do not use this. This is intended only to be used * by the camera's LEGACY mode. * * In situations where a SurfaceFlinger client wishes to set a transform * that is not visible to the producer, and will always be applied in the * hardware composer, the client can set this flag with * native_window_set_buffers_sticky_transform. This can be used to rotate * and flip buffers consumed by hardware composer without actually changing * the aspect ratio of the buffers produced. */ NATIVE_WINDOW_STICKY_TRANSFORM = 11, /** * The default data space for the buffers as set by the consumer. * The values are defined in graphics.h. */ 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, }; /* Valid operations for the (*perform)() hook. * * Values marked as 'deprecated' are supported, but have been superceded by * other functionality. * * Values marked as 'private' should be considered private to the framework. * HAL implementation code with access to an ANativeWindow should not use these, * as it may not interact properly with the framework's use of the * 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 */ }; /* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */ enum { /* Buffers will be queued by EGL via eglSwapBuffers after being filled using * OpenGL ES. */ NATIVE_WINDOW_API_EGL = 1, /* Buffers will be queued after being filled using the CPU */ NATIVE_WINDOW_API_CPU = 2, /* Buffers will be queued by Stagefright after being filled by a video * decoder. The video decoder can either be a software or hardware decoder. */ NATIVE_WINDOW_API_MEDIA = 3, /* Buffers will be queued by the the camera HAL. */ NATIVE_WINDOW_API_CAMERA = 4, }; /* parameter for NATIVE_WINDOW_SET_BUFFERS_TRANSFORM */ enum { /* flip source image horizontally */ NATIVE_WINDOW_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H , /* flip source image vertically */ NATIVE_WINDOW_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V, /* rotate source image 90 degrees clock-wise, and is applied after TRANSFORM_FLIP_{H|V} */ NATIVE_WINDOW_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90, /* rotate source image 180 degrees */ NATIVE_WINDOW_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180, /* rotate source image 270 degrees clock-wise */ NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270, /* transforms source by the inverse transform of the screen it is displayed onto. This * transform is applied last */ NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY = 0x08 }; /* parameter for NATIVE_WINDOW_SET_SCALING_MODE */ enum { /* the window content is not updated (frozen) until a buffer of * the window size is received (enqueued) */ NATIVE_WINDOW_SCALING_MODE_FREEZE = 0, /* the buffer is scaled in both dimensions to match the window size */ NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW = 1, /* the buffer is scaled uniformly such that the smaller dimension * of the buffer matches the window size (cropping in the process) */ NATIVE_WINDOW_SCALING_MODE_SCALE_CROP = 2, /* the window is clipped to the size of the buffer's crop rectangle; pixels * outside the crop rectangle are treated as if they are completely * transparent. */ NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP = 3, }; /* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */ enum { NATIVE_WINDOW_FRAMEBUFFER = 0, /* FramebufferNativeWindow */ NATIVE_WINDOW_SURFACE = 1, /* Surface */ }; /* parameter for NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP * * Special timestamp value to indicate that timestamps should be auto-generated * by the native window when queueBuffer is called. This is equal to INT64_MIN, * defined directly to avoid problems with C99/C++ inclusion of stdint.h. */ static const int64_t NATIVE_WINDOW_TIMESTAMP_AUTO = (-9223372036854775807LL-1); struct ANativeWindow { #ifdef __cplusplus ANativeWindow() : flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0) { common.magic = ANDROID_NATIVE_WINDOW_MAGIC; common.version = sizeof(ANativeWindow); memset(common.reserved, 0, sizeof(common.reserved)); } /* Implement the methods that sp expects so that it can be used to automatically refcount ANativeWindow'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; /* flags describing some attributes of this surface or its updater */ const uint32_t flags; /* min swap interval supported by this updated */ const int minSwapInterval; /* max swap interval supported by this updated */ const int maxSwapInterval; /* horizontal and vertical resolution in DPI */ const float xdpi; const float ydpi; /* Some storage reserved for the OEM's driver. */ intptr_t oem[4]; /* * Set the swap interval for this surface. * * Returns 0 on success or -errno on error. */ int (*setSwapInterval)(struct ANativeWindow* window, int interval); /* * Hook called by EGL to acquire a buffer. After this call, the buffer * is not locked, so its content cannot be modified. 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. * * Returns 0 on success or -errno on error. * * XXX: This function is deprecated. It will continue to work for some * time for binary compatibility, but the new dequeueBuffer function that * outputs a fence file descriptor should be used in its place. */ int (*dequeueBuffer_DEPRECATED)(struct ANativeWindow* window, struct ANativeWindowBuffer** buffer); /* * hook called by EGL to lock a buffer. This MUST be called before modifying * the content of a buffer. The buffer must have been acquired with * dequeueBuffer first. * * Returns 0 on success or -errno on error. * * XXX: This function is deprecated. It will continue to work for some * time for binary compatibility, but it is essentially a no-op, and calls * to it should be removed. */ int (*lockBuffer_DEPRECATED)(struct ANativeWindow* window, struct ANativeWindowBuffer* buffer); /* * 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. * * Buffers MUST be queued in the same order than they were dequeued. * * Returns 0 on success or -errno on error. * * XXX: This function is deprecated. It will continue to work for some * time for binary compatibility, but the new queueBuffer function that * takes a fence file descriptor should be used in its place (pass a value * of -1 for the fence file descriptor if there is no valid one to pass). */ int (*queueBuffer_DEPRECATED)(struct ANativeWindow* window, struct ANativeWindowBuffer* buffer); /* * hook used to retrieve information about the native window. * * Returns 0 on success or -errno on error. */ int (*query)(const struct ANativeWindow* window, int what, int* value); /* * hook used to perform various operations on the surface. * (*perform)() is a generic mechanism to add functionality to * ANativeWindow while keeping backward binary compatibility. * * DO NOT CALL THIS HOOK DIRECTLY. Instead, use the helper functions * defined below. * * (*perform)() returns -ENOENT if the 'what' parameter is not supported * by the surface's implementation. * * See above for a list of valid operations, such as * NATIVE_WINDOW_SET_USAGE or NATIVE_WINDOW_CONNECT */ int (*perform)(struct ANativeWindow* window, int operation, ... ); /* * 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. * * XXX: This function is deprecated. It will continue to work for some * time for binary compatibility, but the new cancelBuffer function that * takes a fence file descriptor should be used in its place (pass a value * of -1 for the fence file descriptor if there is no valid one to pass). */ int (*cancelBuffer_DEPRECATED)(struct ANativeWindow* window, struct ANativeWindowBuffer* buffer); /* * 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 (*dequeueBuffer)(struct ANativeWindow* window, struct 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 (*queueBuffer)(struct ANativeWindow* window, struct 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 (*cancelBuffer)(struct ANativeWindow* window, struct ANativeWindowBuffer* buffer, int fenceFd); }; /* 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) * 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. * 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); } /* deprecated. Always returns 0. Don't call. */ static inline int native_window_connect( struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated; static inline int native_window_connect( struct ANativeWindow* window __UNUSED, int api __UNUSED) { return 0; } /* deprecated. Always returns 0. Don't call. */ static inline int native_window_disconnect( struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated; static inline int native_window_disconnect( struct ANativeWindow* window __UNUSED, int api __UNUSED) { return 0; } /* * native_window_set_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 * pre-transformed buffer 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_crop( struct ANativeWindow* window, android_native_rect_t const * 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. */ static inline int native_window_set_buffer_count( struct ANativeWindow* window, size_t bufferCount) { return window->perform(window, NATIVE_WINDOW_SET_BUFFER_COUNT, bufferCount); } /* * native_window_set_buffers_geometry(..., int w, int h, int format) * All buffers dequeued after this call will have the dimensions and format * specified. A successful call to this function has the same effect as calling * native_window_set_buffers_size and native_window_set_buffers_format. * * XXX: This function is deprecated. The native_window_set_buffers_dimensions * and native_window_set_buffers_format functions should be used instead. */ static inline int native_window_set_buffers_geometry( struct ANativeWindow* window, int w, int h, int format) __deprecated; static inline int native_window_set_buffers_geometry( struct ANativeWindow* window, int w, int h, int format) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY, w, h, format); } /* * native_window_set_buffers_dimensions(..., int w, int h) * 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. */ static inline int native_window_set_buffers_dimensions( struct ANativeWindow* window, int w, int h) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS, w, h); } /* * native_window_set_buffers_user_dimensions(..., int w, int h) * * Sets the user buffer size for the window, which overrides the * window's size. All buffers dequeued after this call will have the * dimensions specified unless overridden by * native_window_set_buffers_dimensions. 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, the * default buffer size will match the windows's size. * * Calling this function will reset the window crop to a NULL value, which * disables cropping of the buffers. */ static inline int native_window_set_buffers_user_dimensions( struct ANativeWindow* window, int w, int h) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS, w, h); } /* * native_window_set_buffers_format(..., int format) * All buffers dequeued after this call will have the format specified. * * If the specified format is 0, the default buffer format will be used. */ static inline int native_window_set_buffers_format( struct ANativeWindow* window, int format) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_FORMAT, format); } /* * native_window_set_buffers_data_space(..., int dataSpace) * All buffers queued after this call will be associated with the dataSpace * parameter specified. * * dataSpace specifies additional information about the buffer that's dependent * on the buffer format and the endpoints. 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, HAL_DATASPACE_UNKNOWN, unless it has been * overridden by the consumer. */ static inline int native_window_set_buffers_data_space( struct ANativeWindow* window, android_dataspace_t dataSpace) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DATASPACE, dataSpace); } /* * native_window_set_buffers_transform(..., int transform) * All buffers queued after this call will be displayed transformed according * to the transform parameter specified. */ static inline int native_window_set_buffers_transform( struct ANativeWindow* window, int transform) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TRANSFORM, transform); } /* * native_window_set_buffers_sticky_transform(..., int transform) * All buffers queued after this call will be displayed transformed according * to the transform parameter specified applied on top of the regular buffer * transform. Setting this transform will disable the transform hint. * * Temporary - This is only intended to be used by the LEGACY camera mode, do * not use this for anything else. */ static inline int native_window_set_buffers_sticky_transform( struct ANativeWindow* window, int transform) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM, transform); } /* * native_window_set_buffers_timestamp(..., int64_t timestamp) * All buffers queued after this call will be associated with the timestamp * 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. */ static inline int native_window_set_buffers_timestamp( struct ANativeWindow* window, int64_t timestamp) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP, timestamp); } /* * native_window_set_scaling_mode(..., int mode) * All buffers queued after this call will be associated with the scaling mode * specified. */ static inline int native_window_set_scaling_mode( struct ANativeWindow* window, int mode) { return window->perform(window, NATIVE_WINDOW_SET_SCALING_MODE, mode); } /* * native_window_api_connect(..., int api) * connects an API to this window. only one API can be connected at a time. * Returns -EINVAL if for some reason the window cannot be connected, which * can happen if it's connected to some other API. */ static inline int native_window_api_connect( struct ANativeWindow* window, int api) { return window->perform(window, NATIVE_WINDOW_API_CONNECT, api); } /* * native_window_api_disconnect(..., int api) * disconnect the API from this window. * An error is returned if for instance the window wasn't connected in the * first place. */ static inline int native_window_api_disconnect( struct ANativeWindow* window, int api) { return window->perform(window, NATIVE_WINDOW_API_DISCONNECT, api); } /* * native_window_dequeue_buffer_and_wait(...) * Dequeue a buffer and wait on the fence associated with that buffer. The * buffer may safely be accessed immediately upon this function returning. An * error is returned if either of the dequeue or the wait operations fail. */ static inline int native_window_dequeue_buffer_and_wait(ANativeWindow *anw, struct ANativeWindowBuffer** anb) { return anw->dequeueBuffer_DEPRECATED(anw, anb); } /* * native_window_set_sideband_stream(..., native_handle_t*) * Attach a sideband buffer stream to a native window. */ static inline int native_window_set_sideband_stream( struct ANativeWindow* window, native_handle_t* sidebandHandle) { return window->perform(window, NATIVE_WINDOW_SET_SIDEBAND_STREAM, sidebandHandle); } /* * native_window_set_surface_damage(..., android_native_rect_t* rects, int numRects) * Set the surface damage (i.e., the region of the surface that has changed * since the previous frame). The damage set by this call will be reset (to the * default of full-surface damage) after calling queue, so this must be called * prior to every frame with damage that does not cover the whole surface if the * caller desires downstream consumers to use this optimization. * * The damage region is specified as an array of rectangles, with the important * caveat that the origin of the surface is considered to be the bottom-left * corner, as in OpenGL ES. * * If numRects is set to 0, rects may be NULL, and the surface damage will be * set to the full surface (the same as if this function had not been called for * this frame). */ static inline int native_window_set_surface_damage( struct ANativeWindow* window, const android_native_rect_t* rects, size_t numRects) { return window->perform(window, NATIVE_WINDOW_SET_SURFACE_DAMAGE, rects, numRects); } __END_DECLS #endif /* SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H */