diff --git a/arch/arm64/boot/dts/exynos/google/gs201-panther.dts b/arch/arm64/boot/dts/exynos/google/gs201-panther.dts index 25594305a5..93ad83c2da 100644 --- a/arch/arm64/boot/dts/exynos/google/gs201-panther.dts +++ b/arch/arm64/boot/dts/exynos/google/gs201-panther.dts @@ -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/; @@ -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"; @@ -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>; + }; }; }; @@ -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"; @@ -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"; diff --git a/drivers/gpu/drm/google/gs-decon.c b/drivers/gpu/drm/google/gs-decon.c index 1a5dd8c216..384a89dc3f 100644 --- a/drivers/gpu/drm/google/gs-decon.c +++ b/drivers/gpu/drm/google/gs-decon.c @@ -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 @@ -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; @@ -276,12 +304,31 @@ 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, }; /* @@ -289,8 +336,8 @@ static const struct gs_decon_soc_data gs201_decon_data = { * 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), @@ -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), @@ -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), @@ -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; @@ -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", @@ -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; @@ -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); @@ -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; } @@ -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], @@ -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) @@ -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; } diff --git a/drivers/gpu/drm/google/gs-dsim-cmd.c b/drivers/gpu/drm/google/gs-dsim-cmd.c index cdb67ffd0c..7edcb71919 100644 --- a/drivers/gpu/drm/google/gs-dsim-cmd.c +++ b/drivers/gpu/drm/google/gs-dsim-cmd.c @@ -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 { diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e3fc3.c b/drivers/gpu/drm/panel/panel-samsung-s6e3fc3.c index 56d97ec744..546abefae0 100644 --- a/drivers/gpu/drm/panel/panel-samsung-s6e3fc3.c +++ b/drivers/gpu/drm/panel/panel-samsung-s6e3fc3.c @@ -4,20 +4,31 @@ * * Command sequences from Google's GPL panel driver * (google-modules/display/samsung/panel/panel-samsung-s6e3fc3-p10.c), - * restricted to the EVT1 and later panels that ship in phones. Local HBM, - * low-power (AOD) modes and the panel revision reads are left out. + * restricted to the EVT1 and later panels that ship in phones. Low-power + * (AOD) modes and the panel revision reads are left out. * * The bootloader powers the panel on and leaves it running. When the * reset line is released at probe, the driver takes the panel over as it * is: it sends nothing until the brightness or the power state changes. + * + * Local high brightness mode (LHBM) lights a bright circle over the + * under-display fingerprint sensor. It is controlled through the backlight + * device's local_hbm_mode attribute, named as in Google's driver, and + * switches itself off after local_hbm_max_timeout milliseconds. */ #include #include +#include +#include #include #include #include +#include #include +#include +#include +#include #include