From cec964c1cb534fe33e5e435a767a2e0ce847f930 Mon Sep 17 00:00:00 2001 From: yuan0927 Date: Fri, 24 May 2024 10:15:17 +0800 Subject: [PATCH] modesetting: add support for phytium S5000C BMC ANBZ: #8989 This patch has been fixed to address the issue of screen distortion in the Phytium S5000C, and it works in conjunction with the patch integrated into the kernel. Signed-off-by: yuan0927 Signed-off-by: WangHao --- ...-patch-for-ast-ft-bmc-card-in-s5000c.patch | 203 ++++++++++++++++++ xorg-x11-server.spec | 6 +- 2 files changed, 208 insertions(+), 1 deletion(-) create mode 100644 0100-xorg-patch-for-ast-ft-bmc-card-in-s5000c.patch diff --git a/0100-xorg-patch-for-ast-ft-bmc-card-in-s5000c.patch b/0100-xorg-patch-for-ast-ft-bmc-card-in-s5000c.patch new file mode 100644 index 0000000..5cc93a0 --- /dev/null +++ b/0100-xorg-patch-for-ast-ft-bmc-card-in-s5000c.patch @@ -0,0 +1,203 @@ +From 2acef96c033f1f67b65c2bd042f6f93c861a197c Mon Sep 17 00:00:00 2001 +From: wanghao +Date: Fri, 24 May 2024 18:37:36 +0800 +Subject: [PATCH] xorg patch for ast&ft bmc card in s5000c + +Signed-off-by: yuan0927 +Signed-off-by: wanghao +--- + hw/xfree86/drivers/modesetting/driver.c | 165 +++++++++++++++++++++++- + 1 file changed, 164 insertions(+), 1 deletion(-) + +diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c +index b3e913a..44f72b8 100644 +--- a/hw/xfree86/drivers/modesetting/driver.c ++++ b/hw/xfree86/drivers/modesetting/driver.c +@@ -1156,12 +1156,171 @@ msUpdateIntersect(modesettingPtr ms, shadowBufPtr pBuf, BoxPtr box, + return dirty; + } + ++static void align_memcpy(void *dest, void *source, size_t size) ++{ ++ char *dst1, *dst2, *p, *src, *dst; ++ ++ src = (char *)source; ++ dst = (char *)dest; ++ ++ dst1 = (char *)(((unsigned long)dst + 0xf) & ~0xf); ++ dst2 = (char *)(((unsigned long)dst + size) & ~0xf); ++ p = dst; ++ ++ while((p< dst1) && size){ ++ *p++ = *src++; ++ size--; ++ }; ++ ++ memcpy(dst1, (char *)src, (size & (~0xf))); ++ ++ src += (size & (~0xf)); ++ size = (size & 0xf); ++ ++ p = dst2; ++ while(size--){ ++ *p++ = *src++; ++ }; ++} ++ ++#define AST_BMC_VENDOR_ID 0x1a03 ++#define FT_BMC_VENDOR_ID 0x1db7 ++#define FT_BMC_DEVICE_ID 0xdc3e ++#define DRM_AST_VRAM_TYPE_DEVICE 0x0 ++#define DRM_IOCTL_AST_VRAM_TYPE_DEVICE DRM_IO(DRM_COMMAND_BASE + DRM_AST_VRAM_TYPE_DEVICE) ++#define DRM_PHYTIUM_VRAM_TYPE_DEVICE 0x0 ++#define DRM_IOCTL_PHYTIUM_VRAM_TYPE_DEVICE DRM_IO(DRM_COMMAND_BASE + DRM_PHYTIUM_VRAM_TYPE_DEVICE) ++ ++static Bool device_is_ast_bmc(struct pci_device *pci) ++{ ++ if (pci->vendor_id == AST_BMC_VENDOR_ID) { ++ return TRUE; ++ } ++ ++ return FALSE; ++} ++ ++static Bool device_is_ft_bmc(struct pci_device *pci) ++{ ++ if (pci->vendor_id == FT_BMC_VENDOR_ID && pci->device_id == FT_BMC_DEVICE_ID) { ++ return TRUE; ++ } ++ ++ return FALSE; ++} ++ ++static void ++msshadowUpdatePacked(ScreenPtr pScreen, shadowBufPtr pBuf) ++{ ++ RegionPtr damage = DamageRegion(pBuf->pDamage); ++ PixmapPtr pShadow = pBuf->pPixmap; ++ int nbox = RegionNumRects(damage); ++ BoxPtr pbox = RegionRects(damage); ++ FbBits *shaBase, *shaLine, *sha; ++ FbStride shaStride; ++ int scrBase, scrLine, scr; ++ int shaBpp; ++ _X_UNUSED int shaXoff, shaYoff; ++ int x, y, w, h, width; ++ int i; ++ FbBits *winBase = NULL, *win; ++ CARD32 winSize; ++ static Bool firstQuery_ast = TRUE; ++ static Bool firstQuery_ft = TRUE; ++ static Bool forceAlign = FALSE; ++ ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); ++ modesettingPtr ms = modesettingPTR(pScrn); ++ ++ if (firstQuery_ast) { ++ if (1 == drmIoctl(ms->fd, DRM_IOCTL_AST_VRAM_TYPE_DEVICE, NULL)) { ++ forceAlign = TRUE; ++ } ++ firstQuery_ast = FALSE; ++ } ++ ++ if (firstQuery_ft) { ++ if (1 == drmIoctl(ms->fd, DRM_IOCTL_PHYTIUM_VRAM_TYPE_DEVICE, NULL)) { ++ forceAlign = TRUE; ++ } ++ firstQuery_ft = FALSE; ++ } ++ ++ fbGetDrawable(&pShadow->drawable, shaBase, shaStride, shaBpp, shaXoff, ++ shaYoff); ++ while (nbox--) { ++ x = pbox->x1 * shaBpp; ++ y = pbox->y1; ++ w = (pbox->x2 - pbox->x1) * shaBpp; ++ h = pbox->y2 - pbox->y1; ++ ++ scrLine = (x >> FB_SHIFT); ++ shaLine = shaBase + y * shaStride + (x >> FB_SHIFT); ++ ++ x &= FB_MASK; ++ w = (w + x + FB_MASK) >> FB_SHIFT; ++ ++ while (h--) { ++ winSize = 0; ++ scrBase = 0; ++ width = w; ++ scr = scrLine; ++ sha = shaLine; ++ while (width) { ++ /* how much remains in this window */ ++ i = scrBase + winSize - scr; ++ if (i <= 0 || scr < scrBase) { ++ winBase = (FbBits *) (*pBuf->window) (pScreen, ++ y, ++ scr * sizeof(FbBits), ++ SHADOW_WINDOW_WRITE, ++ &winSize, ++ pBuf->closure); ++ if (!winBase) ++ return; ++ scrBase = scr; ++ winSize /= sizeof(FbBits); ++ i = winSize; ++ } ++ win = winBase + (scr - scrBase); ++ if (i > width) ++ i = width; ++ width -= i; ++ scr += i; ++ if (forceAlign) { ++ align_memcpy(win, sha, i * sizeof(FbBits)); ++ } else { ++ memcpy(win, sha, i * sizeof(FbBits)); ++ } ++ sha += i; ++ } ++ shaLine += shaStride; ++ y++; ++ } ++ pbox++; ++ } ++} ++ + static void + msUpdatePacked(ScreenPtr pScreen, shadowBufPtr pBuf) + { + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); + modesettingPtr ms = modesettingPTR(pScrn); + Bool use_3224 = ms->drmmode.force_24_32 && pScrn->bitsPerPixel == 32; ++ Bool isAstBMC = FALSE; ++ Bool isFtBMC = FALSE; ++ struct pci_device *pci = NULL; ++ ++ if (BUS_PLATFORM == ms->pEnt->location.type) { ++ pci = ms->pEnt->location.id.plat->pdev; ++ } else if (BUS_PCI == ms->pEnt->location.type) { ++ pci = ms->pEnt->location.id.pci; ++ } ++ ++ if (pci && device_is_ast_bmc(pci)) { ++ isAstBMC = TRUE; ++ } else if (pci && device_is_ft_bmc(pci)) { ++ isFtBMC = TRUE; ++ } + + if (ms->drmmode.shadow_enable2 && ms->drmmode.shadow_fb2) do { + RegionPtr damage = DamageRegion(pBuf->pDamage), tiles; +@@ -1206,7 +1365,11 @@ msUpdatePacked(ScreenPtr pScreen, shadowBufPtr pBuf) + if (use_3224) + ms->shadow.Update32to24(pScreen, pBuf); + else +- ms->shadow.UpdatePacked(pScreen, pBuf); ++ if(isAstBMC || isFtBMC) { ++ msshadowUpdatePacked(pScreen, pBuf); ++ } else { ++ ms->shadow.UpdatePacked(pScreen, pBuf); ++ } + } + + static Bool +-- +2.25.1 + diff --git a/xorg-x11-server.spec b/xorg-x11-server.spec index 6736217..5ee153f 100644 --- a/xorg-x11-server.spec +++ b/xorg-x11-server.spec @@ -1,4 +1,4 @@ -%define anolis_release 13 +%define anolis_release 14 %undefine _hardened_build %undefine _strict_symbol_defs_build %global ansic_major 0 @@ -80,6 +80,7 @@ Patch1012: 1012-Fix-drm_drop_master-before-vt_reldisp.patch Patch1013: 1013-Fix-compilation-error-when-built-without-logind_platform-bus.patch Patch1014: 1014-fix-missing-call-to-vtenter-if-the-platform-device-is-not-paused.patch Patch1015: 1015-x86_logind-fix-suspend_resume-when-there-are-no-input-devices.patch +Patch1016: 0100-xorg-patch-for-ast-ft-bmc-card-in-s5000c.patch BuildRequires: automake make autoconf libtool pkgconfig BuildRequires: dbus-devel libepoxy-devel libudev-devel systemd-devel systemtap-sdt-devel @@ -394,6 +395,9 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/xorg/modules/lib{int10,vbe}.so %{_datadir}/xorg-x11-server-source %changelog +* Fri May 24 2024 yuan0927 - 1:1.20.14-14 +- Fix the splash screen issue in the phytium S5000C + * Wed Dec 6 2023 Wenlong Zhang - 1:1.20.14-13 - delete libunwind for loongarch64 -- Gitee