Skip to contentSkip to conversation

Define per x-screen individual drmmode_crtc_funcs

PATCH In review Michel Dänzer 2 participants 5 messages Feb 13, 2018 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 Define per x-screen individual drmmode_crtc_funcs

From: Mario Kleiner <[email protected]>

This allows to en-/disable some functions depending on individual screen settings.

Prep work for more efficient depth 30 support.

(Ported from radeon commit 21f6753462464acfd3c452393328c977a375ce26)

---
 src/amdgpu_drv.h      |  1 +
 src/drmmode_display.c | 14 ++++++++++----
 2 files changed, 11 insertions(+), 4 deletions(-)
src/amdgpu_drv.h +1 -0
index f60b192da..40157262e 100644
@@ -340,6 +340,7 @@ typedef struct {
 		SetSharedPixmapBackingProcPtr SavedSetSharedPixmapBacking;
 	} glamor;
 
+	xf86CrtcFuncsRec drmmode_crtc_funcs;
 } AMDGPUInfoRec, *AMDGPUInfoPtr;
 
 
src/drmmode_display.c +10 -4
index 047179449..be3deef20 100644
@@ -1344,8 +1344,9 @@ drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_res
 	xf86CrtcPtr crtc;
 	drmmode_crtc_private_ptr drmmode_crtc;
 	AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(pScrn);
+	AMDGPUInfoPtr info = AMDGPUPTR(pScrn);
 
-	crtc = xf86CrtcCreate(pScrn, &drmmode_crtc_funcs);
+	crtc = xf86CrtcCreate(pScrn, &info->drmmode_crtc_funcs);
 	if (crtc == NULL)
 		return 0;
 
@@ -2348,11 +2349,16 @@ Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp)
 	xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, AMDGPU_LOGLEVEL_DEBUG,
 		       "%d crtcs needed for screen.\n", crtcs_needed);
 
+	/* Need per-screen drmmode_crtc_funcs, based on our global template,
+	 * so we can disable some functions, depending on screen settings.
+	 */
+	info->drmmode_crtc_funcs = drmmode_crtc_funcs;
+
 	if (!info->use_glamor) {
 		/* Rotation requires hardware acceleration */
-		drmmode_crtc_funcs.shadow_allocate = NULL;
-		drmmode_crtc_funcs.shadow_create = NULL;
-		drmmode_crtc_funcs.shadow_destroy = NULL;
+		info->drmmode_crtc_funcs.shadow_allocate = NULL;
+		info->drmmode_crtc_funcs.shadow_create = NULL;
+		info->drmmode_crtc_funcs.shadow_destroy = NULL;
 	}
 
 	for (i = 0; i < mode_res->count_crtcs; i++)
Signature · 6 lines
2.16.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20180213175339.10310-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org

#2 lore raw

PATCH 2/4 Disable gamma set when deep color

From: Qiang Yu <[email protected]>

gamma set is disabled in kernel driver when deep color. Enable it will confuse the user.

[ Michel Dänzer: Align drmmode_pre_init change with radeon commit
1f1d4b1fa7d4b22dd8553f7e71251bf17ca7a7b1 ]

---
 src/drmmode_display.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
src/drmmode_display.c +14 -4
index be3deef20..e52b7a355 100644
@@ -858,8 +858,11 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
 		if (drmmode_crtc->tear_free)
 			scanout_id = drmmode_crtc->scanout_id;
 
-		drmmode_crtc_gamma_do_set(crtc, crtc->gamma_red, crtc->gamma_green,
-					  crtc->gamma_blue, crtc->gamma_size);
+		/* gamma is disabled in kernel driver for deep color */
+		if (pScrn->depth != 30)
+			drmmode_crtc_gamma_do_set(
+				crtc, crtc->gamma_red, crtc->gamma_green,
+				crtc->gamma_blue, crtc->gamma_size);
 
 		if (drmmode_crtc->prime_scanout_pixmap) {
 			drmmode_crtc_prime_scanout_update(crtc, mode, scanout_id,
@@ -2361,6 +2364,12 @@ Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp)
 		info->drmmode_crtc_funcs.shadow_destroy = NULL;
 	}
 
+	/* Hw gamma lut's are currently bypassed by the hw at color depth 30,
+	 * so spare the server the effort to compute and update the cluts.
+	 */
+	if (pScrn->depth == 30)
+		info->drmmode_crtc_funcs.gamma_set = NULL;
+
 	for (i = 0; i < mode_res->count_crtcs; i++)
 		if (!xf86IsEntityShared(pScrn->entityList[0]) ||
 		    (crtcs_needed && !(pAMDGPUEnt->assigned_crtcs & (1 << i))))
@@ -2591,8 +2600,9 @@ Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn)
 			       "Initializing kms color map\n");
 		if (!miCreateDefColormap(pScreen))
 			return FALSE;
