Skip to content
Merged
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
3 changes: 2 additions & 1 deletion drivers/gpu/drm/apple/apple_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1857,7 +1857,8 @@ static int apple_probe_per_dcp(struct device *dev,

if (dcp_fw_compat_is_14_7(dcp)) {
planes[0] = apple_plane_init_v14_7(drm, 1U << num, 0,
DRM_PLANE_TYPE_PRIMARY);
DRM_PLANE_TYPE_PRIMARY,
dcp_v14_7_is_internal(dcp));
if (IS_ERR(planes[0]))
return PTR_ERR(planes[0]);
ret = drm_plane_create_zpos_immutable_property(planes[0], 0);
Expand Down
7 changes: 7 additions & 0 deletions drivers/gpu/drm/apple/dcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -4699,6 +4699,13 @@ bool dcp_fw_compat_is_14_7(struct platform_device *pdev)
dcp->fw_compat == DCP_FIRMWARE_V_26_6;
}

bool dcp_v14_7_is_internal(struct platform_device *pdev)
{
struct apple_dcp *dcp = platform_get_drvdata(pdev);

return dcp->fw_compat == DCP_FIRMWARE_V_14_7 && !dcp->external;
}

/*
* GAMMA_LUT entries, 0 where the driver cannot program the gamma table.
*
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/apple/dcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ int dcp_crtc_atomic_check(struct drm_crtc *crtc, struct drm_atomic_commit *commi
int dcp_get_connector_type(struct platform_device *pdev);
bool dcp_fw_compat_is_12_x(struct platform_device *pdev);
bool dcp_fw_compat_is_14_7(struct platform_device *pdev);
bool dcp_v14_7_is_internal(struct platform_device *pdev);
bool dcp_fw_compat_is_desktop(struct platform_device *pdev);
bool dcp_caches_scanout(struct platform_device *pdev);
bool dcp_panel_edr(struct platform_device *pdev);
Expand Down
31 changes: 27 additions & 4 deletions drivers/gpu/drm/apple/iomfb_v14_7.c
Original file line number Diff line number Diff line change
Expand Up @@ -3002,6 +3002,26 @@ static struct drm_framebuffer *dcp_v14_publish_surface(struct apple_dcp_v14 *v14
return old;
}

/* The firmware format that scans out @format; 0: none does. */
static u32 dcp_v14_format(u32 format)
{
switch (format) {
case DRM_FORMAT_XRGB8888:
case DRM_FORMAT_ARGB8888:
return DCP_V14_FORMAT_BGRA;
case DRM_FORMAT_XRGB2101010:
case DRM_FORMAT_ARGB2101010:
return DCP_V14_FORMAT_L10R;
default:
return 0;
}
}

static bool dcp_v14_format_opaque(u32 format)
{
return format == DRM_FORMAT_XRGB8888 || format == DRM_FORMAT_XRGB2101010;
}

/*
* Shows the top-left @width x @height of @fb (or only the black background),
* after the colour matrix of @ctm_state if that is set,
Expand All @@ -3022,8 +3042,9 @@ static bool dcp_v14_present_locked(struct apple_dcp_v14 *v14, struct drm_framebu
return false;
if (fb) {
drm_framebuffer_get(fb);
dcp_v14_encode_surface(surface, fb->pitches[0], fb->width, fb->height,
fb->format->format == DRM_FORMAT_XRGB8888);
dcp_v14_encode_surface(surface, dcp_v14_format(fb->format->format),
fb->pitches[0], fb->width, fb->height,
dcp_v14_format_opaque(fb->format->format));
iova = drm_fb_dma_get_gem_obj(fb, 0)->dma_addr;
}
start = ktime_get_ns();
Expand Down Expand Up @@ -3192,8 +3213,10 @@ int iomfb_v14_7_atomic_check(struct apple_dcp *dcp, struct drm_crtc *crtc,
fb = p->fb;
width = crtc_state->mode.hdisplay;
height = crtc_state->mode.vdisplay;
if (fb->format->format != DRM_FORMAT_XRGB8888 &&
fb->format->format != DRM_FORMAT_ARGB8888)
if (!dcp_v14_format(fb->format->format))
return -EINVAL;
/* 10 bits were only tested on the internal panel. */
if (dcp->external && dcp_v14_format(fb->format->format) != DCP_V14_FORMAT_BGRA)
return -EINVAL;
if (fb->modifier != DRM_FORMAT_MOD_LINEAR || fb->offsets[0] ||
fb->pitches[0] < width * 4 || (fb->pitches[0] & 63))
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/apple/iomfb_v14_7_backlight_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static void v14_bl_swap_unchanged_without_level(struct kunit *test)

