common/usbdbg: Enable RAW binary mode streaming.

This commit is contained in:
Kwabena W. Agyeman 2024-08-05 18:40:03 -07:00
parent 6e705114f1
commit afcd12cb6a
2 changed files with 13 additions and 8 deletions

View File

@ -146,10 +146,11 @@ void usbdbg_data_in(uint32_t size, usbdbg_write_callback_t write_callback) {
case USBDBG_FRAME_SIZE: {
// Return 0 if FB is locked or not ready.
uint32_t buffer[3] = { 0 };
// Try to lock FB. If header size == 0 frame is not ready
buffer[2] = -1; // size < 0
// Try to lock FB. If header size < 0 frame is not ready
if (mutex_try_lock_alternate(&JPEG_FB()->lock, MUTEX_TID_IDE)) {
// If header size == 0 frame is not ready
if (JPEG_FB()->size == 0) {
// If header size < 0 frame is not ready
if (JPEG_FB()->size < 0) {
// unlock FB
mutex_unlock(&JPEG_FB()->lock, MUTEX_TID_IDE);
} else {
@ -170,7 +171,7 @@ void usbdbg_data_in(uint32_t size, usbdbg_write_callback_t write_callback) {
xfer_offs += size;
if (xfer_offs == xfer_size) {
cmd = USBDBG_NONE;
JPEG_FB()->w = 0; JPEG_FB()->h = 0; JPEG_FB()->size = 0;
JPEG_FB()->w = 0; JPEG_FB()->h = 0; JPEG_FB()->size = -1;
mutex_unlock(&JPEG_FB()->lock, MUTEX_TID_IDE);
}
}
@ -203,6 +204,7 @@ void usbdbg_data_in(uint32_t size, usbdbg_write_callback_t write_callback) {
case USBDBG_GET_STATE: {
uint32_t buffer[16] = { 0 };
buffer[3] = -1; // size < 0
// Set script running flag
if (script_running) {
@ -215,10 +217,10 @@ void usbdbg_data_in(uint32_t size, usbdbg_write_callback_t write_callback) {
buffer[0] |= USBDBG_STATE_FLAGS_TEXT;
}
// Try to lock FB. If header size == 0 frame is not ready
// Try to lock FB. If header size < 0 frame is not ready
if (mutex_try_lock_alternate(&JPEG_FB()->lock, MUTEX_TID_IDE)) {
// If header size == 0 frame is not ready
if (JPEG_FB()->size == 0) {
// If header size < 0 frame is not ready
if (JPEG_FB()->size < 0) {
// unlock FB
mutex_unlock(&JPEG_FB()->lock, MUTEX_TID_IDE);
} else {

View File

@ -86,6 +86,9 @@ void framebuffer_init0() {
// Enable streaming.
MAIN_FB()->streaming_enabled = true; // controlled by the OpenMV Cam.
// Set invalid size.
JPEG_FB()->size = -1;
// Set default quality
JPEG_FB()->quality = ((OMV_JPEG_QUALITY_HIGH - OMV_JPEG_QUALITY_LOW) / 2) + OMV_JPEG_QUALITY_LOW;
@ -117,7 +120,7 @@ static void jpegbuffer_init_from_image(image_t *img) {
if (img == NULL) {
jpeg_framebuffer->w = 0;
jpeg_framebuffer->h = 0;
jpeg_framebuffer->size = 0;
jpeg_framebuffer->size = -1;
} else {
jpeg_framebuffer->w = img->w;
jpeg_framebuffer->h = img->h;