summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSooChan Lim <sc1.lim@samsung.com>2018-11-16 11:47:30 +0900
committerSooChan Lim <sc1.lim@samsung.com>2018-11-16 11:47:30 +0900
commit44fbcda4d5505036b4876c8ab34e70fcdf58caec (patch)
treef64db5b678cdff5f7da66c013bb79b7f6a0b7cc3
parent1e9b5b60644de308ec696b4fc4e73ff818fcf57c (diff)
downloadlibtdm-sprd-44fbcda4d5505036b4876c8ab34e70fcdf58caec.tar.gz
libtdm-sprd-44fbcda4d5505036b4876c8ab34e70fcdf58caec.tar.bz2
libtdm-sprd-44fbcda4d5505036b4876c8ab34e70fcdf58caec.zip
hwc: add apply_policy and modify the prepare_commit
change the hwc policy Change-Id: Iccbbe1fc6566f7bed616614d4d33b88018b89f3d
-rw-r--r--src/tdm_sprd_hwc.c239
1 files changed, 129 insertions, 110 deletions
diff --git a/src/tdm_sprd_hwc.c b/src/tdm_sprd_hwc.c
index da77a8f..2410242 100644
--- a/src/tdm_sprd_hwc.c
+++ b/src/tdm_sprd_hwc.c
@@ -6,6 +6,11 @@
#define MIN_WIDTH 32
+#define NUM_LAYERS 2
+#define ZPOS_OSD 1
+#define ZPOS_IMG 0
+#define NUM_UI_LAYERS 1
+
tbm_format hwc_window_video_formats[] = {
TBM_FORMAT_NV12,
TBM_FORMAT_YUV420
@@ -61,7 +66,7 @@ _print_validate_result(tdm_sprd_hwc_data *hwc_data, tdm_hwc_window **composited_
static int
_sprd_hwc_window_has_reserved_buffer(tdm_sprd_hwc_window_data *hwc_window_data) {
tbm_bo bo = NULL;
- int falgs = 0;
+ int flags = 0;
RETURN_VAL_IF_FAIL(hwc_window_data != NULL, 0);
RETURN_VAL_IF_FAIL(hwc_window_data->surface != NULL, 0);
@@ -69,9 +74,9 @@ _sprd_hwc_window_has_reserved_buffer(tdm_sprd_hwc_window_data *hwc_window_data)
bo = tbm_surface_internal_get_bo(hwc_window_data->surface, 0);
RETURN_VAL_IF_FAIL(bo != NULL, 0);
- falgs = tbm_bo_get_flags(bo);
+ flags = tbm_bo_get_flags(bo);
- return falgs & TBM_BO_SCANOUT;
+ return flags & TBM_BO_SCANOUT;
}
static int
@@ -172,46 +177,142 @@ _sprd_hwc_layer_attach_window(tdm_sprd_layer_data *layer_data, tdm_sprd_hwc_wind
static tdm_error
_sprd_hwc_prepare_commit(tdm_sprd_hwc_data *hwc_data)
{
- tdm_sprd_layer_data * layer = NULL;
tdm_sprd_hwc_window_data *hwc_window_data = NULL;
- int osd_use = 0, img_use = 0;
+ tdm_sprd_layer_data *layer_data = NULL;
+ int use_layers_zpos[NUM_LAYERS] = {0,};
+ int i;
/* set target hwc window */
if (hwc_data->need_target_window) {
- layer = _sprd_hwc_get_layer(hwc_data, 1);
- _sprd_hwc_layer_attach_window(layer, hwc_data->target_hwc_window);
- osd_use = 1;
+ layer_data = _sprd_hwc_get_layer(hwc_data, ZPOS_OSD);
+ _sprd_hwc_layer_attach_window(layer_data, hwc_data->target_hwc_window);
+ use_layers_zpos[hwc_data->target_hwc_window->zpos] = 1;
}
/* set hwc windows */
LIST_FOR_EACH_ENTRY_REV(hwc_window_data, &hwc_data->hwc_window_list, link) {
- if (hwc_window_data->validated_type == TDM_HWC_WIN_COMPOSITION_DEVICE) {
- layer = _sprd_hwc_get_layer(hwc_data, 1);
- osd_use = 1;
- } else if (hwc_window_data->validated_type == TDM_HWC_WIN_COMPOSITION_VIDEO) {
- layer = _sprd_hwc_get_layer(hwc_data, 0);
- img_use = 1;
- } else {
+ if (hwc_window_data->validated_type == TDM_COMPOSITION_NONE ||
+ hwc_window_data->validated_type == TDM_COMPOSITION_CLIENT)
+ continue;
+ if (hwc_window_data == hwc_data->target_hwc_window)
continue;
- }
- _sprd_hwc_layer_attach_window(layer, hwc_window_data);
+ layer_data = _sprd_hwc_get_layer(hwc_data, hwc_window_data->zpos);
+ _sprd_hwc_layer_attach_window(layer_data, hwc_window_data);
+ use_layers_zpos[hwc_window_data->zpos] = 1;
}
- /* disable unused layer */
- if (!osd_use) {
- layer = _sprd_hwc_get_layer(hwc_data, 1);
- _sprd_hwc_layer_attach_window(layer, NULL);
- }
+ /* unset the unused layers */
+ for (i = 0; i < NUM_LAYERS; i++) {
+ if (use_layers_zpos[i])
+ continue;
- if (!img_use) {
- layer = _sprd_hwc_get_layer(hwc_data, 0);
- _sprd_hwc_layer_attach_window(layer, NULL);
+ layer_data = _sprd_hwc_get_layer(hwc_data, use_layers_zpos[i]);
+ _sprd_hwc_layer_attach_window(layer_data, NULL);
}
return TDM_ERROR_NONE;
}
+static void
+_sprd_hwc_apply_policy(tdm_sprd_hwc_data *hwc_data , tdm_hwc_window **composited_wnds, uint32_t num_wnds)
+{
+ tdm_sprd_hwc_window_data *hwc_window_data = NULL;
+ tdm_sprd_hwc_window_data **composited_list = NULL;
+ int client_count = 0;
+ int device_count = 0;
+ int video_count = 0;
+ int cursor_count = 0;
+ int next_idx = 0;
+ int ui_zpos = ZPOS_OSD; // this is 1
+ int video_zpos = ZPOS_IMG; // this is 0
+ int i = 0;
+
+ composited_list = (tdm_sprd_hwc_window_data **)composited_wnds;
+
+ /* initialize the need_target_window */
+ hwc_data->need_target_window = 0;
+
+ /* initialize the validated_types */
+ LIST_FOR_EACH_ENTRY_REV(hwc_window_data, &hwc_data->hwc_window_list, link) {
+ if (hwc_window_data->validated_type == TDM_COMPOSITION_NONE)
+ continue;
+ hwc_window_data->validated_type = TDM_COMPOSITION_NONE;
+ }
+
+ /* use the target_window to commit when there is no window. */
+ if (num_wnds == 0) {
+ hwc_data->need_target_window = 1;
+ return;
+ }
+
+ /* count the composited(visible) windows */
+ for (i = 0; i < num_wnds; i++) {
+ if (composited_list[i]->client_type == TDM_COMPOSITION_CURSOR)
+ cursor_count++;
+ if (composited_list[i]->client_type == TDM_COMPOSITION_CLIENT)
+ client_count++;
+ if (client_count == 0 && composited_list[i]->client_type == TDM_COMPOSITION_DEVICE)
+ device_count++;
+ if (composited_list[i]->client_type == TDM_COMPOSITION_VIDEO)
+ video_count++;
+ }
+
+ if (cursor_count > 0)
+ goto set_clients_below;
+
+ if (client_count > 0)
+ goto set_clients_below;
+
+ /* calculate the available device_count */
+ if (device_count > NUM_UI_LAYERS)
+ goto set_clients_below;
+
+ /* NUM_UI_LAYSERS is 1, so device_count always 1 at this point */
+ for (i = 0; i < device_count; i++) {
+ /* for video */
+ if (composited_list[next_idx]->client_type == TDM_COMPOSITION_VIDEO) {
+ composited_list[next_idx]->validated_type = TDM_COMPOSITION_VIDEO;
+ composited_list[next_idx]->zpos = video_zpos;
+ next_idx++;
+ continue;
+ }
+
+ /* set the buffer_queue constraint */
+ composited_list[next_idx]->constraints = TDM_CONSTRAINT_BUFFER_QUEUE;
+ if (!_sprd_hwc_window_can_set_on_hw_layer(composited_list[next_idx])) {
+ composited_list[next_idx]->validated_type = TDM_COMPOSITION_CLIENT;
+ composited_list[next_idx]->zpos = -1;
+ next_idx++;
+ break;
+ }
+
+ /* set the OSD */
+ composited_list[next_idx]->validated_type = TDM_COMPOSITION_DEVICE;
+ composited_list[next_idx]->zpos = ui_zpos--;
+ next_idx++;
+
+ device_count--;
+ }
+
+set_clients_below:
+ while (next_idx < num_wnds) {
+ hwc_data->need_target_window = 1;
+
+ /* for video */
+ if (composited_list[next_idx]->client_type == TDM_COMPOSITION_VIDEO) {
+ composited_list[next_idx]->validated_type = TDM_COMPOSITION_VIDEO;
+ composited_list[next_idx]->zpos = video_zpos;
+ next_idx++;
+ continue;
+ }
+ composited_list[next_idx]->constraints = TDM_CONSTRAINT_NONE;
+ composited_list[next_idx]->validated_type = TDM_COMPOSITION_CLIENT;
+ composited_list[next_idx]->zpos = -1;
+ next_idx++;
+ }
+}
+
int
_sprd_hwc_get_changed_number(tdm_sprd_hwc_data *hwc_data)
{
@@ -364,99 +465,16 @@ tdm_error
sprd_hwc_validate(tdm_hwc *hwc, tdm_hwc_window **composited_wnds, uint32_t num_wnds, uint32_t *num_types)
{
tdm_sprd_hwc_data *hwc_data = hwc;
- tdm_sprd_hwc_window_data *hwc_window_data = NULL;
- tdm_sprd_hwc_window_data **composited_list = NULL;
- int i = 0, zpos = 0;
RETURN_VAL_IF_FAIL(hwc_data != NULL, TDM_ERROR_INVALID_PARAMETER);
RETURN_VAL_IF_FAIL(num_types != NULL, TDM_ERROR_INVALID_PARAMETER);
- composited_list = (tdm_sprd_hwc_window_data **)composited_wnds;
-
- hwc_data->need_target_window = 1;
-
- /* initialize the validated_types */
- LIST_FOR_EACH_ENTRY_REV(hwc_window_data, &hwc_data->hwc_window_list, link) {
- if (hwc_window_data->validated_type == TDM_HWC_WIN_COMPOSITION_NONE)
- continue;
-
- hwc_window_data->validated_type = TDM_HWC_WIN_COMPOSITION_NONE;
- }
-
- if (num_wnds == 0) {
- hwc_data->need_target_window = 1;
- } else if (num_wnds == 1) {
- composited_list[0]->constraints = TDM_HWC_WIN_CONSTRAINT_NONE;
- if (composited_list[0]->client_type == TDM_HWC_WIN_COMPOSITION_DEVICE) {
- if (_sprd_hwc_window_can_set_on_hw_layer(composited_list[0])) {
- hwc_data->need_target_window = 0;
- composited_list[0]->validated_type = TDM_HWC_WIN_COMPOSITION_DEVICE;
- composited_list[0]->zpos = zpos;
- zpos++;
- } else {
- composited_list[0]->validated_type = TDM_HWC_WIN_COMPOSITION_CLIENT;
- composited_list[0]->zpos = -1;
- }
- composited_list[0]->constraints = TDM_HWC_WIN_CONSTRAINT_BUFFER_QUEUE;
- } else if (composited_list[0]->client_type == TDM_HWC_WIN_COMPOSITION_CLIENT) {
- composited_list[0]->validated_type = TDM_HWC_WIN_COMPOSITION_CLIENT;
- composited_list[0]->zpos = -1;
- } else if (composited_list[0]->client_type == TDM_HWC_WIN_COMPOSITION_VIDEO) {
- composited_list[0]->validated_type = TDM_HWC_WIN_COMPOSITION_VIDEO;
- composited_list[0]->zpos = zpos;
- zpos++;
- } else {
- composited_list[0]->validated_type = TDM_HWC_WIN_COMPOSITION_NONE;
- composited_list[0]->zpos = -1;
- }
- } else {
- int has_video = 0;
-
- for (i = 0; i < num_wnds; i++) {
- if (composited_list[i]->client_type == TDM_HWC_WIN_COMPOSITION_VIDEO)
- has_video++;
- }
+ TDM_DBG(" ==============Validate=================================");
- for (i = 0 ; i < num_wnds; i++) {
- composited_list[i]->constraints = TDM_HWC_WIN_CONSTRAINT_NONE;
- if (num_wnds == 2 && has_video == 1) {
- if (composited_list[i]->client_type == TDM_HWC_WIN_COMPOSITION_DEVICE) {
- if (_sprd_hwc_window_can_set_on_hw_layer(composited_list[i])) {
- hwc_data->need_target_window = 0;
- composited_list[i]->validated_type = TDM_HWC_WIN_COMPOSITION_DEVICE;
- composited_list[i]->zpos = zpos;
- zpos++;
- } else {
- composited_list[0]->validated_type = TDM_HWC_WIN_COMPOSITION_CLIENT;
- composited_list[0]->zpos = -1;
- }
- } else if (composited_list[i]->client_type == TDM_HWC_WIN_COMPOSITION_CLIENT) {
- composited_list[i]->validated_type = TDM_HWC_WIN_COMPOSITION_CLIENT;
- composited_list[i]->zpos = -1;
- } else if (composited_list[i]->client_type == TDM_HWC_WIN_COMPOSITION_VIDEO) {
- composited_list[i]->validated_type = TDM_HWC_WIN_COMPOSITION_VIDEO;
- composited_list[i]->zpos = zpos;
- zpos++;
- } else {
- composited_list[i]->validated_type = TDM_HWC_WIN_COMPOSITION_NONE;
- composited_list[i]->zpos = -1;
- }
- } else {
- if (composited_list[i]->client_type == TDM_HWC_WIN_COMPOSITION_DEVICE ||
- composited_list[i]->client_type == TDM_HWC_WIN_COMPOSITION_CLIENT) {
- composited_list[i]->validated_type = TDM_HWC_WIN_COMPOSITION_CLIENT;
- composited_list[i]->zpos = -1;
- } else if (composited_list[i]->client_type == TDM_HWC_WIN_COMPOSITION_NONE) {
- composited_list[i]->validated_type = TDM_HWC_WIN_COMPOSITION_NONE;
- composited_list[i]->zpos = -1;
- }
- }
- }
- }
+ _sprd_hwc_apply_policy(hwc_data, composited_wnds, num_wnds);
*num_types = _sprd_hwc_get_changed_number(hwc_data);
- /* print the result */
_print_validate_result(hwc_data, composited_wnds, num_wnds);
return TDM_ERROR_NONE;
@@ -610,6 +628,7 @@ tdm_sprd_hwc_initailize_target_window(tdm_hwc *hwc, int width, int height)
sprd_hwc_window_destroy(hwc_data->target_hwc_window);
hwc_data->target_hwc_window = target_hwc_window;
+ hwc_data->target_hwc_window->zpos = ZPOS_OSD;
return TDM_ERROR_NONE;
}