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
18 changes: 18 additions & 0 deletions drivers/gpu/drm/apple/dcp-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,24 @@ struct dcp_fb_reference {

#define MAX_NOTCH_HEIGHT 160

struct device_node;
bool dcp_boot_show_notch(const struct device_node *chosen);

/*
* Rows of the panel behind a boot framebuffer of @fb_height rows. A board with
* a @known_height (non-zero) already tells whether the boot loader kept the
* @notch rows: fb_height == known_height means kept, otherwise hidden. When
* @known_height is 0 (unsized board), trust @notch_kept (aura sets
* chosen.asahi,show-notch=1 when it keeps the notch rows).
*/
static inline u32 dcp_boot_panel_height(u32 fb_height, u32 notch,
u32 known_height, bool notch_kept)
{
if (notch && (fb_height == known_height || (!known_height && notch_kept)))
return fb_height;
return fb_height + notch;
}

struct dcp_brightness {
struct backlight_device *bl_dev;
u32 maximum;
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/apple/dcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -7319,7 +7319,7 @@ static bool dcp_external_is_idle(struct apple_dcp *dcp)
* drive the full panel (aura: chosen.asahi,show-notch=1). Follow it, so the
* mode covers the same rows as the boot framebuffer did.
*/
static bool dcp_boot_show_notch(const struct device_node *chosen)
bool dcp_boot_show_notch(const struct device_node *chosen)
{
const char *val;

Expand Down
14 changes: 6 additions & 8 deletions drivers/gpu/drm/apple/iomfb_v14_7.c
Original file line number Diff line number Diff line change
Expand Up @@ -1848,10 +1848,9 @@ int iomfb_v14_7_probe(struct apple_dcp *dcp)

/*
* The boot framebuffer gives the stride and the panel size. The boot loader
* either hides the notch rows from it (the default) or keeps them;
* apple,notch-height is recorded either way. A board with a known panel
* tells the two apart by the height; any other board is taken to have the
* notch hidden.
* either hides the notch rows from it or keeps them and sets
* chosen.asahi,show-notch=1; apple,notch-height is recorded either way. A
* board with a known panel also tells the two apart by the height.
*/
static int dcp_v14_geometry(struct apple_dcp_v14 *v14)
{
Expand All @@ -1876,10 +1875,9 @@ static int dcp_v14_geometry(struct apple_dcp_v14 *v14)
return -EINVAL;
v14->notch_rows = notch;
v14->panel_width = v14->fb_width;
v14->panel_height = v14->fb_height + notch;
/* The boot loader kept the notch rows: the framebuffer is the whole panel. */
if (v14->board->panel_height && notch && v14->fb_height == v14->board->panel_height)
v14->panel_height = v14->fb_height;
v14->panel_height = dcp_boot_panel_height(v14->fb_height, notch,
v14->board->panel_height,
dcp_boot_show_notch(of_chosen));
/* A board with a known panel takes no other. */
if (v14->board->panel_width &&
(v14->panel_width != v14->board->panel_width ||
Expand Down
13 changes: 6 additions & 7 deletions drivers/gpu/drm/apple/iomfb_v26_6.c
Original file line number Diff line number Diff line change
Expand Up @@ -1132,9 +1132,9 @@ int iomfb_v26_6_probe(struct apple_dcp *dcp)

/*
* The boot framebuffer gives the stride and the panel size. The boot loader either hides
* the notch rows from it (the default) or, with chosen.asahi,show-notch=1 in m1n1, keeps
* them; apple,notch-height is recorded either way. A board with a known panel tells the
* two apart by the height; any other board is taken to have the notch hidden.
* the notch rows from it or keeps them and sets chosen.asahi,show-notch=1;
* apple,notch-height is recorded either way. A board with a known panel also tells the
* two apart by the height.
*/
static int dcp_v26_geometry(struct apple_dcp_v26 *v26)
{
Expand All @@ -1159,10 +1159,9 @@ static int dcp_v26_geometry(struct apple_dcp_v26 *v26)
return -EINVAL;
v26->notch_rows = notch;
v26->panel_width = v26->fb_width;
v26->panel_height = v26->fb_height + notch;
/* The boot loader kept the notch rows: the framebuffer is the whole panel. */
if (v26->board->panel_height && notch && v26->fb_height == v26->board->panel_height)
v26->panel_height = v26->fb_height;
v26->panel_height = dcp_boot_panel_height(v26->fb_height, notch,
v26->board->panel_height,
dcp_boot_show_notch(of_chosen));
/* A board with a known panel takes no other. */
if (v26->board->panel_width &&
(v26->panel_width != v26->board->panel_width ||
Expand Down
27 changes: 27 additions & 0 deletions drivers/gpu/drm/apple/v14-board-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <linux/string.h>
#include <linux/unaligned.h>

#include "dcp-internal.h"
#include "iomfb_v14_7_board.h"
#include "iomfb_v14_7_swap.h"

Expand Down Expand Up @@ -311,7 +312,33 @@ static void v14_board_j504(struct kunit *test)
&known));
}

/*
* 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
* the boot loader: a 14" J514S boots with 3024x1964 and 74 notch rows either
* as 1890 rows (hidden) or 1964 (kept), and is 1964 rows high both ways.
*/
static void v14_boot_panel_height(struct kunit *test)
{
/* Unsized board (T6030 J514S): hidden, kept. */
KUNIT_EXPECT_EQ(test, dcp_boot_panel_height(1890, 74, 0, false), 1964);
KUNIT_EXPECT_EQ(test, dcp_boot_panel_height(1964, 74, 0, true), 1964);
/* Unsized board (T6030 J516S), kept. */
KUNIT_EXPECT_EQ(test, dcp_boot_panel_height(2234, 74, 0, true), 2234);
/* Sized board (J504): known by height with or without the chosen flag. */
KUNIT_EXPECT_EQ(test, dcp_boot_panel_height(1964, 74, 1964, false), 1964);
KUNIT_EXPECT_EQ(test, dcp_boot_panel_height(1964, 74, 1964, true), 1964);
KUNIT_EXPECT_EQ(test, dcp_boot_panel_height(1890, 74, 1964, false), 1964);
/* Sized board with a contradictory chosen flag still derives from fb_height. */
KUNIT_EXPECT_EQ(test, dcp_boot_panel_height(1890, 74, 1964, true), 1964);
KUNIT_EXPECT_EQ(test, dcp_boot_panel_height(1800, 64, 1864, true), 1864);
/* No notch: the framebuffer is the panel whatever the flag says. */
KUNIT_EXPECT_EQ(test, dcp_boot_panel_height(1664, 0, 1664, true), 1664);
KUNIT_EXPECT_EQ(test, dcp_boot_panel_height(1080, 0, 0, false), 1080);
}

static struct kunit_case v14_board_cases[] = {
KUNIT_CASE(v14_boot_panel_height),
KUNIT_CASE(v14_board_j504),
KUNIT_CASE(v14_board_j516c),
KUNIT_CASE(v14_board_j514c),
Expand Down
15 changes: 14 additions & 1 deletion tools/asahi/dcp14-panel-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
source = (root/'drivers/gpu/drm/apple/iomfb_v14_7.c').read_text()
board_header = root/'drivers/gpu/drm/apple/iomfb_v14_7_board.h'
board_types = board_header.read_text() if board_header.exists() else ''
internal_header = (root/'drivers/gpu/drm/apple/dcp-internal.h').read_text()
panel_height_helper = ''
if 'static inline u32 dcp_boot_panel_height(' in internal_header:
start = internal_header.index('static inline u32 dcp_boot_panel_height(')
panel_height_helper = internal_header[start:internal_header.index('\n}\n', start) + 3]
cases = [('current', source)]
if args.old_source:
cases.append(('old', args.old_source.read_text()))
Expand Down Expand Up @@ -57,7 +62,10 @@
return 0;
}
static void of_node_put(struct device_node*n){}
'''
static struct device_node *of_chosen;
static bool boot_show_notch;
static bool dcp_boot_show_notch(const struct device_node *chosen){return boot_show_notch;}
''' + panel_height_helper
for name,src in cases:
end=src.index('struct dcp_v14_property {')
if 'struct dcp_v14_board {' in src:
Expand Down Expand Up @@ -113,6 +121,7 @@
image_uuid=p14->firmware_uuid;marker_value=0;assert(probe_gate(&dev,p14)==-ENODEV);marker_value=1;
{struct apple_dcp_v14 q={.dev=&dev,.board=p14};width=3024;height=1890;stride=width*4;notch=74;
assert(dcp_v14_geometry(&q)==0&&q.panel_height==1964&&q.notch_rows==74);
boot_show_notch=true;assert(dcp_v14_geometry(&q)==0&&q.panel_height==1964&&q.notch_rows==74);boot_show_notch=false;
height=1964;notch=0;assert(dcp_v14_geometry(&q)==0&&q.panel_height==1964);
width=2560;height=1600;stride=width*4;notch=64;assert(dcp_v14_geometry(&q)==-EINVAL);}
/* J613 keeps its machine record; J615 and J504 match the panel. */
Expand Down Expand Up @@ -164,6 +173,10 @@
width=3024;height=1890;stride=width*4;notch=74;
assert(dcp_v14_geometry(&m14)==0&&m14.panel_width==3024&&m14.panel_height==1964);
assert(m14.notch_rows==74);
/* Unsized board with boot loader keeping the notch (aura show-notch=1): 1964 stays 1964. */
height=1964;boot_show_notch=true;
assert(dcp_v14_geometry(&m14)==0&&m14.panel_width==3024&&m14.panel_height==1964&&m14.notch_rows==74);
boot_show_notch=false;height=1890;
stride++;assert(dcp_v14_geometry(&m14)==-EINVAL);stride--;
notch=MAX_NOTCH_HEIGHT+1;assert(dcp_v14_geometry(&m14)==-EINVAL);notch=74;
width=0;stride=0;assert(dcp_v14_geometry(&m14)==-EINVAL);
Expand Down
Loading