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
41 changes: 33 additions & 8 deletions arch/arm64/boot/dts/exynos/google/gs201-panther.dts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* USB (NCM + ACM), the cluster watchdogs from gs201.dtsi, a
* simple-framebuffer on the buffer ABL leaves DPP0 scanning out, UFS, the
* three keys, the touchscreen with its rails on the main PMIC, the GPU, the
* haptics, the MAX77759's I2C bus with its fuel gauge, Bluetooth and the
* DSI command path to the panel. The display itself stays on
* simple-framebuffer.
* haptics, the MAX77759's I2C bus with its fuel gauge, Bluetooth, the DSI
* command path to the panel, and the display through gs-decon, which takes
* over from the simple-framebuffer.
*/

/dts-v1/;
Expand Down Expand Up @@ -38,7 +38,7 @@
* ABL leaves DECON0 -> DSIM0 -> panel (sdc-s6e3fc3) running in
* command mode with DPP0 scanning 0xfac00000 (RDMA_BASEADDR_Y8,
* read on this phone). simplefb scans it out and takes the size
* from this node; the panel under dsi0 only takes commands.
* from this node until gs-decon takes the screen over.
*/
framebuffer0: framebuffer@fac00000 {
compatible = "simple-framebuffer";
Expand Down Expand Up @@ -125,6 +125,21 @@
reg = <0x0 0xfac00000 (1080 * 2400 * 4)>;
no-map;
};

/*
* Scanout buffers for gs-decon: DPP0 takes 32-bit addresses and
* the DPU SysMMU is bypassed. Room for five 1080x2400 XRGB8888
* buffers. Reusable, so the pages serve movable allocations
* while unused.
*/
display_pool: display-pool {
compatible = "shared-dma-pool";
reusable;
size = <0x3800000>;
/* read with the root's #address-cells (2), not #size-cells */
alignment = <0x0 0x200000>;
alloc-ranges = <0x0 0x80000000 0x80000000>;
};
};
};

Expand Down Expand Up @@ -214,10 +229,9 @@
};

/*
* Display bring-up, gate D1 (device/panther/DISPLAY-PLAN.md): the DPU and
* DISP clock controllers, and DSIM0 with the panel, so the panel driver can
* take the bootloader's panel over and send it DCS commands. DECON0 stays
* disabled, and simplefb keeps scanning out.
* Display bring-up (device/panther/DISPLAY-PLAN.md): the DPU and DISP clock
* controllers, and DSIM0 with the panel (gate D1), so the panel driver can
* take the bootloader's panel over and send it DCS commands.
*/
&cmu_disp {
status = "okay";
Expand All @@ -227,6 +241,17 @@
status = "okay";
};

/*
* Flip-only KMS on the bootloader's pipeline (gate D3): gs-decon takes the
* screen over from simpledrm once it and the DSIM and panel drivers have
* probed.
*/
&decon0 {
memory-region = <&display_pool>, <&cont_splash_mem>;
memory-region-names = "pool", "boot-framebuffer";
status = "okay";
};

