drm: Add self refresh helpers
Subsystems (10)
PATCH v3 1/10 drm: Add atomic variants of enable/disable to encoder helper funcs
In reply to Sean PaulFrom: Sean Paul <[email protected]>
This patch adds atomic_enable and atomic_disable callbacks to the encoder helpers. This will allow encoders to make informed decisions in their start-up/shutdown based on the committed state.
Aside from the new hooks, this patch also introduces the new signature for .atomic_* functions going forward. Instead of passing object state (well, encoders don't have atomic state, but let's ignore that), we pass the entire atomic state so the driver can inspect more than what's happening locally.
This is particularly important for the upcoming self refresh helpers.
Changes in v3:
- Added patch to the set
--- drivers/gpu/drm/drm_atomic_helper.c | 6 +++- include/drm/drm_modeset_helper_vtables.h | 45 ++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_atomic_helper.c +5 -1
@@ -1001,6 +1001,8 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)if (funcs) {if (new_conn_state->crtc && funcs->prepare) funcs->prepare (encoder); +else if (funcs->atomic_disable) + funcs->atomic_disable (encoder, old_state);else if (funcs->disable) funcs->disable (encoder);else if (funcs->dpms)
@@ -1309,7 +1311,9 @@ void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev,drm_bridge_pre_enable (encoder->bridge);if (funcs) { -if (funcs->enable) +if (funcs->atomic_enable) + funcs->atomic_enable (encoder, old_state); +else if (funcs->enable) funcs->enable (encoder);else if (funcs->commit) funcs->commit (encoder);
include/drm/drm_modeset_helper_vtables.h +45 -0
51 lines not on this page · raw message
Signature · 1 line
Sean Paul, Software Engineer, Google / Chromium OS
PATCH v3 3/10 drm: Add atomic variants for bridge enable/disable
In reply to Sean PaulFrom: Sean Paul <[email protected]>
This patch adds atomic variants for all of pre_enable/enable/disable/post_disable bridge functions. These will be called from the appropriate atomic helper functions. If the bridge driver doesn't implement the atomic version of the function, we will fall back to the vanilla implementation.
Note that some drivers call drm_bridge_disable directly, and these cases are not covered. It's up to the driver to decide whether to implement both atomic_disable and disable, or if it's not necessary.
Changes in v3:
- Added to the patchset
--- drivers/gpu/drm/drm_atomic_helper.c | 8 +- drivers/gpu/drm/drm_bridge.c | 110 +++++++++++++++++++++++++++ include/drm/drm_bridge.h | 114 ++++++++++++++++++++++++++++ 3 files changed, 228 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +4 -4
@@ -995,7 +995,7 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)* Each encoder has at most one connector (since we always steal * it away), so we won't call disable hooks twice. */ -drm_bridge_disable (encoder->bridge); +drm_atomic_bridge_disable (encoder->bridge, old_state);/* Right function depends upon target state. */ if (funcs) {
@@ -1009,7 +1009,7 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state) funcs->dpms (encoder,DRM_MODE_DPMS_OFF ); } -drm_bridge_post_disable (encoder->bridge); +drm_atomic_bridge_post_disable (encoder->bridge, old_state); }for_each_oldnew_crtc_in_state (old_state, crtc, old_crtc_state, new_crtc_state, i) {
@@ -1308,7 +1308,7 @@ void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev,* Each encoder has at most one connector (since we always steal * it away), so we won't call enable hooks twice. */ -drm_bridge_pre_enable (encoder->bridge); +drm_atomic_bridge_pre_enable (encoder->bridge, old_state);if (funcs) {if (funcs->atomic_enable)
@@ -1319,7 +1319,7 @@ void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev, funcs->commit (encoder); } -drm_bridge_enable (encoder->bridge); +drm_atomic_bridge_enable (encoder->bridge, old_state); }drm_atomic_helper_commit_writebacks (dev, old_state);
drivers/gpu/drm/drm_bridge.c +110 -0
116 lines not on this page · raw message
include/drm/drm_bridge.h +114 -0
126 lines not on this page · raw message
Signature · 1 line
Sean Paul, Software Engineer, Google / Chromium OS
PATCH v3 4/10 drm: Convert connector_helper_funcs->atomic_check to accept drm_atomic_state
In reply to Sean PaulFrom: Sean Paul <[email protected]>
Everyone who implements connector_helper_funcs->atomic_check reaches into the connector state to get the atomic state. Instead of continuing this pattern, change the callback signature to just give atomic state and let the driver determine what it does and does not need from it.
Eventually all atomic functions should do this, but that's just too much busy work for me.
Changes in v3:
- Added to the set
--- drivers/gpu/drm/drm_atomic_helper.c | 4 ++-- drivers/gpu/drm/i915/intel_atomic.c | 8 +++++--- drivers/gpu/drm/i915/intel_dp_mst.c | 7 ++++--- drivers/gpu/drm/i915/intel_drv.h | 2 +- drivers/gpu/drm/i915/intel_sdvo.c | 9 +++++---- drivers/gpu/drm/i915/intel_tv.c | 8 +++++--- drivers/gpu/drm/nouveau/dispnv50/disp.c | 5 +++-- drivers/gpu/drm/rcar-du/rcar_lvds.c | 12 +++++++----- drivers/gpu/drm/vc4/vc4_txp.c | 7 ++++--- include/drm/drm_modeset_helper_vtables.h | 2 +- 10 files changed, 37 insertions(+), 27 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +2 -2
@@ -683,7 +683,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev, }if (funcs->atomic_check) - ret = funcs->atomic_check (connector, new_connector_state); + ret = funcs->atomic_check (connector, state);if (ret)return ret;
@@ -725,7 +725,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,continue ;if (funcs->atomic_check) - ret = funcs->atomic_check (connector, new_connector_state); + ret = funcs->atomic_check (connector, state);if (ret)return ret; }
drivers/gpu/drm/i915/intel_atomic.c +5 -3
@@ -103,12 +103,14 @@ int intel_digital_connector_atomic_set_property(struct drm_connector *connector, }int intel_digital_connector_atomic_check (struct drm_connector *conn, -struct drm_connector_state *new_state) +struct drm_atomic_state *state) { +struct drm_connector_state *new_state = +drm_atomic_get_new_connector_state (state, conn);struct intel_digital_connector_state *new_conn_state =to_intel_digital_connector_state (new_state);struct drm_connector_state *old_state = -drm_atomic_get_old_connector_state (new_state->state, conn); +drm_atomic_get_old_connector_state (state, conn);struct intel_digital_connector_state *old_conn_state =to_intel_digital_connector_state (old_state);struct drm_crtc_state *crtc_state;
@@ -118,7 +120,7 @@ int intel_digital_connector_atomic_check(struct drm_connector *conn,if (!new_state->crtc)return 0 ; - crtc_state =drm_atomic_get_new_crtc_state (new_state->state, new_state->crtc); + crtc_state =drm_atomic_get_new_crtc_state (state, new_state->crtc);/* * These properties are handled by fastset, and might not end
drivers/gpu/drm/i915/intel_dp_mst.c +4 -3
@@ -143,9 +143,10 @@ static int intel_dp_mst_compute_config(struct intel_encoder *encoder,static int intel_dp_mst_atomic_check (struct drm_connector *connector, -struct drm_connector_state *new_conn_state) +struct drm_atomic_state *state) { -struct drm_atomic_state *state = new_conn_state->state; +struct drm_connector_state *new_conn_state = +drm_atomic_get_new_connector_state (state, connector);struct drm_connector_state *old_conn_state =drm_atomic_get_old_connector_state (state, connector); struct intel_connector *intel_connector =
@@ -155,7 +156,7 @@ intel_dp_mst_atomic_check(struct drm_connector *connector,struct drm_dp_mst_topology_mgr *mgr;int ret; - ret =intel_digital_connector_atomic_check (connector, new_conn_state); + ret =intel_digital_connector_atomic_check (connector, state);if (ret)return ret;
drivers/gpu/drm/i915/intel_drv.h +1 -1
@@ -2481,7 +2481,7 @@ int intel_digital_connector_atomic_set_property(struct drm_connector *connector,struct drm_property *property, u64 val);int intel_digital_connector_atomic_check (struct drm_connector *conn, -struct drm_connector_state *new_state); +struct drm_atomic_state *state);struct drm_connector_state *intel_digital_connector_duplicate_state (struct drm_connector *connector);
drivers/gpu/drm/i915/intel_sdvo.c +5 -4
@@ -2342,9 +2342,10 @@ static const struct drm_connector_funcs intel_sdvo_connector_funcs = { };static int intel_sdvo_atomic_check (struct drm_connector *conn, -struct drm_connector_state *new_conn_state) +struct drm_atomic_state *state) { -struct drm_atomic_state *state = new_conn_state->state; +struct drm_connector_state *new_conn_state = +drm_atomic_get_new_connector_state (state, conn);struct drm_connector_state *old_conn_state =drm_atomic_get_old_connector_state (state, conn); struct intel_sdvo_connector_state *old_state =
@@ -2356,13 +2357,13 @@ static int intel_sdvo_atomic_check(struct drm_connector *conn, (memcmp(&old_state->tv, &new_state->tv, sizeof(old_state->tv)) || memcmp(&old_conn_state->tv, &new_conn_state->tv, sizeof(old_conn_state->tv)))) {struct drm_crtc_state *crtc_state = -drm_atomic_get_new_crtc_state (new_conn_state->state, +drm_atomic_get_new_crtc_state (state, new_conn_state->crtc); crtc_state->connectors_changed = true; } -return intel_digital_connector_atomic_check (conn, new_conn_state); +return intel_digital_connector_atomic_check (conn, state); }static const struct drm_connector_helper_funcs intel_sdvo_connector_helper_funcs = {
drivers/gpu/drm/i915/intel_tv.c +5 -3
@@ -1817,16 +1817,18 @@ static const struct drm_connector_funcs intel_tv_connector_funcs = { };static int intel_tv_atomic_check (struct drm_connector *connector, -struct drm_connector_state *new_state) +struct drm_atomic_state *state) { +struct drm_connector_state *new_state;struct drm_crtc_state *new_crtc_state;struct drm_connector_state *old_state; + new_state =drm_atomic_get_new_connector_state (state, connector);if (!new_state->crtc)return 0 ; - old_state =drm_atomic_get_old_connector_state (new_state->state, connector); - new_crtc_state =drm_atomic_get_new_crtc_state (new_state->state, new_state->crtc); + old_state =drm_atomic_get_old_connector_state (state, connector); + new_crtc_state =drm_atomic_get_new_crtc_state (state, new_state->crtc); if (old_state->tv.mode != new_state->tv.mode || old_state->tv.margins.left != new_state->tv.margins.left ||
drivers/gpu/drm/nouveau/dispnv50/disp.c +3 -2
@@ -948,11 +948,12 @@ nv50_mstc_get_modes(struct drm_connector *connector)static int nv50_mstc_atomic_check (struct drm_connector *connector, -struct drm_connector_state *new_conn_state) +struct drm_atomic_state *state) { -struct drm_atomic_state *state = new_conn_state->state;struct nv50_mstc *mstc =nv50_mstc (connector);struct drm_dp_mst_topology_mgr *mgr = &mstc->mstm->mgr; +struct drm_connector_state *new_conn_state = +drm_atomic_get_new_connector_state (state, connector);struct drm_connector_state *old_conn_state =drm_atomic_get_old_connector_state (state, connector);struct drm_crtc_state *crtc_state;
drivers/gpu/drm/rcar-du/rcar_lvds.c +7 -5
@@ -92,13 +92,15 @@ static int rcar_lvds_connector_get_modes(struct drm_connector *connector) }static int rcar_lvds_connector_atomic_check (struct drm_connector *connector, -struct drm_connector_state *state) +struct drm_atomic_state *state) {struct rcar_lvds *lvds =connector_to_rcar_lvds (connector);const struct drm_display_mode *panel_mode; +struct drm_connector_state *conn_state;struct drm_crtc_state *crtc_state; -if (!state->crtc) + conn_state =drm_atomic_get_new_connector_state (state, connector); +if (!conn_state->crtc)return 0 ;if (list_empty (&connector->modes)) {
@@ -110,9 +112,9 @@ static int rcar_lvds_connector_atomic_check(struct drm_connector *connector, struct drm_display_mode, head);/* We're not allowed to modify the resolution. */ - crtc_state =drm_atomic_get_crtc_state (state->state, state->crtc); -if (IS_ERR (crtc_state)) -return PTR_ERR (crtc_state); + crtc_state =drm_atomic_get_crtc_state (state, conn_state->crtc); +if (!crtc_state) +return -EINVAL ;if (crtc_state->mode.hdisplay != panel_mode->hdisplay || crtc_state->mode.vdisplay != panel_mode->vdisplay)
drivers/gpu/drm/vc4/vc4_txp.c +4 -3
@@ -221,17 +221,18 @@ static const u32 txp_fmts[] = { };static int vc4_txp_connector_atomic_check (struct drm_connector *conn, -struct drm_connector_state *conn_state) +struct drm_atomic_state *state) { +struct drm_connector_state *conn_state;struct drm_crtc_state *crtc_state;struct drm_framebuffer *fb;int i; + conn_state =drm_atomic_get_new_connector_state (state, conn);if (!conn_state->writeback_job || !conn_state->writeback_job->fb)return 0 ; - crtc_state =drm_atomic_get_new_crtc_state (conn_state->state, - conn_state->crtc); + crtc_state =drm_atomic_get_new_crtc_state (state, conn_state->crtc); fb = conn_state->writeback_job->fb; if (fb->width != crtc_state->mode.hdisplay ||
include/drm/drm_modeset_helper_vtables.h +1 -1
@@ -1020,7 +1020,7 @@ struct drm_connector_helper_funcs {* deadlock. */ int (*atomic_check)(struct drm_connector *connector, -struct drm_connector_state *state); +struct drm_atomic_state *state);/** * @atomic_commit:
Signature · 6 lines
Sean Paul, Software Engineer, Google / Chromium OS _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 6/10 drm/rockchip: Use dirtyfb helper
In reply to Sean PaulFrom: Sean Paul <[email protected]>
Instead of flushing all vops every time we get a dirtyfb call, use the damage helper to kick off an atomic commit. Even though we don't use damage clips, the helper commit will force us through the normal psr_inhibit_get/put sequence.
Changes in v3:
- Added to the set
--- drivers/gpu/drm/rockchip/rockchip_drm_fb.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-)
drivers/gpu/drm/rockchip/rockchip_drm_fb.c +2 -11
@@ -16,6 +16,7 @@#include <drm/drm.h> #include <drm/drmP.h> #include <drm/drm_atomic.h> +#include <drm/drm_damage_helper.h> #include <drm/drm_fb_helper.h> #include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_probe_helper.h>
@@ -25,20 +26,10 @@#include "rockchip_drm_gem.h" #include "rockchip_drm_psr.h" -static int rockchip_drm_fb_dirty (struct drm_framebuffer *fb, -struct drm_file *file, -unsigned int flags,unsigned int color, -struct drm_clip_rect *clips, -unsigned int num_clips) -{ -rockchip_drm_psr_flush_all (fb->dev); -return 0 ; -} -static const struct drm_framebuffer_funcs rockchip_drm_fb_funcs = { .destroy = drm_gem_fb_destroy, .create_handle = drm_gem_fb_create_handle, - .dirty = rockchip_drm_fb_dirty, + .dirty = drm_atomic_helper_dirtyfb, }; static struct drm_framebuffer *
Signature · 1 line
Sean Paul, Software Engineer, Google / Chromium OS
PATCH v3 8/10 drm/rockchip: Use the helpers for PSR
In reply to Sean PaulFrom: Sean Paul <[email protected]>
Instead of rolling our own implementation for tracking when PSR should be [in]active, use the new self refresh helpers to do the heavy lifting.
Changes in v2:
- updated to reflect changes made in the helpers
Changes in v3:
- use the new atomic hooks to inspect crtc state instead of needing conn state (Daniel)
Link to v1: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Link to v2: https://patchwork.freedesktop.org/patch/msgid/[email protected]
--- .../drm/bridge/analogix/analogix_dp_core.c | 265 +++++++++++----- .../drm/bridge/analogix/analogix_dp_core.h | 2 +- drivers/gpu/drm/rockchip/Makefile | 3 +- .../gpu/drm/rockchip/analogix_dp-rockchip.c | 86 +++--- drivers/gpu/drm/rockchip/rockchip_drm_fb.c | 5 - drivers/gpu/drm/rockchip/rockchip_drm_psr.c | 290 ------------------ drivers/gpu/drm/rockchip/rockchip_drm_psr.h | 30 -- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 33 +- include/drm/bridge/analogix_dp.h | 4 - 9 files changed, 243 insertions(+), 475 deletions(-) delete mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_psr.c delete mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_psr.h
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +181 -84
@@ -24,6 +24,7 @@#include <linux/phy/phy.h> #include <drm/drmP.h> +#include <drm/drm_atomic.h> #include <drm/drm_atomic_helper.h> #include <drm/drm_crtc.h> #include <drm/drm_panel.h>
@@ -106,63 +107,7 @@ static int analogix_dp_detect_hpd(struct analogix_dp_device *dp)return 0 ; } -int analogix_dp_psr_enabled (struct analogix_dp_device *dp) -{ - -return dp->psr_enable; -} -EXPORT_SYMBOL_GPL (analogix_dp_psr_enabled); - -int analogix_dp_enable_psr (struct analogix_dp_device *dp) -{ -struct edp_vsc_psr psr_vsc; - -if (!dp->psr_enable) -return 0 ; - -/* Prepare VSC packet as per EDP 1.4 spec, Table 6.9 */ -memset (&psr_vsc,0 ,sizeof (psr_vsc)); - psr_vsc.sdp_header.HB0 =0 ; - psr_vsc.sdp_header.HB1 =0x7 ; - psr_vsc.sdp_header.HB2 =0x2 ; - psr_vsc.sdp_header.HB3 =0x8 ; - - psr_vsc.DB0 =0 ; - psr_vsc.DB1 =EDP_VSC_PSR_STATE_ACTIVE |EDP_VSC_PSR_CRC_VALUES_VALID ; - -return analogix_dp_send_psr_spd (dp, &psr_vsc, true); -} -EXPORT_SYMBOL_GPL (analogix_dp_enable_psr); - -int analogix_dp_disable_psr (struct analogix_dp_device *dp) -{ -struct edp_vsc_psr psr_vsc; -int ret; - -if (!dp->psr_enable) -return 0 ; - -/* Prepare VSC packet as per EDP 1.4 spec, Table 6.9 */ -memset (&psr_vsc,0 ,sizeof (psr_vsc)); - psr_vsc.sdp_header.HB0 =0 ; - psr_vsc.sdp_header.HB1 =0x7 ; - psr_vsc.sdp_header.HB2 =0x2 ; - psr_vsc.sdp_header.HB3 =0x8 ; - - psr_vsc.DB0 =0 ; - psr_vsc.DB1 =0 ; - - ret =drm_dp_dpcd_writeb (&dp->aux,DP_SET_POWER ,DP_SET_POWER_D0 ); -if (ret !=1 ) { -dev_err (dp->dev,"Failed to set DP Power0 %d\n" , ret); -return ret; - } - -return analogix_dp_send_psr_spd (dp, &psr_vsc, false); -} -EXPORT_SYMBOL_GPL (analogix_dp_disable_psr); - -static int analogix_dp_detect_sink_psr (struct analogix_dp_device *dp) +static bool analogix_dp_detect_sink_psr (struct analogix_dp_device *dp) {unsigned char psr_version;int ret;
@@ -170,14 +115,11 @@ static int analogix_dp_detect_sink_psr(struct analogix_dp_device *dp) ret =drm_dp_dpcd_readb (&dp->aux,DP_PSR_SUPPORT , &psr_version);if (ret !=1 ) {dev_err (dp->dev,"failed to get PSR version, disable it\n" ); -return ret; +return false; }dev_dbg (dp->dev,"Panel PSR version : %x\n" , psr_version); - - dp->psr_enable = (psr_version &DP_PSR_IS_SUPPORTED ) ? true : false; - -return 0 ; +return psr_version &DP_PSR_IS_SUPPORTED ; }static int analogix_dp_enable_sink_psr (struct analogix_dp_device *dp)
@@ -200,7 +142,7 @@ static int analogix_dp_enable_sink_psr(struct analogix_dp_device *dp) }/* Main-Link transmitter remains active during PSR active states */ - psr_en =DP_PSR_MAIN_LINK_ACTIVE |DP_PSR_CRC_VERIFICATION ; + psr_en =DP_PSR_CRC_VERIFICATION ; ret =drm_dp_dpcd_writeb (&dp->aux,DP_PSR_EN_CFG , psr_en);if (ret !=1 ) {dev_err (dp->dev,"failed to set panel psr\n" );
@@ -208,8 +150,7 @@ static int analogix_dp_enable_sink_psr(struct analogix_dp_device *dp) }/* Enable psr function */ - psr_en =DP_PSR_ENABLE |DP_PSR_MAIN_LINK_ACTIVE | -DP_PSR_CRC_VERIFICATION ; + psr_en =DP_PSR_ENABLE |DP_PSR_CRC_VERIFICATION ; ret =drm_dp_dpcd_writeb (&dp->aux,DP_PSR_EN_CFG , psr_en);if (ret !=1 ) {dev_err (dp->dev,"failed to set panel psr\n" );
@@ -218,10 +159,11 @@ static int analogix_dp_enable_sink_psr(struct analogix_dp_device *dp)analogix_dp_enable_psr_crc (dp); + dp->psr_supported = true; +return 0 ; end:dev_err (dp->dev,"enable psr fail, force to disable psr\n" ); - dp->psr_enable = false;return ret; }
@@ -1036,25 +978,90 @@ static int analogix_dp_commit(struct analogix_dp_device *dp) } } - ret =analogix_dp_detect_sink_psr (dp); -if (ret) -return ret; -/* Check whether panel supports fast training */ ret =analogix_dp_fast_link_train_detection (dp);if (ret) - dp->psr_enable = false; +return ret; -if (dp->psr_enable) { +if (analogix_dp_detect_sink_psr (dp)) { ret =analogix_dp_enable_sink_psr (dp);if (ret)return ret; } +return ret; +} + +static int analogix_dp_enable_psr (struct analogix_dp_device *dp) +{ +struct edp_vsc_psr psr_vsc; +int ret; +u8 sink; + + ret =drm_dp_dpcd_readb (&dp->aux,DP_PSR_STATUS , &sink); +if (ret !=1 ) +DRM_DEV_ERROR (dp->dev,"Failed to read psr status %d\n" , ret); +else if (sink ==DP_PSR_SINK_ACTIVE_RFB ) +return 0 ; + +/* Prepare VSC packet as per EDP 1.4 spec, Table 6.9 */ +memset (&psr_vsc,0 ,sizeof (psr_vsc)); + psr_vsc.sdp_header.HB0 =0 ; + psr_vsc.sdp_header.HB1 =0x7 ; + psr_vsc.sdp_header.HB2 =0x2 ; + psr_vsc.sdp_header.HB3 =0x8 ; + psr_vsc.DB0 =0 ; + psr_vsc.DB1 =EDP_VSC_PSR_STATE_ACTIVE |EDP_VSC_PSR_CRC_VALUES_VALID ; + + ret =analogix_dp_send_psr_spd (dp, &psr_vsc, true); +if (!ret) +analogix_dp_set_analog_power_down (dp,POWER_ALL , true);return ret; } +static int analogix_dp_disable_psr (struct analogix_dp_device *dp) +{ +struct edp_vsc_psr psr_vsc; +int ret; +u8 sink; + +analogix_dp_set_analog_power_down (dp,POWER_ALL , false); + + ret =drm_dp_dpcd_writeb (&dp->aux,DP_SET_POWER ,DP_SET_POWER_D0 ); +if (ret !=1 ) { +DRM_DEV_ERROR (dp->dev,"Failed to set DP Power0 %d\n" , ret); +return ret; + } + + ret =drm_dp_dpcd_readb (&dp->aux,DP_PSR_STATUS , &sink); +if (ret !=1 ) { +DRM_DEV_ERROR (dp->dev,"Failed to read psr status %d\n" , ret); +return ret; + }else if (sink ==DP_PSR_SINK_INACTIVE ) { +DRM_DEV_ERROR (dp->dev,"sink inactive, skip disable psr" ); +return 0 ; + } + + ret =analogix_dp_train_link (dp); +if (ret) { +DRM_DEV_ERROR (dp->dev,"Failed to train the link %d\n" , ret); +return ret; + } + +/* Prepare VSC packet as per EDP 1.4 spec, Table 6.9 */ +memset (&psr_vsc,0 ,sizeof (psr_vsc)); + psr_vsc.sdp_header.HB0 =0 ; + psr_vsc.sdp_header.HB1 =0x7 ; + psr_vsc.sdp_header.HB2 =0x2 ; + psr_vsc.sdp_header.HB3 =0x8 ; + + psr_vsc.DB0 =0 ; + psr_vsc.DB1 =0 ; + +return analogix_dp_send_psr_spd (dp, &psr_vsc, true); +} +/* * This function is a bit of a catch-all for panel preparation, hopefully * simplifying the logic of functions that need to prepare/unprepare the panel
@@ -1145,9 +1152,37 @@ analogix_dp_best_encoder(struct drm_connector *connector)return dp->encoder; } + +int analogix_dp_atomic_check (struct drm_connector *connector, +struct drm_atomic_state *state) +{ +struct analogix_dp_device *dp =to_dp (connector); +struct drm_connector_state *conn_state; +struct drm_crtc_state *crtc_state; + + conn_state =drm_atomic_get_new_connector_state (state, connector); +if (WARN_ON (!conn_state)) +return -ENODEV ; + + conn_state->self_refresh_aware = true; + +if (!conn_state->crtc) +return 0 ; + + crtc_state =drm_atomic_get_new_crtc_state (state, conn_state->crtc); +if (!crtc_state) +return 0 ; + +if (crtc_state->self_refresh_active && !dp->psr_supported) +return -EINVAL ; + +return 0 ; +} +static const struct drm_connector_helper_funcs analogix_dp_connector_helper_funcs = { .get_modes = analogix_dp_get_modes, .best_encoder = analogix_dp_best_encoder, + .atomic_check = analogix_dp_atomic_check, }; static enum drm_connector_status
@@ -1239,11 +1274,22 @@ static int analogix_dp_bridge_attach(struct drm_bridge *bridge)return 0 ; } -static void analogix_dp_bridge_pre_enable (struct drm_bridge *bridge) +static void analogix_dp_bridge_atomic_pre_enable (struct drm_bridge *bridge, +struct drm_atomic_state *state) {struct analogix_dp_device *dp = bridge->driver_private; +struct drm_crtc_state *old_crtc_state =NULL ;int ret; +drm_atomic_crtc_state_for_encoder (state, dp->encoder,NULL , + &old_crtc_state,NULL ); +if (!old_crtc_state) +return ; + +/* Don't touch the panel if we're coming back from PSR */ +if (old_crtc_state->self_refresh_active) +return ; + ret =analogix_dp_prepare_panel (dp, true, true);if (ret)DRM_ERROR ("failed to setup the panel ret = %d\n" , ret);
@@ -1304,10 +1350,26 @@ static int analogix_dp_set_bridge(struct analogix_dp_device *dp)return ret; } -static void analogix_dp_bridge_enable (struct drm_bridge *bridge) +static void analogix_dp_bridge_atomic_enable (struct drm_bridge *bridge, +struct drm_atomic_state *state) {struct analogix_dp_device *dp = bridge->driver_private; +struct drm_crtc_state *old_crtc_state =NULL ;int timeout_loop =0 ; +int ret; + +drm_atomic_crtc_state_for_encoder (state, dp->encoder,NULL , + &old_crtc_state,NULL ); +if (!old_crtc_state) +return ; + +/* Not a full enable, just disable PSR and continue */ +if (old_crtc_state->self_refresh_active) { + ret =analogix_dp_disable_psr (dp); +if (ret) +DRM_ERROR ("Failed to disable psr %d\n" , ret); +return ; + }if (dp->dpms_mode ==DRM_MODE_DPMS_ON )return ;
@@ -1356,11 +1418,51 @@ static void analogix_dp_bridge_disable(struct drm_bridge *bridge)if (ret)DRM_ERROR ("failed to setup the panel ret = %d\n" , ret); - dp->psr_enable = false; dp->fast_train_enable = false; + dp->psr_supported = false; dp->dpms_mode =DRM_MODE_DPMS_OFF ; } +static void analogix_dp_bridge_atomic_disable (struct drm_bridge *bridge, +struct drm_atomic_state *state) +{ +struct analogix_dp_device *dp = bridge->driver_private; +struct drm_crtc_state *new_crtc_state =NULL ; + +drm_atomic_crtc_state_for_encoder (state, dp->encoder,NULL ,NULL , + &new_crtc_state); +if (!new_crtc_state) + goto out; + +/* Don't do a full disable on PSR transitions */ +if (new_crtc_state->self_refresh_active) +return ; + +out: +analogix_dp_bridge_disable (bridge); +} + +static +void analogix_dp_bridge_atomic_post_disable (struct drm_bridge *bridge, +struct drm_atomic_state *state) +{ +struct analogix_dp_device *dp = bridge->driver_private; +struct drm_crtc_state *new_crtc_state =NULL ; +int ret; + +drm_atomic_crtc_state_for_encoder (state, dp->encoder,NULL ,NULL , + &new_crtc_state); +if (!new_crtc_state) +return ; + +if (!new_crtc_state->self_refresh_active) +return ; + + ret =analogix_dp_enable_psr (dp); +if (ret) +DRM_ERROR ("Failed to enable psr (%d)\n" , ret); +} +static void analogix_dp_bridge_mode_set (struct drm_bridge *bridge,const struct drm_display_mode *orig_mode,const struct drm_display_mode *mode)
@@ -1440,16 +1542,11 @@ static void analogix_dp_bridge_mode_set(struct drm_bridge *bridge, video->interlaced = true; } -static void analogix_dp_bridge_nop (struct drm_bridge *bridge) -{ -/* do nothing */ -} -static const struct drm_bridge_funcs analogix_dp_bridge_funcs = { - .pre_enable = analogix_dp_bridge_pre_enable, - .enable = analogix_dp_bridge_enable, - .disable = analogix_dp_bridge_disable, - .post_disable = analogix_dp_bridge_nop, + .atomic_pre_enable = analogix_dp_bridge_atomic_pre_enable, + .atomic_enable = analogix_dp_bridge_atomic_enable, + .atomic_disable = analogix_dp_bridge_atomic_disable, + .atomic_post_disable = analogix_dp_bridge_atomic_post_disable, .mode_set = analogix_dp_bridge_mode_set, .attach = analogix_dp_bridge_attach, };
drivers/gpu/drm/bridge/analogix/analogix_dp_core.h +1 -1
@@ -173,8 +173,8 @@ struct analogix_dp_device {int dpms_mode;int hpd_gpio;bool force_hpd; -bool psr_enable;bool fast_train_enable; +bool psr_supported;struct mutex panel_lock;bool panel_is_modeset;
drivers/gpu/drm/rockchip/Makefile +1 -2
@@ -4,8 +4,7 @@ # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher. rockchipdrm-y := rockchip_drm_drv.o rockchip_drm_fb.o \ - rockchip_drm_gem.o rockchip_drm_psr.o \ - rockchip_drm_vop.o rockchip_vop_reg.o + rockchip_drm_gem.o rockchip_drm_vop.o rockchip_vop_reg.o rockchipdrm-$(CONFIG_DRM_FBDEV_EMULATION) += rockchip_drm_fbdev.o rockchipdrm-$(CONFIG_ROCKCHIP_ANALOGIX_DP) += analogix_dp-rockchip.o
drivers/gpu/drm/rockchip/analogix_dp-rockchip.c +36 -50
158 lines not on this page · raw message
drivers/gpu/drm/rockchip/rockchip_drm_fb.c +0 -5
@@ -24,7 +24,6 @@#include "rockchip_drm_drv.h" #include "rockchip_drm_fb.h" #include "rockchip_drm_gem.h" -#include "rockchip_drm_psr.h" static const struct drm_framebuffer_funcs rockchip_drm_fb_funcs = { .destroy = drm_gem_fb_destroy,
@@ -123,8 +122,6 @@ rockchip_atomic_helper_commit_tail_rpm(struct drm_atomic_state *old_state) {struct drm_device *dev = old_state->dev; -rockchip_drm_psr_inhibit_get_state (old_state); -drm_atomic_helper_commit_modeset_disables (dev, old_state);drm_atomic_helper_commit_modeset_enables (dev, old_state);
@@ -132,8 +129,6 @@ rockchip_atomic_helper_commit_tail_rpm(struct drm_atomic_state *old_state)drm_atomic_helper_commit_planes (dev, old_state,DRM_PLANE_COMMIT_ACTIVE_ONLY ); -rockchip_drm_psr_inhibit_put_state (old_state); -drm_atomic_helper_commit_hw_done (old_state);drm_atomic_helper_wait_for_vblanks (dev, old_state);
drivers/gpu/drm/rockchip/rockchip_drm_psr.c deleted +0 -290
290 lines not on this page · raw message
drivers/gpu/drm/rockchip/rockchip_drm_psr.h deleted +0 -30
@@ -1,30 +0,0 @@ -/* -* Copyright (C) Fuzhou Rockchip Electronics Co.Ltd -* Author: Yakir Yang <[email protected]> -* -* This software is licensed under the terms of the GNU General Public -* License version 2, as published by the Free Software Foundation, and -* may be copied, distributed, and modified under those terms. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -*/ - -#ifndef __ROCKCHIP_DRM_PSR___ -#define __ROCKCHIP_DRM_PSR___ - -void rockchip_drm_psr_flush_all (struct drm_device *dev); - -int rockchip_drm_psr_inhibit_put (struct drm_encoder *encoder); -int rockchip_drm_psr_inhibit_get (struct drm_encoder *encoder); - -void rockchip_drm_psr_inhibit_get_state (struct drm_atomic_state *state); -void rockchip_drm_psr_inhibit_put_state (struct drm_atomic_state *state); - -int rockchip_drm_psr_register (struct drm_encoder *encoder, -int (*psr_set)(struct drm_encoder *,bool enable)); -void rockchip_drm_psr_unregister (struct drm_encoder *encoder); - -#endif /* __ROCKCHIP_DRM_PSR__ */
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +24 -9
@@ -21,6 +21,7 @@#include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_plane_helper.h> #include <drm/drm_probe_helper.h> +#include <drm/drm_self_refresh_helper.h> #ifdef CONFIG_DRM_ANALOGIX_DP #include <drm/bridge/analogix_dp.h> #endif
@@ -42,10 +43,11 @@#include "rockchip_drm_drv.h" #include "rockchip_drm_gem.h" #include "rockchip_drm_fb.h" -#include "rockchip_drm_psr.h" #include "rockchip_drm_vop.h" #include "rockchip_rgb.h" +#define VOP_SELF_REFRESH_ENTRY_DELAY_MS 100 +#define VOP_WIN_SET (vop, win, name, v) \ vop_reg_set(vop, &win->phy->name, win->base, ~0, v, #name)#define VOP_SCL_SET (vop, win, name, v) \
@@ -541,7 +543,7 @@ static void vop_core_clks_disable(struct vop *vop)clk_disable (vop->hclk); } -static int vop_enable (struct drm_crtc *crtc) +static int vop_enable (struct drm_crtc *crtc,struct drm_crtc_state *old_state) {struct vop *vop =to_vop (crtc);int ret, i;
@@ -581,12 +583,18 @@ static int vop_enable(struct drm_crtc *crtc)* We need to make sure that all windows are disabled before we * enable the crtc. Otherwise we might try to scan from a destroyed * buffer later. +* +* In the case of enable-after-PSR, we don't need to worry about this +* case since the buffer is guaranteed to be valid and disabling the +* window will result in screen glitches on PSR exit. */ -for (i =0 ; i < vop->data->win_size; i++) { -struct vop_win *vop_win = &vop->win[i]; -const struct vop_win_data *win = vop_win->data; +if (!old_state || !old_state->self_refresh_active) { +for (i =0 ; i < vop->data->win_size; i++) { +struct vop_win *vop_win = &vop->win[i]; +const struct vop_win_data *win = vop_win->data; -VOP_WIN_SET (vop, win, enable,0 ); +VOP_WIN_SET (vop, win, enable,0 ); + } }spin_unlock (&vop->reg_lock);
@@ -937,12 +945,10 @@ static void vop_plane_atomic_async_update(struct drm_plane *plane, }if (vop->is_enabled) { -rockchip_drm_psr_inhibit_get_state (new_state->state);vop_plane_atomic_update (plane, plane->state);spin_lock (&vop->reg_lock);vop_cfg_done (vop);spin_unlock (&vop->reg_lock); -rockchip_drm_psr_inhibit_put_state (new_state->state); } plane->funcs->atomic_destroy_state (plane, plane_state);
@@ -1036,7 +1042,7 @@ static void vop_crtc_atomic_enable(struct drm_crtc *crtc,WARN_ON (vop->event); - ret =vop_enable (crtc); + ret =vop_enable (crtc, old_state);if (ret) {mutex_unlock (&vop->vop_lock);DRM_DEV_ERROR (vop->dev,"Failed to enable vop (%d)\n" , ret);
@@ -1518,6 +1524,13 @@ static int vop_create_crtc(struct vop *vop)init_completion (&vop->line_flag_completion); crtc->port = port; + ret =drm_self_refresh_helper_register (crtc, +VOP_SELF_REFRESH_ENTRY_DELAY_MS ); +if (ret) +DRM_DEV_DEBUG_KMS (vop->dev, +"Failed to register %s with SR helpers %d, ignoring\n" , + crtc->name, ret); +return 0 ; err_cleanup_crtc:
@@ -1535,6 +1548,8 @@ static void vop_destroy_crtc(struct vop *vop)struct drm_device *drm_dev = vop->drm_dev;struct drm_plane *plane, *tmp; +drm_self_refresh_helper_unregister (crtc); +of_node_put (crtc->port);/*
include/drm/bridge/analogix_dp.h +0 -4
@@ -42,10 +42,6 @@ struct analogix_dp_plat_data { struct drm_connector *); }; -int analogix_dp_psr_enabled (struct analogix_dp_device *dp); -int analogix_dp_enable_psr (struct analogix_dp_device *dp); -int analogix_dp_disable_psr (struct analogix_dp_device *dp); -int analogix_dp_resume (struct analogix_dp_device *dp);int analogix_dp_suspend (struct analogix_dp_device *dp);
Signature · 6 lines
Sean Paul, Software Engineer, Google / Chromium OS _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 9/10 drm/rockchip: Don't fully disable vop on self refresh
In reply to Sean PaulFrom: Sean Paul <[email protected]>
Instead of fully disabling and re-enabling the vop on self refresh transitions, only disable the active windows. This will speed up self refresh exits substantially and is still a power-savings win.
This patch integrates portions of Zain's patch from here:
https://patchwork.kernel.org/patch/9615063/
Changes in v2:
- None
Changes in v3:
- None
Link to v1: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Link to v2: https://patchwork.freedesktop.org/patch/msgid/[email protected]
--- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 38 +++++++++++++++++++++ 1 file changed, 38 insertions(+)
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +38 -0
@@ -134,6 +134,7 @@ struct vop {bool is_enabled;struct completion dsp_hold_completion; +unsigned int win_enabled;/* protected by dev->event_lock */ struct drm_pending_vblank_event *event;
@@ -594,6 +595,7 @@ static int vop_enable(struct drm_crtc *crtc, struct drm_crtc_state *old_state)const struct vop_win_data *win = vop_win->data;VOP_WIN_SET (vop, win, enable,0 ); + vop->win_enabled &= ~BIT (i); } }spin_unlock (&vop->reg_lock);
@@ -624,6 +626,25 @@ static int vop_enable(struct drm_crtc *crtc, struct drm_crtc_state *old_state)return ret; } +static void rockchip_drm_set_win_enabled (struct drm_crtc *crtc,bool enabled) +{ +struct vop *vop =to_vop (crtc); +int i; + +spin_lock (&vop->reg_lock); + +for (i =0 ; i < vop->data->win_size; i++) { +struct vop_win *vop_win = &vop->win[i]; +const struct vop_win_data *win = vop_win->data; + +VOP_WIN_SET (vop, win, enable, + enabled && (vop->win_enabled &BIT (i))); + } +vop_cfg_done (vop); + +spin_unlock (&vop->reg_lock); +} +static void vop_crtc_atomic_disable (struct drm_crtc *crtc,struct drm_crtc_state *old_state) {
@@ -631,9 +652,15 @@ static void vop_crtc_atomic_disable(struct drm_crtc *crtc,WARN_ON (vop->event); +if (crtc->state->self_refresh_active) +rockchip_drm_set_win_enabled (crtc, false); +mutex_lock (&vop->vop_lock);drm_crtc_vblank_off (crtc); +if (crtc->state->self_refresh_active) + goto out; +/* * Vop standby will take effect at end of current frame, * if dsp hold valid irq happen, it means standby complete.
@@ -664,6 +691,8 @@ static void vop_crtc_atomic_disable(struct drm_crtc *crtc,clk_disable (vop->dclk);vop_core_clks_disable (vop);pm_runtime_put (vop->dev); + +out:mutex_unlock (&vop->vop_lock);if (crtc->state->event && !crtc->state->active) {
@@ -744,6 +773,7 @@ static void vop_plane_atomic_disable(struct drm_plane *plane,spin_lock (&vop->reg_lock);VOP_WIN_SET (vop, win, enable,0 ); + vop->win_enabled &= ~BIT (VOP_WIN_TO_INDEX (vop_win));spin_unlock (&vop->reg_lock); }
@@ -882,6 +912,7 @@ static void vop_plane_atomic_update(struct drm_plane *plane, }VOP_WIN_SET (vop, win, enable,1 ); + vop->win_enabled |=BIT (win_index);spin_unlock (&vop->reg_lock); }
@@ -1038,6 +1069,12 @@ static void vop_crtc_atomic_enable(struct drm_crtc *crtc,int dither_bpc = s->output_bpc ? s->output_bpc :10 ;int ret; +if (old_state && old_state->self_refresh_active) { +drm_crtc_vblank_on (crtc); +rockchip_drm_set_win_enabled (crtc, true); +return ; + } +mutex_lock (&vop->vop_lock);WARN_ON (vop->event);
@@ -1648,6 +1685,7 @@ static int vop_initial(struct vop *vop)VOP_WIN_SET (vop, win, channel, (channel +1 ) <<4 | channel);VOP_WIN_SET (vop, win, enable,0 );VOP_WIN_SET (vop, win, gate,1 ); + vop->win_enabled &= ~BIT (i); }vop_cfg_done (vop);
Signature · 6 lines
Sean Paul, Software Engineer, Google / Chromium OS _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 10/10 drm/rockchip: Use drm_atomic_helper_commit_tail_rpm
In reply to Sean PaulFrom: Sean Paul <[email protected]>
Now that we use the drm psr helpers, we no longer need to hand-roll our atomic_commit_tail implementation. So use the helper
Changes in v2:
- None
Changes in v3:
- None
Link to v1: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Link to v2: https://patchwork.freedesktop.org/patch/msgid/[email protected]
--- drivers/gpu/drm/rockchip/rockchip_drm_fb.c | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-)
drivers/gpu/drm/rockchip/rockchip_drm_fb.c +1 -20
@@ -117,27 +117,8 @@ rockchip_user_fb_create(struct drm_device *dev, struct drm_file *file_priv,return ERR_PTR (ret); } -static void -rockchip_atomic_helper_commit_tail_rpm (struct drm_atomic_state *old_state) -{ -struct drm_device *dev = old_state->dev; - -drm_atomic_helper_commit_modeset_disables (dev, old_state); - -drm_atomic_helper_commit_modeset_enables (dev, old_state); - -drm_atomic_helper_commit_planes (dev, old_state, -DRM_PLANE_COMMIT_ACTIVE_ONLY ); - -drm_atomic_helper_commit_hw_done (old_state); - -drm_atomic_helper_wait_for_vblanks (dev, old_state); - -drm_atomic_helper_cleanup_planes (dev, old_state); -} -static const struct drm_mode_config_helper_funcs rockchip_mode_config_helpers = { - .atomic_commit_tail = rockchip_atomic_helper_commit_tail_rpm, + .atomic_commit_tail = drm_atomic_helper_commit_tail_rpm, };static const struct drm_mode_config_funcs rockchip_drm_mode_config_funcs = {
Signature · 6 lines
Sean Paul, Software Engineer, Google / Chromium OS _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
v3 cover drm: Add self refresh helpers
From: Sean Paul <[email protected]>
Hey all,
Back from my break from this. v3 isn't a whole lot different from v2, aside from the new helpers that I've added. These allowed me to remove some redundant state from connector and rely solely on crtc_state.
Please take a look,
Sean
Sean Paul (10):
drm: Add atomic variants of enable/disable to encoder helper funcs
drm: Add drm_atomic_crtc_state_for_encoder helper
drm: Add atomic variants for bridge enable/disable
drm: Convert connector_helper_funcs->atomic_check to accept
drm_atomic_state
drm: Add helpers to kick off self refresh mode in drivers drm/rockchip: Use dirtyfb helper
drm/rockchip: Check for fast link training before enabling psr drm/rockchip: Use the helpers for PSR
drm/rockchip: Don't fully disable vop on self refresh drm/rockchip: Use drm_atomic_helper_commit_tail_rpm
Documentation/gpu/drm-kms-helpers.rst | 9 + drivers/gpu/drm/Makefile | 2 +- .../drm/bridge/analogix/analogix_dp_core.c | 266 +++++++++++----- .../drm/bridge/analogix/analogix_dp_core.h | 2 +- drivers/gpu/drm/drm_atomic.c | 2 + drivers/gpu/drm/drm_atomic_helper.c | 101 +++++- drivers/gpu/drm/drm_atomic_state_helper.c | 4 + drivers/gpu/drm/drm_atomic_uapi.c | 7 +- drivers/gpu/drm/drm_bridge.c | 110 +++++++ drivers/gpu/drm/drm_self_refresh_helper.c | 205 +++++++++++++ drivers/gpu/drm/i915/intel_atomic.c | 8 +- drivers/gpu/drm/i915/intel_dp_mst.c | 7 +- drivers/gpu/drm/i915/intel_drv.h | 2 +- drivers/gpu/drm/i915/intel_sdvo.c | 9 +- drivers/gpu/drm/i915/intel_tv.c | 8 +- drivers/gpu/drm/nouveau/dispnv50/disp.c | 5 +- drivers/gpu/drm/rcar-du/rcar_lvds.c | 12 +- drivers/gpu/drm/rockchip/Makefile | 3 +- .../gpu/drm/rockchip/analogix_dp-rockchip.c | 86 +++--- drivers/gpu/drm/rockchip/rockchip_drm_fb.c | 39 +-- drivers/gpu/drm/rockchip/rockchip_drm_psr.c | 290 ------------------ drivers/gpu/drm/rockchip/rockchip_drm_psr.h | 30 -- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 71 ++++- drivers/gpu/drm/vc4/vc4_txp.c | 7 +- include/drm/bridge/analogix_dp.h | 4 - include/drm/drm_atomic.h | 15 + include/drm/drm_atomic_helper.h | 6 + include/drm/drm_bridge.h | 114 +++++++ include/drm/drm_connector.h | 14 + include/drm/drm_crtc.h | 19 ++ include/drm/drm_modeset_helper_vtables.h | 47 ++- include/drm/drm_self_refresh_helper.h | 22 ++ 32 files changed, 983 insertions(+), 543 deletions(-) create mode 100644 drivers/gpu/drm/drm_self_refresh_helper.c delete mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_psr.c delete mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_psr.h create mode 100644 include/drm/drm_self_refresh_helper.h
Signature · 6 lines
Sean Paul, Software Engineer, Google / Chromium OS _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 2/10 drm: Add drm_atomic_crtc_state_for_encoder helper
From: Sean Paul <[email protected]>
This patch adds a helper to tease out the currently connected crtc for an encoder, along with its state. This follows the same pattern as the drm_atomic_crtc_*_for_* macros in the atomic helpers. Since the relationship of crtc:encoder is 1:n, we don't need a loop since there is only one crtc per encoder.
Instead of splitting this into 3 functions which all do the same thing, this is presented as one function. Perhaps that's too ugly and it should be split to:
struct drm_crtc *drm_atomic_crtc_for_encoder(state, encoder); struct drm_crtc_state *drm_atomic_new_crtc_state_for_encoder(state, encoder); struct drm_crtc_state *drm_atomic_old_crtc_state_for_encoder(state, encoder);
Suggestions welcome.
Changes in v3:
- Added to the set
--- drivers/gpu/drm/drm_atomic_helper.c | 48 +++++++++++++++++++++++++++++ include/drm/drm_atomic_helper.h | 6 ++++ 2 files changed, 54 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +48 -0
@@ -3591,3 +3591,51 @@ int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,return ret; }EXPORT_SYMBOL (drm_atomic_helper_legacy_gamma_set); + +/** +* drm_atomic_crtc_state_for_encoder - Get crtc and new/old state for an encoder +* @state: Atomic state +* @encoder: The encoder to fetch the crtc information for +* @crtc: If not NULL, receives the currently connected crtc +* @old_crtc_state: If not NULL, receives the crtc's old state +* @new_crtc_state: If not NULL, receives the crtc's new state +* +* This function finds the crtc which is currently connected to @encoder and +* returns it as well as its old and new state. If there is no crtc currently +* connected, the function will clear @crtc, @old_crtc_state, @new_crtc_state. +* +* All of @crtc, @old_crtc_state, and @new_crtc_state are optional. +*/ +void drm_atomic_crtc_state_for_encoder (struct drm_atomic_state *state, +struct drm_encoder *encoder, +struct drm_crtc **crtc, +struct drm_crtc_state **old_crtc_state, +struct drm_crtc_state **new_crtc_state) +{ +struct drm_crtc *tmp_crtc; +struct drm_crtc_state *tmp_new_crtc_state, *tmp_old_crtc_state; +u32 enc_mask =drm_encoder_mask (encoder); +int i; + +for_each_oldnew_crtc_in_state (state, tmp_crtc, tmp_old_crtc_state, + tmp_new_crtc_state, i) { +if (!(tmp_new_crtc_state->encoder_mask & enc_mask)) +continue ; + +if (new_crtc_state) + *new_crtc_state = tmp_new_crtc_state; +if (old_crtc_state) + *old_crtc_state = tmp_old_crtc_state; +if (crtc) + *crtc = tmp_crtc; +return ; + } + +if (new_crtc_state) + *new_crtc_state =NULL ; +if (old_crtc_state) + *old_crtc_state =NULL ; +if (crtc) + *crtc =NULL ; +} +EXPORT_SYMBOL (drm_atomic_crtc_state_for_encoder);
include/drm/drm_atomic_helper.h +6 -0
@@ -153,6 +153,12 @@ int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,uint32_t size, struct drm_modeset_acquire_ctx *ctx); +void drm_atomic_crtc_state_for_encoder (struct drm_atomic_state *state, +struct drm_encoder *encoder, +struct drm_crtc **crtc, +struct drm_crtc_state **old_crtc_state, +struct drm_crtc_state **new_crtc_state); +/** * drm_atomic_crtc_for_each_plane - iterate over planes currently attached to CRTC * @plane: the loop cursor
Signature · 6 lines
Sean Paul, Software Engineer, Google / Chromium OS _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 5/10 drm: Add helpers to kick off self refresh mode in drivers
In reply to Sean PaulFrom: Sean Paul <[email protected]>
This patch adds a new drm helper library to help drivers implement self refresh. Drivers choosing to use it will register crtcs and will receive callbacks when it's time to enter or exit self refresh mode.
In its current form, it has a timer which will trigger after a driver-specified amount of inactivity. When the timer triggers, the helpers will submit a new atomic commit to shut the refreshing pipe off. On the next atomic commit, the drm core will revert the self refresh state and bring everything back up to be actively driven.
From the driver's perspective, this works like a regular disable/enable cycle. The driver need only check the 'self_refresh_active' state in crtc_state. It should initiate self refresh mode on the panel and enter an off or low-power state.
Changes in v2:
- s/psr/self_refresh/ (Daniel)
- integrated the psr exit into the commit that wakes it up (Jose/Daniel)
- made the psr state per-crtc (Jose/Daniel)
Changes in v3:
- Remove the self_refresh_(active|changed) from connector state (Daniel)
- Simplify loop in drm_self_refresh_helper_alter_state (Daniel)
- Improve self_refresh_aware comment (Daniel)
- s/self_refresh_state/self_refresh_data/ (Daniel)
Link to v1: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Link to v2: https://patchwork.freedesktop.org/patch/msgid/[email protected]
--- Documentation/gpu/drm-kms-helpers.rst | 9 + drivers/gpu/drm/Makefile | 2 +- drivers/gpu/drm/drm_atomic.c | 2 + drivers/gpu/drm/drm_atomic_helper.c | 35 +++- drivers/gpu/drm/drm_atomic_state_helper.c | 4 + drivers/gpu/drm/drm_atomic_uapi.c | 7 +- drivers/gpu/drm/drm_self_refresh_helper.c | 205 ++++++++++++++++++++++ include/drm/drm_atomic.h | 15 ++ include/drm/drm_connector.h | 14 ++ include/drm/drm_crtc.h | 19 ++ include/drm/drm_self_refresh_helper.h | 22 +++ 11 files changed, 329 insertions(+), 5 deletions(-) create mode 100644 drivers/gpu/drm/drm_self_refresh_helper.c create mode 100644 include/drm/drm_self_refresh_helper.h
Documentation/gpu/drm-kms-helpers.rst +9 -0
@@ -113,6 +113,15 @@ format Helper Functions Reference .. kernel-doc:: drivers/gpu/drm/drm_format_helper.c :export: +Panel Self Refresh Helper Reference +=================================== + +.. kernel-doc:: drivers/gpu/drm/drm_self_refresh_helper.c + :doc: overview + +.. kernel-doc:: drivers/gpu/drm/drm_self_refresh_helper.c + :export: + Framebuffer CMA Helper Functions Reference ==========================================
drivers/gpu/drm/Makefile +1 -1
@@ -39,7 +39,7 @@ drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o drm_dsc.o drm_probe_helper drm_simple_kms_helper.o drm_modeset_helper.o \ drm_scdc_helper.o drm_gem_framebuffer_helper.o \ drm_atomic_state_helper.o drm_damage_helper.o \ - drm_format_helper.o + drm_format_helper.o drm_self_refresh_helper.o drm_kms_helper-$(CONFIG_DRM_PANEL_BRIDGE) += bridge/panel.o drm_kms_helper-$(CONFIG_DRM_FBDEV_EMULATION) += drm_fb_helper.o
drivers/gpu/drm/drm_atomic.c +2 -0
@@ -379,6 +379,7 @@ static void drm_atomic_crtc_print_state(struct drm_printer *p,drm_printf (p,"crtc[%u]: %s\n" , crtc->base.id, crtc->name);drm_printf (p,"\tenable=%d\n" , state->enable);drm_printf (p,"\tactive=%d\n" , state->active); +drm_printf (p,"\tself_refresh_active=%d\n" , state->self_refresh_active);drm_printf (p,"\tplanes_changed=%d\n" , state->planes_changed);drm_printf (p,"\tmode_changed=%d\n" , state->mode_changed);drm_printf (p,"\tactive_changed=%d\n" , state->active_changed);
@@ -881,6 +882,7 @@ static void drm_atomic_connector_print_state(struct drm_printer *p,drm_printf (p,"connector[%u]: %s\n" , connector->base.id, connector->name);drm_printf (p,"\tcrtc=%s\n" , state->crtc ? state->crtc->name :"(null)" ); +drm_printf (p,"\tself_refresh_aware=%d\n" , state->self_refresh_aware);if (connector->connector_type ==DRM_MODE_CONNECTOR_WRITEBACK )if (state->writeback_job && state->writeback_job->fb)
drivers/gpu/drm/drm_atomic_helper.c +33 -2
@@ -30,6 +30,7 @@#include <drm/drm_atomic_uapi.h> #include <drm/drm_plane_helper.h> #include <drm/drm_atomic_helper.h> +#include <drm/drm_self_refresh_helper.h> #include <drm/drm_writeback.h> #include <drm/drm_damage_helper.h> #include <linux/dma-fence.h>
@@ -950,10 +951,33 @@ int drm_atomic_helper_check(struct drm_device *dev,if (state->legacy_cursor_update) state->async_update = !drm_atomic_helper_async_check (dev, state); +drm_self_refresh_helper_alter_state (state); +return ret; }EXPORT_SYMBOL (drm_atomic_helper_check); +static bool +crtc_needs_disable (struct drm_crtc_state *old_state, +struct drm_crtc_state *new_state) +{ +/* +* No new_state means the crtc is off, so the only criteria is whether +* it's currently active or in self refresh mode. +*/ +if (!new_state) +return drm_atomic_crtc_effectively_active (old_state); + +/* +* We need to run through the crtc_funcs->disable() function if the crtc +* is currently on, if it's transitioning to self refresh mode, or if +* it's in self refresh mode and needs to be fully disabled. +*/ +return old_state->active || + (old_state->self_refresh_active && !new_state->enable) || + new_state->self_refresh_active; +} +static void disable_outputs (struct drm_device *dev,struct drm_atomic_state *old_state) {
@@ -974,7 +998,14 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state) old_crtc_state =drm_atomic_get_old_crtc_state (old_state, old_conn_state->crtc); -if (!old_crtc_state->active || +if (new_conn_state->crtc) + new_crtc_state =drm_atomic_get_new_crtc_state ( + old_state, + new_conn_state->crtc); +else + new_crtc_state =NULL ; + +if (!crtc_needs_disable (old_crtc_state, new_crtc_state) || !drm_atomic_crtc_needs_modeset (old_conn_state->crtc->state))continue ;
@@ -1020,7 +1051,7 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)if (!drm_atomic_crtc_needs_modeset (new_crtc_state))continue ; -if (!old_crtc_state->active) +if (!crtc_needs_disable (old_crtc_state, new_crtc_state))continue ; funcs = crtc->helper_private;
drivers/gpu/drm/drm_atomic_state_helper.c +4 -0
@@ -128,6 +128,10 @@ void __drm_atomic_helper_crtc_duplicate_state(struct drm_crtc *crtc, state->commit =NULL ; state->event =NULL ; state->pageflip_flags =0 ; + +/* Self refresh should be canceled when a new update is available */ + state->active =drm_atomic_crtc_effectively_active (state); + state->self_refresh_active = false; }EXPORT_SYMBOL (__drm_atomic_helper_crtc_duplicate_state);
drivers/gpu/drm/drm_atomic_uapi.c +5 -2
@@ -490,7 +490,7 @@ drm_atomic_crtc_get_property(struct drm_crtc *crtc,struct drm_mode_config *config = &dev->mode_config;if (property == config->prop_active) - *val = state->active; + *val =drm_atomic_crtc_effectively_active (state);else if (property == config->prop_mode_id) *val = (state->mode_blob) ? state->mode_blob->base.id :0 ;else if (property == config->prop_vrr_enabled)
@@ -772,7 +772,10 @@ drm_atomic_connector_get_property(struct drm_connector *connector,if (property == config->prop_crtc_id) { *val = (state->crtc) ? state->crtc->base.id :0 ; }else if (property == config->dpms_property) { - *val = connector->dpms; +if (state->crtc && state->crtc->state->self_refresh_active) + *val =DRM_MODE_DPMS_ON ; +else + *val = connector->dpms; }else if (property == config->tv_select_subconnector_property) { *val = state->tv.subconnector; }else if (property == config->tv_left_margin_property) {
drivers/gpu/drm/drm_self_refresh_helper.c new file +205 -0
205 lines not on this page · raw message
include/drm/drm_atomic.h +15 -0
@@ -944,4 +944,19 @@ drm_atomic_crtc_needs_modeset(const struct drm_crtc_state *state) state->connectors_changed; } +/** +* drm_atomic_crtc_effectively_active - compute whether crtc is actually active +* @state: &drm_crtc_state for the CRTC +* +* When in self refresh mode, the crtc_state->active value will be false, since +* the crtc is off. However in some cases we're interested in whether the crtc +* is active, or effectively active (ie: it's connected to an active display). +* In these cases, use this function instead of just checking active. +*/ +static inline bool +drm_atomic_crtc_effectively_active (const struct drm_crtc_state *state) +{ +return state->active || state->self_refresh_active; +} +#endif /* DRM_ATOMIC_H_ */
include/drm/drm_connector.h +14 -0
@@ -539,6 +539,20 @@ struct drm_connector_state {/** @tv: TV connector state */ struct drm_tv_connector_state tv; +/** +* @self_refresh_aware: +* +* This tracks whether a connector is aware of the self refresh state. +* It should be set to true for those connector implementations which +* understand the self refresh state. This is needed since the crtc +* registers the self refresh helpers and it doesn't know if the +* connectors downstream have implemented self refresh entry/exit. +* +* Drivers should set this to true in atomic_check if they know how to +* handle self_refresh requests. +*/ +bool self_refresh_aware; +/** * @picture_aspect_ratio: Connector property to control the * HDMI infoframe aspect ratio setting.
include/drm/drm_crtc.h +19 -0
@@ -53,6 +53,7 @@ struct drm_mode_set;struct drm_file ;struct drm_clip_rect ;struct drm_printer ; +struct drm_self_refresh_data ;struct device_node ;struct dma_fence ;struct edid ;
@@ -299,6 +300,17 @@ struct drm_crtc_state {*/ bool vrr_enabled; +/** +* @self_refresh_active: +* +* Used by the self refresh helpers to denote when a self refresh +* transition is occuring. This will be set on enable/disable callbacks +* when self refresh is being enabled or disabled. In some cases, it may +* not be desirable to fully shut off the crtc during self refresh. +* CRTC's can inspect this flag and determine the best course of action. +*/ +bool self_refresh_active; +/** * @event: *
@@ -1087,6 +1099,13 @@ struct drm_crtc {* The name of the CRTC's fence timeline. */ char timeline_name[32 ]; + +/** +* @self_refresh_data: Holds the state for the self refresh helpers +* +* Initialized via drm_self_refresh_helper_register(). +*/ +struct drm_self_refresh_data *self_refresh_data; };/**
include/drm/drm_self_refresh_helper.h new file +22 -0
@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright (C) 2019 Google, Inc. +* +* Authors: +* Sean Paul <[email protected]> +*/ +#ifndef DRM_SELF_REFRESH_HELPER_H_ +#define DRM_SELF_REFRESH_HELPER_H_ + +struct drm_atomic_state ; +struct drm_connector ; +struct drm_device ; +struct drm_modeset_acquire_ctx ; + +void drm_self_refresh_helper_alter_state (struct drm_atomic_state *state); + +int drm_self_refresh_helper_register (struct drm_crtc *crtc, +unsigned int entry_delay_ms); + +void drm_self_refresh_helper_unregister (struct drm_crtc *crtc); +#endif
Signature · 6 lines
Sean Paul, Software Engineer, Google / Chromium OS _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 7/10 drm/rockchip: Check for fast link training before enabling psr
In reply to Sean PaulFrom: Sean Paul <[email protected]>
Once we start shutting off the link during PSR, we're going to want fast training to work. If the display doesn't support fast training, don't enable psr.
Changes in v2:
- None
Changes in v3:
- None
Link to v1: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Link to v2: https://patchwork.freedesktop.org/patch/msgid/[email protected]
--- drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +5 -4
@@ -1040,16 +1040,17 @@ static int analogix_dp_commit(struct analogix_dp_device *dp)if (ret)return ret; +/* Check whether panel supports fast training */ + ret =analogix_dp_fast_link_train_detection (dp); +if (ret) + dp->psr_enable = false; +if (dp->psr_enable) { ret =analogix_dp_enable_sink_psr (dp);if (ret)return ret; } -/* Check whether panel supports fast training */ - ret =analogix_dp_fast_link_train_detection (dp); -if (ret) - dp->psr_enable = false;return ret; }
Signature · 6 lines
Sean Paul, Software Engineer, Google / Chromium OS _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 05/10] drm: Add helpers to kick off self refresh mode in drivers
In reply to Sean PaulQuoted 31 lines · Sean Paul
From: Sean Paul <[email protected]>
This patch adds a new drm helper library to help drivers implement self refresh. Drivers choosing to use it will register crtcs and will receive callbacks when it's time to enter or exit self refresh mode.
In its current form, it has a timer which will trigger after a driver-specified amount of inactivity. When the timer triggers, the helpers will submit a new atomic commit to shut the refreshing pipe off. On the next atomic commit, the drm core will revert the self refresh state and bring everything back up to be actively driven.
From the driver's perspective, this works like a regular disable/enable cycle. The driver need only check the '
self_refresh_active' state incrtc_state. It should initiate self refresh mode on the panel and enter an off or low-power state.Changes in v2:
- s/psr/self_refresh/ (Daniel)
- integrated the psr exit into the commit that wakes it up (Jose/Daniel)
- made the psr state per-crtc (Jose/Daniel)
Changes in v3:
- Remove theself_refresh_(active|changed)from connector state (Daniel)
- Simplify loop indrm_self_refresh_helper_alter_state(Daniel)
- Improveself_refresh_awarecomment (Daniel)
- s/self_refresh_state/self_refresh_data/ (Daniel)Link to v1: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Link to v2: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Quoted 6 lines
Cc Daniel Vetter <[email protected]>Cc Jose Souza <[email protected]>Cc Zain Wang <[email protected]>Cc Tomasz Figa <[email protected]>Cc Ville Syrjälä <[email protected]>Signed-off-by Sean Paul <[email protected]>
lgtm now, thanks a lot for sticking with this! Surprising lots of corner cases I had to learn about and figure out what to best do with them.
Quoted 22 lines
--- Documentation/gpu/drm-kms-helpers.rst | 9 + drivers/gpu/drm/Makefile | 2 +- drivers/gpu/drm/drm_atomic.c | 2 + drivers/gpu/drm/drm_atomic_helper.c | 35 +++- drivers/gpu/drm/drm_atomic_state_helper.c | 4 + drivers/gpu/drm/drm_atomic_uapi.c | 7 +- drivers/gpu/drm/drm_self_refresh_helper.c | 205 ++++++++++++++++++++++ include/drm/drm_atomic.h | 15 ++ include/drm/drm_connector.h | 14 ++ include/drm/drm_crtc.h | 19 ++ include/drm/drm_self_refresh_helper.h | 22 +++ 11 files changed, 329 insertions(+), 5 deletions(-) create mode 100644 drivers/gpu/drm/drm_self_refresh_helper.c create mode 100644 include/drm/drm_self_refresh_helper.hDocumentation/gpu/drm-kms-helpers.rst +0
-0@@ -113,6 +113,15 @@ format Helper Functions Reference .. kernel-doc:: drivers/gpu/drm/drm_format_helper.c
Documentation/gpu/drm-kms-helpers.rst format Helper Functions Reference · line 123
Quoted 10 lines
Documentation/gpu/drm-kms-helpers.rst +8
-0:export: +Panel Self Refresh Helper Reference +=================================== + +.. kernel-doc:: drivers/gpu/drm/drm_self_refresh_helper.c + :doc: overview + +.. kernel-doc:: drivers/gpu/drm/drm_self_refresh_helper.c + :export:
I think this isn't the best place to insert the self refresh helpers. I'd put them right below panel helpers, together with the other sink related stuff. I think fits much better there than between the format and gem helpers ...
Quoted 170 lines
Documentation/gpu/drm-kms-helpers.rst +1
-0+ Framebuffer CMA Helper Functions Reference ==========================================drivers/gpu/drm/Makefile +1
-1@@ -39,7 +39,7 @@ drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o drm_dsc.o drm_probe_helper drm_simple_kms_helper.o drm_modeset_helper.o \ drm_scdc_helper.o drm_gem_framebuffer_helper.o \ drm_atomic_state_helper.o drm_damage_helper.o \ - drm_format_helper.o + drm_format_helper.o drm_self_refresh_helper.o drm_kms_helper-$(CONFIG_DRM_PANEL_BRIDGE) += bridge/panel.o drm_kms_helper-$(CONFIG_DRM_FBDEV_EMULATION) += drm_fb_helper.odrivers/gpu/drm/drm_atomic.c +2
-0@@ -379,6 +379,7 @@ static void drm_atomic_crtc_print_state(struct drm_printer *p,drm_printf (p,"crtc[%u]: %s\n" , crtc->base.id, crtc->name);drm_printf (p,"\tenable=%d\n" , state->enable);drm_printf (p,"\tactive=%d\n" , state->active); +drm_printf (p,"\tself_refresh_active=%d\n" , state->self_refresh_active);drm_printf (p,"\tplanes_changed=%d\n" , state->planes_changed);drm_printf (p,"\tmode_changed=%d\n" , state->mode_changed);drm_printf (p,"\tactive_changed=%d\n" , state->active_changed);@@ -881,6 +882,7 @@ static void drm_atomic_connector_print_state(struct drm_printer *p,drm_printf (p,"connector[%u]: %s\n" , connector->base.id, connector->name);drm_printf (p,"\tcrtc=%s\n" , state->crtc ? state->crtc->name :"(null)" ); +drm_printf (p,"\tself_refresh_aware=%d\n" , state->self_refresh_aware);if (connector->connector_type ==DRM_MODE_CONNECTOR_WRITEBACK )if (state->writeback_job && state->writeback_job->fb)drivers/gpu/drm/drm_atomic_helper.c +33
-2@@ -30,6 +30,7 @@#include <drm/drm_atomic_uapi.h> #include <drm/drm_plane_helper.h> #include <drm/drm_atomic_helper.h> +#include <drm/drm_self_refresh_helper.h> #include <drm/drm_writeback.h> #include <drm/drm_damage_helper.h> #include <linux/dma-fence.h> @@ -950,10 +951,33 @@ int drm_atomic_helper_check(struct drm_device *dev,if (state->legacy_cursor_update) state->async_update = !drm_atomic_helper_async_check (dev, state); +drm_self_refresh_helper_alter_state (state); +return ret; }EXPORT_SYMBOL (drm_atomic_helper_check); +static bool +crtc_needs_disable (struct drm_crtc_state *old_state, +struct drm_crtc_state *new_state) +{ +/* +* No new_state means the crtc is off, so the only criteria is whether +* it's currently active or in self refresh mode. +*/ +if (!new_state) +return drm_atomic_crtc_effectively_active (old_state); + +/* +* We need to run through the crtc_funcs->disable() function if the crtc +* is currently on, if it's transitioning to self refresh mode, or if +* it's in self refresh mode and needs to be fully disabled. +*/ +return old_state->active || + (old_state->self_refresh_active && !new_state->enable) || + new_state->self_refresh_active; +} +static void disable_outputs (struct drm_device *dev,struct drm_atomic_state *old_state) {@@ -974,7 +998,14 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state) old_crtc_state =drm_atomic_get_old_crtc_state (old_state, old_conn_state->crtc); -if (!old_crtc_state->active || +if (new_conn_state->crtc) + new_crtc_state =drm_atomic_get_new_crtc_state ( + old_state, + new_conn_state->crtc); +else + new_crtc_state =NULL ; + +if (!crtc_needs_disable (old_crtc_state, new_crtc_state) || !drm_atomic_crtc_needs_modeset (old_conn_state->crtc->state))continue ;@@ -1020,7 +1051,7 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)if (!drm_atomic_crtc_needs_modeset (new_crtc_state))continue ; -if (!old_crtc_state->active) +if (!crtc_needs_disable (old_crtc_state, new_crtc_state))continue ; funcs = crtc->helper_private;drivers/gpu/drm/drm_atomic_state_helper.c +4
-0@@ -128,6 +128,10 @@ void __drm_atomic_helper_crtc_duplicate_state(struct drm_crtc *crtc, state->commit =NULL ; state->event =NULL ; state->pageflip_flags =0 ; + +/* Self refresh should be canceled when a new update is available */ + state->active =drm_atomic_crtc_effectively_active (state); + state->self_refresh_active = false; }EXPORT_SYMBOL (__drm_atomic_helper_crtc_duplicate_state);drivers/gpu/drm/drm_atomic_uapi.c +5
-2@@ -490,7 +490,7 @@ drm_atomic_crtc_get_property(struct drm_crtc *crtc,struct drm_mode_config *config = &dev->mode_config;if (property == config->prop_active) - *val = state->active; + *val =drm_atomic_crtc_effectively_active (state);else if (property == config->prop_mode_id) *val = (state->mode_blob) ? state->mode_blob->base.id :0 ;else if (property == config->prop_vrr_enabled)@@ -772,7 +772,10 @@ drm_atomic_connector_get_property(struct drm_connector *connector,if (property == config->prop_crtc_id) { *val = (state->crtc) ? state->crtc->base.id :0 ; }else if (property == config->dpms_property) { - *val = connector->dpms; +if (state->crtc && state->crtc->state->self_refresh_active) + *val =DRM_MODE_DPMS_ON ; +else + *val = connector->dpms; }else if (property == config->tv_select_subconnector_property) { *val = state->tv.subconnector; }else if (property == config->tv_left_margin_property) {drivers/gpu/drm/drm_self_refresh_helper.c new file +16
-0@@ -0,0 +1,205 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright (C) 2019 Google, Inc. +* +* Authors: +* Sean Paul <[email protected]> +*/ +#include <drm/drm_atomic.h> +#include <drm/drm_atomic_helper.h> +#include <drm/drm_connector.h> +#include <drm/drm_crtc.h> +#include <drm/drm_device.h> +#include <drm/drm_mode_config.h> +#include <drm/drm_modeset_lock.h> +#include <drm/drm_print.h> +#include <drm/drm_self_refresh_helper.h>
drivers/gpu/drm/drm_self_refresh_helper.c line 26
Quoted 10 lines
drivers/gpu/drm/drm_self_refresh_helper.c new file +10
-0+#include <linux/bitops.h> +#include <linux/slab.h> +#include <linux/workqueue.h> + +/** +* DOC: overview +* +* This helper library provides an easy way for drivers to leverage the atomic +* framework to implement panel self refresh (SR) support. Drivers are +* responsible for registering and unregistering the SR helpers on load/unload.
I think better if you mention that you both need to set up the CRTC (using the init/cleanup functions), and also the connector (by setting &drm_connector.self_refresh_aware).
Quoted 5 lines
drivers/gpu/drm/drm_self_refresh_helper.c new file +5
-0+* +* Once a crtc has enabled SR, the helpers will monitor activity and +* call back into the driver to enable/disable SR as appropriate. The best way +* to think about this is that it's a DPMS on/off request with a flag set in +* state that tells you to disable/enable SR on the panel instead of power-
drivers/gpu/drm/drm_self_refresh_helper.c line 41
Quoted 10 lines
drivers/gpu/drm/drm_self_refresh_helper.c new file +10
-0+* cycling it. +* +* Drivers may choose to fully disable their crtc/encoder/bridge hardware, or +* they can use the "self_refresh_active" flags in crtc state if they want to +* enter low power mode without full disable (in case full disable/enable is too +* slow). +* +* SR will be deactivated if there are any atomic updates affecting the +* pipe that is in SR mode. If a crtc is driving multiple connectors, all +* connectors must be SR aware and all will enter SR mode.
I think the above text would be more useful if you spice it up with links to the relevant functions (init/cleanup and alter_state) plus what to look at, i.e. &drm_crtc_state.self_refresh_active.
Quoted 116 lines
drivers/gpu/drm/drm_self_refresh_helper.c new file +116
-0+*/ + +struct drm_self_refresh_data { +struct drm_crtc *crtc; +struct delayed_work entry_work; +struct drm_atomic_state *save_state; +unsigned int entry_delay_ms; +}; + +static void drm_self_refresh_helper_entry_work (struct work_struct *work) +{ +struct drm_self_refresh_data *sr_data =container_of ( +to_delayed_work (work), + struct drm_self_refresh_data, entry_work); +struct drm_crtc *crtc = sr_data->crtc; +struct drm_device *dev = crtc->dev; +struct drm_modeset_acquire_ctx ctx; +struct drm_atomic_state *state; +struct drm_connector *conn; +struct drm_connector_state *conn_state; +struct drm_crtc_state *crtc_state; +int i, ret; + +drm_modeset_acquire_init (&ctx,0 ); + + state =drm_atomic_state_alloc (dev); +if (!state) { + ret = -ENOMEM ; + goto out; + } + +retry: + state->acquire_ctx = &ctx; + + crtc_state =drm_atomic_get_crtc_state (state, crtc); +if (IS_ERR (crtc_state)) { + ret =PTR_ERR (crtc_state); + goto out; + } + +if (!crtc_state->enable) + goto out; + + ret =drm_atomic_add_affected_connectors (state, crtc); +if (ret) + goto out; + +for_each_new_connector_in_state (state, conn, conn_state, i) { +if (!conn_state->self_refresh_aware) + goto out; + } + + crtc_state->active = false; + crtc_state->self_refresh_active = true; + + ret =drm_atomic_commit (state); +if (ret) + goto out; + +out: +if (ret == -EDEADLK ) { +drm_atomic_state_clear (state); + ret =drm_modeset_backoff (&ctx); +if (!ret) + goto retry; + } + +drm_atomic_state_put (state); +drm_modeset_drop_locks (&ctx); +drm_modeset_acquire_fini (&ctx); +} + +/** +* drm_self_refresh_helper_alter_state - Alters the atomic state for SR exit +* @state: the state currently being checked +* +* Called at the end of atomic check. This function checks the state for flags +* incompatible with self refresh exit and changes them. This is a bit +* disingenuous since userspace is expecting one thing and we're giving it +* another. However in order to keep self refresh entirely hidden from +* userspace, this is required. +* +* At the end, we queue up the self refresh entry work so we can enter PSR after +* the desired delay. +*/ +void drm_self_refresh_helper_alter_state (struct drm_atomic_state *state) +{ +struct drm_crtc *crtc; +struct drm_crtc_state *crtc_state; +int i; + +if (state->async_update || !state->allow_modeset) { +for_each_old_crtc_in_state (state, crtc, crtc_state, i) { +if (crtc_state->self_refresh_active) { + state->async_update = false; + state->allow_modeset = true; +break ; + } + } + } + +for_each_new_crtc_in_state (state, crtc, crtc_state, i) { +struct drm_self_refresh_data *sr_data; + +/* Don't trigger the entry timer when we're already in SR */ +if (crtc_state->self_refresh_active) +continue ; + + sr_data = crtc->self_refresh_data; +if (!sr_data) +continue ; + +mod_delayed_work (system_wq, &sr_data->entry_work, +msecs_to_jiffies (sr_data->entry_delay_ms)); + } +}
drivers/gpu/drm/drm_self_refresh_helper.c line 167
Quoted 10 lines
drivers/gpu/drm/drm_self_refresh_helper.c new file +10
-0+EXPORT_SYMBOL (drm_self_refresh_helper_alter_state); + +/** +* drm_self_refresh_helper_register - Registers self refresh helpers for a crtc +* @crtc: the crtc which supports self refresh supported displays +* @entry_delay_ms: amount of inactivity to wait before entering self refresh +*/ +int drm_self_refresh_helper_register (struct drm_crtc *crtc, +unsigned int entry_delay_ms) +{
Bikeshed that I missed in previous rounds: _register/_unregister has pretty clear meaning of "(un)publish an interface to userspace". _init/_cleanup are the common ones.
Quoted 149 lines
drivers/gpu/drm/drm_self_refresh_helper.c new file +38
-0+struct drm_self_refresh_data *sr_data = crtc->self_refresh_data; + +/* Helper is already registered */ +if (WARN_ON (sr_data)) +return -EINVAL ; + + sr_data =kzalloc (sizeof (*sr_data),GFP_KERNEL ); +if (!sr_data) +return -ENOMEM ; + +INIT_DELAYED_WORK (&sr_data->entry_work, + drm_self_refresh_helper_entry_work); + sr_data->entry_delay_ms = entry_delay_ms; + sr_data->crtc = crtc; + + crtc->self_refresh_data = sr_data; +return 0 ; +} +EXPORT_SYMBOL (drm_self_refresh_helper_register); + +/** +* drm_self_refresh_helper_unregister - Unregisters self refresh helpers +* @crtc: the crtc to unregister +*/ +void drm_self_refresh_helper_unregister (struct drm_crtc *crtc) +{ +struct drm_self_refresh_data *sr_data = crtc->self_refresh_data; + +/* Helper is already unregistered */ +if (sr_data) +return ; + + crtc->self_refresh_data =NULL ; + +cancel_delayed_work_sync (&sr_data->entry_work); +kfree (sr_data); +} +EXPORT_SYMBOL (drm_self_refresh_helper_unregister);include/drm/drm_atomic.h +15
-0@@ -944,4 +944,19 @@ drm_atomic_crtc_needs_modeset(const struct drm_crtc_state *state) state->connectors_changed; } +/** +* drm_atomic_crtc_effectively_active - compute whether crtc is actually active +* @state: &drm_crtc_state for the CRTC +* +* When in self refresh mode, the crtc_state->active value will be false, since +* the crtc is off. However in some cases we're interested in whether the crtc +* is active, or effectively active (ie: it's connected to an active display). +* In these cases, use this function instead of just checking active. +*/ +static inline bool +drm_atomic_crtc_effectively_active (const struct drm_crtc_state *state) +{ +return state->active || state->self_refresh_active; +} +#endif /* DRM_ATOMIC_H_ */ include/drm/drm_connector.h +14
-0@@ -539,6 +539,20 @@ struct drm_connector_state {/** @tv: TV connector state */ struct drm_tv_connector_state tv; +/** +* @self_refresh_aware: +* +* This tracks whether a connector is aware of the self refresh state. +* It should be set to true for those connector implementations which +* understand the self refresh state. This is needed since the crtc +* registers the self refresh helpers and it doesn't know if the +* connectors downstream have implemented self refresh entry/exit. +* +* Drivers should set this to true in atomic_check if they know how to +* handle self_refresh requests. +*/ +bool self_refresh_aware; +/** * @picture_aspect_ratio: Connector property to control the * HDMI infoframe aspect ratio setting. include/drm/drm_crtc.h +19
-0@@ -53,6 +53,7 @@ struct drm_mode_set;struct drm_file ;struct drm_clip_rect ;struct drm_printer ; +struct drm_self_refresh_data ;struct device_node ;struct dma_fence ;struct edid ;@@ -299,6 +300,17 @@ struct drm_crtc_state {*/ bool vrr_enabled; +/** +* @self_refresh_active: +* +* Used by the self refresh helpers to denote when a self refresh +* transition is occuring. This will be set on enable/disable callbacks +* when self refresh is being enabled or disabled. In some cases, it may +* not be desirable to fully shut off the crtc during self refresh. +* CRTC's can inspect this flag and determine the best course of action. +*/ +bool self_refresh_active; +/** * @event: * @@ -1087,6 +1099,13 @@ struct drm_crtc {* The name of the CRTC's fence timeline. */ char timeline_name[32 ]; + +/** +* @self_refresh_data: Holds the state for the self refresh helpers +* +* Initialized via drm_self_refresh_helper_register(). +*/ +struct drm_self_refresh_data *self_refresh_data; };/** include/drm/drm_self_refresh_helper.h new file +12
-0@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright (C) 2019 Google, Inc. +* +* Authors: +* Sean Paul <[email protected]> +*/ +#ifndef DRM_SELF_REFRESH_HELPER_H_ +#define DRM_SELF_REFRESH_HELPER_H_ + +struct drm_atomic_state ; +struct drm_connector ;
include/drm/drm_self_refresh_helper.h line 22
Quoted 10 lines
include/drm/drm_self_refresh_helper.h new file +10
-0+struct drm_device ; +struct drm_modeset_acquire_ctx ; + +void drm_self_refresh_helper_alter_state (struct drm_atomic_state *state); + +int drm_self_refresh_helper_register (struct drm_crtc *crtc, +unsigned int entry_delay_ms); + +void drm_self_refresh_helper_unregister (struct drm_crtc *crtc); +#endif
With the remaining nits addressed: Reviewed-by: Daniel Vetter <[email protected]>
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Re: [PATCH v3 03/10] drm: Add atomic variants for bridge enable/disable
In reply to Sean PaulQuoted 71 lines · Sean Paul
From: Sean Paul <[email protected]>
This patch adds atomic variants for all of pre_enable/enable/disable/post_disable bridge functions. These will be called from the appropriate atomic helper functions. If the bridge driver doesn't implement the atomic version of the function, we will fall back to the vanilla implementation.
Note that some drivers call
drm_bridge_disabledirectly, and these cases are not covered. It's up to the driver to decide whether to implement bothatomic_disableand disable, or if it's not necessary.Changes in v3:
- Added to the patchsetCc Daniel Vetter <[email protected]>Cc Ville Syrjälä <[email protected]>Signed-off-by Sean Paul <[email protected]>--- drivers/gpu/drm/drm_atomic_helper.c | 8 +- drivers/gpu/drm/drm_bridge.c | 110 +++++++++++++++++++++++++++ include/drm/drm_bridge.h | 114 ++++++++++++++++++++++++++++ 3 files changed, 228 insertions(+), 4 deletions(-)drivers/gpu/drm/drm_atomic_helper.c +4
-4@@ -995,7 +995,7 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)* Each encoder has at most one connector (since we always steal * it away), so we won't call disable hooks twice. */ -drm_bridge_disable (encoder->bridge); +drm_atomic_bridge_disable (encoder->bridge, old_state);/* Right function depends upon target state. */ if (funcs) {@@ -1009,7 +1009,7 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state) funcs->dpms (encoder,DRM_MODE_DPMS_OFF ); } -drm_bridge_post_disable (encoder->bridge); +drm_atomic_bridge_post_disable (encoder->bridge, old_state); }for_each_oldnew_crtc_in_state (old_state, crtc, old_crtc_state, new_crtc_state, i) {@@ -1308,7 +1308,7 @@ void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev,* Each encoder has at most one connector (since we always steal * it away), so we won't call enable hooks twice. */ -drm_bridge_pre_enable (encoder->bridge); +drm_atomic_bridge_pre_enable (encoder->bridge, old_state);if (funcs) {if (funcs->atomic_enable)@@ -1319,7 +1319,7 @@ void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev, funcs->commit (encoder); } -drm_bridge_enable (encoder->bridge); +drm_atomic_bridge_enable (encoder->bridge, old_state); }drm_atomic_helper_commit_writebacks (dev, old_state);drivers/gpu/drm/drm_bridge.c +0
-0@@ -352,6 +352,116 @@ void drm_bridge_enable(struct drm_bridge *bridge) }EXPORT_SYMBOL (drm_bridge_enable);
drivers/gpu/drm/drm_bridge.c void drm_bridge_enable(struct drm_bridge *bridge) · line 363
Quoted 10 lines
drivers/gpu/drm/drm_bridge.c +9
-0+/** +* drm_atomic_bridge_disable - disables all bridges in the encoder chain +* @bridge: bridge control structure +* @state: atomic state being committed +* +* Calls &drm_bridge_funcs.atomic_disable (falls back on +* &drm_bridge_funcs.disable) op for all the bridges in the encoder chain, +* starting from the last bridge to the first. These are called before calling +* the encoder's prepare op.
Since this is for atomic, where &drm_encoder_helper_funcs.atomic_disable is the recommened one, would be good to change that. Plus use the hyperlinked form. Same for all the below.
Quoted 43 lines
drivers/gpu/drm/drm_bridge.c +43
-0+* +* Note: the bridge passed should be the one closest to the encoder +*/ +void drm_atomic_bridge_disable (struct drm_bridge *bridge, +struct drm_atomic_state *state) +{ +if (!bridge) +return ; + +drm_atomic_bridge_disable (bridge->next, state); + +if (bridge->funcs->atomic_disable) + bridge->funcs->atomic_disable (bridge, state); +else if (bridge->funcs->disable) + bridge->funcs->disable (bridge); +} +EXPORT_SYMBOL (drm_atomic_bridge_disable); + +/** +* drm_atomic_bridge_post_disable - cleans up after disabling all bridges in the +* encoder chain +* @bridge: bridge control structure +* @state: atomic state being committed +* +* Calls &drm_bridge_funcs.atomic_post_disable (falls back on +* &drm_bridge_funcs.post_disable) op for all the bridges in the encoder chain, +* starting from the first bridge to the last. These are called after completing +* the encoder's prepare op. +* +* Note: the bridge passed should be the one closest to the encoder +*/ +void drm_atomic_bridge_post_disable (struct drm_bridge *bridge, +struct drm_atomic_state *state) +{ +if (!bridge) +return ; + +if (bridge->funcs->atomic_post_disable) + bridge->funcs->atomic_post_disable (bridge, state); +else if (bridge->funcs->post_disable) + bridge->funcs->post_disable (bridge); + +drm_atomic_bridge_post_disable (bridge->next, state);
drivers/gpu/drm/drm_bridge.c void drm_bridge_enable(struct drm_bridge *bridge) · line 416
Quoted 10 lines
drivers/gpu/drm/drm_bridge.c +10
-0+} +EXPORT_SYMBOL (drm_atomic_bridge_post_disable); + +/** +* drm_bridge_pre_enable - prepares for enabling all bridges in the encoder +* chain +* @bridge: bridge control structure +* @state: atomic state being committed +* +* Calls &drm_bridge_funcs.pre_enable (falls back on
atomic_pre_enable (I think all the others you've adjusted correctly).
drivers/gpu/drm/drm_bridge.c void drm_bridge_enable(struct drm_bridge *bridge) · line 419
Quoted 3 lines
drivers/gpu/drm/drm_bridge.c +3
-0+* &drm_bridge_funcs.pre_enable) op for all the bridges in the encoder chain, +* starting from the last bridge to the first. These are called before calling +* the encoder's commit op.
&drm_encoder_helper_funcs.atomic_enable
Quoted 58 lines
drivers/gpu/drm/drm_bridge.c +45
-0+* +* Note: the bridge passed should be the one closest to the encoder +*/ +void drm_atomic_bridge_pre_enable (struct drm_bridge *bridge, +struct drm_atomic_state *state) +{ +if (!bridge) +return ; + +drm_atomic_bridge_pre_enable (bridge->next, state); + +if (bridge->funcs->atomic_pre_enable) + bridge->funcs->atomic_pre_enable (bridge, state); +else if (bridge->funcs->pre_enable) + bridge->funcs->pre_enable (bridge); +} +EXPORT_SYMBOL (drm_atomic_bridge_pre_enable); + +/** +* drm_atomic_bridge_enable - enables all bridges in the encoder chain +* @bridge: bridge control structure +* @state: atomic state being committed +* +* Calls &drm_bridge_funcs.atomic_enable (falls back on +* &drm_bridge_funcs.enable) op for all the bridges in the encoder chain, +* starting from the first bridge to the last. These are called after completing +* the encoder's commit op. +* +* Note: the bridge passed should be the one closest to the encoder +*/ +void drm_atomic_bridge_enable (struct drm_bridge *bridge, +struct drm_atomic_state *state) +{ +if (!bridge) +return ; + +if (bridge->funcs->atomic_enable) + bridge->funcs->atomic_enable (bridge, state); +else if (bridge->funcs->enable) + bridge->funcs->enable (bridge); + +drm_atomic_bridge_enable (bridge->next, state); +} +EXPORT_SYMBOL (drm_atomic_bridge_enable); +#ifdef CONFIG_OF /** * of_drm_find_bridge - find the bridge corresponding to the device node in include/drm/drm_bridge.h +2
-0@@ -237,6 +237,111 @@ struct drm_bridge_funcs {* The enable callback is optional. */ void (*enable)(struct drm_bridge *bridge); + +/**
include/drm/drm_bridge.h struct drm_bridge_funcs { · line 251
Quoted 10 lines
include/drm/drm_bridge.h +10
-0+* @atomic_pre_enable: +* +* This callback should enable the bridge. It is called right before +* the preceding element in the display pipe is enabled. If the +* preceding element is a bridge this means it's called before that +* bridge's @atomic_pre_enable or @pre_enable function. If the preceding +* element is a &drm_encoder it's called right before the encoder's +* &drm_encoder_helper_funcs.atomic_enable, +* &drm_encoder_helper_funcs.enable, &drm_encoder_helper_funcs.commit or +* &drm_encoder_helper_funcs.dpms hook.
I woulnd't mention the depracated (for atomic drivers) hooks anymore, i.e. drop commit, dpms, prepare in all these texts. Also makes it more readable.
Quoted 114 lines
include/drm/drm_bridge.h +102
-0+* +* The display pipe (i.e. clocks and timing signals) feeding this bridge +* will not yet be running when this callback is called. The bridge must +* not enable the display link feeding the next bridge in the chain (if +* there is one) when this callback is called. +* +* Note that this function will only be invoked in the context of an +* atomic commit. It will not be invoked from &drm_bridge_pre_enable. It +* would be prudent to also provide an implementation of @pre_enable if +* you are expecting driver calls into &drm_bridge_pre_enable. +* +* The @atomic_pre_enable callback is optional. +*/ +void (*atomic_pre_enable)(struct drm_bridge *bridge, +struct drm_atomic_state *state); + +/** +* @atomic_enable: +* +* This callback should enable the bridge. It is called right after +* the preceding element in the display pipe is enabled. If the +* preceding element is a bridge this means it's called after that +* bridge's @atomic_enable or @enable function. If the preceding element +* is a &drm_encoder it's called right after the encoder's +* &drm_encoder_helper_funcs.atomic_enable, +* &drm_encoder_helper_funcs.enable, &drm_encoder_helper_funcs.commit or +* &drm_encoder_helper_funcs.dpms hook. +* +* The bridge can assume that the display pipe (i.e. clocks and timing +* signals) feeding it is running when this callback is called. This +* callback must enable the display link feeding the next bridge in the +* chain if there is one. +* +* Note that this function will only be invoked in the context of an +* atomic commit. It will not be invoked from &drm_bridge_enable. It +* would be prudent to also provide an implementation of @enable if +* you are expecting driver calls into &drm_bridge_enable. +* +* The enable callback is optional. +*/ +void (*atomic_enable)(struct drm_bridge *bridge, +struct drm_atomic_state *state); +/** +* @atomic_disable: +* +* This callback should disable the bridge. It is called right before +* the preceding element in the display pipe is disabled. If the +* preceding element is a bridge this means it's called before that +* bridge's @atomic_disable or @disable vfunc. If the preceding element +* is a &drm_encoder it's called right before the +* &drm_encoder_helper_funcs.atomic_disable, +* &drm_encoder_helper_funcs.disable, &drm_encoder_helper_funcs.prepare +* or &drm_encoder_helper_funcs.dpms hook. +* +* The bridge can assume that the display pipe (i.e. clocks and timing +* signals) feeding it is still running when this callback is called. +* +* Note that this function will only be invoked in the context of an +* atomic commit. It will not be invoked from &drm_bridge_disable. It +* would be prudent to also provide an implementation of @disable if +* you are expecting driver calls into &drm_bridge_disable. +* +* The disable callback is optional. +*/ +void (*atomic_disable)(struct drm_bridge *bridge, +struct drm_atomic_state *state); + +/** +* @atomic_post_disable: +* +* This callback should disable the bridge. It is called right after the +* preceding element in the display pipe is disabled. If the preceding +* element is a bridge this means it's called after that bridge's +* @atomic_post_disable or @post_disable function. If the preceding +* element is a &drm_encoder it's called right after the encoder's +* &drm_encoder_helper_funcs.atomic_disable, +* &drm_encoder_helper_funcs.disable, &drm_encoder_helper_funcs.prepare +* or &drm_encoder_helper_funcs.dpms hook. +* +* The bridge must assume that the display pipe (i.e. clocks and timing +* singals) feeding it is no longer running when this callback is +* called. +* +* Note that this function will only be invoked in the context of an +* atomic commit. It will not be invoked from &drm_bridge_post_disable. +* It would be prudent to also provide an implementation of +* @post_disable if you are expecting driver calls into +* &drm_bridge_post_disable. +* +* The post_disable callback is optional. +*/ +void (*atomic_post_disable)(struct drm_bridge *bridge, +struct drm_atomic_state *state); };/** @@ -314,6 +419,15 @@ void drm_bridge_mode_set(struct drm_bridge *bridge,void drm_bridge_pre_enable (struct drm_bridge *bridge);void drm_bridge_enable (struct drm_bridge *bridge); +void drm_atomic_bridge_disable (struct drm_bridge *bridge, +struct drm_atomic_state *state); +void drm_atomic_bridge_post_disable (struct drm_bridge *bridge, +struct drm_atomic_state *state); +void drm_atomic_bridge_pre_enable (struct drm_bridge *bridge, +struct drm_atomic_state *state); +void drm_atomic_bridge_enable (struct drm_bridge *bridge, +struct drm_atomic_state *state); +#ifdef CONFIG_DRM_PANEL_BRIDGE struct drm_bridge *drm_panel_bridge_add (struct drm_panel *panel,u32 connector_type);Signature · 1 line
Sean Paul, Software Engineer, Google / Chromium OS
With the doc nits:
Quoted 1 line
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Re: [PATCH v3 01/10] drm: Add atomic variants of enable/disable to encoder helper funcs
In reply to Sean PaulQuoted 30 lines · Sean Paul
From: Sean Paul <[email protected]>
This patch adds
atomic_enableandatomic_disablecallbacks to the encoder helpers. This will allow encoders to make informed decisions in their start-up/shutdown based on the committed state.Aside from the new hooks, this patch also introduces the new signature for .atomic_* functions going forward. Instead of passing object state (well, encoders don't have atomic state, but let's ignore that), we pass the entire atomic state so the driver can inspect more than what's happening locally.
This is particularly important for the upcoming self refresh helpers.
Changes in v3:
- Added patch to the setCc Daniel Vetter <[email protected]>Cc Ville Syrjälä <[email protected]>Signed-off-by Sean Paul <[email protected]>--- drivers/gpu/drm/drm_atomic_helper.c | 6 +++- include/drm/drm_modeset_helper_vtables.h | 45 ++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-)drivers/gpu/drm/drm_atomic_helper.c +0
-0
drivers/gpu/drm/drm_atomic_helper.c disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state) · line 1005
Quoted 5 lines
drivers/gpu/drm/drm_atomic_helper.c +2
-0@@ -1001,6 +1001,8 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)if (funcs) {if (new_conn_state->crtc && funcs->prepare) funcs->prepare (encoder); +else if (funcs->atomic_disable) + funcs->atomic_disable (encoder, old_state);
I'd put the atomic one first. The reason why ->disable here is later is that ->disable has some really funky meaning in the old legacy crtc helpers, and hence ->prepare was preferrable: Legacy ->disable also was supposed to release resources (something we now do in ->atomic_destroy_state). See the huge NOTE: in the @disable kerneldoc.
Quoted 31 lines
drivers/gpu/drm/drm_atomic_helper.c +3
-1else if (funcs->disable) funcs->disable (encoder);else if (funcs->dpms)@@ -1309,7 +1311,9 @@ void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev,drm_bridge_pre_enable (encoder->bridge);if (funcs) { -if (funcs->enable) +if (funcs->atomic_enable) + funcs->atomic_enable (encoder, old_state); +else if (funcs->enable) funcs->enable (encoder);else if (funcs->commit) funcs->commit (encoder);include/drm/drm_modeset_helper_vtables.h +9
-0@@ -675,6 +675,51 @@ struct drm_encoder_helper_funcs {enum drm_connector_status (*detect)(struct drm_encoder *encoder,struct drm_connector *connector); +/** +* @atomic_disable: +* +* This callback should be used to disable the encoder. With the atomic +* drivers it is called before this encoder's CRTC has been shut off +* using their own &drm_crtc_helper_funcs.atomic_disable hook. If that +* sequence is too simple drivers can just add their own driver private +* encoder hooks and call them from CRTC's callback by looping over all +* encoders connected to it using for_each_encoder_on_crtc().
include/drm/drm_modeset_helper_vtables.h struct drm_encoder_helper_funcs { · line 696
Quoted 10 lines
include/drm/drm_modeset_helper_vtables.h +10
-0+* +* This callback is a variant of @disable that provides the atomic state +* to the driver. It takes priority over @disable during atomic commits. +* +* This hook is used only by atomic helpers. Atomic drivers don't need +* to implement it if there's no need to disable anything at the encoder +* level. To ensure that runtime PM handling (using either DPMS or the +* new "ACTIVE" property) works @atomic_disable must be the inverse of +* @atomic_enable. +*/
I'd add something like "For atomic drivers also consider @atomic_disable" to the kerneldoc of @disable (before the NOTE: which is only relevant for pre-atomic). Same for the enable side.
Quoted 6 lines
include/drm/drm_modeset_helper_vtables.h +6
-0+void (*atomic_disable)(struct drm_encoder *encoder, +struct drm_atomic_state *state); + +/** +* @atomic_enable: +*
include/drm/drm_modeset_helper_vtables.h struct drm_encoder_helper_funcs { · line 712
Quoted 10 lines
include/drm/drm_modeset_helper_vtables.h +10
-0+* This callback should be used to enable the encoder. It is called +* after this encoder's CRTC has been enabled using their own +* &drm_crtc_helper_funcs.atomic_enable hook. If that sequence is +* too simple drivers can just add their own driver private encoder +* hooks and call them from CRTC's callback by looping over all encoders +* connected to it using for_each_encoder_on_crtc(). +* +* This callback is a variant of @enable that provides the atomic state +* to the driver. It is called in place of @enable during atomic +* commits.
needs to be adjusted here for "takes priority".
include/drm/drm_modeset_helper_vtables.h struct drm_encoder_helper_funcs { · line 722
Quoted 10 lines
include/drm/drm_modeset_helper_vtables.h +10
-0+* +* This hook is used only by atomic helpers, for symmetry with @disable. +* Atomic drivers don't need to implement it if there's no need to +* enable anything at the encoder level. To ensure that runtime PM +* handling (using either DPMS or the new "ACTIVE" property) works +* @enable must be the inverse of @disable for atomic drivers. +*/ +void (*atomic_enable)(struct drm_encoder *encoder, +struct drm_atomic_state *state); +
With the nits:
Quoted 6 lines
include/drm/drm_modeset_helper_vtables.h +0
-0/** * @disable: * Signature · 1 line
Sean Paul, Software Engineer, Google / Chromium OS
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Re: [PATCH v3 02/10] drm: Add drm_atomic_crtc_state_for_encoder helper
In reply to Sean PaulQuoted 7 lines · Sean Paul
From: Sean Paul <[email protected]>
This patch adds a helper to tease out the currently connected crtc for an encoder, along with its state. This follows the same pattern as the drm_atomic_crtc_*_for_* macros in the atomic helpers. Since the relationship of crtc:encoder is 1:n, we don't need a loop since there is only one crtc per encoder.
No idea which macros you mean, couldn't find them.
Quoted 47 lines
Instead of splitting this into 3 functions which all do the same thing, this is presented as one function. Perhaps that's too ugly and it should be split to:
structdrm_crtc*drm_atomic_crtc_for_encoder(state, encoder); structdrm_crtc_state*drm_atomic_new_crtc_state_for_encoder(state, encoder); structdrm_crtc_state*drm_atomic_old_crtc_state_for_encoder(state, encoder);Suggestions welcome.
Changes in v3:
- Added to the setCc Daniel Vetter <[email protected]>Cc Ville Syrjälä <[email protected]>Signed-off-by Sean Paul <[email protected]>--- drivers/gpu/drm/drm_atomic_helper.c | 48 +++++++++++++++++++++++++++++ include/drm/drm_atomic_helper.h | 6 ++++ 2 files changed, 54 insertions(+)drivers/gpu/drm/drm_atomic_helper.c +18
-0@@ -3591,3 +3591,51 @@ int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,return ret; }EXPORT_SYMBOL (drm_atomic_helper_legacy_gamma_set); + +/** +* drm_atomic_crtc_state_for_encoder - Get crtc and new/old state for an encoder +* @state: Atomic state +* @encoder: The encoder to fetch the crtc information for +* @crtc: If not NULL, receives the currently connected crtc +* @old_crtc_state: If not NULL, receives the crtc's old state +* @new_crtc_state: If not NULL, receives the crtc's new state +* +* This function finds the crtc which is currently connected to @encoder and +* returns it as well as its old and new state. If there is no crtc currently +* connected, the function will clear @crtc, @old_crtc_state, @new_crtc_state. +* +* All of @crtc, @old_crtc_state, and @new_crtc_state are optional. +*/ +void drm_atomic_crtc_state_for_encoder(struct drm_atomic_state *state, + struct drm_encoder *encoder, + struct drm_crtc **crtc,
drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc, · line 3621
Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +10
-0+struct drm_crtc_state **old_crtc_state, + struct drm_crtc_state **new_crtc_state) +{ + struct drm_crtc *tmp_crtc; +struct drm_crtc_state *tmp_new_crtc_state, *tmp_old_crtc_state; +u32 enc_mask =drm_encoder_mask (encoder); +int i; + +for_each_oldnew_crtc_in_state (state, tmp_crtc, tmp_old_crtc_state, + tmp_new_crtc_state, i) {
So there's two ways to do this:
- Using encoder_mask, which is a helper thing. In that case I'd rename this to drm_atomic_helper_crtc_for_encoder.
- By looping over the connectors, and looking at ->best_encoder and ->crtc, see drm_encoder_get_crtc in drm_encoder.c. That's the core way of doing things. In that case call it drm_atomic_crtc_for_encoder, and put it into drm_atomic.c.
There's two ways of doing the 2nd one: looping over connectors in a drm_atomic_state, or the connector list overall. First requires that the encoder is already in drm_atomic_state (which I think makes sense).
Even more complications on old/new_crtc_state: Is that the old state for the old crtc, or the old state for the new crtc (that can switch too). Same for the new crtc state ...
tldr; I'd create 2 functions:
drm_crtc *drm_atomic_encoder_get_new_crtc(drm_atomic_state *state, encoder) drm_crtc *drm_atomic_encoder_get_old_crtc(drm_atomic_state *state, encoder)
With the requirement that they'll return NULL if the encder isn't in in @state, and implemented using looping over connectors in @state.
tldr; this is a lot more tricky than it looks like ... -Daniel
Quoted 40 lines
drivers/gpu/drm/drm_atomic_helper.c +20
-0+if (!(tmp_new_crtc_state->encoder_mask & enc_mask)) +continue ; + +if (new_crtc_state) + *new_crtc_state = tmp_new_crtc_state; +if (old_crtc_state) + *old_crtc_state = tmp_old_crtc_state; +if (crtc) + *crtc = tmp_crtc; +return ; + } + +if (new_crtc_state) + *new_crtc_state =NULL ; +if (old_crtc_state) + *old_crtc_state =NULL ; +if (crtc) + *crtc =NULL ; +} +EXPORT_SYMBOL (drm_atomic_crtc_state_for_encoder);include/drm/drm_atomic_helper.h +6
-0@@ -153,6 +153,12 @@ int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,uint32_t size, struct drm_modeset_acquire_ctx *ctx); +void drm_atomic_crtc_state_for_encoder (struct drm_atomic_state *state, +struct drm_encoder *encoder, +struct drm_crtc **crtc, +struct drm_crtc_state **old_crtc_state, +struct drm_crtc_state **new_crtc_state); +/** * drm_atomic_crtc_for_each_plane - iterate over planes currently attached to CRTC * @plane: the loop cursor Signature · 1 line
Sean Paul, Software Engineer, Google / Chromium OS
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Re: [PATCH v3 04/10] drm: Convert connector_helper_funcs->atomic_check to accept drm_atomic_state
In reply to Sean PaulQuoted 13 lines · Sean Paul
From: Sean Paul <[email protected]>
Everyone who implements
connector_helper_funcs->atomic_checkreaches into the connector state to get the atomic state. Instead of continuing this pattern, change the callback signature to just give atomic state and let the driver determine what it does and does not need from it.Eventually all atomic functions should do this, but that's just too much busy work for me.
Changes in v3:
- Added to the set
Quoted 10 lines
Cc Daniel Vetter <[email protected]>Cc Ville Syrjälä <[email protected]>Cc Jani Nikula <[email protected]>Cc Joonas Lahtinen <[email protected]>Cc Rodrigo Vivi <[email protected]>Cc Ben Skeggs <[email protected]>Cc Laurent Pinchart <[email protected]>Cc Kieran Bingham <[email protected]>Cc Eric Anholt <[email protected]>Signed-off-by Sean Paul <[email protected]>
Assuming it compiles everywhere and intel-gfx-ci approves too
Quoted 259 lines
--- drivers/gpu/drm/drm_atomic_helper.c | 4 ++-- drivers/gpu/drm/i915/intel_atomic.c | 8 +++++--- drivers/gpu/drm/i915/intel_dp_mst.c | 7 ++++--- drivers/gpu/drm/i915/intel_drv.h | 2 +- drivers/gpu/drm/i915/intel_sdvo.c | 9 +++++---- drivers/gpu/drm/i915/intel_tv.c | 8 +++++--- drivers/gpu/drm/nouveau/dispnv50/disp.c | 5 +++-- drivers/gpu/drm/rcar-du/rcar_lvds.c | 12 +++++++----- drivers/gpu/drm/vc4/vc4_txp.c | 7 ++++--- include/drm/drm_modeset_helper_vtables.h | 2 +- 10 files changed, 37 insertions(+), 27 deletions(-)drivers/gpu/drm/drm_atomic_helper.c +2
-2@@ -683,7 +683,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev, }if (funcs->atomic_check) - ret = funcs->atomic_check (connector, new_connector_state); + ret = funcs->atomic_check (connector, state);if (ret)return ret;@@ -725,7 +725,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,continue ;if (funcs->atomic_check) - ret = funcs->atomic_check (connector, new_connector_state); + ret = funcs->atomic_check (connector, state);if (ret)return ret; }drivers/gpu/drm/i915/intel_atomic.c +5
-3@@ -103,12 +103,14 @@ int intel_digital_connector_atomic_set_property(struct drm_connector *connector, }int intel_digital_connector_atomic_check (struct drm_connector *conn, -struct drm_connector_state *new_state) +struct drm_atomic_state *state) { +struct drm_connector_state *new_state = +drm_atomic_get_new_connector_state (state, conn);struct intel_digital_connector_state *new_conn_state =to_intel_digital_connector_state (new_state);struct drm_connector_state *old_state = -drm_atomic_get_old_connector_state (new_state->state, conn); +drm_atomic_get_old_connector_state (state, conn);struct intel_digital_connector_state *old_conn_state =to_intel_digital_connector_state (old_state);struct drm_crtc_state *crtc_state;@@ -118,7 +120,7 @@ int intel_digital_connector_atomic_check(struct drm_connector *conn,if (!new_state->crtc)return 0 ; - crtc_state =drm_atomic_get_new_crtc_state (new_state->state, new_state->crtc); + crtc_state =drm_atomic_get_new_crtc_state (state, new_state->crtc);/* * These properties are handled by fastset, and might not end drivers/gpu/drm/i915/intel_dp_mst.c +4
-3@@ -143,9 +143,10 @@ static int intel_dp_mst_compute_config(struct intel_encoder *encoder,static int intel_dp_mst_atomic_check (struct drm_connector *connector, -struct drm_connector_state *new_conn_state) +struct drm_atomic_state *state) { -struct drm_atomic_state *state = new_conn_state->state; +struct drm_connector_state *new_conn_state = +drm_atomic_get_new_connector_state (state, connector);struct drm_connector_state *old_conn_state =drm_atomic_get_old_connector_state (state, connector); struct intel_connector *intel_connector =@@ -155,7 +156,7 @@ intel_dp_mst_atomic_check(struct drm_connector *connector,struct drm_dp_mst_topology_mgr *mgr;int ret; - ret =intel_digital_connector_atomic_check (connector, new_conn_state); + ret =intel_digital_connector_atomic_check (connector, state);if (ret)return ret;drivers/gpu/drm/i915/intel_drv.h +1
-1@@ -2481,7 +2481,7 @@ int intel_digital_connector_atomic_set_property(struct drm_connector *connector,struct drm_property *property, u64 val);int intel_digital_connector_atomic_check (struct drm_connector *conn, -struct drm_connector_state *new_state); +struct drm_atomic_state *state);struct drm_connector_state *intel_digital_connector_duplicate_state (struct drm_connector *connector);drivers/gpu/drm/i915/intel_sdvo.c +5
-4@@ -2342,9 +2342,10 @@ static const struct drm_connector_funcs intel_sdvo_connector_funcs = { };static int intel_sdvo_atomic_check (struct drm_connector *conn, -struct drm_connector_state *new_conn_state) +struct drm_atomic_state *state) { -struct drm_atomic_state *state = new_conn_state->state; +struct drm_connector_state *new_conn_state = +drm_atomic_get_new_connector_state (state, conn);struct drm_connector_state *old_conn_state =drm_atomic_get_old_connector_state (state, conn); struct intel_sdvo_connector_state *old_state =@@ -2356,13 +2357,13 @@ static int intel_sdvo_atomic_check(struct drm_connector *conn, (memcmp(&old_state->tv, &new_state->tv, sizeof(old_state->tv)) || memcmp(&old_conn_state->tv, &new_conn_state->tv, sizeof(old_conn_state->tv)))) {struct drm_crtc_state *crtc_state = -drm_atomic_get_new_crtc_state (new_conn_state->state, +drm_atomic_get_new_crtc_state (state, new_conn_state->crtc); crtc_state->connectors_changed = true; } -return intel_digital_connector_atomic_check (conn, new_conn_state); +return intel_digital_connector_atomic_check (conn, state); }static const struct drm_connector_helper_funcs intel_sdvo_connector_helper_funcs = {drivers/gpu/drm/i915/intel_tv.c +5
-3@@ -1817,16 +1817,18 @@ static const struct drm_connector_funcs intel_tv_connector_funcs = { };static int intel_tv_atomic_check (struct drm_connector *connector, -struct drm_connector_state *new_state) +struct drm_atomic_state *state) { +struct drm_connector_state *new_state;struct drm_crtc_state *new_crtc_state;struct drm_connector_state *old_state; + new_state =drm_atomic_get_new_connector_state (state, connector);if (!new_state->crtc)return 0 ; - old_state =drm_atomic_get_old_connector_state (new_state->state, connector); - new_crtc_state =drm_atomic_get_new_crtc_state (new_state->state, new_state->crtc); + old_state =drm_atomic_get_old_connector_state (state, connector); + new_crtc_state =drm_atomic_get_new_crtc_state (state, new_state->crtc); if (old_state->tv.mode != new_state->tv.mode || old_state->tv.margins.left != new_state->tv.margins.left ||drivers/gpu/drm/nouveau/dispnv50/disp.c +3
-2@@ -948,11 +948,12 @@ nv50_mstc_get_modes(struct drm_connector *connector)static int nv50_mstc_atomic_check (struct drm_connector *connector, -struct drm_connector_state *new_conn_state) +struct drm_atomic_state *state) { -struct drm_atomic_state *state = new_conn_state->state;struct nv50_mstc *mstc =nv50_mstc (connector);struct drm_dp_mst_topology_mgr *mgr = &mstc->mstm->mgr; +struct drm_connector_state *new_conn_state = +drm_atomic_get_new_connector_state (state, connector);struct drm_connector_state *old_conn_state =drm_atomic_get_old_connector_state (state, connector);struct drm_crtc_state *crtc_state;drivers/gpu/drm/rcar-du/rcar_lvds.c +7
-5@@ -92,13 +92,15 @@ static int rcar_lvds_connector_get_modes(struct drm_connector *connector) }static int rcar_lvds_connector_atomic_check (struct drm_connector *connector, -struct drm_connector_state *state) +struct drm_atomic_state *state) {struct rcar_lvds *lvds =connector_to_rcar_lvds (connector);const struct drm_display_mode *panel_mode; +struct drm_connector_state *conn_state;struct drm_crtc_state *crtc_state; -if (!state->crtc) + conn_state =drm_atomic_get_new_connector_state (state, connector); +if (!conn_state->crtc)return 0 ;if (list_empty (&connector->modes)) {@@ -110,9 +112,9 @@ static int rcar_lvds_connector_atomic_check(struct drm_connector *connector, struct drm_display_mode, head);/* We're not allowed to modify the resolution. */ - crtc_state =drm_atomic_get_crtc_state (state->state, state->crtc); -if (IS_ERR (crtc_state)) -return PTR_ERR (crtc_state); + crtc_state =drm_atomic_get_crtc_state (state, conn_state->crtc); +if (!crtc_state) +return -EINVAL ;if (crtc_state->mode.hdisplay != panel_mode->hdisplay || crtc_state->mode.vdisplay != panel_mode->vdisplay)drivers/gpu/drm/vc4/vc4_txp.c +4
-3@@ -221,17 +221,18 @@ static const u32 txp_fmts[] = { };static int vc4_txp_connector_atomic_check (struct drm_connector *conn, -struct drm_connector_state *conn_state) +struct drm_atomic_state *state) { +struct drm_connector_state *conn_state;struct drm_crtc_state *crtc_state;struct drm_framebuffer *fb;int i; + conn_state =drm_atomic_get_new_connector_state (state, conn);if (!conn_state->writeback_job || !conn_state->writeback_job->fb)return 0 ; - crtc_state =drm_atomic_get_new_crtc_state (conn_state->state, - conn_state->crtc); + crtc_state =drm_atomic_get_new_crtc_state (state, conn_state->crtc); fb = conn_state->writeback_job->fb; if (fb->width != crtc_state->mode.hdisplay ||include/drm/drm_modeset_helper_vtables.h +1
-1@@ -1020,7 +1020,7 @@ struct drm_connector_helper_funcs {* deadlock. */ int (*atomic_check)(struct drm_connector *connector, -struct drm_connector_state *state); +struct drm_atomic_state *state);/** * @atomic_commit: Signature · 1 line
Sean Paul, Software Engineer, Google / Chromium OS
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Re: [PATCH v3 01/10] drm: Add atomic variants of enable/disable to encoder helper funcs
In reply to Daniel VetterQuoted 18 lines · Daniel Vetter
Quoted 17 lines · Sean Paul
From: Sean Paul <[email protected]>
This patch adds
atomic_enableandatomic_disablecallbacks to the encoder helpers. This will allow encoders to make informed decisions in their start-up/shutdown based on the committed state.Aside from the new hooks, this patch also introduces the new signature for .atomic_* functions going forward. Instead of passing object state (well, encoders don't have atomic state, but let's ignore that), we pass the entire atomic state so the driver can inspect more than what's happening locally.
This is particularly important for the upcoming self refresh helpers.
Changes in v3:
- Added patch to the set
Quoted 7 lines
Quoted 7 lines
Cc Daniel Vetter <[email protected]>Cc Ville Syrjälä <[email protected]>Signed-off-by Sean Paul <[email protected]>--- drivers/gpu/drm/drm_atomic_helper.c | 6 +++- include/drm/drm_modeset_helper_vtables.h | 45 ++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-)
/snip
Quoted 42 lines
Quoted 17 lines
include/drm/drm_modeset_helper_vtables.h +9
-0@@ -675,6 +675,51 @@ struct drm_encoder_helper_funcs {enum drm_connector_status (*detect)(struct drm_encoder *encoder,struct drm_connector *connector); +/** +* @atomic_disable: +* +* This callback should be used to disable the encoder. With the atomic +* drivers it is called before this encoder's CRTC has been shut off +* using their own &drm_crtc_helper_funcs.atomic_disable hook. If that +* sequence is too simple drivers can just add their own driver private +* encoder hooks and call them from CRTC's callback by looping over all +* encoders connected to it using for_each_encoder_on_crtc(). include/drm/drm_modeset_helper_vtables.h struct drm_encoder_helper_funcs { · line 696
Quoted 10 lines
include/drm/drm_modeset_helper_vtables.h +10
-0+* +* This callback is a variant of @disable that provides the atomic state +* to the driver. It takes priority over @disable during atomic commits. +* +* This hook is used only by atomic helpers. Atomic drivers don't need +* to implement it if there's no need to disable anything at the encoder +* level. To ensure that runtime PM handling (using either DPMS or the +* new "ACTIVE" property) works @atomic_disable must be the inverse of +* @atomic_enable. +*/ I'd add something like "For atomic drivers also consider @atomic_disable" to the kerneldoc of @disable (before the NOTE: which is only relevant for pre-atomic). Same for the enable side.
Quoted 10 lines
include/drm/drm_modeset_helper_vtables.h +10
-0+void (*atomic_disable)(struct drm_encoder *encoder, +struct drm_atomic_state *state); + +/** +* @atomic_enable: +* +* This callback should be used to enable the encoder. It is called +* after this encoder's CRTC has been enabled using their own +* &drm_crtc_helper_funcs.atomic_enable hook. If that sequence is +* too simple drivers can just add their own driver private encoder
Quoted 8 lines
include/drm/drm_modeset_helper_vtables.h struct drm_encoder_helper_funcs { · line 712
Quoted 6 lines
include/drm/drm_modeset_helper_vtables.h +6
-0+* hooks and call them from CRTC's callback by looping over all encoders +* connected to it using for_each_encoder_on_crtc(). +* +* This callback is a variant of @enable that provides the atomic state +* to the driver. It is called in place of @enable during atomic +* commits. needs to be adjusted here for "takes priority".
Can you clarify this comment? I'm a little fuzzy on what it means.
Quoted 13 lines
include/drm/drm_modeset_helper_vtables.h struct drm_encoder_helper_funcs { · line 722
Quoted 10 lines
include/drm/drm_modeset_helper_vtables.h +10
-0+* +* This hook is used only by atomic helpers, for symmetry with @disable. +* Atomic drivers don't need to implement it if there's no need to +* enable anything at the encoder level. To ensure that runtime PM +* handling (using either DPMS or the new "ACTIVE" property) works +* @enable must be the inverse of @disable for atomic drivers. +*/ +void (*atomic_enable)(struct drm_encoder *encoder, +struct drm_atomic_state *state); +With the nits:
Quoted 1 line
Reviewed-by Daniel Vetter <[email protected]>
Thanks!
Sean
Quoted 12 lines
Quoted 7 lines
include/drm/drm_modeset_helper_vtables.h +0
-0/** * @disable: * Signature · 1 line
Sean Paul, Software Engineer, Google / Chromium OSSignature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Signature · 1 line
Sean Paul, Software Engineer, Google / Chromium OS
Re: [PATCH v3 02/10] drm: Add drm_atomic_crtc_state_for_encoder helper
In reply to Daniel VetterQuoted 10 lines · Daniel Vetter
Quoted 7 lines · Sean Paul
From: Sean Paul <[email protected]>
This patch adds a helper to tease out the currently connected crtc for an encoder, along with its state. This follows the same pattern as the drm_atomic_crtc_*_for_* macros in the atomic helpers. Since the relationship of crtc:encoder is 1:n, we don't need a loop since there is only one crtc per encoder.
No idea which macros you mean, couldn't find them.
No longer relevant with the changes below, but for completeness, I was trying to refer to drm_atomic_crtc_state_for_each_plane and friends. I see now that I wasn't terribly clear :)
Quoted 63 lines
Quoted 47 lines
Instead of splitting this into 3 functions which all do the same thing, this is presented as one function. Perhaps that's too ugly and it should be split to:
structdrm_crtc*drm_atomic_crtc_for_encoder(state, encoder); structdrm_crtc_state*drm_atomic_new_crtc_state_for_encoder(state, encoder); structdrm_crtc_state*drm_atomic_old_crtc_state_for_encoder(state, encoder);Suggestions welcome.
Changes in v3:
- Added to the setCc Daniel Vetter <[email protected]>Cc Ville Syrjälä <[email protected]>Signed-off-by Sean Paul <[email protected]>--- drivers/gpu/drm/drm_atomic_helper.c | 48 +++++++++++++++++++++++++++++ include/drm/drm_atomic_helper.h | 6 ++++ 2 files changed, 54 insertions(+)drivers/gpu/drm/drm_atomic_helper.c +18
-0@@ -3591,3 +3591,51 @@ int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,return ret; }EXPORT_SYMBOL (drm_atomic_helper_legacy_gamma_set); + +/** +* drm_atomic_crtc_state_for_encoder - Get crtc and new/old state for an encoder +* @state: Atomic state +* @encoder: The encoder to fetch the crtc information for +* @crtc: If not NULL, receives the currently connected crtc +* @old_crtc_state: If not NULL, receives the crtc's old state +* @new_crtc_state: If not NULL, receives the crtc's new state +* +* This function finds the crtc which is currently connected to @encoder and +* returns it as well as its old and new state. If there is no crtc currently +* connected, the function will clear @crtc, @old_crtc_state, @new_crtc_state. +* +* All of @crtc, @old_crtc_state, and @new_crtc_state are optional. +*/ +void drm_atomic_crtc_state_for_encoder(struct drm_atomic_state *state, + struct drm_encoder *encoder, + struct drm_crtc **crtc,drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc, · line 3621
Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +10
-0+struct drm_crtc_state **old_crtc_state, + struct drm_crtc_state **new_crtc_state) +{ + struct drm_crtc *tmp_crtc; +struct drm_crtc_state *tmp_new_crtc_state, *tmp_old_crtc_state; +u32 enc_mask =drm_encoder_mask (encoder); +int i; + +for_each_oldnew_crtc_in_state (state, tmp_crtc, tmp_old_crtc_state, + tmp_new_crtc_state, i) {So there's two ways to do this:
- Using
encoder_mask, which is a helper thing. In that case I'd rename this todrm_atomic_helper_crtc_for_encoder.
Quoted 8 lines
- By looping over the connectors, and looking at ->best_encoder and ->crtc, see
drm_encoder_get_crtcindrm_encoder.c. That's the core way of doing things. In that case call itdrm_atomic_crtc_for_encoder, and put it intodrm_atomic.c.There's two ways of doing the 2nd one: looping over connectors in a
drm_atomic_state, or the connector list overall. First requires that the encoder is already indrm_atomic_state(which I think makes sense).
Yeah, I wasn't particularly interested in encoders not in state. I had considered going the connector route, but since you can have multiple connectors per encoder, going through crtc seemed a bit more direct.
Quoted 5 lines
Even more complications on old/new_crtc_state: Is that the old state for the old crtc, or the old state for the new crtc (that can switch too). Same for the new crtc state ...
Quoted 7 lines
tldr; I'd create 2 functions:
drm_crtc*drm_atomic_encoder_get_new_crtc(drm_atomic_state *state, encoder)drm_crtc*drm_atomic_encoder_get_old_crtc(drm_atomic_state *state, encoder)With the requirement that they'll return NULL if the encder isn't in in @state, and implemented using looping over connectors in @state.
It seems like we could just tweak this function a bit to get the new or old crtc for an encoder. Any particular reason for going through connector instead? Is it to avoid the encoder_mask which is a helper thing? In that case, perhaps this should use connector links and live in drm_atomic.c?
Thanks for the review!
Sean
Quoted 50 lines
tldr; this is a lot more tricky than it looks like ... -Daniel
Quoted 40 lines
drivers/gpu/drm/drm_atomic_helper.c +20
-0+if (!(tmp_new_crtc_state->encoder_mask & enc_mask)) +continue ; + +if (new_crtc_state) + *new_crtc_state = tmp_new_crtc_state; +if (old_crtc_state) + *old_crtc_state = tmp_old_crtc_state; +if (crtc) + *crtc = tmp_crtc; +return ; + } + +if (new_crtc_state) + *new_crtc_state =NULL ; +if (old_crtc_state) + *old_crtc_state =NULL ; +if (crtc) + *crtc =NULL ; +} +EXPORT_SYMBOL (drm_atomic_crtc_state_for_encoder);include/drm/drm_atomic_helper.h +6
-0@@ -153,6 +153,12 @@ int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,uint32_t size, struct drm_modeset_acquire_ctx *ctx); +void drm_atomic_crtc_state_for_encoder (struct drm_atomic_state *state, +struct drm_encoder *encoder, +struct drm_crtc **crtc, +struct drm_crtc_state **old_crtc_state, +struct drm_crtc_state **new_crtc_state); +/** * drm_atomic_crtc_for_each_plane - iterate over planes currently attached to CRTC * @plane: the loop cursor Signature · 1 line
Sean Paul, Software Engineer, Google / Chromium OSSignature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Signature · 1 line
Sean Paul, Software Engineer, Google / Chromium OS
Re: [PATCH v3 02/10] drm: Add drm_atomic_crtc_state_for_encoder helper
Quoted 85 lines · Sean Paul
Quoted 10 lines · Daniel Vetter
Quoted 7 lines · Sean Paul
From: Sean Paul <[email protected]>
This patch adds a helper to tease out the currently connected crtc for an encoder, along with its state. This follows the same pattern as the drm_atomic_crtc_*_for_* macros in the atomic helpers. Since the relationship of crtc:encoder is 1:n, we don't need a loop since there is only one crtc per encoder.
No idea which macros you mean, couldn't find them.
No longer relevant with the changes below, but for completeness, I was trying to refer to
drm_atomic_crtc_state_for_each_planeand friends. I see now that I wasn't terribly clear :)Quoted 68 lines
Quoted 47 lines
Instead of splitting this into 3 functions which all do the same thing, this is presented as one function. Perhaps that's too ugly and it should be split to:
structdrm_crtc*drm_atomic_crtc_for_encoder(state, encoder); structdrm_crtc_state*drm_atomic_new_crtc_state_for_encoder(state, encoder); structdrm_crtc_state*drm_atomic_old_crtc_state_for_encoder(state, encoder);Suggestions welcome.
Changes in v3:
- Added to the setCc Daniel Vetter <[email protected]>Cc Ville Syrjälä <[email protected]>Signed-off-by Sean Paul <[email protected]>--- drivers/gpu/drm/drm_atomic_helper.c | 48 +++++++++++++++++++++++++++++ include/drm/drm_atomic_helper.h | 6 ++++ 2 files changed, 54 insertions(+)drivers/gpu/drm/drm_atomic_helper.c +18
-0@@ -3591,3 +3591,51 @@ int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,return ret; }EXPORT_SYMBOL (drm_atomic_helper_legacy_gamma_set); + +/** +* drm_atomic_crtc_state_for_encoder - Get crtc and new/old state for an encoder +* @state: Atomic state +* @encoder: The encoder to fetch the crtc information for +* @crtc: If not NULL, receives the currently connected crtc +* @old_crtc_state: If not NULL, receives the crtc's old state +* @new_crtc_state: If not NULL, receives the crtc's new state +* +* This function finds the crtc which is currently connected to @encoder and +* returns it as well as its old and new state. If there is no crtc currently +* connected, the function will clear @crtc, @old_crtc_state, @new_crtc_state. +* +* All of @crtc, @old_crtc_state, and @new_crtc_state are optional. +*/ +void drm_atomic_crtc_state_for_encoder(struct drm_atomic_state *state, + struct drm_encoder *encoder, + struct drm_crtc **crtc,drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc, · line 3621
Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +10
-0+struct drm_crtc_state **old_crtc_state, + struct drm_crtc_state **new_crtc_state) +{ + struct drm_crtc *tmp_crtc; +struct drm_crtc_state *tmp_new_crtc_state, *tmp_old_crtc_state; +u32 enc_mask =drm_encoder_mask (encoder); +int i; + +for_each_oldnew_crtc_in_state (state, tmp_crtc, tmp_old_crtc_state, + tmp_new_crtc_state, i) {So there's two ways to do this:
- Using
encoder_mask, which is a helper thing. In that case I'd rename this todrm_atomic_helper_crtc_for_encoder.- By looping over the connectors, and looking at ->best_encoder and ->crtc, see
drm_encoder_get_crtcindrm_encoder.c. That's the core way of doing things. In that case call itdrm_atomic_crtc_for_encoder, and put it intodrm_atomic.c.
Quoted 7 lines
Quoted 3 lines
There's two ways of doing the 2nd one: looping over connectors in a
drm_atomic_state, or the connector list overall. First requires that the encoder is already indrm_atomic_state(which I think makes sense).Yeah, I wasn't particularly interested in encoders not in state. I had considered going the connector route, but since you can have multiple connectors per encoder, going through crtc seemed a bit more direct.
You can have multiple possible connectors for a given encoder, and multiple possible encoders for a given connector. In both cases the driver picks for you. But for active encoders and connectors the relationship is 1:1. That's what the helpers exploit by looping over connectors to get at encoders.
Quoted 9 lines
Quoted 9 lines
Even more complications on old/new_crtc_state: Is that the old state for the old crtc, or the old state for the new crtc (that can switch too). Same for the new crtc state ...
tldr; I'd create 2 functions:
drm_crtc*drm_atomic_encoder_get_new_crtc(drm_atomic_state *state, encoder)drm_crtc*drm_atomic_encoder_get_old_crtc(drm_atomic_state *state, encoder)
Quoted 7 lines
Quoted 2 lines
With the requirement that they'll return NULL if the encder isn't in in @state, and implemented using looping over connectors in @state.
It seems like we could just tweak this function a bit to get the new or old crtc for an encoder. Any particular reason for going through connector instead? Is it to avoid the
encoder_maskwhich is a helper thing? In that case, perhaps this should use connector links and live indrm_atomic.c?
Well as explained, there's 3 ways you can achieve the same really. I do think the "loop over connectors in drm_atomic_state, WARN() if we haven't found the encoder you want the crtc for" is probably the most solid aproach since it picks up a core atomic concept. But the others (looping the connector list, or looping encoder_mask) all work too.
Aside: plane/encoder_mask was added to go from crtc to planes/encoders, not really to go the other way round.
Another solution would be to pass the connector_state to all atomic encoder hooks, then you could just look at connector_state->crtc. Plus you can get at all the other interesting bits and pieces of information. In a way this is fallout from us keeping encoders as a meaningful concept for easier transition of legacy drivers, while still keeping them entirely irrelevant for the actual userspace api semantics.
So maybe we want drm_atomic_encoder_get_old/new_connector here. Or maybe we even want the full set of functions, i.e. drm_atomic_encoder_get_old/new_connector/crtc.
In all cases I think only returning the object, not it's state is simplest, since then you avoid the confusion of old/new state for old/new obj.
-Daniel
Quoted 61 lines
Thanks for the review!
Sean
Quoted 42 lines
tldr; this is a lot more tricky than it looks like ... -Daniel
Quoted 37 lines
drivers/gpu/drm/drm_atomic_helper.c +20
-0+if (!(tmp_new_crtc_state->encoder_mask & enc_mask)) +continue ; + +if (new_crtc_state) + *new_crtc_state = tmp_new_crtc_state; +if (old_crtc_state) + *old_crtc_state = tmp_old_crtc_state; +if (crtc) + *crtc = tmp_crtc; +return ; + } + +if (new_crtc_state) + *new_crtc_state =NULL ; +if (old_crtc_state) + *old_crtc_state =NULL ; +if (crtc) + *crtc =NULL ; +} +EXPORT_SYMBOL (drm_atomic_crtc_state_for_encoder);include/drm/drm_atomic_helper.h +6
-0@@ -153,6 +153,12 @@ int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,uint32_t size, struct drm_modeset_acquire_ctx *ctx); +void drm_atomic_crtc_state_for_encoder (struct drm_atomic_state *state, +struct drm_encoder *encoder, +struct drm_crtc **crtc, +struct drm_crtc_state **old_crtc_state, +struct drm_crtc_state **new_crtc_state); +/** * drm_atomic_crtc_for_each_plane - iterate over planes currently attached to CRTC * @plane: the loop cursor Quoted 8 lines
Quoted 3 lines
--
Sean Paul, Software Engineer, Google / Chromium OS--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch--
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH v3 01/10] drm: Add atomic variants of enable/disable to encoder helper funcs
In reply to Sean PaulQuoted 79 lines · Sean Paul
Quoted 18 lines · Daniel Vetter
Quoted 17 lines · Sean Paul
From: Sean Paul <[email protected]>
This patch adds
atomic_enableandatomic_disablecallbacks to the encoder helpers. This will allow encoders to make informed decisions in their start-up/shutdown based on the committed state.Aside from the new hooks, this patch also introduces the new signature for .atomic_* functions going forward. Instead of passing object state (well, encoders don't have atomic state, but let's ignore that), we pass the entire atomic state so the driver can inspect more than what's happening locally.
This is particularly important for the upcoming self refresh helpers.
Changes in v3:
- Added patch to the setQuoted 7 lines
Quoted 7 lines
Cc Daniel Vetter <[email protected]>Cc Ville Syrjälä <[email protected]>Signed-off-by Sean Paul <[email protected]>--- drivers/gpu/drm/drm_atomic_helper.c | 6 +++- include/drm/drm_modeset_helper_vtables.h | 45 ++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-)/snip
Quoted 49 lines
Quoted 17 lines
include/drm/drm_modeset_helper_vtables.h +9
-0@@ -675,6 +675,51 @@ struct drm_encoder_helper_funcs {enum drm_connector_status (*detect)(struct drm_encoder *encoder,struct drm_connector *connector); +/** +* @atomic_disable: +* +* This callback should be used to disable the encoder. With the atomic +* drivers it is called before this encoder's CRTC has been shut off +* using their own &drm_crtc_helper_funcs.atomic_disable hook. If that +* sequence is too simple drivers can just add their own driver private +* encoder hooks and call them from CRTC's callback by looping over all +* encoders connected to it using for_each_encoder_on_crtc(). include/drm/drm_modeset_helper_vtables.h struct drm_encoder_helper_funcs { · line 696
Quoted 10 lines
include/drm/drm_modeset_helper_vtables.h +10
-0+* +* This callback is a variant of @disable that provides the atomic state +* to the driver. It takes priority over @disable during atomic commits. +* +* This hook is used only by atomic helpers. Atomic drivers don't need +* to implement it if there's no need to disable anything at the encoder +* level. To ensure that runtime PM handling (using either DPMS or the +* new "ACTIVE" property) works @atomic_disable must be the inverse of +* @atomic_enable. +*/ I'd add something like "For atomic drivers also consider @atomic_disable" to the kerneldoc of @disable (before the NOTE: which is only relevant for pre-atomic). Same for the enable side.
Quoted 16 lines
include/drm/drm_modeset_helper_vtables.h +16
-0+void (*atomic_disable)(struct drm_encoder *encoder, +struct drm_atomic_state *state); + +/** +* @atomic_enable: +* +* This callback should be used to enable the encoder. It is called +* after this encoder's CRTC has been enabled using their own +* &drm_crtc_helper_funcs.atomic_enable hook. If that sequence is +* too simple drivers can just add their own driver private encoder +* hooks and call them from CRTC's callback by looping over all encoders +* connected to it using for_each_encoder_on_crtc(). +* +* This callback is a variant of @enable that provides the atomic state +* to the driver. It is called in place of @enable during atomic +* commits.
Quoted 3 lines
Quoted 1 line
needs to be adjusted here for "takes priority".
Can you clarify this comment? I'm a little fuzzy on what it means.
Further up I suggest that @atomic_disable should take priority over all the others (plus explain why @disable is lower than @prepare, because of the special semantics this has in legacy crtc helpers). Once you do that you also need to adjust the wording in the kerneldoc here (same wording as in @atomic_enable sounds good to me), i.e. explain that @atomic_disable takes priority over all other hooks. -Daniel
Quoted 41 lines
Quoted 14 lines
include/drm/drm_modeset_helper_vtables.h struct drm_encoder_helper_funcs { · line 722
Quoted 13 lines
include/drm/drm_modeset_helper_vtables.h +10
-0+* +* This hook is used only by atomic helpers, for symmetry with @disable. +* Atomic drivers don't need to implement it if there's no need to +* enable anything at the encoder level. To ensure that runtime PM +* handling (using either DPMS or the new "ACTIVE" property) works +* @enable must be the inverse of @disable for atomic drivers. +*/ +void (*atomic_enable)(struct drm_encoder *encoder, +struct drm_atomic_state *state); +Quoted 3 lines
With the nits:
Reviewed-by Daniel Vetter <[email protected]>Thanks!
Sean
Quoted 8 lines
Quoted 7 lines
include/drm/drm_modeset_helper_vtables.h +0
-1/** * @disable: * -- Sean Paul, Software Engineer, Google / Chromium OS
Quoted 4 lines
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch--
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 02/10] drm: Add drm_atomic_crtc_state_for_encoder helper
In reply to Daniel VetterQuoted 134 lines · Daniel Vetter
Quoted 85 lines · Sean Paul
Quoted 10 lines · Daniel Vetter
Quoted 7 lines · Sean Paul
From: Sean Paul <[email protected]>
This patch adds a helper to tease out the currently connected crtc for an encoder, along with its state. This follows the same pattern as the drm_atomic_crtc_*_for_* macros in the atomic helpers. Since the relationship of crtc:encoder is 1:n, we don't need a loop since there is only one crtc per encoder.
No idea which macros you mean, couldn't find them.
No longer relevant with the changes below, but for completeness, I was trying to refer to
drm_atomic_crtc_state_for_each_planeand friends. I see now that I wasn't terribly clear :)Quoted 68 lines
Quoted 47 lines
Instead of splitting this into 3 functions which all do the same thing, this is presented as one function. Perhaps that's too ugly and it should be split to:
structdrm_crtc*drm_atomic_crtc_for_encoder(state, encoder); structdrm_crtc_state*drm_atomic_new_crtc_state_for_encoder(state, encoder); structdrm_crtc_state*drm_atomic_old_crtc_state_for_encoder(state, encoder);Suggestions welcome.
Changes in v3:
- Added to the setCc Daniel Vetter <[email protected]>Cc Ville Syrjälä <[email protected]>Signed-off-by Sean Paul <[email protected]>--- drivers/gpu/drm/drm_atomic_helper.c | 48 +++++++++++++++++++++++++++++ include/drm/drm_atomic_helper.h | 6 ++++ 2 files changed, 54 insertions(+)drivers/gpu/drm/drm_atomic_helper.c +18
-0@@ -3591,3 +3591,51 @@ int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,return ret; }EXPORT_SYMBOL (drm_atomic_helper_legacy_gamma_set); + +/** +* drm_atomic_crtc_state_for_encoder - Get crtc and new/old state for an encoder +* @state: Atomic state +* @encoder: The encoder to fetch the crtc information for +* @crtc: If not NULL, receives the currently connected crtc +* @old_crtc_state: If not NULL, receives the crtc's old state +* @new_crtc_state: If not NULL, receives the crtc's new state +* +* This function finds the crtc which is currently connected to @encoder and +* returns it as well as its old and new state. If there is no crtc currently +* connected, the function will clear @crtc, @old_crtc_state, @new_crtc_state. +* +* All of @crtc, @old_crtc_state, and @new_crtc_state are optional. +*/ +void drm_atomic_crtc_state_for_encoder(struct drm_atomic_state *state, + struct drm_encoder *encoder, + struct drm_crtc **crtc,drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc, · line 3621
Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +10
-0+struct drm_crtc_state **old_crtc_state, + struct drm_crtc_state **new_crtc_state) +{ + struct drm_crtc *tmp_crtc; +struct drm_crtc_state *tmp_new_crtc_state, *tmp_old_crtc_state; +u32 enc_mask =drm_encoder_mask (encoder); +int i; + +for_each_oldnew_crtc_in_state (state, tmp_crtc, tmp_old_crtc_state, + tmp_new_crtc_state, i) {So there's two ways to do this:
- Using
encoder_mask, which is a helper thing. In that case I'd rename this todrm_atomic_helper_crtc_for_encoder.- By looping over the connectors, and looking at ->best_encoder and ->crtc, see
drm_encoder_get_crtcindrm_encoder.c. That's the core way of doing things. In that case call itdrm_atomic_crtc_for_encoder, and put it intodrm_atomic.c.Quoted 7 lines
Quoted 3 lines
There's two ways of doing the 2nd one: looping over connectors in a
drm_atomic_state, or the connector list overall. First requires that the encoder is already indrm_atomic_state(which I think makes sense).Yeah, I wasn't particularly interested in encoders not in state. I had considered going the connector route, but since you can have multiple connectors per encoder, going through crtc seemed a bit more direct.
You can have multiple possible connectors for a given encoder, and multiple possible encoders for a given connector. In both cases the driver picks for you. But for active encoders and connectors the relationship is 1:1. That's what the helpers exploit by looping over connectors to get at encoders.
Quoted 9 lines
Quoted 9 lines
Even more complications on old/new_crtc_state: Is that the old state for the old crtc, or the old state for the new crtc (that can switch too). Same for the new crtc state ...
tldr; I'd create 2 functions:
drm_crtc*drm_atomic_encoder_get_new_crtc(drm_atomic_state *state, encoder)drm_crtc*drm_atomic_encoder_get_old_crtc(drm_atomic_state *state, encoder)Quoted 7 lines
Quoted 2 lines
With the requirement that they'll return NULL if the encder isn't in in @state, and implemented using looping over connectors in @state.
It seems like we could just tweak this function a bit to get the new or old crtc for an encoder. Any particular reason for going through connector instead? Is it to avoid the
encoder_maskwhich is a helper thing? In that case, perhaps this should use connector links and live indrm_atomic.c?Well as explained, there's 3 ways you can achieve the same really. I do think the "loop over connectors in
drm_atomic_state,WARN()if we haven't found the encoder you want the crtc for" is probably the most solid aproach since it picks up a core atomic concept. But the others (looping the connector list, or loopingencoder_mask) all work too.Aside: plane/encoder_mask was added to go from crtc to planes/encoders, not really to go the other way round.
Another solution would be to pass the
connector_stateto all atomic encoder hooks, then you could just look atconnector_state->crtc. Plus you can get at all the other interesting bits and pieces of information. In a way this is fallout from us keeping encoders as a meaningful concept for easier transition of legacy drivers, while still keeping them entirely irrelevant for the actual userspace api semantics.
Quoted 3 lines
So maybe we want drm_atomic_encoder_get_old/new_connector here. Or maybe we even want the full set of functions, i.e. drm_atomic_encoder_get_old/new_connector/crtc.
Laurent just asked me on irc how to get from a bridge to connector information. Bridge knows its encoder (it's static), so a encode2connector function would already have a 2nd user with this.
I.e. I'd say +1 on that approach, and then you can get at the connector state and whatever else you feel like from there?
Adding Laurent.
-Daniel
Quoted 75 lines
In all cases I think only returning the object, not it's state is simplest, since then you avoid the confusion of old/new state for old/new obj.
-DanielQuoted 61 lines
Thanks for the review!
Sean
Quoted 42 lines
tldr; this is a lot more tricky than it looks like ... -Daniel
Quoted 37 lines
drivers/gpu/drm/drm_atomic_helper.c +20
-0+if (!(tmp_new_crtc_state->encoder_mask & enc_mask)) +continue ; + +if (new_crtc_state) + *new_crtc_state = tmp_new_crtc_state; +if (old_crtc_state) + *old_crtc_state = tmp_old_crtc_state; +if (crtc) + *crtc = tmp_crtc; +return ; + } + +if (new_crtc_state) + *new_crtc_state =NULL ; +if (old_crtc_state) + *old_crtc_state =NULL ; +if (crtc) + *crtc =NULL ; +} +EXPORT_SYMBOL (drm_atomic_crtc_state_for_encoder);include/drm/drm_atomic_helper.h +6
-0@@ -153,6 +153,12 @@ int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,uint32_t size, struct drm_modeset_acquire_ctx *ctx); +void drm_atomic_crtc_state_for_encoder (struct drm_atomic_state *state, +struct drm_encoder *encoder, +struct drm_crtc **crtc, +struct drm_crtc_state **old_crtc_state, +struct drm_crtc_state **new_crtc_state); +/** * drm_atomic_crtc_for_each_plane - iterate over planes currently attached to CRTC * @plane: the loop cursor Quoted 8 lines
Quoted 3 lines
--
Sean Paul, Software Engineer, Google / Chromium OS--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch--
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-develSignature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Laurent Pinchart
reviewerRe: [PATCH v3 02/10] drm: Add drm_atomic_crtc_state_for_encoder helper
Hello,
Quoted 137 lines · Daniel Vetter
Quoted 132 lines · Daniel Vetter
Quoted 83 lines · Sean Paul
Quoted 10 lines · Daniel Vetter
Quoted 7 lines · Sean Paul
From: Sean Paul <[email protected]>
This patch adds a helper to tease out the currently connected crtc for an encoder, along with its state. This follows the same pattern as the drm_atomic_crtc_*_for_* macros in the atomic helpers. Since the relationship of crtc:encoder is 1:n, we don't need a loop since there is only one crtc per encoder.
No idea which macros you mean, couldn't find them.
No longer relevant with the changes below, but for completeness, I was trying to refer to
drm_atomic_crtc_state_for_each_planeand friends. I see now that I wasn't terribly clear :)Quoted 67 lines
Quoted 46 lines
Instead of splitting this into 3 functions which all do the same thing, this is presented as one function. Perhaps that's too ugly and it should be split to:
structdrm_crtc*drm_atomic_crtc_for_encoder(state, encoder); structdrm_crtc_state*drm_atomic_new_crtc_state_for_encoder(state, encoder); structdrm_crtc_state*drm_atomic_old_crtc_state_for_encoder(state, encoder);Suggestions welcome.
Changes in v3:
- Added to the setCc Daniel Vetter <[email protected]>Cc Ville Syrjälä <[email protected]>Signed-off-by Sean Paul <[email protected]>--- drivers/gpu/drm/drm_atomic_helper.c | 48 +++++++++++++++++++++++++++++ include/drm/drm_atomic_helper.h | 6 ++++ 2 files changed, 54 insertions(+)drivers/gpu/drm/drm_atomic_helper.c +18
-0@@ -3591,3 +3591,51 @@ int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,return ret; }EXPORT_SYMBOL (drm_atomic_helper_legacy_gamma_set); + +/** +* drm_atomic_crtc_state_for_encoder - Get crtc and new/old state for an encoder +* @state: Atomic state +* @encoder: The encoder to fetch the crtc information for +* @crtc: If not NULL, receives the currently connected crtc +* @old_crtc_state: If not NULL, receives the crtc's old state +* @new_crtc_state: If not NULL, receives the crtc's new state +* +* This function finds the crtc which is currently connected to @encoder and +* returns it as well as its old and new state. If there is no crtc currently +* connected, the function will clear @crtc, @old_crtc_state, @new_crtc_state. +* +* All of @crtc, @old_crtc_state, and @new_crtc_state are optional. +*/ +void drm_atomic_crtc_state_for_encoder(struct drm_atomic_state *state, + struct drm_encoder *encoder, + struct drm_crtc **crtc,drivers/gpu/drm/drm_atomic_helper.c int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc, · line 3621
Quoted 10 lines
drivers/gpu/drm/drm_atomic_helper.c +10
-0+struct drm_crtc_state **old_crtc_state, + struct drm_crtc_state **new_crtc_state) +{ + struct drm_crtc *tmp_crtc; +struct drm_crtc_state *tmp_new_crtc_state, *tmp_old_crtc_state; +u32 enc_mask =drm_encoder_mask (encoder); +int i; + +for_each_oldnew_crtc_in_state (state, tmp_crtc, tmp_old_crtc_state, + tmp_new_crtc_state, i) {So there's two ways to do this:
- Using
encoder_mask, which is a helper thing. In that case I'd rename this todrm_atomic_helper_crtc_for_encoder.- By looping over the connectors, and looking at ->best_encoder and ->crtc, see
drm_encoder_get_crtcindrm_encoder.c. That's the core way of doing things. In that case call itdrm_atomic_crtc_for_encoder, and put it intodrm_atomic.c.Quoted 7 lines
Quoted 3 lines
There's two ways of doing the 2nd one: looping over connectors in a
drm_atomic_state, or the connector list overall. First requires that the encoder is already indrm_atomic_state(which I think makes sense).Yeah, I wasn't particularly interested in encoders not in state. I had considered going the connector route, but since you can have multiple connectors per encoder, going through crtc seemed a bit more direct.
You can have multiple possible connectors for a given encoder, and multiple possible encoders for a given connector. In both cases the driver picks for you. But for active encoders and connectors the relationship is 1:1. That's what the helpers exploit by looping over connectors to get at encoders.
Quoted 9 lines
Quoted 9 lines
Even more complications on old/new_crtc_state: Is that the old state for the old crtc, or the old state for the new crtc (that can switch too). Same for the new crtc state ...
tldr; I'd create 2 functions:
drm_crtc*drm_atomic_encoder_get_new_crtc(drm_atomic_state *state, encoder)drm_crtc*drm_atomic_encoder_get_old_crtc(drm_atomic_state *state, encoder)Quoted 7 lines
Quoted 2 lines
With the requirement that they'll return NULL if the encder isn't in in @state, and implemented using looping over connectors in @state.
It seems like we could just tweak this function a bit to get the new or old crtc for an encoder. Any particular reason for going through connector instead? Is it to avoid the
encoder_maskwhich is a helper thing? In that case, perhaps this should use connector links and live indrm_atomic.c?Well as explained, there's 3 ways you can achieve the same really. I do think the "loop over connectors in
drm_atomic_state,WARN()if we haven't found the encoder you want the crtc for" is probably the most solid aproach since it picks up a core atomic concept. But the others (looping the connector list, or loopingencoder_mask) all work too.Aside: plane/encoder_mask was added to go from crtc to planes/encoders, not really to go the other way round.
Another solution would be to pass the
connector_stateto all atomic encoder hooks, then you could just look atconnector_state->crtc. Plus you can get at all the other interesting bits and pieces of information. In a way this is fallout from us keeping encoders as a meaningful concept for easier transition of legacy drivers, while still keeping them entirely irrelevant for the actual userspace api semantics.Quoted 3 lines
So maybe we want drm_atomic_encoder_get_old/new_connector here. Or maybe we even want the full set of functions, i.e. drm_atomic_encoder_get_old/new_connector/crtc.
Quoted 8 lines
Laurent just asked me on irc how to get from a bridge to connector information. Bridge knows its encoder (it's static), so a encode2connector function would already have a 2nd user with this.
I.e. I'd say +1 on that approach, and then you can get at the connector state and whatever else you feel like from there?
Adding Laurent.
Thank you. I'll experiment with this, but please don't wait for me to post a v4.
Quoted 43 lines
Quoted 43 lines
In all cases I think only returning the object, not it's state is simplest, since then you avoid the confusion of old/new state for old/new obj.
Quoted 39 lines
Quoted 39 lines
tldr; this is a lot more tricky than it looks like ...
Quoted 37 lines
drivers/gpu/drm/drm_atomic_helper.c +20
-0+if (!(tmp_new_crtc_state->encoder_mask & enc_mask)) +continue ; + +if (new_crtc_state) + *new_crtc_state = tmp_new_crtc_state; +if (old_crtc_state) + *old_crtc_state = tmp_old_crtc_state; +if (crtc) + *crtc = tmp_crtc; +return ; + } + +if (new_crtc_state) + *new_crtc_state =NULL ; +if (old_crtc_state) + *old_crtc_state =NULL ; +if (crtc) + *crtc =NULL ; +} +EXPORT_SYMBOL (drm_atomic_crtc_state_for_encoder);include/drm/drm_atomic_helper.h +6
-0@@ -153,6 +153,12 @@ int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,uint32_t size, struct drm_modeset_acquire_ctx *ctx); +void drm_atomic_crtc_state_for_encoder (struct drm_atomic_state *state, +struct drm_encoder *encoder, +struct drm_crtc **crtc, +struct drm_crtc_state **old_crtc_state, +struct drm_crtc_state **new_crtc_state); +/** * drm_atomic_crtc_for_each_plane - iterate over planes currently attached to CRTC * @plane: the loop cursor
Signature · 7 lines
Regards, Laurent Pinchart _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Laurent Pinchart
reviewerRe: [PATCH v3 04/10] drm: Convert connector_helper_funcs->atomic_check to accept drm_atomic_state
In reply to Sean PaulHi Sean,
Thank you for the patch.
Quoted 9 lines · Sean Paul
From: Sean Paul <[email protected]>
Everyone who implements
connector_helper_funcs->atomic_checkreaches into the connector state to get the atomic state. Instead of continuing this pattern, change the callback signature to just give atomic state and let the driver determine what it does and does not need from it.Eventually all atomic functions should do this, but that's just too much busy work for me.
Given that drivers also access the connector state, isn't this slightly more inefficient ?
Quoted 269 lines
Changes in v3:
- Added to the setCc Daniel Vetter <[email protected]>Cc Ville Syrjälä <[email protected]>Cc Jani Nikula <[email protected]>Cc Joonas Lahtinen <[email protected]>Cc Rodrigo Vivi <[email protected]>Cc Ben Skeggs <[email protected]>Cc Laurent Pinchart <[email protected]>Cc Kieran Bingham <[email protected]>Cc Eric Anholt <[email protected]>Signed-off-by Sean Paul <[email protected]>--- drivers/gpu/drm/drm_atomic_helper.c | 4 ++-- drivers/gpu/drm/i915/intel_atomic.c | 8 +++++--- drivers/gpu/drm/i915/intel_dp_mst.c | 7 ++++--- drivers/gpu/drm/i915/intel_drv.h | 2 +- drivers/gpu/drm/i915/intel_sdvo.c | 9 +++++---- drivers/gpu/drm/i915/intel_tv.c | 8 +++++--- drivers/gpu/drm/nouveau/dispnv50/disp.c | 5 +++-- drivers/gpu/drm/rcar-du/rcar_lvds.c | 12 +++++++----- drivers/gpu/drm/vc4/vc4_txp.c | 7 ++++--- include/drm/drm_modeset_helper_vtables.h | 2 +- 10 files changed, 37 insertions(+), 27 deletions(-)drivers/gpu/drm/drm_atomic_helper.c +2
-2@@ -683,7 +683,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev, }if (funcs->atomic_check) - ret = funcs->atomic_check (connector, new_connector_state); + ret = funcs->atomic_check (connector, state);if (ret)return ret;@@ -725,7 +725,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,continue ;if (funcs->atomic_check) - ret = funcs->atomic_check (connector, new_connector_state); + ret = funcs->atomic_check (connector, state);if (ret)return ret; }drivers/gpu/drm/i915/intel_atomic.c +5
-3@@ -103,12 +103,14 @@ int intel_digital_connector_atomic_set_property(struct drm_connector *connector, }int intel_digital_connector_atomic_check (struct drm_connector *conn, -struct drm_connector_state *new_state) +struct drm_atomic_state *state) { +struct drm_connector_state *new_state = +drm_atomic_get_new_connector_state (state, conn);struct intel_digital_connector_state *new_conn_state =to_intel_digital_connector_state (new_state);struct drm_connector_state *old_state = -drm_atomic_get_old_connector_state (new_state->state, conn); +drm_atomic_get_old_connector_state (state, conn);struct intel_digital_connector_state *old_conn_state =to_intel_digital_connector_state (old_state);struct drm_crtc_state *crtc_state;@@ -118,7 +120,7 @@ int intel_digital_connector_atomic_check(struct drm_connector *conn,if (!new_state->crtc)return 0 ; - crtc_state =drm_atomic_get_new_crtc_state (new_state->state, new_state->crtc); + crtc_state =drm_atomic_get_new_crtc_state (state, new_state->crtc);/* * These properties are handled by fastset, and might not end drivers/gpu/drm/i915/intel_dp_mst.c +4
-3@@ -143,9 +143,10 @@ static int intel_dp_mst_compute_config(struct intel_encoder *encoder,static int intel_dp_mst_atomic_check (struct drm_connector *connector, -struct drm_connector_state *new_conn_state) +struct drm_atomic_state *state) { -struct drm_atomic_state *state = new_conn_state->state; +struct drm_connector_state *new_conn_state = +drm_atomic_get_new_connector_state (state, connector);struct drm_connector_state *old_conn_state =drm_atomic_get_old_connector_state (state, connector); struct intel_connector *intel_connector =@@ -155,7 +156,7 @@ intel_dp_mst_atomic_check(struct drm_connector *connector,struct drm_dp_mst_topology_mgr *mgr;int ret; - ret =intel_digital_connector_atomic_check (connector, new_conn_state); + ret =intel_digital_connector_atomic_check (connector, state);if (ret)return ret;drivers/gpu/drm/i915/intel_drv.h +1
-1@@ -2481,7 +2481,7 @@ int intel_digital_connector_atomic_set_property(struct drm_connector *connector,struct drm_property *property, u64 val);int intel_digital_connector_atomic_check (struct drm_connector *conn, -struct drm_connector_state *new_state); +struct drm_atomic_state *state);struct drm_connector_state *intel_digital_connector_duplicate_state (struct drm_connector *connector);drivers/gpu/drm/i915/intel_sdvo.c +5
-4@@ -2342,9 +2342,10 @@ static const struct drm_connector_funcs intel_sdvo_connector_funcs = { };static int intel_sdvo_atomic_check (struct drm_connector *conn, -struct drm_connector_state *new_conn_state) +struct drm_atomic_state *state) { -struct drm_atomic_state *state = new_conn_state->state; +struct drm_connector_state *new_conn_state = +drm_atomic_get_new_connector_state (state, conn);struct drm_connector_state *old_conn_state =drm_atomic_get_old_connector_state (state, conn); struct intel_sdvo_connector_state *old_state =@@ -2356,13 +2357,13 @@ static int intel_sdvo_atomic_check(struct drm_connector *conn, (memcmp(&old_state->tv, &new_state->tv, sizeof(old_state->tv)) || memcmp(&old_conn_state->tv, &new_conn_state->tv, sizeof(old_conn_state->tv)))) {struct drm_crtc_state *crtc_state = -drm_atomic_get_new_crtc_state (new_conn_state->state, +drm_atomic_get_new_crtc_state (state, new_conn_state->crtc); crtc_state->connectors_changed = true; } -return intel_digital_connector_atomic_check (conn, new_conn_state); +return intel_digital_connector_atomic_check (conn, state); }static const struct drm_connector_helper_funcs intel_sdvo_connector_helper_funcs = {drivers/gpu/drm/i915/intel_tv.c +5
-3@@ -1817,16 +1817,18 @@ static const struct drm_connector_funcs intel_tv_connector_funcs = { };static int intel_tv_atomic_check (struct drm_connector *connector, -struct drm_connector_state *new_state) +struct drm_atomic_state *state) { +struct drm_connector_state *new_state;struct drm_crtc_state *new_crtc_state;struct drm_connector_state *old_state; + new_state =drm_atomic_get_new_connector_state (state, connector);if (!new_state->crtc)return 0 ; - old_state =drm_atomic_get_old_connector_state (new_state->state, connector); - new_crtc_state =drm_atomic_get_new_crtc_state (new_state->state, new_state->crtc); + old_state =drm_atomic_get_old_connector_state (state, connector); + new_crtc_state =drm_atomic_get_new_crtc_state (state, new_state->crtc); if (old_state->tv.mode != new_state->tv.mode || old_state->tv.margins.left != new_state->tv.margins.left ||drivers/gpu/drm/nouveau/dispnv50/disp.c +3
-2@@ -948,11 +948,12 @@ nv50_mstc_get_modes(struct drm_connector *connector)static int nv50_mstc_atomic_check (struct drm_connector *connector, -struct drm_connector_state *new_conn_state) +struct drm_atomic_state *state) { -struct drm_atomic_state *state = new_conn_state->state;struct nv50_mstc *mstc =nv50_mstc (connector);struct drm_dp_mst_topology_mgr *mgr = &mstc->mstm->mgr; +struct drm_connector_state *new_conn_state = +drm_atomic_get_new_connector_state (state, connector);struct drm_connector_state *old_conn_state =drm_atomic_get_old_connector_state (state, connector);struct drm_crtc_state *crtc_state;drivers/gpu/drm/rcar-du/rcar_lvds.c +7
-5@@ -92,13 +92,15 @@ static int rcar_lvds_connector_get_modes(struct drm_connector *connector) }static int rcar_lvds_connector_atomic_check (struct drm_connector *connector, -struct drm_connector_state *state) +struct drm_atomic_state *state) {struct rcar_lvds *lvds =connector_to_rcar_lvds (connector);const struct drm_display_mode *panel_mode; +struct drm_connector_state *conn_state;struct drm_crtc_state *crtc_state; -if (!state->crtc) + conn_state =drm_atomic_get_new_connector_state (state, connector); +if (!conn_state->crtc)return 0 ;if (list_empty (&connector->modes)) {@@ -110,9 +112,9 @@ static int rcar_lvds_connector_atomic_check(struct drm_connector *connector, struct drm_display_mode, head);/* We're not allowed to modify the resolution. */ - crtc_state =drm_atomic_get_crtc_state (state->state, state->crtc); -if (IS_ERR (crtc_state)) -return PTR_ERR (crtc_state); + crtc_state =drm_atomic_get_crtc_state (state, conn_state->crtc); +if (!crtc_state) +return -EINVAL ;if (crtc_state->mode.hdisplay != panel_mode->hdisplay || crtc_state->mode.vdisplay != panel_mode->vdisplay)drivers/gpu/drm/vc4/vc4_txp.c +4
-3@@ -221,17 +221,18 @@ static const u32 txp_fmts[] = { };static int vc4_txp_connector_atomic_check (struct drm_connector *conn, -struct drm_connector_state *conn_state) +struct drm_atomic_state *state) { +struct drm_connector_state *conn_state;struct drm_crtc_state *crtc_state;struct drm_framebuffer *fb;int i; + conn_state =drm_atomic_get_new_connector_state (state, conn);if (!conn_state->writeback_job || !conn_state->writeback_job->fb)return 0 ; - crtc_state =drm_atomic_get_new_crtc_state (conn_state->state, - conn_state->crtc); + crtc_state =drm_atomic_get_new_crtc_state (state, conn_state->crtc); fb = conn_state->writeback_job->fb; if (fb->width != crtc_state->mode.hdisplay ||include/drm/drm_modeset_helper_vtables.h +1
-1@@ -1020,7 +1020,7 @@ struct drm_connector_helper_funcs {* deadlock. */ int (*atomic_check)(struct drm_connector *connector, -struct drm_connector_state *state); +struct drm_atomic_state *state);/** * @atomic_commit:
Signature · 7 lines
Regards, Laurent Pinchart _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 04/10] drm: Convert connector_helper_funcs->atomic_check to accept drm_atomic_state
Quoted 5 lines · Laurent Pinchart
Hi Sean,
Thank you for the patch.
Hey Laurent,
Thanks for looking!
Quoted 8 lines · Sean Paul
Quoted 7 lines
From: Sean Paul <[email protected]>
Everyone who implements
connector_helper_funcs->atomic_checkreaches into the connector state to get the atomic state. Instead of continuing this pattern, change the callback signature to just give atomic state and let the driver determine what it does and does not need from it.
Quoted 6 lines
Quoted 2 lines
Eventually all atomic functions should do this, but that's just too much busy work for me.
Given that drivers also access the connector state, isn't this slightly more inefficient ?
Inefficient in terms of what?
Agree that in isolation this patch might seem unnecessary, but it ties in with the encoder and bridge CLs which accept drm_atomic_state in their hooks. In general the idea is to convert all atomic functions to take overall atomic state instead of just their object state. Reality has proven to be more complicated and we need more access than what the current implementation provides.
Sean
Quoted 267 lines
Quoted 267 lines
Changes in v3:
- Added to the setCc Daniel Vetter <[email protected]>Cc Ville Syrjälä <[email protected]>Cc Jani Nikula <[email protected]>Cc Joonas Lahtinen <[email protected]>Cc Rodrigo Vivi <[email protected]>Cc Ben Skeggs <[email protected]>Cc Laurent Pinchart <[email protected]>Cc Kieran Bingham <[email protected]>Cc Eric Anholt <[email protected]>Signed-off-by Sean Paul <[email protected]>--- drivers/gpu/drm/drm_atomic_helper.c | 4 ++-- drivers/gpu/drm/i915/intel_atomic.c | 8 +++++--- drivers/gpu/drm/i915/intel_dp_mst.c | 7 ++++--- drivers/gpu/drm/i915/intel_drv.h | 2 +- drivers/gpu/drm/i915/intel_sdvo.c | 9 +++++---- drivers/gpu/drm/i915/intel_tv.c | 8 +++++--- drivers/gpu/drm/nouveau/dispnv50/disp.c | 5 +++-- drivers/gpu/drm/rcar-du/rcar_lvds.c | 12 +++++++----- drivers/gpu/drm/vc4/vc4_txp.c | 7 ++++--- include/drm/drm_modeset_helper_vtables.h | 2 +- 10 files changed, 37 insertions(+), 27 deletions(-)drivers/gpu/drm/drm_atomic_helper.c +2
-2@@ -683,7 +683,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev, }if (funcs->atomic_check) - ret = funcs->atomic_check (connector, new_connector_state); + ret = funcs->atomic_check (connector, state);if (ret)return ret;@@ -725,7 +725,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,continue ;if (funcs->atomic_check) - ret = funcs->atomic_check (connector, new_connector_state); + ret = funcs->atomic_check (connector, state);if (ret)return ret; }drivers/gpu/drm/i915/intel_atomic.c +5
-3@@ -103,12 +103,14 @@ int intel_digital_connector_atomic_set_property(struct drm_connector *connector, }int intel_digital_connector_atomic_check (struct drm_connector *conn, -struct drm_connector_state *new_state) +struct drm_atomic_state *state) { +struct drm_connector_state *new_state = +drm_atomic_get_new_connector_state (state, conn);struct intel_digital_connector_state *new_conn_state =to_intel_digital_connector_state (new_state);struct drm_connector_state *old_state = -drm_atomic_get_old_connector_state (new_state->state, conn); +drm_atomic_get_old_connector_state (state, conn);struct intel_digital_connector_state *old_conn_state =to_intel_digital_connector_state (old_state);struct drm_crtc_state *crtc_state;@@ -118,7 +120,7 @@ int intel_digital_connector_atomic_check(struct drm_connector *conn,if (!new_state->crtc)return 0 ; - crtc_state =drm_atomic_get_new_crtc_state (new_state->state, new_state->crtc); + crtc_state =drm_atomic_get_new_crtc_state (state, new_state->crtc);/* * These properties are handled by fastset, and might not end drivers/gpu/drm/i915/intel_dp_mst.c +4
-3@@ -143,9 +143,10 @@ static int intel_dp_mst_compute_config(struct intel_encoder *encoder,static int intel_dp_mst_atomic_check (struct drm_connector *connector, -struct drm_connector_state *new_conn_state) +struct drm_atomic_state *state) { -struct drm_atomic_state *state = new_conn_state->state; +struct drm_connector_state *new_conn_state = +drm_atomic_get_new_connector_state (state, connector);struct drm_connector_state *old_conn_state =drm_atomic_get_old_connector_state (state, connector); struct intel_connector *intel_connector =@@ -155,7 +156,7 @@ intel_dp_mst_atomic_check(struct drm_connector *connector,struct drm_dp_mst_topology_mgr *mgr;int ret; - ret =intel_digital_connector_atomic_check (connector, new_conn_state); + ret =intel_digital_connector_atomic_check (connector, state);if (ret)return ret;drivers/gpu/drm/i915/intel_drv.h +1
-1@@ -2481,7 +2481,7 @@ int intel_digital_connector_atomic_set_property(struct drm_connector *connector,struct drm_property *property, u64 val);int intel_digital_connector_atomic_check (struct drm_connector *conn, -struct drm_connector_state *new_state); +struct drm_atomic_state *state);struct drm_connector_state *intel_digital_connector_duplicate_state (struct drm_connector *connector);drivers/gpu/drm/i915/intel_sdvo.c +5
-4@@ -2342,9 +2342,10 @@ static const struct drm_connector_funcs intel_sdvo_connector_funcs = { };static int intel_sdvo_atomic_check (struct drm_connector *conn, -struct drm_connector_state *new_conn_state) +struct drm_atomic_state *state) { -struct drm_atomic_state *state = new_conn_state->state; +struct drm_connector_state *new_conn_state = +drm_atomic_get_new_connector_state (state, conn);struct drm_connector_state *old_conn_state =drm_atomic_get_old_connector_state (state, conn); struct intel_sdvo_connector_state *old_state =@@ -2356,13 +2357,13 @@ static int intel_sdvo_atomic_check(struct drm_connector *conn, (memcmp(&old_state->tv, &new_state->tv, sizeof(old_state->tv)) || memcmp(&old_conn_state->tv, &new_conn_state->tv, sizeof(old_conn_state->tv)))) {struct drm_crtc_state *crtc_state = -drm_atomic_get_new_crtc_state (new_conn_state->state, +drm_atomic_get_new_crtc_state (state, new_conn_state->crtc); crtc_state->connectors_changed = true; } -return intel_digital_connector_atomic_check (conn, new_conn_state); +return intel_digital_connector_atomic_check (conn, state); }static const struct drm_connector_helper_funcs intel_sdvo_connector_helper_funcs = {drivers/gpu/drm/i915/intel_tv.c +5
-3@@ -1817,16 +1817,18 @@ static const struct drm_connector_funcs intel_tv_connector_funcs = { };static int intel_tv_atomic_check (struct drm_connector *connector, -struct drm_connector_state *new_state) +struct drm_atomic_state *state) { +struct drm_connector_state *new_state;struct drm_crtc_state *new_crtc_state;struct drm_connector_state *old_state; + new_state =drm_atomic_get_new_connector_state (state, connector);if (!new_state->crtc)return 0 ; - old_state =drm_atomic_get_old_connector_state (new_state->state, connector); - new_crtc_state =drm_atomic_get_new_crtc_state (new_state->state, new_state->crtc); + old_state =drm_atomic_get_old_connector_state (state, connector); + new_crtc_state =drm_atomic_get_new_crtc_state (state, new_state->crtc); if (old_state->tv.mode != new_state->tv.mode || old_state->tv.margins.left != new_state->tv.margins.left ||drivers/gpu/drm/nouveau/dispnv50/disp.c +3
-2@@ -948,11 +948,12 @@ nv50_mstc_get_modes(struct drm_connector *connector)static int nv50_mstc_atomic_check (struct drm_connector *connector, -struct drm_connector_state *new_conn_state) +struct drm_atomic_state *state) { -struct drm_atomic_state *state = new_conn_state->state;struct nv50_mstc *mstc =nv50_mstc (connector);struct drm_dp_mst_topology_mgr *mgr = &mstc->mstm->mgr; +struct drm_connector_state *new_conn_state = +drm_atomic_get_new_connector_state (state, connector);struct drm_connector_state *old_conn_state =drm_atomic_get_old_connector_state (state, connector);struct drm_crtc_state *crtc_state;drivers/gpu/drm/rcar-du/rcar_lvds.c +7
-5@@ -92,13 +92,15 @@ static int rcar_lvds_connector_get_modes(struct drm_connector *connector) }static int rcar_lvds_connector_atomic_check (struct drm_connector *connector, -struct drm_connector_state *state) +struct drm_atomic_state *state) {struct rcar_lvds *lvds =connector_to_rcar_lvds (connector);const struct drm_display_mode *panel_mode; +struct drm_connector_state *conn_state;struct drm_crtc_state *crtc_state; -if (!state->crtc) + conn_state =drm_atomic_get_new_connector_state (state, connector); +if (!conn_state->crtc)return 0 ;if (list_empty (&connector->modes)) {@@ -110,9 +112,9 @@ static int rcar_lvds_connector_atomic_check(struct drm_connector *connector, struct drm_display_mode, head);/* We're not allowed to modify the resolution. */ - crtc_state =drm_atomic_get_crtc_state (state->state, state->crtc); -if (IS_ERR (crtc_state)) -return PTR_ERR (crtc_state); + crtc_state =drm_atomic_get_crtc_state (state, conn_state->crtc); +if (!crtc_state) +return -EINVAL ;if (crtc_state->mode.hdisplay != panel_mode->hdisplay || crtc_state->mode.vdisplay != panel_mode->vdisplay)drivers/gpu/drm/vc4/vc4_txp.c +4
-3@@ -221,17 +221,18 @@ static const u32 txp_fmts[] = { };static int vc4_txp_connector_atomic_check (struct drm_connector *conn, -struct drm_connector_state *conn_state) +struct drm_atomic_state *state) { +struct drm_connector_state *conn_state;struct drm_crtc_state *crtc_state;struct drm_framebuffer *fb;int i; + conn_state =drm_atomic_get_new_connector_state (state, conn);if (!conn_state->writeback_job || !conn_state->writeback_job->fb)return 0 ; - crtc_state =drm_atomic_get_new_crtc_state (conn_state->state, - conn_state->crtc); + crtc_state =drm_atomic_get_new_crtc_state (state, conn_state->crtc); fb = conn_state->writeback_job->fb; if (fb->width != crtc_state->mode.hdisplay ||include/drm/drm_modeset_helper_vtables.h +1
-1@@ -1020,7 +1020,7 @@ struct drm_connector_helper_funcs {* deadlock. */ int (*atomic_check)(struct drm_connector *connector, -struct drm_connector_state *state); +struct drm_atomic_state *state);
Quoted 7 lines
include/drm/drm_modeset_helper_vtables.h struct drm_connector_helper_funcs { · line 1026
Quoted 2 lines
include/drm/drm_modeset_helper_vtables.h +0
-0/** * @atomic_commit: --
Regards,Laurent Pinchart
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
Re: [PATCH v3 04/10] drm: Convert connector_helper_funcs->atomic_check to accept drm_atomic_state
In reply to Laurent PinchartQuoted 12 lines · Laurent Pinchart
Hi Sean,
Thank you for the patch.
Quoted 7 lines · Sean Paul
From: Sean Paul <[email protected]>
Everyone who implements
connector_helper_funcs->atomic_checkreaches into the connector state to get the atomic state. Instead of continuing this pattern, change the callback signature to just give atomic state and let the driver determine what it does and does not need from it.
Quoted 5 lines
Quoted 2 lines
Eventually all atomic functions should do this, but that's just too much busy work for me.
Given that drivers also access the connector state, isn't this slightly more inefficient ?
It's atomic code, we're trying to optimize for clean code at the expense of a bit of runtime overhead due to more pointer chasing. And I agree with the general push, the pile of old/new_state pointers of various objects we're passing around is confusing. Passing the overall drm_atomic_state seems much more reasonable, and with that we can get everything else. Plus it's much more obvious whether you have the old/new state (since that's explicit when you look it up from the drm_atomic_state).
If we ever see this show up in profile, and it starts mattering, first thing we need is a hashtable I think (atm it's list walking, which is just terrible). But thus far no one cares.
-Daniel
Quoted 275 lines
Quoted 270 lines
Changes in v3:
- Added to the setCc Daniel Vetter <[email protected]>Cc Ville Syrjälä <[email protected]>Cc Jani Nikula <[email protected]>Cc Joonas Lahtinen <[email protected]>Cc Rodrigo Vivi <[email protected]>Cc Ben Skeggs <[email protected]>Cc Laurent Pinchart <[email protected]>Cc Kieran Bingham <[email protected]>Cc Eric Anholt <[email protected]>Signed-off-by Sean Paul <[email protected]>--- drivers/gpu/drm/drm_atomic_helper.c | 4 ++-- drivers/gpu/drm/i915/intel_atomic.c | 8 +++++--- drivers/gpu/drm/i915/intel_dp_mst.c | 7 ++++--- drivers/gpu/drm/i915/intel_drv.h | 2 +- drivers/gpu/drm/i915/intel_sdvo.c | 9 +++++---- drivers/gpu/drm/i915/intel_tv.c | 8 +++++--- drivers/gpu/drm/nouveau/dispnv50/disp.c | 5 +++-- drivers/gpu/drm/rcar-du/rcar_lvds.c | 12 +++++++----- drivers/gpu/drm/vc4/vc4_txp.c | 7 ++++--- include/drm/drm_modeset_helper_vtables.h | 2 +- 10 files changed, 37 insertions(+), 27 deletions(-)drivers/gpu/drm/drm_atomic_helper.c +2
-2@@ -683,7 +683,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev, }if (funcs->atomic_check) - ret = funcs->atomic_check (connector, new_connector_state); + ret = funcs->atomic_check (connector, state);if (ret)return ret;@@ -725,7 +725,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,continue ;if (funcs->atomic_check) - ret = funcs->atomic_check (connector, new_connector_state); + ret = funcs->atomic_check (connector, state);if (ret)return ret; }drivers/gpu/drm/i915/intel_atomic.c +5
-3@@ -103,12 +103,14 @@ int intel_digital_connector_atomic_set_property(struct drm_connector *connector, }int intel_digital_connector_atomic_check (struct drm_connector *conn, -struct drm_connector_state *new_state) +struct drm_atomic_state *state) { +struct drm_connector_state *new_state = +drm_atomic_get_new_connector_state (state, conn);struct intel_digital_connector_state *new_conn_state =to_intel_digital_connector_state (new_state);struct drm_connector_state *old_state = -drm_atomic_get_old_connector_state (new_state->state, conn); +drm_atomic_get_old_connector_state (state, conn);struct intel_digital_connector_state *old_conn_state =to_intel_digital_connector_state (old_state);struct drm_crtc_state *crtc_state;@@ -118,7 +120,7 @@ int intel_digital_connector_atomic_check(struct drm_connector *conn,if (!new_state->crtc)return 0 ; - crtc_state =drm_atomic_get_new_crtc_state (new_state->state, new_state->crtc); + crtc_state =drm_atomic_get_new_crtc_state (state, new_state->crtc);/* * These properties are handled by fastset, and might not end drivers/gpu/drm/i915/intel_dp_mst.c +4
-3@@ -143,9 +143,10 @@ static int intel_dp_mst_compute_config(struct intel_encoder *encoder,static int intel_dp_mst_atomic_check (struct drm_connector *connector, -struct drm_connector_state *new_conn_state) +struct drm_atomic_state *state) { -struct drm_atomic_state *state = new_conn_state->state; +struct drm_connector_state *new_conn_state = +drm_atomic_get_new_connector_state (state, connector);struct drm_connector_state *old_conn_state =drm_atomic_get_old_connector_state (state, connector); struct intel_connector *intel_connector =@@ -155,7 +156,7 @@ intel_dp_mst_atomic_check(struct drm_connector *connector,struct drm_dp_mst_topology_mgr *mgr;int ret; - ret =intel_digital_connector_atomic_check (connector, new_conn_state); + ret =intel_digital_connector_atomic_check (connector, state);if (ret)return ret;drivers/gpu/drm/i915/intel_drv.h +1
-1@@ -2481,7 +2481,7 @@ int intel_digital_connector_atomic_set_property(struct drm_connector *connector,struct drm_property *property, u64 val);int intel_digital_connector_atomic_check (struct drm_connector *conn, -struct drm_connector_state *new_state); +struct drm_atomic_state *state);struct drm_connector_state *intel_digital_connector_duplicate_state (struct drm_connector *connector);drivers/gpu/drm/i915/intel_sdvo.c +5
-4@@ -2342,9 +2342,10 @@ static const struct drm_connector_funcs intel_sdvo_connector_funcs = { };static int intel_sdvo_atomic_check (struct drm_connector *conn, -struct drm_connector_state *new_conn_state) +struct drm_atomic_state *state) { -struct drm_atomic_state *state = new_conn_state->state; +struct drm_connector_state *new_conn_state = +drm_atomic_get_new_connector_state (state, conn);struct drm_connector_state *old_conn_state =drm_atomic_get_old_connector_state (state, conn); struct intel_sdvo_connector_state *old_state =@@ -2356,13 +2357,13 @@ static int intel_sdvo_atomic_check(struct drm_connector *conn, (memcmp(&old_state->tv, &new_state->tv, sizeof(old_state->tv)) || memcmp(&old_conn_state->tv, &new_conn_state->tv, sizeof(old_conn_state->tv)))) {struct drm_crtc_state *crtc_state = -drm_atomic_get_new_crtc_state (new_conn_state->state, +drm_atomic_get_new_crtc_state (state, new_conn_state->crtc); crtc_state->connectors_changed = true; } -return intel_digital_connector_atomic_check (conn, new_conn_state); +return intel_digital_connector_atomic_check (conn, state); }static const struct drm_connector_helper_funcs intel_sdvo_connector_helper_funcs = {drivers/gpu/drm/i915/intel_tv.c +5
-3@@ -1817,16 +1817,18 @@ static const struct drm_connector_funcs intel_tv_connector_funcs = { };static int intel_tv_atomic_check (struct drm_connector *connector, -struct drm_connector_state *new_state) +struct drm_atomic_state *state) { +struct drm_connector_state *new_state;struct drm_crtc_state *new_crtc_state;struct drm_connector_state *old_state; + new_state =drm_atomic_get_new_connector_state (state, connector);if (!new_state->crtc)return 0 ; - old_state =drm_atomic_get_old_connector_state (new_state->state, connector); - new_crtc_state =drm_atomic_get_new_crtc_state (new_state->state, new_state->crtc); + old_state =drm_atomic_get_old_connector_state (state, connector); + new_crtc_state =drm_atomic_get_new_crtc_state (state, new_state->crtc); if (old_state->tv.mode != new_state->tv.mode || old_state->tv.margins.left != new_state->tv.margins.left ||drivers/gpu/drm/nouveau/dispnv50/disp.c +3
-2@@ -948,11 +948,12 @@ nv50_mstc_get_modes(struct drm_connector *connector)static int nv50_mstc_atomic_check (struct drm_connector *connector, -struct drm_connector_state *new_conn_state) +struct drm_atomic_state *state) { -struct drm_atomic_state *state = new_conn_state->state;struct nv50_mstc *mstc =nv50_mstc (connector);struct drm_dp_mst_topology_mgr *mgr = &mstc->mstm->mgr; +struct drm_connector_state *new_conn_state = +drm_atomic_get_new_connector_state (state, connector);struct drm_connector_state *old_conn_state =drm_atomic_get_old_connector_state (state, connector);struct drm_crtc_state *crtc_state;drivers/gpu/drm/rcar-du/rcar_lvds.c +7
-5@@ -92,13 +92,15 @@ static int rcar_lvds_connector_get_modes(struct drm_connector *connector) }static int rcar_lvds_connector_atomic_check (struct drm_connector *connector, -struct drm_connector_state *state) +struct drm_atomic_state *state) {struct rcar_lvds *lvds =connector_to_rcar_lvds (connector);const struct drm_display_mode *panel_mode; +struct drm_connector_state *conn_state;struct drm_crtc_state *crtc_state; -if (!state->crtc) + conn_state =drm_atomic_get_new_connector_state (state, connector); +if (!conn_state->crtc)return 0 ;if (list_empty (&connector->modes)) {@@ -110,9 +112,9 @@ static int rcar_lvds_connector_atomic_check(struct drm_connector *connector, struct drm_display_mode, head);/* We're not allowed to modify the resolution. */ - crtc_state =drm_atomic_get_crtc_state (state->state, state->crtc); -if (IS_ERR (crtc_state)) -return PTR_ERR (crtc_state); + crtc_state =drm_atomic_get_crtc_state (state, conn_state->crtc); +if (!crtc_state) +return -EINVAL ;if (crtc_state->mode.hdisplay != panel_mode->hdisplay || crtc_state->mode.vdisplay != panel_mode->vdisplay)drivers/gpu/drm/vc4/vc4_txp.c +4
-3@@ -221,17 +221,18 @@ static const u32 txp_fmts[] = { };static int vc4_txp_connector_atomic_check (struct drm_connector *conn, -struct drm_connector_state *conn_state) +struct drm_atomic_state *state) { +struct drm_connector_state *conn_state;struct drm_crtc_state *crtc_state;struct drm_framebuffer *fb;int i; + conn_state =drm_atomic_get_new_connector_state (state, conn);if (!conn_state->writeback_job || !conn_state->writeback_job->fb)return 0 ; - crtc_state =drm_atomic_get_new_crtc_state (conn_state->state, - conn_state->crtc); + crtc_state =drm_atomic_get_new_crtc_state (state, conn_state->crtc); fb = conn_state->writeback_job->fb; if (fb->width != crtc_state->mode.hdisplay ||include/drm/drm_modeset_helper_vtables.h +1
-1@@ -1020,7 +1020,7 @@ struct drm_connector_helper_funcs {* deadlock. */ int (*atomic_check)(struct drm_connector *connector, -struct drm_connector_state *state); +struct drm_atomic_state *state);/** * @atomic_commit: Signature · 3 lines
Regards, Laurent Pinchart
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Laurent Pinchart
reviewerRe: [PATCH v3 04/10] drm: Convert connector_helper_funcs->atomic_check to accept drm_atomic_state
In reply to Sean PaulHi Sean,
Quoted 9 lines · Sean Paul
Quoted 8 lines · Laurent Pinchart
Quoted 7 lines · Sean Paul
From: Sean Paul <[email protected]>
Everyone who implements
connector_helper_funcs->atomic_checkreaches into the connector state to get the atomic state. Instead of continuing this pattern, change the callback signature to just give atomic state and let the driver determine what it does and does not need from it.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Eventually all atomic functions should do this, but that's just too much busy work for me.
Given that drivers also access the connector state, isn't this slightly more inefficient ?
Inefficient in terms of what?
In terms of the operation having to lookup the connector state, when the caller has it and can easily pass it. As Daniel commented, this may be the price to pay for a cleaner API, but I wonder how much overhead all the state tracking is costing.
Quoted 2 lines
Agree that in isolation this patch might seem unnecessary, but it ties in with the encoder and bridge CLs which accept
drm_atomic_statein
CLs ?
Quoted 276 lines
their hooks. In general the idea is to convert all atomic functions to take overall atomic state instead of just their object state. Reality has proven to be more complicated and we need more access than what the current implementation provides.
Sean
Quoted 269 lines
Quoted 269 lines
Changes in v3:
- Added to the setCc Daniel Vetter <[email protected]>Cc Ville Syrjälä <[email protected]>Cc Jani Nikula <[email protected]>Cc Joonas Lahtinen <[email protected]>Cc Rodrigo Vivi <[email protected]>Cc Ben Skeggs <[email protected]>Cc Laurent Pinchart <[email protected]>Cc Kieran Bingham <[email protected]>Cc Eric Anholt <[email protected]>Signed-off-by Sean Paul <[email protected]>--- drivers/gpu/drm/drm_atomic_helper.c | 4 ++-- drivers/gpu/drm/i915/intel_atomic.c | 8 +++++--- drivers/gpu/drm/i915/intel_dp_mst.c | 7 ++++--- drivers/gpu/drm/i915/intel_drv.h | 2 +- drivers/gpu/drm/i915/intel_sdvo.c | 9 +++++---- drivers/gpu/drm/i915/intel_tv.c | 8 +++++--- drivers/gpu/drm/nouveau/dispnv50/disp.c | 5 +++-- drivers/gpu/drm/rcar-du/rcar_lvds.c | 12 +++++++----- drivers/gpu/drm/vc4/vc4_txp.c | 7 ++++--- include/drm/drm_modeset_helper_vtables.h | 2 +- 10 files changed, 37 insertions(+), 27 deletions(-)drivers/gpu/drm/drm_atomic_helper.c +2
-2@@ -683,7 +683,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev, }if (funcs->atomic_check) - ret = funcs->atomic_check (connector, new_connector_state); + ret = funcs->atomic_check (connector, state);if (ret)return ret;@@ -725,7 +725,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,continue ;if (funcs->atomic_check) - ret = funcs->atomic_check (connector, new_connector_state); + ret = funcs->atomic_check (connector, state);if (ret)return ret; }drivers/gpu/drm/i915/intel_atomic.c +5
-3@@ -103,12 +103,14 @@ int intel_digital_connector_atomic_set_property(struct drm_connector *connector, }int intel_digital_connector_atomic_check (struct drm_connector *conn, -struct drm_connector_state *new_state) +struct drm_atomic_state *state) { +struct drm_connector_state *new_state = +drm_atomic_get_new_connector_state (state, conn);struct intel_digital_connector_state *new_conn_state =to_intel_digital_connector_state (new_state);struct drm_connector_state *old_state = -drm_atomic_get_old_connector_state (new_state->state, conn); +drm_atomic_get_old_connector_state (state, conn);struct intel_digital_connector_state *old_conn_state =to_intel_digital_connector_state (old_state);struct drm_crtc_state *crtc_state;@@ -118,7 +120,7 @@ int intel_digital_connector_atomic_check(struct drm_connector *conn,if (!new_state->crtc)return 0 ; - crtc_state =drm_atomic_get_new_crtc_state (new_state->state, new_state->crtc); + crtc_state =drm_atomic_get_new_crtc_state (state, new_state->crtc);/* * These properties are handled by fastset, and might not end drivers/gpu/drm/i915/intel_dp_mst.c +4
-3@@ -143,9 +143,10 @@ static int intel_dp_mst_compute_config(struct intel_encoder *encoder,static int intel_dp_mst_atomic_check (struct drm_connector *connector, -struct drm_connector_state *new_conn_state) +struct drm_atomic_state *state) { -struct drm_atomic_state *state = new_conn_state->state; +struct drm_connector_state *new_conn_state = +drm_atomic_get_new_connector_state (state, connector);struct drm_connector_state *old_conn_state =drm_atomic_get_old_connector_state (state, connector); struct intel_connector *intel_connector =@@ -155,7 +156,7 @@ intel_dp_mst_atomic_check(struct drm_connector *connector,struct drm_dp_mst_topology_mgr *mgr;int ret; - ret =intel_digital_connector_atomic_check (connector, new_conn_state); + ret =intel_digital_connector_atomic_check (connector, state);if (ret)return ret;drivers/gpu/drm/i915/intel_drv.h +1
-1@@ -2481,7 +2481,7 @@ int intel_digital_connector_atomic_set_property(struct drm_connector *connector,struct drm_property *property, u64 val);int intel_digital_connector_atomic_check (struct drm_connector *conn, -struct drm_connector_state *new_state); +struct drm_atomic_state *state);struct drm_connector_state *intel_digital_connector_duplicate_state (struct drm_connector *connector);drivers/gpu/drm/i915/intel_sdvo.c +5
-4@@ -2342,9 +2342,10 @@ static const struct drm_connector_funcs intel_sdvo_connector_funcs = { };static int intel_sdvo_atomic_check (struct drm_connector *conn, -struct drm_connector_state *new_conn_state) +struct drm_atomic_state *state) { -struct drm_atomic_state *state = new_conn_state->state; +struct drm_connector_state *new_conn_state = +drm_atomic_get_new_connector_state (state, conn);struct drm_connector_state *old_conn_state =drm_atomic_get_old_connector_state (state, conn); struct intel_sdvo_connector_state *old_state =@@ -2356,13 +2357,13 @@ static int intel_sdvo_atomic_check(struct drm_connector *conn, (memcmp(&old_state->tv, &new_state->tv, sizeof(old_state->tv)) || memcmp(&old_conn_state->tv, &new_conn_state->tv, sizeof(old_conn_state->tv)))) {struct drm_crtc_state *crtc_state = -drm_atomic_get_new_crtc_state (new_conn_state->state, +drm_atomic_get_new_crtc_state (state, new_conn_state->crtc); crtc_state->connectors_changed = true; } -return intel_digital_connector_atomic_check (conn, new_conn_state); +return intel_digital_connector_atomic_check (conn, state); }static const struct drm_connector_helper_funcs intel_sdvo_connector_helper_funcs = {drivers/gpu/drm/i915/intel_tv.c +5
-3@@ -1817,16 +1817,18 @@ static const struct drm_connector_funcs intel_tv_connector_funcs = { };static int intel_tv_atomic_check (struct drm_connector *connector, -struct drm_connector_state *new_state) +struct drm_atomic_state *state) { +struct drm_connector_state *new_state;struct drm_crtc_state *new_crtc_state;struct drm_connector_state *old_state; + new_state =drm_atomic_get_new_connector_state (state, connector);if (!new_state->crtc)return 0 ; - old_state =drm_atomic_get_old_connector_state (new_state->state, connector); - new_crtc_state =drm_atomic_get_new_crtc_state (new_state->state, new_state->crtc); + old_state =drm_atomic_get_old_connector_state (state, connector); + new_crtc_state =drm_atomic_get_new_crtc_state (state, new_state->crtc); if (old_state->tv.mode != new_state->tv.mode || old_state->tv.margins.left != new_state->tv.margins.left ||drivers/gpu/drm/nouveau/dispnv50/disp.c +3
-2@@ -948,11 +948,12 @@ nv50_mstc_get_modes(struct drm_connector *connector)static int nv50_mstc_atomic_check (struct drm_connector *connector, -struct drm_connector_state *new_conn_state) +struct drm_atomic_state *state) { -struct drm_atomic_state *state = new_conn_state->state;struct nv50_mstc *mstc =nv50_mstc (connector);struct drm_dp_mst_topology_mgr *mgr = &mstc->mstm->mgr; +struct drm_connector_state *new_conn_state = +drm_atomic_get_new_connector_state (state, connector);struct drm_connector_state *old_conn_state =drm_atomic_get_old_connector_state (state, connector);struct drm_crtc_state *crtc_state;drivers/gpu/drm/rcar-du/rcar_lvds.c +7
-5@@ -92,13 +92,15 @@ static int rcar_lvds_connector_get_modes(struct drm_connector *connector) }static int rcar_lvds_connector_atomic_check (struct drm_connector *connector, -struct drm_connector_state *state) +struct drm_atomic_state *state) {struct rcar_lvds *lvds =connector_to_rcar_lvds (connector);const struct drm_display_mode *panel_mode; +struct drm_connector_state *conn_state;struct drm_crtc_state *crtc_state; -if (!state->crtc) + conn_state =drm_atomic_get_new_connector_state (state, connector); +if (!conn_state->crtc)return 0 ;if (list_empty (&connector->modes)) {@@ -110,9 +112,9 @@ static int rcar_lvds_connector_atomic_check(struct drm_connector *connector, struct drm_display_mode, head);/* We're not allowed to modify the resolution. */ - crtc_state =drm_atomic_get_crtc_state (state->state, state->crtc); -if (IS_ERR (crtc_state)) -return PTR_ERR (crtc_state); + crtc_state =drm_atomic_get_crtc_state (state, conn_state->crtc); +if (!crtc_state) +return -EINVAL ;if (crtc_state->mode.hdisplay != panel_mode->hdisplay || crtc_state->mode.vdisplay != panel_mode->vdisplay)drivers/gpu/drm/vc4/vc4_txp.c +4
-3@@ -221,17 +221,18 @@ static const u32 txp_fmts[] = { };static int vc4_txp_connector_atomic_check (struct drm_connector *conn, -struct drm_connector_state *conn_state) +struct drm_atomic_state *state) { +struct drm_connector_state *conn_state;struct drm_crtc_state *crtc_state;struct drm_framebuffer *fb;int i; + conn_state =drm_atomic_get_new_connector_state (state, conn);if (!conn_state->writeback_job || !conn_state->writeback_job->fb)return 0 ; - crtc_state =drm_atomic_get_new_crtc_state (conn_state->state, - conn_state->crtc); + crtc_state =drm_atomic_get_new_crtc_state (state, conn_state->crtc); fb = conn_state->writeback_job->fb; if (fb->width != crtc_state->mode.hdisplay ||include/drm/drm_modeset_helper_vtables.h +1
-1@@ -1020,7 +1020,7 @@ struct drm_connector_helper_funcs {* deadlock. */ int (*atomic_check)(struct drm_connector *connector, -struct drm_connector_state *state); +struct drm_atomic_state *state);/** * @atomic_commit:
Signature · 7 lines
Regards, Laurent Pinchart _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Laurent Pinchart
reviewerRe: [PATCH v3 04/10] drm: Convert connector_helper_funcs->atomic_check to accept drm_atomic_state
In reply to Daniel VetterHi Daniel,
Quoted 15 lines · Daniel Vetter
Quoted 8 lines · Laurent Pinchart
Quoted 7 lines · Sean Paul
From: Sean Paul <[email protected]>
Everyone who implements
connector_helper_funcs->atomic_checkreaches into the connector state to get the atomic state. Instead of continuing this pattern, change the callback signature to just give atomic state and let the driver determine what it does and does not need from it.Quoted 5 lines
Quoted 2 lines
Eventually all atomic functions should do this, but that's just too much busy work for me.
Given that drivers also access the connector state, isn't this slightly more inefficient ?
Quoted 7 lines
It's atomic code, we're trying to optimize for clean code at the expense of a bit of runtime overhead due to more pointer chasing. And I agree with the general push, the pile of old/new_state pointers of various objects we're passing around is confusing. Passing the overall
drm_atomic_stateseems much more reasonable, and with that we can get everything else. Plus it's much more obvious whether you have the old/new state (since that's explicit when you look it up from thedrm_atomic_state).
Yes, I agree it's cleaner. I just hope the atomic state tracking cost can be kept under control :-)
By the way, this is likely not going to happen as it would be way too intrusive, but it would be nice to rename drm_atomic_state to drm_atomic_transaction (or something similar). It doesn't model a state, but a change between an old state to a new state. This confused me in the past, and I'm sure it can still be confusing to newcomers.
Quoted 273 lines
If we ever see this show up in profile, and it starts mattering, first thing we need is a hashtable I think (atm it's list walking, which is just terrible). But thus far no one cares.
Quoted 269 lines
Quoted 269 lines
Changes in v3:
- Added to the setCc Daniel Vetter <[email protected]>Cc Ville Syrjälä <[email protected]>Cc Jani Nikula <[email protected]>Cc Joonas Lahtinen <[email protected]>Cc Rodrigo Vivi <[email protected]>Cc Ben Skeggs <[email protected]>Cc Laurent Pinchart <[email protected]>Cc Kieran Bingham <[email protected]>Cc Eric Anholt <[email protected]>Signed-off-by Sean Paul <[email protected]>--- drivers/gpu/drm/drm_atomic_helper.c | 4 ++-- drivers/gpu/drm/i915/intel_atomic.c | 8 +++++--- drivers/gpu/drm/i915/intel_dp_mst.c | 7 ++++--- drivers/gpu/drm/i915/intel_drv.h | 2 +- drivers/gpu/drm/i915/intel_sdvo.c | 9 +++++---- drivers/gpu/drm/i915/intel_tv.c | 8 +++++--- drivers/gpu/drm/nouveau/dispnv50/disp.c | 5 +++-- drivers/gpu/drm/rcar-du/rcar_lvds.c | 12 +++++++----- drivers/gpu/drm/vc4/vc4_txp.c | 7 ++++--- include/drm/drm_modeset_helper_vtables.h | 2 +- 10 files changed, 37 insertions(+), 27 deletions(-)drivers/gpu/drm/drm_atomic_helper.c +2
-2@@ -683,7 +683,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev, }if (funcs->atomic_check) - ret = funcs->atomic_check (connector, new_connector_state); + ret = funcs->atomic_check (connector, state);if (ret)return ret;@@ -725,7 +725,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,continue ;if (funcs->atomic_check) - ret = funcs->atomic_check (connector, new_connector_state); + ret = funcs->atomic_check (connector, state);if (ret)return ret; }drivers/gpu/drm/i915/intel_atomic.c +5
-3@@ -103,12 +103,14 @@ int intel_digital_connector_atomic_set_property(struct drm_connector *connector, }int intel_digital_connector_atomic_check (struct drm_connector *conn, -struct drm_connector_state *new_state) +struct drm_atomic_state *state) { +struct drm_connector_state *new_state = +drm_atomic_get_new_connector_state (state, conn);struct intel_digital_connector_state *new_conn_state =to_intel_digital_connector_state (new_state);struct drm_connector_state *old_state = -drm_atomic_get_old_connector_state (new_state->state, conn); +drm_atomic_get_old_connector_state (state, conn);struct intel_digital_connector_state *old_conn_state =to_intel_digital_connector_state (old_state);struct drm_crtc_state *crtc_state;@@ -118,7 +120,7 @@ int intel_digital_connector_atomic_check(struct drm_connector *conn,if (!new_state->crtc)return 0 ; - crtc_state =drm_atomic_get_new_crtc_state (new_state->state, new_state->crtc); + crtc_state =drm_atomic_get_new_crtc_state (state, new_state->crtc);/* * These properties are handled by fastset, and might not end drivers/gpu/drm/i915/intel_dp_mst.c +4
-3@@ -143,9 +143,10 @@ static int intel_dp_mst_compute_config(struct intel_encoder *encoder,static int intel_dp_mst_atomic_check (struct drm_connector *connector, -struct drm_connector_state *new_conn_state) +struct drm_atomic_state *state) { -struct drm_atomic_state *state = new_conn_state->state; +struct drm_connector_state *new_conn_state = +drm_atomic_get_new_connector_state (state, connector);struct drm_connector_state *old_conn_state =drm_atomic_get_old_connector_state (state, connector); struct intel_connector *intel_connector =@@ -155,7 +156,7 @@ intel_dp_mst_atomic_check(struct drm_connector *connector,struct drm_dp_mst_topology_mgr *mgr;int ret; - ret =intel_digital_connector_atomic_check (connector, new_conn_state); + ret =intel_digital_connector_atomic_check (connector, state);if (ret)return ret;drivers/gpu/drm/i915/intel_drv.h +1
-1@@ -2481,7 +2481,7 @@ int intel_digital_connector_atomic_set_property(struct drm_connector *connector,struct drm_property *property, u64 val);int intel_digital_connector_atomic_check (struct drm_connector *conn, -struct drm_connector_state *new_state); +struct drm_atomic_state *state);struct drm_connector_state *intel_digital_connector_duplicate_state (struct drm_connector *connector);drivers/gpu/drm/i915/intel_sdvo.c +5
-4@@ -2342,9 +2342,10 @@ static const struct drm_connector_funcs intel_sdvo_connector_funcs = { };static int intel_sdvo_atomic_check (struct drm_connector *conn, -struct drm_connector_state *new_conn_state) +struct drm_atomic_state *state) { -struct drm_atomic_state *state = new_conn_state->state; +struct drm_connector_state *new_conn_state = +drm_atomic_get_new_connector_state (state, conn);struct drm_connector_state *old_conn_state =drm_atomic_get_old_connector_state (state, conn); struct intel_sdvo_connector_state *old_state =@@ -2356,13 +2357,13 @@ static int intel_sdvo_atomic_check(struct drm_connector *conn, (memcmp(&old_state->tv, &new_state->tv, sizeof(old_state->tv)) || memcmp(&old_conn_state->tv, &new_conn_state->tv, sizeof(old_conn_state->tv)))) {struct drm_crtc_state *crtc_state = -drm_atomic_get_new_crtc_state (new_conn_state->state, +drm_atomic_get_new_crtc_state (state, new_conn_state->crtc); crtc_state->connectors_changed = true; } -return intel_digital_connector_atomic_check (conn, new_conn_state); +return intel_digital_connector_atomic_check (conn, state); }static const struct drm_connector_helper_funcs intel_sdvo_connector_helper_funcs = {drivers/gpu/drm/i915/intel_tv.c +5
-3@@ -1817,16 +1817,18 @@ static const struct drm_connector_funcs intel_tv_connector_funcs = { };static int intel_tv_atomic_check (struct drm_connector *connector, -struct drm_connector_state *new_state) +struct drm_atomic_state *state) { +struct drm_connector_state *new_state;struct drm_crtc_state *new_crtc_state;struct drm_connector_state *old_state; + new_state =drm_atomic_get_new_connector_state (state, connector);if (!new_state->crtc)return 0 ; - old_state =drm_atomic_get_old_connector_state (new_state->state, connector); - new_crtc_state =drm_atomic_get_new_crtc_state (new_state->state, new_state->crtc); + old_state =drm_atomic_get_old_connector_state (state, connector); + new_crtc_state =drm_atomic_get_new_crtc_state (state, new_state->crtc); if (old_state->tv.mode != new_state->tv.mode || old_state->tv.margins.left != new_state->tv.margins.left ||drivers/gpu/drm/nouveau/dispnv50/disp.c +3
-2@@ -948,11 +948,12 @@ nv50_mstc_get_modes(struct drm_connector *connector)static int nv50_mstc_atomic_check (struct drm_connector *connector, -struct drm_connector_state *new_conn_state) +struct drm_atomic_state *state) { -struct drm_atomic_state *state = new_conn_state->state;struct nv50_mstc *mstc =nv50_mstc (connector);struct drm_dp_mst_topology_mgr *mgr = &mstc->mstm->mgr; +struct drm_connector_state *new_conn_state = +drm_atomic_get_new_connector_state (state, connector);struct drm_connector_state *old_conn_state =drm_atomic_get_old_connector_state (state, connector);struct drm_crtc_state *crtc_state;drivers/gpu/drm/rcar-du/rcar_lvds.c +7
-5@@ -92,13 +92,15 @@ static int rcar_lvds_connector_get_modes(struct drm_connector *connector) }static int rcar_lvds_connector_atomic_check (struct drm_connector *connector, -struct drm_connector_state *state) +struct drm_atomic_state *state) {struct rcar_lvds *lvds =connector_to_rcar_lvds (connector);const struct drm_display_mode *panel_mode; +struct drm_connector_state *conn_state;struct drm_crtc_state *crtc_state; -if (!state->crtc) + conn_state =drm_atomic_get_new_connector_state (state, connector); +if (!conn_state->crtc)return 0 ;if (list_empty (&connector->modes)) {@@ -110,9 +112,9 @@ static int rcar_lvds_connector_atomic_check(struct drm_connector *connector, struct drm_display_mode, head);/* We're not allowed to modify the resolution. */ - crtc_state =drm_atomic_get_crtc_state (state->state, state->crtc); -if (IS_ERR (crtc_state)) -return PTR_ERR (crtc_state); + crtc_state =drm_atomic_get_crtc_state (state, conn_state->crtc); +if (!crtc_state) +return -EINVAL ;if (crtc_state->mode.hdisplay != panel_mode->hdisplay || crtc_state->mode.vdisplay != panel_mode->vdisplay)drivers/gpu/drm/vc4/vc4_txp.c +4
-3@@ -221,17 +221,18 @@ static const u32 txp_fmts[] = { };static int vc4_txp_connector_atomic_check (struct drm_connector *conn, -struct drm_connector_state *conn_state) +struct drm_atomic_state *state) { +struct drm_connector_state *conn_state;struct drm_crtc_state *crtc_state;struct drm_framebuffer *fb;int i; + conn_state =drm_atomic_get_new_connector_state (state, conn);if (!conn_state->writeback_job || !conn_state->writeback_job->fb)return 0 ; - crtc_state =drm_atomic_get_new_crtc_state (conn_state->state, - conn_state->crtc); + crtc_state =drm_atomic_get_new_crtc_state (state, conn_state->crtc); fb = conn_state->writeback_job->fb; if (fb->width != crtc_state->mode.hdisplay ||include/drm/drm_modeset_helper_vtables.h +1
-1@@ -1020,7 +1020,7 @@ struct drm_connector_helper_funcs {* deadlock. */ int (*atomic_check)(struct drm_connector *connector, -struct drm_connector_state *state); +struct drm_atomic_state *state);/** * @atomic_commit:
Signature · 7 lines
Regards, Laurent Pinchart _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 04/10] drm: Convert connector_helper_funcs->atomic_check to accept drm_atomic_state
Quoted 27 lines · Laurent Pinchart
Hi Daniel,
Quoted 15 lines · Daniel Vetter
Quoted 8 lines · Laurent Pinchart
Quoted 7 lines · Sean Paul
From: Sean Paul <[email protected]>
Everyone who implements
connector_helper_funcs->atomic_checkreaches into the connector state to get the atomic state. Instead of continuing this pattern, change the callback signature to just give atomic state and let the driver determine what it does and does not need from it.Quoted 5 lines
Quoted 2 lines
Eventually all atomic functions should do this, but that's just too much busy work for me.
Given that drivers also access the connector state, isn't this slightly more inefficient ?
Quoted 7 lines
It's atomic code, we're trying to optimize for clean code at the expense of a bit of runtime overhead due to more pointer chasing. And I agree with the general push, the pile of old/new_state pointers of various objects we're passing around is confusing. Passing the overall
drm_atomic_stateseems much more reasonable, and with that we can get everything else. Plus it's much more obvious whether you have the old/new state (since that's explicit when you look it up from thedrm_atomic_state).
Quoted 8 lines
Yes, I agree it's cleaner. I just hope the atomic state tracking cost can be kept under control :-)
By the way, this is likely not going to happen as it would be way too intrusive, but it would be nice to rename
drm_atomic_statetodrm_atomic_transaction(or something similar). It doesn't model a state, but a change between an old state to a new state. This confused me in the past, and I'm sure it can still be confusing to newcomers.
Why are you the first to suggest this, this is awesome! drm_atomic_state is indeed not a state, but a transaction representing how we go from the old to the new state.
I think this is awesome enough that we should actually try to make it happen. Tree-wide cocci + bribing Dave on St. Patrick's day with lots of beer might be enough :-)
-Daniel
Quoted 282 lines
Quoted 271 lines
If we ever see this show up in profile, and it starts mattering, first thing we need is a hashtable I think (atm it's list walking, which is just terrible). But thus far no one cares.
Quoted 267 lines
Quoted 267 lines
Changes in v3:
- Added to the setCc Daniel Vetter <[email protected]>Cc Ville Syrjälä <[email protected]>Cc Jani Nikula <[email protected]>Cc Joonas Lahtinen <[email protected]>Cc Rodrigo Vivi <[email protected]>Cc Ben Skeggs <[email protected]>Cc Laurent Pinchart <[email protected]>Cc Kieran Bingham <[email protected]>Cc Eric Anholt <[email protected]>Signed-off-by Sean Paul <[email protected]>--- drivers/gpu/drm/drm_atomic_helper.c | 4 ++-- drivers/gpu/drm/i915/intel_atomic.c | 8 +++++--- drivers/gpu/drm/i915/intel_dp_mst.c | 7 ++++--- drivers/gpu/drm/i915/intel_drv.h | 2 +- drivers/gpu/drm/i915/intel_sdvo.c | 9 +++++---- drivers/gpu/drm/i915/intel_tv.c | 8 +++++--- drivers/gpu/drm/nouveau/dispnv50/disp.c | 5 +++-- drivers/gpu/drm/rcar-du/rcar_lvds.c | 12 +++++++----- drivers/gpu/drm/vc4/vc4_txp.c | 7 ++++--- include/drm/drm_modeset_helper_vtables.h | 2 +- 10 files changed, 37 insertions(+), 27 deletions(-)drivers/gpu/drm/drm_atomic_helper.c +2
-2@@ -683,7 +683,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev, }if (funcs->atomic_check) - ret = funcs->atomic_check (connector, new_connector_state); + ret = funcs->atomic_check (connector, state);if (ret)return ret;@@ -725,7 +725,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,continue ;if (funcs->atomic_check) - ret = funcs->atomic_check (connector, new_connector_state); + ret = funcs->atomic_check (connector, state);if (ret)return ret; }drivers/gpu/drm/i915/intel_atomic.c +5
-3@@ -103,12 +103,14 @@ int intel_digital_connector_atomic_set_property(struct drm_connector *connector, }int intel_digital_connector_atomic_check (struct drm_connector *conn, -struct drm_connector_state *new_state) +struct drm_atomic_state *state) { +struct drm_connector_state *new_state = +drm_atomic_get_new_connector_state (state, conn);struct intel_digital_connector_state *new_conn_state =to_intel_digital_connector_state (new_state);struct drm_connector_state *old_state = -drm_atomic_get_old_connector_state (new_state->state, conn); +drm_atomic_get_old_connector_state (state, conn);struct intel_digital_connector_state *old_conn_state =to_intel_digital_connector_state (old_state);struct drm_crtc_state *crtc_state;@@ -118,7 +120,7 @@ int intel_digital_connector_atomic_check(struct drm_connector *conn,if (!new_state->crtc)return 0 ; - crtc_state =drm_atomic_get_new_crtc_state (new_state->state, new_state->crtc); + crtc_state =drm_atomic_get_new_crtc_state (state, new_state->crtc);/* * These properties are handled by fastset, and might not end drivers/gpu/drm/i915/intel_dp_mst.c +4
-3@@ -143,9 +143,10 @@ static int intel_dp_mst_compute_config(struct intel_encoder *encoder,static int intel_dp_mst_atomic_check (struct drm_connector *connector, -struct drm_connector_state *new_conn_state) +struct drm_atomic_state *state) { -struct drm_atomic_state *state = new_conn_state->state; +struct drm_connector_state *new_conn_state = +drm_atomic_get_new_connector_state (state, connector);struct drm_connector_state *old_conn_state =drm_atomic_get_old_connector_state (state, connector); struct intel_connector *intel_connector =@@ -155,7 +156,7 @@ intel_dp_mst_atomic_check(struct drm_connector *connector,struct drm_dp_mst_topology_mgr *mgr;int ret; - ret =intel_digital_connector_atomic_check (connector, new_conn_state); + ret =intel_digital_connector_atomic_check (connector, state);if (ret)return ret;drivers/gpu/drm/i915/intel_drv.h +1
-1@@ -2481,7 +2481,7 @@ int intel_digital_connector_atomic_set_property(struct drm_connector *connector,struct drm_property *property, u64 val);int intel_digital_connector_atomic_check (struct drm_connector *conn, -struct drm_connector_state *new_state); +struct drm_atomic_state *state);struct drm_connector_state *intel_digital_connector_duplicate_state (struct drm_connector *connector);drivers/gpu/drm/i915/intel_sdvo.c +5
-4@@ -2342,9 +2342,10 @@ static const struct drm_connector_funcs intel_sdvo_connector_funcs = { };static int intel_sdvo_atomic_check (struct drm_connector *conn, -struct drm_connector_state *new_conn_state) +struct drm_atomic_state *state) { -struct drm_atomic_state *state = new_conn_state->state; +struct drm_connector_state *new_conn_state = +drm_atomic_get_new_connector_state (state, conn);struct drm_connector_state *old_conn_state =drm_atomic_get_old_connector_state (state, conn); struct intel_sdvo_connector_state *old_state =@@ -2356,13 +2357,13 @@ static int intel_sdvo_atomic_check(struct drm_connector *conn, (memcmp(&old_state->tv, &new_state->tv, sizeof(old_state->tv)) || memcmp(&old_conn_state->tv, &new_conn_state->tv, sizeof(old_conn_state->tv)))) {struct drm_crtc_state *crtc_state = -drm_atomic_get_new_crtc_state (new_conn_state->state, +drm_atomic_get_new_crtc_state (state, new_conn_state->crtc); crtc_state->connectors_changed = true; } -return intel_digital_connector_atomic_check (conn, new_conn_state); +return intel_digital_connector_atomic_check (conn, state); }static const struct drm_connector_helper_funcs intel_sdvo_connector_helper_funcs = {drivers/gpu/drm/i915/intel_tv.c +5
-3@@ -1817,16 +1817,18 @@ static const struct drm_connector_funcs intel_tv_connector_funcs = { };static int intel_tv_atomic_check (struct drm_connector *connector, -struct drm_connector_state *new_state) +struct drm_atomic_state *state) { +struct drm_connector_state *new_state;struct drm_crtc_state *new_crtc_state;struct drm_connector_state *old_state; + new_state =drm_atomic_get_new_connector_state (state, connector);if (!new_state->crtc)return 0 ; - old_state =drm_atomic_get_old_connector_state (new_state->state, connector); - new_crtc_state =drm_atomic_get_new_crtc_state (new_state->state, new_state->crtc); + old_state =drm_atomic_get_old_connector_state (state, connector); + new_crtc_state =drm_atomic_get_new_crtc_state (state, new_state->crtc); if (old_state->tv.mode != new_state->tv.mode || old_state->tv.margins.left != new_state->tv.margins.left ||drivers/gpu/drm/nouveau/dispnv50/disp.c +3
-2@@ -948,11 +948,12 @@ nv50_mstc_get_modes(struct drm_connector *connector)static int nv50_mstc_atomic_check (struct drm_connector *connector, -struct drm_connector_state *new_conn_state) +struct drm_atomic_state *state) { -struct drm_atomic_state *state = new_conn_state->state;struct nv50_mstc *mstc =nv50_mstc (connector);struct drm_dp_mst_topology_mgr *mgr = &mstc->mstm->mgr; +struct drm_connector_state *new_conn_state = +drm_atomic_get_new_connector_state (state, connector);struct drm_connector_state *old_conn_state =drm_atomic_get_old_connector_state (state, connector);struct drm_crtc_state *crtc_state;drivers/gpu/drm/rcar-du/rcar_lvds.c +7
-5@@ -92,13 +92,15 @@ static int rcar_lvds_connector_get_modes(struct drm_connector *connector) }static int rcar_lvds_connector_atomic_check (struct drm_connector *connector, -struct drm_connector_state *state) +struct drm_atomic_state *state) {struct rcar_lvds *lvds =connector_to_rcar_lvds (connector);const struct drm_display_mode *panel_mode; +struct drm_connector_state *conn_state;struct drm_crtc_state *crtc_state; -if (!state->crtc) + conn_state =drm_atomic_get_new_connector_state (state, connector); +if (!conn_state->crtc)return 0 ;if (list_empty (&connector->modes)) {@@ -110,9 +112,9 @@ static int rcar_lvds_connector_atomic_check(struct drm_connector *connector, struct drm_display_mode, head);/* We're not allowed to modify the resolution. */ - crtc_state =drm_atomic_get_crtc_state (state->state, state->crtc); -if (IS_ERR (crtc_state)) -return PTR_ERR (crtc_state); + crtc_state =drm_atomic_get_crtc_state (state, conn_state->crtc); +if (!crtc_state) +return -EINVAL ;if (crtc_state->mode.hdisplay != panel_mode->hdisplay || crtc_state->mode.vdisplay != panel_mode->vdisplay)drivers/gpu/drm/vc4/vc4_txp.c +4
-3@@ -221,17 +221,18 @@ static const u32 txp_fmts[] = { };static int vc4_txp_connector_atomic_check (struct drm_connector *conn, -struct drm_connector_state *conn_state) +struct drm_atomic_state *state) { +struct drm_connector_state *conn_state;struct drm_crtc_state *crtc_state;struct drm_framebuffer *fb;int i; + conn_state =drm_atomic_get_new_connector_state (state, conn);if (!conn_state->writeback_job || !conn_state->writeback_job->fb)return 0 ; - crtc_state =drm_atomic_get_new_crtc_state (conn_state->state, - conn_state->crtc); + crtc_state =drm_atomic_get_new_crtc_state (state, conn_state->crtc); fb = conn_state->writeback_job->fb; if (fb->width != crtc_state->mode.hdisplay ||include/drm/drm_modeset_helper_vtables.h +1
-1@@ -1020,7 +1020,7 @@ struct drm_connector_helper_funcs {* deadlock. */ int (*atomic_check)(struct drm_connector *connector, -struct drm_connector_state *state); +struct drm_atomic_state *state);Quoted 2 lines
Quoted 2 lines
include/drm/drm_modeset_helper_vtables.h struct drm_connector_helper_funcs { · line 1026
Quoted 2 lines
include/drm/drm_modeset_helper_vtables.h +0
-0/** * @atomic_commit: --
Regards,Laurent Pinchart
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH v3 04/10] drm: Convert connector_helper_funcs->atomic_check to accept drm_atomic_state
Quoted 32 lines · Daniel Vetter
Quoted 30 lines · Laurent Pinchart
Hi Daniel,
Quoted 15 lines · Daniel Vetter
Quoted 8 lines · Laurent Pinchart
Quoted 7 lines · Sean Paul
From: Sean Paul <[email protected]>
Everyone who implements
connector_helper_funcs->atomic_checkreaches into the connector state to get the atomic state. Instead of continuing this pattern, change the callback signature to just give atomic state and let the driver determine what it does and does not need from it.Quoted 5 lines
Quoted 2 lines
Eventually all atomic functions should do this, but that's just too much busy work for me.
Given that drivers also access the connector state, isn't this slightly more inefficient ?
Quoted 7 lines
It's atomic code, we're trying to optimize for clean code at the expense of a bit of runtime overhead due to more pointer chasing. And I agree with the general push, the pile of old/new_state pointers of various objects we're passing around is confusing. Passing the overall
drm_atomic_stateseems much more reasonable, and with that we can get everything else. Plus it's much more obvious whether you have the old/new state (since that's explicit when you look it up from thedrm_atomic_state).Yes, I agree it's cleaner. I just hope the atomic state tracking cost can be kept under control :-)
Quoted 7 lines
Quoted 5 lines
By the way, this is likely not going to happen as it would be way too intrusive, but it would be nice to rename
drm_atomic_statetodrm_atomic_transaction(or something similar). It doesn't model a state, but a change between an old state to a new state. This confused me in the past, and I'm sure it can still be confusing to newcomers.Why are you the first to suggest this, this is awesome!
Can't quite tell if that's irony or not. Anyways, this has been suggested before but no volunteers stepped forward.
Quoted 2 lines
drm_atomic_stateis indeed not a state, but a transaction representing how we go from the old to the new state.
On a semi-related topic, I've occasionally pondered about moving mode_changed & co. from the obj states to the top level state/transaction (maybe stored as a bitmask). But that would definitely not be a trivial sed job.
Signature · 6 lines
Ville Syrjälä Intel _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 04/10] drm: Convert connector_helper_funcs->atomic_check to accept drm_atomic_state
In reply to Laurent PinchartQuoted 18 lines · Laurent Pinchart
Hi Sean,
Quoted 15 lines · Sean Paul
Quoted 13 lines · Laurent Pinchart
Quoted 9 lines · Sean Paul
From: Sean Paul <[email protected]>
Everyone who implements
connector_helper_funcs->atomic_checkreaches into the connector state to get the atomic state. Instead of continuing this pattern, change the callback signature to just give atomic state and let the driver determine what it does and does not need from it.Eventually all atomic functions should do this, but that's just too much busy work for me.
Given that drivers also access the connector state, isn't this slightly more inefficient ?
Quoted 7 lines
Quoted 1 line
Inefficient in terms of what?
In terms of the operation having to lookup the connector state, when the caller has it and can easily pass it. As Daniel commented, this may be the price to pay for a cleaner API, but I wonder how much overhead all the state tracking is costing.
It'd be interesting to quantify, but iirc the last time we benchmarked atomic check commits they were virtually free (~thousands/s).
Quoted 4 lines
Quoted 2 lines
Agree that in isolation this patch might seem unnecessary, but it ties in with the encoder and bridge CLs which accept
drm_atomic_stateinCLs ?
Googleism for patches, I usually catch these before sending... guess I missed one.
Sean
Quoted 282 lines
Quoted 277 lines
their hooks. In general the idea is to convert all atomic functions to take overall atomic state instead of just their object state. Reality has proven to be more complicated and we need more access than what the current implementation provides.
Sean
Quoted 269 lines
Quoted 269 lines
Changes in v3:
- Added to the setCc Daniel Vetter <[email protected]>Cc Ville Syrjälä <[email protected]>Cc Jani Nikula <[email protected]>Cc Joonas Lahtinen <[email protected]>Cc Rodrigo Vivi <[email protected]>Cc Ben Skeggs <[email protected]>Cc Laurent Pinchart <[email protected]>Cc Kieran Bingham <[email protected]>Cc Eric Anholt <[email protected]>Signed-off-by Sean Paul <[email protected]>--- drivers/gpu/drm/drm_atomic_helper.c | 4 ++-- drivers/gpu/drm/i915/intel_atomic.c | 8 +++++--- drivers/gpu/drm/i915/intel_dp_mst.c | 7 ++++--- drivers/gpu/drm/i915/intel_drv.h | 2 +- drivers/gpu/drm/i915/intel_sdvo.c | 9 +++++---- drivers/gpu/drm/i915/intel_tv.c | 8 +++++--- drivers/gpu/drm/nouveau/dispnv50/disp.c | 5 +++-- drivers/gpu/drm/rcar-du/rcar_lvds.c | 12 +++++++----- drivers/gpu/drm/vc4/vc4_txp.c | 7 ++++--- include/drm/drm_modeset_helper_vtables.h | 2 +- 10 files changed, 37 insertions(+), 27 deletions(-)drivers/gpu/drm/drm_atomic_helper.c +2
-2@@ -683,7 +683,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev, }if (funcs->atomic_check) - ret = funcs->atomic_check (connector, new_connector_state); + ret = funcs->atomic_check (connector, state);if (ret)return ret;@@ -725,7 +725,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,continue ;if (funcs->atomic_check) - ret = funcs->atomic_check (connector, new_connector_state); + ret = funcs->atomic_check (connector, state);if (ret)return ret; }drivers/gpu/drm/i915/intel_atomic.c +5
-3@@ -103,12 +103,14 @@ int intel_digital_connector_atomic_set_property(struct drm_connector *connector, }int intel_digital_connector_atomic_check (struct drm_connector *conn, -struct drm_connector_state *new_state) +struct drm_atomic_state *state) { +struct drm_connector_state *new_state = +drm_atomic_get_new_connector_state (state, conn);struct intel_digital_connector_state *new_conn_state =to_intel_digital_connector_state (new_state);struct drm_connector_state *old_state = -drm_atomic_get_old_connector_state (new_state->state, conn); +drm_atomic_get_old_connector_state (state, conn);struct intel_digital_connector_state *old_conn_state =to_intel_digital_connector_state (old_state);struct drm_crtc_state *crtc_state;@@ -118,7 +120,7 @@ int intel_digital_connector_atomic_check(struct drm_connector *conn,if (!new_state->crtc)return 0 ; - crtc_state =drm_atomic_get_new_crtc_state (new_state->state, new_state->crtc); + crtc_state =drm_atomic_get_new_crtc_state (state, new_state->crtc);/* * These properties are handled by fastset, and might not end drivers/gpu/drm/i915/intel_dp_mst.c +4
-3@@ -143,9 +143,10 @@ static int intel_dp_mst_compute_config(struct intel_encoder *encoder,static int intel_dp_mst_atomic_check (struct drm_connector *connector, -struct drm_connector_state *new_conn_state) +struct drm_atomic_state *state) { -struct drm_atomic_state *state = new_conn_state->state; +struct drm_connector_state *new_conn_state = +drm_atomic_get_new_connector_state (state, connector);struct drm_connector_state *old_conn_state =drm_atomic_get_old_connector_state (state, connector); struct intel_connector *intel_connector =@@ -155,7 +156,7 @@ intel_dp_mst_atomic_check(struct drm_connector *connector,struct drm_dp_mst_topology_mgr *mgr;int ret; - ret =intel_digital_connector_atomic_check (connector, new_conn_state); + ret =intel_digital_connector_atomic_check (connector, state);if (ret)return ret;drivers/gpu/drm/i915/intel_drv.h +1
-1@@ -2481,7 +2481,7 @@ int intel_digital_connector_atomic_set_property(struct drm_connector *connector,struct drm_property *property, u64 val);int intel_digital_connector_atomic_check (struct drm_connector *conn, -struct drm_connector_state *new_state); +struct drm_atomic_state *state);struct drm_connector_state *intel_digital_connector_duplicate_state (struct drm_connector *connector);drivers/gpu/drm/i915/intel_sdvo.c +5
-4@@ -2342,9 +2342,10 @@ static const struct drm_connector_funcs intel_sdvo_connector_funcs = { };static int intel_sdvo_atomic_check (struct drm_connector *conn, -struct drm_connector_state *new_conn_state) +struct drm_atomic_state *state) { -struct drm_atomic_state *state = new_conn_state->state; +struct drm_connector_state *new_conn_state = +drm_atomic_get_new_connector_state (state, conn);struct drm_connector_state *old_conn_state =drm_atomic_get_old_connector_state (state, conn); struct intel_sdvo_connector_state *old_state =@@ -2356,13 +2357,13 @@ static int intel_sdvo_atomic_check(struct drm_connector *conn, (memcmp(&old_state->tv, &new_state->tv, sizeof(old_state->tv)) || memcmp(&old_conn_state->tv, &new_conn_state->tv, sizeof(old_conn_state->tv)))) {struct drm_crtc_state *crtc_state = -drm_atomic_get_new_crtc_state (new_conn_state->state, +drm_atomic_get_new_crtc_state (state, new_conn_state->crtc); crtc_state->connectors_changed = true; } -return intel_digital_connector_atomic_check (conn, new_conn_state); +return intel_digital_connector_atomic_check (conn, state); }static const struct drm_connector_helper_funcs intel_sdvo_connector_helper_funcs = {drivers/gpu/drm/i915/intel_tv.c +5
-3@@ -1817,16 +1817,18 @@ static const struct drm_connector_funcs intel_tv_connector_funcs = { };static int intel_tv_atomic_check (struct drm_connector *connector, -struct drm_connector_state *new_state) +struct drm_atomic_state *state) { +struct drm_connector_state *new_state;struct drm_crtc_state *new_crtc_state;struct drm_connector_state *old_state; + new_state =drm_atomic_get_new_connector_state (state, connector);if (!new_state->crtc)return 0 ; - old_state =drm_atomic_get_old_connector_state (new_state->state, connector); - new_crtc_state =drm_atomic_get_new_crtc_state (new_state->state, new_state->crtc); + old_state =drm_atomic_get_old_connector_state (state, connector); + new_crtc_state =drm_atomic_get_new_crtc_state (state, new_state->crtc); if (old_state->tv.mode != new_state->tv.mode || old_state->tv.margins.left != new_state->tv.margins.left ||drivers/gpu/drm/nouveau/dispnv50/disp.c +3
-2@@ -948,11 +948,12 @@ nv50_mstc_get_modes(struct drm_connector *connector)static int nv50_mstc_atomic_check (struct drm_connector *connector, -struct drm_connector_state *new_conn_state) +struct drm_atomic_state *state) { -struct drm_atomic_state *state = new_conn_state->state;struct nv50_mstc *mstc =nv50_mstc (connector);struct drm_dp_mst_topology_mgr *mgr = &mstc->mstm->mgr; +struct drm_connector_state *new_conn_state = +drm_atomic_get_new_connector_state (state, connector);struct drm_connector_state *old_conn_state =drm_atomic_get_old_connector_state (state, connector);struct drm_crtc_state *crtc_state;drivers/gpu/drm/rcar-du/rcar_lvds.c +7
-5@@ -92,13 +92,15 @@ static int rcar_lvds_connector_get_modes(struct drm_connector *connector) }static int rcar_lvds_connector_atomic_check (struct drm_connector *connector, -struct drm_connector_state *state) +struct drm_atomic_state *state) {struct rcar_lvds *lvds =connector_to_rcar_lvds (connector);const struct drm_display_mode *panel_mode; +struct drm_connector_state *conn_state;struct drm_crtc_state *crtc_state; -if (!state->crtc) + conn_state =drm_atomic_get_new_connector_state (state, connector); +if (!conn_state->crtc)return 0 ;if (list_empty (&connector->modes)) {@@ -110,9 +112,9 @@ static int rcar_lvds_connector_atomic_check(struct drm_connector *connector, struct drm_display_mode, head);/* We're not allowed to modify the resolution. */ - crtc_state =drm_atomic_get_crtc_state (state->state, state->crtc); -if (IS_ERR (crtc_state)) -return PTR_ERR (crtc_state); + crtc_state =drm_atomic_get_crtc_state (state, conn_state->crtc); +if (!crtc_state) +return -EINVAL ;if (crtc_state->mode.hdisplay != panel_mode->hdisplay || crtc_state->mode.vdisplay != panel_mode->vdisplay)drivers/gpu/drm/vc4/vc4_txp.c +4
-3@@ -221,17 +221,18 @@ static const u32 txp_fmts[] = { };static int vc4_txp_connector_atomic_check (struct drm_connector *conn, -struct drm_connector_state *conn_state) +struct drm_atomic_state *state) { +struct drm_connector_state *conn_state;struct drm_crtc_state *crtc_state;struct drm_framebuffer *fb;int i; + conn_state =drm_atomic_get_new_connector_state (state, conn);if (!conn_state->writeback_job || !conn_state->writeback_job->fb)return 0 ; - crtc_state =drm_atomic_get_new_crtc_state (conn_state->state, - conn_state->crtc); + crtc_state =drm_atomic_get_new_crtc_state (state, conn_state->crtc); fb = conn_state->writeback_job->fb; if (fb->width != crtc_state->mode.hdisplay ||include/drm/drm_modeset_helper_vtables.h +1
-1@@ -1020,7 +1020,7 @@ struct drm_connector_helper_funcs {* deadlock. */ int (*atomic_check)(struct drm_connector *connector, -struct drm_connector_state *state); +struct drm_atomic_state *state);/** * @atomic_commit: Signature · 3 lines
Regards, Laurent Pinchart
Signature · 1 line
Sean Paul, Software Engineer, Google / Chromium OS