hwc: Do not set the release fence is buffer of window is not updated 99/287899/3
authorChangyeon Lee <cyeon.lee@samsung.com>
Tue, 31 Jan 2023 10:39:06 +0000 (19:39 +0900)
committerChangyeon Lee <cyeon.lee@samsung.com>
Thu, 9 Feb 2023 03:52:58 +0000 (12:52 +0900)
output can be updated when other window update buffer.
hwc should check whether buffer of window is updated when
set the release fence.

Change-Id: I2847e7d24ea22c27691b78725e65eaea9f2a9d1a

src/tdm_backend_vc4.h
src/tdm_backend_vc4_types.h
src/tdm_vc4_display.c
src/tdm_vc4_hwc.c

index 5c17786..fbb1173 100644 (file)
@@ -139,6 +139,7 @@ hal_tdm_error  tdm_vc4_layer_set_buffer(tdm_vc4_layer *layer_data, tbm_surface_h
 hal_tdm_error  tdm_vc4_layer_unset_buffer(tdm_vc4_layer *layer_data);
 hal_tdm_error  tdm_vc4_layer_get_buffer_flags(tdm_vc4_layer *layer_data, unsigned int *flags);
 hal_tdm_error  tdm_vc4_layer_set_acquire_fence(tdm_vc4_layer *layer_data, int acquire_fence);
+hal_tdm_error  tdm_vc4_layer_set_hwc_window(tdm_vc4_layer *layer_data, tdm_vc4_hwc_window *hwc_window_data);
 
 /* vc4 format */
 uint32_t    tdm_format_get_drm_format(tbm_format format);
index 46e6b08..a94b67e 100644 (file)
@@ -292,6 +292,7 @@ struct _tdm_vc4_layer {
        } atomic_props_ids;
 
        int acquire_fence;
+       tdm_vc4_hwc_window *hwc_window_data;
 };
 
 struct _tdm_vc4_hwc {
@@ -334,6 +335,7 @@ struct _tdm_vc4_hwc_window {
        int cursor_img_refresh;
 
        int acquire_fence;
+       int attach_buffer_changed;
 };
 
 #endif /* _TDM_VC4_TYPES_H_ */
index 00878e7..837470c 100644 (file)
@@ -2391,3 +2391,15 @@ tdm_vc4_layer_set_acquire_fence(tdm_vc4_layer *layer_data, int acquire_fence)
 
        return HAL_TDM_ERROR_NONE;
 }
