disp: msm: adapt crtc plane and connector atomic functions for multiple SIs

Commit ddac29b ("disp: msm: Pass the full state to crtc plane and connector
atomic functions") pass full state to crtc, plane, and connector atomic
functions and retrieve drm_crtc/plane/connector_state within the atomic
function.
This change puts macros in the callers of atomic functions to handle API
changes between kernel version 5.10 and version 5.15.

Change-Id: I8e710e33f0a149bbfaa54820a7174a05810e2da4
Signed-off-by: Bruce Hoo <bingchua@codeaurora.org>
This commit is contained in:
Bruce Hoo
2021-11-10 12:32:46 +08:00
parent a7ee8c6b1e
commit 773b0e5b64
4 changed files with 58 additions and 0 deletions

View File

@@ -17,6 +17,7 @@
*/ */
#include <drm/drm_panel.h> #include <drm/drm_panel.h>
#include <drm/drm_vblank.h> #include <drm/drm_vblank.h>
#include <linux/version.h>
#include "msm_drv.h" #include "msm_drv.h"
#include "msm_gem.h" #include "msm_gem.h"
@@ -419,7 +420,11 @@ static void msm_atomic_helper_commit_modeset_enables(struct drm_device *dev,
crtc->base.id); crtc->base.id);
if (funcs->atomic_enable) if (funcs->atomic_enable)
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0))
funcs->atomic_enable(crtc, old_state); funcs->atomic_enable(crtc, old_state);
#else
funcs->atomic_enable(crtc, old_crtc_state);
#endif
else else
funcs->commit(crtc); funcs->commit(crtc);
} }

View File

