weston: modify resume flow [1/1]
PD#SWPL-192800
Problem:
mode should not set when hdmitx_pwr is 0.
modify resume flow according to tx's request
Solution:
modify resume flow according to tx's request
Verify:
sc2
Change-Id: I49806279808b3b10ad8cff978addafe6db9a9a7c
Signed-off-by: limin.tian <limin.tian@amlogic.com>
diff --git a/aml-weston/aml-backend.c b/aml-weston/aml-backend.c
index aba1720..a2c3469 100644
--- a/aml-weston/aml-backend.c
+++ b/aml-weston/aml-backend.c
@@ -1122,7 +1122,7 @@
return;
compositor = b->compositor;
- b->display_enable = enable;
+ weston_log("\n :%s %d enable:%d\n",__FUNCTION__,__LINE__, enable);
if (enable == 1) {
wl_list_for_each(output, &compositor->output_list, base.link) {
@@ -1131,20 +1131,21 @@
mode_policy_set_head(head);
mode_policy_resume();
wst_mode = mode_policy_choose_mode(NULL);
- if (wst_mode)
+ if (wst_mode) {
weston_output_mode_set_native(&output->base,
wst_mode, output->base.current_scale);
+ b->state_invalid = true;
+ b->allow_modeset = true;
+ }
#endif
+ b->display_enable = enable;
if (output->base.start_repaint_loop) {
- if (output->base.repaint_status == REPAINT_NOT_SCHEDULED) {
- output->base.repaint_status = REPAINT_AWAITING_COMPLETION;
- output->base.start_repaint_loop(&output->base);
- } else if (output->base.repaint_status == REPAINT_AWAITING_COMPLETION && !output->state_last)
- weston_output_finish_frame(&output->base, NULL,
- WP_PRESENTATION_FEEDBACK_INVALID);
+ weston_compositor_damage_all(compositor);
+ weston_log("\n :%s %d repaint_status:%d\n",__FUNCTION__,__LINE__, output->base.repaint_status);
}
}
} else if (enable == 0) {
+ b->display_enable = enable;
drm_change_to_dummy_mode(compositor);
}
}
@@ -1371,6 +1372,7 @@
return;
wl_list_for_each_safe(output_state, tmp, &pending_state->output_list, link) {
+ output_state->output->base.repaint_status = REPAINT_NOT_SCHEDULED;
wl_list_for_each_safe(ps, next, &output_state->plane_list, link) {
if (ps->plane && !ps->plane->is_video_plane)
drm_plane_reset_state(ps->plane);
@@ -1472,8 +1474,9 @@
{
if (view && plane_state) {
plane_state->video_zpos = view->surface->video_zorder;
- weston_log("video_zorder %d plane %d \n",view->surface->video_zorder,
- plane_state->plane->plane_id);
+ if (view->surface->compositor->enable_video_debug)
+ weston_log("video_zorder %d plane %d \n",view->surface->video_zorder,
+ plane_state->plane->plane_id);
}
}
@@ -1649,9 +1652,22 @@
{
const char *dev_val;
dev_val = udev_device_get_property_value(device, "hdmitx_hdcppwr");
- weston_log("\n %s %d hdmitx_hdcppwr:%s\n", __FUNCTION__,__LINE__,dev_val);
if (dev_val && strcmp(dev_val, "1") ==0 ) {
- resume_display(b);
+ weston_log("late resume\n");
+ b->hdmitx_hdcppwr = 1;
+ }
+ if (dev_val && strcmp(dev_val, "0") ==0 ) {
+ b->hdmitx_hdcppwr = 0;
+ struct drm_output *output;
+ struct weston_head *head;
+ wl_list_for_each(output, &b->compositor->output_list, base.link) {
+ head = weston_output_get_first_head(&output->base);
+ weston_log("early suspend, output:%s head:%s :%d\n", output->base.name, head->name, head->connected);
+ if (strcmp("HDMI-A-1", head->name) == 0 && head->connected ) {
+ head->need_change = true;
+ break;
+ }
+ }
}
}
void resume_display(struct drm_backend *b)
@@ -1674,6 +1690,7 @@
#endif
if (output->base.start_repaint_loop) {
output->base.repaint_status = REPAINT_AWAITING_COMPLETION;
+ weston_log("\n :%s %d ->start_repaint_loop\n",__FUNCTION__,__LINE__);
output->base.start_repaint_loop(&output->base);
}
}
diff --git a/aml-weston/aml-compositor.c b/aml-weston/aml-compositor.c
index 46feb2e..689a19f 100644
--- a/aml-weston/aml-compositor.c
+++ b/aml-weston/aml-compositor.c
@@ -315,8 +315,10 @@
surface->video_buffer_release[FRAME_FREE] = NULL;
surface->is_video_surface = true;
}
- weston_log("\n video_surface_attach surface:%p (%s) buffer:%p count:%d\n", surface, surface->name, buffer, surface->frameN);
- surface->frameN++;
+ if (surface->compositor->enable_video_debug) {
+ weston_log("\n video_surface_attach surface:%p (%s) buffer:%p count:%d\n", surface, surface->name, buffer, surface->frameN);
+ surface->frameN++;
+ }
}
break;
default:
@@ -586,8 +588,8 @@
weston_compositor_read_presentation_clock(compositor, &now);
int64_t mdiff;
mdiff = timespec_sub_to_msec(&now, &compositor->last_repaint_start);
- if (mdiff > 17 && compositor->enable_video_debug)
- weston_log("\n output_repaint_timer_handler %d now (%ld.%09ld) last (%ld.%09ld) diff:%lld\n", __LINE__,
+ if (compositor->enable_video_debug)
+ weston_log("\n start output_repaint_timer_handler_aml %d now (%ld.%09ld) last (%ld.%09ld) diff:%lld\n", __LINE__,
now.tv_sec, now.tv_nsec, compositor->last_repaint_start.tv_sec, compositor->last_repaint_start.tv_nsec, mdiff);
compositor->last_repaint_start = now;
pts_exsit = check_commit_video_surface(compositor, now);
@@ -647,8 +649,8 @@
int64_t take;
weston_compositor_read_presentation_clock(compositor, &t1);
take = timespec_sub_to_msec(&t1, &now);
- if (take >= 10 && compositor->enable_video_debug)
- weston_log("\n timer_handler %d start (%ld.%09ld) end (%ld.%09ld) take:%lld\n", __LINE__,
+ if (compositor->enable_video_debug)
+ weston_log("\n end output_repaint_timer_handler_aml %d start (%ld.%09ld) end (%ld.%09ld) take:%lld\n", __LINE__,
now.tv_sec, now.tv_nsec, t1.tv_sec, t1.tv_nsec, take);
if ( need_repaint ) {
wl_list_for_each(output, &compositor->output_list, link) {
@@ -659,6 +661,7 @@
return 0;
}
}
+
output_repaint_timer_arm(compositor);
return 0;
}
diff --git a/aml-weston/aml-main.c b/aml-weston/aml-main.c
index 2909264..6909a4e 100644
--- a/aml-weston/aml-main.c
+++ b/aml-weston/aml-main.c
@@ -54,19 +54,21 @@
enabled = weston_head_is_enabled(head);
changed = weston_head_is_device_changed(head);
forced = drm_head_should_force_enable(wet, head);
- weston_log("\n %s %d head:%s connected:%d,enabled:%d,changed:%d forced:%d should_enable:%d\n",
- __FUNCTION__, __LINE__, head->name, connected, enabled, changed, forced, should_enable);
- if (((connected || forced) && should_enable) && !enabled) {
+ weston_log("\n %s %d head:%s connected:%d,enabled:%d,changed:%d forced:%d should_enable:%d head->need_change:%d\n",
+ __FUNCTION__, __LINE__, head->name, connected, enabled, changed, forced, should_enable, head->need_change);
+ if (((connected || forced) && should_enable) && (!enabled || head->need_change)) {
if (strcmp("HDMI-A-1", head->name) == 0) {
weston_log("\n enable HDMI and release stranded buffers\n");
weston_release_stranded_buffers(wet->compositor);
}
+ head->need_change = false;
drm_head_prepare_enable(wet, head);
- } else if (!((connected || forced) && should_enable) && enabled) {
+ } else if (!((connected || forced) && should_enable) && (enabled || head->need_change)) {
if (strcmp("HDMI-A-1", head->name) == 0) {
weston_log("\n disable HDMI and release stranded buffers\n");
weston_release_stranded_buffers(wet->compositor);
}
+ head->need_change = false;
drm_head_disable(head);
} else if (enabled && changed) {
weston_log("Detected a monitor change on head '%s', "
diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h
index ac33691..5bff593 100644
--- a/include/libweston/libweston.h
+++ b/include/libweston/libweston.h
@@ -273,6 +273,7 @@
/** Current content protection status */
enum weston_hdcp_protection current_protection;
+ bool need_change;
};
/** Content producer for heads
diff --git a/libweston/backend-drm/drm-internal.h b/libweston/backend-drm/drm-internal.h
index 1ed73d3..d4747b2 100644
--- a/libweston/backend-drm/drm-internal.h
+++ b/libweston/backend-drm/drm-internal.h
@@ -326,6 +326,7 @@
int vdin_detect_fd;
bool allow_modeset;
int display_enable;
+ int hdmitx_hdcppwr;
};
struct drm_mode {
diff --git a/libweston/backend-drm/drm.c b/libweston/backend-drm/drm.c
index e84621d..2f4729b 100644
--- a/libweston/backend-drm/drm.c
+++ b/libweston/backend-drm/drm.c
@@ -317,11 +317,12 @@
ts.tv_sec = sec;
ts.tv_nsec = usec * 1000;
- if (output->state_cur->dpms != WESTON_DPMS_OFF)
+ if (output->state_cur->dpms != WESTON_DPMS_OFF) {
weston_output_finish_frame(&output->base, &ts, flags);
- else
+ } else {
weston_output_finish_frame(&output->base, NULL,
WP_PRESENTATION_FEEDBACK_INVALID);
+ }
/* We can't call this from frame_notify, because the output's
* repaint needed flag is cleared just after that */
@@ -547,9 +548,20 @@
.request.signal = 0,
};
- if (output->disable_pending || output->destroy_pending)
+ weston_log("disable_pending:%d destroy_pending:%d fb%p state_invalid:%d hdmitx_hdcppwr:%d display_enable:%d\n",
+ output->disable_pending, output->destroy_pending, scanout_plane->state_cur->fb,
+ backend->state_invalid, backend->hdmitx_hdcppwr, backend->display_enable);
+
+ if (output->disable_pending || output->destroy_pending )
return 0;
+ if (!backend->display_enable) {
+ weston_log("\n :%s %d hdmitx_hdcppwr:%d display_enable:%d REPAINT_NOT_SCHEDULED\n",__FUNCTION__,__LINE__,
+ backend->hdmitx_hdcppwr, backend->display_enable);
+ output_base->repaint_status = REPAINT_NOT_SCHEDULED;
+ return 0;
+ }
+
if (!scanout_plane->state_cur->fb) {
/* We can't page flip if there's no mode set */
goto finish_frame;
@@ -2526,10 +2538,11 @@
sysnum = udev_device_get_sysnum(device);
if (!sysnum || atoi(sysnum) != b->drm.id)
return 0;
-
val = udev_device_get_property_value(device, "HOTPLUG");
if (!val)
return 0;
+ if (val)
+ weston_log("\n %s %d :HOTPLUG val:%s\n", __FUNCTION__,__LINE__,val);
return strcmp(val, "1") == 0;
}
@@ -2568,14 +2581,16 @@
event = udev_monitor_receive_device(b->udev_monitor);
udev_event_is_resume(b, event);
- if (udev_event_is_hotplug(b, event) && b->display_enable) {
+ if (udev_event_is_hotplug(b, event) && (b->display_enable || b->hdmitx_hdcppwr)) {
#ifdef ENABLE_MODE_POLICY
mode_policy_set_hotplug(AML_WESTON_HOTPLUG_PLUG | AML_WESTON_HOTPLUG_UNPLUG, true);
#endif
- if (udev_event_is_conn_prop_change(b, event, &conn_id, &prop_id))
+ if (udev_event_is_conn_prop_change(b, event, &conn_id, &prop_id)) {
drm_backend_update_conn_props(b, conn_id, prop_id);
- else
+ } else {
drm_backend_update_connectors(b, event);
+ weston_log("\n %s %d update connectors\n",__FUNCTION__,__LINE__);
+ }
}
#ifdef BUILD_AML_TV
@@ -2651,17 +2666,7 @@
if (compositor->session_active) {
weston_log("activating session\n");
udev_input_enable(&b->input);
- wl_list_for_each(output, &compositor->output_list, base.link) {
- head = weston_output_get_first_head(&output->base);
- weston_log("activating session, output:%s head:%s :%d\n", output->base.name, head->name, head->connected);
- if (strcmp("HDMI-A-1", head->name) == 0 && head->connected ) {
- found = true;
- }
- }
- if (!found) {
- weston_log("activating session, no HDMI\n");
- resume_display(b);
- }
+ resume_display(b);
weston_compositor_resume_focus(compositor);
weston_compositor_wake(compositor);
weston_compositor_damage_all(compositor);
@@ -3196,12 +3201,14 @@
wl_event_loop_add_fd(loop, b->drm.fd,
WL_EVENT_READABLE, on_drm_input, b);
- b->udev_monitor = udev_monitor_new_from_netlink(b->udev, "udev");
+ b->udev_monitor = udev_monitor_new_from_netlink(b->udev, "kernel");
if (b->udev_monitor == NULL) {
weston_log("failed to initialize udev monitor\n");
goto err_drm_source;
}
udev_monitor_filter_add_match_subsystem_devtype(b->udev_monitor,
+ "amhdmitx", NULL);
+ udev_monitor_filter_add_match_subsystem_devtype(b->udev_monitor,
"drm", NULL);
#ifdef BUILD_AML_TV
udev_monitor_filter_add_match_subsystem_devtype(b->udev_monitor,
@@ -3209,8 +3216,7 @@
udev_monitor_filter_add_match_subsystem_devtype(b->udev_monitor,
"framerate_adapter", NULL);
#endif
- udev_monitor_filter_add_match_subsystem_devtype(b->udev_monitor,
- "amhdmitx", NULL);
+
b->udev_drm_source =
wl_event_loop_add_fd(loop,
diff --git a/libweston/backend-drm/kms.c b/libweston/backend-drm/kms.c
index 11692d6..1accda3 100644
--- a/libweston/backend-drm/kms.c
+++ b/libweston/backend-drm/kms.c
@@ -1205,6 +1205,7 @@
if (b->allow_modeset) {
flags |= DRM_MODE_ATOMIC_ALLOW_MODESET;
mode_changed = true;
+ weston_log("\n allow_modeset:%d\n", b->allow_modeset);
}
}
@@ -1228,6 +1229,7 @@
if (mode != DRM_STATE_TEST_ONLY &&
mode_policy_add_prop(req, mode_changed) > 0) {
flags |= DRM_MODE_ATOMIC_ALLOW_MODESET;
+ weston_log("\n add prop, allow_modeset:%d\n", b->allow_modeset);
}
#endif
@@ -1254,7 +1256,7 @@
link)
drm_output_assign_state(output_state, mode);
- if (mode_changed &&
+ if (/*mode_changed &&*/
state_invalid == b->state_invalid &&
allow_modeset == b->allow_modeset) {
b->state_invalid = false;
diff --git a/libweston/compositor.c b/libweston/compositor.c
index 44b7942..f011f55 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -3284,7 +3284,6 @@
{
struct weston_output *output = data;
int ret;
-
assert(output->repaint_status == REPAINT_BEGIN_FROM_IDLE);
output->repaint_status = REPAINT_AWAITING_COMPLETION;
output->idle_repaint_source = NULL;
@@ -5878,7 +5877,7 @@
WL_EXPORT void
weston_head_set_connection_status(struct weston_head *head, bool connected)
{
- if (head->connected == connected)
+ if (head->connected == connected && !head->need_change)
return;
head->connected = connected;