hwc: implement new video API 79/162479/3
authorRoman Marchenko <r.marchenko@samsung.com>
Fri, 1 Dec 2017 14:44:50 +0000 (16:44 +0200)
committerRoman Marchenko <r.marchenko@samsung.com>
Mon, 4 Dec 2017 09:52:06 +0000 (11:52 +0200)
implement callback functions:
   - output_hwc_get_video_supported_formats;
   - output_hwc_create_video_window;
remove callback functions:
   - hwc_window_video_get_supported_format.

Change-Id: I14f467a53f0209fae32741ab595c0767a4c64833
Signed-off-by: Roman Marchenko <r.marchenko@samsung.com>
src/tdm_sprd.c
src/tdm_sprd.h
src/tdm_sprd_display.c

index dcd5383..3c1f4dd 100755 (executable)
@@ -181,6 +181,8 @@ tdm_sprd_init(tdm_display *dpy, tdm_error *error)
                sprd_func_output.output_hwc_accept_changes = sprd_output_hwc_accept_changes;
                sprd_func_output.output_hwc_get_target_buffer_queue = sprd_output_hwc_get_target_buffer_queue;
                sprd_func_output.output_hwc_set_client_target_buffer = sprd_output_hwc_set_client_target_buffer;
+               sprd_func_output.output_hwc_get_video_supported_formats = sprd_output_hwc_get_video_supported_formats;
+               sprd_func_output.output_hwc_create_video_window = sprd_output_hwc_create_video_window;
        }
 
        if (sprd_data->hwc_mode) {
@@ -194,7 +196,6 @@ tdm_sprd_init(tdm_display *dpy, tdm_error *error)
                sprd_func_hwc_window.hwc_window_set_flags = sprd_hwc_window_set_flags;
                sprd_func_hwc_window.hwc_window_unset_flags = sprd_hwc_window_unset_flags;
                sprd_func_hwc_window.hwc_window_video_get_capability = sprd_hwc_window_video_get_capability;
-               sprd_func_hwc_window.hwc_window_video_get_supported_format = sprd_hwc_window_video_get_supported_format;
        }
 
        memset(&sprd_func_layer, 0, sizeof(sprd_func_layer));
index 41971c9..e9edf08 100644 (file)
@@ -50,6 +50,10 @@ tdm_error    sprd_output_hwc_accept_changes(tdm_output *output);
 tbm_surface_queue_h sprd_output_hwc_get_target_buffer_queue(tdm_output *output, tdm_error *error);
 tdm_error    sprd_output_hwc_set_client_target_buffer(tdm_output *output, tbm_surface_h buffer,
                                                                        tdm_hwc_region damage);
+tdm_error    sprd_output_hwc_get_video_supported_formats(tdm_output *output,
+                                                                       const tbm_format **formats, int *count);
+tdm_hwc_window *sprd_output_hwc_create_video_window(tdm_output *output, tdm_error *error);
+
 tdm_error    sprd_layer_get_capability(tdm_layer *layer, tdm_caps_layer *caps);
 tdm_error    sprd_layer_set_property(tdm_layer *layer, unsigned int id, tdm_value value);
 tdm_error    sprd_layer_get_property(tdm_layer *layer, unsigned int id, tdm_value *value);
@@ -60,9 +64,6 @@ tdm_error    sprd_layer_unset_buffer(tdm_layer *layer);
 tdm_error    sprd_layer_get_buffer_flags(tdm_layer *layer, unsigned int *flags);
 tdm_error    sprd_hwc_window_video_get_capability(tdm_hwc_window *hwc_window,
                                                                                                  tdm_hwc_window_video_capability *video_capability);