&dsi0 {
status = "okay";

Expand Down
115 changes: 90 additions & 25 deletions drivers/gpu/drm/google/gs-decon.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,27 @@ static const struct drm_display_mode gs_decon_modes[] = {
GS_DECON_MODE(120),
};

/*
* The Pixel 7's S6E3FC3 P10 at 1080x2400, as in Google's panel driver. The
* bootloader starts it at 60 Hz; its 90 Hz mode is not offered yet.
*/
static const struct drm_display_mode panther_decon_modes[] = {
{
.clock = (1080 + 32 + 12 + 26) * (2400 + 12 + 4 + 26) * 60 / 1000,
.hdisplay = 1080,
.hsync_start = 1080 + 32,
.hsync_end = 1080 + 32 + 12,
.htotal = 1080 + 32 + 12 + 26,
.vdisplay = 2400,
.vsync_start = 2400 + 12,
.vsync_end = 2400 + 12 + 4,
.vtotal = 2400 + 12 + 4 + 26,
.width_mm = 66,
.height_mm = 146,
.type = DRM_MODE_TYPE_DRIVER,
},
};

/*
* TG4B/TG4C timings from panel-gs-tg4b.c and panel-gs-tg4c.c, at 60 Hz (the
* bootloader's) and 120 Hz. TG4A uses different porches; DECON only needs
Expand Down Expand Up @@ -259,9 +280,16 @@ static const struct drm_display_mode hk3_decon_modes[] = {
HK3_DECON_MODE(120),
};

struct gs_decon_soc_data {
/* The modes of one panel; the first is the bootloader's. */
struct gs_decon_mode_set {
const struct drm_display_mode *modes;
unsigned int num_modes;
};

struct gs_decon_soc_data {
/* one per panel, picked by the size the bootloader scans out */
const struct gs_decon_mode_set *mode_sets;
unsigned int num_mode_sets;
u32 image_size_reg;
u32 source_offset_reg;
u32 shadow_update_mask;
Expand All @@ -276,21 +304,40 @@ struct gs_decon_soc_data {
bool vt_switch_fbdev_only;
};

static const struct gs_decon_mode_set gs_decon_mode_sets[] = {
{ gs_decon_modes, ARRAY_SIZE(gs_decon_modes) },
};

static const struct gs_decon_mode_set gs201_mode_sets[] = {
{ gs_decon_modes, ARRAY_SIZE(gs_decon_modes) },
{ panther_decon_modes, ARRAY_SIZE(panther_decon_modes) },
};

static const struct gs_decon_mode_set zumapro_mode_sets[] = {
{ tegu_decon_modes, ARRAY_SIZE(tegu_decon_modes) },
};

static const struct gs_decon_mode_set zuma_mode_sets[] = {
{ hk3_decon_modes, ARRAY_SIZE(hk3_decon_modes) },
};

static const struct gs_decon_soc_data gs201_decon_data = {
.modes = gs_decon_modes,
.num_modes = ARRAY_SIZE(gs_decon_modes),
.mode_sets = gs201_mode_sets,
.num_mode_sets = ARRAY_SIZE(gs201_mode_sets),
.image_size_reg = RDMA_IMG_SIZE,
.source_offset_reg = RDMA_SRC_OFFSET,
.shadow_update_mask = SHD_REG_UP_REQ_FLIP(SHD_REG_UP_REQ_ALL_WIN),
/* 1080-pixel rows (Pixel 7) get padded to 64 bytes by allocators */
.padded_pitch = true,
};

/*
* gs101 is gs201's DECON; the boot framebuffer and sleep handling below were
* found and tested on raven only, so they stay off for gs201.
*/
static const struct gs_decon_soc_data gs101_decon_data = {
.modes = gs_decon_modes,
.num_modes = ARRAY_SIZE(gs_decon_modes),
.mode_sets = gs_decon_mode_sets,
.num_mode_sets = ARRAY_SIZE(gs_decon_mode_sets),
.image_size_reg = RDMA_IMG_SIZE,
.source_offset_reg = RDMA_SRC_OFFSET,
.shadow_update_mask = SHD_REG_UP_REQ_FLIP(SHD_REG_UP_REQ_ALL_WIN),
Expand All @@ -299,8 +346,8 @@ static const struct gs_decon_soc_data gs101_decon_data = {
};

static const struct gs_decon_soc_data zumapro_decon_data = {
.modes = tegu_decon_modes,
.num_modes = ARRAY_SIZE(tegu_decon_modes),
.mode_sets = zumapro_mode_sets,
.num_mode_sets = ARRAY_SIZE(zumapro_mode_sets),
.image_size_reg = 0x001c,
.source_offset_reg = 0x0018,
.shadow_update_mask = SHD_REG_UP_REQ_FLIP(0x3fff),
Expand All @@ -312,8 +359,8 @@ static const struct gs_decon_soc_data zumapro_decon_data = {

/* G3 shares G4's CAL (cal_9865) and DECON0 registers. */
static const struct gs_decon_soc_data zuma_decon_data = {
.modes = hk3_decon_modes,
.num_modes = ARRAY_SIZE(hk3_decon_modes),
.mode_sets = zuma_mode_sets,
.num_mode_sets = ARRAY_SIZE(zuma_mode_sets),
.image_size_reg = 0x001c,
.source_offset_reg = 0x0018,
.shadow_update_mask = SHD_REG_UP_REQ_FLIP(0x3fff),
Expand All @@ -334,6 +381,9 @@ struct gs_decon {

struct device *dev;
const struct gs_decon_soc_data *soc;
/* the panel's modes, from soc->mode_sets */
const struct drm_display_mode *modes;
unsigned int num_modes;
void __iomem *regs;
void __iomem *dma;
int irq_fs;
Expand Down Expand Up @@ -459,6 +509,7 @@ static int gs_decon_check_boot_state(struct gs_decon *dc)
u32 src = readl(dc->dma + RDMA_SRC_SIZE);
u32 addr = readl(dc->dma + RDMA_BASEADDR_Y8);
u32 source_width, source_height;
unsigned int i;

if ((global & run) != run) {
dev_err(dc->dev, "DECON is not running in command mode (GLOBAL_CON 0x%08x)\n",
Expand All @@ -477,9 +528,17 @@ static int gs_decon_check_boot_state(struct gs_decon *dc)
}
/* the source width is the stride in pixels */
dc->pitch = source_width * 4;
if (dc->width != dc->soc->modes[0].hdisplay ||
dc->height != dc->soc->modes[0].vdisplay ||
source_height != dc->height || dc->pitch < dc->width * 4) {
for (i = 0; i < dc->soc->num_mode_sets; i++) {
const struct drm_display_mode *boot = &dc->soc->mode_sets[i].modes[0];

if (dc->width == boot->hdisplay && dc->height == boot->vdisplay) {
dc->modes = dc->soc->mode_sets[i].modes;
dc->num_modes = dc->soc->mode_sets[i].num_modes;
break;
}
}
if (!dc->modes || source_height != dc->height ||
dc->pitch < dc->width * 4) {
dev_err(dc->dev, "unexpected scanout size %ux%u (source %ux%u)\n",
dc->width, dc->height, source_width, source_height);
return -ENODEV;
Expand Down Expand Up @@ -659,9 +718,14 @@ static void gs_decon_set_scanout_locked(struct gs_decon *dc, dma_addr_t addr,
dc->xrgb = true;
}

/* G4's source width includes row padding, in pixels, not bytes. */
/*
* The source width includes row padding, in pixels, not bytes. On G4
* the height has its own register; on gs201 it shares this one.
*/
if (dc->soc->padded_pitch)
writel(pitch / 4, dc->dma + RDMA_SRC_SIZE);
writel(dc->soc->separate_source_height ? pitch / 4 :
(dc->height << 16) | (pitch / 4),
dc->dma + RDMA_SRC_SIZE);
writel(lower_32_bits(addr), dc->dma + RDMA_BASEADDR_Y8);
writel(readl(dc->regs + DECON_SHD_REG_UP_REQ) | dc->soc->shadow_update_mask,
dc->regs + DECON_SHD_REG_UP_REQ);
Expand Down Expand Up @@ -895,10 +959,10 @@ static unsigned int gs_decon_mode_hz(struct gs_decon *dc,
{
int i;

for (i = 0; i < dc->soc->num_modes; i++)
if (drm_mode_equal(mode, &dc->soc->modes[i]) &&
drm_mode_vrefresh(&dc->soc->modes[i]) <= dc->max_hz)
return drm_mode_vrefresh(&dc->soc->modes[i]);
for (i = 0; i < dc->num_modes; i++)
if (drm_mode_equal(mode, &dc->modes[i]) &&
drm_mode_vrefresh(&dc->modes[i]) <= dc->max_hz)
return drm_mode_vrefresh(&dc->modes[i]);

return 0;
}
Expand Down Expand Up @@ -929,12 +993,13 @@ static int gs_decon_plane_atomic_check(struct drm_plane *plane,
if (ret)
return ret;

/* G4 accepts padded RGB rows; older variants keep the boot layout. */
/* Padded RGB rows, up to the source width field's limit */
if (fb->width != dc->width || fb->height != dc->height ||
new->src_x || new->src_y ||
(dc->soc->padded_pitch ?
(fb->pitches[0] < dc->width * 4 || fb->pitches[0] % 4 ||
fb->pitches[0] / 4 > 0xffffff) :
fb->pitches[0] / 4 > (dc->soc->separate_source_height ?
0xffffff : 0xffff)) :
fb->pitches[0] != dc->pitch)) {
drm_dbg_kms(plane->dev, "fb %ux%u pitch %u does not match %ux%u pitch %u\n",
fb->width, fb->height, fb->pitches[0],
Expand Down Expand Up @@ -1131,13 +1196,13 @@ static int gs_decon_connector_get_modes(struct drm_connector *connector)
struct gs_decon *dc = drm_to_decon(connector->dev);
int i, count = 0;

for (i = 0; i < dc->soc->num_modes; i++) {
unsigned int hz = drm_mode_vrefresh(&dc->soc->modes[i]);
for (i = 0; i < dc->num_modes; i++) {
unsigned int hz = drm_mode_vrefresh(&dc->modes[i]);
struct drm_display_mode *mode;

if (hz > dc->max_hz)
continue;
mode = drm_mode_duplicate(connector->dev, &dc->soc->modes[i]);
mode = drm_mode_duplicate(connector->dev, &dc->modes[i]);
if (!mode)
break;
if (hz == dc->max_hz)
Expand All @@ -1146,8 +1211,8 @@ static int gs_decon_connector_get_modes(struct drm_connector *connector)
drm_mode_probed_add(connector, mode);
count++;
}
connector->display_info.width_mm = dc->soc->modes[0].width_mm;
connector->display_info.height_mm = dc->soc->modes[0].height_mm;
connector->display_info.width_mm = dc->modes[0].width_mm;
connector->display_info.height_mm = dc->modes[0].height_mm;

return count;
}
Expand Down
8 changes: 8 additions & 0 deletions drivers/gpu/drm/google/gs-dsim-cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ static const struct gs_dsim_rate gs_dsim_rates[][2] = {
{ .hz = 60, .underrun = 0x2235, .te_ctrl1 = 0x34c53c1e },
{ .hz = 120, .underrun = 0x06a7, .te_ctrl1 = 0x1a621e0f },
},
/*
* Pixel 7, S6E3FC3 P10: the bootloader's 60 Hz pair, read on the
* phone. Its 90 Hz has no timers yet, so the second slot stays
* empty and the link is never switched.
*/
{
{ .hz = 60, .underrun = 0x1cf8, .te_ctrl1 = 0x2a82306d },
},
};

struct gs_dsim {
Expand Down
Loading