common/usbdbg: Revert changes to usbdbg/framebuffer.

This reverts commit afcd12cb6a.
This commit is contained in:
iabdalkader 2024-08-12 22:03:58 +03:00
parent a0db6fe794
commit c5e4297bef
2 changed files with 8 additions and 13 deletions

View File

@ -146,11 +146,10 @@ 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 };
buffer[2] = -1; // size < 0
// 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 {
@ -171,7 +170,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 = -1;
JPEG_FB()->w = 0; JPEG_FB()->h = 0; JPEG_FB()->size = 0;
mutex_unlock(&JPEG_FB()->lock, MUTEX_TID_IDE);
}
}
@ -204,7 +203,6 @@ 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) {
@ -217,10 +215,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,9 +86,6 @@ 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;
@ -120,7 +117,7 @@ static void jpegbuffer_init_from_image(image_t *img) {
if (img == NULL) {
jpeg_framebuffer->w = 0;
jpeg_framebuffer->h = 0;
jpeg_framebuffer->size = -1;
jpeg_framebuffer->size = 0;
} else {
jpeg_framebuffer->w = img->w;
jpeg_framebuffer->h = img->h;