KUNIT_ASSERT_NOT_NULL(test, swap);
KUNIT_ASSERT_NOT_NULL(test, plain);
dcp_v14_encode_surface(surface, 3456 * 4, 3456, 2160, true);
dcp_v14_encode_surface(surface, DCP_V14_FORMAT_BGRA, 3456 * 4, 3456, 2160, true);
dcp_v14_encode_swap(plain, 7, DCP_V14_BLACK, surface, 0x100000000ULL, 3456, 2160, 74,
DCP_V14_LAYER);
dcp_v14_encode_swap(swap, 7, DCP_V14_BLACK, surface, 0x100000000ULL, 3456, 2160, 74,
Expand Down
15 changes: 9 additions & 6 deletions drivers/gpu/drm/apple/iomfb_v14_7_swap.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,25 @@ static inline int dcp_v14_encode_nits(u8 *swap, bool change, u32 nits)

/* 'BGRA': 8-bit linear, ARGB8888 in DRM terms. */
#define DCP_V14_FORMAT_BGRA 0x42475241
/* 'l10r': 10-bit linear, ARGB2101010 in DRM terms. */
#define DCP_V14_FORMAT_L10R 0x6c313072

/*
* A single-plane linear BGRA surface covering the whole framebuffer. The
* firmware has no XRGB format: an opaque surface blends as premultiplied
* alpha over the black background, which shows XRGB pixels unchanged.
* A single-plane linear surface of @format covering the whole framebuffer.
* The firmware has no XRGB formats: an opaque surface blends as
* premultiplied alpha over the black background, which shows XRGB pixels
* unchanged.
*/
static inline void dcp_v14_encode_surface(u8 *s, u32 stride, u32 width, u32 height,
bool opaque)
static inline void dcp_v14_encode_surface(u8 *s, u32 format, u32 stride, u32 width,
u32 height, bool opaque)
{
u32 bytes = stride * height;

memset(s, 0, DCP_V14_SURFACE_SIZE);
s[DCP_V14_SURF_OPAQUE] = opaque;
put_unaligned_le32(1, s + 0x03);
put_unaligned_le32(1, s + 0x07);
put_unaligned_le32(DCP_V14_FORMAT_BGRA, s + DCP_V14_SURF_FORMAT);
put_unaligned_le32(format, s + DCP_V14_SURF_FORMAT);
s[0x13] = 13;
s[0x14] = 12;
put_unaligned_le32(stride, s + DCP_V14_SURF_STRIDE);
Expand Down
21 changes: 17 additions & 4 deletions drivers/gpu/drm/apple/plane.c
Original file line number Diff line number Diff line change
Expand Up @@ -916,26 +916,39 @@ struct drm_plane *apple_plane_init(struct drm_device *dev,
return &plane->base;
}

/* The formats the T6030 (14.x firmware) scanout was qualified with. */
/* The formats the T6030 (14.x firmware) external and 26.6 scanout were qualified with. */
static const u32 dcp_primary_formats_14_7_8bit[] = {
DRM_FORMAT_XRGB8888,
DRM_FORMAT_ARGB8888,
};

/* The formats the T6030 (14.7 firmware) internal panel scanout was qualified with. */
static const u32 dcp_primary_formats_14_7[] = {
DRM_FORMAT_XRGB8888,
DRM_FORMAT_ARGB8888,
DRM_FORMAT_XRGB2101010,
DRM_FORMAT_ARGB2101010,
};

struct drm_plane *apple_plane_init_v14_7(struct drm_device *dev,
unsigned long possible_crtcs,
u32 iomfb_surf,
enum drm_plane_type type)
enum drm_plane_type type,
bool internal_v14_7)
{
const u32 *formats = internal_v14_7 ? dcp_primary_formats_14_7 :
dcp_primary_formats_14_7_8bit;
unsigned int format_count = internal_v14_7 ?
ARRAY_SIZE(dcp_primary_formats_14_7) :
ARRAY_SIZE(dcp_primary_formats_14_7_8bit);
struct apple_plane *plane;
int ret;

if (type != DRM_PLANE_TYPE_PRIMARY)
return ERR_PTR(-EINVAL);

plane = drmm_universal_plane_alloc(dev, struct apple_plane, base, possible_crtcs,
&apple_plane_funcs, dcp_primary_formats_14_7,
ARRAY_SIZE(dcp_primary_formats_14_7),
&apple_plane_funcs, formats, format_count,
format_modifiers_no_ix, type, NULL);
if (IS_ERR(plane))
return ERR_CAST(plane);
Expand Down
3 changes: 2 additions & 1 deletion drivers/gpu/drm/apple/plane.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ struct drm_plane *apple_plane_init(struct drm_device *dev,
struct drm_plane *apple_plane_init_v14_7(struct drm_device *dev,
unsigned long possible_crtcs,
u32 iomfb_surf,
enum drm_plane_type type);
enum drm_plane_type type,
bool internal_v14_7);

/* T8132 internal panel: the qualified single-surface firmware profile. */
struct drm_plane *apple_plane_init_v26_6(struct drm_device *dev,
Expand Down
18 changes: 17 additions & 1 deletion drivers/gpu/drm/apple/v14-board-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ static void v14_swap_timestamps_encoding(struct kunit *test)
plain = kunit_kzalloc(test, DCP_V14_SWAP_SIZE, GFP_KERNEL);
stamped = kunit_kzalloc(test, DCP_V14_SWAP_SIZE, GFP_KERNEL);
KUNIT_ASSERT_TRUE(test, plain && stamped);
dcp_v14_encode_surface(surface, 3456 * 4, 3456, 2160, true);
dcp_v14_encode_surface(surface, DCP_V14_FORMAT_BGRA, 3456 * 4, 3456, 2160, true);

for (pass = 0; pass < 2; pass++) {
const u8 *s = pass ? surface : NULL;
Expand Down Expand Up @@ -312,6 +312,21 @@ static void v14_board_j504(struct kunit *test)
&known));
}

static void v14_encode_surface_l10r(struct kunit *test)
{
u8 opaque[DCP_V14_SURFACE_SIZE], alpha[DCP_V14_SURFACE_SIZE];

dcp_v14_encode_surface(opaque, DCP_V14_FORMAT_L10R, 3024 * 4, 3024, 1964, true);
KUNIT_EXPECT_EQ(test, get_unaligned_le32(opaque + DCP_V14_SURF_FORMAT),
(u32)DCP_V14_FORMAT_L10R);
KUNIT_EXPECT_EQ(test, opaque[DCP_V14_SURF_OPAQUE], 1);

dcp_v14_encode_surface(alpha, DCP_V14_FORMAT_L10R, 3024 * 4, 3024, 1964, false);
KUNIT_EXPECT_EQ(test, get_unaligned_le32(alpha + DCP_V14_SURF_FORMAT),
(u32)DCP_V14_FORMAT_L10R);
KUNIT_EXPECT_EQ(test, alpha[DCP_V14_SURF_OPAQUE], 0);
}

/*
* The panel behind the boot framebuffer. The T6030 record has no panel
* size, so a kept notch (aura chosen.asahi,show-notch=1) is known only from
Expand Down Expand Up @@ -347,6 +362,7 @@ static struct kunit_case v14_board_cases[] = {
KUNIT_CASE(v14_board_unchanged),
KUNIT_CASE(v14_board_swap_timestamps),
KUNIT_CASE(v14_swap_timestamps_encoding),
KUNIT_CASE(v14_encode_surface_l10r),
{}
};

Expand Down
Loading