7 Star 0 Fork 4

src-openEuler/libxcvt

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0001-Fix-hsync_start-computation.patch 2.35 KB
一键复制 编辑 原始数据 按行查看 历史
From 26164df08976b31ea7d28dfbe3c2e18e67bcac87 Mon Sep 17 00:00:00 2001
From: nyanpasu64 <nyanpasu64@tuta.io>
Date: Sat, 22 Apr 2023 02:48:06 -0700
Subject: [PATCH 1/2] Fix hsync_start computation
The CVT v1.2 specification says, in section 3.4.1 "Standard CRT-based
Timing":
> The Horizontal Sync Pulse duration will in all cases be set as closely
> as possible to 8% of the Total Horizontal time, rounded down to the
> nearest cell width.
The previous code achieved this by first setting mode_info->hsync_end to
a multiple of the cell width, then calculating mode_info->hsync_start
and rounding its position up to a cell width. However, if
mode_info->hsync_start was already a multiple of 8 (for example on
640x480@60), the rounding code would erroneously add 8 to it, shortening
the hsync duration by 8 pixels.
This commit fixes the bug by calculating and rounding the sync width
separately, closer to the specification's wording.
Signed-off-by: nyanpasu64 <nyanpasu64@tuta.io>
Closes: https://gitlab.freedesktop.org/xorg/lib/libxcvt/-/issues/6
Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
---
lib/libxcvt.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/lib/libxcvt.c b/lib/libxcvt.c
index 51a61e7..8d0eb53 100644
--- a/lib/libxcvt.c
+++ b/lib/libxcvt.c
@@ -161,7 +161,7 @@ libxcvt_gen_mode_info(int hdisplay, int vdisplay, float vrefresh, bool reduced,
float hblank_percentage;
int vsync_and_back_porch, vback_porch;
- int hblank;
+ int hblank, hsync_w;
/* 8. Estimated Horizontal period */
hperiod = ((float) (1000000.0 / vfield_rate - CVT_MIN_VSYNC_BP)) /
@@ -216,10 +216,9 @@ libxcvt_gen_mode_info(int hdisplay, int vdisplay, float vrefresh, bool reduced,
/* Fill in HSync values */
mode_info->hsync_end = mode_info->hdisplay + hblank / 2;
- mode_info->hsync_start = mode_info->hsync_end -
- (mode_info->htotal * CVT_HSYNC_PERCENTAGE) / 100;
- mode_info->hsync_start += CVT_H_GRANULARITY -
- mode_info->hsync_start % CVT_H_GRANULARITY;
+ hsync_w = (mode_info->htotal * CVT_HSYNC_PERCENTAGE) / 100;
+ hsync_w -= hsync_w % CVT_H_GRANULARITY;
+ mode_info->hsync_start = mode_info->hsync_end - hsync_w;
/* Fill in vsync values */
mode_info->vsync_start = mode_info->vdisplay + CVT_MIN_V_PORCH;
--
2.20.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/libxcvt.git
git@gitee.com:src-openeuler/libxcvt.git
src-openeuler
libxcvt
libxcvt
master

搜索帮助