5
5
#define GOGGLES_V1_VOFFSET 575
6
6
#define GOGGLES_V2_VOFFSET 215
7
7
8
+ static uint8_t which_fb = 0 ;
9
+
8
10
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 ) {
9
11
dji_display_state_t * display_state = (dji_display_state_t * )user_ctx ;
10
12
display_state -> frame_waiting = 0 ;
13
+ printf ("fbdebug pop_func\n" );
11
14
return 0 ;
12
15
}
13
16
@@ -63,15 +66,15 @@ void dji_display_open_framebuffer(dji_display_state_t *display_state, duss_disp_
63
66
// Blending algorithm 1 seems to work.
64
67
65
68
display_state -> pb_0 -> blending_alg = 1 ;
66
-
69
+
67
70
duss_hal_device_desc_t device_descs [3 ] = {
68
71
{"/dev/dji_display" , & duss_hal_attach_disp , & duss_hal_detach_disp , 0x0 },
69
72
{"/dev/ion" , & duss_hal_attach_ion_mem , & duss_hal_detach_ion_mem , 0x0 },
70
73
{0 ,0 ,0 ,0 }
71
74
};
72
75
73
76
duss_hal_initialize (device_descs );
74
-
77
+
75
78
res = duss_hal_device_open ("/dev/dji_display" ,& hal_device_open_unk ,& display_state -> disp_handle );
76
79
if (res != 0 ) {
77
80
printf ("failed to open dji_display device" );
@@ -82,13 +85,13 @@ void dji_display_open_framebuffer(dji_display_state_t *display_state, duss_disp_
82
85
printf ("failed to open display hal" );
83
86
exit (0 );
84
87
}
85
-
88
+
86
89
res = duss_hal_display_reset (display_state -> disp_instance_handle );
87
90
if (res != 0 ) {
88
91
printf ("failed to reset display" );
89
92
exit (0 );
90
93
}
91
-
94
+
92
95
// No idea what this "plane mode" actually does but it's different on V2
93
96
uint8_t acquire_plane_mode = display_state -> is_v2_goggles ? 6 : 0 ;
94
97
@@ -109,7 +112,7 @@ void dji_display_open_framebuffer(dji_display_state_t *display_state, duss_disp_
109
112
}
110
113
111
114
res = duss_hal_display_plane_blending_set (display_state -> disp_instance_handle , plane_id , display_state -> pb_0 );
112
-
115
+
113
116
if (res != 0 ) {
114
117
printf ("failed to set blending" );
115
118
exit (0 );
@@ -158,7 +161,7 @@ void dji_display_open_framebuffer(dji_display_state_t *display_state, duss_disp_
158
161
exit (0 );
159
162
}
160
163
printf ("second buffer VRAM mapped virtual memory is at %p : %p\n" , display_state -> fb1_virtual_addr , display_state -> fb1_physical_addr );
161
-
164
+
162
165
for (int i = 0 ; i < 2 ; i ++ ) {
163
166
duss_frame_buffer_t * fb = i ? display_state -> fb_1 : display_state -> fb_0 ;
164
167
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
276
279
}
277
280
}
278
281
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 );
282
285
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 );
283
289
display_state -> frame_waiting = 1 ;
290
+ printf ("fbdebug pushing frame\n" );
284
291
duss_hal_display_push_frame (display_state -> disp_instance_handle , display_state -> plane_id , fb );
285
- return !which_fb ;
286
292
} else {
287
293
DEBUG_PRINT ("!!! Dropped frame due to pending frame push!\n" );
288
- return which_fb ;
294
+ printf ( "fbdebug dropping frame\n" ) ;
289
295
}
290
296
}
291
297
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 ) {
293
299
return which_fb ? display_state -> fb1_virtual_addr : display_state -> fb0_virtual_addr ;
294
300
}
295
301
0 commit comments