@@ -19,6 +19,7 @@
#include "sde_rm.h" #include "sde_rm.h"
#include "sde_vm.h" #include "sde_vm.h"
#include <drm/drm_probe_helper.h> #include <drm/drm_probe_helper.h>
#include <linux/version.h>
#define BL_NODE_NAME_SIZE 32 #define BL_NODE_NAME_SIZE 32
#define HDR10_PLUS_VSIF_TYPE_CODE 0x81 #define HDR10_PLUS_VSIF_TYPE_CODE 0x81
@@ -2618,14 +2619,22 @@ sde_connector_best_encoder(struct drm_connector *connector)
return c_conn->encoder; return c_conn->encoder;
} }
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0))
static struct drm_encoder * static struct drm_encoder *
sde_connector_atomic_best_encoder(struct drm_connector *connector, sde_connector_atomic_best_encoder(struct drm_connector *connector,
struct drm_atomic_state *state) struct drm_atomic_state *state)
#else
static struct drm_encoder *
sde_connector_atomic_best_encoder(struct drm_connector *connector,
struct drm_connector_state *connector_state)
#endif
{ {
struct sde_connector *c_conn; struct sde_connector *c_conn;
struct drm_encoder *encoder = NULL; struct drm_encoder *encoder = NULL;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0))
struct drm_connector_state *connector_state = struct drm_connector_state *connector_state =
drm_atomic_get_new_connector_state(state, connector); drm_atomic_get_new_connector_state(state, connector);
#endif
if (!connector) { if (!connector) {
SDE_ERROR("invalid connector\n"); SDE_ERROR("invalid connector\n");

View File

@@ -26,6 +26,7 @@
#include <drm/drm_probe_helper.h> #include <drm/drm_probe_helper.h>
#include <drm/drm_flip_work.h> #include <drm/drm_flip_work.h>
#include <soc/qcom/of_common.h> #include <soc/qcom/of_common.h>
#include <linux/version.h>
#include "sde_kms.h" #include "sde_kms.h"
#include "sde_hw_lm.h" #include "sde_hw_lm.h"
@@ -3528,8 +3529,13 @@ static void _sde_crtc_clear_all_blend_stages(struct sde_crtc *sde_crtc)
} }
} }
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0))
static void sde_crtc_atomic_begin(struct drm_crtc *crtc, static void sde_crtc_atomic_begin(struct drm_crtc *crtc,
struct drm_atomic_state *state) struct drm_atomic_state *state)
#else
static void sde_crtc_atomic_begin(struct drm_crtc *crtc,
struct drm_crtc_state *old_state)
#endif
{ {
struct sde_crtc *sde_crtc; struct sde_crtc *sde_crtc;
struct drm_encoder *encoder; struct drm_encoder *encoder;
@@ -3538,7 +3544,9 @@ static void sde_crtc_atomic_begin(struct drm_crtc *crtc,
struct sde_splash_display *splash_display; struct sde_splash_display *splash_display;
bool cont_splash_enabled = false; bool cont_splash_enabled = false;
size_t i; size_t i;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0))
struct drm_crtc_state *old_state = drm_atomic_get_new_crtc_state(state, crtc); struct drm_crtc_state *old_state = drm_atomic_get_new_crtc_state(state, crtc);
#endif
if (!crtc) { if (!crtc) {
SDE_ERROR("invalid crtc\n"); SDE_ERROR("invalid crtc\n");
@@ -3631,8 +3639,13 @@ end:
SDE_ATRACE_END("crtc_atomic_begin"); SDE_ATRACE_END("crtc_atomic_begin");
} }
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0))
static void sde_crtc_atomic_flush(struct drm_crtc *crtc, static void sde_crtc_atomic_flush(struct drm_crtc *crtc,
struct drm_atomic_state *state) struct drm_atomic_state *state)
#else
static void sde_crtc_atomic_flush(struct drm_crtc *crtc,
struct drm_crtc_state *old_crtc_state)
#endif
{ {
struct drm_encoder *encoder; struct drm_encoder *encoder;
struct sde_crtc *sde_crtc; struct sde_crtc *sde_crtc;
@@ -4599,8 +4612,13 @@ static void sde_crtc_disable(struct drm_crtc *crtc)
mutex_unlock(&sde_crtc->crtc_lock); mutex_unlock(&sde_crtc->crtc_lock);
} }
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0))
static void sde_crtc_enable(struct drm_crtc *crtc, static void sde_crtc_enable(struct drm_crtc *crtc,
struct drm_atomic_state *old_state) struct drm_atomic_state *old_state)
#else
static void sde_crtc_enable(struct drm_crtc *crtc,
struct drm_crtc_state *old_crtc_state)
#endif
{ {
struct sde_crtc *sde_crtc; struct sde_crtc *sde_crtc;
struct drm_encoder *encoder; struct drm_encoder *encoder;
@@ -5347,8 +5365,13 @@ static int _sde_crtc_check_plane_layout(struct drm_crtc *crtc,
return 0; return 0;
} }
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0))
static int sde_crtc_atomic_check(struct drm_crtc *crtc, static int sde_crtc_atomic_check(struct drm_crtc *crtc,
struct drm_atomic_state *atomic_state) struct drm_atomic_state *atomic_state)
#else
static int sde_crtc_atomic_check(struct drm_crtc *crtc,
struct drm_crtc_state *state)
#endif
{ {
struct drm_device *dev; struct drm_device *dev;
struct sde_crtc *sde_crtc; struct sde_crtc *sde_crtc;
@@ -5359,7 +5382,9 @@ static int sde_crtc_atomic_check(struct drm_crtc *crtc,
struct sde_multirect_plane_states *multirect_plane = NULL; struct sde_multirect_plane_states *multirect_plane = NULL;
struct drm_connector *conn; struct drm_connector *conn;
struct drm_connector_list_iter conn_iter; struct drm_connector_list_iter conn_iter;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0))
struct drm_crtc_state *state = drm_atomic_get_new_crtc_state(atomic_state, crtc); struct drm_crtc_state *state = drm_atomic_get_new_crtc_state(atomic_state, crtc);
#endif
if (!crtc) { if (!crtc) {
SDE_ERROR("invalid crtc\n"); SDE_ERROR("invalid crtc\n");

View File

@@ -22,6 +22,7 @@
#include <linux/dma-buf.h> #include <linux/dma-buf.h>
#include <drm/sde_drm.h> #include <drm/sde_drm.h>
#include <drm/msm_drm_pp.h> #include <drm/msm_drm_pp.h>
#include <linux/version.h>
#include "msm_prop.h" #include "msm_prop.h"
#include "msm_drv.h" #include "msm_drv.h"
@@ -2703,13 +2704,20 @@ modeset_update:
return ret; return ret;
} }
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0))
static int sde_plane_atomic_check(struct drm_plane *plane, static int sde_plane_atomic_check(struct drm_plane *plane,
struct drm_atomic_state *atomic_state) struct drm_atomic_state *atomic_state)
#else
static int sde_plane_atomic_check(struct drm_plane *plane,
struct drm_plane_state *state)
#endif
{ {
int ret = 0; int ret = 0;
struct sde_plane *psde; struct sde_plane *psde;
struct sde_plane_state *pstate; struct sde_plane_state *pstate;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0))
struct drm_plane_state *state = drm_atomic_get_new_plane_state(atomic_state, plane); struct drm_plane_state *state = drm_atomic_get_new_plane_state(atomic_state, plane);
#endif
if (!plane || !state) { if (!plane || !state) {
SDE_ERROR("invalid arg(s), plane %d state %d\n", SDE_ERROR("invalid arg(s), plane %d state %d\n",
@@ -3389,8 +3397,13 @@ static void _sde_plane_atomic_disable(struct drm_plane *plane,
multirect_index, SDE_SSPP_MULTIRECT_TIME_MX); multirect_index, SDE_SSPP_MULTIRECT_TIME_MX);
} }
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0))
static void _sde_plane_atomic_update(struct drm_plane *plane, static void _sde_plane_atomic_update(struct drm_plane *plane,
struct drm_plane_state *old_state) struct drm_plane_state *old_state)
#else
static void sde_plane_atomic_update(struct drm_plane *plane,
struct drm_plane_state *old_state)
#endif
{ {
struct sde_plane *psde; struct sde_plane *psde;
struct drm_plane_state *state; struct drm_plane_state *state;
@@ -3420,6 +3433,7 @@ static void _sde_plane_atomic_update(struct drm_plane *plane,
} }
} }
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0))
static void sde_plane_atomic_update(struct drm_plane *plane, static void sde_plane_atomic_update(struct drm_plane *plane,
struct drm_atomic_state *atomic_state) struct drm_atomic_state *atomic_state)
{ {
@@ -3427,6 +3441,7 @@ static void sde_plane_atomic_update(struct drm_plane *plane,
_sde_plane_atomic_update(plane, old_state); _sde_plane_atomic_update(plane, old_state);
} }
#endif
void sde_plane_restore(struct drm_plane *plane) void sde_plane_restore(struct drm_plane *plane)
{ {
@@ -3449,7 +3464,11 @@ void sde_plane_restore(struct drm_plane *plane)
SDE_DEBUG_PLANE(psde, "\n"); SDE_DEBUG_PLANE(psde, "\n");
/* last plane state is same as current state */ /* last plane state is same as current state */
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0))
_sde_plane_atomic_update(plane, plane->state); _sde_plane_atomic_update(plane, plane->state);
#else
sde_plane_atomic_update(plane, plane->state);
#endif
} }
bool sde_plane_is_cache_required(struct drm_plane *plane, bool sde_plane_is_cache_required(struct drm_plane *plane,