+
+hal_tdm_error
+tdm_vc4_layer_set_hwc_window(tdm_vc4_layer *layer_data, tdm_vc4_hwc_window *hwc_window_data)
+{
+       TDM_BACKEND_RETURN_VAL_IF_FAIL(layer_data, HAL_TDM_ERROR_INVALID_PARAMETER);
+
+       TDM_BACKEND_DBG("layer_data[%p]zpos[%d] hwc_window_data:%p", layer_data, layer_data->zpos, hwc_window_data);
+
+       layer_data->hwc_window_data = hwc_window_data;
+
+       return HAL_TDM_ERROR_NONE;
+}
index 8a5ce77..9022231 100644 (file)
@@ -430,19 +430,39 @@ _vc4_hwc_layer_attach_window(tdm_vc4_layer *layer_data, tdm_vc4_hwc_window *hwc_
        TDM_BACKEND_RETURN_VAL_IF_FAIL(layer_data, HAL_TDM_ERROR_OPERATION_FAILED);
 
        if (hwc_window_data == NULL || hwc_window_data->surface == NULL) {
-               if (layer_data->display_buffer)
-                       ret = tdm_vc4_layer_unset_buffer(layer_data);
+               if (layer_data->hwc_window_data)
+                       layer_data->hwc_window_data->attach_buffer_changed = 1;
+
+               ret = tdm_vc4_layer_set_hwc_window(layer_data, NULL);
                TDM_BACKEND_RETURN_VAL_IF_FAIL(ret == HAL_TDM_ERROR_NONE, ret);
 
-               if (layer_data->acquire_fence >= 0)
+               if (layer_data->display_buffer) {
+                       ret = tdm_vc4_layer_unset_buffer(layer_data);
+                       TDM_BACKEND_RETURN_VAL_IF_FAIL(ret == HAL_TDM_ERROR_NONE, ret);
+               }
+
+               if (layer_data->acquire_fence >= 0) {
                        ret = tdm_vc4_layer_set_acquire_fence(layer_data, -1);
-               TDM_BACKEND_RETURN_VAL_IF_FAIL(ret == HAL_TDM_ERROR_NONE, ret);
+                       TDM_BACKEND_RETURN_VAL_IF_FAIL(ret == HAL_TDM_ERROR_NONE, ret);
+               }
        } else {
+               TDM_BACKEND_RETURN_VAL_IF_FAIL(hwc_window_data->surface != NULL, HAL_TDM_ERROR_INVALID_PARAMETER);
+
+               if ((layer_data->hwc_window_data) && (layer_data->hwc_window_data != hwc_window_data))
+                       layer_data->hwc_window_data->attach_buffer_changed = 1;
+
+               ret = tdm_vc4_layer_set_hwc_window(layer_data, hwc_window_data);
+               TDM_BACKEND_RETURN_VAL_IF_FAIL(ret == HAL_TDM_ERROR_NONE, ret);
+
                ret = tdm_vc4_layer_set_info((tdm_vc4_layer *)layer_data, (tdm_vc4_layer_info *)&(hwc_window_data->info));
                TDM_BACKEND_RETURN_VAL_IF_FAIL(ret == HAL_TDM_ERROR_NONE, ret);
-               TDM_BACKEND_RETURN_VAL_IF_FAIL(hwc_window_data->surface != NULL, HAL_TDM_ERROR_INVALID_PARAMETER);
+
                ret = tdm_vc4_layer_set_buffer(layer_data, hwc_window_data->surface);
                TDM_BACKEND_RETURN_VAL_IF_FAIL(ret == HAL_TDM_ERROR_NONE, ret);
+
+               if (layer_data->display_buffer_changed)
+                       hwc_window_data->attach_buffer_changed = 1;
+
                ret = tdm_vc4_layer_set_acquire_fence(layer_data, hwc_window_data->acquire_fence);
                TDM_BACKEND_RETURN_VAL_IF_FAIL(ret == HAL_TDM_ERROR_NONE, ret);
        }
@@ -455,61 +475,51 @@ _vc4_hwc_prepare_commit(tdm_vc4_hwc *hwc_data)
 {
        tdm_vc4_hwc_window *hwc_window_data = NULL;
        tdm_vc4_layer *layer_data = NULL;
-       int use_layers_zpos[NUM_LAYERS] = {0,};
+       tdm_vc4_hwc_window *use_layer_windows[NUM_LAYERS] = {NULL, };
        int lzpos = 0;
        int cursor_enabled = 0;
 
-       /* set target hwc window to the layer_data */
-       if (hwc_data->need_target_window) {
-               layer_data = tdm_vc4_output_get_layer_data(hwc_data->output_data, hwc_data->target_hwc_window->lzpos);
-               _vc4_hwc_layer_attach_window(layer_data, hwc_data->target_hwc_window);
-               use_layers_zpos[hwc_data->target_hwc_window->lzpos] = 1;
-       }
+       /* set target hwc window to the layer */
+       hwc_data->target_hwc_window->attach_buffer_changed = 0;
+       if (hwc_data->need_target_window)
+               use_layer_windows[hwc_data->target_hwc_window->lzpos] = hwc_data->target_hwc_window;
 
        /* set the hwc_windows to the layers */
        LIST_FOR_EACH_ENTRY_REV(hwc_window_data, &hwc_data->hwc_window_list, link) {
-               if (hwc_window_data->validated_type == HAL_TDM_HWC_WIN_COMPOSITION_NONE ||
-                       hwc_window_data->validated_type == HAL_TDM_HWC_WIN_COMPOSITION_CLIENT) {
+               hwc_window_data->attach_buffer_changed = 0;
+
+               if ((hwc_window_data->validated_type == HAL_TDM_HWC_WIN_COMPOSITION_NONE) ||
+                       (hwc_window_data->validated_type == HAL_TDM_HWC_WIN_COMPOSITION_CLIENT)) {
                        if (hwc_window_data->cursor_img_surface)
                                _vc4_hwc_cursor_window_surface_clear(hwc_window_data);
 
                        continue;
                }
 
-               if (hwc_window_data == hwc_data->target_hwc_window)
-                       continue;
-
                /* set the cursor buffer HERE if it needs */
                if (hwc_window_data->validated_type == HAL_TDM_HWC_WIN_COMPOSITION_CURSOR) {
                        _vc4_hwc_cursor_buffer_set(hwc_data, hwc_window_data);
                        cursor_enabled = 1;
                }
 
-               layer_data = tdm_vc4_output_get_layer_data(hwc_data->output_data, hwc_window_data->lzpos);
-               _vc4_hwc_layer_attach_window(layer_data, hwc_window_data);
-               use_layers_zpos[hwc_window_data->lzpos] = 1;
+               use_layer_windows[hwc_window_data->lzpos] = hwc_window_data;
        }
 
        /* unset the unused layers */
        for (lzpos = 0; lzpos < NUM_LAYERS; lzpos++) {
-               if (use_layers_zpos[lzpos])
-                       continue;
-
                layer_data = tdm_vc4_output_get_layer_data(hwc_data->output_data, lzpos);
                if (!layer_data)
                        continue;
 
-               _vc4_hwc_layer_attach_window(layer_data, NULL);
+               _vc4_hwc_layer_attach_window(layer_data, use_layer_windows[lzpos]);
        }
 
        if (!cursor_enabled)
                _vc4_hwc_cursor_buffer_unset(hwc_data);
 
        /* for debug */
-       for (lzpos = NUM_LAYERS -1 ; lzpos >= 0; lzpos--) {
-               if (use_layers_zpos[lzpos])
-                       TDM_BACKEND_DBG(" lzpos(%d) : %s", lzpos, use_layers_zpos[lzpos] ? "SET" : "UNSET");
-       }
+       for (lzpos = NUM_LAYERS -1 ; lzpos >= 0; lzpos--)
+               TDM_BACKEND_DBG(" lzpos(%d) : %s", lzpos, use_layer_windows[lzpos] ? "SET" : "UNSET");
 
        return HAL_TDM_ERROR_NONE;
 }
@@ -995,8 +1005,7 @@ vc4_hwc_get_release_fences(hal_tdm_hwc *hwc, uint32_t *num_elements,
        TDM_BACKEND_RETURN_VAL_IF_FAIL(output_data, HAL_TDM_ERROR_INVALID_PARAMETER);
 
        LIST_FOR_EACH_ENTRY_REV(hwc_window_data, &hwc_data->hwc_window_list, link) {
-               if ((hwc_window_data->validated_type != HAL_TDM_HWC_WIN_COMPOSITION_DEVICE) &&
-                       (hwc_window_data->validated_type != HAL_TDM_HWC_WIN_COMPOSITION_VIDEO))
+               if (!hwc_window_data->attach_buffer_changed)
                        continue;
 
                if (hwc_wnds && fences) {