@@ -42,6 +42,14 @@ static void armada_drm_slave_destroy(struct drm_encoder *enc)
kfree(slave);
}
+static void armada_drm_slave_mode_set(struct drm_encoder *encoder,
+ struct drm_display_mode *mode,
+ struct drm_display_mode *adjusted_mode)
+{
+ drm_i2c_encoder_mode_set(encoder, mode, adjusted_mode);
+}
+
+
static const struct drm_encoder_funcs armada_drm_slave_encoder_funcs = {
.destroy = armada_drm_slave_destroy,
};
@@ -59,7 +67,7 @@ static const struct drm_encoder_helper_funcs drm_slave_encoder_helpers = {
.mode_fixup = drm_i2c_encoder_mode_fixup,
.prepare = drm_i2c_encoder_prepare,
.commit = drm_i2c_encoder_commit,
- .mode_set = drm_i2c_encoder_mode_set,
+ .mode_set = armada_drm_slave_mode_set,
.detect = drm_i2c_encoder_detect,
};
@@ -157,8 +157,8 @@ void drm_i2c_encoder_commit(struct drm_encoder *encoder)
EXPORT_SYMBOL(drm_i2c_encoder_commit);
void drm_i2c_encoder_mode_set(struct drm_encoder *encoder,
- struct drm_display_mode *mode,
- struct drm_display_mode *adjusted_mode)
+ const struct drm_display_mode *mode,
+ const struct drm_display_mode *adjusted_mode)
{
get_slave_funcs(encoder)->mode_set(encoder, mode, adjusted_mode);
}
@@ -639,7 +639,7 @@ adv7511_encoder_detect(struct drm_encoder *encoder,
}
static int adv7511_encoder_mode_valid(struct drm_encoder *encoder,
- struct drm_display_mode *mode)
+ const struct drm_display_mode *mode)
{
if (mode->clock > 165000)
return MODE_CLOCK_HIGH;
@@ -648,8 +648,8 @@ static int adv7511_encoder_mode_valid(struct drm_encoder *encoder,
}
static void adv7511_encoder_mode_set(struct drm_encoder *encoder,
- struct drm_display_mode *mode,
- struct drm_display_mode *adj_mode)
+ const struct drm_display_mode *mode,
+ const struct drm_display_mode *adj_mode)
{
struct adv7511 *adv7511 = encoder_to_adv7511(encoder);
unsigned int low_refresh_rate;
@@ -102,7 +102,7 @@ static bool ch7006_encoder_mode_fixup(struct drm_encoder *encoder,
}
static int ch7006_encoder_mode_valid(struct drm_encoder *encoder,
- struct drm_display_mode *mode)
+ const struct drm_display_mode *mode)
{
if (ch7006_lookup_mode(encoder, mode))
return MODE_OK;
@@ -111,8 +111,8 @@ static int ch7006_encoder_mode_valid(struct drm_encoder *encoder,
}
static void ch7006_encoder_mode_set(struct drm_encoder *encoder,
- struct drm_display_mode *drm_mode,
- struct drm_display_mode *adjusted_mode)
+ const struct drm_display_mode *drm_mode,
+ const struct drm_display_mode *adjusted_mode)
{
struct i2c_client *client = drm_i2c_encoder_get_client(encoder);
struct ch7006_priv *priv = to_ch7006_priv(encoder);
@@ -262,7 +262,7 @@ sil164_encoder_mode_fixup(struct drm_encoder *encoder,
static int
sil164_encoder_mode_valid(struct drm_encoder *encoder,
- struct drm_display_mode *mode)
+ const struct drm_display_mode *mode)
{
struct sil164_priv *priv = to_sil164_priv(encoder);
@@ -278,8 +278,8 @@ sil164_encoder_mode_valid(struct drm_encoder *encoder,
static void
sil164_encoder_mode_set(struct drm_encoder *encoder,
- struct drm_display_mode *mode,
- struct drm_display_mode *adjusted_mode)
+ const struct drm_display_mode *mode,
+ const struct drm_display_mode *adjusted_mode)
{
struct sil164_priv *priv = to_sil164_priv(encoder);
bool duallink = adjusted_mode->clock > 165000;
@@ -632,7 +632,8 @@ tda998x_write_aif(struct tda998x_priv *priv, struct tda998x_encoder_params *p)
}
static void
-tda998x_write_avi(struct tda998x_priv *priv, struct drm_display_mode *mode)
+tda998x_write_avi(struct tda998x_priv *priv,
+ const struct drm_display_mode *mode)
{
u8 buf[PB(HDMI_AVI_INFOFRAME_SIZE) + 1];
@@ -662,7 +663,8 @@ static void tda998x_audio_mute(struct tda998x_priv *priv, bool on)
static void
tda998x_configure_audio(struct tda998x_priv *priv,
- struct drm_display_mode *mode, struct tda998x_encoder_params *p)
+ const struct drm_display_mode *mode,
+ struct tda998x_encoder_params *p)
{
uint8_t buf[6], clksel_aip, clksel_fs, cts_n, adiv;
uint32_t n;
@@ -825,7 +827,7 @@ tda998x_encoder_mode_fixup(struct drm_encoder *encoder,
}
static int tda998x_encoder_mode_valid(struct tda998x_priv *priv,
- struct drm_display_mode *mode)
+ const struct drm_display_mode *mode)
{
if (mode->clock > 150000)
return MODE_CLOCK_HIGH;
@@ -838,8 +840,8 @@ static int tda998x_encoder_mode_valid(struct tda998x_priv *priv,
static void
tda998x_encoder_mode_set(struct tda998x_priv *priv,
- struct drm_display_mode *mode,
- struct drm_display_mode *adjusted_mode)
+ const struct drm_display_mode *mode,
+ const struct drm_display_mode *adjusted_mode)
{
uint16_t ref_pix, ref_line, n_pix, n_line;
uint16_t hs_pix_s, hs_pix_e;
@@ -1176,15 +1178,15 @@ static void tda998x_encoder_slave_dpms(struct drm_encoder *encoder, int mode)
}
static int tda998x_encoder_slave_mode_valid(struct drm_encoder *encoder,
- struct drm_display_mode *mode)
+ const struct drm_display_mode *mode)
{
return tda998x_encoder_mode_valid(to_tda998x_priv(encoder), mode);
}
static void
tda998x_encoder_slave_mode_set(struct drm_encoder *encoder,
- struct drm_display_mode *mode,
- struct drm_display_mode *adjusted_mode)
+ const struct drm_display_mode *mode,
+ const struct drm_display_mode *adjusted_mode)
{
tda998x_encoder_mode_set(to_tda998x_priv(encoder), mode, adjusted_mode);
}
@@ -1280,7 +1280,7 @@ unlock_ret:
}
int msm_edp_ctrl_timing_cfg(struct edp_ctrl *ctrl,
- const struct drm_display_mode *mode,
+ const const struct drm_display_mode *mode,
const struct drm_display_info *info)
{
u32 hstart_from_sync, vstart_from_sync;
@@ -309,7 +309,7 @@ static int nv17_tv_get_modes(struct drm_encoder *encoder,
}
static int nv17_tv_mode_valid(struct drm_encoder *encoder,
- struct drm_display_mode *mode)
+ const struct drm_display_mode *mode)
{
struct nv17_tv_norm_params *tv_norm = get_tv_norm(encoder);
@@ -524,7 +524,7 @@ static void nv17_tv_mode_set(struct drm_encoder *encoder,
tv_regs->tv_enc[i] = tv_norm->tv_enc_mode.tv_enc[i];
} else {
- struct drm_display_mode *output_mode =
+ const struct drm_display_mode *output_mode =
&tv_norm->ctv_enc_mode.mode;
/* The registers in PRAMDAC+0xc00 control some timings and CSC
@@ -96,6 +96,12 @@ static bool slave_encoder_fixup(struct drm_encoder *encoder,
return drm_i2c_encoder_mode_fixup(encoder, mode, adjusted_mode);
}
+static void slave_encoder_mode_set(struct drm_encoder *encoder,
+ struct drm_display_mode *mode,
+ struct drm_display_mode *adjusted_mode)
+{
+ drm_i2c_encoder_mode_set(encoder, mode, adjusted_mode);
+}
static const struct drm_encoder_funcs slave_encoder_funcs = {
.destroy = slave_encoder_destroy,
@@ -106,7 +112,7 @@ static const struct drm_encoder_helper_funcs slave_encoder_helper_funcs = {
.mode_fixup = slave_encoder_fixup,
.prepare = slave_encoder_prepare,
.commit = drm_i2c_encoder_commit,
- .mode_set = drm_i2c_encoder_mode_set,
+ .mode_set = slave_encoder_mode_set,
.save = drm_i2c_encoder_save,
.restore = drm_i2c_encoder_restore,
};
@@ -57,10 +57,10 @@ struct drm_encoder_slave_funcs {
const struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode);
int (*mode_valid)(struct drm_encoder *encoder,
- struct drm_display_mode *mode);
+ const struct drm_display_mode *mode);
void (*mode_set)(struct drm_encoder *encoder,
- struct drm_display_mode *mode,
- struct drm_display_mode *adjusted_mode);
+ const struct drm_display_mode *mode,
+ const struct drm_display_mode *adjusted_mode);
enum drm_connector_status (*detect)(struct drm_encoder *encoder,
struct drm_connector *connector);
@@ -171,8 +171,8 @@ bool drm_i2c_encoder_mode_fixup(struct drm_encoder *encoder,
void drm_i2c_encoder_prepare(struct drm_encoder *encoder);
void drm_i2c_encoder_commit(struct drm_encoder *encoder);
void drm_i2c_encoder_mode_set(struct drm_encoder *encoder,
- struct drm_display_mode *mode,
- struct drm_display_mode *adjusted_mode);
+ const struct drm_display_mode *mode,
+ const struct drm_display_mode *adjusted_mode);
enum drm_connector_status drm_i2c_encoder_detect(struct drm_encoder *encoder,
struct drm_connector *connector);
void drm_i2c_encoder_save(struct drm_encoder *encoder);
Enforce the existing rules on when modes can be modified (never modify the passed-in mode; only modify adjusted_mode in mode_fixup), by adding const. tilcdc gains an interim helper function, as it registers an encoder mode_set (as yet non-const), which directly calls the slave helper (newly const). This can disappear when normal encoder functions gain constness. Signed-off-by: Daniel Stone <daniels@collabora.com> --- drivers/gpu/drm/armada/armada_slave.c | 10 +++++++++- drivers/gpu/drm/drm_encoder_slave.c | 4 ++-- drivers/gpu/drm/i2c/adv7511.c | 6 +++--- drivers/gpu/drm/i2c/ch7006_drv.c | 6 +++--- drivers/gpu/drm/i2c/sil164_drv.c | 6 +++--- drivers/gpu/drm/i2c/tda998x_drv.c | 18 ++++++++++-------- drivers/gpu/drm/msm/edp/edp_ctrl.c | 2 +- drivers/gpu/drm/nouveau/dispnv04/tvnv17.c | 4 ++-- drivers/gpu/drm/tilcdc/tilcdc_slave.c | 8 +++++++- include/drm/drm_encoder_slave.h | 10 +++++----- 10 files changed, 45 insertions(+), 29 deletions(-)