From 6c4f875abc1027be7cfecfa87336a29df45e72d2 Mon Sep 17 00:00:00 2001 From: yuan0927 Date: Tue, 21 May 2024 10:08:47 +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 --- 0100-phytium-xorg-x11-server-bmc.patch | 192 +++++++++++++++++++++++++ xorg-x11-server.spec | 6 +- 2 files changed, 197 insertions(+), 1 deletion(-) create mode 100644 0100-phytium-xorg-x11-server-bmc.patch diff --git a/0100-phytium-xorg-x11-server-bmc.patch b/0100-phytium-xorg-x11-server-bmc.patch new file mode 100644 index 0000000..a4e03d0 --- /dev/null +++ b/0100-phytium-xorg-x11-server-bmc.patch @@ -0,0 +1,192 @@ +From 2a96fbdc5b15c1d430151cf5bb4390b97993772f Mon Sep 17 00:00:00 2001 +From: yuan0927 +Date: Tue, 21 May 2024 09:40:12 +0800 +Subject: [PATCH 2/2] modesetting: add support for phytium S5000C BMC + +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 +--- + hw/xfree86/drivers/modesetting/driver.c | 158 +++++++++++++++++++++++- + 1 file changed, 157 insertions(+), 1 deletion(-) + +diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c +index ef4a314..f9555e4 100644 +--- a/hw/xfree86/drivers/modesetting/driver.c ++++ b/hw/xfree86/drivers/modesetting/driver.c +@@ -1143,6 +1143,162 @@ 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 = TRUE; ++ static Bool forceAlign = FALSE; ++ Bool isAstBMC = FALSE; ++ Bool isFtBMC = FALSE; ++ ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); ++ modesettingPtr ms = modesettingPTR(pScrn); ++ 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; ++ if (firstQuery) { ++ if (1 == drmIoctl(ms->fd, DRM_IOCTL_AST_VRAM_TYPE_DEVICE, NULL)) { ++ forceAlign = TRUE; ++ } ++ firstQuery = FALSE; ++ } ++ } else if (pci && device_is_ft_bmc(pci)) { ++ isFtBMC = TRUE; ++ if (firstQuery) { ++ if (1 == drmIoctl(ms->fd, DRM_IOCTL_PHYTIUM_VRAM_TYPE_DEVICE, NULL)) { ++ forceAlign = TRUE; ++ } ++ firstQuery = 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 ((isFtBMC || isAstBMC) && 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) + { +@@ -1193,7 +1349,7 @@ msUpdatePacked(ScreenPtr pScreen, shadowBufPtr pBuf) + if (use_3224) + shadowUpdate32to24(pScreen, pBuf); + else +- shadowUpdatePacked(pScreen, pBuf); ++ msshadowUpdatePacked(pScreen, pBuf); + } + + static Bool +-- +2.39.3 + diff --git a/xorg-x11-server.spec b/xorg-x11-server.spec index a42bf4c..26f4e18 100644 --- a/xorg-x11-server.spec +++ b/xorg-x11-server.spec @@ -47,7 +47,7 @@ Summary: X.Org X11 X server Name: xorg-x11-server Version: 1.20.11 -Release: 16%{?gitdate:.%{gitdate}}%{anolis_release}%{?dist} +Release: 17%{?gitdate:.%{gitdate}}%{anolis_release}%{?dist} URL: http://www.x.org License: MIT Group: User Interface/X @@ -103,6 +103,7 @@ Patch18: 0001-mustard-Work-around-broken-fbdev-headers.patch # fix to be upstreamed Patch100: 0001-linux-Make-platform-device-probe-less-fragile.patch Patch102: 0001-xfree86-ensure-the-readlink-buffer-is-null-terminate.patch +Patch103: 0100-phytium-xorg-x11-server-bmc.patch # fix already upstream Patch200: 0001-Fix-segfault-on-probing-a-non-PCI-platform-device-on.patch @@ -613,6 +614,9 @@ find %{inst_srcdir}/hw/xfree86 -name \*.c -delete %changelog +* Thu May 23 2024 yuan0927 - 1.20.11-16.0.4 +- Fix the splash screen issue in the phytium S5000C + * Thu Mar 21 2024 Weisson - 1.20.11-16.0.3 - cherry-pick: `add sw arch #3b1aa1ee2c00aeebe71a618589826c2d1cab136e`. -- Gitee