1
0
Fork 0

Merge native PSR/GPR access

This commit is contained in:
hpi1 2019-02-01 14:27:47 +02:00
parent 9f3036004d
commit 49e142f8cd
3 changed files with 34 additions and 79 deletions

View File

@ -574,7 +574,7 @@ public class Libbluray {
*/
public static void writeGPR(int num, int value) {
int ret = writeGPRN(nativePointer, num, value);
int ret = writeRegN(nativePointer, 0, num, value, 0xffffffff);
if (ret == -1)
throw new IllegalArgumentException("Invalid GPR");
@ -585,7 +585,7 @@ public class Libbluray {
}
public static void writePSR(int num, int value, int psr_value_mask) {
int ret = writePSRN(nativePointer, num, value, psr_value_mask);
int ret = writeRegN(nativePointer, 1, num, value, psr_value_mask);
if (ret == -1)
throw new IllegalArgumentException("Invalid PSR");
@ -595,14 +595,14 @@ public class Libbluray {
if (num < 0 || (num >= 4096))
throw new IllegalArgumentException("Invalid GPR");
return readGPRN(nativePointer, num);
return readRegN(nativePointer, 0, num);
}
public static int readPSR(int num) {
if (num < 0 || (num >= 128))
throw new IllegalArgumentException("Invalid PSR");
return readPSRN(nativePointer, num);
return readRegN(nativePointer, 1, num);
}
/*
@ -796,11 +796,9 @@ public class Libbluray {
private static native void setKeyInterestN(long np, int mask);
private static native long tellTimeN(long np);
private static native int selectRateN(long np, float rate, int reason);
private static native int writeGPRN(long np, int num, int value);
private static native int writePSRN(long np, int num, int value, int psr_value_mask);
private static native int readGPRN(long np, int num);
private static native int writeRegN(long np, int is_psr, int num, int value, int psr_value_mask);
private static native int readRegN(long np, int is_psr, int num);
private static native int setVirtualPackageN(long np, String vpPath, boolean psrBackup);
private static native int readPSRN(long np, int num);
private static native int cacheBdRomFileN(long np, String path, String cachePath);
private static native String[] listBdFilesN(long np, String path, boolean onlyBdRom);
private static native Bdjo getBdjoN(long np, String name);

View File

@ -349,46 +349,29 @@ JNIEXPORT jint JNICALL Java_org_videolan_Libbluray_selectRateN(JNIEnv * env,
return 1;
}
JNIEXPORT jint JNICALL Java_org_videolan_Libbluray_writeGPRN(JNIEnv * env,
jclass cls, jlong np, jint num, jint value) {
JNIEXPORT jint JNICALL Java_org_videolan_Libbluray_readRegN(JNIEnv * env,
jclass cls, jlong np, jint is_psr, jint num) {
BLURAY* bd = (BLURAY*)(intptr_t)np;
int value = bd_reg_read(bd, is_psr, num);
BD_DEBUG(DBG_JNI, "writeGPRN(%d,%d)\n", (int)num, (int)value);
return bd_reg_write(bd, 0, num, value, ~0);
}
JNIEXPORT jint JNICALL Java_org_videolan_Libbluray_readGPRN(JNIEnv * env,
jclass cls, jlong np, jint num) {
BLURAY* bd = (BLURAY*)(intptr_t)np;
int value = bd_reg_read(bd, 0, num);
BD_DEBUG(DBG_JNI, "readGPRN(%d) -> %d\n", (int)num, (int)value);
BD_DEBUG(DBG_JNI, "readRegN(%s_%d) -> %d\n", is_psr ? "PSR" : "GPR", (int)num, (int)value);
return value;
}
JNIEXPORT jint JNICALL Java_org_videolan_Libbluray_writePSRN(JNIEnv * env,
jclass cls, jlong np, jint num, jint value, jint mask) {
JNIEXPORT jint JNICALL Java_org_videolan_Libbluray_writeRegN(JNIEnv * env,
jclass cls, jlong np, jint is_psr, jint num, jint value, jint mask) {
BLURAY* bd = (BLURAY*)(intptr_t)np;
if ((uint32_t)mask == 0xffffffff) {
BD_DEBUG(DBG_JNI, "writePSRN(%d,%d)\n", (int)num, (int)value);
BD_DEBUG(DBG_JNI, "writeRegN(%s_%d,%d)\n",
is_psr ? "PSR" : "GPR", (int)num, (int)value);
} else {
BD_DEBUG(DBG_JNI, "writePSRN(%d,0x%x,0x%08x)\n", (int)num, (int)value, (int)mask);
BD_DEBUG(DBG_JNI, "writeRegN(%s_%d,0x%x,0x%08x)\n",
is_psr ? "PSR" : "GPR", (int)num, (int)value, (int)mask);
}
return bd_reg_write(bd, 1, num, value, mask);
}
JNIEXPORT jint JNICALL Java_org_videolan_Libbluray_readPSRN(JNIEnv * env,
jclass cls, jlong np, jint num) {
BLURAY* bd = (BLURAY*)(intptr_t)np;
int value = bd_reg_read(bd, 1, num);
BD_DEBUG(DBG_JNI, "readPSRN(%d) -> %d\n", (int)num, (int)value);
return value;
return bd_reg_write(bd, is_psr, num, value, mask);
}
JNIEXPORT jint JNICALL Java_org_videolan_Libbluray_cacheBdRomFileN(JNIEnv * env,
@ -724,24 +707,14 @@ Java_org_videolan_Libbluray_methods[] =
VC(Java_org_videolan_Libbluray_selectRateN),
},
{
CC("writeGPRN"),
CC("writeRegN"),
CC("(JIIII)I"),
VC(Java_org_videolan_Libbluray_writeRegN),
},
{
CC("readRegN"),
CC("(JII)I"),
VC(Java_org_videolan_Libbluray_writeGPRN),
},
{
CC("writePSRN"),
CC("(JIII)I"),
VC(Java_org_videolan_Libbluray_writePSRN),
},
{
CC("readGPRN"),
CC("(JI)I"),
VC(Java_org_videolan_Libbluray_readGPRN),
},
{
CC("readPSRN"),
CC("(JI)I"),
VC(Java_org_videolan_Libbluray_readPSRN),
VC(Java_org_videolan_Libbluray_readRegN),
},
{
CC("cacheBdRomFileN"),

View File

@ -206,36 +206,20 @@ JNIEXPORT jint JNICALL Java_org_videolan_Libbluray_selectRateN
/*
* Class: org_videolan_Libbluray
* Method: writeGPRN
* Method: writeRegN
* Signature: (JIIII)I
*/
JNIEXPORT jint JNICALL Java_org_videolan_Libbluray_writeRegN
(JNIEnv *, jclass, jlong, jint, jint, jint, jint);
/*
* Class: org_videolan_Libbluray
* Method: readRegN
* Signature: (JII)I
*/
JNIEXPORT jint JNICALL Java_org_videolan_Libbluray_writeGPRN
JNIEXPORT jint JNICALL Java_org_videolan_Libbluray_readRegN
(JNIEnv *, jclass, jlong, jint, jint);
/*
* Class: org_videolan_Libbluray
* Method: writePSRN
* Signature: (JIII)I
*/
JNIEXPORT jint JNICALL Java_org_videolan_Libbluray_writePSRN
(JNIEnv *, jclass, jlong, jint, jint, jint);
/*
* Class: org_videolan_Libbluray
* Method: readGPRN
* Signature: (JI)I
*/
JNIEXPORT jint JNICALL Java_org_videolan_Libbluray_readGPRN
(JNIEnv *, jclass, jlong, jint);
/*
* Class: org_videolan_Libbluray
* Method: readPSRN
* Signature: (JI)I
*/
JNIEXPORT jint JNICALL Java_org_videolan_Libbluray_readPSRN
(JNIEnv *, jclass, jlong, jint);
/*
* Class: org_videolan_Libbluray
* Method: cacheBdRomFileN