Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,46 @@ properties:
reg:
maxItems: 1

panel-timing:
$ref: /schemas/display/panel/panel-timing.yaml#
description: |
Native progressive active-scanout timing of the attached internal
panel (two active subframes, i.e. the 120 Hz base scanout). The active
resolution is matched against simple-framebuffer and half the total
vertical line count (lines per subframe) is verified against the
running H9G boot scanout; pixel clock, total horizontal pixels and
subframe line count are used to derive the alternate H9G cadence
modes. Where individual porch and sync pulse splits have not yet been
measured from hardware, total blanking may be carried in the front
porch with zero sync length and back porch (not literal zero-width
hardware pulses).

required:
- compatible
- reg

additionalProperties: false

examples:
- |
soc {
#address-cells = <2>;
#size-cells = <2>;

display-controller@206000000 {
compatible = "apple,t8011-h9g-display";
reg = <0x2 0x06000000 0x0 0xe0000>;

panel-timing {
clock-frequency = <517107000>;
hactive = <1668>;
vactive = <2224>;
hfront-porch = <62>;
hback-porch = <18>;
hsync-len = <8>;
vfront-porch = <230>;
vback-porch = <0>;
vsync-len = <0>;
};
};
};
19 changes: 19 additions & 0 deletions arch/arm64/boot/dts/apple/t8011-j120.dts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,25 @@
compatible = "apple,j120-bcm4355c0-bt", "brcm,bcm4355c0-bt";
};

&h9g_display {
panel-timing {
/*
* 12.9-inch iPad Pro 2 native 120 Hz active scanout (two
* 1497-line subframes). Only total blanking (htotal 2088,
* vtotal 2994) is known, carried in the front porches.
*/
clock-frequency = <750001000>;
hactive = <2048>;
vactive = <2732>;
hfront-porch = <40>;
hback-porch = <0>;
hsync-len = <0>;
vfront-porch = <262>;
vback-porch = <0>;
vsync-len = <0>;
};
};

&headphones {
simple-audio-card,name = "J120 Headphones";
};
Expand Down
19 changes: 19 additions & 0 deletions arch/arm64/boot/dts/apple/t8011-j121.dts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,25 @@
compatible = "apple,j121-bcm4355c0-bt", "brcm,bcm4355c0-bt";
};

&h9g_display {
panel-timing {
/*
* 12.9-inch iPad Pro 2 native 120 Hz active scanout (two
* 1497-line subframes). Only total blanking (htotal 2088,
* vtotal 2994) is known, carried in the front porches.
*/
clock-frequency = <750001000>;
hactive = <2048>;
vactive = <2732>;
hfront-porch = <40>;
hback-porch = <0>;
hsync-len = <0>;
vfront-porch = <262>;
vback-porch = <0>;
vsync-len = <0>;
};
};

&headphones {
simple-audio-card,name = "J121 Headphones";
};
Expand Down
18 changes: 18 additions & 0 deletions arch/arm64/boot/dts/apple/t8011-j207.dts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@
compatible = "apple,j207-bcm4355c0-bt", "brcm,bcm4355c0-bt";
};

&h9g_display {
panel-timing {
/*
* 10.5-inch iPad Pro 2 native 120 Hz active scanout (two
* 1227-line subframes, htotal 1756, vtotal 2454).
*/
clock-frequency = <517107000>;
hactive = <1668>;
vactive = <2224>;
hfront-porch = <62>;
hback-porch = <18>;
hsync-len = <8>;
vfront-porch = <230>;
vback-porch = <0>;
vsync-len = <0>;
};
};

&headphones {
simple-audio-card,name = "J207 Headphones";
};
Expand Down
18 changes: 18 additions & 0 deletions arch/arm64/boot/dts/apple/t8011-j208.dts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@
compatible = "apple,j208-bcm4355c0-bt", "brcm,bcm4355c0-bt";
};

&h9g_display {
panel-timing {
/*
* 10.5-inch iPad Pro 2 native 120 Hz active scanout (two
* 1227-line subframes, htotal 1756, vtotal 2454).
*/
clock-frequency = <517107000>;
hactive = <1668>;
vactive = <2224>;
hfront-porch = <62>;
hback-porch = <18>;
hsync-len = <8>;
vfront-porch = <230>;
vback-porch = <0>;
vsync-len = <0>;
};
};

