diff --git a/app/src/main/cpp/MpPreview.cpp b/app/src/main/cpp/MpPreview.cpp index c1165f4..0cbecb3 100644 --- a/app/src/main/cpp/MpPreview.cpp +++ b/app/src/main/cpp/MpPreview.cpp @@ -18,6 +18,39 @@ #include "hdr.h" + + +#define IOT_PARAM_WRITE 0xAE +#define IOT_PARAM_READ 0xAF +#define MAX_STRING_LEN 32 + +typedef struct +{ + int cmd; + int value; + int result; + long value2; + char str[MAX_STRING_LEN]; +}IOT_PARAM; + +int setGpioInt(int cmd, int val) +{ + int fd = open("/dev/mtkgpioctrl", O_RDONLY); + // LOGE("set_int fd=%d,cmd=%d,value=%d\r\n",fd, cmd, value); + if( fd > 0 ) + { + IOT_PARAM param; + param.cmd = cmd; + param.value = val; + int res = ioctl(fd, IOT_PARAM_WRITE, ¶m); + // LOGE("set_int22 cmd=%d,value=%d,result=%d\r\n",param.cmd, param.value, param.result); + close(fd); + return 0; + } + return -1; +} + + namespace cv2 { using namespace cv; @@ -497,4 +530,11 @@ JNIEXPORT jboolean JNICALL Java_com_xypower_mppreview_Camera2RawFragment_decodeDng(JNIEnv *env, jclass clazz, jobject byte_buffer, jstring output_path) { // TODO: implement decodeDng() +} +extern "C" +JNIEXPORT void JNICALL +Java_com_xypower_mppreview_ui_CameraChannelActivity_setInt(JNIEnv *env, jclass clazz, jint cmd, + jint val) { + // TODO: implement setInt() + setGpioInt(cmd, val); } \ No newline at end of file diff --git a/app/src/main/java/com/xypower/mppreview/ui/CameraChannelActivity.java b/app/src/main/java/com/xypower/mppreview/ui/CameraChannelActivity.java index d630259..5176c0a 100644 --- a/app/src/main/java/com/xypower/mppreview/ui/CameraChannelActivity.java +++ b/app/src/main/java/com/xypower/mppreview/ui/CameraChannelActivity.java @@ -1,5 +1,7 @@ package com.xypower.mppreview.ui; +import static java.lang.System.loadLibrary; + import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import androidx.camera.core.CameraInfo; @@ -33,12 +35,18 @@ import java.util.concurrent.Executors; public class CameraChannelActivity extends AppCompatActivity implements View.OnClickListener { + static { + loadLibrary("mppreview"); + } + private com.xypower.mppreview.databinding.ActivityCameraChannelBinding viewBinding; private int camerid; private ImageCapture imageCapture; private ExecutorService cameraExecutor; private File outputDirectory; + private static native void setInt(int cmd, int val); + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);