diff options
author | Jayaprakash <jmadiset@codeaurora.org> | 2020-12-16 12:50:32 +0530 |
---|---|---|
committer | Jayaprakash <jmadiset@codeaurora.org> | 2020-12-16 12:57:16 +0530 |
commit | f0e165a896b4ce26c5949265081a2aba31dbe93e (patch) | |
tree | e19a54343ae5551a6d73714135bbf256c63f1b72 | |
parent | a5efd1f0887f7f8e4286462df13123a0199b1c53 (diff) | |
download | display-drivers-f0e165a896b4ce26c5949265081a2aba31dbe93e.tar.gz |
disp: msm: sde: add helper function for setting crtc to conn state
Add changes to move the state operations for setting crtc to
connector state to a helper api. This can be reused during
preclose operation for issuing a drm commit.
Change-Id: I8daf4f2119c8d0e54c123a07255cb8119c2040ea
Signed-off-by: Jayaprakash <jmadiset@codeaurora.org>
-rw-r--r-- | msm/sde/sde_kms.c | 71 |
1 files changed, 42 insertions, 29 deletions
diff --git a/msm/sde/sde_kms.c b/msm/sde/sde_kms.c index 25a869fb..37be6817 100644 --- a/msm/sde/sde_kms.c +++ b/msm/sde/sde_kms.c @@ -2029,6 +2029,46 @@ static void sde_kms_destroy(struct msm_kms *kms) kfree(sde_kms); } +static int sde_kms_set_crtc_for_conn(struct drm_device *dev, + struct drm_encoder *enc, struct drm_atomic_state *state) +{ + struct drm_connector *conn = NULL; + struct drm_connector *tmp_conn = NULL; + struct drm_connector_list_iter conn_iter; + struct drm_crtc_state *crtc_state = NULL; + struct drm_connector_state *conn_state = NULL; + int ret = 0; + + drm_connector_list_iter_begin(dev, &conn_iter); + drm_for_each_connector_iter(tmp_conn, &conn_iter) { + if (enc == tmp_conn->state->best_encoder) { + conn = tmp_conn; + break; + } + } + drm_connector_list_iter_end(&conn_iter); + + if (!conn) { + SDE_ERROR("error in finding conn for enc:%d\n", DRMID(enc)); + return -EINVAL; + } + + crtc_state = drm_atomic_get_crtc_state(state, enc->crtc); + conn_state = drm_atomic_get_connector_state(state, conn); + if (IS_ERR(conn_state)) { + SDE_ERROR("error %d getting connector %d state\n", + ret, DRMID(conn)); + return -EINVAL; + } + + crtc_state->active = true; + ret = drm_atomic_set_crtc_for_connector(conn_state, enc->crtc); + if (ret) + SDE_ERROR("error %d setting the crtc\n", ret); + + return 0; +} + static void _sde_kms_plane_force_remove(struct drm_plane *plane, struct drm_atomic_state *state) { @@ -2744,12 +2784,7 @@ static void _sde_kms_null_commit(struct drm_device *dev, struct drm_encoder *enc) { struct drm_modeset_acquire_ctx ctx; - struct drm_connector *conn = NULL; - struct drm_connector *tmp_conn = NULL; - struct drm_connector_list_iter conn_iter; struct drm_atomic_state *state = NULL; - struct drm_crtc_state *crtc_state = NULL; - struct drm_connector_state *conn_state = NULL; int retry_cnt = 0; int ret = 0; @@ -2773,32 +2808,10 @@ retry: } state->acquire_ctx = &ctx; - drm_connector_list_iter_begin(dev, &conn_iter); - drm_for_each_connector_iter(tmp_conn, &conn_iter) { - if (enc == tmp_conn->state->best_encoder) { - conn = tmp_conn; - break; - } - } - drm_connector_list_iter_end(&conn_iter); - if (!conn) { - SDE_ERROR("error in finding conn for enc:%d\n", DRMID(enc)); - goto end; - } - - crtc_state = drm_atomic_get_crtc_state(state, enc->crtc); - conn_state = drm_atomic_get_connector_state(state, conn); - if (IS_ERR(conn_state)) { - SDE_ERROR("error %d getting connector %d state\n", - ret, DRMID(conn)); - goto end; - } - - crtc_state->active = true; - ret = drm_atomic_set_crtc_for_connector(conn_state, enc->crtc); + ret = sde_kms_set_crtc_for_conn(dev, enc, state); if (ret) - SDE_ERROR("error %d setting the crtc\n", ret); + goto end; ret = drm_atomic_commit(state); if (ret) |