Skip to content

Commit aaa1042

Browse files
committed
drm/asahi: Do not use l10r for 12.3 DCP firmware
DCP firmware 12.3 (tested as 12.4 on a M2) does not support l10r as buffer format. Drop 30-bit support for 12.x firmware. 12.3 based installs are considered legacy and support for 12.4 (M2 only) was dropped. This ensures such installs remain usable without complicating the driver too much. DCP complains on syslog with > UPPipeDCP_H13P.cpp:3302: IOMFB verify_surfaces: No support for format l10r Fixes: b6a8d6b ("drm: apple: Advertise ARGB2101010 support") Signed-off-by: Janne Grunau <j@jannau.net>
1 parent 64fedb9 commit aaa1042

5 files changed

Lines changed: 65 additions & 6 deletions

File tree

drivers/gpu/drm/apple/apple_drv.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,10 @@ static int apple_probe_per_dcp(struct device *dev,
273273
struct drm_plane *planes[DCP_MAX_PLANES];
274274
int ret, i;
275275
int immutable_zpos = 0;
276+
bool supports_l10r = !dcp_fw_compat_is_12_x(dcp);
276277

277-
planes[0] = apple_plane_init(drm, 1U << num, DRM_PLANE_TYPE_PRIMARY);
278+
planes[0] = apple_plane_init(drm, 1U << num, supports_l10r,
279+
DRM_PLANE_TYPE_PRIMARY);
278280
if (IS_ERR(planes[0]))
279281
return PTR_ERR(planes[0]);
280282
ret = drm_plane_create_zpos_immutable_property(planes[0], immutable_zpos);
@@ -285,7 +287,8 @@ static int apple_probe_per_dcp(struct device *dev,
285287

286288
/* Set up our other planes */
287289
for (i = 1; i < DCP_MAX_PLANES; i++) {
288-
planes[i] = apple_plane_init(drm, 1U << num, DRM_PLANE_TYPE_OVERLAY);
290+
planes[i] = apple_plane_init(drm, 1U << num, supports_l10r,
291+
DRM_PLANE_TYPE_OVERLAY);
289292
if (IS_ERR(planes[i]))
290293
return PTR_ERR(planes[i]);
291294
immutable_zpos++;

drivers/gpu/drm/apple/dcp.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,14 @@ void dcp_link(struct platform_device *pdev, struct apple_crtc *crtc,
501501
dcp->connector = connector;
502502
}
503503

504+
505+
bool dcp_fw_compat_is_12_x(struct platform_device *pdev)
506+
{
507+
struct apple_dcp *dcp = platform_get_drvdata(pdev);
508+
509+
return dcp->fw_compat == DCP_FIRMWARE_V_12_3;
510+
}
511+
504512
int dcp_start(struct platform_device *pdev)
505513
{
506514
struct apple_dcp *dcp = platform_get_drvdata(pdev);

drivers/gpu/drm/apple/dcp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ void dcp_poweron(struct platform_device *pdev);
3434
int dcp_set_crc(struct drm_crtc *crtc, bool enabled);
3535
int dcp_crtc_atomic_check(struct drm_crtc *crtc, struct drm_atomic_state *state);
3636
int dcp_get_connector_type(struct platform_device *pdev);
37+
bool dcp_fw_compat_is_12_x(struct platform_device *pdev);
3738
void dcp_link(struct platform_device *pdev, struct apple_crtc *apple,
3839
struct apple_connector *connector);
3940
int dcp_start(struct platform_device *pdev);

drivers/gpu/drm/apple/plane.c

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,37 @@ static const u32 dcp_overlay_formats[] = {
394394
#endif
395395
};
396396

397+
/*
398+
* Formats for the 12.x firmware which does not support "l10r" / ARGB2101010
399+
*/
400+
static const u32 dcp_primary_formats_12_x[] = {
401+
DRM_FORMAT_XRGB8888,
402+
DRM_FORMAT_ARGB8888,
403+
DRM_FORMAT_XBGR8888,
404+
DRM_FORMAT_ABGR8888,
405+
DRM_FORMAT_NV12,
406+
DRM_FORMAT_NV16,
407+
DRM_FORMAT_NV24,
408+
DRM_FORMAT_P010,
409+
DRM_FORMAT_P210,
410+
#if defined(DRM_FORMAT_P410)
411+
DRM_FORMAT_P410,
412+
#endif
413+
};
414+
415+
static const u32 dcp_overlay_formats_12_x[] = {
416+
DRM_FORMAT_ARGB8888,
417+
DRM_FORMAT_ABGR8888,
418+
DRM_FORMAT_NV12,
419+
DRM_FORMAT_NV16,
420+
DRM_FORMAT_NV24,
421+
DRM_FORMAT_P010,
422+
DRM_FORMAT_P210,
423+
#if defined(DRM_FORMAT_P410)
424+
DRM_FORMAT_P410,
425+
#endif
426+
};
427+
397428
u64 apple_format_modifiers[] = {
398429
DRM_FORMAT_MOD_LINEAR,
399430
DRM_FORMAT_MOD_INVALID
@@ -405,22 +436,37 @@ struct apple_plane {
405436

406437
struct drm_plane *apple_plane_init(struct drm_device *dev,
407438
unsigned long possible_crtcs,
439+
bool supports_l10r,
408440
enum drm_plane_type type)
409441
{
410442
struct apple_plane *plane;
443+
const u32 *fmts;
444+
u32 num_fmts;
411445

412446
switch (type) {
413447
case DRM_PLANE_TYPE_PRIMARY:
448+
if (supports_l10r) {
449+
fmts = dcp_primary_formats;
450+
num_fmts = ARRAY_SIZE(dcp_primary_formats);
451+
} else {
452+
fmts = dcp_primary_formats_12_x;
453+
num_fmts = ARRAY_SIZE(dcp_primary_formats_12_x);
454+
}
414455
plane = drmm_universal_plane_alloc(dev, struct apple_plane, base, possible_crtcs,
415-
&apple_plane_funcs,
416-
dcp_primary_formats, ARRAY_SIZE(dcp_primary_formats),
456+
&apple_plane_funcs, fmts, num_fmts,
417457
apple_format_modifiers, type, NULL);
418458
break;
419459
case DRM_PLANE_TYPE_OVERLAY:
420460
case DRM_PLANE_TYPE_CURSOR:
461+
if (supports_l10r) {
462+
fmts = dcp_overlay_formats;
463+
num_fmts = ARRAY_SIZE(dcp_overlay_formats);
464+
} else {
465+
fmts = dcp_overlay_formats_12_x;
466+
num_fmts = ARRAY_SIZE(dcp_overlay_formats_12_x);
467+
}
421468
plane = drmm_universal_plane_alloc(dev, struct apple_plane, base, possible_crtcs,
422-
&apple_plane_funcs,
423-
dcp_overlay_formats, ARRAY_SIZE(dcp_overlay_formats),
469+
&apple_plane_funcs, fmts, num_fmts,
424470
apple_format_modifiers, type, NULL);
425471
break;
426472
default:

drivers/gpu/drm/apple/plane.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ struct apple_plane_state {
2424

2525
struct drm_plane *apple_plane_init(struct drm_device *dev,
2626
unsigned long possible_crtcs,
27+
bool supports_l10r,
2728
enum drm_plane_type type);
2829

2930
#endif /* __APPLE_PLANE_H__ */

0 commit comments

Comments
 (0)