&headphones {
simple-audio-card,name = "J208 Headphones";
};
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/sysfb/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ config DRM_SIMPLEDRM
select DRM_GEM_SHMEM_HELPER
select DRM_KMS_HELPER
select DRM_SYSFB_HELPER
select VIDEOMODE_HELPERS if OF
help
DRM driver for simple platform-provided framebuffers.

Expand Down
112 changes: 82 additions & 30 deletions drivers/gpu/drm/sysfb/simpledrm.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <linux/aperture.h>
#include <linux/clk.h>
#include <linux/iopoll.h>
#include <linux/limits.h>
#include <linux/minmax.h>
#include <linux/of_address.h>
#include <linux/of_clk.h>
Expand All @@ -14,6 +15,9 @@
#include <linux/pm_domain.h>
#include <linux/regulator/consumer.h>

#include <video/display_timing.h>
#include <video/of_display_timing.h>

#include <drm/clients/drm_client_setup.h>
#include <drm/drm_atomic.h>
#include <drm/drm_atomic_state_helper.h>
Expand Down Expand Up @@ -587,19 +591,15 @@ static int simpledrm_device_attach_genpd(struct simpledrm_device *sdev)
#define H9G_ACTIVE_SUBFRAME_COUNT 2
#define H9G_BOOT_SUBFRAMES 2

