Skip to content

Commit 852542c

Browse files
cubanismogregkh
authored andcommitted
drm/nouveau: Advertise correct modifiers on GB20x
commit 664ce10 upstream. 8 and 16 bit formats use a different layout on GB20x than they did on prior chips. Add the corresponding DRM format modifiers to the list of modifiers supported by the display engine on such chips, and filter the supported modifiers for each format based on its bytes per pixel in nv50_plane_format_mod_supported(). Note this logic will need to be updated when GB10 support is added, since it is a GB20x chip that uses the pre-GB20x sector layout for all formats. Fixes: 6cc6e08 ("drm/nouveau/kms: add support for GB20x") Signed-off-by: James Jones <[email protected]> Reviewed-by: Faith Ekstrand <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Cc: [email protected] Link: https://patch.msgid.link/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 6c19a8c commit 852542c

File tree

4 files changed

+59
-3
lines changed

4 files changed

+59
-3
lines changed

drivers/gpu/drm/nouveau/dispnv50/disp.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2867,7 +2867,9 @@ nv50_display_create(struct drm_device *dev)
28672867
}
28682868

28692869
/* Assign the correct format modifiers */
2870-
if (disp->disp->object.oclass >= TU102_DISP)
2870+
if (disp->disp->object.oclass >= GB202_DISP)
2871+
nouveau_display(dev)->format_modifiers = wndwca7e_modifiers;
2872+
else if (disp->disp->object.oclass >= TU102_DISP)
28712873
nouveau_display(dev)->format_modifiers = wndwc57e_modifiers;
28722874
else
28732875
if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_FERMI)

drivers/gpu/drm/nouveau/dispnv50/disp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,5 @@ struct nouveau_encoder *nv50_real_outp(struct drm_encoder *encoder);
104104
extern const u64 disp50xx_modifiers[];
105105
extern const u64 disp90xx_modifiers[];
106106
extern const u64 wndwc57e_modifiers[];
107+
extern const u64 wndwca7e_modifiers[];
107108
#endif

drivers/gpu/drm/nouveau/dispnv50/wndw.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -786,27 +786,47 @@ nv50_wndw_destroy(struct drm_plane *plane)
786786
}
787787

788788
/* This function assumes the format has already been validated against the plane
789-
* and the modifier was validated against the device-wides modifier list at FB
789+
* and the modifier was validated against the device-wide modifier list at FB
790790
* creation time.
791791
*/
792792
static bool nv50_plane_format_mod_supported(struct drm_plane *plane,
793793
u32 format, u64 modifier)
794794
{
795795
struct nouveau_drm *drm = nouveau_drm(plane->dev);
796+
const struct drm_format_info *info = drm_format_info(format);
796797
uint8_t i;
797798

798799
/* All chipsets can display all formats in linear layout */
799800
if (modifier == DRM_FORMAT_MOD_LINEAR)
800801
return true;
801802

802803
if (drm->client.device.info.chipset < 0xc0) {
803-
const struct drm_format_info *info = drm_format_info(format);
804804
const uint8_t kind = (modifier >> 12) & 0xff;
805805

806806
if (!format) return false;
807807

808808
for (i = 0; i < info->num_planes; i++)
809809
if ((info->cpp[i] != 4) && kind != 0x70) return false;
810+
} else if (drm->client.device.info.chipset >= 0x1b2) {
811+
const uint8_t slayout = ((modifier >> 22) & 0x1) |
812+
((modifier >> 25) & 0x6);
813+
814+
if (!format)
815+
return false;
816+
817+
/*
818+
* Note in practice this implies only formats where cpp is equal
819+
* for each plane, or >= 4 for all planes, are supported.
820+
*/
821+
for (i = 0; i < info->num_planes; i++) {
822+
if (((info->cpp[i] == 2) && slayout != 3) ||
823+
((info->cpp[i] == 1) && slayout != 2) ||
824+
((info->cpp[i] >= 4) && slayout != 1))
825+
return false;
826+
827+
/* 24-bit not supported. It has yet another layout */
828+
WARN_ON(info->cpp[i] == 3);
829+
}
810830
}
811831

812832
return true;

drivers/gpu/drm/nouveau/dispnv50/wndwca7e.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,39 @@ wndwca7e_ntfy_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
179179
return 0;
180180
}
181181

182+
/****************************************************************
183+
* Log2(block height) ----------------------------+ *
184+
* Page Kind ----------------------------------+ | *
185+
* Gob Height/Page Kind Generation ------+ | | *
186+
* Sector layout -------+ | | | *
187+
* Compression ------+ | | | | */
188+
const u64 wndwca7e_modifiers[] = { /* | | | | | */
189+
/* 4cpp+ modifiers */
190+
DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 2, 0x06, 0),
191+
DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 2, 0x06, 1),
192+
DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 2, 0x06, 2),
193+
DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 2, 0x06, 3),
194+
DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 2, 0x06, 4),
195+
DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 2, 0x06, 5),
196+
/* 1cpp/8bpp modifiers */
197+
DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 2, 2, 0x06, 0),
198+
DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 2, 2, 0x06, 1),
199+
DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 2, 2, 0x06, 2),
200+
DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 2, 2, 0x06, 3),
201+
DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 2, 2, 0x06, 4),
202+
DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 2, 2, 0x06, 5),
203+
/* 2cpp/16bpp modifiers */
204+
DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 3, 2, 0x06, 0),
205+
DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 3, 2, 0x06, 1),
206+
DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 3, 2, 0x06, 2),
207+
DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 3, 2, 0x06, 3),
208+
DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 3, 2, 0x06, 4),
209+
DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 3, 2, 0x06, 5),
210+
/* All formats support linear */
211+
DRM_FORMAT_MOD_LINEAR,
212+
DRM_FORMAT_MOD_INVALID
213+
};
214+
182215
static const struct nv50_wndw_func
183216
wndwca7e = {
184217
.acquire = wndwc37e_acquire,

0 commit comments

Comments
 (0)