weston: add interlace mode support [1/1]
PD#SWPL-179990
Problem:
add interlace mode support
Solution:
add interlace mode support
Verify:
ah212
Change-Id: I449a9758f5a4c6e52b39fa78c10adc4d4f4d78eb
Signed-off-by: leng.fang <leng.fang@amlogic.com>
diff --git a/aml-weston/aml-backend.c b/aml-weston/aml-backend.c
index 0560dd2..806f48f 100644
--- a/aml-weston/aml-backend.c
+++ b/aml-weston/aml-backend.c
@@ -1338,3 +1338,32 @@
}
return ret;
}
+
+int drm_parse_modeline(const char *modeline,
+ int *width, int *height, uint32_t *refresh,
+ uint32_t *aspect_width, uint32_t *aspect_height,
+ uint32_t *flags)
+{
+ char height_str[32] = { 0 };
+ char others[32] = { 0 };
+ int w = 0;
+ int h = 0;
+ int rate = 0;
+ int n;
+
+ n = sscanf(modeline, "%dx%[^@]@%d %u:%u", &w, height_str, &rate,
+ aspect_width, aspect_height);
+ if ( n > 2) {
+ if (sscanf(height_str, "%d%s", &h, others) == 2) {
+ if (strstr(others, "i"))
+ *flags |= DRM_MODE_FLAG_INTERLACE;
+ if (strstr(others, "d"))
+ *flags |= DRM_MODE_FLAG_DBLSCAN;
+ }
+ }
+ *width = w;
+ *height = h;
+ *refresh = rate;
+
+ return n;
+}
diff --git a/aml-weston/aml-backend.h b/aml-weston/aml-backend.h
index 56f0f0b..376fac3 100644
--- a/aml-weston/aml-backend.h
+++ b/aml-weston/aml-backend.h
@@ -73,5 +73,9 @@
struct drm_plane *plane,
const char *p_name);
bool is_direct_display(struct weston_buffer* buffer);
+int drm_parse_modeline(const char *modeline,
+ int *width, int *height, uint32_t *refresh,
+ uint32_t *aspect_width, uint32_t *aspect_height,
+ uint32_t *flags);
#endif
diff --git a/libweston/backend-drm/modes.c b/libweston/backend-drm/modes.c
index e984e4c..acaf58f 100644
--- a/libweston/backend-drm/modes.c
+++ b/libweston/backend-drm/modes.c
@@ -589,14 +589,15 @@
int32_t width = 0;
int32_t height = 0;
uint32_t refresh = 0;
+ uint32_t flags = 0;
uint32_t aspect_width = 0;
uint32_t aspect_height = 0;
enum weston_mode_aspect_ratio aspect_ratio = WESTON_MODE_PIC_AR_NONE;
int n;
if (mode == WESTON_DRM_BACKEND_OUTPUT_PREFERRED && modeline) {
- n = sscanf(modeline, "%dx%d@%d %u:%u", &width, &height,
- &refresh, &aspect_width, &aspect_height);
+ n = drm_parse_modeline(modeline, &width, &height, &refresh,
+ &aspect_width, &aspect_height, &flags);
if (backend->aspect_ratio_supported && n == 5) {
if (aspect_width == 4 && aspect_height == 3)
aspect_ratio = WESTON_MODE_PIC_AR_4_3;
@@ -627,7 +628,8 @@
wl_list_for_each_reverse(drm_mode, &output->base.mode_list, base.link) {
if (width == drm_mode->base.width &&
height == drm_mode->base.height &&
- (refresh == 0 || refresh == drm_mode->mode_info.vrefresh)) {
+ (refresh == 0 || refresh == drm_mode->mode_info.vrefresh) &&
+ (drm_mode->mode_info.flags & DRM_MODE_FLAG_INTERLACE) == (flags & DRM_MODE_FLAG_INTERLACE)) {
if (!backend->aspect_ratio_supported ||
aspect_ratio == drm_mode->base.aspect_ratio)
configured = drm_mode;
@@ -830,8 +832,9 @@
mode_policy_set_head(&head->base);
wstmode = mode_policy_choose_mode(NULL);
if (wstmode)
- sprintf(wstmodeline, "%dx%d@%d %u:%u",
+ sprintf(wstmodeline, "%dx%d%s@%d %u:%u",
wstmode->width, wstmode->height,
+ wstmode->flags & DRM_MODE_FLAG_INTERLACE ? "i" : "",
wstmode->refresh / 1000, 0, 0);
#endif