-		/* all amdgpus support 10 bit CLUTs */
-		if (!xf86HandleColormaps(pScreen, 256, 10,
+		/* All radeons support 10 bit CLUTs. They get bypassed at depth 30. */
+		if (pScrn->depth != 30 &&
+		    !xf86HandleColormaps(pScreen, 256, 10,
 					 NULL, NULL,
 					 CMAP_PALETTED_TRUECOLOR
 #if 0				/* This option messes up text mode! ([email protected]) */
Signature · 6 lines
2.16.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#3 lore raw

PATCH 3/4 Add 30bit RGB color format support

In reply to a message not in the archive

From: Hawking Zhang <[email protected]>

[ Michel Dänzer:
* Require Xorg >= 1.19.99.1 for depth 30, otherwise it can't work with glamor
* Update manpage, per radeon commit 574bfab4bf1fcd95163a8f33cea2889189429d30 ]

---
 man/amdgpu.man         | 2 +-
 src/amdgpu_bo_helper.c | 2 ++
 src/amdgpu_dri2.c      | 1 +
 src/amdgpu_kms.c       | 8 ++++++++
 4 files changed, 12 insertions(+), 1 deletion(-)
man/amdgpu.man +1 -1
index 0d9dd93d9..390f4837b 100644
@@ -18,7 +18,7 @@ following features:
 .PD 0
 .TP 2
 \(bu
-Support for 24-bit pixel depth;
+Support for 24- and 30-bit pixel depths;
 .TP
 \(bu
 RandR support up to version 1.4;
src/amdgpu_bo_helper.c +2 -0
index ba2212228..34880ff12 100644
@@ -42,6 +42,8 @@ amdgpu_get_gbm_format(int depth, int bitsPerPixel)
 		return GBM_FORMAT_RGB565;
 	case 32:
 		return GBM_FORMAT_ARGB8888;
+	case 30:
+		return GBM_FORMAT_XRGB2101010;
 	case 24:
 		if (bitsPerPixel == 32)
 			return GBM_FORMAT_XRGB8888;
src/amdgpu_dri2.c +1 -0
index 4ffa34676..4a0f8bf24 100644
@@ -120,6 +120,7 @@ amdgpu_dri2_create_buffer2(ScreenPtr pScreen,
 			cpp = 2;
 			break;
 		case 24:
+		case 30:
 			cpp = 4;
 			break;
 		default:
src/amdgpu_kms.c +8 -0
index 49044f514..7dc9e22a9 100644
@@ -1085,6 +1085,14 @@ static Bool AMDGPUPreInitVisual(ScrnInfoPtr pScrn)
 	case 24:
 		break;
 
+	case 30:
+		if (xorgGetVersion() < XORG_VERSION_NUMERIC(1,19,99,1,0)) {
+			xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+				   "Depth 30 requires Xorg >= 1.19.99.1\n");
+			return FALSE;
+		}
+		break;
+
 	default:
 		xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 			   "Given depth (%d) is not supported by %s driver\n",
Signature · 6 lines
2.16.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#4 lore raw

PATCH 4/4 Always use screen depth/bpp for KMS framebuffers

In reply to a message not in the archive

From: Michel Dänzer <[email protected]>

DRI clients can use depth 32 pixmaps while the screen is depth 24, in which case page flipping would fail.

(Ported from radeon commit 733f606dd6ca8350e6e7f0858bfff5454ddc98ed)

---
 src/amdgpu_pixmap.h   | 13 ++++++-------
 src/drmmode_display.c |  5 ++---
 2 files changed, 8 insertions(+), 10 deletions(-)
src/amdgpu_pixmap.h +6 -7
index eded17037..d744ca573 100644
@@ -104,8 +104,8 @@ static inline struct amdgpu_buffer *amdgpu_get_pixmap_bo(PixmapPtr pPix)
 }
 
 static inline struct drmmode_fb*
-amdgpu_fb_create(int drm_fd, uint32_t width, uint32_t height, uint8_t depth,
-		 uint8_t bpp, uint32_t pitch, uint32_t handle)
+amdgpu_fb_create(ScrnInfoPtr scrn, int drm_fd, uint32_t width, uint32_t height,
+		 uint32_t pitch, uint32_t handle)
 {
 	struct drmmode_fb *fb  = malloc(sizeof(*fb));
 
@@ -113,8 +113,8 @@ amdgpu_fb_create(int drm_fd, uint32_t width, uint32_t height, uint8_t depth,
 		return NULL;
 
 	fb->refcnt = 1;
-	if (drmModeAddFB(drm_fd, width, height, depth, bpp, pitch, handle,
-			 &fb->handle) == 0)
+	if (drmModeAddFB(drm_fd, width, height, scrn->depth, scrn->bitsPerPixel,
+			 pitch, handle, &fb->handle) == 0)
 		return fb;
 
 	free(fb);
@@ -154,9 +154,8 @@ amdgpu_pixmap_get_fb(PixmapPtr pix)
 			ScrnInfoPtr scrn = xf86ScreenToScrn(pix->drawable.pScreen);
 			AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(scrn);
 
-			*fb_ptr = amdgpu_fb_create(pAMDGPUEnt->fd, pix->drawable.width,
-						   pix->drawable.height, pix->drawable.depth,
-						   pix->drawable.bitsPerPixel, pix->devKind,
+			*fb_ptr = amdgpu_fb_create(scrn, pAMDGPUEnt->fd, pix->drawable.width,
+						   pix->drawable.height, pix->devKind,
 						   handle);
 		}
 	}
src/drmmode_display.c +2 -3
index e52b7a355..8ccbf735d 100644
@@ -885,9 +885,8 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
 			union gbm_bo_handle bo_handle;
 
 			bo_handle = gbm_bo_get_handle(info->front_buffer->bo.gbm);
-			fb = amdgpu_fb_create(pAMDGPUEnt->fd, pScrn->virtualX,
-					      pScrn->virtualY, pScrn->depth,
-					      pScrn->bitsPerPixel,
+			fb = amdgpu_fb_create(pScrn, pAMDGPUEnt->fd,
+					      pScrn->virtualX, pScrn->virtualY,
 					      pScrn->displayWidth * info->pixel_bytes,
 					      bo_handle.u32);
 			/* Prevent refcnt of ad-hoc FBs from reaching 2 */
Signature · 6 lines
2.16.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20180213175339.10310-4-michel-otUistvHUpPR7s880joybQ@public.gmane.org

Reviewed-by
#6 lore raw

Re: [PATCH xf86-video-amdgpu 4/4] Always use screen depth/bpp for KMS framebuffers

Quoted 9 lines · Michel Dänzer

From: Michel Dänzer <[email protected]>

DRI clients can use depth 32 pixmaps while the screen is depth 24, in which case page flipping would fail.

(Ported from radeon commit 733f606dd6ca8350e6e7f0858bfff5454ddc98ed)

Series is:

Quoted 62 lines
---
 src/amdgpu_pixmap.h   | 13 ++++++-------
 src/drmmode_display.c |  5 ++---
 2 files changed, 8 insertions(+), 10 deletions(-)
src/amdgpu_pixmap.h +6 -7
index eded17037..d744ca573 100644
@@ -104,8 +104,8 @@ static inline struct amdgpu_buffer *amdgpu_get_pixmap_bo(PixmapPtr pPix)
 }
 
 static inline struct drmmode_fb*
-amdgpu_fb_create(int drm_fd, uint32_t width, uint32_t height, uint8_t depth,
-                uint8_t bpp, uint32_t pitch, uint32_t handle)
+amdgpu_fb_create(ScrnInfoPtr scrn, int drm_fd, uint32_t width, uint32_t height,
+                uint32_t pitch, uint32_t handle)
 {
        struct drmmode_fb *fb  = malloc(sizeof(*fb));
 
@@ -113,8 +113,8 @@ amdgpu_fb_create(int drm_fd, uint32_t width, uint32_t height, uint8_t depth,
                return NULL;
 
        fb->refcnt = 1;
-       if (drmModeAddFB(drm_fd, width, height, depth, bpp, pitch, handle,
-                        &fb->handle) == 0)
+       if (drmModeAddFB(drm_fd, width, height, scrn->depth, scrn->bitsPerPixel,
+                        pitch, handle, &fb->handle) == 0)
                return fb;
 
        free(fb);
@@ -154,9 +154,8 @@ amdgpu_pixmap_get_fb(PixmapPtr pix)
                        ScrnInfoPtr scrn = xf86ScreenToScrn(pix->drawable.pScreen);
                        AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(scrn);
 
-                       *fb_ptr = amdgpu_fb_create(pAMDGPUEnt->fd, pix->drawable.width,
-                                                  pix->drawable.height, pix->drawable.depth,
-                                                  pix->drawable.bitsPerPixel, pix->devKind,
+                       *fb_ptr = amdgpu_fb_create(scrn, pAMDGPUEnt->fd, pix->drawable.width,
+                                                  pix->drawable.height, pix->devKind,
                                                   handle);
                }
        }
src/drmmode_display.c +2 -4
index e52b7a355..8ccbf735d 100644
@@ -885,9 +885,8 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
                        union gbm_bo_handle bo_handle;
 
                        bo_handle = gbm_bo_get_handle(info->front_buffer->bo.gbm);
-                       fb = amdgpu_fb_create(pAMDGPUEnt->fd, pScrn->virtualX,
-                                             pScrn->virtualY, pScrn->depth,
-                                             pScrn->bitsPerPixel,
+                       fb = amdgpu_fb_create(pScrn, pAMDGPUEnt->fd,
+                                             pScrn->virtualX, pScrn->virtualY,
                                              pScrn->displayWidth * info->pixel_bytes,
                                              bo_handle.u32);
                        /* Prevent refcnt of ad-hoc FBs from reaching 2 */
--

2.16.1

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx