weston: fix cvbs output mode set [1/1]
PD#SWPL-179859
Problem:
UI display abnormal in cvbs output
Solution:
modify set mode flow of cvbs
Verify:
bm201
Change-Id: If77e8feed397bb56a7b671015ee573e86c4c47d2
Signed-off-by: leng.fang <leng.fang@amlogic.com>
diff --git a/aml-weston/aml-backend.c b/aml-weston/aml-backend.c
index abe7541..e4c5558 100644
--- a/aml-weston/aml-backend.c
+++ b/aml-weston/aml-backend.c
@@ -442,12 +442,13 @@
#ifdef ENABLE_DRM_HELP
struct drm_head *head = to_drm_head(weston_output_get_first_head(base));
- if (head && head->connector.conn)
+ if ((head && head->connector.conn &&
+ head->connector.conn->connector_type == DRM_MODE_CONNECTOR_HDMIA) ||
+ strstr(base->name, "HDMI"))
{
- if (head->connector.conn->connector_type == DRM_MODE_CONNECTOR_HDMIA)
- {
- help_set_switch_mode_function(NULL, NULL);
- }
+ help_set_switch_mode_function(NULL, NULL);
+ help_set_force_refresh_function(NULL);
+ help_set_property_function(NULL);
}
#endif
struct drm_crtc *crtc = output->crtc;
diff --git a/libweston/modepolicy/ModePolicy.cpp b/libweston/modepolicy/ModePolicy.cpp
index c9da3a7..c24ad21 100644
--- a/libweston/modepolicy/ModePolicy.cpp
+++ b/libweston/modepolicy/ModePolicy.cpp
@@ -919,12 +919,7 @@
MESON_LOGD("ModePolicy handle hotplug:%d", connected);
//plugout or suspend,set dummy_l
if (!connected) {
- std::string displayMode("auto");
- if (isVMXCertification()) {
- displayMode = "576cvbs";
- }
-
- setSourceOutputMode(displayMode.c_str(), true);
+ setDisplay(OUTPUT_MODE_STATE_POWER);
return;
}
@@ -2725,7 +2720,40 @@
}
}
+void ModePolicy::setDisplay(output_mode_state state)
+{
+ if ((state == OUTPUT_MODE_STATE_INIT) ||
+ (state == OUTPUT_MODE_STATE_POWER)) {
+ memset(&mConData, 0, sizeof(meson_policy_in));
+ memset(&mDvInfo, 0, sizeof(hdmi_amdv_info_t));
+ mState = state;
+ mConData.state = static_cast<meson_mode_state>(state);
+ getConnectorData(&mConData, &mDvInfo);
+ if (isTvSupportDV() && isMboxSupportDV()) {
+ strcpy(mDvInfo.amdv_enable, "1");
+ mConData.hdr_info.is_amdv_enable = isDVEnable();
+ }
+
+ strcpy(mConData.cur_displaymode, mConData.con_info.ubootenv_hdmimode);
+ }
+
+ // TOD sceneProcess
+ if (isBestPolicy()) {
+ if (state == OUTPUT_MODE_STATE_INIT || mPolicy == MESON_POLICY_INVALID) {
+ mPolicy = MESON_POLICY_MIX;
+ }
+ } else {
+ mPolicy = MESON_POLICY_INVALID;
+ }
+
+ meson_mode_set_policy(mModeConType, mPolicy);
+ meson_mode_set_policy_input(mModeConType, &mConData);
+ meson_mode_get_policy_output(mModeConType, &mSceneOutInfo);
+
+ //5. apply settings to driver
+ applyDisplaySetting(state == OUTPUT_MODE_STATE_POWER);
+}
/*
* OUTPUT_MODE_STATE_INIT for boot
* OUTPUT_MODE_STATE_POWER for hdmi plug and suspend/resume
@@ -2736,13 +2764,8 @@
//1. hdmi used and hpd = 0
//set dummy_l mode
if ((isHdmiUsed() == true) && (isConnected() == false)) {
- MESON_LOGD("hdmi usd, set dummy_l");
- std::string displayMode("auto");
- if (isVMXCertification()) {
- displayMode = "576cvbs";
- }
-
- setSourceOutputModeNoLock(displayMode.c_str(), false);
+ MESON_LOGD("hdmi usd, set cvbs");
+ setDisplay(state);
MESON_LOGI("hdmi used but plugout when boot\n");
return;
}
diff --git a/libweston/modepolicy/ModePolicy.h b/libweston/modepolicy/ModePolicy.h
index 4ca8a2a..d6d73cf 100644
--- a/libweston/modepolicy/ModePolicy.h
+++ b/libweston/modepolicy/ModePolicy.h
@@ -453,6 +453,7 @@
void drmMode2MesonMode(meson_mode_info_t &mesonMode, drm_mode_info_t &drmMode);
void getSupportedModes();
bool isModeSupported(drm_mode_info_t mode);
+ void setDisplay(output_mode_state state);
protected:
static void * threadMain(void * data);
diff --git a/libweston/modepolicy/modepolicy_aml.cpp b/libweston/modepolicy/modepolicy_aml.cpp
index 9f71289..a01653a 100644
--- a/libweston/modepolicy/modepolicy_aml.cpp
+++ b/libweston/modepolicy/modepolicy_aml.cpp
@@ -284,6 +284,9 @@
conn->modes[i].vrefresh, conn->modes[i].name,
conn->modes[i].type, conn->modes[i].flags );
+ if (!strcmp(conn->modes[i].name, mode))
+ miBest = i;
+
if ( (conn->modes[i].hdisplay == width) &&
(conn->modes[i].vdisplay == height) ) {
bool modeIsInterlaced = (conn->modes[i].flags & DRM_MODE_FLAG_INTERLACE);
@@ -537,6 +540,11 @@
if (!ctx)
return 0;
+ if (!ctx->conn || ctx->conn->connector_type != DRM_MODE_CONNECTOR_HDMIA) {
+ MESON_LOGW("isn't hdmi, don't set property");
+ return 0;
+ }
+
initModePolicyFun(ctx->crtc, ctx->conn, callback);
if (value < 0 || id < 0)
return mode_policy_parse_other(ctx, name, value);
@@ -726,6 +734,16 @@
return false;
}
+static void mode_policy_add_mode(weston_ctx_list * ctx_list, bool mode_changed)
+{
+ weston_ctx *ctx, *tmp;
+
+ wl_list_for_each_safe(ctx, tmp, &ctx_list->ctx_list, link) {
+ if (ctx->mode_changed && mode_changed)
+ ctx->need_update_hdmi_param = true;
+ }
+}
+
int mode_policy_add_prop(drmModeAtomicReq *req, bool mode_changed)
{
prop_info *info;
@@ -734,6 +752,7 @@
weston_ctx_list * ctx_list = weston_get_ctx_list();
weston_ctx *ctx, *tmp;
+ mode_policy_add_mode(ctx_list, mode_changed);
wl_list_for_each_safe(ctx, tmp, &ctx_list->ctx_list, link) {
wl_list_for_each(info, &ctx->prop_list, link) {
if (info->need_change) {
@@ -859,7 +878,7 @@
while (!ctx_list->update_env_thread_stop_requested)
{
wl_list_for_each_safe(ctx, tmp, &ctx_list->ctx_list, link) {
- if ((ctx->mode_changed && !ctx->prop_changed) ||
+ if ((ctx->mode_changed && !ctx->prop_changed && ctx->need_update_hdmi_param) ||
(ctx->prop_changed && ctx->need_update_hdmi_param))
{
weston_log("%s[%d]\n", __func__, __LINE__);