Skip to content

Commit ebae124

Browse files
committed
Debug / disable clear + draw the blanks in the main loop
1 parent 71b8811 commit ebae124

File tree

3 files changed

+26
-21
lines changed

3 files changed

+26
-21
lines changed

jni/hw/dji_display.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
#define GOGGLES_V1_VOFFSET 575
66
#define GOGGLES_V2_VOFFSET 215
77

8+
static uint8_t which_fb = 0;
9+
810
static duss_result_t pop_func(duss_disp_instance_handle_t *disp_handle,duss_disp_plane_id_t plane_id, duss_frame_buffer_t *frame_buffer,void *user_ctx) {
911
dji_display_state_t *display_state = (dji_display_state_t *)user_ctx;
1012
display_state->frame_waiting = 0;
13+
printf("fbdebug pop_func\n");
1114
return 0;
1215
}
1316

@@ -63,15 +66,15 @@ void dji_display_open_framebuffer(dji_display_state_t *display_state, duss_disp_
6366
// Blending algorithm 1 seems to work.
6467

6568
display_state->pb_0->blending_alg = 1;
66-
69+
6770
duss_hal_device_desc_t device_descs[3] = {
6871
{"/dev/dji_display", &duss_hal_attach_disp, &duss_hal_detach_disp, 0x0},
6972
{"/dev/ion", &duss_hal_attach_ion_mem, &duss_hal_detach_ion_mem, 0x0},
7073
{0,0,0,0}
7174
};
7275

7376
duss_hal_initialize(device_descs);
74-
77+
7578
res = duss_hal_device_open("/dev/dji_display",&hal_device_open_unk,&display_state->disp_handle);
7679
if (res != 0) {
7780
printf("failed to open dji_display device");
@@ -82,13 +85,13 @@ void dji_display_open_framebuffer(dji_display_state_t *display_state, duss_disp_
8285
printf("failed to open display hal");
8386
exit(0);
8487
}
85-
88+
8689
res = duss_hal_display_reset(display_state->disp_instance_handle);
8790
if (res != 0) {
8891
printf("failed to reset display");
8992
exit(0);
9093
}
91-
94+
9295
// No idea what this "plane mode" actually does but it's different on V2
9396
uint8_t acquire_plane_mode = display_state->is_v2_goggles ? 6 : 0;
9497

@@ -109,7 +112,7 @@ void dji_display_open_framebuffer(dji_display_state_t *display_state, duss_disp_
109112
}
110113

111114
res = duss_hal_display_plane_blending_set(display_state->disp_instance_handle, plane_id, display_state->pb_0);
112-
115+
113116
if (res != 0) {
114117
printf("failed to set blending");
115118
exit(0);
@@ -158,7 +161,7 @@ void dji_display_open_framebuffer(dji_display_state_t *display_state, duss_disp_
158161
exit(0);
159162
}
160163
printf("second buffer VRAM mapped virtual memory is at %p : %p\n", display_state->fb1_virtual_addr, display_state->fb1_physical_addr);
161-
164+
162165
for(int i = 0; i < 2; i++) {
163166
duss_frame_buffer_t *fb = i ? display_state->fb_1 : display_state->fb_0;
164167
fb->buffer = i ? display_state->ion_buf_1 : display_state->ion_buf_0;
@@ -276,20 +279,23 @@ void dji_display_open_framebuffer_injected(dji_display_state_t *display_state, d
276279
}
277280
}
278281

279-
uint8_t dji_display_push_frame(dji_display_state_t *display_state, uint8_t which_fb) {
280-
duss_frame_buffer_t *fb = which_fb ? display_state->fb_1 : display_state->fb_0;
281-
duss_hal_mem_sync(fb->buffer, 1);
282+
void dji_display_push_frame(dji_display_state_t *display_state) {
283+
// print which_fb
284+
printf("fbdebug which_fb: %d\n", which_fb);
282285
if (display_state->frame_waiting == 0) {
286+
which_fb = !which_fb;
287+
duss_frame_buffer_t *fb = which_fb ? display_state->fb_1 : display_state->fb_0;
288+
duss_hal_mem_sync(fb->buffer, 1);
283289
display_state->frame_waiting = 1;
290+
printf("fbdebug pushing frame\n");
284291
duss_hal_display_push_frame(display_state->disp_instance_handle, display_state->plane_id, fb);
285-
return !which_fb;
286292
} else {
287293
DEBUG_PRINT("!!! Dropped frame due to pending frame push!\n");
288-
return which_fb;
294+
printf("fbdebug dropping frame\n");
289295
}
290296
}
291297

292-
void *dji_display_get_fb_address(dji_display_state_t *display_state, uint8_t which_fb) {
298+
void *dji_display_get_fb_address(dji_display_state_t *display_state) {
293299
return which_fb ? display_state->fb1_virtual_addr : display_state->fb0_virtual_addr;
294300
}
295301

jni/hw/dji_display.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ typedef struct dji_display_state_s {
2020
uint8_t frame_waiting;
2121
} dji_display_state_t;
2222

23-
uint8_t dji_display_push_frame(dji_display_state_t *display_state, uint8_t which_fb);
23+
void dji_display_push_frame(dji_display_state_t *display_state);
2424
void dji_display_open_framebuffer(dji_display_state_t *display_state, duss_disp_plane_id_t plane_id);
2525
void dji_display_open_framebuffer_injected(dji_display_state_t *display_state, duss_disp_instance_handle_t *disp, duss_hal_obj_handle_t ion_handle, duss_disp_plane_id_t plane_id);
2626
void dji_display_close_framebuffer(dji_display_state_t *display_state);
2727
dji_display_state_t *dji_display_state_alloc(uint8_t is_v2_goggles);
2828
void dji_display_state_free(dji_display_state_t *display_state);
29-
void *dji_display_get_fb_address(dji_display_state_t *display_state, uint8_t which_fb);
29+
void *dji_display_get_fb_address(dji_display_state_t *display_state);

jni/osd_dji_overlay_udp.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ static uint16_t msp_character_map[MAX_DISPLAY_X][MAX_DISPLAY_Y];
104104
static uint16_t msp_render_character_map[MAX_DISPLAY_X][MAX_DISPLAY_Y];
105105
static uint16_t overlay_character_map[MAX_DISPLAY_X][MAX_DISPLAY_Y];
106106
static displayport_vtable_t *display_driver;
107-
static uint8_t which_fb = 0;
108107
struct timespec last_render;
109108

110109
static char current_fc_variant[5];
@@ -189,7 +188,7 @@ static void draw_character_map(display_info_t *display_info, void* restrict fb_a
189188
for(int y = 0; y < display_info->char_height; y++) {
190189
for(int x = 0; x < display_info->char_width; x++) {
191190
uint16_t c = character_map[x][y];
192-
if (c != 0) {
191+
// if (c != 0) {
193192
font = display_info->font_page_1;
194193
if (c > 255) {
195194
c = c & 0xFF;
@@ -211,23 +210,23 @@ static void draw_character_map(display_info_t *display_info, void* restrict fb_a
211210
target_offset += WIDTH * BYTES_PER_PIXEL - (display_info->font_width * BYTES_PER_PIXEL);
212211
}
213212
// DEBUG_PRINT("%c", c > 31 ? c : 20);
214-
}
213+
// }
215214
// DEBUG_PRINT(" ");
216215
}
217216
// DEBUG_PRINT("\n");
218217
}
219218
}
220219

221220
static void clear_framebuffer() {
222-
void *fb_addr = dji_display_get_fb_address(dji_display, which_fb);
221+
void *fb_addr = dji_display_get_fb_address(dji_display);
223222
// DJI has a backwards alpha channel - FF is transparent, 00 is opaque.
224223
memset(fb_addr, 0x000000FF, WIDTH * HEIGHT * BYTES_PER_PIXEL);
225224
}
226225

227226
static void draw_screen() {
228-
void *fb_addr = dji_display_get_fb_address(dji_display, which_fb);
227+
void *fb_addr = dji_display_get_fb_address(dji_display);
229228
// DJI has a backwards alpha channel - FF is transparent, 00 is opaque.
230-
memset(fb_addr, 0x000000FF, WIDTH * HEIGHT * BYTES_PER_PIXEL);
229+
// memset(fb_addr, 0x000000FF, WIDTH * HEIGHT * BYTES_PER_PIXEL);
231230

232231
if (fakehd_is_enabled()) {
233232
fakehd_map_sd_character_map_to_hd(msp_character_map, msp_render_character_map);
@@ -252,7 +251,7 @@ static void render_screen() {
252251
if (display_mode == DISPLAY_DISABLED) {
253252
clear_framebuffer();
254253
}
255-
which_fb = dji_display_push_frame(dji_display, which_fb);
254+
dji_display_push_frame(dji_display);
256255
DEBUG_PRINT("drew a frame\n");
257256
clock_gettime(CLOCK_MONOTONIC, &last_render);
258257
}

0 commit comments

Comments
 (0)