static void
_exynos_output_hwc_adapt_policy(tdm_exynos_output_data *output_data, tdm_hwc_window **composited_wnds, uint32_t num_wnds)
{
- tdm_exynos_hwc_window_data *hwc_window_data = NULL;
tdm_exynos_hwc_window_data **composited_list = NULL;
int num_visible_windows = num_wnds;
int available_layers = LIST_LENGTH(&output_data->layer_list);
- int primary_layer_zpos = _get_primary_layer_zpos(output_data);
- int candidate_ui_top_zpos = 0;
- int num_video_layers = 0;
- int is_assigned = 0;
+ int num_videos = 0, num_clients = 0;
+ int min_zpos = 0, max_zpos = 0;
int i;
composited_list = (tdm_exynos_hwc_window_data**)composited_wnds;
- /* reset the validated_type and hw layer policy */
- for (i = 0; i < num_wnds; i++) {
- if (composited_list[i]->client_type == TDM_COMPOSITION_VIDEO)
- continue;
- composited_list[i]->validated_type = TDM_COMPOSITION_CLIENT;
- composited_list[i]->candidate_layer_zpos = -1;
- }
+ TDM_DBG("1. available_layers=%d, primary_layer_zpos=%d, num_visible_windows=%d", available_layers, _get_primary_layer_zpos(output_data), num_visible_windows);
/* initialize the zpos of the target_window */
- output_data->target_window_zpos = primary_layer_zpos;
+ output_data->target_window_zpos = _get_primary_layer_zpos(output_data);
output_data->need_target_window = 0;
/* need_target_window is true and return when there are no visible windows */
return;
}
- /* At first, assign the hw layers to the video windows from the bottom to the top.
- * Currenty, exynos supports only one video window.
- */
- if (output_data->video_hwc_window &&
- output_data->video_hwc_window->client_type == TDM_COMPOSITION_VIDEO) {
- hwc_window_data = output_data->video_hwc_window;
+ /* reset the validated_type and hw layer policy */
+ for (i = 0; i < num_wnds; i++) {
+ if (composited_list[i]->client_type == TDM_COMPOSITION_VIDEO &&
+ output_data->video_hwc_window == composited_list[i]) {
+ composited_list[i]->validated_type = composited_list[i]->client_type;
+ composited_list[i]->candidate_layer_zpos = 0;
+ ++num_videos;
+ /* The video window occupies the bottom layer */
+ ++min_zpos;
+ --available_layers;
+ continue;
+ }
- hwc_window_data->validated_type = hwc_window_data->client_type;
- hwc_window_data->candidate_layer_zpos = 0;
+ composited_list[i]->validated_type = TDM_COMPOSITION_CLIENT;
+ composited_list[i]->candidate_layer_zpos = -1;
+
+ /* The validate type of all windows below this window are TDM_COMPOSITION_CLIENT
+ * if the upper window is TDM_COMPSITION_CLIENT type.
+ */
+ if (num_clients > 0) {
+ ++num_clients;
+ continue;
+ }
- available_layers--;
- num_visible_windows--;
- num_video_layers++;
+ /* increase the num_clients when the type of the window is TDM_COMPOSITE_CLIENT. */
+ if (composited_list[i]->client_type == TDM_COMPOSITION_CLIENT) {
+ ++num_clients;
+ /* need target_window to composite */
+ ++min_zpos;
+ --available_layers;
+ output_data->need_target_window = 1;
+ }
}
- /* need target_window when the number of the visible windows is
- * more than the number of the available layers.
- */
- if (available_layers < num_visible_windows) {
- output_data->need_target_window = 1;
- /* the zpos of the primary layer is 1
- * therefore, exynos backend cannot use the zpos 0 layer
- * when it uses the target_window.
- */
- available_layers = available_layers - 2;
+ /* calculate the num windows which can be the candidates */
+ num_visible_windows = num_visible_windows - num_clients - num_videos;
+ if (num_visible_windows > available_layers) {
+ /* need target_window to composite if need_target_window is not set above */
+ if (output_data->need_target_window == 0) {
+ if (num_videos > 0) {
+ ++min_zpos;
+ --available_layers;
+ } else {
+ min_zpos = min_zpos + 2;
+ available_layers = available_layers - 2;
+ }
+ output_data->need_target_window = 1;
+ }
+ max_zpos = LIST_LENGTH(&output_data->layer_list) - 1;
} else {
- output_data->need_target_window = 0;
+ if (num_visible_windows == 1)
+ max_zpos = 1;
+ else
+ max_zpos = min_zpos + num_visible_windows - 1;
}
- /* set the top zpos for ui */
- candidate_ui_top_zpos = num_visible_windows + num_video_layers - 1;
+ TDM_DBG("2. available_layers=%d, max_zpos=%d, num_visible_windows=%d", available_layers, max_zpos, num_visible_windows);
/* assgin the hw layers to the ui windows from the top to the bottom */
for (i = 0; i < num_wnds; i++) {
if (composited_list[i]->client_type == TDM_COMPOSITION_VIDEO)
continue;
- if (composited_list[i] == output_data->video_hwc_window)
- continue;
if (available_layers == 0)
break;
- /* meet the client type, set need_target_window and break */
- if (composited_list[i]->client_type == TDM_COMPOSITION_CLIENT) {
- output_data->need_target_window = 1;
- break;
- }
-
if (composited_list[i]->client_type == TDM_COMPOSITION_DEVICE ||
composited_list[i]->client_type == TDM_COMPOSITION_CURSOR) {
if (_can_set_hwc_window_on_hw_layer(composited_list[i])) {
composited_list[i]->validated_type = composited_list[i]->client_type;
- composited_list[i]->candidate_layer_zpos = candidate_ui_top_zpos;
- candidate_ui_top_zpos--;
+ composited_list[i]->candidate_layer_zpos = max_zpos;
+ max_zpos--;
available_layers--;
- if (!is_assigned)
- is_assigned = 1;
} else
goto set_all_client_types;
}
}
- /* all windows are CLIENT type when is_assigned is 0 */
- if (!is_assigned)
- output_data->need_target_window = 1;
-
return;
set_all_client_types:
+ TDM_DBG("Set all windows to be CLIENT type due to hw restriction.!!");
+
for (i = 0; i < num_wnds; i++) {
if (composited_list[i]->client_type == TDM_COMPOSITION_VIDEO)
continue;
}
output_data->need_target_window = 1;
- output_data->target_window_zpos = primary_layer_zpos;
+ output_data->target_window_zpos = _get_primary_layer_zpos(output_data);
}
static void