From: Maxime Ripard <mripard@kernel.org>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>,
Simona Vetter <simona@ffwll.ch>,
Andrzej Hajda <andrzej.hajda@intel.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
Robert Foss <rfoss@kernel.org>,
Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
Jonas Karlman <jonas@kwiboo.se>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Jyri Sarha <jyri.sarha@iki.fi>,
Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Cc: Devarsh Thakkar <devarsht@ti.com>,
dri-devel@lists.freedesktop.org,
Maxime Ripard <mripard@kernel.org>
Subject: [PATCH v9 36/42] drm/tidss: dispc: Add hardware state readout helpers
Date: Fri, 20 Nov 2026 13:55:28 +0100 [thread overview]
Message-ID: <20261120-drm-state-readout-v9-36-a67c2b45b8ec@kernel.org> (raw)
In-Reply-To: <20261120-drm-state-readout-v9-0-a67c2b45b8ec@kernel.org>
The state readout of the tidss CRTCs, planes and OLDI transmitters has
to decode what the firmware programmed in the DISPC registers back into
KMS state. However, the driver only has helpers to program those
registers.
Add helpers to read out the video ports: whether one is enabled, its
display mode, its bus format and its bus flags. The timing registers
don't hold the refresh rate, so dispc_vp_readout_mode() derives it by
matching the video port clock rate against the 30, 50 and 60 Hz
standard refresh rates, with and without the 1000/1001 factor, and
fails if none of them is close enough. The bus format is decoded from
the DATALINES field, along with the OLDI mapping on the AM65x video
ports that drive an OLDI transmitter.
Add helpers to read out the planes: whether one is enabled, the video
port, overlay layer and position it is routed to with
dispc_ovr_get_plane(), its picture and output sizes, its format, global
alpha and blend mode, and its pixel and row increments.
Two existing paths also need to cope with a pipeline the firmware left
running:
- dispc_vp_init() disables DPIENABLE for every video port. Skip the
ones that are enabled, so that their output keeps running until it
is read out.
- dispc_plane_setup() programs the DMA address of the framebuffer. A
framebuffer reconstructed from a readout has no GEM object to
derive it from, and the hardware is already scanning out that
buffer, so keep the address the firmware programmed.
Finally, split dispc_vp_set_dpi_output() out of dispc_vp_setup(), so
that the CRTC can record the DPI output state of a video port it takes
over without going through a full setup.
Signed-off-by: Maxime Ripard <mripard@kernel.org>
---
drivers/gpu/drm/tidss/tidss_dispc.c | 444 +++++++++++++++++++++++++++++++++++-
drivers/gpu/drm/tidss/tidss_dispc.h | 22 ++
2 files changed, 457 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/tidss/tidss_dispc.c b/drivers/gpu/drm/tidss/tidss_dispc.c
index e186c63ba5fb..8e61216d4532 100644
--- a/drivers/gpu/drm/tidss/tidss_dispc.c
+++ b/drivers/gpu/drm/tidss/tidss_dispc.c
@@ -1149,10 +1149,16 @@ void dispc_vp_enable(struct dispc_device *dispc, u32 hw_videoport)
{
VP_REG_FLD_MOD(dispc, hw_videoport, DISPC_VP_CONTROL, 1,
DISPC_VP_CONTROL_ENABLE_MASK);
}
+bool dispc_vp_is_enabled(struct dispc_device *dispc, u32 hw_videoport)
+{
+ return FIELD_GET(DISPC_VP_CONTROL_ENABLE_MASK,
+ dispc_vp_read(dispc, hw_videoport, DISPC_VP_CONTROL));
+}
+
void dispc_vp_disable(struct dispc_device *dispc, u32 hw_videoport)
{
VP_REG_FLD_MOD(dispc, hw_videoport, DISPC_VP_CONTROL, 0,
DISPC_VP_CONTROL_ENABLE_MASK);
}
@@ -1399,10 +1405,232 @@ int dispc_vp_set_clk_rate(struct dispc_device *dispc, u32 hw_videoport,
hw_videoport, clk_get_rate(dispc->vp_clk[hw_videoport]), rate);
return 0;
}
+static unsigned long calc_pixel_clock_hz(unsigned int htotal,
+ unsigned int vtotal,
+ unsigned int refresh,
+ unsigned int freq_div)
+{
+ u64 rate = (u64)htotal * vtotal * refresh;
+
+ return div_u64(rate * 1000, freq_div);
+}
+
+static const unsigned int refresh_tries[] = {30, 50, 60};
+static const unsigned int refresh_factors_tries[] = {1000, 1001};
+
+static unsigned int dispc_find_closest_refresh_rate_from_clk(struct drm_device *dev,
+ struct clk *clk,
+ unsigned int htotal,
+ unsigned int vtotal,
+ unsigned long *pixel_clock_hz)
+{
+ unsigned long actual_clk_rate = clk_get_rate(clk);
+ unsigned long best_clk_rate = 0;
+ unsigned long best_rate_diff = ULONG_MAX;
+ unsigned int best_refresh = 0;
+ unsigned int i, j;
+
+ drm_dbg(dev, "Actual clock rate is %lu\n", actual_clk_rate);
+
+ for (i = 0; i < ARRAY_SIZE(refresh_tries); i++) {
+ for (j = 0; j < ARRAY_SIZE(refresh_factors_tries); j++) {
+ unsigned int try_refresh = refresh_tries[i];
+ unsigned int try_factor = refresh_factors_tries[j];
+ unsigned long try_clk_rate = calc_pixel_clock_hz(htotal,
+ vtotal,
+ try_refresh,
+ try_factor);
+ unsigned long diff;
+
+ drm_dbg(dev, "Evaluating refresh %u, factor %u, rate %lu\n",
+ try_refresh, try_factor, try_clk_rate);
+
+ if (try_clk_rate == actual_clk_rate) {
+ drm_dbg(dev, "Found exact match. Stopping.\n");
+ best_refresh = try_refresh;
+ best_clk_rate = try_clk_rate;
+ goto out;
+ }
+
+
+ diff = abs_diff(actual_clk_rate, try_clk_rate);
+ if (diff < best_rate_diff) {
+ drm_dbg(dev, "Found new candidate. Difference is %lu\n", diff);
+ best_refresh = try_refresh;
+ best_clk_rate = try_clk_rate;
+ best_rate_diff = diff;
+ }
+ }
+ }
+
+ /*
+ * The video port clock doesn't match any standard refresh rate,
+ * so the mode we would report would be plain wrong. Report the
+ * configuration as unsupported by returning 0, so that the
+ * caller falls back on the regular initialization path.
+ *
+ * We tolerate the same 5% difference that
+ * dispc_vp_set_clk_rate() accepts when programming the clock.
+ */
+ if (dispc_pclk_diff(best_clk_rate, actual_clk_rate) > 5) {
+ drm_dbg(dev, "Clock rate %lu doesn't match any standard refresh rate\n",
+ actual_clk_rate);
+ return 0;
+ }
+
+out:
+ drm_dbg(dev, "Best candidate is %u Hz, pixel clock rate %lu Hz",
+ best_refresh, best_clk_rate);
+
+ if (pixel_clock_hz)
+ *pixel_clock_hz = best_clk_rate;
+
+ return best_refresh;
+}
+
+int dispc_vp_readout_mode(struct dispc_device *dispc,
+ u32 hw_videoport,
+ struct drm_display_mode *mode)
+{
+ struct tidss_device *tidss = dispc->tidss;
+ struct drm_device *dev = &tidss->ddev;
+ unsigned long pixel_clock;
+ unsigned int refresh;
+ u16 hdisplay, hfp, hsw, hbp;
+ u16 vdisplay, vfp, vsw, vbp;
+ u32 val;
+
+ val = dispc_vp_read(dispc, hw_videoport, DISPC_VP_SIZE_SCREEN);
+ hdisplay = FIELD_GET(DISPC_VP_SIZE_SCREEN_HDISPLAY_MASK, val) + 1;
+ vdisplay = FIELD_GET(DISPC_VP_SIZE_SCREEN_VDISPLAY_MASK, val) + 1;
+
+ mode->hdisplay = hdisplay;
+ mode->vdisplay = vdisplay;
+
+ val = dispc_vp_read(dispc, hw_videoport, DISPC_VP_TIMING_H);
+ hsw = FIELD_GET(DISPC_VP_TIMING_H_SYNC_PULSE_MASK, val) + 1;
+ hfp = FIELD_GET(DISPC_VP_TIMING_H_FRONT_PORCH_MASK, val) + 1;
+ hbp = FIELD_GET(DISPC_VP_TIMING_H_BACK_PORCH_MASK, val) + 1;
+
+ mode->hsync_start = hdisplay + hfp;
+ mode->hsync_end = hdisplay + hfp + hsw;
+ mode->htotal = hdisplay + hfp + hsw + hbp;
+
+ val = dispc_vp_read(dispc, hw_videoport, DISPC_VP_TIMING_V);
+ vsw = FIELD_GET(DISPC_VP_TIMING_V_SYNC_PULSE_MASK, val) + 1;
+ vfp = FIELD_GET(DISPC_VP_TIMING_V_FRONT_PORCH_MASK, val);
+ vbp = FIELD_GET(DISPC_VP_TIMING_V_BACK_PORCH_MASK, val);
+
+ mode->vsync_start = vdisplay + vfp;
+ mode->vsync_end = vdisplay + vfp + vsw;
+ mode->vtotal = vdisplay + vfp + vsw + vbp;
+
+ refresh = dispc_find_closest_refresh_rate_from_clk(dev,
+ dispc->vp_clk[hw_videoport],
+ mode->htotal,
+ mode->vtotal,
+ &pixel_clock);
+ if (!refresh)
+ return -EINVAL;
+
+ mode->clock = pixel_clock / 1000;
+
+ val = dispc_vp_read(dispc, hw_videoport, DISPC_VP_POL_FREQ);
+ if (FIELD_GET(DISPC_VP_POL_FREQ_IVS_MASK, val))
+ mode->flags |= DRM_MODE_FLAG_NVSYNC;
+ else
+ mode->flags |= DRM_MODE_FLAG_PVSYNC;
+
+ if (FIELD_GET(DISPC_VP_POL_FREQ_IHS_MASK, val))
+ mode->flags |= DRM_MODE_FLAG_NHSYNC;
+ else
+ mode->flags |= DRM_MODE_FLAG_PHSYNC;
+
+ mode->type |= DRM_MODE_TYPE_DRIVER;
+ drm_mode_set_name(mode);
+ drm_mode_set_crtcinfo(mode, 0);
+
+ return 0;
+}
+
+int dispc_vp_get_bus_format(struct dispc_device *dispc, u32 hw_videoport,
+ u32 *bus_fmt)
+{
+ static const u32 datalines_to_width[] = { 12, 16, 18, 24, 30, 36 };
+ struct tidss_device *tidss = dispc->tidss;
+ struct drm_device *dev = &tidss->ddev;
+ u32 datalines, data_width;
+ unsigned int i;
+
+ datalines = VP_REG_GET(dispc, hw_videoport, DISPC_VP_CONTROL,
+ DISPC_VP_CONTROL_DATALINES_MASK);
+
+ if (datalines < ARRAY_SIZE(datalines_to_width)) {
+ data_width = datalines_to_width[datalines];
+ } else {
+ drm_dbg(dev, "Unknown DATALINES encoding %u on %s\n",
+ datalines, dispc->feat->vp_name[hw_videoport]);
+ return -EINVAL;
+ }
+
+ if (dispc_vp_is_am65x_oldi(dispc->feat, hw_videoport)) {
+ u32 oldi_cfg = dispc_vp_read(dispc, hw_videoport,
+ DISPC_VP_DSS_OLDI_CFG);
+ u32 map = FIELD_GET(DISPC_VP_DSS_OLDI_CFG_MAP_MASK, oldi_cfg);
+
+ for (i = 0; i < ARRAY_SIZE(dispc_bus_formats); i++) {
+ if (dispc_bus_formats[i].is_oldi_fmt &&
+ dispc_bus_formats[i].data_width == data_width &&
+ dispc_bus_formats[i].am65x_oldi_mode_reg_val == map) {
+ *bus_fmt = dispc_bus_formats[i].bus_fmt;
+ return 0;
+ }
+ }
+
+ drm_dbg(dev, "Unknown OLDI mapping %u on %s\n", map,
+ dispc->feat->vp_name[hw_videoport]);
+ return -EINVAL;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(dispc_bus_formats); i++) {
+ if (!dispc_bus_formats[i].is_oldi_fmt &&
+ dispc_bus_formats[i].data_width == data_width) {
+ *bus_fmt = dispc_bus_formats[i].bus_fmt;
+ return 0;
+ }
+ }
+
+ return -EINVAL;
+}
+
+u32 dispc_vp_get_bus_flags(struct dispc_device *dispc, u32 hw_videoport)
+{
+ u32 flags = 0;
+ u32 val;
+
+ val = dispc_vp_read(dispc, hw_videoport, DISPC_VP_POL_FREQ);
+ if (FIELD_GET(DISPC_VP_POL_FREQ_IPC_MASK, val))
+ flags |= DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE;
+ else
+ flags |= DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE;
+
+ if (FIELD_GET(DISPC_VP_POL_FREQ_IEO_MASK, val))
+ flags |= DRM_BUS_FLAG_DE_LOW;
+ else
+ flags |= DRM_BUS_FLAG_DE_HIGH;
+
+ if (FIELD_GET(DISPC_VP_POL_FREQ_RF_MASK, val))
+ flags |= DRM_BUS_FLAG_SYNC_DRIVE_POSEDGE;
+ else
+ flags |= DRM_BUS_FLAG_SYNC_DRIVE_NEGEDGE;
+
+ return flags;
+}
+
/* OVR */
static void dispc_k2g_ovr_set_plane(struct dispc_device *dispc,
u32 hw_plane, u32 hw_videoport,
u32 x, u32 y, u32 layer)
{
@@ -1471,10 +1699,97 @@ void dispc_ovr_enable_layer(struct dispc_device *dispc,
OVR_REG_FLD_MOD(dispc, hw_videoport, DISPC_OVR_ATTRIBUTES(layer),
!!enable, DISPC_OVR_ATTRIBUTES_ENABLE_MASK);
}
+/**
+ * dispc_ovr_get_plane - find the overlay layer a plane is routed to
+ * @dispc: the dispc
+ * @hw_plane: the plane to look for
+ * @hw_videoport: returned video port the plane is routed to
+ * @x: returned X position of the plane
+ * @y: returned Y position of the plane
+ * @layer: returned overlay layer index the plane is routed to
+ *
+ * Reads the overlay manager registers to find which video port, at
+ * which position and in which layer, a plane is currently routed to.
+ * The layer index matches the normalized zpos the plane was committed
+ * with, as that is what dispc_ovr_set_plane() uses as the layer index.
+ *
+ * The CHANNELIN field of a disabled layer keeps its stale value, so
+ * only the enabled layers are considered.
+ *
+ * RETURNS:
+ *
+ * 0 on success, -ENODEV if the plane is not routed to any enabled
+ * overlay layer.
+ */
+int dispc_ovr_get_plane(struct dispc_device *dispc, u32 hw_plane,
+ u32 *hw_videoport, int *x, int *y, u32 *layer)
+{
+ u32 vp, l;
+
+ switch (dispc->feat->subrev) {
+ case DISPC_K2G: {
+ u32 val;
+
+ /*
+ * On K2G there is only one plane and no overlay
+ * manager: the position is programmed in the VID
+ * pipeline registers.
+ */
+ val = dispc_vid_read(dispc, hw_plane, DISPC_VID_K2G_POSITION);
+ *hw_videoport = 0;
+ *layer = 0;
+ *x = val & 0xffff;
+ *y = val >> 16;
+ return 0;
+ }
+ case DISPC_AM625:
+ case DISPC_AM62L:
+ case DISPC_AM65X:
+ case DISPC_J721E:
+ for (vp = 0; vp < dispc->feat->num_vps; vp++) {
+ for (l = 0; l < dispc->feat->num_vids; l++) {
+ u32 attrs = dispc_ovr_read(dispc, vp,
+ DISPC_OVR_ATTRIBUTES(l));
+
+ if (!(attrs & DISPC_OVR_ATTRIBUTES_ENABLE_MASK))
+ continue;
+
+ if (FIELD_GET(DISPC_OVR_ATTRIBUTES_CHANNELIN_MASK,
+ attrs) != dispc->feat->vid_info[hw_plane].hw_id)
+ continue;
+
+ *hw_videoport = vp;
+ *layer = l;
+
+ if (dispc->feat->subrev == DISPC_J721E) {
+ u32 attrs2 = dispc_ovr_read(dispc, vp,
+ DISPC_OVR_ATTRIBUTES2(l));
+
+ *x = FIELD_GET(DISPC_OVR_ATTRIBUTES2_POSX_MASK,
+ attrs2);
+ *y = FIELD_GET(DISPC_OVR_ATTRIBUTES2_POSY_MASK,
+ attrs2);
+ } else {
+ *x = FIELD_GET(DISPC_OVR_ATTRIBUTES_POSX_MASK,
+ attrs);
+ *y = FIELD_GET(DISPC_OVR_ATTRIBUTES_POSY_MASK,
+ attrs);
+ }
+
+ return 0;
+ }
+ }
+
+ return -ENODEV;
+ default:
+ return -ENODEV;
+ }
+}
+
/* CSC */
enum csc_ctm {
CSC_RR, CSC_RG, CSC_RB,
CSC_GR, CSC_GG, CSC_GB,
CSC_BR, CSC_BG, CSC_BB,
@@ -2043,10 +2358,21 @@ static const struct {
{ DRM_FORMAT_UYVY, 0x3f, },
{ DRM_FORMAT_NV12, 0x3d, },
};
+static u32 dispc_plane_find_fourcc_by_dss_code(u8 code)
+{
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(dispc_color_formats); ++i)
+ if (dispc_color_formats[i].dss_code == code)
+ return dispc_color_formats[i].fourcc;
+
+ return 0;
+}
+
static void dispc_plane_set_pixel_format(struct dispc_device *dispc,
u32 hw_plane, u32 fourcc)
{
unsigned int i;
@@ -2129,21 +2455,30 @@ void dispc_plane_setup(struct dispc_device *dispc, u32 hw_plane,
{
bool lite = dispc->feat->vid_info[hw_plane].is_lite;
u32 fourcc = state->fb->format->format;
u16 cpp = state->fb->format->cpp[0];
u32 fb_width = state->fb->pitches[0] / cpp;
- dma_addr_t dma_addr = drm_fb_dma_get_gem_addr(state->fb, state, 0);
struct dispc_scaling_params scale;
dispc_vid_calc_scaling(dispc, state, &scale, lite);
dispc_plane_set_pixel_format(dispc, hw_plane, fourcc);
- dispc_vid_write(dispc, hw_plane, DISPC_VID_BA_0, dma_addr & 0xffffffff);
- dispc_vid_write(dispc, hw_plane, DISPC_VID_BA_EXT_0, (u64)dma_addr >> 32);
- dispc_vid_write(dispc, hw_plane, DISPC_VID_BA_1, dma_addr & 0xffffffff);
- dispc_vid_write(dispc, hw_plane, DISPC_VID_BA_EXT_1, (u64)dma_addr >> 32);
+ /*
+ * A framebuffer reconstructed from a hardware state readout has
+ * no GEM object to derive the DMA address from. The hardware is
+ * already scanning out that buffer, so keep the address the
+ * firmware programmed.
+ */
+ if (state->fb->obj[0]) {
+ dma_addr_t dma_addr = drm_fb_dma_get_gem_addr(state->fb, state, 0);
+
+ dispc_vid_write(dispc, hw_plane, DISPC_VID_BA_0, dma_addr & 0xffffffff);
+ dispc_vid_write(dispc, hw_plane, DISPC_VID_BA_EXT_0, (u64)dma_addr >> 32);
+ dispc_vid_write(dispc, hw_plane, DISPC_VID_BA_1, dma_addr & 0xffffffff);
+ dispc_vid_write(dispc, hw_plane, DISPC_VID_BA_EXT_1, (u64)dma_addr >> 32);
+ }
dispc_vid_write(dispc, hw_plane, DISPC_VID_PICTURE_SIZE,
FIELD_PREP(DISPC_VID_PICTURE_SIZE_MEMSIZEY_MASK, scale.in_h - 1) |
FIELD_PREP(DISPC_VID_PICTURE_SIZE_MEMSIZEX_MASK, scale.in_w - 1));
@@ -2208,16 +2543,97 @@ void dispc_plane_setup(struct dispc_device *dispc, u32 hw_plane,
else
VID_REG_FLD_MOD(dispc, hw_plane, DISPC_VID_ATTRIBUTES, 0,
DISPC_VID_ATTRIBUTES_PREMULTIPLYALPHA_MASK);
}
+void dispc_plane_get_picture_size(struct dispc_device *dispc, u32 hw_plane,
+ unsigned int *width, unsigned int *height)
+{
+ u32 val;
+ u16 w, h;
+
+ val = dispc_vid_read(dispc, hw_plane, DISPC_VID_PICTURE_SIZE);
+ w = FIELD_GET(DISPC_VID_PICTURE_SIZE_MEMSIZEX_MASK, val);
+ h = FIELD_GET(DISPC_VID_PICTURE_SIZE_MEMSIZEY_MASK, val);
+
+ *width = w + 1;
+ *height = h + 1;
+}
+
+void dispc_plane_get_size(struct dispc_device *dispc, u32 hw_plane,
+ unsigned int *width, unsigned int *height)
+{
+ bool lite = dispc->feat->vid_info[hw_plane].is_lite;
+
+ if (!lite) {
+ u32 val = dispc_vid_read(dispc, hw_plane, DISPC_VID_SIZE);
+ *width = FIELD_GET(DISPC_VID_SIZE_SIZEX_MASK, val) + 1;
+ *height = FIELD_GET(DISPC_VID_SIZE_SIZEY_MASK, val) + 1;
+ } else {
+ dispc_plane_get_picture_size(dispc, hw_plane, width, height);
+ }
+}
+
+const struct drm_format_info *
+dispc_plane_get_current_format(struct dispc_device *dispc, u32 hw_plane)
+{
+ const struct drm_format_info *info;
+ u32 fourcc;
+ u32 val;
+
+ val = dispc_vid_read(dispc, hw_plane, DISPC_VID_ATTRIBUTES);
+ fourcc = dispc_plane_find_fourcc_by_dss_code(
+ FIELD_GET(DISPC_VID_ATTRIBUTES_FORMAT_MASK, val));
+ if (!fourcc)
+ return ERR_PTR(-EINVAL);
+
+ info = drm_format_info(fourcc);
+ if (!info)
+ return ERR_PTR(-EINVAL);
+
+ return info;
+}
+
+u8 dispc_plane_get_global_alpha(struct dispc_device *dispc, u32 hw_plane)
+{
+ return FIELD_GET(DISPC_VID_GLOBAL_ALPHA_GLOBALALPHA_MASK,
+ dispc_vid_read(dispc, hw_plane,
+ DISPC_VID_GLOBAL_ALPHA));
+}
+
+u32 dispc_plane_get_pixel_inc(struct dispc_device *dispc, u32 hw_plane)
+{
+ return dispc_vid_read(dispc, hw_plane, DISPC_VID_PIXEL_INC);
+}
+
+u32 dispc_plane_get_row_inc(struct dispc_device *dispc, u32 hw_plane)
+{
+ return dispc_vid_read(dispc, hw_plane, DISPC_VID_ROW_INC);
+}
+
+u16 dispc_plane_get_blend_mode(struct dispc_device *dispc, u32 hw_plane)
+{
+ u32 val = dispc_vid_read(dispc, hw_plane, DISPC_VID_ATTRIBUTES);
+
+ if (FIELD_GET(DISPC_VID_ATTRIBUTES_PREMULTIPLYALPHA_MASK, val))
+ return DRM_MODE_BLEND_PREMULTI;
+ else
+ return DRM_MODE_BLEND_COVERAGE;
+}
+
void dispc_plane_enable(struct dispc_device *dispc, u32 hw_plane, bool enable)
{
VID_REG_FLD_MOD(dispc, hw_plane, DISPC_VID_ATTRIBUTES, !!enable,
DISPC_VID_ATTRIBUTES_ENABLE_MASK);
}
+bool dispc_plane_is_enabled(struct dispc_device *dispc, u32 hw_plane)
+{
+ return FIELD_GET(DISPC_VID_ATTRIBUTES_ENABLE_MASK,
+ dispc_vid_read(dispc, hw_plane, DISPC_VID_ATTRIBUTES));
+}
+
static u32 dispc_vid_get_fifo_size(struct dispc_device *dispc, u32 hw_plane)
{
return VID_REG_GET(dispc, hw_plane, DISPC_VID_BUF_SIZE_STATUS,
DISPC_VID_BUF_SIZE_STATUS_BUFSIZE_MASK);
}
@@ -2371,15 +2787,19 @@ static void dispc_vp_init(struct dispc_device *dispc)
for (i = 0; i < dispc->feat->num_vps; i++) {
/* Enable the gamma Shadow bit-field for all VPs*/
VP_REG_FLD_MOD(dispc, i, DISPC_VP_CONFIG, 1,
DISPC_VP_CONFIG_GAMMAENABLE_MASK);
- if (dispc->feat->has_vp_control_dpienable) {
- /* Disable DPIENABLE for all VPs */
+ /*
+ * Disable DPIENABLE for all VPs, but the ones left
+ * enabled, by the firmware for example, so that their
+ * output keeps running and can be read out.
+ */
+ if (dispc->feat->has_vp_control_dpienable &&
+ !dispc_vp_is_enabled(dispc, i))
VP_REG_FLD_MOD(dispc, i, DISPC_VP_CONTROL, 0,
DISPC_VP_CONTROL_DPIENABLE_MASK);
- }
}
}
static void dispc_initial_config(struct dispc_device *dispc)
{
@@ -2706,15 +3126,21 @@ static void dispc_vp_set_color_mgmt(struct dispc_device *dispc,
dispc_k2g_vp_set_ctm(dispc, hw_videoport, ctm);
else
dispc_k3_vp_set_ctm(dispc, hw_videoport, ctm);
}
+void dispc_vp_set_dpi_output(struct dispc_device *dispc, u32 hw_videoport,
+ bool dpi_output)
+{
+ dispc->vp_data[hw_videoport].dpi_output = dpi_output;
+}
+
void dispc_vp_setup(struct dispc_device *dispc, u32 hw_videoport,
const struct drm_crtc_state *state, bool newmodeset,
bool dpi_output)
{
- dispc->vp_data[hw_videoport].dpi_output = dpi_output;
+ dispc_vp_set_dpi_output(dispc, hw_videoport, dpi_output);
dispc_vp_set_default_color(dispc, hw_videoport, 0);
dispc_vp_set_color_mgmt(dispc, hw_videoport, state, newmodeset);
}
int dispc_runtime_suspend(struct dispc_device *dispc)
diff --git a/drivers/gpu/drm/tidss/tidss_dispc.h b/drivers/gpu/drm/tidss/tidss_dispc.h
index dcd4d3b18ef4..4abcb9e679ac 100644
--- a/drivers/gpu/drm/tidss/tidss_dispc.h
+++ b/drivers/gpu/drm/tidss/tidss_dispc.h
@@ -109,14 +109,17 @@ dispc_irq_t dispc_read_and_clear_irqstatus(struct dispc_device *dispc);
void dispc_ovr_set_plane(struct dispc_device *dispc, u32 hw_plane,
u32 hw_videoport, u32 x, u32 y, u32 layer);
void dispc_ovr_enable_layer(struct dispc_device *dispc,
u32 hw_videoport, u32 layer, bool enable);
+int dispc_ovr_get_plane(struct dispc_device *dispc, u32 hw_plane,
+ u32 *hw_videoport, int *x, int *y, u32 *layer);
void dispc_vp_prepare(struct dispc_device *dispc, u32 hw_videoport,
const struct drm_crtc_state *state);
void dispc_vp_enable(struct dispc_device *dispc, u32 hw_videoport);
+bool dispc_vp_is_enabled(struct dispc_device *dispc, u32 hw_videoport);
void dispc_vp_disable(struct dispc_device *dispc, u32 hw_videoport);
void dispc_vp_unprepare(struct dispc_device *dispc, u32 hw_videoport);
bool dispc_vp_go_busy(struct dispc_device *dispc, u32 hw_videoport);
void dispc_vp_go(struct dispc_device *dispc, u32 hw_videoport);
int dispc_vp_bus_check(struct dispc_device *dispc, u32 hw_videoport,
@@ -126,24 +129,43 @@ enum drm_mode_status dispc_vp_mode_valid(struct dispc_device *dispc,
const struct drm_display_mode *mode);
int dispc_vp_enable_clk(struct dispc_device *dispc, u32 hw_videoport);
void dispc_vp_disable_clk(struct dispc_device *dispc, u32 hw_videoport);
int dispc_vp_set_clk_rate(struct dispc_device *dispc, u32 hw_videoport,
unsigned long rate);
+void dispc_vp_set_dpi_output(struct dispc_device *dispc, u32 hw_videoport,
+ bool dpi_output);
void dispc_vp_setup(struct dispc_device *dispc, u32 hw_videoport,
const struct drm_crtc_state *state, bool newmodeset,
bool dpi_output);
+int dispc_vp_readout_mode(struct dispc_device *dispc,
+ u32 hw_videoport,
+ struct drm_display_mode *mode);
+int dispc_vp_get_bus_format(struct dispc_device *dispc, u32 hw_videoport,
+ u32 *bus_fmt);
+u32 dispc_vp_get_bus_flags(struct dispc_device *dispc, u32 hw_videoport);
int dispc_runtime_suspend(struct dispc_device *dispc);
int dispc_runtime_resume(struct dispc_device *dispc);
int dispc_plane_check(struct dispc_device *dispc, u32 hw_plane,
const struct drm_plane_state *state,
u32 hw_videoport);
void dispc_plane_setup(struct dispc_device *dispc, u32 hw_plane,
struct drm_plane_state *state,
u32 hw_videoport);
+void dispc_plane_get_picture_size(struct dispc_device *dispc, u32 hw_plane,
+ unsigned int *width, unsigned int *height);
+void dispc_plane_get_size(struct dispc_device *dispc, u32 hw_plane,
+ unsigned int *width, unsigned int *height);
+const struct drm_format_info *
+dispc_plane_get_current_format(struct dispc_device *dispc, u32 hw_plane);
+u8 dispc_plane_get_global_alpha(struct dispc_device *dispc, u32 hw_plane);
+u32 dispc_plane_get_pixel_inc(struct dispc_device *dispc, u32 hw_plane);
+u32 dispc_plane_get_row_inc(struct dispc_device *dispc, u32 hw_plane);
+u16 dispc_plane_get_blend_mode(struct dispc_device *dispc, u32 hw_plane);
void dispc_plane_enable(struct dispc_device *dispc, u32 hw_plane, bool enable);
+bool dispc_plane_is_enabled(struct dispc_device *dispc, u32 hw_plane);
const u32 *dispc_plane_formats(struct dispc_device *dispc, unsigned int *len);
int dispc_reset_hw(struct dispc_device *dispc);
int dispc_init(struct tidss_device *tidss);
void dispc_remove(struct tidss_device *tidss);
--
2.56.1
next prev parent reply other threads:[~2026-11-20 12:59 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 12:54 [PATCH v9 00/42] drm: Implement state readout support Maxime Ripard
2026-11-20 12:54 ` [PATCH v9 01/42] drm/atomic: Add drm_atomic_get_connector_for_encoder_locked() Maxime Ripard
2026-11-20 12:54 ` [PATCH v9 02/42] drm/bridge-helper: Don't unlock the connection mutex after a backoff Maxime Ripard
2026-11-20 12:54 ` [PATCH v9 03/42] drm/tests: hdmi-state-helper: Handle EDEADLK in the 420-only test Maxime Ripard
2026-11-20 12:54 ` [PATCH v9 04/42] drm/tests: hdmi-state-helper: Handle EDEADLK in the color format test Maxime Ripard
2026-11-20 12:54 ` [PATCH v9 05/42] drm/colorop: Export drm_atomic_helper_colorop_create_state() Maxime Ripard
2026-11-20 12:54 ` [PATCH v9 06/42] drm/atomic: Fix private obj error handling Maxime Ripard
2026-11-20 12:54 ` [PATCH v9 07/42] drm/atomic: Add drm_private_obj name Maxime Ripard
2026-11-20 12:55 ` [PATCH v9 08/42] drm/bridge: Switch print_state to use bridge name Maxime Ripard
2026-11-20 12:55 ` [PATCH v9 09/42] drm/bridge: Add drm_private_obj_is_bridge() Maxime Ripard
2026-11-20 12:55 ` [PATCH v9 10/42] drm/fb-dma-helper: Handle framebuffers without a GEM object Maxime Ripard
2026-11-20 12:55 ` [PATCH v9 11/42] drm/gem-atomic-helper: " Maxime Ripard
2026-11-20 12:55 ` [PATCH v9 12/42] drm/atomic: Export drm_atomic_*_print_state Maxime Ripard
2026-11-20 12:55 ` [PATCH v9 13/42] drm/atomic_sro: Create drm_atomic_sro_state container Maxime Ripard
2026-11-20 12:55 ` [PATCH v9 14/42] drm/atomic_sro: Create kernel parameter to force or disable readout Maxime Ripard
2026-11-20 12:55 ` [PATCH v9 15/42] drm/atomic_sro: Add atomic state readout infrastructure Maxime Ripard
2026-11-20 12:55 ` [PATCH v9 16/42] drm/atomic_sro: Create documentation Maxime Ripard
2026-11-20 12:55 ` [PATCH v9 17/42] drm/bridge: Handle bridges with hardware state readout Maxime Ripard
2026-11-20 13:18 ` sashiko-bot
2026-11-20 12:55 ` [PATCH v9 18/42] drm/mode-config: Read out hardware state in drm_mode_config_create_initial_state Maxime Ripard
2026-11-20 12:55 ` [PATCH v9 19/42] drm/atomic_sro: Provide helpers to implement hardware state readout Maxime Ripard
2026-11-20 13:17 ` sashiko-bot
2026-11-20 12:55 ` [PATCH v9 20/42] drm/mode-config: Introduce hw_reset hook Maxime Ripard
2026-11-20 12:55 ` [PATCH v9 21/42] drm/modeset-helper: Add drm_mode_config_helper_hw_reset() Maxime Ripard
2026-11-20 12:55 ` [PATCH v9 22/42] drm/atomic_helper: Compare actual and readout states once the commit is done Maxime Ripard
2026-11-20 12:55 ` [PATCH v9 23/42] drm/atomic-state-helper: Provide comparison macros Maxime Ripard
2026-11-20 12:55 ` [PATCH v9 24/42] drm/atomic-state-helper: Provide atomic_compare_state helpers Maxime Ripard
2026-11-20 13:14 ` sashiko-bot
2026-11-20 12:55 ` [PATCH v9 25/42] drm/atomic-helper: Document State Read-Out as a state initialization approach Maxime Ripard
2026-11-20 12:55 ` [PATCH v9 26/42] drm/tests: kunit: Add a drm_printer helper Maxime Ripard
2026-11-20 12:55 ` [PATCH v9 27/42] drm/tests: Add tests for the atomic state readout Maxime Ripard
2026-11-20 12:55 ` [PATCH v9 28/42] drm/encoder: Create atomic_sro_get_current_crtc hook Maxime Ripard
2026-11-20 12:55 ` [PATCH v9 29/42] drm/bridge: display-connector: Implement readout support Maxime Ripard
2026-11-20 12:55 ` [PATCH v9 30/42] drm/bridge_connector: Implement hw readout for connector Maxime Ripard
2026-11-20 12:55 ` [PATCH v9 31/42] drm/tidss: Implement hw_reset Maxime Ripard
2026-11-20 12:55 ` [PATCH v9 32/42] drm/tidss: crtc: Implement hardware state readout Maxime Ripard
2026-11-20 13:14 ` sashiko-bot
2026-11-20 12:55 ` [PATCH v9 33/42] drm/tidss: encoder: " Maxime Ripard
2026-11-20 12:55 ` [PATCH v9 34/42] drm/tidss: kms: Hook up " Maxime Ripard
2026-11-20 13:25 ` sashiko-bot
2026-11-20 12:55 ` [PATCH v9 35/42] drm/tidss: plane: Implement " Maxime Ripard
2026-11-20 13:28 ` sashiko-bot
2026-11-20 12:55 ` Maxime Ripard [this message]
2026-11-20 12:55 ` [PATCH v9 37/42] drm/tidss: encoder: Implement atomic_sro_get_current_crtc Maxime Ripard
2026-11-20 12:55 ` [PATCH v9 38/42] drm/bridge: sii902x: Implement hw state readout Maxime Ripard
2026-11-20 13:26 ` sashiko-bot
2026-11-20 12:55 ` [PATCH v9 39/42] drm/panel: Implement state readout support Maxime Ripard
2026-11-20 12:55 ` [PATCH DO NOT MERGE v9 40/42] fixup! drm/tidss: dispc: Add hardware state readout helpers Maxime Ripard
2026-11-20 12:55 ` [PATCH DO NOT MERGE v9 41/42] drm/tidss: oldi: Implement hardware state readout Maxime Ripard
2026-11-20 13:34 ` sashiko-bot
2026-11-20 12:55 ` [PATCH HACK v9 42/42] drm/panel: Prepare and enable panels read out as active Maxime Ripard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261120-drm-state-readout-v9-36-a67c2b45b8ec@kernel.org \
--to=mripard@kernel.org \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=airlied@gmail.com \
--cc=andrzej.hajda@intel.com \
--cc=devarsht@ti.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jernej.skrabec@gmail.com \
--cc=jonas@kwiboo.se \
--cc=jyri.sarha@iki.fi \
--cc=maarten.lankhorst@linux.intel.com \
--cc=neil.armstrong@linaro.org \
--cc=rfoss@kernel.org \
--cc=simona@ffwll.ch \
--cc=tomi.valkeinen@ideasonboard.com \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.