hwc: simplify the validate function. 07/166907/2
authorSooChan Lim <sc1.lim@samsung.com>
Fri, 12 Jan 2018 11:12:35 +0000 (20:12 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Wed, 17 Jan 2018 05:05:18 +0000 (05:05 +0000)
Change-Id: Id556e6c8badb507a9eca344bd39791d63770fe3d

src/tdm_sprd_display.c

index d4a964d..2ecf66f 100644 (file)
@@ -1758,6 +1758,7 @@ sprd_layer_get_zpos(tdm_layer *layer, int *zpos)
        return TDM_ERROR_NONE;
 }
 
+#if 0
 static int
 _sprd_layer_is_supported_format(tdm_sprd_layer_data *layer_data, tbm_format format)
 {
@@ -1780,6 +1781,7 @@ _sprd_hwc_window_is_reserved_buffer(tdm_sprd_hwc_window_data *hwc_window_data) {
 
        return falgs & TBM_BO_SCANOUT;
 }
+#endif
 
 tdm_error
 _sprd_output_insert_hwc_window(tdm_sprd_output_data *output, tdm_sprd_hwc_window_data *hwc_window_data)
@@ -1924,86 +1926,49 @@ sprd_output_hwc_validate(tdm_output *output, uint32_t *num_types)
 {
        tdm_sprd_output_data *output_data = output;
        tdm_sprd_data *sprd_data = NULL;
+       tdm_sprd_hwc_window_data *hwc_window_data = NULL;
+
        RETURN_VAL_IF_FAIL(output_data != NULL, TDM_ERROR_INVALID_PARAMETER);
        RETURN_VAL_IF_FAIL(num_types != NULL, TDM_ERROR_INVALID_PARAMETER);
-       tdm_sprd_hwc_window_data *hwc_window_data = NULL;
-       int hw_layer_count = 0;
-       int need_target_buffer = 0;
-       int is_client_detected = 0;
-       int max_hw_layer = HW_LAYER_NUM;
 
        sprd_data = output_data->sprd_data;
        RETURN_VAL_IF_FAIL(sprd_data != NULL, TDM_ERROR_INVALID_PARAMETER);
 
-       tdm_sprd_layer_data * layer = NULL;
-
-       /* video_hwc_window always is set to the lowest layer (index 0) */
-       if (output_data->video_hwc_window)
-               hw_layer_count++;
-
-       if (_get_number_of_visible_windows(output_data) > max_hw_layer - hw_layer_count)
-               need_target_buffer = 1;
-
-       /* check client_type */
+       /* decide the validated_types with client_types */
        LIST_FOR_EACH_ENTRY(hwc_window_data, &output_data->hwc_window_list, link) {
-               if (hwc_window_data->client_type == TDM_COMPOSITION_NONE)
+               /* set the none to validated_type */
+               if (hwc_window_data->client_type == TDM_COMPOSITION_NONE &&
+                       hwc_window_data->validated_type != TDM_COMPOSITION_NONE) {
+                       hwc_window_data->validated_type = TDM_COMPOSITION_NONE;
                        continue;
+                 }
 
-               if (hwc_window_data->client_type == TDM_COMPOSITION_DEVICE && !is_client_detected) {
-                       hwc_window_data->validated_type = TDM_COMPOSITION_DEVICE_CANDIDATE;
-               } else {
-                       hwc_window_data->validated_type = TDM_COMPOSITION_CLIENT;
-                       need_target_buffer = 1;
-                       is_client_detected = 1;
-               }
-       }
-
-       if (need_target_buffer)
-               max_hw_layer--;
-
-       is_client_detected = 0;
-       /* check format and flags for DEVICE_CANDIDATE */
-       LIST_FOR_EACH_ENTRY(hwc_window_data, &output_data->hwc_window_list, link) {
-               if (hwc_window_data->client_type == TDM_COMPOSITION_NONE)
+               /* set the TDM_COMPOSITION_VIDEO type */
+               if (hwc_window_data == output_data->video_hwc_window) {
+                       hwc_window_data->validated_type = TDM_COMPOSITION_DEVICE;
                        continue;
+               }
 
-               if (hwc_window_data->validated_type == TDM_COMPOSITION_DEVICE_CANDIDATE) {
-                       if (is_client_detected || hw_layer_count >= max_hw_layer) {
-                               is_client_detected = 1;
-                               hwc_window_data->validated_type = TDM_COMPOSITION_CLIENT;
-                       } else {
-                               layer = _sprd_output_get_layer(output_data, hw_layer_count);
-                               /* check format */
-                               if (!_sprd_layer_is_supported_format(layer, hwc_window_data->info.src_config.format))
-                                       hwc_window_data->validated_type = TDM_COMPOSITION_CLIENT;
-                               else if (!hwc_window_data->display_buffer || !hwc_window_data->display_buffer->buffer)
-                                       hwc_window_data->validated_type = TDM_COMPOSITION_CLIENT;
-                               /* check buffer flags */
-                               else if (_sprd_hwc_window_is_reserved_buffer(hwc_window_data)) {
-                                       hw_layer_count++;
-                                       hwc_window_data->validated_type = TDM_COMPOSITION_DEVICE;
-                                       continue;
-                               }
-                               is_client_detected = 1;
-                       }
+               /* all hwc_windows make TDM_COMPOSITION_CLIENT */
+               if (hwc_window_data->client_type != TDM_COMPOSITION_CLIENT) {
+                       hwc_window_data->validated_type = TDM_COMPOSITION_CLIENT;
                }
        }
 
-       if (is_client_detected)
-               need_target_buffer = 1;
-
+    /* debugging log */
        LIST_FOR_EACH_ENTRY(hwc_window_data, &output_data->hwc_window_list, link) {
                if (hwc_window_data->client_type == TDM_COMPOSITION_NONE)
                        continue;
 
                TDM_DBG(" window(%p) type: %s -> %s", hwc_window_data,
-                               _comp_to_str(hwc_window_data->client_type), _comp_to_str(hwc_window_data->validated_type));
+                               _comp_to_str(hwc_window_data->client_type),
+                               _comp_to_str(hwc_window_data->validated_type));
        }
 
-       output_data->need_target_buffer = need_target_buffer;
+    /* The driver always needs the target_buffer */
+       output_data->need_target_buffer = 1;
 
        *num_types = _sprd_output_get_changed_number(output_data);
-
        if (*num_types == 0)
                output_data->need_validate = 0;
 
@@ -2233,8 +2198,7 @@ sprd_hwc_window_set_composition_type(tdm_hwc_window *hwc_window,
                return TDM_ERROR_NONE;
 
        hwc_window_data->client_type = comp_type;
-       if (comp_type == TDM_COMPOSITION_NONE)
-               hwc_window_data->validated_type = comp_type;
+
        output_data->need_validate = 1;
 
        return TDM_ERROR_NONE;