-tdm_error    sprd_hwc_window_video_get_supported_format(tdm_hwc_window *hwc_window,
-                                                                                                               const tbm_format **formats,
-                                                                                                               int *count);
 tbm_surface_queue_h sprd_hwc_window_get_tbm_buffer_queue(tdm_hwc_window *hwc_window, tdm_error *error);
 tdm_error    sprd_hwc_window_set_zpos(tdm_hwc_window *hwc_window, uint32_t zpos);
 tdm_error    sprd_hwc_window_set_composition_type(tdm_hwc_window *hwc_window,
index 66bae8b..5691b7a 100644 (file)
@@ -93,6 +93,7 @@ struct _tdm_sprd_output_data {
        tdm_output_dpms dpms_value;
 
        tdm_sprd_hwc_window_data *target_hwc_window;
+       tdm_sprd_hwc_window_data *video_hwc_window;
 
        int need_validate;
        int need_target_buffer;
@@ -488,7 +489,6 @@ _sprd_layer_attach_window(tdm_sprd_layer_data *layer_data, tdm_sprd_hwc_window_d
        tdm_error ret = TDM_ERROR_NONE;
 
        RETURN_VAL_IF_FAIL(layer_data, TDM_ERROR_OPERATION_FAILED);
-       RETURN_VAL_IF_FAIL(hwc_window_data, TDM_ERROR_OPERATION_FAILED);
 
        if (hwc_window_data == NULL || hwc_window_data->display_buffer == NULL) {
                ret = sprd_layer_unset_buffer(layer_data);
@@ -1229,6 +1229,11 @@ _tdm_sprd_display_prepare_commit(tdm_sprd_output_data *output_data) {
                _sprd_layer_attach_window(layer, output_data->target_hwc_window);
        }
 
+       if (output_data->video_hwc_window) {
+               layer = _sprd_output_get_layer(output_data, 0);
+               _sprd_layer_attach_window(layer, output_data->video_hwc_window);
+       }
+
        if (_are_windows_with_client_candidate_type(&output_data->hwc_window_list))
                return TDM_ERROR_NONE;
 
@@ -1236,7 +1241,7 @@ _tdm_sprd_display_prepare_commit(tdm_sprd_output_data *output_data) {
        LIST_FOR_EACH_ENTRY_REV(hw, &output_data->hwc_window_list, link) {
                if (hw->client_type == TDM_COMPOSITION_NONE)
                        continue;
-               if (hw->client_type != TDM_COMPOSITION_DEVICE && hw->client_type != TDM_COMPOSITION_VIDEO)
+               if (hw->client_type != TDM_COMPOSITION_DEVICE)
                        continue;
                if (i < 0)
                        return TDM_ERROR_OPERATION_FAILED;
@@ -1246,6 +1251,8 @@ _tdm_sprd_display_prepare_commit(tdm_sprd_output_data *output_data) {
 
        /* disable unused layer */
        while (i >= 0) {
+               if (i == 0 && output_data->video_hwc_window)
+                       break;
                layer = _sprd_output_get_layer(output_data, i--);
                _sprd_layer_attach_window(layer, NULL);
        }
@@ -1253,7 +1260,6 @@ _tdm_sprd_display_prepare_commit(tdm_sprd_output_data *output_data) {
        return TDM_ERROR_NONE;
 }
 
-
 tdm_error
 sprd_output_commit(tdm_output *output, int sync, void *user_data)
 {
@@ -1913,8 +1919,6 @@ _comp_to_str(tdm_hwc_window_composition composition_type)
                return "DEVICE";
        else if (composition_type == TDM_COMPOSITION_CURSOR)
                return "CURSOR";
-       else if (composition_type == TDM_COMPOSITION_VIDEO)
-               return "VIDEO";
        else if (composition_type == TDM_COMPOSITION_NONE)
                return "NONE";
 
@@ -1974,14 +1978,11 @@ _reset_windows_to_client(struct list_head *hwc_wnds)
 
                else if (hw->prev_validated_type == TDM_COMPOSITION_DEVICE)
                        hw->validated_type = TDM_COMPOSITION_CLIENT_CANDIDATE;
-
-               else if (hw->prev_validated_type == TDM_COMPOSITION_VIDEO)
-                       hw->validated_type = TDM_COMPOSITION_CLIENT_CANDIDATE;
        }
 }
 
 /*
- * If we got at least one device/video -> client transition or we still have at
+ * If we got at least one device -> client transition or we still have at
  * least one window at the client_candidate state we reset all windows
  * to the client/client_candidate state as it's a reference implementation
  * of the driver
@@ -2004,10 +2005,6 @@ _is_reset_to_client_needed(struct list_head *hwc_wnds)
                                hw->validated_type == TDM_COMPOSITION_CLIENT)
                        return 1;
 
-               if (hw->prev_validated_type == TDM_COMPOSITION_VIDEO &&
-                               hw->validated_type == TDM_COMPOSITION_CLIENT)
-                       return 1;
-
                if (hw->client_type == TDM_COMPOSITION_CLIENT_CANDIDATE)
                        return 1;
        }
@@ -2034,17 +2031,19 @@ sprd_output_hwc_validate(tdm_output *output, uint32_t *num_types)
 
        tdm_sprd_layer_data * layer = NULL;
 
-       if (_get_number_of_visible_windows(sprd_output) > max_hw_layer)
+       /* video_hwc_window always is set to the lowest layer (index 0) */
+       if (sprd_output->video_hwc_window)
+               hw_layer_count++;
+
+       if (_get_number_of_visible_windows(sprd_output) > max_hw_layer - hw_layer_count)
                need_target_buffer = 1;
 
-       is_client_detected = 0;
        /* check client_type */
        LIST_FOR_EACH_ENTRY(hw, &sprd_output->hwc_window_list, link) {
                if (hw->client_type == TDM_COMPOSITION_NONE)
                        continue;
 
-               if ((hw->client_type == TDM_COMPOSITION_DEVICE || hw->client_type == TDM_COMPOSITION_VIDEO)
-                       && !is_client_detected) {
+               if (hw->client_type == TDM_COMPOSITION_DEVICE && !is_client_detected) {
                        hw->validated_type = TDM_COMPOSITION_DEVICE_CANDIDATE;
                } else {
                        hw->validated_type = TDM_COMPOSITION_CLIENT;
@@ -2067,13 +2066,6 @@ sprd_output_hwc_validate(tdm_output *output, uint32_t *num_types)
                                is_client_detected = 1;
                                hw->validated_type = TDM_COMPOSITION_CLIENT;
                        } else {
-                               if (hw->client_type == TDM_COMPOSITION_VIDEO && hw_layer_count == 0 &&
-                                       _sprd_hwc_window_is_reserved_buffer(hw)) {
-                                       hw_layer_count++;
-                                       hw->validated_type = TDM_COMPOSITION_VIDEO;
-                                       continue;
-
-                               }
                                layer = _sprd_output_get_layer(sprd_output, hw_layer_count);
                                /* check format */
                                if (!_sprd_layer_is_supported_format(layer, hw->info.src_config.format))
@@ -2085,7 +2077,6 @@ sprd_output_hwc_validate(tdm_output *output, uint32_t *num_types)
                                        hw_layer_count++;
                                        hw->validated_type = TDM_COMPOSITION_DEVICE;
                                        continue;
-
                                }
                                is_client_detected = 1;
                        }
@@ -2227,6 +2218,51 @@ sprd_output_hwc_set_client_target_buffer(tdm_output *output, tbm_surface_h buffe
        return TDM_ERROR_NONE;
 }
 
+tdm_error
+sprd_output_hwc_get_video_supported_formats(tdm_output *output,
+                                                                                       const tbm_format **formats,
+                                                                                       int *count)
+{
+       RETURN_VAL_IF_FAIL(output != NULL, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(formats != NULL, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(count != NULL, TDM_ERROR_INVALID_PARAMETER);
+
+       *formats = hwc_window_video_formats;
+       *count = sizeof(hwc_window_video_formats) / sizeof(tbm_format);
+
+       return TDM_ERROR_NONE;
+}
+
+tdm_hwc_window *
+sprd_output_hwc_create_video_window(tdm_output *output, tdm_error *error)
+{
+       tdm_sprd_hwc_window_data *sprd_hwc_window = NULL;
+       tdm_sprd_output_data *sprd_output = output;
+
+       if (error)
+               *error = TDM_ERROR_INVALID_PARAMETER;
+
+       RETURN_VAL_IF_FAIL(sprd_output != NULL, NULL);
+
+       if (error)
+               *error = TDM_ERROR_OPERATION_FAILED;
+
+       if (sprd_output->video_hwc_window)
+               return NULL;
+
+       sprd_hwc_window = _sprd_output_hwc_window_create(sprd_output, NULL, error);
+       if (sprd_hwc_window == NULL)
+               return NULL;
+
+       sprd_output->video_hwc_window = sprd_hwc_window;
+
+       TDM_DBG("hwc_window(%p) video create", sprd_hwc_window);
+       if (error)
+               *error = TDM_ERROR_NONE;
+
+       return sprd_hwc_window;
+}
+
 tbm_surface_queue_h
 sprd_hwc_window_get_tbm_buffer_queue(tdm_hwc_window *hwc_window, tdm_error *error)
 {
@@ -2405,33 +2441,18 @@ sprd_hwc_window_unset_flags(tdm_hwc_window *hwc_window, tdm_hwc_window_flag flag
 
 tdm_error
 sprd_hwc_window_video_get_capability(tdm_hwc_window *hwc_window,
-                                                                          tdm_hwc_window_video_capability *video_capability)
+                                                                        tdm_hwc_window_video_capability *video_capability)
 {
        tdm_sprd_hwc_window_data *sprd_hwc_window = hwc_window;
+       tdm_sprd_output_data *sprd_output;
 
        RETURN_VAL_IF_FAIL(hwc_window != NULL, TDM_ERROR_INVALID_PARAMETER);
+       sprd_output = sprd_hwc_window->output_data;
+       RETURN_VAL_IF_FAIL(sprd_output != NULL, TDM_ERROR_INVALID_PARAMETER);
        RETURN_VAL_IF_FAIL(video_capability != NULL, TDM_ERROR_INVALID_PARAMETER);
-       RETURN_VAL_IF_FAIL(sprd_hwc_window->validated_type == TDM_COMPOSITION_VIDEO, TDM_ERROR_INVALID_PARAMETER);
+       RETURN_VAL_IF_FAIL(sprd_output->video_hwc_window == sprd_hwc_window, TDM_ERROR_INVALID_PARAMETER);
 
        *video_capability = TDM_HWC_WINDOW_VIDEO_CAPABILITY_SCANOUT;
 
        return TDM_ERROR_NONE;
 }
-
-tdm_error
-sprd_hwc_window_video_get_supported_format(tdm_hwc_window *hwc_window,
-                                                                                        const tbm_format **formats,
-                                                                                        int *count)
-{
-       tdm_sprd_hwc_window_data *sprd_hwc_window = hwc_window;
-
-       RETURN_VAL_IF_FAIL(hwc_window != NULL, TDM_ERROR_INVALID_PARAMETER);
-       RETURN_VAL_IF_FAIL(formats != NULL, TDM_ERROR_INVALID_PARAMETER);
-       RETURN_VAL_IF_FAIL(count != NULL, TDM_ERROR_INVALID_PARAMETER);
-       RETURN_VAL_IF_FAIL(sprd_hwc_window->validated_type == TDM_COMPOSITION_VIDEO, TDM_ERROR_INVALID_PARAMETER);
-
-       *formats = hwc_window_video_formats;
-       *count = sizeof(hwc_window_video_formats) / sizeof(tbm_format);
-
-       return TDM_ERROR_NONE;
-}