rockchip/drm: drv: use upstream method to get crtc for encoder

Here are exist a drm framework api to get crtc for encoder. It's
better to use drm framework api which will also reduce work when
kernel upgrade in the future. To compatible with GKI, moving these
api in the rockchip_drm_drv.c.

The upstream commit has been merge in linux kernel 6.4 and the
commit info as follow:
Commit: 7b9a9e35e4 ("drm: add helper functions to retrieve old and new crtc")
Patchwork: https://patchwork.freedesktop.org/patch/524718/
Link: https://lore.kernel.org/r/1677774797-31063-2-git-send-email-quic_vpolimer@quicinc.com

Change-Id: I1d36e22e3389a372e5aadbf8d55410c643f2a005
Signed-off-by: Zhang Yubing <yubing.zhang@rock-chips.com>
This commit is contained in:
Zhang Yubing
2025-01-25 09:42:18 +08:00
committed by Tao Huang
parent 4cb1325d1a
commit 5209cde33a
4 changed files with 30 additions and 44 deletions

View File

@@ -2931,8 +2931,8 @@ static void dw_dp_encoder_atomic_disable(struct drm_encoder *encoder,
struct drm_crtc *old_crtc, *new_crtc;
struct rockchip_crtc_state *s;
old_crtc = rockchip_drm_encoder_get_old_crtc(encoder, state);
new_crtc = rockchip_drm_encoder_get_new_crtc(encoder, state);
old_crtc = drm_atomic_get_old_crtc_for_encoder(state, encoder);
new_crtc = drm_atomic_get_new_crtc_for_encoder(state, encoder);
if (old_crtc && old_crtc != new_crtc) {
s = to_rockchip_crtc_state(old_crtc->state);

View File

@@ -1945,8 +1945,8 @@ static void dw_hdmi_rockchip_encoder_atomic_disable(struct drm_encoder *encoder,
struct drm_crtc *old_crtc, *new_crtc;
struct rockchip_crtc_state *s;
old_crtc = rockchip_drm_encoder_get_old_crtc(encoder, state);
new_crtc = rockchip_drm_encoder_get_new_crtc(encoder, state);
old_crtc = drm_atomic_get_old_crtc_for_encoder(state, encoder);
new_crtc = drm_atomic_get_new_crtc_for_encoder(state, encoder);
if (old_crtc && old_crtc != new_crtc) {
s = to_rockchip_crtc_state(old_crtc->state);

View File

@@ -473,57 +473,43 @@ void rockchip_drm_te_handle(struct drm_crtc *crtc)
}
EXPORT_SYMBOL(rockchip_drm_te_handle);
struct drm_crtc *rockchip_drm_encoder_get_old_crtc(struct drm_encoder *encoder,
struct drm_atomic_state *state)
struct drm_crtc *
drm_atomic_get_old_crtc_for_encoder(struct drm_atomic_state *state,
struct drm_encoder *encoder)
{
struct drm_device *drm_dev = state->dev;
struct drm_connector *connector;
struct drm_connector_list_iter conn_iter;
struct drm_connector_state *conn_state;
drm_connector_list_iter_begin(drm_dev, &conn_iter);
drm_for_each_connector_iter(connector, &conn_iter) {
conn_state = drm_atomic_get_old_connector_state(state, connector);
if (!conn_state)
continue;
connector = drm_atomic_get_old_connector_for_encoder(state, encoder);
if (!connector)
return NULL;
if (conn_state->best_encoder != encoder)
continue;
conn_state = drm_atomic_get_old_connector_state(state, connector);
if (!conn_state)
return NULL;
drm_connector_list_iter_end(&conn_iter);
return conn_state->crtc;
}
drm_connector_list_iter_end(&conn_iter);
return NULL;
return conn_state->crtc;
}
EXPORT_SYMBOL(rockchip_drm_encoder_get_old_crtc);
EXPORT_SYMBOL(drm_atomic_get_old_crtc_for_encoder);
struct drm_crtc *rockchip_drm_encoder_get_new_crtc(struct drm_encoder *encoder,
struct drm_atomic_state *state)
struct drm_crtc *
drm_atomic_get_new_crtc_for_encoder(struct drm_atomic_state *state,
struct drm_encoder *encoder)
{
struct drm_device *drm_dev = state->dev;
struct drm_connector *connector;
struct drm_connector_list_iter conn_iter;
struct drm_connector_state *conn_state;
drm_connector_list_iter_begin(drm_dev, &conn_iter);
drm_for_each_connector_iter(connector, &conn_iter) {
conn_state = drm_atomic_get_new_connector_state(state, connector);
if (!conn_state)
continue;
connector = drm_atomic_get_new_connector_for_encoder(state, encoder);
if (!connector)
return NULL;
if (conn_state->best_encoder != encoder)
continue;
conn_state = drm_atomic_get_new_connector_state(state, connector);
if (!conn_state)
return NULL;
drm_connector_list_iter_end(&conn_iter);
return conn_state->crtc;
}
drm_connector_list_iter_end(&conn_iter);
return NULL;
return conn_state->crtc;
}
EXPORT_SYMBOL(rockchip_drm_encoder_get_new_crtc);
EXPORT_SYMBOL(drm_atomic_get_new_crtc_for_encoder);
static const struct drm_display_mode rockchip_drm_default_modes[] = {
/* 4 - 1280x720@60Hz 16:9 */

View File

@@ -634,10 +634,10 @@ void rockchip_drm_unregister_sub_dev(struct rockchip_drm_sub_dev *sub_dev);
struct rockchip_drm_sub_dev *rockchip_drm_get_sub_dev(struct device_node *node);
int rockchip_drm_add_modes_noedid(struct drm_connector *connector);
void rockchip_drm_te_handle(struct drm_crtc *crtc);
struct drm_crtc *rockchip_drm_encoder_get_old_crtc(struct drm_encoder *encoder,
struct drm_atomic_state *state);
struct drm_crtc *rockchip_drm_encoder_get_new_crtc(struct drm_encoder *encoder,
struct drm_atomic_state *state);
struct drm_crtc *drm_atomic_get_old_crtc_for_encoder(struct drm_atomic_state *state,
struct drm_encoder *encoder);
struct drm_crtc *drm_atomic_get_new_crtc_for_encoder(struct drm_atomic_state *state,
struct drm_encoder *encoder);
void drm_mode_convert_to_split_mode(struct drm_display_mode *mode);
void drm_mode_convert_to_origin_mode(struct drm_display_mode *mode);
const char *rockchip_drm_get_color_encoding_name(enum drm_color_encoding encoding);