Commit b0febde7 authored by Jose Abreu's avatar Jose Abreu Committed by Archit Taneja

drm/bridge/synopsys: dw-hdmi: Use bridge->mode_valid() callback

Now that we have a callback to check if bridge supports a given mode
we can use it in Synopsys Designware HDMI bridge so that we restrict
the number of probbed modes to the ones we can actually display.

Also, there is no need to use mode_fixup() callback as mode_valid()
will handle the mode validation.

NOTE: I also had to change the pdata declaration of mode_valid
custom callback so that the passed modes are const. I also changed
in the platforms I found. Not even compiled it though.
Signed-off-by: default avatarJose Abreu <joabreu@synopsys.com>
Acked-by: default avatarNeil Armstrong <narmstrong@baylibre.com>
Acked-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
Cc: Carlos Palminha <palminha@synopsys.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Archit Taneja <architt@codeaurora.org>
Cc: Andrzej Hajda <a.hajda@samsung.com>
Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Carlo Caione <carlo@caione.org>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Mark Yao <mark.yao@rock-chips.com>
Cc: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: default avatarArchit Taneja <architt@codeaurora.org>
Link: http://patchwork.freedesktop.org/patch/msgid/3d8d449e4d13d2535fa292c75f5fa931de4a4fa8.1495720737.git.joabreu@synopsys.com
parent f3ca01d3
...@@ -1907,24 +1907,6 @@ static int dw_hdmi_connector_get_modes(struct drm_connector *connector) ...@@ -1907,24 +1907,6 @@ static int dw_hdmi_connector_get_modes(struct drm_connector *connector)
return ret; return ret;
} }
static enum drm_mode_status
dw_hdmi_connector_mode_valid(struct drm_connector *connector,
struct drm_display_mode *mode)
{
struct dw_hdmi *hdmi = container_of(connector,
struct dw_hdmi, connector);
enum drm_mode_status mode_status = MODE_OK;
/* We don't support double-clocked modes */
if (mode->flags & DRM_MODE_FLAG_DBLCLK)
return MODE_BAD;
if (hdmi->plat_data->mode_valid)
mode_status = hdmi->plat_data->mode_valid(connector, mode);
return mode_status;
}
static void dw_hdmi_connector_force(struct drm_connector *connector) static void dw_hdmi_connector_force(struct drm_connector *connector)
{ {
struct dw_hdmi *hdmi = container_of(connector, struct dw_hdmi, struct dw_hdmi *hdmi = container_of(connector, struct dw_hdmi,
...@@ -1950,7 +1932,6 @@ static const struct drm_connector_funcs dw_hdmi_connector_funcs = { ...@@ -1950,7 +1932,6 @@ static const struct drm_connector_funcs dw_hdmi_connector_funcs = {
static const struct drm_connector_helper_funcs dw_hdmi_connector_helper_funcs = { static const struct drm_connector_helper_funcs dw_hdmi_connector_helper_funcs = {
.get_modes = dw_hdmi_connector_get_modes, .get_modes = dw_hdmi_connector_get_modes,
.mode_valid = dw_hdmi_connector_mode_valid,
.best_encoder = drm_atomic_helper_best_encoder, .best_encoder = drm_atomic_helper_best_encoder,
}; };
...@@ -1973,18 +1954,22 @@ static int dw_hdmi_bridge_attach(struct drm_bridge *bridge) ...@@ -1973,18 +1954,22 @@ static int dw_hdmi_bridge_attach(struct drm_bridge *bridge)
return 0; return 0;
} }
static bool dw_hdmi_bridge_mode_fixup(struct drm_bridge *bridge, static enum drm_mode_status
const struct drm_display_mode *orig_mode, dw_hdmi_bridge_mode_valid(struct drm_bridge *bridge,
struct drm_display_mode *mode) const struct drm_display_mode *mode)
{ {
struct dw_hdmi *hdmi = bridge->driver_private; struct dw_hdmi *hdmi = bridge->driver_private;
struct drm_connector *connector = &hdmi->connector; struct drm_connector *connector = &hdmi->connector;
enum drm_mode_status status; enum drm_mode_status mode_status = MODE_OK;
status = dw_hdmi_connector_mode_valid(connector, mode); /* We don't support double-clocked modes */
if (status != MODE_OK) if (mode->flags & DRM_MODE_FLAG_DBLCLK)
return false; return MODE_BAD;
return true;
if (hdmi->plat_data->mode_valid)
mode_status = hdmi->plat_data->mode_valid(connector, mode);
return mode_status;
} }
static void dw_hdmi_bridge_mode_set(struct drm_bridge *bridge, static void dw_hdmi_bridge_mode_set(struct drm_bridge *bridge,
...@@ -2028,7 +2013,7 @@ static const struct drm_bridge_funcs dw_hdmi_bridge_funcs = { ...@@ -2028,7 +2013,7 @@ static const struct drm_bridge_funcs dw_hdmi_bridge_funcs = {
.enable = dw_hdmi_bridge_enable, .enable = dw_hdmi_bridge_enable,
.disable = dw_hdmi_bridge_disable, .disable = dw_hdmi_bridge_disable,
.mode_set = dw_hdmi_bridge_mode_set, .mode_set = dw_hdmi_bridge_mode_set,
.mode_fixup = dw_hdmi_bridge_mode_fixup, .mode_valid = dw_hdmi_bridge_mode_valid,
}; };
static irqreturn_t dw_hdmi_i2c_irq(struct dw_hdmi *hdmi) static irqreturn_t dw_hdmi_i2c_irq(struct dw_hdmi *hdmi)
......
...@@ -147,8 +147,9 @@ static const struct drm_encoder_funcs dw_hdmi_imx_encoder_funcs = { ...@@ -147,8 +147,9 @@ static const struct drm_encoder_funcs dw_hdmi_imx_encoder_funcs = {
.destroy = drm_encoder_cleanup, .destroy = drm_encoder_cleanup,
}; };
static enum drm_mode_status imx6q_hdmi_mode_valid(struct drm_connector *con, static enum drm_mode_status
struct drm_display_mode *mode) imx6q_hdmi_mode_valid(struct drm_connector *con,
const struct drm_display_mode *mode)
{ {
if (mode->clock < 13500) if (mode->clock < 13500)
return MODE_CLOCK_LOW; return MODE_CLOCK_LOW;
...@@ -159,8 +160,9 @@ static enum drm_mode_status imx6q_hdmi_mode_valid(struct drm_connector *con, ...@@ -159,8 +160,9 @@ static enum drm_mode_status imx6q_hdmi_mode_valid(struct drm_connector *con,
return MODE_OK; return MODE_OK;
} }
static enum drm_mode_status imx6dl_hdmi_mode_valid(struct drm_connector *con, static enum drm_mode_status
struct drm_display_mode *mode) imx6dl_hdmi_mode_valid(struct drm_connector *con,
const struct drm_display_mode *mode)
{ {
if (mode->clock < 13500) if (mode->clock < 13500)
return MODE_CLOCK_LOW; return MODE_CLOCK_LOW;
......
...@@ -536,8 +536,9 @@ static irqreturn_t dw_hdmi_top_thread_irq(int irq, void *dev_id) ...@@ -536,8 +536,9 @@ static irqreturn_t dw_hdmi_top_thread_irq(int irq, void *dev_id)
} }
/* TOFIX Enable support for non-vic modes */ /* TOFIX Enable support for non-vic modes */
static enum drm_mode_status dw_hdmi_mode_valid(struct drm_connector *connector, static enum drm_mode_status
struct drm_display_mode *mode) dw_hdmi_mode_valid(struct drm_connector *connector,
const struct drm_display_mode *mode)
{ {
unsigned int vclk_freq; unsigned int vclk_freq;
unsigned int venc_freq; unsigned int venc_freq;
......
...@@ -155,7 +155,7 @@ static int rockchip_hdmi_parse_dt(struct rockchip_hdmi *hdmi) ...@@ -155,7 +155,7 @@ static int rockchip_hdmi_parse_dt(struct rockchip_hdmi *hdmi)
static enum drm_mode_status static enum drm_mode_status
dw_hdmi_rockchip_mode_valid(struct drm_connector *connector, dw_hdmi_rockchip_mode_valid(struct drm_connector *connector,
struct drm_display_mode *mode) const struct drm_display_mode *mode)
{ {
const struct dw_hdmi_mpll_config *mpll_cfg = rockchip_mpll_cfg; const struct dw_hdmi_mpll_config *mpll_cfg = rockchip_mpll_cfg;
int pclk = mode->clock * 1000; int pclk = mode->clock * 1000;
......
...@@ -125,7 +125,7 @@ struct dw_hdmi_phy_ops { ...@@ -125,7 +125,7 @@ struct dw_hdmi_phy_ops {
struct dw_hdmi_plat_data { struct dw_hdmi_plat_data {
struct regmap *regm; struct regmap *regm;
enum drm_mode_status (*mode_valid)(struct drm_connector *connector, enum drm_mode_status (*mode_valid)(struct drm_connector *connector,
struct drm_display_mode *mode); const struct drm_display_mode *mode);
unsigned long input_bus_format; unsigned long input_bus_format;
unsigned long input_bus_encoding; unsigned long input_bus_encoding;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment