Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backports from xf86-video-fbdev #59

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ fbturbo_drv_la_SOURCES = \
compat-api.h \
uthash.h \
arm_asm.S \
aarch64_asm.S \
cpuinfo.c \
cpuinfo.h \
cpu_backend.c \
Expand Down
98 changes: 98 additions & 0 deletions src/aarch64_asm.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* Copyright © 2016 Siarhei Siamashka <[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/

/* Prevent the stack from becoming executable */
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif

#ifdef __aarch64__

.cpu cortex-a53+fp+simd
.text
.align 2

/******************************************************************************/

.macro asm_function function_name
.global \function_name
#ifdef __ELF__
.hidden \function_name
.type \function_name, %function
#endif
.func \function_name
\function_name:
.endm

/******************************************************************************/

asm_function aligned_fetch_fbmem_to_scratch_neon
SIZE .req x0
DST .req x1
SRC .req x2

subs SIZE, SIZE, #128
blt 1f
0:
ldp q0, q1, [SRC, #(0 * 32)]
ldp q2, q3, [SRC, #(1 * 32)]
stp q0, q1, [DST, #(0 * 32)]
stp q2, q3, [DST, #(1 * 32)]
ldp q0, q1, [SRC, #(2 * 32)]
ldp q2, q3, [SRC, #(3 * 32)]
add SRC, SRC, #128
stp q0, q1, [DST, #(2 * 32)]
stp q2, q3, [DST, #(3 * 32)]
add DST, DST, #128
subs SIZE, SIZE, #128
bge 0b
1:
tst SIZE, #64
beq 1f
ldp q0, q1, [SRC, #(0 * 32)]
ldp q2, q3, [SRC, #(1 * 32)]
add SRC, SRC, #64
stp q0, q1, [DST, #(0 * 32)]
stp q2, q3, [DST, #(1 * 32)]
add DST, DST, #64
1:
tst SIZE, #32
beq 1f
ldp q0, q1, [SRC, #(0 * 32)]
add SRC, SRC, #32
stp q0, q1, [DST, #(0 * 32)]
add DST, DST, #32
1:
tst SIZE, #31
beq 1f
ldp q0, q1, [SRC]
stp q0, q1, [DST]
1:
ret

.unreq SIZE
.unreq DST
.unreq SRC
.endfunc

#endif
24 changes: 23 additions & 1 deletion src/cpu_backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "cpuinfo.h"
#include "cpu_backend.h"

#ifdef __arm__
#if defined(__arm__) || defined(__aarch64__)

#ifdef __GNUC__
#define always_inline inline __attribute__((always_inline))
Expand All @@ -47,6 +47,16 @@ writeback_scratch_to_mem_arm(int size, void *dst, const void *src)
memcpy_armv5te(dst, src, size);
}

#ifdef __aarch64__
static always_inline void
writeback_scratch_to_mem_memcpy(int size, void *dst, const void *src)
{
memcpy(dst, src, size);
}

#define writeback_scratch_to_mem_neon writeback_scratch_to_mem_memcpy
#endif

#define SCRATCHSIZE 2048

/*
Expand Down Expand Up @@ -114,6 +124,8 @@ twopass_memmove_neon(void *dst, const void *src, size_t size)
writeback_scratch_to_mem_neon);
}

#ifdef __arm__

static void
twopass_memmove_vfp(void *dst, const void *src, size_t size)
{
Expand All @@ -130,6 +142,8 @@ twopass_memmove_arm(void *dst, const void *src, size_t size)
writeback_scratch_to_mem_arm);
}

#endif

static void
twopass_blt_8bpp(int width,
int height,
Expand Down Expand Up @@ -226,6 +240,8 @@ overlapped_blt_neon(void *self,
twopass_memmove_neon);
}

#ifdef __arm__

static int
overlapped_blt_vfp(void *self,
uint32_t *src_bits,
Expand Down Expand Up @@ -270,6 +286,8 @@ overlapped_blt_arm(void *self,

#endif

#endif

/* An empty, always failing implementation */
static int
overlapped_blt_noop(void *self,
Expand Down Expand Up @@ -322,6 +340,10 @@ cpu_backend_t *cpu_backend_init(uint8_t *uncached_buffer,
}
#endif

#ifdef __aarch64__
ctx->blt2d.overlapped_blt = overlapped_blt_neon;
#endif

return ctx;
}

Expand Down
14 changes: 10 additions & 4 deletions src/cpuinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,10 @@ static int parse_proc_cpuinfo(cpuinfo_t *cpuinfo)
}
if ((val = cpuinfo_match_prefix(buffer, "Features"))) {
cpuinfo->has_arm_edsp = find_feature(val, "edsp");
cpuinfo->has_arm_vfp = find_feature(val, "vfp");
cpuinfo->has_arm_neon = find_feature(val, "neon");
cpuinfo->has_arm_vfp = find_feature(val, "vfp") ||
find_feature(val, "fp");
cpuinfo->has_arm_neon = find_feature(val, "neon") ||
find_feature(val, "asimd");
cpuinfo->has_arm_wmmx = find_feature(val, "iwmmxt");
}
else if ((val = cpuinfo_match_prefix(buffer, "CPU implementer"))) {
Expand All @@ -105,7 +107,9 @@ static int parse_proc_cpuinfo(cpuinfo_t *cpuinfo)
}
}
else if ((val = cpuinfo_match_prefix(buffer, "CPU architecture"))) {
if (sscanf(val, "%i", &cpuinfo->arm_architecture) != 1) {
if (strncmp(val, "AArch64", 7) == 0) {
cpuinfo->arm_architecture = 8;
} else if (sscanf(val, "%i", &cpuinfo->arm_architecture) != 1) {
fclose(fd);
free(buffer);
return 0;
Expand Down Expand Up @@ -158,7 +162,9 @@ cpuinfo_t *cpuinfo_init()
return cpuinfo;
}

if (cpuinfo->arm_implementer == 0x41 && cpuinfo->arm_part == 0xC0F) {
if (cpuinfo->arm_implementer == 0x41 && cpuinfo->arm_part == 0xD03) {
cpuinfo->processor_name = strdup("ARM Cortex-A53");
} else if (cpuinfo->arm_implementer == 0x41 && cpuinfo->arm_part == 0xC0F) {
cpuinfo->processor_name = strdup("ARM Cortex-A15");
} else if (cpuinfo->arm_implementer == 0x41 && cpuinfo->arm_part == 0xC09) {
if (cpuinfo->has_arm_neon)
Expand Down
120 changes: 116 additions & 4 deletions src/fbdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@
#include <pciaccess.h>
#endif

#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) > 23
#define HAVE_SHADOW_3224
#endif

static Bool debug = 0;

#define TRACE_ENTER(str) \
Expand Down Expand Up @@ -269,6 +273,35 @@ FBDevIdentify(int flags)
xf86PrintChipsets(FBDEV_NAME, "driver for framebuffer", FBDevChipsets);
}

static Bool
fbdevSwitchMode(ScrnInfoPtr pScrn, DisplayModePtr mode)
{
return fbdevHWSwitchMode(pScrn, mode);
}

static void
fbdevAdjustFrame(ScrnInfoPtr pScrn, int x, int y)
{
fbdevHWAdjustFrame(pScrn, x, y);
}

static Bool
fbdevEnterVT(ScrnInfoPtr pScrn)
{
return fbdevHWEnterVT(pScrn);
}

static void
fbdevLeaveVT(ScrnInfoPtr pScrn)
{
fbdevHWLeaveVT(pScrn);
}

static ModeStatus
fbdevValidMode(ScrnInfoPtr pScrn, DisplayModePtr mode, Bool verbose, int flags)
{
return fbdevHWValidMode(pScrn, mode, verbose, flags);
}

#ifdef XSERVER_LIBPCIACCESS
static Bool FBDevPciProbe(DriverPtr drv, int entity_num,
Expand Down Expand Up @@ -467,6 +500,40 @@ FBDevPreInit(ScrnInfoPtr pScrn, int flags)
if (!fbdevHWInit(pScrn,NULL,xf86FindOptionValue(fPtr->pEnt->device->options,"fbdev")))
return FALSE;
default_depth = fbdevHWGetDepth(pScrn,&fbbpp);
#if 0 /* TODO: Not sure if merging this too */
+
+ if (default_depth == 8) do {
+ /* trust the command line */
+ if (xf86FbBpp > 0 || xf86Depth > 0)
+ break;
+
+ /* trust the config file's Screen stanza */
+ if (pScrn->confScreen->defaultfbbpp > 0 ||
+ pScrn->confScreen->defaultdepth > 0)
+ break;
+
+ /* trust our Device stanza in the config file */
+ if (xf86FindOption(fPtr->pEnt->device->options, "DefaultDepth") ||
+ xf86FindOption(fPtr->pEnt->device->options, "DefaultFbBpp"))
+ break;
+
+ /* otherwise, lol no */
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Console is 8bpp, defaulting to 32bpp\n");
+ default_depth = 24;
+ fbbpp = 32;
+ } while (0);
+
+ fPtr->shadow24 = FALSE;
+#ifdef HAVE_SHADOW_3224
+ /* okay but 24bpp is awful */
+ if (fbbpp == 24) {
+ fPtr->shadow24 = TRUE;
+ fbbpp = 32;
+ }
+#endif
+
#endif
if (!xf86SetDepthBpp(pScrn, default_depth, default_depth, fbbpp,
Support24bppFb | Support32bppFb | SupportConvert32to24 | SupportConvert24to32))
return FALSE;
Expand Down Expand Up @@ -656,6 +723,25 @@ FBDevPreInit(ScrnInfoPtr pScrn, int flags)
return TRUE;
}

static void
fbdevUpdate32to24(ScreenPtr pScreen, shadowBufPtr pBuf)
{
#ifdef HAVE_SHADOW_3224
shadowUpdate32to24(pScreen, pBuf);
#endif
}

static void
fbdevUpdateRotatePacked(ScreenPtr pScreen, shadowBufPtr pBuf)
{
shadowUpdateRotatePacked(pScreen, pBuf);
}

static void
fbdevUpdatePacked(ScreenPtr pScreen, shadowBufPtr pBuf)
{
shadowUpdatePacked(pScreen, pBuf);
}

static Bool
FBDevCreateScreenResources(ScreenPtr pScreen)
Expand All @@ -664,6 +750,7 @@ FBDevCreateScreenResources(ScreenPtr pScreen)
ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
FBDevPtr fPtr = FBDEVPTR(pScrn);
Bool ret;
void (*update)(ScreenPtr, shadowBufPtr);

pScreen->CreateScreenResources = fPtr->CreateScreenResources;
ret = pScreen->CreateScreenResources(pScreen);
Expand All @@ -674,9 +761,15 @@ FBDevCreateScreenResources(ScreenPtr pScreen)

pPixmap = pScreen->GetScreenPixmap(pScreen);

if (!shadowAdd(pScreen, pPixmap, fPtr->rotate ?
shadowUpdateRotatePackedWeak() : shadowUpdatePackedWeak(),
FBDevWindowLinear, fPtr->rotate, NULL)) {
if (fPtr->shadow24)
update = fbdevUpdate32to24;
else if (fPtr->rotate)
update = fbdevUpdateRotatePacked;
else
update = fbdevUpdatePacked;

if (!shadowAdd(pScreen, pPixmap, update,
FBDevWindowLinear, fPtr->rotate, NULL)) {
return FALSE;
}

Expand All @@ -699,6 +792,23 @@ FBDevShadowInit(ScreenPtr pScreen)
return TRUE;
}

static void
fbdevLoadPalette(ScrnInfoPtr pScrn, int num, int *i, LOCO *col, VisualPtr pVis)
{
fbdevHWLoadPalette(pScrn, num, i, col, pVis);
}

static void
fbdevDPMSSet(ScrnInfoPtr pScrn, int mode, int flags)
{
fbdevHWDPMSSet(pScrn, mode, flags);
}

static Bool
fbdevSaveScreen(ScreenPtr pScreen, int mode)
{
return fbdevHWSaveScreen(pScreen, mode);
}

static Bool
FBDevScreenInit(SCREEN_INIT_ARGS_DECL)
Expand Down Expand Up @@ -884,7 +994,7 @@ FBDevScreenInit(SCREEN_INIT_ARGS_DECL)
*/
useBackingStore = xf86ReturnOptValBool(fPtr->Options, OPTION_USE_BS,
!fPtr->shadowFB);
#ifndef __arm__
#if !(defined(__arm__) || defined(__aarch64__))
/*
* right now we can only make "smart" decisions on ARM hardware,
* everything else (for example x86) would take a performance hit
Expand Down Expand Up @@ -979,7 +1089,9 @@ FBDevScreenInit(SCREEN_INIT_ARGS_DECL)
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "display rotated; disabling DGA\n");
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "using driver rotation; disabling "
"XRandR\n");
#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 24
xf86DisableRandR();
#endif
if (pScrn->bitsPerPixel == 24)
xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "rotation might be broken at 24 "
"bits per pixel\n");
Expand Down
Loading