[libbluray-devel] Add wrapper functions for BD-J register access.

hpi1 git at videolan.org
Wed Nov 27 16:21:19 CET 2013


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Wed Nov 27 17:07:52 2013 +0200| [3a13579dbb82b7dbb8c356b195dbb11f001d0593] | committer: hpi1

Add wrapper functions for BD-J register access.

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=3a13579dbb82b7dbb8c356b195dbb11f001d0593
---

 src/libbluray/bdj/bdj.c                           |    3 +--
 src/libbluray/bdj/bdj.h                           |    3 +--
 src/libbluray/bdj/bdj_private.h                   |    2 --
 src/libbluray/bdj/native/org_videolan_Libbluray.c |   21 +++++++++-------
 src/libbluray/bluray.c                            |   27 ++++++++++++++++++++-
 src/libbluray/bluray_internal.h                   |    3 +++
 6 files changed, 43 insertions(+), 16 deletions(-)

diff --git a/src/libbluray/bdj/bdj.c b/src/libbluray/bdj/bdj.c
index d60d6fc..896d45e 100644
--- a/src/libbluray/bdj/bdj.c
+++ b/src/libbluray/bdj/bdj.c
@@ -251,7 +251,7 @@ static int _bdj_init(BDJAVA *bdjava, JNIEnv *env)
 }
 
 BDJAVA* bdj_open(const char *path, struct bluray *bd,
-                 struct bd_registers_s *registers, struct indx_root_s *index,
+                 struct indx_root_s *index,
                  bdj_overlay_cb osd_cb, struct bd_argb_buffer_s *buf)
 {
     BD_DEBUG(DBG_BDJ, "bdj_open()\n");
@@ -275,7 +275,6 @@ BDJAVA* bdj_open(const char *path, struct bluray *bd,
 
     BDJAVA* bdjava = calloc(1, sizeof(BDJAVA));
     bdjava->bd = bd;
-    bdjava->reg = registers;
     bdjava->index = index;
     bdjava->path = path;
     bdjava->h_libjvm = jvm_lib;
diff --git a/src/libbluray/bdj/bdj.h b/src/libbluray/bdj/bdj.h
index 4207de5..203cf53 100644
--- a/src/libbluray/bdj/bdj.h
+++ b/src/libbluray/bdj/bdj.h
@@ -45,7 +45,6 @@ typedef enum {
 typedef struct bdjava_s BDJAVA;
 
 struct bluray;
-struct bd_registers_s;
 struct indx_root_s;
 struct bd_argb_buffer_s;
 
@@ -53,7 +52,7 @@ typedef void (*bdj_overlay_cb)(struct bluray *, const unsigned *, int, int,
                                int, int, int, int);
 
 BD_PRIVATE BDJAVA* bdj_open(const char *path, struct bluray *bd,
-                            struct bd_registers_s *registers, struct indx_root_s *index,
+                            struct indx_root_s *index,
                             bdj_overlay_cb osd_cb, struct bd_argb_buffer_s *buf);
 BD_PRIVATE int  bdj_start(BDJAVA *bdjava, unsigned title);
 BD_PRIVATE int  bdj_stop(BDJAVA *bdjava);
diff --git a/src/libbluray/bdj/bdj_private.h b/src/libbluray/bdj/bdj_private.h
index 32e6e52..37165ae 100644
--- a/src/libbluray/bdj/bdj_private.h
+++ b/src/libbluray/bdj/bdj_private.h
@@ -20,7 +20,6 @@
 #ifndef BDJ_PRIVATE_H_
 #define BDJ_PRIVATE_H_
 
-#include "libbluray/register.h"
 #include "libbluray/bluray.h"
 #include "libbluray/bdnav/index_parse.h"
 #include "libbluray/decoders/overlay.h"
@@ -28,7 +27,6 @@
 
 struct bdjava_s {
     BLURAY       *bd;
-    BD_REGISTERS *reg;
     INDX_ROOT    *index;
 
     bdj_overlay_cb  osd_cb;
diff --git a/src/libbluray/bdj/native/org_videolan_Libbluray.c b/src/libbluray/bdj/native/org_videolan_Libbluray.c
index 6fa96cb..d604a9c 100644
--- a/src/libbluray/bdj/native/org_videolan_Libbluray.c
+++ b/src/libbluray/bdj/native/org_videolan_Libbluray.c
@@ -22,11 +22,9 @@
 #include "libbluray/bdj/bdj_private.h"
 #include "libbluray/bdj/bdj_util.h"
 #include "libbluray/bdj/bdjo_parser.h"
-#include "libbluray/register.h"
 #include "libbluray/bluray.h"
 #include "libbluray/bluray_internal.h"
 
-#include "util/mutex.h"
 #include "util/strutl.h"
 #include "util/macro.h"
 #include "util/logging.h"
@@ -341,13 +339,17 @@ JNIEXPORT jint JNICALL Java_org_videolan_Libbluray_writeGPRN(JNIEnv * env,
 
     BD_DEBUG(DBG_JNI, "writeGPRN(%d,%d)\n", (int)num, (int)value);
 
-    return bd_gpr_write(bdj->reg, num, value);
+    return bd_reg_write(bdj->bd, 0, num, value);
 }
 
 JNIEXPORT jint JNICALL Java_org_videolan_Libbluray_readGPRN(JNIEnv * env,
         jclass cls, jlong np, jint num) {
     BDJAVA* bdj = (BDJAVA*)(intptr_t)np;
-    return bd_gpr_read(bdj->reg, num);
+    int value = bd_reg_read(bdj->bd, 0, num);
+
+    BD_DEBUG(DBG_JNI, "readGPRN(%d) -> %d\n", (int)num, (int)value);
+
+    return value;
 }
 
 JNIEXPORT jint JNICALL Java_org_videolan_Libbluray_writePSRN(JNIEnv * env,
@@ -356,16 +358,17 @@ JNIEXPORT jint JNICALL Java_org_videolan_Libbluray_writePSRN(JNIEnv * env,
 
     BD_DEBUG(DBG_JNI, "writePSRN(%d,%d)\n", (int)num, (int)value);
 
-    bd_mutex_lock((BD_MUTEX*)bdj->bd);
-    int res = bd_psr_write(bdj->reg, num, value);
-    bd_mutex_unlock((BD_MUTEX*)bdj->bd);
-    return res;
+    return bd_reg_write(bdj->bd, 1, num, value);
 }
 
 JNIEXPORT jint JNICALL Java_org_videolan_Libbluray_readPSRN(JNIEnv * env,
         jclass cls, jlong np, jint num) {
     BDJAVA* bdj = (BDJAVA*)(intptr_t)np;
-    return bd_psr_read(bdj->reg, num);
+    int value = bd_reg_read(bdj->bd, 1, num);
+
+    BD_DEBUG(DBG_JNI, "readPSRN(%d) -> %d\n", (int)num, (int)value);
+
+    return value;
 }
 
 JNIEXPORT jobject JNICALL Java_org_videolan_Libbluray_getBdjoN(JNIEnv * env,
diff --git a/src/libbluray/bluray.c b/src/libbluray/bluray.c
index 6255b62..7012cd9 100644
--- a/src/libbluray/bluray.c
+++ b/src/libbluray/bluray.c
@@ -975,6 +975,31 @@ uint64_t bd_get_uo_mask(BLURAY *bd)
 #endif
 
 #ifdef USING_BDJAVA
+uint32_t bd_reg_read(BLURAY *bd, int psr, int reg)
+{
+    if (psr) {
+        return bd_psr_read(bd->regs, reg);
+    } else {
+        return bd_gpr_read(bd->regs, reg);
+    }
+}
+#endif
+
+#ifdef USING_BDJAVA
+int bd_reg_write(BLURAY *bd, int psr, int reg, uint32_t value)
+{
+    if (psr) {
+        bd_mutex_lock(&bd->mutex); /* avoid deadlocks (psr_write triggers callbacks that may lock this mutex) */
+        int res = bd_psr_write(bd->regs, reg, value);
+        bd_mutex_unlock(&bd->mutex);
+        return res;
+    } else {
+        return bd_gpr_write(bd->regs, reg, value);
+    }
+}
+#endif
+
+#ifdef USING_BDJAVA
 /*
  * handle graphics updates from BD-J layer
  */
@@ -1055,7 +1080,7 @@ static int _start_bdj(BLURAY *bd, unsigned title)
 {
 #ifdef USING_BDJAVA
     if (bd->bdjava == NULL) {
-        bd->bdjava = bdj_open(bd->device_path, bd, bd->regs, bd->index, _bdj_osd_cb, bd->argb_buffer);
+        bd->bdjava = bdj_open(bd->device_path, bd, bd->index, _bdj_osd_cb, bd->argb_buffer);
         if (!bd->bdjava) {
             return 0;
         }
diff --git a/src/libbluray/bluray_internal.h b/src/libbluray/bluray_internal.h
index 9c61e53..a834fe1 100644
--- a/src/libbluray/bluray_internal.h
+++ b/src/libbluray/bluray_internal.h
@@ -31,4 +31,7 @@ BD_PRIVATE const uint8_t *bd_get_aacs_data(BLURAY *bd, int type);
 BD_PRIVATE uint64_t bd_get_uo_mask(BLURAY *bd);
 BD_PRIVATE int bd_play_title_internal(BLURAY *bd, unsigned title);
 
+BD_PRIVATE uint32_t bd_reg_read(BLURAY *bd, int psr, int reg);
+BD_PRIVATE int bd_reg_write(BLURAY *bd, int psr, int reg, uint32_t value);
+
 #endif  /* _BLURAY_INTERNAL_H_ */



More information about the libbluray-devel mailing list