struct simpledrm_h9g_panel {
u16 hdisplay;
u16 vdisplay;
struct simpledrm_h9g_timing {
u32 clock;
u32 flags;
u16 hsync_start;
u16 hsync_end;
u16 htotal;
u16 vsync_start;
u16 vsync_end;
u16 subframe_lines;
u32 clock;
};

static const struct simpledrm_h9g_panel simpledrm_h9g_panels[] = {
/* 12.9-inch iPad Pro 2 (J120/J121) */
{ 2048, 2732, 2088, 1497, 750001 },
/* 10.5-inch iPad Pro 2 (J207/J208) */
{ 1668, 2224, 1756, 1227, 517107 },
};

/*
Expand Down Expand Up @@ -628,17 +628,66 @@ static void simpledrm_h9g_restore(void *data)
drm_err(&sdev->sysfb.dev, "failed to restore H9G boot cadence\n");
}

static const struct simpledrm_h9g_panel *
simpledrm_h9g_find_panel(const struct drm_display_mode *mode)
static bool simpledrm_h9g_parse_timing(struct device_node *display,
const struct drm_display_mode *fb_mode,
struct simpledrm_h9g_timing *timing)
{
struct display_timing dt;
u64 htotal, vtotal, subframe_lines, max_vtotal;
u32 clock_khz;
u16 max_extra = H9G_BOOT_SUBFRAMES;
unsigned int i;

for (i = 0; i < ARRAY_SIZE(simpledrm_h9g_panels); i++) {
if (mode->hdisplay == simpledrm_h9g_panels[i].hdisplay &&
mode->vdisplay == simpledrm_h9g_panels[i].vdisplay)
return &simpledrm_h9g_panels[i];
}
return NULL;
if (of_get_display_timing(display, "panel-timing", &dt))
return false;

if (dt.flags & (DISPLAY_FLAGS_INTERLACED | DISPLAY_FLAGS_DOUBLESCAN |
DISPLAY_FLAGS_DOUBLECLK))
return false;

if (dt.hactive.typ != fb_mode->hdisplay ||
dt.vactive.typ != fb_mode->vdisplay)
return false;

clock_khz = dt.pixelclock.typ / 1000;
if (!clock_khz)
return false;

htotal = (u64)dt.hactive.typ + dt.hfront_porch.typ +
dt.hsync_len.typ + dt.hback_porch.typ;
vtotal = (u64)dt.vactive.typ + dt.vfront_porch.typ +
dt.vsync_len.typ + dt.vback_porch.typ;
if (htotal > U16_MAX || vtotal % H9G_ACTIVE_SUBFRAME_COUNT)
return false;

subframe_lines = vtotal / H9G_ACTIVE_SUBFRAME_COUNT;
if (!subframe_lines || subframe_lines > U16_MAX)
return false;

for (i = 0; i < ARRAY_SIZE(simpledrm_h9g_extra_subframes); i++)
max_extra = max(max_extra, simpledrm_h9g_extra_subframes[i]);
max_vtotal = (u64)(H9G_ACTIVE_SUBFRAME_COUNT + max_extra) *
subframe_lines;
if (max_vtotal > U16_MAX)
return false;

timing->clock = clock_khz;
timing->flags = 0;
if (dt.flags & DISPLAY_FLAGS_HSYNC_HIGH)
timing->flags |= DRM_MODE_FLAG_PHSYNC;
else if (dt.flags & DISPLAY_FLAGS_HSYNC_LOW)
timing->flags |= DRM_MODE_FLAG_NHSYNC;
if (dt.flags & DISPLAY_FLAGS_VSYNC_HIGH)
timing->flags |= DRM_MODE_FLAG_PVSYNC;
else if (dt.flags & DISPLAY_FLAGS_VSYNC_LOW)
timing->flags |= DRM_MODE_FLAG_NVSYNC;
timing->hsync_start = dt.hactive.typ + dt.hfront_porch.typ;
timing->hsync_end = timing->hsync_start + dt.hsync_len.typ;
timing->htotal = htotal;
timing->vsync_start = dt.vactive.typ + dt.vfront_porch.typ;
timing->vsync_end = timing->vsync_start + dt.vsync_len.typ;
timing->subframe_lines = subframe_lines;
return true;
}

static bool simpledrm_h9g_mode_subframes(const struct simpledrm_device *sdev,
Expand All @@ -664,22 +713,20 @@ static void simpledrm_h9g_init(struct simpledrm_device *sdev)
{
struct drm_sysfb_device *sysfb = &sdev->sysfb;
struct device *dev = sysfb->dev.dev;
const struct simpledrm_h9g_panel *panel;
struct simpledrm_h9g_timing timing;
struct device_node *display;
struct resource res;
void __iomem *regs;
unsigned int i;
u16 subframes;
int ret = -ENODEV;

/* iPad Pro 2 (12.9-inch or 10.5-inch) panel behind an A10X H9G pipe */
panel = simpledrm_h9g_find_panel(&sysfb->fb_mode);
if (!panel)
return;
/* Internal panel behind an A10X H9G pipe with panel-timing in DT */
display = of_parse_phandle(dev->of_node, "display", 0);
if (!display)
return;
if (of_device_is_compatible(display, "apple,t8011-h9g-display"))
if (of_device_is_compatible(display, "apple,t8011-h9g-display") &&
simpledrm_h9g_parse_timing(display, &sysfb->fb_mode, &timing))
ret = of_address_to_resource(display, 0, &res);
of_node_put(display);
if (ret || resource_size(&res) < H9G_EXTRA_SUBFRAMES_WRITE + sizeof(u32))
Expand All @@ -691,7 +738,7 @@ static void simpledrm_h9g_init(struct simpledrm_device *sdev)
/* Adopt only the boot scanout with the firmware processor stopped. */
if (readl(regs + H9G_M3_CONTROL) != 3 || readl(regs + H9G_MODE) != 1 ||
readl(regs + H9G_IRQ_ENABLE) || readl(regs + H9G_OUTPUT_ENABLE) ||
readl(regs + H9G_SUBFRAME_LINES) != panel->subframe_lines ||
readl(regs + H9G_SUBFRAME_LINES) != timing.subframe_lines ||
readl(regs + H9G_ACTIVE_SUBFRAMES) != 0x200 ||
subframes != H9G_BOOT_SUBFRAMES)
return;
Expand All @@ -704,15 +751,20 @@ static void simpledrm_h9g_init(struct simpledrm_device *sdev)
}

/* The boot link runs at the same pixel clock for every cadence. */
sysfb->fb_mode.clock = panel->clock;
sysfb->fb_mode.htotal = panel->htotal;
sysfb->fb_mode.clock = timing.clock;
sysfb->fb_mode.flags = timing.flags;
sysfb->fb_mode.hsync_start = timing.hsync_start;
sysfb->fb_mode.hsync_end = timing.hsync_end;
sysfb->fb_mode.htotal = timing.htotal;
sysfb->fb_mode.vsync_start = timing.vsync_start;
sysfb->fb_mode.vsync_end = timing.vsync_end;
sysfb->fb_mode.vtotal = (H9G_ACTIVE_SUBFRAME_COUNT + subframes) *
panel->subframe_lines;
timing.subframe_lines;
for (i = 0; i < ARRAY_SIZE(sdev->h9g_modes); i++) {
sdev->h9g_modes[i] = sysfb->fb_mode;
sdev->h9g_modes[i].vtotal = (H9G_ACTIVE_SUBFRAME_COUNT +
simpledrm_h9g_extra_subframes[i]) *
panel->subframe_lines;
timing.subframe_lines;
}
}

Expand Down
Loading