1 /* 2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 #include <stdlib.h> 27 #include <stdio.h> 28 29 #include "lensPort.h" 30 #include "lensPortInternal.h" 31 32 int platform_log_level = 0; 33 34 Platform_Logger *platform_logf = 0; 35 36 static void setPlatformLogging(Platform_Logger *logger, int level) { 37 platform_logf = logger; 38 platform_log_level = level; 39 } 40 41 #ifdef USE_DISPMAN 42 extern jboolean select_dispman_cursor(LensNativePort *lensPort); 43 #endif // USE_DISPMAN 44 45 #if defined(OMAP3) || defined(IMX6_PLATFORM) 46 extern jboolean fbFBRobotScreen(jint x, jint y, 47 jint width, jint height, 48 jint *pixels); 49 #endif 50 51 #ifdef OMAP3 52 extern jboolean select_omap_cursor(LensNativePort *lensPort); 53 #endif 54 55 #ifdef IMX6_PLATFORM 56 extern jboolean check_imx6_cursor(LensNativePort *lensPort); 57 #endif 58 59 jboolean lens_platform_initialize(LensNativePort* lensPort) { 60 61 // check if we are within the range of what we can accept 62 if ((!lensPort) || lensPort->version != NATIVE_PRISM_PORT_VERSION) { 63 // something is really wrong here ! 64 printf("lensPort VERSION FAILED\n"); 65 return JNI_FALSE; 66 } 67 68 // report the version we actually are 69 lensPort->version = NATIVE_LENS_PORT_VERSION; 70 lensPort->setLogger = &setPlatformLogging; 71 72 #ifdef USE_DISPMAN 73 if (select_dispman_cursor(lensPort)) { 74 return JNI_TRUE; 75 } 76 #endif // USE_DISPMAN 77 78 #ifdef IMX6_PLATFORM 79 if (check_imx6_cursor(lensPort)) { 80 lensPort->robotScreenCapture = fbFBRobotScreen; 81 return JNI_TRUE; 82 } 83 #endif //IMX6_PLATFORM 84 85 #ifdef OMAP3 86 { // this is our default, no real test 87 select_omap_cursor(lensPort); 88 lensPort->robotScreenCapture = fbFBRobotScreen; 89 return JNI_TRUE; 90 } 91 #endif //OMAP3 92 93 #ifdef ANDROID_NDK 94 return JNI_TRUE; 95 #endif //Android 96 97 // Fatal Error 98 fprintf(stderr,"Fatal error loading native porting layer in Lens\n"); 99 exit(-1); 100 101 return JNI_FALSE; 102 } 103 104 // fix these return values? 105 extern void* util_getNativeWindowType(void); 106 extern void* util_getNativeDisplayType(void); 107 extern void* util_wr_eglGetDisplay(void *); 108 extern void* util_getLibGLEShandle(void); 109 110 jboolean prism_platform_initialize(PrismNativePort* prismPort) { 111 112 // check if we are within the range of what we can accept 113 if ((!prismPort) || prismPort->version != NATIVE_PRISM_PORT_VERSION) { 114 // something is really wrong here ! 115 fprintf(stderr,"failed (version?) in prism_platform_initialize\n"); 116 exit(-1); 117 } 118 119 prismPort->version = NATIVE_PRISM_PORT_VERSION; 120 prismPort->getNativeWindowType = &util_getNativeWindowType; 121 prismPort->getNativeDisplayType = &util_getNativeDisplayType; 122 prismPort->wr_eglGetDisplay = &util_wr_eglGetDisplay; 123 prismPort->getLibGLEShandle = &util_getLibGLEShandle; 124 125 return JNI_TRUE; 126 } 127