if (type == DRM_PLANE_TYPE_CURSOR) {
if (output_data->cursor_layer)
continue;
- } else if (type == DRM_PLANE_TYPE_OVERLAY) {
- if (output_data->overlay_layer)
- continue;
} else if (type == DRM_PLANE_TYPE_PRIMARY) {
if (output_data->primary_layer)
continue;
if (type == DRM_PLANE_TYPE_CURSOR) {
layer_data->capabilities = TDM_VC4_LAYER_CAPABILITY_CURSOR |
TDM_VC4_LAYER_CAPABILITY_GRAPHIC;
- layer_data->zpos = 2;
+ layer_data->zpos = output_data->layer_count;
+ output_data->layer_count++;
output_data->cursor_layer = layer_data;
} else if (type == DRM_PLANE_TYPE_OVERLAY) {
layer_data->capabilities = TDM_VC4_LAYER_CAPABILITY_OVERLAY |
TDM_VC4_LAYER_CAPABILITY_GRAPHIC;
- layer_data->zpos = 1;
- output_data->overlay_layer = layer_data;
+ layer_data->zpos = output_data->layer_count;
+ output_data->layer_count++;
+ output_data->overlay_layer_count++;
} else if (type == DRM_PLANE_TYPE_PRIMARY) {
layer_data->capabilities = TDM_VC4_LAYER_CAPABILITY_PRIMARY |
TDM_VC4_LAYER_CAPABILITY_GRAPHIC;
- layer_data->zpos = 0;
+ layer_data->zpos = output_data->layer_count;
+ output_data->layer_count++;
output_data->primary_layer = layer_data;
} else {
drmModeFreePlane(plane);
#include "tdm_backend_vc4.h"
#include <pixman.h>
-#define NUM_LAYERS 4
#define NUM_BUFFERS 3
-#define NUM_UI_LAYERS 2
-
-#define ZPOS_MAX 3
-#define ZPOS_CURSOR 2
-#define ZPOS_1 1
-#define ZPOS_0 0
-#define ZPOS_VIDEO1 0
#define ZPOS_NONE -999
tbm_format hwc_window_video_formats[] = {
_vc4_hwc_prepare_commit(tdm_vc4_hwc *hwc_data)
{
tdm_vc4_hwc_window *hwc_window_data = NULL;
+ tdm_vc4_output *output_data = hwc_data->output_data;
tdm_vc4_layer *layer_data = NULL;
- tdm_vc4_hwc_window *use_layer_windows[NUM_LAYERS] = {NULL, };
+ tdm_vc4_hwc_window **use_layer_windows;
int lzpos = 0;
int cursor_enabled = 0;
+ use_layer_windows = calloc(output_data->layer_count, sizeof(tdm_vc4_hwc_window *));
+ if (!use_layer_windows) return HAL_TDM_ERROR_OUT_OF_MEMORY;
+
/* set target hwc window to the layer */
hwc_data->target_hwc_window->attach_buffer_changed = 0;
if (hwc_data->need_target_window)
}
/* unset the unused layers */
- for (lzpos = 0; lzpos < NUM_LAYERS; lzpos++) {
+ for (lzpos = 0; lzpos < output_data->layer_count; lzpos++) {
layer_data = tdm_vc4_output_get_layer_data(hwc_data->output_data, lzpos);
if (!layer_data)
continue;
_vc4_hwc_cursor_buffer_unset(hwc_data);
/* for debug */
- for (lzpos = NUM_LAYERS -1 ; lzpos >= 0; lzpos--)
+ for (lzpos = output_data->layer_count -1 ; lzpos >= 0; lzpos--)
TDM_BACKEND_DBG(" lzpos(%d) : %s", lzpos, use_layer_windows[lzpos] ? "SET" : "UNSET");
+ free(use_layer_windows);
+
return HAL_TDM_ERROR_NONE;
}
static void
_vc4_hwc_apply_policy(tdm_vc4_hwc *hwc_data , hal_tdm_hwc_window **composited_wnds, uint32_t num_wnds)
{
+ tdm_vc4_output *output_data = hwc_data->output_data;
tdm_vc4_hwc_window *hwc_window_data = NULL;
tdm_vc4_hwc_window **composited_list = NULL;
- int client_count = 0;
- int device_count = 0;
- int video_count = 0;
- int cursor_count = 0;
- int ui_lzpos_top = ZPOS_1;
- int ui_lzpos_bottom = ZPOS_0;
- int num_ui_layers = NUM_UI_LAYERS;
+ int client_count = 0, device_count = 0, video_count = 0, cursor_count = 0;
+ int ui_lzpos_top = 0, ui_lzpos_bottom = 0, num_ui_layers = 0, video_lzpos_top = 0;
int set_clients_below = 0;
int i = 0;
+ num_ui_layers = output_data->overlay_layer_count + 1;
+ ui_lzpos_top = output_data->overlay_layer_count;
+ ui_lzpos_bottom = 0;
+
composited_list = (tdm_vc4_hwc_window **)composited_wnds;
/* initialize the need_target_window */
case HAL_TDM_HWC_WIN_COMPOSITION_VIDEO:
composited_list[i]->validated_type = HAL_TDM_HWC_WIN_COMPOSITION_VIDEO;
video_count++;
- num_ui_layers--;
continue;
case HAL_TDM_HWC_WIN_COMPOSITION_CURSOR:
+ if (!output_data->cursor_layer) break;
if (set_clients_below) break;
if (cursor_count > 0) break;
}
/* 2. check need target window and set ui_lzpos top and bottom */
- num_ui_layers = NUM_UI_LAYERS;
+ num_ui_layers = output_data->overlay_layer_count + 1;
if (video_count > 0) {
- ui_lzpos_bottom++;
- num_ui_layers--;
+ ui_lzpos_bottom += video_count;
+ num_ui_layers -= video_count;
+ video_lzpos_top = video_count - 1;
}
- if ((client_count > 0) ||
- ((video_count > 0) && (device_count == NUM_UI_LAYERS))) {
+ if ((client_count > 0) || (device_count > num_ui_layers)) {
+ hwc_data->need_target_window = 1;
+ hwc_data->target_hwc_window->lzpos = ui_lzpos_bottom;
ui_lzpos_bottom++;
num_ui_layers--;
- hwc_data->need_target_window = 1;
- hwc_data->target_hwc_window->lzpos = ui_lzpos_bottom - 1;
}
if (num_ui_layers > device_count)
for (i = 0; i < num_wnds; i++) {
switch (composited_list[i]->validated_type) {
case HAL_TDM_HWC_WIN_COMPOSITION_VIDEO:
- composited_list[i]->lzpos = ZPOS_VIDEO1;
+ composited_list[i]->lzpos = video_lzpos_top;
+ video_lzpos_top--;
continue;
case HAL_TDM_HWC_WIN_COMPOSITION_CURSOR:
- composited_list[i]->lzpos = ZPOS_CURSOR;
+ if (!output_data->cursor_layer) break;
+ composited_list[i]->lzpos = output_data->cursor_layer->zpos;
continue;
case HAL_TDM_HWC_WIN_COMPOSITION_DEVICE:
if (num_ui_layers <= 0) break;
composited_list[i]->validated_type = HAL_TDM_HWC_WIN_COMPOSITION_CLIENT;
}
hwc_data->need_target_window = 1;
- hwc_data->target_hwc_window->lzpos = ZPOS_0;
+ hwc_data->target_hwc_window->lzpos = 0;
} else {
_vc4_hwc_apply_policy(hwc_data, composited_wnds, num_wnds);
}