answer
stringlengths
15
1.25M
/** \addtogroup frameworks */ #ifndef UNITY_INTERNALS_H #define UNITY_INTERNALS_H #ifdef <API key> #include "unity_config.h" #endif #include <setjmp.h> /* Unity Attempts to Auto-Detect Integer Types * Attempt 1: UINT_MAX, ULONG_MAX, etc in <stdint.h> * Attempt 2: UINT_MAX, ULONG_MAX, etc in <limits.h> * Attempt 3: Deduced from sizeof() macros */ #ifndef <API key> #include <stdint.h> #endif #ifndef <API key> #include <limits.h> #endif #ifndef <API key> #ifndef UINT_MAX #define UINT_MAX (sizeof(unsigned int) * 256 - 1) #endif #ifndef ULONG_MAX #define ULONG_MAX (sizeof(unsigned long) * 256 - 1) #endif #ifndef UINTPTR_MAX /* apparently this is not a constant expression: (sizeof(unsigned int *) * 256 - 1) so we have to just let this fall through */ #endif #endif #ifndef <API key> #include <math.h> #endif /* Determine the size of an int, if not already specificied. * We cannot use sizeof(int), because it is not yet defined * at this stage in the trnslation of the C program. * Therefore, infer it from UINT_MAX if possible. */ #ifndef UNITY_INT_WIDTH #ifdef UINT_MAX #if (UINT_MAX == 0xFFFF) #define UNITY_INT_WIDTH (16) #elif (UINT_MAX == 0xFFFFFFFF) #define UNITY_INT_WIDTH (32) #elif (UINT_MAX == 0xFFFFFFFFFFFFFFFF) #define UNITY_INT_WIDTH (64) #endif #endif #endif #ifndef UNITY_INT_WIDTH #define UNITY_INT_WIDTH (32) #endif /* Determine the size of a long, if not already specified, * by following the process used above to define * UNITY_INT_WIDTH. */ #ifndef UNITY_LONG_WIDTH #ifdef ULONG_MAX #if (ULONG_MAX == 0xFFFF) #define UNITY_LONG_WIDTH (16) #elif (ULONG_MAX == 0xFFFFFFFF) #define UNITY_LONG_WIDTH (32) #elif (ULONG_MAX == 0xFFFFFFFFFFFFFFFF) #define UNITY_LONG_WIDTH (64) #endif #endif #endif #ifndef UNITY_LONG_WIDTH #define UNITY_LONG_WIDTH (32) #endif /* Determine the size of a pointer, if not already specified, * by following the process used above to define * UNITY_INT_WIDTH. */ #ifndef UNITY_POINTER_WIDTH #ifdef UINTPTR_MAX #if (UINTPTR_MAX+0 <= 0xFFFF) #define UNITY_POINTER_WIDTH (16) #elif (UINTPTR_MAX+0 <= 0xFFFFFFFF) #define UNITY_POINTER_WIDTH (32) #elif (UINTPTR_MAX+0 <= 0xFFFFFFFFFFFFFFFF) #define UNITY_POINTER_WIDTH (64) #endif #endif #endif #ifndef UNITY_POINTER_WIDTH #ifdef INTPTR_MAX #if (INTPTR_MAX+0 <= 0x7FFF) #define UNITY_POINTER_WIDTH (16) #elif (INTPTR_MAX+0 <= 0x7FFFFFFF) #define UNITY_POINTER_WIDTH (32) #elif (INTPTR_MAX+0 <= 0x7FFFFFFFFFFFFFFF) #define UNITY_POINTER_WIDTH (64) #endif #endif #endif #ifndef UNITY_POINTER_WIDTH #define UNITY_POINTER_WIDTH UNITY_LONG_WIDTH #endif #if (UNITY_INT_WIDTH == 32) typedef unsigned char _UU8; typedef unsigned short _UU16; typedef unsigned int _UU32; typedef signed char _US8; typedef signed short _US16; typedef signed int _US32; #elif (UNITY_INT_WIDTH == 16) typedef unsigned char _UU8; typedef unsigned int _UU16; typedef unsigned long _UU32; typedef signed char _US8; typedef signed int _US16; typedef signed long _US32; #else #error Invalid UNITY_INT_WIDTH specified! (16 or 32 are supported) #endif #ifndef UNITY_SUPPORT_64 #if UNITY_LONG_WIDTH > 32 #define UNITY_SUPPORT_64 #endif #endif #ifndef UNITY_SUPPORT_64 #if UNITY_POINTER_WIDTH > 32 #define UNITY_SUPPORT_64 #endif #endif #ifndef UNITY_SUPPORT_64 /* No 64-bit Support */ typedef _UU32 _U_UINT; typedef _US32 _U_SINT; #else /* 64-bit Support */ #if (UNITY_LONG_WIDTH == 32) typedef unsigned long long _UU64; typedef signed long long _US64; #elif (UNITY_LONG_WIDTH == 64) typedef unsigned long _UU64; typedef signed long _US64; #else #error Invalid UNITY_LONG_WIDTH specified! (32 or 64 are supported) #endif typedef _UU64 _U_UINT; typedef _US64 _U_SINT; #endif #if (UNITY_POINTER_WIDTH == 32) typedef _UU32 _UP; #define <API key> <API key> #elif (UNITY_POINTER_WIDTH == 64) typedef _UU64 _UP; #define <API key> <API key> #elif (UNITY_POINTER_WIDTH == 16) typedef _UU16 _UP; #define <API key> <API key> #else #error Invalid UNITY_POINTER_WIDTH specified! (16, 32 or 64 are supported) #endif #ifndef UNITY_PTR_ATTRIBUTE #define UNITY_PTR_ATTRIBUTE #endif #ifndef UNITY_INTERNAL_PTR #define UNITY_INTERNAL_PTR UNITY_PTR_ATTRIBUTE const void* /* #define UNITY_INTERNAL_PTR UNITY_PTR_ATTRIBUTE const _UU8* */ #endif #ifdef UNITY_EXCLUDE_FLOAT /* No Floating Point Support */ #undef UNITY_INCLUDE_FLOAT #undef <API key> #undef UNITY_FLOAT_TYPE #undef UNITY_FLOAT_VERBOSE #else #ifndef UNITY_INCLUDE_FLOAT #define UNITY_INCLUDE_FLOAT #endif /* Floating Point Support */ #ifndef <API key> #define <API key> (0.00001f) #endif #ifndef UNITY_FLOAT_TYPE #define UNITY_FLOAT_TYPE float #endif typedef UNITY_FLOAT_TYPE _UF; #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) #else #ifndef isinf #define isinf(n) (((1.0f / f_zero) == n) ? 1 : 0) || (((-1.0f / f_zero) == n) ? 1 : 0) #define <API key> #endif #ifndef isnan #define isnan(n) ((n != n) ? 1 : 0) #endif #endif /* ARMC6 */ #ifndef isneg #define isneg(n) ((n < 0.0f) ? 1 : 0) #endif #ifndef ispos #define ispos(n) ((n > 0.0f) ? 1 : 0) #endif #endif /* unlike FLOAT, we DON'T include by default */ #ifndef <API key> #ifndef <API key> #define <API key> #endif #endif #ifdef <API key> /* No Floating Point Support */ #undef <API key> #undef UNITY_DOUBLE_TYPE #undef <API key> #ifdef <API key> #undef <API key> #endif #else /* Double Floating Point Support */ #ifndef <API key> #define <API key> (1e-12f) #endif #ifndef UNITY_DOUBLE_TYPE #define UNITY_DOUBLE_TYPE double #endif typedef UNITY_DOUBLE_TYPE _UD; #endif #ifdef <API key> #ifndef UNITY_FLOAT_VERBOSE #define UNITY_FLOAT_VERBOSE #endif #endif #ifndef UNITY_OUTPUT_CHAR /* Default to using putchar, which is defined in stdio.h */ #include <stdio.h> #define UNITY_OUTPUT_CHAR(a) (void)putchar(a) #else /* If defined as something else, make sure we declare it here so it's ready for use */ #ifndef <API key> extern void UNITY_OUTPUT_CHAR(int); #endif #endif #ifndef UNITY_OUTPUT_FLUSH /* Default to using putchar, which is defined in stdio.h */ #include <stdio.h> #define UNITY_OUTPUT_FLUSH() (void)fflush(stdout) #else /* If defined as something else, make sure we declare it here so it's ready for use */ #ifndef <API key> extern void UNITY_OUTPUT_FLUSH(void); #endif #endif #ifndef UNITY_PRINT_EOL #define UNITY_PRINT_EOL() UNITY_OUTPUT_CHAR('\n') #endif #ifndef UNITY_OUTPUT_START #define UNITY_OUTPUT_START() #endif #ifndef <API key> #define <API key>() #endif #ifndef UNITY_LINE_TYPE #define UNITY_LINE_TYPE _U_UINT #endif #ifndef UNITY_COUNTER_TYPE #define UNITY_COUNTER_TYPE _U_UINT #endif #if !defined(<API key>) && !defined(UNITY_WEAK_PRAGMA) # ifdef __GNUC__ /* includes clang */ # if !(defined(__WIN32__) && defined(__clang__)) # define <API key> __attribute__((weak)) # endif # endif #endif #ifdef UNITY_NO_WEAK # undef <API key> # undef UNITY_WEAK_PRAGMA #endif typedef void (*UnityTestFunction)(void); #define <API key> (0x10) #define <API key> (0x20) #define <API key> (0x40) #define <API key> (0x80) typedef enum { #if (UNITY_INT_WIDTH == 16) <API key> = 2 + <API key> + <API key>, #elif (UNITY_INT_WIDTH == 32) <API key> = 4 + <API key> + <API key>, #elif (UNITY_INT_WIDTH == 64) <API key> = 8 + <API key> + <API key>, #endif <API key> = 1 + <API key>, <API key> = 2 + <API key>, <API key> = 4 + <API key>, #ifdef UNITY_SUPPORT_64 <API key> = 8 + <API key>, #endif #if (UNITY_INT_WIDTH == 16) <API key> = 2 + <API key> + <API key>, #elif (UNITY_INT_WIDTH == 32) <API key> = 4 + <API key> + <API key>, #elif (UNITY_INT_WIDTH == 64) <API key> = 8 + <API key> + <API key>, #endif <API key> = 1 + <API key>, <API key> = 2 + <API key>, <API key> = 4 + <API key>, #ifdef UNITY_SUPPORT_64 <API key> = 8 + <API key>, #endif <API key> = 1 + <API key>, <API key> = 2 + <API key>, <API key> = 4 + <API key>, #ifdef UNITY_SUPPORT_64 <API key> = 8 + <API key>, #endif <API key> } <API key>; #ifndef UNITY_EXCLUDE_FLOAT typedef enum <API key> { <API key> = 0, UNITY_FLOAT_IS_INF, <API key>, <API key>, <API key>, UNITY_FLOAT_IS_NAN, <API key>, UNITY_FLOAT_IS_DET, <API key> } UNITY_FLOAT_TRAIT_T; #endif struct _Unity { const char* TestFile; const char* CurrentTestName; #ifndef <API key> const char* CurrentDetail1; const char* CurrentDetail2; #endif UNITY_LINE_TYPE <API key>; UNITY_COUNTER_TYPE NumberOfTests; UNITY_COUNTER_TYPE TestFailures; UNITY_COUNTER_TYPE TestIgnores; UNITY_COUNTER_TYPE CurrentTestFailed; UNITY_COUNTER_TYPE CurrentTestIgnored; jmp_buf AbortFrame; }; extern struct _Unity Unity; #ifdef __cplusplus extern "C" { #endif void UnityBegin(const char* filename); int UnityEnd(void); void UnityConcludeTest(void); void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum); #ifdef <API key> #define UNITY_CLR_DETAILS() #define UNITY_SET_DETAIL(d1) #define UNITY_SET_DETAILS(d1,d2) #else #define UNITY_CLR_DETAILS() { Unity.CurrentDetail1 = 0; Unity.CurrentDetail2 = 0; } #define UNITY_SET_DETAIL(d1) { Unity.CurrentDetail1 = d1; Unity.CurrentDetail2 = 0; } #define UNITY_SET_DETAILS(d1,d2) { Unity.CurrentDetail1 = d1; Unity.CurrentDetail2 = d2; } #ifndef UNITY_DETAIL1_NAME #define UNITY_DETAIL1_NAME "Function" #endif #ifndef UNITY_DETAIL2_NAME #define UNITY_DETAIL2_NAME "Argument" #endif #endif void UnityPrint(const char* string); void UnityPrintMask(const _U_UINT mask, const _U_UINT number); void <API key>(const _U_SINT number, const <API key> style); void UnityPrintNumber(const _U_SINT number); void <API key>(const _U_UINT number); void UnityPrintNumberHex(const _U_UINT number, const char nibbles); #ifdef UNITY_FLOAT_VERBOSE void UnityPrintFloat(const _UF number); #endif void <API key>(const _U_SINT expected, const _U_SINT actual, const char* msg, const UNITY_LINE_TYPE lineNumber, const <API key> style); void <API key>(UNITY_INTERNAL_PTR expected, UNITY_INTERNAL_PTR actual, const _UU32 num_elements, const char* msg, const UNITY_LINE_TYPE lineNumber, const <API key> style); void UnityAssertBits(const _U_SINT mask, const _U_SINT expected, const _U_SINT actual, const char* msg, const UNITY_LINE_TYPE lineNumber); void <API key>(const char* expected, const char* actual, const char* msg, const UNITY_LINE_TYPE lineNumber); void <API key>(const char* expected, const char* actual, const _UU32 length, const char* msg, const UNITY_LINE_TYPE lineNumber); void <API key>( const char** expected, const char** actual, const _UU32 num_elements, const char* msg, const UNITY_LINE_TYPE lineNumber); void <API key>( UNITY_INTERNAL_PTR expected, UNITY_INTERNAL_PTR actual, const _UU32 length, const _UU32 num_elements, const char* msg, const UNITY_LINE_TYPE lineNumber); void <API key>(const _U_UINT delta, const _U_SINT expected, const _U_SINT actual, const char* msg, const UNITY_LINE_TYPE lineNumber, const <API key> style); void UnityFail(const char* message, const UNITY_LINE_TYPE line); void UnityIgnore(const char* message, const UNITY_LINE_TYPE line); #ifndef UNITY_EXCLUDE_FLOAT void <API key>(const _UF delta, const _UF expected, const _UF actual, const char* msg, const UNITY_LINE_TYPE lineNumber); void <API key>(UNITY_PTR_ATTRIBUTE const _UF* expected, UNITY_PTR_ATTRIBUTE const _UF* actual, const _UU32 num_elements, const char* msg, const UNITY_LINE_TYPE lineNumber); void <API key>(const _UF actual, const char* msg, const UNITY_LINE_TYPE lineNumber, const UNITY_FLOAT_TRAIT_T style); #endif #ifndef <API key> void <API key>(const _UD delta, const _UD expected, const _UD actual, const char* msg, const UNITY_LINE_TYPE lineNumber); void <API key>(UNITY_PTR_ATTRIBUTE const _UD* expected, UNITY_PTR_ATTRIBUTE const _UD* actual, const _UU32 num_elements, const char* msg, const UNITY_LINE_TYPE lineNumber); void <API key>(const _UD actual, const char* msg, const UNITY_LINE_TYPE lineNumber, const UNITY_FLOAT_TRAIT_T style); #endif #ifdef __cplusplus } #endif // __cplusplus extern const char UnityStrErrFloat[]; extern const char UnityStrErrDouble[]; extern const char UnityStrErr64[]; #define TEST_PROTECT() (setjmp(Unity.AbortFrame) == 0) #define TEST_ABORT() {longjmp(Unity.AbortFrame, 1);} /* This tricky series of macros gives us an optional line argument to treat it as RUN_TEST(func, num=__LINE__) */ #ifndef RUN_TEST #ifdef __STDC_VERSION__ #if __STDC_VERSION__ >= 199901L #define RUN_TEST(...) UnityDefaultTestRun(RUN_TEST_FIRST(__VA_ARGS__), RUN_TEST_SECOND(__VA_ARGS__)) #define RUN_TEST_FIRST(...) <API key>(__VA_ARGS__, throwaway) #define <API key>(first, ...) (first), #first #define RUN_TEST_SECOND(...) <API key>(__VA_ARGS__, __LINE__, throwaway) #define <API key>(first, second, ...) (second) #endif #endif #endif /* If we can't do the tricky version, we'll just have to require them to always include the line number */ #ifndef RUN_TEST #ifdef CMOCK #define RUN_TEST(func, num) UnityDefaultTestRun(func, #func, num) #else #define RUN_TEST(func) UnityDefaultTestRun(func, #func, __LINE__) #endif #endif #define TEST_LINE_NUM (Unity.<API key>) #define TEST_IS_IGNORED (Unity.CurrentTestIgnored) #define UNITY_NEW_TEST(a) \ Unity.CurrentTestName = (a); \ Unity.<API key> = (UNITY_LINE_TYPE)(__LINE__); \ Unity.NumberOfTests++; #ifndef UNITY_BEGIN #define UNITY_BEGIN() UnityBegin(__FILE__) #endif #ifndef UNITY_END #define UNITY_END() UnityEnd() #endif #define UNITY_UNUSED(x) (void)(sizeof(x)) #define UNITY_TEST_FAIL(line, message) UnityFail( (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_IGNORE(line, message) UnityIgnore( (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_ASSERT(condition, line, message) if (condition) {} else {UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), (message));} #define <API key>(pointer, line, message) UNITY_TEST_ASSERT(((pointer) == NULL), (UNITY_LINE_TYPE)(line), (message)) #define <API key>(pointer, line, message) UNITY_TEST_ASSERT(((pointer) != NULL), (UNITY_LINE_TYPE)(line), (message)) #define <API key>(expected, actual, line, message) <API key>((_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(expected, actual, line, message) <API key>((_U_SINT)(_US8 )(expected), (_U_SINT)(_US8 )(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(expected, actual, line, message) <API key>((_U_SINT)(_US16)(expected), (_U_SINT)(_US16)(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(expected, actual, line, message) <API key>((_U_SINT)(_US32)(expected), (_U_SINT)(_US32)(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(expected, actual, line, message) <API key>((_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(expected, actual, line, message) <API key>((_U_SINT)(_UU8 )(expected), (_U_SINT)(_UU8 )(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(expected, actual, line, message) <API key>((_U_SINT)(_UU16)(expected), (_U_SINT)(_UU16)(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(expected, actual, line, message) <API key>((_U_SINT)(_UU32)(expected), (_U_SINT)(_UU32)(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(expected, actual, line, message) <API key>((_U_SINT)(_US8 )(expected), (_U_SINT)(_US8 )(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(expected, actual, line, message) <API key>((_U_SINT)(_US16)(expected), (_U_SINT)(_US16)(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(expected, actual, line, message) <API key>((_U_SINT)(_US32)(expected), (_U_SINT)(_US32)(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(mask, expected, actual, line, message) UnityAssertBits((_U_SINT)(mask), (_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)(line)) #define <API key>(delta, expected, actual, line, message) <API key>((delta), (_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(delta, expected, actual, line, message) <API key>((_UU8 )(delta), (_U_SINT)(_US8 )(expected), (_U_SINT)(_US8 )(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(delta, expected, actual, line, message) <API key>((_UU16)(delta), (_U_SINT)(_US16)(expected), (_U_SINT)(_US16)(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(delta, expected, actual, line, message) <API key>((_UU32)(delta), (_U_SINT)(_US32)(expected), (_U_SINT)(_US32)(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(delta, expected, actual, line, message) <API key>((delta), (_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(delta, expected, actual, line, message) <API key>((_UU8 )(delta), (_U_SINT)(_U_UINT)(_UU8 )(expected), (_U_SINT)(_U_UINT)(_UU8 )(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(delta, expected, actual, line, message) <API key>((_UU16)(delta), (_U_SINT)(_U_UINT)(_UU16)(expected), (_U_SINT)(_U_UINT)(_UU16)(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(delta, expected, actual, line, message) <API key>((_UU32)(delta), (_U_SINT)(_U_UINT)(_UU32)(expected), (_U_SINT)(_U_UINT)(_UU32)(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(delta, expected, actual, line, message) <API key>((_UU8 )(delta), (_U_SINT)(_U_UINT)(_UU8 )(expected), (_U_SINT)(_U_UINT)(_UU8 )(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(delta, expected, actual, line, message) <API key>((_UU16)(delta), (_U_SINT)(_U_UINT)(_UU16)(expected), (_U_SINT)(_U_UINT)(_UU16)(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(delta, expected, actual, line, message) <API key>((_UU32)(delta), (_U_SINT)(_U_UINT)(_UU32)(expected), (_U_SINT)(_U_UINT)(_UU32)(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(expected, actual, line, message) <API key>((_U_SINT)(_UP)(expected), (_U_SINT)(_UP)(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(expected, actual, line, message) <API key>((const char*)(expected), (const char*)(actual), (message), (UNITY_LINE_TYPE)(line)) #define <API key>(expected, actual, len, line, message) <API key>((const char*)(expected), (const char*)(actual), (_UU32)(len), (message), (UNITY_LINE_TYPE)(line)) #define <API key>(expected, actual, len, line, message) <API key>((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (_UU32)(len), 1, (message), (UNITY_LINE_TYPE)(line)) #define <API key>(expected, actual, num_elements, line, message) <API key>((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(expected, actual, num_elements, line, message) <API key>((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(expected, actual, num_elements, line, message) <API key>((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(expected, actual, num_elements, line, message) <API key>((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(expected, actual, num_elements, line, message) <API key>((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(expected, actual, num_elements, line, message) <API key>((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(expected, actual, num_elements, line, message) <API key>((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(expected, actual, num_elements, line, message) <API key>((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(expected, actual, num_elements, line, message) <API key>((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(expected, actual, num_elements, line, message) <API key>((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(expected, actual, num_elements, line, message) <API key>((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(expected, actual, num_elements, line, message) <API key>((UNITY_INTERNAL_PTR)(_UP*)(expected), (UNITY_INTERNAL_PTR)(_UP*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(expected, actual, num_elements, line, message) <API key>((const char**)(expected), (const char**)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)(line)) #define <API key>(expected, actual, len, num_elements, line, message) <API key>((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (_UU32)(len), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)(line)) #ifdef UNITY_SUPPORT_64 #define <API key>(expected, actual, line, message) <API key>((_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(expected, actual, line, message) <API key>((_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(expected, actual, line, message) <API key>((_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(expected, actual, num_elements, line, message) <API key>((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(expected, actual, num_elements, line, message) <API key>((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(expected, actual, num_elements, line, message) <API key>((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(delta, expected, actual, line, message) <API key>((delta), (_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(delta, expected, actual, line, message) <API key>((delta), (_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(delta, expected, actual, line, message) <API key>((delta), (_U_SINT)(expected), (_U_SINT)(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #else #define <API key>(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define <API key>(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define <API key>(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define <API key>(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define <API key>(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define <API key>(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define <API key>(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define <API key>(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define <API key>(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #endif #ifdef UNITY_EXCLUDE_FLOAT #define <API key>(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define <API key>(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define <API key>(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define <API key>(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define <API key>(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define <API key>(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define <API key>(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define <API key>(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define <API key>(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define <API key>(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define <API key>(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #else #define <API key>(delta, expected, actual, line, message) <API key>((_UF)(delta), (_UF)(expected), (_UF)(actual), (message), (UNITY_LINE_TYPE)(line)) #define <API key>(expected, actual, line, message) <API key>((_UF)(expected) * (_UF)<API key>, (_UF)(expected), (_UF)(actual), (UNITY_LINE_TYPE)(line), (message)) #define <API key>(expected, actual, num_elements, line, message) <API key>((_UF*)(expected), (_UF*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)(line)) #define <API key>(actual, line, message) <API key>((_UF)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_INF) #define <API key>(actual, line, message) <API key>((_UF)(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(actual, line, message) <API key>((_UF)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NAN) #define <API key>(actual, line, message) <API key>((_UF)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_DET) #define <API key>(actual, line, message) <API key>((_UF)(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(actual, line, message) <API key>((_UF)(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(actual, line, message) <API key>((_UF)(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(actual, line, message) <API key>((_UF)(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #endif #ifdef <API key> #define <API key>(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define <API key>(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define <API key>(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define <API key>(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define <API key>(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define <API key>(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define <API key>(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define <API key>(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define <API key>(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define <API key>(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define <API key>(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #else #define <API key>(delta, expected, actual, line, message) <API key>((_UD)(delta), (_UD)(expected), (_UD)(actual), (message), (UNITY_LINE_TYPE)line) #define <API key>(expected, actual, line, message) <API key>((_UD)(expected) * (_UD)<API key>, (_UD)expected, (_UD)actual, (UNITY_LINE_TYPE)(line), message) #define <API key>(expected, actual, num_elements, line, message) <API key>((_UD*)(expected), (_UD*)(actual), (_UU32)(num_elements), (message), (UNITY_LINE_TYPE)line) #define <API key>(actual, line, message) <API key>((_UD)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_INF) #define <API key>(actual, line, message) <API key>((_UD)(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(actual, line, message) <API key>((_UD)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NAN) #define <API key>(actual, line, message) <API key>((_UD)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_DET) #define <API key>(actual, line, message) <API key>((_UD)(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(actual, line, message) <API key>((_UD)(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(actual, line, message) <API key>((_UD)(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #define <API key>(actual, line, message) <API key>((_UD)(actual), (message), (UNITY_LINE_TYPE)(line), <API key>) #endif /* End of UNITY_INTERNALS_H */ #endif
#ifndef <API key> #define <API key> #include <string> #include "base/bind.h" #include "base/bind_helpers.h" #include "base/callback.h" #include "base/strings/string16.h" #include "chrome/browser/ui/webui/chromeos/login/<API key>.h" #include "content/public/browser/web_ui.h" #include "content/public/browser/<API key>.h" #include "ui/gfx/native_widget_types.h" namespace base { class DictionaryValue; class ListValue; class Value; } namespace chromeos { // Class that collects Localized Values for translation. class <API key> { public: explicit <API key>(base::DictionaryValue* dict); // Method to declare localized value. |key| is the i18n key used in html. // |message| is text of the message. void Add(const std::string& key, const std::string& message); // Method to declare localized value. |key| is the i18n key used in html. // |message| is text of the message. void Add(const std::string& key, const string16& message); // Method to declare localized value. |key| is the i18n key used in html. // |message_id| is a resource id of message. void Add(const std::string& key, int message_id); // Method to declare localized value. |key| is the i18n key used in html. // |message_id| is a resource id of message. Message is expected to have // one format parameter subsituted by |a|. void AddF(const std::string& key, int message_id, const string16& a); // Method to declare localized value. |key| is the i18n key used in html. // |message_id| is a resource id of message. Message is expected to have // two format parameters subsituted by |a| and |b| respectively. void AddF(const std::string& key, int message_id, const string16& a, const string16& b); // Method to declare localized value. |key| is the i18n key used in html. // |message_id| is a resource id of message. Message is expected to have // one format parameter subsituted by resource identified by |message_id_a|. void AddF(const std::string& key, int message_id, int message_id_a); // Method to declare localized value. |key| is the i18n key used in html. // |message_id| is a resource id of message. Message is expected to have // two format parameters subsituted by resource identified by |message_id_a| // and |message_id_b| respectively. void AddF(const std::string& key, int message_id, int message_id_a, int message_id_b); private: // Not owned. base::DictionaryValue* dict_; }; // Base class for the OOBE/Login WebUI handlers. class BaseScreenHandler : public content::WebUIMessageHandler { public: // C-tor used when JS screen prefix is not needed. BaseScreenHandler(); // C-tor used when JS screen prefix is needed. explicit BaseScreenHandler(const std::string& js_screen_path); virtual ~BaseScreenHandler(); // Gets localized strings to be used on the page. void GetLocalizedStrings( base::DictionaryValue* localized_strings); // This method is called when page is ready. It propagates to inherited class // via virtual Initialize() method (see below). void InitializeBase(); protected: // All subclasses should implement this method to provide localized values. virtual void <API key>(<API key>* builder) = 0; // Subclasses can override these methods to pass additional parameters // to loadTimeData. Generally, it is a bad approach, and it should be replaced // with Context at some point. virtual void <API key>(base::DictionaryValue* parameters); // Shortcut for calling JS methods on WebUI side. void CallJS(const std::string& method); template<typename A1> void CallJS(const std::string& method, const A1& arg1) { web_ui()-><API key>(FullMethodPath(method), MakeValue(arg1)); } template<typename A1, typename A2> void CallJS(const std::string& method, const A1& arg1, const A2& arg2) { web_ui()-><API key>(FullMethodPath(method), MakeValue(arg1), MakeValue(arg2)); } template<typename A1, typename A2, typename A3> void CallJS(const std::string& method, const A1& arg1, const A2& arg2, const A3& arg3) { web_ui()-><API key>(FullMethodPath(method), MakeValue(arg1), MakeValue(arg2), MakeValue(arg3)); } template<typename A1, typename A2, typename A3, typename A4> void CallJS(const std::string& method, const A1& arg1, const A2& arg2, const A3& arg3, const A4& arg4) { web_ui()-><API key>(FullMethodPath(method), MakeValue(arg1), MakeValue(arg2), MakeValue(arg3), MakeValue(arg4)); } // Shortcut methods for adding WebUI callbacks. template<typename T> void AddRawCallback(const std::string& name, void (T::*method)(const base::ListValue* args)) { web_ui()-><API key>( name, base::Bind(method, base::Unretained(static_cast<T*>(this)))); } template<typename T> void AddCallback(const std::string& name, void (T::*method)()) { base::Callback<void()> callback = base::Bind(method, base::Unretained(static_cast<T*>(this))); web_ui()-><API key>( name, base::Bind(&CallbackWrapper0, callback)); } template<typename T, typename A1> void AddCallback(const std::string& name, void (T::*method)(A1 arg1)) { base::Callback<void(A1)> callback = base::Bind(method, base::Unretained(static_cast<T*>(this))); web_ui()-><API key>( name, base::Bind(&CallbackWrapper1<A1>, callback)); } template<typename T, typename A1, typename A2> void AddCallback(const std::string& name, void (T::*method)(A1 arg1, A2 arg2)) { base::Callback<void(A1, A2)> callback = base::Bind(method, base::Unretained(static_cast<T*>(this))); web_ui()-><API key>( name, base::Bind(&CallbackWrapper2<A1, A2>, callback)); } template<typename T, typename A1, typename A2, typename A3> void AddCallback(const std::string& name, void (T::*method)(A1 arg1, A2 arg2, A3 arg3)) { base::Callback<void(A1, A2, A3)> callback = base::Bind(method, base::Unretained(static_cast<T*>(this))); web_ui()-><API key>( name, base::Bind(&CallbackWrapper3<A1, A2, A3>, callback)); } template<typename T, typename A1, typename A2, typename A3, typename A4> void AddCallback(const std::string& name, void (T::*method)(A1 arg1, A2 arg2, A3 arg3, A4 arg4)) { base::Callback<void(A1, A2, A3, A4)> callback = base::Bind(method, base::Unretained(static_cast<T*>(this))); web_ui()-><API key>( name, base::Bind(&CallbackWrapper4<A1, A2, A3, A4>, callback)); } // Called when the page is ready and handler can do initialization. virtual void Initialize() = 0; // Show selected WebUI |screen|. Optionally it can pass screen initialization // data via |data| parameter. void ShowScreen(const char* screen, const base::DictionaryValue* data); // Whether page is ready. bool page_is_ready() const { return page_is_ready_; } // Returns the window which shows us. virtual gfx::NativeWindow GetNativeWindow(); private: // Returns full name of JS method based on screen and method // names. std::string FullMethodPath(const std::string& method) const; // Keeps whether page is ready. bool page_is_ready_; base::DictionaryValue* localized_values_; // Full name of the corresponding JS screen object. Can be empty, if // there are no corresponding screen object or several different // objects. std::string <API key>; <API key>(BaseScreenHandler); }; } // namespace chromeos #endif // <API key>
#include "base/bind.h" #include "base/bind_helpers.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" #include "net/url_request/url_request.h" #include "testing/gtest/include/gtest/gtest.h" #include "webkit/browser/appcache/appcache.h" #include "webkit/browser/appcache/<API key>.h" #include "webkit/browser/appcache/appcache_group.h" #include "webkit/browser/appcache/appcache_host.h" #include "webkit/browser/appcache/<API key>.h" #include "webkit/browser/appcache/<API key>.h" #include "webkit/browser/quota/quota_manager.h" namespace appcache { class AppCacheHostTest : public testing::Test { public: AppCacheHostTest() { <API key> = base::Bind(&AppCacheHostTest::GetStatusCallback, base::Unretained(this)); <API key> = base::Bind(&AppCacheHostTest::StartUpdateCallback, base::Unretained(this)); <API key> = base::Bind(&AppCacheHostTest::SwapCacheCallback, base::Unretained(this)); } class MockFrontend : public AppCacheFrontend { public: MockFrontend() : last_host_id_(-222), last_cache_id_(-222), last_status_(appcache::OBSOLETE), <API key>(appcache::OBSOLETE), last_event_id_(appcache::OBSOLETE_EVENT), content_blocked_(false) { } virtual void OnCacheSelected( int host_id, const appcache::AppCacheInfo& info) OVERRIDE { last_host_id_ = host_id; last_cache_id_ = info.cache_id; last_status_ = info.status; } virtual void OnStatusChanged(const std::vector<int>& host_ids, appcache::Status status) OVERRIDE { <API key> = status; } virtual void OnEventRaised(const std::vector<int>& host_ids, appcache::EventID event_id) OVERRIDE { last_event_id_ = event_id; } virtual void OnErrorEventRaised(const std::vector<int>& host_ids, const std::string& message) OVERRIDE { last_event_id_ = ERROR_EVENT; } virtual void <API key>(const std::vector<int>& host_ids, const GURL& url, int num_total, int num_complete) OVERRIDE { last_event_id_ = PROGRESS_EVENT; } virtual void OnLogMessage(int host_id, appcache::LogLevel log_level, const std::string& message) OVERRIDE { } virtual void OnContentBlocked(int host_id, const GURL& manifest_url) OVERRIDE { content_blocked_ = true; } int last_host_id_; int64 last_cache_id_; appcache::Status last_status_; appcache::Status <API key>; appcache::EventID last_event_id_; bool content_blocked_; }; class <API key> : public quota::QuotaManagerProxy { public: <API key>() : QuotaManagerProxy(NULL, NULL) {} // Not needed for our tests. virtual void RegisterClient(quota::QuotaClient* client) OVERRIDE {} virtual void <API key>(quota::QuotaClient::ID client_id, const GURL& origin, quota::StorageType type) OVERRIDE {} virtual void <API key>(quota::QuotaClient::ID client_id, const GURL& origin, quota::StorageType type, int64 delta) OVERRIDE {} virtual void NotifyOriginInUse(const GURL& origin) OVERRIDE { inuse_[origin] += 1; } virtual void <API key>(const GURL& origin) OVERRIDE { inuse_[origin] -= 1; } int GetInUseCount(const GURL& origin) { return inuse_[origin]; } void reset() { inuse_.clear(); } // Map from origin to count of inuse notifications. std::map<GURL, int> inuse_; protected: virtual ~<API key>() {} }; void GetStatusCallback(Status status, void* param) { last_status_result_ = status; <API key> = param; } void StartUpdateCallback(bool result, void* param) { last_start_result_ = result; <API key> = param; } void SwapCacheCallback(bool result, void* param) { last_swap_result_ = result; <API key> = param; } base::MessageLoop message_loop_; // Mock classes for the 'host' to work with MockAppCacheService service_; MockFrontend mock_frontend_; // Mock callbacks we expect to receive from the 'host' appcache::GetStatusCallback <API key>; appcache::StartUpdateCallback <API key>; appcache::SwapCacheCallback <API key>; Status last_status_result_; bool last_swap_result_; bool last_start_result_; void* <API key>; }; TEST_F(AppCacheHostTest, Basic) { // Construct a host and test what state it appears to be in. AppCacheHost host(1, &mock_frontend_, &service_); EXPECT_EQ(1, host.host_id()); EXPECT_EQ(&service_, host.service()); EXPECT_EQ(&mock_frontend_, host.frontend()); EXPECT_EQ(NULL, host.associated_cache()); EXPECT_FALSE(host.<API key>()); // See that the callbacks are delivered immediately // and respond as if there is no cache selected. last_status_result_ = OBSOLETE; host.<API key>(<API key>, reinterpret_cast<void*>(1)); EXPECT_EQ(UNCACHED, last_status_result_); EXPECT_EQ(reinterpret_cast<void*>(1), <API key>); last_start_result_ = true; host.<API key>(<API key>, reinterpret_cast<void*>(2)); EXPECT_FALSE(last_start_result_); EXPECT_EQ(reinterpret_cast<void*>(2), <API key>); last_swap_result_ = true; host.<API key>(<API key>, reinterpret_cast<void*>(3)); EXPECT_FALSE(last_swap_result_); EXPECT_EQ(reinterpret_cast<void*>(3), <API key>); } TEST_F(AppCacheHostTest, SelectNoCache) { scoped_refptr<<API key>> mock_quota_proxy( new <API key>); service_.<API key>(mock_quota_proxy.get()); // Reset our mock frontend mock_frontend_.last_cache_id_ = -333; mock_frontend_.last_host_id_ = -333; mock_frontend_.last_status_ = OBSOLETE; const GURL kDocAndOriginUrl(GURL("http://whatever/").GetOrigin()); { AppCacheHost host(1, &mock_frontend_, &service_); host.SelectCache(kDocAndOriginUrl, kNoCacheId, GURL()); EXPECT_EQ(1, mock_quota_proxy->GetInUseCount(kDocAndOriginUrl)); // We should have received an OnCacheSelected msg EXPECT_EQ(1, mock_frontend_.last_host_id_); EXPECT_EQ(kNoCacheId, mock_frontend_.last_cache_id_); EXPECT_EQ(UNCACHED, mock_frontend_.last_status_); // Otherwise, see that it respond as if there is no cache selected. EXPECT_EQ(1, host.host_id()); EXPECT_EQ(&service_, host.service()); EXPECT_EQ(&mock_frontend_, host.frontend()); EXPECT_EQ(NULL, host.associated_cache()); EXPECT_FALSE(host.<API key>()); EXPECT_TRUE(host.<API key>().is_empty()); } EXPECT_EQ(0, mock_quota_proxy->GetInUseCount(kDocAndOriginUrl)); service_.<API key>(NULL); } TEST_F(AppCacheHostTest, ForeignEntry) { // Reset our mock frontend mock_frontend_.last_cache_id_ = -333; mock_frontend_.last_host_id_ = -333; mock_frontend_.last_status_ = OBSOLETE; // Precondition, a cache with an entry that is not marked as foreign. const int kCacheId = 22; const GURL kDocumentURL("http://origin/document"); scoped_refptr<AppCache> cache = new AppCache(service_.storage(), kCacheId); cache->AddEntry(kDocumentURL, AppCacheEntry(AppCacheEntry::EXPLICIT)); AppCacheHost host(1, &mock_frontend_, &service_); host.MarkAsForeignEntry(kDocumentURL, kCacheId); // We should have received an OnCacheSelected msg for kNoCacheId. EXPECT_EQ(1, mock_frontend_.last_host_id_); EXPECT_EQ(kNoCacheId, mock_frontend_.last_cache_id_); EXPECT_EQ(UNCACHED, mock_frontend_.last_status_); // See that it respond as if there is no cache selected. EXPECT_EQ(1, host.host_id()); EXPECT_EQ(&service_, host.service()); EXPECT_EQ(&mock_frontend_, host.frontend()); EXPECT_EQ(NULL, host.associated_cache()); EXPECT_FALSE(host.<API key>()); // See that the entry was marked as foreign. EXPECT_TRUE(cache->GetEntry(kDocumentURL)->IsForeign()); } TEST_F(AppCacheHostTest, <API key>) { // Reset our mock frontend mock_frontend_.last_cache_id_ = -333; mock_frontend_.last_host_id_ = -333; mock_frontend_.last_status_ = OBSOLETE; // Precondition, a cache with a fallback entry that is not marked as foreign. const int kCacheId = 22; const GURL kFallbackURL("http://origin/fallback_resource"); scoped_refptr<AppCache> cache = new AppCache(service_.storage(), kCacheId); cache->AddEntry(kFallbackURL, AppCacheEntry(AppCacheEntry::FALLBACK)); AppCacheHost host(1, &mock_frontend_, &service_); host.<API key>(kFallbackURL); host.MarkAsForeignEntry(GURL("http://origin/missing_document"), kCacheId); // We should have received an OnCacheSelected msg for kNoCacheId. EXPECT_EQ(1, mock_frontend_.last_host_id_); EXPECT_EQ(kNoCacheId, mock_frontend_.last_cache_id_); EXPECT_EQ(UNCACHED, mock_frontend_.last_status_); // See that the fallback entry was marked as foreign. EXPECT_TRUE(cache->GetEntry(kFallbackURL)->IsForeign()); } TEST_F(AppCacheHostTest, FailedCacheLoad) { // Reset our mock frontend mock_frontend_.last_cache_id_ = -333; mock_frontend_.last_host_id_ = -333; mock_frontend_.last_status_ = OBSOLETE; AppCacheHost host(1, &mock_frontend_, &service_); EXPECT_FALSE(host.<API key>()); const int kMockCacheId = 333; // Put it in a state where we're waiting on a cache // load prior to finishing cache selection. host.<API key> = kMockCacheId; EXPECT_TRUE(host.<API key>()); // The callback should not occur until we finish cache selection. last_status_result_ = OBSOLETE; <API key> = reinterpret_cast<void*>(-1); host.<API key>(<API key>, reinterpret_cast<void*>(1)); EXPECT_EQ(OBSOLETE, last_status_result_); EXPECT_EQ(reinterpret_cast<void*>(-1), <API key>); // Satisfy the load with NULL, a failure. host.OnCacheLoaded(NULL, kMockCacheId); // Cache selection should have finished EXPECT_FALSE(host.<API key>()); EXPECT_EQ(1, mock_frontend_.last_host_id_); EXPECT_EQ(kNoCacheId, mock_frontend_.last_cache_id_); EXPECT_EQ(UNCACHED, mock_frontend_.last_status_); // Callback should have fired upon completing the cache load too. EXPECT_EQ(UNCACHED, last_status_result_); EXPECT_EQ(reinterpret_cast<void*>(1), <API key>); } TEST_F(AppCacheHostTest, FailedGroupLoad) { AppCacheHost host(1, &mock_frontend_, &service_); const GURL kMockManifestUrl("http://foo.bar/baz"); // Put it in a state where we're waiting on a cache // load prior to finishing cache selection. host.<API key> = kMockManifestUrl; EXPECT_TRUE(host.<API key>()); // The callback should not occur until we finish cache selection. last_status_result_ = OBSOLETE; <API key> = reinterpret_cast<void*>(-1); host.<API key>(<API key>, reinterpret_cast<void*>(1)); EXPECT_EQ(OBSOLETE, last_status_result_); EXPECT_EQ(reinterpret_cast<void*>(-1), <API key>); // Satisfy the load will NULL, a failure. host.OnGroupLoaded(NULL, kMockManifestUrl); // Cache selection should have finished EXPECT_FALSE(host.<API key>()); EXPECT_EQ(1, mock_frontend_.last_host_id_); EXPECT_EQ(kNoCacheId, mock_frontend_.last_cache_id_); EXPECT_EQ(UNCACHED, mock_frontend_.last_status_); // Callback should have fired upon completing the group load. EXPECT_EQ(UNCACHED, last_status_result_); EXPECT_EQ(reinterpret_cast<void*>(1), <API key>); } TEST_F(AppCacheHostTest, SetSwappableCache) { AppCacheHost host(1, &mock_frontend_, &service_); host.SetSwappableCache(NULL); EXPECT_FALSE(host.swappable_cache_.get()); scoped_refptr<AppCacheGroup> group1(new AppCacheGroup( service_.storage(), GURL(), service_.storage()->NewGroupId())); host.SetSwappableCache(group1.get()); EXPECT_FALSE(host.swappable_cache_.get()); AppCache* cache1 = new AppCache(service_.storage(), 111); cache1->set_complete(true); group1->AddCache(cache1); host.SetSwappableCache(group1.get()); EXPECT_EQ(cache1, host.swappable_cache_.get()); mock_frontend_.last_host_id_ = -222; // to verify we received OnCacheSelected host.<API key>(cache1); EXPECT_FALSE(host.swappable_cache_.get()); // was same as associated cache EXPECT_EQ(appcache::IDLE, host.GetStatus()); // verify OnCacheSelected was called EXPECT_EQ(host.host_id(), mock_frontend_.last_host_id_); EXPECT_EQ(cache1->cache_id(), mock_frontend_.last_cache_id_); EXPECT_EQ(appcache::IDLE, mock_frontend_.last_status_); AppCache* cache2 = new AppCache(service_.storage(), 222); cache2->set_complete(true); group1->AddCache(cache2); EXPECT_EQ(cache2, host.swappable_cache_.get()); // updated to newest scoped_refptr<AppCacheGroup> group2( new AppCacheGroup(service_.storage(), GURL("http://foo.com"), service_.storage()->NewGroupId())); AppCache* cache3 = new AppCache(service_.storage(), 333); cache3->set_complete(true); group2->AddCache(cache3); AppCache* cache4 = new AppCache(service_.storage(), 444); cache4->set_complete(true); group2->AddCache(cache4); EXPECT_EQ(cache2, host.swappable_cache_.get()); // unchanged host.<API key>(cache3); EXPECT_EQ(cache4, host.swappable_cache_.get()); // newest cache in group2 EXPECT_FALSE(group1->HasCache()); // both caches in group1 have refcount 0 host.AssociateNoCache(GURL()); EXPECT_FALSE(host.swappable_cache_.get()); EXPECT_FALSE(group2->HasCache()); // both caches in group2 have refcount 0 // Host adds reference to newest cache when an update is complete. AppCache* cache5 = new AppCache(service_.storage(), 555); cache5->set_complete(true); group2->AddCache(cache5); host.<API key> = group2; host.OnUpdateComplete(group2.get()); EXPECT_FALSE(host.<API key>.get()); EXPECT_EQ(cache5, host.swappable_cache_.get()); group2->RemoveCache(cache5); EXPECT_FALSE(group2->HasCache()); host.<API key> = group2; host.OnUpdateComplete(group2.get()); EXPECT_FALSE(host.<API key>.get()); EXPECT_FALSE(host.swappable_cache_.get()); // group2 had no newest cache } TEST_F(AppCacheHostTest, ForDedicatedWorker) { const int kMockProcessId = 1; const int kParentHostId = 1; const int kWorkerHostId = 2; AppCacheBackendImpl backend_impl; backend_impl.Initialize(&service_, &mock_frontend_, kMockProcessId); backend_impl.RegisterHost(kParentHostId); backend_impl.RegisterHost(kWorkerHostId); AppCacheHost* parent_host = backend_impl.GetHost(kParentHostId); EXPECT_FALSE(parent_host-><API key>()); AppCacheHost* worker_host = backend_impl.GetHost(kWorkerHostId); worker_host-><API key>(kParentHostId, kMockProcessId); EXPECT_TRUE(worker_host-><API key>()); EXPECT_EQ(parent_host, worker_host-><API key>()); // We should have received an OnCacheSelected msg for the worker_host. // The host for workers always indicates 'no cache selected' regardless // of its parent's state. This is OK because the worker cannot access // the scriptable interface, the only function available is resource // loading (see <API key> those tests). EXPECT_EQ(kWorkerHostId, mock_frontend_.last_host_id_); EXPECT_EQ(kNoCacheId, mock_frontend_.last_cache_id_); EXPECT_EQ(UNCACHED, mock_frontend_.last_status_); // Simulate the parent being torn down. backend_impl.UnregisterHost(kParentHostId); parent_host = NULL; EXPECT_EQ(NULL, backend_impl.GetHost(kParentHostId)); EXPECT_EQ(NULL, worker_host-><API key>()); } TEST_F(AppCacheHostTest, SelectCacheAllowed) { scoped_refptr<<API key>> mock_quota_proxy( new <API key>); MockAppCachePolicy <API key>; <API key>.<API key> = true; service_.<API key>(mock_quota_proxy.get()); service_.set_appcache_policy(&<API key>); // Reset our mock frontend mock_frontend_.last_cache_id_ = -333; mock_frontend_.last_host_id_ = -333; mock_frontend_.last_status_ = OBSOLETE; mock_frontend_.last_event_id_ = OBSOLETE_EVENT; mock_frontend_.content_blocked_ = false; const GURL kDocAndOriginUrl(GURL("http://whatever/").GetOrigin()); const GURL kManifestUrl(GURL("http://whatever/cache.manifest")); { AppCacheHost host(1, &mock_frontend_, &service_); host.first_party_url_ = kDocAndOriginUrl; host.SelectCache(kDocAndOriginUrl, kNoCacheId, kManifestUrl); EXPECT_EQ(1, mock_quota_proxy->GetInUseCount(kDocAndOriginUrl)); // MockAppCacheService::LoadOrCreateGroup is asynchronous, so we shouldn't // have received an OnCacheSelected msg yet. EXPECT_EQ(-333, mock_frontend_.last_host_id_); EXPECT_EQ(-333, mock_frontend_.last_cache_id_); EXPECT_EQ(OBSOLETE, mock_frontend_.last_status_); // No error events either EXPECT_EQ(OBSOLETE_EVENT, mock_frontend_.last_event_id_); EXPECT_FALSE(mock_frontend_.content_blocked_); EXPECT_TRUE(host.<API key>()); } EXPECT_EQ(0, mock_quota_proxy->GetInUseCount(kDocAndOriginUrl)); service_.<API key>(NULL); } TEST_F(AppCacheHostTest, SelectCacheBlocked) { scoped_refptr<<API key>> mock_quota_proxy( new <API key>); MockAppCachePolicy <API key>; <API key>.<API key> = false; service_.<API key>(mock_quota_proxy.get()); service_.set_appcache_policy(&<API key>); // Reset our mock frontend mock_frontend_.last_cache_id_ = -333; mock_frontend_.last_host_id_ = -333; mock_frontend_.last_status_ = OBSOLETE; mock_frontend_.last_event_id_ = OBSOLETE_EVENT; mock_frontend_.content_blocked_ = false; const GURL kDocAndOriginUrl(GURL("http://whatever/").GetOrigin()); const GURL kManifestUrl(GURL("http://whatever/cache.manifest")); { AppCacheHost host(1, &mock_frontend_, &service_); host.first_party_url_ = kDocAndOriginUrl; host.SelectCache(kDocAndOriginUrl, kNoCacheId, kManifestUrl); EXPECT_EQ(1, mock_quota_proxy->GetInUseCount(kDocAndOriginUrl)); // We should have received an OnCacheSelected msg EXPECT_EQ(1, mock_frontend_.last_host_id_); EXPECT_EQ(kNoCacheId, mock_frontend_.last_cache_id_); EXPECT_EQ(UNCACHED, mock_frontend_.last_status_); // Also, an error event was raised EXPECT_EQ(ERROR_EVENT, mock_frontend_.last_event_id_); EXPECT_TRUE(mock_frontend_.content_blocked_); // Otherwise, see that it respond as if there is no cache selected. EXPECT_EQ(1, host.host_id()); EXPECT_EQ(&service_, host.service()); EXPECT_EQ(&mock_frontend_, host.frontend()); EXPECT_EQ(NULL, host.associated_cache()); EXPECT_FALSE(host.<API key>()); EXPECT_TRUE(host.<API key>().is_empty()); } EXPECT_EQ(0, mock_quota_proxy->GetInUseCount(kDocAndOriginUrl)); service_.<API key>(NULL); } } // namespace appcache
<?php namespace ZendTest\Filter\Word; use Zend\Filter\Word\<API key> as <API key>; /** * Test class for <API key>. * * @category Zend * @package Zend_Filter * @subpackage UnitTests * @group Zend_Filter */ class <API key> extends \<API key> { public function <API key>() { $string = 'CamelCasedWords'; $filter = new <API key>(); $filtered = $filter($string); $this->assertNotEquals($string, $filtered); $this->assertEquals('Camel_Cased_Words', $filtered); } public function <API key>() { $string = 'PaTitle'; $filter = new <API key>(); $filtered = $filter($string); $this->assertNotEquals($string, $filtered); $this->assertEquals('Pa_Title', $filtered); $string = 'Pa2Title'; $filter = new <API key>(); $filtered = $filter($string); $this->assertNotEquals($string, $filtered); $this->assertEquals('Pa2_Title', $filtered); $string = 'Pa2aTitle'; $filter = new <API key>(); $filtered = $filter($string); $this->assertNotEquals($string, $filtered); $this->assertEquals('Pa2a_Title', $filtered); } }
<?php namespace ZendTest\I18n\Translator\Loader; use <API key> as TestCase; use Locale; use Zend\I18n\Translator\Loader\Ini as IniLoader; class IniTest extends TestCase { protected $testFilesDir; protected $originalLocale; public function setUp() { $this->testFilesDir = realpath(__DIR__ . '/../_files'); } public function <API key>() { $loader = new IniLoader(); $this-><API key>('Zend\I18n\Exception\<API key>', 'Could not open file'); $loader->load('en_EN', 'missing'); } public function <API key>() { $loader = new IniLoader(); $textDomain = $loader->load('en_EN', $this->testFilesDir . '/translation_empty.ini'); $this->assertInstanceOf('Zend\I18n\Translator\TextDomain', $textDomain); } public function <API key>() { $loader = new IniLoader(); $this-><API key>('Zend\I18n\Exception\<API key>', 'Each INI row must be an array with message and translation'); $loader->load('en_EN', $this->testFilesDir . '/failed.ini'); } public function <API key>() { $loader = new IniLoader(); $this-><API key>('Zend\I18n\Exception\<API key>', 'Each INI row must be an array with message and translation'); $loader->load('en_EN', $this->testFilesDir . '/failed_syntax.ini'); } public function <API key>() { $loader = new IniLoader(); $textDomain = $loader->load('en_EN', $this->testFilesDir . '/translation_en.ini'); $this->assertEquals('Message 1 (en)', $textDomain['Message 1']); $this->assertEquals('Message 4 (en)', $textDomain['Message 4']); } public function <API key>() { $loader = new IniLoader(); $textDomain = $loader->load('en_EN', $this->testFilesDir . '/<API key>.ini'); $this->assertEquals('Message 1 (en)', $textDomain['Message 1']); $this->assertEquals('Message 4 (en)', $textDomain['Message 4']); } public function <API key>() { $loader = new IniLoader(); $textDomain = $loader->load('en_EN', $this->testFilesDir . '/<API key>.ini'); $this->assertEquals('Message 1 (en)', $textDomain['Message 1']); $this->assertEquals('Message 4 (en)', $textDomain['Message 4']); } public function <API key>() { $loader = new IniLoader(); $textDomain = $loader->load('en_EN', $this->testFilesDir . '/translation_en.ini'); $this->assertEquals(2, $textDomain->getPluralRule()->evaluate(0)); $this->assertEquals(0, $textDomain->getPluralRule()->evaluate(1)); $this->assertEquals(1, $textDomain->getPluralRule()->evaluate(2)); $this->assertEquals(2, $textDomain->getPluralRule()->evaluate(10)); } }
/* This file is auto-generated from the drm_pciids.txt in the DRM CVS Please contact dri-devel@lists.sf.net to add new cards to this list */ #define radeon_PCI_IDS \ {0x1002, 0x3150, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_IS_MOBILITY}, \ {0x1002, 0x3151, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x3152, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x3154, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x3155, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x3E50, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_NEW_MEMMAP}, \ {0x1002, 0x3E54, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_NEW_MEMMAP}, \ {0x1002, 0x4136, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS100|RADEON_IS_IGP}, \ {0x1002, 0x4137, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS200|RADEON_IS_IGP}, \ {0x1002, 0x4144, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \ {0x1002, 0x4145, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \ {0x1002, 0x4146, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \ {0x1002, 0x4147, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \ {0x1002, 0x4148, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R350}, \ {0x1002, 0x4149, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R350}, \ {0x1002, 0x414A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R350}, \ {0x1002, 0x414B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R350}, \ {0x1002, 0x4150, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350}, \ {0x1002, 0x4151, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350}, \ {0x1002, 0x4152, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350}, \ {0x1002, 0x4153, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350}, \ {0x1002, 0x4154, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350}, \ {0x1002, 0x4155, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350}, \ {0x1002, 0x4156, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350}, \ {0x1002, 0x4237, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS200|RADEON_IS_IGP}, \ {0x1002, 0x4242, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R200}, \ {0x1002, 0x4336, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS100|RADEON_IS_IGP|RADEON_IS_MOBILITY}, \ {0x1002, 0x4337, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS200|RADEON_IS_IGP|RADEON_IS_MOBILITY}, \ {0x1002, 0x4437, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS200|RADEON_IS_IGP|RADEON_IS_MOBILITY}, \ {0x1002, 0x4966, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV250}, \ {0x1002, 0x4967, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV250}, \ {0x1002, 0x4A48, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \ {0x1002, 0x4A49, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \ {0x1002, 0x4A4A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \ {0x1002, 0x4A4B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \ {0x1002, 0x4A4C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \ {0x1002, 0x4A4D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \ {0x1002, 0x4A4E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x4A4F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \ {0x1002, 0x4A50, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \ {0x1002, 0x4A54, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \ {0x1002, 0x4B48, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \ {0x1002, 0x4B49, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \ {0x1002, 0x4B4A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \ {0x1002, 0x4B4B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \ {0x1002, 0x4B4C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R420|RADEON_NEW_MEMMAP}, \ {0x1002, 0x4C57, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV200|RADEON_IS_MOBILITY}, \ {0x1002, 0x4C58, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV200|RADEON_IS_MOBILITY}, \ {0x1002, 0x4C59, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV100|RADEON_IS_MOBILITY}, \ {0x1002, 0x4C5A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV100|RADEON_IS_MOBILITY}, \ {0x1002, 0x4C64, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV250|RADEON_IS_MOBILITY}, \ {0x1002, 0x4C66, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV250|RADEON_IS_MOBILITY}, \ {0x1002, 0x4C67, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV250|RADEON_IS_MOBILITY}, \ {0x1002, 0x4C6E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280|RADEON_IS_MOBILITY}, \ {0x1002, 0x4E44, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \ {0x1002, 0x4E45, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \ {0x1002, 0x4E46, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \ {0x1002, 0x4E47, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \ {0x1002, 0x4E48, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R350}, \ {0x1002, 0x4E49, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R350}, \ {0x1002, 0x4E4A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R350}, \ {0x1002, 0x4E4B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R350}, \ {0x1002, 0x4E50, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350|RADEON_IS_MOBILITY}, \ {0x1002, 0x4E51, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350|RADEON_IS_MOBILITY}, \ {0x1002, 0x4E52, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350|RADEON_IS_MOBILITY}, \ {0x1002, 0x4E53, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350|RADEON_IS_MOBILITY}, \ {0x1002, 0x4E54, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350|RADEON_IS_MOBILITY}, \ {0x1002, 0x4E56, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV350|RADEON_IS_MOBILITY}, \ {0x1002, 0x5144, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R100|RADEON_SINGLE_CRTC}, \ {0x1002, 0x5145, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R100|RADEON_SINGLE_CRTC}, \ {0x1002, 0x5146, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R100|RADEON_SINGLE_CRTC}, \ {0x1002, 0x5147, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R100|RADEON_SINGLE_CRTC}, \ {0x1002, 0x5148, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R200}, \ {0x1002, 0x514C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R200}, \ {0x1002, 0x514D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R200}, \ {0x1002, 0x5157, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV200}, \ {0x1002, 0x5158, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV200}, \ {0x1002, 0x5159, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV100}, \ {0x1002, 0x515A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV100}, \ {0x1002, 0x515E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV100|RADEON_SINGLE_CRTC}, \ {0x1002, 0x5460, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_IS_MOBILITY}, \ {0x1002, 0x5462, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_IS_MOBILITY}, \ {0x1002, 0x5464, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_IS_MOBILITY}, \ {0x1002, 0x5548, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \ {0x1002, 0x5549, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \ {0x1002, 0x554A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \ {0x1002, 0x554B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \ {0x1002, 0x554C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \ {0x1002, 0x554D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \ {0x1002, 0x554E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \ {0x1002, 0x554F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \ {0x1002, 0x5550, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \ {0x1002, 0x5551, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \ {0x1002, 0x5552, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \ {0x1002, 0x5554, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \ {0x1002, 0x564A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x564B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x564F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x5652, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x5653, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x5657, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_NEW_MEMMAP}, \ {0x1002, 0x5834, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|RADEON_IS_IGP}, \ {0x1002, 0x5835, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|RADEON_IS_IGP|RADEON_IS_MOBILITY}, \ {0x1002, 0x5954, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS480|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART}, \ {0x1002, 0x5955, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS480|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART}, \ {0x1002, 0x5974, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS480|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART}, \ {0x1002, 0x5975, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS480|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART}, \ {0x1002, 0x5960, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \ {0x1002, 0x5961, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \ {0x1002, 0x5962, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \ {0x1002, 0x5964, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \ {0x1002, 0x5965, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \ {0x1002, 0x5969, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV100|RADEON_SINGLE_CRTC}, \ {0x1002, 0x5a41, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS400|RADEON_IS_IGP|RADEON_IS_IGPGART}, \ {0x1002, 0x5a42, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS400|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART}, \ {0x1002, 0x5a61, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS400|RADEON_IS_IGP|RADEON_IS_IGPGART}, \ {0x1002, 0x5a62, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS400|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART}, \ {0x1002, 0x5b60, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_NEW_MEMMAP}, \ {0x1002, 0x5b62, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_NEW_MEMMAP}, \ {0x1002, 0x5b63, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_NEW_MEMMAP}, \ {0x1002, 0x5b64, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_NEW_MEMMAP}, \ {0x1002, 0x5b65, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_NEW_MEMMAP}, \ {0x1002, 0x5c61, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280|RADEON_IS_MOBILITY}, \ {0x1002, 0x5c63, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280|RADEON_IS_MOBILITY}, \ {0x1002, 0x5d48, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x5d49, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x5d4a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x5d4c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \ {0x1002, 0x5d4d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \ {0x1002, 0x5d4e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \ {0x1002, 0x5d4f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \ {0x1002, 0x5d50, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \ {0x1002, 0x5d52, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \ {0x1002, 0x5d57, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R423|RADEON_NEW_MEMMAP}, \ {0x1002, 0x5e48, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_NEW_MEMMAP}, \ {0x1002, 0x5e4a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_NEW_MEMMAP}, \ {0x1002, 0x5e4b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_NEW_MEMMAP}, \ {0x1002, 0x5e4c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_NEW_MEMMAP}, \ {0x1002, 0x5e4d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_NEW_MEMMAP}, \ {0x1002, 0x5e4f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6700, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6701, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6702, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6703, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6704, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6705, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6706, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6707, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6708, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6709, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6718, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6719, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \ {0x1002, 0x671c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \ {0x1002, 0x671d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \ {0x1002, 0x671f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAYMAN|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6720, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6721, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6722, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6723, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6724, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6725, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6726, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6727, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6728, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6729, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6738, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6739, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x673e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BARTS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6740, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6741, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6742, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6743, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6744, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6745, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6746, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6747, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6748, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6749, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x674A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6750, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6751, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6758, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6759, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x675B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x675D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x675F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6760, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6761, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6762, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6763, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6764, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6765, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6766, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6767, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6768, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6770, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6771, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6772, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6778, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6779, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x677B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CAICOS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6780, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6784, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6788, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \ {0x1002, 0x678A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6790, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6791, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6792, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6798, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6799, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \ {0x1002, 0x679A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \ {0x1002, 0x679B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \ {0x1002, 0x679E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \ {0x1002, 0x679F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6800, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6801, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6802, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6806, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6808, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6809, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6810, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6811, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6816, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6817, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6818, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6819, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6820, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6821, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6822, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6823, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6824, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6825, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6826, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6827, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6828, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6829, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_NEW_MEMMAP}, \ {0x1002, 0x682A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x682B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x682D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x682F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6830, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6831, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6835, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6837, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6838, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6839, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_NEW_MEMMAP}, \ {0x1002, 0x683B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_NEW_MEMMAP}, \ {0x1002, 0x683D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_NEW_MEMMAP}, \ {0x1002, 0x683F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6840, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6841, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6842, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6843, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6849, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x684C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6850, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6858, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6859, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TURKS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6880, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6888, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6889, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x688A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x688C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x688D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6898, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x6899, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x689b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x689c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HEMLOCK|RADEON_NEW_MEMMAP}, \ {0x1002, 0x689d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HEMLOCK|RADEON_NEW_MEMMAP}, \ {0x1002, 0x689e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CYPRESS|RADEON_NEW_MEMMAP}, \ {0x1002, 0x68a0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x68a1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x68a8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_NEW_MEMMAP}, \ {0x1002, 0x68a9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_NEW_MEMMAP}, \ {0x1002, 0x68b0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x68b8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_NEW_MEMMAP}, \ {0x1002, 0x68b9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_NEW_MEMMAP}, \ {0x1002, 0x68ba, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_NEW_MEMMAP}, \ {0x1002, 0x68be, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_NEW_MEMMAP}, \ {0x1002, 0x68bf, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_JUNIPER|RADEON_NEW_MEMMAP}, \ {0x1002, 0x68c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_REDWOOD|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x68c1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_REDWOOD|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x68c7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_REDWOOD|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x68c8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_REDWOOD|RADEON_NEW_MEMMAP}, \ {0x1002, 0x68c9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_REDWOOD|RADEON_NEW_MEMMAP}, \ {0x1002, 0x68d8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_REDWOOD|RADEON_NEW_MEMMAP}, \ {0x1002, 0x68d9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_REDWOOD|RADEON_NEW_MEMMAP}, \ {0x1002, 0x68da, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_REDWOOD|RADEON_NEW_MEMMAP}, \ {0x1002, 0x68de, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_REDWOOD|RADEON_NEW_MEMMAP}, \ {0x1002, 0x68e0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CEDAR|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x68e1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CEDAR|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x68e4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CEDAR|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x68e5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CEDAR|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x68e8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CEDAR|RADEON_NEW_MEMMAP}, \ {0x1002, 0x68e9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CEDAR|RADEON_NEW_MEMMAP}, \ {0x1002, 0x68f1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CEDAR|RADEON_NEW_MEMMAP}, \ {0x1002, 0x68f2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CEDAR|RADEON_NEW_MEMMAP}, \ {0x1002, 0x68f8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CEDAR|RADEON_NEW_MEMMAP}, \ {0x1002, 0x68f9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CEDAR|RADEON_NEW_MEMMAP}, \ {0x1002, 0x68fa, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CEDAR|RADEON_NEW_MEMMAP}, \ {0x1002, 0x68fe, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_CEDAR|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7101, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7102, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7103, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7104, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7105, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7106, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7109, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_NEW_MEMMAP}, \ {0x1002, 0x710A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_NEW_MEMMAP}, \ {0x1002, 0x710B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_NEW_MEMMAP}, \ {0x1002, 0x710C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_NEW_MEMMAP}, \ {0x1002, 0x710E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_NEW_MEMMAP}, \ {0x1002, 0x710F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R520|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7140, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7141, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7142, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7143, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7144, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7145, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7146, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7147, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7149, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x714A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x714B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x714C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x714D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \ {0x1002, 0x714E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \ {0x1002, 0x714F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7151, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7152, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7153, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \ {0x1002, 0x715E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \ {0x1002, 0x715F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7180, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7181, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7183, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7186, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7187, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7188, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x718A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x718B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x718C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x718D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x718F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7193, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7196, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x719B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \ {0x1002, 0x719F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \ {0x1002, 0x71C0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \ {0x1002, 0x71C1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \ {0x1002, 0x71C2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \ {0x1002, 0x71C3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \ {0x1002, 0x71C4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x71C5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x71C6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \ {0x1002, 0x71C7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \ {0x1002, 0x71CD, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \ {0x1002, 0x71CE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \ {0x1002, 0x71D2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \ {0x1002, 0x71D4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x71D5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x71D6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x71DA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_NEW_MEMMAP}, \ {0x1002, 0x71DE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV530|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7200, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7210, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7211, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV515|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7240, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7243, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7244, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7245, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7246, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7247, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7248, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7249, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \ {0x1002, 0x724A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \ {0x1002, 0x724B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \ {0x1002, 0x724C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \ {0x1002, 0x724D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \ {0x1002, 0x724E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \ {0x1002, 0x724F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7280, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV570|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7281, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV560|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7283, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV560|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7284, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R580|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7287, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV560|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7288, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV570|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7289, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV570|RADEON_NEW_MEMMAP}, \ {0x1002, 0x728B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV570|RADEON_NEW_MEMMAP}, \ {0x1002, 0x728C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV570|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7290, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV560|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7291, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV560|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7293, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV560|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7297, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV560|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7834, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|RADEON_IS_IGP|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7835, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x791e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS690|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART}, \ {0x1002, 0x791f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS690|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART}, \ {0x1002, 0x793f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS600|RADEON_IS_IGP|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7941, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS600|RADEON_IS_IGP|RADEON_NEW_MEMMAP}, \ {0x1002, 0x7942, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS600|RADEON_IS_IGP|RADEON_NEW_MEMMAP}, \ {0x1002, 0x796c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS740|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART}, \ {0x1002, 0x796d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS740|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART}, \ {0x1002, 0x796e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS740|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART}, \ {0x1002, 0x796f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS740|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART}, \ {0x1002, 0x9400, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R600|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9401, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R600|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9402, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R600|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9403, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R600|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9405, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R600|RADEON_NEW_MEMMAP}, \ {0x1002, 0x940A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R600|RADEON_NEW_MEMMAP}, \ {0x1002, 0x940B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R600|RADEON_NEW_MEMMAP}, \ {0x1002, 0x940F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R600|RADEON_NEW_MEMMAP}, \ {0x1002, 0x94A0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV740|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x94A1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV740|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x94A3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV740|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x94B1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV740|RADEON_NEW_MEMMAP}, \ {0x1002, 0x94B3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV740|RADEON_NEW_MEMMAP}, \ {0x1002, 0x94B4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV740|RADEON_NEW_MEMMAP}, \ {0x1002, 0x94B5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV740|RADEON_NEW_MEMMAP}, \ {0x1002, 0x94B9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV740|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9440, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9441, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9442, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9443, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9444, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9446, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_NEW_MEMMAP}, \ {0x1002, 0x944A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x944B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x944C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_NEW_MEMMAP}, \ {0x1002, 0x944E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9450, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9452, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9456, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_NEW_MEMMAP}, \ {0x1002, 0x945A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x945B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x945E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9460, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9462, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_NEW_MEMMAP}, \ {0x1002, 0x946A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x946B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x947A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x947B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9480, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9487, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9488, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9489, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x948A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x948F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9490, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9491, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9495, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9498, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_NEW_MEMMAP}, \ {0x1002, 0x949C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_NEW_MEMMAP}, \ {0x1002, 0x949E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_NEW_MEMMAP}, \ {0x1002, 0x949F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_NEW_MEMMAP}, \ {0x1002, 0x94C0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV610|RADEON_NEW_MEMMAP}, \ {0x1002, 0x94C1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV610|RADEON_NEW_MEMMAP}, \ {0x1002, 0x94C3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV610|RADEON_NEW_MEMMAP}, \ {0x1002, 0x94C4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV610|RADEON_NEW_MEMMAP}, \ {0x1002, 0x94C5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV610|RADEON_NEW_MEMMAP}, \ {0x1002, 0x94C6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV610|RADEON_NEW_MEMMAP}, \ {0x1002, 0x94C7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV610|RADEON_NEW_MEMMAP}, \ {0x1002, 0x94C8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV610|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x94C9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV610|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x94CB, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV610|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x94CC, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV610|RADEON_NEW_MEMMAP}, \ {0x1002, 0x94CD, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV610|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9500, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV670|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9501, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV670|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9504, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV670|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9505, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV670|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9506, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV670|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9507, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV670|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9508, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV670|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9509, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV670|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x950F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV670|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9511, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV670|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9515, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV670|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9517, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV670|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9519, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV670|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9540, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV710|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9541, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV710|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9542, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV710|RADEON_NEW_MEMMAP}, \ {0x1002, 0x954E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV710|RADEON_NEW_MEMMAP}, \ {0x1002, 0x954F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV710|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9552, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV710|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9553, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV710|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9555, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV710|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9557, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV710|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x955f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV710|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9580, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV630|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9581, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV630|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9583, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV630|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9586, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV630|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9587, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV630|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9588, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV630|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9589, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV630|RADEON_NEW_MEMMAP}, \ {0x1002, 0x958A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV630|RADEON_NEW_MEMMAP}, \ {0x1002, 0x958B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV630|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x958C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV630|RADEON_NEW_MEMMAP}, \ {0x1002, 0x958D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV630|RADEON_NEW_MEMMAP}, \ {0x1002, 0x958E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV630|RADEON_NEW_MEMMAP}, \ {0x1002, 0x958F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV630|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9590, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV635|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9591, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV635|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9593, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV635|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9595, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV635|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9596, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV635|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9597, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV635|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9598, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV635|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9599, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV635|RADEON_NEW_MEMMAP}, \ {0x1002, 0x959B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV635|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x95C0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV620|RADEON_NEW_MEMMAP}, \ {0x1002, 0x95C2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV620|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x95C4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV620|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ {0x1002, 0x95C5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV620|RADEON_NEW_MEMMAP}, \ {0x1002, 0x95C6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV620|RADEON_NEW_MEMMAP}, \ {0x1002, 0x95C7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV620|RADEON_NEW_MEMMAP}, \ {0x1002, 0x95C9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV620|RADEON_NEW_MEMMAP}, \ {0x1002, 0x95CC, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV620|RADEON_NEW_MEMMAP}, \ {0x1002, 0x95CD, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV620|RADEON_NEW_MEMMAP}, \ {0x1002, 0x95CE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV620|RADEON_NEW_MEMMAP}, \ {0x1002, 0x95CF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV620|RADEON_NEW_MEMMAP}, \ {0x1002, 0x9610, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9611, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9612, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9613, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9614, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9615, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9616, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9640, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SUMO|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9641, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SUMO|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9642, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SUMO2|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9643, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SUMO2|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9644, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SUMO2|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9645, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SUMO2|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9647, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SUMO|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP},\ {0x1002, 0x9648, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SUMO|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP},\ {0x1002, 0x9649, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SUMO|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP},\ {0x1002, 0x964a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SUMO|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x964b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SUMO|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x964c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SUMO|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x964e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SUMO|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP},\ {0x1002, 0x964f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_SUMO|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP},\ {0x1002, 0x9710, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS880|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9711, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS880|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9712, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS880|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9713, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS880|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9714, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS880|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9715, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS880|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9802, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PALM|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9803, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PALM|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9804, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PALM|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9805, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PALM|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9806, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PALM|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9807, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PALM|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9808, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PALM|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9809, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PALM|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x980A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PALM|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9900, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9901, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9903, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9904, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9905, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9906, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9907, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9908, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9909, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x990A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x990B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x990C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x990D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x990E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x990F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9910, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9913, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9917, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9918, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9919, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9990, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9991, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9992, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9993, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9994, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9995, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9996, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9997, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9998, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x9999, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x999A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x999B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x999C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x999D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x99A0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x99A2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0x1002, 0x99A4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ {0, 0, 0} #define r128_PCI_IDS \ {0x1002, 0x4c45, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x4c46, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x4d46, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x4d4c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x5041, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x5042, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x5043, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x5044, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x5045, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x5046, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x5047, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x5048, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x5049, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x504A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x504B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x504C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x504D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x504E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x504F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x5050, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x5051, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x5052, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x5053, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x5054, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x5055, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x5056, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x5057, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x5058, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x5245, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x5246, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x5247, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x524b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x524c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x534d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x5446, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x544C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x5452, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0, 0, 0} #define mga_PCI_IDS \ {0x102b, 0x0520, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MGA_CARD_TYPE_G200}, \ {0x102b, 0x0521, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MGA_CARD_TYPE_G200}, \ {0x102b, 0x0525, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MGA_CARD_TYPE_G400}, \ {0x102b, 0x2527, PCI_ANY_ID, PCI_ANY_ID, 0, 0, MGA_CARD_TYPE_G550}, \ {0, 0, 0} #define mach64_PCI_IDS \ {0x1002, 0x4749, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x4750, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x4751, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x4742, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x4744, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x4c49, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x4c50, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x4c51, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x4c42, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x4c44, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x474c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x474f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x4752, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x4753, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x474d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x474e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x4c52, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x4c53, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x4c4d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1002, 0x4c4e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0, 0, 0} #define sisdrv_PCI_IDS \ {0x1039, 0x0300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1039, 0x5300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1039, 0x6300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1039, 0x6330, PCI_ANY_ID, PCI_ANY_ID, 0, 0, SIS_CHIP_315}, \ {0x1039, 0x6351, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1039, 0x7300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x18CA, 0x0040, PCI_ANY_ID, PCI_ANY_ID, 0, 0, SIS_CHIP_315}, \ {0x18CA, 0x0042, PCI_ANY_ID, PCI_ANY_ID, 0, 0, SIS_CHIP_315}, \ {0, 0, 0} #define tdfx_PCI_IDS \ {0x121a, 0x0003, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x121a, 0x0004, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x121a, 0x0005, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x121a, 0x0007, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x121a, 0x0009, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x121a, 0x000b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0, 0, 0} #define viadrv_PCI_IDS \ {0x1106, 0x3022, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1106, 0x3118, PCI_ANY_ID, PCI_ANY_ID, 0, 0, VIA_PRO_GROUP_A}, \ {0x1106, 0x3122, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1106, 0x7205, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1106, 0x3108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1106, 0x3344, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1106, 0x3343, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x1106, 0x3230, PCI_ANY_ID, PCI_ANY_ID, 0, 0, VIA_DX9_0}, \ {0x1106, 0x3157, PCI_ANY_ID, PCI_ANY_ID, 0, 0, VIA_PRO_GROUP_A}, \ {0, 0, 0} #define i810_PCI_IDS \ {0x8086, 0x7121, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x8086, 0x7123, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x8086, 0x7125, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x8086, 0x1132, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0, 0, 0} #define i830_PCI_IDS \ {0x8086, 0x3577, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x8086, 0x2562, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x8086, 0x3582, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x8086, 0x2572, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0x8086, 0x358e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0, 0, 0} #define gamma_PCI_IDS \ {0x3d3d, 0x0008, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, \ {0, 0, 0} #define savage_PCI_IDS \ {0x5333, 0x8a20, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SAVAGE3D}, \ {0x5333, 0x8a21, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SAVAGE3D}, \ {0x5333, 0x8a22, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SAVAGE4}, \ {0x5333, 0x8a23, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SAVAGE4}, \ {0x5333, 0x8c10, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SAVAGE_MX}, \ {0x5333, 0x8c11, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SAVAGE_MX}, \ {0x5333, 0x8c12, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SAVAGE_MX}, \ {0x5333, 0x8c13, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SAVAGE_MX}, \ {0x5333, 0x8c22, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SUPERSAVAGE}, \ {0x5333, 0x8c24, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SUPERSAVAGE}, \ {0x5333, 0x8c26, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SUPERSAVAGE}, \ {0x5333, 0x8c2a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SUPERSAVAGE}, \ {0x5333, 0x8c2b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SUPERSAVAGE}, \ {0x5333, 0x8c2c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SUPERSAVAGE}, \ {0x5333, 0x8c2d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SUPERSAVAGE}, \ {0x5333, 0x8c2e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SUPERSAVAGE}, \ {0x5333, 0x8c2f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_SUPERSAVAGE}, \ {0x5333, 0x8a25, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_PROSAVAGE}, \ {0x5333, 0x8a26, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_PROSAVAGE}, \ {0x5333, 0x8d01, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_TWISTER}, \ {0x5333, 0x8d02, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_TWISTER}, \ {0x5333, 0x8d03, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_PROSAVAGEDDR}, \ {0x5333, 0x8d04, PCI_ANY_ID, PCI_ANY_ID, 0, 0, S3_PROSAVAGEDDR}, \ {0, 0, 0} #define ffb_PCI_IDS \ {0, 0, 0} #define i915_PCI_IDS \ {0x8086, 0x3577, PCI_ANY_ID, PCI_ANY_ID, <API key> << 8, 0xffff00, 0}, \ {0x8086, 0x2562, PCI_ANY_ID, PCI_ANY_ID, <API key> << 8, 0xffff00, 0}, \ {0x8086, 0x3582, PCI_ANY_ID, PCI_ANY_ID, <API key> << 8, 0xffff00, 0}, \ {0x8086, 0x2572, PCI_ANY_ID, PCI_ANY_ID, <API key> << 8, 0xffff00, 0}, \ {0x8086, 0x2582, PCI_ANY_ID, PCI_ANY_ID, <API key> << 8, 0xffff00, 0}, \ {0x8086, 0x258a, PCI_ANY_ID, PCI_ANY_ID, <API key> << 8, 0xffff00, 0}, \ {0x8086, 0x2592, PCI_ANY_ID, PCI_ANY_ID, <API key> << 8, 0xffff00, 0}, \ {0x8086, 0x2772, PCI_ANY_ID, PCI_ANY_ID, <API key> << 8, 0xffff00, 0}, \ {0x8086, 0x27a2, PCI_ANY_ID, PCI_ANY_ID, <API key> << 8, 0xffff00, 0}, \ {0x8086, 0x27ae, PCI_ANY_ID, PCI_ANY_ID, <API key> << 8, 0xffff00, 0}, \ {0x8086, 0x2972, PCI_ANY_ID, PCI_ANY_ID, <API key> << 8, 0xffff00, 0}, \ {0x8086, 0x2982, PCI_ANY_ID, PCI_ANY_ID, <API key> << 8, 0xffff00, 0}, \ {0x8086, 0x2992, PCI_ANY_ID, PCI_ANY_ID, <API key> << 8, 0xffff00, 0}, \ {0x8086, 0x29a2, PCI_ANY_ID, PCI_ANY_ID, <API key> << 8, 0xffff00, 0}, \ {0x8086, 0x29b2, PCI_ANY_ID, PCI_ANY_ID, <API key> << 8, 0xffff00, 0}, \ {0x8086, 0x29c2, PCI_ANY_ID, PCI_ANY_ID, <API key> << 8, 0xffff00, 0}, \ {0x8086, 0x29d2, PCI_ANY_ID, PCI_ANY_ID, <API key> << 8, 0xffff00, 0}, \ {0x8086, 0x2a02, PCI_ANY_ID, PCI_ANY_ID, <API key> << 8, 0xffff00, 0}, \ {0x8086, 0x2a12, PCI_ANY_ID, PCI_ANY_ID, <API key> << 8, 0xffff00, 0}, \ {0x8086, 0x2a42, PCI_ANY_ID, PCI_ANY_ID, <API key> << 8, 0xffff00, 0}, \ {0x8086, 0x2e02, PCI_ANY_ID, PCI_ANY_ID, <API key> << 8, 0xffff00, 0}, \ {0x8086, 0x2e12, PCI_ANY_ID, PCI_ANY_ID, <API key> << 8, 0xffff00, 0}, \ {0x8086, 0x2e22, PCI_ANY_ID, PCI_ANY_ID, <API key> << 8, 0xffff00, 0}, \ {0x8086, 0x2e32, PCI_ANY_ID, PCI_ANY_ID, <API key> << 8, 0xffff00, 0}, \ {0x8086, 0x2e42, PCI_ANY_ID, PCI_ANY_ID, <API key> << 8, 0xffff00, 0}, \ {0x8086, 0xa001, PCI_ANY_ID, PCI_ANY_ID, <API key> << 8, 0xffff00, 0}, \ {0x8086, 0xa011, PCI_ANY_ID, PCI_ANY_ID, <API key> << 8, 0xffff00, 0}, \ {0x8086, 0x35e8, PCI_ANY_ID, PCI_ANY_ID, <API key> << 8, 0xffff00, 0}, \ {0x8086, 0x0042, PCI_ANY_ID, PCI_ANY_ID, <API key> << 8, 0xffff00, 0}, \ {0x8086, 0x0046, PCI_ANY_ID, PCI_ANY_ID, <API key> << 8, 0xffff00, 0}, \ {0x8086, 0x0102, PCI_ANY_ID, PCI_ANY_ID, <API key> << 8, 0xffff00, 0}, \ {0, 0, 0}
package javax.print; /** * Services may optionally provide UIs which allow different styles * of interaction in different roles. * One role may be end-user browsing and setting of print options. * Another role may be administering the print service. * <p> * Although the Print Service API does not presently provide standardised * support for administering a print service, monitoring of the print * service is possible and a UI may provide for private update mechanisms. * <p> * The basic design intent is to allow applications to lazily locate and * initialize services only when needed without any API dependencies * except in an environment in which they are used. * <p> * Swing UIs are preferred as they provide a more consistent {@literal L&F} * and can support accessibility APIs. * <p> * Example usage: * <pre> * ServiceUIFactory factory = printService.getServiceUIFactory(); * if (factory != null) { * JComponent swingui = (JComponent)factory.getUI( * ServiceUIFactory.MAIN_UIROLE, * ServiceUIFactory.JCOMPONENT_UI); * if (swingui != null) { * tabbedpane.add("Custom UI", swingui); * } * } * </pre> */ public abstract class ServiceUIFactory { /** * Denotes a UI implemented as a Swing component. * The value of the String is the fully qualified classname : * "javax.swing.JComponent". */ public static final String JCOMPONENT_UI = "javax.swing.JComponent"; /** * Denotes a UI implemented as an AWT panel. * The value of the String is the fully qualified classname : * "java.awt.Panel" */ public static final String PANEL_UI = "java.awt.Panel"; /** * Denotes a UI implemented as an AWT dialog. * The value of the String is the fully qualified classname : * "java.awt.Dialog" */ public static final String DIALOG_UI = "java.awt.Dialog"; /** * Denotes a UI implemented as a Swing dialog. * The value of the String is the fully qualified classname : * "javax.swing.JDialog" */ public static final String JDIALOG_UI = "javax.swing.JDialog"; /** * Denotes a UI which performs an informative "About" role. */ public static final int ABOUT_UIROLE = 1; /** * Denotes a UI which performs an administrative role. */ public static final int ADMIN_UIROLE = 2; /** * Denotes a UI which performs the normal end user role. */ public static final int MAIN_UIROLE = 3; /** * Not a valid role but role id's greater than this may be used * for private roles supported by a service. Knowledge of the * function performed by this role is required to make proper use * of it. */ public static final int RESERVED_UIROLE = 99; /** * Get a UI object which may be cast to the requested UI type * by the application and used in its user interface. * <P> * @param role requested. Must be one of the standard roles or * a private role supported by this factory. * @param ui type in which the role is requested. * @return the UI role or null if the requested UI role is not available * from this factory * @throws <API key> if the role or ui is neither * one of the standard ones, nor a private one * supported by the factory. */ public abstract Object getUI(int role, String ui) ; /** * Given a UI role obtained from this factory obtain the UI * types available from this factory which implement this role. * The returned Strings should refer to the static variables defined * in this class so that applications can use equality of reference * ("=="). * @param role to be looked up. * @return the UI types supported by this class for the specified role, * null if no UIs are available for the role. * @throws <API key> is the role is a non-standard * role not supported by this factory. */ public abstract String[] <API key>(int role) ; }
/** * @file * Provides date format preview feature. */ (function ($, Drupal, drupalSettings) { "use strict"; var dateFormats = drupalSettings.dateFormats; /** * Display the preview for date format entered. * * @type {Drupal~behavior} * * @prop {Drupal~behaviorAttach} attach * Attach behavior for previewing date formats on input elements. */ Drupal.behaviors.dateFormat = { attach: function (context) { var $context = $(context); var $source = $context.find('[<API key>="source"]').once('dateFormat'); var $target = $context.find('[<API key>="preview"]').once('dateFormat'); var $preview = $target.find('em'); // All elements have to exist. if (!$source.length || !$target.length) { return; } /** * Event handler that replaces date characters with value. * * @param {jQuery.Event} e * The jQuery event triggered. */ function dateFormatHandler(e) { var baseValue = $(e.target).val() || ''; var dateString = baseValue.replace(/\\?(.?)/gi, function (key, value) { return dateFormats[key] ? dateFormats[key] : value; }); $preview.html(dateString); $target.toggleClass('js-hide', !dateString.length); } /** * On given event triggers the date character replacement. */ $source.on('keyup.dateFormat change.dateFormat input.dateFormat', dateFormatHandler) // Initialize preview. .trigger('keyup'); } }; })(jQuery, Drupal, drupalSettings);
<?php if (!defined('APPLICATION')) exit(); $Message = $this->_Message; if (is_array($Message)) { echo '<div class="DismissMessage'.($Message['CssClass'] == '' ? '' : ' '.$Message['CssClass']).'">'; $Session = Gdn::Session(); if ($Message['AllowDismiss'] == '1' && $Session->IsValid()) { echo Anchor('×', "/dashboard/message/dismiss/{$Message['MessageID']}/".$Session->TransientKey().'?Target='.$this->_Sender->SelfUrl, 'Dismiss'); } // echo Gdn_Format::To($this->_Message->Content, 'Html'); echo nl2br($Message['Content']); echo '</div>'; }
#include <linux/module.h> #include <linux/types.h> #include <linux/kernel.h> #include <linux/mtd/mtd.h> #include <linux/mtd/map.h> #include <linux/mtd/partitions.h> #include <asm/io.h> #include <msp_prom.h> #include <msp_regs.h> static struct mtd_info **msp_flash; static struct mtd_partition **msp_parts; static struct map_info *msp_maps; static int fcnt; #define DEBUG_MARKER printk(KERN_NOTICE "%s[%d]\n",__FUNCTION__,__LINE__) int __init init_msp_flash(void) { int i, j; int offset, coff; char *env; int pcnt; char flash_name[] = "flash0"; char part_name[] = "flash0_0"; unsigned addr, size; /* If ELB is disabled by "ful-mux" mode, we can't get at flash */ if ((*DEV_ID_REG & DEV_ID_SINGLE_PC) && (*ELB_1PC_EN_REG & SINGLE_PCCARD)) { printk(KERN_NOTICE "Single PC Card mode: no flash access\n"); return -ENXIO; } /* examine the prom environment for flash devices */ for (fcnt = 0; (env = prom_getenv(flash_name)); fcnt++) flash_name[5] = '0' + fcnt + 1; if (fcnt < 1) return -ENXIO; printk(KERN_NOTICE "Found %d PMC flash devices\n", fcnt); msp_flash = kmalloc(fcnt * sizeof(struct map_info *), GFP_KERNEL); msp_parts = kmalloc(fcnt * sizeof(struct mtd_partition *), GFP_KERNEL); msp_maps = kcalloc(fcnt, sizeof(struct mtd_info), GFP_KERNEL); if (!msp_flash || !msp_parts || !msp_maps) { kfree(msp_maps); kfree(msp_parts); kfree(msp_flash); return -ENOMEM; } /* loop over the flash devices, initializing each */ for (i = 0; i < fcnt; i++) { /* examine the prom environment for flash partititions */ part_name[5] = '0' + i; part_name[7] = '0'; for (pcnt = 0; (env = prom_getenv(part_name)); pcnt++) part_name[7] = '0' + pcnt + 1; if (pcnt == 0) { printk(KERN_NOTICE "Skipping flash device %d " "(no partitions defined)\n", i); continue; } msp_parts[i] = kcalloc(pcnt, sizeof(struct mtd_partition), GFP_KERNEL); /* now initialize the devices proper */ flash_name[5] = '0' + i; env = prom_getenv(flash_name); if (sscanf(env, "%x:%x", &addr, &size) < 2) return -ENXIO; addr = CPHYSADDR(addr); printk(KERN_NOTICE "MSP flash device \"%s\": 0x%08x at 0x%08x\n", flash_name, size, addr); /* This must matchs the actual size of the flash chip */ msp_maps[i].size = size; msp_maps[i].phys = addr; /* * Platforms have a specific limit of the size of memory * which may be mapped for flash: */ if (size > <API key>) size = <API key>; msp_maps[i].virt = ioremap(addr, size); msp_maps[i].bankwidth = 1; msp_maps[i].name = strncpy(kmalloc(7, GFP_KERNEL), flash_name, 7); if (msp_maps[i].virt == NULL) return -ENXIO; for (j = 0; j < pcnt; j++) { part_name[5] = '0' + i; part_name[7] = '0' + j; env = prom_getenv(part_name); if (sscanf(env, "%x:%x:%n", &offset, &size, &coff) < 2) return -ENXIO; msp_parts[i][j].size = size; msp_parts[i][j].offset = offset; msp_parts[i][j].name = env + coff; } /* now probe and add the device */ simple_map_init(&msp_maps[i]); msp_flash[i] = do_map_probe("cfi_probe", &msp_maps[i]); if (msp_flash[i]) { msp_flash[i]->owner = THIS_MODULE; add_mtd_partitions(msp_flash[i], msp_parts[i], pcnt); } else { printk(KERN_ERR "map probe failed for flash\n"); return -ENXIO; } } return 0; } static void __exit cleanup_msp_flash(void) { int i; for (i = 0; i < sizeof(msp_flash) / sizeof(struct mtd_info **); i++) { del_mtd_partitions(msp_flash[i]); map_destroy(msp_flash[i]); iounmap((void *)msp_maps[i].virt); /* free the memory */ kfree(msp_maps[i].name); kfree(msp_parts[i]); } kfree(msp_flash); kfree(msp_parts); kfree(msp_maps); } MODULE_AUTHOR("PMC-Sierra, Inc"); MODULE_DESCRIPTION("MTD map driver for PMC-Sierra MSP boards"); MODULE_LICENSE("GPL"); module_init(init_msp_flash); module_exit(cleanup_msp_flash);
#include <linux/clk.h> #include <linux/clockchips.h> #include <linux/init.h> #include <linux/interrupt.h> #include <linux/sched_clock.h> #include <linux/slab.h> #include <linux/of.h> #include <linux/of_address.h> #include <linux/of_irq.h> #define TIMER_NAME "rk_timer" #define TIMER_LOAD_COUNT0 0x00 #define TIMER_LOAD_COUNT1 0x04 #define <API key> 0x08 #define <API key> 0x0C #define <API key> 0x10 #define <API key> 0x1c #define TIMER_INT_STATUS 0x18 #define TIMER_DISABLE 0x0 #define TIMER_ENABLE 0x1 #define <API key> (0 << 1) #define <API key> (1 << 1) #define TIMER_INT_UNMASK (1 << 2) struct rk_timer { void __iomem *base; void __iomem *ctrl; struct clk *clk; struct clk *pclk; u32 freq; int irq; }; struct rk_clkevt { struct clock_event_device ce; struct rk_timer timer; }; static struct rk_clkevt *rk_clkevt; static struct rk_timer *rk_clksrc; static inline struct rk_timer *rk_timer(struct clock_event_device *ce) { return &container_of(ce, struct rk_clkevt, ce)->timer; } static inline void rk_timer_disable(struct rk_timer *timer) { writel_relaxed(TIMER_DISABLE, timer->ctrl); } static inline void rk_timer_enable(struct rk_timer *timer, u32 flags) { writel_relaxed(TIMER_ENABLE | flags, timer->ctrl); } static void <API key>(unsigned long cycles, struct rk_timer *timer) { writel_relaxed(cycles, timer->base + TIMER_LOAD_COUNT0); writel_relaxed(0, timer->base + TIMER_LOAD_COUNT1); } static void <API key>(struct rk_timer *timer) { writel_relaxed(1, timer->base + TIMER_INT_STATUS); } static inline int <API key>(unsigned long cycles, struct clock_event_device *ce) { struct rk_timer *timer = rk_timer(ce); rk_timer_disable(timer); <API key>(cycles, timer); rk_timer_enable(timer, <API key> | TIMER_INT_UNMASK); return 0; } static int rk_timer_shutdown(struct clock_event_device *ce) { struct rk_timer *timer = rk_timer(ce); rk_timer_disable(timer); return 0; } static int <API key>(struct clock_event_device *ce) { struct rk_timer *timer = rk_timer(ce); rk_timer_disable(timer); <API key>(timer->freq / HZ - 1, timer); rk_timer_enable(timer, <API key> | TIMER_INT_UNMASK); return 0; } static irqreturn_t rk_timer_interrupt(int irq, void *dev_id) { struct clock_event_device *ce = dev_id; struct rk_timer *timer = rk_timer(ce); <API key>(timer); if (<API key>(ce)) rk_timer_disable(timer); ce->event_handler(ce); return IRQ_HANDLED; } static u64 notrace rk_timer_sched_read(void) { return ~readl_relaxed(rk_clksrc->base + <API key>); } static int __init rk_timer_probe(struct rk_timer *timer, struct device_node *np) { struct clk *timer_clk; struct clk *pclk; int ret = -EINVAL, irq; u32 ctrl_reg = <API key>; timer->base = of_iomap(np, 0); if (!timer->base) { pr_err("Failed to get base address for '%s'\n", TIMER_NAME); return -ENXIO; } if (<API key>(np, "rockchip,rk3399-timer")) ctrl_reg = <API key>; timer->ctrl = timer->base + ctrl_reg; pclk = of_clk_get_by_name(np, "pclk"); if (IS_ERR(pclk)) { ret = PTR_ERR(pclk); pr_err("Failed to get pclk for '%s'\n", TIMER_NAME); goto out_unmap; } ret = clk_prepare_enable(pclk); if (ret) { pr_err("Failed to enable pclk for '%s'\n", TIMER_NAME); goto out_unmap; } timer->pclk = pclk; timer_clk = of_clk_get_by_name(np, "timer"); if (IS_ERR(timer_clk)) { ret = PTR_ERR(timer_clk); pr_err("Failed to get timer clock for '%s'\n", TIMER_NAME); goto out_timer_clk; } ret = clk_prepare_enable(timer_clk); if (ret) { pr_err("Failed to enable timer clock\n"); goto out_timer_clk; } timer->clk = timer_clk; timer->freq = clk_get_rate(timer_clk); irq = <API key>(np, 0); if (!irq) { ret = -EINVAL; pr_err("Failed to map interrupts for '%s'\n", TIMER_NAME); goto out_irq; } timer->irq = irq; <API key>(timer); rk_timer_disable(timer); return 0; out_irq: <API key>(timer_clk); out_timer_clk: <API key>(pclk); out_unmap: iounmap(timer->base); return ret; } static void __init rk_timer_cleanup(struct rk_timer *timer) { <API key>(timer->clk); <API key>(timer->pclk); iounmap(timer->base); } static int __init rk_clkevt_init(struct device_node *np) { struct clock_event_device *ce; int ret = -EINVAL; rk_clkevt = kzalloc(sizeof(struct rk_clkevt), GFP_KERNEL); if (!rk_clkevt) { ret = -ENOMEM; goto out; } ret = rk_timer_probe(&rk_clkevt->timer, np); if (ret) goto out_probe; ce = &rk_clkevt->ce; ce->name = TIMER_NAME; ce->features = <API key> | <API key> | <API key>; ce->set_next_event = <API key>; ce->set_state_shutdown = rk_timer_shutdown; ce->set_state_periodic = <API key>; ce->irq = rk_clkevt->timer.irq; ce->cpumask = cpu_possible_mask; ce->rating = 250; ret = request_irq(rk_clkevt->timer.irq, rk_timer_interrupt, IRQF_TIMER, TIMER_NAME, ce); if (ret) { pr_err("Failed to initialize '%s': %d\n", TIMER_NAME, ret); goto out_irq; } <API key>(&rk_clkevt->ce, rk_clkevt->timer.freq, 1, UINT_MAX); return 0; out_irq: rk_timer_cleanup(&rk_clkevt->timer); out_probe: kfree(rk_clkevt); out: /* Leave rk_clkevt not NULL to prevent future init */ rk_clkevt = ERR_PTR(ret); return ret; } static int __init rk_clksrc_init(struct device_node *np) { int ret = -EINVAL; rk_clksrc = kzalloc(sizeof(struct rk_timer), GFP_KERNEL); if (!rk_clksrc) { ret = -ENOMEM; goto out; } ret = rk_timer_probe(rk_clksrc, np); if (ret) goto out_probe; <API key>(UINT_MAX, rk_clksrc); rk_timer_enable(rk_clksrc, 0); ret = <API key>(rk_clksrc->base + <API key>, TIMER_NAME, rk_clksrc->freq, 250, 32, <API key>); if (ret) { pr_err("Failed to register clocksource"); goto out_clocksource; } <API key>(rk_timer_sched_read, 32, rk_clksrc->freq); return 0; out_clocksource: rk_timer_cleanup(rk_clksrc); out_probe: kfree(rk_clksrc); out: /* Leave rk_clksrc not NULL to prevent future init */ rk_clksrc = ERR_PTR(ret); return ret; } static int __init rk_timer_init(struct device_node *np) { if (!rk_clkevt) return rk_clkevt_init(np); if (!rk_clksrc) return rk_clksrc_init(np); pr_err("Too many timer definitions for '%s'\n", TIMER_NAME); return -EINVAL; } <API key>(rk3288_timer, "rockchip,rk3288-timer", rk_timer_init); <API key>(rk3399_timer, "rockchip,rk3399-timer", rk_timer_init);
<?php // Moodle is free software: you can redistribute it and/or modify // (at your option) any later version. // Moodle is distributed in the hope that it will be useful, // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the defined('MOODLE_INTERNAL') || die(); /** * Quiz overview report upgrade function. * @param number $oldversion */ function <API key>($oldversion) { global $CFG, $DB; $dbman = $DB->get_manager(); // Moodle v2.2.0 release upgrade line. // Put any upgrade step following this. // Moodle v2.3.0 release upgrade line // Put any upgrade step following this return true; }
""" Shogun demo Fernando J. Iglesias Garcia This example shows the use of dimensionality reduction methods, mainly Stochastic Proximity Embedding (SPE), although Isomap is also used for comparison. The data selected to be embedded is an helix. Two different methods of SPE (global and local) are applied showing that the global method outperforms the local one in this case. Actually the results of local SPE are fairly poor for this input. Finally, the reduction achieved with Isomap is better than the two previous ones, more robust against noise. Isomap exploits the parametrization of the input data. """ import math import mpl_toolkits.mplot3d as mpl3 import numpy as np import pylab import util from modshogun import RealFeatures from modshogun import <API key>, SPE_GLOBAL from modshogun import SPE_LOCAL, Isomap # Number of data points N = 500 # Generate helix t = np.linspace(1, N, N).T / N t = t*2*math.pi X = np.r_[ [ ( 2 + np.cos(8*t) ) * np.cos(t) ], [ ( 2 + np.cos(8*t) ) * np.sin(t) ], [ np.sin(8*t) ] ] # Bi-color helix labels = np.round( (t*1.5) ) % 2 y1 = labels == 1 y2 = labels == 0 # Plot helix fig = pylab.figure() fig.add_subplot(2, 2, 1, projection = '3d') pylab.plot(X[0, y1], X[1, y1], X[2, y1], 'ro') pylab.plot(X[0, y2], X[1, y2], X[2, y2], 'go') pylab.title('Original 3D Helix') # Create features instance features = RealFeatures(X) # Create Stochastic Proximity Embedding converter instance converter = <API key>() # Set target dimensionality converter.set_target_dim(2) # Set strategy converter.set_strategy(SPE_GLOBAL) # Compute SPE embedding embedding = converter.embed(features) X = embedding.get_feature_matrix() fig.add_subplot(2, 2, 2) pylab.plot(X[0, y1], X[1, y1], 'ro') pylab.plot(X[0, y2], X[1, y2], 'go') pylab.title('SPE with global strategy') # Compute a second SPE embedding with local strategy converter.set_strategy(SPE_LOCAL) converter.set_k(12) embedding = converter.embed(features) X = embedding.get_feature_matrix() fig.add_subplot(2, 2, 3) pylab.plot(X[0, y1], X[1, y1], 'ro') pylab.plot(X[0, y2], X[1, y2], 'go') pylab.title('SPE with local strategy') # Compute Isomap embedding (for comparison) converter = Isomap() converter.set_target_dim(2) converter.set_k(6) embedding = converter.embed(features) X = embedding.get_feature_matrix() fig.add_subplot(2, 2, 4) pylab.plot(X[0, y1], X[1, y1], 'ro') pylab.plot(X[0, y2], X[1, y2], 'go') pylab.title('Isomap') pylab.connect('key_press_event', util.quit) pylab.show()
'use strict'; exports.__esModule = true; exports['default'] = deprecated; function <API key>(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _warning = require('warning'); var _warning2 = <API key>(_warning); function deprecated(propType, explanation) { return function validate(props, propName, componentName) { if (props[propName] != null) { _warning2['default'](false, '"' + propName + '" property of "' + componentName + '" has been deprecated.\n' + explanation); } return propType(props, propName, componentName); }; } module.exports = exports['default'];
#include <windows.h> #include <atlstr.h> #include <wincrypt.h> #include <wintrust.h> #include "base/base_paths.h" #include "base/basictypes.h" #include "base/compiler_specific.h" #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/logging.h" #include "base/path_service.h" #include "base/strings/<API key>.h" #include "base/strings/string_piece.h" #include "base/strings/string_util.h" #include "chrome/app/<API key>.h" #include "crypto/sha2.h" #include "net/cert/test_root_certs.h" #include "testing/gtest/include/gtest/gtest.h" namespace { const char kGoogleCertIssuer[] = "Google Inc"; const int CERT_BUFFER_SIZE = 1024; const base::FilePath::CharType <API key>[] = FILE_PATH_LITERAL("chrome\\app\\test_data\\certificates\\"); const base::FilePath::CharType kDLLRelativePath[] = FILE_PATH_LITERAL("chrome\\app\\test_data\\dlls\\"); class <API key> : public testing::Test { protected: <API key>() {} void SetUp() OVERRIDE { test_roots_ = net::TestRootCerts::GetInstance(); base::FilePath cert_path = <API key>().Append(L"AuthorityCert.cer"); base::FilePath other_cert_path = <API key>().Append(L"OtherAuthorityCert.cer"); test_roots_->AddFromFile(cert_path); test_roots_->AddFromFile(other_cert_path); EXPECT_FALSE(test_roots_->IsEmpty()); SetExpectedHash(<API key>().Append(L"ValidCert.cer")); } void TearDown() OVERRIDE { test_roots_->Clear(); EXPECT_TRUE(test_roots_->IsEmpty()); } base::FilePath <API key>() { base::FilePath src_root; PathService::Get(base::DIR_SOURCE_ROOT, &src_root); return src_root.Append(<API key>); } base::FilePath <API key>() { base::FilePath src_root; PathService::Get(base::DIR_SOURCE_ROOT, &src_root); return src_root.Append(kDLLRelativePath); } void SetExpectedHash(const base::FilePath& cert_path) { char cert_buffer[CERT_BUFFER_SIZE]; base::ReadFile(cert_path, cert_buffer, CERT_BUFFER_SIZE); PCCERT_CONTEXT cert = <API key>(X509_ASN_ENCODING, reinterpret_cast<byte*>(&cert_buffer), CERT_BUFFER_SIZE); CRYPT_BIT_BLOB blob = cert->pCertInfo-><API key>.PublicKey; size_t public_key_length = blob.cbData; uint8* public_key = blob.pbData; uint8 hash[crypto::kSHA256Length] = {0}; base::StringPiece key_bytes(reinterpret_cast<char*>(public_key), public_key_length); crypto::SHA256HashString(key_bytes, hash, crypto::kSHA256Length); std::string public_key_hash = base::StringToLowerASCII(base::HexEncode(hash, arraysize(hash))); expected_hashes_.push_back(public_key_hash); } void RunTest(const wchar_t* dll_filename, bool isValid, bool isGoogle) { base::FilePath full_dll_path = <API key>().Append(dll_filename); ASSERT_EQ(isValid, Verify<API key>(full_dll_path)); ASSERT_EQ(isGoogle, <API key>(full_dll_path, kGoogleCertIssuer, expected_hashes_)); } private: net::TestRootCerts* test_roots_; std::vector<std::string> expected_hashes_; }; } // namespace TEST_F(<API key>, ValidSigTest) { RunTest(L"valid_sig.dll", true, true); } TEST_F(<API key>, SelfSignedTest) { RunTest(L"self_signed.dll", false, false); } TEST_F(<API key>, NotSignedTest) { RunTest(L"not_signed.dll", false, false); } TEST_F(<API key>, NotGoogleTest) { RunTest(L"not_google.dll", true, false); } TEST_F(<API key>, CertPinningTest) { RunTest(L"different_hash.dll", true, false); } TEST_F(<API key>, ExpiredCertTest) { //TODO(caitkp): Figure out how to sign a dll with an expired cert. RunTest(L"expired.dll", false, false); }
#ifndef <API key> #define <API key> #include <gnuradio/analog/api.h> #include <gnuradio/sync_block.h> namespace gr { namespace analog { /*! * \brief quadrature demodulator: complex in, float out * \ingroup modulators_blk * * \details * This can be used to demod FM, FSK, GMSK, etc. The input is complex * baseband, output is the signal frequency in relation to the sample * rated, multiplied with the gain. * * Mathematically, this block calculates the product of the one-sample * delayed input and the conjugate undelayed signal, and then calculates * the argument of the resulting complex number: * * \f$y[n] = \mathrm{arg}\left(x[n] \, \bar x [n-1]\right)\f$. * * Let \f$x\f$ be a complex sinusoid with amplitude \f$A>0\f$, (absolute) * frequency \f$f\in\mathbb R\f$ and phase \f$\phi_0\in[0;2\pi]\f$ sampled at * \f$f_s>0\f$ so, without loss of generality, * * \f$x[n]= A e^{j2\pi( \frac f{f_s} n + \phi_0)}\f$ * * then * * \f{align*}{ y[n] &= \mathrm{arg}\left(A e^{j2\pi\left( \frac f{f_s} n + \phi_0\right)} \overline{A e^{j2\pi( \frac f{f_s} (n-1) + \phi_0)}}\right)\\ * & = \mathrm{arg}\left(A^2 e^{j2\pi\left( \frac f{f_s} n + \phi_0\right)} e^{-j2\pi( \frac f{f_s} (n-1) + \phi_0)}\right)\\ * & = \mathrm{arg}\left( A^2 e^{j2\pi\left( \frac f{f_s} n + \phi_0 - \frac f{f_s} (n-1) - \phi_0\right)}\right)\\ * & = \mathrm{arg}\left( A^2 e^{j2\pi\left( \frac f{f_s} n - \frac f{f_s} (n-1)\right)}\right)\\ * & = \mathrm{arg}\left( A^2 e^{j2\pi\left( \frac f{f_s} \left(n-(n-1)\right)\right)}\right)\\ * & = \mathrm{arg}\left( A^2 e^{j2\pi \frac f{f_s}}\right) \intertext{$A$ is real, so is $A^2$ and hence only \textit{scales}, therefore $\mathrm{arg}(\cdot)$ is invariant:} &= \mathrm{arg}\left(e^{j2\pi \frac f{f_s}}\right)\\ * &= \frac f{f_s}\\ * &&\blacksquare * \f} */ class ANALOG_API quadrature_demod_cf : virtual public sync_block { public: // gr::analog::quadrature_demod_cf::sptr typedef boost::shared_ptr<quadrature_demod_cf> sptr; /* \brief Make a quadrature demodulator block. * * \param gain Gain setting to adjust the output amplitude. Set * based on converting the phase difference between * samples to a nominal output value. */ static sptr make(float gain); virtual void set_gain(float gain) = 0; virtual float gain() const = 0; }; } /* namespace analog */ } /* namespace gr */ #endif /* <API key> */
package docker import ( "bytes" "fmt" "regexp" "github.com/hashicorp/terraform/helper/hashcode" "github.com/hashicorp/terraform/helper/schema" ) func <API key>() *schema.Resource { return &schema.Resource{ Create: <API key>, Read: <API key>, Update: <API key>, Delete: <API key>, Schema: map[string]*schema.Schema{ "name": &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, }, // Indicates whether the container must be running. // An assumption is made that configured containers // should be running; if not, they should not be in // the configuration. Therefore a stopped container // should be started. Set to false to have the // provider leave the container alone. // Actively-debugged containers are likely to be // stopped and started manually, and Docker has // some provisions for restarting containers that // stop. The utility here comes from the fact that // this will delete and re-create the container // following the principle that the containers // should be pristine when started. "must_run": &schema.Schema{ Type: schema.TypeBool, Default: true, Optional: true, }, // ForceNew is not true for image because we need to // sane this against Docker image IDs, as each image // can have multiple names/tags attached do it. "image": &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, }, "hostname": &schema.Schema{ Type: schema.TypeString, Optional: true, ForceNew: true, }, "domainname": &schema.Schema{ Type: schema.TypeString, Optional: true, ForceNew: true, }, "command": &schema.Schema{ Type: schema.TypeList, Optional: true, ForceNew: true, Elem: &schema.Schema{Type: schema.TypeString}, }, "entrypoint": &schema.Schema{ Type: schema.TypeList, Optional: true, ForceNew: true, Elem: &schema.Schema{Type: schema.TypeString}, }, "user": &schema.Schema{ Type: schema.TypeString, Optional: true, ForceNew: true, Elem: &schema.Schema{Type: schema.TypeString}, }, "dns": &schema.Schema{ Type: schema.TypeSet, Optional: true, ForceNew: true, Elem: &schema.Schema{Type: schema.TypeString}, Set: schema.HashString, }, "dns_opts": &schema.Schema{ Type: schema.TypeSet, Optional: true, ForceNew: true, Elem: &schema.Schema{Type: schema.TypeString}, Set: schema.HashString, }, "dns_search": &schema.Schema{ Type: schema.TypeSet, Optional: true, ForceNew: true, Elem: &schema.Schema{Type: schema.TypeString}, Set: schema.HashString, }, "publish_all_ports": &schema.Schema{ Type: schema.TypeBool, Optional: true, ForceNew: true, }, "restart": &schema.Schema{ Type: schema.TypeString, Optional: true, ForceNew: true, Default: "no", ValidateFunc: func(v interface{}, k string) (ws []string, es []error) { value := v.(string) if !regexp.MustCompile(`^(no|on-failure|always|unless-stopped)$`).MatchString(value) { es = append(es, fmt.Errorf( "%q must be one of \"no\", \"on-failure\", \"always\" or \"unless-stopped\"", k)) } return }, }, "max_retry_count": &schema.Schema{ Type: schema.TypeInt, Optional: true, ForceNew: true, }, "volumes": &schema.Schema{ Type: schema.TypeSet, Optional: true, ForceNew: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "from_container": &schema.Schema{ Type: schema.TypeString, Optional: true, ForceNew: true, }, "container_path": &schema.Schema{ Type: schema.TypeString, Optional: true, ForceNew: true, }, "host_path": &schema.Schema{ Type: schema.TypeString, Optional: true, ForceNew: true, ValidateFunc: func(v interface{}, k string) (ws []string, es []error) { value := v.(string) if !regexp.MustCompile(`^/`).MatchString(value) { es = append(es, fmt.Errorf( "%q must be an absolute path", k)) } return }, }, "volume_name": &schema.Schema{ Type: schema.TypeString, Optional: true, ForceNew: true, }, "read_only": &schema.Schema{ Type: schema.TypeBool, Optional: true, ForceNew: true, }, }, }, Set: <API key>, }, "ports": &schema.Schema{ Type: schema.TypeSet, Optional: true, ForceNew: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "internal": &schema.Schema{ Type: schema.TypeInt, Required: true, ForceNew: true, }, "external": &schema.Schema{ Type: schema.TypeInt, Optional: true, ForceNew: true, }, "ip": &schema.Schema{ Type: schema.TypeString, Optional: true, ForceNew: true, }, "protocol": &schema.Schema{ Type: schema.TypeString, Default: "tcp", Optional: true, ForceNew: true, }, }, }, Set: <API key>, }, "host": &schema.Schema{ Type: schema.TypeSet, Optional: true, ForceNew: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "ip": &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, }, "host": &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, }, }, }, Set: <API key>, }, "env": &schema.Schema{ Type: schema.TypeSet, Optional: true, ForceNew: true, Elem: &schema.Schema{Type: schema.TypeString}, Set: schema.HashString, }, "links": &schema.Schema{ Type: schema.TypeSet, Optional: true, ForceNew: true, Elem: &schema.Schema{Type: schema.TypeString}, Set: schema.HashString, }, "ip_address": &schema.Schema{ Type: schema.TypeString, Computed: true, }, "ip_prefix_length": &schema.Schema{ Type: schema.TypeInt, Computed: true, }, "gateway": &schema.Schema{ Type: schema.TypeString, Computed: true, }, "bridge": &schema.Schema{ Type: schema.TypeString, Computed: true, }, "privileged": &schema.Schema{ Type: schema.TypeBool, Optional: true, ForceNew: true, }, "<API key>": &schema.Schema{ Type: schema.TypeInt, Optional: true, }, "labels": &schema.Schema{ Type: schema.TypeMap, Optional: true, ForceNew: true, }, "memory": &schema.Schema{ Type: schema.TypeInt, Optional: true, ForceNew: true, ValidateFunc: func(v interface{}, k string) (ws []string, es []error) { value := v.(int) if value < 0 { es = append(es, fmt.Errorf("%q must be greater than or equal to 0", k)) } return }, }, "memory_swap": &schema.Schema{ Type: schema.TypeInt, Optional: true, ForceNew: true, ValidateFunc: func(v interface{}, k string) (ws []string, es []error) { value := v.(int) if value < -1 { es = append(es, fmt.Errorf("%q must be greater than or equal to -1", k)) } return }, }, "cpu_shares": &schema.Schema{ Type: schema.TypeInt, Optional: true, ForceNew: true, ValidateFunc: func(v interface{}, k string) (ws []string, es []error) { value := v.(int) if value < 0 { es = append(es, fmt.Errorf("%q must be greater than or equal to 0", k)) } return }, }, "log_driver": &schema.Schema{ Type: schema.TypeString, Optional: true, ForceNew: true, Default: "json-file", ValidateFunc: func(v interface{}, k string) (ws []string, es []error) { value := v.(string) if !regexp.MustCompile(`^(json-file|syslog|journald|gelf|fluentd)$`).MatchString(value) { es = append(es, fmt.Errorf( "%q must be one of \"json-file\", \"syslog\", \"journald\", \"gelf\", or \"fluentd\"", k)) } return }, }, "log_opts": &schema.Schema{ Type: schema.TypeMap, Optional: true, ForceNew: true, }, "network_mode": &schema.Schema{ Type: schema.TypeString, Optional: true, ForceNew: true, }, "networks": &schema.Schema{ Type: schema.TypeSet, Optional: true, ForceNew: true, Elem: &schema.Schema{Type: schema.TypeString}, Set: schema.HashString, }, "upload": &schema.Schema{ Type: schema.TypeSet, Optional: true, ForceNew: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "content": &schema.Schema{ Type: schema.TypeString, Required: true, // This is intentional. The container is mutated once, and never updated later. // New configuration forces a new deployment, even with the same binaries. ForceNew: true, }, "file": &schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, }, }, }, Set: <API key>, }, }, } } func <API key>(v interface{}) int { var buf bytes.Buffer m := v.(map[string]interface{}) buf.WriteString(fmt.Sprintf("%v-", m["internal"].(int))) if v, ok := m["external"]; ok { buf.WriteString(fmt.Sprintf("%v-", v.(int))) } if v, ok := m["ip"]; ok { buf.WriteString(fmt.Sprintf("%v-", v.(string))) } if v, ok := m["protocol"]; ok { buf.WriteString(fmt.Sprintf("%v-", v.(string))) } return hashcode.String(buf.String()) } func <API key>(v interface{}) int { var buf bytes.Buffer m := v.(map[string]interface{}) if v, ok := m["ip"]; ok { buf.WriteString(fmt.Sprintf("%v-", v.(string))) } if v, ok := m["host"]; ok { buf.WriteString(fmt.Sprintf("%v-", v.(string))) } return hashcode.String(buf.String()) } func <API key>(v interface{}) int { var buf bytes.Buffer m := v.(map[string]interface{}) if v, ok := m["from_container"]; ok { buf.WriteString(fmt.Sprintf("%v-", v.(string))) } if v, ok := m["container_path"]; ok { buf.WriteString(fmt.Sprintf("%v-", v.(string))) } if v, ok := m["host_path"]; ok { buf.WriteString(fmt.Sprintf("%v-", v.(string))) } if v, ok := m["volume_name"]; ok { buf.WriteString(fmt.Sprintf("%v-", v.(string))) } if v, ok := m["read_only"]; ok { buf.WriteString(fmt.Sprintf("%v-", v.(bool))) } return hashcode.String(buf.String()) } func <API key>(v interface{}) int { var buf bytes.Buffer m := v.(map[string]interface{}) if v, ok := m["content"]; ok { buf.WriteString(fmt.Sprintf("%v-", v.(string))) } if v, ok := m["file"]; ok { buf.WriteString(fmt.Sprintf("%v-", v.(string))) } return hashcode.String(buf.String()) }
#include "unp.h" #include <stropts.h> int main(int argc, char *argv[]) { int fd, i, nmods; struct str_list list; if (argc != 2) err_quit("usage: a.out { tcp | udp }"); fd = Socket(AF_INET, (strcmp(argv[1], "tcp") == 0) ? SOCK_STREAM : SOCK_DGRAM, 0); if (isastream(fd) == 0) err_quit("%s is not a stream", argv[1]); list.sl_nmods = nmods = Ioctl(fd, I_LIST, (void *) 0); printf("%d modules\n", nmods); list.sl_modlist = Calloc(nmods, sizeof(struct str_mlist)); Ioctl(fd, I_LIST, &list); for (i = 1; i <= nmods; i++) printf(" %s: %s\n", (i == nmods) ? "driver" : "module", list.sl_modlist++); exit(0); }
<?php final class MultimeterControl extends Phobject { private static $instance; private $events = array(); private $sampleRate; private $pauseDepth; private $eventViewer; private $eventContext; private function __construct() { // Private. } public static function newInstance() { $instance = new MultimeterControl(); // NOTE: We don't set the sample rate yet. This allows the multimeter to // be initialized and begin recording events, then make a decision about // whether the page will be sampled or not later on (once we've loaded // enough configuration). self::$instance = $instance; return self::getInstance(); } public static function getInstance() { return self::$instance; } public function isActive() { return ($this->sampleRate !== 0) && ($this->pauseDepth == 0); } public function setSampleRate($rate) { if ($rate && (mt_rand(1, $rate) == $rate)) { $sample_rate = $rate; } else { $sample_rate = 0; } $this->sampleRate = $sample_rate; return; } public function pauseMultimeter() { $this->pauseDepth++; return $this; } public function unpauseMultimeter() { if (!$this->pauseDepth) { throw new Exception(pht('Trying to unpause an active multimeter!')); } $this->pauseDepth return $this; } public function newEvent($type, $label, $cost) { if (!$this->isActive()) { return null; } $event = id(new MultimeterEvent()) ->setEventType($type) ->setEventLabel($label) ->setResourceCost($cost) ->setEpoch(PhabricatorTime::getNow()); $this->events[] = $event; return $event; } public function saveEvents() { if (!$this->isActive()) { return; } $events = $this->events; if (!$events) { return; } if ($this->sampleRate === null) { throw new <API key>('setSampleRate'); } $this->addServiceEvents(); // Don't sample any of this stuff. $this->pauseMultimeter(); $use_scope = AphrontWriteGuard::isGuardActive(); if ($use_scope) { $unguarded = AphrontWriteGuard::<API key>(); } else { AphrontWriteGuard::<API key>(true); } $caught = null; try { $this->writeEvents(); } catch (Exception $ex) { $caught = $ex; } if ($use_scope) { unset($unguarded); } else { AphrontWriteGuard::<API key>(false); } $this->unpauseMultimeter(); if ($caught) { throw $caught; } } private function writeEvents() { $events = $this->events; $random = Filesystem::readRandomBytes(32); $request_key = PhabricatorHash::digestForIndex($random); $host_id = $this->loadHostID(php_uname('n')); $context_id = $this->loadEventContextID($this->eventContext); $viewer_id = $this->loadEventViewerID($this->eventViewer); $label_map = $this->loadEventLabelIDs(mpull($events, 'getEventLabel')); foreach ($events as $event) { $event ->setRequestKey($request_key) ->setSampleRate($this->sampleRate) ->setEventHostID($host_id) ->setEventContextID($context_id) ->setEventViewerID($viewer_id) ->setEventLabelID($label_map[$event->getEventLabel()]) ->save(); } } public function setEventContext($event_context) { $this->eventContext = $event_context; return $this; } public function getEventContext() { return $this->eventContext; } public function setEventViewer($viewer) { $this->eventViewer = $viewer; return $this; } private function loadHostID($host) { $map = $this->loadDimensionMap(new MultimeterHost(), array($host)); return idx($map, $host); } private function loadEventViewerID($viewer) { $map = $this->loadDimensionMap(new MultimeterViewer(), array($viewer)); return idx($map, $viewer); } private function loadEventContextID($context) { $map = $this->loadDimensionMap(new MultimeterContext(), array($context)); return idx($map, $context); } private function loadEventLabelIDs(array $labels) { return $this->loadDimensionMap(new MultimeterLabel(), $labels); } private function loadDimensionMap(MultimeterDimension $table, array $names) { $hashes = array(); foreach ($names as $name) { $hashes[] = PhabricatorHash::digestForIndex($name); } $objects = $table->loadAllWhere('nameHash IN (%Ls)', $hashes); $map = mpull($objects, 'getID', 'getName'); $need = array(); foreach ($names as $name) { if (isset($map[$name])) { continue; } $need[$name] = $name; } foreach ($need as $name) { $object = id(clone $table) ->setName($name) ->save(); $map[$name] = $object->getID(); } return $map; } private function addServiceEvents() { $events = <API key>::getInstance()->getServiceCallLog(); foreach ($events as $event) { $type = idx($event, 'type'); switch ($type) { case 'exec': $this->newEvent( MultimeterEvent::TYPE_EXEC_TIME, $label = $this-><API key>($event['command']), (1000000 * $event['duration'])); break; } } } private function <API key>($command) { $argv = preg_split('/\s+/', $command); $bin = array_shift($argv); $bin = basename($bin); $bin = trim($bin, '"\''); // It's important to avoid leaking details about command parameters, // because some may be sensitive. Given this, it's not trivial to // determine which parts of a command are arguments and which parts are // flags. // Rather than try too hard for now, just whitelist some workflows that we // know about and record everything else generically. Overall, this will // produce labels like "pygmentize" or "git log", discarding all flags and // arguments. $workflows = array( 'git' => array( 'log' => true, 'for-each-ref' => true, 'pull' => true, 'clone' => true, 'fetch' => true, 'cat-file' => true, 'init' => true, 'config' => true, 'remote' => true, 'rev-parse' => true, 'diff' => true, 'ls-tree' => true, ), 'svn' => array( 'log' => true, 'diff' => true, ), 'hg' => array( 'log' => true, 'locate' => true, 'pull' => true, 'clone' => true, 'init' => true, 'diff' => true, 'cat' => true, ), 'svnadmin' => array( 'create' => true, ), ); $workflow = null; $candidates = idx($workflows, $bin); if ($candidates) { foreach ($argv as $arg) { if (isset($candidates[$arg])) { $workflow = $arg; break; } } } if ($workflow) { return 'bin.'.$bin.' '.$workflow; } else { return 'bin.'.$bin; } } }
using System; using System.Composition; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.VisualStudio.Text; namespace Microsoft.CodeAnalysis.Editor.Shared { [<API key>(typeof(<API key>), ServiceLayer.Editor), Shared] internal sealed class <API key> : <API key> { [<API key>] [Obsolete(MefConstruction.<API key>, error: true)] public <API key>() { } public bool SupportsCodeFixes(ITextBuffer textBuffer) => true; public bool <API key>(ITextBuffer textBuffer) => true; public bool SupportsRename(ITextBuffer textBuffer) => true; public bool <API key>(ITextBuffer textBuffer) => true; } }
/** * @fileoverview Rule to flag duplicate arguments * @author Jamund Ferguson */ "use strict"; // Rule Definition module.exports = { meta: { type: "problem", docs: { description: "disallow duplicate arguments in `function` definitions", category: "Possible Errors", recommended: true, url: "https://eslint.org/docs/rules/no-dupe-args" }, schema: [], messages: { unexpected: "Duplicate param '{{name}}'." } }, create(context) { // Helpers /** * Checks whether or not a given definition is a parameter's. * @param {eslint-scope.DefEntry} def - A definition to check. * @returns {boolean} `true` if the definition is a parameter's. */ function isParameter(def) { return def.type === "Parameter"; } /** * Determines if a given node has duplicate parameters. * @param {ASTNode} node The node to check. * @returns {void} * @private */ function checkParams(node) { const variables = context.<API key>(node); for (let i = 0; i < variables.length; ++i) { const variable = variables[i]; // Checks and reports duplications. const defs = variable.defs.filter(isParameter); if (defs.length >= 2) { context.report({ node, messageId: "unexpected", data: { name: variable.name } }); } } } // Public API return { FunctionDeclaration: checkParams, FunctionExpression: checkParams }; } };
@echo off java -cp lib\axiom-1.2.11.wso2v1.jar;lib\axis2-1.6.1.wso2v4.jar;lib\commons-codec-1.3.0.wso2v1.jar;lib\<API key>.1.0.wso2v1.jar;lib\commons-logging-1.1.1.jar;lib\httpcore-4.1.0.wso2v1.jar;lib\neethi-2.0.4.wso2v3.jar;lib\org.wso2.carbon.identity.entitlement.stub_4.0.7.jar;lib\org.wso2.carbon.um.ws.api.stub-4.0.8.jar;lib\org.wso2.securevault-1.0.0.jar;lib\wsdl4j-1.6.2.wso2v2.jar;lib\XmlSchema-1.4.7.wso2v1.jar;target\org.wso2.carbon.identity.samples.entitlement.kmarket.trading-1.0.0.jar org.wso2.carbon.identity.samples.entitlement.kmarket.trading.<API key> setup
#import <Foundation/Foundation.h> #pragma mark * MSSerializer Protocol // The |MSSerializer| protocol defines serializers that can serialize // items into instances of NSData and vice-versa. It does require that // item instances have an associated id that is an unsigned 64-bit integer. @protocol MSSerializer <NSObject> @required #pragma mark * Serialization Methods // Called for updates and inserts so that the item can be serialized into // an |NSData| instance. Inserts are not allows to have items that already have // an id. -(NSData *)dataFromItem:(id)item idAllowed:(BOOL)idAllowed ensureDictionary:(BOOL)ensureDictionary <API key>:(BOOL)<API key> orError:(NSError **)error; // Called to obtain the id of an item. -(id)itemIdFromItem:(id)item orError:(NSError **)error; // Called to obtain a string representation of an id of an item. -(NSString *)stringFromItemId:(id)itemId orError:(NSError **)error; // Called to get a string id only from a given item -(NSString *) stringIdFromItem:(NSDictionary *)item orError:(NSError **)error; #pragma mark * Deserialization Methods // Called for updates and inserts when the data will be a single item. If // the original item is--that is the item that was serialized and // sent in the update or insert--is non-nil, it should be updated with // the values from the item deserialized from the data. -(id)itemFromData:(NSData *)data withOriginalItem:(id)originalItem ensureDictionary:(BOOL)ensureDictionary orError:(NSError **)error; // Called to deserialize a response to an NSArray -(NSArray *) arrayFromData:(NSData *)data orError:(NSError **)error; // Called for reads when the data will either by an array of items or // an array of items and a total count. After returning, either the items // parameter or the error parameter (but not both) will be set. The // return value will be the total count, if it was requested or -1 otherwise. -(NSInteger)totalCountAndItems:(NSArray **)items fromData:(NSData *)data orError:(NSError **)error; // Called when the data is expected to have an error message instead of // an item; for example, if the HTTP response status code was >= 400. May // return nil if no error message could be obtained from the data. -(NSError *)errorFromData:(NSData *)data MIMEType:(NSString *)MIMEType; - (void) <API key>:(NSMutableDictionary *) item; @end
using System; using System.Globalization; using System.Threading; using System.Xml.Linq; using Autofac; using Moq; using NHibernate; using NUnit.Framework; using Orchard.Caching; using Orchard.ContentManagement.FieldStorage.InfosetStorage; using Orchard.ContentManagement.MetaData; using Orchard.ContentManagement.MetaData.Models; using Orchard.ContentManagement.MetaData.Services; using Orchard.Core.Settings.Metadata; using Orchard.Data; using Orchard.ContentManagement; using Orchard.ContentManagement.Handlers; using Orchard.ContentManagement.Records; using Orchard.DisplayManagement; using Orchard.DisplayManagement.Descriptors; using Orchard.DisplayManagement.Implementation; using Orchard.Environment; using Orchard.Environment.Extensions; using Orchard.Messaging.Events; using Orchard.Messaging.Services; using Orchard.Security; using Orchard.Security.Providers; using Orchard.Tests.Stubs; using Orchard.Tests.Utility; using Orchard.UI.PageClass; using Orchard.Users.Handlers; using Orchard.Users.Models; using Orchard.Users.Services; using Orchard.Services; using Orchard.Tests.Messaging; using Orchard.Tests.Modules.Stubs; namespace Orchard.Tests.Modules.Users.Services { [TestFixture] public class UserServiceTests { private IMembershipService _membershipService; private IUserService _userService; private IClock _clock; private <API key> _channel; private ISessionFactory _sessionFactory; private ISession _session; private IContainer _container; private CultureInfo _currentCulture; public class TestSessionLocator : ISessionLocator { private readonly ISession _session; public TestSessionLocator(ISession session) { _session = session; } public ISession For(Type entityType) { return _session; } } [TestFixtureSetUp] public void InitFixture() { _currentCulture = Thread.CurrentThread.CurrentCulture; var databaseFileName = System.IO.Path.GetTempFileName(); _sessionFactory = DataUtility.<API key>( databaseFileName, typeof(UserPartRecord), typeof(<API key>), typeof(ContentItemRecord), typeof(ContentTypeRecord)); } [TestFixtureTearDown] public void TermFixture() { Thread.CurrentThread.CurrentCulture = _currentCulture; } [SetUp] public void Init() { var builder = new ContainerBuilder(); _channel = new <API key>(); builder.RegisterType<MembershipService>().As<IMembershipService>(); builder.RegisterType<UserService>().As<IUserService>(); builder.RegisterInstance(_clock = new StubClock()).As<IClock>(); builder.RegisterType<DefaultContentQuery>().As<IContentQuery>(); builder.RegisterType<<API key>>().As<IContentManager>(); builder.RegisterType<StubCacheManager>().As<ICacheManager>(); builder.RegisterType<Signals>().As<ISignals>(); builder.RegisterType(typeof(SettingsFormatter)).As<ISettingsFormatter>(); builder.RegisterType<<API key>>().As<<API key>>(); builder.RegisterType<<API key>>().As<<API key>>(); builder.RegisterType<UserPartHandler>().As<IContentHandler>(); builder.RegisterType<<API key>>().As<<API key>>(); builder.RegisterType<OrchardServices>().As<IOrchardServices>(); builder.RegisterAutoMocking(MockBehavior.Loose); builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>)); builder.RegisterInstance(new <API key>(_channel)).As<<API key>>(); builder.RegisterType<<API key>>().As<IShapeTableManager>(); builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>(); builder.RegisterType<<API key>>().As<IExtensionManager>(); builder.RegisterInstance(new Mock<IPageClassBuilder>().Object); builder.RegisterType<<API key>>().As<IContentDisplay>(); builder.RegisterType<InfosetHandler>().As<IContentHandler>(); builder.RegisterType<<API key>>().As<IEncryptionService>(); builder.RegisterInstance(<API key>.<API key>()); _session = _sessionFactory.OpenSession(); _session.BeginTransaction(); builder.RegisterInstance(new TestSessionLocator(_session)).As<ISessionLocator>(); _container = builder.Build(); _membershipService = _container.Resolve<IMembershipService>(); _userService = _container.Resolve<IUserService>(); } [TearDown] public void TearDown() { _session.Transaction.Commit(); _session.Transaction.Dispose(); } [Test] public void <API key>() { var user = _membershipService.CreateUser(new CreateUserParams("foo", "66554321", "foo@bar.com", "", "", true)); var nonce = _userService.CreateNonce(user, new TimeSpan(1, 0, 0)); Assert.That(nonce, Is.Not.Empty); string username; DateTime validateByUtc; var result = _userService.DecryptNonce(nonce, out username, out validateByUtc); Assert.That(result, Is.True); Assert.That(username, Is.EqualTo("foo")); Assert.That(validateByUtc, Is.GreaterThan(_clock.UtcNow)); } [Test] public void <API key>() { CultureInfo turkishCulture = new CultureInfo("tr-TR"); Thread.CurrentThread.CurrentCulture = turkishCulture; // Create user lower case _membershipService.CreateUser(new CreateUserParams("admin", "66554321", "foo@bar.com", "", "", true)); // Verify unicity with upper case which with turkish coallition would yeld admin with an i without the dot and therefore generate a different user name Assert.That(_userService.VerifyUserUnicity("ADMIN", "differentfoo@bar.com"), Is.False); } } }
use crate::syntax::Type; use proc_macro2::Ident; use std::fmt::{self, Display}; #[derive(Copy, Clone, PartialEq)] pub enum Atom { Bool, Char, // C char, not Rust char U8, U16, U32, U64, Usize, I8, I16, I32, I64, Isize, F32, F64, CxxString, RustString, } impl Atom { pub fn from(ident: &Ident) -> Option<Self> { Self::from_str(ident.to_string().as_str()) } pub fn from_str(s: &str) -> Option<Self> { use self::Atom::*; match s { "bool" => Some(Bool), "c_char" => Some(Char), "u8" => Some(U8), "u16" => Some(U16), "u32" => Some(U32), "u64" => Some(U64), "usize" => Some(Usize), "i8" => Some(I8), "i16" => Some(I16), "i32" => Some(I32), "i64" => Some(I64), "isize" => Some(Isize), "f32" => Some(F32), "f64" => Some(F64), "CxxString" => Some(CxxString), "String" => Some(RustString), _ => None, } } } impl Display for Atom { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { formatter.write_str(self.as_ref()) } } impl AsRef<str> for Atom { fn as_ref(&self) -> &str { use self::Atom::*; match self { Bool => "bool", Char => "c_char", U8 => "u8", U16 => "u16", U32 => "u32", U64 => "u64", Usize => "usize", I8 => "i8", I16 => "i16", I32 => "i32", I64 => "i64", Isize => "isize", F32 => "f32", F64 => "f64", CxxString => "CxxString", RustString => "String", } } } impl PartialEq<Atom> for Type { fn eq(&self, atom: &Atom) -> bool { match self { Type::Ident(ident) => ident.rust == atom, _ => false, } } } impl PartialEq<Atom> for &Ident { fn eq(&self, atom: &Atom) -> bool { *self == atom } } impl PartialEq<Atom> for &Type { fn eq(&self, atom: &Atom) -> bool { *self == atom } }
#include "arch/x86/insts/microop.hh" #include "arch/x86/regs/misc.hh" namespace X86ISA { bool X86MicroopBase::checkCondition(uint64_t flags, int condition) const { CCFlagBits ccflags = flags; switch(condition) { case ConditionTests::True: return true; case ConditionTests::ECF: return ccflags.ecf; case ConditionTests::EZF: return ccflags.ezf; case ConditionTests::SZnZF: return !(!ccflags.ezf && ccflags.zf); case ConditionTests::MSTRZ: panic("This condition is not implemented!"); case ConditionTests::STRZ: panic("This condition is not implemented!"); case ConditionTests::MSTRC: panic("This condition is not implemented!"); case ConditionTests::STRZnEZF: return !ccflags.ezf && ccflags.zf; //And no interrupts or debug traps are waiting case ConditionTests::OF: return ccflags.of; case ConditionTests::CF: return ccflags.cf; case ConditionTests::ZF: return ccflags.zf; case ConditionTests::CvZF: return ccflags.cf | ccflags.zf; case ConditionTests::SF: return ccflags.sf; case ConditionTests::PF: return ccflags.pf; case ConditionTests::SxOF: return ccflags.sf ^ ccflags.of; case ConditionTests::SxOvZF: return (ccflags.sf ^ ccflags.of) | ccflags.zf; case ConditionTests::False: return false; case ConditionTests::NotECF: return !ccflags.ecf; case ConditionTests::NotEZF: return !ccflags.ezf; case ConditionTests::NotSZnZF: return !ccflags.ezf && ccflags.zf; case ConditionTests::NotMSTRZ: panic("This condition is not implemented!"); case ConditionTests::NotSTRZ: panic("This condition is not implemented!"); case ConditionTests::NotMSTRC: panic("This condition is not implemented!"); case ConditionTests::STRnZnEZF: return !ccflags.ezf && !ccflags.zf; //And no interrupts or debug traps are waiting case ConditionTests::NotOF: return !ccflags.of; case ConditionTests::NotCF: return !ccflags.cf; case ConditionTests::NotZF: return !ccflags.zf; case ConditionTests::NotCvZF: return !(ccflags.cf | ccflags.zf); case ConditionTests::NotSF: return !ccflags.sf; case ConditionTests::NotPF: return !ccflags.pf; case ConditionTests::NotSxOF: return !(ccflags.sf ^ ccflags.of); case ConditionTests::NotSxOvZF: return !((ccflags.sf ^ ccflags.of) | ccflags.zf); } panic("Unknown condition: %d\n", condition); return true; } }
@media screen and (min-width: 1000px) { a { text-decoration: underline; } }
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE html PUBLIC "- <html xmlns="http: <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>DbEnv::get_tx_timestamp()</title> <link rel="stylesheet" href="apiReference.css" type="text/css" /> <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> <link rel="start" href="index.html" title="Berkeley DB C++ API Reference" /> <link rel="up" href="txn.html" title="Chapter 13.  The DbTxn Handle" /> <link rel="prev" href="envget_tx_max.html" title="DbEnv::get_tx_max()" /> <link rel="next" href="envset_tx_max.html" title="DbEnv::set_tx_max()" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">DbEnv::get_tx_timestamp()</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="envget_tx_max.html">Prev</a> </td> <th width="60%" align="center">Chapter 13. The DbTxn Handle </th> <td width="20%" align="right"> <a accesskey="n" href="envset_tx_max.html">Next</a></td> </tr> </table> <hr /> </div> <div class="sect1" lang="en" xml:lang="en"> <div class="titlepage"> <div> <div> <h2 class="title" style="clear: both"><a id="envget_tx_timestamp"></a>DbEnv::get_tx_timestamp()</h2> </div> </div> </div> <pre class="programlisting">#include &lt;db_cxx.h&gt; int DbEnv::get_tx_timestamp(time_t *timestampp);</pre> <p> The <code class="methodname">DbEnv::get_tx_timestamp()</code> method returns the recovery timestamp. This value can be modified using the <a class="xref" href="envset_tx_timestamp.html" title="DbEnv::set_tx_timestamp()">DbEnv::set_tx_timestamp()</a> method. </p> <p> The <code class="methodname">DbEnv::get_tx_timestamp()</code> method may be called at any time during the life of the application. </p> <p> The <code class="methodname">DbEnv::get_tx_timestamp()</code> <span> <span> method either returns a non-zero error value or throws an exception that encapsulates a non-zero error value on failure, and returns 0 on success. </span> </span> </p> <div class="sect2" lang="en" xml:lang="en"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="id1712146"></a>Parameters</h3> </div> </div> </div> <div class="sect3" lang="en" xml:lang="en"> <div class="titlepage"> <div> <div> <h4 class="title"><a id="id1712800"></a>timestampp</h4> </div> </div> </div> <p> The <code class="methodname">DbEnv::get_tx_timestamp()</code> method returns the recovery timestamp in <span class="bold"><strong>timestampp</strong></span>. </p> </div> </div> <div class="sect2" lang="en" xml:lang="en"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="id1712148"></a>Class</h3> </div> </div> </div> <p> <a class="link" href="env.html" title="Chapter 5.  The DbEnv Handle">DbEnv</a>, <a class="link" href="txn.html" title="Chapter 13.  The DbTxn Handle">DbTxn</a> </p> </div> <div class="sect2" lang="en" xml:lang="en"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="id1712862"></a>See Also</h3> </div> </div> </div> <p> <a class="xref" href="txn.html#txnlist" title="Transaction Subsystem and Related Methods">Transaction Subsystem and Related Methods</a>, <a class="xref" href="envset_tx_timestamp.html" title="DbEnv::set_tx_timestamp()">DbEnv::set_tx_timestamp()</a> </p> </div> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="envget_tx_max.html">Prev</a> </td> <td width="20%" align="center"> <a accesskey="u" href="txn.html">Up</a> </td> <td width="40%" align="right"> <a accesskey="n" href="envset_tx_max.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">DbEnv::get_tx_max() </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> DbEnv::set_tx_max()</td> </tr> </table> </div> </body> </html>
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE html PUBLIC "- <html xmlns="http: <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title><API key></title> <link rel="stylesheet" href="apiReference.css" type="text/css" /> <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> <link rel="start" href="index.html" title="Berkeley DB C API Reference" /> <link rel="up" href="dbt.html" title="Chapter 4.  The DBT Handle" /> <link rel="prev" href="<API key>.html" title="<API key>" /> <link rel="next" href="<API key>.html" title="<API key>" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center"><API key></th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="<API key>.html">Prev</a> </td> <th width="60%" align="center">Chapter 4. The DBT Handle </th> <td width="20%" align="right"> <a accesskey="n" href="<API key>.html">Next</a></td> </tr> </table> <hr /> </div> <div class="sect1" lang="en" xml:lang="en"> <div class="titlepage"> <div> <div> <h2 class="title" style="clear: both"><a id="<API key>"></a><API key></h2> </div> </div> </div> <pre class="programlisting">#include &lt;db.h&gt; <API key>(void *pointer, DBT *dbt, void *key, size_t klen, void *data, size_t dlen); </pre> <p> Appends a key / data pair to the bulk buffer. </p> <div class="sect2" lang="en" xml:lang="en"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="id1659220"></a>Parameters</h3> </div> </div> </div> <div class="sect3" lang="en" xml:lang="en"> <div class="titlepage"> <div> <div> <h4 class="title"><a id="id1659317"></a>pointer</h4> </div> </div> </div> <p> The <span class="bold"><strong>pointer</strong></span> parameter is a variable that must have been initialized by a call to <a class="xref" href="<API key>.html" title="<API key>"><API key></a>. </p> <p> This parameter is set to NULL if the data item does not fit in the buffer. </p> </div> <div class="sect3" lang="en" xml:lang="en"> <div class="titlepage"> <div> <div> <h4 class="title"><a id="id1659197"></a>dbt</h4> </div> </div> </div> <p> The <span class="bold"><strong>dbt</strong></span> parameter is a <a class="link" href="dbt.html" title="Chapter 4.  The DBT Handle">DBT</a> structure initialized with <a class="xref" href="<API key>.html" title="<API key>"><API key></a>. </p> </div> <div class="sect3" lang="en" xml:lang="en"> <div class="titlepage"> <div> <div> <h4 class="title"><a id="id1659505"></a>key</h4> </div> </div> </div> <p> A pointer to the bytes for the key to be copied into the bulk buffer. </p> </div> <div class="sect3" lang="en" xml:lang="en"> <div class="titlepage"> <div> <div> <h4 class="title"><a id="id1659231"></a>klen</h4> </div> </div> </div> <p> The number of bytes to be copied for the key. </p> </div> <div class="sect3" lang="en" xml:lang="en"> <div class="titlepage"> <div> <div> <h4 class="title"><a id="id1659541"></a>data</h4> </div> </div> </div> <p> A pointer to the bytes for the data item to be copied into the bulk buffer. </p> </div> <div class="sect3" lang="en" xml:lang="en"> <div class="titlepage"> <div> <div> <h4 class="title"><a id="id1659542"></a>dlen</h4> </div> </div> </div> <p> The number of bytes to be copied for the data item. </p> </div> </div> <div class="sect2" lang="en" xml:lang="en"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="id1659513"></a>Class</h3> </div> </div> </div> <p> <a class="link" href="dbt.html" title="Chapter 4.  The DBT Handle">DBT</a> </p> </div> <div class="sect2" lang="en" xml:lang="en"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="id1659232"></a>See Also</h3> </div> </div> </div> <p> <a class="xref" href="dbt.html#dbtlist" title="DBT and Bulk Operations">DBT and Bulk Operations</a> </p> </div> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="<API key>.html">Prev</a> </td> <td width="20%" align="center"> <a accesskey="u" href="dbt.html">Up</a> </td> <td width="40%" align="right"> <a accesskey="n" href="<API key>.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top"><API key> </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> <API key></td> </tr> </table> </div> </body> </html>
/* $Id: string.c 3553 2011-05-05 06:14:19Z nanang $ */ #include <pj/string.h> #include <pj/assert.h> #include <pj/pool.h> #include <pj/ctype.h> #include <pj/rand.h> #include <pj/os.h> #if <API key>==0 # include <pj/string_i.h> #endif PJ_DEF(char*) pj_strstr(const pj_str_t *str, const pj_str_t *substr) { const char *s, *ends; /* Special case when substr is zero */ if (substr->slen == 0) { return (char*)str->ptr; } s = str->ptr; ends = str->ptr + str->slen - substr->slen; for (; s<=ends; ++s) { if (pj_ansi_strncmp(s, substr->ptr, substr->slen)==0) return (char*)s; } return NULL; } PJ_DEF(char*) pj_stristr(const pj_str_t *str, const pj_str_t *substr) { const char *s, *ends; /* Special case when substr is zero */ if (substr->slen == 0) { return (char*)str->ptr; } s = str->ptr; ends = str->ptr + str->slen - substr->slen; for (; s<=ends; ++s) { if (pj_ansi_strnicmp(s, substr->ptr, substr->slen)==0) return (char*)s; } return NULL; } PJ_DEF(pj_str_t*) pj_strltrim( pj_str_t *str ) { char *end = str->ptr + str->slen; register char *p = str->ptr; while (p < end && pj_isspace(*p)) ++p; str->slen -= (p - str->ptr); str->ptr = p; return str; } PJ_DEF(pj_str_t*) pj_strrtrim( pj_str_t *str ) { char *end = str->ptr + str->slen; register char *p = end - 1; while (p >= str->ptr && pj_isspace(*p)) --p; str->slen -= ((end - p) - 1); return str; } PJ_DEF(char*) <API key>(char *str, pj_size_t len) { unsigned i; char *p = str; PJ_CHECK_STACK(); for (i=0; i<len/8; ++i) { pj_uint32_t val = pj_rand(); pj_val_to_hex_digit( (val & 0xFF000000) >> 24, p+0 ); pj_val_to_hex_digit( (val & 0x00FF0000) >> 16, p+2 ); pj_val_to_hex_digit( (val & 0x0000FF00) >> 8, p+4 ); pj_val_to_hex_digit( (val & 0x000000FF) >> 0, p+6 ); p += 8; } for (i=i * 8; i<len; ++i) { *p++ = pj_hex_digits[ pj_rand() & 0x0F ]; } return str; } PJ_DEF(unsigned long) pj_strtoul(const pj_str_t *str) { unsigned long value; unsigned i; PJ_CHECK_STACK(); value = 0; for (i=0; i<(unsigned)str->slen; ++i) { if (!pj_isdigit(str->ptr[i])) break; value = value * 10 + (str->ptr[i] - '0'); } return value; } PJ_DEF(unsigned long) pj_strtoul2(const pj_str_t *str, pj_str_t *endptr, unsigned base) { unsigned long value; unsigned i; PJ_CHECK_STACK(); value = 0; if (base <= 10) { for (i=0; i<(unsigned)str->slen; ++i) { unsigned c = (str->ptr[i] - '0'); if (c >= base) break; value = value * base + c; } } else if (base == 16) { for (i=0; i<(unsigned)str->slen; ++i) { if (!pj_isxdigit(str->ptr[i])) break; value = value * 16 + pj_hex_digit_to_val(str->ptr[i]); } } else { pj_assert(!"Unsupported base"); i = 0; value = 0xFFFFFFFFUL; } if (endptr) { endptr->ptr = str->ptr + i; endptr->slen = str->slen - i; } return value; } PJ_DEF(int) pj_utoa(unsigned long val, char *buf) { return pj_utoa_pad(val, buf, 0, 0); } PJ_DEF(int) pj_utoa_pad( unsigned long val, char *buf, int min_dig, int pad) { char *p; int len; PJ_CHECK_STACK(); p = buf; do { unsigned long digval = (unsigned long) (val % 10); val /= 10; *p++ = (char) (digval + '0'); } while (val > 0); len = p-buf; while (len < min_dig) { *p++ = (char)pad; ++len; } *p do { char temp = *p; *p = *buf; *buf = temp; --p; ++buf; } while (buf < p); return len; }
#include <linux/slab.h> #include <asm/ebcdic.h> #include <linux/hashtable.h> #include "qeth_l3.h" #define QETH_DEVICE_ATTR(_id, _name, _mode, _show, _store) \ struct device_attribute dev_attr_##_id = __ATTR(_name, _mode, _show, _store) static ssize_t <API key>(struct qeth_card *card, struct qeth_routing_info *route, char *buf) { switch (route->type) { case PRIMARY_ROUTER: return sprintf(buf, "%s\n", "primary router"); case SECONDARY_ROUTER: return sprintf(buf, "%s\n", "secondary router"); case MULTICAST_ROUTER: if (card->info.broadcast_capable == <API key>) return sprintf(buf, "%s\n", "multicast router+"); else return sprintf(buf, "%s\n", "multicast router"); case PRIMARY_CONNECTOR: if (card->info.broadcast_capable == <API key>) return sprintf(buf, "%s\n", "primary connector+"); else return sprintf(buf, "%s\n", "primary connector"); case SECONDARY_CONNECTOR: if (card->info.broadcast_capable == <API key>) return sprintf(buf, "%s\n", "secondary connector+"); else return sprintf(buf, "%s\n", "secondary connector"); default: return sprintf(buf, "%s\n", "no"); } } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, char *buf) { struct qeth_card *card = dev_get_drvdata(dev); if (!card) return -EINVAL; return <API key>(card, &card->options.route4, buf); } static ssize_t <API key>(struct qeth_card *card, struct qeth_routing_info *route, enum qeth_prot_versions prot, const char *buf, size_t count) { enum qeth_routing_types old_route_type = route->type; int rc = 0; mutex_lock(&card->conf_mutex); if (sysfs_streq(buf, "no_router")) { route->type = NO_ROUTER; } else if (sysfs_streq(buf, "primary_connector")) { route->type = PRIMARY_CONNECTOR; } else if (sysfs_streq(buf, "secondary_connector")) { route->type = SECONDARY_CONNECTOR; } else if (sysfs_streq(buf, "primary_router")) { route->type = PRIMARY_ROUTER; } else if (sysfs_streq(buf, "secondary_router")) { route->type = SECONDARY_ROUTER; } else if (sysfs_streq(buf, "multicast_router")) { route->type = MULTICAST_ROUTER; } else { rc = -EINVAL; goto out; } if (<API key>(card) && (old_route_type != route->type)) { if (prot == QETH_PROT_IPV4) rc = <API key>(card); else if (prot == QETH_PROT_IPV6) rc = <API key>(card); } out: if (rc) route->type = old_route_type; mutex_unlock(&card->conf_mutex); return rc ? rc : count; } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct qeth_card *card = dev_get_drvdata(dev); if (!card) return -EINVAL; return <API key>(card, &card->options.route4, QETH_PROT_IPV4, buf, count); } static DEVICE_ATTR(route4, 0644, <API key>, <API key>); static ssize_t <API key>(struct device *dev, struct device_attribute *attr, char *buf) { struct qeth_card *card = dev_get_drvdata(dev); if (!card) return -EINVAL; return <API key>(card, &card->options.route6, buf); } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct qeth_card *card = dev_get_drvdata(dev); if (!card) return -EINVAL; return <API key>(card, &card->options.route6, QETH_PROT_IPV6, buf, count); } static DEVICE_ATTR(route6, 0644, <API key>, <API key>); static ssize_t <API key>(struct device *dev, struct device_attribute *attr, char *buf) { struct qeth_card *card = dev_get_drvdata(dev); if (!card) return -EINVAL; return sprintf(buf, "%i\n", card->options.fake_broadcast? 1:0); } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct qeth_card *card = dev_get_drvdata(dev); char *tmp; int i, rc = 0; if (!card) return -EINVAL; mutex_lock(&card->conf_mutex); if ((card->state != CARD_STATE_DOWN) && (card->state != CARD_STATE_RECOVER)) { rc = -EPERM; goto out; } i = simple_strtoul(buf, &tmp, 16); if ((i == 0) || (i == 1)) card->options.fake_broadcast = i; else rc = -EINVAL; out: mutex_unlock(&card->conf_mutex); return rc ? rc : count; } static DEVICE_ATTR(fake_broadcast, 0644, <API key>, <API key>); static ssize_t <API key>(struct device *dev, struct device_attribute *attr, char *buf) { struct qeth_card *card = dev_get_drvdata(dev); if (!card) return -EINVAL; return sprintf(buf, "%i\n", card->options.sniffer ? 1 : 0); } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct qeth_card *card = dev_get_drvdata(dev); int rc = 0; unsigned long i; if (!card) return -EINVAL; if (card->info.type != QETH_CARD_TYPE_IQD) return -EPERM; if (card->options.cq == QETH_CQ_ENABLED) return -EPERM; mutex_lock(&card->conf_mutex); if ((card->state != CARD_STATE_DOWN) && (card->state != CARD_STATE_RECOVER)) { rc = -EPERM; goto out; } rc = kstrtoul(buf, 16, &i); if (rc) { rc = -EINVAL; goto out; } switch (i) { case 0: card->options.sniffer = i; break; case 1: qdio_get_ssqd_desc(CARD_DDEV(card), &card->ssqd); if (card->ssqd.qdioac2 & QETH_SNIFF_AVAIL) { card->options.sniffer = i; if (card->qdio.init_pool.buf_count != <API key>) <API key>(card, <API key>); } else rc = -EPERM; break; default: rc = -EINVAL; } out: mutex_unlock(&card->conf_mutex); return rc ? rc : count; } static DEVICE_ATTR(sniffer, 0644, <API key>, <API key>); static ssize_t <API key>(struct device *dev, struct device_attribute *attr, char *buf) { struct qeth_card *card = dev_get_drvdata(dev); char tmp_hsuid[9]; if (!card) return -EINVAL; if (card->info.type != QETH_CARD_TYPE_IQD) return -EPERM; if (card->state == CARD_STATE_DOWN) return -EPERM; memcpy(tmp_hsuid, card->options.hsuid, sizeof(tmp_hsuid)); EBCASC(tmp_hsuid, 8); return sprintf(buf, "%s\n", tmp_hsuid); } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct qeth_card *card = dev_get_drvdata(dev); struct qeth_ipaddr *addr; char *tmp; int i; if (!card) return -EINVAL; if (card->info.type != QETH_CARD_TYPE_IQD) return -EPERM; if (card->state != CARD_STATE_DOWN && card->state != CARD_STATE_RECOVER) return -EPERM; if (card->options.sniffer) return -EPERM; if (card->options.cq == <API key>) return -EPERM; tmp = strsep((char **)&buf, "\n"); if (strlen(tmp) > 8) return -EINVAL; if (card->options.hsuid[0]) { /* delete old ip address */ addr = <API key>(QETH_PROT_IPV6); if (!addr) return -ENOMEM; addr->u.a6.addr.s6_addr32[0] = 0xfe800000; addr->u.a6.addr.s6_addr32[1] = 0x00000000; for (i = 8; i < 16; i++) addr->u.a6.addr.s6_addr[i] = card->options.hsuid[i - 8]; addr->u.a6.pfxlen = 0; addr->type = QETH_IP_TYPE_NORMAL; qeth_l3_delete_ip(card, addr); kfree(addr); } if (strlen(tmp) == 0) { /* delete ip address only */ card->options.hsuid[0] = '\0'; if (card->dev) memcpy(card->dev->perm_addr, card->options.hsuid, 9); qeth_configure_cq(card, QETH_CQ_DISABLED); return count; } if (qeth_configure_cq(card, QETH_CQ_ENABLED)) return -EPERM; snprintf(card->options.hsuid, sizeof(card->options.hsuid), "%-8s", tmp); ASCEBC(card->options.hsuid, 8); if (card->dev) memcpy(card->dev->perm_addr, card->options.hsuid, 9); addr = <API key>(QETH_PROT_IPV6); if (addr != NULL) { addr->u.a6.addr.s6_addr32[0] = 0xfe800000; addr->u.a6.addr.s6_addr32[1] = 0x00000000; for (i = 8; i < 16; i++) addr->u.a6.addr.s6_addr[i] = card->options.hsuid[i - 8]; addr->u.a6.pfxlen = 0; addr->type = QETH_IP_TYPE_NORMAL; } else return -ENOMEM; qeth_l3_add_ip(card, addr); kfree(addr); return count; } static DEVICE_ATTR(hsuid, 0644, <API key>, <API key>); static struct attribute *<API key>[] = { &dev_attr_route4.attr, &dev_attr_route6.attr, &<API key>.attr, &dev_attr_sniffer.attr, &dev_attr_hsuid.attr, NULL, }; static struct attribute_group <API key> = { .attrs = <API key>, }; static ssize_t <API key>(struct device *dev, struct device_attribute *attr, char *buf) { struct qeth_card *card = dev_get_drvdata(dev); if (!card) return -EINVAL; return sprintf(buf, "%i\n", card->ipato.enabled? 1:0); } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct qeth_card *card = dev_get_drvdata(dev); struct qeth_ipaddr *addr; int i, rc = 0; if (!card) return -EINVAL; mutex_lock(&card->conf_mutex); if ((card->state != CARD_STATE_DOWN) && (card->state != CARD_STATE_RECOVER)) { rc = -EPERM; goto out; } if (sysfs_streq(buf, "toggle")) { card->ipato.enabled = (card->ipato.enabled)? 0 : 1; } else if (sysfs_streq(buf, "1")) { card->ipato.enabled = 1; hash_for_each(card->ip_htable, i, addr, hnode) { if ((addr->type == QETH_IP_TYPE_NORMAL) && <API key>(card, addr)) addr->set_flags |= <API key>; } } else if (sysfs_streq(buf, "0")) { card->ipato.enabled = 0; hash_for_each(card->ip_htable, i, addr, hnode) { if (addr->set_flags & <API key>) addr->set_flags &= ~<API key>; } } else rc = -EINVAL; out: mutex_unlock(&card->conf_mutex); return rc ? rc : count; } static QETH_DEVICE_ATTR(ipato_enable, enable, 0644, <API key>, <API key>); static ssize_t <API key>(struct device *dev, struct device_attribute *attr, char *buf) { struct qeth_card *card = dev_get_drvdata(dev); if (!card) return -EINVAL; return sprintf(buf, "%i\n", card->ipato.invert4? 1:0); } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct qeth_card *card = dev_get_drvdata(dev); int rc = 0; if (!card) return -EINVAL; mutex_lock(&card->conf_mutex); if (sysfs_streq(buf, "toggle")) card->ipato.invert4 = (card->ipato.invert4)? 0 : 1; else if (sysfs_streq(buf, "1")) card->ipato.invert4 = 1; else if (sysfs_streq(buf, "0")) card->ipato.invert4 = 0; else rc = -EINVAL; mutex_unlock(&card->conf_mutex); return rc ? rc : count; } static QETH_DEVICE_ATTR(ipato_invert4, invert4, 0644, <API key>, <API key>); static ssize_t <API key>(char *buf, struct qeth_card *card, enum qeth_prot_versions proto) { struct qeth_ipato_entry *ipatoe; char addr_str[40]; int entry_len; /* length of 1 entry string, differs between v4 and v6 */ int i = 0; entry_len = (proto == QETH_PROT_IPV4)? 12 : 40; /* add strlen for "/<mask>\n" */ entry_len += (proto == QETH_PROT_IPV4)? 5 : 6; spin_lock_bh(&card->ip_lock); list_for_each_entry(ipatoe, &card->ipato.entries, entry) { if (ipatoe->proto != proto) continue; /* String must not be longer than PAGE_SIZE. So we check if * string length gets near PAGE_SIZE. Then we can savely display * the next IPv6 address (worst case, compared to IPv4) */ if ((PAGE_SIZE - i) <= entry_len) break; <API key>(proto, ipatoe->addr, addr_str); i += snprintf(buf + i, PAGE_SIZE - i, "%s/%i\n", addr_str, ipatoe->mask_bits); } spin_unlock_bh(&card->ip_lock); i += snprintf(buf + i, PAGE_SIZE - i, "\n"); return i; } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, char *buf) { struct qeth_card *card = dev_get_drvdata(dev); if (!card) return -EINVAL; return <API key>(buf, card, QETH_PROT_IPV4); } static int <API key>(const char *buf, enum qeth_prot_versions proto, u8 *addr, int *mask_bits) { const char *start, *end; char *tmp; char buffer[40] = {0, }; start = buf; /* get address string */ end = strchr(start, '/'); if (!end || (end - start >= 40)) { return -EINVAL; } strncpy(buffer, start, end - start); if (<API key>(buffer, proto, addr)) { return -EINVAL; } start = end + 1; *mask_bits = simple_strtoul(start, &tmp, 10); if (!strlen(start) || (tmp == start) || (*mask_bits > ((proto == QETH_PROT_IPV4) ? 32 : 128))) { return -EINVAL; } return 0; } static ssize_t <API key>(const char *buf, size_t count, struct qeth_card *card, enum qeth_prot_versions proto) { struct qeth_ipato_entry *ipatoe; u8 addr[16]; int mask_bits; int rc = 0; mutex_lock(&card->conf_mutex); rc = <API key>(buf, proto, addr, &mask_bits); if (rc) goto out; ipatoe = kzalloc(sizeof(struct qeth_ipato_entry), GFP_KERNEL); if (!ipatoe) { rc = -ENOMEM; goto out; } ipatoe->proto = proto; memcpy(ipatoe->addr, addr, (proto == QETH_PROT_IPV4)? 4:16); ipatoe->mask_bits = mask_bits; rc = <API key>(card, ipatoe); if (rc) kfree(ipatoe); out: mutex_unlock(&card->conf_mutex); return rc ? rc : count; } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct qeth_card *card = dev_get_drvdata(dev); if (!card) return -EINVAL; return <API key>(buf, count, card, QETH_PROT_IPV4); } static QETH_DEVICE_ATTR(ipato_add4, add4, 0644, <API key>, <API key>); static ssize_t <API key>(const char *buf, size_t count, struct qeth_card *card, enum qeth_prot_versions proto) { u8 addr[16]; int mask_bits; int rc = 0; mutex_lock(&card->conf_mutex); rc = <API key>(buf, proto, addr, &mask_bits); if (!rc) <API key>(card, proto, addr, mask_bits); mutex_unlock(&card->conf_mutex); return rc ? rc : count; } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct qeth_card *card = dev_get_drvdata(dev); if (!card) return -EINVAL; return <API key>(buf, count, card, QETH_PROT_IPV4); } static QETH_DEVICE_ATTR(ipato_del4, del4, 0200, NULL, <API key>); static ssize_t <API key>(struct device *dev, struct device_attribute *attr, char *buf) { struct qeth_card *card = dev_get_drvdata(dev); if (!card) return -EINVAL; return sprintf(buf, "%i\n", card->ipato.invert6? 1:0); } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct qeth_card *card = dev_get_drvdata(dev); int rc = 0; if (!card) return -EINVAL; mutex_lock(&card->conf_mutex); if (sysfs_streq(buf, "toggle")) card->ipato.invert6 = (card->ipato.invert6)? 0 : 1; else if (sysfs_streq(buf, "1")) card->ipato.invert6 = 1; else if (sysfs_streq(buf, "0")) card->ipato.invert6 = 0; else rc = -EINVAL; mutex_unlock(&card->conf_mutex); return rc ? rc : count; } static QETH_DEVICE_ATTR(ipato_invert6, invert6, 0644, <API key>, <API key>); static ssize_t <API key>(struct device *dev, struct device_attribute *attr, char *buf) { struct qeth_card *card = dev_get_drvdata(dev); if (!card) return -EINVAL; return <API key>(buf, card, QETH_PROT_IPV6); } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct qeth_card *card = dev_get_drvdata(dev); if (!card) return -EINVAL; return <API key>(buf, count, card, QETH_PROT_IPV6); } static QETH_DEVICE_ATTR(ipato_add6, add6, 0644, <API key>, <API key>); static ssize_t <API key>(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct qeth_card *card = dev_get_drvdata(dev); if (!card) return -EINVAL; return <API key>(buf, count, card, QETH_PROT_IPV6); } static QETH_DEVICE_ATTR(ipato_del6, del6, 0200, NULL, <API key>); static struct attribute *<API key>[] = { &<API key>.attr, &<API key>.attr, &dev_attr_ipato_add4.attr, &dev_attr_ipato_del4.attr, &<API key>.attr, &dev_attr_ipato_add6.attr, &dev_attr_ipato_del6.attr, NULL, }; static struct attribute_group <API key> = { .name = "ipa_takeover", .attrs = <API key>, }; static ssize_t <API key>(char *buf, struct qeth_card *card, enum qeth_prot_versions proto) { struct qeth_ipaddr *ipaddr; struct hlist_node *tmp; char addr_str[40]; int entry_len; /* length of 1 entry string, differs between v4 and v6 */ int i = 0; entry_len = (proto == QETH_PROT_IPV4)? 12 : 40; entry_len += 2; /* \n + terminator */ spin_lock_bh(&card->ip_lock); hash_for_each_safe(card->ip_htable, i, tmp, ipaddr, hnode) { if (ipaddr->proto != proto) continue; if (ipaddr->type != QETH_IP_TYPE_VIPA) continue; /* String must not be longer than PAGE_SIZE. So we check if * string length gets near PAGE_SIZE. Then we can savely display * the next IPv6 address (worst case, compared to IPv4) */ if ((PAGE_SIZE - i) <= entry_len) break; <API key>(proto, (const u8 *)&ipaddr->u, addr_str); i += snprintf(buf + i, PAGE_SIZE - i, "%s\n", addr_str); } spin_unlock_bh(&card->ip_lock); i += snprintf(buf + i, PAGE_SIZE - i, "\n"); return i; } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, char *buf) { struct qeth_card *card = dev_get_drvdata(dev); if (!card) return -EINVAL; return <API key>(buf, card, QETH_PROT_IPV4); } static int qeth_l3_parse_vipae(const char *buf, enum qeth_prot_versions proto, u8 *addr) { if (<API key>(buf, proto, addr)) { return -EINVAL; } return 0; } static ssize_t <API key>(const char *buf, size_t count, struct qeth_card *card, enum qeth_prot_versions proto) { u8 addr[16] = {0, }; int rc; mutex_lock(&card->conf_mutex); rc = qeth_l3_parse_vipae(buf, proto, addr); if (!rc) rc = qeth_l3_add_vipa(card, proto, addr); mutex_unlock(&card->conf_mutex); return rc ? rc : count; } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct qeth_card *card = dev_get_drvdata(dev); if (!card) return -EINVAL; return <API key>(buf, count, card, QETH_PROT_IPV4); } static QETH_DEVICE_ATTR(vipa_add4, add4, 0644, <API key>, <API key>); static ssize_t <API key>(const char *buf, size_t count, struct qeth_card *card, enum qeth_prot_versions proto) { u8 addr[16]; int rc; mutex_lock(&card->conf_mutex); rc = qeth_l3_parse_vipae(buf, proto, addr); if (!rc) qeth_l3_del_vipa(card, proto, addr); mutex_unlock(&card->conf_mutex); return rc ? rc : count; } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct qeth_card *card = dev_get_drvdata(dev); if (!card) return -EINVAL; return <API key>(buf, count, card, QETH_PROT_IPV4); } static QETH_DEVICE_ATTR(vipa_del4, del4, 0200, NULL, <API key>); static ssize_t <API key>(struct device *dev, struct device_attribute *attr, char *buf) { struct qeth_card *card = dev_get_drvdata(dev); if (!card) return -EINVAL; return <API key>(buf, card, QETH_PROT_IPV6); } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct qeth_card *card = dev_get_drvdata(dev); if (!card) return -EINVAL; return <API key>(buf, count, card, QETH_PROT_IPV6); } static QETH_DEVICE_ATTR(vipa_add6, add6, 0644, <API key>, <API key>); static ssize_t <API key>(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct qeth_card *card = dev_get_drvdata(dev); if (!card) return -EINVAL; return <API key>(buf, count, card, QETH_PROT_IPV6); } static QETH_DEVICE_ATTR(vipa_del6, del6, 0200, NULL, <API key>); static struct attribute *<API key>[] = { &dev_attr_vipa_add4.attr, &dev_attr_vipa_del4.attr, &dev_attr_vipa_add6.attr, &dev_attr_vipa_del6.attr, NULL, }; static struct attribute_group <API key> = { .name = "vipa", .attrs = <API key>, }; static ssize_t <API key>(char *buf, struct qeth_card *card, enum qeth_prot_versions proto) { struct qeth_ipaddr *ipaddr; struct hlist_node *tmp; char addr_str[40]; int entry_len; /* length of 1 entry string, differs between v4 and v6 */ int i = 0; entry_len = (proto == QETH_PROT_IPV4)? 12 : 40; entry_len += 2; /* \n + terminator */ spin_lock_bh(&card->ip_lock); hash_for_each_safe(card->ip_htable, i, tmp, ipaddr, hnode) { if (ipaddr->proto != proto) continue; if (ipaddr->type != QETH_IP_TYPE_RXIP) continue; /* String must not be longer than PAGE_SIZE. So we check if * string length gets near PAGE_SIZE. Then we can savely display * the next IPv6 address (worst case, compared to IPv4) */ if ((PAGE_SIZE - i) <= entry_len) break; <API key>(proto, (const u8 *)&ipaddr->u, addr_str); i += snprintf(buf + i, PAGE_SIZE - i, "%s\n", addr_str); } spin_unlock_bh(&card->ip_lock); i += snprintf(buf + i, PAGE_SIZE - i, "\n"); return i; } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, char *buf) { struct qeth_card *card = dev_get_drvdata(dev); if (!card) return -EINVAL; return <API key>(buf, card, QETH_PROT_IPV4); } static int qeth_l3_parse_rxipe(const char *buf, enum qeth_prot_versions proto, u8 *addr) { if (<API key>(buf, proto, addr)) { return -EINVAL; } return 0; } static ssize_t <API key>(const char *buf, size_t count, struct qeth_card *card, enum qeth_prot_versions proto) { u8 addr[16] = {0, }; int rc; mutex_lock(&card->conf_mutex); rc = qeth_l3_parse_rxipe(buf, proto, addr); if (!rc) rc = qeth_l3_add_rxip(card, proto, addr); mutex_unlock(&card->conf_mutex); return rc ? rc : count; } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct qeth_card *card = dev_get_drvdata(dev); if (!card) return -EINVAL; return <API key>(buf, count, card, QETH_PROT_IPV4); } static QETH_DEVICE_ATTR(rxip_add4, add4, 0644, <API key>, <API key>); static ssize_t <API key>(const char *buf, size_t count, struct qeth_card *card, enum qeth_prot_versions proto) { u8 addr[16]; int rc; mutex_lock(&card->conf_mutex); rc = qeth_l3_parse_rxipe(buf, proto, addr); if (!rc) qeth_l3_del_rxip(card, proto, addr); mutex_unlock(&card->conf_mutex); return rc ? rc : count; } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct qeth_card *card = dev_get_drvdata(dev); if (!card) return -EINVAL; return <API key>(buf, count, card, QETH_PROT_IPV4); } static QETH_DEVICE_ATTR(rxip_del4, del4, 0200, NULL, <API key>); static ssize_t <API key>(struct device *dev, struct device_attribute *attr, char *buf) { struct qeth_card *card = dev_get_drvdata(dev); if (!card) return -EINVAL; return <API key>(buf, card, QETH_PROT_IPV6); } static ssize_t <API key>(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct qeth_card *card = dev_get_drvdata(dev); if (!card) return -EINVAL; return <API key>(buf, count, card, QETH_PROT_IPV6); } static QETH_DEVICE_ATTR(rxip_add6, add6, 0644, <API key>, <API key>); static ssize_t <API key>(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct qeth_card *card = dev_get_drvdata(dev); if (!card) return -EINVAL; return <API key>(buf, count, card, QETH_PROT_IPV6); } static QETH_DEVICE_ATTR(rxip_del6, del6, 0200, NULL, <API key>); static struct attribute *<API key>[] = { &dev_attr_rxip_add4.attr, &dev_attr_rxip_del4.attr, &dev_attr_rxip_add6.attr, &dev_attr_rxip_del6.attr, NULL, }; static struct attribute_group <API key> = { .name = "rxip", .attrs = <API key>, }; int <API key>(struct device *dev) { int ret; ret = sysfs_create_group(&dev->kobj, &<API key>); if (ret) return ret; ret = sysfs_create_group(&dev->kobj, &<API key>); if (ret) { sysfs_remove_group(&dev->kobj, &<API key>); return ret; } ret = sysfs_create_group(&dev->kobj, &<API key>); if (ret) { sysfs_remove_group(&dev->kobj, &<API key>); sysfs_remove_group(&dev->kobj, &<API key>); return ret; } ret = sysfs_create_group(&dev->kobj, &<API key>); if (ret) { sysfs_remove_group(&dev->kobj, &<API key>); sysfs_remove_group(&dev->kobj, &<API key>); sysfs_remove_group(&dev->kobj, &<API key>); return ret; } return 0; } void <API key>(struct device *dev) { sysfs_remove_group(&dev->kobj, &<API key>); sysfs_remove_group(&dev->kobj, &<API key>); sysfs_remove_group(&dev->kobj, &<API key>); sysfs_remove_group(&dev->kobj, &<API key>); }
#include <boost/container/stable_vector.hpp> struct empty { friend bool operator == (const empty &, const empty &){ return true; } friend bool operator < (const empty &, const empty &){ return true; } }; template class ::boost::container::stable_vector<empty>; int main() { ::boost::container::stable_vector<empty> dummy; (void)dummy; return 0; }
package google import ( "fmt" "testing" "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" ) func <API key>(t *testing.T) { poolName := fmt.Sprintf("tf-%s", acctest.RandString(10)) ruleName := fmt.Sprintf("tf-%s", acctest.RandString(10)) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: <API key>, Steps: []resource.TestStep{ resource.TestStep{ Config: <API key>(poolName, ruleName), Check: resource.<API key>( <API key>( "<API key>.foobar"), ), }, }, }) } func <API key>(t *testing.T) { addrName := fmt.Sprintf("tf-%s", acctest.RandString(10)) poolName := fmt.Sprintf("tf-%s", acctest.RandString(10)) ruleName := fmt.Sprintf("tf-%s", acctest.RandString(10)) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: <API key>, Steps: []resource.TestStep{ resource.TestStep{ Config: <API key>(addrName, poolName, ruleName), Check: resource.<API key>( <API key>( "<API key>.foobar"), ), }, }, }) } func <API key>(t *testing.T) { serviceName := fmt.Sprintf("tf-%s", acctest.RandString(10)) checkName := fmt.Sprintf("tf-%s", acctest.RandString(10)) ruleName := fmt.Sprintf("tf-%s", acctest.RandString(10)) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: <API key>, Steps: []resource.TestStep{ resource.TestStep{ Config: <API key>(serviceName, checkName, ruleName), Check: resource.<API key>( <API key>( "<API key>.foobar"), ), }, }, }) } func <API key>(s *terraform.State) error { config := testAccProvider.Meta().(*Config) for _, rs := range s.RootModule().Resources { if rs.Type != "<API key>" { continue } _, err := config.clientCompute.ForwardingRules.Get( config.Project, config.Region, rs.Primary.ID).Do() if err == nil { return fmt.Errorf("ForwardingRule still exists") } } return nil } func <API key>(n string) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] if !ok { return fmt.Errorf("Not found: %s", n) } if rs.Primary.ID == "" { return fmt.Errorf("No ID is set") } config := testAccProvider.Meta().(*Config) found, err := config.clientCompute.ForwardingRules.Get( config.Project, config.Region, rs.Primary.ID).Do() if err != nil { return err } if found.Name != rs.Primary.ID { return fmt.Errorf("ForwardingRule not found") } return nil } } func <API key>(poolName, ruleName string) string { return fmt.Sprintf(` resource "<API key>" "foobar-tp" { description = "Resource created for Terraform acceptance testing" instances = ["us-central1-a/foo", "us-central1-b/bar"] name = "%s" } resource "<API key>" "foobar" { description = "Resource created for Terraform acceptance testing" ip_protocol = "UDP" name = "%s" port_range = "80-81" target = "${<API key>.foobar-tp.self_link}" } `, poolName, ruleName) } func <API key>(addrName, poolName, ruleName string) string { return fmt.Sprintf(` resource "<API key>" "foo" { name = "%s" } resource "<API key>" "foobar-tp" { description = "Resource created for Terraform acceptance testing" instances = ["us-central1-a/foo", "us-central1-b/bar"] name = "%s" } resource "<API key>" "foobar" { description = "Resource created for Terraform acceptance testing" ip_address = "${<API key>.foo.address}" ip_protocol = "TCP" name = "%s" port_range = "80-81" target = "${<API key>.foobar-tp.self_link}" } `, addrName, poolName, ruleName) } func <API key>(serviceName, checkName, ruleName string) string { return fmt.Sprintf(` resource "<API key>" "foobar-bs" { name = "%s" description = "Resource created for Terraform acceptance testing" health_checks = ["${<API key>.zero.self_link}"] region = "us-central1" } resource "<API key>" "zero" { name = "%s" description = "Resource created for Terraform acceptance testing" check_interval_sec = 1 timeout_sec = 1 tcp_health_check { port = "80" } } resource "<API key>" "foobar" { description = "Resource created for Terraform acceptance testing" name = "%s" <API key> = "INTERNAL" backend_service = "${<API key>.foobar-bs.self_link}" ports = ["80"] } `, serviceName, checkName, ruleName) }
THREE.BinaryLoader = function ( showStatus ) { THREE.Loader.call( this, showStatus ); }; THREE.BinaryLoader.prototype = Object.create( THREE.Loader.prototype ); // Load models generated by slim OBJ converter with BINARY option (<API key>.py -t binary) // - binary models consist of two files: JS and BIN // - parameters // - url (required) // - callback (required) // - texturePath (optional: if not specified, textures will be assumed to be in the same folder as JS model file) // - binaryPath (optional: if not specified, binary file will be assumed to be in the same folder as JS model file) THREE.BinaryLoader.prototype.load = function ( url, callback, texturePath, binaryPath ) { // todo: unify load API to for easier SceneLoader use texturePath = texturePath || this.extractUrlBase( url ); binaryPath = binaryPath || this.extractUrlBase( url ); var callbackProgress = this.showProgress ? THREE.Loader.prototype.updateProgress : undefined; this.onLoadStart(); // #1 load JS part via web worker this.loadAjaxJSON( this, url, callback, texturePath, binaryPath, callbackProgress ); }; THREE.BinaryLoader.prototype.loadAjaxJSON = function ( context, url, callback, texturePath, binaryPath, callbackProgress ) { var xhr = new XMLHttpRequest(); texturePath = texturePath && ( typeof texturePath === "string" ) ? texturePath : this.extractUrlBase( url ); binaryPath = binaryPath && ( typeof binaryPath === "string" ) ? binaryPath : this.extractUrlBase( url ); xhr.onreadystatechange = function () { if ( xhr.readyState == 4 ) { if ( xhr.status == 200 || xhr.status == 0 ) { var json = JSON.parse( xhr.responseText ); context.loadAjaxBuffers( json, callback, binaryPath, texturePath, callbackProgress ); } else { console.error( "THREE.BinaryLoader: Couldn't load [" + url + "] [" + xhr.status + "]" ); } } }; xhr.open( "GET", url, true ); xhr.send( null ); }; THREE.BinaryLoader.prototype.loadAjaxBuffers = function ( json, callback, binaryPath, texturePath, callbackProgress ) { var xhr = new XMLHttpRequest(), url = binaryPath + json.buffers; xhr.addEventListener( 'load', function ( event ) { var buffer = xhr.response; if ( buffer === undefined ) { // IEWEBGL needs this buffer = ( new Uint8Array( xhr.responseBody ) ).buffer; } if ( buffer.byteLength == 0 ) { // iOS and other XMLHttpRequest level 1 var buffer = new ArrayBuffer( xhr.responseText.length ); var bufView = new Uint8Array( buffer ); for ( var i = 0, l = xhr.responseText.length; i < l; i ++ ) { bufView[ i ] = xhr.responseText.charCodeAt( i ) & 0xff; } } THREE.BinaryLoader.prototype.createBinModel( buffer, callback, texturePath, json.materials ); }, false ); if ( callbackProgress !== undefined ) { xhr.addEventListener( 'progress', function ( event ) { if ( event.lengthComputable ) { callbackProgress( event ); } }, false ); } xhr.addEventListener( 'error', function ( event ) { console.error( "THREE.BinaryLoader: Couldn't load [" + url + "] [" + xhr.status + "]" ); }, false ); xhr.open( "GET", url, true ); xhr.responseType = "arraybuffer"; if ( xhr.overrideMimeType ) xhr.overrideMimeType( "text/plain; charset=x-user-defined" ); xhr.send( null ); }; // Binary AJAX parser THREE.BinaryLoader.prototype.createBinModel = function ( data, callback, texturePath, jsonMaterials ) { var Model = function ( texturePath ) { var scope = this, currentOffset = 0, md, normals = [], uvs = [], start_tri_flat, start_tri_smooth, start_tri_flat_uv, start_tri_smooth_uv, start_quad_flat, start_quad_smooth, start_quad_flat_uv, <API key>, tri_size, quad_size, len_tri_flat, len_tri_smooth, len_tri_flat_uv, len_tri_smooth_uv, len_quad_flat, len_quad_smooth, len_quad_flat_uv, len_quad_smooth_uv; THREE.Geometry.call( this ); md = parseMetaData( data, currentOffset ); currentOffset += md.header_bytes; /* md.vertex_index_bytes = Uint32Array.BYTES_PER_ELEMENT; md.<API key> = Uint16Array.BYTES_PER_ELEMENT; md.normal_index_bytes = Uint32Array.BYTES_PER_ELEMENT; md.uv_index_bytes = Uint32Array.BYTES_PER_ELEMENT; */ // buffers sizes tri_size = md.vertex_index_bytes * 3 + md.<API key>; quad_size = md.vertex_index_bytes * 4 + md.<API key>; len_tri_flat = md.ntri_flat * ( tri_size ); len_tri_smooth = md.ntri_smooth * ( tri_size + md.normal_index_bytes * 3 ); len_tri_flat_uv = md.ntri_flat_uv * ( tri_size + md.uv_index_bytes * 3 ); len_tri_smooth_uv = md.ntri_smooth_uv * ( tri_size + md.normal_index_bytes * 3 + md.uv_index_bytes * 3 ); len_quad_flat = md.nquad_flat * ( quad_size ); len_quad_smooth = md.nquad_smooth * ( quad_size + md.normal_index_bytes * 4 ); len_quad_flat_uv = md.nquad_flat_uv * ( quad_size + md.uv_index_bytes * 4 ); len_quad_smooth_uv = md.nquad_smooth_uv * ( quad_size + md.normal_index_bytes * 4 + md.uv_index_bytes * 4 ); // read buffers currentOffset += init_vertices( currentOffset ); currentOffset += init_normals( currentOffset ); currentOffset += handlePadding( md.nnormals * 3 ); currentOffset += init_uvs( currentOffset ); start_tri_flat = currentOffset; start_tri_smooth = start_tri_flat + len_tri_flat + handlePadding( md.ntri_flat * 2 ); start_tri_flat_uv = start_tri_smooth + len_tri_smooth + handlePadding( md.ntri_smooth * 2 ); start_tri_smooth_uv = start_tri_flat_uv + len_tri_flat_uv + handlePadding( md.ntri_flat_uv * 2 ); start_quad_flat = start_tri_smooth_uv + len_tri_smooth_uv + handlePadding( md.ntri_smooth_uv * 2 ); start_quad_smooth = start_quad_flat + len_quad_flat + handlePadding( md.nquad_flat * 2 ); start_quad_flat_uv = start_quad_smooth + len_quad_smooth + handlePadding( md.nquad_smooth * 2 ); <API key>= start_quad_flat_uv + len_quad_flat_uv + handlePadding( md.nquad_flat_uv * 2 ); // have to first process faces with uvs // so that face and uv indices match <API key>( start_tri_flat_uv ); <API key>( start_tri_smooth_uv ); init_quads_flat_uv( start_quad_flat_uv ); <API key>( <API key> ); // now we can process untextured faces init_triangles_flat( start_tri_flat ); <API key>( start_tri_smooth ); init_quads_flat( start_quad_flat ); init_quads_smooth( start_quad_smooth ); this.computeCentroids(); this.computeFaceNormals(); function handlePadding( n ) { return ( n % 4 ) ? ( 4 - n % 4 ) : 0; }; function parseMetaData( data, offset ) { var metaData = { 'signature' :parseString( data, offset, 12 ), 'header_bytes' :parseUChar8( data, offset + 12 ), '<API key>' :parseUChar8( data, offset + 13 ), '<API key>' :parseUChar8( data, offset + 14 ), 'uv_coordinate_bytes' :parseUChar8( data, offset + 15 ), 'vertex_index_bytes' :parseUChar8( data, offset + 16 ), 'normal_index_bytes' :parseUChar8( data, offset + 17 ), 'uv_index_bytes' :parseUChar8( data, offset + 18 ), '<API key>' :parseUChar8( data, offset + 19 ), 'nvertices' :parseUInt32( data, offset + 20 ), 'nnormals' :parseUInt32( data, offset + 20 + 4*1 ), 'nuvs' :parseUInt32( data, offset + 20 + 4*2 ), 'ntri_flat' :parseUInt32( data, offset + 20 + 4*3 ), 'ntri_smooth' :parseUInt32( data, offset + 20 + 4*4 ), 'ntri_flat_uv' :parseUInt32( data, offset + 20 + 4*5 ), 'ntri_smooth_uv' :parseUInt32( data, offset + 20 + 4*6 ), 'nquad_flat' :parseUInt32( data, offset + 20 + 4*7 ), 'nquad_smooth' :parseUInt32( data, offset + 20 + 4*8 ), 'nquad_flat_uv' :parseUInt32( data, offset + 20 + 4*9 ), 'nquad_smooth_uv' :parseUInt32( data, offset + 20 + 4*10 ) }; /* console.log( "signature: " + metaData.signature ); console.log( "header_bytes: " + metaData.header_bytes ); console.log( "<API key>: " + metaData.<API key> ); console.log( "<API key>: " + metaData.<API key> ); console.log( "uv_coordinate_bytes: " + metaData.uv_coordinate_bytes ); console.log( "vertex_index_bytes: " + metaData.vertex_index_bytes ); console.log( "normal_index_bytes: " + metaData.normal_index_bytes ); console.log( "uv_index_bytes: " + metaData.uv_index_bytes ); console.log( "<API key>: " + metaData.<API key> ); console.log( "nvertices: " + metaData.nvertices ); console.log( "nnormals: " + metaData.nnormals ); console.log( "nuvs: " + metaData.nuvs ); console.log( "ntri_flat: " + metaData.ntri_flat ); console.log( "ntri_smooth: " + metaData.ntri_smooth ); console.log( "ntri_flat_uv: " + metaData.ntri_flat_uv ); console.log( "ntri_smooth_uv: " + metaData.ntri_smooth_uv ); console.log( "nquad_flat: " + metaData.nquad_flat ); console.log( "nquad_smooth: " + metaData.nquad_smooth ); console.log( "nquad_flat_uv: " + metaData.nquad_flat_uv ); console.log( "nquad_smooth_uv: " + metaData.nquad_smooth_uv ); var total = metaData.header_bytes + metaData.nvertices * metaData.<API key> * 3 + metaData.nnormals * metaData.<API key> * 3 + metaData.nuvs * metaData.uv_coordinate_bytes * 2 + metaData.ntri_flat * ( metaData.vertex_index_bytes*3 + metaData.<API key> ) + metaData.ntri_smooth * ( metaData.vertex_index_bytes*3 + metaData.<API key> + metaData.normal_index_bytes*3 ) + metaData.ntri_flat_uv * ( metaData.vertex_index_bytes*3 + metaData.<API key> + metaData.uv_index_bytes*3 ) + metaData.ntri_smooth_uv * ( metaData.vertex_index_bytes*3 + metaData.<API key> + metaData.normal_index_bytes*3 + metaData.uv_index_bytes*3 ) + metaData.nquad_flat * ( metaData.vertex_index_bytes*4 + metaData.<API key> ) + metaData.nquad_smooth * ( metaData.vertex_index_bytes*4 + metaData.<API key> + metaData.normal_index_bytes*4 ) + metaData.nquad_flat_uv * ( metaData.vertex_index_bytes*4 + metaData.<API key> + metaData.uv_index_bytes*4 ) + metaData.nquad_smooth_uv * ( metaData.vertex_index_bytes*4 + metaData.<API key> + metaData.normal_index_bytes*4 + metaData.uv_index_bytes*4 ); console.log( "total bytes: " + total ); */ return metaData; }; function parseString( data, offset, length ) { var charArray = new Uint8Array( data, offset, length ); var text = ""; for ( var i = 0; i < length; i ++ ) { text += String.fromCharCode( charArray[ offset + i ] ); } return text; }; function parseUChar8( data, offset ) { var charArray = new Uint8Array( data, offset, 1 ); return charArray[ 0 ]; }; function parseUInt32( data, offset ) { var intArray = new Uint32Array( data, offset, 1 ); return intArray[ 0 ]; }; function init_vertices( start ) { var nElements = md.nvertices; var coordArray = new Float32Array( data, start, nElements * 3 ); var i, x, y, z; for( i = 0; i < nElements; i ++ ) { x = coordArray[ i * 3 ]; y = coordArray[ i * 3 + 1 ]; z = coordArray[ i * 3 + 2 ]; vertex( scope, x, y, z ); } return nElements * 3 * Float32Array.BYTES_PER_ELEMENT; }; function init_normals( start ) { var nElements = md.nnormals; if ( nElements ) { var normalArray = new Int8Array( data, start, nElements * 3 ); var i, x, y, z; for( i = 0; i < nElements; i ++ ) { x = normalArray[ i * 3 ]; y = normalArray[ i * 3 + 1 ]; z = normalArray[ i * 3 + 2 ]; normals.push( x/127, y/127, z/127 ); } } return nElements * 3 * Int8Array.BYTES_PER_ELEMENT; }; function init_uvs( start ) { var nElements = md.nuvs; if ( nElements ) { var uvArray = new Float32Array( data, start, nElements * 2 ); var i, u, v; for( i = 0; i < nElements; i ++ ) { u = uvArray[ i * 2 ]; v = uvArray[ i * 2 + 1 ]; uvs.push( u, v ); } } return nElements * 2 * Float32Array.BYTES_PER_ELEMENT; }; function init_uvs3( nElements, offset ) { var i, uva, uvb, uvc, u1, u2, u3, v1, v2, v3; var uvIndexBuffer = new Uint32Array( data, offset, 3 * nElements ); for( i = 0; i < nElements; i ++ ) { uva = uvIndexBuffer[ i * 3 ]; uvb = uvIndexBuffer[ i * 3 + 1 ]; uvc = uvIndexBuffer[ i * 3 + 2 ]; u1 = uvs[ uva*2 ]; v1 = uvs[ uva*2 + 1 ]; u2 = uvs[ uvb*2 ]; v2 = uvs[ uvb*2 + 1 ]; u3 = uvs[ uvc*2 ]; v3 = uvs[ uvc*2 + 1 ]; uv3( scope.faceVertexUvs[ 0 ], u1, v1, u2, v2, u3, v3 ); } }; function init_uvs4( nElements, offset ) { var i, uva, uvb, uvc, uvd, u1, u2, u3, u4, v1, v2, v3, v4; var uvIndexBuffer = new Uint32Array( data, offset, 4 * nElements ); for( i = 0; i < nElements; i ++ ) { uva = uvIndexBuffer[ i * 4 ]; uvb = uvIndexBuffer[ i * 4 + 1 ]; uvc = uvIndexBuffer[ i * 4 + 2 ]; uvd = uvIndexBuffer[ i * 4 + 3 ]; u1 = uvs[ uva*2 ]; v1 = uvs[ uva*2 + 1 ]; u2 = uvs[ uvb*2 ]; v2 = uvs[ uvb*2 + 1 ]; u3 = uvs[ uvc*2 ]; v3 = uvs[ uvc*2 + 1 ]; u4 = uvs[ uvd*2 ]; v4 = uvs[ uvd*2 + 1 ]; uv4( scope.faceVertexUvs[ 0 ], u1, v1, u2, v2, u3, v3, u4, v4 ); } }; function init_faces3_flat( nElements, offsetVertices, offsetMaterials ) { var i, a, b, c, m; var vertexIndexBuffer = new Uint32Array( data, offsetVertices, 3 * nElements ); var materialIndexBuffer = new Uint16Array( data, offsetMaterials, nElements ); for( i = 0; i < nElements; i ++ ) { a = vertexIndexBuffer[ i * 3 ]; b = vertexIndexBuffer[ i * 3 + 1 ]; c = vertexIndexBuffer[ i * 3 + 2 ]; m = materialIndexBuffer[ i ]; f3( scope, a, b, c, m ); } }; function init_faces4_flat( nElements, offsetVertices, offsetMaterials ) { var i, a, b, c, d, m; var vertexIndexBuffer = new Uint32Array( data, offsetVertices, 4 * nElements ); var materialIndexBuffer = new Uint16Array( data, offsetMaterials, nElements ); for( i = 0; i < nElements; i ++ ) { a = vertexIndexBuffer[ i * 4 ]; b = vertexIndexBuffer[ i * 4 + 1 ]; c = vertexIndexBuffer[ i * 4 + 2 ]; d = vertexIndexBuffer[ i * 4 + 3 ]; m = materialIndexBuffer[ i ]; f4( scope, a, b, c, d, m ); } }; function init_faces3_smooth( nElements, offsetVertices, offsetNormals, offsetMaterials ) { var i, a, b, c, m; var na, nb, nc; var vertexIndexBuffer = new Uint32Array( data, offsetVertices, 3 * nElements ); var normalIndexBuffer = new Uint32Array( data, offsetNormals, 3 * nElements ); var materialIndexBuffer = new Uint16Array( data, offsetMaterials, nElements ); for( i = 0; i < nElements; i ++ ) { a = vertexIndexBuffer[ i * 3 ]; b = vertexIndexBuffer[ i * 3 + 1 ]; c = vertexIndexBuffer[ i * 3 + 2 ]; na = normalIndexBuffer[ i * 3 ]; nb = normalIndexBuffer[ i * 3 + 1 ]; nc = normalIndexBuffer[ i * 3 + 2 ]; m = materialIndexBuffer[ i ]; f3n( scope, normals, a, b, c, m, na, nb, nc ); } }; function init_faces4_smooth( nElements, offsetVertices, offsetNormals, offsetMaterials ) { var i, a, b, c, d, m; var na, nb, nc, nd; var vertexIndexBuffer = new Uint32Array( data, offsetVertices, 4 * nElements ); var normalIndexBuffer = new Uint32Array( data, offsetNormals, 4 * nElements ); var materialIndexBuffer = new Uint16Array( data, offsetMaterials, nElements ); for( i = 0; i < nElements; i ++ ) { a = vertexIndexBuffer[ i * 4 ]; b = vertexIndexBuffer[ i * 4 + 1 ]; c = vertexIndexBuffer[ i * 4 + 2 ]; d = vertexIndexBuffer[ i * 4 + 3 ]; na = normalIndexBuffer[ i * 4 ]; nb = normalIndexBuffer[ i * 4 + 1 ]; nc = normalIndexBuffer[ i * 4 + 2 ]; nd = normalIndexBuffer[ i * 4 + 3 ]; m = materialIndexBuffer[ i ]; f4n( scope, normals, a, b, c, d, m, na, nb, nc, nd ); } }; function init_triangles_flat( start ) { var nElements = md.ntri_flat; if ( nElements ) { var offsetMaterials = start + nElements * Uint32Array.BYTES_PER_ELEMENT * 3; init_faces3_flat( nElements, start, offsetMaterials ); } }; function <API key>( start ) { var nElements = md.ntri_flat_uv; if ( nElements ) { var offsetUvs = start + nElements * Uint32Array.BYTES_PER_ELEMENT * 3; var offsetMaterials = offsetUvs + nElements * Uint32Array.BYTES_PER_ELEMENT * 3; init_faces3_flat( nElements, start, offsetMaterials ); init_uvs3( nElements, offsetUvs ); } }; function <API key>( start ) { var nElements = md.ntri_smooth; if ( nElements ) { var offsetNormals = start + nElements * Uint32Array.BYTES_PER_ELEMENT * 3; var offsetMaterials = offsetNormals + nElements * Uint32Array.BYTES_PER_ELEMENT * 3; init_faces3_smooth( nElements, start, offsetNormals, offsetMaterials ); } }; function <API key>( start ) { var nElements = md.ntri_smooth_uv; if ( nElements ) { var offsetNormals = start + nElements * Uint32Array.BYTES_PER_ELEMENT * 3; var offsetUvs = offsetNormals + nElements * Uint32Array.BYTES_PER_ELEMENT * 3; var offsetMaterials = offsetUvs + nElements * Uint32Array.BYTES_PER_ELEMENT * 3; init_faces3_smooth( nElements, start, offsetNormals, offsetMaterials ); init_uvs3( nElements, offsetUvs ); } }; function init_quads_flat( start ) { var nElements = md.nquad_flat; if ( nElements ) { var offsetMaterials = start + nElements * Uint32Array.BYTES_PER_ELEMENT * 4; init_faces4_flat( nElements, start, offsetMaterials ); } }; function init_quads_flat_uv( start ) { var nElements = md.nquad_flat_uv; if ( nElements ) { var offsetUvs = start + nElements * Uint32Array.BYTES_PER_ELEMENT * 4; var offsetMaterials = offsetUvs + nElements * Uint32Array.BYTES_PER_ELEMENT * 4; init_faces4_flat( nElements, start, offsetMaterials ); init_uvs4( nElements, offsetUvs ); } }; function init_quads_smooth( start ) { var nElements = md.nquad_smooth; if ( nElements ) { var offsetNormals = start + nElements * Uint32Array.BYTES_PER_ELEMENT * 4; var offsetMaterials = offsetNormals + nElements * Uint32Array.BYTES_PER_ELEMENT * 4; init_faces4_smooth( nElements, start, offsetNormals, offsetMaterials ); } }; function <API key>( start ) { var nElements = md.nquad_smooth_uv; if ( nElements ) { var offsetNormals = start + nElements * Uint32Array.BYTES_PER_ELEMENT * 4; var offsetUvs = offsetNormals + nElements * Uint32Array.BYTES_PER_ELEMENT * 4; var offsetMaterials = offsetUvs + nElements * Uint32Array.BYTES_PER_ELEMENT * 4; init_faces4_smooth( nElements, start, offsetNormals, offsetMaterials ); init_uvs4( nElements, offsetUvs ); } }; }; function vertex ( scope, x, y, z ) { scope.vertices.push( new THREE.Vector3( x, y, z ) ); }; function f3 ( scope, a, b, c, mi ) { scope.faces.push( new THREE.Face3( a, b, c, null, null, mi ) ); }; function f4 ( scope, a, b, c, d, mi ) { scope.faces.push( new THREE.Face3( a, b, d, null, null, mi ) ); scope.faces.push( new THREE.Face3( b, c, d, null, null, mi ) ); }; function f3n ( scope, normals, a, b, c, mi, na, nb, nc ) { var nax = normals[ na*3 ], nay = normals[ na*3 + 1 ], naz = normals[ na*3 + 2 ], nbx = normals[ nb*3 ], nby = normals[ nb*3 + 1 ], nbz = normals[ nb*3 + 2 ], ncx = normals[ nc*3 ], ncy = normals[ nc*3 + 1 ], ncz = normals[ nc*3 + 2 ]; scope.faces.push( new THREE.Face3( a, b, c, [new THREE.Vector3( nax, nay, naz ), new THREE.Vector3( nbx, nby, nbz ), new THREE.Vector3( ncx, ncy, ncz )], null, mi ) ); }; function f4n ( scope, normals, a, b, c, d, mi, na, nb, nc, nd ) { var nax = normals[ na*3 ], nay = normals[ na*3 + 1 ], naz = normals[ na*3 + 2 ], nbx = normals[ nb*3 ], nby = normals[ nb*3 + 1 ], nbz = normals[ nb*3 + 2 ], ncx = normals[ nc*3 ], ncy = normals[ nc*3 + 1 ], ncz = normals[ nc*3 + 2 ], ndx = normals[ nd*3 ], ndy = normals[ nd*3 + 1 ], ndz = normals[ nd*3 + 2 ]; scope.faces.push( new THREE.Face3( a, b, d, [ new THREE.Vector3( nax, nay, naz ), new THREE.Vector3( nbx, nby, nbz ), new THREE.Vector3( ndx, ndy, ndz ) ], null, mi ) ); scope.faces.push( new THREE.Face3( b, c, d, [ new THREE.Vector3( nbx, nby, nbz ), new THREE.Vector3( ncx, ncy, ncz ), new THREE.Vector3( ndx, ndy, ndz ) ], null, mi ) ); }; function uv3 ( where, u1, v1, u2, v2, u3, v3 ) { where.push( [ new THREE.Vector2( u1, v1 ), new THREE.Vector2( u2, v2 ), new THREE.Vector2( u3, v3 ) ] ); }; function uv4 ( where, u1, v1, u2, v2, u3, v3, u4, v4 ) { where.push( [ new THREE.Vector2( u1, v1 ), new THREE.Vector2( u2, v2 ), new THREE.Vector2( u4, v4 ) ] ); where.push( [ new THREE.Vector2( u2, v2 ), new THREE.Vector2( u3, v3 ), new THREE.Vector2( u4, v4 ) ] ); }; Model.prototype = Object.create( THREE.Geometry.prototype ); var geometry = new Model( texturePath ); var materials = this.initMaterials( jsonMaterials, texturePath ); if ( this.needsTangents( materials ) ) geometry.computeTangents(); callback( geometry, materials ); };
;(function ($, window, document, undefined) { "use strict"; window = (typeof window != 'undefined' && window.Math == Math) ? window : (typeof self != 'undefined' && self.Math == Math) ? self : Function('return this')() ; $.fn.rating = function(parameters) { var $allModules = $(this), moduleSelector = $allModules.selector || '', time = new Date().getTime(), performance = [], query = arguments[0], methodInvoked = (typeof query == 'string'), queryArguments = [].slice.call(arguments, 1), returnedValue ; $allModules .each(function() { var settings = ( $.isPlainObject(parameters) ) ? $.extend(true, {}, $.fn.rating.settings, parameters) : $.extend({}, $.fn.rating.settings), namespace = settings.namespace, className = settings.className, metadata = settings.metadata, selector = settings.selector, error = settings.error, eventNamespace = '.' + namespace, moduleNamespace = 'module-' + namespace, element = this, instance = $(this).data(moduleNamespace), $module = $(this), $icon = $module.find(selector.icon), initialLoad, module ; module = { initialize: function() { module.verbose('Initializing rating module', settings); if($icon.length === 0) { module.setup.layout(); } if(settings.interactive) { module.enable(); } else { module.disable(); } module.set.initialLoad(); module.set.rating( module.get.initialRating() ); module.remove.initialLoad(); module.instantiate(); }, instantiate: function() { module.verbose('Instantiating module', settings); instance = module; $module .data(moduleNamespace, module) ; }, destroy: function() { module.verbose('Destroying previous instance', instance); module.remove.events(); $module .removeData(moduleNamespace) ; }, refresh: function() { $icon = $module.find(selector.icon); }, setup: { layout: function() { var maxRating = module.get.maxRating(), html = $.fn.rating.settings.templates.icon(maxRating) ; module.debug('Generating icon html dynamically'); $module .html(html) ; module.refresh(); } }, event: { mouseenter: function() { var $activeIcon = $(this) ; $activeIcon .nextAll() .removeClass(className.selected) ; $module .addClass(className.selected) ; $activeIcon .addClass(className.selected) .prevAll() .addClass(className.selected) ; }, mouseleave: function() { $module .removeClass(className.selected) ; $icon .removeClass(className.selected) ; }, click: function() { var $activeIcon = $(this), currentRating = module.get.rating(), rating = $icon.index($activeIcon) + 1, canClear = (settings.clearable == 'auto') ? ($icon.length === 1) : settings.clearable ; if(canClear && currentRating == rating) { module.clearRating(); } else { module.set.rating( rating ); } } }, clearRating: function() { module.debug('Clearing current rating'); module.set.rating(0); }, bind: { events: function() { module.verbose('Binding events'); $module .on('mouseenter' + eventNamespace, selector.icon, module.event.mouseenter) .on('mouseleave' + eventNamespace, selector.icon, module.event.mouseleave) .on('click' + eventNamespace, selector.icon, module.event.click) ; } }, remove: { events: function() { module.verbose('Removing events'); $module .off(eventNamespace) ; }, initialLoad: function() { initialLoad = false; } }, enable: function() { module.debug('Setting rating to interactive mode'); module.bind.events(); $module .removeClass(className.disabled) ; }, disable: function() { module.debug('Setting rating to read-only mode'); module.remove.events(); $module .addClass(className.disabled) ; }, is: { initialLoad: function() { return initialLoad; } }, get: { initialRating: function() { if($module.data(metadata.rating) !== undefined) { $module.removeData(metadata.rating); return $module.data(metadata.rating); } return settings.initialRating; }, maxRating: function() { if($module.data(metadata.maxRating) !== undefined) { $module.removeData(metadata.maxRating); return $module.data(metadata.maxRating); } return settings.maxRating; }, rating: function() { var currentRating = $icon.filter('.' + className.active).length ; module.verbose('Current rating retrieved', currentRating); return currentRating; } }, set: { rating: function(rating) { var ratingIndex = (rating - 1 >= 0) ? (rating - 1) : 0, $activeIcon = $icon.eq(ratingIndex) ; $module .removeClass(className.selected) ; $icon .removeClass(className.selected) .removeClass(className.active) ; if(rating > 0) { module.verbose('Setting current rating to', rating); $activeIcon .prevAll() .addBack() .addClass(className.active) ; } if(!module.is.initialLoad()) { settings.onRate.call(element, rating); } }, initialLoad: function() { initialLoad = true; } }, setting: function(name, value) { module.debug('Changing setting', name, value); if( $.isPlainObject(name) ) { $.extend(true, settings, name); } else if(value !== undefined) { if($.isPlainObject(settings[name])) { $.extend(true, settings[name], value); } else { settings[name] = value; } } else { return settings[name]; } }, internal: function(name, value) { if( $.isPlainObject(name) ) { $.extend(true, module, name); } else if(value !== undefined) { module[name] = value; } else { return module[name]; } }, debug: function() { if(!settings.silent && settings.debug) { if(settings.performance) { module.performance.log(arguments); } else { module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':'); module.debug.apply(console, arguments); } } }, verbose: function() { if(!settings.silent && settings.verbose && settings.debug) { if(settings.performance) { module.performance.log(arguments); } else { module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':'); module.verbose.apply(console, arguments); } } }, error: function() { if(!settings.silent) { module.error = Function.prototype.bind.call(console.error, console, settings.name + ':'); module.error.apply(console, arguments); } }, performance: { log: function(message) { var currentTime, executionTime, previousTime ; if(settings.performance) { currentTime = new Date().getTime(); previousTime = time || currentTime; executionTime = currentTime - previousTime; time = currentTime; performance.push({ 'Name' : message[0], 'Arguments' : [].slice.call(message, 1) || '', 'Element' : element, 'Execution Time' : executionTime }); } clearTimeout(module.performance.timer); module.performance.timer = setTimeout(module.performance.display, 500); }, display: function() { var title = settings.name + ':', totalTime = 0 ; time = false; clearTimeout(module.performance.timer); $.each(performance, function(index, data) { totalTime += data['Execution Time']; }); title += ' ' + totalTime + 'ms'; if(moduleSelector) { title += ' \'' + moduleSelector + '\''; } if($allModules.length > 1) { title += ' ' + '(' + $allModules.length + ')'; } if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) { console.groupCollapsed(title); if(console.table) { console.table(performance); } else { $.each(performance, function(index, data) { console.log(data['Name'] + ': ' + data['Execution Time']+'ms'); }); } console.groupEnd(); } performance = []; } }, invoke: function(query, passedArguments, context) { var object = instance, maxDepth, found, response ; passedArguments = passedArguments || queryArguments; context = element || context; if(typeof query == 'string' && object !== undefined) { query = query.split(/[\. ]/); maxDepth = query.length - 1; $.each(query, function(depth, value) { var camelCaseValue = (depth != maxDepth) ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1) : query ; if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) { object = object[camelCaseValue]; } else if( object[camelCaseValue] !== undefined ) { found = object[camelCaseValue]; return false; } else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) { object = object[value]; } else if( object[value] !== undefined ) { found = object[value]; return false; } else { return false; } }); } if ( $.isFunction( found ) ) { response = found.apply(context, passedArguments); } else if(found !== undefined) { response = found; } if($.isArray(returnedValue)) { returnedValue.push(response); } else if(returnedValue !== undefined) { returnedValue = [returnedValue, response]; } else if(response !== undefined) { returnedValue = response; } return found; } }; if(methodInvoked) { if(instance === undefined) { module.initialize(); } module.invoke(query); } else { if(instance !== undefined) { instance.invoke('destroy'); } module.initialize(); } }) ; return (returnedValue !== undefined) ? returnedValue : this ; }; $.fn.rating.settings = { name : 'Rating', namespace : 'rating', slent : false, debug : false, verbose : false, performance : true, initialRating : 0, interactive : true, maxRating : 4, clearable : 'auto', fireOnInit : false, onRate : function(rating){}, error : { method : 'The method you called is not defined', noMaximum : 'No maximum rating specified. Cannot generate HTML automatically' }, metadata: { rating : 'rating', maxRating : 'maxRating' }, className : { active : 'active', disabled : 'disabled', selected : 'selected', loading : 'loading' }, selector : { icon : '.icon' }, templates: { icon: function(maxRating) { var icon = 1, html = '' ; while(icon <= maxRating) { html += '<i class="icon"></i>'; icon++; } return html; } } }; })( jQuery, window, document );
/* cp_instrument.h */ /* This file is part of: */ /* GODOT ENGINE */ /* a copy of this software and associated documentation files (the */ /* "Software"), to deal in the Software without restriction, including */ /* without limitation the rights to use, copy, modify, merge, publish, */ /* permit persons to whom the Software is furnished to do so, subject to */ /* the following conditions: */ /* included in all copies or substantial portions of the Software. */ /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef CP_INSTRUMENT_H #define CP_INSTRUMENT_H #include "cp_config.h" #include "cp_note.h" #include "cp_envelope.h" class CPInstrument { public: enum NNA_Type { NNA_NOTE_CUT, NNA_NOTE_CONTINUE, NNA_NOTE_OFF, NNA_NOTE_FADE }; enum DC_Type { DCT_DISABLED, DCT_NOTE, DCT_SAMPLE, DCT_INSTRUMENT }; enum DC_Action { DCA_NOTE_CUT, DCA_NOTE_OFF, DCA_NOTE_FADE, }; enum EnvelopeType { VOLUME_ENVELOPE, PAN_ENVELOPE, PITCH_ENVELOPE }; enum { MAX_NAME_LEN=26, MAX_ENVELOPE_NODES=25, ENVELOPE_FRAC_BITS=8, MAX_VOLUME=128, MAX_FADEOUT=256, MAX_PAN=128, MAX_VOLUME_RANDOM=100, MAX_PAN_RANDOM=64, //what did this guy have inside his head? MAX_FILTER_CUTOFF=127, <API key>=127 }; struct Data { uint8_t sample_number[CPNote::NOTES]; uint8_t note_number[CPNote::NOTES]; NNA_Type NNA_type; DC_Type DC_type; DC_Action DC_action; struct Volume { CPEnvelope envelope; uint8_t global_amount; uint16_t fadeout; uint8_t random_variation; } volume; struct Pan { CPEnvelope envelope; bool use_default; uint8_t default_amount; int8_t pitch_separation; uint8_t pitch_center; uint8_t random_variation; } pan; struct Pitch { CPEnvelope envelope; bool use_as_filter; bool use_default_cutoff; uint8_t default_cutoff; bool <API key>; uint8_t default_resonance; } pitch; }; private: Data data; char name[MAX_NAME_LEN]; public: /* CPInstrument General */ const char *get_name(); void set_name(const char *p_name); void set_sample_number(uint8_t p_note,uint8_t p_sample_id); uint8_t get_sample_number(uint8_t p_note); void set_note_number(uint8_t p_note,uint8_t p_note_id); uint8_t get_note_number(uint8_t p_note); void set_NNA_type(NNA_Type p_NNA_type); NNA_Type get_NNA_type(); void set_DC_type(DC_Type p_DC_type); DC_Type get_DC_type(); void set_DC_action(DC_Action p_DC_action); DC_Action get_DC_action(); /* Volume */ void <API key>(uint8_t p_amount); uint8_t <API key>(); void set_volume_fadeout(uint16_t p_amount); uint16_t get_volume_fadeout(); void <API key>(uint8_t p_amount); uint8_t <API key>(); /* Panning */ void <API key>(uint8_t p_amount); uint8_t <API key>(); void <API key>(bool p_enabled); bool <API key>(); void <API key>(int8_t p_amount); int8_t <API key>(); void <API key>(uint8_t p_amount); uint8_t <API key>(); void <API key>(uint8_t p_amount); uint8_t <API key>(); /* Pitch / Filter */ void <API key>(bool p_enabled); bool <API key>(); void <API key>(bool p_enabled); bool <API key>(); void <API key>(uint8_t p_amount); uint8_t <API key>(); void <API key>(bool p_enabled); bool <API key>(); void <API key>(uint8_t p_amount); uint8_t <API key>(); CPEnvelope* get_volume_envelope(); CPEnvelope* get_pan_envelope(); CPEnvelope* <API key>(); bool is_empty(); void reset(); CPInstrument(); }; #endif
export { Calibrate20 as default } from "../../";
require File.dirname(__FILE__) + '/../abstract_unit' class ProcTests < Test::Unit::TestCase def <API key> block = Proc.new { self } assert_equal self, block.call bound_block = block.bind("hello") assert_not_equal block, bound_block assert_equal "hello", bound_block.call end end
export { NoodleBowl32 as default } from "../../";
export { <API key> as default } from "../../";
<!DOCTYPE html PUBLIC "- <html xmlns="http: <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <title>RakNet: RakNet::SendInvite_Func Struct Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">RakNet &#160;<span id="projectnumber">4.0</span> </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.2 --> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main&#160;Page</span></a></li> <li><a href="pages.html"><span>Related&#160;Pages</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li class="current"><a href="annotated.html"><span>Classes</span></a></li> <li><a href="files.html"><span>Files</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="annotated.html"><span>Class&#160;List</span></a></li> <li><a href="classes.html"><span>Class&#160;Index</span></a></li> <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li> <li><a href="functions.html"><span>Class&#160;Members</span></a></li> </ul> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="namespaceRakNet.html">RakNet</a></li><li class="navelem"><a class="el" href="<API key>.html">SendInvite_Func</a></li> </ul> </div> </div><!-- top --> <div class="header"> <div class="summary"> <a href="<API key>.html">List of all members</a> </div> <div class="headertitle"> <div class="title">RakNet::SendInvite_Func Struct Reference<div class="ingroups"><a class="el" href="<API key>.html">RoomsCommands</a></div></div> </div> </div><!--header <div class="contents"> <p>Sends an invitation to someone. <a href="<API key>.html#details">More...</a></p> <p><code>#include &lt;RoomsPlugin.h&gt;</code></p> <div class="dynheader"> Inheritance diagram for RakNet::SendInvite_Func:</div> <div class="dyncontent"> <div class="center"> <img src="<API key>.png" usemap="#RakNet::SendInvite_Func_map" alt=""/> <map id="RakNet::SendInvite_Func_map" name="RakNet::SendInvite_Func_map"> <area href="<API key>.html" title="Base class for rooms functionality." alt="RakNet::RoomsPluginFunc" shape="rect" coords="0,0,159,24"/> </map> </div></div> <table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="inherited"></a> Additional Inherited Members</h2></td></tr> <tr class="inherit_header <API key>"><td colspan="2" onclick="javascript:toggleInherit('<API key>')"><img src="closed.png" alt="-"/>&#160;Public Attributes inherited from <a class="el" href="<API key>.html">RakNet::RoomsPluginFunc</a></td></tr> <tr class="memitem:<API key> inherit <API key>"><td class="memItemLeft" align="right" valign="top"><a class="el" href="<API key>.html">RakNet::RakString</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="<API key>.html#<API key>">userName</a></td></tr> <tr class="separator:<API key> inherit <API key>"><td class="memSeparator" colspan="2">&#160;</td></tr> <tr class="memitem:<API key> inherit <API key>"><td class="memItemLeft" align="right" valign="top">RoomsErrorCode&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="<API key>.html#<API key>">resultCode</a></td></tr> <tr class="separator:<API key> inherit <API key>"><td class="memSeparator" colspan="2">&#160;</td></tr> </table> <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> <div class="textblock"><p>Sends an invitation to someone. </p> <p>Each user may have at most one invitation to the same room, although they have have invitations to multiple rooms.<br/> This may fail depending on the room settings - the moderator may not allow other users to send invitations.<br/> Invitations may be cleared when the moderator changes, depending on the room settings </p> </div><hr/>The documentation for this struct was generated from the following file:<ul> <li>D:/temp/RakNet_PC/DependentExtensions/Lobby2/Rooms/<a class="el" href="RoomsPlugin_8h.html">RoomsPlugin.h</a></li> </ul> </div><!-- contents --> <!-- start footer part --> <hr class="footer"/><address class="footer"><small> Generated on Mon Jun 2 2014 20:10:30 for RakNet by & <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.8.2 </small></address> </body> </html>
#ifndef MSM_FB_PANEL_H #define MSM_FB_PANEL_H #include "msm_fb_def.h" struct msm_fb_data_type; typedef void (*<API key>) (void *arg); /* panel id type */ typedef struct panel_id_s { uint16 id; uint16 type; } panel_id_type; /* panel type list */ #define NO_PANEL 0xffff /* No Panel */ #define MDDI_PANEL 1 /* MDDI */ #define EBI2_PANEL 2 /* EBI2 */ #define LCDC_PANEL 3 /* internal LCDC type */ #define EXT_MDDI_PANEL 4 /* Ext.MDDI */ #define TV_PANEL 5 #define HDMI_PANEL 6 /* HDMI TV */ #define DTV_PANEL 7 /* DTV */ #define MIPI_VIDEO_PANEL 8 /* MIPI */ #define MIPI_CMD_PANEL 9 /* MIPI */ #define WRITEBACK_PANEL 10 /* Wifi display */ /* panel class */ typedef enum { DISPLAY_LCD = 0, /* lcd = ebi2/mddi */ DISPLAY_LCDC, /* lcdc */ DISPLAY_TV, /* TV Out */ DISPLAY_EXT_MDDI, /* External MDDI */ } DISP_TARGET; /* panel device locaiton */ typedef enum { DISPLAY_1 = 0, /* attached as first device */ DISPLAY_2, /* attached on second device */ DISPLAY_3, /* attached on third writeback device */ MAX_PHYS_TARGET_NUM, } DISP_TARGET_PHYS; /* panel info type */ struct lcd_panel_info { __u32 vsync_enable; __u32 refx100; __u32 v_back_porch; __u32 v_front_porch; __u32 v_pulse_width; __u32 hw_vsync_mode; __u32 <API key>; __u32 rev; }; struct lcdc_panel_info { __u32 h_back_porch; __u32 h_front_porch; __u32 h_pulse_width; __u32 v_back_porch; __u32 v_front_porch; __u32 v_pulse_width; __u32 border_clr; __u32 underflow_clr; __u32 hsync_skew; }; struct mddi_panel_info { __u32 vdopkt; }; /* DSI PHY configuration */ struct mipi_dsi_phy_ctrl { uint32 regulator[5]; uint32 timing[12]; uint32 ctrl[4]; uint32 strength[4]; uint32 pll[21]; }; struct mipi_panel_info { char mode; /* video/cmd */ char interleave_mode; char crc_check; char ecc_check; char dst_format; /* shared by video and command */ char data_lane0; char data_lane1; char data_lane2; char data_lane3; char dlane_swap; /* data lane swap */ char rgb_swap; char b_sel; char g_sel; char r_sel; char rx_eot_ignore; char tx_eot_append; char t_clk_post; /* 0xc0, <API key> */ char t_clk_pre; /* 0xc0, <API key> */ char vc; /* virtual channel */ struct mipi_dsi_phy_ctrl *dsi_phy_db; /* video mode */ char pulse_mode_hsa_he; char hfp_power_stop; char hbp_power_stop; char hsa_power_stop; char eof_bllp_power_stop; char bllp_power_stop; char traffic_mode; char frame_rate; /* command mode */ char interleave_max; char insert_dcs_cmd; char wr_mem_continue; char wr_mem_start; char te_sel; char stream; /* 0 or 1 */ char mdp_trigger; char dma_trigger; uint32 dsi_pclk_rate; /* The packet-size should not bet changed */ char no_max_pkt_size; /* Clock required during LP commands */ char force_clk_lane_hs; /* Pad width */ uint32 xres_pad; /* Pad height */ uint32 yres_pad; }; struct msm_panel_info { __u32 xres; __u32 yres; __u32 bpp; __u32 mode2_xres; __u32 mode2_yres; __u32 mode2_bpp; __u32 type; __u32 wait_cycle; DISP_TARGET_PHYS pdest; __u32 bl_max; __u32 bl_min; __u32 fb_num; __u32 clk_rate; __u32 clk_min; __u32 clk_max; __u32 frame_count; __u32 is_3d_panel; struct mddi_panel_info mddi; struct lcd_panel_info lcd; struct lcdc_panel_info lcdc; struct mipi_panel_info mipi; }; #define <API key>(pinfo) \ do { \ (pinfo)->mode2_xres = 0; \ (pinfo)->mode2_yres = 0; \ (pinfo)->mode2_bpp = 0; \ } while (0) struct msm_fb_panel_data { struct msm_panel_info panel_info; void (*set_rect) (int x, int y, int xres, int yres); void (*set_vsync_notifier) (<API key>, void *arg); void (*set_backlight) (struct msm_fb_data_type *); void (*display_on) (struct msm_fb_data_type *); /* function entry chain */ int (*on) (struct platform_device *pdev); int (*off) (struct platform_device *pdev); void (*bklswitch) (struct msm_fb_data_type *, bool on); void (*bklctrl) (struct msm_fb_data_type *, bool on); void (*panel_type_detect) (struct mipi_panel_info *); struct platform_device *next; int (*clk_func) (int enable); }; struct platform_device *msm_fb_device_alloc(struct msm_fb_panel_data *pdata, u32 type, u32 id); int panel_next_on(struct platform_device *pdev); int panel_next_off(struct platform_device *pdev); int <API key>(struct msm_panel_info *pinfo); int <API key>(struct msm_panel_info *pinfo, u32 channel, u32 panel); #endif /* MSM_FB_PANEL_H */
#include "gmp.h" #include "gmp-impl.h" #include "longlong.h" void mpn_mod_1s_2p_cps (mp_limb_t cps[5], mp_limb_t b) { mp_limb_t bi; mp_limb_t B1modb, B2modb, B3modb; int cnt; ASSERT (b <= (~(mp_limb_t) 0) / 2); count_leading_zeros (cnt, b); b <<= cnt; invert_limb (bi, b); cps[0] = bi; cps[1] = cnt; B1modb = -b * ((bi >> (GMP_LIMB_BITS-cnt)) | (CNST_LIMB(1) << cnt)); ASSERT (B1modb <= b); /* NB: not fully reduced mod b */ cps[2] = B1modb >> cnt; udiv_rnnd_preinv (B2modb, B1modb, CNST_LIMB(0), b, bi); cps[3] = B2modb >> cnt; udiv_rnnd_preinv (B3modb, B2modb, CNST_LIMB(0), b, bi); cps[4] = B3modb >> cnt; #if WANT_ASSERT { int i; b = cps[2]; for (i = 3; i <= 4; i++) { b += cps[i]; ASSERT (b >= cps[i]); } } #endif } mp_limb_t mpn_mod_1s_2p (mp_srcptr ap, mp_size_t n, mp_limb_t b, const mp_limb_t cps[5]) { mp_limb_t rh, rl, bi, ph, pl, ch, cl, r; mp_limb_t B1modb, B2modb, B3modb; mp_size_t i; int cnt; ASSERT (n >= 1); B1modb = cps[2]; B2modb = cps[3]; B3modb = cps[4]; if ((n & 1) != 0) { if (n == 1) { rl = ap[n - 1]; bi = cps[0]; cnt = cps[1]; udiv_rnnd_preinv (r, rl >> (GMP_LIMB_BITS - cnt), rl << cnt, b, bi); return r >> cnt; } umul_ppmm (ph, pl, ap[n - 2], B1modb); add_ssaaaa (ph, pl, ph, pl, CNST_LIMB(0), ap[n - 3]); umul_ppmm (rh, rl, ap[n - 1], B2modb); add_ssaaaa (rh, rl, rh, rl, ph, pl); n } else { rh = ap[n - 1]; rl = ap[n - 2]; } for (i = n - 4; i >= 0; i -= 2) { /* rr = ap[i] < B + ap[i+1] * (B mod b) <= (B-1)(b-1) + LO(rr) * (B^2 mod b) <= (B-1)(b-1) + HI(rr) * (B^3 mod b) <= (B-1)(b-1) */ umul_ppmm (ph, pl, ap[i + 1], B1modb); add_ssaaaa (ph, pl, ph, pl, CNST_LIMB(0), ap[i + 0]); umul_ppmm (ch, cl, rl, B2modb); add_ssaaaa (ph, pl, ph, pl, ch, cl); umul_ppmm (rh, rl, rh, B3modb); add_ssaaaa (rh, rl, rh, rl, ph, pl); } umul_ppmm (rh, cl, rh, B1modb); add_ssaaaa (rh, rl, rh, rl, CNST_LIMB(0), cl); cnt = cps[1]; bi = cps[0]; r = (rh << cnt) | (rl >> (GMP_LIMB_BITS - cnt)); udiv_rnnd_preinv (r, r, rl << cnt, b, bi); return r >> cnt; }
/** * Japanese */ $.FE.LANGUAGE['ja'] = { translation: { // Place holder "Type something": "\u4f55\u304b\u5165\u529b", // Basic formatting "Bold": "\u592a\u5b57", "Italic": "\u659c\u4f53", "Underline": "\u4e0b\u7dda", "Strikethrough": "\u53d6\u308a\u6d88\u3057\u7dda", // Main buttons "Insert": "\u30a4\u30f3\u30b5\u30fc\u30c8", "Delete": "\u524a\u9664", "Cancel": "\u30ad\u30e3\u30f3\u30bb\u30eb", "OK": "OK", "Back": "\u30d0\u30c3\u30af", "Remove": "\u524a\u9664\u3057\u307e\u3059", "More": "\u3082\u3063\u3068", "Update": "\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8", "Style": "\u30b9\u30bf\u30a4\u30eb", // Font "Font Family": "\u30d5\u30a9\u30f3\u30c8\u30d5\u30a1\u30df\u30ea\u30fc", "Font Size": "\u30d5\u30a9\u30f3\u30c8\u30b5\u30a4\u30ba", // Colors "Colors": "\u8272", "Background": "\u80cc\u666f", "Text": "\u30c6\u30ad\u30b9\u30c8", // Paragraphs "Paragraph Format": "\u6bb5\u843d\u306e\u66f8\u5f0f", "Normal": "\u30ce\u30fc\u30de\u30eb", "Code": "\u30b3\u30fc\u30c9", "Heading 1": "\u30d8\u30c3\u30c0\u30fc 1", "Heading 2": "\u30d8\u30c3\u30c0\u30fc 2", "Heading 3": "\u30d8\u30c3\u30c0\u30fc 3", "Heading 4": "\u30d8\u30c3\u30c0\u30fc 4", // Style "Paragraph Style": "\u6bb5\u843d\u30b9\u30bf\u30a4\u30eb", "Inline Style": "\u30a4\u30f3\u30e9\u30a4\u30f3\u30b9\u30bf\u30a4\u30eb", // Alignment "Align": "\u914d\u7f6e", "Align Left": "\u5de6\u5bc4\u305b", "Align Center": "\u4e2d\u592e\u63c3\u3048", "Align Right": "\u53f3\u5bc4\u305b", "Align Justify": "\u4e21\u7aef\u63c3\u3048", "None": "\u306a\u3057", // Lists "Ordered List": "\u756a\u53f7\u4ed8\u304d\u7b87\u6761\u66f8\u304d", "Unordered List": "\u7b87\u6761\u66f8\u304d", // Indent "Decrease Indent": "\u30a4\u30f3\u30c7\u30f3\u30c8\u3092\u6e1b\u3089\u3059", "Increase Indent": "\u30a4\u30f3\u30c7\u30f3\u30c8\u3092\u5897\u3084\u3059", // Links "Insert Link": "\u30ea\u30f3\u30af", "Open in new tab": "\u65b0\u3057\u3044\u30bf\u30d6\u3067\u958b\u304f", "Open Link": "\u30ea\u30f3\u30af\u3092\u958b\u304d\u307e\u3059", "Edit Link": "\u7de8\u96c6\u30ea\u30f3\u30af", "Unlink": "\u30ea\u30f3\u30af\u306e\u524a\u9664", "Choose Link": "\u30ea\u30f3\u30af\u3092\u9078\u629e\u3057\u3066\u304f\u3060\u3055\u3044", // Images "Insert Image": "\u753b\u50cf\u306e\u633f\u5165", "Upload Image": "\u753b\u50cf\u3092\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9", "By URL": "URL \u306b\u3088\u3063\u3066", "Browse": "\u30d6\u30e9\u30a6\u30ba", "Drop image": "\u753b\u50cf\u3092\u30c9\u30ed\u30c3\u30d7", "or click": "\u307e\u305f\u306f\u30af\u30ea\u30c3\u30af", "Manage Images": "\u30a4\u30e1\u30fc\u30b8\u3092\u7ba1\u7406\u3059\u308b", "Loading": "\u30ed\u30fc\u30c7\u30a3\u30f3\u30b0", "Deleting": "\u524a\u9664", "Tags": "\u30bf\u30b0", "Are you sure? Image will be deleted.": "\u672c\u5f53\u306b\u524a\u9664\u3057\u307e\u3059\u304b\uff1f", "Replace": "\u4ea4\u63db\u3057\u307e\u3059", "Uploading": "\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9", "Loading image": "\u753b\u50cf\u8aad\u307f\u8fbc\u307f\u4e2d", "Display": "\u30c7\u30a3\u30b9\u30d7\u30ec\u30a4", "Inline": "\u5217\u3092\u306a\u3057\u3066", "Break Text": "\u30d6\u30ec\u30fc\u30af\u30c6\u30ad\u30b9\u30c8", "Alternate Text": "\u4ee3\u66ff\u30c6\u30ad\u30b9\u30c8", "Change Size": "\u30b5\u30a4\u30ba\u5909\u66f4", "Width": "\u5e45", "Height": "\u9ad8\u3055", "Something went wrong. Please try again.": "\u4f55\u304b\u304c\u9593\u9055\u3063\u3066\u3044\u307e\u3057\u305f\u3002\u3082\u3046\u4e00\u5ea6\u3084\u308a\u76f4\u3057\u3066\u304f\u3060\u3055\u3044\u3002", // Video "Insert Video": "\u52d5\u753b\u306e\u633f\u5165", "Embedded Code": "\u57cb\u3081\u8fbc\u307f\u30b3\u30fc\u30c9", // Tables "Insert Table": "\u8868\u306e\u633f\u5165", "Table Header": "\u8868\u306e\u30d8\u30c3\u30c0\u30fc", "Remove Table": "\u30c6\u30fc\u30d6\u30eb\u3092\u524a\u9664\u3057\u307e\u3059", "Table Style": "\u8868\u306e\u30b9\u30bf\u30a4\u30eb", "Horizontal Align": "\u5e73\u9762\u7dda\u5f62", "Row": "\u884c", "Insert row above": "\u4e0a\u5074\u306b\u884c\u3092\u633f\u5165", "Insert row below": "\u4e0b\u5074\u306b\u884c\u3092\u633f\u5165", "Delete row": "\u884c\u306e\u524a\u9664", "Column": "\u5217", "Insert column before": "\u5de6\u5074\u306b\u5217\u3092\u633f\u5165", "Insert column after": "\u53f3\u5074\u306b\u5217\u3092\u633f\u5165", "Delete column": "\u5217\u306e\u524a\u9664", "Cell": "\u30bb\u30eb", "Merge cells": "\u30bb\u30eb\u306e\u7d50\u5408", "Horizontal split": "\u6c34\u5e73\u5206\u5272", "Vertical split": "\u5782\u76f4\u5206\u5272", "Cell Background": "\u30bb\u30eb\u306e\u80cc\u666f", "Vertical Align": "\u5782\u76f4\u6574\u5217", "Top": "\u4e0a", "Middle": "\u30df\u30c9\u30eb", "Bottom": "\u30dc\u30c8\u30e0", "Align Top": "\u30c8\u30c3\u30d7\u306e\u4f4d\u7f6e\u3092\u5408\u308f\u305b\u307e\u3059", "Align Middle": "\u4e2d\u592e\u3092\u5408\u308f\u305b\u307e\u3059", "Align Bottom": "\u30dc\u30c8\u30e0\u3092\u5408\u308f\u305b", "Cell Style": "\u30bb\u30eb\u30b9\u30bf\u30a4\u30eb", // Files "Upload File": "\u30d5\u30a1\u30a4\u30eb\u306e\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9", "Drop file": "\u30d5\u30a1\u30a4\u30eb\u3092\u30c9\u30ed\u30c3\u30d7", // Emoticons "Emoticons": "\u7d75\u6587\u5b57", "Grinning face": "\u300c\u9854\u3092\u306b\u3084\u306b\u3084", "Grinning face with smiling eyes": "\u300c\u7b11\u9854\u306e\u76ee\u3067\u9854\u3092\u30cb\u30e4\u30ea", "Face with tears of joy": "\u300c\u559c\u3073\u306e\u6d99\u3067\u9854\u300d", "Smiling face with open mouth": "\u300c\u53e3\u3092\u958b\u3051\u3066\u9854\u3092\u7b11\u9854", "Smiling face with open mouth and smiling eyes": "\u300c\u958b\u3044\u305f\u53e3\u3068\u9854\u3092\u7b11\u9854\u3068\u76ee\u3092\u7b11\u9854", "Smiling face with open mouth and cold sweat": "\u300c\u53e3\u3092\u958b\u3051\u3001\u51b7\u305f\u3044\u6c57\u3067\u9854\u3092\u7b11\u9854", "Smiling face with open mouth and tightly-closed eyes": "\u300c\u53e3\u3092\u958b\u3051\u3001\u3057\u3063\u304b\u308a\u3068\u9589\u3058\u305f\u76ee\u3067\u9854\u3092\u7b11\u9854", "Smiling face with halo": "\u300c\u30cf\u30ed\u3068\u9854\u3092\u7b11\u9854", "Smiling face with horns": "\u300c\u89d2\u3067\u9854\u3092\u7b11\u9854", "Winking face": "\u300c\u9854\u306e\u30a6\u30a3\u30f3\u30af", "Smiling face with smiling eyes": "\u300c\u7b11\u9854\u306e\u76ee\u3067\u9854\u3092\u7b11\u9854", "Face savoring delicious food": "\u300c\u7f8e\u5473\u3057\u3044\u6599\u7406\u3092\u5473\u308f\u3046\u9854\u300d", "Relieved face": "\u300c\u5b89\u5fc3\u3057\u305f\u9854", "Smiling face with heart-shaped eyes": "\u300c\u30cf\u30fc\u30c8\u578b\u306e\u76ee\u3067\u9854\u3092\u7b11\u9854", "Smiling face with sunglasses": "\u300c\u30b5\u30f3\u30b0\u30e9\u30b9\u3067\u9854\u3092\u7b11\u9854", "Smirking face": "\u300c\u9854\u3092\u30cb\u30e4\u30cb\u30e4\u7b11\u3044", "Neutral face": "\u300c\u30cb\u30e5\u30fc\u30c8\u30e9\u30eb\u9854", "Expressionless face": "\u300c\u7121\u8868\u60c5\u9854\u300d", "Unamused face": "\u300c\u3057\u3089\u3051\u305f\u9854", "Face with cold sweat": "\u51b7\u305f\u3044\u6c57\u3067\u9854", "Pensive face": "\u300c\u7269\u601d\u3044\u9854", "Confused face": "\u300c\u56f0\u60d1\u3057\u305f\u9854", "Confounded face": "\u300c\u3079\u3089\u307c\u3046\u9854", "Kissing face": "\u300c\u9854\u3092\u30ad\u30b9", "Face throwing a kiss": "\u30ad\u30b9\u3092\u6295\u3052\u308b\u9854\u300d", "Kissing face with smiling eyes": "\u300c\u7b11\u9854\u306e\u76ee\u3067\u9854\u3092\u30ad\u30b9", "Kissing face with closed eyes": "\u300c\u76ee\u3092\u9589\u3058\u9854\u3092\u30ad\u30b9", "Face with stuck out tongue": "\u7a81\u304d\u51fa\u3057\u820c\u3067\u9854", "Face with stuck out tongue and winking eye": "\u7a81\u304d\u51fa\u3057\u820c\u3068\u76ee\u3067\u30a6\u30a4\u30f3\u30af\u9854", "Face with stuck out tongue and tightly-closed eyes": "\u7a81\u304d\u51fa\u3057\u820c\u3001\u3057\u3063\u304b\u308a\u3068\u9589\u3058\u305f\u76ee\u3092\u6301\u3064\u9854", "Disappointed face": "\u304c\u3063\u304b\u308a\u3057\u305f\u9854", "Worried face": "\u300c\u5fc3\u914d\u9854", "Angry face": "\u300c\u6012\u3063\u3066\u3044\u308b\u9854", "Pouting face": "\u300c\u9854\u3092\u6012\u3063\u3066", "Crying face": "\u6ce3\u304d\u9854", "Persevering face": "\u300c\u9854\u306e\u7c98\u308a\u5f37\u3044\u3067\u3059", "Face with look of triumph": "\u300c\u52dd\u5229\u306e\u8868\u60c5\u3067\u9854\u300d", "Disappointed but relieved face": "\u5931\u671b\u3059\u308b\u304c\u9854\u3092\u5b89\u5fc3", "Frowning face with open mouth": "\u300c\u53e3\u3092\u958b\u3051\u3066\u9854\u3092\u3057\u304b\u3081\u3063\u9762", "Anguished face": "\u300c\u82e6\u60a9\u306b\u6e80\u3061\u305f\u9854", "Fearful face": "\u300c\u6050\u308d\u3057\u3044\u9854", "Weary face": "\u300c\u75b2\u308c\u305f\u9854", "Sleepy face": "\u300c\u7720\u3044\u9854", "Tired face": "\u300c\u75b2\u308c\u305f\u9854", "Grimacing face": "\u300c\u9854\u306e\u9854\u3092\u3086\u304c\u3081\u307e\u3059", "Loudly crying face": "\u300c\u5927\u58f0\u9854\u3092\u6ce3\u3044", "Face with open mouth": "\u300c\u53e3\u3092\u958b\u3051\u3066\u9854\u300d", "Hushed face": "\u300c\u9759\u304b\u9854", "Face with open mouth and cold sweat": "\u300c\u53e3\u3092\u958b\u3051\u3001\u51b7\u305f\u3044\u6c57\u3067\u9854\u300d", "Face screaming in fear": "\u6050\u6016\u306e\u4e2d\u3067\u53eb\u3093\u3067\u9854\u300d", "Astonished face": "\u300c\u3073\u3063\u304f\u308a\u3057\u305f\u9854", "Flushed face": "\u300c\u30d5\u30e9\u30c3\u30b7\u30e5\u9854", "Sleeping face": "\u300c\u9854\u306e\u7720\u308a\u307e\u3059", "Dizzy face": "\u300c\u30c7\u30a3\u30b8\u30fc\u9854", "Face without mouth": "\u300c\u53e3\u306a\u3057\u3067\u9854\u300d", "Face with medical mask": "\u300c\u533b\u7642\u7528\u30de\u30b9\u30af\u3067\u9854", // Line breaker "Break": "\u30d6\u30ec\u30fc\u30af", // Math "Subscript": "\u4e0b\u4ed8\u304d\u6587\u5b57", "Superscript": "\u4e0a\u4ed8\u304d\u6587\u5b57", // Full screen "Fullscreen": "\u5168\u753b\u9762\u8868\u793a", // Horizontal line "Insert Horizontal Line": "\u6c34\u5e73\u7dda\u306e\u633f\u5165", // Clear formatting "Clear Formatting": "\u66f8\u5f0f\u306e\u30af\u30ea\u30a2", // Undo, redo "Undo": "\u5143\u306b\u623b\u3059", "Redo": "\u3084\u308a\u76f4\u3059", // Select all "Select All": "\u5168\u3066\u3092\u9078\u629e", // Code view "Code View": "\u30b3\u30fc\u30c9\u30d3\u30e5\u30fc", // Quote "Quote": "\u5f15\u7528", "Increase": "\u5897\u52a0", "Decrease": "\u6e1b\u5c11", // Quick Insert "Quick Insert": "\u30af\u30a4\u30c3\u30af\u30a4\u30f3\u30b5\u30fc\u30c8" }, direction: "ltr" };
#ifndef XPSEUDO_ASM_GCC_H /* prevent circular inclusions */ #define XPSEUDO_ASM_GCC_H /* by using protection macros */ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /* necessary for pre-processor */ #define stringify(s) tostring(s) #define tostring(s) /* pseudo assembler instructions */ #define mfcpsr() ({unsigned int rval; \ __asm__ __volatile__(\ "mrs %0, cpsr\n"\ : "=r" (rval)\ );\ rval;\ }) #define mtcpsr(v) __asm__ __volatile__(\ "msr cpsr,%0\n"\ : : "r" (v)\ ) #define cpsiei() __asm__ __volatile__("cpsie i\n") #define cpsidi() __asm__ __volatile__("cpsid i\n") #define cpsief() __asm__ __volatile__("cpsie f\n") #define cpsidf() __asm__ __volatile__("cpsid f\n") #define mtgpr(rn, v) __asm__ __volatile__(\ "mov r" stringify(rn) ", %0 \n"\ : : "r" (v)\ ) #define mfgpr(rn) ({unsigned int rval; \ __asm__ __volatile__(\ "mov %0,r" stringify(rn) "\n"\ : "=r" (rval)\ );\ rval;\ }) /* memory synchronization operations */ /* Instruction Synchronization Barrier */ #define isb() __asm__ __volatile__ ("isb" : : : "memory") /* Data Synchronization Barrier */ #define dsb() __asm__ __volatile__ ("dsb" : : : "memory") /* Data Memory Barrier */ #define dmb() __asm__ __volatile__ ("dmb" : : : "memory") /* Memory Operations */ #define ldr(adr) ({unsigned long rval; \ __asm__ __volatile__(\ "ldr %0,[%1]"\ : "=r" (rval) : "r" (adr)\ );\ rval;\ }) #define ldrb(adr) ({unsigned char rval; \ __asm__ __volatile__(\ "ldrb %0,[%1]"\ : "=r" (rval) : "r" (adr)\ );\ rval;\ }) #define str(adr, val) __asm__ __volatile__(\ "str %0,[%1]\n"\ : : "r" (val), "r" (adr)\ ) #define strb(adr, val) __asm__ __volatile__(\ "strb %0,[%1]\n"\ : : "r" (val), "r" (adr)\ ) /* Count leading zeroes (clz) */ #define clz(arg) ({unsigned char rval; \ __asm__ __volatile__(\ "clz %0,%1"\ : "=r" (rval) : "r" (arg)\ );\ rval;\ }) /* CP15 operations */ #define mtcp(rn, v) __asm__ __volatile__(\ "mcr " rn "\n"\ : : "r" (v)\ ); #define mfcp(rn) ({unsigned int rval; \ __asm__ __volatile__(\ "mrc " rn "\n"\ : "=r" (rval)\ );\ rval;\ }) #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* XPSEUDO_ASM_GCC_H */
<!DOCTYPE html> <meta charset="utf-8"> <title>If no ancestors generate CSS boxes, the list item has no owner, and thus gets numbered as 0</title> <link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me"> <link rel="help" href="https://html.spec.whatwg.org/multipage/semantics.html#ordinal-value"> <link rel="help" href="https://html.spec.whatwg.org/multipage/semantics.html#list-owner"> <link rel="match" href="<API key>.html"> <style> html, body { display: contents; } li { list-style-type: decimal; margin-left: 50px; } </style> <p>This test matches if the list displays similar to the following</p> <pre>0. A 0. B 0. C</pre> <hr> <li>A</li> <li>B</li> <li>C</li>
package org.appcelerator.titanium.util; import java.io.<API key>; import java.io.IOException; import java.io.InputStream; import java.lang.ref.WeakReference; import java.lang.reflect.<API key>; import java.lang.reflect.Method; import java.net.HttpURLConnection; import java.net.<API key>; import java.net.URL; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.commons.codec.digest.DigestUtils; import org.appcelerator.kroll.KrollDict; import org.appcelerator.kroll.KrollProxy; import org.appcelerator.kroll.common.<API key>; import org.appcelerator.kroll.common.Log; import org.appcelerator.kroll.common.TiMessenger; import org.appcelerator.titanium.TiApplication; import org.appcelerator.titanium.TiBaseActivity; import org.appcelerator.titanium.TiBlob; import org.appcelerator.titanium.TiC; import org.appcelerator.titanium.TiDimension; import org.appcelerator.titanium.io.TiBaseFile; import org.appcelerator.titanium.io.TiFileFactory; import org.appcelerator.titanium.proxy.TiViewProxy; import org.appcelerator.titanium.proxy.TiWindowProxy; import org.appcelerator.titanium.proxy.TiWindowProxy.PostOpenListener; import org.appcelerator.titanium.view.<API key>; import org.appcelerator.titanium.view.TiDrawableReference; import org.appcelerator.titanium.view.TiUIView; import android.app.Activity; import android.support.v7.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.content.res.AssetManager; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.Bitmap.CompressFormat; import android.graphics.Bitmap.Config; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.ColorFilter; import android.graphics.ColorMatrix; import android.graphics.<API key>; import android.graphics.Paint; import android.graphics.PixelFormat; import android.graphics.Rect; import android.graphics.Shader; import android.graphics.Typeface; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; import android.graphics.drawable.StateListDrawable; import android.net.Uri; import android.os.AsyncTask; import android.os.Build; import android.os.Handler; import android.os.Looper; import android.os.Process; import android.text.Spanned; import android.text.method.LinkMovementMethod; import android.text.util.Linkify; import android.util.DisplayMetrics; import android.util.TypedValue; import android.view.Gravity; import android.view.View; import android.view.View.MeasureSpec; import android.view.inputmethod.InputMethodManager; import android.widget.TextView; /** * A set of utility methods focused on UI and View operations. */ @SuppressWarnings("deprecation") public class TiUIHelper { private static final String TAG = "TiUIHelper"; private static final String customFontPath = "Resources/fonts"; public static final int PORTRAIT = 1; public static final int UPSIDE_PORTRAIT = 2; public static final int LANDSCAPE_LEFT = 3; public static final int LANDSCAPE_RIGHT = 4; public static final int FACE_UP = 5; public static final int FACE_DOWN = 6; public static final int UNKNOWN = 7; public static final Pattern SIZED_VALUE = Pattern.compile("([0-9]*\\.?[0-9]+)\\W*(px|dp|dip|sp|sip|mm|pt|in)?"); public static final String MIME_TYPE_PNG = "image/png"; private static Method <API key>; private static Map<String, String> resourceImageKeys = Collections.synchronizedMap(new HashMap<String, String>()); private static Map<String, Typeface> mCustomTypeFaces = Collections.synchronizedMap(new HashMap<String, Typeface>()); public static OnClickListener <API key>() { return new OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Do nothing } }; } public static OnClickListener createKillListener() { return new OnClickListener() { public void onClick(DialogInterface dialog, int which) { Process.killProcess(Process.myPid()); } }; } public static OnClickListener <API key>(final Activity me) { return new OnClickListener(){ public void onClick(DialogInterface dialog, int which) { me.finish(); } }; } public static void <API key>(Context context, String title, String message, OnClickListener positiveListener, OnClickListener negativeListener) { if (positiveListener == null) { positiveListener = <API key>(); } if (negativeListener == null) { negativeListener = createKillListener(); } new AlertDialog.Builder(context).setTitle(title).setMessage(message) .setPositiveButton("Continue", positiveListener) .setNegativeButton("Kill", negativeListener) .setCancelable(false).create().show(); } public static void linkifyIfEnabled(TextView tv, Object autoLink) { if (autoLink != null) { //Default to Ti.UI.AUTOLINK_NONE boolean success = Linkify.addLinks(tv, TiConvert.toInt(autoLink, 16)); if (!success && tv.getText() instanceof Spanned) { tv.setMovementMethod(LinkMovementMethod.getInstance()); } } } /** * Waits for the current activity to be ready, then invokes * {@link <API key>#<API key>(Activity)}. * @param l the <API key>. */ public static void <API key>(final <API key> l) { // Some window opens are async, so we need to make sure we don't // sandwich ourselves in between windows when transitioning // between activities TIMOB-3644 TiWindowProxy waitingForOpen = TiWindowProxy.getWaitingForOpen(); if (waitingForOpen != null) { waitingForOpen.setPostOpenListener(new PostOpenListener() { // TODO @Override public void onPostOpen(TiWindowProxy window) { TiApplication app = TiApplication.getInstance(); Activity activity = app.getCurrentActivity(); if (activity != null) { l.<API key>(activity); } } }); } else { TiApplication app = TiApplication.getInstance(); Activity activity = app.getCurrentActivity(); if (activity != null) { l.<API key>(activity); } } } /** * Creates and shows a dialog with an OK button given title and message. * The dialog's creation context is the current activity. * @param title the title of dialog. * @param message the dialog's message. * @param listener the click listener for click events. */ public static void doOkDialog(final String title, final String message, OnClickListener listener) { if (listener == null) { listener = new OnClickListener() { public void onClick(DialogInterface dialog, int which) { Activity ownerActivity = ((AlertDialog)dialog).getOwnerActivity(); //if activity is not finishing, remove dialog to free memory if (ownerActivity != null && !ownerActivity.isFinishing()) { ((TiBaseActivity)ownerActivity).removeDialog((AlertDialog) dialog); } }}; } final OnClickListener fListener = listener; <API key>(new <API key>() { // TODO @Override public void <API key>(Activity activity) { //add dialog to activity for cleaning up purposes if (!activity.isFinishing()) { AlertDialog dialog = new AlertDialog.Builder(activity).setTitle(title).setMessage(message) .setPositiveButton(android.R.string.ok, fListener) .setCancelable(false).create(); if (activity instanceof TiBaseActivity) { TiBaseActivity baseActivity = (TiBaseActivity) activity; baseActivity.addDialog(baseActivity.new DialogWrapper(dialog, true, new WeakReference<TiBaseActivity>(baseActivity))); dialog.setOwnerActivity(activity); } dialog.show(); } } }); } public static int toTypefaceStyle(String fontWeight, String fontStyle) { int style = Typeface.NORMAL; if (fontWeight != null) { if (fontWeight.equals("bold")) { if (fontStyle != null && fontStyle.equals("italic")) { style = Typeface.BOLD_ITALIC; } else { style = Typeface.BOLD; } } else if (fontStyle != null && fontStyle.equals("italic")) { style = Typeface.ITALIC; } } else if (fontStyle != null && fontStyle.equals("italic")) { style = Typeface.ITALIC; } return style; } public static int getSizeUnits(String size) { int units = TypedValue.COMPLEX_UNIT_PX; String unitString = null; if (size != null) { Matcher m = SIZED_VALUE.matcher(size.trim()); if (m.matches()) { if (m.groupCount() == 2) { unitString = m.group(2); } } } if (unitString == null) { unitString = TiApplication.getInstance().getDefaultUnit(); } if (TiDimension.UNIT_PX.equals(unitString) || TiDimension.UNIT_SYSTEM.equals(unitString)) { units = TypedValue.COMPLEX_UNIT_PX; } else if (TiDimension.UNIT_PT.equals(unitString)) { units = TypedValue.COMPLEX_UNIT_PT; } else if (TiDimension.UNIT_DP.equals(unitString) || TiDimension.UNIT_DIP.equals(unitString)) { units = TypedValue.COMPLEX_UNIT_DIP; } else if (TiDimension.UNIT_SP.equals(unitString) || TiDimension.UNIT_SIP.equals(unitString)) { units = TypedValue.COMPLEX_UNIT_SP; } else if (TiDimension.UNIT_MM.equals(unitString)) { units = TypedValue.COMPLEX_UNIT_MM; } else if (TiDimension.UNIT_CM.equals(unitString)) { units = TiDimension.COMPLEX_UNIT_CM; } else if (TiDimension.UNIT_IN.equals(unitString)) { units = TypedValue.COMPLEX_UNIT_IN; } else { if (unitString != null) { Log.w(TAG, "Unknown unit: " + unitString, Log.DEBUG_MODE); } } return units; } public static float getSize(String size) { float value = 15.0f; if (size != null) { Matcher m = SIZED_VALUE.matcher(size.trim()); if (m.matches()) { value = Float.parseFloat(m.group(1)); } } return value; } public static float getRawSize(int unit, float size, Context context) { Resources r; if (context != null) { r = context.getResources(); } else { r = Resources.getSystem(); } return TypedValue.applyDimension(unit, size, r.getDisplayMetrics()); } public static float getRawDIPSize(float size, Context context) { return getRawSize(TypedValue.COMPLEX_UNIT_DIP, size, context); } public static float getRawSize(String size, Context context) { return getRawSize(getSizeUnits(size), getSize(size), context); } public static void styleText(TextView tv, HashMap<String, Object> d) { if (d == null) { TiUIHelper.styleText(tv, null, null, null); return; } String fontSize = null; String fontWeight = null; String fontFamily = null; String fontStyle = null; if (d.containsKey("fontSize")) { fontSize = TiConvert.toString(d, "fontSize"); } if (d.containsKey("fontWeight")) { fontWeight = TiConvert.toString(d, "fontWeight"); } if (d.containsKey("fontFamily")) { fontFamily = TiConvert.toString(d, "fontFamily"); } if (d.containsKey("fontStyle")) { fontStyle = TiConvert.toString(d, "fontStyle"); } TiUIHelper.styleText(tv, fontFamily, fontSize, fontWeight, fontStyle); } public static void styleText(TextView tv, String fontFamily, String fontSize, String fontWeight) { styleText(tv, fontFamily, fontSize, fontWeight, null); } public static void styleText(TextView tv, String fontFamily, String fontSize, String fontWeight, String fontStyle) { Typeface tf = tv.getTypeface(); tf = toTypeface(tv.getContext(), fontFamily); tv.setTypeface(tf, toTypefaceStyle(fontWeight, fontStyle)); tv.setTextSize(getSizeUnits(fontSize), getSize(fontSize)); } public static boolean isAndroidTypeface(String fontFamily) { if (fontFamily != null) { if ("monospace".equals(fontFamily)) { return true; } else if ("serif".equals(fontFamily)) { return true; } else if ("sans-serif".equals(fontFamily)) { return true; } } return false; } public static Typeface toTypeface(Context context, String fontFamily) { Typeface tf = Typeface.SANS_SERIF; // default if (fontFamily != null) { if ("monospace".equals(fontFamily)) { tf = Typeface.MONOSPACE; } else if ("serif".equals(fontFamily)) { tf = Typeface.SERIF; } else if ("sans-serif".equals(fontFamily)) { tf = Typeface.SANS_SERIF; } else { Typeface loadedTf = null; if (context != null) { loadedTf = loadTypeface(context, fontFamily); } if (loadedTf == null) { Log.w(TAG, "Unsupported font: '" + fontFamily + "' supported fonts are 'monospace', 'serif', 'sans-serif'.", Log.DEBUG_MODE); } else { tf = loadedTf; } } } return tf; } public static Typeface toTypeface(String fontFamily) { return toTypeface(null, fontFamily); } private static Typeface loadTypeface(Context context, String fontFamily) { if (context == null) { return null; } if (mCustomTypeFaces.containsKey(fontFamily)) { return mCustomTypeFaces.get(fontFamily); } AssetManager mgr = context.getAssets(); try { String[] fontFiles = mgr.list(customFontPath); for (String f : fontFiles) { if (f.toLowerCase() == fontFamily.toLowerCase() || f.toLowerCase().startsWith(fontFamily.toLowerCase() + ".")) { Typeface tf = Typeface.createFromAsset(mgr, customFontPath + "/" + f); synchronized(mCustomTypeFaces) { mCustomTypeFaces.put(fontFamily, tf); } return tf; } } } catch (IOException e) { Log.e(TAG, "Unable to load 'fonts' assets. Perhaps doesn't exist? " + e.getMessage()); } mCustomTypeFaces.put(fontFamily, null); return null; } public static String getDefaultFontSize(Context context) { String size = "15.0px"; TextView tv = new TextView(context); if (tv != null) { size = String.valueOf(tv.getTextSize()) + "px"; tv = null; } return size; } public static String <API key>(Context context) { String style = "normal"; TextView tv = new TextView(context); if (tv != null) { Typeface tf = tv.getTypeface(); if (tf != null && tf.isBold()) { style = "bold"; } } return style; } public static void setAlignment(TextView tv, String textAlign, String verticalAlign) { int gravity = Gravity.NO_GRAVITY; if (textAlign != null) { if ("left".equals(textAlign)) { gravity |= Gravity.LEFT; } else if ("center".equals(textAlign)) { gravity |= Gravity.CENTER_HORIZONTAL; } else if ("right".equals(textAlign)) { gravity |= Gravity.RIGHT; } else { Log.w(TAG, "Unsupported horizontal alignment: " + textAlign); } } else { // Nothing has been set - let's set if something was set previously // You can do this with shortcut syntax - but long term maint of code is easier if it's explicit Log.w(TAG, "No alignment set - old horizontal align was: " + (tv.getGravity() & Gravity.<API key>), Log.DEBUG_MODE); if ((tv.getGravity() & Gravity.<API key>) != Gravity.NO_GRAVITY) { // Something was set before - so let's use it gravity |= tv.getGravity() & Gravity.<API key>; } } if (verticalAlign != null) { if ("top".equals(verticalAlign)) { gravity |= Gravity.TOP; } else if ("middle".equals(verticalAlign)) { gravity |= Gravity.CENTER_VERTICAL; } else if ("bottom".equals(verticalAlign)) { gravity |= Gravity.BOTTOM; } else { Log.w(TAG, "Unsupported vertical alignment: " + verticalAlign); } } else { // Nothing has been set - let's set if something was set previously // You can do this with shortcut syntax - but long term maint of code is easier if it's explicit Log.w(TAG, "No alignment set - old vertical align was: " + (tv.getGravity() & Gravity.<API key>), Log.DEBUG_MODE); if ((tv.getGravity() & Gravity.<API key>) != Gravity.NO_GRAVITY) { // Something was set before - so let's use it gravity |= tv.getGravity() & Gravity.<API key>; } } tv.setGravity(gravity); } public static final int FONT_SIZE_POSITION = 0; public static final int <API key> = 1; public static final int <API key> = 2; public static final int FONT_STYLE_POSITION = 3; public static String[] getFontProperties(KrollDict fontProps) { boolean bFontSet = false; String[] fontProperties = new String[4]; if (fontProps.containsKey(TiC.PROPERTY_FONT) && fontProps.get(TiC.PROPERTY_FONT) instanceof HashMap) { bFontSet = true; KrollDict font = fontProps.getKrollDict(TiC.PROPERTY_FONT); if (font.containsKey(TiC.PROPERTY_FONTSIZE)) { fontProperties[FONT_SIZE_POSITION] = TiConvert.toString(font, TiC.PROPERTY_FONTSIZE); } if (font.containsKey(TiC.PROPERTY_FONTFAMILY)) { fontProperties[<API key>] = TiConvert.toString(font, TiC.PROPERTY_FONTFAMILY); } if (font.containsKey(TiC.PROPERTY_FONTWEIGHT)) { fontProperties[<API key>] = TiConvert.toString(font, TiC.PROPERTY_FONTWEIGHT); } if (font.containsKey(TiC.PROPERTY_FONTSTYLE)) { fontProperties[FONT_STYLE_POSITION] = TiConvert.toString(font, TiC.PROPERTY_FONTSTYLE); } } else { if (fontProps.containsKey(TiC.<API key>)) { bFontSet = true; fontProperties[<API key>] = TiConvert.toString(fontProps, TiC.<API key>); } if (fontProps.containsKey(TiC.PROPERTY_FONT_SIZE)) { bFontSet = true; fontProperties[FONT_SIZE_POSITION] = TiConvert.toString(fontProps, TiC.PROPERTY_FONT_SIZE); } if (fontProps.containsKey(TiC.<API key>)) { bFontSet = true; fontProperties[<API key>] = TiConvert.toString(fontProps, TiC.<API key>); } if (fontProps.containsKey(TiC.PROPERTY_FONTFAMILY)) { bFontSet = true; fontProperties[<API key>] = TiConvert.toString(fontProps, TiC.PROPERTY_FONTFAMILY); } if (fontProps.containsKey(TiC.PROPERTY_FONTSIZE)) { bFontSet = true; fontProperties[FONT_SIZE_POSITION] = TiConvert.toString(fontProps, TiC.PROPERTY_FONTSIZE); } if (fontProps.containsKey(TiC.PROPERTY_FONTWEIGHT)) { bFontSet = true; fontProperties[<API key>] = TiConvert.toString(fontProps, TiC.PROPERTY_FONTWEIGHT); } if (fontProps.containsKey(TiC.PROPERTY_FONTSTYLE)) { bFontSet = true; fontProperties[FONT_STYLE_POSITION] = TiConvert.toString(fontProps, TiC.PROPERTY_FONTSTYLE); } } if (!bFontSet) { return null; } return fontProperties; } public static void <API key>(TextView textView, int horizontalPadding, int verticalPadding) { int rawHPadding = (int)getRawDIPSize(horizontalPadding, textView.getContext()); int rawVPadding = (int)getRawDIPSize(verticalPadding, textView.getContext()); textView.setPadding(rawHPadding, rawVPadding, rawHPadding, rawVPadding); } public static Drawable <API key>(String color, String image, boolean tileImage, Drawable gradientDrawable) { // Create an array of the layers that will compose this background. // Note that the order in which the layers is important to get the // correct rendering behavior. ArrayList<Drawable> layers = new ArrayList<Drawable>(3); if (color != null) { Drawable colorDrawable = new ColorDrawable(TiColorHelper.parseColor(color)); layers.add(colorDrawable); } if (gradientDrawable != null) { layers.add(gradientDrawable); } Drawable imageDrawable = null; if (image != null) { TiFileHelper tfh = TiFileHelper.getInstance(); imageDrawable = tfh.loadDrawable(image, false, true, false); if (tileImage) { if (imageDrawable instanceof BitmapDrawable) { BitmapDrawable tiledBackground = (BitmapDrawable) imageDrawable; tiledBackground.setTileModeX(Shader.TileMode.REPEAT); tiledBackground.setTileModeY(Shader.TileMode.REPEAT); imageDrawable = tiledBackground; } } if (imageDrawable != null) { layers.add(imageDrawable); } } return new LayerDrawable(layers.toArray(new Drawable[layers.size()])); } private static final int[] <API key> = { android.R.attr.<API key>, android.R.attr.state_enabled }; private static final int[] <API key> = { android.R.attr.state_enabled }; private static final int[] <API key> = { android.R.attr.<API key>, android.R.attr.state_enabled, android.R.attr.state_pressed }; private static final int[] <API key> = { android.R.attr.state_focused, android.R.attr.<API key>, android.R.attr.state_enabled }; private static final int[] <API key> = { -android.R.attr.state_enabled }; public static StateListDrawable <API key>( String image, boolean tileImage, String color, String selectedImage, String selectedColor, String disabledImage, String disabledColor, String focusedImage, String focusedColor, Drawable gradientDrawable) { StateListDrawable sld = new StateListDrawable(); Drawable bgSelectedDrawable = <API key>(selectedColor, selectedImage, tileImage, gradientDrawable); if (bgSelectedDrawable != null) { sld.addState(<API key>, bgSelectedDrawable); } Drawable bgFocusedDrawable = <API key>(focusedColor, focusedImage, tileImage, gradientDrawable); if (bgFocusedDrawable != null) { sld.addState(<API key>, bgFocusedDrawable); } Drawable bgDisabledDrawable = <API key>(disabledColor, disabledImage, tileImage, gradientDrawable); if (bgDisabledDrawable != null) { sld.addState(<API key>, bgDisabledDrawable); } Drawable bgDrawable = <API key>(color, image, tileImage, gradientDrawable); if (bgDrawable != null) { sld.addState(<API key>, bgDrawable); sld.addState(<API key>, bgDrawable); } return sld; } public static KrollDict createDictForImage(int width, int height, byte[] data) { KrollDict d = new KrollDict(); d.put(TiC.PROPERTY_X, 0); d.put(TiC.PROPERTY_Y, 0); d.put(TiC.PROPERTY_WIDTH, width); d.put(TiC.PROPERTY_HEIGHT, height); d.put(TiC.PROPERTY_MIMETYPE, MIME_TYPE_PNG); KrollDict cropRect = new KrollDict(); cropRect.put(TiC.PROPERTY_X, 0); cropRect.put(TiC.PROPERTY_X, 0); cropRect.put(TiC.PROPERTY_WIDTH, width); cropRect.put(TiC.PROPERTY_HEIGHT, height); d.put(TiC.PROPERTY_CROP_RECT, cropRect); d.put(TiC.PROPERTY_MEDIA, TiBlob.blobFromData(data, MIME_TYPE_PNG)); return d; } public static TiBlob getImageFromDict(KrollDict dict) { if (dict != null) { if (dict.containsKey(TiC.PROPERTY_MEDIA)) { Object media = dict.get(TiC.PROPERTY_MEDIA); if (media instanceof TiBlob) { return (TiBlob) media; } } } return null; } public static KrollDict viewToImage(KrollDict proxyDict, View view) { KrollDict image = new KrollDict(); if (view != null) { int width = view.getWidth(); int height = view.getHeight(); // maybe move this out to a separate method once other refactor regarding "getWidth", etc is done if (view.getWidth() == 0 && proxyDict != null && proxyDict.containsKey(TiC.PROPERTY_WIDTH)) { TiDimension widthDimension = new TiDimension(proxyDict.getString(TiC.PROPERTY_WIDTH), TiDimension.TYPE_WIDTH); width = widthDimension.getAsPixels(view); } if (view.getHeight() == 0 && proxyDict != null && proxyDict.containsKey(TiC.PROPERTY_HEIGHT)) { TiDimension heightDimension = new TiDimension(proxyDict.getString(TiC.PROPERTY_HEIGHT), TiDimension.TYPE_HEIGHT); height = heightDimension.getAsPixels(view); } int wmode = width == 0 ? MeasureSpec.UNSPECIFIED : MeasureSpec.EXACTLY; int hmode = height == 0 ? MeasureSpec.UNSPECIFIED : MeasureSpec.EXACTLY; view.measure(MeasureSpec.makeMeasureSpec(width, wmode), MeasureSpec.makeMeasureSpec(height, hmode)); // Will force the view to layout itself, grab dimensions width = view.getMeasuredWidth(); height = view.getMeasuredHeight(); // set a default BS value if the dimension is still 0 and log a warning if (width == 0) { width = 100; Log.e(TAG, "Width property is 0 for view, display view before calling toImage()", Log.DEBUG_MODE); } if (height == 0) { height = 100; Log.e(TAG, "Height property is 0 for view, display view before calling toImage()", Log.DEBUG_MODE); } if (view.getParent() == null) { Log.i(TAG, "View does not have parent, calling layout", Log.DEBUG_MODE); view.layout(0, 0, width, height); } // opacity should support transparency by default Config bitmapConfig = Config.ARGB_8888; Drawable viewBackground = view.getBackground(); if (viewBackground != null) { /* * If the background is opaque then we should be able to safely use a space saving format that * does not support the alpha channel. Basically, if a view has a background color set then the * the pixel format will be opaque. If a background image supports an alpha channel, the pixel * format will report transparency (even if the image doesn't actually look transparent). In * short, most of the time the Config.ARGB_8888 format will be used when viewToImage is used * but in the cases where the background is opaque, the lower memory approach will be used. */ if (viewBackground.getOpacity() == PixelFormat.OPAQUE) { bitmapConfig = Config.RGB_565; } } Bitmap bitmap = Bitmap.createBitmap(width, height, bitmapConfig); Canvas canvas = new Canvas(bitmap); view.draw(canvas); <API key> bos = new <API key>(); if (bitmap.compress(CompressFormat.PNG, 100, bos)) { image = createDictForImage(width, height, bos.toByteArray()); } canvas = null; bitmap.recycle(); } return image; } /** * Creates and returns a Bitmap from an InputStream. * @param stream an InputStream to read bitmap data. * @return a new bitmap instance. * @module.api */ public static Bitmap createBitmap(InputStream stream) { Rect pad = new Rect(); BitmapFactory.Options opts = new BitmapFactory.Options(); opts.inPurgeable = true; opts.inInputShareable = true; Bitmap b = null; try { b = BitmapFactory.<API key>(null, null, stream, pad, opts); } catch (OutOfMemoryError e) { Log.e(TAG, "Unable to load bitmap. Not enough memory: " + e.getMessage()); } return b; } /** * Creates and returns a density scaled Bitmap from an InputStream. * @param stream an InputStream to read bitmap data. * @return a new bitmap instance. */ public static Bitmap <API key>(InputStream stream) { Rect pad = new Rect(); BitmapFactory.Options opts = new BitmapFactory.Options(); opts.inPurgeable = true; opts.inInputShareable = true; DisplayMetrics dm = new DisplayMetrics(); dm.setToDefaults(); opts.inDensity = DisplayMetrics.DENSITY_MEDIUM; opts.inTargetDensity = dm.densityDpi; opts.inScaled = true; Bitmap b = null; try { b = BitmapFactory.<API key>(null, null, stream, pad, opts); } catch (OutOfMemoryError e) { Log.e(TAG, "Unable to load bitmap. Not enough memory: " + e.getMessage()); } return b; } private static String <API key>(String url) { if (resourceImageKeys.containsKey(url)) { return resourceImageKeys.get(url); } Pattern pattern = Pattern.compile("^.*/Resources/images/(.*$)"); Matcher matcher = pattern.matcher(url); if (!matcher.matches()) { return null; } String chopped = matcher.group(1); if (chopped == null) { return null; } chopped = chopped.toLowerCase(); String forHash = chopped; if (forHash.endsWith(".9.png")) { forHash = forHash.replace(".9.png", ".png"); } String withoutExtension = chopped; if (chopped.matches("^.*\\..*$")) { if (chopped.endsWith(".9.png")) { withoutExtension = chopped.substring(0, chopped.lastIndexOf(".9.png")); } else { withoutExtension = chopped.substring(0, chopped.lastIndexOf('.')); } } String <API key> = withoutExtension.replaceAll("[^a-z0-9_]", "_"); StringBuilder result = new StringBuilder(100); result.append(<API key>.substring(0, Math.min(<API key>.length(), 80))) ; result.append("_"); result.append(DigestUtils.md5Hex(forHash).substring(0, 10)); String sResult = result.toString(); resourceImageKeys.put(url, sResult); return sResult; } public static int getResourceId(String url) { if (!url.contains("Resources/images/")) { return 0; } String key = <API key>(url); if (key == null) { return 0; } try { return TiRHelper.getResource("drawable." + key, false); } catch (TiRHelper.<API key> e) { return 0; } } /** * Creates and returns a bitmap from its url. * @param url the bitmap url. * @return a new bitmap instance * @module.api */ public static Bitmap getResourceBitmap(String url) { int id = getResourceId(url); if (id == 0) { return null; } else { return getResourceBitmap(id); } } /** * Creates and returns a bitmap for the specified resource ID. * @param res_id the bitmap id. * @return a new bitmap instance. * @module.api */ public static Bitmap getResourceBitmap(int res_id) { BitmapFactory.Options opts = new BitmapFactory.Options(); opts.inPurgeable = true; opts.inInputShareable = true; Bitmap bitmap = null; try { bitmap = BitmapFactory.decodeResource(TiApplication.getInstance().getResources(), res_id, opts); } catch (OutOfMemoryError e) { Log.e(TAG, "Unable to load bitmap. Not enough memory: " + e.getMessage()); } return bitmap; } public static Drawable loadFastDevDrawable(String url) { try { TiBaseFile tbf = TiFileFactory.createTitaniumFile(new String[] { url }, false); InputStream stream = tbf.getInputStream(); Drawable d = BitmapDrawable.createFromStream(stream, url); stream.close(); return d; } catch (IOException e) { Log.w(TAG, e.getMessage(), e); } return null; } public static Drawable getResourceDrawable(String url) { int id = getResourceId(url); if (id == 0) { return null; } return getResourceDrawable(id); } public static Drawable getResourceDrawable(int res_id) { return TiApplication.getInstance().getResources().getDrawable(res_id); } public static Drawable getResourceDrawable(Object path) { Drawable d = null; try { if (path instanceof String) { TiUrl imageUrl = new TiUrl((String) path); TiFileHelper tfh = new TiFileHelper(TiApplication.getInstance()); d = tfh.loadDrawable(imageUrl.resolve(), false); } else { d = TiDrawableReference.fromObject(TiApplication.getInstance().getCurrentActivity(), path).getDrawable(); } } catch (Exception e) { Log.w(TAG, "Could not load drawable "+e.getMessage(), Log.DEBUG_MODE); d = null; } return d; } public static void <API key>(Activity activity) { if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.DONUT) { return; } if (<API key> == null) { try { <API key> = Activity.class.getMethod("<API key>", Integer.TYPE, Integer.TYPE); } catch (<API key> e) { Log.w(TAG, "Activity.<API key>() not found"); } } if (<API key> != null) { try { <API key>.invoke(activity, new Object[]{0,0}); } catch (<API key> e) { Log.e(TAG, "Called incorrectly: " + e.getMessage()); } catch (<API key> e) { Log.e(TAG, "Illegal access: " + e.getMessage()); } } } public static ColorFilter <API key>(float opacity) { // 5x4 identity color matrix + fade the alpha to achieve opacity float[] matrix = { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, opacity, 0 }; return new <API key>(new ColorMatrix(matrix)); } public static void setDrawableOpacity(Drawable drawable, float opacity) { if (drawable instanceof ColorDrawable || drawable instanceof <API key>) { drawable.setAlpha(Math.round(opacity * 255)); } else if (drawable != null) { drawable.setColorFilter(<API key>(opacity)); } } public static void setPaintOpacity(Paint paint, float opacity) { paint.setColorFilter(<API key>(opacity)); } public static void <API key>(KrollProxy proxy, View view) { int focusState = TiUIView.<API key>; if (proxy.hasProperty(TiC.<API key>)) { focusState = TiConvert.toInt(proxy.getProperty(TiC.<API key>)); } if (focusState > TiUIView.<API key>) { if (focusState == TiUIView.<API key>) { showSoftKeyboard(view, true); } else if (focusState == TiUIView.<API key>) { showSoftKeyboard(view, false); } else { Log.w(TAG, "Unknown onFocus state: " + focusState); } } } /** * Shows/hides the soft keyboard. * @param view the current focused view. * @param show whether to show soft keyboard. */ public static void showSoftKeyboard(View view, boolean show) { InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Activity.<API key>); if (imm != null) { boolean useForce = (Build.VERSION.SDK_INT <= Build.VERSION_CODES.DONUT || Build.VERSION.SDK_INT >= 8) ? true : false; String model = TiPlatformHelper.getInstance().getModel(); if (model != null && model.toLowerCase().startsWith("droid")) { useForce = true; } if (show) { imm.showSoftInput(view, useForce ? InputMethodManager.SHOW_FORCED : InputMethodManager.SHOW_IMPLICIT); } else { imm.<API key>(view.getWindowToken(), useForce ? 0 : InputMethodManager.HIDE_IMPLICIT_ONLY); } } } /** * Run the Runnable "delayed" by using an AsyncTask to first require a new * thread and only then, in onPostExecute, run the Runnable on the UI thread. * @param runnable Runnable to run on UI thread. */ public static void runUiDelayed(final Runnable runnable) { (new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... arg0) { return null; } /** * Always invoked on UI thread. */ @Override protected void onPostExecute(Void result) { Handler handler = new Handler(Looper.getMainLooper()); handler.post(runnable); } }).execute(); } /** * If there is a block on the UI message queue, run the Runnable "delayed". * @param runnable Runnable to run on UI thread. */ public static void runUiDelayedIfBlock(final Runnable runnable) { //if (TiApplication.getInstance().getMessageQueue().isBlocking()) { if (TiMessenger.getMainMessenger().isBlocking()) { runUiDelayed(runnable); } else { //Handler handler = new Handler(Looper.getMainLooper()); //handler.post(runnable); TiMessenger.getMainMessenger().getHandler().post(runnable); } } public static void firePostLayoutEvent(TiViewProxy proxy) { if (proxy != null && proxy.hasListeners(TiC.EVENT_POST_LAYOUT)) { proxy.fireEvent(TiC.EVENT_POST_LAYOUT, null, false); } } /** * To get the redirected Uri * @param Uri */ public static Uri getRedirectUri(Uri mUri) throws <API key>, IOException { if (Build.VERSION.SDK_INT < TiC.API_LEVEL_HONEYCOMB && ("http".equals(mUri.getScheme()) || "https".equals(mUri.getScheme()))) { // Media player doesn't handle redirects, try to follow them // here. (Redirects work fine without this in ICS.) while (true) { // java.net.URL doesn't handle rtsp if (mUri.getScheme() != null && mUri.getScheme().equals("rtsp")) break; URL url = new URL(mUri.toString()); HttpURLConnection cn = (HttpURLConnection) url.openConnection(); cn.<API key>(false); String location = cn.getHeaderField("Location"); if (location != null) { String host = mUri.getHost(); int port = mUri.getPort(); String scheme = mUri.getScheme(); mUri = Uri.parse(location); if (mUri.getScheme() == null) { // Absolute URL on existing host/port/scheme if (scheme == null) { scheme = "http"; } String authority = port == -1 ? host : host + ":" + port; mUri = mUri.buildUpon().scheme(scheme).encodedAuthority(authority).build(); } } else { break; } } } return mUri; } }
<script src="../lodash/lodash.min.js"></script> <script src="../graphlib/dist/graphlib.core.js"></script>
// +build cgo #include <sys/statvfs.h> int getBytesFree(const char *path, unsigned long long *bytes) { struct statvfs buf; int res; if ((res = statvfs(path, &buf)) && res != 0) { return -1; } *bytes = buf.f_frsize * buf.f_bfree; return 0; } int getBytesTotal(const char *path, unsigned long long *bytes) { struct statvfs buf; int res; if ((res = statvfs(path, &buf)) && res != 0) { return -1; } *bytes = buf.f_frsize * buf.f_blocks; return 0; }
/* * cblas_ztbmv.c * The program is a C interface to ztbmv. * * Keita Teranishi 5/20/98 * */ #include "cblas.h" #include "cblas_f77.h" void cblas_ztbmv(const enum CBLAS_ORDER order, const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_DIAG Diag, const int N, const int K, const void *A, const int lda, void *X, const int incX) { char TA; char UL; char DI; #ifdef F77_CHAR F77_CHAR F77_TA, F77_UL, F77_DI; #else #define F77_TA &TA #define F77_UL &UL #define F77_DI &DI #endif #ifdef F77_INT F77_INT F77_N=N, F77_lda=lda, F77_K=K, F77_incX=incX; #else #define F77_N N #define F77_K K #define F77_lda lda #define F77_incX incX #endif int n, i=0, tincX; double *st=0, *x=(double *)X; extern int CBLAS_CallFromC; extern int RowMajorStrg; RowMajorStrg = 0; CBLAS_CallFromC = 1; if (order == CblasColMajor) { if (Uplo == CblasUpper) UL = 'U'; else if (Uplo == CblasLower) UL = 'L'; else { cblas_xerbla(2, "cblas_ztbmv","Illegal Uplo setting, %d\n", Uplo); CBLAS_CallFromC = 0; RowMajorStrg = 0; return; } if (TransA == CblasNoTrans) TA = 'N'; else if (TransA == CblasTrans) TA = 'T'; else if (TransA == CblasConjTrans) TA = 'C'; else { cblas_xerbla(3, "cblas_ztbmv","Illegal TransA setting, %d\n", TransA); CBLAS_CallFromC = 0; RowMajorStrg = 0; return; } if (Diag == CblasUnit) DI = 'U'; else if (Diag == CblasNonUnit) DI = 'N'; else { cblas_xerbla(4, "cblas_ztbmv","Illegal Diag setting, %d\n", Diag); CBLAS_CallFromC = 0; RowMajorStrg = 0; return; } #ifdef F77_CHAR F77_UL = C2F_CHAR(&UL); F77_TA = C2F_CHAR(&TA); F77_DI = C2F_CHAR(&DI); #endif F77_ztbmv( F77_UL, F77_TA, F77_DI, &F77_N, &F77_K, A, &F77_lda, X, &F77_incX); } else if (order == CblasRowMajor) { RowMajorStrg = 1; if (Uplo == CblasUpper) UL = 'L'; else if (Uplo == CblasLower) UL = 'U'; else { cblas_xerbla(2, "cblas_ztbmv","Illegal Uplo setting, %d\n", Uplo); CBLAS_CallFromC = 0; RowMajorStrg = 0; return; } if (TransA == CblasNoTrans) TA = 'T'; else if (TransA == CblasTrans) TA = 'N'; else if (TransA == CblasConjTrans) { TA = 'N'; if ( N > 0) { if(incX > 0) tincX = incX; else tincX = -incX; i = tincX << 1; n = i * N; x++; st = x + n; do { *x = -(*x); x+= i; } while (x != st); x -= n; } } else { cblas_xerbla(3, "cblas_ztbmv","Illegal TransA setting, %d\n", TransA); CBLAS_CallFromC = 0; RowMajorStrg = 0; return; } if (Diag == CblasUnit) DI = 'U'; else if (Diag == CblasNonUnit) DI = 'N'; else { cblas_xerbla(4, "cblas_ztbmv","Illegal Uplo setting, %d\n", Uplo); CBLAS_CallFromC = 0; RowMajorStrg = 0; return; } #ifdef F77_CHAR F77_UL = C2F_CHAR(&UL); F77_TA = C2F_CHAR(&TA); F77_DI = C2F_CHAR(&DI); #endif F77_ztbmv( F77_UL, F77_TA, F77_DI, &F77_N, &F77_K, A, &F77_lda, X, &F77_incX); if (TransA == CblasConjTrans) { if (N > 0) { do { *x = -(*x); x += i; } while (x != st); } } } else cblas_xerbla(1, "cblas_ztbmv", "Illegal Order setting, %d\n", order); CBLAS_CallFromC = 0; RowMajorStrg = 0; return; }
require File.dirname(__FILE__)+'/../test_helper' class <API key> < Test::Unit::TestCase def setup @controller = PostsController.new @create = ResourceController::<API key>.new end should "have success and fails" do assert ResourceController::ActionOptions, @create.success.class assert ResourceController::ActionOptions, @create.fails.class end %w(before).each do |accessor| should "have a block accessor for #{accessor}" do @create.send(accessor) do "return_something" end assert_equal "return_something", @create.send(accessor).first.call(nil) end end should "delegate flash to success" do @create.flash "Successfully created." assert_equal "Successfully created.", @create.success.flash end should "delegate after to success" do @create.after do "something" end assert_equal "something", @create.success.after.first.call end should "delegate response to success" do @create.response do |wants| wants.html end assert @create.wants[:html] end should "delegate wants to success" do @create.wants.html assert @create.wants[:html] end context "duplication" do setup do @opts = ResourceController::<API key>.new @opts.wants.js @opts.failure.wants.js @opts.before {} @dup = @opts.dup end should "duplicate success" do assert !@dup.success.equal?(@opts.success) assert @dup.success.wants[:js] end should "duplicate failure" do assert !@dup.failure.equal?(@opts.failure) assert @dup.failure.wants[:js] end should "duplicate before" do assert !@dup.before.equal?(@opts.before) assert @dup.before end end end
<?php /* vim: set expandtab sw=4 ts=4 sts=4: */ /** * * @package PhpMyAdmin */ if (! defined('PHPMYADMIN')) { exit; } require_once './libraries/Message.class.php'; /** * Handles the recently used tables. * * @TODO Change the release version in table pma_recent * (#recent in documentation) * * @package PhpMyAdmin */ class PMA_RecentTable { /** * Defines the internal PMA table which contains recent tables. * * @access private * @var string */ private $_pmaTable; /** * Reference to session variable containing recently used tables. * * @access public * @var array */ public $tables; /** * PMA_RecentTable instance. * * @var PMA_RecentTable */ private static $_instance; public function __construct() { if (strlen($GLOBALS['cfg']['Server']['pmadb']) && strlen($GLOBALS['cfg']['Server']['recent']) ) { $this->_pmaTable = PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb']) . "." . PMA_Util::backquote($GLOBALS['cfg']['Server']['recent']); } $server_id = $GLOBALS['server']; if (! isset($_SESSION['tmp_user_values']['recent_tables'][$server_id])) { $_SESSION['tmp_user_values']['recent_tables'][$server_id] = isset($this->_pmaTable) ? $this->getFromDb() : array(); } $this->tables =& $_SESSION['tmp_user_values']['recent_tables'][$server_id]; } /** * Returns class instance. * * @return PMA_RecentTable */ public static function getInstance() { if (is_null(self::$_instance)) { self::$_instance = new PMA_RecentTable(); } return self::$_instance; } /** * Returns recently used tables from phpMyAdmin database. * * @return array */ public function getFromDb() { // Read from phpMyAdmin database, if recent tables is not in session $sql_query = " SELECT `tables` FROM " . $this->_pmaTable . " WHERE `username` = '" . $GLOBALS['cfg']['Server']['user'] . "'"; $row = PMA_DBI_fetch_array(<API key>($sql_query)); if (isset($row[0])) { return json_decode($row[0], true); } else { return array(); } } /** * Save recent tables into phpMyAdmin database. * * @return true|PMA_Message */ public function saveToDb() { $username = $GLOBALS['cfg']['Server']['user']; $sql_query = " REPLACE INTO " . $this->_pmaTable . " (`username`, `tables`)" . " VALUES ('" . $username . "', '" . PMA_Util::sqlAddSlashes( json_encode($this->tables) ) . "')"; $success = PMA_DBI_try_query($sql_query, $GLOBALS['controllink']); if (! $success) { $message = PMA_Message::error(__('Could not save recent table')); $message->addMessage('<br /><br />'); $message->addMessage( PMA_Message::rawError(PMA_DBI_getError($GLOBALS['controllink'])) ); return $message; } return true; } /** * Trim recent table according to the NumRecentTables configuration. * * @return boolean True if trimming occurred */ public function trim() { $max = max($GLOBALS['cfg']['NumRecentTables'], 0); $trimming_occured = count($this->tables) > $max; while (count($this->tables) > $max) { array_pop($this->tables); } return $trimming_occured; } /** * Return options for HTML select. * * @return string */ public function getHtmlSelectOption() { // trim and save, in case where the configuration is changed if ($this->trim() && isset($this->_pmaTable)) { $this->saveToDb(); } $html = '<option value="">(' . __('Recent tables') . ') ...</option>'; if (count($this->tables)) { foreach ($this->tables as $table) { $html .= '<option value="' . htmlspecialchars(json_encode($table)) . '">' . htmlspecialchars( '`' . $table['db'] . '`.`' . $table['table'] . '`' ) . '</option>'; } } else { $html .= '<option value="">' . __('There are no recent tables') . '</option>'; } return $html; } /** * Return HTML select. * * @return string */ public function getHtmlSelect() { $html = '<select name="<API key>" id="recentTable">'; $html .= $this->getHtmlSelectOption(); $html .= '</select>'; return $html; } /** * Add recently used tables. * * @param string $db database name where the table is located * @param string $table table name * * @return true|PMA_Message True if success, PMA_Message if not */ public function add($db, $table) { $table_arr = array(); $table_arr['db'] = $db; $table_arr['table'] = $table; // add only if this is new table if (! isset($this->tables[0]) || $this->tables[0] != $table_arr) { array_unshift($this->tables, $table_arr); $this->tables = array_merge(array_unique($this->tables, SORT_REGULAR)); $this->trim(); if (isset($this->_pmaTable)) { return $this->saveToDb(); } } return true; } } ?>
{% load i18n wagtailadmin_tags %} {% if <API key> %} <div class="panel nice-padding">{# TODO try moving these classes onto the section tag #} <section> <h2>{% trans 'Pages awaiting moderation' %}</h2> <table class="listing"> <col /> <col width="30%"/> <col width="15%"/> <col width="15%"/> <thead> <tr> <th class="title">{% trans "Title" %}</th> <th>{% trans "Parent" %}</th> <th>{% trans "Type" %}</th> <th>{% trans "Edited" %}</th> </tr> </thead> <tbody> {% for revision in <API key> %} <tr> <td class="title" valign="top"> <h2> <a href="{% url 'wagtailadmin_pages:edit' revision.page.id %}" title="{% trans 'Edit this page' %}">{{ revision.page.title }}</a> {% include "wagtailadmin/pages/listing/_privacy_indicator.html" with page=revision.page %} {% include "wagtailadmin/pages/listing/_locked_indicator.html" with page=revision.page %} </h2> <ul class="actions"> <li> <form action="{% url 'wagtailadmin_pages:approve_moderation' revision.id %}" method="POST"> {% csrf_token %} <input type="submit" class="button button-small button-secondary" value="{% trans 'Approve' %}"> </form> </li> <li class="no-border"> <form action="{% url 'wagtailadmin_pages:reject_moderation' revision.id %}" method="POST"> {% csrf_token %} <input type="submit" class="button button-small button-secondary no" value="{% trans 'Reject' %}"> </form> </li> <li><a href="{% url 'wagtailadmin_pages:edit' revision.page.id %}" class="button button-small button-secondary">{% trans 'Edit' %}</a></li> <li><a href="{% url 'wagtailadmin_pages:<API key>' revision.id %}" class="button button-small button-secondary">{% trans 'Preview' %}</a></li> </ul> </td> <td valign="top"> <a href="{% url '<API key>' revision.page.get_parent.id %}">{{ revision.page.get_parent.title }}</a> </td> <td class="type" valign="top"> {{ revision.page.content_type.model_class.get_verbose_name }} </td> <td valign="top"> <div class="human-readable-date" title="{{ revision.created_at|date:"d M Y H:i" }}">{{ revision.created_at|timesince }} ago </div> by {{ revision.user.get_full_name|default:revision.user.get_username }} </td> </tr> {% endfor %} </tbody> </table> </section> </div> {% endif %}
<?php /** * Implement needed classes */ #require_once 'Zend/Measure/Abstract.php'; #require_once 'Zend/Locale.php'; class <API key> extends <API key> { const STANDARD = 'HERTZ'; const ONE_PER_SECOND = 'ONE_PER_SECOND'; const CYCLE_PER_SECOND = 'CYCLE_PER_SECOND'; const DEGREE_PER_HOUR = 'DEGREE_PER_HOUR'; const DEGREE_PER_MINUTE = 'DEGREE_PER_MINUTE'; const DEGREE_PER_SECOND = 'DEGREE_PER_SECOND'; const GIGAHERTZ = 'GIGAHERTZ'; const HERTZ = 'HERTZ'; const KILOHERTZ = 'KILOHERTZ'; const MEGAHERTZ = 'MEGAHERTZ'; const MILLIHERTZ = 'MILLIHERTZ'; const RADIAN_PER_HOUR = 'RADIAN_PER_HOUR'; const RADIAN_PER_MINUTE = 'RADIAN_PER_MINUTE'; const RADIAN_PER_SECOND = 'RADIAN_PER_SECOND'; const REVOLUTION_PER_HOUR = 'REVOLUTION_PER_HOUR'; const <API key> = '<API key>'; const <API key> = '<API key>'; const RPM = 'RPM'; const TERRAHERTZ = 'TERRAHERTZ'; /** * Calculations for all frequency units * * @var array */ protected $_units = array( 'ONE_PER_SECOND' => array('1', '1/s'), 'CYCLE_PER_SECOND' => array('1', 'cps'), 'DEGREE_PER_HOUR' => array(array('' => '1', '/' => '1296000'), '°/h'), 'DEGREE_PER_MINUTE' => array(array('' => '1', '/' => '21600'), '°/m'), 'DEGREE_PER_SECOND' => array(array('' => '1', '/' => '360'), '°/s'), 'GIGAHERTZ' => array('1000000000', 'GHz'), 'HERTZ' => array('1', 'Hz'), 'KILOHERTZ' => array('1000', 'kHz'), 'MEGAHERTZ' => array('1000000', 'MHz'), 'MILLIHERTZ' => array('0.001', 'mHz'), 'RADIAN_PER_HOUR' => array(array('' => '1', '/' => '22619.467'), 'rad/h'), 'RADIAN_PER_MINUTE' => array(array('' => '1', '/' => '376.99112'), 'rad/m'), 'RADIAN_PER_SECOND' => array(array('' => '1', '/' => '6.2831853'), 'rad/s'), 'REVOLUTION_PER_HOUR' => array(array('' => '1', '/' => '3600'), 'rph'), '<API key>' => array(array('' => '1', '/' => '60'), 'rpm'), '<API key>' => array('1', 'rps'), 'RPM' => array(array('' => '1', '/' => '60'), 'rpm'), 'TERRAHERTZ' => array('1000000000000', 'THz'), 'STANDARD' =>'HERTZ' ); }
#include "fci_types.h" #include "fci_tun.h" #include "fc8101_regs.h" #include "fc8101_bb.h" #include "fci_hal.h" #include "fc8101_isr.h" int BBM_RESET(HANDLE hDevice) { int res; res = fc8101_reset(hDevice); return res; } int BBM_PROBE(HANDLE hDevice) { int res; res = fc8101_probe(hDevice); return res; } int BBM_INIT(HANDLE hDevice) { int res; res = fc8101_init(hDevice); return res; } int BBM_DEINIT(HANDLE hDevice) { int res; res = fc8101_deinit(hDevice); return res; } int BBM_READ(HANDLE hDevice, u16 addr, u8 *data) { int res; res = bbm_read(hDevice, addr, data); return res; } int BBM_BYTE_READ(HANDLE hDevice, u16 addr, u8 *data) { int res; res = bbm_byte_read(hDevice, addr, data); return res; } int BBM_WORD_READ(HANDLE hDevice, u16 addr, u16 *data) { int res; res = bbm_word_read(hDevice, addr, data); return res; } int BBM_LONG_READ(HANDLE hDevice, u16 addr, u32 *data) { int res; res = bbm_long_read(hDevice, addr, data); return BBM_OK; } int BBM_BULK_READ(HANDLE hDevice, u16 addr, u8 *data, u16 size) { int res; res = bbm_bulk_read(hDevice, addr, data, size); return res; } int BBM_WRITE(HANDLE hDevice, u16 addr, u8 data) { int res; res = bbm_write(hDevice, addr, data); return res; } int BBM_BYTE_WRITE(HANDLE hDevice, u16 addr, u8 data) { int res; res = bbm_byte_write(hDevice, addr, data); return res; } int BBM_WORD_WRITE(HANDLE hDevice, u16 addr, u16 data) { int res; res = bbm_word_write(hDevice, addr, data); return res; } int BBM_LONG_WRITE(HANDLE hDevice, u16 addr, u32 data) { int res; res = bbm_long_write(hDevice, addr, data); return res; } int BBM_BULK_WRITE(HANDLE hDevice, u16 addr, u8 *data, u16 size) { int res; res = bbm_bulk_write(hDevice, addr, data, size); return res; } int BBM_I2C_INIT(HANDLE hDevice, u32 type) { int res; res = tuner_ctrl_select(hDevice, (i2c_type) type); return res; } int BBM_I2C_DEINIT(HANDLE hDevice) { int res; res = tuner_ctrl_deselect(hDevice); return res; } int BBM_TUNER_READ(HANDLE hDevice, u8 addr, u8 alen, u8 *buffer, u8 len) { int res; res = tuner_i2c_rf_read(hDevice, addr, alen, buffer, len); return res; } int BBM_TUNER_WRITE(HANDLE hDevice, u8 addr, u8 alen, u8 *buffer, u8 len) { int res; res = tuner_i2c_rf_write(hDevice, addr, alen, buffer, len); return res; } int BBM_TUNER_SET_FREQ(HANDLE hDevice, u32 ch_num) { int res = BBM_OK; res = tuner_set_freq(hDevice, ch_num); return res; } int BBM_TUNER_SELECT(HANDLE hDevice, u32 product, u32 band) { int res = BBM_OK; res = tuner_select(hDevice, product, band); return res; } int BBM_TUNER_DESELECT(HANDLE hDevice) { int res = BBM_OK; res = tuner_deselect(hDevice); return res; } int BBM_TUNER_GET_RSSI(HANDLE hDevice, s32 *rssi) { int res = BBM_OK; res = tuner_get_rssi(hDevice, rssi); return res; } int BBM_SCAN_STATUS(HANDLE hDevice) { int res = BBM_OK; res = fc8101_scan_status(hDevice); return res; } void BBM_ISR(HANDLE hDevice) { fc8101_isr(hDevice); } int BBM_HOSTIF_SELECT(HANDLE hDevice, u8 hostif) { int res = BBM_NOK; res = bbm_hostif_select(hDevice, hostif); return res; } int BBM_HOSTIF_DESELECT(HANDLE hDevice) { int res = BBM_NOK; res = bbm_hostif_deselect(hDevice); return res; } int <API key>(u32 userdata, int (*callback)(u32 userdata, u8 *data, int length)) { gTSUserData = userdata; pTSCallback = callback; return BBM_OK; } int <API key>(HANDLE hDevice) { gTSUserData = 0; pTSCallback = NULL; return BBM_OK; }
// <API key>: GPL-2.0+ // saa711x - Philips SAA711x video decoder driver // This driver can work with saa7111, saa7111a, saa7113, saa7114, // saa7115 and saa7118. // Based on saa7114 driver by Maxim Yevtyushkin, which is based on // the saa7111 driver by Dave Perks. // Slight changes for video timing and attachment output by // Wolfgang Scherr <scherr@net4you.net> // Moved over to the linux >= 2.4.x i2c protocol (1/1/2003) // by Ronald Bultje <rbultje@ronald.bitfreak.net> // Added saa7115 support by Kevin Thayer <nufan_wfk at yahoo.com> // (2/17/2003) // VBI support (2004) and cleanups (2005) by Hans Verkuil <hverkuil@xs4all.nl> // SAA7111, SAA7113 and SAA7118 support #include "saa711x_regs.h" #include <linux/kernel.h> #include <linux/module.h> #include <linux/slab.h> #include <linux/i2c.h> #include <linux/videodev2.h> #include <media/v4l2-device.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-mc.h> #include <media/i2c/saa7115.h> #include <asm/div64.h> #define VRES_60HZ (480+16) MODULE_DESCRIPTION("Philips SAA7111/SAA7113/SAA7114/SAA7115/SAA7118 video decoder driver"); MODULE_AUTHOR( "Maxim Yevtyushkin, Kevin Thayer, Chris Kennedy, " "Hans Verkuil, Mauro Carvalho Chehab"); MODULE_LICENSE("GPL"); static bool debug; module_param(debug, bool, 0644); MODULE_PARM_DESC(debug, "Debug level (0-1)"); enum saa711x_model { SAA7111A, SAA7111, SAA7113, GM7113C, SAA7114, SAA7115, SAA7118, }; struct saa711x_state { struct v4l2_subdev sd; #ifdef <API key> struct media_pad pads[DEMOD_NUM_PADS]; #endif struct v4l2_ctrl_handler hdl; struct { /* chroma gain control cluster */ struct v4l2_ctrl *agc; struct v4l2_ctrl *gain; }; v4l2_std_id std; int input; int output; int enable; int radio; int width; int height; enum saa711x_model ident; u32 audclk_freq; u32 crystal_freq; bool ucgc; u8 cgcdiv; bool apll; bool double_asclk; }; static inline struct saa711x_state *to_state(struct v4l2_subdev *sd) { return container_of(sd, struct saa711x_state, sd); } static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl) { return &container_of(ctrl->handler, struct saa711x_state, hdl)->sd; } static inline int saa711x_write(struct v4l2_subdev *sd, u8 reg, u8 value) { struct i2c_client *client = v4l2_get_subdevdata(sd); return <API key>(client, reg, value); } /* Sanity routine to check if a register is present */ static int saa711x_has_reg(const int id, const u8 reg) { if (id == SAA7111) return reg < 0x20 && reg != 0x01 && reg != 0x0f && (reg < 0x13 || reg > 0x19) && reg != 0x1d && reg != 0x1e; if (id == SAA7111A) return reg < 0x20 && reg != 0x01 && reg != 0x0f && reg != 0x14 && reg != 0x18 && reg != 0x19 && reg != 0x1d && reg != 0x1e; /* common for saa7113/4/5/8 */ if (unlikely((reg >= 0x3b && reg <= 0x3f) || reg == 0x5c || reg == 0x5f || reg == 0xa3 || reg == 0xa7 || reg == 0xab || reg == 0xaf || (reg >= 0xb5 && reg <= 0xb7) || reg == 0xd3 || reg == 0xd7 || reg == 0xdb || reg == 0xdf || (reg >= 0xe5 && reg <= 0xe7) || reg == 0x82 || (reg >= 0x89 && reg <= 0x8e))) return 0; switch (id) { case GM7113C: return reg != 0x14 && (reg < 0x18 || reg > 0x1e) && reg < 0x20; case SAA7113: return reg != 0x14 && (reg < 0x18 || reg > 0x1e) && (reg < 0x20 || reg > 0x3f) && reg != 0x5d && reg < 0x63; case SAA7114: return (reg < 0x1a || reg > 0x1e) && (reg < 0x20 || reg > 0x2f) && (reg < 0x63 || reg > 0x7f) && reg != 0x33 && reg != 0x37 && reg != 0x81 && reg < 0xf0; case SAA7115: return (reg < 0x20 || reg > 0x2f) && reg != 0x65 && (reg < 0xfc || reg > 0xfe); case SAA7118: return (reg < 0x1a || reg > 0x1d) && (reg < 0x20 || reg > 0x22) && (reg < 0x26 || reg > 0x28) && reg != 0x33 && reg != 0x37 && (reg < 0x63 || reg > 0x7f) && reg != 0x81 && reg < 0xf0; } return 1; } static int saa711x_writeregs(struct v4l2_subdev *sd, const unsigned char *regs) { struct saa711x_state *state = to_state(sd); unsigned char reg, data; while (*regs != 0x00) { reg = *(regs++); data = *(regs++); /* According with datasheets, reserved regs should be filled with 0 - seems better not to touch on they */ if (saa711x_has_reg(state->ident, reg)) { if (saa711x_write(sd, reg, data) < 0) return -1; } else { v4l2_dbg(1, debug, sd, "tried to access reserved reg 0x%02x\n", reg); } } return 0; } static inline int saa711x_read(struct v4l2_subdev *sd, u8 reg) { struct i2c_client *client = v4l2_get_subdevdata(sd); return <API key>(client, reg); } /* SAA7111 initialization table */ static const unsigned char saa7111_init[] = { R_01_INC_DELAY, 0x00, /* reserved */ /*front end */ R_02_INPUT_CNTL_1, 0xd0, /* FUSE=3, GUDL=2, MODE=0 */ R_03_INPUT_CNTL_2, 0x23, /* HLNRS=0, VBSL=1, WPOFF=0, HOLDG=0, * GAFIX=0, GAI1=256, GAI2=256 */ R_04_INPUT_CNTL_3, 0x00, /* GAI1=256 */ R_05_INPUT_CNTL_4, 0x00, /* GAI2=256 */ /* decoder */ R_06_H_SYNC_START, 0xf3, /* HSB at 13(50Hz) / 17(60Hz) * pixels after end of last line */ R_07_H_SYNC_STOP, 0xe8, /* HSS seems to be needed to * work with NTSC, too */ R_08_SYNC_CNTL, 0xc8, /* AUFD=1, FSEL=1, EXFIL=0, * VTRC=1, HPLL=0, VNOI=0 */ R_09_LUMA_CNTL, 0x01, /* BYPS=0, PREF=0, BPSS=0, * VBLB=0, UPTCV=0, APER=1 */ <API key>, 0x80, <API key>, 0x47, /* 0b - CONT=1.109 */ <API key>, 0x40, <API key>, 0x00, R_0E_CHROMA_CNTL_1, 0x01, /* 0e - CDTO=0, CSTD=0, DCCF=0, * FCTC=0, CHBW=1 */ <API key>, 0x00, /* reserved */ R_10_CHROMA_CNTL_2, 0x48, /* 10 - OFTS=1, HDEL=0, VRLN=1, YDEL=0 */ <API key>, 0x1c, /* 11 - GPSW=0, CM99=0, FECO=0, COMPO=1, * OEYC=1, OEHV=1, VIPB=0, COLO=0 */ R_12_RT_SIGNAL_CNTL, 0x00, /* 12 - output control 2 */ <API key>, 0x00, /* 13 - output control 3 */ <API key>, 0x00, <API key>, 0x00, R_16_VGATE_STOP, 0x00, <API key>, 0x00, 0x00, 0x00 }; /* SAA7113 Init codes */ static const unsigned char saa7113_init[] = { R_01_INC_DELAY, 0x08, R_02_INPUT_CNTL_1, 0xc2, R_03_INPUT_CNTL_2, 0x30, R_04_INPUT_CNTL_3, 0x00, R_05_INPUT_CNTL_4, 0x00, R_07_H_SYNC_STOP, 0x0d, R_08_SYNC_CNTL, 0x88, /* Not datasheet default. * HTC = VTR mode, should be 0x98 */ R_09_LUMA_CNTL, 0x01, <API key>, 0x80, <API key>, 0x47, <API key>, 0x40, <API key>, 0x00, R_0E_CHROMA_CNTL_1, 0x01, <API key>, 0x2a, R_10_CHROMA_CNTL_2, 0x08, /* Not datsheet default. * VRLN enabled, should be 0x00 */ <API key>, 0x0c, R_12_RT_SIGNAL_CNTL, 0x07, /* Not datasheet default, * should be 0x01 */ <API key>, 0x00, <API key>, 0x00, <API key>, 0x00, R_16_VGATE_STOP, 0x00, <API key>, 0x00, 0x00, 0x00 }; /* * GM7113C is a clone of the SAA7113 chip * This init table is copied out of the saa7113 datasheet. * In R_08 we enable "Automatic Field Detection" [AUFD], * this is disabled when saa711x_set_v4lstd is called. */ static const unsigned char gm7113c_init[] = { R_01_INC_DELAY, 0x08, R_02_INPUT_CNTL_1, 0xc0, R_03_INPUT_CNTL_2, 0x33, R_04_INPUT_CNTL_3, 0x00, R_05_INPUT_CNTL_4, 0x00, R_06_H_SYNC_START, 0xe9, R_07_H_SYNC_STOP, 0x0d, R_08_SYNC_CNTL, 0x98, R_09_LUMA_CNTL, 0x01, <API key>, 0x80, <API key>, 0x47, <API key>, 0x40, <API key>, 0x00, R_0E_CHROMA_CNTL_1, 0x01, <API key>, 0x2a, R_10_CHROMA_CNTL_2, 0x00, <API key>, 0x0c, R_12_RT_SIGNAL_CNTL, 0x01, <API key>, 0x00, <API key>, 0x00, <API key>, 0x00, R_16_VGATE_STOP, 0x00, <API key>, 0x00, 0x00, 0x00 }; /* If a value differs from the Hauppauge driver values, then the comment starts with 'was 0xXX' to denote the Hauppauge value. Otherwise the value is identical to what the Hauppauge driver sets. */ /* SAA7114 and SAA7115 initialization table */ static const unsigned char <API key>[] = { /* Front-End Part */ R_01_INC_DELAY, 0x48, /* white peak control disabled */ R_03_INPUT_CNTL_2, 0x20, /* was 0x30. 0x20: long vertical blanking */ R_04_INPUT_CNTL_3, 0x90, /* analog gain set to 0 */ R_05_INPUT_CNTL_4, 0x90, /* analog gain set to 0 */ /* Decoder Part */ R_06_H_SYNC_START, 0xeb, /* horiz sync begin = -21 */ R_07_H_SYNC_STOP, 0xe0, /* horiz sync stop = -17 */ R_09_LUMA_CNTL, 0x53, /* 0x53, was 0x56 for 60hz. luminance control */ <API key>, 0x80, /* was 0x88. decoder brightness, 0x80 is itu standard */ <API key>, 0x44, /* was 0x48. decoder contrast, 0x44 is itu standard */ <API key>, 0x40, /* was 0x47. decoder saturation, 0x40 is itu standard */ <API key>, 0x00, <API key>, 0x00, /* use automatic gain */ R_10_CHROMA_CNTL_2, 0x06, /* chroma: active adaptive combfilter */ <API key>, 0x00, R_12_RT_SIGNAL_CNTL, 0x9d, /* RTS0 output control: VGATE */ <API key>, 0x80, /* ITU656 standard mode, RTCO output enable RTCE */ <API key>, 0x00, <API key>, 0x40, /* gain 0x00 = nominal */ <API key>, 0x80, <API key>, 0x77, /* recommended value */ R_1B_MISC_TVVCRDET, 0x42, /* recommended value */ <API key>, 0xa9, /* recommended value */ <API key>, 0x01, /* recommended value */ R_80_GLOBAL_CNTL_1, 0x0, /* No tasks enabled at init */ /* Power Device Control */ <API key>, 0xd0, /* reset device */ <API key>, 0xf0, /* set device programmed, all in operational mode */ 0x00, 0x00 }; /* Used to reset saa7113, saa7114 and saa7115 */ static const unsigned char <API key>[] = { <API key>, 0x00, /* disable I-port output */ <API key>, 0xd0, /* reset scaler */ <API key>, 0xf0, /* activate scaler */ <API key>, 0x01, /* enable I-port output */ 0x00, 0x00 }; static const unsigned char <API key>[] = { R_80_GLOBAL_CNTL_1, 0x00, /* reset tasks */ <API key>, 0xd0, /* reset scaler */ <API key>, 0x03, R_16_VGATE_STOP, 0x11, <API key>, 0x9c, R_08_SYNC_CNTL, 0x68, /* 0xBO: auto detection, 0x68 = NTSC */ R_0E_CHROMA_CNTL_1, 0x07, /* video autodetection is on */ <API key>, 0x06, /* standard 60hz value for ITU656 line counting */ /* Task A */ <API key>, 0x80, <API key>, 0x48, <API key>, 0x40, <API key>, 0x84, /* hoffset low (input), 0x0002 is minimum */ <API key>, 0x01, <API key>, 0x00, /* hsize low (input), 0x02d0 = 720 */ <API key>, 0xd0, <API key>, 0x02, <API key>, 0x05, <API key>, 0x00, <API key>, 0x0c, <API key>, 0x00, <API key>, 0xa0, <API key>, 0x05, <API key>, 0x0c, <API key>, 0x00, /* Task B */ <API key>, 0x00, <API key>, 0x08, <API key>, 0x00, <API key>, 0x80, /* 0x0002 is minimum */ <API key>, 0x02, <API key>, 0x00, /* 0x02d0 = 720 */ <API key>, 0xd0, <API key>, 0x02, /* vwindow start 0x12 = 18 */ <API key>, 0x12, <API key>, 0x00, /* vwindow length 0xf8 = 248 */ <API key>, VRES_60HZ>>1, <API key>, VRES_60HZ>>9, /* hwindow 0x02d0 = 720 */ <API key>, 0xd0, <API key>, 0x02, R_F0_LFCO_PER_LINE, 0xad, /* Set PLL Register. 60hz 525 lines per frame, 27 MHz */ <API key>, 0x05, /* low bit with 0xF0 */ <API key>, 0xad, <API key>, 0x01, 0x00, 0x00 }; static const unsigned char <API key>[] = { R_80_GLOBAL_CNTL_1, 0x00, <API key>, 0xd0, /* reset scaler */ <API key>, 0x37, /* VGATE start */ R_16_VGATE_STOP, 0x16, <API key>, 0x99, R_08_SYNC_CNTL, 0x28, /* 0x28 = PAL */ R_0E_CHROMA_CNTL_1, 0x07, <API key>, 0x03, /* standard 50hz value */ /* Task A */ <API key>, 0x81, <API key>, 0x48, <API key>, 0x40, <API key>, 0x84, /* This is weird: the datasheet says that you should use 2 as the minimum value, */ /* but Hauppauge uses 0, and changing that to 2 causes indeed problems (for 50hz) */ /* hoffset low (input), 0x0002 is minimum */ <API key>, 0x00, <API key>, 0x00, /* hsize low (input), 0x02d0 = 720 */ <API key>, 0xd0, <API key>, 0x02, <API key>, 0x03, <API key>, 0x00, /* vsize 0x12 = 18 */ <API key>, 0x12, <API key>, 0x00, /* hsize 0x05a0 = 1440 */ <API key>, 0xa0, <API key>, 0x05, /* hsize hi (output) */ <API key>, 0x12, /* vsize low (output), 0x12 = 18 */ <API key>, 0x00, /* vsize hi (output) */ /* Task B */ <API key>, 0x00, <API key>, 0x08, <API key>, 0x00, <API key>, 0x80, /* This is weird: the datasheet says that you should use 2 as the minimum value, */ /* but Hauppauge uses 0, and changing that to 2 causes indeed problems (for 50hz) */ /* hoffset low (input), 0x0002 is minimum. See comment above. */ <API key>, 0x00, <API key>, 0x00, /* hsize 0x02d0 = 720 */ <API key>, 0xd0, <API key>, 0x02, /* voffset 0x16 = 22 */ <API key>, 0x16, <API key>, 0x00, /* vsize 0x0120 = 288 */ <API key>, 0x20, <API key>, 0x01, /* hsize 0x02d0 = 720 */ <API key>, 0xd0, <API key>, 0x02, R_F0_LFCO_PER_LINE, 0xb0, /* Set PLL Register. 50hz 625 lines per frame, 27 MHz */ <API key>, 0x05, /* low bit with 0xF0, (was 0x05) */ <API key>, 0xb0, <API key>, 0x01, 0x00, 0x00 }; static const unsigned char saa7115_cfg_vbi_on[] = { R_80_GLOBAL_CNTL_1, 0x00, /* reset tasks */ <API key>, 0xd0, /* reset scaler */ R_80_GLOBAL_CNTL_1, 0x30, /* Activate both tasks */ <API key>, 0xf0, /* activate scaler */ <API key>, 0x01, /* Enable I-port output */ 0x00, 0x00 }; static const unsigned char saa7115_cfg_vbi_off[] = { R_80_GLOBAL_CNTL_1, 0x00, /* reset tasks */ <API key>, 0xd0, /* reset scaler */ R_80_GLOBAL_CNTL_1, 0x20, /* Activate only task "B" */ <API key>, 0xf0, /* activate scaler */ <API key>, 0x01, /* Enable I-port output */ 0x00, 0x00 }; static const unsigned char saa7115_init_misc[] = { <API key>, 0x01, <API key>, 0x01, <API key>, 0x20, <API key>, 0x21, <API key>, 0xc5, <API key>, 0x01, /* Task A */ <API key>, 0x01, <API key>, 0x00, <API key>, 0x00, /* Configure controls at nominal value*/ <API key>, 0x80, <API key>, 0x40, <API key>, 0x40, /* note: 2 x zoom ensures that VBI lines have same length as video lines. */ <API key>, 0x00, <API key>, 0x02, <API key>, 0x00, /* must be horiz lum scaling / 2 */ <API key>, 0x00, <API key>, 0x01, /* must be offset luma / 2 */ <API key>, 0x00, <API key>, 0x00, <API key>, 0x04, <API key>, 0x00, <API key>, 0x04, <API key>, 0x01, <API key>, 0x00, <API key>, 0x00, <API key>, 0x00, <API key>, 0x00, <API key>, 0x00, <API key>, 0x00, <API key>, 0x00, <API key>, 0x00, /* Task B */ <API key>, 0x01, <API key>, 0x00, <API key>, 0x00, /* Configure controls at nominal value*/ <API key>, 0x80, <API key>, 0x40, <API key>, 0x40, /* hor lum scaling 0x0400 = 1 */ <API key>, 0x00, <API key>, 0x04, <API key>, 0x00, /* must be hor lum scaling / 2 */ <API key>, 0x00, <API key>, 0x02, /* must be offset luma / 2 */ <API key>, 0x00, <API key>, 0x00, <API key>, 0x04, <API key>, 0x00, <API key>, 0x04, <API key>, 0x01, <API key>, 0x00, <API key>, 0x00, <API key>, 0x00, <API key>, 0x00, <API key>, 0x00, <API key>, 0x00, <API key>, 0x00, <API key>, 0x00, <API key>, 0x50, /* crystal clock = 24.576 MHz, target = 27MHz */ R_F3_PLL_INCREMENT, 0x46, R_F4_PLL2_STATUS, 0x00, <API key>, 0x4b, /* not the recommended settings! */ R_F8_PULSE_B_POS, 0x00, <API key>, 0x4b, R_FA_PULSE_C_POS, 0x00, <API key>, 0x4b, /* PLL2 lock detection settings: 71 lines 50% phase error */ <API key>, 0x88, /* Turn off VBI */ R_40_SLICER_CNTL_1, 0x20, /* No framing code errors allowed. */ R_41_LCR_BASE, 0xff, R_41_LCR_BASE+1, 0xff, R_41_LCR_BASE+2, 0xff, R_41_LCR_BASE+3, 0xff, R_41_LCR_BASE+4, 0xff, R_41_LCR_BASE+5, 0xff, R_41_LCR_BASE+6, 0xff, R_41_LCR_BASE+7, 0xff, R_41_LCR_BASE+8, 0xff, R_41_LCR_BASE+9, 0xff, R_41_LCR_BASE+10, 0xff, R_41_LCR_BASE+11, 0xff, R_41_LCR_BASE+12, 0xff, R_41_LCR_BASE+13, 0xff, R_41_LCR_BASE+14, 0xff, R_41_LCR_BASE+15, 0xff, R_41_LCR_BASE+16, 0xff, R_41_LCR_BASE+17, 0xff, R_41_LCR_BASE+18, 0xff, R_41_LCR_BASE+19, 0xff, R_41_LCR_BASE+20, 0xff, R_41_LCR_BASE+21, 0xff, R_41_LCR_BASE+22, 0xff, <API key>, 0x40, <API key>, 0x47, <API key>, 0x83, R_5D_DID, 0xbd, R_5E_SDID, 0x35, R_02_INPUT_CNTL_1, 0xc4, /* input tuner -> input 4, amplifier active */ R_80_GLOBAL_CNTL_1, 0x20, /* enable task B */ <API key>, 0xd0, <API key>, 0xf0, 0x00, 0x00 }; static int saa711x_odd_parity(u8 c) { c ^= (c >> 4); c ^= (c >> 2); c ^= (c >> 1); return c & 1; } static int saa711x_decode_vps(u8 *dst, u8 *p) { static const u8 biphase_tbl[] = { 0xf0, 0x78, 0x70, 0xf0, 0xb4, 0x3c, 0x34, 0xb4, 0xb0, 0x38, 0x30, 0xb0, 0xf0, 0x78, 0x70, 0xf0, 0xd2, 0x5a, 0x52, 0xd2, 0x96, 0x1e, 0x16, 0x96, 0x92, 0x1a, 0x12, 0x92, 0xd2, 0x5a, 0x52, 0xd2, 0xd0, 0x58, 0x50, 0xd0, 0x94, 0x1c, 0x14, 0x94, 0x90, 0x18, 0x10, 0x90, 0xd0, 0x58, 0x50, 0xd0, 0xf0, 0x78, 0x70, 0xf0, 0xb4, 0x3c, 0x34, 0xb4, 0xb0, 0x38, 0x30, 0xb0, 0xf0, 0x78, 0x70, 0xf0, 0xe1, 0x69, 0x61, 0xe1, 0xa5, 0x2d, 0x25, 0xa5, 0xa1, 0x29, 0x21, 0xa1, 0xe1, 0x69, 0x61, 0xe1, 0xc3, 0x4b, 0x43, 0xc3, 0x87, 0x0f, 0x07, 0x87, 0x83, 0x0b, 0x03, 0x83, 0xc3, 0x4b, 0x43, 0xc3, 0xc1, 0x49, 0x41, 0xc1, 0x85, 0x0d, 0x05, 0x85, 0x81, 0x09, 0x01, 0x81, 0xc1, 0x49, 0x41, 0xc1, 0xe1, 0x69, 0x61, 0xe1, 0xa5, 0x2d, 0x25, 0xa5, 0xa1, 0x29, 0x21, 0xa1, 0xe1, 0x69, 0x61, 0xe1, 0xe0, 0x68, 0x60, 0xe0, 0xa4, 0x2c, 0x24, 0xa4, 0xa0, 0x28, 0x20, 0xa0, 0xe0, 0x68, 0x60, 0xe0, 0xc2, 0x4a, 0x42, 0xc2, 0x86, 0x0e, 0x06, 0x86, 0x82, 0x0a, 0x02, 0x82, 0xc2, 0x4a, 0x42, 0xc2, 0xc0, 0x48, 0x40, 0xc0, 0x84, 0x0c, 0x04, 0x84, 0x80, 0x08, 0x00, 0x80, 0xc0, 0x48, 0x40, 0xc0, 0xe0, 0x68, 0x60, 0xe0, 0xa4, 0x2c, 0x24, 0xa4, 0xa0, 0x28, 0x20, 0xa0, 0xe0, 0x68, 0x60, 0xe0, 0xf0, 0x78, 0x70, 0xf0, 0xb4, 0x3c, 0x34, 0xb4, 0xb0, 0x38, 0x30, 0xb0, 0xf0, 0x78, 0x70, 0xf0, 0xd2, 0x5a, 0x52, 0xd2, 0x96, 0x1e, 0x16, 0x96, 0x92, 0x1a, 0x12, 0x92, 0xd2, 0x5a, 0x52, 0xd2, 0xd0, 0x58, 0x50, 0xd0, 0x94, 0x1c, 0x14, 0x94, 0x90, 0x18, 0x10, 0x90, 0xd0, 0x58, 0x50, 0xd0, 0xf0, 0x78, 0x70, 0xf0, 0xb4, 0x3c, 0x34, 0xb4, 0xb0, 0x38, 0x30, 0xb0, 0xf0, 0x78, 0x70, 0xf0, }; int i; u8 c, err = 0; for (i = 0; i < 2 * 13; i += 2) { err |= biphase_tbl[p[i]] | biphase_tbl[p[i + 1]]; c = (biphase_tbl[p[i + 1]] & 0xf) | ((biphase_tbl[p[i]] & 0xf) << 4); dst[i / 2] = c; } return err & 0xf0; } static int saa711x_decode_wss(u8 *p) { static const int wss_bits[8] = { 0, 0, 0, 1, 0, 1, 1, 1 }; unsigned char parity; int wss = 0; int i; for (i = 0; i < 16; i++) { int b1 = wss_bits[p[i] & 7]; int b2 = wss_bits[(p[i] >> 3) & 7]; if (b1 == b2) return -1; wss |= b2 << i; } parity = wss & 15; parity ^= parity >> 2; parity ^= parity >> 1; if (!(parity & 1)) return -1; return wss; } static int <API key>(struct v4l2_subdev *sd, u32 freq) { struct saa711x_state *state = to_state(sd); u32 acpf; u32 acni; u32 hz; u64 f; u8 acc = 0; /* reg 0x3a, audio clock control */ /* Checks for chips that don't have audio clock (saa7111, saa7113) */ if (!saa711x_has_reg(state->ident, <API key>)) return 0; v4l2_dbg(1, debug, sd, "set audio clock freq: %d\n", freq); /* sanity check */ if (freq < 32000 || freq > 48000) return -EINVAL; /* hz is the refresh rate times 100 */ hz = (state->std & V4L2_STD_525_60) ? 5994 : 5000; /* acpf = (256 * freq) / field_frequency == (256 * 100 * freq) / hz */ acpf = (25600 * freq) / hz; /* acni = (256 * freq * 2^23) / crystal_frequency = (freq * 2^(8+23)) / crystal_frequency = (freq << 31) / crystal_frequency */ f = freq; f = f << 31; do_div(f, state->crystal_freq); acni = f; if (state->ucgc) { acpf = acpf * state->cgcdiv / 16; acni = acni * state->cgcdiv / 16; acc = 0x80; if (state->cgcdiv == 3) acc |= 0x40; } if (state->apll) acc |= 0x08; if (state->double_asclk) { acpf <<= 1; acni <<= 1; } saa711x_write(sd, <API key>, 0x03); saa711x_write(sd, <API key>, 0x10 << state->double_asclk); saa711x_write(sd, <API key>, acc); saa711x_write(sd, <API key>, acpf & 0xff); saa711x_write(sd, <API key>+1, (acpf >> 8) & 0xff); saa711x_write(sd, <API key>+2, (acpf >> 16) & 0x03); saa711x_write(sd, <API key>, acni & 0xff); saa711x_write(sd, <API key>+1, (acni >> 8) & 0xff); saa711x_write(sd, <API key>+2, (acni >> 16) & 0x3f); state->audclk_freq = freq; return 0; } static int <API key>(struct v4l2_ctrl *ctrl) { struct v4l2_subdev *sd = to_sd(ctrl); struct saa711x_state *state = to_state(sd); switch (ctrl->id) { case V4L2_CID_CHROMA_AGC: /* chroma gain cluster */ if (state->agc->val) state->gain->val = saa711x_read(sd, <API key>) & 0x7f; break; } return 0; } static int saa711x_s_ctrl(struct v4l2_ctrl *ctrl) { struct v4l2_subdev *sd = to_sd(ctrl); struct saa711x_state *state = to_state(sd); switch (ctrl->id) { case V4L2_CID_BRIGHTNESS: saa711x_write(sd, <API key>, ctrl->val); break; case V4L2_CID_CONTRAST: saa711x_write(sd, <API key>, ctrl->val); break; case V4L2_CID_SATURATION: saa711x_write(sd, <API key>, ctrl->val); break; case V4L2_CID_HUE: saa711x_write(sd, <API key>, ctrl->val); break; case V4L2_CID_CHROMA_AGC: /* chroma gain cluster */ if (state->agc->val) saa711x_write(sd, <API key>, state->gain->val); else saa711x_write(sd, <API key>, state->gain->val | 0x80); break; default: return -EINVAL; } return 0; } static int saa711x_set_size(struct v4l2_subdev *sd, int width, int height) { struct saa711x_state *state = to_state(sd); int HPSC, HFSC; int VSCY; int res; int is_50hz = state->std & V4L2_STD_625_50; int Vsrc = is_50hz ? 576 : 480; v4l2_dbg(1, debug, sd, "decoder set size to %ix%i\n", width, height); /* FIXME need better bounds checking here */ if ((width < 1) || (width > 1440)) return -EINVAL; if ((height < 1) || (height > Vsrc)) return -EINVAL; if (!saa711x_has_reg(state->ident, <API key>)) { /* Decoder only supports 720 columns and 480 or 576 lines */ if (width != 720) return -EINVAL; if (height != Vsrc) return -EINVAL; } state->width = width; state->height = height; if (!saa711x_has_reg(state->ident, <API key>)) return 0; /* probably have a valid size, let's set it */ /* Set output width/height */ /* width */ saa711x_write(sd, <API key>, (u8) (width & 0xff)); saa711x_write(sd, <API key>, (u8) ((width >> 8) & 0xff)); /* Vertical Scaling uses height/2 */ res = height / 2; /* On 60Hz, it is using a higher Vertical Output Size */ if (!is_50hz) res += (VRES_60HZ - 480) >> 1; /* height */ saa711x_write(sd, <API key>, (u8) (res & 0xff)); saa711x_write(sd, <API key>, (u8) ((res >> 8) & 0xff)); /* Scaling settings */ /* Hprescaler is floor(inres/outres) */ HPSC = (int)(720 / width); /* 0 is not allowed (div. by zero) */ HPSC = HPSC ? HPSC : 1; HFSC = (int)((1024 * 720) / (HPSC * width)); /* FIXME hardcodes to "Task B" * write H prescaler integer */ saa711x_write(sd, <API key>, (u8) (HPSC & 0x3f)); v4l2_dbg(1, debug, sd, "Hpsc: 0x%05x, Hfsc: 0x%05x\n", HPSC, HFSC); /* write H fine-scaling (luminance) */ saa711x_write(sd, <API key>, (u8) (HFSC & 0xff)); saa711x_write(sd, <API key>, (u8) ((HFSC >> 8) & 0xff)); /* write H fine-scaling (chrominance) * must be lum/2, so i'll just bitshift :) */ saa711x_write(sd, <API key>, (u8) ((HFSC >> 1) & 0xff)); saa711x_write(sd, <API key>, (u8) ((HFSC >> 9) & 0xff)); VSCY = (int)((1024 * Vsrc) / height); v4l2_dbg(1, debug, sd, "Vsrc: %d, Vscy: 0x%05x\n", Vsrc, VSCY); /* Correct Contrast and Luminance */ saa711x_write(sd, <API key>, (u8) (64 * 1024 / VSCY)); saa711x_write(sd, <API key>, (u8) (64 * 1024 / VSCY)); /* write V fine-scaling (luminance) */ saa711x_write(sd, <API key>, (u8) (VSCY & 0xff)); saa711x_write(sd, <API key>, (u8) ((VSCY >> 8) & 0xff)); /* write V fine-scaling (chrominance) */ saa711x_write(sd, <API key>, (u8) (VSCY & 0xff)); saa711x_write(sd, <API key>, (u8) ((VSCY >> 8) & 0xff)); saa711x_writeregs(sd, <API key>); /* Activates task "B" */ saa711x_write(sd, R_80_GLOBAL_CNTL_1, saa711x_read(sd, R_80_GLOBAL_CNTL_1) | 0x20); return 0; } static void saa711x_set_v4lstd(struct v4l2_subdev *sd, v4l2_std_id std) { struct saa711x_state *state = to_state(sd); /* Prevent unnecessary standard changes. During a standard change the I-Port is temporarily disabled. Any devices reading from that port can get confused. Note that s_std is also used to switch from radio to TV mode, so if a s_std is broadcast to all I2C devices then you do not want to have an unwanted side-effect here. */ if (std == state->std) return; state->std = std; // This works for NTSC-M, SECAM-L and the 50Hz PAL variants. if (std & V4L2_STD_525_60) { v4l2_dbg(1, debug, sd, "decoder set standard 60 Hz\n"); if (state->ident == GM7113C) { u8 reg = saa711x_read(sd, R_08_SYNC_CNTL); reg &= ~(SAA7113_R_08_FSEL | SAA7113_R_08_AUFD); reg |= SAA7113_R_08_FSEL; saa711x_write(sd, R_08_SYNC_CNTL, reg); } else { saa711x_writeregs(sd, <API key>); } saa711x_set_size(sd, 720, 480); } else { v4l2_dbg(1, debug, sd, "decoder set standard 50 Hz\n"); if (state->ident == GM7113C) { u8 reg = saa711x_read(sd, R_08_SYNC_CNTL); reg &= ~(SAA7113_R_08_FSEL | SAA7113_R_08_AUFD); saa711x_write(sd, R_08_SYNC_CNTL, reg); } else { saa711x_writeregs(sd, <API key>); } saa711x_set_size(sd, 720, 576); } /* Register 0E - Bits D6-D4 on NO-AUTO mode (SAA7111 and SAA7113 doesn't have auto mode) 50 Hz / 625 lines 60 Hz / 525 lines 000 PAL BGDHI (4.43Mhz) NTSC M (3.58MHz) 001 NTSC 4.43 (50 Hz) PAL 4.43 (60 Hz) 010 Combination-PAL N (3.58MHz) NTSC 4.43 (60 Hz) 011 NTSC N (3.58MHz) PAL M (3.58MHz) 100 reserved NTSC-Japan (3.58MHz) */ if (state->ident <= SAA7113 || state->ident == GM7113C) { u8 reg = saa711x_read(sd, R_0E_CHROMA_CNTL_1) & 0x8f; if (std == V4L2_STD_PAL_M) { reg |= 0x30; } else if (std == V4L2_STD_PAL_Nc) { reg |= 0x20; } else if (std == V4L2_STD_PAL_60) { reg |= 0x10; } else if (std == V4L2_STD_NTSC_M_JP) { reg |= 0x40; } else if (std & V4L2_STD_SECAM) { reg |= 0x50; } saa711x_write(sd, R_0E_CHROMA_CNTL_1, reg); } else { /* restart task B if needed */ int taskb = saa711x_read(sd, R_80_GLOBAL_CNTL_1) & 0x10; if (taskb && state->ident == SAA7114) saa711x_writeregs(sd, saa7115_cfg_vbi_on); /* switch audio mode too! */ <API key>(sd, state->audclk_freq); } } /* setup the sliced VBI lcr registers according to the sliced VBI format */ static void saa711x_set_lcr(struct v4l2_subdev *sd, struct <API key> *fmt) { struct saa711x_state *state = to_state(sd); int is_50hz = (state->std & V4L2_STD_625_50); u8 lcr[24]; int i, x; #if 1 /* saa7113/7114/7118 VBI support are experimental */ if (!saa711x_has_reg(state->ident, R_41_LCR_BASE)) return; #else /* SAA7113 and SAA7118 also should support VBI - Need testing */ if (state->ident != SAA7115) return; #endif for (i = 0; i <= 23; i++) lcr[i] = 0xff; if (fmt == NULL) { /* raw VBI */ if (is_50hz) for (i = 6; i <= 23; i++) lcr[i] = 0xdd; else for (i = 10; i <= 21; i++) lcr[i] = 0xdd; } else { /* sliced VBI */ /* first clear lines that cannot be captured */ if (is_50hz) { for (i = 0; i <= 5; i++) fmt->service_lines[0][i] = fmt->service_lines[1][i] = 0; } else { for (i = 0; i <= 9; i++) fmt->service_lines[0][i] = fmt->service_lines[1][i] = 0; for (i = 22; i <= 23; i++) fmt->service_lines[0][i] = fmt->service_lines[1][i] = 0; } /* Now set the lcr values according to the specified service */ for (i = 6; i <= 23; i++) { lcr[i] = 0; for (x = 0; x <= 1; x++) { switch (fmt->service_lines[1-x][i]) { case 0: lcr[i] |= 0xf << (4 * x); break; case <API key>: lcr[i] |= 1 << (4 * x); break; case <API key>: lcr[i] |= 4 << (4 * x); break; case V4L2_SLICED_WSS_625: lcr[i] |= 5 << (4 * x); break; case V4L2_SLICED_VPS: lcr[i] |= 7 << (4 * x); break; } } } } /* write the lcr registers */ for (i = 2; i <= 23; i++) { saa711x_write(sd, i - 2 + R_41_LCR_BASE, lcr[i]); } /* enable/disable raw VBI capturing */ saa711x_writeregs(sd, fmt == NULL ? saa7115_cfg_vbi_on : saa7115_cfg_vbi_off); } static int <API key>(struct v4l2_subdev *sd, struct <API key> *sliced) { static u16 lcr2vbi[] = { 0, <API key>, 0, 0, <API key>, V4L2_SLICED_WSS_625, 0, V4L2_SLICED_VPS, 0, 0, 0, 0, 0, 0, 0, 0 }; int i; memset(sliced->service_lines, 0, sizeof(sliced->service_lines)); sliced->service_set = 0; /* done if using raw VBI */ if (saa711x_read(sd, R_80_GLOBAL_CNTL_1) & 0x10) return 0; for (i = 2; i <= 23; i++) { u8 v = saa711x_read(sd, i - 2 + R_41_LCR_BASE); sliced->service_lines[0][i] = lcr2vbi[v >> 4]; sliced->service_lines[1][i] = lcr2vbi[v & 0xf]; sliced->service_set |= sliced->service_lines[0][i] | sliced->service_lines[1][i]; } return 0; } static int saa711x_s_raw_fmt(struct v4l2_subdev *sd, struct v4l2_vbi_format *fmt) { saa711x_set_lcr(sd, NULL); return 0; } static int <API key>(struct v4l2_subdev *sd, struct <API key> *fmt) { saa711x_set_lcr(sd, fmt); return 0; } static int saa711x_set_fmt(struct v4l2_subdev *sd, struct <API key> *cfg, struct v4l2_subdev_format *format) { struct v4l2_mbus_framefmt *fmt = &format->format; if (format->pad || fmt->code != MEDIA_BUS_FMT_FIXED) return -EINVAL; fmt->field = <API key>; fmt->colorspace = <API key>; if (format->which == <API key>) return 0; return saa711x_set_size(sd, fmt->width, fmt->height); } static int <API key>(struct v4l2_subdev *sd, struct <API key> *vbi) { struct saa711x_state *state = to_state(sd); static const char vbi_no_data_pattern[] = { 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0 }; u8 *p = vbi->p; u32 wss; int id1, id2; /* the ID1 and ID2 bytes from the internal header */ vbi->type = 0; /* mark result as a failure */ id1 = p[2]; id2 = p[3]; /* Note: the field bit is inverted for 60 Hz video */ if (state->std & V4L2_STD_525_60) id1 ^= 0x40; /* Skip internal header, p now points to the start of the payload */ p += 4; vbi->p = p; /* calculate field and line number of the VBI packet (1-23) */ vbi->is_second_field = ((id1 & 0x40) != 0); vbi->line = (id1 & 0x3f) << 3; vbi->line |= (id2 & 0x70) >> 4; /* Obtain data type */ id2 &= 0xf; /* If the VBI slicer does not detect any signal it will fill up the payload buffer with 0xa0 bytes. */ if (!memcmp(p, vbi_no_data_pattern, sizeof(vbi_no_data_pattern))) return 0; /* decode payloads */ switch (id2) { case 1: vbi->type = <API key>; break; case 4: if (!saa711x_odd_parity(p[0]) || !saa711x_odd_parity(p[1])) return 0; vbi->type = <API key>; break; case 5: wss = saa711x_decode_wss(p); if (wss == -1) return 0; p[0] = wss & 0xff; p[1] = wss >> 8; vbi->type = V4L2_SLICED_WSS_625; break; case 7: if (saa711x_decode_vps(p, p) != 0) return 0; vbi->type = V4L2_SLICED_VPS; break; default: break; } return 0; } static int saa711x_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt) { struct saa711x_state *state = to_state(sd); int status; if (state->radio) return 0; status = saa711x_read(sd, <API key>); v4l2_dbg(1, debug, sd, "status: 0x%02x\n", status); vt->signal = ((status & (1 << 6)) == 0) ? 0xffff : 0x0; return 0; } static int saa711x_s_std(struct v4l2_subdev *sd, v4l2_std_id std) { struct saa711x_state *state = to_state(sd); state->radio = 0; saa711x_set_v4lstd(sd, std); return 0; } static int saa711x_s_radio(struct v4l2_subdev *sd) { struct saa711x_state *state = to_state(sd); state->radio = 1; return 0; } static int saa711x_s_routing(struct v4l2_subdev *sd, u32 input, u32 output, u32 config) { struct saa711x_state *state = to_state(sd); u8 mask = (state->ident <= SAA7111A) ? 0xf8 : 0xf0; v4l2_dbg(1, debug, sd, "decoder set input %d output %d\n", input, output); /* saa7111/3 does not have these inputs */ if ((state->ident <= SAA7113 || state->ident == GM7113C) && (input == SAA7115_COMPOSITE4 || input == SAA7115_COMPOSITE5)) { return -EINVAL; } if (input > SAA7115_SVIDEO3) return -EINVAL; if (state->input == input && state->output == output) return 0; v4l2_dbg(1, debug, sd, "now setting %s input %s output\n", (input >= SAA7115_SVIDEO0) ? "S-Video" : "Composite", (output == SAA7115_IPORT_ON) ? "iport on" : "iport off"); state->input = input; /* saa7111 has slightly different input numbering */ if (state->ident <= SAA7111A) { if (input >= SAA7115_COMPOSITE4) input -= 2; /* saa7111 specific */ saa711x_write(sd, R_10_CHROMA_CNTL_2, (saa711x_read(sd, R_10_CHROMA_CNTL_2) & 0x3f) | ((output & 0xc0) ^ 0x40)); saa711x_write(sd, <API key>, (saa711x_read(sd, <API key>) & 0xf0) | ((output & 2) ? 0x0a : 0)); } /* select mode */ saa711x_write(sd, R_02_INPUT_CNTL_1, (saa711x_read(sd, R_02_INPUT_CNTL_1) & mask) | input); /* bypass chrominance trap for S-Video modes */ saa711x_write(sd, R_09_LUMA_CNTL, (saa711x_read(sd, R_09_LUMA_CNTL) & 0x7f) | (state->input >= SAA7115_SVIDEO0 ? 0x80 : 0x0)); state->output = output; if (state->ident == SAA7114 || state->ident == SAA7115) { saa711x_write(sd, <API key>, (saa711x_read(sd, <API key>) & 0xfe) | (state->output & 0x01)); } if (state->ident > SAA7111A) { if (config & <API key>) saa711x_write(sd, <API key>, 0x20); else saa711x_write(sd, <API key>, 0x21); } return 0; } static int saa711x_s_gpio(struct v4l2_subdev *sd, u32 val) { struct saa711x_state *state = to_state(sd); if (state->ident > SAA7111A) return -EINVAL; saa711x_write(sd, 0x11, (saa711x_read(sd, 0x11) & 0x7f) | (val ? 0x80 : 0)); return 0; } static int saa711x_s_stream(struct v4l2_subdev *sd, int enable) { struct saa711x_state *state = to_state(sd); v4l2_dbg(1, debug, sd, "%s output\n", enable ? "enable" : "disable"); if (state->enable == enable) return 0; state->enable = enable; if (!saa711x_has_reg(state->ident, <API key>)) return 0; saa711x_write(sd, <API key>, state->enable); return 0; } static int <API key>(struct v4l2_subdev *sd, u32 freq, u32 flags) { struct saa711x_state *state = to_state(sd); if (freq != <API key> && freq != <API key>) return -EINVAL; state->crystal_freq = freq; state->double_asclk = flags & <API key>; state->cgcdiv = (flags & <API key>) ? 3 : 4; state->ucgc = flags & <API key>; state->apll = flags & <API key>; <API key>(sd, state->audclk_freq); return 0; } static int saa711x_reset(struct v4l2_subdev *sd, u32 val) { v4l2_dbg(1, debug, sd, "decoder RESET\n"); saa711x_writeregs(sd, <API key>); return 0; } static int saa711x_g_vbi_data(struct v4l2_subdev *sd, struct <API key> *data) { /* Note: the internal field ID is inverted for NTSC, so data->field 0 maps to the saa7115 even field, whereas for PAL it maps to the saa7115 odd field. */ switch (data->id) { case V4L2_SLICED_WSS_625: if (saa711x_read(sd, 0x6b) & 0xc0) return -EIO; data->data[0] = saa711x_read(sd, 0x6c); data->data[1] = saa711x_read(sd, 0x6d); return 0; case <API key>: if (data->field == 0) { if (saa711x_read(sd, 0x66) & 0x30) return -EIO; data->data[0] = saa711x_read(sd, 0x69); data->data[1] = saa711x_read(sd, 0x6a); return 0; } /* XDS */ if (saa711x_read(sd, 0x66) & 0xc0) return -EIO; data->data[0] = saa711x_read(sd, 0x67); data->data[1] = saa711x_read(sd, 0x68); return 0; default: return -EINVAL; } } static int saa711x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std) { struct saa711x_state *state = to_state(sd); int reg1f, reg1e; /* * The V4L2 core already initializes std with all supported * Standards. All driver needs to do is to mask it, to remove * standards that don't apply from the mask */ reg1f = saa711x_read(sd, <API key>); if (state->ident == SAA7115) { reg1e = saa711x_read(sd, <API key>); v4l2_dbg(1, debug, sd, "Status byte 1 (0x1e)=0x%02x\n", reg1e); switch (reg1e & 0x03) { case 1: *std &= V4L2_STD_NTSC; break; case 2: /* * V4L2_STD_PAL just cover the european PAL standards. * This is wrong, as the device could also be using an * other PAL standard. */ *std &= V4L2_STD_PAL | V4L2_STD_PAL_N | V4L2_STD_PAL_Nc | V4L2_STD_PAL_M | V4L2_STD_PAL_60; break; case 3: *std &= V4L2_STD_SECAM; break; default: *std = V4L2_STD_UNKNOWN; /* Can't detect anything */ break; } } v4l2_dbg(1, debug, sd, "Status byte 2 (0x1f)=0x%02x\n", reg1f); /* horizontal/vertical not locked */ if (reg1f & 0x40) { *std = V4L2_STD_UNKNOWN; goto ret; } if (reg1f & 0x20) *std &= V4L2_STD_525_60; else *std &= V4L2_STD_625_50; ret: v4l2_dbg(1, debug, sd, "detected std mask = %08Lx\n", *std); return 0; } static int <API key>(struct v4l2_subdev *sd, u32 *status) { struct saa711x_state *state = to_state(sd); int reg1e = 0x80; int reg1f; *status = <API key>; if (state->ident == SAA7115) reg1e = saa711x_read(sd, <API key>); reg1f = saa711x_read(sd, <API key>); if ((reg1f & 0xc1) == 0x81 && (reg1e & 0xc0) == 0x80) *status = 0; return 0; } #ifdef <API key> static int saa711x_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) { reg->val = saa711x_read(sd, reg->reg & 0xff); reg->size = 1; return 0; } static int saa711x_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg) { saa711x_write(sd, reg->reg & 0xff, reg->val & 0xff); return 0; } #endif static int saa711x_log_status(struct v4l2_subdev *sd) { struct saa711x_state *state = to_state(sd); int reg1e, reg1f; int signalOk; int vcr; v4l2_info(sd, "Audio frequency: %d Hz\n", state->audclk_freq); if (state->ident != SAA7115) { /* status for the saa7114 */ reg1f = saa711x_read(sd, <API key>); signalOk = (reg1f & 0xc1) == 0x81; v4l2_info(sd, "Video signal: %s\n", signalOk ? "ok" : "bad"); v4l2_info(sd, "Frequency: %s\n", (reg1f & 0x20) ? "60 Hz" : "50 Hz"); return 0; } /* status for the saa7115 */ reg1e = saa711x_read(sd, <API key>); reg1f = saa711x_read(sd, <API key>); signalOk = (reg1f & 0xc1) == 0x81 && (reg1e & 0xc0) == 0x80; vcr = !(reg1f & 0x10); if (state->input >= 6) v4l2_info(sd, "Input: S-Video %d\n", state->input - 6); else v4l2_info(sd, "Input: Composite %d\n", state->input); v4l2_info(sd, "Video signal: %s\n", signalOk ? (vcr ? "VCR" : "broadcast/DVD") : "bad"); v4l2_info(sd, "Frequency: %s\n", (reg1f & 0x20) ? "60 Hz" : "50 Hz"); switch (reg1e & 0x03) { case 1: v4l2_info(sd, "Detected format: NTSC\n"); break; case 2: v4l2_info(sd, "Detected format: PAL\n"); break; case 3: v4l2_info(sd, "Detected format: SECAM\n"); break; default: v4l2_info(sd, "Detected format: BW/No color\n"); break; } v4l2_info(sd, "Width, Height: %d, %d\n", state->width, state->height); <API key>(&state->hdl, sd->name); return 0; } static const struct v4l2_ctrl_ops saa711x_ctrl_ops = { .s_ctrl = saa711x_s_ctrl, .g_volatile_ctrl = <API key>, }; static const struct <API key> saa711x_core_ops = { .log_status = saa711x_log_status, .reset = saa711x_reset, .s_gpio = saa711x_s_gpio, #ifdef <API key> .g_register = saa711x_g_register, .s_register = saa711x_s_register, #endif }; static const struct <API key> saa711x_tuner_ops = { .s_radio = saa711x_s_radio, .g_tuner = saa711x_g_tuner, }; static const struct <API key> saa711x_audio_ops = { .s_clock_freq = <API key>, }; static const struct <API key> saa711x_video_ops = { .s_std = saa711x_s_std, .s_routing = saa711x_s_routing, .s_crystal_freq = <API key>, .s_stream = saa711x_s_stream, .querystd = saa711x_querystd, .g_input_status = <API key>, }; static const struct v4l2_subdev_vbi_ops saa711x_vbi_ops = { .g_vbi_data = saa711x_g_vbi_data, .decode_vbi_line = <API key>, .g_sliced_fmt = <API key>, .s_sliced_fmt = <API key>, .s_raw_fmt = saa711x_s_raw_fmt, }; static const struct v4l2_subdev_pad_ops saa711x_pad_ops = { .set_fmt = saa711x_set_fmt, }; static const struct v4l2_subdev_ops saa711x_ops = { .core = &saa711x_core_ops, .tuner = &saa711x_tuner_ops, .audio = &saa711x_audio_ops, .video = &saa711x_video_ops, .vbi = &saa711x_vbi_ops, .pad = &saa711x_pad_ops, }; #define CHIP_VER_SIZE 16 static void <API key>(struct saa711x_state *state, struct <API key> *data) { struct v4l2_subdev *sd = &state->sd; u8 work; if (state->ident != GM7113C && state->ident != SAA7113) return; if (data->saa7113_r08_htc) { work = saa711x_read(sd, R_08_SYNC_CNTL); work &= ~<API key>; work |= ((*data->saa7113_r08_htc) << <API key>); saa711x_write(sd, R_08_SYNC_CNTL, work); } if (data->saa7113_r10_vrln) { work = saa711x_read(sd, R_10_CHROMA_CNTL_2); work &= ~<API key>; if (*data->saa7113_r10_vrln) work |= (1 << <API key>); saa711x_write(sd, R_10_CHROMA_CNTL_2, work); } if (data->saa7113_r10_ofts) { work = saa711x_read(sd, R_10_CHROMA_CNTL_2); work &= ~<API key>; work |= (*data->saa7113_r10_ofts << <API key>); saa711x_write(sd, R_10_CHROMA_CNTL_2, work); } if (data->saa7113_r12_rts0) { work = saa711x_read(sd, R_12_RT_SIGNAL_CNTL); work &= ~<API key>; work |= (*data->saa7113_r12_rts0 << <API key>); /* According to the datasheet, * SAA7113_RTS_DOT_IN should only be used on RTS1 */ WARN_ON(*data->saa7113_r12_rts0 == SAA7113_RTS_DOT_IN); saa711x_write(sd, R_12_RT_SIGNAL_CNTL, work); } if (data->saa7113_r12_rts1) { work = saa711x_read(sd, R_12_RT_SIGNAL_CNTL); work &= ~<API key>; work |= (*data->saa7113_r12_rts1 << <API key>); saa711x_write(sd, R_12_RT_SIGNAL_CNTL, work); } if (data->saa7113_r13_adlsb) { work = saa711x_read(sd, <API key>); work &= ~<API key>; if (*data->saa7113_r13_adlsb) work |= (1 << <API key>); saa711x_write(sd, <API key>, work); } } /** * saa711x_detect_chip - Detects the saa711x (or clone) variant * @client: I2C client structure. * @id: I2C device ID structure. * @name: Name of the device to be filled. * * Detects the Philips/NXP saa711x chip, or some clone of it. * if 'id' is NULL or id->driver_data is equal to 1, it auto-probes * the analog demod. * If the tuner is not found, it returns -ENODEV. * If auto-detection is disabled and the tuner doesn't match what it was * required, it returns -EINVAL and fills 'name'. * If the chip is found, it returns the chip ID and fills 'name'. */ static int saa711x_detect_chip(struct i2c_client *client, const struct i2c_device_id *id, char *name) { char chip_ver[CHIP_VER_SIZE]; char chip_id; int i; int autodetect; autodetect = !id || id->driver_data == 1; /* Read the chip version register */ for (i = 0; i < CHIP_VER_SIZE; i++) { <API key>(client, 0, i); chip_ver[i] = <API key>(client, 0); name[i] = (chip_ver[i] & 0x0f) + '0'; if (name[i] > '9') name[i] += 'a' - '9' - 1; } name[i] = '\0'; /* Check if it is a Philips/NXP chip */ if (!memcmp(name + 1, "f711", 4)) { chip_id = name[5]; snprintf(name, CHIP_VER_SIZE, "saa711%c", chip_id); if (!autodetect && strcmp(name, id->name)) return -EINVAL; switch (chip_id) { case '1': if (chip_ver[0] & 0xf0) { snprintf(name, CHIP_VER_SIZE, "saa711%ca", chip_id); v4l_info(client, "saa7111a variant found\n"); return SAA7111A; } return SAA7111; case '3': return SAA7113; case '4': return SAA7114; case '5': return SAA7115; case '8': return SAA7118; default: v4l2_info(client, "WARNING: Philips/NXP chip unknown - Falling back to saa7111\n"); return SAA7111; } } /* Check if it is a gm7113c */ if (!memcmp(name, "0000", 4)) { chip_id = 0; for (i = 0; i < 4; i++) { chip_id = chip_id << 1; chip_id |= (chip_ver[i] & 0x80) ? 1 : 0; } /* * Note: From the datasheet, only versions 1 and 2 * exists. However, tests on a device labeled as: * "GM7113C 1145" returned "10" on all 16 chip * version (reg 0x00) reads. So, we need to also * accept at least verion 0. For now, let's just * assume that a device that returns "0000" for * the lower nibble is a gm7113c. */ strlcpy(name, "gm7113c", CHIP_VER_SIZE); if (!autodetect && strcmp(name, id->name)) return -EINVAL; v4l_dbg(1, debug, client, "It seems to be a %s chip (%*ph) @ 0x%x.\n", name, 16, chip_ver, client->addr << 1); return GM7113C; } /* Check if it is a CJC7113 */ if (!memcmp(name, "1111111111111111", CHIP_VER_SIZE)) { strlcpy(name, "cjc7113", CHIP_VER_SIZE); if (!autodetect && strcmp(name, id->name)) return -EINVAL; v4l_dbg(1, debug, client, "It seems to be a %s chip (%*ph) @ 0x%x.\n", name, 16, chip_ver, client->addr << 1); /* CJC7113 seems to be SAA7113-compatible */ return SAA7113; } /* Chip was not discovered. Return its ID and don't bind */ v4l_dbg(1, debug, client, "chip %*ph @ 0x%x is unknown.\n", 16, chip_ver, client->addr << 1); return -ENODEV; } static int saa711x_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct saa711x_state *state; struct v4l2_subdev *sd; struct v4l2_ctrl_handler *hdl; struct <API key> *pdata; int ident; char name[CHIP_VER_SIZE + 1]; #if defined(<API key>) int ret; #endif /* Check if the adapter supports the needed features */ if (!<API key>(client->adapter, <API key>)) return -EIO; ident = saa711x_detect_chip(client, id, name); if (ident == -EINVAL) { /* Chip exists, but doesn't match */ v4l_warn(client, "found %s while %s was expected\n", name, id->name); return -ENODEV; } if (ident < 0) return ident; strlcpy(client->name, name, sizeof(client->name)); state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); if (state == NULL) return -ENOMEM; sd = &state->sd; <API key>(sd, client, &saa711x_ops); #if defined(<API key>) state->pads[DEMOD_PAD_IF_INPUT].flags = MEDIA_PAD_FL_SINK; state->pads[DEMOD_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE; state->pads[DEMOD_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE; sd->entity.function = <API key>; ret = <API key>(&sd->entity, DEMOD_NUM_PADS, state->pads); if (ret < 0) return ret; #endif v4l_info(client, "%s found @ 0x%x (%s)\n", name, client->addr << 1, client->adapter->name); hdl = &state->hdl; <API key>(hdl, 6); /* add in ascending ID order */ v4l2_ctrl_new_std(hdl, &saa711x_ctrl_ops, V4L2_CID_BRIGHTNESS, 0, 255, 1, 128); v4l2_ctrl_new_std(hdl, &saa711x_ctrl_ops, V4L2_CID_CONTRAST, 0, 127, 1, 64); v4l2_ctrl_new_std(hdl, &saa711x_ctrl_ops, V4L2_CID_SATURATION, 0, 127, 1, 64); v4l2_ctrl_new_std(hdl, &saa711x_ctrl_ops, V4L2_CID_HUE, -128, 127, 1, 0); state->agc = v4l2_ctrl_new_std(hdl, &saa711x_ctrl_ops, V4L2_CID_CHROMA_AGC, 0, 1, 1, 1); state->gain = v4l2_ctrl_new_std(hdl, &saa711x_ctrl_ops, <API key>, 0, 127, 1, 40); sd->ctrl_handler = hdl; if (hdl->error) { int err = hdl->error; <API key>(hdl); return err; } <API key>(2, &state->agc, 0, true); state->input = -1; state->output = SAA7115_IPORT_ON; state->enable = 1; state->radio = 0; state->ident = ident; state->audclk_freq = 48000; v4l2_dbg(1, debug, sd, "writing init values\n"); /* init to 60hz/48khz */ state->crystal_freq = <API key>; pdata = client->dev.platform_data; switch (state->ident) { case SAA7111: case SAA7111A: saa711x_writeregs(sd, saa7111_init); break; case GM7113C: saa711x_writeregs(sd, gm7113c_init); break; case SAA7113: if (pdata && pdata-><API key>) saa711x_writeregs(sd, gm7113c_init); else saa711x_writeregs(sd, saa7113_init); break; default: state->crystal_freq = <API key>; saa711x_writeregs(sd, <API key>); } if (state->ident > SAA7111A && state->ident != GM7113C) saa711x_writeregs(sd, saa7115_init_misc); if (pdata) <API key>(state, pdata); saa711x_set_v4lstd(sd, V4L2_STD_NTSC); <API key>(hdl); v4l2_dbg(1, debug, sd, "status: (1E) 0x%02x, (1F) 0x%02x\n", saa711x_read(sd, <API key>), saa711x_read(sd, <API key>)); return 0; } static int saa711x_remove(struct i2c_client *client) { struct v4l2_subdev *sd = i2c_get_clientdata(client); <API key>(sd); <API key>(sd->ctrl_handler); return 0; } static const struct i2c_device_id saa711x_id[] = { { "saa7115_auto", 1 }, /* autodetect */ { "saa7111", 0 }, { "saa7113", 0 }, { "saa7114", 0 }, { "saa7115", 0 }, { "saa7118", 0 }, { "gm7113c", 0 }, { } }; MODULE_DEVICE_TABLE(i2c, saa711x_id); static struct i2c_driver saa711x_driver = { .driver = { .name = "saa7115", }, .probe = saa711x_probe, .remove = saa711x_remove, .id_table = saa711x_id, }; module_i2c_driver(saa711x_driver);
-- Label Templates set NAMES 'utf8'; LOCK TABLES `labels_templates` WRITE; INSERT INTO `labels_templates` VALUES (1,0,'Avery 5160 | 1 x 2-5/8', '3 colonnes, 10 lignes d''étiquette', 8.5, 11, 2.63, 1, 0.139, 0, 0.35, 0.23, 3, 10, 0.13, 0, 'INCH'), (2,0,'Gaylord 8511 Spine Label','Imprime uniquement dans la colnne de gauche d''une planche Gaylord 8511.', 8.5, 11, 1, 1.25, 0.6, 0.5, 0, 0, 1, 8, 0, 0, 'INCH'), (3,0,'Avery 5460 vertical', '', 3.625, 5.625, 1.5, 0.75, 0.38, 0.35, 2, 7, 2, 1, 0.25, 0, 'INCH'), (4,0,'Avery 5460 spine labels', '', 5.625, 3.625, 0.75, 1.5, 0.35, 0.31, 7, 2, 1, 0, 0.25, 0, 'INCH'), (5,0,'Avery 8163', '2colonnes x 5 colonnes', 8.5, 11, 4, 2, 0, 0, 0.5, 0.17, 2, 5, 0.2, 0.01, 'INCH'), (6,0,'cards', 'Avery 5160 | 1 x 2-5/8 : 1 x 2-5/8\" [3x10] : equivalent: Gaylord JD-ML3000', 8.5, 11, 2.75, 1.05, 0, 0, 0.25, 0, 3, 10, 0.2, 0.01, 'INCH'), (7,0,'Demco WS14942260', '1\" X 1.5\" Etiquettes de cotes', 8.5, 11, 1.5, 1, 0.236, 0, 0.4, 0.25, 5, 10, 0.0625, 0, 'INCH'); UNLOCK TABLES; LOCK TABLES `labels_layouts` WRITE; /*!40000 ALTER TABLE `labels_layouts` DISABLE KEYS */; INSERT INTO `labels_layouts` VALUES (1,'CODE39','BIBBAR','biblio and barcode',0,'TR',7,0,'L','title, author, itemcallnumber'), (2,'CODE39','BIB','spine',0,'TR',3,1,'L','itemcallnumber'), (3,'CODE39','BARBIB','barcode and biblio',0,'TR',3,1,'L','title, author, itemcallnumber'); /*!40000 ALTER TABLE `labels_layouts` ENABLE KEYS */; UNLOCK TABLES;
<script type="text/javascript"> function confirm_reset() { var answer = confirm("<?php _e('All of options will return to default settings. Are you sure you want to reset all settings?'); ?>"); if(answer) return true; else return false; } jQuery(document).ready(function($){ $("#<API key>").click(function(e){ e.preventDefault(); state = $(this).attr("state"); if(state == "visible"){ $(".wpm_advanced").slideUp(); $("#wpm_options_reset").fadeOut(); $(this).attr("state", "hidden"); $(this).attr("value", "<?php echo __('Show Advanced Options', $this->name); ?>" + " " + String.fromCharCode(187)); $.ajax({ type : "POST", url : "admin-ajax.php", data : { action : "wpm", _ajax_nonce: "<?php echo wp_create_nonce($this->name); ?>", wpm_action : "hide_advanced" }, success : function(resp){ // do nothing visually }, error : function(resp){ alert("Error:" + resp); } }); } else{ $(".wpm_advanced").slideDown(); $("#wpm_options_reset").fadeIn(); $(this).attr("state", "visible"); $(this).attr("value", "<?php echo __('Hide Advanced Options', $this->name); ?>" + " " + String.fromCharCode(187)); $.ajax({ type : "POST", url : "admin-ajax.php", data : { action : "wpm", _ajax_nonce: "<?php echo wp_create_nonce($this->name); ?>", wpm_action : "show_advanced" }, success : function(resp){ // do nothing visually }, error : function(resp){ alert("Error:" + resp); } }); } }); $('#<API key>').click(function(e) { state = $(this).attr("state"); if (state == "on") { $(".wpm_include").slideDown(); $(this).attr("state", "off"); } else { $(".wpm_include").slideUp(); $(this).attr("state", "on"); } }); }); </script> <form method="post"><fieldset> <?php // take care of advanced options if ($wpm_options['show_advanced']) { $advanced_style = ''; $<API key> = __('Hide Advanced Options', $this->name); $<API key> = 'visible'; } else { $advanced_style = 'style="display:none"'; $<API key> = __('Show Advanced Options', $this->name); $<API key> = 'hidden'; } if ($wpm_options['cache_external']) { $include_style = 'style="display:none"'; $<API key> = 'on'; } else { $include_style = ''; $<API key> = 'off'; } printf(' <h2>%s</h2> <p><label>%s &nbsp; <input name="wpm_options_update[show_link]" value="on" type="radio" '.checked(true, $wpm_options['show_link'], false).'/></label></p> <p><label>%s (<a href="http://omninoggin.com/donate">%s</a>) &nbsp; <input name="wpm_options_update[show_link]" value="off" type="radio" '.checked(false, $wpm_options['show_link'], false).'/></label></p> ', __('Support this plugin!', $this->name), __('Display "Page optimized by WP Minify" link in the footer', $this->name), __('Do not display "Page optimized by WP Minify" link.', $this->name), __('Donations are appreciated!', $this->name) ); printf(' <h2>%s</h2> <p><label>%s &nbsp; <input name="wpm_options_update[enable_js]" type="checkbox" '.checked(true, $wpm_options['enable_js'], false).'/></label></p> <p><label>%s &nbsp; <input name="wpm_options_update[enable_css]" type="checkbox" '.checked(true, $wpm_options['enable_css'], false).'/></label></p> <p><label>%s &nbsp; <input name="wpm_options_update[enable_html]" type="checkbox" '.checked(true, $wpm_options['enable_html'], false).'/></label></p> ', __('General Configuration', $this->name), __('Enable JavaScript Minification', $this->name), __('Enable CSS Minification', $this->name), __('Enable HTML Minification', $this->name) ); printf(' <h2 class="wpm_advanced" '.$advanced_style.'>%s</h2> <p class="wpm_advanced" '.$advanced_style.'><label>%s &nbsp; <input name="wpm_options_update[debug_nominify]" type="checkbox" '.checked(true, $wpm_options['debug_nominify'], false).'/></label></p> <p class="wpm_advanced" '.$advanced_style.'><label><a href="http://omninoggin.com/wordpress-posts/<API key>/">%s</a> &nbsp; <input name="wpm_options_update[debug_firephp]" type="checkbox" '.checked(true, $wpm_options['debug_firephp'], false).'/></label></p> ', __('Debugging', $this->name), __('Combine files but do not minify', $this->name), __('Show minify errors through FirePHP', $this->name) ); printf(' <h2 class="wpm_advanced" '.$advanced_style.'>%s</h2> <p><label>%s<br/><textarea name="wpm_options_update[js_exclude]" style="width:600px" rows="5">'.attribute_escape(implode(chr(10), $wpm_options['js_exclude'])).'</textarea></label></p> <p><label>%s<br/><textarea name="wpm_options_update[css_exclude]" style="width:600px" rows="5">'.attribute_escape(implode(chr(10), $wpm_options['css_exclude'])).'</textarea></label></p> <p class="wpm_advanced" '.$advanced_style.'><label>%s<br/><textarea name="wpm_options_update[uri_exclude]" style="width:600px" rows="5">'.attribute_escape(implode(chr(10), $wpm_options['uri_exclude'])).'</textarea></label></p> ', __('Local Files Minification', $this->name), __('JavaScript files to exclude from minify (line delimited).', $this->name), __('CSS files to exclude from minify (line delimited).', $this->name), __('URIs on which WP-Minify parsing will be disabled (line delimited)', $this->name) ); printf(' <h2 class="wpm_advanced" '.$advanced_style.'>%s</h2> <p class="wpm_advanced" '.$advanced_style.'><label>%s &nbsp; <input name="wpm_options_update[cache_external]" id="<API key>" state="'.$<API key>.'" type="checkbox" '.checked(true, $wpm_options['cache_external'], false).'/> &nbsp; (%s)</label></p> <p class="wpm_advanced wpm_include" '.$advanced_style.' '.$include_style.'><label>%s (%s, <a href="http://omninoggin.com/wordpress-posts/<API key>/#<API key>">%s</a>)<br/><textarea name="wpm_options_update[js_include]" style="width:600px" rows="5">'.attribute_escape(implode(chr(10), $wpm_options['js_include'])).'</textarea></label></p> <p class="wpm_advanced wpm_include" '.$advanced_style.' '.$include_style.'><label>%s (%s, <a href="http://omninoggin.com/wordpress-posts/<API key>/#<API key>">%s</a>)<br/><textarea name="wpm_options_update[css_include]" style="width:600px" rows="5">'.attribute_escape(implode(chr(10), $wpm_options['css_include'])).'</textarea></label></p> ', __('Non-Local Files Minification', $this->name), __('Enable minification on external files', $this->name), __('Not recommended unless you want to exclude a bunch of external .js/.css files', $this->name), __('External JavaScript files to include into minify.', $this->name), __('Only useful if "Minification on external files" is unchecked', $this->name), __('more info', $this->name), __('External CSS files to include into minify.', $this->name), __('Only useful if "Minification on external files" is unchecked', $this->name), __('more info', $this->name) ); printf(' <h2 class="wpm_advanced" '.$advanced_style.'>%s</h2> <p class="wpm_advanced" '.$advanced_style.'><label>%s<input name="wpm_options_ update[cache_interval]" type="text" size="4" value="'.attribute_escape($wpm_options['cache_interval']).'"/>%s <span class="submit"><input type="submit" name="<API key>" value="%s"/></span></p></label> ', __('Caching', $this->name), __('Cache expires after every', $this->name), __('seconds', $this->name), __('Manually Clear Cache', $this->name) ); printf(' <h2 class="wpm_advanced" '.$advanced_style.'>%s</h2> <p class="wpm_advanced" '.$advanced_style.'><label>%s &nbsp; <input name="wpm_options_update[pretty_url]" type="checkbox" '.checked(true, $wpm_options['pretty_url'], false).'/> &nbsp; (%s)</label></p> <p class="wpm_advanced" '.$advanced_style.'><label>%s &nbsp; <input name="wpm_options_update[js_in_footer]" type="checkbox" '.checked(true, $wpm_options['js_in_footer'], false).'/> &nbsp; (%s, <a href="http://omninoggin.com/wordpress-posts/<API key>/#manual_placement">%s</a>)</label></p> ', __('Tweaking/Tuning', $this->name), __('Use "pretty" URL"', $this->name), __('i.e. use "wp-minify/cache/1234abcd.js" instead of "wp-minify/min/?f=file1.js,file2.js,...,fileN.js"', $this->name), __('Place Minified JavaScript in footer', $this->name), __('Not recommended', $this->name), __('more info', $this->name) ); printf(' <p class="wpm_advanced" '.$advanced_style.'><label>%s &nbsp; <input name="wpm_options_update[force_https]" type="checkbox" '.checked(true, $wpm_options['force_https'], false).'/></label></p> ', __('Force all JavaScript/CSS calls to be HTTPS on HTTPS pages', $this->name) ); printf(' <p class="wpm_advanced" '.$advanced_style.'><label>%s &nbsp; <input name="wpm_options_update[auto_base]" type="checkbox" '.checked(true, $wpm_options['auto_base'], false).'/></label></p> <p class="wpm_advanced" '.$advanced_style.'><label>%s<br/><input name="wpm_options_update[<API key>]" type="text" size="100" value="'.attribute_escape($wpm_options['<API key>']).'"/><br/><em>%s</em></label></p> ', __('Automatically set your Minify base per siteurl setting (recommended)', $this->name), __('Extra arguments to pass to minify engine. This value will get append to calls to URL "wp-minify/min/?f=file1.js,file2.js,...,fileN.js".', $this->name), __('e.g. You can specify this value to be b=somepath to specify the base path for all files passed into Minify.', $this->name) ); if ( function_exists( 'wp_nonce_field' ) && wp_nonce_field( $this->name ) ) { printf(' <p class="submit"> <input type="submit" name="<API key>" value="%s &#187;" /> <input type="submit" name="<API key>" id="wpm_options_reset" value="%s &#187;" onclick="return confirm_reset()" '.$advanced_style.'/> <input type="button" id="<API key>" state="'.$<API key>.'" value="'.$<API key>.' &#187;"/> </p> ', __('Update Options', $this->name), __('Reset ALL Options', $this->name) ); } ?> </fieldset></form>
# Py2.7+ only import sys def test_set_literal(): """ type(test_set_literal()) is set True sorted(test_set_literal()) ['a', 'b', 1] """ s1 = {1, 'a', 1, 'b', 'a'} return s1 def test_set_add(): """ type(test_set_add()) is set True sorted(test_set_add()) ['a', 1, (1, 2)] """ s1 = {1, (1, 2)} s1.add(1) s1.add('a') s1.add(1) s1.add((1, 2)) return s1 def test_set_comp(): """ type(test_set_comp()) is set True sorted(test_set_comp()) [0, 1, 2] """ s1 = {i % 3 for i in range(5)} return s1 def <API key>(): """ type(<API key>()) is frozenset True sorted(<API key>()) [0, 1, 2] """ s1 = frozenset({i % 3 for i in range(5)}) return s1 def <API key>(): """ <API key>() [2, 4, 5] """ L = [] def sideeffect(x): L.append(x) return x def unhashable_value(x): L.append(x) return set() try: s = {1, sideeffect(2), 3, unhashable_value(4), sideeffect(5)} except TypeError: pass else: assert False, "expected exception not raised" return L def <API key>(): """ <API key>() (None, [2, 4]) """ L = [] def value(x): return x def sideeffect(x): L.append(x) return x def unhashable_value(x): L.append(x) return set() s = None try: s = {f(i) for i, f in enumerate([value, sideeffect, value, unhashable_value, sideeffect], 1)} except TypeError: pass else: assert False, "expected exception not raised" return s, L def sorted(it): # Py3 can't compare different types chars = [] nums = [] tuples = [] for item in it: if type(item) is int: nums.append(item) elif type(item) is tuple: tuples.append(item) else: chars.append(item) nums.sort() chars.sort() tuples.sort() return chars+nums+tuples
#include <linux/init.h> #include <linux/kernel.h> #include <linux/io.h> #include <linux/pm_runtime.h> #include <linux/pm_domain.h> #include <linux/slab.h> #include <linux/err.h> #include <linux/sched.h> #include <linux/suspend.h> static LIST_HEAD(gpd_list); static DEFINE_MUTEX(gpd_list_lock); #ifdef CONFIG_PM static struct generic_pm_domain *dev_to_genpd(struct device *dev) { if (IS_ERR_OR_NULL(dev->pm_domain)) return ERR_PTR(-EINVAL); return pd_to_genpd(dev->pm_domain); } static bool <API key>(struct generic_pm_domain *genpd) { bool ret = false; if (!WARN_ON(atomic_read(&genpd->sd_count) == 0)) ret = !!atomic_dec_and_test(&genpd->sd_count); return ret; } static void <API key>(struct generic_pm_domain *genpd) { atomic_inc(&genpd->sd_count); <API key>(); } static void genpd_acquire_lock(struct generic_pm_domain *genpd) { DEFINE_WAIT(wait); mutex_lock(&genpd->lock); /* * Wait for the domain to transition into either the active, * or the power off state. */ for (;;) { prepare_to_wait(&genpd->status_wait_queue, &wait, <API key>); if (genpd->status == GPD_STATE_ACTIVE || genpd->status == GPD_STATE_POWER_OFF) break; mutex_unlock(&genpd->lock); schedule(); mutex_lock(&genpd->lock); } finish_wait(&genpd->status_wait_queue, &wait); } static void genpd_release_lock(struct generic_pm_domain *genpd) { mutex_unlock(&genpd->lock); } static void genpd_set_active(struct generic_pm_domain *genpd) { if (genpd->resume_count == 0) genpd->status = GPD_STATE_ACTIVE; } /** * __pm_genpd_poweron - Restore power to a given PM domain and its masters. * @genpd: PM domain to power up. * * Restore power to @genpd and all of its masters so that it is possible to * resume a device belonging to it. */ int __pm_genpd_poweron(struct generic_pm_domain *genpd) __releases(&genpd->lock) __acquires(&genpd->lock) { struct gpd_link *link; DEFINE_WAIT(wait); int ret = 0; /* If the domain's master is being waited for, we have to wait too. */ for (;;) { prepare_to_wait(&genpd->status_wait_queue, &wait, <API key>); if (genpd->status != <API key>) break; mutex_unlock(&genpd->lock); schedule(); mutex_lock(&genpd->lock); } finish_wait(&genpd->status_wait_queue, &wait); if (genpd->status == GPD_STATE_ACTIVE || (genpd->prepared_count > 0 && genpd->suspend_power_off)) return 0; if (genpd->status != GPD_STATE_POWER_OFF) { genpd_set_active(genpd); return 0; } /* * The list is guaranteed not to change while the loop below is being * executed, unless one of the masters' .power_on() callbacks fiddles * with it. */ list_for_each_entry(link, &genpd->slave_links, slave_node) { <API key>(link->master); genpd->status = <API key>; mutex_unlock(&genpd->lock); ret = pm_genpd_poweron(link->master); mutex_lock(&genpd->lock); /* * The "wait for parent" status is guaranteed not to change * while the master is powering on. */ genpd->status = GPD_STATE_POWER_OFF; wake_up_all(&genpd->status_wait_queue); if (ret) { <API key>(link->master); goto err; } } if (genpd->power_on) { ret = genpd->power_on(genpd); if (ret) goto err; } genpd_set_active(genpd); return 0; err: <API key>(link, &genpd->slave_links, slave_node) <API key>(link->master); return ret; } /** * pm_genpd_poweron - Restore power to a given PM domain and its masters. * @genpd: PM domain to power up. */ int pm_genpd_poweron(struct generic_pm_domain *genpd) { int ret; mutex_lock(&genpd->lock); ret = __pm_genpd_poweron(genpd); mutex_unlock(&genpd->lock); return ret; } #endif /* CONFIG_PM */ #ifdef CONFIG_PM_RUNTIME /** * <API key> - Save the pre-suspend state of a device. * @pdd: Domain data of the device to save the state of. * @genpd: PM domain the device belongs to. */ static int <API key>(struct pm_domain_data *pdd, struct generic_pm_domain *genpd) __releases(&genpd->lock) __acquires(&genpd->lock) { struct <API key> *gpd_data = to_gpd_data(pdd); struct device *dev = pdd->dev; struct device_driver *drv = dev->driver; int ret = 0; if (gpd_data->need_restore) return 0; mutex_unlock(&genpd->lock); if (drv && drv->pm && drv->pm->runtime_suspend) { if (genpd->start_device) genpd->start_device(dev); ret = drv->pm->runtime_suspend(dev); if (genpd->stop_device) genpd->stop_device(dev); } mutex_lock(&genpd->lock); if (!ret) gpd_data->need_restore = true; return ret; } /** * <API key> - Restore the pre-suspend state of a device. * @pdd: Domain data of the device to restore the state of. * @genpd: PM domain the device belongs to. */ static void <API key>(struct pm_domain_data *pdd, struct generic_pm_domain *genpd) __releases(&genpd->lock) __acquires(&genpd->lock) { struct <API key> *gpd_data = to_gpd_data(pdd); struct device *dev = pdd->dev; struct device_driver *drv = dev->driver; if (!gpd_data->need_restore) return; mutex_unlock(&genpd->lock); if (drv && drv->pm && drv->pm->runtime_resume) { if (genpd->start_device) genpd->start_device(dev); drv->pm->runtime_resume(dev); if (genpd->stop_device) genpd->stop_device(dev); } mutex_lock(&genpd->lock); gpd_data->need_restore = false; } /** * <API key> - Check if a PM domain power off should be aborted. * @genpd: PM domain to check. * * Return true if a PM domain's status changed to GPD_STATE_ACTIVE during * a "power off" operation, which means that a "power on" has occured in the * meantime, or if its resume_count field is different from zero, which means * that one of its devices has been resumed in the meantime. */ static bool <API key>(struct generic_pm_domain *genpd) { return genpd->status == <API key> || genpd->status == GPD_STATE_ACTIVE || genpd->resume_count > 0; } /** * <API key> - Queue up the execution of pm_genpd_poweroff(). * @genpd: PM domait to power off. * * Queue up the execution of pm_genpd_poweroff() unless it's already been done * before. */ void <API key>(struct generic_pm_domain *genpd) { if (!work_pending(&genpd->power_off_work)) queue_work(pm_wq, &genpd->power_off_work); } /** * pm_genpd_poweroff - Remove power from a given PM domain. * @genpd: PM domain to power down. * * If all of the @genpd's devices have been suspended and all of its subdomains * have been powered down, run the runtime suspend callbacks provided by all of * the @genpd's devices' drivers and remove power from @genpd. */ static int pm_genpd_poweroff(struct generic_pm_domain *genpd) __releases(&genpd->lock) __acquires(&genpd->lock) { struct pm_domain_data *pdd; struct gpd_link *link; unsigned int not_suspended; int ret = 0; start: /* * Do not try to power off the domain in the following situations: * (1) The domain is already in the "power off" state. * (2) The domain is waiting for its master to power up. * (3) One of the domain's devices is being resumed right now. * (4) System suspend is in progress. */ if (genpd->status == GPD_STATE_POWER_OFF || genpd->status == <API key> || genpd->resume_count > 0 || genpd->prepared_count > 0) return 0; if (atomic_read(&genpd->sd_count) > 0) return -EBUSY; not_suspended = 0; list_for_each_entry(pdd, &genpd->dev_list, list_node) if (pdd->dev->driver && (!<API key>(pdd->dev) || pdd->dev->power.irq_safe)) not_suspended++; if (not_suspended > genpd->in_progress) return -EBUSY; if (genpd->poweroff_task) { /* * Another instance of pm_genpd_poweroff() is executing * callbacks, so tell it to start over and return. */ genpd->status = GPD_STATE_REPEAT; return 0; } if (genpd->gov && genpd->gov->power_down_ok) { if (!genpd->gov->power_down_ok(&genpd->domain)) return -EAGAIN; } genpd->status = GPD_STATE_BUSY; genpd->poweroff_task = current; <API key>(pdd, &genpd->dev_list, list_node) { ret = atomic_read(&genpd->sd_count) == 0 ? <API key>(pdd, genpd) : -EBUSY; if (<API key>(genpd)) goto out; if (ret) { genpd_set_active(genpd); goto out; } if (genpd->status == GPD_STATE_REPEAT) { genpd->poweroff_task = NULL; goto start; } } if (genpd->power_off) { if (atomic_read(&genpd->sd_count) > 0) { ret = -EBUSY; goto out; } /* * If sd_count > 0 at this point, one of the subdomains hasn't * managed to call pm_genpd_poweron() for the master yet after * incrementing it. In that case pm_genpd_poweron() will wait * for us to drop the lock, so we can call .power_off() and let * the pm_genpd_poweron() restore power for us (this shouldn't * happen very often). */ ret = genpd->power_off(genpd); if (ret == -EBUSY) { genpd_set_active(genpd); goto out; } } genpd->status = GPD_STATE_POWER_OFF; list_for_each_entry(link, &genpd->slave_links, slave_node) { <API key>(link->master); <API key>(link->master); } out: genpd->poweroff_task = NULL; wake_up_all(&genpd->status_wait_queue); return ret; } /** * <API key> - Power off PM domain whose subdomain count is 0. * @work: Work structure used for scheduling the execution of this function. */ static void <API key>(struct work_struct *work) { struct generic_pm_domain *genpd; genpd = container_of(work, struct generic_pm_domain, power_off_work); genpd_acquire_lock(genpd); pm_genpd_poweroff(genpd); genpd_release_lock(genpd); } /** * <API key> - Suspend a device belonging to I/O PM domain. * @dev: Device to suspend. * * Carry out a runtime suspend of a device under the assumption that its * pm_domain field points to the domain member of an object of type * struct generic_pm_domain representing a PM domain consisting of I/O devices. */ static int <API key>(struct device *dev) { struct generic_pm_domain *genpd; dev_dbg(dev, "%s()\n", __func__); genpd = dev_to_genpd(dev); if (IS_ERR(genpd)) return -EINVAL; might_sleep_if(!genpd->dev_irq_safe); if (genpd->stop_device) { int ret = genpd->stop_device(dev); if (ret) return ret; } /* * If power.irq_safe is set, this routine will be run with interrupts * off, so it can't use mutexes. */ if (dev->power.irq_safe) return 0; mutex_lock(&genpd->lock); genpd->in_progress++; pm_genpd_poweroff(genpd); genpd->in_progress mutex_unlock(&genpd->lock); return 0; } /** * <API key> - Resume a device belonging to I/O PM domain. * @dev: Device to resume. * * Carry out a runtime resume of a device under the assumption that its * pm_domain field points to the domain member of an object of type * struct generic_pm_domain representing a PM domain consisting of I/O devices. */ static int <API key>(struct device *dev) { struct generic_pm_domain *genpd; DEFINE_WAIT(wait); int ret; dev_dbg(dev, "%s()\n", __func__); genpd = dev_to_genpd(dev); if (IS_ERR(genpd)) return -EINVAL; might_sleep_if(!genpd->dev_irq_safe); /* If power.irq_safe, the PM domain is never powered off. */ if (dev->power.irq_safe) goto out; mutex_lock(&genpd->lock); ret = __pm_genpd_poweron(genpd); if (ret) { mutex_unlock(&genpd->lock); return ret; } genpd->status = GPD_STATE_BUSY; genpd->resume_count++; for (;;) { prepare_to_wait(&genpd->status_wait_queue, &wait, <API key>); /* * If current is the powering off task, we have been called * reentrantly from one of the device callbacks, so we should * not wait. */ if (!genpd->poweroff_task || genpd->poweroff_task == current) break; mutex_unlock(&genpd->lock); schedule(); mutex_lock(&genpd->lock); } finish_wait(&genpd->status_wait_queue, &wait); <API key>(dev->power.subsys_data->domain_data, genpd); genpd->resume_count genpd_set_active(genpd); wake_up_all(&genpd->status_wait_queue); mutex_unlock(&genpd->lock); out: if (genpd->start_device) genpd->start_device(dev); return 0; } /** * <API key> - Power off all PM domains with no devices in use. */ void <API key>(void) { struct generic_pm_domain *genpd; mutex_lock(&gpd_list_lock); list_for_each_entry(genpd, &gpd_list, gpd_list_node) <API key>(genpd); mutex_unlock(&gpd_list_lock); } #else static inline void <API key>(struct work_struct *work) {} #define <API key> NULL #define <API key> NULL #endif /* CONFIG_PM_RUNTIME */ #ifdef CONFIG_PM_SLEEP /** * <API key> - Synchronously power off a PM domain and its masters. * @genpd: PM domain to power off, if possible. * * Check if the given PM domain can be powered off (during system suspend or * hibernation) and do that if so. Also, in that case propagate to its masters. * * This function is only called in "noirq" stages of system power transitions, * so it need not acquire locks (all of the "noirq" callbacks are executed * sequentially, so it is guaranteed that it will never run twice in parallel). */ static void <API key>(struct generic_pm_domain *genpd) { struct gpd_link *link; if (genpd->status == GPD_STATE_POWER_OFF) return; if (genpd->suspended_count != genpd->device_count || atomic_read(&genpd->sd_count) > 0) return; if (genpd->power_off) genpd->power_off(genpd); genpd->status = GPD_STATE_POWER_OFF; list_for_each_entry(link, &genpd->slave_links, slave_node) { <API key>(link->master); <API key>(link->master); } } /** * resume_needed - Check whether to resume a device before system suspend. * @dev: Device to check. * @genpd: PM domain the device belongs to. * * There are two cases in which a device that can wake up the system from sleep * states should be resumed by pm_genpd_prepare(): (1) if the device is enabled * to wake up the system and it has to remain active for this purpose while the * system is in the sleep state and (2) if the device is not enabled to wake up * the system from sleep states and it generally doesn't generate wakeup signals * by itself (those signals are generated on its behalf by other parts of the * system). In the latter case it may be necessary to reconfigure the device's * wakeup settings during system suspend, because it may have been set up to * signal remote wakeup from the system's working state as needed by runtime PM. * Return 'true' in either of the above cases. */ static bool resume_needed(struct device *dev, struct generic_pm_domain *genpd) { bool active_wakeup; if (!device_can_wakeup(dev)) return false; active_wakeup = genpd->active_wakeup && genpd->active_wakeup(dev); return device_may_wakeup(dev) ? active_wakeup : !active_wakeup; } /** * pm_genpd_prepare - Start power transition of a device in a PM domain. * @dev: Device to start the transition of. * * Start a power transition of a device (during a system-wide power transition) * under the assumption that its pm_domain field points to the domain member of * an object of type struct generic_pm_domain representing a PM domain * consisting of I/O devices. */ static int pm_genpd_prepare(struct device *dev) { struct generic_pm_domain *genpd; int ret; dev_dbg(dev, "%s()\n", __func__); genpd = dev_to_genpd(dev); if (IS_ERR(genpd)) return -EINVAL; /* * If a wakeup request is pending for the device, it should be woken up * at this point and a system wakeup event should be reported if it's * set up to wake up the system from sleep states. */ <API key>(dev); if (pm_runtime_barrier(dev) && device_may_wakeup(dev)) pm_wakeup_event(dev, 0); if (pm_wakeup_pending()) { pm_runtime_put_sync(dev); return -EBUSY; } if (resume_needed(dev, genpd)) pm_runtime_resume(dev); genpd_acquire_lock(genpd); if (genpd->prepared_count++ == 0) genpd->suspend_power_off = genpd->status == GPD_STATE_POWER_OFF; genpd_release_lock(genpd); if (genpd->suspend_power_off) { <API key>(dev); return 0; } /* * The PM domain must be in the GPD_STATE_ACTIVE state at this point, * so pm_genpd_poweron() will return immediately, but if the device * is suspended (e.g. it's been stopped by .stop_device()), we need * to make it operational. */ pm_runtime_resume(dev); <API key>(dev, false); ret = pm_generic_prepare(dev); if (ret) { mutex_lock(&genpd->lock); if (--genpd->prepared_count == 0) genpd->suspend_power_off = false; mutex_unlock(&genpd->lock); pm_runtime_enable(dev); } pm_runtime_put_sync(dev); return ret; } /** * pm_genpd_suspend - Suspend a device belonging to an I/O PM domain. * @dev: Device to suspend. * * Suspend a device under the assumption that its pm_domain field points to the * domain member of an object of type struct generic_pm_domain representing * a PM domain consisting of I/O devices. */ static int pm_genpd_suspend(struct device *dev) { struct generic_pm_domain *genpd; dev_dbg(dev, "%s()\n", __func__); genpd = dev_to_genpd(dev); if (IS_ERR(genpd)) return -EINVAL; return genpd->suspend_power_off ? 0 : pm_generic_suspend(dev); } /** * <API key> - Late suspend of a device from an I/O PM domain. * @dev: Device to suspend. * * Carry out a late suspend of a device under the assumption that its * pm_domain field points to the domain member of an object of type * struct generic_pm_domain representing a PM domain consisting of I/O devices. */ static int <API key>(struct device *dev) { struct generic_pm_domain *genpd; int ret; dev_dbg(dev, "%s()\n", __func__); genpd = dev_to_genpd(dev); if (IS_ERR(genpd)) return -EINVAL; if (genpd->suspend_power_off) return 0; ret = <API key>(dev); if (ret) return ret; if (dev->power.wakeup_path && genpd->active_wakeup && genpd->active_wakeup(dev)) return 0; if (genpd->stop_device) genpd->stop_device(dev); /* * Since all of the "noirq" callbacks are executed sequentially, it is * guaranteed that this function will never run twice in parallel for * the same PM domain, so it is not necessary to use locking here. */ genpd->suspended_count++; <API key>(genpd); return 0; } /** * <API key> - Early resume of a device from an I/O power domain. * @dev: Device to resume. * * Carry out an early resume of a device under the assumption that its * pm_domain field points to the domain member of an object of type * struct generic_pm_domain representing a power domain consisting of I/O * devices. */ static int <API key>(struct device *dev) { struct generic_pm_domain *genpd; dev_dbg(dev, "%s()\n", __func__); genpd = dev_to_genpd(dev); if (IS_ERR(genpd)) return -EINVAL; if (genpd->suspend_power_off || (dev->power.wakeup_path && <API key>(genpd, dev))) return 0; /* * Since all of the "noirq" callbacks are executed sequentially, it is * guaranteed that this function will never run twice in parallel for * the same PM domain, so it is not necessary to use locking here. */ pm_genpd_poweron(genpd); genpd->suspended_count if (genpd->start_device) genpd->start_device(dev); return <API key>(dev); } /** * pm_genpd_resume - Resume a device belonging to an I/O power domain. * @dev: Device to resume. * * Resume a device under the assumption that its pm_domain field points to the * domain member of an object of type struct generic_pm_domain representing * a power domain consisting of I/O devices. */ static int pm_genpd_resume(struct device *dev) { struct generic_pm_domain *genpd; dev_dbg(dev, "%s()\n", __func__); genpd = dev_to_genpd(dev); if (IS_ERR(genpd)) return -EINVAL; return genpd->suspend_power_off ? 0 : pm_generic_resume(dev); } /** * pm_genpd_freeze - Freeze a device belonging to an I/O power domain. * @dev: Device to freeze. * * Freeze a device under the assumption that its pm_domain field points to the * domain member of an object of type struct generic_pm_domain representing * a power domain consisting of I/O devices. */ static int pm_genpd_freeze(struct device *dev) { struct generic_pm_domain *genpd; dev_dbg(dev, "%s()\n", __func__); genpd = dev_to_genpd(dev); if (IS_ERR(genpd)) return -EINVAL; return genpd->suspend_power_off ? 0 : pm_generic_freeze(dev); } /** * <API key> - Late freeze of a device from an I/O power domain. * @dev: Device to freeze. * * Carry out a late freeze of a device under the assumption that its * pm_domain field points to the domain member of an object of type * struct generic_pm_domain representing a power domain consisting of I/O * devices. */ static int <API key>(struct device *dev) { struct generic_pm_domain *genpd; int ret; dev_dbg(dev, "%s()\n", __func__); genpd = dev_to_genpd(dev); if (IS_ERR(genpd)) return -EINVAL; if (genpd->suspend_power_off) return 0; ret = <API key>(dev); if (ret) return ret; if (genpd->stop_device) genpd->stop_device(dev); return 0; } /** * pm_genpd_thaw_noirq - Early thaw of a device from an I/O power domain. * @dev: Device to thaw. * * Carry out an early thaw of a device under the assumption that its * pm_domain field points to the domain member of an object of type * struct generic_pm_domain representing a power domain consisting of I/O * devices. */ static int pm_genpd_thaw_noirq(struct device *dev) { struct generic_pm_domain *genpd; dev_dbg(dev, "%s()\n", __func__); genpd = dev_to_genpd(dev); if (IS_ERR(genpd)) return -EINVAL; if (genpd->suspend_power_off) return 0; if (genpd->start_device) genpd->start_device(dev); return <API key>(dev); } /** * pm_genpd_thaw - Thaw a device belonging to an I/O power domain. * @dev: Device to thaw. * * Thaw a device under the assumption that its pm_domain field points to the * domain member of an object of type struct generic_pm_domain representing * a power domain consisting of I/O devices. */ static int pm_genpd_thaw(struct device *dev) { struct generic_pm_domain *genpd; dev_dbg(dev, "%s()\n", __func__); genpd = dev_to_genpd(dev); if (IS_ERR(genpd)) return -EINVAL; return genpd->suspend_power_off ? 0 : pm_generic_thaw(dev); } /** * <API key> - Power off a device belonging to an I/O PM domain. * @dev: Device to suspend. * * Power off a device under the assumption that its pm_domain field points to * the domain member of an object of type struct generic_pm_domain representing * a PM domain consisting of I/O devices. */ static int <API key>(struct device *dev) { struct generic_pm_domain *genpd; dev_dbg(dev, "%s()\n", __func__); genpd = dev_to_genpd(dev); if (IS_ERR(genpd)) return -EINVAL; return genpd->suspend_power_off ? 0 : pm_generic_poweroff(dev); } /** * <API key> - Late power off of a device from a PM domain. * @dev: Device to suspend. * * Carry out a late powering off of a device under the assumption that its * pm_domain field points to the domain member of an object of type * struct generic_pm_domain representing a PM domain consisting of I/O devices. */ static int <API key>(struct device *dev) { struct generic_pm_domain *genpd; int ret; dev_dbg(dev, "%s()\n", __func__); genpd = dev_to_genpd(dev); if (IS_ERR(genpd)) return -EINVAL; if (genpd->suspend_power_off) return 0; ret = <API key>(dev); if (ret) return ret; if (dev->power.wakeup_path && genpd->active_wakeup && genpd->active_wakeup(dev)) return 0; if (genpd->stop_device) genpd->stop_device(dev); /* * Since all of the "noirq" callbacks are executed sequentially, it is * guaranteed that this function will never run twice in parallel for * the same PM domain, so it is not necessary to use locking here. */ genpd->suspended_count++; <API key>(genpd); return 0; } /** * <API key> - Early restore of a device from an I/O power domain. * @dev: Device to resume. * * Carry out an early restore of a device under the assumption that its * pm_domain field points to the domain member of an object of type * struct generic_pm_domain representing a power domain consisting of I/O * devices. */ static int <API key>(struct device *dev) { struct generic_pm_domain *genpd; dev_dbg(dev, "%s()\n", __func__); genpd = dev_to_genpd(dev); if (IS_ERR(genpd)) return -EINVAL; /* * Since all of the "noirq" callbacks are executed sequentially, it is * guaranteed that this function will never run twice in parallel for * the same PM domain, so it is not necessary to use locking here. */ genpd->status = GPD_STATE_POWER_OFF; if (genpd->suspend_power_off) { /* * The boot kernel might put the domain into the power on state, * so make sure it really is powered off. */ if (genpd->power_off) genpd->power_off(genpd); return 0; } pm_genpd_poweron(genpd); genpd->suspended_count if (genpd->start_device) genpd->start_device(dev); return <API key>(dev); } /** * pm_genpd_restore - Restore a device belonging to an I/O power domain. * @dev: Device to resume. * * Restore a device under the assumption that its pm_domain field points to the * domain member of an object of type struct generic_pm_domain representing * a power domain consisting of I/O devices. */ static int pm_genpd_restore(struct device *dev) { struct generic_pm_domain *genpd; dev_dbg(dev, "%s()\n", __func__); genpd = dev_to_genpd(dev); if (IS_ERR(genpd)) return -EINVAL; return genpd->suspend_power_off ? 0 : pm_generic_restore(dev); } /** * pm_genpd_complete - Complete power transition of a device in a power domain. * @dev: Device to complete the transition of. * * Complete a power transition of a device (during a system-wide power * transition) under the assumption that its pm_domain field points to the * domain member of an object of type struct generic_pm_domain representing * a power domain consisting of I/O devices. */ static void pm_genpd_complete(struct device *dev) { struct generic_pm_domain *genpd; bool run_complete; dev_dbg(dev, "%s()\n", __func__); genpd = dev_to_genpd(dev); if (IS_ERR(genpd)) return; mutex_lock(&genpd->lock); run_complete = !genpd->suspend_power_off; if (--genpd->prepared_count == 0) genpd->suspend_power_off = false; mutex_unlock(&genpd->lock); if (run_complete) { pm_generic_complete(dev); <API key>(dev); pm_runtime_enable(dev); pm_runtime_idle(dev); } } #else #define pm_genpd_prepare NULL #define pm_genpd_suspend NULL #define <API key> NULL #define <API key> NULL #define pm_genpd_resume NULL #define pm_genpd_freeze NULL #define <API key> NULL #define pm_genpd_thaw_noirq NULL #define pm_genpd_thaw NULL #define <API key> NULL #define <API key> NULL #define <API key> NULL #define pm_genpd_restore NULL #define pm_genpd_complete NULL #endif /* CONFIG_PM_SLEEP */ /** * pm_genpd_add_device - Add a device to an I/O PM domain. * @genpd: PM domain to add the device to. * @dev: Device to be added. */ int pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev) { struct <API key> *gpd_data; struct pm_domain_data *pdd; int ret = 0; dev_dbg(dev, "%s()\n", __func__); if (IS_ERR_OR_NULL(genpd) || IS_ERR_OR_NULL(dev)) return -EINVAL; genpd_acquire_lock(genpd); if (genpd->status == GPD_STATE_POWER_OFF) { ret = -EINVAL; goto out; } if (genpd->prepared_count > 0) { ret = -EAGAIN; goto out; } list_for_each_entry(pdd, &genpd->dev_list, list_node) if (pdd->dev == dev) { ret = -EINVAL; goto out; } gpd_data = kzalloc(sizeof(*gpd_data), GFP_KERNEL); if (!gpd_data) { ret = -ENOMEM; goto out; } genpd->device_count++; dev->pm_domain = &genpd->domain; <API key>(dev); dev->power.subsys_data->domain_data = &gpd_data->base; gpd_data->base.dev = dev; gpd_data->need_restore = false; list_add_tail(&gpd_data->base.list_node, &genpd->dev_list); out: genpd_release_lock(genpd); return ret; } /** * <API key> - Remove a device from an I/O PM domain. * @genpd: PM domain to remove the device from. * @dev: Device to be removed. */ int <API key>(struct generic_pm_domain *genpd, struct device *dev) { struct pm_domain_data *pdd; int ret = -EINVAL; dev_dbg(dev, "%s()\n", __func__); if (IS_ERR_OR_NULL(genpd) || IS_ERR_OR_NULL(dev)) return -EINVAL; genpd_acquire_lock(genpd); if (genpd->prepared_count > 0) { ret = -EAGAIN; goto out; } list_for_each_entry(pdd, &genpd->dev_list, list_node) { if (pdd->dev != dev) continue; list_del_init(&pdd->list_node); pdd->dev = NULL; <API key>(dev); dev->pm_domain = NULL; kfree(to_gpd_data(pdd)); genpd->device_count ret = 0; break; } out: genpd_release_lock(genpd); return ret; } /** * <API key> - Add a subdomain to an I/O PM domain. * @genpd: Master PM domain to add the subdomain to. * @subdomain: Subdomain to be added. */ int <API key>(struct generic_pm_domain *genpd, struct generic_pm_domain *subdomain) { struct gpd_link *link; int ret = 0; if (IS_ERR_OR_NULL(genpd) || IS_ERR_OR_NULL(subdomain)) return -EINVAL; start: genpd_acquire_lock(genpd); mutex_lock_nested(&subdomain->lock, <API key>); if (subdomain->status != GPD_STATE_POWER_OFF && subdomain->status != GPD_STATE_ACTIVE) { mutex_unlock(&subdomain->lock); genpd_release_lock(genpd); goto start; } if (genpd->status == GPD_STATE_POWER_OFF && subdomain->status != GPD_STATE_POWER_OFF) { ret = -EINVAL; goto out; } list_for_each_entry(link, &genpd->slave_links, slave_node) { if (link->slave == subdomain && link->master == genpd) { ret = -EINVAL; goto out; } } link = kzalloc(sizeof(*link), GFP_KERNEL); if (!link) { ret = -ENOMEM; goto out; } link->master = genpd; list_add_tail(&link->master_node, &genpd->master_links); link->slave = subdomain; list_add_tail(&link->slave_node, &subdomain->slave_links); if (subdomain->status != GPD_STATE_POWER_OFF) <API key>(genpd); out: mutex_unlock(&subdomain->lock); genpd_release_lock(genpd); return ret; } /** * <API key> - Remove a subdomain from an I/O PM domain. * @genpd: Master PM domain to remove the subdomain from. * @subdomain: Subdomain to be removed. */ int <API key>(struct generic_pm_domain *genpd, struct generic_pm_domain *subdomain) { struct gpd_link *link; int ret = -EINVAL; if (IS_ERR_OR_NULL(genpd) || IS_ERR_OR_NULL(subdomain)) return -EINVAL; start: genpd_acquire_lock(genpd); list_for_each_entry(link, &genpd->master_links, master_node) { if (link->slave != subdomain) continue; mutex_lock_nested(&subdomain->lock, <API key>); if (subdomain->status != GPD_STATE_POWER_OFF && subdomain->status != GPD_STATE_ACTIVE) { mutex_unlock(&subdomain->lock); genpd_release_lock(genpd); goto start; } list_del(&link->master_node); list_del(&link->slave_node); kfree(link); if (subdomain->status != GPD_STATE_POWER_OFF) <API key>(genpd); mutex_unlock(&subdomain->lock); ret = 0; break; } genpd_release_lock(genpd); return ret; } /** * pm_genpd_init - Initialize a generic I/O PM domain object. * @genpd: PM domain object to initialize. * @gov: PM domain governor to associate with the domain (may be NULL). * @is_off: Initial value of the domain's power_is_off field. */ void pm_genpd_init(struct generic_pm_domain *genpd, struct dev_power_governor *gov, bool is_off) { if (IS_ERR_OR_NULL(genpd)) return; INIT_LIST_HEAD(&genpd->master_links); INIT_LIST_HEAD(&genpd->slave_links); INIT_LIST_HEAD(&genpd->dev_list); mutex_init(&genpd->lock); genpd->gov = gov; INIT_WORK(&genpd->power_off_work, <API key>); genpd->in_progress = 0; atomic_set(&genpd->sd_count, 0); genpd->status = is_off ? GPD_STATE_POWER_OFF : GPD_STATE_ACTIVE; init_waitqueue_head(&genpd->status_wait_queue); genpd->poweroff_task = NULL; genpd->resume_count = 0; genpd->device_count = 0; genpd->suspended_count = 0; genpd->domain.ops.runtime_suspend = <API key>; genpd->domain.ops.runtime_resume = <API key>; genpd->domain.ops.runtime_idle = <API key>; genpd->domain.ops.prepare = pm_genpd_prepare; genpd->domain.ops.suspend = pm_genpd_suspend; genpd->domain.ops.suspend_noirq = <API key>; genpd->domain.ops.resume_noirq = <API key>; genpd->domain.ops.resume = pm_genpd_resume; genpd->domain.ops.freeze = pm_genpd_freeze; genpd->domain.ops.freeze_noirq = <API key>; genpd->domain.ops.thaw_noirq = pm_genpd_thaw_noirq; genpd->domain.ops.thaw = pm_genpd_thaw; genpd->domain.ops.poweroff = <API key>; genpd->domain.ops.poweroff_noirq = <API key>; genpd->domain.ops.restore_noirq = <API key>; genpd->domain.ops.restore = pm_genpd_restore; genpd->domain.ops.complete = pm_genpd_complete; mutex_lock(&gpd_list_lock); list_add(&genpd->gpd_list_node, &gpd_list); mutex_unlock(&gpd_list_lock); }
// This is core/vnl/vnl_double_3x3.h #ifndef vnl_double_3x3_h_ #define vnl_double_3x3_h_ #ifdef <API key> #pragma interface #endif // \file // \brief 3x3 matrix of double // vnl_double_3x3 is a vnl_matrix<double> of fixed size 3x3. // It is merely a typedef for vnl_matrix_fixed<double,3,3> // \author Andrew W. Fitzgibbon, Oxford RRG // \date 04 Aug 96 #include <vnl/vnl_matrix_fixed.h> typedef vnl_matrix_fixed<double,3,3> vnl_double_3x3; #endif // vnl_double_3x3_h_
/* port_driver.c */ #include <stdio.h> #include "erl_driver.h" typedef struct { ErlDrvPort port; } example_data; static ErlDrvData example_drv_start(ErlDrvPort port, char *buff) { example_data* d = (example_data*)driver_alloc(sizeof(example_data)); d->port = port; return (ErlDrvData)d; } static void example_drv_stop(ErlDrvData handle) { driver_free((char*)handle); } static void example_drv_output(ErlDrvData handle, char *buff, ErlDrvSizeT bufflen) { example_data* d = (example_data*)handle; char fn = buff[0], arg = buff[1], res; if (fn == 1) { res = foo(arg); } else if (fn == 2) { res = bar(arg); } driver_output(d->port, &res, 1); } ErlDrvEntry <API key> = { NULL, /* F_PTR init, called when driver is loaded */ example_drv_start, /* L_PTR start, called when port is opened */ example_drv_stop, /* F_PTR stop, called when port is closed */ example_drv_output, /* F_PTR output, called when erlang has sent */ NULL, /* F_PTR ready_input, called when input descriptor ready */ NULL, /* F_PTR ready_output, called when output descriptor ready */ "example_drv", /* char *driver_name, the argument to open_port */ NULL, /* F_PTR finish, called when unloaded */ NULL, /* void *handle, Reserved by VM */ NULL, /* F_PTR control, port_command callback */ NULL, /* F_PTR timeout, reserved */ NULL, /* F_PTR outputv, reserved */ NULL, /* F_PTR ready_async, only for async drivers */ NULL, /* F_PTR flush, called when port is about to be closed, but there is data in driver queue */ NULL, /* F_PTR call, much like control, sync call to driver */ NULL, /* unused */ <API key>, /* int extended marker, Should always be set to indicate driver versioning */ <API key>, /* int major_version, should always be set to this value */ <API key>, /* int minor_version, should always be set to this value */ 0, /* int driver_flags, see documentation */ NULL, /* void *handle2, reserved for VM use */ NULL, /* F_PTR process_exit, called when a monitored process dies */ NULL /* F_PTR stop_select, called to close an event object */ }; DRIVER_INIT(example_drv) /* must match name in driver_entry */ { return &<API key>; }
<!DOCTYPE html> <meta charset="UTF-8"> <link rel="help" href="https://drafts.csswg.org/css-backgrounds-3/#background-position"> <meta name="test" content="<API key> supports animation"> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> <script src="/css/support/<API key>.js"></script> <style> .parent { <API key>: 60px; } .target { <API key>: 40px; } </style> <body> <script> test_interpolation({ property: '<API key>', from: neutralKeyframe, to: '80px', }, [ {at: -0.25, expect: '30px'}, {at: 0, expect: '40px'}, {at: 0.25, expect: '50px'}, {at: 0.5, expect: '60px'}, {at: 0.75, expect: '70px'}, {at: 1, expect: '80px'}, {at: 1.25, expect: '90px'}, ]); test_interpolation({ property: '<API key>', from: 'initial', to: 'right', }, [ {at: -0.25, expect: '-25%'}, {at: 0, expect: '0%'}, {at: 0.25, expect: '25%'}, {at: 0.5, expect: '50%'}, {at: 0.75, expect: '75%'}, {at: 1, expect: '100%'}, {at: 1.25, expect: '125%'}, ]); test_interpolation({ property: '<API key>', from: 'inherit', to: '80px', }, [ {at: -0.25, expect: '55px'}, {at: 0, expect: '60px'}, {at: 0.25, expect: '65px'}, {at: 0.5, expect: '70px'}, {at: 0.75, expect: '75px'}, {at: 1, expect: '80px'}, {at: 1.25, expect: '85px'}, ]); test_interpolation({ property: '<API key>', from: '300px, 400px', to: '500px, 600px, 700px', }, [ {at: -0.25, expect: '250px, 350px, 200px, 375px, 225px, 325px'}, {at: 0, expect: '300px, 400px, 300px, 400px, 300px, 400px'}, {at: 0.25, expect: '350px, 450px, 400px, 425px, 375px, 475px'}, {at: 0.5, expect: '400px, 500px, 500px, 450px, 450px, 550px'}, {at: 0.75, expect: '450px, 550px, 600px, 475px, 525px, 625px'}, {at: 1, expect: '500px, 600px, 700px, 500px, 600px, 700px'}, {at: 1.25, expect: '550px, 650px, 800px, 525px, 675px, 775px'}, ]); </script> </body>
#include "def-helper.h" DEF_HELPER_1(raise_exception, void, i32) DEF_HELPER_1(tlb_flush_pid, void, i32) DEF_HELPER_1(spc_write, void, i32) DEF_HELPER_3(dump, void, i32, i32, i32) DEF_HELPER_0(rfe, void); DEF_HELPER_0(rfn, void); DEF_HELPER_2(movl_sreg_reg, void, i32, i32) DEF_HELPER_2(movl_reg_sreg, void, i32, i32) DEF_HELPER_FLAGS_1(lz, TCG_CALL_PURE, i32, i32); DEF_HELPER_FLAGS_3(btst, TCG_CALL_PURE, i32, i32, i32, i32); DEF_HELPER_FLAGS_3(evaluate_flags_muls, TCG_CALL_PURE, i32, i32, i32, i32) DEF_HELPER_FLAGS_3(evaluate_flags_mulu, TCG_CALL_PURE, i32, i32, i32, i32) DEF_HELPER_FLAGS_4(evaluate_flags_mcp, TCG_CALL_PURE, i32, i32, i32, i32, i32) DEF_HELPER_FLAGS_4(<API key>, TCG_CALL_PURE, i32, i32, i32, i32, i32) DEF_HELPER_FLAGS_4(<API key>, TCG_CALL_PURE, i32, i32, i32, i32, i32) DEF_HELPER_FLAGS_2(<API key>, TCG_CALL_PURE, i32, i32, i32) DEF_HELPER_FLAGS_2(<API key>, TCG_CALL_PURE, i32, i32, i32) DEF_HELPER_0(evaluate_flags, void) DEF_HELPER_0(top_evaluate_flags, void) #include "def-helper.h"
#include <linux/via-core.h> #include "global.h" struct res_map_refresh res_map_refresh_tbl[] = { /*hres, vres, vclock, vmode_refresh*/ {480, 640, <API key>, 60}, {640, 480, <API key>, 60}, {640, 480, <API key>, 75}, {640, 480, <API key>, 85}, {640, 480, <API key>, 100}, {640, 480, <API key>, 120}, {720, 480, <API key>, 60}, {720, 576, <API key>, 60}, {800, 480, <API key>, 60}, {800, 600, <API key>, 60}, {800, 600, <API key>, 75}, {800, 600, <API key>, 85}, {800, 600, <API key>, 100}, {800, 600, <API key>, 120}, {848, 480, <API key>, 60}, {856, 480, <API key>, 60}, {1024, 512, <API key>, 60}, {1024, 600, <API key>, 60}, {1024, 768, <API key>, 60}, {1024, 768, <API key>, 75}, {1024, 768, <API key>, 85}, {1024, 768, <API key>, 100}, /* {1152,864, <API key>, 70},*/ {1152, 864, <API key>, 75}, {1280, 768, <API key>, 60}, {1280, 800, <API key>, 60}, {1280, 960, <API key>, 60}, {1280, 1024, <API key>, 60}, {1280, 1024, <API key>, 75}, {1280, 1024, <API key>, 85}, {1440, 1050, <API key>, 60}, {1600, 1200, <API key>, 60}, {1600, 1200, <API key>, 75}, {1280, 720, <API key>, 60}, {1920, 1080, <API key>, 60}, {1400, 1050, <API key>, 60}, {1400, 1050, <API key>, 75}, {1368, 768, <API key>, 60}, {960, 600, <API key>, 60}, {1000, 600, <API key>, 60}, {1024, 576, <API key>, 60}, {1088, 612, <API key>, 60}, {1152, 720, <API key>, 60}, {1200, 720, <API key>, 60}, {1200, 900, <API key>, 60}, {1280, 600, <API key>, 60}, {1280, 720, <API key>, 50}, {1280, 768, <API key>, 50}, {1360, 768, <API key>, 60}, {1366, 768, <API key>, 50}, {1366, 768, <API key>, 60}, {1440, 900, <API key>, 60}, {1440, 900, <API key>, 75}, {1600, 900, <API key>, 60}, {1600, 1024, <API key>, 60}, {1680, 1050, <API key>, 60}, {1680, 1050, <API key>, 75}, {1792, 1344, <API key>, 60}, {1856, 1392, <API key>, 60}, {1920, 1200, <API key>, 60}, {1920, 1440, <API key>, 60}, {1920, 1440, <API key>, 75}, {2048, 1536, <API key>, 60} }; struct io_reg CN400_ModeXregs[] = { {VIASR, SR10, 0xFF, 0x01}, {VIASR, SR15, 0x02, 0x02}, {VIASR, SR16, 0xBF, 0x08}, {VIASR, SR17, 0xFF, 0x1F}, {VIASR, SR18, 0xFF, 0x4E}, {VIASR, SR1A, 0xFB, 0x08}, {VIASR, SR1E, 0x0F, 0x01}, {VIASR, SR2A, 0xFF, 0x00}, {VIACR, CR0A, 0xFF, 0x1E}, /* Cursor Start */ {VIACR, CR0B, 0xFF, 0x00}, /* Cursor End */ {VIACR, CR0E, 0xFF, 0x00}, /* Cursor Location High */ {VIACR, CR0F, 0xFF, 0x00}, /* Cursor Localtion Low */ {VIACR, CR32, 0xFF, 0x00}, {VIACR, CR33, 0xFF, 0x00}, {VIACR, CR35, 0xFF, 0x00}, {VIACR, CR36, 0x08, 0x00}, {VIACR, CR69, 0xFF, 0x00}, {VIACR, CR6A, 0xFF, 0x40}, {VIACR, CR6B, 0xFF, 0x00}, {VIACR, CR6C, 0xFF, 0x00}, {VIACR, CR7A, 0xFF, 0x01}, /* LCD Scaling Parameter 1 */ {VIACR, CR7B, 0xFF, 0x02}, /* LCD Scaling Parameter 2 */ {VIACR, CR7C, 0xFF, 0x03}, /* LCD Scaling Parameter 3 */ {VIACR, CR7D, 0xFF, 0x04}, /* LCD Scaling Parameter 4 */ {VIACR, CR7E, 0xFF, 0x07}, /* LCD Scaling Parameter 5 */ {VIACR, CR7F, 0xFF, 0x0A}, /* LCD Scaling Parameter 6 */ {VIACR, CR80, 0xFF, 0x0D}, /* LCD Scaling Parameter 7 */ {VIACR, CR81, 0xFF, 0x13}, /* LCD Scaling Parameter 8 */ {VIACR, CR82, 0xFF, 0x16}, /* LCD Scaling Parameter 9 */ {VIACR, CR83, 0xFF, 0x19}, /* LCD Scaling Parameter 10 */ {VIACR, CR84, 0xFF, 0x1C}, /* LCD Scaling Parameter 11 */ {VIACR, CR85, 0xFF, 0x1D}, /* LCD Scaling Parameter 12 */ {VIACR, CR86, 0xFF, 0x1E}, /* LCD Scaling Parameter 13 */ {VIACR, CR87, 0xFF, 0x1F}, /* LCD Scaling Parameter 14 */ {VIACR, CR88, 0xFF, 0x40}, /* LCD Panel Type */ {VIACR, CR89, 0xFF, 0x00}, /* LCD Timing Control 0 */ {VIACR, CR8A, 0xFF, 0x88}, /* LCD Timing Control 1 */ {VIACR, CR8B, 0xFF, 0x69}, /* LCD Power Sequence Control 0 */ {VIACR, CR8C, 0xFF, 0x57}, /* LCD Power Sequence Control 1 */ {VIACR, CR8D, 0xFF, 0x00}, /* LCD Power Sequence Control 2 */ {VIACR, CR8E, 0xFF, 0x7B}, /* LCD Power Sequence Control 3 */ {VIACR, CR8F, 0xFF, 0x03}, /* LCD Power Sequence Control 4 */ {VIACR, CR90, 0xFF, 0x30}, /* LCD Power Sequence Control 5 */ {VIACR, CR91, 0xFF, 0xA0}, /* 24/12 bit LVDS Data off */ {VIACR, CR96, 0xFF, 0x00}, {VIACR, CR97, 0xFF, 0x00}, {VIACR, CR99, 0xFF, 0x00}, {VIACR, CR9B, 0xFF, 0x00} }; /* Video Mode Table for VT3314 chipset*/ /* Common Setting for Video Mode */ struct io_reg CN700_ModeXregs[] = { {VIASR, SR10, 0xFF, 0x01}, {VIASR, SR15, 0x02, 0x02}, {VIASR, SR16, 0xBF, 0x08}, {VIASR, SR17, 0xFF, 0x1F}, {VIASR, SR18, 0xFF, 0x4E}, {VIASR, SR1A, 0xFB, 0x82}, {VIASR, SR1B, 0xFF, 0xF0}, {VIASR, SR1F, 0xFF, 0x00}, {VIASR, SR1E, 0xFF, 0x01}, {VIASR, SR22, 0xFF, 0x1F}, {VIASR, SR2A, 0x0F, 0x00}, {VIASR, SR2E, 0xFF, 0xFF}, {VIASR, SR3F, 0xFF, 0xFF}, {VIASR, SR40, 0xF7, 0x00}, {VIASR, CR30, 0xFF, 0x04}, {VIACR, CR32, 0xFF, 0x00}, {VIACR, CR33, 0x7F, 0x00}, {VIACR, CR35, 0xFF, 0x00}, {VIACR, CR36, 0xFF, 0x31}, {VIACR, CR41, 0xFF, 0x80}, {VIACR, CR42, 0xFF, 0x00}, {VIACR, CR55, 0x80, 0x00}, {VIACR, CR5D, 0x80, 0x00}, /*Horizontal Retrace Start bit[11] should be 0*/ {VIACR, CR68, 0xFF, 0x67}, /* Default FIFO For IGA2 */ {VIACR, CR69, 0xFF, 0x00}, {VIACR, CR6A, 0xFD, 0x40}, {VIACR, CR6B, 0xFF, 0x00}, {VIACR, CR6C, 0xFF, 0x00}, {VIACR, CR77, 0xFF, 0x00}, /* LCD scaling Factor */ {VIACR, CR78, 0xFF, 0x00}, /* LCD scaling Factor */ {VIACR, CR79, 0xFF, 0x00}, /* LCD scaling Factor */ {VIACR, CR9F, 0x03, 0x00}, /* LCD scaling Factor */ {VIACR, CR7A, 0xFF, 0x01}, /* LCD Scaling Parameter 1 */ {VIACR, CR7B, 0xFF, 0x02}, /* LCD Scaling Parameter 2 */ {VIACR, CR7C, 0xFF, 0x03}, /* LCD Scaling Parameter 3 */ {VIACR, CR7D, 0xFF, 0x04}, /* LCD Scaling Parameter 4 */ {VIACR, CR7E, 0xFF, 0x07}, /* LCD Scaling Parameter 5 */ {VIACR, CR7F, 0xFF, 0x0A}, /* LCD Scaling Parameter 6 */ {VIACR, CR80, 0xFF, 0x0D}, /* LCD Scaling Parameter 7 */ {VIACR, CR81, 0xFF, 0x13}, /* LCD Scaling Parameter 8 */ {VIACR, CR82, 0xFF, 0x16}, /* LCD Scaling Parameter 9 */ {VIACR, CR83, 0xFF, 0x19}, /* LCD Scaling Parameter 10 */ {VIACR, CR84, 0xFF, 0x1C}, /* LCD Scaling Parameter 11 */ {VIACR, CR85, 0xFF, 0x1D}, /* LCD Scaling Parameter 12 */ {VIACR, CR86, 0xFF, 0x1E}, /* LCD Scaling Parameter 13 */ {VIACR, CR87, 0xFF, 0x1F}, /* LCD Scaling Parameter 14 */ {VIACR, CR88, 0xFF, 0x40}, /* LCD Panel Type */ {VIACR, CR89, 0xFF, 0x00}, /* LCD Timing Control 0 */ {VIACR, CR8A, 0xFF, 0x88}, /* LCD Timing Control 1 */ {VIACR, CR8B, 0xFF, 0x5D}, /* LCD Power Sequence Control 0 */ {VIACR, CR8C, 0xFF, 0x2B}, /* LCD Power Sequence Control 1 */ {VIACR, CR8D, 0xFF, 0x6F}, /* LCD Power Sequence Control 2 */ {VIACR, CR8E, 0xFF, 0x2B}, /* LCD Power Sequence Control 3 */ {VIACR, CR8F, 0xFF, 0x01}, /* LCD Power Sequence Control 4 */ {VIACR, CR90, 0xFF, 0x01}, /* LCD Power Sequence Control 5 */ {VIACR, CR91, 0xFF, 0xA0}, /* 24/12 bit LVDS Data off */ {VIACR, CR96, 0xFF, 0x00}, {VIACR, CR97, 0xFF, 0x00}, {VIACR, CR99, 0xFF, 0x00}, {VIACR, CR9B, 0xFF, 0x00}, {VIACR, CR9D, 0xFF, 0x80}, {VIACR, CR9E, 0xFF, 0x80} }; struct io_reg KM400_ModeXregs[] = { {VIASR, SR10, 0xFF, 0x01}, /* Unlock Register */ {VIASR, SR16, 0xFF, 0x08}, /* Display FIFO threshold Control */ {VIASR, SR17, 0xFF, 0x1F}, /* Display FIFO Control */ {VIASR, SR18, 0xFF, 0x4E}, /* GFX PREQ threshold */ {VIASR, SR1A, 0xFF, 0x0a}, /* GFX PREQ threshold */ {VIASR, SR1F, 0xFF, 0x00}, /* Memory Control 0 */ {VIASR, SR1B, 0xFF, 0xF0}, /* Power Management Control 0 */ {VIASR, SR1E, 0xFF, 0x01}, /* Power Management Control */ {VIASR, SR20, 0xFF, 0x00}, /* Sequencer Arbiter Control 0 */ {VIASR, SR21, 0xFF, 0x00}, /* Sequencer Arbiter Control 1 */ {VIASR, SR22, 0xFF, 0x1F}, /* Display Arbiter Control 1 */ {VIASR, SR2A, 0xFF, 0x00}, /* Power Management Control 5 */ {VIASR, SR2D, 0xFF, 0xFF}, /* Power Management Control 1 */ {VIASR, SR2E, 0xFF, 0xFF}, /* Power Management Control 2 */ {VIACR, CR0A, 0xFF, 0x1E}, /* Cursor Start */ {VIACR, CR0B, 0xFF, 0x00}, /* Cursor End */ {VIACR, CR0E, 0xFF, 0x00}, /* Cursor Location High */ {VIACR, CR0F, 0xFF, 0x00}, /* Cursor Localtion Low */ {VIACR, CR33, 0xFF, 0x00}, {VIACR, CR55, 0x80, 0x00}, {VIACR, CR5D, 0x80, 0x00}, {VIACR, CR36, 0xFF, 0x01}, /* Power Mangement 3 */ {VIACR, CR68, 0xFF, 0x67}, /* Default FIFO For IGA2 */ {VIACR, CR6A, 0x20, 0x20}, /* Extended FIFO On */ {VIACR, CR7A, 0xFF, 0x01}, /* LCD Scaling Parameter 1 */ {VIACR, CR7B, 0xFF, 0x02}, /* LCD Scaling Parameter 2 */ {VIACR, CR7C, 0xFF, 0x03}, /* LCD Scaling Parameter 3 */ {VIACR, CR7D, 0xFF, 0x04}, /* LCD Scaling Parameter 4 */ {VIACR, CR7E, 0xFF, 0x07}, /* LCD Scaling Parameter 5 */ {VIACR, CR7F, 0xFF, 0x0A}, /* LCD Scaling Parameter 6 */ {VIACR, CR80, 0xFF, 0x0D}, /* LCD Scaling Parameter 7 */ {VIACR, CR81, 0xFF, 0x13}, /* LCD Scaling Parameter 8 */ {VIACR, CR82, 0xFF, 0x16}, /* LCD Scaling Parameter 9 */ {VIACR, CR83, 0xFF, 0x19}, /* LCD Scaling Parameter 10 */ {VIACR, CR84, 0xFF, 0x1C}, /* LCD Scaling Parameter 11 */ {VIACR, CR85, 0xFF, 0x1D}, /* LCD Scaling Parameter 12 */ {VIACR, CR86, 0xFF, 0x1E}, /* LCD Scaling Parameter 13 */ {VIACR, CR87, 0xFF, 0x1F}, /* LCD Scaling Parameter 14 */ {VIACR, CR88, 0xFF, 0x40}, /* LCD Panel Type */ {VIACR, CR89, 0xFF, 0x00}, /* LCD Timing Control 0 */ {VIACR, CR8A, 0xFF, 0x88}, /* LCD Timing Control 1 */ {VIACR, CR8B, 0xFF, 0x2D}, /* LCD Power Sequence Control 0 */ {VIACR, CR8C, 0xFF, 0x2D}, /* LCD Power Sequence Control 1 */ {VIACR, CR8D, 0xFF, 0xC8}, /* LCD Power Sequence Control 2 */ {VIACR, CR8E, 0xFF, 0x36}, /* LCD Power Sequence Control 3 */ {VIACR, CR8F, 0xFF, 0x00}, /* LCD Power Sequence Control 4 */ {VIACR, CR90, 0xFF, 0x10}, /* LCD Power Sequence Control 5 */ {VIACR, CR91, 0xFF, 0xA0}, /* 24/12 bit LVDS Data off */ {VIACR, CR96, 0xFF, 0x03}, /* DVP0 ; DVP0 Clock Skew */ {VIACR, CR97, 0xFF, 0x03}, /* DFP high ; DFPH Clock Skew */ {VIACR, CR99, 0xFF, 0x03}, /* DFP low ; DFPL Clock Skew*/ {VIACR, CR9B, 0xFF, 0x07} /* DVI on DVP1 ; DVP1 Clock Skew*/ }; /* For VT3324: Common Setting for Video Mode */ struct io_reg CX700_ModeXregs[] = { {VIASR, SR10, 0xFF, 0x01}, {VIASR, SR15, 0x02, 0x02}, {VIASR, SR16, 0xBF, 0x08}, {VIASR, SR17, 0xFF, 0x1F}, {VIASR, SR18, 0xFF, 0x4E}, {VIASR, SR1A, 0xFB, 0x08}, {VIASR, SR1B, 0xFF, 0xF0}, {VIASR, SR1E, 0xFF, 0x01}, {VIASR, SR2A, 0xFF, 0x00}, {VIASR, SR2D, 0xFF, 0xFF}, /* VCK and LCK PLL power on. */ {VIACR, CR0A, 0xFF, 0x1E}, /* Cursor Start */ {VIACR, CR0B, 0xFF, 0x00}, /* Cursor End */ {VIACR, CR0E, 0xFF, 0x00}, /* Cursor Location High */ {VIACR, CR0F, 0xFF, 0x00}, /* Cursor Localtion Low */ {VIACR, CR32, 0xFF, 0x00}, {VIACR, CR33, 0xFF, 0x00}, {VIACR, CR35, 0xFF, 0x00}, {VIACR, CR36, 0x08, 0x00}, {VIACR, CR47, 0xC8, 0x00}, /* Clear VCK Plus. */ {VIACR, CR69, 0xFF, 0x00}, {VIACR, CR6A, 0xFF, 0x40}, {VIACR, CR6B, 0xFF, 0x00}, {VIACR, CR6C, 0xFF, 0x00}, {VIACR, CR7A, 0xFF, 0x01}, /* LCD Scaling Parameter 1 */ {VIACR, CR7B, 0xFF, 0x02}, /* LCD Scaling Parameter 2 */ {VIACR, CR7C, 0xFF, 0x03}, /* LCD Scaling Parameter 3 */ {VIACR, CR7D, 0xFF, 0x04}, /* LCD Scaling Parameter 4 */ {VIACR, CR7E, 0xFF, 0x07}, /* LCD Scaling Parameter 5 */ {VIACR, CR7F, 0xFF, 0x0A}, /* LCD Scaling Parameter 6 */ {VIACR, CR80, 0xFF, 0x0D}, /* LCD Scaling Parameter 7 */ {VIACR, CR81, 0xFF, 0x13}, /* LCD Scaling Parameter 8 */ {VIACR, CR82, 0xFF, 0x16}, /* LCD Scaling Parameter 9 */ {VIACR, CR83, 0xFF, 0x19}, /* LCD Scaling Parameter 10 */ {VIACR, CR84, 0xFF, 0x1C}, /* LCD Scaling Parameter 11 */ {VIACR, CR85, 0xFF, 0x1D}, /* LCD Scaling Parameter 12 */ {VIACR, CR86, 0xFF, 0x1E}, /* LCD Scaling Parameter 13 */ {VIACR, CR87, 0xFF, 0x1F}, /* LCD Scaling Parameter 14 */ {VIACR, CR88, 0xFF, 0x40}, /* LCD Panel Type */ {VIACR, CR89, 0xFF, 0x00}, /* LCD Timing Control 0 */ {VIACR, CR8A, 0xFF, 0x88}, /* LCD Timing Control 1 */ {VIACR, CRD4, 0xFF, 0x81}, /* Second power sequence control */ {VIACR, CR8B, 0xFF, 0x5D}, /* LCD Power Sequence Control 0 */ {VIACR, CR8C, 0xFF, 0x2B}, /* LCD Power Sequence Control 1 */ {VIACR, CR8D, 0xFF, 0x6F}, /* LCD Power Sequence Control 2 */ {VIACR, CR8E, 0xFF, 0x2B}, /* LCD Power Sequence Control 3 */ {VIACR, CR8F, 0xFF, 0x01}, /* LCD Power Sequence Control 4 */ {VIACR, CR90, 0xFF, 0x01}, /* LCD Power Sequence Control 5 */ {VIACR, CR91, 0xFF, 0x80}, /* 24/12 bit LVDS Data off */ {VIACR, CR96, 0xFF, 0x00}, {VIACR, CR97, 0xFF, 0x00}, {VIACR, CR99, 0xFF, 0x00}, {VIACR, CR9B, 0xFF, 0x00} }; struct io_reg VX855_ModeXregs[] = { {VIASR, SR10, 0xFF, 0x01}, {VIASR, SR15, 0x02, 0x02}, {VIASR, SR16, 0xBF, 0x08}, {VIASR, SR17, 0xFF, 0x1F}, {VIASR, SR18, 0xFF, 0x4E}, {VIASR, SR1A, 0xFB, 0x08}, {VIASR, SR1B, 0xFF, 0xF0}, {VIASR, SR1E, 0x07, 0x01}, {VIASR, SR2A, 0xF0, 0x00}, {VIASR, SR58, 0xFF, 0x00}, {VIASR, SR59, 0xFF, 0x00}, {VIASR, SR2D, 0xFF, 0xFF}, /* VCK and LCK PLL power on. */ {VIACR, CR09, 0xFF, 0x00}, /* Initial CR09=0*/ {VIACR, CR11, 0x8F, 0x00}, /* IGA1 initial Vertical end */ {VIACR, CR17, 0x7F, 0x00}, /* IGA1 CRT Mode control init */ {VIACR, CR0A, 0xFF, 0x1E}, /* Cursor Start */ {VIACR, CR0B, 0xFF, 0x00}, /* Cursor End */ {VIACR, CR0E, 0xFF, 0x00}, /* Cursor Location High */ {VIACR, CR0F, 0xFF, 0x00}, /* Cursor Localtion Low */ {VIACR, CR32, 0xFF, 0x00}, {VIACR, CR33, 0x7F, 0x00}, {VIACR, CR35, 0xFF, 0x00}, {VIACR, CR36, 0x08, 0x00}, {VIACR, CR69, 0xFF, 0x00}, {VIACR, CR6A, 0xFD, 0x60}, {VIACR, CR6B, 0xFF, 0x00}, {VIACR, CR6C, 0xFF, 0x00}, {VIACR, CR7A, 0xFF, 0x01}, /* LCD Scaling Parameter 1 */ {VIACR, CR7B, 0xFF, 0x02}, /* LCD Scaling Parameter 2 */ {VIACR, CR7C, 0xFF, 0x03}, /* LCD Scaling Parameter 3 */ {VIACR, CR7D, 0xFF, 0x04}, /* LCD Scaling Parameter 4 */ {VIACR, CR7E, 0xFF, 0x07}, /* LCD Scaling Parameter 5 */ {VIACR, CR7F, 0xFF, 0x0A}, /* LCD Scaling Parameter 6 */ {VIACR, CR80, 0xFF, 0x0D}, /* LCD Scaling Parameter 7 */ {VIACR, CR81, 0xFF, 0x13}, /* LCD Scaling Parameter 8 */ {VIACR, CR82, 0xFF, 0x16}, /* LCD Scaling Parameter 9 */ {VIACR, CR83, 0xFF, 0x19}, /* LCD Scaling Parameter 10 */ {VIACR, CR84, 0xFF, 0x1C}, /* LCD Scaling Parameter 11 */ {VIACR, CR85, 0xFF, 0x1D}, /* LCD Scaling Parameter 12 */ {VIACR, CR86, 0xFF, 0x1E}, /* LCD Scaling Parameter 13 */ {VIACR, CR87, 0xFF, 0x1F}, /* LCD Scaling Parameter 14 */ {VIACR, CR88, 0xFF, 0x40}, /* LCD Panel Type */ {VIACR, CR89, 0xFF, 0x00}, /* LCD Timing Control 0 */ {VIACR, CR8A, 0xFF, 0x88}, /* LCD Timing Control 1 */ {VIACR, CRD4, 0xFF, 0x81}, /* Second power sequence control */ {VIACR, CR91, 0xFF, 0x80}, /* 24/12 bit LVDS Data off */ {VIACR, CR96, 0xFF, 0x00}, {VIACR, CR97, 0xFF, 0x00}, {VIACR, CR99, 0xFF, 0x00}, {VIACR, CR9B, 0xFF, 0x00}, {VIACR, CRD2, 0xFF, 0xFF} /* TMDS/LVDS control register. */ }; /* Video Mode Table */ /* Common Setting for Video Mode */ struct io_reg CLE266_ModeXregs[] = { {VIASR, SR1E, 0xF0, 0x00}, {VIASR, SR2A, 0x0F, 0x00}, {VIASR, SR15, 0x02, 0x02}, {VIASR, SR16, 0xBF, 0x08}, {VIASR, SR17, 0xFF, 0x1F}, {VIASR, SR18, 0xFF, 0x4E}, {VIASR, SR1A, 0xFB, 0x08}, {VIACR, CR32, 0xFF, 0x00}, {VIACR, CR35, 0xFF, 0x00}, {VIACR, CR36, 0x08, 0x00}, {VIACR, CR6A, 0xFF, 0x80}, {VIACR, CR6A, 0xFF, 0xC0}, {VIACR, CR55, 0x80, 0x00}, {VIACR, CR5D, 0x80, 0x00}, {VIAGR, GR20, 0xFF, 0x00}, {VIAGR, GR21, 0xFF, 0x00}, {VIAGR, GR22, 0xFF, 0x00}, /* LCD Parameters */ {VIACR, CR7A, 0xFF, 0x01}, /* LCD Parameter 1 */ {VIACR, CR7B, 0xFF, 0x02}, /* LCD Parameter 2 */ {VIACR, CR7C, 0xFF, 0x03}, /* LCD Parameter 3 */ {VIACR, CR7D, 0xFF, 0x04}, /* LCD Parameter 4 */ {VIACR, CR7E, 0xFF, 0x07}, /* LCD Parameter 5 */ {VIACR, CR7F, 0xFF, 0x0A}, /* LCD Parameter 6 */ {VIACR, CR80, 0xFF, 0x0D}, /* LCD Parameter 7 */ {VIACR, CR81, 0xFF, 0x13}, /* LCD Parameter 8 */ {VIACR, CR82, 0xFF, 0x16}, /* LCD Parameter 9 */ {VIACR, CR83, 0xFF, 0x19}, /* LCD Parameter 10 */ {VIACR, CR84, 0xFF, 0x1C}, /* LCD Parameter 11 */ {VIACR, CR85, 0xFF, 0x1D}, /* LCD Parameter 12 */ {VIACR, CR86, 0xFF, 0x1E}, /* LCD Parameter 13 */ {VIACR, CR87, 0xFF, 0x1F}, /* LCD Parameter 14 */ }; /* Mode:1024X768 */ struct io_reg PM1024x768[] = { {VIASR, 0x16, 0xBF, 0x0C}, {VIASR, 0x18, 0xFF, 0x4C} }; struct patch_table res_patch_table[] = { {ARRAY_SIZE(PM1024x768), PM1024x768} }; /* struct VPITTable { unsigned char Misc; unsigned char SR[StdSR]; unsigned char CR[StdCR]; unsigned char GR[StdGR]; unsigned char AR[StdAR]; };*/ struct VPITTable VPIT = { /* Msic */ 0xC7, /* Sequencer */ {0x01, 0x0F, 0x00, 0x0E}, /* Graphic Controller */ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0F, 0xFF}, /* Attribute Controller */ {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x01, 0x00, 0x0F, 0x00} }; /* Mode Table */ /* 480x640 */ struct crt_mode_table CRTM480x640[] = { /* r_rate, vclk, hsp, vsp */ /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_25_175M, M480X640_R60_HSP, M480X640_R60_VSP, {624, 480, 480, 144, 504, 48, 663, 640, 640, 23, 641, 3} } /* GTF*/ }; /* 640x480*/ struct crt_mode_table CRTM640x480[] = { /*r_rate,vclk,hsp,vsp */ /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_25_175M, M640X480_R60_HSP, M640X480_R60_VSP, {800, 640, 648, 144, 656, 96, 525, 480, 480, 45, 490, 2} }, {REFRESH_75, CLK_31_500M, M640X480_R75_HSP, M640X480_R75_VSP, {840, 640, 640, 200, 656, 64, 500, 480, 480, 20, 481, 3} }, {REFRESH_85, CLK_36_000M, M640X480_R85_HSP, M640X480_R85_VSP, {832, 640, 640, 192, 696, 56, 509, 480, 480, 29, 481, 3} }, {REFRESH_100, CLK_43_163M, M640X480_R100_HSP, M640X480_R100_VSP, {848, 640, 640, 208, 680, 64, 509, 480, 480, 29, 481, 3} }, /*GTF*/ {REFRESH_120, CLK_52_406M, M640X480_R120_HSP, M640X480_R120_VSP, {848, 640, 640, 208, 680, 64, 515, 480, 480, 35, 481, 3} } /*GTF*/ }; /*720x480 (GTF)*/ struct crt_mode_table CRTM720x480[] = { /*r_rate,vclk,hsp,vsp */ /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_26_880M, M720X480_R60_HSP, M720X480_R60_VSP, {896, 720, 720, 176, 736, 72, 497, 480, 480, 17, 481, 3} } }; /*720x576 (GTF)*/ struct crt_mode_table CRTM720x576[] = { /*r_rate,vclk,hsp,vsp */ /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_32_668M, M720X576_R60_HSP, M720X576_R60_VSP, {912, 720, 720, 192, 744, 72, 597, 576, 576, 21, 577, 3} } }; /* 800x480 (CVT) */ struct crt_mode_table CRTM800x480[] = { /* r_rate, vclk, hsp, vsp */ /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_29_581M, M800X480_R60_HSP, M800X480_R60_VSP, {992, 800, 800, 192, 824, 72, 500, 480, 480, 20, 483, 7} } }; /* 800x600*/ struct crt_mode_table CRTM800x600[] = { /*r_rate,vclk,hsp,vsp */ /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_40_000M, M800X600_R60_HSP, M800X600_R60_VSP, {1056, 800, 800, 256, 840, 128, 628, 600, 600, 28, 601, 4} }, {REFRESH_75, CLK_49_500M, M800X600_R75_HSP, M800X600_R75_VSP, {1056, 800, 800, 256, 816, 80, 625, 600, 600, 25, 601, 3} }, {REFRESH_85, CLK_56_250M, M800X600_R85_HSP, M800X600_R85_VSP, {1048, 800, 800, 248, 832, 64, 631, 600, 600, 31, 601, 3} }, {REFRESH_100, CLK_68_179M, M800X600_R100_HSP, M800X600_R100_VSP, {1072, 800, 800, 272, 848, 88, 636, 600, 600, 36, 601, 3} }, {REFRESH_120, CLK_83_950M, M800X600_R120_HSP, M800X600_R120_VSP, {1088, 800, 800, 288, 856, 88, 643, 600, 600, 43, 601, 3} } }; /* 848x480 (CVT) */ struct crt_mode_table CRTM848x480[] = { /* r_rate, vclk, hsp, vsp */ /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_31_500M, M848X480_R60_HSP, M848X480_R60_VSP, {1056, 848, 848, 208, 872, 80, 500, 480, 480, 20, 483, 5} } }; /*856x480 (GTF) convert to 852x480*/ struct crt_mode_table CRTM852x480[] = { /*r_rate,vclk,hsp,vsp */ /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_31_728M, M852X480_R60_HSP, M852X480_R60_VSP, {1064, 856, 856, 208, 872, 88, 497, 480, 480, 17, 481, 3} } }; /*1024x512 (GTF)*/ struct crt_mode_table CRTM1024x512[] = { /*r_rate,vclk,hsp,vsp */ /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_41_291M, M1024X512_R60_HSP, M1024X512_R60_VSP, {1296, 1024, 1024, 272, 1056, 104, 531, 512, 512, 19, 513, 3} } }; /* 1024x600*/ struct crt_mode_table CRTM1024x600[] = { /*r_rate,vclk,hsp,vsp */ /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_48_875M, M1024X600_R60_HSP, M1024X600_R60_VSP, {1312, 1024, 1024, 288, 1064, 104, 622, 600, 600, 22, 601, 3} }, }; /* 1024x768*/ struct crt_mode_table CRTM1024x768[] = { /*r_rate,vclk,hsp,vsp */ /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_65_000M, M1024X768_R60_HSP, M1024X768_R60_VSP, {1344, 1024, 1024, 320, 1048, 136, 806, 768, 768, 38, 771, 6} }, {REFRESH_75, CLK_78_750M, M1024X768_R75_HSP, M1024X768_R75_VSP, {1312, 1024, 1024, 288, 1040, 96, 800, 768, 768, 32, 769, 3} }, {REFRESH_85, CLK_94_500M, M1024X768_R85_HSP, M1024X768_R85_VSP, {1376, 1024, 1024, 352, 1072, 96, 808, 768, 768, 40, 769, 3} }, {REFRESH_100, CLK_113_309M, M1024X768_R100_HSP, M1024X768_R100_VSP, {1392, 1024, 1024, 368, 1096, 112, 814, 768, 768, 46, 769, 3} } }; /* 1152x864*/ struct crt_mode_table CRTM1152x864[] = { /*r_rate,vclk,hsp,vsp */ /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_75, CLK_108_000M, M1152X864_R75_HSP, M1152X864_R75_VSP, {1600, 1152, 1152, 448, 1216, 128, 900, 864, 864, 36, 865, 3} } }; /* 1280x720 (HDMI 720P)*/ struct crt_mode_table CRTM1280x720[] = { /*r_rate,vclk,hsp,vsp */ /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_74_481M, M1280X720_R60_HSP, M1280X720_R60_VSP, {1648, 1280, 1280, 368, 1392, 40, 750, 720, 720, 30, 725, 5} }, {REFRESH_50, CLK_60_466M, M1280X720_R50_HSP, M1280X720_R50_VSP, {1632, 1280, 1280, 352, 1328, 128, 741, 720, 720, 21, 721, 3} } }; /*1280x768 (GTF)*/ struct crt_mode_table CRTM1280x768[] = { /*r_rate,vclk,hsp,vsp */ /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_80_136M, M1280X768_R60_HSP, M1280X768_R60_VSP, {1680, 1280, 1280, 400, 1344, 136, 795, 768, 768, 27, 769, 3} }, {REFRESH_50, CLK_65_178M, M1280X768_R50_HSP, M1280X768_R50_VSP, {1648, 1280, 1280, 368, 1336, 128, 791, 768, 768, 23, 769, 3} } }; /* 1280x800 (CVT) */ struct crt_mode_table CRTM1280x800[] = { /* r_rate, vclk, hsp, vsp */ /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_83_375M, M1280X800_R60_HSP, M1280X800_R60_VSP, {1680, 1280, 1280, 400, 1352, 128, 831, 800, 800, 31, 803, 6} } }; /*1280x960*/ struct crt_mode_table CRTM1280x960[] = { /*r_rate,vclk,hsp,vsp */ /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_108_000M, M1280X960_R60_HSP, M1280X960_R60_VSP, {1800, 1280, 1280, 520, 1376, 112, 1000, 960, 960, 40, 961, 3} } }; /* 1280x1024*/ struct crt_mode_table CRTM1280x1024[] = { /*r_rate,vclk,,hsp,vsp */ /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_108_000M, M1280X1024_R60_HSP, M1280X1024_R60_VSP, {1688, 1280, 1280, 408, 1328, 112, 1066, 1024, 1024, 42, 1025, 3} }, {REFRESH_75, CLK_135_000M, M1280X1024_R75_HSP, M1280X1024_R75_VSP, {1688, 1280, 1280, 408, 1296, 144, 1066, 1024, 1024, 42, 1025, 3} }, {REFRESH_85, CLK_157_500M, M1280X1024_R85_HSP, M1280X1024_R85_VSP, {1728, 1280, 1280, 448, 1344, 160, 1072, 1024, 1024, 48, 1025, 3} } }; /* 1368x768 (GTF) */ struct crt_mode_table CRTM1368x768[] = { /* r_rate, vclk, hsp, vsp */ /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_85_860M, M1368X768_R60_HSP, M1368X768_R60_VSP, {1800, 1368, 1368, 432, 1440, 144, 795, 768, 768, 27, 769, 3} } }; /*1440x1050 (GTF)*/ struct crt_mode_table CRTM1440x1050[] = { /*r_rate,vclk,hsp,vsp */ /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_125_104M, M1440X1050_R60_HSP, M1440X1050_R60_VSP, {1936, 1440, 1440, 496, 1536, 152, 1077, 1040, 1040, 37, 1041, 3} } }; /* 1600x1200*/ struct crt_mode_table CRTM1600x1200[] = { /*r_rate,vclk,hsp,vsp */ /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_162_000M, M1600X1200_R60_HSP, M1600X1200_R60_VSP, {2160, 1600, 1600, 560, 1664, 192, 1250, 1200, 1200, 50, 1201, 3} }, {REFRESH_75, CLK_202_500M, M1600X1200_R75_HSP, M1600X1200_R75_VSP, {2160, 1600, 1600, 560, 1664, 192, 1250, 1200, 1200, 50, 1201, 3} } }; /* 1680x1050 (CVT) */ struct crt_mode_table CRTM1680x1050[] = { /* r_rate, vclk, hsp, vsp */ /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_146_760M, M1680x1050_R60_HSP, M1680x1050_R60_VSP, {2240, 1680, 1680, 560, 1784, 176, 1089, 1050, 1050, 39, 1053, 6} }, {REFRESH_75, CLK_187_000M, M1680x1050_R75_HSP, M1680x1050_R75_VSP, {2272, 1680, 1680, 592, 1800, 176, 1099, 1050, 1050, 49, 1053, 6} } }; /* 1680x1050 (CVT Reduce Blanking) */ struct crt_mode_table CRTM1680x1050_RB[] = { /* r_rate, vclk, hsp, vsp */ /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_119_000M, <API key>, <API key>, {1840, 1680, 1680, 160, 1728, 32, 1080, 1050, 1050, 30, 1053, 6} } }; /* 1920x1080 (CVT)*/ struct crt_mode_table CRTM1920x1080[] = { /*r_rate,vclk,hsp,vsp */ /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_172_798M, M1920X1080_R60_HSP, M1920X1080_R60_VSP, {2576, 1920, 1920, 656, 2048, 200, 1120, 1080, 1080, 40, 1083, 5} } }; /* 1920x1080 (CVT with Reduce Blanking) */ struct crt_mode_table CRTM1920x1080_RB[] = { /* r_rate, vclk, hsp, vsp */ /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_138_400M, <API key>, <API key>, {2080, 1920, 1920, 160, 1968, 32, 1111, 1080, 1080, 31, 1083, 5} } }; /* 1920x1440*/ struct crt_mode_table CRTM1920x1440[] = { /*r_rate,vclk,hsp,vsp */ /*HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_234_000M, M1920X1440_R60_HSP, M1920X1440_R60_VSP, {2600, 1920, 1920, 680, 2048, 208, 1500, 1440, 1440, 60, 1441, 3} }, {REFRESH_75, CLK_297_500M, M1920X1440_R75_HSP, M1920X1440_R75_VSP, {2640, 1920, 1920, 720, 2064, 224, 1500, 1440, 1440, 60, 1441, 3} } }; /* 1400x1050 (CVT) */ struct crt_mode_table CRTM1400x1050[] = { /* r_rate, vclk, hsp, vsp */ /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_121_750M, M1400X1050_R60_HSP, M1400X1050_R60_VSP, {1864, 1400, 1400, 464, 1488, 144, 1089, 1050, 1050, 39, 1053, 4} }, {REFRESH_75, CLK_156_000M, M1400X1050_R75_HSP, M1400X1050_R75_VSP, {1896, 1400, 1400, 496, 1504, 144, 1099, 1050, 1050, 49, 1053, 4} } }; /* 1400x1050 (CVT Reduce Blanking) */ struct crt_mode_table CRTM1400x1050_RB[] = { /* r_rate, vclk, hsp, vsp */ /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_101_000M, <API key>, <API key>, {1560, 1400, 1400, 160, 1448, 32, 1080, 1050, 1050, 30, 1053, 4} } }; /* 960x600 (CVT) */ struct crt_mode_table CRTM960x600[] = { /* r_rate, vclk, hsp, vsp */ /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_45_250M, M960X600_R60_HSP, M960X600_R60_VSP, {1216, 960, 960, 256, 992, 96, 624, 600, 600, 24, 603, 6} } }; /* 1000x600 (GTF) */ struct crt_mode_table CRTM1000x600[] = { /* r_rate, vclk, hsp, vsp */ /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_48_000M, M1000X600_R60_HSP, M1000X600_R60_VSP, {1288, 1000, 1000, 288, 1040, 104, 622, 600, 600, 22, 601, 3} } }; /* 1024x576 (GTF) */ struct crt_mode_table CRTM1024x576[] = { /* r_rate, vclk, hsp, vsp */ /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_46_996M, M1024X576_R60_HSP, M1024X576_R60_VSP, {1312, 1024, 1024, 288, 1064, 104, 597, 576, 576, 21, 577, 3} } }; /* 1088x612 (CVT) */ struct crt_mode_table CRTM1088x612[] = { /* r_rate, vclk, hsp, vsp */ /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_52_977M, M1088X612_R60_HSP, M1088X612_R60_VSP, {1392, 1088, 1088, 304, 1136, 104, 636, 612, 612, 24, 615, 5} } }; /* 1152x720 (CVT) */ struct crt_mode_table CRTM1152x720[] = { /* r_rate, vclk, hsp, vsp */ /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_66_750M, M1152X720_R60_HSP, M1152X720_R60_VSP, {1488, 1152, 1152, 336, 1208, 112, 748, 720, 720, 28, 723, 6} } }; /* 1200x720 (GTF) */ struct crt_mode_table CRTM1200x720[] = { /* r_rate, vclk, hsp, vsp */ /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_70_159M, M1200X720_R60_HSP, M1200X720_R60_VSP, {1568, 1200, 1200, 368, 1256, 128, 746, 720, 720, 26, 721, 3} } }; /* 1200x900 (DCON) */ struct crt_mode_table DCON1200x900[] = { /* r_rate, vclk, hsp, vsp */ {REFRESH_60, CLK_57_275M, M1200X900_R60_HSP, M1200X900_R60_VSP, /* The correct htotal is 1240, but this doesn't raster on VX855. */ /* Via suggested changing to a multiple of 16, hence 1264. */ /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {1264, 1200, 1200, 64, 1211, 32, 912, 900, 900, 12, 901, 10} } }; /* 1280x600 (GTF) */ struct crt_mode_table CRTM1280x600[] = { /* r_rate, vclk, hsp, vsp */ /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_61_500M, M1280x600_R60_HSP, M1280x600_R60_VSP, {1648, 1280, 1280, 368, 1336, 128, 622, 600, 600, 22, 601, 3} } }; /* 1360x768 (CVT) */ struct crt_mode_table CRTM1360x768[] = { /* r_rate, vclk, hsp, vsp */ /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_84_750M, M1360X768_R60_HSP, M1360X768_R60_VSP, {1776, 1360, 1360, 416, 1432, 136, 798, 768, 768, 30, 771, 5} } }; /* 1360x768 (CVT Reduce Blanking) */ struct crt_mode_table CRTM1360x768_RB[] = { /* r_rate, vclk, hsp, vsp */ /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_72_000M, <API key>, <API key>, {1520, 1360, 1360, 160, 1408, 32, 790, 768, 768, 22, 771, 5} } }; /* 1366x768 (GTF) */ struct crt_mode_table CRTM1366x768[] = { /* r_rate, vclk, hsp, vsp */ /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_85_860M, M1368X768_R60_HSP, M1368X768_R60_VSP, {1800, 1368, 1368, 432, 1440, 144, 795, 768, 768, 27, 769, 3} }, {REFRESH_50, CLK_69_924M, M1368X768_R50_HSP, M1368X768_R50_VSP, {1768, 1368, 1368, 400, 1424, 144, 791, 768, 768, 23, 769, 3} } }; /* 1440x900 (CVT) */ struct crt_mode_table CRTM1440x900[] = { /* r_rate, vclk, hsp, vsp */ /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_106_500M, M1440X900_R60_HSP, M1440X900_R60_VSP, {1904, 1440, 1440, 464, 1520, 152, 934, 900, 900, 34, 903, 6} }, {REFRESH_75, CLK_136_700M, M1440X900_R75_HSP, M1440X900_R75_VSP, {1936, 1440, 1440, 496, 1536, 152, 942, 900, 900, 42, 903, 6} } }; /* 1440x900 (CVT Reduce Blanking) */ struct crt_mode_table CRTM1440x900_RB[] = { /* r_rate, vclk, hsp, vsp */ /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_88_750M, <API key>, <API key>, {1600, 1440, 1440, 160, 1488, 32, 926, 900, 900, 26, 903, 6} } }; /* 1600x900 (CVT) */ struct crt_mode_table CRTM1600x900[] = { /* r_rate, vclk, hsp, vsp */ /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_118_840M, M1600X900_R60_HSP, M1600X900_R60_VSP, {2112, 1600, 1600, 512, 1688, 168, 934, 900, 900, 34, 903, 5} } }; /* 1600x900 (CVT Reduce Blanking) */ struct crt_mode_table CRTM1600x900_RB[] = { /* r_rate, vclk, hsp, vsp */ /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_97_750M, <API key>, <API key>, {1760, 1600, 1600, 160, 1648, 32, 926, 900, 900, 26, 903, 5} } }; /* 1600x1024 (GTF) */ struct crt_mode_table CRTM1600x1024[] = { /* r_rate, vclk, hsp, vsp */ /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_136_700M, M1600X1024_R60_HSP, M1600X1024_R60_VSP, {2144, 1600, 1600, 544, 1704, 168, 1060, 1024, 1024, 36, 1025, 3} } }; /* 1792x1344 (DMT) */ struct crt_mode_table CRTM1792x1344[] = { /* r_rate, vclk, hsp, vsp */ /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_204_000M, M1792x1344_R60_HSP, M1792x1344_R60_VSP, {2448, 1792, 1792, 656, 1920, 200, 1394, 1344, 1344, 50, 1345, 3} } }; /* 1856x1392 (DMT) */ struct crt_mode_table CRTM1856x1392[] = { /* r_rate, vclk, hsp, vsp */ /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_218_500M, M1856x1392_R60_HSP, M1856x1392_R60_VSP, {2528, 1856, 1856, 672, 1952, 224, 1439, 1392, 1392, 47, 1393, 3} } }; /* 1920x1200 (CVT) */ struct crt_mode_table CRTM1920x1200[] = { /* r_rate, vclk, hsp, vsp */ /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_193_295M, M1920X1200_R60_HSP, M1920X1200_R60_VSP, {2592, 1920, 1920, 672, 2056, 200, 1245, 1200, 1200, 45, 1203, 6} } }; /* 1920x1200 (CVT with Reduce Blanking) */ struct crt_mode_table CRTM1920x1200_RB[] = { /* r_rate, vclk, hsp, vsp */ /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_153_920M, <API key>, <API key>, {2080, 1920, 1920, 160, 1968, 32, 1235, 1200, 1200, 35, 1203, 6} } }; /* 2048x1536 (CVT) */ struct crt_mode_table CRTM2048x1536[] = { /* r_rate, vclk, hsp, vsp */ /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {REFRESH_60, CLK_267_250M, M2048x1536_R60_HSP, M2048x1536_R60_VSP, {2800, 2048, 2048, 752, 2200, 224, 1592, 1536, 1536, 56, 1539, 4} } }; struct VideoModeTable viafb_modes[] = { /* Display : 480x640 (GTF) */ {CRTM480x640, ARRAY_SIZE(CRTM480x640)}, /* Display : 640x480 */ {CRTM640x480, ARRAY_SIZE(CRTM640x480)}, /* Display : 720x480 (GTF) */ {CRTM720x480, ARRAY_SIZE(CRTM720x480)}, /* Display : 720x576 (GTF) */ {CRTM720x576, ARRAY_SIZE(CRTM720x576)}, /* Display : 800x600 */ {CRTM800x600, ARRAY_SIZE(CRTM800x600)}, /* Display : 800x480 (CVT) */ {CRTM800x480, ARRAY_SIZE(CRTM800x480)}, /* Display : 848x480 (CVT) */ {CRTM848x480, ARRAY_SIZE(CRTM848x480)}, /* Display : 852x480 (GTF) */ {CRTM852x480, ARRAY_SIZE(CRTM852x480)}, /* Display : 1024x512 (GTF) */ {CRTM1024x512, ARRAY_SIZE(CRTM1024x512)}, /* Display : 1024x600 */ {CRTM1024x600, ARRAY_SIZE(CRTM1024x600)}, /* Display : 1024x768 */ {CRTM1024x768, ARRAY_SIZE(CRTM1024x768)}, /* Display : 1152x864 */ {CRTM1152x864, ARRAY_SIZE(CRTM1152x864)}, /* Display : 1280x768 (GTF) */ {CRTM1280x768, ARRAY_SIZE(CRTM1280x768)}, /* Display : 960x600 (CVT) */ {CRTM960x600, ARRAY_SIZE(CRTM960x600)}, /* Display : 1000x600 (GTF) */ {CRTM1000x600, ARRAY_SIZE(CRTM1000x600)}, /* Display : 1024x576 (GTF) */ {CRTM1024x576, ARRAY_SIZE(CRTM1024x576)}, /* Display : 1088x612 (GTF) */ {CRTM1088x612, ARRAY_SIZE(CRTM1088x612)}, /* Display : 1152x720 (CVT) */ {CRTM1152x720, ARRAY_SIZE(CRTM1152x720)}, /* Display : 1200x720 (GTF) */ {CRTM1200x720, ARRAY_SIZE(CRTM1200x720)}, /* Display : 1200x900 (DCON) */ {DCON1200x900, ARRAY_SIZE(DCON1200x900)}, /* Display : 1280x600 (GTF) */ {CRTM1280x600, ARRAY_SIZE(CRTM1280x600)}, /* Display : 1280x800 (CVT) */ {CRTM1280x800, ARRAY_SIZE(CRTM1280x800)}, /* Display : 1280x960 */ {CRTM1280x960, ARRAY_SIZE(CRTM1280x960)}, /* Display : 1280x1024 */ {CRTM1280x1024, ARRAY_SIZE(CRTM1280x1024)}, /* Display : 1360x768 (CVT) */ {CRTM1360x768, ARRAY_SIZE(CRTM1360x768)}, /* Display : 1366x768 */ {CRTM1366x768, ARRAY_SIZE(CRTM1366x768)}, /* Display : 1368x768 (GTF) */ {CRTM1368x768, ARRAY_SIZE(CRTM1368x768)}, /* Display : 1440x900 (CVT) */ {CRTM1440x900, ARRAY_SIZE(CRTM1440x900)}, /* Display : 1440x1050 (GTF) */ {CRTM1440x1050, ARRAY_SIZE(CRTM1440x1050)}, /* Display : 1600x900 (CVT) */ {CRTM1600x900, ARRAY_SIZE(CRTM1600x900)}, /* Display : 1600x1024 (GTF) */ {CRTM1600x1024, ARRAY_SIZE(CRTM1600x1024)}, /* Display : 1600x1200 */ {CRTM1600x1200, ARRAY_SIZE(CRTM1600x1200)}, /* Display : 1680x1050 (CVT) */ {CRTM1680x1050, ARRAY_SIZE(CRTM1680x1050)}, /* Display : 1792x1344 (DMT) */ {CRTM1792x1344, ARRAY_SIZE(CRTM1792x1344)}, /* Display : 1856x1392 (DMT) */ {CRTM1856x1392, ARRAY_SIZE(CRTM1856x1392)}, /* Display : 1920x1440 */ {CRTM1920x1440, ARRAY_SIZE(CRTM1920x1440)}, /* Display : 2048x1536 */ {CRTM2048x1536, ARRAY_SIZE(CRTM2048x1536)}, /* Display : 1280x720 */ {CRTM1280x720, ARRAY_SIZE(CRTM1280x720)}, /* Display : 1920x1080 (CVT) */ {CRTM1920x1080, ARRAY_SIZE(CRTM1920x1080)}, /* Display : 1920x1200 (CVT) */ {CRTM1920x1200, ARRAY_SIZE(CRTM1920x1200)}, /* Display : 1400x1050 (CVT) */ {CRTM1400x1050, ARRAY_SIZE(CRTM1400x1050)} }; struct VideoModeTable viafb_rb_modes[] = { /* Display : 1360x768 (CVT Reduce Blanking) */ {CRTM1360x768_RB, ARRAY_SIZE(CRTM1360x768_RB)}, /* Display : 1440x900 (CVT Reduce Blanking) */ {CRTM1440x900_RB, ARRAY_SIZE(CRTM1440x900_RB)}, /* Display : 1400x1050 (CVT Reduce Blanking) */ {CRTM1400x1050_RB, ARRAY_SIZE(CRTM1400x1050_RB)}, /* Display : 1600x900 (CVT Reduce Blanking) */ {CRTM1600x900_RB, ARRAY_SIZE(CRTM1600x900_RB)}, /* Display : 1680x1050 (CVT Reduce Blanking) */ {CRTM1680x1050_RB, ARRAY_SIZE(CRTM1680x1050_RB)}, /* Display : 1920x1080 (CVT Reduce Blanking) */ {CRTM1920x1080_RB, ARRAY_SIZE(CRTM1920x1080_RB)}, /* Display : 1920x1200 (CVT Reduce Blanking) */ {CRTM1920x1200_RB, ARRAY_SIZE(CRTM1920x1200_RB)} }; struct crt_mode_table CEAM1280x720[] = { {REFRESH_60, CLK_74_270M, <API key>, <API key>, /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {1650, 1280, 1280, 370, 1390, 40, 750, 720, 720, 30, 725, 5} } }; struct crt_mode_table CEAM1920x1080[] = { {REFRESH_60, CLK_148_500M, <API key>, <API key>, /* HT, HA, HBS, HBE, HSS, HSE, VT, VA, VBS, VBE, VSS, VSE */ {2200, 1920, 1920, 300, 2008, 44, 1125, 1080, 1080, 45, 1084, 5} } }; struct VideoModeTable CEA_HDMI_Modes[] = { /* Display : 1280x720 */ {CEAM1280x720, ARRAY_SIZE(CEAM1280x720)}, {CEAM1920x1080, ARRAY_SIZE(CEAM1920x1080)} }; int <API key> = ARRAY_SIZE(res_map_refresh_tbl); int NUM_TOTAL_CEA_MODES = ARRAY_SIZE(CEA_HDMI_Modes); int <API key> = ARRAY_SIZE(CN400_ModeXregs); int <API key> = ARRAY_SIZE(CN700_ModeXregs); int <API key> = ARRAY_SIZE(KM400_ModeXregs); int <API key> = ARRAY_SIZE(CX700_ModeXregs); int <API key> = ARRAY_SIZE(VX855_ModeXregs); int <API key> = ARRAY_SIZE(CLE266_ModeXregs); int <API key> = ARRAY_SIZE(res_patch_table); struct VideoModeTable *viafb_get_mode(int hres, int vres) { u32 i; for (i = 0; i < ARRAY_SIZE(viafb_modes); i++) if (viafb_modes[i].mode_array && viafb_modes[i].crtc[0].crtc.hor_addr == hres && viafb_modes[i].crtc[0].crtc.ver_addr == vres) return &viafb_modes[i]; return NULL; } struct VideoModeTable *viafb_get_rb_mode(int hres, int vres) { u32 i; for (i = 0; i < ARRAY_SIZE(viafb_rb_modes); i++) if (viafb_rb_modes[i].mode_array && viafb_rb_modes[i].crtc[0].crtc.hor_addr == hres && viafb_rb_modes[i].crtc[0].crtc.ver_addr == vres) return &viafb_rb_modes[i]; return NULL; }
#include <linux/cache.h> #include <linux/spinlock.h> #include <linux/threads.h> #include <linux/cpumask.h> #include <linux/seqlock.h> /* * Define shape of hierarchy based on NR_CPUS and CONFIG_RCU_FANOUT. * In theory, it should be possible to add more levels straightforwardly. * In practice, this did work well going from three levels to four. * Of course, your mileage may vary. */ #define MAX_RCU_LVLS 4 #if CONFIG_RCU_FANOUT > 16 #define RCU_FANOUT_LEAF 16 #else /* #if CONFIG_RCU_FANOUT > 16 */ #define RCU_FANOUT_LEAF (CONFIG_RCU_FANOUT) #endif /* #else #if CONFIG_RCU_FANOUT > 16 */ #define RCU_FANOUT_1 (RCU_FANOUT_LEAF) #define RCU_FANOUT_2 (RCU_FANOUT_1 * CONFIG_RCU_FANOUT) #define RCU_FANOUT_3 (RCU_FANOUT_2 * CONFIG_RCU_FANOUT) #define RCU_FANOUT_4 (RCU_FANOUT_3 * CONFIG_RCU_FANOUT) #if NR_CPUS <= RCU_FANOUT_1 # define NUM_RCU_LVLS 1 # define NUM_RCU_LVL_0 1 # define NUM_RCU_LVL_1 (NR_CPUS) # define NUM_RCU_LVL_2 0 # define NUM_RCU_LVL_3 0 # define NUM_RCU_LVL_4 0 #elif NR_CPUS <= RCU_FANOUT_2 # define NUM_RCU_LVLS 2 # define NUM_RCU_LVL_0 1 # define NUM_RCU_LVL_1 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_1) # define NUM_RCU_LVL_2 (NR_CPUS) # define NUM_RCU_LVL_3 0 # define NUM_RCU_LVL_4 0 #elif NR_CPUS <= RCU_FANOUT_3 # define NUM_RCU_LVLS 3 # define NUM_RCU_LVL_0 1 # define NUM_RCU_LVL_1 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_2) # define NUM_RCU_LVL_2 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_1) # define NUM_RCU_LVL_3 (NR_CPUS) # define NUM_RCU_LVL_4 0 #elif NR_CPUS <= RCU_FANOUT_4 # define NUM_RCU_LVLS 4 # define NUM_RCU_LVL_0 1 # define NUM_RCU_LVL_1 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_3) # define NUM_RCU_LVL_2 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_2) # define NUM_RCU_LVL_3 DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_1) # define NUM_RCU_LVL_4 (NR_CPUS) #else # error "CONFIG_RCU_FANOUT insufficient for NR_CPUS" #endif /* #if (NR_CPUS) <= RCU_FANOUT_1 */ #define RCU_SUM (NUM_RCU_LVL_0 + NUM_RCU_LVL_1 + NUM_RCU_LVL_2 + NUM_RCU_LVL_3 + NUM_RCU_LVL_4) #define NUM_RCU_NODES (RCU_SUM - NR_CPUS) /* * Dynticks per-CPU state. */ struct rcu_dynticks { long long dynticks_nesting; /* Track irq/process nesting level. */ /* Process level is worth LLONG_MAX/2. */ int <API key>; /* Track NMI nesting level. */ atomic_t dynticks; /* Even value for idle, else odd. */ }; /* RCU's kthread states for tracing. */ #define RCU_KTHREAD_STOPPED 0 #define RCU_KTHREAD_RUNNING 1 #define RCU_KTHREAD_WAITING 2 #define RCU_KTHREAD_OFFCPU 3 #define <API key> 4 #define RCU_KTHREAD_MAX 4 /* * Definition for node within the RCU <API key> hierarchy. */ struct rcu_node { raw_spinlock_t lock; /* Root rcu_node's lock protects some */ /* rcu_state fields as well as following. */ unsigned long gpnum; /* Current grace period for this node. */ /* This will either be equal to or one */ /* behind the root rcu_node's gpnum. */ unsigned long completed; /* Last GP completed for this node. */ /* This will either be equal to or one */ /* behind the root rcu_node's gpnum. */ unsigned long qsmask; /* CPUs or groups that need to switch in */ /* order for current grace period to proceed.*/ /* In leaf rcu_node, each bit corresponds to */ /* an rcu_data structure, otherwise, each */ /* bit corresponds to a child rcu_node */ /* structure. */ unsigned long expmask; /* Groups that have ->blkd_tasks */ /* elements that need to drain to allow the */ /* current expedited grace period to */ /* complete (only for TREE_PREEMPT_RCU). */ atomic_t wakemask; /* CPUs whose kthread needs to be awakened. */ /* Since this has meaning only for leaf */ /* rcu_node structures, 32 bits suffices. */ unsigned long qsmaskinit; /* Per-GP initial value for qsmask & expmask. */ unsigned long grpmask; /* Mask to apply to parent qsmask. */ /* Only one bit will be set in this mask. */ int grplo; /* lowest-numbered CPU or group here. */ int grphi; /* highest-numbered CPU or group here. */ u8 grpnum; /* CPU/group number for next level up. */ u8 level; /* root is at level 0. */ struct rcu_node *parent; struct list_head blkd_tasks; /* Tasks blocked in RCU read-side critical */ /* section. Tasks are placed at the head */ /* of this list and age towards the tail. */ struct list_head *gp_tasks; /* Pointer to the first task blocking the */ /* current grace period, or NULL if there */ /* is no such task. */ struct list_head *exp_tasks; /* Pointer to the first task blocking the */ /* current expedited grace period, or NULL */ /* if there is no such task. If there */ /* is no current expedited grace period, */ /* then there can cannot be any such task. */ #ifdef CONFIG_RCU_BOOST struct list_head *boost_tasks; /* Pointer to first task that needs to be */ /* priority boosted, or NULL if no priority */ /* boosting is needed for this rcu_node */ /* structure. If there are no tasks */ /* queued on this rcu_node structure that */ /* are blocking the current grace period, */ /* there can be no such task. */ unsigned long boost_time; /* When to start boosting (jiffies). */ struct task_struct *boost_kthread_task; /* kthread that takes care of priority */ /* boosting for this rcu_node structure. */ unsigned int <API key>; /* State of boost_kthread_task for tracing. */ unsigned long n_tasks_boosted; /* Total number of tasks boosted. */ unsigned long n_exp_boosts; /* Number of tasks boosted for expedited GP. */ unsigned long n_normal_boosts; /* Number of tasks boosted for normal GP. */ unsigned long n_balk_blkd_tasks; /* Refused to boost: no blocked tasks. */ unsigned long n_balk_exp_gp_tasks; /* Refused to boost: nothing blocking GP. */ unsigned long n_balk_boost_tasks; /* Refused to boost: already boosting. */ unsigned long n_balk_notblocked; /* Refused to boost: RCU RS CS still running. */ unsigned long n_balk_notyet; /* Refused to boost: not yet time. */ unsigned long n_balk_nos; /* Refused to boost: not sure why, though. */ /* This can happen due to race conditions. */ #endif /* #ifdef CONFIG_RCU_BOOST */ struct task_struct *node_kthread_task; /* kthread that takes care of this rcu_node */ /* structure, for example, awakening the */ /* per-CPU kthreads as needed. */ unsigned int node_kthread_status; /* State of node_kthread_task for tracing. */ } <API key>; /* * Do a full breadth-first scan of the rcu_node structures for the * specified rcu_state structure. */ #define <API key>(rsp, rnp) \ for ((rnp) = &(rsp)->node[0]; \ (rnp) < &(rsp)->node[NUM_RCU_NODES]; (rnp)++) /* * Do a breadth-first scan of the non-leaf rcu_node structures for the * specified rcu_state structure. Note that if there is a singleton * rcu_node tree with but one rcu_node structure, this loop is a no-op. */ #define <API key>(rsp, rnp) \ for ((rnp) = &(rsp)->node[0]; \ (rnp) < (rsp)->level[NUM_RCU_LVLS - 1]; (rnp)++) /* * Scan the leaves of the rcu_node hierarchy for the specified rcu_state * structure. Note that if there is a singleton rcu_node tree with but * one rcu_node structure, this loop -will- visit the rcu_node structure. * It is still a leaf node, even if it is also the root node. */ #define <API key>(rsp, rnp) \ for ((rnp) = (rsp)->level[NUM_RCU_LVLS - 1]; \ (rnp) < &(rsp)->node[NUM_RCU_NODES]; (rnp)++) /* Index values for nxttail array in struct rcu_data. */ #define RCU_DONE_TAIL 0 /* Also RCU_WAIT head. */ #define RCU_WAIT_TAIL 1 /* Also RCU_NEXT_READY head. */ #define RCU_NEXT_READY_TAIL 2 /* Also RCU_NEXT head. */ #define RCU_NEXT_TAIL 3 #define RCU_NEXT_SIZE 4 /* Per-CPU data for read-copy update. */ struct rcu_data { /* 1) quiescent-state and grace-period handling : */ unsigned long completed; /* Track rsp->completed gp number */ /* in order to detect GP end. */ unsigned long gpnum; /* Highest gp number that this CPU */ /* is aware of having started. */ unsigned long <API key>; /* gpnum at time of quiescent state. */ bool passed_quiesce; /* User-mode/idle loop etc. */ bool qs_pending; /* Core waits for quiesc state. */ bool beenonline; /* CPU online at least once. */ bool preemptible; /* Preemptible RCU? */ struct rcu_node *mynode; /* This CPU's leaf of hierarchy */ unsigned long grpmask; /* Mask to apply to leaf qsmask. */ #ifdef <API key> unsigned long ticks_this_gp; /* The number of scheduling-clock */ /* ticks this CPU has handled */ /* during and after the last grace */ /* period it is aware of. */ #endif /* #ifdef <API key> */ /* 2) batch handling */ /* * If nxtlist is not NULL, it is partitioned as follows. * Any of the partitions might be empty, in which case the * pointer to that partition will be equal to the pointer for * the following partition. When the list is empty, all of * the nxttail elements point to the ->nxtlist pointer itself, * which in that case is NULL. * * [nxtlist, *nxttail[RCU_DONE_TAIL]): * Entries that batch # <= ->completed * The grace period for these entries has completed, and * the other <API key> entries may be moved * here temporarily in <API key>(). * [*nxttail[RCU_DONE_TAIL], *nxttail[RCU_WAIT_TAIL]): * Entries that batch # <= ->completed - 1: waiting for current GP * [*nxttail[RCU_WAIT_TAIL], *nxttail[RCU_NEXT_READY_TAIL]): * Entries known to have arrived before current GP ended * [*nxttail[RCU_NEXT_READY_TAIL], *nxttail[RCU_NEXT_TAIL]): * Entries that might have arrived after current GP ended * Note that the value of *nxttail[RCU_NEXT_TAIL] will * always be NULL, as this is the end of the list. */ struct rcu_head *nxtlist; struct rcu_head **nxttail[RCU_NEXT_SIZE]; long qlen_lazy; /* # of lazy queued callbacks */ long qlen; /* # of queued callbacks, incl lazy */ long qlen_last_fqs_check; /* qlen at last check for QS forcing */ unsigned long n_cbs_invoked; /* count of RCU cbs invoked. */ unsigned long n_cbs_orphaned; /* RCU cbs orphaned by dying CPU */ unsigned long n_cbs_adopted; /* RCU cbs adopted from dying CPU */ unsigned long n_force_qs_snap; /* did other CPU force QS recently? */ long blimit; /* Upper limit on a processed batch */ /* 3) dynticks interface. */ struct rcu_dynticks *dynticks; /* Shared per-CPU dynticks state. */ int dynticks_snap; /* Per-GP tracking for dynticks. */ /* 4) reasons this CPU needed to be kicked by <API key> */ unsigned long dynticks_fqs; /* Kicked due to dynticks idle. */ unsigned long offline_fqs; /* Kicked due to being offline. */ /* 5) __rcu_pending() statistics. */ unsigned long n_rcu_pending; /* rcu_pending() calls since boot. */ unsigned long n_rp_qs_pending; unsigned long n_rp_report_qs; unsigned long n_rp_cb_ready; unsigned long n_rp_cpu_needs_gp; unsigned long n_rp_gp_completed; unsigned long n_rp_gp_started; unsigned long n_rp_need_fqs; unsigned long n_rp_need_nothing; int cpu; struct rcu_state *rsp; }; /* Values for fqs_state field in struct rcu_state. */ #define RCU_GP_IDLE 0 /* No grace period in progress. */ #define RCU_GP_INIT 1 /* Grace period being initialized. */ #define RCU_SAVE_DYNTICK 2 /* Need to scan dyntick state. */ #define RCU_FORCE_QS 3 /* Need to force quiescent state. */ #define RCU_SIGNAL_INIT RCU_SAVE_DYNTICK #define <API key> 3 /* for rsp->jiffies_force_qs */ #ifdef CONFIG_PROVE_RCU #define <API key> (5 * HZ) #else #define <API key> 0 #endif #define RCU_STALL_RAT_DELAY 2 /* Allow other CPUs time */ /* to take at least one */ /* scheduling clock irq */ /* before ratting on them. */ #define rcu_wait(cond) \ do { \ for (;;) { \ set_current_state(TASK_INTERRUPTIBLE); \ if (cond) \ break; \ schedule(); \ } \ __set_current_state(TASK_RUNNING); \ } while (0) /* * RCU global state, including node hierarchy. This hierarchy is * represented in "heap" form in a dense array. The root (first level) * of the hierarchy is in ->node[0] (referenced by ->level[0]), the second * level in ->node[1] through ->node[m] (->node[1] referenced by ->level[1]), * and the third level in ->node[m+1] and following (->node[m+1] referenced * by ->level[2]). The number of levels is determined by the number of * CPUs and by CONFIG_RCU_FANOUT. Small systems will have a "hierarchy" * consisting of a single rcu_node. */ struct rcu_state { struct rcu_node node[NUM_RCU_NODES]; /* Hierarchy. */ struct rcu_node *level[NUM_RCU_LVLS]; /* Hierarchy levels. */ u32 levelcnt[MAX_RCU_LVLS + 1]; /* # nodes in each level. */ u8 levelspread[NUM_RCU_LVLS]; /* kids/node in each level. */ struct rcu_data __percpu *rda; /* pointer of percu rcu_data. */ /* The following fields are guarded by the root rcu_node's lock. */ u8 fqs_state <API key>; /* Force QS state. */ u8 fqs_active; /* <API key>() */ /* is running. */ u8 fqs_need_gp; /* A CPU was prevented from */ /* starting a new grace */ /* period because */ /* <API key>() */ /* was running. */ u8 boost; /* Subject to priority boost. */ unsigned long gpnum; /* Current gp number. */ unsigned long completed; /* # of last completed gp. */ /* End of fields guarded by root rcu_node's lock. */ raw_spinlock_t onofflock; /* exclude on/offline and */ /* starting new GP. */ raw_spinlock_t fqslock; /* Only one task forcing */ /* quiescent states. */ unsigned long jiffies_force_qs; /* Time at which to invoke */ /* <API key>(). */ unsigned long n_force_qs; /* Number of calls to */ /* <API key>(). */ unsigned long n_force_qs_lh; /* ~Number of calls leaving */ /* due to lock unavailable. */ unsigned long n_force_qs_ngp; /* Number of calls leaving */ /* due to no GP active. */ unsigned long gp_start; /* Time at which GP started, */ /* but in jiffies. */ unsigned long jiffies_stall; /* Time at which to check */ /* for CPU stalls. */ unsigned long gp_max; /* Maximum GP duration in */ /* jiffies. */ char *name; /* Name of structure. */ }; /* Return values for <API key>(). */ #define <API key> 0x1 /* Tasks blocking normal */ /* GP were moved to root. */ #define <API key> 0x2 /* Tasks blocking expedited */ /* GP were moved to root. */ /* * RCU implementation internal declarations: */ extern struct rcu_state rcu_sched_state; DECLARE_PER_CPU(struct rcu_data, rcu_sched_data); extern struct rcu_state rcu_bh_state; DECLARE_PER_CPU(struct rcu_data, rcu_bh_data); #ifdef <API key> extern struct rcu_state rcu_preempt_state; DECLARE_PER_CPU(struct rcu_data, rcu_preempt_data); #endif /* #ifdef <API key> */ #ifdef CONFIG_RCU_BOOST DECLARE_PER_CPU(unsigned int, <API key>); DECLARE_PER_CPU(int, rcu_cpu_kthread_cpu); DECLARE_PER_CPU(unsigned int, <API key>); DECLARE_PER_CPU(char, rcu_cpu_has_work); #endif /* #ifdef CONFIG_RCU_BOOST */ #ifndef RCU_TREE_NONCORE /* Forward declarations for rcutree_plugin.h */ static void rcu_bootup_announce(void); long <API key>(void); static void <API key>(int cpu); static int <API key>(struct rcu_node *rnp); #ifdef CONFIG_HOTPLUG_CPU static void <API key>(struct rcu_node *rnp, unsigned long flags); static void <API key>(int cpu); #endif /* #ifdef CONFIG_HOTPLUG_CPU */ static void <API key>(struct rcu_state *rsp); static int <API key>(struct rcu_node *rnp); static void <API key>(void); static void <API key>(struct rcu_node *rnp); #ifdef CONFIG_HOTPLUG_CPU static int <API key>(struct rcu_state *rsp, struct rcu_node *rnp, struct rcu_data *rdp); #endif /* #ifdef CONFIG_HOTPLUG_CPU */ static void <API key>(int cpu); static void <API key>(int cpu); static void <API key>(void); void call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu)); #if defined(CONFIG_HOTPLUG_CPU) || defined(<API key>) static void rcu_report_exp_rnp(struct rcu_state *rsp, struct rcu_node *rnp, bool wake); #endif /* #if defined(CONFIG_HOTPLUG_CPU) || defined(<API key>) */ static int rcu_preempt_pending(int cpu); static int <API key>(int cpu); static void __cpuinit <API key>(int cpu); static void <API key>(void); static void __init __rcu_init_preempt(void); static void rcu_initiate_boost(struct rcu_node *rnp, unsigned long flags); static void <API key>(struct rcu_node *rnp); static void <API key>(void); static bool <API key>(void); #ifdef CONFIG_RCU_BOOST static void <API key>(void); static void <API key>(struct rcu_node *rnp, cpumask_var_t cm); static int __cpuinit <API key>(struct rcu_state *rsp, struct rcu_node *rnp, int rnp_index); static void <API key>(struct rcu_node *rnp); static void rcu_yield(void (*f)(unsigned long), unsigned long arg); #endif /* #ifdef CONFIG_RCU_BOOST */ static void <API key>(int cpu, int to_rt); static void __cpuinit <API key>(int cpu); static void <API key>(int cpu); static void <API key>(int cpu); static void <API key>(int cpu); static void <API key>(void); static void <API key>(struct rcu_state *rsp, int cpu); static void <API key>(void); static void <API key>(struct rcu_data *rdp); static void <API key>(void); #endif /* #ifndef RCU_TREE_NONCORE */
metric_suffix(42) metric_suffix(999) // 999 metric_suffix(1000) // 1.0k metric_suffix(1234, 2) // 1.2k metric_suffix(12345, 2) // 12k metric_suffix(123456, 2) // 123k metric_suffix(1234, 3) // 1.23k metric_suffix(12345, 3) // 12.3k metric_suffix(123456, 3) // 123k metric_suffix(1234, 4) // 1.234k metric_suffix(12345, 4) // 12.35k metric_suffix(123456, 4) // 123.5k metric_suffix(986725) // 987k metric_suffix(986725, 4) // 986.7k metric_suffix(986725123) // 987M metric_suffix(986725123, 5) // 986.73M
#define FLT_ROUNDS 1 #ifdef __FLT_EVAL_METHOD__ #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ #else #define FLT_EVAL_METHOD 0 #endif #define LDBL_TRUE_MIN 3.<API key> #define LDBL_MIN 3.<API key> #define LDBL_MAX 1.<API key>+4932L #define LDBL_EPSILON 1.<API key> #define LDBL_MANT_DIG 64 #define LDBL_MIN_EXP (-16381) #define LDBL_MAX_EXP 16384 #define LDBL_DIG 18 #define LDBL_MIN_10_EXP (-4931) #define LDBL_MAX_10_EXP 4932 #define DECIMAL_DIG 21
# 1. DocType / Schema Changes If you are in `developer_mode`, the `.json` files for each **DocType** are automatically updated. When you update in your production using `--latest` or `bench update`, these changes are updated in the site's schema too! Permissions do not get updated because the user may have changed them. To update permissions, you can add a new patch in the `patches.txt` of your app. execute:frappe.permissions.reset_perms("[docype]") <!-- markdown -->
<?php if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } require_once ABSPATH . 'wp-admin/includes/admin.php'; class WC_API_Server { const METHOD_GET = 1; const METHOD_POST = 2; const METHOD_PUT = 4; const METHOD_PATCH = 8; const METHOD_DELETE = 16; const READABLE = 1; // GET const CREATABLE = 2; // POST const EDITABLE = 14; // POST | PUT | PATCH const DELETABLE = 16; // DELETE const ALLMETHODS = 31; // GET | POST | PUT | PATCH | DELETE /** * Does the endpoint accept a raw request body? */ const ACCEPT_RAW_DATA = 64; /** Does the endpoint accept a request body? (either JSON or XML) */ const ACCEPT_DATA = 128; /** * Should we hide this endpoint from the index? */ const HIDDEN_ENDPOINT = 256; /** * Map of HTTP verbs to constants * @var array */ public static $method_map = array( 'HEAD' => self::METHOD_GET, 'GET' => self::METHOD_GET, 'POST' => self::METHOD_POST, 'PUT' => self::METHOD_PUT, 'PATCH' => self::METHOD_PATCH, 'DELETE' => self::METHOD_DELETE, ); /** * Requested path (relative to the API root, wp-json.php) * * @var string */ public $path = ''; /** * Requested method (GET/HEAD/POST/PUT/PATCH/DELETE) * * @var string */ public $method = 'HEAD'; /** * Request parameters * * This acts as an abstraction of the superglobals * (GET => $_GET, POST => $_POST) * * @var array */ public $params = array( 'GET' => array(), 'POST' => array() ); /** * Request headers * * @var array */ public $headers = array(); /** * Request files (matches $_FILES) * * @var array */ public $files = array(); /** * Request/Response handler, either JSON by default * or XML if requested by client * * @var WC_API_Handler */ public $handler; /** * Setup class and set request/response handler * * @since 2.1 * @param $path */ public function __construct( $path ) { if ( empty( $path ) ) { if ( isset( $_SERVER['PATH_INFO'] ) ) { $path = $_SERVER['PATH_INFO']; } else { $path = '/'; } } $this->path = $path; $this->method = $_SERVER['REQUEST_METHOD']; $this->params['GET'] = $_GET; $this->params['POST'] = $_POST; $this->headers = $this->get_headers( $_SERVER ); $this->files = $_FILES; // Compatibility for clients that can't use PUT/PATCH/DELETE if ( isset( $_GET['_method'] ) ) { $this->method = strtoupper( $_GET['_method'] ); } elseif ( isset( $_SERVER['<API key>'] ) ) { $this->method = $_SERVER['<API key>']; } // load response handler $handler_class = apply_filters( '<API key>', 'WC_API_JSON_Handler', $this->path, $this ); $this->handler = new $handler_class(); } /** * Check authentication for the request * * @since 2.1 * @return WP_User|WP_Error WP_User object indicates successful login, WP_Error indicates unsuccessful login */ public function <API key>() { // allow plugins to remove default authentication or add their own authentication $user = apply_filters( '<API key>', null, $this ); if ( is_a( $user, 'WP_User' ) ) { // API requests run under the context of the authenticated user wp_set_current_user( $user->ID ); } elseif ( ! is_wp_error( $user ) ) { // WP_Errors are handled in serve_request() $user = new WP_Error( 'woocommerce_api_<API key>, __( 'Invalid authentication method', 'woocommerce' ), array( 'code' => 500 ) ); } return $user; } /** * Convert an error to an array * * This iterates over all error codes and messages to change it into a flat * array. This enables simpler client behaviour, as it is represented as a * list in JSON rather than an object/map * * @since 2.1 * @param WP_Error $error * @return array List of associative arrays with code and message keys */ protected function error_to_array( $error ) { $errors = array(); foreach ( (array) $error->errors as $code => $messages ) { foreach ( (array) $messages as $message ) { $errors[] = array( 'code' => $code, 'message' => $message ); } } return array( 'errors' => $errors ); } /** * Handle serving an API request * * Matches the current server URI to a route and runs the first matching * callback then outputs a JSON representation of the returned value. * * @since 2.1 * @uses WC_API_Server::dispatch() */ public function serve_request() { do_action( '<API key>', $this ); $this->header( 'Content-Type', $this->handler->get_content_type(), true ); // the API is enabled by default if ( ! apply_filters( '<API key>', true, $this ) || ( 'no' === get_option( '<API key>' ) ) ) { $this->send_status( 404 ); echo $this->handler->generate_response( array( 'errors' => array( 'code' => '<API key>', 'message' => 'The WooCommerce API is disabled on this site' ) ) ); return; } $result = $this-><API key>(); // if authorization check was successful, dispatch the request if ( ! is_wp_error( $result ) ) { $result = $this->dispatch(); } // handle any dispatch errors if ( is_wp_error( $result ) ) { $data = $result->get_error_data(); if ( is_array( $data ) && isset( $data['status'] ) ) { $this->send_status( $data['status'] ); } $result = $this->error_to_array( $result ); } // This is a filter rather than an action, since this is designed to be // re-entrant if needed $served = apply_filters( '<API key>', false, $result, $this ); if ( ! $served ) { if ( 'HEAD' === $this->method ) { return; } echo $this->handler->generate_response( $result ); } } /** * Retrieve the route map * * The route map is an associative array with path regexes as the keys. The * value is an indexed array with the callback function/method as the first * item, and a bitmask of HTTP methods as the second item (see the class * constants). * * Each route can be mapped to more than one callback by using an array of * the indexed arrays. This allows mapping e.g. GET requests to one callback * and POST requests to another. * * Note that the path regexes (array keys) must have @ escaped, as this is * used as the delimiter with preg_match() * * @since 2.1 * @return array `'/path/regex' => array( $callback, $bitmask )` or `'/path/regex' => array( array( $callback, $bitmask ), ...)` */ public function get_routes() { // index added by default $endpoints = array( '/' => array( array( $this, 'get_index' ), self::READABLE ), ); $endpoints = apply_filters( '<API key>', $endpoints ); // Normalise the endpoints foreach ( $endpoints as $route => &$handlers ) { if ( count( $handlers ) <= 2 && isset( $handlers[1] ) && ! is_array( $handlers[1] ) ) { $handlers = array( $handlers ); } } return $endpoints; } /** * Match the request to a callback and call it * * @since 2.1 * @return mixed The value returned by the callback, or a WP_Error instance */ public function dispatch() { switch ( $this->method ) { case 'HEAD' : case 'GET' : $method = self::METHOD_GET; break; case 'POST' : $method = self::METHOD_POST; break; case 'PUT' : $method = self::METHOD_PUT; break; case 'PATCH' : $method = self::METHOD_PATCH; break; case 'DELETE' : $method = self::METHOD_DELETE; break; default : return new WP_Error( '<API key>', __( 'Unsupported request method', 'woocommerce' ), array( 'status' => 400 ) ); } foreach ( $this->get_routes() as $route => $handlers ) { foreach ( $handlers as $handler ) { $callback = $handler[0]; $supported = isset( $handler[1] ) ? $handler[1] : self::METHOD_GET; if ( ! ( $supported & $method ) ) { continue; } $match = preg_match( '@^' . $route . '$@i', urldecode( $this->path ), $args ); if ( ! $match ) { continue; } if ( ! is_callable( $callback ) ) { return new WP_Error( '<API key>', __( 'The handler for the route is invalid', 'woocommerce' ), array( 'status' => 500 ) ); } $args = array_merge( $args, $this->params['GET'] ); if ( $method & self::METHOD_POST ) { $args = array_merge( $args, $this->params['POST'] ); } if ( $supported & self::ACCEPT_DATA ) { $data = $this->handler->parse_body( $this->get_raw_data() ); $args = array_merge( $args, array( 'data' => $data ) ); } elseif ( $supported & self::ACCEPT_RAW_DATA ) { $data = $this->get_raw_data(); $args = array_merge( $args, array( 'data' => $data ) ); } $args['_method'] = $method; $args['_route'] = $route; $args['_path'] = $this->path; $args['_headers'] = $this->headers; $args['_files'] = $this->files; $args = apply_filters( '<API key>', $args, $callback ); // Allow plugins to halt the request via this filter if ( is_wp_error( $args ) ) { return $args; } $params = $this-><API key>( $callback, $args ); if ( is_wp_error( $params ) ) { return $params; } return <API key>( $callback, $params ); } } return new WP_Error( '<API key>', __( 'No route was found matching the URL and request method', 'woocommerce' ), array( 'status' => 404 ) ); } /** * urldecode deep. * * @since 2.2 * @param string|array $value Data to decode with urldecode. * @return string|array Decoded data. */ protected function urldecode_deep( $value ) { if ( is_array( $value ) ) { return array_map( array( $this, 'urldecode_deep' ), $value ); } else { return urldecode( $value ); } } /** * Sort parameters by order specified in method declaration * * Takes a callback and a list of available params, then filters and sorts * by the parameters the method actually needs, using the Reflection API * * @since 2.2 * * @param callable|array $callback the endpoint callback * @param array $provided the provided request parameters * * @return array|WP_Error */ protected function <API key>( $callback, $provided ) { if ( is_array( $callback ) ) { $ref_func = new ReflectionMethod( $callback[0], $callback[1] ); } else { $ref_func = new ReflectionFunction( $callback ); } $wanted = $ref_func->getParameters(); $ordered_parameters = array(); foreach ( $wanted as $param ) { if ( isset( $provided[ $param->getName() ] ) ) { // We have this parameters in the list to choose from if ( 'data' == $param->getName() ) { $ordered_parameters[] = $provided[ $param->getName() ]; continue; } $ordered_parameters[] = $this->urldecode_deep( $provided[ $param->getName() ] ); } elseif ( $param-><API key>() ) { // We don't have this parameter, but it's optional $ordered_parameters[] = $param->getDefaultValue(); } else { // We don't have this parameter and it wasn't optional, abort! return new WP_Error( '<API key>', sprintf( __( 'Missing parameter %s', 'woocommerce' ), $param->getName() ), array( 'status' => 400 ) ); } } return $ordered_parameters; } /** * Get the site index. * * This endpoint describes the capabilities of the site. * * @since 2.3 * @return array Index entity */ public function get_index() { // General site data $available = array( 'store' => array( 'name' => get_option( 'blogname' ), 'description' => get_option( 'blogdescription' ), 'URL' => get_option( 'siteurl' ), 'wc_version' => WC()->version, 'routes' => array(), 'meta' => array( 'timezone' => wc_timezone_string(), 'currency' => <API key>(), 'currency_format' => <API key>(), 'currency_position' => get_option( '<API key>' ), 'thousand_separator' => get_option( '<API key>' ), 'decimal_separator' => get_option( '<API key>' ), 'price_num_decimals' => <API key>(), 'tax_included' => <API key>(), 'weight_unit' => get_option( '<API key>' ), 'dimension_unit' => get_option( '<API key>' ), 'ssl_enabled' => ( 'yes' === get_option( '<API key>' ) ), 'permalinks_enabled' => ( '' !== get_option( 'permalink_structure' ) ), 'generate_password' => ( 'yes' === get_option( '<API key>' ) ), 'links' => array( 'help' => 'https://woocommerce.github.io/<API key>/', ), ), ), ); // Find the available routes foreach ( $this->get_routes() as $route => $callbacks ) { $data = array(); $route = preg_replace( '#\(\?P(<\w+?>).*?\)#', '$1', $route ); foreach ( self::$method_map as $name => $bitmask ) { foreach ( $callbacks as $callback ) { // Skip to the next route if any callback is hidden if ( $callback[1] & self::HIDDEN_ENDPOINT ) { continue 3; } if ( $callback[1] & $bitmask ) { $data['supports'][] = $name; } if ( $callback[1] & self::ACCEPT_DATA ) { $data['accepts_data'] = true; } // For non-variable routes, generate links if ( strpos( $route, '<' ) === false ) { $data['meta'] = array( 'self' => <API key>( $route ), ); } } } $available['store']['routes'][ $route ] = apply_filters( '<API key>', $data ); } return apply_filters( '<API key>', $available ); } /** * Send a HTTP status code * * @since 2.1 * @param int $code HTTP status */ public function send_status( $code ) { status_header( $code ); } /** * Send a HTTP header * * @since 2.1 * @param string $key Header key * @param string $value Header value * @param boolean $replace Should we replace the existing header? */ public function header( $key, $value, $replace = true ) { header( sprintf( '%s: %s', $key, $value ), $replace ); } public function link_header( $rel, $link, $other = array() ) { $header = sprintf( '<%s>; rel="%s"', $link, esc_attr( $rel ) ); foreach ( $other as $key => $value ) { if ( 'title' == $key ) { $value = '"' . $value . '"'; } $header .= '; ' . $key . '=' . $value; } $this->header( 'Link', $header, false ); } /** * Send pagination headers for resources * * @since 2.1 * @param WP_Query|WP_User_Query|stdClass $query */ public function <API key>( $query ) { // WP_User_Query if ( is_a( $query, 'WP_User_Query' ) ) { $single = count( $query->get_results() ) == 1; $total = $query->get_total(); if ( $query->get( 'number' ) > 0 ) { $page = ( $query->get( 'offset' ) / $query->get( 'number' ) ) + 1; $total_pages = ceil( $total / $query->get( 'number' ) ); } else { $page = 1; $total_pages = 1; } } elseif ( is_a( $query, 'stdClass' ) ) { $page = $query->page; $single = $query->is_single; $total = $query->total; $total_pages = $query->total_pages; // WP_Query } else { $page = $query->get( 'paged' ); $single = $query->is_single(); $total = $query->found_posts; $total_pages = $query->max_num_pages; } if ( ! $page ) { $page = 1; } $next_page = absint( $page ) + 1; if ( ! $single ) { // first/prev if ( $page > 1 ) { $this->link_header( 'first', $this->get_paginated_url( 1 ) ); $this->link_header( 'prev', $this->get_paginated_url( $page -1 ) ); } // next if ( $next_page <= $total_pages ) { $this->link_header( 'next', $this->get_paginated_url( $next_page ) ); } // last if ( $page != $total_pages ) { $this->link_header( 'last', $this->get_paginated_url( $total_pages ) ); } } $this->header( 'X-WC-Total', $total ); $this->header( 'X-WC-TotalPages', $total_pages ); do_action( '<API key>', $this, $query ); } /** * Returns the request URL with the page query parameter set to the specified page * * @since 2.1 * @param int $page * @return string */ private function get_paginated_url( $page ) { // remove existing page query param $request = remove_query_arg( 'page' ); // add provided page query param $request = urldecode( add_query_arg( 'page', $page, $request ) ); // get the home host $host = parse_url( get_home_url(), PHP_URL_HOST ); return set_url_scheme( "http://{$host}{$request}" ); } /** * Retrieve the raw request entity (body) * * @since 2.1 * @return string */ public function get_raw_data() { // @<API key> // $HTTP_RAW_POST_DATA is deprecated on PHP 5.6. if ( function_exists( 'phpversion' ) && version_compare( phpversion(), '5.6', '>=' ) ) { return file_get_contents( 'php://input' ); } global $HTTP_RAW_POST_DATA; // A bug in PHP < 5.2.2 makes $HTTP_RAW_POST_DATA not set by default, // but we can do it ourself. if ( ! isset( $HTTP_RAW_POST_DATA ) ) { $HTTP_RAW_POST_DATA = file_get_contents( 'php://input' ); } return $HTTP_RAW_POST_DATA; // @<API key> } /** * Parse an RFC3339 datetime into a MySQl datetime * * Invalid dates default to unix epoch * * @since 2.1 * @param string $datetime RFC3339 datetime * @return string MySQl datetime (YYYY-MM-DD HH:MM:SS) */ public function parse_datetime( $datetime ) { // Strip millisecond precision (a full stop followed by one or more digits) if ( strpos( $datetime, '.' ) !== false ) { $datetime = preg_replace( '/\.\d+/', '', $datetime ); } // default timezone to UTC $datetime = preg_replace( '/[+-]\d+:+\d+$/', '+00:00', $datetime ); try { $datetime = new DateTime( $datetime, new DateTimeZone( 'UTC' ) ); } catch ( Exception $e ) { $datetime = new DateTime( '@0' ); } return $datetime->format( 'Y-m-d H:i:s' ); } /** * Format a unix timestamp or MySQL datetime into an RFC3339 datetime * * @since 2.1 * @param int|string $timestamp unix timestamp or MySQL datetime * @param bool $convert_to_utc * @param bool $convert_to_gmt Use GMT timezone. * @return string RFC3339 datetime */ public function format_datetime( $timestamp, $convert_to_utc = false, $convert_to_gmt = false ) { if ( $convert_to_gmt ) { if ( is_numeric( $timestamp ) ) { $timestamp = date( 'Y-m-d H:i:s', $timestamp ); } $timestamp = get_gmt_from_date( $timestamp ); } if ( $convert_to_utc ) { $timezone = new DateTimeZone( wc_timezone_string() ); } else { $timezone = new DateTimeZone( 'UTC' ); } try { if ( is_numeric( $timestamp ) ) { $date = new DateTime( "@{$timestamp}" ); } else { $date = new DateTime( $timestamp, $timezone ); } // convert to UTC by adjusting the time based on the offset of the site's timezone if ( $convert_to_utc ) { $date->modify( -1 * $date->getOffset() . ' seconds' ); } } catch ( Exception $e ) { $date = new DateTime( '@0' ); } return $date->format( 'Y-m-d\TH:i:s\Z' ); } /** * Extract headers from a PHP-style $_SERVER array * * @since 2.1 * @param array $server Associative array similar to $_SERVER * @return array Headers extracted from the input */ public function get_headers( $server ) { $headers = array(); // CONTENT_* headers are not prefixed with HTTP_ $additional = array( 'CONTENT_LENGTH' => true, 'CONTENT_MD5' => true, 'CONTENT_TYPE' => true ); foreach ( $server as $key => $value ) { if ( strpos( $key, 'HTTP_' ) === 0 ) { $headers[ substr( $key, 5 ) ] = $value; } elseif ( isset( $additional[ $key ] ) ) { $headers[ $key ] = $value; } } return $headers; } }
// <API key>: GPL-2.0-only #include "tpm.h" #include <crypto/hash_info.h> static struct tpm2_hash tpm2_hash_map[] = { {HASH_ALGO_SHA1, TPM_ALG_SHA1}, {HASH_ALGO_SHA256, TPM_ALG_SHA256}, {HASH_ALGO_SHA384, TPM_ALG_SHA384}, {HASH_ALGO_SHA512, TPM_ALG_SHA512}, {HASH_ALGO_SM3_256, TPM_ALG_SM3_256}, }; int tpm2_get_timeouts(struct tpm_chip *chip) { /* Fixed timeouts for TPM2 */ chip->timeout_a = msecs_to_jiffies(TPM2_TIMEOUT_A); chip->timeout_b = msecs_to_jiffies(TPM2_TIMEOUT_B); chip->timeout_c = msecs_to_jiffies(TPM2_TIMEOUT_C); chip->timeout_d = msecs_to_jiffies(TPM2_TIMEOUT_D); /* PTP spec timeouts */ chip->duration[TPM_SHORT] = msecs_to_jiffies(TPM2_DURATION_SHORT); chip->duration[TPM_MEDIUM] = msecs_to_jiffies(<API key>); chip->duration[TPM_LONG] = msecs_to_jiffies(TPM2_DURATION_LONG); /* Key creation commands long timeouts */ chip->duration[TPM_LONG_LONG] = msecs_to_jiffies(<API key>); chip->flags |= <API key>; return 0; } /** * <API key>() - returns an index to the chip duration table * @ordinal: TPM command ordinal. * * The function returns an index to the chip duration table * (enum tpm_duration), that describes the maximum amount of * time the chip could take to return the result for a particular ordinal. * * The values of the MEDIUM, and LONG durations are taken * from the PC Client Profile (PTP) specification (750, 2000 msec) * * LONG_LONG is for commands that generates keys which empirically takes * a longer time on some systems. * * Return: * * TPM_MEDIUM * * TPM_LONG * * TPM_LONG_LONG * * TPM_UNDEFINED */ static u8 <API key>(u32 ordinal) { switch (ordinal) { /* Startup */ case TPM2_CC_STARTUP: /* 144 */ return TPM_MEDIUM; case TPM2_CC_SELF_TEST: /* 143 */ return TPM_LONG; case TPM2_CC_GET_RANDOM: /* 17B */ return TPM_LONG; case <API key>: /* 15C */ return TPM_MEDIUM; case <API key>: /* 13E */ return TPM_MEDIUM; case <API key>: /* 185 */ return TPM_MEDIUM; case <API key>: /* 186 */ return TPM_MEDIUM; case <API key>: /* 177 */ return TPM_LONG; case TPM2_CC_PCR_EXTEND: /* 182 */ return TPM_MEDIUM; case <API key>: /* 121 */ return TPM_LONG; case <API key>: /* 129 */ return TPM_LONG; case <API key>: /* 17A */ return TPM_MEDIUM; case TPM2_CC_NV_READ: /* 14E */ return TPM_LONG; case <API key>: /* 131 */ return TPM_LONG_LONG; case TPM2_CC_CREATE: /* 153 */ return TPM_LONG_LONG; case <API key>: /* 191 */ return TPM_LONG_LONG; default: return TPM_UNDEFINED; } } /** * <API key>() - calculate the maximum command duration * @chip: TPM chip to use. * @ordinal: TPM command ordinal. * * The function returns the maximum amount of time the chip could take * to return the result for a particular ordinal in jiffies. * * Return: A maximal duration time for an ordinal in jiffies. */ unsigned long <API key>(struct tpm_chip *chip, u32 ordinal) { unsigned int index; index = <API key>(ordinal); if (index != TPM_UNDEFINED) return chip->duration[index]; else return msecs_to_jiffies(<API key>); } struct tpm2_pcr_read_out { __be32 update_cnt; __be32 pcr_selects_cnt; __be16 hash_alg; u8 pcr_select_size; u8 pcr_select[TPM2_PCR_SELECT_MIN]; __be32 digests_cnt; __be16 digest_size; u8 digest[]; } __packed; /** * tpm2_pcr_read() - read a PCR value * @chip: TPM chip to use. * @pcr_idx: index of the PCR to read. * @digest: PCR bank and buffer current PCR value is written to. * @digest_size_ptr: pointer to variable that stores the digest size. * * Return: Same as with tpm_transmit_cmd. */ int tpm2_pcr_read(struct tpm_chip *chip, u32 pcr_idx, struct tpm_digest *digest, u16 *digest_size_ptr) { int i; int rc; struct tpm_buf buf; struct tpm2_pcr_read_out *out; u8 pcr_select[TPM2_PCR_SELECT_MIN] = {0}; u16 digest_size; u16 <API key> = 0; if (pcr_idx >= TPM2_PLATFORM_PCR) return -EINVAL; if (!digest_size_ptr) { for (i = 0; i < chip->nr_allocated_banks && chip->allocated_banks[i].alg_id != digest->alg_id; i++) ; if (i == chip->nr_allocated_banks) return -EINVAL; <API key> = chip->allocated_banks[i].digest_size; } rc = tpm_buf_init(&buf, TPM2_ST_NO_SESSIONS, TPM2_CC_PCR_READ); if (rc) return rc; pcr_select[pcr_idx >> 3] = 1 << (pcr_idx & 0x7); tpm_buf_append_u32(&buf, 1); tpm_buf_append_u16(&buf, digest->alg_id); tpm_buf_append_u8(&buf, TPM2_PCR_SELECT_MIN); tpm_buf_append(&buf, (const unsigned char *)pcr_select, sizeof(pcr_select)); rc = tpm_transmit_cmd(chip, &buf, 0, "attempting to read a pcr value"); if (rc) goto out; out = (struct tpm2_pcr_read_out *)&buf.data[TPM_HEADER_SIZE]; digest_size = be16_to_cpu(out->digest_size); if (digest_size > sizeof(digest->digest) || (!digest_size_ptr && digest_size != <API key>)) { rc = -EINVAL; goto out; } if (digest_size_ptr) *digest_size_ptr = digest_size; memcpy(digest->digest, out->digest, digest_size); out: tpm_buf_destroy(&buf); return rc; } struct tpm2_null_auth_area { __be32 handle; __be16 nonce_size; u8 attributes; __be16 auth_size; } __packed; /** * tpm2_pcr_extend() - extend a PCR value * * @chip: TPM chip to use. * @pcr_idx: index of the PCR. * @digests: list of pcr banks and corresponding digest values to extend. * * Return: Same as with tpm_transmit_cmd. */ int tpm2_pcr_extend(struct tpm_chip *chip, u32 pcr_idx, struct tpm_digest *digests) { struct tpm_buf buf; struct tpm2_null_auth_area auth_area; int rc; int i; rc = tpm_buf_init(&buf, TPM2_ST_SESSIONS, TPM2_CC_PCR_EXTEND); if (rc) return rc; tpm_buf_append_u32(&buf, pcr_idx); auth_area.handle = cpu_to_be32(TPM2_RS_PW); auth_area.nonce_size = 0; auth_area.attributes = 0; auth_area.auth_size = 0; tpm_buf_append_u32(&buf, sizeof(struct tpm2_null_auth_area)); tpm_buf_append(&buf, (const unsigned char *)&auth_area, sizeof(auth_area)); tpm_buf_append_u32(&buf, chip->nr_allocated_banks); for (i = 0; i < chip->nr_allocated_banks; i++) { tpm_buf_append_u16(&buf, digests[i].alg_id); tpm_buf_append(&buf, (const unsigned char *)&digests[i].digest, chip->allocated_banks[i].digest_size); } rc = tpm_transmit_cmd(chip, &buf, 0, "attempting extend a PCR value"); tpm_buf_destroy(&buf); return rc; } struct tpm2_get_random_out { __be16 size; u8 buffer[TPM_MAX_RNG_DATA]; } __packed; /** * tpm2_get_random() - get random bytes from the TPM RNG * * @chip: a &tpm_chip instance * @dest: destination buffer * @max: the max number of random bytes to pull * * Return: * size of the buffer on success, * -errno otherwise (positive TPM return codes are masked to -EIO) */ int tpm2_get_random(struct tpm_chip *chip, u8 *dest, size_t max) { struct tpm2_get_random_out *out; struct tpm_buf buf; u32 recd; u32 num_bytes = max; int err; int total = 0; int retries = 5; u8 *dest_ptr = dest; if (!num_bytes || max > TPM_MAX_RNG_DATA) return -EINVAL; err = tpm_buf_init(&buf, 0, 0); if (err) return err; do { tpm_buf_reset(&buf, TPM2_ST_NO_SESSIONS, TPM2_CC_GET_RANDOM); tpm_buf_append_u16(&buf, num_bytes); err = tpm_transmit_cmd(chip, &buf, offsetof(struct tpm2_get_random_out, buffer), "attempting get random"); if (err) { if (err > 0) err = -EIO; goto out; } out = (struct tpm2_get_random_out *) &buf.data[TPM_HEADER_SIZE]; recd = min_t(u32, be16_to_cpu(out->size), num_bytes); if (tpm_buf_length(&buf) < TPM_HEADER_SIZE + offsetof(struct tpm2_get_random_out, buffer) + recd) { err = -EFAULT; goto out; } memcpy(dest_ptr, out->buffer, recd); dest_ptr += recd; total += recd; num_bytes -= recd; } while (retries-- && total < max); tpm_buf_destroy(&buf); return total ? total : -EIO; out: tpm_buf_destroy(&buf); return err; } /** * tpm2_flush_context() - execute a TPM2_FlushContext command * @chip: TPM chip to use * @handle: context handle */ void tpm2_flush_context(struct tpm_chip *chip, u32 handle) { struct tpm_buf buf; int rc; rc = tpm_buf_init(&buf, TPM2_ST_NO_SESSIONS, <API key>); if (rc) { dev_warn(&chip->dev, "0x%08x was not flushed, out of memory\n", handle); return; } tpm_buf_append_u32(&buf, handle); tpm_transmit_cmd(chip, &buf, 0, "flushing context"); tpm_buf_destroy(&buf); } EXPORT_SYMBOL_GPL(tpm2_flush_context); struct tpm2_get_cap_out { u8 more_data; __be32 subcap_id; __be32 property_cnt; __be32 property_id; __be32 value; } __packed; /** * tpm2_get_tpm_pt() - get value of a <API key> type property * @chip: a &tpm_chip instance * @property_id: property ID. * @value: output variable. * @desc: passed to tpm_transmit_cmd() * * Return: * 0 on success, * -errno or a TPM return code otherwise */ ssize_t tpm2_get_tpm_pt(struct tpm_chip *chip, u32 property_id, u32 *value, const char *desc) { struct tpm2_get_cap_out *out; struct tpm_buf buf; int rc; rc = tpm_buf_init(&buf, TPM2_ST_NO_SESSIONS, <API key>); if (rc) return rc; tpm_buf_append_u32(&buf, <API key>); tpm_buf_append_u32(&buf, property_id); tpm_buf_append_u32(&buf, 1); rc = tpm_transmit_cmd(chip, &buf, 0, NULL); if (!rc) { out = (struct tpm2_get_cap_out *) &buf.data[TPM_HEADER_SIZE]; *value = be32_to_cpu(out->value); } tpm_buf_destroy(&buf); return rc; } EXPORT_SYMBOL_GPL(tpm2_get_tpm_pt); /** * tpm2_shutdown() - send a TPM shutdown command * * Sends a TPM shutdown command. The shutdown command is used in call * sites where the system is going down. If it fails, there is not much * that can be done except print an error message. * * @chip: a &tpm_chip instance * @shutdown_type: TPM_SU_CLEAR or TPM_SU_STATE. */ void tpm2_shutdown(struct tpm_chip *chip, u16 shutdown_type) { struct tpm_buf buf; int rc; rc = tpm_buf_init(&buf, TPM2_ST_NO_SESSIONS, TPM2_CC_SHUTDOWN); if (rc) return; tpm_buf_append_u16(&buf, shutdown_type); tpm_transmit_cmd(chip, &buf, 0, "stopping the TPM"); tpm_buf_destroy(&buf); } /** * tpm2_do_selftest() - ensure that all self tests have passed * * @chip: TPM chip to use * * Return: Same as with tpm_transmit_cmd. * * The TPM can either run all self tests synchronously and then return * RC_SUCCESS once all tests were successful. Or it can choose to run the tests * asynchronously and return RC_TESTING immediately while the self tests still * execute in the background. This function handles both cases and waits until * all tests have completed. */ static int tpm2_do_selftest(struct tpm_chip *chip) { struct tpm_buf buf; int full; int rc; for (full = 0; full < 2; full++) { rc = tpm_buf_init(&buf, TPM2_ST_NO_SESSIONS, TPM2_CC_SELF_TEST); if (rc) return rc; tpm_buf_append_u8(&buf, full); rc = tpm_transmit_cmd(chip, &buf, 0, "attempting the self test"); tpm_buf_destroy(&buf); if (rc == TPM2_RC_TESTING) rc = TPM2_RC_SUCCESS; if (rc == TPM2_RC_INITIALIZE || rc == TPM2_RC_SUCCESS) return rc; } return rc; } /** * tpm2_probe() - probe for the TPM 2.0 protocol * @chip: a &tpm_chip instance * * Send an idempotent TPM 2.0 command and see whether there is TPM2 chip in the * other end based on the response tag. The flag TPM_CHIP_FLAG_TPM2 is set by * this function if this is the case. * * Return: * 0 on success, * -errno otherwise */ int tpm2_probe(struct tpm_chip *chip) { struct tpm_header *out; struct tpm_buf buf; int rc; rc = tpm_buf_init(&buf, TPM2_ST_NO_SESSIONS, <API key>); if (rc) return rc; tpm_buf_append_u32(&buf, <API key>); tpm_buf_append_u32(&buf, <API key>); tpm_buf_append_u32(&buf, 1); rc = tpm_transmit_cmd(chip, &buf, 0, NULL); /* We ignore TPM return codes on purpose. */ if (rc >= 0) { out = (struct tpm_header *)buf.data; if (be16_to_cpu(out->tag) == TPM2_ST_NO_SESSIONS) chip->flags |= TPM_CHIP_FLAG_TPM2; } tpm_buf_destroy(&buf); return 0; } EXPORT_SYMBOL_GPL(tpm2_probe); static int tpm2_init_bank_info(struct tpm_chip *chip, u32 bank_index) { struct tpm_bank_info *bank = chip->allocated_banks + bank_index; struct tpm_digest digest = { .alg_id = bank->alg_id }; int i; /* * Avoid unnecessary PCR read operations to reduce overhead * and obtain identifiers of the crypto subsystem. */ for (i = 0; i < ARRAY_SIZE(tpm2_hash_map); i++) { enum hash_algo crypto_algo = tpm2_hash_map[i].crypto_id; if (bank->alg_id != tpm2_hash_map[i].tpm_id) continue; bank->digest_size = hash_digest_size[crypto_algo]; bank->crypto_id = crypto_algo; return 0; } bank->crypto_id = HASH_ALGO__LAST; return tpm2_pcr_read(chip, 0, &digest, &bank->digest_size); } struct tpm2_pcr_selection { __be16 hash_alg; u8 size_of_select; u8 pcr_select[3]; } __packed; ssize_t <API key>(struct tpm_chip *chip) { struct tpm2_pcr_selection pcr_selection; struct tpm_buf buf; void *marker; void *end; void *pcr_select_offset; u32 <API key>; u32 nr_possible_banks; u32 nr_alloc_banks = 0; u16 hash_alg; u32 rsp_len; int rc; int i = 0; rc = tpm_buf_init(&buf, TPM2_ST_NO_SESSIONS, <API key>); if (rc) return rc; tpm_buf_append_u32(&buf, TPM2_CAP_PCRS); tpm_buf_append_u32(&buf, 0); tpm_buf_append_u32(&buf, 1); rc = tpm_transmit_cmd(chip, &buf, 9, "get tpm pcr allocation"); if (rc) goto out; nr_possible_banks = be32_to_cpup( (__be32 *)&buf.data[TPM_HEADER_SIZE + 5]); chip->allocated_banks = kcalloc(nr_possible_banks, sizeof(*chip->allocated_banks), GFP_KERNEL); if (!chip->allocated_banks) { rc = -ENOMEM; goto out; } marker = &buf.data[TPM_HEADER_SIZE + 9]; rsp_len = be32_to_cpup((__be32 *)&buf.data[2]); end = &buf.data[rsp_len]; for (i = 0; i < nr_possible_banks; i++) { pcr_select_offset = marker + offsetof(struct tpm2_pcr_selection, size_of_select); if (pcr_select_offset >= end) { rc = -EFAULT; break; } memcpy(&pcr_selection, marker, sizeof(pcr_selection)); hash_alg = be16_to_cpu(pcr_selection.hash_alg); pcr_select_offset = memchr_inv(pcr_selection.pcr_select, 0, pcr_selection.size_of_select); if (pcr_select_offset) { chip->allocated_banks[nr_alloc_banks].alg_id = hash_alg; rc = tpm2_init_bank_info(chip, nr_alloc_banks); if (rc < 0) break; nr_alloc_banks++; } <API key> = sizeof(pcr_selection.hash_alg) + sizeof(pcr_selection.size_of_select) + pcr_selection.size_of_select; marker = marker + <API key>; } chip->nr_allocated_banks = nr_alloc_banks; out: tpm_buf_destroy(&buf); return rc; } int <API key>(struct tpm_chip *chip) { struct tpm_buf buf; u32 nr_commands; __be32 *attrs; u32 cc; int i; int rc; rc = tpm2_get_tpm_pt(chip, <API key>, &nr_commands, NULL); if (rc) goto out; if (nr_commands > 0xFFFFF) { rc = -EFAULT; goto out; } chip->cc_attrs_tbl = devm_kcalloc(&chip->dev, 4, nr_commands, GFP_KERNEL); if (!chip->cc_attrs_tbl) { rc = -ENOMEM; goto out; } rc = tpm_buf_init(&buf, TPM2_ST_NO_SESSIONS, <API key>); if (rc) goto out; tpm_buf_append_u32(&buf, TPM2_CAP_COMMANDS); tpm_buf_append_u32(&buf, TPM2_CC_FIRST); tpm_buf_append_u32(&buf, nr_commands); rc = tpm_transmit_cmd(chip, &buf, 9 + 4 * nr_commands, NULL); if (rc) { tpm_buf_destroy(&buf); goto out; } if (nr_commands != be32_to_cpup((__be32 *)&buf.data[TPM_HEADER_SIZE + 5])) { rc = -EFAULT; tpm_buf_destroy(&buf); goto out; } chip->nr_commands = nr_commands; attrs = (__be32 *)&buf.data[TPM_HEADER_SIZE + 9]; for (i = 0; i < nr_commands; i++, attrs++) { chip->cc_attrs_tbl[i] = be32_to_cpup(attrs); cc = chip->cc_attrs_tbl[i] & 0xFFFF; if (cc == <API key> || cc == <API key>) { chip->cc_attrs_tbl[i] &= ~(GENMASK(2, 0) << <API key>); chip->cc_attrs_tbl[i] |= 1 << <API key>; } } tpm_buf_destroy(&buf); out: if (rc > 0) rc = -ENODEV; return rc; } EXPORT_SYMBOL_GPL(<API key>); static int tpm2_startup(struct tpm_chip *chip) { struct tpm_buf buf; int rc; dev_info(&chip->dev, "starting up the TPM manually\n"); rc = tpm_buf_init(&buf, TPM2_ST_NO_SESSIONS, TPM2_CC_STARTUP); if (rc < 0) return rc; tpm_buf_append_u16(&buf, TPM2_SU_CLEAR); rc = tpm_transmit_cmd(chip, &buf, 0, "attempting to start the TPM"); tpm_buf_destroy(&buf); return rc; } /** * tpm2_auto_startup - Perform the standard automatic TPM initialization * sequence * @chip: TPM chip to use * * Returns 0 on success, < 0 in case of fatal error. */ int tpm2_auto_startup(struct tpm_chip *chip) { int rc; rc = tpm2_get_timeouts(chip); if (rc) goto out; rc = tpm2_do_selftest(chip); if (rc && rc != TPM2_RC_INITIALIZE) goto out; if (rc == TPM2_RC_INITIALIZE) { rc = tpm2_startup(chip); if (rc) goto out; rc = tpm2_do_selftest(chip); if (rc) goto out; } rc = <API key>(chip); out: if (rc > 0) rc = -ENODEV; return rc; } int tpm2_find_cc(struct tpm_chip *chip, u32 cc) { int i; for (i = 0; i < chip->nr_commands; i++) if (cc == (chip->cc_attrs_tbl[i] & GENMASK(15, 0))) return i; return -1; }
# Changelog > **Tags:** > - :boom: [Breaking Change] > - :eyeglasses: [Spec Compliancy] > - :rocket: [New Feature] > - :bug: [Bug Fix] > - :memo: [Documentation] > - :house: [Internal] > - :nail_care: [Polish] > Semver Policy: https://github.com/babel/babylon#semver _Note: Gaps between patch versions are faulty, broken or test releases._ See the [Babel Changelog](https://github.com/babel/babel/blob/master/CHANGELOG.md) for the pre-6.8.0 version Changelog. ## 6.17.2 (2017-05-31) * Fixed disappearing comments following a trailing comma on the last property of an object literal or the last argument of a call expression (#478) (aardito2) * Fix #437: only prohibit 'export type from "module" ' when flow is enabled (#438) (Kevin Gibbons) * Fix handling of anonymous parameters in `<API key>`. (#526) (Max Schaefer) * Convert argument of SpreadElement correctly to assignable (#518) (Daniel Tschinder) ## 6.17.1 (2017-05-10) * Fix typo in flow spread operator error (Brian Ng) * Fixed invalid number literal parsing ([ * Fix number parser ([ * Ensure non pattern shorthand props are checked for reserved words ([ * Remove jsx context when parsing arrow functions ([ * Allow super in class properties ([ * Allow flow class field to be named constructor ([ ## 6.17.0 (2017-04-20) * Cherry-pick * Add support for invalid escapes in tagged templates ([ * Throw error if new.target is used outside of a function ([ * Fix parsing of class properties ([ * Fix parsing yield with dynamicImport ([ * Ensure consistent start args for parseParenItem ([ ## 6.16.0 (2017-02-23) :rocket: New Feature ***ESTree*** compatibility as plugin ([ We finally introduce a new compatibility layer for ESTree. To put babylon into ESTree-compatible mode the new plugin `estree` can be enabled. In this mode the parser will output an AST that is compliant to the specs of [ESTree](https://github.com/estree/estree/) We highly recommend everyone who uses babylon outside of babel to use this plugin. This will make it much easier for users to switch between different ESTree-compatible parsers. We so far tested several projects with different parsers and exchanged their parser to babylon and in nearly all cases it worked out of the box. Some other estree-compatible parsers include `acorn`, `esprima`, `espree`, `flow-parser`, etc. To enable `estree` mode simply add the plugin in the config: json { "plugins": [ "estree" ] } If you want to migrate your project from non-ESTree mode to ESTree, have a look at our [Readme](https://github.com/babel/babylon/#output), where all deviations are mentioned. Add a parseExpression public method ([ Babylon exports a new function to parse a single expression js import { parseExpression } from 'babylon'; const ast = parseExpression('x || y && z', options); The returned AST will only consist of the expression. The options are the same as for `parse()` Add startLine option ([ A new option was added to babylon allowing to change the intial linenumber for the first line which is usually `1`. Changing this for example to `100` will make line `1` of the input source to be marked as line `100`, line `2` as `101`, line `3` as `102`, ... Function predicate declaration ([ Added support for function predicates which flow introduced in version 0.33.0 js declare function is_number(x: mixed): boolean %checks(typeof x === "number"); Allow imports in declare module ([ Added support for imports within module declarations which flow introduced in version 0.37.0 js declare module "C" { import type { DT } from "D"; declare export type CT = { D: DT }; } :eyeglasses: Spec Compliancy Forbid semicolons after decorators in classes ([ This example now correctly throws an error when there is a semicolon after the decorator: js class A { @a; foo(){} } Keywords are not allowed as local specifier ([ Using keywords in imports is not allowed anymore: js import { default } from "foo"; import { a as debugger } from "foo"; Do not allow overwritting of primitive types ([ In flow it is now forbidden to overwrite the primitve types `"any"`, `"mixed"`, `"empty"`, `"bool"`, `"boolean"`, `"number"`, `"string"`, `"void"` and `"null"` with your own type declaration. Disallow import type { type a } from … ([ The following code now correctly throws an error js import type { type a } from "foo"; Don't parse class properties without initializers when classProperties is disabled and Flow is enabled ([ Ensure that you enable the `classProperties` plugin in order to enable correct parsing of class properties. Prior to this version it was possible to parse them by enabling the `flow` plugin but this was not intended the behaviour. If you enable the flow plugin you can only define the type of the class properties, but not initialize them. Fix export default async function to be FunctionDeclaration ([ Parsing the following code now returns a `FunctionDeclaration` AST node instead of `FunctionExpression`. js export default async function bar() {}; :nail_care: Polish Improve error message on attempt to destructure named import ([ :bug: Bug Fix Fix negative number literal typeannotations ([ Ensure takeDecorators is called on exported class ([ ESTree: correctly change literals in all cases ([ Correctly convert RestProperty to Assignable ([ Fix Fix Fix parse error when destructuring `set` with default value ([ Fix <API key> static ([ :house: Internal Fix <API key> spec ([ Fix flow <API key> test with unintended semantic ([ Cleanup and splitup parser functions ([ chore(package): update flow-bin to version 0.38.0 ([ Call inner function instead of 1:1 copy to plugin ([ Update eslint-config-babel to the latest version ([ Update eslint-config-babel to the latest version ([ devDeps: remove eslint-plugin-babel ([ Correct indent eslint rule config ([ Fail tests that have expected.json and throws-option ([ :memo: Documentation Update contributing with more test info [skip ci] ([ Update API documentation ([ Added keywords to package.json ([ AST spec: fix casing of `RegExpLiteral` ([ ## 6.15.0 (2017-01-10) :eyeglasses: Spec Compliancy Add support for Flow shorthand import type ([ This change implements flows new shorthand import syntax and where previously you had to write this code: js import {someValue} from "blah"; import type {someType} from "blah"; import typeof {someOtherValue} from "blah"; you can now write it like this: js import { someValue, type someType, typeof someOtherValue, } from "blah"; For more information look at [this](https://github.com/facebook/flow/pull/2890) pull request. flow: allow leading pipes in all positions ([ This change now allows a leading pipe everywhere types can be used: js var f = (x): | 1 | 2 => 1; Throw error when exporting non-declaration ([ Previously babylon parsed the following exports, although they are not valid: js export typeof foo; export new Foo(); export function() {}; export for (;;); export while(foo); :bug: Bug Fix Don't set inType flag when parsing property names ([ This fixes parsing of this case: js const map = { [age <= 17] : 'Too young' }; Fix source location for JSXEmptyExpression nodes (fixes The following case produced an invalid AST js <div>{/* foo */}</div> Use fromCodePoint to convert high value unicode entities ([ When high value unicode entities (e.g. ) were used in the input source code they are now correctly encoded in the resulting AST. Rename folder to avoid Windows-illegal characters ([ Allow this.state.clone() when parsing decorators ([ :house: Internal User external-helpers ([ Add watch script for dev ([ Freeze current plugins list for "*" option, and remove from README.md ([ Prepare tests for multiple fixture runners. ([ Add some test coverage for decorators stage-0 plugin ([ Refactor tokenizer types file ([ Update eslint-config-babel to the latest version ([ chore(package): update rollup to version 0.41.0 ([ chore(package): update flow-bin to version 0.37.0 ([ ## 6.14.1 (2016-11-17) :bug: Bug Fix Allow `"plugins": ["*"]` ([ js { "plugins": ["*"] } Will include all parser plugins instead of specifying each one individually. Useful for tools like babel-eslint, jscodeshift, and ast-explorer. ## 6.14.0 (2016-11-16) :eyeglasses: Spec Compliancy Throw error for reserved words `enum` and `await` ([ [11.6.2.2 Future Reserved Words](http://www.ecma-international.org/ecma-262/6.0/#<API key>) Babylon will throw for more reserved words such as `enum` or `await` (in strict mode). class enum {} // throws class await {} // throws in strict mode (module) Optional names for function types and object type indexers ([ So where you used to have to write js type A = (x: string, y: boolean) => number; type B = (z: string) => number; type C = { [key: string]: number }; you can now write (with flow 0.34.0) js type A = (string, boolean) => number; type B = string => number; type C = { [string]: number }; Parse flow nested array type annotations like `number[][]` ([ Supports these form now of specifying array types: js var a: number[][][][]; var b: string[][]; :bug: Bug Fix Correctly eat semicolon at the end of `<API key>` ([ declare module "foo" { declare module.exports: number } declare module "foo" { declare module.exports: number; } // also allowed now :house: Internal * Count Babel tests towards Babylon code coverage ([ * Fix strange line endings ([ * Add node 7 (Daniel Tschinder) * chore(package): update flow-bin to version 0.34.0 ([ ## v6.13.1 (2016-10-26) :nail_care: Polish - Use rollup for bundling to speed up startup time ([ js const babylon = require('babylon'); const ast = babylon.parse('var foo = "lol";'); With that test case, there was a ~95ms savings by removing the need for node to build/traverse the dependency graph. **Without bundling** ![image](https://cloud.githubusercontent.com/assets/5233399/19420264/<API key>.png) **With bundling** ![image](https://cloud.githubusercontent.com/assets/5233399/19420267/<API key>.png) - add clean command [skip ci] ([ - add ForAwaitStatement (async generator already added) [skip ci] ([ ## v6.13.0 (2016-10-21) :eyeglasses: Spec Compliancy Property variance type annotations for Flow plugin ([ > See https://flowtype.org/docs/variance.html for more information js type T = { +p: T }; interface T { -p: T }; declare class T { +[k:K]: V }; class T { -[k:K]: V }; class C2 { +p: T = e }; Raise error on duplicate definition of __proto__ ([ js ({ __proto__: 1, __proto__: 2 }) // Throws an error now :bug: Bug Fix Flow: Allow class properties to be named `static` ([ js declare class A { static: T; } Allow "async" as identifier for object literal property shorthand ([ js var foo = { async, bar }; :nail_care: Polish Fix flowtype and add inType to state ([ > This improves the performance slightly (because of hidden classes) :house: Internal Fix .gitattributes line ending setting ([ Increase test coverage ([ Readd missin .eslinignore for IDEs (Daniel Tschinder) Error on missing expected.json fixture in CI ([ Add .gitattributes and .editorconfig for LF line endings ([ Fixes two tests that are failing after the merge of ## v6.12.0 (2016-10-14) :eyeglasses: Spec Compliancy Implement import() syntax ([ # Dynamic Import - Proposal Repo: https://github.com/domenic/<API key> - Championed by [@domenic](https://github.com/domenic) - stage-2 - [sept-28 tc39 notes](https://github.com/rwaldron/tc39-notes/blob/master/es7/2016-09/sept-28.md#113a-import) > This repository contains a proposal for adding a "function-like" import() module loading syntactic form to JavaScript js import(`./section-modules/${link.dataset.entryModule}.js`) .then(module => { module.loadPageInto(main); }) Add EmptyTypeAnnotation ([ # EmptyTypeAnnotation Just wasn't covered before. js type T = empty; :bug: Bug Fix Fix crash when exporting with destructuring and sparse array ([ js // was failing due to sparse array export const { foo: [ ,, qux7 ] } = bar; Allow keyword in Flow object declaration property names with type parameters ([ js declare class X { foobar<T>(): void; static foobar<T>(): void; } Allow keyword in object/class property names with Flow type parameters ([ js class Foo { delete<T>(item: T): T { return item; } } Allow typeAnnotations for yield expressions ([ js function *foo() { const x = (yield 5: any); } :nail_care: Polish Annotate more errors with expected token ([ js // Unexpected token, expected ; (1:6) { set 1 } :house: Internal Remove kcheck ([ Also run flow, linting, babel tests on seperate instances (add back node 0.10) ## v6.11.6 (2016-10-12) :bug: Bug Fix/Regression Fix crash when exporting with destructuring and sparse array ([ js // was failing with `Cannot read property 'type' of null` because of null identifiers export const { foo: [ ,, qux7 ] } = bar; ## v6.11.5 (2016-10-12) :eyeglasses: Spec Compliancy Fix: Check for duplicate named exports in exported destructuring assignments ([ js // `foo` has already been exported. Exported identifiers must be unique. (2:20) export function foo() {}; export const { a: [{foo}] } = bar; Fix: Check for duplicate named exports in exported rest elements/properties ([ js // `foo` has already been exported. Exported identifiers must be unique. (2:22) export const foo = 1; export const [bar, ...foo] = baz; :bug: Bug Fix Fix: Allow identifier `async` for default param in arrow expression ([ js // this is ok now const test = ({async = true}) => {}; :nail_care: Polish Babylon will now print out the token it's expecting if there's a `SyntaxError` ([ bash # So in the case of a missing ending curly (`}`) Module build failed: SyntaxError: Unexpected token, expected } (30:0) 28 | } 29 | > 30 | | ^ ## v6.11.4 (2016-10-03) Temporary rollback for erroring on trailing comma with spread (#154) (Henry Zhu) ## v6.11.3 (2016-10-01) :eyeglasses: Spec Compliancy Add static errors for object rest ( > https://github.com/sebmarkbage/<API key> Object rest copies the *rest* of properties from the right hand side `obj` starting from the left to right. js let { x, y, ...z } = { x: 1, y: 2, z: 3 }; // x = 1 // y = 2 // z = { z: 3 } # New Syntax Errors: **SyntaxError**: The rest element has to be the last element when destructuring (1:10) bash > 1 | let { ...x, y, z } = { x: 1, y: 2, z: 3}; | ^ # Previous behavior: # x = { x: 1, y: 2, z: 3 } # y = 2 # z = 3 Before, this was just a more verbose way of shallow copying `obj` since it doesn't actually do what you think. **SyntaxError**: Cannot have multiple rest elements when destructuring (1:13) bash > 1 | let { x, ...y, ...z } = { x: 1, y: 2, z: 3}; | ^ # Previous behavior: # x = 1 # y = { y: 2, z: 3 } # z = { y: 2, z: 3 } Before y and z would just be the same value anyway so there is no reason to need to have both. **SyntaxError**: A trailing comma is not permitted after the rest element (1:16) js let { x, y, ...z, } = obj; The rationale for this is that the use case for trailing comma is that you can add something at the end without affecting the line above. Since a RestProperty always has to be the last property it doesn't make sense. get / set are valid property names in default assignment ( js // valid function something({ set = null, get = null }) {} ## v6.11.2 (2016-09-23) Bug Fix - [ js // regression with duplicate export check SyntaxError: ./typography.js: `undefined` has already been exported. Exported identifiers must be unique. (22:13) 20 | 21 | export const { rhythm } = typography; > 22 | export const { TypographyStyle } = typography Bail out for now, and make a change to account for destructuring in the next release. ## 6.11.1 (2016-09-22) Bug Fix - [ javascript export toString from './toString'; bash `toString` has already been exported. Exported identifiers must be unique. (1:7) > 1 | export toString from './toString'; | ^ 2 | ## 6.11.0 (2016-09-22) Spec Compliancy (will break CI) - Disallow duplicate named exports ([ js // Only one default export allowed per module. (2:9) export default function() {}; export { foo as default }; // Only one default export allowed per module. (2:0) export default {}; export default function() {}; // `Foo` has already been exported. Exported identifiers must be unique. (2:0) export { Foo }; export class Foo {}; New Feature (Syntax) - Add support for computed class property names ([ js // AST interface ClassProperty <: Node { type: "ClassProperty"; key: Identifier; value: Expression; computed: boolean; // added } js // with "plugins": ["classProperties"] class Foo { [x] ['y'] } class Bar { [p] [m] () {} } Bug Fix - Fix `static` property falling through in the declare class Flow AST ([ js declare class X { a: number; static b: number; // static c: number; // this was being marked as static in the AST as well } Polish - Rephrase "assigning/binding to rvalue" errors to include context ([ js // Used to error with: // SyntaxError: Assigning to rvalue (1:0) // Now: // Invalid left-hand side in assignment expression (1:0) 3 = 4 // Invalid left-hand side in for-in statement (1:5) for (+i in {}); Internal - Fix call to `this.parseMaybeAssign` with correct arguments ([ - Add semver note to changelog ([ ## 6.10.0 (2016-09-19) > We plan to include some spec compliancy bugs in patch versions. An example was the multiple default exports issue. Spec Compliancy * Implement ES2016 check for simple parameter list in strict mode ([ > It is a Syntax Error if ContainsUseStrict of FunctionBody is true and <API key> of FormalParameters is false. https://tc39.github.io/ecma262/2016/#<API key> More Context: [tc39-notes](https://github.com/rwaldron/tc39-notes/blob/master/es7/2015-07/july-29.md#<API key>) For example: js // this errors because it uses destructuring and default parameters // in a function with a "use strict" directive function a([ option1, option2 ] = []) { "use strict"; } The solution would be to use a top level "use strict" or to remove the destructuring or default parameters when using a function + "use strict" or to. New Feature * Exact object type annotations for Flow plugin ([ Added to flow in https://github.com/facebook/flow/commit/<SHA1-like> Looks like: js var a : {| x: number, y: string |} = { x: 0, y: 'foo' }; Bug Fixes * Include `typeParameter` location in `<API key>` ([ * Error on invalid flow type annotation with default assignment ([ * Fix Flow return types on arrow functions ([ Misc * Add tests for export extensions ([ * Fix Contributing guidelines [skip ci] (Daniel Tschinder) ## 6.9.2 (2016-09-09) The only change is to remove the `babel-runtime` dependency by compiling with Babel's ES2015 loose mode. So using babylon standalone should be smaller. ## 6.9.1 (2016-08-23) This release contains mainly small bugfixes but also updates babylons default mode to es2017. The features for `<API key>`, `asyncFunctions` and `<API key>` which previously needed to be activated via plugin are now enabled by default and the plugins are now no-ops. Bug Fixes - Fix issues with default object params in async functions ([ - Fix issues with flow-types and async function ([ - Fix arrow functions with destructuring, types & default value ([ - Fix declare class with qualified type identifier ([ - Remove <API key>, asyncFunctions, <API key> plugins and enable them by default ([ ## 6.9.0 (2016-08-16) New syntax support - Add JSX spread children ([ (Be aware that React is not going to support this syntax) js <div> {...todos.map(todo => <Todo key={todo.id} todo={todo}/>)} </div> - Add support for declare module.exports ([ js declare module "foo" { declare module.exports: {} } New Features - If supplied, attach filename property to comment node loc. ([ - Add identifier name to node loc field ([ Bug Fixes - Fix exponential operator to behave according to spec ([ - Fix lookahead to not add comments to arrays which are not cloned ([ - Fix accidental fall-through in Flow type parsing. ([ - Only allow declares inside declare module ([ - Small fix for parsing type parameter declarations ([ - Fix arrow param locations with flow types ([ - Fixes SyntaxError position with flow optional type ([ Internal - Add codecoverage to tests @danez - Fix tests to not save expected output if we expect the test to fail @danez - Make a shallow clone of babel for testing @danez - chore(package): update cross-env to version 2.0.0 ([ - chore(package): update ava to version 0.16.0 ([ - chore(package): update <API key> to version 2.0.0 ([ - chore(package): update nyc to version 8.0.0 ([ ## 6.8.4 (2016-07-06) Bug Fixes - Fix the location of params, when flow and default value used ([ ## 6.8.3 (2016-07-02) Bug Fixes - Fix performance regression introduced in 6.8.2 with conditionals ([ ## 6.8.2 (2016-06-24) Bug Fixes - Fix parse error with yielding jsx elements in generators `function* it() { yield <a></a>; }` ([ - When cloning nodes do not clone its comments ([ - Fix parse errors when using arrow functions with an spread element and return type `(...props): void => {}` ([ - Fix leading comments added from previous node ([ - Fix parse errors with flow's optional arguments `(arg?) => {}` ([ - Support negative numeric type literals @kittens - Remove line terminator restriction after await keyword @kittens - Remove grouped type arrow restriction as it seems flow no longer has it @kittens - Fix parse error with generic methods that have the name `get` or `set` `class foo { get() {} }` ([ - Fix parse error with arrow functions that have flow type parameter declarations `<T>(x: T): T => x;` ([ Documentation - Document AST differences from ESTree ([ - Move ast spec from babel/babel ([ Internal - Enable skipped tests ([ - Add script to test latest version of babylon with babel ([ - Upgrade test runner ava @kittens - Add missing <API key> script @kittens - Rename parser context types @kittens - Add node v6 to travis testing @hzoo - Update to Unicode v9 ([ ## 6.8.1 (2016-06-06) New Feature - Parse type parameter declarations with defaults like `type Foo<T = string> = T` Bug Fixes - Type parameter declarations need 1 or more type parameters. - The existential type `*` is not a valid type parameter. - The existential type `*` is a primary type Spec Compliancy - The param list for type parameter declarations now consists of `TypeParameter` nodes - New `TypeParameter` AST Node (replaces using the `Identifier` node before) interface TypeParameter <: Node { bound: TypeAnnotation; default: TypeAnnotation; name: string; variance: "plus" | "minus"; } ## 6.8.0 (2016-05-02) # New Feature > [Method Parameter Decorators](https: Examples: js class Foo { constructor(@foo() x, @bar({ a: 123 }) @baz() y) {} } export default function func(@foo() x, @bar({ a: 123 }) @baz() y) {} var obj = { method(@foo() x, @bar({ a: 123 }) @baz() y) {} }; There is also a new node type, `ForAwaitStatement`. > [Async generators and for-await](https://github.com/tc39/<API key>) are now a [stage 2 proposal](https://github.com/tc39/ecma262#current-proposals). Example: js async function f() { for await (let x of y); }
#include "chrome/browser/net/<API key>.h" #include "base/bind.h" #include "base/compiler_specific.h" #include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop_proxy.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/io_thread.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_io_data.h" #include "chrome/browser/profiles/<API key>.h" #include "content/public/browser/browser_thread.h" #include "net/cookies/cookie_store.h" using content::BrowserThread; class <API key> { public: <API key>() {} virtual ~<API key>() {} // Called to create a new instance (will only be called once). virtual net::URLRequestContext* Create() = 0; protected: <API key>(<API key>); }; namespace { // Helper factories // Factory that creates the main URLRequestContext. class FactoryForMain : public <API key> { public: FactoryForMain( const ProfileIOData* profile_io_data, content::ProtocolHandlerMap* protocol_handlers, content::<API key> <API key>) : profile_io_data_(profile_io_data), <API key>(<API key>.Pass()) { std::swap(protocol_handlers_, *protocol_handlers); } virtual net::URLRequestContext* Create() OVERRIDE { profile_io_data_->Init(&protocol_handlers_, <API key>.Pass()); return profile_io_data_-><API key>(); } private: const ProfileIOData* const profile_io_data_; content::ProtocolHandlerMap protocol_handlers_; content::<API key> <API key>; }; // Factory that creates the URLRequestContext for extensions. class <API key> : public <API key> { public: explicit <API key>(const ProfileIOData* profile_io_data) : profile_io_data_(profile_io_data) {} virtual net::URLRequestContext* Create() OVERRIDE { return profile_io_data_-><API key>(); } private: const ProfileIOData* const profile_io_data_; }; // Factory that creates the URLRequestContext for a given isolated app. class <API key> : public <API key> { public: <API key>( const ProfileIOData* profile_io_data, const <API key>& <API key>, <API key>* main_context, scoped_ptr<<API key>::<API key>> <API key>, content::ProtocolHandlerMap* protocol_handlers, content::<API key> <API key>) : profile_io_data_(profile_io_data), <API key>(<API key>), <API key>(main_context), <API key>(<API key>.Pass()), <API key>(<API key>.Pass()) { std::swap(protocol_handlers_, *protocol_handlers); } virtual net::URLRequestContext* Create() OVERRIDE { // We will copy most of the state from the main request context. // Note that this factory is one-shot. After Create() is called once, the // factory is actually destroyed. Thus it is safe to destructively pass // state onwards. return profile_io_data_-><API key>( <API key>-><API key>(), <API key>, <API key>.Pass(), &protocol_handlers_, <API key>.Pass()); } private: const ProfileIOData* const profile_io_data_; const <API key> <API key>; scoped_refptr<<API key>> <API key>; scoped_ptr<<API key>::<API key>> <API key>; content::ProtocolHandlerMap protocol_handlers_; content::<API key> <API key>; }; // Factory that creates the media URLRequestContext for a given isolated // app. The media context is based on the corresponding isolated app's context. class <API key> : public <API key> { public: <API key>( const ProfileIOData* profile_io_data, const <API key>& <API key>, <API key>* app_context) : profile_io_data_(profile_io_data), <API key>(<API key>), app_context_getter_(app_context) {} virtual net::URLRequestContext* Create() OVERRIDE { // We will copy most of the state from the corresopnding app's // request context. We expect to have the same lifetime as // the associated |app_context_getter_| so we can just reuse // all its backing objects, including the // |<API key>|. This is why the API // looks different from <API key>'s. return profile_io_data_-><API key>( app_context_getter_-><API key>(), <API key>); } private: const ProfileIOData* const profile_io_data_; const <API key> <API key>; scoped_refptr<<API key>> app_context_getter_; }; // Factory that creates the URLRequestContext for media. class FactoryForMedia : public <API key> { public: explicit FactoryForMedia(const ProfileIOData* profile_io_data) : profile_io_data_(profile_io_data) { } virtual net::URLRequestContext* Create() OVERRIDE { return profile_io_data_-><API key>(); } private: const ProfileIOData* const profile_io_data_; }; } // namespace // <API key> <API key>::<API key>( <API key>* factory) : factory_(factory), <API key>(NULL) { DCHECK(factory); } <API key>::~<API key>() {} // Lazily create a URLRequestContext using our factory. net::URLRequestContext* <API key>::<API key>() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); if (factory_.get()) { DCHECK(!<API key>); <API key> = factory_->Create(); factory_.reset(); } // Context reference is valid, unless we're trying to use the // <API key> after the Profile has already been deleted. CHECK(<API key>); return <API key>; } void <API key>::Invalidate() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); factory_.reset(); <API key> = NULL; } scoped_refptr<base::<API key>> <API key>::<API key>() const { return BrowserThread::<API key>(BrowserThread::IO); } // static <API key>* <API key>::Create( Profile* profile, const ProfileIOData* profile_io_data, content::ProtocolHandlerMap* protocol_handlers, content::<API key> <API key>) { return new <API key>(new FactoryForMain( profile_io_data, protocol_handlers, <API key>.Pass())); } // static <API key>* <API key>::CreateForMedia( Profile* profile, const ProfileIOData* profile_io_data) { return new <API key>( new FactoryForMedia(profile_io_data)); } // static <API key>* <API key>::CreateForExtensions( Profile* profile, const ProfileIOData* profile_io_data) { return new <API key>( new <API key>(profile_io_data)); } // static <API key>* <API key>::<API key>( Profile* profile, const ProfileIOData* profile_io_data, const <API key>& <API key>, scoped_ptr<<API key>::<API key>> <API key>, content::ProtocolHandlerMap* protocol_handlers, content::<API key> <API key>) { <API key>* main_context = static_cast<<API key>*>(profile->GetRequestContext()); return new <API key>( new <API key>(profile_io_data, <API key>, main_context, <API key>.Pass(), protocol_handlers, <API key>.Pass())); } // static <API key>* <API key>::<API key>( Profile* profile, <API key>* app_context, const ProfileIOData* profile_io_data, const <API key>& <API key>) { return new <API key>( new <API key>( profile_io_data, <API key>, app_context)); }
/* Generated automatically. DO NOT EDIT! */ #define SIMD_HEADER "simd-altivec.h" #include "../common/n2fv_12.c"
#include "config.h" #include "mock-transport.h" #include "common/cockpitjson.h" #include <gio/gio.h> typedef <API key> MockTransportClass; typedef struct { gpointer data; GDestroyNotify func; } Trash; G_DEFINE_TYPE (MockTransport, mock_transport, <API key>); static void trash_free (gpointer data) { Trash *trash = data; (trash->func) (trash->data); g_free (trash); } static void trash_push (MockTransport *self, gpointer data, GDestroyNotify func) { Trash *trash = g_new0 (Trash, 1); g_assert (func != NULL); trash->data = data; trash->func = func; self->trash = g_list_prepend (self->trash, trash); } static void mock_transport_init (MockTransport *self) { self->channels = <API key> (g_str_hash, g_str_equal, g_free, (GDestroyNotify)g_queue_free); self->control = g_queue_new (); } static void <API key> (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { switch (prop_id) { case 1: g_value_set_string (value, "mock-name"); break; default: <API key> (); break; } } static void <API key> (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { switch (prop_id) { case 1: break; default: <API key> (); break; } } static void <API key> (GObject *object) { MockTransport *self = (MockTransport *)object; g_free (self->problem); g_queue_free (self->control); g_list_free_full (self->trash, trash_free); <API key> (self->channels); G_OBJECT_CLASS (<API key>)->finalize (object); } static void mock_transport_send (CockpitTransport *transport, const gchar *channel_id, GBytes *data) { MockTransport *self = (MockTransport *)transport; JsonObject *object; GError *error = NULL; GQueue *queue; if (!channel_id) { object = <API key> (data, &error); g_assert_no_error (error); g_queue_push_tail (self->control, object); trash_push (self, object, (GDestroyNotify)json_object_unref); } else { queue = g_hash_table_lookup (self->channels, channel_id); if (!queue) { queue = g_queue_new (); g_hash_table_insert (self->channels, g_strdup (channel_id), queue); } g_queue_push_tail (queue, g_bytes_ref (data)); trash_push (self, data, (GDestroyNotify)g_bytes_unref); } self->count++; } static void <API key> (CockpitTransport *transport, const gchar *problem) { MockTransport *self = (MockTransport *)transport; g_assert (!self->closed); self->problem = g_strdup (problem); self->closed = TRUE; <API key> (transport, problem); } static void <API key> (MockTransportClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); <API key> *transport_class = <API key> (klass); object_class->finalize = <API key>; object_class->get_property = <API key>; object_class->set_property = <API key>; <API key> (object_class, 1, "name"); transport_class->send = mock_transport_send; transport_class->close = <API key>; } MockTransport * mock_transport_new (void) { return g_object_new (MOCK_TYPE_TRANSPORT, NULL); } GBytes * <API key> (MockTransport *mock, const gchar *channel_id) { GQueue *queue; g_assert (channel_id != NULL); queue = g_hash_table_lookup (mock->channels, channel_id); if (queue) return g_queue_pop_head (queue); return NULL; } JsonObject * <API key> (MockTransport *mock) { return g_queue_pop_head (mock->control); } guint <API key> (MockTransport *mock) { return mock->count; } GBytes * <API key> (MockTransport *transport, const gchar *channel_id, guint *count) { GByteArray *combined; GBytes *block; if (count) *count = 0; combined = g_byte_array_new (); for (;;) { block = <API key> (transport, channel_id); if (!block) break; g_byte_array_append (combined, g_bytes_get_data (block, NULL), g_bytes_get_size (block)); if (count) (*count)++; } return <API key> (combined); }
// RUN: %clang_cc1 -triple=x86_64-apple-darwin -fsyntax-only -verify %s // PR23086 __builtin_isinf(...); // expected-warning {{type specifier missing, defaults to 'int'}} expected-error {{ISO C requires a named parameter before '...'}} // expected-error {{conflicting types for '__builtin_isinf'}} // expected-note {{'__builtin_isinf' is a builtin with type 'int ()'}}
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( int_or_none, parse_duration, parse_iso8601, ) class MnetIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?mnet\.(?:com|interest\.me)/tv/vod/(?:.*?\bclip_id=)?(?P<id>[0-9]+)' _TESTS = [{ 'url': 'http: 'info_dict': { 'id': '171008', 'title': 'SS_@', 'description': 'md5:<API key>', 'duration': 88, 'upload_date': '20151231', 'timestamp': 1451564040, 'age_limit': 0, 'thumbnails': 'mincount:5', 'thumbnail': r're:^https?://.*\.jpg$', 'ext': 'flv', }, 'params': { # rtmp download 'skip_download': True, }, }, { 'url': 'http://mnet.interest.me/tv/vod/172790', 'only_matching': True, }, { 'url': 'http: 'only_matching': True, }] def _real_extract(self, url): video_id = self._match_id(url) # TODO: extract rtmp formats # no stype -> rtmp url # stype=H -> m3u8 url # stype=M -> mpd url info = self._download_json( 'http://content.api.mnet.com/player/vodConfig', video_id, 'Downloading vod config JSON', query={ 'id': video_id, 'ctype': 'CLIP', 'stype': 'H', })['data']['info'] title = info['title'] cdn_data = self._download_json( info['cdn'], video_id, 'Downloading vod cdn JSON')['data'][0] m3u8_url = cdn_data['url'] token = cdn_data.get('token') if token and token != '-': m3u8_url += '?' + token formats = self.<API key>( m3u8_url, video_id, skip_protocols=['rtmp', 'rtsp', 'f4m']) self._sort_formats(formats) description = info.get('ment') duration = parse_duration(info.get('time')) timestamp = parse_iso8601(info.get('date'), delimiter=' ') age_limit = info.get('adult') if age_limit is not None: age_limit = 0 if age_limit == 'N' else 18 thumbnails = [{ 'id': thumb_format, 'url': thumb['url'], 'width': int_or_none(thumb.get('width')), 'height': int_or_none(thumb.get('height')), } for thumb_format, thumb in info.get('cover', {}).items() if thumb.get('url')] return { 'id': video_id, 'title': title, 'description': description, 'duration': duration, 'timestamp': timestamp, 'age_limit': age_limit, 'thumbnails': thumbnails, 'formats': formats, }
# Camel Servlet REST and OSGi Blueprint example ========================================== Introduction This example shows how to use Servlet REST to define REST endpoints in Camel routes using the Rest DSL Build You will need to compile this example first: mvn install run To install Apache Camel in Karaf you type in the shell (we use version ${project.version}): feature:repo-add camel ${project.version} feature:install camel First you need to install the following features in Karaf/ServiceMix with: feature:install camel-servlet feature:install camel-jackson feature:install war Then you can install the Camel example: install -s mvn:org.apache.camel/<API key>/${project.version} And you can see the application running by tailing the logs log:tail And you can use <kbd>ctrl</kbd>+<kbd>c</kbd> to stop tailing the log. There is a user REST service that supports the following operations - GET /user/{id} - to view a user with the given id </li> - GET /user/final - to view all users</li> - PUT /user - to update/create an user</li> The view operations are HTTP GET, and update is using HTTP PUT. From a web browser you can access the first two services using the following links http://localhost:8181/<API key>/rest/user/123 - to view the user with id 123 http://localhost:8181/<API key>/rest/user/findAll - to list all users From the command shell you can use curl to access the service as shown below: curl -X GET -H "Accept: application/json" http://localhost:8181/<API key>/rest/user/123 curl -X GET -H "Accept: application/json" http://localhost:8181/<API key>/rest/user/findAll curl -X PUT -d "{ \"id\": 666, \"name\": \"The devil\"}" -H "Accept: application/json" http://localhost:8181/<API key>/rest/user Configuration This example is implemented in XML DSL in the `src/main/resources/OSGI-INF/bluepring/camel.xml` file. Forum, Help, etc If you hit an problems please let us know on the Camel Forums <http://camel.apache.org/discussion-forums.html> Please help us make Apache Camel better - we appreciate any feedback you may have. Enjoy!
// This file is part of GCC. // GCC is free software; you can redistribute it and/or modify // the Free Software Foundation; either version 3, or (at your option) // any later version. // GCC is distributed in the hope that it will be useful, // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // Under Section 7 of GPL version 3, you are granted additional // 3.1, as published by the Free Software Foundation. // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include "tinfo.h" namespace __cxxabiv1 { __pointer_type_info:: ~__pointer_type_info () {} bool __pointer_type_info:: __is_pointer_p () const { return true; } bool __pointer_type_info:: __pointer_catch (const __pbase_type_info *thrown_type, void **thr_obj, unsigned outer) const { #ifdef __GXX_RTTI if (outer < 2 && *__pointee == typeid (void)) { // conversion to void return !thrown_type->__pointee->__is_function_p (); } #endif return __pbase_type_info::__pointer_catch (thrown_type, thr_obj, outer); } }
YUI.add('node-menunav', function (Y, NAME) { // Util shortcuts var UA = Y.UA, later = Y.later, getClassName = Y.ClassNameManager.getClassName, // Frequently used strings MENU = "menu", MENUITEM = "menuitem", HIDDEN = "hidden", PARENT_NODE = "parentNode", CHILDREN = "children", OFFSET_HEIGHT = "offsetHeight", OFFSET_WIDTH = "offsetWidth", PX = "px", ID = "id", PERIOD = ".", HANDLED_MOUSEOUT = "handledMouseOut", HANDLED_MOUSEOVER = "handledMouseOver", ACTIVE = "active", LABEL = "label", LOWERCASE_A = "a", MOUSEDOWN = "mousedown", KEYDOWN = "keydown", CLICK = "click", EMPTY_STRING = "", FIRST_OF_TYPE = "first-of-type", ROLE = "role", PRESENTATION = "presentation", DESCENDANTS = "descendants", UI = "UI", ACTIVE_DESCENDANT = "activeDescendant", USE_ARIA = "useARIA", ARIA_HIDDEN = "aria-hidden", CONTENT = "content", HOST = "host", <API key> = ACTIVE_DESCENDANT + "Change", // Attribute keys <API key> = "autoSubmenuDisplay", MOUSEOUT_HIDE_DELAY = "mouseOutHideDelay", // CSS class names CSS_MENU = getClassName(MENU), CSS_MENU_HIDDEN = getClassName(MENU, HIDDEN), CSS_MENU_HORIZONTAL = getClassName(MENU, "horizontal"), CSS_MENU_LABEL = getClassName(MENU, LABEL), <API key> = getClassName(MENU, LABEL, ACTIVE), <API key> = getClassName(MENU, LABEL, (MENU + "visible")), CSS_MENUITEM = getClassName(MENUITEM), CSS_MENUITEM_ACTIVE = getClassName(MENUITEM, ACTIVE), // CSS selectors MENU_SELECTOR = PERIOD + CSS_MENU, <API key> = (PERIOD + getClassName(MENU, "toggle")), <API key> = PERIOD + getClassName(MENU, CONTENT), MENU_LABEL_SELECTOR = PERIOD + CSS_MENU_LABEL, STANDARD_QUERY = ">" + <API key> + ">ul>li>a", EXTENDED_QUERY = ">" + <API key> + ">ul>li>" + MENU_LABEL_SELECTOR + ">a:first-child"; // Utility functions var getPreviousSibling = function (node) { var oPrevious = node.previous(), oChildren; if (!oPrevious) { oChildren = node.get(PARENT_NODE).get(CHILDREN); oPrevious = oChildren.item(oChildren.size() - 1); } return oPrevious; }; var getNextSibling = function (node) { var oNext = node.next(); if (!oNext) { oNext = node.get(PARENT_NODE).get(CHILDREN).item(0); } return oNext; }; var isAnchor = function (node) { var bReturnVal = false; if (node) { bReturnVal = node.get("nodeName").toLowerCase() === LOWERCASE_A; } return bReturnVal; }; var isMenuItem = function (node) { return node.hasClass(CSS_MENUITEM); }; var isMenuLabel = function (node) { return node.hasClass(CSS_MENU_LABEL); }; var isHorizontalMenu = function (menu) { return menu.hasClass(CSS_MENU_HORIZONTAL); }; var hasVisibleSubmenu = function (menuLabel) { return menuLabel.hasClass(<API key>); }; var getItemAnchor = function (node) { return isAnchor(node) ? node : node.one(LOWERCASE_A); }; var getNodeWithClass = function (node, className, searchAncestors) { var oItem; if (node) { if (node.hasClass(className)) { oItem = node; } if (!oItem && searchAncestors) { oItem = node.ancestor((PERIOD + className)); } } return oItem; }; var getParentMenu = function (node) { return node.ancestor(MENU_SELECTOR); }; var getMenu = function (node, searchAncestors) { return getNodeWithClass(node, CSS_MENU, searchAncestors); }; var getMenuItem = function (node, searchAncestors) { var oItem; if (node) { oItem = getNodeWithClass(node, CSS_MENUITEM, searchAncestors); } return oItem; }; var getMenuLabel = function (node, searchAncestors) { var oItem; if (node) { if (searchAncestors) { oItem = getNodeWithClass(node, CSS_MENU_LABEL, searchAncestors); } else { oItem = getNodeWithClass(node, CSS_MENU_LABEL) || node.one((PERIOD + CSS_MENU_LABEL)); } } return oItem; }; var getItem = function (node, searchAncestors) { var oItem; if (node) { oItem = getMenuItem(node, searchAncestors) || getMenuLabel(node, searchAncestors); } return oItem; }; var getFirstItem = function (menu) { return getItem(menu.one("li")); }; var getActiveClass = function (node) { return isMenuItem(node) ? CSS_MENUITEM_ACTIVE : <API key>; }; var <API key> = function (node, target) { return node && !node[HANDLED_MOUSEOVER] && (node.compareTo(target) || node.contains(target)); }; var <API key> = function (node, relatedTarget) { return node && !node[HANDLED_MOUSEOUT] && (!node.compareTo(relatedTarget) && !node.contains(relatedTarget)); }; /** * The NodeMenuNav class is a plugin for a Node instance. The class is used via * the <a href="Node.html#method_plug"><code>plug</code></a> method of Node and * should not be instantiated directly. * @namespace plugin * @class NodeMenuNav */ var NodeMenuNav = function () { NodeMenuNav.superclass.constructor.apply(this, arguments); }; NodeMenuNav.NAME = "nodeMenuNav"; NodeMenuNav.NS = "menuNav"; /** * @property SHIM_TEMPLATE_TITLE * @description String representing the value for the <code>title</code> * attribute for the shim used to prevent <code>&#60;select&#62;</code> elements * from poking through menus in IE 6. * @default "Menu Stacking Shim" * @type String */ NodeMenuNav.SHIM_TEMPLATE_TITLE = "Menu Stacking Shim"; /** * @property SHIM_TEMPLATE * @description String representing the HTML used to create the * <code>&#60;iframe&#62;</code> shim used to prevent * <code>&#60;select&#62;</code> elements from poking through menus in IE 6. * @default &#34;&#60;iframe frameborder=&#34;0&#34; tabindex=&#34;-1&#34; * class=&#34;yui-shim&#34; title=&#34;Menu Stacking Shim&#34; * src=&#34;javascript:false;&#34;&#62;&#60;/iframe&#62;&#34; * @type String */ // <iframe> shim notes: // 1) Need to set the "frameBorder" property to 0 to suppress the default // <iframe> border in IE. (Setting the CSS "border" property alone doesn't // suppress it.) // 2) The "src" attribute of the <iframe> is set to "javascript:false;" so // that it won't load a page inside it, preventing the secure/nonsecure // warning in IE when using HTTPS. // 3) Since the role of the <iframe> shim is completely presentational, its // "tabindex" attribute is set to "-1" and its title attribute is set to // "Menu Stacking Shim". Both strategies help users of screen readers to // avoid mistakenly interacting with the <iframe> shim. NodeMenuNav.SHIM_TEMPLATE = '<iframe frameborder="0" tabindex="-1" class="' + getClassName("shim") + '" title="' + NodeMenuNav.SHIM_TEMPLATE_TITLE + '" src="javascript:false;"></iframe>'; NodeMenuNav.ATTRS = { /** * Boolean indicating if use of the WAI-ARIA Roles and States should be * enabled for the menu. * * @attribute useARIA * @readOnly * @writeOnce * @default true * @type boolean */ useARIA: { value: true, writeOnce: true, lazyAdd: false, setter: function (value) { var oMenu = this.get(HOST), oMenuLabel, oMenuToggle, oSubmenu, sID; if (value) { oMenu.set(ROLE, MENU); oMenu.all("ul,li," + <API key>).set(ROLE, PRESENTATION); oMenu.all((PERIOD + getClassName(MENUITEM, CONTENT))).set(ROLE, MENUITEM); oMenu.all((PERIOD + CSS_MENU_LABEL)).each(function (node) { oMenuLabel = node; oMenuToggle = node.one(<API key>); if (oMenuToggle) { oMenuToggle.set(ROLE, PRESENTATION); oMenuLabel = oMenuToggle.previous(); } oMenuLabel.set(ROLE, MENUITEM); oMenuLabel.set("aria-haspopup", true); oSubmenu = node.next(); if (oSubmenu) { oSubmenu.set(ROLE, MENU); oMenuLabel = oSubmenu.previous(); oMenuToggle = oMenuLabel.one(<API key>); if (oMenuToggle) { oMenuLabel = oMenuToggle; } sID = Y.stamp(oMenuLabel); if (!oMenuLabel.get(ID)) { oMenuLabel.set(ID, sID); } oSubmenu.set("aria-labelledby", sID); oSubmenu.set(ARIA_HIDDEN, true); } }); } } }, /** * Boolean indicating if submenus are automatically made visible when the * user mouses over the menu's items. * * @attribute autoSubmenuDisplay * @readOnly * @writeOnce * @default true * @type boolean */ autoSubmenuDisplay: { value: true, writeOnce: true }, /** * Number indicating the time (in milliseconds) that should expire before a * submenu is made visible when the user mouses over the menu's label. * * @attribute submenuShowDelay * @readOnly * @writeOnce * @default 250 * @type Number */ submenuShowDelay: { value: 250, writeOnce: true }, /** * Number indicating the time (in milliseconds) that should expire before a * submenu is hidden when the user mouses out of a menu label heading in the * direction of a submenu. * * @attribute submenuHideDelay * @readOnly * @writeOnce * @default 250 * @type Number */ submenuHideDelay: { value: 250, writeOnce: true }, /** * Number indicating the time (in milliseconds) that should expire before a * submenu is hidden when the user mouses out of it. * * @attribute mouseOutHideDelay * @readOnly * @writeOnce * @default 750 * @type Number */ mouseOutHideDelay: { value: 750, writeOnce: true } }; Y.extend(NodeMenuNav, Y.Plugin.Base, { // Protected properties /** * @property _rootMenu * @description Node instance representing the root menu in the menu. * @default null * @protected * @type Node */ _rootMenu: null, /** * @property _activeItem * @description Node instance representing the menu's active descendent: * the menuitem or menu label the user is currently interacting with. * @default null * @protected * @type Node */ _activeItem: null, /** * @property _activeMenu * @description Node instance representing the menu that is the parent of * the menu's active descendent. * @default null * @protected * @type Node */ _activeMenu: null, /** * @property _hasFocus * @description Boolean indicating if the menu has focus. * @default false * @protected * @type Boolean */ _hasFocus: false, // In gecko-based browsers a mouseover and mouseout event will fire even // if a DOM element moves out from under the mouse without the user // actually moving the mouse. This bug affects NodeMenuNav because the // user can hit the Esc key to hide a menu, and if the mouse is over the // menu when the user presses Esc, the _onMenuMouseOut handler will be // called. To fix this bug the following flag (_blockMouseEvent) is used // to block the code in the _onMenuMouseOut handler from executing. /** * @property _blockMouseEvent * @description Boolean indicating whether or not to handle the * "mouseover" event. * @default false * @protected * @type Boolean */ _blockMouseEvent: false, /** * @property _currentMouseX * @description Number representing the current x coordinate of the mouse * inside the menu. * @default 0 * @protected * @type Number */ _currentMouseX: 0, /** * @property _movingToSubmenu * @description Boolean indicating if the mouse is moving from a menu * label to its corresponding submenu. * @default false * @protected * @type Boolean */ _movingToSubmenu: false, /** * @property _showSubmenuTimer * @description Timer used to show a submenu. * @default null * @protected * @type Object */ _showSubmenuTimer: null, /** * @property _hideSubmenuTimer * @description Timer used to hide a submenu. * @default null * @protected * @type Object */ _hideSubmenuTimer: null, /** * @property <API key> * @description Timer used to hide a all submenus. * @default null * @protected * @type Object */ <API key>: null, /** * @property _firstItem * @description Node instance representing the first item (menuitem or menu * label) in the root menu of a menu. * @default null * @protected * @type Node */ _firstItem: null, // Public methods initializer: function (config) { var menuNav = this, oRootMenu = this.get(HOST), aHandlers = [], oDoc; Y.log("WARNING: Node-MenuNav is a deprecated module as of YUI 3.9.0. This module will be removed from a later version of the library.", "warn"); if (oRootMenu) { menuNav._rootMenu = oRootMenu; oRootMenu.all("ul:first-child").addClass(FIRST_OF_TYPE); // Hide all visible submenus oRootMenu.all(MENU_SELECTOR).addClass(CSS_MENU_HIDDEN); // Wire up all event handlers aHandlers.push(oRootMenu.on("mouseover", menuNav._onMouseOver, menuNav)); aHandlers.push(oRootMenu.on("mouseout", menuNav._onMouseOut, menuNav)); aHandlers.push(oRootMenu.on("mousemove", menuNav._onMouseMove, menuNav)); aHandlers.push(oRootMenu.on(MOUSEDOWN, menuNav.<API key>, menuNav)); aHandlers.push(Y.on("key", menuNav.<API key>, oRootMenu, "down:13", menuNav)); aHandlers.push(oRootMenu.on(CLICK, menuNav.<API key>, menuNav)); aHandlers.push(oRootMenu.on("keypress", menuNav._onKeyPress, menuNav)); aHandlers.push(oRootMenu.on(KEYDOWN, menuNav._onKeyDown, menuNav)); oDoc = oRootMenu.get("ownerDocument"); aHandlers.push(oDoc.on(MOUSEDOWN, menuNav._onDocMouseDown, menuNav)); aHandlers.push(oDoc.on("focus", menuNav._onDocFocus, menuNav)); this._eventHandlers = aHandlers; menuNav._initFocusManager(); } }, destructor: function () { var aHandlers = this._eventHandlers; if (aHandlers) { Y.Array.each(aHandlers, function (handle) { handle.detach(); }); this._eventHandlers = null; } this.get(HOST).unplug("focusManager"); }, // Protected methods /** * @method _isRoot * @description Returns a boolean indicating if the specified menu is the * root menu in the menu. * @protected * @param {Node} menu Node instance representing a menu. * @return {Boolean} Boolean indicating if the specified menu is the root * menu in the menu. */ _isRoot: function (menu) { return this._rootMenu.compareTo(menu); }, /** * @method _getTopmostSubmenu * @description Returns the topmost submenu of a submenu hierarchy. * @protected * @param {Node} menu Node instance representing a menu. * @return {Node} Node instance representing a menu. */ _getTopmostSubmenu: function (menu) { var menuNav = this, oMenu = getParentMenu(menu), returnVal; if (!oMenu) { returnVal = menu; } else if (menuNav._isRoot(oMenu)) { returnVal = menu; } else { returnVal = menuNav._getTopmostSubmenu(oMenu); } return returnVal; }, /** * @method _clearActiveItem * @description Clears the menu's active descendent. * @protected */ _clearActiveItem: function () { var menuNav = this, oActiveItem = menuNav._activeItem; if (oActiveItem) { oActiveItem.removeClass(getActiveClass(oActiveItem)); } menuNav._activeItem = null; }, /** * @method _setActiveItem * @description Sets the specified menuitem or menu label as the menu's * active descendent. * @protected * @param {Node} item Node instance representing a menuitem or menu label. */ _setActiveItem: function (item) { var menuNav = this; if (item) { menuNav._clearActiveItem(); item.addClass(getActiveClass(item)); menuNav._activeItem = item; } }, /** * @method _focusItem * @description Focuses the specified menuitem or menu label. * @protected * @param {Node} item Node instance representing a menuitem or menu label. */ _focusItem: function (item) { var menuNav = this, oMenu, oItem; if (item && menuNav._hasFocus) { oMenu = getParentMenu(item); oItem = getItemAnchor(item); if (oMenu && !oMenu.compareTo(menuNav._activeMenu)) { menuNav._activeMenu = oMenu; menuNav._initFocusManager(); } menuNav._focusManager.focus(oItem); } }, /** * @method _showMenu * @description Shows the specified menu. * @protected * @param {Node} menu Node instance representing a menu. */ _showMenu: function (menu) { var oParentMenu = getParentMenu(menu), oLI = menu.get(PARENT_NODE), aXY = oLI.getXY(); if (this.get(USE_ARIA)) { menu.set(ARIA_HIDDEN, false); } if (isHorizontalMenu(oParentMenu)) { aXY[1] = aXY[1] + oLI.get(OFFSET_HEIGHT); } else { aXY[0] = aXY[0] + oLI.get(OFFSET_WIDTH); } menu.setXY(aXY); if (UA.ie && UA.ie < 8) { if (UA.ie === 6 && !menu.hasIFrameShim) { menu.appendChild(Y.Node.create(NodeMenuNav.SHIM_TEMPLATE)); menu.hasIFrameShim = true; } // Clear previous values for height and width menu.setStyles({ height: EMPTY_STRING, width: EMPTY_STRING }); // Set the width and height of the menu's bounding box - this is // necessary for IE 6 so that the CSS for the <iframe> shim can // simply set the <iframe>'s width and height to 100% to ensure // that dimensions of an <iframe> shim are always sync'd to the // that of its parent menu. Specifying a width and height also // helps when positioning decorator elements (for creating effects // like rounded corners) inside a menu's bounding box in IE 7. menu.setStyles({ height: (menu.get(OFFSET_HEIGHT) + PX), width: (menu.get(OFFSET_WIDTH) + PX) }); } menu.previous().addClass(<API key>); menu.removeClass(CSS_MENU_HIDDEN); }, /** * @method _hideMenu * @description Hides the specified menu. * @protected * @param {Node} menu Node instance representing a menu. * @param {Boolean} <API key> Boolean indicating if the label * for the specified * menu should be focused and set as active. */ _hideMenu: function (menu, <API key>) { var menuNav = this, oLabel = menu.previous(), oActiveItem; oLabel.removeClass(<API key>); if (<API key>) { menuNav._focusItem(oLabel); menuNav._setActiveItem(oLabel); } oActiveItem = menu.one((PERIOD + CSS_MENUITEM_ACTIVE)); if (oActiveItem) { oActiveItem.removeClass(CSS_MENUITEM_ACTIVE); } // Clear the values for top and left that were set by the call to // "setXY" when the menu was shown so that the hidden position // specified in the core CSS file will take affect. menu.setStyles({ left: EMPTY_STRING, top: EMPTY_STRING }); menu.addClass(CSS_MENU_HIDDEN); if (menuNav.get(USE_ARIA)) { menu.set(ARIA_HIDDEN, true); } }, /** * @method _hideAllSubmenus * @description Hides all submenus of the specified menu. * @protected * @param {Node} menu Node instance representing a menu. */ _hideAllSubmenus: function (menu) { var menuNav = this; menu.all(MENU_SELECTOR).each(Y.bind(function (submenuNode) { menuNav._hideMenu(submenuNode); }, menuNav)); }, /** * @method <API key> * @description Cancels the timer used to show a submenu. * @protected */ <API key>: function () { var menuNav = this, oShowSubmenuTimer = menuNav._showSubmenuTimer; if (oShowSubmenuTimer) { oShowSubmenuTimer.cancel(); menuNav._showSubmenuTimer = null; } }, /** * @method <API key> * @description Cancels the timer used to hide a submenu. * @protected */ <API key>: function () { var menuNav = this, oHideSubmenuTimer = menuNav._hideSubmenuTimer; if (oHideSubmenuTimer) { oHideSubmenuTimer.cancel(); menuNav._hideSubmenuTimer = null; } }, /** * @method _initFocusManager * @description Initializes and updates the Focus Manager so that is is * always managing descendants of the active menu. * @protected */ _initFocusManager: function () { var menuNav = this, oRootMenu = menuNav._rootMenu, oMenu = menuNav._activeMenu || oRootMenu, sSelectorBase = menuNav._isRoot(oMenu) ? EMPTY_STRING : ("#" + oMenu.get("id")), oFocusManager = menuNav._focusManager, sKeysVal, sDescendantSelector, sQuery; if (isHorizontalMenu(oMenu)) { sDescendantSelector = sSelectorBase + STANDARD_QUERY + "," + sSelectorBase + EXTENDED_QUERY; sKeysVal = { next: "down:39", previous: "down:37" }; } else { sDescendantSelector = sSelectorBase + STANDARD_QUERY; sKeysVal = { next: "down:40", previous: "down:38" }; } if (!oFocusManager) { oRootMenu.plug(Y.Plugin.NodeFocusManager, { descendants: sDescendantSelector, keys: sKeysVal, circular: true }); oFocusManager = oRootMenu.focusManager; sQuery = "#" + oRootMenu.get("id") + MENU_SELECTOR + " a," + <API key>; oRootMenu.all(sQuery).set("tabIndex", -1); oFocusManager.on(<API key>, this.<API key>, oFocusManager, this); oFocusManager.after(<API key>, this.<API key>, oFocusManager, this); menuNav._focusManager = oFocusManager; } else { oFocusManager.set(ACTIVE_DESCENDANT, -1); oFocusManager.set(DESCENDANTS, sDescendantSelector); oFocusManager.set("keys", sKeysVal); } }, // Event handlers for discrete pieces of pieces of the menu /** * @method <API key> * @description "<API key>" event handler for menu's * Focus Manager. * @protected * @param {Object} event Object representing the Attribute change event. * @param {NodeMenuNav} menuNav Object representing the NodeMenuNav instance. */ <API key>: function (event, menuNav) { if (event.src === UI && menuNav._activeMenu && !menuNav._movingToSubmenu) { menuNav._hideAllSubmenus(menuNav._activeMenu); } }, /** * @method <API key> * @description "<API key>" event handler for menu's * Focus Manager. * @protected * @param {Object} event Object representing the Attribute change event. * @param {NodeMenuNav} menuNav Object representing the NodeMenuNav instance. */ <API key>: function (event, menuNav) { var oItem; if (event.src === UI) { oItem = getItem(this.get(DESCENDANTS).item(event.newVal), true); menuNav._setActiveItem(oItem); } }, /** * @method _onDocFocus * @description "focus" event handler for the owner document of the MenuNav. * @protected * @param {Object} event Object representing the DOM event. */ _onDocFocus: function (event) { var menuNav = this, oActiveItem = menuNav._activeItem, oTarget = event.target, oMenu; if (menuNav._rootMenu.contains(oTarget)) { // The menu has focus if (menuNav._hasFocus) { oMenu = getParentMenu(oTarget); // If the element that was focused is a descendant of the // root menu, but is in a submenu not currently being // managed by the Focus Manager, update the Focus Manager so // that it is now managing the submenu that is the parent of // the element that was focused. if (!menuNav._activeMenu.compareTo(oMenu)) { menuNav._activeMenu = oMenu; menuNav._initFocusManager(); menuNav._focusManager.set(ACTIVE_DESCENDANT, oTarget); menuNav._setActiveItem(getItem(oTarget, true)); } } else { // Initial focus // First time the menu has been focused, need to setup focused // state and established active active descendant menuNav._hasFocus = true; oActiveItem = getItem(oTarget, true); if (oActiveItem) { menuNav._setActiveItem(oActiveItem); } } } else { // The menu has lost focus menuNav._clearActiveItem(); menuNav.<API key>(); menuNav._hideAllSubmenus(menuNav._rootMenu); menuNav._activeMenu = menuNav._rootMenu; menuNav._initFocusManager(); menuNav._focusManager.set(ACTIVE_DESCENDANT, 0); menuNav._hasFocus = false; } }, /** * @method _onMenuMouseOver * @description "mouseover" event handler for a menu. * @protected * @param {Node} menu Node instance representing a menu. * @param {Object} event Object representing the DOM event. */ _onMenuMouseOver: function (menu, event) { var menuNav = this, <API key> = menuNav.<API key>; if (<API key>) { <API key>.cancel(); menuNav.<API key> = null; } menuNav.<API key>(); // Need to update the FocusManager in advance of focus a new // Menu in order to avoid the FocusManager thinking that // it has lost focus if (menu && !menu.compareTo(menuNav._activeMenu)) { menuNav._activeMenu = menu; if (menuNav._hasFocus) { menuNav._initFocusManager(); } } if (menuNav._movingToSubmenu && isHorizontalMenu(menu)) { menuNav._movingToSubmenu = false; } }, /** * @method _hideAndFocusLabel * @description Hides all of the submenus of the root menu and focuses the * label of the topmost submenu * @protected */ _hideAndFocusLabel: function () { var menuNav = this, oActiveMenu = menuNav._activeMenu, oSubmenu; menuNav._hideAllSubmenus(menuNav._rootMenu); if (oActiveMenu) { // Focus the label element for the topmost submenu oSubmenu = menuNav._getTopmostSubmenu(oActiveMenu); menuNav._focusItem(oSubmenu.previous()); } }, /** * @method _onMenuMouseOut * @description "mouseout" event handler for a menu. * @protected * @param {Node} menu Node instance representing a menu. * @param {Object} event Object representing the DOM event. */ _onMenuMouseOut: function (menu, event) { var menuNav = this, oActiveMenu = menuNav._activeMenu, oRelatedTarget = event.relatedTarget, oActiveItem = menuNav._activeItem, oParentMenu, oMenu; if (oActiveMenu && !oActiveMenu.contains(oRelatedTarget)) { oParentMenu = getParentMenu(oActiveMenu); if (oParentMenu && !oParentMenu.contains(oRelatedTarget)) { if (menuNav.get(MOUSEOUT_HIDE_DELAY) > 0) { menuNav.<API key>(); menuNav.<API key> = later(menuNav.get(MOUSEOUT_HIDE_DELAY), menuNav, menuNav._hideAndFocusLabel); } } else { if (oActiveItem) { oMenu = getParentMenu(oActiveItem); if (!menuNav._isRoot(oMenu)) { menuNav._focusItem(oMenu.previous()); } } } } }, /** * @method <API key> * @description "mouseover" event handler for a menu label. * @protected * @param {Node} menuLabel Node instance representing a menu label. * @param {Object} event Object representing the DOM event. */ <API key>: function (menuLabel, event) { var menuNav = this, oActiveMenu = menuNav._activeMenu, bIsRoot = menuNav._isRoot(oActiveMenu), <API key> = (menuNav.get(<API key>) && bIsRoot || !bIsRoot), submenuShowDelay = menuNav.get("submenuShowDelay"), oSubmenu; var showSubmenu = function (delay) { menuNav.<API key>(); menuNav.<API key>(); if (!hasVisibleSubmenu(menuLabel)) { oSubmenu = menuLabel.next(); if (oSubmenu) { menuNav._hideAllSubmenus(oActiveMenu); menuNav._showSubmenuTimer = later(delay, menuNav, menuNav._showMenu, oSubmenu); } } }; menuNav._focusItem(menuLabel); menuNav._setActiveItem(menuLabel); if (<API key>) { if (menuNav._movingToSubmenu) { // If the user is moving diagonally from a submenu to // another submenu and they then stop and pause on a // menu label for an amount of time equal to the amount of // time defined for the display of a submenu then show the // submenu immediately. //Y.message("Pause path"); menuNav._hoverTimer = later(submenuShowDelay, menuNav, function () { showSubmenu(0); }); } else { showSubmenu(submenuShowDelay); } } }, /** * @method <API key> * @description "mouseout" event handler for a menu label. * @protected * @param {Node} menuLabel Node instance representing a menu label. * @param {Object} event Object representing the DOM event. */ <API key>: function (menuLabel, event) { var menuNav = this, bIsRoot = menuNav._isRoot(menuNav._activeMenu), <API key> = (menuNav.get(<API key>) && bIsRoot || !bIsRoot), oRelatedTarget = event.relatedTarget, oSubmenu = menuLabel.next(), hoverTimer = menuNav._hoverTimer; if (hoverTimer) { hoverTimer.cancel(); } menuNav._clearActiveItem(); if (<API key>) { if (menuNav._movingToSubmenu && !menuNav._showSubmenuTimer && oSubmenu) { // If the mouse is moving diagonally toward the submenu and // another submenu isn't in the process of being displayed // (via a timer), then hide the submenu via a timer to give // the user some time to reach the submenu. menuNav._hideSubmenuTimer = later(menuNav.get("submenuHideDelay"), menuNav, menuNav._hideMenu, oSubmenu); } else if (!menuNav._movingToSubmenu && oSubmenu && (!oRelatedTarget || (oRelatedTarget && !oSubmenu.contains(oRelatedTarget) && !oRelatedTarget.compareTo(oSubmenu)))) { // If the mouse is not moving toward the submenu, cancel any // submenus that might be in the process of being displayed // (via a timer) and hide this submenu immediately. menuNav.<API key>(); menuNav._hideMenu(oSubmenu); } } }, /** * @method <API key> * @description "mouseover" event handler for a menuitem. * @protected * @param {Node} menuItem Node instance representing a menuitem. * @param {Object} event Object representing the DOM event. */ <API key>: function (menuItem, event) { var menuNav = this, oActiveMenu = menuNav._activeMenu, bIsRoot = menuNav._isRoot(oActiveMenu), <API key> = (menuNav.get(<API key>) && bIsRoot || !bIsRoot); menuNav._focusItem(menuItem); menuNav._setActiveItem(menuItem); if (<API key> && !menuNav._movingToSubmenu) { menuNav._hideAllSubmenus(oActiveMenu); } }, /** * @method _onMenuItemMouseOut * @description "mouseout" event handler for a menuitem. * @protected * @param {Node} menuItem Node instance representing a menuitem. * @param {Object} event Object representing the DOM event. */ _onMenuItemMouseOut: function (menuItem, event) { this._clearActiveItem(); }, /** * @method <API key> * @description "keydown" event handler for vertical menus. * @protected * @param {Object} event Object representing the DOM event. */ <API key>: function (event) { var menuNav = this, oActiveMenu = menuNav._activeMenu, oRootMenu = menuNav._rootMenu, oTarget = event.target, bPreventDefault = false, nKeyCode = event.keyCode, oSubmenu, oParentMenu, oLI, oItem; switch (nKeyCode) { case 37: // left arrow oParentMenu = getParentMenu(oActiveMenu); if (oParentMenu && isHorizontalMenu(oParentMenu)) { menuNav._hideMenu(oActiveMenu); oLI = getPreviousSibling(oActiveMenu.get(PARENT_NODE)); oItem = getItem(oLI); if (oItem) { if (isMenuLabel(oItem)) { // Menu label oSubmenu = oItem.next(); if (oSubmenu) { menuNav._showMenu(oSubmenu); menuNav._focusItem(getFirstItem(oSubmenu)); menuNav._setActiveItem(getFirstItem(oSubmenu)); } else { menuNav._focusItem(oItem); menuNav._setActiveItem(oItem); } } else { // MenuItem menuNav._focusItem(oItem); menuNav._setActiveItem(oItem); } } } else if (!menuNav._isRoot(oActiveMenu)) { menuNav._hideMenu(oActiveMenu, true); } bPreventDefault = true; break; case 39: // right arrow if (isMenuLabel(oTarget)) { oSubmenu = oTarget.next(); if (oSubmenu) { menuNav._showMenu(oSubmenu); menuNav._focusItem(getFirstItem(oSubmenu)); menuNav._setActiveItem(getFirstItem(oSubmenu)); } } else if (isHorizontalMenu(oRootMenu)) { oSubmenu = menuNav._getTopmostSubmenu(oActiveMenu); oLI = getNextSibling(oSubmenu.get(PARENT_NODE)); oItem = getItem(oLI); menuNav._hideAllSubmenus(oRootMenu); if (oItem) { if (isMenuLabel(oItem)) { // Menu label oSubmenu = oItem.next(); if (oSubmenu) { menuNav._showMenu(oSubmenu); menuNav._focusItem(getFirstItem(oSubmenu)); menuNav._setActiveItem(getFirstItem(oSubmenu)); } else { menuNav._focusItem(oItem); menuNav._setActiveItem(oItem); } } else { // MenuItem menuNav._focusItem(oItem); menuNav._setActiveItem(oItem); } } } bPreventDefault = true; break; } if (bPreventDefault) { // Prevent the browser from scrolling the window event.preventDefault(); } }, /** * @method <API key> * @description "keydown" event handler for horizontal menus. * @protected * @param {Object} event Object representing the DOM event. */ <API key>: function (event) { var menuNav = this, oActiveMenu = menuNav._activeMenu, oTarget = event.target, oFocusedItem = getItem(oTarget, true), bPreventDefault = false, nKeyCode = event.keyCode, oSubmenu; if (nKeyCode === 40) { menuNav._hideAllSubmenus(oActiveMenu); if (isMenuLabel(oFocusedItem)) { oSubmenu = oFocusedItem.next(); if (oSubmenu) { menuNav._showMenu(oSubmenu); menuNav._focusItem(getFirstItem(oSubmenu)); menuNav._setActiveItem(getFirstItem(oSubmenu)); } bPreventDefault = true; } } if (bPreventDefault) { // Prevent the browser from scrolling the window event.preventDefault(); } }, // Generic DOM Event handlers /** * @method _onMouseMove * @description "mousemove" event handler for the menu. * @protected * @param {Object} event Object representing the DOM event. */ _onMouseMove: function (event) { var menuNav = this; // Using a timer to set the value of the "_currentMouseX" property // helps improve the reliability of the calculation used to set the // value of the "_movingToSubmenu" property - especially in Opera. later(10, menuNav, function () { menuNav._currentMouseX = event.pageX; }); }, /** * @method _onMouseOver * @description "mouseover" event handler for the menu. * @protected * @param {Object} event Object representing the DOM event. */ _onMouseOver: function (event) { var menuNav = this, oTarget, oMenu, oMenuLabel, oParentMenu, oMenuItem; if (menuNav._blockMouseEvent) { menuNav._blockMouseEvent = false; } else { oTarget = event.target; oMenu = getMenu(oTarget, true); oMenuLabel = getMenuLabel(oTarget, true); oMenuItem = getMenuItem(oTarget, true); if (<API key>(oMenu, oTarget)) { menuNav._onMenuMouseOver(oMenu, event); oMenu[HANDLED_MOUSEOVER] = true; oMenu[HANDLED_MOUSEOUT] = false; oParentMenu = getParentMenu(oMenu); if (oParentMenu) { oParentMenu[HANDLED_MOUSEOUT] = true; oParentMenu[HANDLED_MOUSEOVER] = false; } } if (<API key>(oMenuLabel, oTarget)) { menuNav.<API key>(oMenuLabel, event); oMenuLabel[HANDLED_MOUSEOVER] = true; oMenuLabel[HANDLED_MOUSEOUT] = false; } if (<API key>(oMenuItem, oTarget)) { menuNav.<API key>(oMenuItem, event); oMenuItem[HANDLED_MOUSEOVER] = true; oMenuItem[HANDLED_MOUSEOUT] = false; } } }, /** * @method _onMouseOut * @description "mouseout" event handler for the menu. * @protected * @param {Object} event Object representing the DOM event. */ _onMouseOut: function (event) { var menuNav = this, oActiveMenu = menuNav._activeMenu, bMovingToSubmenu = false, oTarget, oRelatedTarget, oMenu, oMenuLabel, oSubmenu, oMenuItem; menuNav._movingToSubmenu = (oActiveMenu && !isHorizontalMenu(oActiveMenu) && ((event.pageX - 5) > menuNav._currentMouseX)); oTarget = event.target; oRelatedTarget = event.relatedTarget; oMenu = getMenu(oTarget, true); oMenuLabel = getMenuLabel(oTarget, true); oMenuItem = getMenuItem(oTarget, true); if (<API key>(oMenuLabel, oRelatedTarget)) { menuNav.<API key>(oMenuLabel, event); oMenuLabel[HANDLED_MOUSEOUT] = true; oMenuLabel[HANDLED_MOUSEOVER] = false; } if (<API key>(oMenuItem, oRelatedTarget)) { menuNav._onMenuItemMouseOut(oMenuItem, event); oMenuItem[HANDLED_MOUSEOUT] = true; oMenuItem[HANDLED_MOUSEOVER] = false; } if (oMenuLabel) { oSubmenu = oMenuLabel.next(); if (oSubmenu && oRelatedTarget && (oRelatedTarget.compareTo(oSubmenu) || oSubmenu.contains(oRelatedTarget))) { bMovingToSubmenu = true; } } if (<API key>(oMenu, oRelatedTarget) || bMovingToSubmenu) { menuNav._onMenuMouseOut(oMenu, event); oMenu[HANDLED_MOUSEOUT] = true; oMenu[HANDLED_MOUSEOVER] = false; } }, /** * @method <API key> * @description "mousedown," "keydown," and "click" event handler for the * menu used to toggle the display of a submenu. * @protected * @param {Object} event Object representing the DOM event. */ <API key>: function (event) { var menuNav = this, oTarget = event.target, oMenuLabel = getMenuLabel(oTarget, true), sType = event.type, oAnchor, oSubmenu, sHref, nHashPos, nLen, sId; if (oMenuLabel) { oAnchor = isAnchor(oTarget) ? oTarget : oTarget.ancestor(isAnchor); if (oAnchor) { // Need to pass "2" as a second argument to "getAttribute" for // IE otherwise IE will return a fully qualified URL for the // value of the "href" attribute. sHref = oAnchor.getAttribute("href", 2); nHashPos = sHref.indexOf(" nLen = sHref.length; if (nHashPos === 0 && nLen > 1) { sId = sHref.substr(1, nLen); oSubmenu = oMenuLabel.next(); if (oSubmenu && (oSubmenu.get(ID) === sId)) { if (sType === MOUSEDOWN || sType === KEYDOWN) { if ((UA.opera || UA.gecko || UA.ie) && sType === KEYDOWN && !menuNav._preventClickHandle) { // Prevent the browser from following the URL of // the anchor element menuNav._preventClickHandle = menuNav._rootMenu.on("click", function (event) { event.preventDefault(); menuNav._preventClickHandle.detach(); menuNav._preventClickHandle = null; }); } if (sType == MOUSEDOWN) { // Prevent the target from getting focused by // default, since the element to be focused will // be determined by weather or not the submenu // is visible. event.preventDefault(); // FocusManager will attempt to focus any // descendant that is the target of the mousedown // event. Since we want to explicitly control // where focus is going, we need to call // "<API key>" to stop the // FocusManager from doing its thing. event.<API key>(); // The "_focusItem" method relies on the // "_hasFocus" property being set to true. The // "_hasFocus" property is normally set via a // "focus" event listener, but since we've // blocked focus from happening, we need to set // this property manually. menuNav._hasFocus = true; } if (menuNav._isRoot(getParentMenu(oTarget))) { // Event target is a submenu label in the root menu // Menu label toggle functionality if (hasVisibleSubmenu(oMenuLabel)) { menuNav._hideMenu(oSubmenu); menuNav._focusItem(oMenuLabel); menuNav._setActiveItem(oMenuLabel); } else { menuNav._hideAllSubmenus(menuNav._rootMenu); menuNav._showMenu(oSubmenu); menuNav._focusItem(getFirstItem(oSubmenu)); menuNav._setActiveItem(getFirstItem(oSubmenu)); } } else { // Event target is a submenu label within a submenu if (menuNav._activeItem == oMenuLabel) { menuNav._showMenu(oSubmenu); menuNav._focusItem(getFirstItem(oSubmenu)); menuNav._setActiveItem(getFirstItem(oSubmenu)); } else { if (!oMenuLabel._clickHandle) { oMenuLabel._clickHandle = oMenuLabel.on("click", function () { menuNav._hideAllSubmenus(menuNav._rootMenu); menuNav._hasFocus = false; menuNav._clearActiveItem(); oMenuLabel._clickHandle.detach(); oMenuLabel._clickHandle = null; }); } } } } if (sType === CLICK) { // Prevent the browser from following the URL of // the anchor element event.preventDefault(); } } } } } }, /** * @method _onKeyPress * @description "keypress" event handler for the menu. * @protected * @param {Object} event Object representing the DOM event. */ _onKeyPress: function (event) { switch (event.keyCode) { case 37: // left arrow case 38: // up arrow case 39: // right arrow case 40: // down arrow // Prevent the browser from scrolling the window event.preventDefault(); break; } }, /** * @method _onKeyDown * @description "keydown" event handler for the menu. * @protected * @param {Object} event Object representing the DOM event. */ _onKeyDown: function (event) { var menuNav = this, oActiveItem = menuNav._activeItem, oTarget = event.target, oActiveMenu = getParentMenu(oTarget), oSubmenu; if (oActiveMenu) { menuNav._activeMenu = oActiveMenu; if (isHorizontalMenu(oActiveMenu)) { menuNav.<API key>(event); } else { menuNav.<API key>(event); } if (event.keyCode === 27) { if (!menuNav._isRoot(oActiveMenu)) { if (UA.opera) { later(0, menuNav, function () { menuNav._hideMenu(oActiveMenu, true); }); } else { menuNav._hideMenu(oActiveMenu, true); } event.stopPropagation(); menuNav._blockMouseEvent = UA.gecko ? true : false; } else if (oActiveItem) { if (isMenuLabel(oActiveItem) && hasVisibleSubmenu(oActiveItem)) { oSubmenu = oActiveItem.next(); if (oSubmenu) { menuNav._hideMenu(oSubmenu); } } else { menuNav._focusManager.blur(); // This is necessary for Webkit since blurring the // active menuitem won't result in the document // gaining focus, meaning the that _onDocFocus // listener won't clear the active menuitem. menuNav._clearActiveItem(); menuNav._hasFocus = false; } } } } }, /** * @method _onDocMouseDown * @description "mousedown" event handler for the owner document of * the menu. * @protected * @param {Object} event Object representing the DOM event. */ _onDocMouseDown: function (event) { var menuNav = this, oRoot = menuNav._rootMenu, oTarget = event.target; if (!(oRoot.compareTo(oTarget) || oRoot.contains(oTarget))) { menuNav._hideAllSubmenus(oRoot); // Document doesn't receive focus in Webkit when the user mouses // down on it, so the "_hasFocus" property won't get set to the // correct value. The following line corrects the problem. if (UA.webkit) { menuNav._hasFocus = false; menuNav._clearActiveItem(); } } } }); Y.namespace('Plugin'); Y.Plugin.NodeMenuNav = NodeMenuNav; }, '@VERSION@', {"requires": ["node", "classnamemanager", "plugin", "node-focusmanager"], "skinnable": true});
package java.text; import java.io.<API key>; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.math.BigInteger; import java.math.RoundingMode; import java.text.spi.<API key>; import java.util.Currency; import java.util.HashMap; import java.util.Hashtable; import java.util.Locale; import java.util.Map; import java.util.ResourceBundle; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import java.util.spi.<API key>; import sun.util.locale.provider.<API key>; import sun.util.locale.provider.<API key>; /** * <code>NumberFormat</code> is the abstract base class for all number * formats. This class provides the interface for formatting and parsing * numbers. <code>NumberFormat</code> also provides methods for determining * which locales have number formats, and what their names are. * * <p> * <code>NumberFormat</code> helps you to format and parse numbers for any locale. * Your code can be completely independent of the locale conventions for * decimal points, <API key>, or even the particular decimal * digits used, or whether the number format is even decimal. * * <p> * To format a number for the current Locale, use one of the factory * class methods: * <blockquote> * <pre>{@code * myString = NumberFormat.getInstance().format(myNumber); * }</pre> * </blockquote> * If you are formatting multiple numbers, it is * more efficient to get the format and use it multiple times so that * the system doesn't have to fetch the information about the local * language and country conventions multiple times. * <blockquote> * <pre>{@code * NumberFormat nf = NumberFormat.getInstance(); * for (int i = 0; i < myNumber.length; ++i) { * output.println(nf.format(myNumber[i]) + "; "); * } * }</pre> * </blockquote> * To format a number for a different Locale, specify it in the * call to <code>getInstance</code>. * <blockquote> * <pre>{@code * NumberFormat nf = NumberFormat.getInstance(Locale.FRENCH); * }</pre> * </blockquote> * You can also use a <code>NumberFormat</code> to parse numbers: * <blockquote> * <pre>{@code * myNumber = nf.parse(myString); * }</pre> * </blockquote> * Use <code>getInstance</code> or <code>getNumberInstance</code> to get the * normal number format. Use <code>getIntegerInstance</code> to get an * integer number format. Use <code>getCurrencyInstance</code> to get the * currency number format. And use <code>getPercentInstance</code> to get a * format for displaying percentages. With this format, a fraction like * 0.53 is displayed as 53%. * * <p> * You can also control the display of numbers with such methods as * <code><API key></code>. * If you want even more control over the format or parsing, * or want to give your users more control, * you can try casting the <code>NumberFormat</code> you get from the factory methods * to a <code>DecimalFormat</code>. This will work for the vast majority * of locales; just remember to put it in a <code>try</code> block in case you * encounter an unusual one. * * <p> * NumberFormat and DecimalFormat are designed such that some controls * work for formatting and others work for parsing. The following is * the detailed description for each these control methods, * <p> * setParseIntegerOnly : only affects parsing, e.g. * if true, "3456.78" &rarr; 3456 (and leaves the parse position just after index 6) * if false, "3456.78" &rarr; 3456.78 (and leaves the parse position just after index 8) * This is independent of formatting. If you want to not show a decimal point * where there might be no digits after the decimal point, use * <API key>. * <p> * <API key> : only affects formatting, and only where * there might be no digits after the decimal point, such as with a pattern * like "#,##0.##", e.g., * if true, 3456.00 &rarr; "3,456." * if false, 3456.00 &rarr; "3456" * This is independent of parsing. If you want parsing to stop at the decimal * point, use setParseIntegerOnly. * * <p> * You can also use forms of the <code>parse</code> and <code>format</code> * methods with <code>ParsePosition</code> and <code>FieldPosition</code> to * allow you to: * <ul> * <li> progressively parse through pieces of a string * <li> align the decimal point and other areas * </ul> * For example, you can align numbers in two ways: * <ol> * <li> If you are using a monospaced font with spacing for alignment, * you can pass the <code>FieldPosition</code> in your format call, with * <code>field</code> = <code>INTEGER_FIELD</code>. On output, * <code>getEndIndex</code> will be set to the offset between the * last character of the integer and the decimal. Add * (desiredSpaceCount - getEndIndex) spaces at the front of the string. * * <li> If you are using proportional fonts, * instead of padding with spaces, measure the width * of the string in pixels from the start to <code>getEndIndex</code>. * Then move the pen by * (desiredPixelWidth - <API key>) before drawing the text. * It also works where there is no decimal, but possibly additional * characters at the end, e.g., with parentheses in negative * numbers: "(12)" for -12. * </ol> * * <h3><a name="synchronization">Synchronization</a></h3> * * <p> * Number formats are generally not synchronized. * It is recommended to create separate format instances for each thread. * If multiple threads access a format concurrently, it must be synchronized * externally. * * @see DecimalFormat * @see ChoiceFormat * @author Mark Davis * @author Helena Shih */ public abstract class NumberFormat extends Format { /** * Field constant used to construct a FieldPosition object. Signifies that * the position of the integer part of a formatted number should be returned. * @see java.text.FieldPosition */ public static final int INTEGER_FIELD = 0; /** * Field constant used to construct a FieldPosition object. Signifies that * the position of the fraction part of a formatted number should be returned. * @see java.text.FieldPosition */ public static final int FRACTION_FIELD = 1; /** * Sole constructor. (For invocation by subclass constructors, typically * implicit.) */ protected NumberFormat() { } /** * Formats a number and appends the resulting text to the given string * buffer. * The number can be of any subclass of {@link java.lang.Number}. * <p> * This implementation extracts the number's value using * {@link java.lang.Number#longValue()} for all integral type values that * can be converted to <code>long</code> without loss of information, * including <code>BigInteger</code> values with a * {@link java.math.BigInteger#bitLength() bit length} of less than 64, * and {@link java.lang.Number#doubleValue()} for all other types. It * then calls * {@link #format(long,java.lang.StringBuffer,java.text.FieldPosition)} * or {@link #format(double,java.lang.StringBuffer,java.text.FieldPosition)}. * This may result in loss of magnitude information and precision for * <code>BigInteger</code> and <code>BigDecimal</code> values. * @param number the number to format * @param toAppendTo the <code>StringBuffer</code> to which the formatted * text is to be appended * @param pos On input: an alignment field, if desired. * On output: the offsets of the alignment field. * @return the value passed in as <code>toAppendTo</code> * @exception <API key> if <code>number</code> is * null or not an instance of <code>Number</code>. * @exception <API key> if <code>toAppendTo</code> or * <code>pos</code> is null * @exception ArithmeticException if rounding is needed with rounding * mode being set to RoundingMode.UNNECESSARY * @see java.text.FieldPosition */ @Override public StringBuffer format(Object number, StringBuffer toAppendTo, FieldPosition pos) { if (number instanceof Long || number instanceof Integer || number instanceof Short || number instanceof Byte || number instanceof AtomicInteger || number instanceof AtomicLong || (number instanceof BigInteger && ((BigInteger)number).bitLength() < 64)) { return format(((Number)number).longValue(), toAppendTo, pos); } else if (number instanceof Number) { return format(((Number)number).doubleValue(), toAppendTo, pos); } else { throw new <API key>("Cannot format given Object as a Number"); } } /** * Parses text from a string to produce a <code>Number</code>. * <p> * The method attempts to parse text starting at the index given by * <code>pos</code>. * If parsing succeeds, then the index of <code>pos</code> is updated * to the index after the last character used (parsing does not necessarily * use all characters up to the end of the string), and the parsed * number is returned. The updated <code>pos</code> can be used to * indicate the starting point for the next call to this method. * If an error occurs, then the index of <code>pos</code> is not * changed, the error index of <code>pos</code> is set to the index of * the character where the error occurred, and null is returned. * <p> * See the {@link #parse(String, ParsePosition)} method for more information * on number parsing. * * @param source A <code>String</code>, part of which should be parsed. * @param pos A <code>ParsePosition</code> object with index and error * index information as described above. * @return A <code>Number</code> parsed from the string. In case of * error, returns null. * @exception <API key> if <code>pos</code> is null. */ @Override public final Object parseObject(String source, ParsePosition pos) { return parse(source, pos); } /** * Specialization of format. * * @param number the double number to format * @return the formatted String * @exception ArithmeticException if rounding is needed with rounding * mode being set to RoundingMode.UNNECESSARY * @see java.text.Format#format */ public final String format(double number) { // Use fast-path for double result if that works String result = fastFormat(number); if (result != null) return result; return format(number, new StringBuffer(), <API key>.INSTANCE).toString(); } /* * fastFormat() is supposed to be implemented in concrete subclasses only. * Default implem always returns null. */ String fastFormat(double number) { return null; } /** * Specialization of format. * * @param number the long number to format * @return the formatted String * @exception ArithmeticException if rounding is needed with rounding * mode being set to RoundingMode.UNNECESSARY * @see java.text.Format#format */ public final String format(long number) { return format(number, new StringBuffer(), <API key>.INSTANCE).toString(); } /** * Specialization of format. * * @param number the double number to format * @param toAppendTo the StringBuffer to which the formatted text is to be * appended * @param pos the field position * @return the formatted StringBuffer * @exception ArithmeticException if rounding is needed with rounding * mode being set to RoundingMode.UNNECESSARY * @see java.text.Format#format */ public abstract StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos); /** * Specialization of format. * * @param number the long number to format * @param toAppendTo the StringBuffer to which the formatted text is to be * appended * @param pos the field position * @return the formatted StringBuffer * @exception ArithmeticException if rounding is needed with rounding * mode being set to RoundingMode.UNNECESSARY * @see java.text.Format#format */ public abstract StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos); /** * Returns a Long if possible (e.g., within the range [Long.MIN_VALUE, * Long.MAX_VALUE] and with no decimals), otherwise a Double. * If IntegerOnly is set, will stop at a decimal * point (or equivalent; e.g., for rational numbers "1 2/3", will stop * after the 1). * Does not throw an exception; if no object can be parsed, index is * unchanged! * * @param source the String to parse * @param parsePosition the parse position * @return the parsed value * @see java.text.NumberFormat#isParseIntegerOnly * @see java.text.Format#parseObject */ public abstract Number parse(String source, ParsePosition parsePosition); /** * Parses text from the beginning of the given string to produce a number. * The method may not use the entire text of the given string. * <p> * See the {@link #parse(String, ParsePosition)} method for more information * on number parsing. * * @param source A <code>String</code> whose beginning should be parsed. * @return A <code>Number</code> parsed from the string. * @exception ParseException if the beginning of the specified string * cannot be parsed. */ public Number parse(String source) throws ParseException { ParsePosition parsePosition = new ParsePosition(0); Number result = parse(source, parsePosition); if (parsePosition.index == 0) { throw new ParseException("Unparseable number: \"" + source + "\"", parsePosition.errorIndex); } return result; } /** * Returns true if this format will parse numbers as integers only. * For example in the English locale, with ParseIntegerOnly true, the * string "1234." would be parsed as the integer value 1234 and parsing * would stop at the "." character. Of course, the exact format accepted * by the parse operation is locale dependant and determined by sub-classes * of NumberFormat. * * @return {@code true} if numbers should be parsed as integers only; * {@code false} otherwise */ public boolean isParseIntegerOnly() { return parseIntegerOnly; } /** * Sets whether or not numbers should be parsed as integers only. * * @param value {@code true} if numbers should be parsed as integers only; * {@code false} otherwise * @see #isParseIntegerOnly */ public void setParseIntegerOnly(boolean value) { parseIntegerOnly = value; } /** * Returns a general-purpose number format for the current default * {@link java.util.Locale.Category#FORMAT FORMAT} locale. * This is the same as calling * {@link #getNumberInstance() getNumberInstance()}. * * @return the {@code NumberFormat} instance for general-purpose number * formatting */ public final static NumberFormat getInstance() { return getInstance(Locale.getDefault(Locale.Category.FORMAT), NUMBERSTYLE); } /** * Returns a general-purpose number format for the specified locale. * This is the same as calling * {@link #getNumberInstance(java.util.Locale) getNumberInstance(inLocale)}. * * @param inLocale the desired locale * @return the {@code NumberFormat} instance for general-purpose number * formatting */ public static NumberFormat getInstance(Locale inLocale) { return getInstance(inLocale, NUMBERSTYLE); } /** * Returns a general-purpose number format for the current default * {@link java.util.Locale.Category#FORMAT FORMAT} locale. * <p>This is equivalent to calling * {@link #getNumberInstance(Locale) * getNumberInstance(Locale.getDefault(Locale.Category.FORMAT))}. * * @return the {@code NumberFormat} instance for general-purpose number * formatting * @see java.util.Locale#getDefault(java.util.Locale.Category) * @see java.util.Locale.Category#FORMAT */ public final static NumberFormat getNumberInstance() { return getInstance(Locale.getDefault(Locale.Category.FORMAT), NUMBERSTYLE); } /** * Returns a general-purpose number format for the specified locale. * * @param inLocale the desired locale * @return the {@code NumberFormat} instance for general-purpose number * formatting */ public static NumberFormat getNumberInstance(Locale inLocale) { return getInstance(inLocale, NUMBERSTYLE); } /** * Returns an integer number format for the current default * {@link java.util.Locale.Category#FORMAT FORMAT} locale. The * returned number format is configured to round floating point numbers * to the nearest integer using half-even rounding (see {@link * java.math.RoundingMode#HALF_EVEN RoundingMode.HALF_EVEN}) for formatting, * and to parse only the integer part of an input string (see {@link * #isParseIntegerOnly isParseIntegerOnly}). * <p>This is equivalent to calling * {@link #getIntegerInstance(Locale) * getIntegerInstance(Locale.getDefault(Locale.Category.FORMAT))}. * * @see #getRoundingMode() * @see java.util.Locale#getDefault(java.util.Locale.Category) * @see java.util.Locale.Category#FORMAT * @return a number format for integer values * @since 1.4 */ public final static NumberFormat getIntegerInstance() { return getInstance(Locale.getDefault(Locale.Category.FORMAT), INTEGERSTYLE); } /** * Returns an integer number format for the specified locale. The * returned number format is configured to round floating point numbers * to the nearest integer using half-even rounding (see {@link * java.math.RoundingMode#HALF_EVEN RoundingMode.HALF_EVEN}) for formatting, * and to parse only the integer part of an input string (see {@link * #isParseIntegerOnly isParseIntegerOnly}). * * @param inLocale the desired locale * @see #getRoundingMode() * @return a number format for integer values * @since 1.4 */ public static NumberFormat getIntegerInstance(Locale inLocale) { return getInstance(inLocale, INTEGERSTYLE); } /** * Returns a currency format for the current default * {@link java.util.Locale.Category#FORMAT FORMAT} locale. * <p>This is equivalent to calling * {@link #getCurrencyInstance(Locale) * getCurrencyInstance(Locale.getDefault(Locale.Category.FORMAT))}. * * @return the {@code NumberFormat} instance for currency formatting * @see java.util.Locale#getDefault(java.util.Locale.Category) * @see java.util.Locale.Category#FORMAT */ public final static NumberFormat getCurrencyInstance() { return getInstance(Locale.getDefault(Locale.Category.FORMAT), CURRENCYSTYLE); } /** * Returns a currency format for the specified locale. * * @param inLocale the desired locale * @return the {@code NumberFormat} instance for currency formatting */ public static NumberFormat getCurrencyInstance(Locale inLocale) { return getInstance(inLocale, CURRENCYSTYLE); } /** * Returns a percentage format for the current default * {@link java.util.Locale.Category#FORMAT FORMAT} locale. * <p>This is equivalent to calling * {@link #getPercentInstance(Locale) * getPercentInstance(Locale.getDefault(Locale.Category.FORMAT))}. * * @return the {@code NumberFormat} instance for percentage formatting * @see java.util.Locale#getDefault(java.util.Locale.Category) * @see java.util.Locale.Category#FORMAT */ public final static NumberFormat getPercentInstance() { return getInstance(Locale.getDefault(Locale.Category.FORMAT), PERCENTSTYLE); } /** * Returns a percentage format for the specified locale. * * @param inLocale the desired locale * @return the {@code NumberFormat} instance for percentage formatting */ public static NumberFormat getPercentInstance(Locale inLocale) { return getInstance(inLocale, PERCENTSTYLE); } /** * Returns a scientific format for the current default locale. */ /*public*/ final static NumberFormat <API key>() { return getInstance(Locale.getDefault(Locale.Category.FORMAT), SCIENTIFICSTYLE); } /** * Returns a scientific format for the specified locale. * * @param inLocale the desired locale */ /*public*/ static NumberFormat <API key>(Locale inLocale) { return getInstance(inLocale, SCIENTIFICSTYLE); } /** * Returns an array of all locales for which the * <code>get*Instance</code> methods of this class can return * localized instances. * The returned array represents the union of locales supported by the Java * runtime and by installed * {@link java.text.spi.<API key> <API key>} implementations. * It must contain at least a <code>Locale</code> instance equal to * {@link java.util.Locale#US Locale.US}. * * @return An array of locales for which localized * <code>NumberFormat</code> instances are available. */ public static Locale[] getAvailableLocales() { <API key> pool = <API key>.getPool(<API key>.class); return pool.getAvailableLocales(); } /** * Overrides hashCode. */ @Override public int hashCode() { return <API key> * 37 + maxFractionDigits; // just enough fields for a reasonable distribution } /** * Overrides equals. */ @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (this == obj) { return true; } if (getClass() != obj.getClass()) { return false; } NumberFormat other = (NumberFormat) obj; return (<API key> == other.<API key> && <API key> == other.<API key> && <API key> == other.<API key> && <API key> == other.<API key> && groupingUsed == other.groupingUsed && parseIntegerOnly == other.parseIntegerOnly); } /** * Overrides Cloneable. */ @Override public Object clone() { NumberFormat other = (NumberFormat) super.clone(); return other; } /** * Returns true if grouping is used in this format. For example, in the * English locale, with grouping on, the number 1234567 might be formatted * as "1,234,567". The grouping separator as well as the size of each group * is locale dependant and is determined by sub-classes of NumberFormat. * * @return {@code true} if grouping is used; * {@code false} otherwise * @see #setGroupingUsed */ public boolean isGroupingUsed() { return groupingUsed; } /** * Set whether or not grouping will be used in this format. * * @param newValue {@code true} if grouping is used; * {@code false} otherwise * @see #isGroupingUsed */ public void setGroupingUsed(boolean newValue) { groupingUsed = newValue; } /** * Returns the maximum number of digits allowed in the integer portion of a * number. * * @return the maximum number of digits * @see #<API key> */ public int <API key>() { return <API key>; } /** * Sets the maximum number of digits allowed in the integer portion of a * number. <API key> must be &ge; <API key>. If the * new value for <API key> is less than the current value * of <API key>, then <API key> will also be set to * the new value. * * @param newValue the maximum number of integer digits to be shown; if * less than zero, then zero is used. The concrete subclass may enforce an * upper limit to this value appropriate to the numeric type being formatted. * @see #<API key> */ public void <API key>(int newValue) { <API key> = Math.max(0,newValue); if (<API key> > <API key>) { <API key> = <API key>; } } /** * Returns the minimum number of digits allowed in the integer portion of a * number. * * @return the minimum number of digits * @see #<API key> */ public int <API key>() { return <API key>; } /** * Sets the minimum number of digits allowed in the integer portion of a * number. <API key> must be &le; <API key>. If the * new value for <API key> exceeds the current value * of <API key>, then <API key> will also be set to * the new value * * @param newValue the minimum number of integer digits to be shown; if * less than zero, then zero is used. The concrete subclass may enforce an * upper limit to this value appropriate to the numeric type being formatted. * @see #<API key> */ public void <API key>(int newValue) { <API key> = Math.max(0,newValue); if (<API key> > <API key>) { <API key> = <API key>; } } /** * Returns the maximum number of digits allowed in the fraction portion of a * number. * * @return the maximum number of digits. * @see #<API key> */ public int <API key>() { return <API key>; } /** * Sets the maximum number of digits allowed in the fraction portion of a * number. <API key> must be &ge; <API key>. If the * new value for <API key> is less than the current value * of <API key>, then <API key> will also be set to * the new value. * * @param newValue the maximum number of fraction digits to be shown; if * less than zero, then zero is used. The concrete subclass may enforce an * upper limit to this value appropriate to the numeric type being formatted. * @see #<API key> */ public void <API key>(int newValue) { <API key> = Math.max(0,newValue); if (<API key> < <API key>) { <API key> = <API key>; } } /** * Returns the minimum number of digits allowed in the fraction portion of a * number. * * @return the minimum number of digits * @see #<API key> */ public int <API key>() { return <API key>; } /** * Sets the minimum number of digits allowed in the fraction portion of a * number. <API key> must be &le; <API key>. If the * new value for <API key> exceeds the current value * of <API key>, then <API key> will also be set to * the new value * * @param newValue the minimum number of fraction digits to be shown; if * less than zero, then zero is used. The concrete subclass may enforce an * upper limit to this value appropriate to the numeric type being formatted. * @see #<API key> */ public void <API key>(int newValue) { <API key> = Math.max(0,newValue); if (<API key> < <API key>) { <API key> = <API key>; } } /** * Gets the currency used by this number format when formatting * currency values. The initial value is derived in a locale dependent * way. The returned value may be null if no valid * currency could be determined and no currency has been set using * {@link #setCurrency(java.util.Currency) setCurrency}. * <p> * The default implementation throws * <code><API key></code>. * * @return the currency used by this number format, or <code>null</code> * @exception <API key> if the number format class * doesn't implement currency formatting * @since 1.4 */ public Currency getCurrency() { throw new <API key>(); } /** * Sets the currency used by this number format when formatting * currency values. This does not update the minimum or maximum * number of fraction digits used by the number format. * <p> * The default implementation throws * <code><API key></code>. * * @param currency the new currency to be used by this number format * @exception <API key> if the number format class * doesn't implement currency formatting * @exception <API key> if <code>currency</code> is null * @since 1.4 */ public void setCurrency(Currency currency) { throw new <API key>(); } /** * Gets the {@link java.math.RoundingMode} used in this NumberFormat. * The default implementation of this method in NumberFormat * always throws {@link java.lang.<API key>}. * Subclasses which handle different rounding modes should override * this method. * * @exception <API key> The default implementation * always throws this exception * @return The <code>RoundingMode</code> used for this NumberFormat. * @see #setRoundingMode(RoundingMode) * @since 1.6 */ public RoundingMode getRoundingMode() { throw new <API key>(); } /** * Sets the {@link java.math.RoundingMode} used in this NumberFormat. * The default implementation of this method in NumberFormat always * throws {@link java.lang.<API key>}. * Subclasses which handle different rounding modes should override * this method. * * @exception <API key> The default implementation * always throws this exception * @exception <API key> if <code>roundingMode</code> is null * @param roundingMode The <code>RoundingMode</code> to be used * @see #getRoundingMode() * @since 1.6 */ public void setRoundingMode(RoundingMode roundingMode) { throw new <API key>(); } private static NumberFormat getInstance(Locale desiredLocale, int choice) { <API key> adapter; adapter = <API key>.getAdapter(<API key>.class, desiredLocale); NumberFormat numberFormat = getInstance(adapter, desiredLocale, choice); if (numberFormat == null) { numberFormat = getInstance(<API key>.forJRE(), desiredLocale, choice); } return numberFormat; } private static NumberFormat getInstance(<API key> adapter, Locale locale, int choice) { <API key> provider = adapter.<API key>(); NumberFormat numberFormat = null; switch (choice) { case NUMBERSTYLE: numberFormat = provider.getNumberInstance(locale); break; case PERCENTSTYLE: numberFormat = provider.getPercentInstance(locale); break; case CURRENCYSTYLE: numberFormat = provider.getCurrencyInstance(locale); break; case INTEGERSTYLE: numberFormat = provider.getIntegerInstance(locale); break; } return numberFormat; } /** * First, read in the default serializable data. * * Then, if <code><API key></code> is less than 1, indicating that * the stream was written by JDK 1.1, * set the <code>int</code> fields such as <code><API key></code> * to be equal to the <code>byte</code> fields such as <code>maxIntegerDigits</code>, * since the <code>int</code> fields were not present in JDK 1.1. * Finally, set <API key> back to the maximum allowed value so that * default serialization will work properly if this object is streamed out again. * * <p>If <code><API key></code> is greater than * <code><API key></code> or <code><API key></code> * is greater than <code><API key></code>, then the stream data * is invalid and this method throws an <code><API key></code>. * In addition, if any of these values is negative, then this method throws * an <code><API key></code>. * * @since 1.2 */ private void readObject(ObjectInputStream stream) throws IOException, <API key> { stream.defaultReadObject(); if (<API key> < 1) { // Didn't have additional int fields, reassign to use them. <API key> = maxIntegerDigits; <API key> = minIntegerDigits; <API key> = maxFractionDigits; <API key> = minFractionDigits; } if (<API key> > <API key> || <API key> > <API key> || <API key> < 0 || <API key> < 0) { throw new <API key>("Digit count range invalid"); } <API key> = <API key>; } /** * Write out the default serializable data, after first setting * the <code>byte</code> fields such as <code>maxIntegerDigits</code> to be * equal to the <code>int</code> fields such as <code><API key></code> * (or to <code>Byte.MAX_VALUE</code>, whichever is smaller), for compatibility * with the JDK 1.1 version of the stream format. * * @since 1.2 */ private void writeObject(ObjectOutputStream stream) throws IOException { maxIntegerDigits = (<API key> > Byte.MAX_VALUE) ? Byte.MAX_VALUE : (byte)<API key>; minIntegerDigits = (<API key> > Byte.MAX_VALUE) ? Byte.MAX_VALUE : (byte)<API key>; maxFractionDigits = (<API key> > Byte.MAX_VALUE) ? Byte.MAX_VALUE : (byte)<API key>; minFractionDigits = (<API key> > Byte.MAX_VALUE) ? Byte.MAX_VALUE : (byte)<API key>; stream.defaultWriteObject(); } // Constants used by factory methods to specify a style of format. private static final int NUMBERSTYLE = 0; private static final int CURRENCYSTYLE = 1; private static final int PERCENTSTYLE = 2; private static final int SCIENTIFICSTYLE = 3; private static final int INTEGERSTYLE = 4; /** * True if the grouping (i.e. thousands) separator is used when * formatting and parsing numbers. * * @serial * @see #isGroupingUsed */ private boolean groupingUsed = true; /** * The maximum number of digits allowed in the integer portion of a * number. <code>maxIntegerDigits</code> must be greater than or equal to * <code>minIntegerDigits</code>. * <p> * <strong>Note:</strong> This field exists only for serialization * compatibility with JDK 1.1. In Java platform 2 v1.2 and higher, the new * <code>int</code> field <code><API key></code> is used instead. * When writing to a stream, <code>maxIntegerDigits</code> is set to * <code><API key></code> or <code>Byte.MAX_VALUE</code>, * whichever is smaller. When reading from a stream, this field is used * only if <code><API key></code> is less than 1. * * @serial * @see #<API key> */ private byte maxIntegerDigits = 40; /** * The minimum number of digits allowed in the integer portion of a * number. <code><API key></code> must be less than or equal to * <code><API key></code>. * <p> * <strong>Note:</strong> This field exists only for serialization * compatibility with JDK 1.1. In Java platform 2 v1.2 and higher, the new * <code>int</code> field <code><API key></code> is used instead. * When writing to a stream, <code>minIntegerDigits</code> is set to * <code><API key></code> or <code>Byte.MAX_VALUE</code>, * whichever is smaller. When reading from a stream, this field is used * only if <code><API key></code> is less than 1. * * @serial * @see #<API key> */ private byte minIntegerDigits = 1; /** * The maximum number of digits allowed in the fractional portion of a * number. <code><API key></code> must be greater than or equal to * <code><API key></code>. * <p> * <strong>Note:</strong> This field exists only for serialization * compatibility with JDK 1.1. In Java platform 2 v1.2 and higher, the new * <code>int</code> field <code><API key></code> is used instead. * When writing to a stream, <code>maxFractionDigits</code> is set to * <code><API key></code> or <code>Byte.MAX_VALUE</code>, * whichever is smaller. When reading from a stream, this field is used * only if <code><API key></code> is less than 1. * * @serial * @see #<API key> */ private byte maxFractionDigits = 3; // invariant, >= minFractionDigits /** * The minimum number of digits allowed in the fractional portion of a * number. <code><API key></code> must be less than or equal to * <code><API key></code>. * <p> * <strong>Note:</strong> This field exists only for serialization * compatibility with JDK 1.1. In Java platform 2 v1.2 and higher, the new * <code>int</code> field <code><API key></code> is used instead. * When writing to a stream, <code>minFractionDigits</code> is set to * <code><API key></code> or <code>Byte.MAX_VALUE</code>, * whichever is smaller. When reading from a stream, this field is used * only if <code><API key></code> is less than 1. * * @serial * @see #<API key> */ private byte minFractionDigits = 0; /** * True if this format will parse numbers as integers only. * * @serial * @see #isParseIntegerOnly */ private boolean parseIntegerOnly = false; // new fields for 1.2. byte is too small for integer digits. /** * The maximum number of digits allowed in the integer portion of a * number. <code><API key></code> must be greater than or equal to * <code><API key></code>. * * @serial * @since 1.2 * @see #<API key> */ private int <API key> = 40; /** * The minimum number of digits allowed in the integer portion of a * number. <code><API key></code> must be less than or equal to * <code><API key></code>. * * @serial * @since 1.2 * @see #<API key> */ private int <API key> = 1; /** * The maximum number of digits allowed in the fractional portion of a * number. <code><API key></code> must be greater than or equal to * <code><API key></code>. * * @serial * @since 1.2 * @see #<API key> */ private int <API key> = 3; // invariant, >= minFractionDigits /** * The minimum number of digits allowed in the fractional portion of a * number. <code><API key></code> must be less than or equal to * <code><API key></code>. * * @serial * @since 1.2 * @see #<API key> */ private int <API key> = 0; static final int <API key> = 1; /** * Describes the version of <code>NumberFormat</code> present on the stream. * Possible values are: * <ul> * <li><b>0</b> (or uninitialized): the JDK 1.1 version of the stream format. * In this version, the <code>int</code> fields such as * <code><API key></code> were not present, and the <code>byte</code> * fields such as <code>maxIntegerDigits</code> are used instead. * * <li><b>1</b>: the 1.2 version of the stream format. The values of the * <code>byte</code> fields such as <code>maxIntegerDigits</code> are ignored, * and the <code>int</code> fields such as <code><API key></code> * are used instead. * </ul> * When streaming out a <code>NumberFormat</code>, the most recent format * (corresponding to the highest allowable <code><API key></code>) * is always written. * * @serial * @since 1.2 */ private int <API key> = <API key>; // Removed "implements Cloneable" clause. Needs to update serialization // ID for backward compatibility. static final long serialVersionUID = -<API key>; // class for <API key> attributes /** * Defines constants that are used as attribute keys in the * <code><API key></code> returned * from <code>NumberFormat.<API key></code> and as * field identifiers in <code>FieldPosition</code>. * * @since 1.4 */ public static class Field extends Format.Field { // Proclaim serial compatibility with 1.4 FCS private static final long serialVersionUID = <API key>; // table of all instances in this class, used by readResolve private static final Map<String, Field> instanceMap = new HashMap<>(11); /** * Creates a Field instance with the specified * name. * * @param name Name of the attribute */ protected Field(String name) { super(name); if (this.getClass() == NumberFormat.Field.class) { instanceMap.put(name, this); } } /** * Resolves instances being deserialized to the predefined constants. * * @throws <API key> if the constant could not be resolved. * @return resolved NumberFormat.Field constant */ @Override protected Object readResolve() throws <API key> { if (this.getClass() != NumberFormat.Field.class) { throw new <API key>("subclass didn't correctly implement readResolve"); } Object instance = instanceMap.get(getName()); if (instance != null) { return instance; } else { throw new <API key>("unknown attribute name"); } } /** * Constant identifying the integer field. */ public static final Field INTEGER = new Field("integer"); /** * Constant identifying the fraction field. */ public static final Field FRACTION = new Field("fraction"); /** * Constant identifying the exponent field. */ public static final Field EXPONENT = new Field("exponent"); /** * Constant identifying the decimal separator field. */ public static final Field DECIMAL_SEPARATOR = new Field("decimal separator"); /** * Constant identifying the sign field. */ public static final Field SIGN = new Field("sign"); /** * Constant identifying the grouping separator field. */ public static final Field GROUPING_SEPARATOR = new Field("grouping separator"); /** * Constant identifying the exponent symbol field. */ public static final Field EXPONENT_SYMBOL = new Field("exponent symbol"); /** * Constant identifying the percent field. */ public static final Field PERCENT = new Field("percent"); /** * Constant identifying the permille field. */ public static final Field PERMILLE = new Field("per mille"); /** * Constant identifying the currency field. */ public static final Field CURRENCY = new Field("currency"); /** * Constant identifying the exponent sign field. */ public static final Field EXPONENT_SIGN = new Field("exponent sign"); } }
declare namespace Token { type Nesting = 1 | 0 | -1; } /** * Create new token and fill passed properties. */ declare class Token { constructor(type: string, tag: string, nesting: Token.Nesting); /** * Type of the token, e.g. "paragraph_open" */ type: string; /** * HTML tag name, e.g. "p" */ tag: string; /** * HTML attributes. Format: `[[name1, value1], [name2, value2]]` */ attrs: [string, string][] | null; /** * Source map info. Format: `[line_begin, line_end]` */ map: [number, number] | null; /** * Level change (number in {-1, 0, 1} set), where: * * - `1` means the tag is opening * - `0` means the tag is self-closing * - `-1` means the tag is closing */ nesting: 1 | 0 | -1; /** * nesting level, the same as `state.level` */ level: number; /** * An array of child nodes (inline and img tokens) */ children: Token[] | null; /** * In a case of self-closing tag (code, html, fence, etc.), * it has contents of this tag. */ content: string; /** * '*' or '_' for emphasis, fence string for fence, etc. */ markup: string; /** * Fence info string */ info: string; /** * A place for plugins to store an arbitrary data */ meta: any; /** * True for block-level tokens, false for inline tokens. * Used in renderer to calculate line breaks */ block: boolean; /** * If it's true, ignore this element when rendering. Used for tight lists * to hide paragraphs. */ hidden: boolean; /** * Search attribute index by name. */ attrIndex(name: string): number; /** * Add `[name, value]` attribute to list. Init attrs if necessary */ attrPush(attrData: [string, string]): void; /** * Set `name` attribute to `value`. Override old value if exists. */ attrSet(name: string, value: string): void; /** * Get the value of attribute `name`, or null if it does not exist. */ attrGet(name: string): string | null; /** * * Join value to existing attribute via space. Or create new attribute if not * exists. Useful to operate with token classes. */ attrJoin(name: string, value: string): void; } export = Token;
"use strict"; var Shim = require("./shim"); var SortedArraySet = require("./sorted-array-set"); var GenericCollection = require("./generic-collection"); var GenericMap = require("./generic-map"); var PropertyChanges = require("./listen/property-changes"); module.exports = SortedArrayMap; function SortedArrayMap(values, equals, compare, getDefault) { if (!(this instanceof SortedArrayMap)) { return new SortedArrayMap(values, equals, compare, getDefault); } equals = equals || Object.equals; compare = compare || Object.compare; getDefault = getDefault || Function.noop; this.contentEquals = equals; this.contentCompare = compare; this.getDefault = getDefault; this.store = new SortedArraySet( null, function keysEqual(a, b) { return equals(a.key, b.key); }, function compareKeys(a, b) { return compare(a.key, b.key); } ); this.length = 0; this.addEach(values); } Object.addEach(SortedArrayMap.prototype, GenericCollection.prototype); Object.addEach(SortedArrayMap.prototype, GenericMap.prototype); Object.addEach(SortedArrayMap.prototype, PropertyChanges.prototype); SortedArrayMap.prototype.constructClone = function (values) { return new this.constructor( values, this.contentEquals, this.contentCompare, this.getDefault ); };
package org.eclipse.smarthome.io.transport.mqtt.internal; import java.util.TimerTask; /** * Connection helper which can be executed periodically to try to reconnect to a broker if the connection was previously * lost. * * @author Davy Vanherbergen */ public class <API key> extends TimerTask { private <API key> connection; /** * Create new connection helper to help reconnect the given connection. * * @param connection to reconnect. */ public <API key>(<API key> connection) { this.connection = connection; } @Override public void run() { try { connection.start(); } catch (Exception e) { // reconnect failed, // maybe we will have more luck next time... } } }
#import "CSHandle.h" @interface XADXORHandle:CSHandle { CSHandle *parent; NSData *password; const uint8_t *passwordbytes; int passwordlength; } -(id)initWithHandle:(CSHandle *)handle password:(NSData *)passdata; -(id)initAsCopyOf:(XADXORHandle *)other; -(void)dealloc; -(off_t)fileSize; -(off_t)offsetInFile; -(BOOL)atEndOfFile; -(void)seekToFileOffset:(off_t)offs; -(void)seekToEndOfFile; -(int)readAtMost:(int)num toBuffer:(void *)buffer; @end
// This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // with this library; see the file COPYING3. If not see // { <API key> "" } // { dg-do run { xfail *-*-* } } #include <list> #include <debug/checks.h> void test01() { __gnu_test::check_assign1<std::list<int> >(); } int main() { test01(); return 0; }
#ifndef leastSquaresGrad_H #define leastSquaresGrad_H #include "gradScheme.H" namespace Foam { namespace fv { template<class Type> class leastSquaresGrad : public fv::gradScheme<Type> { // Private Member Functions //- Disallow default bitwise copy construct leastSquaresGrad(const leastSquaresGrad&); //- Disallow default bitwise assignment void operator=(const leastSquaresGrad&); public: //- Runtime type information TypeName("leastSquares"); // Constructors //- Construct from mesh leastSquaresGrad(const fvMesh& mesh) : gradScheme<Type>(mesh) {} //- Construct from Istream leastSquaresGrad(const fvMesh& mesh, Istream&) : gradScheme<Type>(mesh) {} // Member Functions //- Return the gradient of the given field to the gradScheme::grad // for optional caching virtual tmp < GeometricField <typename outerProduct<vector, Type>::type, fvPatchField, volMesh> > calcGrad ( const GeometricField<Type, fvPatchField, volMesh>& vsf, const word& name ) const; }; } // End namespace fv } // End namespace Foam #ifdef NoRepository # include "leastSquaresGrad.C" #endif #endif
module X (x, D1(..), D2(..)) where data D1 = D { f :: D2 } -- deriving Show data D2 = A | B -- deriving Show x :: D1 x = D { f = A }
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include "m5602_po1030.h" static int po1030_get_exposure(struct gspca_dev *gspca_dev, __s32 *val); static int po1030_set_exposure(struct gspca_dev *gspca_dev, __s32 val); static int po1030_get_gain(struct gspca_dev *gspca_dev, __s32 *val); static int po1030_set_gain(struct gspca_dev *gspca_dev, __s32 val); static int <API key>(struct gspca_dev *gspca_dev, __s32 *val); static int <API key>(struct gspca_dev *gspca_dev, __s32 val); static int <API key>(struct gspca_dev *gspca_dev, __s32 *val); static int <API key>(struct gspca_dev *gspca_dev, __s32 val); static int <API key>(struct gspca_dev *gspca_dev, __s32 *val); static int <API key>(struct gspca_dev *gspca_dev, __s32 val); static int po1030_get_hflip(struct gspca_dev *gspca_dev, __s32 *val); static int po1030_set_hflip(struct gspca_dev *gspca_dev, __s32 val); static int po1030_get_vflip(struct gspca_dev *gspca_dev, __s32 *val); static int po1030_set_vflip(struct gspca_dev *gspca_dev, __s32 val); static int <API key>(struct gspca_dev *gspca_dev, __s32 val); static int <API key>(struct gspca_dev *gspca_dev, __s32 *val); static int <API key>(struct gspca_dev *gspca_dev, __s32 val); static int <API key>(struct gspca_dev *gspca_dev, __s32 *val); static struct v4l2_pix_format po1030_modes[] = { { 640, 480, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, .sizeimage = 640 * 480, .bytesperline = 640, .colorspace = <API key>, .priv = 2 } }; static const struct ctrl po1030_ctrls[] = { #define GAIN_IDX 0 { { .id = V4L2_CID_GAIN, .type = <API key>, .name = "gain", .minimum = 0x00, .maximum = 0x4f, .step = 0x1, .default_value = <API key>, .flags = <API key> }, .set = po1030_set_gain, .get = po1030_get_gain }, #define EXPOSURE_IDX 1 { { .id = V4L2_CID_EXPOSURE, .type = <API key>, .name = "exposure", .minimum = 0x00, .maximum = 0x02ff, .step = 0x1, .default_value = <API key>, .flags = <API key> }, .set = po1030_set_exposure, .get = po1030_get_exposure }, #define RED_BALANCE_IDX 2 { { .id = <API key>, .type = <API key>, .name = "red balance", .minimum = 0x00, .maximum = 0xff, .step = 0x1, .default_value = <API key>, .flags = <API key> }, .set = <API key>, .get = <API key> }, #define BLUE_BALANCE_IDX 3 { { .id = <API key>, .type = <API key>, .name = "blue balance", .minimum = 0x00, .maximum = 0xff, .step = 0x1, .default_value = <API key>, .flags = <API key> }, .set = <API key>, .get = <API key> }, #define HFLIP_IDX 4 { { .id = V4L2_CID_HFLIP, .type = <API key>, .name = "horizontal flip", .minimum = 0, .maximum = 1, .step = 1, .default_value = 0, }, .set = po1030_set_hflip, .get = po1030_get_hflip }, #define VFLIP_IDX 5 { { .id = V4L2_CID_VFLIP, .type = <API key>, .name = "vertical flip", .minimum = 0, .maximum = 1, .step = 1, .default_value = 0, }, .set = po1030_set_vflip, .get = po1030_get_vflip }, #define <API key> 6 { { .id = <API key>, .type = <API key>, .name = "auto white balance", .minimum = 0, .maximum = 1, .step = 1, .default_value = 0, }, .set = <API key>, .get = <API key> }, #define AUTO_EXPOSURE_IDX 7 { { .id = <API key>, .type = <API key>, .name = "auto exposure", .minimum = 0, .maximum = 1, .step = 1, .default_value = 0, }, .set = <API key>, .get = <API key> }, #define GREEN_BALANCE_IDX 8 { { .id = <API key>, .type = <API key>, .name = "green balance", .minimum = 0x00, .maximum = 0xff, .step = 0x1, .default_value = <API key>, .flags = <API key> }, .set = <API key>, .get = <API key> }, }; static void <API key>(struct sd *sd); int po1030_probe(struct sd *sd) { u8 dev_id_h = 0, i; s32 *sensor_settings; if (force_sensor) { if (force_sensor == PO1030_SENSOR) { pr_info("Forcing a %s sensor\n", po1030.name); goto sensor_found; } /* If we want to force another sensor, don't try to probe this * one */ return -ENODEV; } PDEBUG(D_PROBE, "Probing for a po1030 sensor"); /* Run the pre-init to actually probe the unit */ for (i = 0; i < ARRAY_SIZE(preinit_po1030); i++) { u8 data = preinit_po1030[i][2]; if (preinit_po1030[i][0] == SENSOR) m5602_write_sensor(sd, preinit_po1030[i][1], &data, 1); else m5602_write_bridge(sd, preinit_po1030[i][1], data); } if (m5602_read_sensor(sd, PO1030_DEVID_H, &dev_id_h, 1)) return -ENODEV; if (dev_id_h == 0x30) { pr_info("Detected a po1030 sensor\n"); goto sensor_found; } return -ENODEV; sensor_found: sensor_settings = kmalloc( ARRAY_SIZE(po1030_ctrls) * sizeof(s32), GFP_KERNEL); if (!sensor_settings) return -ENOMEM; sd->gspca_dev.cam.cam_mode = po1030_modes; sd->gspca_dev.cam.nmodes = ARRAY_SIZE(po1030_modes); sd->desc->ctrls = po1030_ctrls; sd->desc->nctrls = ARRAY_SIZE(po1030_ctrls); for (i = 0; i < ARRAY_SIZE(po1030_ctrls); i++) sensor_settings[i] = po1030_ctrls[i].qctrl.default_value; sd->sensor_priv = sensor_settings; return 0; } int po1030_init(struct sd *sd) { s32 *sensor_settings = sd->sensor_priv; int i, err = 0; /* Init the sensor */ for (i = 0; i < ARRAY_SIZE(init_po1030) && !err; i++) { u8 data[2] = {0x00, 0x00}; switch (init_po1030[i][0]) { case BRIDGE: err = m5602_write_bridge(sd, init_po1030[i][1], init_po1030[i][2]); break; case SENSOR: data[0] = init_po1030[i][2]; err = m5602_write_sensor(sd, init_po1030[i][1], data, 1); break; default: pr_info("Invalid stream command, exiting init\n"); return -EINVAL; } } if (err < 0) return err; if (dump_sensor) <API key>(sd); err = po1030_set_exposure(&sd->gspca_dev, sensor_settings[EXPOSURE_IDX]); if (err < 0) return err; err = po1030_set_gain(&sd->gspca_dev, sensor_settings[GAIN_IDX]); if (err < 0) return err; err = po1030_set_hflip(&sd->gspca_dev, sensor_settings[HFLIP_IDX]); if (err < 0) return err; err = po1030_set_vflip(&sd->gspca_dev, sensor_settings[VFLIP_IDX]); if (err < 0) return err; err = <API key>(&sd->gspca_dev, sensor_settings[RED_BALANCE_IDX]); if (err < 0) return err; err = <API key>(&sd->gspca_dev, sensor_settings[BLUE_BALANCE_IDX]); if (err < 0) return err; err = <API key>(&sd->gspca_dev, sensor_settings[GREEN_BALANCE_IDX]); if (err < 0) return err; err = <API key>(&sd->gspca_dev, sensor_settings[<API key>]); if (err < 0) return err; err = <API key>(&sd->gspca_dev, sensor_settings[AUTO_EXPOSURE_IDX]); return err; } int po1030_start(struct sd *sd) { struct cam *cam = &sd->gspca_dev.cam; int i, err = 0; int width = cam->cam_mode[sd->gspca_dev.curr_mode].width; int height = cam->cam_mode[sd->gspca_dev.curr_mode].height; int ver_offs = cam->cam_mode[sd->gspca_dev.curr_mode].priv; u8 data; switch (width) { case 320: data = PO1030_SUBSAMPLING; err = m5602_write_sensor(sd, PO1030_CONTROL3, &data, 1); if (err < 0) return err; data = ((width + 3) >> 8) & 0xff; err = m5602_write_sensor(sd, <API key>, &data, 1); if (err < 0) return err; data = (width + 3) & 0xff; err = m5602_write_sensor(sd, <API key>, &data, 1); if (err < 0) return err; data = ((height + 1) >> 8) & 0xff; err = m5602_write_sensor(sd, <API key>, &data, 1); if (err < 0) return err; data = (height + 1) & 0xff; err = m5602_write_sensor(sd, <API key>, &data, 1); height += 6; width -= 1; break; case 640: data = 0; err = m5602_write_sensor(sd, PO1030_CONTROL3, &data, 1); if (err < 0) return err; data = ((width + 7) >> 8) & 0xff; err = m5602_write_sensor(sd, <API key>, &data, 1); if (err < 0) return err; data = (width + 7) & 0xff; err = m5602_write_sensor(sd, <API key>, &data, 1); if (err < 0) return err; data = ((height + 3) >> 8) & 0xff; err = m5602_write_sensor(sd, <API key>, &data, 1); if (err < 0) return err; data = (height + 3) & 0xff; err = m5602_write_sensor(sd, <API key>, &data, 1); height += 12; width -= 2; break; } err = m5602_write_bridge(sd, <API key>, 0x0c); if (err < 0) return err; err = m5602_write_bridge(sd, <API key>, 0x81); if (err < 0) return err; err = m5602_write_bridge(sd, <API key>, 0x82); if (err < 0) return err; err = m5602_write_bridge(sd, M5602_XB_SIG_INI, 0x01); if (err < 0) return err; err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, ((ver_offs >> 8) & 0xff)); if (err < 0) return err; err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, (ver_offs & 0xff)); if (err < 0) return err; for (i = 0; i < 2 && !err; i++) err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, 0); if (err < 0) return err; err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, (height >> 8) & 0xff); if (err < 0) return err; err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, (height & 0xff)); if (err < 0) return err; for (i = 0; i < 2 && !err; i++) err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, 0); for (i = 0; i < 2 && !err; i++) err = m5602_write_bridge(sd, M5602_XB_SIG_INI, 0); for (i = 0; i < 2 && !err; i++) err = m5602_write_bridge(sd, M5602_XB_HSYNC_PARA, 0); if (err < 0) return err; err = m5602_write_bridge(sd, M5602_XB_HSYNC_PARA, (width >> 8) & 0xff); if (err < 0) return err; err = m5602_write_bridge(sd, M5602_XB_HSYNC_PARA, (width & 0xff)); if (err < 0) return err; err = m5602_write_bridge(sd, M5602_XB_SIG_INI, 0); return err; } static int po1030_get_exposure(struct gspca_dev *gspca_dev, __s32 *val) { struct sd *sd = (struct sd *) gspca_dev; s32 *sensor_settings = sd->sensor_priv; *val = sensor_settings[EXPOSURE_IDX]; PDEBUG(D_V4L2, "Exposure read as %d", *val); return 0; } static int po1030_set_exposure(struct gspca_dev *gspca_dev, __s32 val) { struct sd *sd = (struct sd *) gspca_dev; s32 *sensor_settings = sd->sensor_priv; u8 i2c_data; int err; sensor_settings[EXPOSURE_IDX] = val; PDEBUG(D_V4L2, "Set exposure to %d", val & 0xffff); i2c_data = ((val & 0xff00) >> 8); PDEBUG(D_V4L2, "Set exposure to high byte to 0x%x", i2c_data); err = m5602_write_sensor(sd, PO1030_INTEGLINES_H, &i2c_data, 1); if (err < 0) return err; i2c_data = (val & 0xff); PDEBUG(D_V4L2, "Set exposure to low byte to 0x%x", i2c_data); err = m5602_write_sensor(sd, PO1030_INTEGLINES_M, &i2c_data, 1); return err; } static int po1030_get_gain(struct gspca_dev *gspca_dev, __s32 *val) { struct sd *sd = (struct sd *) gspca_dev; s32 *sensor_settings = sd->sensor_priv; *val = sensor_settings[GAIN_IDX]; PDEBUG(D_V4L2, "Read global gain %d", *val); return 0; } static int po1030_set_gain(struct gspca_dev *gspca_dev, __s32 val) { struct sd *sd = (struct sd *) gspca_dev; s32 *sensor_settings = sd->sensor_priv; u8 i2c_data; int err; sensor_settings[GAIN_IDX] = val; i2c_data = val & 0xff; PDEBUG(D_V4L2, "Set global gain to %d", i2c_data); err = m5602_write_sensor(sd, PO1030_GLOBALGAIN, &i2c_data, 1); return err; } static int po1030_get_hflip(struct gspca_dev *gspca_dev, __s32 *val) { struct sd *sd = (struct sd *) gspca_dev; s32 *sensor_settings = sd->sensor_priv; *val = sensor_settings[HFLIP_IDX]; PDEBUG(D_V4L2, "Read hflip %d", *val); return 0; } static int po1030_set_hflip(struct gspca_dev *gspca_dev, __s32 val) { struct sd *sd = (struct sd *) gspca_dev; s32 *sensor_settings = sd->sensor_priv; u8 i2c_data; int err; sensor_settings[HFLIP_IDX] = val; PDEBUG(D_V4L2, "Set hflip %d", val); err = m5602_read_sensor(sd, PO1030_CONTROL2, &i2c_data, 1); if (err < 0) return err; i2c_data = (0x7f & i2c_data) | ((val & 0x01) << 7); err = m5602_write_sensor(sd, PO1030_CONTROL2, &i2c_data, 1); return err; } static int po1030_get_vflip(struct gspca_dev *gspca_dev, __s32 *val) { struct sd *sd = (struct sd *) gspca_dev; s32 *sensor_settings = sd->sensor_priv; *val = sensor_settings[VFLIP_IDX]; PDEBUG(D_V4L2, "Read vflip %d", *val); return 0; } static int po1030_set_vflip(struct gspca_dev *gspca_dev, __s32 val) { struct sd *sd = (struct sd *) gspca_dev; s32 *sensor_settings = sd->sensor_priv; u8 i2c_data; int err; sensor_settings[VFLIP_IDX] = val; PDEBUG(D_V4L2, "Set vflip %d", val); err = m5602_read_sensor(sd, PO1030_CONTROL2, &i2c_data, 1); if (err < 0) return err; i2c_data = (i2c_data & 0xbf) | ((val & 0x01) << 6); err = m5602_write_sensor(sd, PO1030_CONTROL2, &i2c_data, 1); return err; } static int <API key>(struct gspca_dev *gspca_dev, __s32 *val) { struct sd *sd = (struct sd *) gspca_dev; s32 *sensor_settings = sd->sensor_priv; *val = sensor_settings[RED_BALANCE_IDX]; PDEBUG(D_V4L2, "Read red gain %d", *val); return 0; } static int <API key>(struct gspca_dev *gspca_dev, __s32 val) { struct sd *sd = (struct sd *) gspca_dev; s32 *sensor_settings = sd->sensor_priv; u8 i2c_data; int err; sensor_settings[RED_BALANCE_IDX] = val; i2c_data = val & 0xff; PDEBUG(D_V4L2, "Set red gain to %d", i2c_data); err = m5602_write_sensor(sd, PO1030_RED_GAIN, &i2c_data, 1); return err; } static int <API key>(struct gspca_dev *gspca_dev, __s32 *val) { struct sd *sd = (struct sd *) gspca_dev; s32 *sensor_settings = sd->sensor_priv; *val = sensor_settings[BLUE_BALANCE_IDX]; PDEBUG(D_V4L2, "Read blue gain %d", *val); return 0; } static int <API key>(struct gspca_dev *gspca_dev, __s32 val) { struct sd *sd = (struct sd *) gspca_dev; s32 *sensor_settings = sd->sensor_priv; u8 i2c_data; int err; sensor_settings[BLUE_BALANCE_IDX] = val; i2c_data = val & 0xff; PDEBUG(D_V4L2, "Set blue gain to %d", i2c_data); err = m5602_write_sensor(sd, PO1030_BLUE_GAIN, &i2c_data, 1); return err; } static int <API key>(struct gspca_dev *gspca_dev, __s32 *val) { struct sd *sd = (struct sd *) gspca_dev; s32 *sensor_settings = sd->sensor_priv; *val = sensor_settings[GREEN_BALANCE_IDX]; PDEBUG(D_V4L2, "Read green gain %d", *val); return 0; } static int <API key>(struct gspca_dev *gspca_dev, __s32 val) { struct sd *sd = (struct sd *) gspca_dev; s32 *sensor_settings = sd->sensor_priv; u8 i2c_data; int err; sensor_settings[GREEN_BALANCE_IDX] = val; i2c_data = val & 0xff; PDEBUG(D_V4L2, "Set green gain to %d", i2c_data); err = m5602_write_sensor(sd, PO1030_GREEN_1_GAIN, &i2c_data, 1); if (err < 0) return err; return m5602_write_sensor(sd, PO1030_GREEN_2_GAIN, &i2c_data, 1); } static int <API key>(struct gspca_dev *gspca_dev, __s32 *val) { struct sd *sd = (struct sd *) gspca_dev; s32 *sensor_settings = sd->sensor_priv; *val = sensor_settings[<API key>]; PDEBUG(D_V4L2, "Auto white balancing is %d", *val); return 0; } static int <API key>(struct gspca_dev *gspca_dev, __s32 val) { struct sd *sd = (struct sd *) gspca_dev; s32 *sensor_settings = sd->sensor_priv; u8 i2c_data; int err; sensor_settings[<API key>] = val; err = m5602_read_sensor(sd, PO1030_AUTOCTRL1, &i2c_data, 1); if (err < 0) return err; PDEBUG(D_V4L2, "Set auto white balance to %d", val); i2c_data = (i2c_data & 0xfe) | (val & 0x01); err = m5602_write_sensor(sd, PO1030_AUTOCTRL1, &i2c_data, 1); return err; } static int <API key>(struct gspca_dev *gspca_dev, __s32 *val) { struct sd *sd = (struct sd *) gspca_dev; s32 *sensor_settings = sd->sensor_priv; *val = sensor_settings[AUTO_EXPOSURE_IDX]; PDEBUG(D_V4L2, "Auto exposure is %d", *val); return 0; } static int <API key>(struct gspca_dev *gspca_dev, __s32 val) { struct sd *sd = (struct sd *) gspca_dev; s32 *sensor_settings = sd->sensor_priv; u8 i2c_data; int err; sensor_settings[AUTO_EXPOSURE_IDX] = val; err = m5602_read_sensor(sd, PO1030_AUTOCTRL1, &i2c_data, 1); if (err < 0) return err; PDEBUG(D_V4L2, "Set auto exposure to %d", val); i2c_data = (i2c_data & 0xfd) | ((val & 0x01) << 1); return m5602_write_sensor(sd, PO1030_AUTOCTRL1, &i2c_data, 1); } void po1030_disconnect(struct sd *sd) { sd->sensor = NULL; kfree(sd->sensor_priv); } static void <API key>(struct sd *sd) { int address; u8 value = 0; pr_info("Dumping the po1030 sensor core registers\n"); for (address = 0; address < 0x7f; address++) { m5602_read_sensor(sd, address, &value, 1); pr_info("register 0x%x contains 0x%x\n", address, value); } pr_info("po1030 register state dump complete\n"); pr_info("Probing for which registers that are read/write\n"); for (address = 0; address < 0xff; address++) { u8 old_value, ctrl_value; u8 test_value[2] = {0xff, 0xff}; m5602_read_sensor(sd, address, &old_value, 1); m5602_write_sensor(sd, address, test_value, 1); m5602_read_sensor(sd, address, &ctrl_value, 1); if (ctrl_value == test_value[0]) pr_info("register 0x%x is writeable\n", address); else pr_info("register 0x%x is read only\n", address); /* Restore original value */ m5602_write_sensor(sd, address, &old_value, 1); } }
local combat = Combat() combat:setParameter(COMBAT_PARAM_EFFECT, <API key>) local condition = Condition(<API key>) condition:setParameter(<API key>, 4000) condition:setParameter(<API key>, 25) local area = createCombatArea(AREA_BEAM1) combat:setArea(area) combat:setCondition(condition) function onCastSpell(creature, var) return combat:execute(creature, var) end
#ifndef POLL_H_ #define POLL_H_ #include "config.h" #ifdef HAVE_POLL #include <poll.h> typedef struct pollfd ssh_pollfd_t; #else /* HAVE_POLL */ /* poll emulation support */ typedef struct ssh_pollfd_struct { socket_t fd; /* file descriptor */ short events; /* requested events */ short revents; /* returned events */ } ssh_pollfd_t; typedef unsigned long int nfds_t; #ifdef _WIN32 #ifndef POLLRDNORM #define POLLRDNORM 0x0100 #endif #ifndef POLLRDBAND #define POLLRDBAND 0x0200 #endif #ifndef POLLIN #define POLLIN (POLLRDNORM | POLLRDBAND) #endif #ifndef POLLPRI #define POLLPRI 0x0400 #endif #ifndef POLLWRNORM #define POLLWRNORM 0x0010 #endif #ifndef POLLOUT #define POLLOUT (POLLWRNORM) #endif #ifndef POLLWRBAND #define POLLWRBAND 0x0020 #endif #ifndef POLLERR #define POLLERR 0x0001 #endif #ifndef POLLHUP #define POLLHUP 0x0002 #endif #ifndef POLLNVAL #define POLLNVAL 0x0004 #endif #else /* _WIN32 */ /* poll.c */ #ifndef POLLIN #define POLLIN 0x001 /* There is data to read. */ #endif #ifndef POLLPRI #define POLLPRI 0x002 /* There is urgent data to read. */ #endif #ifndef POLLOUT #define POLLOUT 0x004 /* Writing now will not block. */ #endif #ifndef POLLERR #define POLLERR 0x008 /* Error condition. */ #endif #ifndef POLLHUP #define POLLHUP 0x010 /* Hung up. */ #endif #ifndef POLLNVAL #define POLLNVAL 0x020 /* Invalid polling request. */ #endif #ifndef POLLRDNORM #define POLLRDNORM 0x040 /* mapped to read fds_set */ #endif #ifndef POLLRDBAND #define POLLRDBAND 0x080 /* mapped to exception fds_set */ #endif #ifndef POLLWRNORM #define POLLWRNORM 0x100 /* mapped to write fds_set */ #endif #ifndef POLLWRBAND #define POLLWRBAND 0x200 /* mapped to write fds_set */ #endif #endif /* WIN32 */ #endif /* HAVE_POLL */ void ssh_poll_init(void); void ssh_poll_cleanup(void); int ssh_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout); typedef struct ssh_poll_ctx_struct *ssh_poll_ctx; typedef struct <API key> *ssh_poll_handle; /** * @brief SSH poll callback. This callback will be used when an event * caught on the socket. * * @param p Poll object this callback belongs to. * @param fd The raw socket. * @param revents The current poll events on the socket. * @param userdata Userdata to be passed to the callback function. * * @return 0 on success, < 0 if you removed the poll object from * its poll context. */ typedef int (*ssh_poll_callback)(ssh_poll_handle p, socket_t fd, int revents, void *userdata); struct ssh_socket_struct; ssh_poll_handle ssh_poll_new(socket_t fd, short events, ssh_poll_callback cb, void *userdata); void ssh_poll_free(ssh_poll_handle p); ssh_poll_ctx ssh_poll_get_ctx(ssh_poll_handle p); short ssh_poll_get_events(ssh_poll_handle p); void ssh_poll_set_events(ssh_poll_handle p, short events); void ssh_poll_add_events(ssh_poll_handle p, short events); void <API key>(ssh_poll_handle p, short events); socket_t ssh_poll_get_fd(ssh_poll_handle p); void ssh_poll_set_fd(ssh_poll_handle p, socket_t fd); void <API key>(ssh_poll_handle p, ssh_poll_callback cb, void *userdata); ssh_poll_ctx ssh_poll_ctx_new(size_t chunk_size); void ssh_poll_ctx_free(ssh_poll_ctx ctx); int ssh_poll_ctx_add(ssh_poll_ctx ctx, ssh_poll_handle p); int <API key> (ssh_poll_ctx ctx, struct ssh_socket_struct *s); void ssh_poll_ctx_remove(ssh_poll_ctx ctx, ssh_poll_handle p); int ssh_poll_ctx_dopoll(ssh_poll_ctx ctx, int timeout); ssh_poll_ctx <API key>(ssh_session session); #endif /* POLL_H_ */
#ifndef _GPXE_PCI_IDS_H #define _GPXE_PCI_IDS_H /* * PCI Class, Vendor and Device IDs * * Please keep sorted. */ FILE_LICENCE ( GPL2_ONLY ); /* Device classes and subclasses */ #define <API key> 0x0000 #define <API key> 0x0001 #define <API key> 0x01 #define <API key> 0x0100 #define <API key> 0x0101 #define <API key> 0x0102 #define <API key> 0x0103 #define <API key> 0x0104 #define <API key> 0x0180 #define <API key> 0x02 #define <API key> 0x0200 #define <API key> 0x0201 #define <API key> 0x0202 #define <API key> 0x0203 #define <API key> 0x0280 #define <API key> 0x03 #define <API key> 0x0300 #define <API key> 0x0301 #define <API key> 0x0302 #define <API key> 0x0380 #define <API key> 0x04 #define <API key> 0x0400 #define <API key> 0x0401 #define <API key> 0x0402 #define <API key> 0x0480 #define <API key> 0x05 #define <API key> 0x0500 #define <API key> 0x0501 #define <API key> 0x0580 #define <API key> 0x06 #define <API key> 0x0600 #define <API key> 0x0601 #define <API key> 0x0602 #define PCI_CLASS_BRIDGE_MC 0x0603 #define <API key> 0x0604 #define <API key> 0x0605 #define <API key> 0x0606 #define <API key> 0x0607 #define <API key> 0x0608 #define <API key> 0x0680 #define <API key> 0x07 #define <API key> 0x0700 #define <API key> 0x0701 #define <API key> 0x0702 #define <API key> 0x0703 #define <API key> 0x0780 #define <API key> 0x08 #define <API key> 0x0800 #define <API key> 0x0801 #define <API key> 0x0802 #define <API key> 0x0803 #define <API key> 0x0804 #define <API key> 0x0880 #define <API key> 0x09 #define <API key> 0x0900 #define PCI_CLASS_INPUT_PEN 0x0901 #define <API key> 0x0902 #define <API key> 0x0903 #define <API key> 0x0904 #define <API key> 0x0980 #define <API key> 0x0a #define <API key> 0x0a00 #define <API key> 0x0a80 #define <API key> 0x0b #define <API key> 0x0b00 #define <API key> 0x0b01 #define <API key> 0x0b02 #define <API key> 0x0b10 #define <API key> 0x0b20 #define <API key> 0x0b30 #define <API key> 0x0b40 #define <API key> 0x0c #define <API key> 0x0c00 #define <API key> 0x0c01 #define <API key> 0x0c02 #define <API key> 0x0c03 #define <API key> 0x0c04 #define <API key> 0x0c05 #define <API key> 0x0e #define <API key> 0x0e00 #define <API key> 0x0f #define <API key> 0x0f00 #define <API key> 0x0f01 #define <API key> 0x0f03 #define <API key> 0x0f04 #define <API key> 0x10 #define <API key> 0x1000 #define <API key> 0x1001 #define <API key> 0x1080 #define <API key> 0x11 #define PCI_CLASS_SP_DPIO 0x1100 #define PCI_CLASS_SP_OTHER 0x1180 #define PCI_CLASS_OTHERS 0xff /* Vendors */ #define <API key> 0x0675 #define <API key> 0x0871 #define <API key> 0x0e11 #define PCI_VENDOR_ID_NCR 0x1000 #define <API key> 0x1000 #define PCI_VENDOR_ID_ATI 0x1002 #define PCI_VENDOR_ID_VLSI 0x1004 #define PCI_VENDOR_ID_ADL 0x1005 #define PCI_VENDOR_ID_NS 0x100b #define PCI_VENDOR_ID_TSENG 0x100c #define <API key> 0x100e #define PCI_VENDOR_ID_DEC 0x1011 #define <API key> 0x1013 #define PCI_VENDOR_ID_IBM 0x1014 #define <API key> 0x101a /* pci.ids says "AT&T GIS (NCR)" */ #define PCI_VENDOR_ID_WD 0x101c #define PCI_VENDOR_ID_AMI 0x101e #define PCI_VENDOR_ID_AMD 0x1022 #define <API key> 0x1023 #define PCI_VENDOR_ID_AI 0x1025 #define PCI_VENDOR_ID_DELL 0x1028 #define <API key> 0x102B #define PCI_VENDOR_ID_CT 0x102c #define PCI_VENDOR_ID_MIRO 0x1031 #define PCI_VENDOR_ID_NEC 0x1033 #define PCI_VENDOR_ID_FD 0x1036 #define PCI_VENDOR_ID_SIS 0x1039 #define PCI_VENDOR_ID_SI 0x1039 #define PCI_VENDOR_ID_HP 0x103c #define <API key> 0x1042 #define <API key> 0x1043 #define PCI_VENDOR_ID_DPT 0x1044 #define PCI_VENDOR_ID_OPTI 0x1045 #define PCI_VENDOR_ID_ELSA 0x1048 #define PCI_VENDOR_ID_ELSA 0x1048 #define PCI_VENDOR_ID_SGS 0x104a #define <API key> 0x104B #define PCI_VENDOR_ID_TI 0x104c #define PCI_VENDOR_ID_SONY 0x104d #define PCI_VENDOR_ID_OAK 0x104e /* Winbond have two vendor IDs! See 0x10ad as well */ #define <API key> 0x1050 #define <API key> 0x1051 #define PCI_VENDOR_ID_EFAR 0x1055 #define <API key> 0x1057 #define <API key> 0x1507 #define <API key> 0x105a #define PCI_VENDOR_ID_N9 0x105d #define PCI_VENDOR_ID_UMC 0x1060 #define PCI_VENDOR_ID_X 0x1061 #define PCI_VENDOR_ID_MYLEX 0x1069 #define PCI_VENDOR_ID_PICOP 0x1066 #define PCI_VENDOR_ID_APPLE 0x106b #define <API key> 0x1073 #define <API key> 0x1074 #define <API key> 0x1077 #define PCI_VENDOR_ID_CYRIX 0x1078 #define <API key> 0x107d #define <API key> 0x107e #define <API key> 0x1080 #define PCI_VENDOR_ID_FOREX 0x1083 #define <API key> 0x108d #define PCI_VENDOR_ID_SUN 0x108e #define PCI_VENDOR_ID_CMD 0x1095 #define <API key> 0x1098 #define <API key> 0x109e #define <API key> 0x10a8 #define PCI_VENDOR_ID_SGI 0x10a9 #define PCI_VENDOR_ID_ACC 0x10aa #define <API key> 0x10ad #define <API key> 0x10b3 #define PCI_VENDOR_ID_PLX 0x10b5 #define PCI_VENDOR_ID_MADGE 0x10b6 #define PCI_VENDOR_ID_3COM 0x10b7 #define PCI_VENDOR_ID_SMC 0x10b8 #define <API key> 0x13F0 #define PCI_VENDOR_ID_AL 0x10b9 #define <API key> 0x10ba #define <API key> 0x10bd #define <API key> 0x10c8 #define PCI_VENDOR_ID_ASP 0x10cd #define <API key> 0x10d9 #define <API key> 0x10da #define PCI_VENDOR_ID_CERN 0x10dc #define <API key> 0x10de #define PCI_VENDOR_ID_IMS 0x10e0 #define <API key> 0x10e1 #define <API key> 0x10e3 #define PCI_VENDOR_ID_AMCC 0x10e8 #define <API key> 0x10ea #define <API key> 0x10ec #define <API key> 0x10ee #define <API key> 0x10fa #define PCI_VENDOR_ID_INIT 0x1101 #define <API key> 0x1102 /* duplicate: ECTIVA */ #define <API key> 0x1102 /* duplicate: CREATIVE */ #define PCI_VENDOR_ID_TTI 0x1103 #define PCI_VENDOR_ID_VIA 0x1106 #define <API key> 0x1106 #define <API key> 0x110A #define PCI_VENDOR_ID_SMC2 0x1113 #define <API key> 0x1119 #define PCI_VENDOR_ID_EF 0x111a #define PCI_VENDOR_ID_IDT 0x111d #define PCI_VENDOR_ID_FORE 0x1127 #define <API key> 0x112f #define <API key> 0x1131 #define PCI_VENDOR_ID_EICON 0x1133 #define <API key> 0x113c #define <API key> 0x1142 #define <API key> 0x1148 #define PCI_VENDOR_ID_VMIC 0x114a #define PCI_VENDOR_ID_DIGI 0x114f #define <API key> 0x1159 #define <API key> 0x115d #define <API key> 0x1163 #define <API key> 0x1166 #define PCI_VENDOR_ID_SBE 0x1176 #define <API key> 0x1179 #define PCI_VENDOR_ID_RICOH 0x1180 #define PCI_VENDOR_ID_DLINK 0x1186 #define PCI_VENDOR_ID_ARTOP 0x1191 #define <API key> 0x1193 #define PCI_VENDOR_ID_OMEGA 0x119b #define <API key> 0x119e #define <API key> 0x11a9 #define <API key> 0x11ab #define <API key> 0x11ad #define <API key> 0x11ad #define PCI_VENDOR_ID_V3 0x11b0 #define PCI_VENDOR_ID_NP 0x11bc #define PCI_VENDOR_ID_ATT 0x11c1 #define <API key> 0x11cb #define <API key> 0x11d1 #define <API key> 0x11d4 #define PCI_VENDOR_ID_IKON 0x11d5 #define PCI_VENDOR_ID_ZORAN 0x11de #define <API key> 0x11f4 #define <API key> 0x11f6 #define PCI_VENDOR_ID_RP 0x11fe #define <API key> 0x120e #define <API key> 0x120f #define PCI_VENDOR_ID_O2 0x1217 #define PCI_VENDOR_ID_3DFX 0x121a #define <API key> 0x1236 #define PCI_VENDOR_ID_CCUBE 0x123f #define PCI_VENDOR_ID_AVM 0x1244 #define PCI_VENDOR_ID_DIPIX 0x1246 #define <API key> 0x124d #define <API key> 0x1255 #define PCI_VENDOR_ID_ESS 0x125d #define <API key> 0x1260 #define <API key> 0x1267 #define <API key> 0x1273 #define <API key> 0x1274 #define <API key> 0x127A #define <API key> 0x1282 #define PCI_VENDOR_ID_ITE 0x1283 /* formerly Platform Tech */ #define <API key> 0x1285 #define <API key> 0x12ae #define PCI_VENDOR_ID_USR 0x12B9 #define <API key> 0x12c3 #define <API key> 0x12c4 #define <API key> 0x12c5 #define <API key> 0x12d2 #define <API key> 0x12E0 #define <API key> 0x124D #define <API key> 0x12eb #define <API key> 0x1307 #define PCI_VENDOR_ID_SIIG 0x131f #define <API key> 0x1317 #define PCI_VENDOR_ID_DOMEX 0x134a #define <API key> 0x135C #define <API key> 0x135e #define <API key> 0x1365 #define <API key> 0x136b #define PCI_VENDOR_ID_LMC 0x1376 #define <API key> 0x1385 #define <API key> 0x1389 #define PCI_VENDOR_ID_MOXA 0x1393 #define PCI_VENDOR_ID_CCD 0x1397 #define <API key> 0x13c0 #define PCI_VENDOR_ID_3WARE 0x13C1 #define <API key> 0x13D1 #define <API key> 0x13f6 #define PCI_VENDOR_ID_LAVA 0x1407 #define <API key> 0x1409 #define <API key> 0x1415 #define <API key> 0x14b9 #define <API key> 0x14c1 #define PCI_VENDOR_ID_TITAN 0x14D2 #define <API key> 0x14d4 #define <API key> 0x14e4 #define PCI_VENDOR_ID_SYBA 0x1592 #define <API key> 0x15aa #define <API key> 0x15b0 #define PCI_VENDOR_ID_PDC 0x15e9 #define PCI_VENDOR_ID_FSC 0x1734 #define <API key> 0x1c1c #define <API key> 0x1de1 #define <API key> 0x3d3d #define <API key> 0x4005 #define PCI_VENDOR_ID_AKS 0x416c #define <API key> 0x4a14 #define PCI_VENDOR_ID_S3 0x5333 #define PCI_VENDOR_ID_DCI 0x6666 #define <API key> 0x5555 #define PCI_VENDOR_ID_INTEL 0x8086 #define <API key> 0x8e0e #define <API key> 0x8e0e #define PCI_VENDOR_ID_KTI 0x8e2e #define <API key> 0x9004 #define <API key> 0x9005 #define <API key> 0x907f #define <API key> 0x9412 #define <API key> 0x9710 #define <API key> 0xd84d #define <API key> 0xe159 #define PCI_VENDOR_ID_ARK 0xedd8 #endif /* _GPXE_PCI_IDS_H */
#include "main.h" #include "soft-interface.h" #include "hard-interface.h" #include "<API key>.h" #include "routing.h" #include "send.h" #include "debugfs.h" #include "translation-table.h" #include "hash.h" #include "gateway_common.h" #include "gateway_client.h" #include "sysfs.h" #include "originator.h" #include <linux/slab.h> #include <linux/ethtool.h> #include <linux/etherdevice.h> #include <linux/if_vlan.h> #include "multicast.h" #include "<API key>.h" #include "network-coding.h" static int batadv_get_settings(struct net_device *dev, struct ethtool_cmd *cmd); static void batadv_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info); static u32 batadv_get_msglevel(struct net_device *dev); static void batadv_set_msglevel(struct net_device *dev, u32 value); static u32 batadv_get_link(struct net_device *dev); static void batadv_get_strings(struct net_device *dev, u32 stringset, u8 *data); static void <API key>(struct net_device *dev, struct ethtool_stats *stats, u64 *data); static int <API key>(struct net_device *dev, int stringset); static const struct ethtool_ops batadv_ethtool_ops = { .get_settings = batadv_get_settings, .get_drvinfo = batadv_get_drvinfo, .get_msglevel = batadv_get_msglevel, .set_msglevel = batadv_set_msglevel, .get_link = batadv_get_link, .get_strings = batadv_get_strings, .get_ethtool_stats = <API key>, .get_sset_count = <API key>, }; int <API key>(struct sk_buff *skb, unsigned int len) { int result; /* TODO: We must check if we can release all references to non-payload * data using skb_header_release in our skbs to allow skb_cow_header to * work optimally. This means that those skbs are not allowed to read * or write any data which is before the current position of skb->data * after that call and thus allow other skbs with the same data buffer * to write freely in that area. */ result = skb_cow_head(skb, len); if (result < 0) return result; skb_push(skb, len); return 0; } static int <API key>(struct net_device *dev) { netif_start_queue(dev); return 0; } static int <API key>(struct net_device *dev) { netif_stop_queue(dev); return 0; } static struct net_device_stats *<API key>(struct net_device *dev) { struct batadv_priv *bat_priv = netdev_priv(dev); struct net_device_stats *stats = &bat_priv->stats; stats->tx_packets = batadv_sum_counter(bat_priv, BATADV_CNT_TX); stats->tx_bytes = batadv_sum_counter(bat_priv, BATADV_CNT_TX_BYTES); stats->tx_dropped = batadv_sum_counter(bat_priv, <API key>); stats->rx_packets = batadv_sum_counter(bat_priv, BATADV_CNT_RX); stats->rx_bytes = batadv_sum_counter(bat_priv, BATADV_CNT_RX_BYTES); return stats; } static int <API key>(struct net_device *dev, void *p) { struct batadv_priv *bat_priv = netdev_priv(dev); struct sockaddr *addr = p; uint8_t old_addr[ETH_ALEN]; if (!is_valid_ether_addr(addr->sa_data)) return -EADDRNOTAVAIL; ether_addr_copy(old_addr, dev->dev_addr); ether_addr_copy(dev->dev_addr, addr->sa_data); /* only modify transtable if it has been initialized before */ if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_ACTIVE) { <API key>(bat_priv, old_addr, BATADV_NO_FLAGS, "mac address changed", false); batadv_tt_local_add(dev, addr->sa_data, BATADV_NO_FLAGS, BATADV_NULL_IFINDEX, BATADV_NO_MARK); } return 0; } static int <API key>(struct net_device *dev, int new_mtu) { /* check ranges */ if ((new_mtu < 68) || (new_mtu > <API key>(dev))) return -EINVAL; dev->mtu = new_mtu; return 0; } /** * <API key> - set the rx mode of a device * @dev: registered network device to modify * * We do not actually need to set any rx filters for the virtual batman * soft interface. However a dummy handler enables a user to set static * multicast listeners for instance. */ static void <API key>(struct net_device *dev) { } static int batadv_interface_tx(struct sk_buff *skb, struct net_device *soft_iface) { struct ethhdr *ethhdr; struct batadv_priv *bat_priv = netdev_priv(soft_iface); struct batadv_hard_iface *primary_if = NULL; struct batadv_bcast_packet *bcast_packet; __be16 ethertype = htons(ETH_P_BATMAN); static const uint8_t stp_addr[ETH_ALEN] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x00}; static const uint8_t ectp_addr[ETH_ALEN] = {0xCF, 0x00, 0x00, 0x00, 0x00, 0x00}; enum <API key> dhcp_rcp = BATADV_DHCP_NO; uint8_t *dst_hint = NULL, chaddr[ETH_ALEN]; struct vlan_ethhdr *vhdr; unsigned int header_len = 0; int data_len = skb->len, ret; unsigned long brd_delay = 1; bool do_bcast = false, client_added; unsigned short vid; uint32_t seqno; int gw_mode; enum batadv_forw_mode forw_mode; struct batadv_orig_node *mcast_single_orig = NULL; if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE) goto dropped; soft_iface->trans_start = jiffies; vid = batadv_get_vid(skb, 0); ethhdr = eth_hdr(skb); switch (ntohs(ethhdr->h_proto)) { case ETH_P_8021Q: vhdr = vlan_eth_hdr(skb); if (vhdr-><API key> != ethertype) break; /* fall through */ case ETH_P_BATMAN: goto dropped; } if (batadv_bla_tx(bat_priv, skb, vid)) goto dropped; /* skb->data might have been reallocated by batadv_bla_tx() */ ethhdr = eth_hdr(skb); /* Register the client MAC in the transtable */ if (!<API key>(ethhdr->h_source)) { client_added = batadv_tt_local_add(soft_iface, ethhdr->h_source, vid, skb->skb_iif, skb->mark); if (!client_added) goto dropped; } /* don't accept stp packets. STP does not help in meshes. * better use the bridge loop avoidance ... * * The same goes for ECTP sent at least by some Cisco Switches, * it might confuse the mesh when used with bridge loop avoidance. */ if (batadv_compare_eth(ethhdr->h_dest, stp_addr)) goto dropped; if (batadv_compare_eth(ethhdr->h_dest, ectp_addr)) goto dropped; gw_mode = atomic_read(&bat_priv->gw_mode); if (<API key>(ethhdr->h_dest)) { /* if gw mode is off, broadcast every packet */ if (gw_mode == BATADV_GW_MODE_OFF) { do_bcast = true; goto send; } dhcp_rcp = <API key>(skb, &header_len, chaddr); ethhdr = eth_hdr(skb); /* if gw_mode is on, broadcast any non-DHCP message. * All the DHCP packets are going to be sent as unicast */ if (dhcp_rcp == BATADV_DHCP_NO) { do_bcast = true; goto send; } if (dhcp_rcp == <API key>) dst_hint = chaddr; else if ((gw_mode == <API key>) && (dhcp_rcp == <API key>)) /* gateways should not forward any DHCP message if * directed to a DHCP server */ goto dropped; send: if (do_bcast && !<API key>(ethhdr->h_dest)) { forw_mode = <API key>(bat_priv, skb, &mcast_single_orig); if (forw_mode == BATADV_FORW_NONE) goto dropped; if (forw_mode == BATADV_FORW_SINGLE) do_bcast = false; } } <API key>(skb, 0); /* ethernet packet should be broadcasted */ if (do_bcast) { primary_if = <API key>(bat_priv); if (!primary_if) goto dropped; /* in case of ARP request, we do not immediately broadcasti the * packet, instead we first wait for DAT to try to retrieve the * correct ARP entry */ if (<API key>(bat_priv, skb)) brd_delay = msecs_to_jiffies(ARP_REQ_DELAY); if (<API key>(skb, sizeof(*bcast_packet)) < 0) goto dropped; bcast_packet = (struct batadv_bcast_packet *)skb->data; bcast_packet->version = <API key>; bcast_packet->ttl = BATADV_TTL; /* batman packet type: broadcast */ bcast_packet->packet_type = BATADV_BCAST; bcast_packet->reserved = 0; /* hw address of first interface is the orig mac because only * this mac is known throughout the mesh */ ether_addr_copy(bcast_packet->orig, primary_if->net_dev->dev_addr); /* set broadcast sequence number */ seqno = atomic_inc_return(&bat_priv->bcast_seqno); bcast_packet->seqno = htonl(seqno); <API key>(bat_priv, skb, brd_delay); /* a copy is stored in the bcast list, therefore removing * the original skb. */ kfree_skb(skb); /* unicast packet */ } else { /* DHCP packets going to a server will use the GW feature */ if (dhcp_rcp == <API key>) { ret = <API key>(bat_priv, skb); if (ret) goto dropped; ret = <API key>(bat_priv, skb, vid); } else if (mcast_single_orig) { ret = <API key>(bat_priv, skb, BATADV_UNICAST, 0, mcast_single_orig, vid); } else { if (<API key>(bat_priv, skb)) goto dropped; <API key>(bat_priv, skb); ret = <API key>(bat_priv, skb, dst_hint, vid); } if (ret == NET_XMIT_DROP) goto dropped_freed; } batadv_inc_counter(bat_priv, BATADV_CNT_TX); batadv_add_counter(bat_priv, BATADV_CNT_TX_BYTES, data_len); goto end; dropped: kfree_skb(skb); dropped_freed: batadv_inc_counter(bat_priv, <API key>); end: if (primary_if) <API key>(primary_if); return NETDEV_TX_OK; } void batadv_interface_rx(struct net_device *soft_iface, struct sk_buff *skb, struct batadv_hard_iface *recv_if, int hdr_size, struct batadv_orig_node *orig_node) { struct batadv_bcast_packet *batadv_bcast_packet; struct batadv_priv *bat_priv = netdev_priv(soft_iface); __be16 ethertype = htons(ETH_P_BATMAN); struct vlan_ethhdr *vhdr; struct ethhdr *ethhdr; unsigned short vid; bool is_bcast; batadv_bcast_packet = (struct batadv_bcast_packet *)skb->data; is_bcast = (batadv_bcast_packet->packet_type == BATADV_BCAST); /* check if enough space is available for pulling, and pull */ if (!pskb_may_pull(skb, hdr_size)) goto dropped; skb_pull_rcsum(skb, hdr_size); <API key>(skb); /* clean the netfilter state now that the batman-adv header has been * removed */ nf_reset(skb); vid = batadv_get_vid(skb, 0); ethhdr = eth_hdr(skb); switch (ntohs(ethhdr->h_proto)) { case ETH_P_8021Q: vhdr = (struct vlan_ethhdr *)skb->data; if (vhdr-><API key> != ethertype) break; /* fall through */ case ETH_P_BATMAN: goto dropped; } /* skb->dev & skb->pkt_type are set here */ if (unlikely(!pskb_may_pull(skb, ETH_HLEN))) goto dropped; skb->protocol = eth_type_trans(skb, soft_iface); /* should not be necessary anymore as we use skb_pull_rcsum() * TODO: please verify this and remove this TODO * -- Dec 21st 2009, Simon Wunderlich */ /* skb->ip_summed = <API key>; */ batadv_inc_counter(bat_priv, BATADV_CNT_RX); batadv_add_counter(bat_priv, BATADV_CNT_RX_BYTES, skb->len + ETH_HLEN); soft_iface->last_rx = jiffies; /* Let the bridge loop avoidance check the packet. If will * not handle it, we can safely push it up. */ if (batadv_bla_rx(bat_priv, skb, vid, is_bcast)) goto out; if (orig_node) <API key>(bat_priv, orig_node, ethhdr->h_source, vid); if (<API key>(ethhdr->h_dest)) { /* set the mark on broadcast packets if AP isolation is ON and * the packet is coming from an "isolated" client */ if (<API key>(bat_priv, vid) && <API key>(bat_priv, ethhdr->h_source, vid)) { /* save bits in skb->mark not covered by the mask and * apply the mark on the rest */ skb->mark &= ~bat_priv->isolation_mark_mask; skb->mark |= bat_priv->isolation_mark; } } else if (<API key>(bat_priv, ethhdr->h_source, ethhdr->h_dest, vid)) { goto dropped; } netif_rx(skb); goto out; dropped: kfree_skb(skb); out: return; } /** * <API key> - decrease the vlan object refcounter and * possibly free it * @softif_vlan: the vlan object to release */ void <API key>(struct batadv_softif_vlan *vlan) { if (atomic_dec_and_test(&vlan->refcount)) { spin_lock_bh(&vlan->bat_priv-><API key>); hlist_del_rcu(&vlan->list); spin_unlock_bh(&vlan->bat_priv-><API key>); kfree_rcu(vlan, rcu); } } /** * <API key> - get the vlan object for a specific vid * @bat_priv: the bat priv with all the soft interface information * @vid: the identifier of the vlan object to retrieve * * Returns the private data of the vlan matching the vid passed as argument or * NULL otherwise. The refcounter of the returned object is incremented by 1. */ struct batadv_softif_vlan *<API key>(struct batadv_priv *bat_priv, unsigned short vid) { struct batadv_softif_vlan *vlan_tmp, *vlan = NULL; rcu_read_lock(); <API key>(vlan_tmp, &bat_priv->softif_vlan_list, list) { if (vlan_tmp->vid != vid) continue; if (!atomic_inc_not_zero(&vlan_tmp->refcount)) continue; vlan = vlan_tmp; break; } rcu_read_unlock(); return vlan; } /** * batadv_create_vlan - allocate the needed resources for a new vlan * @bat_priv: the bat priv with all the soft interface information * @vid: the VLAN identifier * * Returns 0 on success, a negative error otherwise. */ int <API key>(struct batadv_priv *bat_priv, unsigned short vid) { struct batadv_softif_vlan *vlan; int err; vlan = <API key>(bat_priv, vid); if (vlan) { <API key>(vlan); return -EEXIST; } vlan = kzalloc(sizeof(*vlan), GFP_ATOMIC); if (!vlan) return -ENOMEM; vlan->bat_priv = bat_priv; vlan->vid = vid; atomic_set(&vlan->refcount, 1); atomic_set(&vlan->ap_isolation, 0); err = <API key>(bat_priv->soft_iface, vlan); if (err) { kfree(vlan); return err; } spin_lock_bh(&bat_priv-><API key>); hlist_add_head_rcu(&vlan->list, &bat_priv->softif_vlan_list); spin_unlock_bh(&bat_priv-><API key>); /* add a new TT local entry. This one will be marked with the NOPURGE * flag */ batadv_tt_local_add(bat_priv->soft_iface, bat_priv->soft_iface->dev_addr, vid, BATADV_NULL_IFINDEX, BATADV_NO_MARK); return 0; } /** * <API key> - remove and destroy a softif_vlan object * @bat_priv: the bat priv with all the soft interface information * @vlan: the object to remove */ static void <API key>(struct batadv_priv *bat_priv, struct batadv_softif_vlan *vlan) { /* explicitly remove the associated TT local entry because it is marked * with the NOPURGE flag */ <API key>(bat_priv, bat_priv->soft_iface->dev_addr, vlan->vid, "vlan interface destroyed", false); <API key>(bat_priv, vlan); <API key>(vlan); } /** * <API key> - ndo_add_vid API implementation * @dev: the netdev of the mesh interface * @vid: identifier of the new vlan * * Set up all the internal structures for handling the new vlan on top of the * mesh interface * * Returns 0 on success or a negative error code in case of failure. */ static int <API key>(struct net_device *dev, __be16 proto, unsigned short vid) { struct batadv_priv *bat_priv = netdev_priv(dev); struct batadv_softif_vlan *vlan; int ret; /* only 802.1Q vlans are supported. * batman-adv does not know how to handle other types */ if (proto != htons(ETH_P_8021Q)) return -EINVAL; vid |= BATADV_VLAN_HAS_TAG; /* if a new vlan is getting created and it already exists, it means that * it was not deleted yet. <API key>() increases the * refcount in order to revive the object. * * if it does not exist then create it. */ vlan = <API key>(bat_priv, vid); if (!vlan) return <API key>(bat_priv, vid); /* recreate the sysfs object if it was already destroyed (and it should * be since we received a kill_vid() for this vlan */ if (!vlan->kobj) { ret = <API key>(bat_priv->soft_iface, vlan); if (ret) { <API key>(vlan); return ret; } } /* add a new TT local entry. This one will be marked with the NOPURGE * flag. This must be added again, even if the vlan object already * exists, because the entry was deleted by kill_vid() */ batadv_tt_local_add(bat_priv->soft_iface, bat_priv->soft_iface->dev_addr, vid, BATADV_NULL_IFINDEX, BATADV_NO_MARK); return 0; } /** * <API key> - ndo_kill_vid API implementation * @dev: the netdev of the mesh interface * @vid: identifier of the deleted vlan * * Destroy all the internal structures used to handle the vlan identified by vid * on top of the mesh interface * * Returns 0 on success, -EINVAL if the specified prototype is not ETH_P_8021Q * or -ENOENT if the specified vlan id wasn't registered. */ static int <API key>(struct net_device *dev, __be16 proto, unsigned short vid) { struct batadv_priv *bat_priv = netdev_priv(dev); struct batadv_softif_vlan *vlan; /* only 802.1Q vlans are supported. batman-adv does not know how to * handle other types */ if (proto != htons(ETH_P_8021Q)) return -EINVAL; vlan = <API key>(bat_priv, vid | BATADV_VLAN_HAS_TAG); if (!vlan) return -ENOENT; <API key>(bat_priv, vlan); /* finally free the vlan object */ <API key>(vlan); return 0; } /* batman-adv network devices have devices nesting below it and are a special * "super class" of normal network devices; split their locks off into a * separate class since they always nest. */ static struct lock_class_key <API key>; static struct lock_class_key <API key>; /** * <API key> - Set lockdep class for a single tx queue * @dev: device which owns the tx queue * @txq: tx queue to modify * @_unused: always NULL */ static void <API key>(struct net_device *dev, struct netdev_queue *txq, void *_unused) { lockdep_set_class(&txq->_xmit_lock, &<API key>); } /** * <API key> - Set txq and addr_list lockdep class * @dev: network device to modify */ static void <API key>(struct net_device *dev) { lockdep_set_class(&dev->addr_list_lock, &<API key>); <API key>(dev, <API key>, NULL); } /** * <API key> - cleans up the remains of a softif * @work: work queue item * * Free the parts of the soft interface which can not be removed under * rtnl lock (to prevent deadlock situations). */ static void <API key>(struct work_struct *work) { struct batadv_softif_vlan *vlan; struct batadv_priv *bat_priv; struct net_device *soft_iface; bat_priv = container_of(work, struct batadv_priv, cleanup_work); soft_iface = bat_priv->soft_iface; /* destroy the "untagged" VLAN */ vlan = <API key>(bat_priv, BATADV_NO_FLAGS); if (vlan) { <API key>(bat_priv, vlan); <API key>(vlan); } <API key>(soft_iface); unregister_netdev(soft_iface); } /** * <API key> - late stage initialization of soft interface * @dev: registered network device to modify * * Returns error code on failures */ static int <API key>(struct net_device *dev) { struct batadv_priv *bat_priv; uint32_t random_seqno; int ret; size_t cnt_len = sizeof(uint64_t) * BATADV_CNT_NUM; <API key>(dev); bat_priv = netdev_priv(dev); bat_priv->soft_iface = dev; INIT_WORK(&bat_priv->cleanup_work, <API key>); /* <API key>() needs to be available as soon as * register_netdevice() has been called */ bat_priv->bat_counters = __alloc_percpu(cnt_len, __alignof__(uint64_t)); if (!bat_priv->bat_counters) return -ENOMEM; atomic_set(&bat_priv->aggregated_ogms, 1); atomic_set(&bat_priv->bonding, 0); #ifdef <API key> atomic_set(&bat_priv-><API key>, 0); #endif #ifdef <API key> atomic_set(&bat_priv-><API key>, 1); #endif #ifdef <API key> bat_priv->mcast.flags = BATADV_NO_FLAGS; atomic_set(&bat_priv->multicast_mode, 1); atomic_set(&bat_priv->mcast.num_disabled, 0); atomic_set(&bat_priv->mcast.<API key>, 0); atomic_set(&bat_priv->mcast.num_want_all_ipv4, 0); atomic_set(&bat_priv->mcast.num_want_all_ipv6, 0); #endif atomic_set(&bat_priv->gw_mode, BATADV_GW_MODE_OFF); atomic_set(&bat_priv->gw_sel_class, 20); atomic_set(&bat_priv->gw.bandwidth_down, 100); atomic_set(&bat_priv->gw.bandwidth_up, 20); atomic_set(&bat_priv->orig_interval, 1000); atomic_set(&bat_priv->hop_penalty, 15); #ifdef <API key> atomic_set(&bat_priv->log_level, 0); #endif atomic_set(&bat_priv->fragmentation, 1); atomic_set(&bat_priv->packet_size_max, ETH_DATA_LEN); atomic_set(&bat_priv->bcast_queue_left, <API key>); atomic_set(&bat_priv->batman_queue_left, <API key>); atomic_set(&bat_priv->mesh_state, <API key>); atomic_set(&bat_priv->bcast_seqno, 1); atomic_set(&bat_priv->tt.vn, 0); atomic_set(&bat_priv->tt.local_changes, 0); atomic_set(&bat_priv->tt.ogm_append_cnt, 0); #ifdef <API key> atomic_set(&bat_priv->bla.num_requests, 0); #endif bat_priv->tt.last_changeset = NULL; bat_priv->tt.last_changeset_len = 0; bat_priv->isolation_mark = 0; bat_priv->isolation_mark_mask = 0; /* randomize initial seqno to avoid collision */ get_random_bytes(&random_seqno, sizeof(random_seqno)); atomic_set(&bat_priv->frag_seqno, random_seqno); bat_priv->primary_if = NULL; bat_priv->num_ifaces = 0; <API key>(bat_priv); ret = batadv_algo_select(bat_priv, batadv_routing_algo); if (ret < 0) goto free_bat_counters; ret = <API key>(dev); if (ret < 0) goto free_bat_counters; ret = batadv_mesh_init(dev); if (ret < 0) goto unreg_debugfs; return 0; unreg_debugfs: <API key>(dev); free_bat_counters: free_percpu(bat_priv->bat_counters); bat_priv->bat_counters = NULL; return ret; } /** * <API key> - Add a slave interface to a <API key> * @dev: <API key> used as master interface * @slave_dev: net_device which should become the slave interface * * Return 0 if successful or error otherwise. */ static int <API key>(struct net_device *dev, struct net_device *slave_dev) { struct batadv_hard_iface *hard_iface; int ret = -EINVAL; hard_iface = <API key>(slave_dev); if (!hard_iface || hard_iface->soft_iface != NULL) goto out; ret = <API key>(hard_iface, dev->name); out: if (hard_iface) <API key>(hard_iface); return ret; } /** * <API key> - Delete a slave iface from a <API key> * @dev: <API key> used as master interface * @slave_dev: net_device which should be removed from the master interface * * Return 0 if successful or error otherwise. */ static int <API key>(struct net_device *dev, struct net_device *slave_dev) { struct batadv_hard_iface *hard_iface; int ret = -EINVAL; hard_iface = <API key>(slave_dev); if (!hard_iface || hard_iface->soft_iface != dev) goto out; <API key>(hard_iface, <API key>); ret = 0; out: if (hard_iface) <API key>(hard_iface); return ret; } static const struct net_device_ops batadv_netdev_ops = { .ndo_init = <API key>, .ndo_open = <API key>, .ndo_stop = <API key>, .ndo_get_stats = <API key>, .ndo_vlan_rx_add_vid = <API key>, .<API key> = <API key>, .ndo_set_mac_address = <API key>, .ndo_change_mtu = <API key>, .ndo_set_rx_mode = <API key>, .ndo_start_xmit = batadv_interface_tx, .ndo_validate_addr = eth_validate_addr, .ndo_add_slave = <API key>, .ndo_del_slave = <API key>, }; /** * batadv_softif_free - Deconstructor of <API key> * @dev: Device to cleanup and remove */ static void batadv_softif_free(struct net_device *dev) { <API key>(dev); batadv_mesh_free(dev); /* some scheduled RCU callbacks need the bat_priv struct to accomplish * their tasks. Wait for them all to be finished before freeing the * netdev and its private data (bat_priv) */ rcu_barrier(); free_netdev(dev); } /** * <API key> - early stage initialization of soft interface * @dev: registered network device to modify */ static void <API key>(struct net_device *dev) { struct batadv_priv *priv = netdev_priv(dev); ether_setup(dev); dev->netdev_ops = &batadv_netdev_ops; dev->destructor = batadv_softif_free; dev->features |= <API key>; dev->tx_queue_len = 0; /* can't call min_mtu, because the needed variables * have not been initialized yet */ dev->mtu = ETH_DATA_LEN; /* reserve more space in the skbuff for our header */ dev->hard_header_len = <API key>(); /* generate random address */ eth_hw_addr_random(dev); dev->ethtool_ops = &batadv_ethtool_ops; memset(priv, 0, sizeof(*priv)); } struct net_device *<API key>(const char *name) { struct net_device *soft_iface; int ret; soft_iface = alloc_netdev(sizeof(struct batadv_priv), name, <API key>); if (!soft_iface) return NULL; soft_iface->rtnl_link_ops = &batadv_link_ops; ret = register_netdevice(soft_iface); if (ret < 0) { pr_err("Unable to register the batman interface '%s': %i\n", name, ret); free_netdev(soft_iface); return NULL; } return soft_iface; } /** * <API key> - deletion of <API key> via sysfs * @soft_iface: the to-be-removed batman-adv interface */ void <API key>(struct net_device *soft_iface) { struct batadv_priv *bat_priv = netdev_priv(soft_iface); queue_work(<API key>, &bat_priv->cleanup_work); } /** * <API key> - deletion of <API key> via netlink * @soft_iface: the to-be-removed batman-adv interface * @head: list pointer */ static void <API key>(struct net_device *soft_iface, struct list_head *head) { struct batadv_hard_iface *hard_iface; list_for_each_entry(hard_iface, &batadv_hardif_list, list) { if (hard_iface->soft_iface == soft_iface) <API key>(hard_iface, <API key>); } <API key>(soft_iface); <API key>(soft_iface, head); } int <API key>(const struct net_device *net_dev) { if (net_dev->netdev_ops->ndo_start_xmit == batadv_interface_tx) return 1; return 0; } struct rtnl_link_ops batadv_link_ops __read_mostly = { .kind = "batadv", .priv_size = sizeof(struct batadv_priv), .setup = <API key>, .dellink = <API key>, }; /* ethtool */ static int batadv_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) { cmd->supported = 0; cmd->advertising = 0; <API key>(cmd, SPEED_10); cmd->duplex = DUPLEX_FULL; cmd->port = PORT_TP; cmd->phy_address = 0; cmd->transceiver = XCVR_INTERNAL; cmd->autoneg = AUTONEG_DISABLE; cmd->maxtxpkt = 0; cmd->maxrxpkt = 0; return 0; } static void batadv_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { strlcpy(info->driver, "B.A.T.M.A.N. advanced", sizeof(info->driver)); strlcpy(info->version, <API key>, sizeof(info->version)); strlcpy(info->fw_version, "N/A", sizeof(info->fw_version)); strlcpy(info->bus_info, "batman", sizeof(info->bus_info)); } static u32 batadv_get_msglevel(struct net_device *dev) { return -EOPNOTSUPP; } static void batadv_set_msglevel(struct net_device *dev, u32 value) { } static u32 batadv_get_link(struct net_device *dev) { return 1; } /* Inspired by drivers/net/ethernet/dlink/sundance.c:1702 * Declare each description string in struct.name[] to get fixed sized buffer * and compile time checking for strings longer than ETH_GSTRING_LEN. */ static const struct { const char name[ETH_GSTRING_LEN]; } <API key>[] = { { "tx" }, { "tx_bytes" }, { "tx_dropped" }, { "rx" }, { "rx_bytes" }, { "forward" }, { "forward_bytes" }, { "mgmt_tx" }, { "mgmt_tx_bytes" }, { "mgmt_rx" }, { "mgmt_rx_bytes" }, { "frag_tx" }, { "frag_tx_bytes" }, { "frag_rx" }, { "frag_rx_bytes" }, { "frag_fwd" }, { "frag_fwd_bytes" }, { "tt_request_tx" }, { "tt_request_rx" }, { "tt_response_tx" }, { "tt_response_rx" }, { "tt_roam_adv_tx" }, { "tt_roam_adv_rx" }, #ifdef <API key> { "dat_get_tx" }, { "dat_get_rx" }, { "dat_put_tx" }, { "dat_put_rx" }, { "dat_cached_reply_tx" }, #endif #ifdef <API key> { "nc_code" }, { "nc_code_bytes" }, { "nc_recode" }, { "nc_recode_bytes" }, { "nc_buffer" }, { "nc_decode" }, { "nc_decode_bytes" }, { "nc_decode_failed" }, { "nc_sniffed" }, #endif }; static void batadv_get_strings(struct net_device *dev, uint32_t stringset, uint8_t *data) { if (stringset == ETH_SS_STATS) memcpy(data, <API key>, sizeof(<API key>)); } static void <API key>(struct net_device *dev, struct ethtool_stats *stats, uint64_t *data) { struct batadv_priv *bat_priv = netdev_priv(dev); int i; for (i = 0; i < BATADV_CNT_NUM; i++) data[i] = batadv_sum_counter(bat_priv, i); } static int <API key>(struct net_device *dev, int stringset) { if (stringset == ETH_SS_STATS) return BATADV_CNT_NUM; return -EOPNOTSUPP; }
#include <linux/uaccess.h> #include <linux/types.h> #include <linux/fcntl.h> #include <linux/socket.h> #include <linux/sockios.h> #include <linux/in.h> #include <linux/errno.h> #include <linux/timer.h> #include <linux/mm.h> #include <linux/inet.h> #include <linux/netdevice.h> #include <net/snmp.h> #include <net/ip.h> #include <net/icmp.h> #include <net/protocol.h> #include <linux/skbuff.h> #include <linux/proc_fs.h> #include <linux/export.h> #include <net/sock.h> #include <net/ping.h> #include <net/udp.h> #include <net/route.h> #include <net/inet_common.h> #include <net/checksum.h> #if IS_ENABLED(CONFIG_IPV6) #include <linux/in6.h> #include <linux/icmpv6.h> #include <net/addrconf.h> #include <net/ipv6.h> #include <net/transp_v6.h> #endif struct ping_table { struct hlist_nulls_head hash[PING_HTABLE_SIZE]; rwlock_t lock; }; static struct ping_table ping_table; struct pingv6_ops pingv6_ops; EXPORT_SYMBOL_GPL(pingv6_ops); static u16 ping_port_rover; static inline int ping_hashfn(struct net *net, unsigned int num, unsigned int mask) { int res = (num + net_hash_mix(net)) & mask; pr_debug("hash(%d) = %d\n", num, res); return res; } EXPORT_SYMBOL_GPL(ping_hash); static inline struct hlist_nulls_head *ping_hashslot(struct ping_table *table, struct net *net, unsigned int num) { return &table->hash[ping_hashfn(net, num, PING_HTABLE_MASK)]; } int ping_get_port(struct sock *sk, unsigned short ident) { struct hlist_nulls_node *node; struct hlist_nulls_head *hlist; struct inet_sock *isk, *isk2; struct sock *sk2 = NULL; isk = inet_sk(sk); write_lock_bh(&ping_table.lock); if (ident == 0) { u32 i; u16 result = ping_port_rover + 1; for (i = 0; i < (1L << 16); i++, result++) { if (!result) result++; /* avoid zero */ hlist = ping_hashslot(&ping_table, sock_net(sk), result); <API key>(sk2, node, hlist) { isk2 = inet_sk(sk2); if (isk2->inet_num == result) goto next_port; } /* found */ ping_port_rover = ident = result; break; next_port: ; } if (i >= (1L << 16)) goto fail; } else { hlist = ping_hashslot(&ping_table, sock_net(sk), ident); <API key>(sk2, node, hlist) { isk2 = inet_sk(sk2); /* BUG? Why is this reuse and not reuseaddr? ping.c * doesn't turn off SO_REUSEADDR, and it doesn't expect * that other ping processes can steal its packets. */ if ((isk2->inet_num == ident) && (sk2 != sk) && (!sk2->sk_reuse || !sk->sk_reuse)) goto fail; } } pr_debug("found port/ident = %d\n", ident); isk->inet_num = ident; if (sk_unhashed(sk)) { pr_debug("was not hashed\n"); sock_hold(sk); <API key>(&sk->sk_nulls_node, hlist); sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); } write_unlock_bh(&ping_table.lock); return 0; fail: write_unlock_bh(&ping_table.lock); return 1; } EXPORT_SYMBOL_GPL(ping_get_port); void ping_hash(struct sock *sk) { pr_debug("ping_hash(sk->port=%u)\n", inet_sk(sk)->inet_num); BUG(); /* "Please do not press this button again." */ } void ping_unhash(struct sock *sk) { struct inet_sock *isk = inet_sk(sk); pr_debug("ping_unhash(isk=%p,isk->num=%u)\n", isk, isk->inet_num); if (sk_hashed(sk)) { write_lock_bh(&ping_table.lock); hlist_nulls_del(&sk->sk_nulls_node); sock_put(sk); isk->inet_num = 0; isk->inet_sport = 0; sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1); write_unlock_bh(&ping_table.lock); } } EXPORT_SYMBOL_GPL(ping_unhash); static struct sock *ping_lookup(struct net *net, struct sk_buff *skb, u16 ident) { struct hlist_nulls_head *hslot = ping_hashslot(&ping_table, net, ident); struct sock *sk = NULL; struct inet_sock *isk; struct hlist_nulls_node *hnode; int dif = skb->dev->ifindex; if (skb->protocol == htons(ETH_P_IP)) { pr_debug("try to find: num = %d, daddr = %pI4, dif = %d\n", (int)ident, &ip_hdr(skb)->daddr, dif); #if IS_ENABLED(CONFIG_IPV6) } else if (skb->protocol == htons(ETH_P_IPV6)) { pr_debug("try to find: num = %d, daddr = %pI6c, dif = %d\n", (int)ident, &ipv6_hdr(skb)->daddr, dif); #endif } read_lock_bh(&ping_table.lock); <API key>(sk, hnode, hslot) { isk = inet_sk(sk); pr_debug("iterate\n"); if (isk->inet_num != ident) continue; if (skb->protocol == htons(ETH_P_IP) && sk->sk_family == AF_INET) { pr_debug("found: %p: num=%d, daddr=%pI4, dif=%d\n", sk, (int) isk->inet_num, &isk->inet_rcv_saddr, sk->sk_bound_dev_if); if (isk->inet_rcv_saddr && isk->inet_rcv_saddr != ip_hdr(skb)->daddr) continue; #if IS_ENABLED(CONFIG_IPV6) } else if (skb->protocol == htons(ETH_P_IPV6) && sk->sk_family == AF_INET6) { pr_debug("found: %p: num=%d, daddr=%pI6c, dif=%d\n", sk, (int) isk->inet_num, &sk->sk_v6_rcv_saddr, sk->sk_bound_dev_if); if (!ipv6_addr_any(&sk->sk_v6_rcv_saddr) && !ipv6_addr_equal(&sk->sk_v6_rcv_saddr, &ipv6_hdr(skb)->daddr)) continue; #endif } else { continue; } if (sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif) continue; sock_hold(sk); goto exit; } sk = NULL; exit: read_unlock_bh(&ping_table.lock); return sk; } static void <API key>(struct net *net, kgid_t *low, kgid_t *high) { kgid_t *data = net->ipv4.ping_group_range.range; unsigned int seq; do { seq = read_seqbegin(&net->ipv4.ping_group_range.lock); *low = data[0]; *high = data[1]; } while (read_seqretry(&net->ipv4.ping_group_range.lock, seq)); } int ping_init_sock(struct sock *sk) { struct net *net = sock_net(sk); kgid_t group = current_egid(); struct group_info *group_info; int i, j, count; kgid_t low, high; int ret = 0; <API key>(net, &low, &high); if (gid_lte(low, group) && gid_lte(group, high)) return 0; group_info = get_current_groups(); count = group_info->ngroups; for (i = 0; i < group_info->nblocks; i++) { int cp_count = min_t(int, NGROUPS_PER_BLOCK, count); for (j = 0; j < cp_count; j++) { kgid_t gid = group_info->blocks[i][j]; if (gid_lte(low, gid) && gid_lte(gid, high)) goto out_release_group; } count -= cp_count; } ret = -EACCES; out_release_group: put_group_info(group_info); return ret; } EXPORT_SYMBOL_GPL(ping_init_sock); void ping_close(struct sock *sk, long timeout) { pr_debug("ping_close(sk=%p,sk->num=%u)\n", inet_sk(sk), inet_sk(sk)->inet_num); pr_debug("isk->refcnt = %d\n", sk->sk_refcnt.counter); sk_common_release(sk); } EXPORT_SYMBOL_GPL(ping_close); /* Checks the bind address and possibly modifies sk->sk_bound_dev_if. */ static int <API key>(struct sock *sk, struct inet_sock *isk, struct sockaddr *uaddr, int addr_len) { struct net *net = sock_net(sk); if (sk->sk_family == AF_INET) { struct sockaddr_in *addr = (struct sockaddr_in *) uaddr; int chk_addr_ret; if (addr_len < sizeof(*addr)) return -EINVAL; pr_debug("<API key>(sk=%p,addr=%pI4,port=%d)\n", sk, &addr->sin_addr.s_addr, ntohs(addr->sin_port)); chk_addr_ret = inet_addr_type(net, addr->sin_addr.s_addr); if (addr->sin_addr.s_addr == htonl(INADDR_ANY)) chk_addr_ret = RTN_LOCAL; if ((net->ipv4.<API key> == 0 && isk->freebind == 0 && isk->transparent == 0 && chk_addr_ret != RTN_LOCAL) || chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST) return -EADDRNOTAVAIL; #if IS_ENABLED(CONFIG_IPV6) } else if (sk->sk_family == AF_INET6) { struct sockaddr_in6 *addr = (struct sockaddr_in6 *) uaddr; int addr_type, scoped, has_addr; struct net_device *dev = NULL; if (addr_len < sizeof(*addr)) return -EINVAL; if (addr->sin6_family != AF_INET6) return -EINVAL; pr_debug("<API key>(sk=%p,addr=%pI6c,port=%d)\n", sk, addr->sin6_addr.s6_addr, ntohs(addr->sin6_port)); addr_type = ipv6_addr_type(&addr->sin6_addr); scoped = <API key>(addr_type); if ((addr_type != IPV6_ADDR_ANY && !(addr_type & IPV6_ADDR_UNICAST)) || (scoped && !addr->sin6_scope_id)) return -EINVAL; rcu_read_lock(); if (addr->sin6_scope_id) { dev = <API key>(net, addr->sin6_scope_id); if (!dev) { rcu_read_unlock(); return -ENODEV; } } has_addr = pingv6_ops.ipv6_chk_addr(net, &addr->sin6_addr, dev, scoped); rcu_read_unlock(); if (!(isk->freebind || isk->transparent || has_addr || addr_type == IPV6_ADDR_ANY)) return -EADDRNOTAVAIL; if (scoped) sk->sk_bound_dev_if = addr->sin6_scope_id; #endif } else { return -EAFNOSUPPORT; } return 0; } static void ping_set_saddr(struct sock *sk, struct sockaddr *saddr) { if (saddr->sa_family == AF_INET) { struct inet_sock *isk = inet_sk(sk); struct sockaddr_in *addr = (struct sockaddr_in *) saddr; isk->inet_rcv_saddr = isk->inet_saddr = addr->sin_addr.s_addr; #if IS_ENABLED(CONFIG_IPV6) } else if (saddr->sa_family == AF_INET6) { struct sockaddr_in6 *addr = (struct sockaddr_in6 *) saddr; struct ipv6_pinfo *np = inet6_sk(sk); sk->sk_v6_rcv_saddr = np->saddr = addr->sin6_addr; #endif } } static void ping_clear_saddr(struct sock *sk, int dif) { sk->sk_bound_dev_if = dif; if (sk->sk_family == AF_INET) { struct inet_sock *isk = inet_sk(sk); isk->inet_rcv_saddr = isk->inet_saddr = 0; #if IS_ENABLED(CONFIG_IPV6) } else if (sk->sk_family == AF_INET6) { struct ipv6_pinfo *np = inet6_sk(sk); memset(&sk->sk_v6_rcv_saddr, 0, sizeof(sk->sk_v6_rcv_saddr)); memset(&np->saddr, 0, sizeof(np->saddr)); #endif } } /* * We need our own bind because there are no privileged id's == local ports. * Moreover, we don't allow binding to multi- and broadcast addresses. */ int ping_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) { struct inet_sock *isk = inet_sk(sk); unsigned short snum; int err; int dif = sk->sk_bound_dev_if; err = <API key>(sk, isk, uaddr, addr_len); if (err) return err; lock_sock(sk); err = -EINVAL; if (isk->inet_num != 0) goto out; err = -EADDRINUSE; ping_set_saddr(sk, uaddr); snum = ntohs(((struct sockaddr_in *)uaddr)->sin_port); if (ping_get_port(sk, snum) != 0) { ping_clear_saddr(sk, dif); goto out; } pr_debug("after bind(): num = %d, dif = %d\n", (int)isk->inet_num, (int)sk->sk_bound_dev_if); err = 0; if (sk->sk_family == AF_INET && isk->inet_rcv_saddr) sk->sk_userlocks |= SOCK_BINDADDR_LOCK; #if IS_ENABLED(CONFIG_IPV6) if (sk->sk_family == AF_INET6 && !ipv6_addr_any(&sk->sk_v6_rcv_saddr)) sk->sk_userlocks |= SOCK_BINDADDR_LOCK; #endif if (snum) sk->sk_userlocks |= SOCK_BINDPORT_LOCK; isk->inet_sport = htons(isk->inet_num); isk->inet_daddr = 0; isk->inet_dport = 0; #if IS_ENABLED(CONFIG_IPV6) if (sk->sk_family == AF_INET6) memset(&sk->sk_v6_daddr, 0, sizeof(sk->sk_v6_daddr)); #endif sk_dst_reset(sk); out: release_sock(sk); pr_debug("ping_v4_bind -> %d\n", err); return err; } EXPORT_SYMBOL_GPL(ping_bind); /* * Is this a supported type of ICMP message? */ static inline int ping_supported(int family, int type, int code) { return (family == AF_INET && type == ICMP_ECHO && code == 0) || (family == AF_INET6 && type == ICMPV6_ECHO_REQUEST && code == 0); } /* * This routine is called by the ICMP module when it gets some * sort of error condition. */ void ping_err(struct sk_buff *skb, int offset, u32 info) { int family; struct icmphdr *icmph; struct inet_sock *inet_sock; int type; int code; struct net *net = dev_net(skb->dev); struct sock *sk; int harderr; int err; if (skb->protocol == htons(ETH_P_IP)) { family = AF_INET; type = icmp_hdr(skb)->type; code = icmp_hdr(skb)->code; icmph = (struct icmphdr *)(skb->data + offset); } else if (skb->protocol == htons(ETH_P_IPV6)) { family = AF_INET6; type = icmp6_hdr(skb)->icmp6_type; code = icmp6_hdr(skb)->icmp6_code; icmph = (struct icmphdr *) (skb->data + offset); } else { BUG(); } /* We assume the packet has already been checked by icmp_unreach */ if (!ping_supported(family, icmph->type, icmph->code)) return; pr_debug("ping_err(proto=0x%x,type=%d,code=%d,id=%04x,seq=%04x)\n", skb->protocol, type, code, ntohs(icmph->un.echo.id), ntohs(icmph->un.echo.sequence)); sk = ping_lookup(net, skb, ntohs(icmph->un.echo.id)); if (sk == NULL) { pr_debug("no socket, dropping\n"); return; /* No socket for error */ } pr_debug("err on socket %p\n", sk); err = 0; harderr = 0; inet_sock = inet_sk(sk); if (skb->protocol == htons(ETH_P_IP)) { switch (type) { default: case ICMP_TIME_EXCEEDED: err = EHOSTUNREACH; break; case ICMP_SOURCE_QUENCH: /* This is not a real error but ping wants to see it. * Report it with some fake errno. */ err = EREMOTEIO; break; case ICMP_PARAMETERPROB: err = EPROTO; harderr = 1; break; case ICMP_DEST_UNREACH: if (code == ICMP_FRAG_NEEDED) { /* Path MTU discovery */ ipv4_sk_update_pmtu(skb, sk, info); if (inet_sock->pmtudisc != IP_PMTUDISC_DONT) { err = EMSGSIZE; harderr = 1; break; } goto out; } err = EHOSTUNREACH; if (code <= NR_ICMP_UNREACH) { harderr = icmp_err_convert[code].fatal; err = icmp_err_convert[code].errno; } break; case ICMP_REDIRECT: /* See ICMP_SOURCE_QUENCH */ ipv4_sk_redirect(skb, sk); err = EREMOTEIO; break; } #if IS_ENABLED(CONFIG_IPV6) } else if (skb->protocol == htons(ETH_P_IPV6)) { harderr = pingv6_ops.icmpv6_err_convert(type, code, &err); #endif } /* * RFC1122: OK. Passes ICMP errors back to application, as per * 4.1.3.3. */ if ((family == AF_INET && !inet_sock->recverr) || (family == AF_INET6 && !inet6_sk(sk)->recverr)) { if (!harderr || sk->sk_state != TCP_ESTABLISHED) goto out; } else { if (family == AF_INET) { ip_icmp_error(sk, skb, err, 0 /* no remote port */, info, (u8 *)icmph); #if IS_ENABLED(CONFIG_IPV6) } else if (family == AF_INET6) { pingv6_ops.ipv6_icmp_error(sk, skb, err, 0, info, (u8 *)icmph); #endif } } sk->sk_err = err; sk->sk_error_report(sk); out: sock_put(sk); } EXPORT_SYMBOL_GPL(ping_err); /* * Copy and checksum an ICMP Echo packet from user space into a buffer * starting from the payload. */ int ping_getfrag(void *from, char *to, int offset, int fraglen, int odd, struct sk_buff *skb) { struct pingfakehdr *pfh = (struct pingfakehdr *)from; if (offset == 0) { fraglen -= sizeof(struct icmphdr); if (fraglen < 0) BUG(); if (<API key>(to + sizeof(struct icmphdr), fraglen, &pfh->wcheck, &pfh->msg->msg_iter) != fraglen) return -EFAULT; } else if (offset < sizeof(struct icmphdr)) { BUG(); } else { if (<API key>(to, fraglen, &pfh->wcheck, &pfh->msg->msg_iter) != fraglen) return -EFAULT; } #if IS_ENABLED(CONFIG_IPV6) /* For IPv6, checksum each skb as we go along, as expected by * <API key>. For IPv4, accumulate the checksum in * wcheck, it will be finalized in <API key>. */ if (pfh->family == AF_INET6) { skb->csum = pfh->wcheck; skb->ip_summed = CHECKSUM_NONE; pfh->wcheck = 0; } #endif return 0; } EXPORT_SYMBOL_GPL(ping_getfrag); static int <API key>(struct sock *sk, struct pingfakehdr *pfh, struct flowi4 *fl4) { struct sk_buff *skb = skb_peek(&sk->sk_write_queue); pfh->wcheck = csum_partial((char *)&pfh->icmph, sizeof(struct icmphdr), pfh->wcheck); pfh->icmph.checksum = csum_fold(pfh->wcheck); memcpy(icmp_hdr(skb), &pfh->icmph, sizeof(struct icmphdr)); skb->ip_summed = CHECKSUM_NONE; return <API key>(sk, fl4); } int ping_common_sendmsg(int family, struct msghdr *msg, size_t len, void *user_icmph, size_t icmph_len) { u8 type, code; if (len > 0xFFFF) return -EMSGSIZE; /* * Check the flags. */ /* Mirror BSD error message compatibility */ if (msg->msg_flags & MSG_OOB) return -EOPNOTSUPP; /* * Fetch the ICMP header provided by the userland. * iovec is modified! The ICMP header is consumed. */ if (memcpy_from_msg(user_icmph, msg, icmph_len)) return -EFAULT; if (family == AF_INET) { type = ((struct icmphdr *) user_icmph)->type; code = ((struct icmphdr *) user_icmph)->code; #if IS_ENABLED(CONFIG_IPV6) } else if (family == AF_INET6) { type = ((struct icmp6hdr *) user_icmph)->icmp6_type; code = ((struct icmp6hdr *) user_icmph)->icmp6_code; #endif } else { BUG(); } if (!ping_supported(family, type, code)) return -EINVAL; return 0; } EXPORT_SYMBOL_GPL(ping_common_sendmsg); static int ping_v4_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, size_t len) { struct net *net = sock_net(sk); struct flowi4 fl4; struct inet_sock *inet = inet_sk(sk); struct ipcm_cookie ipc; struct icmphdr user_icmph; struct pingfakehdr pfh; struct rtable *rt = NULL; struct ip_options_data opt_copy; int free = 0; __be32 saddr, daddr, faddr; u8 tos; int err; pr_debug("ping_v4_sendmsg(sk=%p,sk->num=%u)\n", inet, inet->inet_num); err = ping_common_sendmsg(AF_INET, msg, len, &user_icmph, sizeof(user_icmph)); if (err) return err; /* * Get and verify the address. */ if (msg->msg_name) { DECLARE_SOCKADDR(struct sockaddr_in *, usin, msg->msg_name); if (msg->msg_namelen < sizeof(*usin)) return -EINVAL; if (usin->sin_family != AF_INET) return -EINVAL; daddr = usin->sin_addr.s_addr; /* no remote port */ } else { if (sk->sk_state != TCP_ESTABLISHED) return -EDESTADDRREQ; daddr = inet->inet_daddr; /* no remote port */ } ipc.addr = inet->inet_saddr; ipc.opt = NULL; ipc.oif = sk->sk_bound_dev_if; ipc.tx_flags = 0; ipc.ttl = 0; ipc.tos = -1; sock_tx_timestamp(sk, &ipc.tx_flags); if (msg->msg_controllen) { err = ip_cmsg_send(sock_net(sk), msg, &ipc, false); if (err) return err; if (ipc.opt) free = 1; } if (!ipc.opt) { struct ip_options_rcu *inet_opt; rcu_read_lock(); inet_opt = rcu_dereference(inet->inet_opt); if (inet_opt) { memcpy(&opt_copy, inet_opt, sizeof(*inet_opt) + inet_opt->opt.optlen); ipc.opt = &opt_copy.opt; } rcu_read_unlock(); } saddr = ipc.addr; ipc.addr = faddr = daddr; if (ipc.opt && ipc.opt->opt.srr) { if (!daddr) return -EINVAL; faddr = ipc.opt->opt.faddr; } tos = get_rttos(&ipc, inet); if (sock_flag(sk, SOCK_LOCALROUTE) || (msg->msg_flags & MSG_DONTROUTE) || (ipc.opt && ipc.opt->opt.is_strictroute)) { tos |= RTO_ONLINK; } if (ipv4_is_multicast(daddr)) { if (!ipc.oif) ipc.oif = inet->mc_index; if (!saddr) saddr = inet->mc_addr; } else if (!ipc.oif) ipc.oif = inet->uc_index; flowi4_init_output(&fl4, ipc.oif, sk->sk_mark, tos, RT_SCOPE_UNIVERSE, sk->sk_protocol, inet_sk_flowi_flags(sk), faddr, saddr, 0, 0); <API key>(sk, flowi4_to_flowi(&fl4)); rt = <API key>(net, &fl4, sk); if (IS_ERR(rt)) { err = PTR_ERR(rt); rt = NULL; if (err == -ENETUNREACH) IP_INC_STATS(net, <API key>); goto out; } err = -EACCES; if ((rt->rt_flags & RTCF_BROADCAST) && !sock_flag(sk, SOCK_BROADCAST)) goto out; if (msg->msg_flags & MSG_CONFIRM) goto do_confirm; back_from_confirm: if (!ipc.addr) ipc.addr = fl4.daddr; lock_sock(sk); pfh.icmph.type = user_icmph.type; /* already checked */ pfh.icmph.code = user_icmph.code; /* ditto */ pfh.icmph.checksum = 0; pfh.icmph.un.echo.id = inet->inet_sport; pfh.icmph.un.echo.sequence = user_icmph.un.echo.sequence; pfh.msg = msg; pfh.wcheck = 0; pfh.family = AF_INET; err = ip_append_data(sk, &fl4, ping_getfrag, &pfh, len, 0, &ipc, &rt, msg->msg_flags); if (err) <API key>(sk); else err = <API key>(sk, &pfh, &fl4); release_sock(sk); out: ip_rt_put(rt); if (free) kfree(ipc.opt); if (!err) { icmp_out_count(sock_net(sk), user_icmph.type); return len; } return err; do_confirm: dst_confirm(&rt->dst); if (!(msg->msg_flags & MSG_PROBE) || len) goto back_from_confirm; err = 0; goto out; } int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, size_t len, int noblock, int flags, int *addr_len) { struct inet_sock *isk = inet_sk(sk); int family = sk->sk_family; struct sk_buff *skb; int copied, err; pr_debug("ping_recvmsg(sk=%p,sk->num=%u)\n", isk, isk->inet_num); err = -EOPNOTSUPP; if (flags & MSG_OOB) goto out; if (flags & MSG_ERRQUEUE) return inet_recv_error(sk, msg, len, addr_len); skb = skb_recv_datagram(sk, flags, noblock, &err); if (!skb) goto out; copied = skb->len; if (copied > len) { msg->msg_flags |= MSG_TRUNC; copied = len; } /* Don't bother checking the checksum */ err = <API key>(skb, 0, msg, copied); if (err) goto done; sock_recv_timestamp(msg, sk, skb); /* Copy the address and add cmsg data. */ if (family == AF_INET) { DECLARE_SOCKADDR(struct sockaddr_in *, sin, msg->msg_name); if (sin) { sin->sin_family = AF_INET; sin->sin_port = 0 /* skb->h.uh->source */; sin->sin_addr.s_addr = ip_hdr(skb)->saddr; memset(sin->sin_zero, 0, sizeof(sin->sin_zero)); *addr_len = sizeof(*sin); } if (isk->cmsg_flags) ip_cmsg_recv(msg, skb); #if IS_ENABLED(CONFIG_IPV6) } else if (family == AF_INET6) { struct ipv6_pinfo *np = inet6_sk(sk); struct ipv6hdr *ip6 = ipv6_hdr(skb); DECLARE_SOCKADDR(struct sockaddr_in6 *, sin6, msg->msg_name); if (sin6) { sin6->sin6_family = AF_INET6; sin6->sin6_port = 0; sin6->sin6_addr = ip6->saddr; sin6->sin6_flowinfo = 0; if (np->sndflow) sin6->sin6_flowinfo = ip6_flowinfo(ip6); sin6->sin6_scope_id = ipv6_iface_scope_id(&sin6->sin6_addr, inet6_iif(skb)); *addr_len = sizeof(*sin6); } if (inet6_sk(sk)->rxopt.all) pingv6_ops.<API key>(sk, msg, skb); if (skb->protocol == htons(ETH_P_IPV6) && inet6_sk(sk)->rxopt.all) pingv6_ops.<API key>(sk, msg, skb); else if (skb->protocol == htons(ETH_P_IP) && isk->cmsg_flags) ip_cmsg_recv(msg, skb); #endif } else { BUG(); } err = copied; done: skb_free_datagram(sk, skb); out: pr_debug("ping_recvmsg -> %d\n", err); return err; } EXPORT_SYMBOL_GPL(ping_recvmsg); int ping_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) { pr_debug("ping_queue_rcv_skb(sk=%p,sk->num=%d,skb=%p)\n", inet_sk(sk), inet_sk(sk)->inet_num, skb); if (sock_queue_rcv_skb(sk, skb) < 0) { kfree_skb(skb); pr_debug("ping_queue_rcv_skb -> failed\n"); return -1; } return 0; } EXPORT_SYMBOL_GPL(ping_queue_rcv_skb); /* * All we need to do is get the socket. */ bool ping_rcv(struct sk_buff *skb) { struct sock *sk; struct net *net = dev_net(skb->dev); struct icmphdr *icmph = icmp_hdr(skb); /* We assume the packet has already been checked by icmp_rcv */ pr_debug("ping_rcv(skb=%p,id=%04x,seq=%04x)\n", skb, ntohs(icmph->un.echo.id), ntohs(icmph->un.echo.sequence)); /* Push ICMP header back */ skb_push(skb, skb->data - (u8 *)icmph); sk = ping_lookup(net, skb, ntohs(icmph->un.echo.id)); if (sk != NULL) { struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC); pr_debug("rcv on socket %p\n", sk); if (skb2) ping_queue_rcv_skb(sk, skb2); sock_put(sk); return true; } pr_debug("no socket, dropping\n"); return false; } EXPORT_SYMBOL_GPL(ping_rcv); struct proto ping_prot = { .name = "PING", .owner = THIS_MODULE, .init = ping_init_sock, .close = ping_close, .connect = <API key>, .disconnect = udp_disconnect, .setsockopt = ip_setsockopt, .getsockopt = ip_getsockopt, .sendmsg = ping_v4_sendmsg, .recvmsg = ping_recvmsg, .bind = ping_bind, .backlog_rcv = ping_queue_rcv_skb, .release_cb = <API key>, .hash = ping_hash, .unhash = ping_unhash, .get_port = ping_get_port, .obj_size = sizeof(struct inet_sock), }; EXPORT_SYMBOL(ping_prot); #ifdef CONFIG_PROC_FS static struct sock *ping_get_first(struct seq_file *seq, int start) { struct sock *sk; struct ping_iter_state *state = seq->private; struct net *net = seq_file_net(seq); for (state->bucket = start; state->bucket < PING_HTABLE_SIZE; ++state->bucket) { struct hlist_nulls_node *node; struct hlist_nulls_head *hslot; hslot = &ping_table.hash[state->bucket]; if (hlist_nulls_empty(hslot)) continue; sk_nulls_for_each(sk, node, hslot) { if (net_eq(sock_net(sk), net) && sk->sk_family == state->family) goto found; } } sk = NULL; found: return sk; } static struct sock *ping_get_next(struct seq_file *seq, struct sock *sk) { struct ping_iter_state *state = seq->private; struct net *net = seq_file_net(seq); do { sk = sk_nulls_next(sk); } while (sk && (!net_eq(sock_net(sk), net))); if (!sk) return ping_get_first(seq, state->bucket + 1); return sk; } static struct sock *ping_get_idx(struct seq_file *seq, loff_t pos) { struct sock *sk = ping_get_first(seq, 0); if (sk) while (pos && (sk = ping_get_next(seq, sk)) != NULL) --pos; return pos ? NULL : sk; } void *ping_seq_start(struct seq_file *seq, loff_t *pos, sa_family_t family) { struct ping_iter_state *state = seq->private; state->bucket = 0; state->family = family; read_lock_bh(&ping_table.lock); return *pos ? ping_get_idx(seq, *pos-1) : SEQ_START_TOKEN; } EXPORT_SYMBOL_GPL(ping_seq_start); static void *ping_v4_seq_start(struct seq_file *seq, loff_t *pos) { return ping_seq_start(seq, pos, AF_INET); } void *ping_seq_next(struct seq_file *seq, void *v, loff_t *pos) { struct sock *sk; if (v == SEQ_START_TOKEN) sk = ping_get_idx(seq, 0); else sk = ping_get_next(seq, v); ++*pos; return sk; } EXPORT_SYMBOL_GPL(ping_seq_next); void ping_seq_stop(struct seq_file *seq, void *v) { read_unlock_bh(&ping_table.lock); } EXPORT_SYMBOL_GPL(ping_seq_stop); static void ping_v4_format_sock(struct sock *sp, struct seq_file *f, int bucket) { struct inet_sock *inet = inet_sk(sp); __be32 dest = inet->inet_daddr; __be32 src = inet->inet_rcv_saddr; __u16 destp = ntohs(inet->inet_dport); __u16 srcp = ntohs(inet->inet_sport); seq_printf(f, "%5d: %08X:%04X %08X:%04X" " %02X %08X:%08X %02X:%08lX %08X %5u %8d %lu %d %pK %d", bucket, src, srcp, dest, destp, sp->sk_state, sk_wmem_alloc_get(sp), sk_rmem_alloc_get(sp), 0, 0L, 0, from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)), 0, sock_i_ino(sp), atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops)); } static int ping_v4_seq_show(struct seq_file *seq, void *v) { seq_setwidth(seq, 127); if (v == SEQ_START_TOKEN) seq_puts(seq, " sl local_address rem_address st tx_queue " "rx_queue tr tm->when retrnsmt uid timeout " "inode ref pointer drops"); else { struct ping_iter_state *state = seq->private; ping_v4_format_sock(v, seq, state->bucket); } seq_pad(seq, '\n'); return 0; } static const struct seq_operations ping_v4_seq_ops = { .show = ping_v4_seq_show, .start = ping_v4_seq_start, .next = ping_seq_next, .stop = ping_seq_stop, }; static int ping_seq_open(struct inode *inode, struct file *file) { struct ping_seq_afinfo *afinfo = PDE_DATA(inode); return seq_open_net(inode, file, &afinfo->seq_ops, sizeof(struct ping_iter_state)); } const struct file_operations ping_seq_fops = { .open = ping_seq_open, .read = seq_read, .llseek = seq_lseek, .release = seq_release_net, }; EXPORT_SYMBOL_GPL(ping_seq_fops); static struct ping_seq_afinfo ping_v4_seq_afinfo = { .name = "icmp", .family = AF_INET, .seq_fops = &ping_seq_fops, .seq_ops = { .start = ping_v4_seq_start, .show = ping_v4_seq_show, .next = ping_seq_next, .stop = ping_seq_stop, }, }; int ping_proc_register(struct net *net, struct ping_seq_afinfo *afinfo) { struct proc_dir_entry *p; p = proc_create_data(afinfo->name, S_IRUGO, net->proc_net, afinfo->seq_fops, afinfo); if (!p) return -ENOMEM; return 0; } EXPORT_SYMBOL_GPL(ping_proc_register); void <API key>(struct net *net, struct ping_seq_afinfo *afinfo) { remove_proc_entry(afinfo->name, net->proc_net); } EXPORT_SYMBOL_GPL(<API key>); static int __net_init <API key>(struct net *net) { return ping_proc_register(net, &ping_v4_seq_afinfo); } static void __net_exit <API key>(struct net *net) { <API key>(net, &ping_v4_seq_afinfo); } static struct pernet_operations ping_v4_net_ops = { .init = <API key>, .exit = <API key>, }; int __init ping_proc_init(void) { return <API key>(&ping_v4_net_ops); } void ping_proc_exit(void) { <API key>(&ping_v4_net_ops); } #endif void __init ping_init(void) { int i; for (i = 0; i < PING_HTABLE_SIZE; i++) <API key>(&ping_table.hash[i], i); rwlock_init(&ping_table.lock); }
# Makefile for physical layer USB drivers ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG obj-$(CONFIG_USB_PHY) += phy.o obj-$(CONFIG_OF) += of.o obj-$(<API key>) += otg-wakelock.o obj-$(<API key>) += class-dual-role.o # transceiver drivers, keep the list sorted obj-$(CONFIG_AB8500_USB) += phy-ab8500-usb.o phy-fsl-usb2-objs := phy-fsl-usb.o phy-fsm-usb.o obj-$(CONFIG_FSL_USB2_OTG) += phy-fsl-usb2.o obj-$(CONFIG_ISP1301_OMAP) += phy-isp1301-omap.o obj-$(CONFIG_MV_U3D_PHY) += phy-mv-u3d-usb.o obj-$(<API key>) += phy-nop.o obj-$(<API key>) += phy-omap-control.o obj-$(CONFIG_OMAP_USB2) += phy-omap-usb2.o obj-$(CONFIG_OMAP_USB3) += phy-omap-usb3.o obj-$(<API key>) += phy-samsung-usb.o obj-$(<API key>) += phy-samsung-usb2.o obj-$(<API key>) += phy-samsung-usb3.o obj-$(CONFIG_TWL4030_USB) += phy-twl4030-usb.o obj-$(CONFIG_TWL6030_USB) += phy-twl6030-usb.o obj-$(<API key>) += phy-tegra-usb.o obj-$(<API key>) += phy-gpio-vbus-usb.o obj-$(CONFIG_USB_ISP1301) += phy-isp1301.o obj-$(CONFIG_USB_MSM_OTG) += phy-msm-usb.o obj-$(<API key>) += phy-msm-hsusb.o obj-$(<API key>) += phy-msm-ssusb.o obj-$(<API key>) += phy-msm-hsusb-pp.o obj-$(<API key>) += phy-msm-ssusb-pp.o obj-$(<API key>) += phy-msm-ssusb-qmp.o obj-$(CONFIG_MSM_QUSB_PHY) += phy-msm-qusb.o obj-$(CONFIG_USB_MV_OTG) += phy-mv-usb.o obj-$(CONFIG_USB_MXS_PHY) += phy-mxs-usb.o obj-$(CONFIG_USB_RCAR_PHY) += phy-rcar-usb.o obj-$(CONFIG_USB_ULPI) += phy-ulpi.o obj-$(<API key>) += phy-ulpi-viewport.o
/* * TEST SUITE FOR MB/WC FUNCTIONS IN C LIBRARY * * FILE: dat_wcscmp.c * * WCSCMP: int wcscmp (const wchar_t *ws1, const wchar_t *ws2); */ /* NOTE: This is not a locale sensitive function and it may not make sence testing it for each locale ... */ TST_WCSCMP tst_wcscmp_loc [] = { { { Twcscmp, TST_LOC_de }, { { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 }, { 0x00D1,0x00D2,0x00D3,0x0000 }, }, /*expect*/ { 0,1,0, }, }, { /*input.*/ { { 0x0000,0x00D1,0x00D3,0x0000 }, { 0x0000,0x00D2,0x00D3,0x0000 }, }, /*expect*/ { 0,1,0, }, }, { /*input.*/ { { 0x00D1,0x00D1,0x00D3,0x0000 }, { 0x0000,0x00D2,0x00D3,0x0000 }, }, /*expect*/ { 0,1,1, }, }, { /*input.*/ { { 0x0000,0x00D2,0x00D3,0x0000 }, { 0x00D1,0x00D1,0x00D3,0x0000 }, }, /*expect*/ { 0,1,-1, }, }, { /*input.*/ { { 0x00D1,0x00D5,0x00D3,0x0000 }, { 0x00D1,0x00D2,0x00D3,0x0000 }, }, /*expect*/ { 0,1,1, }, }, { /*input.*/ { { 0x00D1,0x00D2,0x00D3,0x0000 }, { 0x00D1,0x00D2,0x00D9,0x0000 }, }, /*expect*/ { 0,1,-1, }, }, { /*input.*/ { { 0x00D1,0x00D2,0x0000 }, { 0x00D1,0x00D2,0x00D9,0x0000 }, }, /*expect*/ { 0,1,-1, }, }, { /*input.*/ { { 0x00D1,0x00D2,0x00D9,0x0000 }, { 0x00D1,0x00D2,0x0000 }, }, /*expect*/ { 0,1,1, }, }, { .is_last = 1 } } }, { { Twcscmp, TST_LOC_enUS }, { { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 }, { 0x0041,0x0042,0x0043,0x0000 }, }, /*expect*/ { 0,1,0, }, }, { /*input.*/ { { 0x0000,0x0041,0x0043,0x0000 }, { 0x0000,0x0042,0x0043,0x0000 }, }, /*expect*/ { 0,1,0, }, }, { /*input.*/ { { 0x0041,0x0041,0x0043,0x0000 }, { 0x0000,0x0042,0x0043,0x0000 }, }, /*expect*/ { 0,1,1, }, }, { /*input.*/ { { 0x0000,0x0042,0x0043,0x0000 }, { 0x0041,0x0041,0x0043,0x0000 }, }, /*expect*/ { 0,1,-1, }, }, { /*input.*/ { { 0x0041,0x0045,0x0043,0x0000 }, { 0x0041,0x0042,0x0043,0x0000 }, }, /*expect*/ { 0,1,1, }, }, { /*input.*/ { { 0x0041,0x0042,0x0043,0x0000 }, { 0x0041,0x0042,0x0049,0x0000 }, }, /*expect*/ { 0,1,-1, }, }, { /*input.*/ { { 0x0041,0x0042,0x0000 }, { 0x0041,0x0042,0x0049,0x0000 }, }, /*expect*/ { 0,1,-1, }, }, { /*input.*/ { { 0x0041,0x0042,0x0049,0x0000 }, { 0x0041,0x0042,0x0000 }, }, /*expect*/ { 0,1,1, }, }, { .is_last = 1 } } }, { #if 0 { Twcscmp, TST_LOC_eucJP}, #else { Twcscmp, TST_LOC_ja_UTF8}, #endif { { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 }, { 0x3041,0x3042,0x3043,0x0000 }, }, /*expect*/ { 0,1,0, }, }, { /*input.*/ { { 0x0000,0x3041,0x3043,0x0000 }, { 0x0000,0x3042,0x3043,0x0000 }, }, /*expect*/ { 0,1,0, }, }, { /*input.*/ { { 0x3041,0x3041,0x3043,0x0000 }, { 0x0000,0x3042,0x3043,0x0000 }, }, /*expect*/ { 0,1,1, }, }, { /*input.*/ { { 0x0000,0x3042,0x3043,0x0000 }, { 0x3041,0x3041,0x3043,0x0000 }, }, /*expect*/ { 0,1,-1, }, }, { /*input.*/ { { 0x3041,0x3045,0x3043,0x0000 }, { 0x3041,0x3042,0x3043,0x0000 }, }, /*expect*/ { 0,1,1, }, }, { /*input.*/ { { 0x3041,0x3042,0x3043,0x0000 }, { 0x3041,0x3042,0x3049,0x0000 }, }, /*expect*/ { 0,1,-1, }, }, { /*input.*/ { { 0x3041,0x3042,0x0000 }, { 0x3041,0x3042,0x3049,0x0000 }, }, /*expect*/ { 0,1,-1, }, }, { /*input.*/ { { 0x3041,0x3042,0x3049,0x0000 }, { 0x3041,0x3042,0x0000 }, }, /*expect*/ { 0,1,1, }, }, { .is_last = 1 } } }, { { Twcschr, TST_LOC_end} } };
#ifndef <API key> #define <API key> #include "cc/base/cc_export.h" #include "cc/layers/layer.h" namespace cc { // Base class for layers that need contents scale. // The content bounds are determined by bounds and scale of the contents. class CC_EXPORT <API key> : public Layer { public: virtual void <API key>(float <API key>, float* contents_scale_x, float* contents_scale_y, gfx::Size* content_bounds) OVERRIDE; virtual bool Update(ResourceUpdateQueue* queue, const OcclusionTracker<Layer>* occlusion) OVERRIDE; protected: <API key>(); virtual ~<API key>(); gfx::Size <API key>(float scale_x, float scale_y) const; private: float <API key>; float <API key>; <API key>(<API key>); }; } // namespace cc #endif // <API key>
.<API key> { width: 27px; height: 27px; border-radius: 20px; border: 2px solid #ffffff; padding: 0px; margin: 0px; margin-top: 8px; margin-bottom: 8px; background-image: url("images/dark/back.png"); background-position: 50% 50%; background-size: 27px 27px; background-repeat: no-repeat; } .dj_gecko .<API key> { -moz-transform: scale(0.77, 1.05) rotate(45deg); } .dj_ff3 .<API key> { -moz-border-radius: 1px; } .dj_ff3 .<API key> { -moz-border-radius: 0; } .dj_ff3 .<API key> .<API key> { -<API key>: 0; -<API key>: 0; } .dj_ff3 .<API key> .<API key> { -<API key>: 0; -<API key>: 0; } .dj_ie .<API key> { top: 0; left: -2px; width: 13px; height: 31px; border-style: none; border-radius: 0; background-image: url(compat/arrow-button-head.png); } .dj_ie .<API key> .<API key> { background-image: url(compat/<API key>.png); } .dj_ie .<API key> { top: 0; right: -3px; width: 13px; height: 31px; border-style: none; border-radius: 0; background-image: url(compat/<API key>.png); } .dj_ie .<API key> .<API key> { background-image: url(compat/<API key>.png); } .dj_ie .<API key> { background-image: url(compat/arrow-button-bg.png); background-position: left bottom; } .dj_ie .<API key> { background-image: url(compat/arrow-button-bg-sel.png); } .dj_ie .<API key> table { margin: 0; } .dj_ie .<API key> .<API key> { <API key>: 0; <API key>: 0; } .dj_ie .<API key> .<API key> { <API key>: 0; <API key>: 0; } .dj_ie6 .mblToolBarButton .<API key> { background-position: left top; }
#<API key> { height: 609px; /* Same size as GAIA sign in screen.*/ padding: 0 0; /* Some screens have elements right next to borders. */ width: 722px; } #<API key> .step-contents { height: 100%; } #<API key> .nofocus:focus { outline: none; } #<API key> .step-controls { -webkit-padding-end: 20px; align-items: center; bottom: 20px; display: flex; justify-content: space-between; } #<API key> .controls-links { align-items: center; display: flex; justify-content: flex-start; } #<API key> .controls-buttons { align-items: center; display: flex; justify-content: flex-end; } #<API key> .logo-padded-text { padding: 0 17px 0; } #<API key> .marketing { background-color: green; height: 344px; } #<API key> .below-marketing { font-size: 12px; line-height: 18px; max-height: 184px; overflow-x: auto; } #<API key> .button-link { font-size: small; padding: 0 20px; } .below-marketing::-webkit-scrollbar { width: 8px; } .below-marketing::-<API key> { background: #eee; } .below-marketing::-<API key> { background: #888; } #<API key> .page-no-marketing { height: 470px; padding: 70px 17px 0; } #<API key> .page-title { color: #000; font-size: 15px; line-height: 24px; } .below-marketing strong { color: #000; font-weight: bold; } #<API key> .<API key> { color: rgb(150, 150, 150); font-size: 12px; } #<API key> .page-title.inline { -webkit-margin-end: 1ex; display: inline-block; } #<API key> .<API key>.inline { display: inline; } #<API key> .page-title.centred { text-align: center; } #<API key> .<API key>.centred { text-align: center; } #<API key> { font-size: x-large; text-align: center; } #<API key> { background-color: gray; font-size: x-large; height: 150px; text-align: center; } #<API key> .below-marketing { margin: 20px 21px 2px 40px; } #<API key> { margin-bottom: 12px; margin-top: 12px; } #<API key> { margin-top: 12px; } #<API key> .below-marketing { margin: 20px 40px 0; } #<API key> { max-width: 600px; word-wrap: break-word; } #<API key> { margin-top: 20px; max-width: 600px; word-wrap: break-word; } #<API key> { margin-top: 20px; } #<API key>, #<API key> { margin-top: 10px; } #<API key> { margin-bottom: 20px; margin-top: 10px; } input.<API key>, #<API key>, #<API key> { padding: 4px 6px; } #<API key> { margin-top: 12px; padding: 4px 6px; } #<API key> { visibility: hidden; } #<API key>.error { color: rgb(207, 93, 70); padding-left: 28px; visibility: visible; } #<API key> { display: flex; flex-direction: column; height: 100%; } #<API key> { border: 1px solid #c8c8c8; height: 100%; margin-top: 20px; overflow-x: hidden; overflow-y: auto; } /* This class will be set for elements with hide-on-import class by JS when * page is used in 'import' mode */ #<API key> .hidden-on-import { display: none; } #<API key> { padding: 175px 120px 0; text-align: center; } #<API key> .error-icon { -webkit-margin-after: 50px; } #<API key> .<API key> { -webkit-margin-after: 40px; -<API key>: 30px; } .<API key> { margin-left: 10px !important; } .import-pod { height: 32px; opacity: 0.8; padding: 20px; width: 646px; } .import-pod .import-pod-name { color: #000; display: inline-block; height: 32px; max-height: 32px; padding-top: 6px; vertical-align: top; } .import-pod.imported .import-pod-name { color: rgb(141, 141, 141); } .import-pod .import-pod-image { border: 1px solid gray; display: inline; height: 30px; width: 30px; } .manager-pod { height: 32px; opacity: 0.8; padding: 20px; width: 646px; } .manager-pod .<API key> { float: left; min-height: 32px; } .manager-pod .<API key> { border: 1px solid gray; display: inline-block; height: 30px; width: 30px; } .manager-pod .<API key> { display: inline-block; margin: 0 8px; min-height: 32px; } .manager-pod .<API key> { display: inline-block; min-height: 32px; vertical-align: top; } .manager-pod .password-block { float: right; } .manager-pod .<API key> { color: #666; font-size: small; max-height: 16px; } .manager-pod .<API key> { color: #000; font-size: small; max-height: 16px; } #<API key> { margin: 4px 10px; } #<API key> .error { color: rgb(207, 93, 70); } #<API key> .spinner-wrapper { -webkit-margin-start: 3px; display: inline-flex; margin-top: 3px; vertical-align: top; } #<API key> .id-text { display: inline-flex; margin-top: 1px; max-width: 480px; vertical-align: baseline; } .manager-pod.focused { background-color: rgb(66, 129, 244); opacity: 1; } .import-pod.imported.focused { background-color: rgb(238, 238, 238); opacity: 1; } .import-pod.focused { background-color: rgb(66, 129, 244); opacity: 1; } .manager-pod.focused .<API key> { color: #fff; } .manager-pod.focused .<API key> { color: #fff; } #<API key> { border: 1px solid #c8c8c8; height: 400px; overflow-x: hidden; overflow-y: auto; } #<API key> .<API key> { padding-bottom: 10px; padding-top: 6px; } .manager-pod .password-error, #<API key> .password-error, #<API key> .duplicate-name { border: 1px solid red !important; } #<API key> { margin-top: 16px; } #<API key> { -webkit-user-drag: none; -webkit-user-select: none; display: inline-block; height: 264px; margin: 0; outline: none; overflow: hidden; padding: 0; width: 400px; } #<API key> img { background-color: white; height: 50px; vertical-align: middle; width: 50px; } #<API key> > li { border: 1px solid rgba(0, 0, 0, 0.15); border-radius: 4px; display: inline-block; margin: 4px; padding: 3px; } #<API key> [selected] { border: 2px solid rgb(0, 102, 204); padding: 2px; } #<API key> { float: right; margin: 4px; max-width: 220px; position: relative; } html[dir=rtl] #<API key> { float: left; } #<API key> { display: block; max-height: 220px; max-width: 220px; } #<API key>.animated-transform { -webkit-transition: -webkit-transform 200ms linear; } .camera.live #<API key> { display: none; } .camera.flip-x #<API key> { -webkit-transform: rotateY(180deg); } .default-image #<API key> { background: white; border: solid 1px #cacaca; border-radius: 4px; padding: 2px; } .<API key> { display: none; padding: 0; position: relative; } .camera.live .<API key> { display: block; } #<API key> { -webkit-transition: -webkit-transform 200ms linear; height: 220px; overflow: hidden; position: relative; width: 220px; } .flip-x #<API key> { -webkit-transform: rotateY(180deg); } .<API key> { border: solid 1px #cacaca; height: 220px; /* Center image for 4:3 aspect ratio. */ left: -16.6%; position: absolute; visibility: hidden; } .online .<API key> { visibility: visible; } #<API key> { color: dimGray; font-size: smaller; margin: 8px 4px; } .camera #<API key> { display: none; } #<API key> { -webkit-transition: opacity 75ms linear; background: url('chrome://theme/IDR_MIRROR_FLIP') no-repeat; border: none; bottom: 44px; /* 8px + image bottom. */ display: block; height: 32px; opacity: 0; position: absolute; right: 8px; width: 32px; } /* TODO(merkulova): remove when webkit crbug.com/126479 is fixed. */ .flip-trick { -webkit-transform: translateZ(1px); } html[dir=rtl] #<API key> { left: 8px; right: auto; } /* "Flip photo" button is hidden during flip animation. */ .camera.online:not(.animation) #<API key>, .camera.phototaken:not(.animation) #<API key> { opacity: 0.75; } #<API key>, #<API key> { display: none; height: 25px; margin: 4px 1px; padding: 0; width: 220px; } .camera:not(.live) #<API key> { background: url('chrome://theme/<API key>') no-repeat center center; display: block; } .camera.live.online #<API key> { background: url('chrome://theme/<API key>') no-repeat center -1px; display: block; } #<API key> .perspective-box { -webkit-perspective: 600px; border: solid 1px #cacaca; border-radius: 4px; padding: 2px; width: 220px; } .<API key> .spinner { display: none; height: 44px; left: 50%; margin-left: -22px; margin-top: -22px; position: absolute; top: 50%; width: 44px; } .camera.live:not(.online) .<API key> .spinner { display: block; }
/* * Please do not edit this file. * It was generated using rpcgen. */ #include <config.h> #include "vxi.h" bool_t xdr_Device_Link (XDR *xdrs, Device_Link *objp) { if (!xdr_long (xdrs, objp)) return FALSE; return TRUE; } bool_t <API key> (XDR *xdrs, Device_AddrFamily *objp) { if (!xdr_enum (xdrs, (enum_t *) objp)) return FALSE; return TRUE; } bool_t xdr_Device_Flags (XDR *xdrs, Device_Flags *objp) { if (!xdr_long (xdrs, objp)) return FALSE; return TRUE; } bool_t <API key> (XDR *xdrs, Device_ErrorCode *objp) { if (!xdr_long (xdrs, objp)) return FALSE; return TRUE; } bool_t xdr_Device_Error (XDR *xdrs, Device_Error *objp) { if (!<API key> (xdrs, &objp->error)) return FALSE; return TRUE; } bool_t <API key> (XDR *xdrs, Create_LinkParms *objp) { register int32_t *buf; if (xdrs->x_op == XDR_ENCODE) { buf = XDR_INLINE (xdrs, 3 * BYTES_PER_XDR_UNIT); if (buf == NULL) { if (!xdr_long (xdrs, &objp->clientId)) return FALSE; if (!xdr_bool (xdrs, &objp->lockDevice)) return FALSE; if (!xdr_u_long (xdrs, &objp->lock_timeout)) return FALSE; } else { IXDR_PUT_LONG(buf, objp->clientId); IXDR_PUT_BOOL(buf, objp->lockDevice); IXDR_PUT_U_LONG(buf, objp->lock_timeout); } if (!xdr_string (xdrs, &objp->device, ~0)) return FALSE; return TRUE; } else if (xdrs->x_op == XDR_DECODE) { buf = XDR_INLINE (xdrs, 3 * BYTES_PER_XDR_UNIT); if (buf == NULL) { if (!xdr_long (xdrs, &objp->clientId)) return FALSE; if (!xdr_bool (xdrs, &objp->lockDevice)) return FALSE; if (!xdr_u_long (xdrs, &objp->lock_timeout)) return FALSE; } else { objp->clientId = IXDR_GET_LONG(buf); objp->lockDevice = IXDR_GET_BOOL(buf); objp->lock_timeout = IXDR_GET_U_LONG(buf); } if (!xdr_string (xdrs, &objp->device, ~0)) return FALSE; return TRUE; } if (!xdr_long (xdrs, &objp->clientId)) return FALSE; if (!xdr_bool (xdrs, &objp->lockDevice)) return FALSE; if (!xdr_u_long (xdrs, &objp->lock_timeout)) return FALSE; if (!xdr_string (xdrs, &objp->device, ~0)) return FALSE; return TRUE; } bool_t xdr_Create_LinkResp (XDR *xdrs, Create_LinkResp *objp) { if (!<API key> (xdrs, &objp->error)) return FALSE; if (!xdr_Device_Link (xdrs, &objp->lid)) return FALSE; if (!xdr_u_short (xdrs, &objp->abortPort)) return FALSE; if (!xdr_u_long (xdrs, &objp->maxRecvSize)) return FALSE; return TRUE; } bool_t <API key> (XDR *xdrs, Device_WriteParms *objp) { if (!xdr_Device_Link (xdrs, &objp->lid)) return FALSE; if (!xdr_u_long (xdrs, &objp->io_timeout)) return FALSE; if (!xdr_u_long (xdrs, &objp->lock_timeout)) return FALSE; if (!xdr_Device_Flags (xdrs, &objp->flags)) return FALSE; if (!xdr_bytes (xdrs, (char **)&objp->data.data_val, (u_int *) &objp->data.data_len, ~0)) return FALSE; return TRUE; } bool_t <API key> (XDR *xdrs, Device_WriteResp *objp) { if (!<API key> (xdrs, &objp->error)) return FALSE; if (!xdr_u_long (xdrs, &objp->size)) return FALSE; return TRUE; } bool_t <API key> (XDR *xdrs, Device_ReadParms *objp) { register int32_t *buf; if (xdrs->x_op == XDR_ENCODE) { if (!xdr_Device_Link (xdrs, &objp->lid)) return FALSE; buf = XDR_INLINE (xdrs, 3 * BYTES_PER_XDR_UNIT); if (buf == NULL) { if (!xdr_u_long (xdrs, &objp->requestSize)) return FALSE; if (!xdr_u_long (xdrs, &objp->io_timeout)) return FALSE; if (!xdr_u_long (xdrs, &objp->lock_timeout)) return FALSE; } else { IXDR_PUT_U_LONG(buf, objp->requestSize); IXDR_PUT_U_LONG(buf, objp->io_timeout); IXDR_PUT_U_LONG(buf, objp->lock_timeout); } if (!xdr_Device_Flags (xdrs, &objp->flags)) return FALSE; if (!xdr_char (xdrs, &objp->termChar)) return FALSE; return TRUE; } else if (xdrs->x_op == XDR_DECODE) { if (!xdr_Device_Link (xdrs, &objp->lid)) return FALSE; buf = XDR_INLINE (xdrs, 3 * BYTES_PER_XDR_UNIT); if (buf == NULL) { if (!xdr_u_long (xdrs, &objp->requestSize)) return FALSE; if (!xdr_u_long (xdrs, &objp->io_timeout)) return FALSE; if (!xdr_u_long (xdrs, &objp->lock_timeout)) return FALSE; } else { objp->requestSize = IXDR_GET_U_LONG(buf); objp->io_timeout = IXDR_GET_U_LONG(buf); objp->lock_timeout = IXDR_GET_U_LONG(buf); } if (!xdr_Device_Flags (xdrs, &objp->flags)) return FALSE; if (!xdr_char (xdrs, &objp->termChar)) return FALSE; return TRUE; } if (!xdr_Device_Link (xdrs, &objp->lid)) return FALSE; if (!xdr_u_long (xdrs, &objp->requestSize)) return FALSE; if (!xdr_u_long (xdrs, &objp->io_timeout)) return FALSE; if (!xdr_u_long (xdrs, &objp->lock_timeout)) return FALSE; if (!xdr_Device_Flags (xdrs, &objp->flags)) return FALSE; if (!xdr_char (xdrs, &objp->termChar)) return FALSE; return TRUE; } bool_t xdr_Device_ReadResp (XDR *xdrs, Device_ReadResp *objp) { if (!<API key> (xdrs, &objp->error)) return FALSE; if (!xdr_long (xdrs, &objp->reason)) return FALSE; if (!xdr_bytes (xdrs, (char **)&objp->data.data_val, (u_int *) &objp->data.data_len, ~0)) return FALSE; return TRUE; } bool_t <API key> (XDR *xdrs, Device_ReadStbResp *objp) { if (!<API key> (xdrs, &objp->error)) return FALSE; if (!xdr_u_char (xdrs, &objp->stb)) return FALSE; return TRUE; } bool_t <API key> (XDR *xdrs, Device_GenericParms *objp) { if (!xdr_Device_Link (xdrs, &objp->lid)) return FALSE; if (!xdr_Device_Flags (xdrs, &objp->flags)) return FALSE; if (!xdr_u_long (xdrs, &objp->lock_timeout)) return FALSE; if (!xdr_u_long (xdrs, &objp->io_timeout)) return FALSE; return TRUE; } bool_t <API key> (XDR *xdrs, Device_RemoteFunc *objp) { register int32_t *buf; if (xdrs->x_op == XDR_ENCODE) { buf = XDR_INLINE (xdrs, 4 * BYTES_PER_XDR_UNIT); if (buf == NULL) { if (!xdr_u_long (xdrs, &objp->hostAddr)) return FALSE; if (!xdr_u_short (xdrs, &objp->hostPort)) return FALSE; if (!xdr_u_long (xdrs, &objp->progNum)) return FALSE; if (!xdr_u_long (xdrs, &objp->progVers)) return FALSE; } else { IXDR_PUT_U_LONG(buf, objp->hostAddr); IXDR_PUT_U_SHORT(buf, objp->hostPort); IXDR_PUT_U_LONG(buf, objp->progNum); IXDR_PUT_U_LONG(buf, objp->progVers); } if (!<API key> (xdrs, &objp->progFamily)) return FALSE; return TRUE; } else if (xdrs->x_op == XDR_DECODE) { buf = XDR_INLINE (xdrs, 4 * BYTES_PER_XDR_UNIT); if (buf == NULL) { if (!xdr_u_long (xdrs, &objp->hostAddr)) return FALSE; if (!xdr_u_short (xdrs, &objp->hostPort)) return FALSE; if (!xdr_u_long (xdrs, &objp->progNum)) return FALSE; if (!xdr_u_long (xdrs, &objp->progVers)) return FALSE; } else { objp->hostAddr = IXDR_GET_U_LONG(buf); objp->hostPort = IXDR_GET_U_SHORT(buf); objp->progNum = IXDR_GET_U_LONG(buf); objp->progVers = IXDR_GET_U_LONG(buf); } if (!<API key> (xdrs, &objp->progFamily)) return FALSE; return TRUE; } if (!xdr_u_long (xdrs, &objp->hostAddr)) return FALSE; if (!xdr_u_short (xdrs, &objp->hostPort)) return FALSE; if (!xdr_u_long (xdrs, &objp->progNum)) return FALSE; if (!xdr_u_long (xdrs, &objp->progVers)) return FALSE; if (!<API key> (xdrs, &objp->progFamily)) return FALSE; return TRUE; } bool_t <API key> (XDR *xdrs, <API key> *objp) { if (!xdr_Device_Link (xdrs, &objp->lid)) return FALSE; if (!xdr_bool (xdrs, &objp->enable)) return FALSE; if (!xdr_bytes (xdrs, (char **)&objp->handle.handle_val, (u_int *) &objp->handle.handle_len, 40)) return FALSE; return TRUE; } bool_t <API key> (XDR *xdrs, Device_LockParms *objp) { if (!xdr_Device_Link (xdrs, &objp->lid)) return FALSE; if (!xdr_Device_Flags (xdrs, &objp->flags)) return FALSE; if (!xdr_u_long (xdrs, &objp->lock_timeout)) return FALSE; return TRUE; } bool_t <API key> (XDR *xdrs, Device_DocmdParms *objp) { register int32_t *buf; if (xdrs->x_op == XDR_ENCODE) { if (!xdr_Device_Link (xdrs, &objp->lid)) return FALSE; if (!xdr_Device_Flags (xdrs, &objp->flags)) return FALSE; buf = XDR_INLINE (xdrs, 5 * BYTES_PER_XDR_UNIT); if (buf == NULL) { if (!xdr_u_long (xdrs, &objp->io_timeout)) return FALSE; if (!xdr_u_long (xdrs, &objp->lock_timeout)) return FALSE; if (!xdr_long (xdrs, &objp->cmd)) return FALSE; if (!xdr_bool (xdrs, &objp->network_order)) return FALSE; if (!xdr_long (xdrs, &objp->datasize)) return FALSE; } else { IXDR_PUT_U_LONG(buf, objp->io_timeout); IXDR_PUT_U_LONG(buf, objp->lock_timeout); IXDR_PUT_LONG(buf, objp->cmd); IXDR_PUT_BOOL(buf, objp->network_order); IXDR_PUT_LONG(buf, objp->datasize); } if (!xdr_bytes (xdrs, (char **)&objp->data_in.data_in_val, (u_int *) &objp->data_in.data_in_len, ~0)) return FALSE; return TRUE; } else if (xdrs->x_op == XDR_DECODE) { if (!xdr_Device_Link (xdrs, &objp->lid)) return FALSE; if (!xdr_Device_Flags (xdrs, &objp->flags)) return FALSE; buf = XDR_INLINE (xdrs, 5 * BYTES_PER_XDR_UNIT); if (buf == NULL) { if (!xdr_u_long (xdrs, &objp->io_timeout)) return FALSE; if (!xdr_u_long (xdrs, &objp->lock_timeout)) return FALSE; if (!xdr_long (xdrs, &objp->cmd)) return FALSE; if (!xdr_bool (xdrs, &objp->network_order)) return FALSE; if (!xdr_long (xdrs, &objp->datasize)) return FALSE; } else { objp->io_timeout = IXDR_GET_U_LONG(buf); objp->lock_timeout = IXDR_GET_U_LONG(buf); objp->cmd = IXDR_GET_LONG(buf); objp->network_order = IXDR_GET_BOOL(buf); objp->datasize = IXDR_GET_LONG(buf); } if (!xdr_bytes (xdrs, (char **)&objp->data_in.data_in_val, (u_int *) &objp->data_in.data_in_len, ~0)) return FALSE; return TRUE; } if (!xdr_Device_Link (xdrs, &objp->lid)) return FALSE; if (!xdr_Device_Flags (xdrs, &objp->flags)) return FALSE; if (!xdr_u_long (xdrs, &objp->io_timeout)) return FALSE; if (!xdr_u_long (xdrs, &objp->lock_timeout)) return FALSE; if (!xdr_long (xdrs, &objp->cmd)) return FALSE; if (!xdr_bool (xdrs, &objp->network_order)) return FALSE; if (!xdr_long (xdrs, &objp->datasize)) return FALSE; if (!xdr_bytes (xdrs, (char **)&objp->data_in.data_in_val, (u_int *) &objp->data_in.data_in_len, ~0)) return FALSE; return TRUE; } bool_t <API key> (XDR *xdrs, Device_DocmdResp *objp) { if (!<API key> (xdrs, &objp->error)) return FALSE; if (!xdr_bytes (xdrs, (char **)&objp->data_out.data_out_val, (u_int *) &objp->data_out.data_out_len, ~0)) return FALSE; return TRUE; } bool_t xdr_Device_SrqParms (XDR *xdrs, Device_SrqParms *objp) { if (!xdr_bytes (xdrs, (char **)&objp->handle.handle_val, (u_int *) &objp->handle.handle_len, ~0)) return FALSE; return TRUE; }