Hi,
Here's a series containing miscallaneous improvements for omapdrm from TI's kernel.
The main things here are probably IRQ based HDMI hotplug and the refactoring of dispc to expose dispc_ops. The dispc_ops are needed for DSS6 work, which I have not yet sent.
Tomi
Hemant Hariyani (1): drm/omap: Add support for render nodes
Peter Ujfalusi (11): drm/omap: Init fbdev emulation only when we have displays drm/omap: dss: Functions to check components in the display/output list drm/omap: dss: Support for detecting display stack readiness drm/omap: Use omapdss_stack_is_ready() to check that the display stack is up drm/omap: display: Add displays in sorted order to the panel_list drm/omap: Create fbdev emulation only for the first DRM connector drm/omap: poll only connectors where the connect/disconnect can be checked drm/omap: Support for HDMI hot plug detection drm/omap: displays: connector-hdmi: Support for hot plug detection drm/omap: displays: encoder-tpd12s015: Support for hot plug detection drm/omap: displays: panel-dpi: Support for handling backlight devices
Tomi Valkeinen (24): drm/omap: work-around for errata i886 drm/omap: subclass drm_crtc_state drm/omap: add crtc background property drm/omap: remove divider constraint from hsdiv drm/omap: decrease min width & height drm/omap: improve DPI clock selection on DRA7xx drm/omap: fix HDMI sync polarities drm/omap: add omapdss_of_get_endpoint() helper drm/omap: add omapdss-base.ko drm/omap: move dss_initialized to omapdss-base drm/omap: output: use dev_err instead of DSSERR drm/omap: display: don't use dsi_get_pixel_size() drm/omap: move display, dss-of, output to omapdss-base drm/omap: move dispc related dss-feat funcs to dispc drm/omap: add dispc_ops drm/omap: fill dispc_ops drm/omap: use dispc_ops drm/omap: remove all EXPORT_SYMBOLs from dispc.c drm/omap: remove unused dispc_wb_enable & dispc_wb_is_enabled drm/omap: fix replication logic drm/omap: fix plane update warning when crtc is disabled drm/omap: fix max fb width drm/omap: dispc: improve debug print of display flags drm/omap: fix display SYNC/DE flags
drivers/gpu/drm/omapdrm/displays/connector-hdmi.c | 63 +++++++ .../gpu/drm/omapdrm/displays/encoder-tpd12s015.c | 55 ++++++ drivers/gpu/drm/omapdrm/displays/panel-dpi.c | 37 +++- drivers/gpu/drm/omapdrm/dss/Kconfig | 4 + drivers/gpu/drm/omapdrm/dss/Makefile | 8 +- drivers/gpu/drm/omapdrm/dss/base.c | 140 +++++++++++++++ drivers/gpu/drm/omapdrm/dss/dispc.c | 177 +++++++++++-------- drivers/gpu/drm/omapdrm/dss/display.c | 36 +++- drivers/gpu/drm/omapdrm/dss/dpi.c | 55 ++++-- drivers/gpu/drm/omapdrm/dss/dsi.c | 2 +- drivers/gpu/drm/omapdrm/dss/dss-of.c | 64 ++++++- drivers/gpu/drm/omapdrm/dss/dss.c | 13 +- drivers/gpu/drm/omapdrm/dss/dss.h | 17 +- drivers/gpu/drm/omapdrm/dss/dss_features.c | 3 - drivers/gpu/drm/omapdrm/dss/dss_features.h | 4 + drivers/gpu/drm/omapdrm/dss/hdmi_wp.c | 12 +- drivers/gpu/drm/omapdrm/dss/omapdss.h | 113 +++++++++---- drivers/gpu/drm/omapdrm/dss/output.c | 27 ++- drivers/gpu/drm/omapdrm/dss/pll.c | 4 +- drivers/gpu/drm/omapdrm/omap_connector.c | 40 ++++- drivers/gpu/drm/omapdrm/omap_crtc.c | 187 +++++++++++++++++---- drivers/gpu/drm/omapdrm/omap_drv.c | 59 ++++--- drivers/gpu/drm/omapdrm/omap_drv.h | 7 +- drivers/gpu/drm/omapdrm/omap_fbdev.c | 7 +- drivers/gpu/drm/omapdrm/omap_irq.c | 33 ++-- drivers/gpu/drm/omapdrm/omap_plane.c | 19 ++- 26 files changed, 928 insertions(+), 258 deletions(-) create mode 100644 drivers/gpu/drm/omapdrm/dss/base.c
DRA7 errata i886 (FPDLink PLL Unlocks With Certain SoC PLL M/N Values) says that FPDLink is sensitive to jitter on the vout clock, and that low PLL M and N values result in more jitter than high M and N values.
This patch implements a workaround for the problem by changing the PLL setup to search for clocks starting from high M and N values, instead of low values. This should not cause any functional change, and only reduces the jitter.
Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/dss/pll.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/pll.c b/drivers/gpu/drm/omapdrm/dss/pll.c index 0a76c89cdc2e..65c478d85caa 100644 --- a/drivers/gpu/drm/omapdrm/dss/pll.c +++ b/drivers/gpu/drm/omapdrm/dss/pll.c @@ -231,7 +231,7 @@ bool dss_pll_calc_a(const struct dss_pll *pll, unsigned long clkin,
pll_max = pll_max ? pll_max : ULONG_MAX;
- for (n = n_start; n <= n_stop; ++n) { + for (n = n_stop; n >= n_start; --n) { fint = clkin / n;
m_start = max(DIV_ROUND_UP(DIV_ROUND_UP(pll_min, fint), 2), @@ -240,7 +240,7 @@ bool dss_pll_calc_a(const struct dss_pll *pll, unsigned long clkin, (unsigned)(pll_hw_max / fint / 2), hw->m_max);
- for (m = m_start; m <= m_stop; ++m) { + for (m = m_stop; m >= m_start; --m) { clkdco = 2 * m * fint;
if (func(n, m, fint, clkdco, data))
We need to extend drm_crtc_state to be able to handle omap specific crtc properties. This patch adds the necessary code to do the subclassing, without adding any properties.
Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/omap_crtc.c | 54 ++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c index 8dea89030e66..ff1570c096f8 100644 --- a/drivers/gpu/drm/omapdrm/omap_crtc.c +++ b/drivers/gpu/drm/omapdrm/omap_crtc.c @@ -27,6 +27,7 @@ #include "omap_drv.h"
#define to_omap_crtc(x) container_of(x, struct omap_crtc, base) +#define to_omap_crtc_state(x) container_of(x, struct omap_crtc_state, base)
struct omap_crtc { struct drm_crtc base; @@ -45,6 +46,10 @@ struct omap_crtc { wait_queue_head_t pending_wait; };
+struct omap_crtc_state { + struct drm_crtc_state base; +}; + /* ----------------------------------------------------------------------------- * Helper Functions */ @@ -318,6 +323,49 @@ static void omap_crtc_vblank_irq(struct omap_drm_irq *irq, uint32_t irqstatus) * CRTC Functions */
+static struct drm_crtc_state * +omap_crtc_atomic_duplicate_state(struct drm_crtc *crtc) +{ + struct omap_crtc_state *state; + struct omap_crtc_state *copy; + + if (WARN_ON(!crtc->state)) + return NULL; + + state = to_omap_crtc_state(crtc->state); + copy = kmemdup(state, sizeof(*state), GFP_KERNEL); + if (copy == NULL) + return NULL; + + __drm_atomic_helper_crtc_duplicate_state(crtc, ©->base); + + return ©->base; +} + +static void omap_crtc_atomic_destroy_state(struct drm_crtc *crtc, + struct drm_crtc_state *state) +{ + __drm_atomic_helper_crtc_destroy_state(state); + kfree(to_omap_crtc_state(state)); +} + +static void omap_crtc_reset(struct drm_crtc *crtc) +{ + struct omap_crtc_state *omap_state; + + if (crtc->state) { + omap_crtc_atomic_destroy_state(crtc, crtc->state); + crtc->state = NULL; + } + + omap_state = kzalloc(sizeof(*omap_state), GFP_KERNEL); + if (omap_state == NULL) + return; + + crtc->state = &omap_state->base; + crtc->state->crtc = crtc; +} + static void omap_crtc_destroy(struct drm_crtc *crtc) { struct omap_crtc *omap_crtc = to_omap_crtc(crtc); @@ -483,14 +531,14 @@ static int omap_crtc_atomic_get_property(struct drm_crtc *crtc, }
static const struct drm_crtc_funcs omap_crtc_funcs = { - .reset = drm_atomic_helper_crtc_reset, + .reset = omap_crtc_reset, .set_config = drm_atomic_helper_set_config, .destroy = omap_crtc_destroy, .page_flip = drm_atomic_helper_page_flip, .gamma_set = drm_atomic_helper_legacy_gamma_set, .set_property = drm_atomic_helper_crtc_set_property, - .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state, - .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state, + .atomic_duplicate_state = omap_crtc_atomic_duplicate_state, + .atomic_destroy_state = omap_crtc_atomic_destroy_state, .atomic_set_property = omap_crtc_atomic_set_property, .atomic_get_property = omap_crtc_atomic_get_property, };
Add DRM property for crtc background color property. Background color is shown on areas where there are no planes.
Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/omap_crtc.c | 60 ++++++++++++++++++++++++++++++------- drivers/gpu/drm/omapdrm/omap_drv.c | 9 ++++++ drivers/gpu/drm/omapdrm/omap_drv.h | 5 +++- 3 files changed, 63 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c index ff1570c096f8..c0e30a4cb2a9 100644 --- a/drivers/gpu/drm/omapdrm/omap_crtc.c +++ b/drivers/gpu/drm/omapdrm/omap_crtc.c @@ -48,6 +48,8 @@ struct omap_crtc {
struct omap_crtc_state { struct drm_crtc_state base; + + u32 default_color; };
/* ----------------------------------------------------------------------------- @@ -196,15 +198,7 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable) static int omap_crtc_dss_enable(enum omap_channel channel) { struct omap_crtc *omap_crtc = omap_crtcs[channel]; - struct omap_overlay_manager_info info; - - memset(&info, 0, sizeof(info)); - info.default_color = 0x00000000; - info.trans_key = 0x00000000; - info.trans_key_type = OMAP_DSS_COLOR_KEY_GFX_DST; - info.trans_enabled = false;
- dispc_mgr_setup(omap_crtc->channel, &info); dispc_mgr_set_timings(omap_crtc->channel, &omap_crtc->vm); omap_crtc_set_enabled(&omap_crtc->base, true); @@ -319,6 +313,20 @@ static void omap_crtc_vblank_irq(struct omap_drm_irq *irq, uint32_t irqstatus) wake_up(&omap_crtc->pending_wait); }
+static void omap_crtc_write_crtc_properties(struct drm_crtc *crtc) +{ + struct omap_crtc *omap_crtc = to_omap_crtc(crtc); + struct omap_overlay_manager_info info; + const struct omap_crtc_state *omap_state = + to_omap_crtc_state(crtc->state); + + memset(&info, 0, sizeof(info)); + info.default_color = omap_state->default_color; + info.trans_enabled = false; + + dispc_mgr_setup(omap_crtc->channel, &info); +} + /* ----------------------------------------------------------------------------- * CRTC Functions */ @@ -362,6 +370,8 @@ static void omap_crtc_reset(struct drm_crtc *crtc) if (omap_state == NULL) return;
+ omap_state->default_color = 0; + crtc->state = &omap_state->base; crtc->state->crtc = crtc; } @@ -462,6 +472,8 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc, dispc_mgr_set_gamma(omap_crtc->channel, lut, length); }
+ omap_crtc_write_crtc_properties(crtc); + if (dispc_mgr_is_enabled(omap_crtc->channel)) {
DBG("%s: GO", omap_crtc->name); @@ -491,6 +503,10 @@ static int omap_crtc_atomic_set_property(struct drm_crtc *crtc, struct drm_property *property, uint64_t val) { + struct drm_device *dev = crtc->dev; + struct omap_drm_private *priv = dev->dev_private; + struct omap_crtc_state *omap_state = to_omap_crtc_state(state); + if (omap_crtc_is_plane_prop(crtc, property)) { struct drm_plane_state *plane_state; struct drm_plane *plane = crtc->primary; @@ -508,7 +524,12 @@ static int omap_crtc_atomic_set_property(struct drm_crtc *crtc, property, val); }
- return -EINVAL; + if (property == priv->background_color_prop) + omap_state->default_color = val; + else + return -EINVAL; + + return 0; }
static int omap_crtc_atomic_get_property(struct drm_crtc *crtc, @@ -516,6 +537,10 @@ static int omap_crtc_atomic_get_property(struct drm_crtc *crtc, struct drm_property *property, uint64_t *val) { + struct drm_device *dev = crtc->dev; + struct omap_drm_private *priv = dev->dev_private; + struct omap_crtc_state *omap_state = to_omap_crtc_state(state); + if (omap_crtc_is_plane_prop(crtc, property)) { /* * Delegate property get to the primary plane. The @@ -527,7 +552,12 @@ static int omap_crtc_atomic_get_property(struct drm_crtc *crtc, property, val); }
- return -EINVAL; + if (property == priv->background_color_prop) + *val = omap_state->default_color; + else + return -EINVAL; + + return 0; }
static const struct drm_crtc_funcs omap_crtc_funcs = { @@ -573,6 +603,15 @@ void omap_crtc_pre_uninit(void) dss_uninstall_mgr_ops(); }
+static void omap_crtc_install_properties(struct drm_crtc *crtc) +{ + struct drm_device *dev = crtc->dev; + struct drm_mode_object *obj = &crtc->base; + struct omap_drm_private *priv = dev->dev_private; + + drm_object_attach_property(obj, priv->background_color_prop, 0); +} + /* initialize crtc */ struct drm_crtc *omap_crtc_init(struct drm_device *dev, struct drm_plane *plane, enum omap_channel channel, int id) @@ -625,6 +664,7 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev, drm_mode_crtc_set_gamma_size(crtc, gamma_lut_size); }
+ omap_crtc_install_properties(crtc); omap_plane_install_properties(crtc->primary, &crtc->base);
omap_crtcs[channel] = omap_crtc; diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c index 39c5312b466c..8c58ca7db382 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.c +++ b/drivers/gpu/drm/omapdrm/omap_drv.c @@ -293,10 +293,19 @@ static int omap_modeset_init_properties(struct drm_device *dev) { struct omap_drm_private *priv = dev->dev_private;
+ /* plane properties */ + priv->zorder_prop = drm_property_create_range(dev, 0, "zorder", 0, 3); if (!priv->zorder_prop) return -ENOMEM;
+ /* crtc properties */ + + priv->background_color_prop = drm_property_create_range(dev, 0, + "background", 0, 0xffffff); + if (!priv->background_color_prop) + return -ENOMEM; + return 0; }
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h index 4c51135eb9a6..0d16294e8145 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.h +++ b/drivers/gpu/drm/omapdrm/omap_drv.h @@ -97,9 +97,12 @@ struct omap_drm_private { struct omap_drm_usergart *usergart; bool has_dmm;
- /* properties: */ + /* plane properties */ struct drm_property *zorder_prop;
+ /* crtc properties */ + struct drm_property *background_color_prop; + /* irq handling: */ struct list_head irq_list; /* list of omap_drm_irq */ uint32_t vblank_mask; /* irq bits set for userspace vblank */
Hi Tomi,
Thank you for the patch.
On Wednesday 30 Nov 2016 13:17:05 Tomi Valkeinen wrote:
Add DRM property for crtc background color property. Background color is shown on areas where there are no planes.
The background property is useful for the rcar-du driver as well, and I assume for a bunch of other display engines too. Could you please standardize it ? And for the usual bikeshedding required in those circumstances, should it be called background-color or bgcolor instead ?
Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com
drivers/gpu/drm/omapdrm/omap_crtc.c | 60 +++++++++++++++++++++++++++------- drivers/gpu/drm/omapdrm/omap_drv.c | 9 ++++++ drivers/gpu/drm/omapdrm/omap_drv.h | 5 +++- 3 files changed, 63 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c index ff1570c096f8..c0e30a4cb2a9 100644 --- a/drivers/gpu/drm/omapdrm/omap_crtc.c +++ b/drivers/gpu/drm/omapdrm/omap_crtc.c @@ -48,6 +48,8 @@ struct omap_crtc {
struct omap_crtc_state { struct drm_crtc_state base;
- u32 default_color;
};
/*
-- @@ -196,15 +198,7 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable) static int omap_crtc_dss_enable(enum omap_channel channel) { struct omap_crtc *omap_crtc = omap_crtcs[channel];
struct omap_overlay_manager_info info;
memset(&info, 0, sizeof(info));
info.default_color = 0x00000000;
info.trans_key = 0x00000000;
info.trans_key_type = OMAP_DSS_COLOR_KEY_GFX_DST;
info.trans_enabled = false;
dispc_mgr_setup(omap_crtc->channel, &info); dispc_mgr_set_timings(omap_crtc->channel, &omap_crtc->vm); omap_crtc_set_enabled(&omap_crtc->base, true);
@@ -319,6 +313,20 @@ static void omap_crtc_vblank_irq(struct omap_drm_irq *irq, uint32_t irqstatus) wake_up(&omap_crtc->pending_wait); }
+static void omap_crtc_write_crtc_properties(struct drm_crtc *crtc) +{
- struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
- struct omap_overlay_manager_info info;
- const struct omap_crtc_state *omap_state =
to_omap_crtc_state(crtc->state);
- memset(&info, 0, sizeof(info));
- info.default_color = omap_state->default_color;
- info.trans_enabled = false;
- dispc_mgr_setup(omap_crtc->channel, &info);
+}
/*
-- * CRTC Functions */ @@ -362,6 +370,8 @@ static void omap_crtc_reset(struct drm_crtc *crtc) if (omap_state == NULL) return;
- omap_state->default_color = 0;
- crtc->state = &omap_state->base; crtc->state->crtc = crtc;
} @@ -462,6 +472,8 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc, dispc_mgr_set_gamma(omap_crtc->channel, lut, length); }
omap_crtc_write_crtc_properties(crtc);
if (dispc_mgr_is_enabled(omap_crtc->channel)) {
DBG("%s: GO", omap_crtc->name);
@@ -491,6 +503,10 @@ static int omap_crtc_atomic_set_property(struct drm_crtc *crtc, struct drm_property *property, uint64_t val) {
- struct drm_device *dev = crtc->dev;
- struct omap_drm_private *priv = dev->dev_private;
- struct omap_crtc_state *omap_state = to_omap_crtc_state(state);
- if (omap_crtc_is_plane_prop(crtc, property)) { struct drm_plane_state *plane_state; struct drm_plane *plane = crtc->primary;
@@ -508,7 +524,12 @@ static int omap_crtc_atomic_set_property(struct drm_crtc *crtc, property, val); }
- return -EINVAL;
- if (property == priv->background_color_prop)
omap_state->default_color = val;
- else
return -EINVAL;
- return 0;
}
static int omap_crtc_atomic_get_property(struct drm_crtc *crtc, @@ -516,6 +537,10 @@ static int omap_crtc_atomic_get_property(struct drm_crtc *crtc, struct drm_property *property, uint64_t *val) {
- struct drm_device *dev = crtc->dev;
- struct omap_drm_private *priv = dev->dev_private;
- struct omap_crtc_state *omap_state = to_omap_crtc_state(state);
- if (omap_crtc_is_plane_prop(crtc, property)) { /*
- Delegate property get to the primary plane. The
@@ -527,7 +552,12 @@ static int omap_crtc_atomic_get_property(struct drm_crtc *crtc, property, val); }
- return -EINVAL;
- if (property == priv->background_color_prop)
*val = omap_state->default_color;
- else
return -EINVAL;
- return 0;
}
static const struct drm_crtc_funcs omap_crtc_funcs = { @@ -573,6 +603,15 @@ void omap_crtc_pre_uninit(void) dss_uninstall_mgr_ops(); }
+static void omap_crtc_install_properties(struct drm_crtc *crtc) +{
- struct drm_device *dev = crtc->dev;
- struct drm_mode_object *obj = &crtc->base;
- struct omap_drm_private *priv = dev->dev_private;
- drm_object_attach_property(obj, priv->background_color_prop, 0);
+}
/* initialize crtc */ struct drm_crtc *omap_crtc_init(struct drm_device *dev, struct drm_plane *plane, enum omap_channel channel, int id) @@ -625,6 +664,7 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev, drm_mode_crtc_set_gamma_size(crtc, gamma_lut_size); }
omap_crtc_install_properties(crtc); omap_plane_install_properties(crtc->primary, &crtc->base);
omap_crtcs[channel] = omap_crtc;
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c index 39c5312b466c..8c58ca7db382 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.c +++ b/drivers/gpu/drm/omapdrm/omap_drv.c @@ -293,10 +293,19 @@ static int omap_modeset_init_properties(struct drm_device *dev) { struct omap_drm_private *priv = dev->dev_private;
/* plane properties */
priv->zorder_prop = drm_property_create_range(dev, 0, "zorder", 0, 3); if (!priv->zorder_prop) return -ENOMEM;
/* crtc properties */
priv->background_color_prop = drm_property_create_range(dev, 0,
"background", 0, 0xffffff);
if (!priv->background_color_prop)
return -ENOMEM;
return 0;
}
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h index 4c51135eb9a6..0d16294e8145 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.h +++ b/drivers/gpu/drm/omapdrm/omap_drv.h @@ -97,9 +97,12 @@ struct omap_drm_private { struct omap_drm_usergart *usergart; bool has_dmm;
- /* properties: */
/* plane properties */ struct drm_property *zorder_prop;
/* crtc properties */
struct drm_property *background_color_prop;
/* irq handling: */ struct list_head irq_list; /* list of omap_drm_irq */ uint32_t vblank_mask; /* irq bits set for userspace vblank */
On 30/11/16 13:25, Laurent Pinchart wrote:
Hi Tomi,
Thank you for the patch.
On Wednesday 30 Nov 2016 13:17:05 Tomi Valkeinen wrote:
Add DRM property for crtc background color property. Background color is shown on areas where there are no planes.
The background property is useful for the rcar-du driver as well, and I assume for a bunch of other display engines too. Could you please standardize it ? And for the usual bikeshedding required in those circumstances, should it be called background-color or bgcolor instead ?
The possible color values for background color property depend on the HW. The current OMAP DSS has 8 bits per component, but other sizes should be supported too.
I'm not sure how to implement that in a generic way... Always use 16 bits per component for the property?
Tomi
On Wednesday 30 Nov 2016 14:51:26 Tomi Valkeinen wrote:
On 30/11/16 13:25, Laurent Pinchart wrote:
Hi Tomi,
Thank you for the patch.
On Wednesday 30 Nov 2016 13:17:05 Tomi Valkeinen wrote:
Add DRM property for crtc background color property. Background color is shown on areas where there are no planes.
The background property is useful for the rcar-du driver as well, and I assume for a bunch of other display engines too. Could you please standardize it ? And for the usual bikeshedding required in those circumstances, should it be called background-color or bgcolor instead ?
The possible color values for background color property depend on the HW. The current OMAP DSS has 8 bits per component, but other sizes should be supported too.
I'm not sure how to implement that in a generic way... Always use 16 bits per component for the property?
That's one option. Another one would be to decide that 8 bit per component is enough. The value of the background colour property could also possibly be device-dependent, for instance if a device specifies it in YUV.
On Wed, Nov 30, 2016 at 03:34:58PM +0200, Laurent Pinchart wrote:
On Wednesday 30 Nov 2016 14:51:26 Tomi Valkeinen wrote:
On 30/11/16 13:25, Laurent Pinchart wrote:
Hi Tomi,
Thank you for the patch.
On Wednesday 30 Nov 2016 13:17:05 Tomi Valkeinen wrote:
Add DRM property for crtc background color property. Background color is shown on areas where there are no planes.
The background property is useful for the rcar-du driver as well, and I assume for a bunch of other display engines too. Could you please standardize it ? And for the usual bikeshedding required in those circumstances, should it be called background-color or bgcolor instead ?
The possible color values for background color property depend on the HW. The current OMAP DSS has 8 bits per component, but other sizes should be supported too.
I'm not sure how to implement that in a generic way... Always use 16 bits per component for the property?
That's one option. Another one would be to decide that 8 bit per component is enough. The value of the background colour property could also possibly be device-dependent, for instance if a device specifies it in YUV.
We have enough for 16 bits per component in u64. We can just throw away the lsbs. I have already suggested that approach about a dozen times throughout the years ;) We migth even have some i915 patches doing that...
I don't have a very good idea for exposing the actual bpc though. Might be doable with a parallel immutable mask property. But the big open question is what happens if the actual bpc can change depending on the crtc configuration. I would suggest we just ignore that issue for now.
For the RGB vs. YUV, we might just have separate props for those I suppose. Although again it migth depend on the CRTC configuration which one is effective. Maybe we need a separate "enable this bg color" type of thing, which would then allow the driver to return an error if the user is trying to set the wrong one? Or we could just have an enum prop to select the format of the bg color property (RGB vs. YCbCr to start with I guess). Yeah, I think I like that idea. And maybe we'd need to expand that to include even more information about the actual colorspace (eg. BT601 vs. BT709 vs. whatever for YCbCr)?
Hi Ville,
On Wednesday 30 Nov 2016 15:53:53 Ville Syrjälä wrote:
On Wed, Nov 30, 2016 at 03:34:58PM +0200, Laurent Pinchart wrote:
On Wednesday 30 Nov 2016 14:51:26 Tomi Valkeinen wrote:
On 30/11/16 13:25, Laurent Pinchart wrote:
On Wednesday 30 Nov 2016 13:17:05 Tomi Valkeinen wrote:
Add DRM property for crtc background color property. Background color is shown on areas where there are no planes.
The background property is useful for the rcar-du driver as well, and I assume for a bunch of other display engines too. Could you please standardize it ? And for the usual bikeshedding required in those circumstances, should it be called background-color or bgcolor instead ?
The possible color values for background color property depend on the HW. The current OMAP DSS has 8 bits per component, but other sizes should be supported too.
I'm not sure how to implement that in a generic way... Always use 16 bits per component for the property?
That's one option. Another one would be to decide that 8 bit per component is enough. The value of the background colour property could also possibly be device-dependent, for instance if a device specifies it in YUV.
We have enough for 16 bits per component in u64. We can just throw away the lsbs. I have already suggested that approach about a dozen times throughout the years ;) We migth even have some i915 patches doing that...
I don't have a very good idea for exposing the actual bpc though. Might be doable with a parallel immutable mask property. But the big open question is what happens if the actual bpc can change depending on the crtc configuration. I would suggest we just ignore that issue for now.
I don't think we need to expose the number of bits per component. If the colours are always expressed with 16 bits per component, the kernel can ignore the LSBs completely transparently for userspace.
For the RGB vs. YUV, we might just have separate props for those I suppose. Although again it migth depend on the CRTC configuration which one is effective. Maybe we need a separate "enable this bg color" type of thing, which would then allow the driver to return an error if the user is trying to set the wrong one? Or we could just have an enum prop to select the format of the bg color property (RGB vs. YCbCr to start with I guess). Yeah, I think I like that idea. And maybe we'd need to expand that to include even more information about the actual colorspace (eg. BT601 vs. BT709 vs. whatever for YCbCr)?
It might be a theoretical issue though, as I'm not sure whether there's hardware out there that expresses the background colour in YUV.
On Wed, Nov 30, 2016 at 03:56:38PM +0200, Laurent Pinchart wrote:
Hi Ville,
On Wednesday 30 Nov 2016 15:53:53 Ville Syrjälä wrote:
On Wed, Nov 30, 2016 at 03:34:58PM +0200, Laurent Pinchart wrote:
On Wednesday 30 Nov 2016 14:51:26 Tomi Valkeinen wrote:
On 30/11/16 13:25, Laurent Pinchart wrote:
On Wednesday 30 Nov 2016 13:17:05 Tomi Valkeinen wrote:
Add DRM property for crtc background color property. Background color is shown on areas where there are no planes.
The background property is useful for the rcar-du driver as well, and I assume for a bunch of other display engines too. Could you please standardize it ? And for the usual bikeshedding required in those circumstances, should it be called background-color or bgcolor instead ?
The possible color values for background color property depend on the HW. The current OMAP DSS has 8 bits per component, but other sizes should be supported too.
I'm not sure how to implement that in a generic way... Always use 16 bits per component for the property?
That's one option. Another one would be to decide that 8 bit per component is enough. The value of the background colour property could also possibly be device-dependent, for instance if a device specifies it in YUV.
We have enough for 16 bits per component in u64. We can just throw away the lsbs. I have already suggested that approach about a dozen times throughout the years ;) We migth even have some i915 patches doing that...
I don't have a very good idea for exposing the actual bpc though. Might be doable with a parallel immutable mask property. But the big open question is what happens if the actual bpc can change depending on the crtc configuration. I would suggest we just ignore that issue for now.
I don't think we need to expose the number of bits per component. If the colours are always expressed with 16 bits per component, the kernel can ignore the LSBs completely transparently for userspace.
For the RGB vs. YUV, we might just have separate props for those I suppose. Although again it migth depend on the CRTC configuration which one is effective. Maybe we need a separate "enable this bg color" type of thing, which would then allow the driver to return an error if the user is trying to set the wrong one? Or we could just have an enum prop to select the format of the bg color property (RGB vs. YCbCr to start with I guess). Yeah, I think I like that idea. And maybe we'd need to expand that to include even more information about the actual colorspace (eg. BT601 vs. BT709 vs. whatever for YCbCr)?
It might be a theoretical issue though, as I'm not sure whether there's hardware out there that expresses the background colour in YUV.
Not sure about bg color. I know of hardware that has a color palette in YUV, and some obviously have color key in YUV.
Hi Ville,
On Wednesday 30 Nov 2016 16:40:30 Ville Syrjälä wrote:
On Wed, Nov 30, 2016 at 03:56:38PM +0200, Laurent Pinchart wrote:
On Wednesday 30 Nov 2016 15:53:53 Ville Syrjälä wrote:
On Wed, Nov 30, 2016 at 03:34:58PM +0200, Laurent Pinchart wrote:
On Wednesday 30 Nov 2016 14:51:26 Tomi Valkeinen wrote:
On 30/11/16 13:25, Laurent Pinchart wrote:
On Wednesday 30 Nov 2016 13:17:05 Tomi Valkeinen wrote: > Add DRM property for crtc background color property. Background > color is shown on areas where there are no planes.
The background property is useful for the rcar-du driver as well, and I assume for a bunch of other display engines too. Could you please standardize it ? And for the usual bikeshedding required in those circumstances, should it be called background-color or bgcolor instead ?
The possible color values for background color property depend on the HW. The current OMAP DSS has 8 bits per component, but other sizes should be supported too.
I'm not sure how to implement that in a generic way... Always use 16 bits per component for the property?
That's one option. Another one would be to decide that 8 bit per component is enough. The value of the background colour property could also possibly be device-dependent, for instance if a device specifies it in YUV.
We have enough for 16 bits per component in u64. We can just throw away the lsbs. I have already suggested that approach about a dozen times throughout the years ;) We migth even have some i915 patches doing that...
I don't have a very good idea for exposing the actual bpc though. Might be doable with a parallel immutable mask property. But the big open question is what happens if the actual bpc can change depending on the crtc configuration. I would suggest we just ignore that issue for now.
I don't think we need to expose the number of bits per component. If the colours are always expressed with 16 bits per component, the kernel can ignore the LSBs completely transparently for userspace.
For the RGB vs. YUV, we might just have separate props for those I suppose. Although again it migth depend on the CRTC configuration which one is effective. Maybe we need a separate "enable this bg color" type of thing, which would then allow the driver to return an error if the user is trying to set the wrong one? Or we could just have an enum prop to select the format of the bg color property (RGB vs. YCbCr to start with I guess). Yeah, I think I like that idea. And maybe we'd need to expand that to include even more information about the actual colorspace (eg. BT601 vs. BT709 vs. whatever for YCbCr)?
It might be a theoretical issue though, as I'm not sure whether there's hardware out there that expresses the background colour in YUV.
Not sure about bg color. I know of hardware that has a color palette in YUV, and some obviously have color key in YUV.
I can't be 100% sure either of course, but I'd be surprised. And even if that happens, the background colour would either always be expressed in YUV for that hardware, or would switch between YUV and RGB based on CRTC configuration. We can document the bgcolor property as being a set of 4 16-bit components, with defined mappings for RGB and YUV, and leave the rest to userspace. If userspace configures the CRTC in a way that uses a YUV background colour, userspace would be also responsible for updating the bgcolor value to a YUV value.
On Wed, Nov 30, 2016 at 04:46:36PM +0200, Laurent Pinchart wrote:
Hi Ville,
On Wednesday 30 Nov 2016 16:40:30 Ville Syrjälä wrote:
On Wed, Nov 30, 2016 at 03:56:38PM +0200, Laurent Pinchart wrote:
On Wednesday 30 Nov 2016 15:53:53 Ville Syrjälä wrote:
On Wed, Nov 30, 2016 at 03:34:58PM +0200, Laurent Pinchart wrote:
On Wednesday 30 Nov 2016 14:51:26 Tomi Valkeinen wrote:
On 30/11/16 13:25, Laurent Pinchart wrote: > On Wednesday 30 Nov 2016 13:17:05 Tomi Valkeinen wrote: >> Add DRM property for crtc background color property. Background >> color is shown on areas where there are no planes. > > The background property is useful for the rcar-du driver as well, > and I assume for a bunch of other display engines too. Could you > please standardize it ? And for the usual bikeshedding required in > those circumstances, should it be called background-color or bgcolor > instead ?
The possible color values for background color property depend on the HW. The current OMAP DSS has 8 bits per component, but other sizes should be supported too.
I'm not sure how to implement that in a generic way... Always use 16 bits per component for the property?
That's one option. Another one would be to decide that 8 bit per component is enough. The value of the background colour property could also possibly be device-dependent, for instance if a device specifies it in YUV.
We have enough for 16 bits per component in u64. We can just throw away the lsbs. I have already suggested that approach about a dozen times throughout the years ;) We migth even have some i915 patches doing that...
I don't have a very good idea for exposing the actual bpc though. Might be doable with a parallel immutable mask property. But the big open question is what happens if the actual bpc can change depending on the crtc configuration. I would suggest we just ignore that issue for now.
I don't think we need to expose the number of bits per component. If the colours are always expressed with 16 bits per component, the kernel can ignore the LSBs completely transparently for userspace.
For the RGB vs. YUV, we might just have separate props for those I suppose. Although again it migth depend on the CRTC configuration which one is effective. Maybe we need a separate "enable this bg color" type of thing, which would then allow the driver to return an error if the user is trying to set the wrong one? Or we could just have an enum prop to select the format of the bg color property (RGB vs. YCbCr to start with I guess). Yeah, I think I like that idea. And maybe we'd need to expand that to include even more information about the actual colorspace (eg. BT601 vs. BT709 vs. whatever for YCbCr)?
It might be a theoretical issue though, as I'm not sure whether there's hardware out there that expresses the background colour in YUV.
Not sure about bg color. I know of hardware that has a color palette in YUV, and some obviously have color key in YUV.
I can't be 100% sure either of course, but I'd be surprised. And even if that happens, the background colour would either always be expressed in YUV for that hardware, or would switch between YUV and RGB based on CRTC configuration. We can document the bgcolor property as being a set of 4 16-bit components, with defined mappings for RGB and YUV, and leave the rest to userspace. If userspace configures the CRTC in a way that uses a YUV background colour, userspace would be also responsible for updating the bgcolor value to a YUV value.
Yeah we can always cross that bridge when/if we come to it. Starting with just RGB is good enough for now I think.
On Wed, Nov 30, 2016 at 01:17:05PM +0200, Tomi Valkeinen wrote:
Add DRM property for crtc background color property. Background color is shown on areas where there are no planes.
Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com
Where is the userspace for this? Why is this not part of the general blending engine we expose through kms, and try to document in drm_blend.c? E.g. there's i915 background color patches too, but they haven't landed yet because there's not yet an open-source userspace for it. Or proper uabi documentation. -Daniel
drivers/gpu/drm/omapdrm/omap_crtc.c | 60 ++++++++++++++++++++++++++++++------- drivers/gpu/drm/omapdrm/omap_drv.c | 9 ++++++ drivers/gpu/drm/omapdrm/omap_drv.h | 5 +++- 3 files changed, 63 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c index ff1570c096f8..c0e30a4cb2a9 100644 --- a/drivers/gpu/drm/omapdrm/omap_crtc.c +++ b/drivers/gpu/drm/omapdrm/omap_crtc.c @@ -48,6 +48,8 @@ struct omap_crtc {
struct omap_crtc_state { struct drm_crtc_state base;
- u32 default_color;
};
/* ----------------------------------------------------------------------------- @@ -196,15 +198,7 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable) static int omap_crtc_dss_enable(enum omap_channel channel) { struct omap_crtc *omap_crtc = omap_crtcs[channel];
struct omap_overlay_manager_info info;
memset(&info, 0, sizeof(info));
info.default_color = 0x00000000;
info.trans_key = 0x00000000;
info.trans_key_type = OMAP_DSS_COLOR_KEY_GFX_DST;
info.trans_enabled = false;
dispc_mgr_setup(omap_crtc->channel, &info); dispc_mgr_set_timings(omap_crtc->channel, &omap_crtc->vm); omap_crtc_set_enabled(&omap_crtc->base, true);
@@ -319,6 +313,20 @@ static void omap_crtc_vblank_irq(struct omap_drm_irq *irq, uint32_t irqstatus) wake_up(&omap_crtc->pending_wait); }
+static void omap_crtc_write_crtc_properties(struct drm_crtc *crtc) +{
- struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
- struct omap_overlay_manager_info info;
- const struct omap_crtc_state *omap_state =
to_omap_crtc_state(crtc->state);
- memset(&info, 0, sizeof(info));
- info.default_color = omap_state->default_color;
- info.trans_enabled = false;
- dispc_mgr_setup(omap_crtc->channel, &info);
+}
/* -----------------------------------------------------------------------------
- CRTC Functions
*/ @@ -362,6 +370,8 @@ static void omap_crtc_reset(struct drm_crtc *crtc) if (omap_state == NULL) return;
- omap_state->default_color = 0;
- crtc->state = &omap_state->base; crtc->state->crtc = crtc;
} @@ -462,6 +472,8 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc, dispc_mgr_set_gamma(omap_crtc->channel, lut, length); }
omap_crtc_write_crtc_properties(crtc);
if (dispc_mgr_is_enabled(omap_crtc->channel)) {
DBG("%s: GO", omap_crtc->name);
@@ -491,6 +503,10 @@ static int omap_crtc_atomic_set_property(struct drm_crtc *crtc, struct drm_property *property, uint64_t val) {
- struct drm_device *dev = crtc->dev;
- struct omap_drm_private *priv = dev->dev_private;
- struct omap_crtc_state *omap_state = to_omap_crtc_state(state);
- if (omap_crtc_is_plane_prop(crtc, property)) { struct drm_plane_state *plane_state; struct drm_plane *plane = crtc->primary;
@@ -508,7 +524,12 @@ static int omap_crtc_atomic_set_property(struct drm_crtc *crtc, property, val); }
- return -EINVAL;
- if (property == priv->background_color_prop)
omap_state->default_color = val;
- else
return -EINVAL;
- return 0;
}
static int omap_crtc_atomic_get_property(struct drm_crtc *crtc, @@ -516,6 +537,10 @@ static int omap_crtc_atomic_get_property(struct drm_crtc *crtc, struct drm_property *property, uint64_t *val) {
- struct drm_device *dev = crtc->dev;
- struct omap_drm_private *priv = dev->dev_private;
- struct omap_crtc_state *omap_state = to_omap_crtc_state(state);
- if (omap_crtc_is_plane_prop(crtc, property)) { /*
- Delegate property get to the primary plane. The
@@ -527,7 +552,12 @@ static int omap_crtc_atomic_get_property(struct drm_crtc *crtc, property, val); }
- return -EINVAL;
- if (property == priv->background_color_prop)
*val = omap_state->default_color;
- else
return -EINVAL;
- return 0;
}
static const struct drm_crtc_funcs omap_crtc_funcs = { @@ -573,6 +603,15 @@ void omap_crtc_pre_uninit(void) dss_uninstall_mgr_ops(); }
+static void omap_crtc_install_properties(struct drm_crtc *crtc) +{
- struct drm_device *dev = crtc->dev;
- struct drm_mode_object *obj = &crtc->base;
- struct omap_drm_private *priv = dev->dev_private;
- drm_object_attach_property(obj, priv->background_color_prop, 0);
+}
/* initialize crtc */ struct drm_crtc *omap_crtc_init(struct drm_device *dev, struct drm_plane *plane, enum omap_channel channel, int id) @@ -625,6 +664,7 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev, drm_mode_crtc_set_gamma_size(crtc, gamma_lut_size); }
omap_crtc_install_properties(crtc); omap_plane_install_properties(crtc->primary, &crtc->base);
omap_crtcs[channel] = omap_crtc;
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c index 39c5312b466c..8c58ca7db382 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.c +++ b/drivers/gpu/drm/omapdrm/omap_drv.c @@ -293,10 +293,19 @@ static int omap_modeset_init_properties(struct drm_device *dev) { struct omap_drm_private *priv = dev->dev_private;
/* plane properties */
priv->zorder_prop = drm_property_create_range(dev, 0, "zorder", 0, 3); if (!priv->zorder_prop) return -ENOMEM;
/* crtc properties */
priv->background_color_prop = drm_property_create_range(dev, 0,
"background", 0, 0xffffff);
if (!priv->background_color_prop)
return -ENOMEM;
return 0;
}
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h index 4c51135eb9a6..0d16294e8145 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.h +++ b/drivers/gpu/drm/omapdrm/omap_drv.h @@ -97,9 +97,12 @@ struct omap_drm_private { struct omap_drm_usergart *usergart; bool has_dmm;
- /* properties: */
/* plane properties */ struct drm_property *zorder_prop;
/* crtc properties */
struct drm_property *background_color_prop;
/* irq handling: */ struct list_head irq_list; /* list of omap_drm_irq */ uint32_t vblank_mask; /* irq bits set for userspace vblank */
-- 2.7.4
dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
On 30/11/16 15:32, Daniel Vetter wrote:
On Wed, Nov 30, 2016 at 01:17:05PM +0200, Tomi Valkeinen wrote:
Add DRM property for crtc background color property. Background color is shown on areas where there are no planes.
Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com
Where is the userspace for this? Why is this not part of the general blending engine we expose through kms, and try to document in drm_blend.c? E.g. there's i915 background color patches too, but they haven't landed yet because there's not yet an open-source userspace for it. Or proper uabi documentation.
I'll drop this for now, and see later how to do it in a generic way.
But I'm not sure what you mean with userspace here. Do you mean that we should have a libdrm wrapper for all DRM properties?
Tomi
On Fri, Dec 09, 2016 at 01:03:33PM +0200, Tomi Valkeinen wrote:
On 30/11/16 15:32, Daniel Vetter wrote:
On Wed, Nov 30, 2016 at 01:17:05PM +0200, Tomi Valkeinen wrote:
Add DRM property for crtc background color property. Background color is shown on areas where there are no planes.
Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com
Where is the userspace for this? Why is this not part of the general blending engine we expose through kms, and try to document in drm_blend.c? E.g. there's i915 background color patches too, but they haven't landed yet because there's not yet an open-source userspace for it. Or proper uabi documentation.
I'll drop this for now, and see later how to do it in a generic way.
But I'm not sure what you mean with userspace here. Do you mean that we should have a libdrm wrapper for all DRM properties?
No, some real thing like drm_hwcomposer or weston support or something similar that gives us a clear idea how this thing is supposed to work and how it fits into the overall blending equations kms compositors can expect from properly working drivers.
See https://dri.freedesktop.org/docs/drm/gpu/drm-uapi.html#open-source-userspace... -Daniel
The driver only uses even dividers for hsdiv when pclk >= 100MHz, as odd dividers can create uneven duty cycle. However, while this holds true for some dividers like DISPC's LCK and PCK dividers, it is not actually true for hsdiv.
hsdiv always produces even duty cycle, so the constraint can be removed.
Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/dss/dpi.c | 8 -------- 1 file changed, 8 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c index e75162d26ac0..e0b0c5c24c55 100644 --- a/drivers/gpu/drm/omapdrm/dss/dpi.c +++ b/drivers/gpu/drm/omapdrm/dss/dpi.c @@ -170,14 +170,6 @@ static bool dpi_calc_hsdiv_cb(int m_dispc, unsigned long dispc, { struct dpi_clk_calc_ctx *ctx = data;
- /* - * Odd dividers give us uneven duty cycle, causing problem when level - * shifted. So skip all odd dividers when the pixel clock is on the - * higher side. - */ - if (m_dispc > 1 && m_dispc % 2 != 0 && ctx->pck_min >= 100000000) - return false; - ctx->pll_cinfo.mX[ctx->clkout_idx] = m_dispc; ctx->pll_cinfo.clkout[ctx->clkout_idx] = dispc;
mode_config's min_width and min_height are both set to 32, which is overly restrictive.
The real limits depend on whether we're configuring a crtc or a plane, but a limit of 8x2 is safe for both cases.
Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/omap_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c index 8c58ca7db382..828cd1c9ecbc 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.c +++ b/drivers/gpu/drm/omapdrm/omap_drv.c @@ -478,8 +478,8 @@ static int omap_modeset_init(struct drm_device *dev) priv->num_planes, priv->num_crtcs, priv->num_encoders, priv->num_connectors);
- dev->mode_config.min_width = 32; - dev->mode_config.min_height = 32; + dev->mode_config.min_width = 8; + dev->mode_config.min_height = 2;
/* note: eventually will need some cpu_is_omapXYZ() type stuff here * to fill in these limits properly on different OMAP generations..
The clock source selection for the LCD outputs is too hardcoded at the moment. For example, LCD3 is set to use PLL2_1, and PLL2 doesn't exist on DRA72x SoCs.
There are quite many ways to configure the clocks, even using HDMI PLL for LCD outputs, but enabling full configuration of the clocks is rather tricky.
This patch improves the situation a bit by checking if the PLL about to be used exists, and if not, tries another one.
Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/dss/dpi.c | 47 ++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c index e0b0c5c24c55..0f32d5d078c6 100644 --- a/drivers/gpu/drm/omapdrm/dss/dpi.c +++ b/drivers/gpu/drm/omapdrm/dss/dpi.c @@ -67,6 +67,42 @@ static struct dpi_data *dpi_get_data_from_pdev(struct platform_device *pdev) return dev_get_drvdata(&pdev->dev); }
+static enum dss_clk_source dpi_get_clk_src_dra7xx(enum omap_channel channel) +{ + /* + * Possible clock sources: + * LCD1: FCK/PLL1_1/HDMI_PLL + * LCD2: FCK/PLL1_3/HDMI_PLL (DRA74x: PLL2_3) + * LCD3: FCK/PLL1_3/HDMI_PLL (DRA74x: PLL2_1) + */ + + switch (channel) { + case OMAP_DSS_CHANNEL_LCD: + { + if (dss_pll_find_by_src(DSS_CLK_SRC_PLL1_1)) + return DSS_CLK_SRC_PLL1_1; + } + case OMAP_DSS_CHANNEL_LCD2: + { + if (dss_pll_find_by_src(DSS_CLK_SRC_PLL1_3)) + return DSS_CLK_SRC_PLL1_3; + if (dss_pll_find_by_src(DSS_CLK_SRC_PLL2_3)) + return DSS_CLK_SRC_PLL2_3; + } + case OMAP_DSS_CHANNEL_LCD3: + { + if (dss_pll_find_by_src(DSS_CLK_SRC_PLL2_1)) + return DSS_CLK_SRC_PLL2_1; + if (dss_pll_find_by_src(DSS_CLK_SRC_PLL1_3)) + return DSS_CLK_SRC_PLL1_3; + } + default: + break; + } + + return DSS_CLK_SRC_FCK; +} + static enum dss_clk_source dpi_get_clk_src(enum omap_channel channel) { /* @@ -107,16 +143,7 @@ static enum dss_clk_source dpi_get_clk_src(enum omap_channel channel) }
case OMAPDSS_VER_DRA7xx: - switch (channel) { - case OMAP_DSS_CHANNEL_LCD: - return DSS_CLK_SRC_PLL1_1; - case OMAP_DSS_CHANNEL_LCD2: - return DSS_CLK_SRC_PLL1_3; - case OMAP_DSS_CHANNEL_LCD3: - return DSS_CLK_SRC_PLL2_1; - default: - return DSS_CLK_SRC_FCK; - } + return dpi_get_clk_src_dra7xx(channel);
default: return DSS_CLK_SRC_FCK;
From: Peter Ujfalusi peter.ujfalusi@ti.com
Do not try to init the fbdev if either num_crtcs or num_connectors is 0. In this case we do not have display so the fbdev init would fail anyways.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@ti.com Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/omap_fbdev.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/drivers/gpu/drm/omapdrm/omap_fbdev.c b/drivers/gpu/drm/omapdrm/omap_fbdev.c index 8d8ac173f55d..2b045262f8ad 100644 --- a/drivers/gpu/drm/omapdrm/omap_fbdev.c +++ b/drivers/gpu/drm/omapdrm/omap_fbdev.c @@ -255,6 +255,9 @@ struct drm_fb_helper *omap_fbdev_init(struct drm_device *dev) struct drm_fb_helper *helper; int ret = 0;
+ if (!priv->num_crtcs || !priv->num_connectors) + return NULL; + fbdev = kzalloc(sizeof(*fbdev), GFP_KERNEL); if (!fbdev) goto fail;
On Wed, Nov 30, 2016 at 01:17:09PM +0200, Tomi Valkeinen wrote:
From: Peter Ujfalusi peter.ujfalusi@ti.com
Do not try to init the fbdev if either num_crtcs or num_connectors is 0. In this case we do not have display so the fbdev init would fail anyways.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@ti.com Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com
drivers/gpu/drm/omapdrm/omap_fbdev.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/drivers/gpu/drm/omapdrm/omap_fbdev.c b/drivers/gpu/drm/omapdrm/omap_fbdev.c index 8d8ac173f55d..2b045262f8ad 100644 --- a/drivers/gpu/drm/omapdrm/omap_fbdev.c +++ b/drivers/gpu/drm/omapdrm/omap_fbdev.c @@ -255,6 +255,9 @@ struct drm_fb_helper *omap_fbdev_init(struct drm_device *dev) struct drm_fb_helper *helper; int ret = 0;
- if (!priv->num_crtcs || !priv->num_connectors)
return NULL;
Thierry Redding had patches to implement this in a generic fashion in the fbdev emulation (just wait with fbdev init until the first screen shows up). Would be great to polish up that work (I've reviewed the original series already) and land it, instead of driver hacks forever.
https://patchwork.freedesktop.org/patch/91448/
Cheers, Daniel
- fbdev = kzalloc(sizeof(*fbdev), GFP_KERNEL); if (!fbdev) goto fail;
-- 2.7.4
dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
On 30/11/16 15:46, Daniel Vetter wrote:
On Wed, Nov 30, 2016 at 01:17:09PM +0200, Tomi Valkeinen wrote:
From: Peter Ujfalusi peter.ujfalusi@ti.com
Do not try to init the fbdev if either num_crtcs or num_connectors is 0. In this case we do not have display so the fbdev init would fail anyways.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@ti.com Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com
drivers/gpu/drm/omapdrm/omap_fbdev.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/drivers/gpu/drm/omapdrm/omap_fbdev.c b/drivers/gpu/drm/omapdrm/omap_fbdev.c index 8d8ac173f55d..2b045262f8ad 100644 --- a/drivers/gpu/drm/omapdrm/omap_fbdev.c +++ b/drivers/gpu/drm/omapdrm/omap_fbdev.c @@ -255,6 +255,9 @@ struct drm_fb_helper *omap_fbdev_init(struct drm_device *dev) struct drm_fb_helper *helper; int ret = 0;
- if (!priv->num_crtcs || !priv->num_connectors)
return NULL;
Thierry Redding had patches to implement this in a generic fashion in the fbdev emulation (just wait with fbdev init until the first screen shows up). Would be great to polish up that work (I've reviewed the original series already) and land it, instead of driver hacks forever.
This is not doing the same thing, or at least the point is not the same.
OMAP DSS has writeback support, which can be used in a plain memory-to-memory mode (not yet in the mainline, though). The need for this patch came up when people tried to use WB on boards that don't have any displays.
So this was not about deferred setup but skipping fbdev totally if we don't have any display outputs.
Tomi
On Fri, Dec 09, 2016 at 01:13:11PM +0200, Tomi Valkeinen wrote:
On 30/11/16 15:46, Daniel Vetter wrote:
On Wed, Nov 30, 2016 at 01:17:09PM +0200, Tomi Valkeinen wrote:
From: Peter Ujfalusi peter.ujfalusi@ti.com
Do not try to init the fbdev if either num_crtcs or num_connectors is 0. In this case we do not have display so the fbdev init would fail anyways.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@ti.com Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com
drivers/gpu/drm/omapdrm/omap_fbdev.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/drivers/gpu/drm/omapdrm/omap_fbdev.c b/drivers/gpu/drm/omapdrm/omap_fbdev.c index 8d8ac173f55d..2b045262f8ad 100644 --- a/drivers/gpu/drm/omapdrm/omap_fbdev.c +++ b/drivers/gpu/drm/omapdrm/omap_fbdev.c @@ -255,6 +255,9 @@ struct drm_fb_helper *omap_fbdev_init(struct drm_device *dev) struct drm_fb_helper *helper; int ret = 0;
- if (!priv->num_crtcs || !priv->num_connectors)
return NULL;
Thierry Redding had patches to implement this in a generic fashion in the fbdev emulation (just wait with fbdev init until the first screen shows up). Would be great to polish up that work (I've reviewed the original series already) and land it, instead of driver hacks forever.
This is not doing the same thing, or at least the point is not the same.
OMAP DSS has writeback support, which can be used in a plain memory-to-memory mode (not yet in the mainline, though). The need for this patch came up when people tried to use WB on boards that don't have any displays.
So this was not about deferred setup but skipping fbdev totally if we don't have any display outputs.
ah ok. Would still fix both problems ;-) But I understand that a more direct solution here makes more sense. -Daniel
From: Hemant Hariyani hemanthariyani@ti.com
Add support for render nodes in omap driver and allow required ioctls to be accessible via render nodes.
This enables unprivileged clients to allocate resources like GEM buffers for rendering their content into. Mode setting (KMS ioctls) is not allowed using render nodes. These buffers are then shared with a previleged process (e.g compositor) that has mode setting access.
An example of this use case is Android where the hardware composer is the only master and has mode setting access. Every other client then uses render node(e.g /dev/dri/renderD128 to allocate and use its buffers.
Signed-off-by: Hemant Hariyani hemanthariyani@ti.com Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/omap_drv.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c index 828cd1c9ecbc..f7af377561d8 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.c +++ b/drivers/gpu/drm/omapdrm/omap_drv.c @@ -622,12 +622,18 @@ static int ioctl_gem_info(struct drm_device *dev, void *data, }
static const struct drm_ioctl_desc ioctls[DRM_COMMAND_END - DRM_COMMAND_BASE] = { - DRM_IOCTL_DEF_DRV(OMAP_GET_PARAM, ioctl_get_param, DRM_AUTH), - DRM_IOCTL_DEF_DRV(OMAP_SET_PARAM, ioctl_set_param, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF_DRV(OMAP_GEM_NEW, ioctl_gem_new, DRM_AUTH), - DRM_IOCTL_DEF_DRV(OMAP_GEM_CPU_PREP, ioctl_gem_cpu_prep, DRM_AUTH), - DRM_IOCTL_DEF_DRV(OMAP_GEM_CPU_FINI, ioctl_gem_cpu_fini, DRM_AUTH), - DRM_IOCTL_DEF_DRV(OMAP_GEM_INFO, ioctl_gem_info, DRM_AUTH), + DRM_IOCTL_DEF_DRV(OMAP_GET_PARAM, ioctl_get_param, + DRM_AUTH | DRM_RENDER_ALLOW), + DRM_IOCTL_DEF_DRV(OMAP_SET_PARAM, ioctl_set_param, + DRM_AUTH | DRM_MASTER | DRM_ROOT_ONLY), + DRM_IOCTL_DEF_DRV(OMAP_GEM_NEW, ioctl_gem_new, + DRM_AUTH | DRM_RENDER_ALLOW), + DRM_IOCTL_DEF_DRV(OMAP_GEM_CPU_PREP, ioctl_gem_cpu_prep, + DRM_AUTH | DRM_RENDER_ALLOW), + DRM_IOCTL_DEF_DRV(OMAP_GEM_CPU_FINI, ioctl_gem_cpu_fini, + DRM_AUTH | DRM_RENDER_ALLOW), + DRM_IOCTL_DEF_DRV(OMAP_GEM_INFO, ioctl_gem_info, + DRM_AUTH | DRM_RENDER_ALLOW), };
/* @@ -806,7 +812,7 @@ static const struct file_operations omapdriver_fops = {
static struct drm_driver omap_drm_driver = { .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME | - DRIVER_ATOMIC, + DRIVER_ATOMIC | DRIVER_RENDER, .load = dev_load, .unload = dev_unload, .open = dev_open,
While implementing writeback support, odd behavior of WBDELAYCOUNT was observed with the combination of WB capture and HDMI. The result of the debugging was that the HDMI sync polarities are not set correctly.
The current code sets the sync polarities going from HDMI WP to DISPC according to the video mode used, which seems to work normally fine, but causes problems with WB as WB expects the syncs to be active-high.
This patch changes the HDMI sync polarities so that the DISPC always gets active-high syncs from HDMI WP, and the HDMI core gets sync polarities according to the used video mode.
Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/dss/hdmi_wp.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi_wp.c b/drivers/gpu/drm/omapdrm/dss/hdmi_wp.c index b783d5a0750e..597ec9d87d1d 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi_wp.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi_wp.c @@ -147,15 +147,17 @@ void hdmi_wp_video_config_interface(struct hdmi_wp_data *wp, struct videomode *vm) { u32 r; - bool vsync_pol, hsync_pol; + bool vsync_inv, hsync_inv; DSSDBG("Enter hdmi_wp_video_config_interface\n");
- vsync_pol = !!(vm->flags & DISPLAY_FLAGS_VSYNC_HIGH); - hsync_pol = !!(vm->flags & DISPLAY_FLAGS_HSYNC_HIGH); + vsync_inv = !!(vm->flags & DISPLAY_FLAGS_VSYNC_LOW); + hsync_inv = !!(vm->flags & DISPLAY_FLAGS_HSYNC_LOW);
r = hdmi_read_reg(wp->base, HDMI_WP_VIDEO_CFG); - r = FLD_MOD(r, vsync_pol, 7, 7); - r = FLD_MOD(r, hsync_pol, 6, 6); + r = FLD_MOD(r, 1, 7, 7); /* VSYNC_POL to dispc active high */ + r = FLD_MOD(r, 1, 6, 6); /* HSYNC_POL to dispc active high */ + r = FLD_MOD(r, vsync_inv, 5, 5); /* CORE_VSYNC_INV */ + r = FLD_MOD(r, hsync_inv, 4, 4); /* CORE_HSYNC_INV */ r = FLD_MOD(r, !!(vm->flags & DISPLAY_FLAGS_INTERLACED), 3, 3); r = FLD_MOD(r, 1, 1, 0); /* HDMI_TIMING_MASTER_24BIT */ hdmi_write_reg(wp->base, HDMI_WP_VIDEO_CFG, r);
Add omapdss_of_get_endpoint() helper function to get the endpoint node for the given port index and endpoint index.
Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/dss/dss-of.c | 61 +++++++++++++++++++++++++++++++++++ drivers/gpu/drm/omapdrm/dss/omapdss.h | 3 ++ 2 files changed, 64 insertions(+)
diff --git a/drivers/gpu/drm/omapdrm/dss/dss-of.c b/drivers/gpu/drm/omapdrm/dss/dss-of.c index dfd4e9621e3b..aa9415d3c60b 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss-of.c +++ b/drivers/gpu/drm/omapdrm/dss/dss-of.c @@ -180,3 +180,64 @@ omapdss_of_find_source_for_first_ep(struct device_node *node) return src ? src : ERR_PTR(-EPROBE_DEFER); } EXPORT_SYMBOL_GPL(omapdss_of_find_source_for_first_ep); + +static struct device_node *omapdss_of_get_port_by_index(struct device_node *parent, + int index) +{ + struct device_node *port; + + for (port = omapdss_of_get_next_port(parent, NULL); + port != NULL; + port = omapdss_of_get_next_port(parent, port)) { + u32 reg; + int r; + + r = of_property_read_u32(port, "reg", ®); + if (r) + reg = 0; + + if (reg == index) + return port; + } + + return NULL; +} + +static struct device_node *omapdss_of_get_endpoint_by_index(struct device_node *port, + int index) +{ + struct device_node *ep; + + for (ep = omapdss_of_get_next_endpoint(port, NULL); + ep != NULL; + ep = omapdss_of_get_next_endpoint(port, ep)) { + u32 reg; + int r; + + r = of_property_read_u32(ep, "reg", ®); + if (r) + reg = 0; + + if (reg == index) + return ep; + } + + return NULL; +} + +struct device_node *omapdss_of_get_endpoint(struct device_node *parent, + int port_index, int ep_index) +{ + struct device_node *port, *ep; + + port = omapdss_of_get_port_by_index(parent, port_index); + if (port == NULL) + return NULL; + + ep = omapdss_of_get_endpoint_by_index(port, ep_index); + + of_node_put(port); + + return ep; +} +EXPORT_SYMBOL_GPL(omapdss_of_get_endpoint); diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h index b420dde8c0fb..403bab718738 100644 --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h @@ -844,6 +844,9 @@ omapdss_of_get_first_endpoint(const struct device_node *parent); struct omap_dss_device * omapdss_of_find_source_for_first_ep(struct device_node *node);
+struct device_node *omapdss_of_get_endpoint(struct device_node *parent, + int port_index, int ep_index); + u32 dispc_read_irqstatus(void); void dispc_clear_irqstatus(u32 mask); u32 dispc_read_irqenable(void);
We are working towards enabling omapdss6, which will consists of a new dss, dispc and dpi drivers. omapdss6 will be a new module. The panel, encoder and omapdrm will need to use either the current omapdss driver or the new omapdss6 driver, depending on the platform.
This will be implemented with a common base module and function pointers.
This patch adds a skeleton omapdss-base.ko module, to which we'll be moving common dss functionality like registration of the panels.
Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/dss/Kconfig | 4 ++++ drivers/gpu/drm/omapdrm/dss/Makefile | 4 ++++ drivers/gpu/drm/omapdrm/dss/base.c | 6 ++++++ 3 files changed, 14 insertions(+) create mode 100644 drivers/gpu/drm/omapdrm/dss/base.c
diff --git a/drivers/gpu/drm/omapdrm/dss/Kconfig b/drivers/gpu/drm/omapdrm/dss/Kconfig index d1fa730c7d54..f53adb944a0d 100644 --- a/drivers/gpu/drm/omapdrm/dss/Kconfig +++ b/drivers/gpu/drm/omapdrm/dss/Kconfig @@ -1,8 +1,12 @@ config OMAP2_DSS_INIT bool
+config OMAP_DSS_BASE + tristate + menuconfig OMAP2_DSS tristate "OMAP2+ Display Subsystem support" + select OMAP_DSS_BASE select VIDEOMODE_HELPERS select OMAP2_DSS_INIT select HDMI diff --git a/drivers/gpu/drm/omapdrm/dss/Makefile b/drivers/gpu/drm/omapdrm/dss/Makefile index b651ec9751e6..c7d070168152 100644 --- a/drivers/gpu/drm/omapdrm/dss/Makefile +++ b/drivers/gpu/drm/omapdrm/dss/Makefile @@ -1,4 +1,8 @@ obj-$(CONFIG_OMAP2_DSS_INIT) += omapdss-boot-init.o + +obj-$(CONFIG_OMAP_DSS_BASE) += omapdss-base.o +omapdss-base-y := base.o + obj-$(CONFIG_OMAP2_DSS) += omapdss.o # Core DSS files omapdss-y := core.o dss.o dss_features.o dispc.o dispc_coefs.o display.o \ diff --git a/drivers/gpu/drm/omapdrm/dss/base.c b/drivers/gpu/drm/omapdrm/dss/base.c new file mode 100644 index 000000000000..943030a7523c --- /dev/null +++ b/drivers/gpu/drm/omapdrm/dss/base.c @@ -0,0 +1,6 @@ +#include <linux/kernel.h> +#include <linux/module.h> + +MODULE_AUTHOR("Tomi Valkeinen tomi.valkeinen@ti.com"); +MODULE_DESCRIPTION("OMAP Display Subsystem Base"); +MODULE_LICENSE("GPL v2");
omapdss_is_initialized() is used to find out if omapdss has been probed successfully. This patch moves the related code to the common omapdss-base module, so that the same support will be there for both omapdss and omapdss6.
Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/dss/base.c | 14 ++++++++++++++ drivers/gpu/drm/omapdrm/dss/dss.c | 12 ++---------- drivers/gpu/drm/omapdrm/dss/omapdss.h | 2 ++ 3 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/base.c b/drivers/gpu/drm/omapdrm/dss/base.c index 943030a7523c..03942097b9f1 100644 --- a/drivers/gpu/drm/omapdrm/dss/base.c +++ b/drivers/gpu/drm/omapdrm/dss/base.c @@ -1,6 +1,20 @@ #include <linux/kernel.h> #include <linux/module.h>
+static bool dss_initialized; + +void omapdss_set_is_initialized(bool set) +{ + dss_initialized = set; +} +EXPORT_SYMBOL(omapdss_set_is_initialized); + +bool omapdss_is_initialized(void) +{ + return dss_initialized; +} +EXPORT_SYMBOL(omapdss_is_initialized); + MODULE_AUTHOR("Tomi Valkeinen tomi.valkeinen@ti.com"); MODULE_DESCRIPTION("OMAP Display Subsystem Base"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c index 14887d5b02e5..e647cebe7d9d 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.c +++ b/drivers/gpu/drm/omapdrm/dss/dss.c @@ -117,14 +117,6 @@ static const char * const dss_generic_clk_source_names[] = { [DSS_CLK_SRC_HDMI_PLL] = "HDMI PLL", };
-static bool dss_initialized; - -bool omapdss_is_initialized(void) -{ - return dss_initialized; -} -EXPORT_SYMBOL(omapdss_is_initialized); - static inline void dss_write_reg(const struct dss_reg idx, u32 val) { __raw_writel(val, dss.base + idx.idx); @@ -1267,7 +1259,7 @@ static int dss_bind(struct device *dev)
pm_set_vt_switch(0);
- dss_initialized = true; + omapdss_set_is_initialized(true);
return 0;
@@ -1291,7 +1283,7 @@ static void dss_unbind(struct device *dev) { struct platform_device *pdev = to_platform_device(dev);
- dss_initialized = false; + omapdss_set_is_initialized(false);
component_unbind_all(&pdev->dev, NULL);
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h index 403bab718738..877484adbbdc 100644 --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h @@ -847,6 +847,8 @@ omapdss_of_find_source_for_first_ep(struct device_node *node); struct device_node *omapdss_of_get_endpoint(struct device_node *parent, int port_index, int ep_index);
+void omapdss_set_is_initialized(bool set); + u32 dispc_read_irqstatus(void); void dispc_clear_irqstatus(u32 mask); u32 dispc_read_irqenable(void);
We don't have omapdss's custom error printing functions in the common omapdss-base module, to which we want to move output.c.
This patch changes output.c to use dev_err instead of DSSERR so that it doesn't depend on DSSERR.
Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/dss/output.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/output.c b/drivers/gpu/drm/omapdrm/dss/output.c index a901af5a9bc3..0858958677a1 100644 --- a/drivers/gpu/drm/omapdrm/dss/output.c +++ b/drivers/gpu/drm/omapdrm/dss/output.c @@ -35,14 +35,15 @@ int omapdss_output_set_device(struct omap_dss_device *out, mutex_lock(&output_lock);
if (out->dst) { - DSSERR("output already has device %s connected to it\n", + dev_err(out->dev, + "output already has device %s connected to it\n", out->dst->name); r = -EINVAL; goto err; }
if (out->output_type != dssdev->type) { - DSSERR("output type and display type don't match\n"); + dev_err(out->dev, "output type and display type don't match\n"); r = -EINVAL; goto err; } @@ -67,14 +68,16 @@ int omapdss_output_unset_device(struct omap_dss_device *out) mutex_lock(&output_lock);
if (!out->dst) { - DSSERR("output doesn't have a device connected to it\n"); + dev_err(out->dev, + "output doesn't have a device connected to it\n"); r = -EINVAL; goto err; }
if (out->dst->state != OMAP_DSS_DISPLAY_DISABLED) { - DSSERR("device %s is not disabled, cannot unset device\n", - out->dst->name); + dev_err(out->dev, + "device %s is not disabled, cannot unset device\n", + out->dst->name); r = -EINVAL; goto err; }
display.c uses dsi_get_pixel_size() which is implemented in the DSI driver, and we won't have that in the omapdss-base module, to which we want to move display.c
This patch changes display.c not to use dsi_get_pixel_size(). The call can be replaced with a simple check for OMAP_DSS_DSI_FMT_RGB565.
We can also make dsi_get_pixel_size() static as it's no longer used outside dsi.c.
Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/dss/display.c | 6 +++--- drivers/gpu/drm/omapdrm/dss/dsi.c | 2 +- drivers/gpu/drm/omapdrm/dss/dss.h | 8 -------- 3 files changed, 4 insertions(+), 12 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/display.c b/drivers/gpu/drm/omapdrm/dss/display.c index 425a5a8dff8b..333ba284ef6d 100644 --- a/drivers/gpu/drm/omapdrm/dss/display.c +++ b/drivers/gpu/drm/omapdrm/dss/display.c @@ -55,10 +55,10 @@ int omapdss_default_get_recommended_bpp(struct omap_dss_device *dssdev) else return 16; case OMAP_DISPLAY_TYPE_DSI: - if (dsi_get_pixel_size(dssdev->panel.dsi_pix_fmt) > 16) - return 24; - else + if (dssdev->panel.dsi_pix_fmt == OMAP_DSS_DSI_FMT_RGB565) return 16; + else + return 24; case OMAP_DISPLAY_TYPE_VENC: case OMAP_DISPLAY_TYPE_SDI: case OMAP_DISPLAY_TYPE_HDMI: diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c index f060bda31235..404579883a5a 100644 --- a/drivers/gpu/drm/omapdrm/dss/dsi.c +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c @@ -527,7 +527,7 @@ static inline int wait_for_bit_change(struct platform_device *dsidev, return !value; }
-u8 dsi_get_pixel_size(enum omap_dss_dsi_pixel_format fmt) +static u8 dsi_get_pixel_size(enum omap_dss_dsi_pixel_format fmt) { switch (fmt) { case OMAP_DSS_DSI_FMT_RGB888: diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h index 56493b290731..5ed1713b1ca5 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.h +++ b/drivers/gpu/drm/omapdrm/dss/dss.h @@ -318,15 +318,7 @@ void dsi_uninit_platform_driver(void); void dsi_dump_clocks(struct seq_file *s);
void dsi_irq_handler(void); -u8 dsi_get_pixel_size(enum omap_dss_dsi_pixel_format fmt);
-#else -static inline u8 dsi_get_pixel_size(enum omap_dss_dsi_pixel_format fmt) -{ - WARN(1, "%s: DSI not compiled in, returning pixel_size as 0\n", - __func__); - return 0; -} #endif
/* DPI */
This patch moves the common parts of omapdss to omapdss-base so that both the current omapdss driver and the new omapdss6 driver can use them.
Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/dss/Makefile | 6 +++--- drivers/gpu/drm/omapdrm/dss/display.c | 2 -- drivers/gpu/drm/omapdrm/dss/dss-of.c | 3 ++- drivers/gpu/drm/omapdrm/dss/dss.h | 4 ---- drivers/gpu/drm/omapdrm/dss/omapdss.h | 3 +++ drivers/gpu/drm/omapdrm/dss/output.c | 1 - 6 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/Makefile b/drivers/gpu/drm/omapdrm/dss/Makefile index c7d070168152..75ec30f231c7 100644 --- a/drivers/gpu/drm/omapdrm/dss/Makefile +++ b/drivers/gpu/drm/omapdrm/dss/Makefile @@ -1,12 +1,12 @@ obj-$(CONFIG_OMAP2_DSS_INIT) += omapdss-boot-init.o
obj-$(CONFIG_OMAP_DSS_BASE) += omapdss-base.o -omapdss-base-y := base.o +omapdss-base-y := base.o display.o dss-of.o output.o
obj-$(CONFIG_OMAP2_DSS) += omapdss.o # Core DSS files -omapdss-y := core.o dss.o dss_features.o dispc.o dispc_coefs.o display.o \ - output.o dss-of.o pll.o video-pll.o +omapdss-y := core.o dss.o dss_features.o dispc.o dispc_coefs.o \ + pll.o video-pll.o omapdss-$(CONFIG_OMAP2_DSS_DPI) += dpi.o omapdss-$(CONFIG_OMAP2_DSS_RFBI) += rfbi.o omapdss-$(CONFIG_OMAP2_DSS_VENC) += venc.o diff --git a/drivers/gpu/drm/omapdrm/dss/display.c b/drivers/gpu/drm/omapdrm/dss/display.c index 333ba284ef6d..e567ff68b216 100644 --- a/drivers/gpu/drm/omapdrm/dss/display.c +++ b/drivers/gpu/drm/omapdrm/dss/display.c @@ -29,8 +29,6 @@ #include <linux/of.h>
#include "omapdss.h" -#include "dss.h" -#include "dss_features.h"
void omapdss_default_get_resolution(struct omap_dss_device *dssdev, u16 *xres, u16 *yres) diff --git a/drivers/gpu/drm/omapdrm/dss/dss-of.c b/drivers/gpu/drm/omapdrm/dss/dss-of.c index aa9415d3c60b..b5771593adc4 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss-of.c +++ b/drivers/gpu/drm/omapdrm/dss/dss-of.c @@ -19,7 +19,6 @@ #include <linux/seq_file.h>
#include "omapdss.h" -#include "dss.h"
struct device_node * omapdss_of_get_next_port(const struct device_node *parent, @@ -110,6 +109,7 @@ struct device_node *dss_of_port_get_parent_device(struct device_node *port)
return NULL; } +EXPORT_SYMBOL_GPL(dss_of_port_get_parent_device);
u32 dss_of_port_get_port_number(struct device_node *port) { @@ -122,6 +122,7 @@ u32 dss_of_port_get_port_number(struct device_node *port)
return reg; } +EXPORT_SYMBOL_GPL(dss_of_port_get_port_number);
static struct device_node *omapdss_of_get_remote_port(const struct device_node *node) { diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h index 5ed1713b1ca5..63bdf38f4b92 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.h +++ b/drivers/gpu/drm/omapdrm/dss/dss.h @@ -256,10 +256,6 @@ struct dss_pll *dss_video_pll_init(struct platform_device *pdev, int id, struct regulator *regulator); void dss_video_pll_uninit(struct dss_pll *pll);
-/* dss-of */ -struct device_node *dss_of_port_get_parent_device(struct device_node *port); -u32 dss_of_port_get_port_number(struct device_node *port); - #if defined(CONFIG_OMAP2_DSS_DEBUGFS) void dss_debug_dump_clocks(struct seq_file *s); #endif diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h index 877484adbbdc..c365652699e5 100644 --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h @@ -849,6 +849,9 @@ struct device_node *omapdss_of_get_endpoint(struct device_node *parent,
void omapdss_set_is_initialized(bool set);
+struct device_node *dss_of_port_get_parent_device(struct device_node *port); +u32 dss_of_port_get_port_number(struct device_node *port); + u32 dispc_read_irqstatus(void); void dispc_clear_irqstatus(u32 mask); u32 dispc_read_irqenable(void); diff --git a/drivers/gpu/drm/omapdrm/dss/output.c b/drivers/gpu/drm/omapdrm/dss/output.c index 0858958677a1..2b999dc48621 100644 --- a/drivers/gpu/drm/omapdrm/dss/output.c +++ b/drivers/gpu/drm/omapdrm/dss/output.c @@ -22,7 +22,6 @@ #include <linux/of.h>
#include "omapdss.h" -#include "dss.h"
static LIST_HEAD(output_list); static DEFINE_MUTEX(output_lock);
omapdrm still uses a few non-dispc functions: dss_feat_get_num_mgrs(), dss_feat_get_num_ovls() and dss_feat_get_supported_color_modes(). We want to provide omapdrm a single dispc_ops function pointer struct so that omapdrm will use either the current omapdss or the new omapdss6 driver depending on the platform.
Those three functions are really dispc functions, but are located in the dss_features.c for legacy reasons.
This patch adds similar functionss to the dispc, and changes omapdrm to use those new functions. Underneath the functions still call the functions from dss_feature.c.
Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/dss/dispc.c | 18 ++++++++++++++++++ drivers/gpu/drm/omapdrm/dss/dss_features.c | 3 --- drivers/gpu/drm/omapdrm/dss/dss_features.h | 4 ++++ drivers/gpu/drm/omapdrm/dss/omapdss.h | 5 +++++ drivers/gpu/drm/omapdrm/omap_drv.c | 4 ++-- drivers/gpu/drm/omapdrm/omap_plane.c | 2 +- 6 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c index c839f6456db2..c5d9dd51aec4 100644 --- a/drivers/gpu/drm/omapdrm/dss/dispc.c +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c @@ -1122,6 +1122,18 @@ static u32 dispc_ovl_get_burst_size(enum omap_plane plane) return unit * 8; }
+enum omap_color_mode dispc_ovl_get_color_modes(enum omap_plane plane) +{ + return dss_feat_get_supported_color_modes(plane); +} +EXPORT_SYMBOL(dispc_ovl_get_color_modes); + +int dispc_get_num_ovls(void) +{ + return dss_feat_get_num_ovls(); +} +EXPORT_SYMBOL(dispc_get_num_ovls); + static void dispc_mgr_enable_cpr(enum omap_channel channel, bool enable) { if (channel == OMAP_DSS_CHANNEL_DIGIT) @@ -2949,6 +2961,12 @@ void dispc_pck_free_enable(bool enable) REG_FLD_MOD(DISPC_CONTROL, enable ? 1 : 0, 27, 27); }
+int dispc_get_num_mgrs(void) +{ + return dss_feat_get_num_mgrs(); +} +EXPORT_SYMBOL(dispc_get_num_mgrs); + static void dispc_mgr_enable_fifohandcheck(enum omap_channel channel, bool enable) { mgr_fld_write(channel, DISPC_MGR_FLD_FIFOHANDCHECK, enable); diff --git a/drivers/gpu/drm/omapdrm/dss/dss_features.c b/drivers/gpu/drm/omapdrm/dss/dss_features.c index ee5b93ce2763..26c29332b8e3 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss_features.c +++ b/drivers/gpu/drm/omapdrm/dss/dss_features.c @@ -774,13 +774,11 @@ int dss_feat_get_num_mgrs(void) { return omap_current_dss_features->num_mgrs; } -EXPORT_SYMBOL(dss_feat_get_num_mgrs);
int dss_feat_get_num_ovls(void) { return omap_current_dss_features->num_ovls; } -EXPORT_SYMBOL(dss_feat_get_num_ovls);
unsigned long dss_feat_get_param_min(enum dss_range_param param) { @@ -806,7 +804,6 @@ enum omap_color_mode dss_feat_get_supported_color_modes(enum omap_plane plane) { return omap_current_dss_features->supported_color_modes[plane]; } -EXPORT_SYMBOL(dss_feat_get_supported_color_modes);
enum omap_overlay_caps dss_feat_get_overlay_caps(enum omap_plane plane) { diff --git a/drivers/gpu/drm/omapdrm/dss/dss_features.h b/drivers/gpu/drm/omapdrm/dss/dss_features.h index bb4b7f0e642b..bcec68ba8db9 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss_features.h +++ b/drivers/gpu/drm/omapdrm/dss/dss_features.h @@ -104,4 +104,8 @@ void dss_features_init(enum omapdss_version version); enum omap_display_type dss_feat_get_supported_displays(enum omap_channel channel); enum omap_dss_output_id dss_feat_get_supported_outputs(enum omap_channel channel);
+int dss_feat_get_num_mgrs(void); +int dss_feat_get_num_ovls(void); +enum omap_color_mode dss_feat_get_supported_color_modes(enum omap_plane plane); + #endif diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h index c365652699e5..aed76d6f41f6 100644 --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h @@ -863,6 +863,9 @@ void dispc_free_irq(void *dev_id); int dispc_runtime_get(void); void dispc_runtime_put(void);
+int dispc_get_num_ovls(void); +int dispc_get_num_mgrs(void); + void dispc_mgr_enable(enum omap_channel channel, bool enable); bool dispc_mgr_is_enabled(enum omap_channel channel); u32 dispc_mgr_get_vsync_irq(enum omap_channel channel); @@ -876,6 +879,7 @@ void dispc_mgr_set_timings(enum omap_channel channel, const struct videomode *vm); void dispc_mgr_setup(enum omap_channel channel, const struct omap_overlay_manager_info *info); +enum omap_dss_output_id dispc_mgr_get_supported_outputs(enum omap_channel channel); u32 dispc_mgr_gamma_size(enum omap_channel channel); void dispc_mgr_set_gamma(enum omap_channel channel, const struct drm_color_lut *lut, @@ -887,6 +891,7 @@ void dispc_ovl_set_channel_out(enum omap_plane plane, enum omap_channel channel); int dispc_ovl_setup(enum omap_plane plane, const struct omap_overlay_info *oi, bool replication, const struct videomode *vm, bool mem_to_mem); +enum omap_color_mode dispc_ovl_get_color_modes(enum omap_plane plane);
enum omap_dss_output_id dispc_mgr_get_supported_outputs(enum omap_channel channel);
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c index f7af377561d8..e655b8a16f48 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.c +++ b/drivers/gpu/drm/omapdrm/omap_drv.c @@ -313,8 +313,8 @@ static int omap_modeset_init(struct drm_device *dev) { struct omap_drm_private *priv = dev->dev_private; struct omap_dss_device *dssdev = NULL; - int num_ovls = dss_feat_get_num_ovls(); - int num_mgrs = dss_feat_get_num_mgrs(); + int num_ovls = dispc_get_num_ovls(); + int num_mgrs = dispc_get_num_mgrs(); int num_crtcs; int i, id = 0; int ret; diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c index 9c43cb481e62..0e861a44fd5e 100644 --- a/drivers/gpu/drm/omapdrm/omap_plane.c +++ b/drivers/gpu/drm/omapdrm/omap_plane.c @@ -371,7 +371,7 @@ struct drm_plane *omap_plane_init(struct drm_device *dev,
omap_plane->nformats = omap_framebuffer_get_formats( omap_plane->formats, ARRAY_SIZE(omap_plane->formats), - dss_feat_get_supported_color_modes(id)); + dispc_ovl_get_color_modes(id)); omap_plane->id = id; omap_plane->name = plane_names[id];
We want to change the dispc API from plain functions to a struct with functions pointers, so that omapdrm can call either omapdss or omapdss6 depending on the platform.
This patch adds 'struct dispc_ops' and adds functions to omapdss-base to set and get the ops.
Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/dss/base.c | 13 +++++++++ drivers/gpu/drm/omapdrm/dss/omapdss.h | 50 +++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+)
diff --git a/drivers/gpu/drm/omapdrm/dss/base.c b/drivers/gpu/drm/omapdrm/dss/base.c index 03942097b9f1..7dd447e6c4d7 100644 --- a/drivers/gpu/drm/omapdrm/dss/base.c +++ b/drivers/gpu/drm/omapdrm/dss/base.c @@ -2,6 +2,7 @@ #include <linux/module.h>
static bool dss_initialized; +static const struct dispc_ops *ops;
void omapdss_set_is_initialized(bool set) { @@ -15,6 +16,18 @@ bool omapdss_is_initialized(void) } EXPORT_SYMBOL(omapdss_is_initialized);
+void dispc_set_ops(const struct dispc_ops *o) +{ + ops = o; +} +EXPORT_SYMBOL(dispc_set_ops); + +const struct dispc_ops *dispc_get_ops(void) +{ + return ops; +} +EXPORT_SYMBOL(dispc_get_ops); + MODULE_AUTHOR("Tomi Valkeinen tomi.valkeinen@ti.com"); MODULE_DESCRIPTION("OMAP Display Subsystem Base"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h index aed76d6f41f6..134f153669ea 100644 --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h @@ -933,4 +933,54 @@ int dss_mgr_register_framedone_handler(enum omap_channel channel, void dss_mgr_unregister_framedone_handler(enum omap_channel channel, void (*handler)(void *), void *data);
+/* dispc ops */ + +struct dispc_ops { + u32 (*read_irqstatus)(void); + void (*clear_irqstatus)(u32 mask); + u32 (*read_irqenable)(void); + void (*write_irqenable)(u32 mask); + + int (*request_irq)(irq_handler_t handler, void *dev_id); + void (*free_irq)(void *dev_id); + + int (*runtime_get)(void); + void (*runtime_put)(void); + + int (*get_num_ovls)(void); + int (*get_num_mgrs)(void); + + void (*mgr_enable)(enum omap_channel channel, bool enable); + bool (*mgr_is_enabled)(enum omap_channel channel); + u32 (*mgr_get_vsync_irq)(enum omap_channel channel); + u32 (*mgr_get_framedone_irq)(enum omap_channel channel); + u32 (*mgr_get_sync_lost_irq)(enum omap_channel channel); + bool (*mgr_go_busy)(enum omap_channel channel); + void (*mgr_go)(enum omap_channel channel); + void (*mgr_set_lcd_config)(enum omap_channel channel, + const struct dss_lcd_mgr_config *config); + void (*mgr_set_timings)(enum omap_channel channel, + const struct videomode *vm); + void (*mgr_setup)(enum omap_channel channel, + const struct omap_overlay_manager_info *info); + enum omap_dss_output_id (*mgr_get_supported_outputs)(enum omap_channel channel); + u32 (*mgr_gamma_size)(enum omap_channel channel); + void (*mgr_set_gamma)(enum omap_channel channel, + const struct drm_color_lut *lut, + unsigned int length); + + int (*ovl_enable)(enum omap_plane plane, bool enable); + bool (*ovl_enabled)(enum omap_plane plane); + void (*ovl_set_channel_out)(enum omap_plane plane, + enum omap_channel channel); + int (*ovl_setup)(enum omap_plane plane, const struct omap_overlay_info *oi, + bool replication, const struct videomode *vm, + bool mem_to_mem); + + enum omap_color_mode (*ovl_get_color_modes)(enum omap_plane plane); +}; + +void dispc_set_ops(const struct dispc_ops *o); +const struct dispc_ops *dispc_get_ops(void); + #endif /* __OMAP_DRM_DSS_H */
This patch changes the current omapdss driver to fill a dispc_ops struct and set it to omapdss-base.
Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/dss/dispc.c | 40 +++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c index c5d9dd51aec4..00cddb119dab 100644 --- a/drivers/gpu/drm/omapdrm/dss/dispc.c +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c @@ -4341,6 +4341,42 @@ static void dispc_errata_i734_wa(void) REG_FLD_MOD(DISPC_CONFIG, gatestate, 8, 4); }
+static const struct dispc_ops dispc_ops = { + .read_irqstatus = dispc_read_irqstatus, + .clear_irqstatus = dispc_clear_irqstatus, + .read_irqenable = dispc_read_irqenable, + .write_irqenable = dispc_write_irqenable, + + .request_irq = dispc_request_irq, + .free_irq = dispc_free_irq, + + .runtime_get = dispc_runtime_get, + .runtime_put = dispc_runtime_put, + + .get_num_ovls = dispc_get_num_ovls, + .get_num_mgrs = dispc_get_num_mgrs, + + .mgr_enable = dispc_mgr_enable, + .mgr_is_enabled = dispc_mgr_is_enabled, + .mgr_get_vsync_irq = dispc_mgr_get_vsync_irq, + .mgr_get_framedone_irq = dispc_mgr_get_framedone_irq, + .mgr_get_sync_lost_irq = dispc_mgr_get_sync_lost_irq, + .mgr_go_busy = dispc_mgr_go_busy, + .mgr_go = dispc_mgr_go, + .mgr_set_lcd_config = dispc_mgr_set_lcd_config, + .mgr_set_timings = dispc_mgr_set_timings, + .mgr_setup = dispc_mgr_setup, + .mgr_get_supported_outputs = dispc_mgr_get_supported_outputs, + .mgr_gamma_size = dispc_mgr_gamma_size, + .mgr_set_gamma = dispc_mgr_set_gamma, + + .ovl_enable = dispc_ovl_enable, + .ovl_enabled = dispc_ovl_enabled, + .ovl_set_channel_out = dispc_ovl_set_channel_out, + .ovl_setup = dispc_ovl_setup, + .ovl_get_color_modes = dispc_ovl_get_color_modes, +}; + /* DISPC HW IP initialisation */ static int dispc_bind(struct device *dev, struct device *master, void *data) { @@ -4413,6 +4449,8 @@ static int dispc_bind(struct device *dev, struct device *master, void *data)
dispc_runtime_put();
+ dispc_set_ops(&dispc_ops); + dss_debugfs_create_file("dispc", dispc_dump_regs);
return 0; @@ -4425,6 +4463,8 @@ static int dispc_bind(struct device *dev, struct device *master, void *data) static void dispc_unbind(struct device *dev, struct device *master, void *data) { + dispc_set_ops(NULL); + pm_runtime_disable(dev);
dispc_errata_i734_wa_fini();
Change omapdrm to get dispc_ops and use that to call the dispc functions instead or direct function calls.
The change is very straightforward.
The only problem was in omap_crtc_init() which calls pipe2vbl(crtc), and at that point of time the crtc->dev link, which is used to get the dispc_ops, has not been set up yet. This patch makes omap_crtc_init() skip the call to pipe2vbl() and instead calls dispc_ops->mgr_get_vsync_irq() directly.
Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/omap_crtc.c | 47 ++++++++++++++++++++++-------------- drivers/gpu/drm/omapdrm/omap_drv.c | 10 +++++--- drivers/gpu/drm/omapdrm/omap_drv.h | 2 ++ drivers/gpu/drm/omapdrm/omap_irq.c | 33 ++++++++++++++----------- drivers/gpu/drm/omapdrm/omap_plane.c | 14 ++++++----- 5 files changed, 64 insertions(+), 42 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c index c0e30a4cb2a9..f3fd786de598 100644 --- a/drivers/gpu/drm/omapdrm/omap_crtc.c +++ b/drivers/gpu/drm/omapdrm/omap_crtc.c @@ -59,8 +59,9 @@ struct omap_crtc_state { uint32_t pipe2vbl(struct drm_crtc *crtc) { struct omap_crtc *omap_crtc = to_omap_crtc(crtc); + struct omap_drm_private *priv = crtc->dev->dev_private;
- return dispc_mgr_get_vsync_irq(omap_crtc->channel); + return priv->dispc_ops->mgr_get_vsync_irq(omap_crtc->channel); }
struct videomode *omap_crtc_timings(struct drm_crtc *crtc) @@ -109,10 +110,12 @@ static struct omap_dss_device *omap_crtc_output[8]; static int omap_crtc_dss_connect(enum omap_channel channel, struct omap_dss_device *dst) { + const struct dispc_ops *dispc_ops = dispc_get_ops(); + if (omap_crtc_output[channel]) return -EINVAL;
- if ((dispc_mgr_get_supported_outputs(channel) & dst->id) == 0) + if ((dispc_ops->mgr_get_supported_outputs(channel) & dst->id) == 0) return -EINVAL;
omap_crtc_output[channel] = dst; @@ -136,6 +139,7 @@ static void omap_crtc_dss_start_update(enum omap_channel channel) static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable) { struct drm_device *dev = crtc->dev; + struct omap_drm_private *priv = dev->dev_private; struct omap_crtc *omap_crtc = to_omap_crtc(crtc); enum omap_channel channel = omap_crtc->channel; struct omap_irq_wait *wait; @@ -143,11 +147,11 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable) int ret;
if (omap_crtc_output[channel]->output_type == OMAP_DISPLAY_TYPE_HDMI) { - dispc_mgr_enable(channel, enable); + priv->dispc_ops->mgr_enable(channel, enable); return; }
- if (dispc_mgr_is_enabled(channel) == enable) + if (priv->dispc_ops->mgr_is_enabled(channel) == enable) return;
if (omap_crtc->channel == OMAP_DSS_CHANNEL_DIGIT) { @@ -158,8 +162,8 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable) omap_crtc->ignore_digit_sync_lost = true; }
- framedone_irq = dispc_mgr_get_framedone_irq(channel); - vsync_irq = dispc_mgr_get_vsync_irq(channel); + framedone_irq = priv->dispc_ops->mgr_get_framedone_irq(channel); + vsync_irq = priv->dispc_ops->mgr_get_vsync_irq(channel);
if (enable) { wait = omap_irq_wait_init(dev, vsync_irq, 1); @@ -179,7 +183,7 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable) wait = omap_irq_wait_init(dev, vsync_irq, 2); }
- dispc_mgr_enable(channel, enable); + priv->dispc_ops->mgr_enable(channel, enable);
ret = omap_irq_wait(dev, wait, msecs_to_jiffies(100)); if (ret) { @@ -198,9 +202,9 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable) static int omap_crtc_dss_enable(enum omap_channel channel) { struct omap_crtc *omap_crtc = omap_crtcs[channel]; + struct omap_drm_private *priv = omap_crtc->base.dev->dev_private;
- dispc_mgr_set_timings(omap_crtc->channel, - &omap_crtc->vm); + priv->dispc_ops->mgr_set_timings(omap_crtc->channel, &omap_crtc->vm); omap_crtc_set_enabled(&omap_crtc->base, true);
return 0; @@ -225,8 +229,10 @@ static void omap_crtc_dss_set_lcd_config(enum omap_channel channel, const struct dss_lcd_mgr_config *config) { struct omap_crtc *omap_crtc = omap_crtcs[channel]; + struct omap_drm_private *priv = omap_crtc->base.dev->dev_private; + DBG("%s", omap_crtc->name); - dispc_mgr_set_lcd_config(omap_crtc->channel, config); + priv->dispc_ops->mgr_set_lcd_config(omap_crtc->channel, config); }
static int omap_crtc_dss_register_framedone( @@ -293,8 +299,9 @@ static void omap_crtc_vblank_irq(struct omap_drm_irq *irq, uint32_t irqstatus) struct omap_crtc *omap_crtc = container_of(irq, struct omap_crtc, vblank_irq); struct drm_device *dev = omap_crtc->base.dev; + struct omap_drm_private *priv = dev->dev_private;
- if (dispc_mgr_go_busy(omap_crtc->channel)) + if (priv->dispc_ops->mgr_go_busy(omap_crtc->channel)) return;
DBG("%s: apply done", omap_crtc->name); @@ -315,6 +322,7 @@ static void omap_crtc_vblank_irq(struct omap_drm_irq *irq, uint32_t irqstatus)
static void omap_crtc_write_crtc_properties(struct drm_crtc *crtc) { + struct omap_drm_private *priv = crtc->dev->dev_private; struct omap_crtc *omap_crtc = to_omap_crtc(crtc); struct omap_overlay_manager_info info; const struct omap_crtc_state *omap_state = @@ -324,7 +332,7 @@ static void omap_crtc_write_crtc_properties(struct drm_crtc *crtc) info.default_color = omap_state->default_color; info.trans_enabled = false;
- dispc_mgr_setup(omap_crtc->channel, &info); + priv->dispc_ops->mgr_setup(omap_crtc->channel, &info); }
/* ----------------------------------------------------------------------------- @@ -455,6 +463,7 @@ static void omap_crtc_atomic_begin(struct drm_crtc *crtc, static void omap_crtc_atomic_flush(struct drm_crtc *crtc, struct drm_crtc_state *old_crtc_state) { + struct omap_drm_private *priv = crtc->dev->dev_private; struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
WARN_ON(omap_crtc->vblank_irq.registered); @@ -469,12 +478,12 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc, length = crtc->state->gamma_lut->length / sizeof(*lut); } - dispc_mgr_set_gamma(omap_crtc->channel, lut, length); + priv->dispc_ops->mgr_set_gamma(omap_crtc->channel, lut, length); }
omap_crtc_write_crtc_properties(crtc);
- if (dispc_mgr_is_enabled(omap_crtc->channel)) { + if (priv->dispc_ops->mgr_is_enabled(omap_crtc->channel)) {
DBG("%s: GO", omap_crtc->name);
@@ -483,7 +492,7 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc, omap_crtc->pending = true; wmb();
- dispc_mgr_go(omap_crtc->channel); + priv->dispc_ops->mgr_go(omap_crtc->channel); omap_irq_register(crtc->dev, &omap_crtc->vblank_irq); } } @@ -616,6 +625,7 @@ static void omap_crtc_install_properties(struct drm_crtc *crtc) struct drm_crtc *omap_crtc_init(struct drm_device *dev, struct drm_plane *plane, enum omap_channel channel, int id) { + struct omap_drm_private *priv = dev->dev_private; struct drm_crtc *crtc = NULL; struct omap_crtc *omap_crtc; int ret; @@ -633,11 +643,12 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev, omap_crtc->channel = channel; omap_crtc->name = channel_names[channel];
- omap_crtc->vblank_irq.irqmask = pipe2vbl(crtc); + omap_crtc->vblank_irq.irqmask = + priv->dispc_ops->mgr_get_vsync_irq(channel); omap_crtc->vblank_irq.irq = omap_crtc_vblank_irq;
omap_crtc->error_irq.irqmask = - dispc_mgr_get_sync_lost_irq(channel); + priv->dispc_ops->mgr_get_sync_lost_irq(channel); omap_crtc->error_irq.irq = omap_crtc_error_irq; omap_irq_register(dev, &omap_crtc->error_irq);
@@ -657,7 +668,7 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev, * extracted with dispc_mgr_gamma_size(). If it returns 0 * gamma table is not supprted. */ - if (dispc_mgr_gamma_size(channel)) { + if (priv->dispc_ops->mgr_gamma_size(channel)) { uint gamma_lut_size = 256;
drm_crtc_enable_color_mgmt(crtc, 0, false, gamma_lut_size); diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c index e655b8a16f48..4894e09a75f6 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.c +++ b/drivers/gpu/drm/omapdrm/omap_drv.c @@ -93,7 +93,7 @@ static void omap_atomic_complete(struct omap_atomic_state_commit *commit) struct drm_atomic_state *old_state = commit->state;
/* Apply the atomic update. */ - dispc_runtime_get(); + priv->dispc_ops->runtime_get();
drm_atomic_helper_commit_modeset_disables(dev, old_state); drm_atomic_helper_commit_planes(dev, old_state, 0); @@ -103,7 +103,7 @@ static void omap_atomic_complete(struct omap_atomic_state_commit *commit)
drm_atomic_helper_cleanup_planes(dev, old_state);
- dispc_runtime_put(); + priv->dispc_ops->runtime_put();
drm_atomic_state_put(old_state);
@@ -313,8 +313,8 @@ static int omap_modeset_init(struct drm_device *dev) { struct omap_drm_private *priv = dev->dev_private; struct omap_dss_device *dssdev = NULL; - int num_ovls = dispc_get_num_ovls(); - int num_mgrs = dispc_get_num_mgrs(); + int num_ovls = priv->dispc_ops->get_num_ovls(); + int num_mgrs = priv->dispc_ops->get_num_mgrs(); int num_crtcs; int i, id = 0; int ret; @@ -665,6 +665,8 @@ static int dev_load(struct drm_device *dev, unsigned long flags)
priv->omaprev = pdata->omaprev;
+ priv->dispc_ops = dispc_get_ops(); + dev->dev_private = priv;
priv->wq = alloc_ordered_workqueue("omapdrm", 0); diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h index 0d16294e8145..11427f21e2ef 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.h +++ b/drivers/gpu/drm/omapdrm/omap_drv.h @@ -72,6 +72,8 @@ int omap_irq_wait(struct drm_device *dev, struct omap_irq_wait *wait, struct omap_drm_private { uint32_t omaprev;
+ const struct dispc_ops *dispc_ops; + unsigned int num_crtcs; struct drm_crtc *crtcs[8];
diff --git a/drivers/gpu/drm/omapdrm/omap_irq.c b/drivers/gpu/drm/omapdrm/omap_irq.c index 60e1e8016708..7e5374f201b7 100644 --- a/drivers/gpu/drm/omapdrm/omap_irq.c +++ b/drivers/gpu/drm/omapdrm/omap_irq.c @@ -41,8 +41,8 @@ static void omap_irq_update(struct drm_device *dev)
DBG("irqmask=%08x", irqmask);
- dispc_write_irqenable(irqmask); - dispc_read_irqenable(); /* flush posted write */ + priv->dispc_ops->write_irqenable(irqmask); + priv->dispc_ops->read_irqenable(); /* flush posted write */ }
void __omap_irq_register(struct drm_device *dev, struct omap_drm_irq *irq) @@ -63,11 +63,13 @@ void __omap_irq_register(struct drm_device *dev, struct omap_drm_irq *irq)
void omap_irq_register(struct drm_device *dev, struct omap_drm_irq *irq) { - dispc_runtime_get(); + struct omap_drm_private *priv = dev->dev_private; + + priv->dispc_ops->runtime_get();
__omap_irq_register(dev, irq);
- dispc_runtime_put(); + priv->dispc_ops->runtime_put(); }
void __omap_irq_unregister(struct drm_device *dev, struct omap_drm_irq *irq) @@ -87,11 +89,13 @@ void __omap_irq_unregister(struct drm_device *dev, struct omap_drm_irq *irq)
void omap_irq_unregister(struct drm_device *dev, struct omap_drm_irq *irq) { - dispc_runtime_get(); + struct omap_drm_private *priv = dev->dev_private; + + priv->dispc_ops->runtime_get();
__omap_irq_unregister(dev, irq);
- dispc_runtime_put(); + priv->dispc_ops->runtime_put(); }
struct omap_irq_wait { @@ -192,9 +196,9 @@ static irqreturn_t omap_irq_handler(int irq, void *arg) unsigned int id; u32 irqstatus;
- irqstatus = dispc_read_irqstatus(); - dispc_clear_irqstatus(irqstatus); - dispc_read_irqstatus(); /* flush posted write */ + irqstatus = priv->dispc_ops->read_irqstatus(); + priv->dispc_ops->clear_irqstatus(irqstatus); + priv->dispc_ops->read_irqstatus(); /* flush posted write */
VERB("irqs: %08x", irqstatus);
@@ -233,11 +237,11 @@ int omap_drm_irq_install(struct drm_device *dev)
INIT_LIST_HEAD(&priv->irq_list);
- dispc_runtime_get(); - dispc_clear_irqstatus(0xffffffff); - dispc_runtime_put(); + priv->dispc_ops->runtime_get(); + priv->dispc_ops->clear_irqstatus(0xffffffff); + priv->dispc_ops->runtime_put();
- ret = dispc_request_irq(omap_irq_handler, dev); + ret = priv->dispc_ops->request_irq(omap_irq_handler, dev); if (ret < 0) return ret;
@@ -258,6 +262,7 @@ int omap_drm_irq_install(struct drm_device *dev)
void omap_drm_irq_uninstall(struct drm_device *dev) { + struct omap_drm_private *priv = dev->dev_private; unsigned long irqflags; int i;
@@ -278,5 +283,5 @@ void omap_drm_irq_uninstall(struct drm_device *dev) spin_unlock_irqrestore(&dev->vbl_lock, irqflags); }
- dispc_free_irq(dev); + priv->dispc_ops->free_irq(dev); } diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c index 0e861a44fd5e..b674c5cc77e8 100644 --- a/drivers/gpu/drm/omapdrm/omap_plane.c +++ b/drivers/gpu/drm/omapdrm/omap_plane.c @@ -78,6 +78,7 @@ static void omap_plane_cleanup_fb(struct drm_plane *plane, static void omap_plane_atomic_update(struct drm_plane *plane, struct drm_plane_state *old_state) { + struct omap_drm_private *priv = plane->dev->dev_private; struct omap_plane *omap_plane = to_omap_plane(plane); struct drm_plane_state *state = plane->state; struct omap_plane_state *omap_state = to_omap_plane_state(state); @@ -125,25 +126,26 @@ static void omap_plane_atomic_update(struct drm_plane *plane, DBG("%d,%d %pad %pad", info.pos_x, info.pos_y, &info.paddr, &info.p_uv_addr);
- dispc_ovl_set_channel_out(omap_plane->id, + priv->dispc_ops->ovl_set_channel_out(omap_plane->id, omap_crtc_channel(state->crtc));
/* and finally, update omapdss: */ - ret = dispc_ovl_setup(omap_plane->id, &info, false, + ret = priv->dispc_ops->ovl_setup(omap_plane->id, &info, false, omap_crtc_timings(state->crtc), false); if (ret) { dev_err(plane->dev->dev, "Failed to setup plane %s\n", omap_plane->name); - dispc_ovl_enable(omap_plane->id, false); + priv->dispc_ops->ovl_enable(omap_plane->id, false); return; }
- dispc_ovl_enable(omap_plane->id, true); + priv->dispc_ops->ovl_enable(omap_plane->id, true); }
static void omap_plane_atomic_disable(struct drm_plane *plane, struct drm_plane_state *old_state) { + struct omap_drm_private *priv = plane->dev->dev_private; struct omap_plane_state *omap_state = to_omap_plane_state(plane->state); struct omap_plane *omap_plane = to_omap_plane(plane);
@@ -151,7 +153,7 @@ static void omap_plane_atomic_disable(struct drm_plane *plane, omap_state->zorder = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : omap_plane->id;
- dispc_ovl_enable(omap_plane->id, false); + priv->dispc_ops->ovl_enable(omap_plane->id, false); }
static int omap_plane_atomic_check(struct drm_plane *plane, @@ -371,7 +373,7 @@ struct drm_plane *omap_plane_init(struct drm_device *dev,
omap_plane->nformats = omap_framebuffer_get_formats( omap_plane->formats, ARRAY_SIZE(omap_plane->formats), - dispc_ovl_get_color_modes(id)); + priv->dispc_ops->ovl_get_color_modes(id)); omap_plane->id = id; omap_plane->name = plane_names[id];
omapdrm now uses dispc_ops instead of direct function calls so we can remove all EXPORT_SYMBOLs from dispc. Most of the functions can also be made static, but a few are used outside dispc.c.
Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/dss/dispc.c | 87 +++++++++++++---------------------- drivers/gpu/drm/omapdrm/dss/dss.h | 3 ++ drivers/gpu/drm/omapdrm/dss/omapdss.h | 43 ----------------- 3 files changed, 34 insertions(+), 99 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c index 00cddb119dab..cfc6daf2cedf 100644 --- a/drivers/gpu/drm/omapdrm/dss/dispc.c +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c @@ -306,6 +306,10 @@ static unsigned long dispc_mgr_pclk_rate(enum omap_channel channel); static unsigned long dispc_plane_pclk_rate(enum omap_plane plane); static unsigned long dispc_plane_lclk_rate(enum omap_plane plane);
+static void dispc_clear_irqstatus(u32 mask); +static bool dispc_mgr_is_enabled(enum omap_channel channel); +static void dispc_clear_irqstatus(u32 mask); + static inline void dispc_write_reg(const u16 idx, u32 val) { __raw_writel(val, dispc.base + idx); @@ -581,7 +585,6 @@ int dispc_runtime_get(void) WARN_ON(r < 0); return r < 0 ? r : 0; } -EXPORT_SYMBOL(dispc_runtime_get);
void dispc_runtime_put(void) { @@ -592,41 +595,36 @@ void dispc_runtime_put(void) r = pm_runtime_put_sync(&dispc.pdev->dev); WARN_ON(r < 0 && r != -ENOSYS); } -EXPORT_SYMBOL(dispc_runtime_put);
-u32 dispc_mgr_get_vsync_irq(enum omap_channel channel) +static u32 dispc_mgr_get_vsync_irq(enum omap_channel channel) { return mgr_desc[channel].vsync_irq; } -EXPORT_SYMBOL(dispc_mgr_get_vsync_irq);
-u32 dispc_mgr_get_framedone_irq(enum omap_channel channel) +static u32 dispc_mgr_get_framedone_irq(enum omap_channel channel) { if (channel == OMAP_DSS_CHANNEL_DIGIT && dispc.feat->no_framedone_tv) return 0;
return mgr_desc[channel].framedone_irq; } -EXPORT_SYMBOL(dispc_mgr_get_framedone_irq);
-u32 dispc_mgr_get_sync_lost_irq(enum omap_channel channel) +static u32 dispc_mgr_get_sync_lost_irq(enum omap_channel channel) { return mgr_desc[channel].sync_lost_irq; } -EXPORT_SYMBOL(dispc_mgr_get_sync_lost_irq);
u32 dispc_wb_get_framedone_irq(void) { return DISPC_IRQ_FRAMEDONEWB; }
-bool dispc_mgr_go_busy(enum omap_channel channel) +static bool dispc_mgr_go_busy(enum omap_channel channel) { return mgr_fld_read(channel, DISPC_MGR_FLD_GO) == 1; } -EXPORT_SYMBOL(dispc_mgr_go_busy);
-void dispc_mgr_go(enum omap_channel channel) +static void dispc_mgr_go(enum omap_channel channel) { WARN_ON(!dispc_mgr_is_enabled(channel)); WARN_ON(dispc_mgr_go_busy(channel)); @@ -635,7 +633,6 @@ void dispc_mgr_go(enum omap_channel channel)
mgr_fld_write(channel, DISPC_MGR_FLD_GO, 1); } -EXPORT_SYMBOL(dispc_mgr_go);
bool dispc_wb_go_busy(void) { @@ -984,7 +981,7 @@ static void dispc_ovl_configure_burst_type(enum omap_plane plane, REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), 0, 29, 29); }
-void dispc_ovl_set_channel_out(enum omap_plane plane, enum omap_channel channel) +static void dispc_ovl_set_channel_out(enum omap_plane plane, enum omap_channel channel) { int shift; u32 val; @@ -1044,7 +1041,6 @@ void dispc_ovl_set_channel_out(enum omap_plane plane, enum omap_channel channel) } dispc_write_reg(DISPC_OVL_ATTRIBUTES(plane), val); } -EXPORT_SYMBOL(dispc_ovl_set_channel_out);
static enum omap_channel dispc_ovl_get_channel_out(enum omap_plane plane) { @@ -1122,17 +1118,15 @@ static u32 dispc_ovl_get_burst_size(enum omap_plane plane) return unit * 8; }
-enum omap_color_mode dispc_ovl_get_color_modes(enum omap_plane plane) +static enum omap_color_mode dispc_ovl_get_color_modes(enum omap_plane plane) { return dss_feat_get_supported_color_modes(plane); } -EXPORT_SYMBOL(dispc_ovl_get_color_modes);
-int dispc_get_num_ovls(void) +static int dispc_get_num_ovls(void) { return dss_feat_get_num_ovls(); } -EXPORT_SYMBOL(dispc_get_num_ovls);
static void dispc_mgr_enable_cpr(enum omap_channel channel, bool enable) { @@ -2797,9 +2791,8 @@ static int dispc_ovl_setup_common(enum omap_plane plane, return 0; }
-int dispc_ovl_setup(enum omap_plane plane, const struct omap_overlay_info *oi, - bool replication, const struct videomode *vm, - bool mem_to_mem) +static int dispc_ovl_setup(enum omap_plane plane, const struct omap_overlay_info *oi, + bool replication, const struct videomode *vm, bool mem_to_mem) { int r; enum omap_overlay_caps caps = dss_feat_get_overlay_caps(plane); @@ -2821,7 +2814,6 @@ int dispc_ovl_setup(enum omap_plane plane, const struct omap_overlay_info *oi,
return r; } -EXPORT_SYMBOL(dispc_ovl_setup);
int dispc_wb_setup(const struct omap_dss_writeback_info *wi, bool mem_to_mem, const struct videomode *vm) @@ -2891,7 +2883,7 @@ int dispc_wb_setup(const struct omap_dss_writeback_info *wi, return r; }
-int dispc_ovl_enable(enum omap_plane plane, bool enable) +static int dispc_ovl_enable(enum omap_plane plane, bool enable) { DSSDBG("dispc_enable_plane %d, %d\n", plane, enable);
@@ -2899,33 +2891,28 @@ int dispc_ovl_enable(enum omap_plane plane, bool enable)
return 0; } -EXPORT_SYMBOL(dispc_ovl_enable);
-bool dispc_ovl_enabled(enum omap_plane plane) +static bool dispc_ovl_enabled(enum omap_plane plane) { return REG_GET(DISPC_OVL_ATTRIBUTES(plane), 0, 0); } -EXPORT_SYMBOL(dispc_ovl_enabled);
-enum omap_dss_output_id dispc_mgr_get_supported_outputs(enum omap_channel channel) +static enum omap_dss_output_id dispc_mgr_get_supported_outputs(enum omap_channel channel) { return dss_feat_get_supported_outputs(channel); } -EXPORT_SYMBOL(dispc_mgr_get_supported_outputs);
-void dispc_mgr_enable(enum omap_channel channel, bool enable) +static void dispc_mgr_enable(enum omap_channel channel, bool enable) { mgr_fld_write(channel, DISPC_MGR_FLD_ENABLE, enable); /* flush posted write */ mgr_fld_read(channel, DISPC_MGR_FLD_ENABLE); } -EXPORT_SYMBOL(dispc_mgr_enable);
-bool dispc_mgr_is_enabled(enum omap_channel channel) +static bool dispc_mgr_is_enabled(enum omap_channel channel) { return !!mgr_fld_read(channel, DISPC_MGR_FLD_ENABLE); } -EXPORT_SYMBOL(dispc_mgr_is_enabled);
void dispc_wb_enable(bool enable) { @@ -2961,11 +2948,10 @@ void dispc_pck_free_enable(bool enable) REG_FLD_MOD(DISPC_CONTROL, enable ? 1 : 0, 27, 27); }
-int dispc_get_num_mgrs(void) +static int dispc_get_num_mgrs(void) { return dss_feat_get_num_mgrs(); } -EXPORT_SYMBOL(dispc_get_num_mgrs);
static void dispc_mgr_enable_fifohandcheck(enum omap_channel channel, bool enable) { @@ -3015,7 +3001,7 @@ static void dispc_mgr_enable_alpha_fixed_zorder(enum omap_channel ch, REG_FLD_MOD(DISPC_CONFIG, enable, 19, 19); }
-void dispc_mgr_setup(enum omap_channel channel, +static void dispc_mgr_setup(enum omap_channel channel, const struct omap_overlay_manager_info *info) { dispc_mgr_set_default_color(channel, info->default_color); @@ -3028,7 +3014,6 @@ void dispc_mgr_setup(enum omap_channel channel, dispc_mgr_set_cpr_coef(channel, &info->cpr_coefs); } } -EXPORT_SYMBOL(dispc_mgr_setup);
static void dispc_mgr_set_tft_data_lines(enum omap_channel channel, u8 data_lines) { @@ -3089,7 +3074,7 @@ static void dispc_mgr_enable_stallmode(enum omap_channel channel, bool enable) mgr_fld_write(channel, DISPC_MGR_FLD_STALLMODE, enable); }
-void dispc_mgr_set_lcd_config(enum omap_channel channel, +static void dispc_mgr_set_lcd_config(enum omap_channel channel, const struct dss_lcd_mgr_config *config) { dispc_mgr_set_io_pad_mode(config->io_pad_mode); @@ -3105,7 +3090,6 @@ void dispc_mgr_set_lcd_config(enum omap_channel channel,
dispc_mgr_set_lcd_type_tft(channel); } -EXPORT_SYMBOL(dispc_mgr_set_lcd_config);
static bool _dispc_mgr_size_ok(u16 width, u16 height) { @@ -3236,7 +3220,7 @@ static void _dispc_mgr_set_lcd_timings(enum omap_channel channel, }
/* change name to mode? */ -void dispc_mgr_set_timings(enum omap_channel channel, +static void dispc_mgr_set_timings(enum omap_channel channel, const struct videomode *vm) { unsigned xtot, ytot; @@ -3283,7 +3267,6 @@ void dispc_mgr_set_timings(enum omap_channel channel,
dispc_mgr_set_size(channel, t.hactive, t.vactive); } -EXPORT_SYMBOL(dispc_mgr_set_timings);
static void dispc_mgr_set_lcd_divisor(enum omap_channel channel, u16 lck_div, u16 pck_div) @@ -3763,25 +3746,22 @@ int dispc_mgr_get_clock_div(enum omap_channel channel, return 0; }
-u32 dispc_read_irqstatus(void) +static u32 dispc_read_irqstatus(void) { return dispc_read_reg(DISPC_IRQSTATUS); } -EXPORT_SYMBOL(dispc_read_irqstatus);
-void dispc_clear_irqstatus(u32 mask) +static void dispc_clear_irqstatus(u32 mask) { dispc_write_reg(DISPC_IRQSTATUS, mask); } -EXPORT_SYMBOL(dispc_clear_irqstatus);
-u32 dispc_read_irqenable(void) +static u32 dispc_read_irqenable(void) { return dispc_read_reg(DISPC_IRQENABLE); } -EXPORT_SYMBOL(dispc_read_irqenable);
-void dispc_write_irqenable(u32 mask) +static void dispc_write_irqenable(u32 mask) { u32 old_mask = dispc_read_reg(DISPC_IRQENABLE);
@@ -3790,7 +3770,6 @@ void dispc_write_irqenable(u32 mask)
dispc_write_reg(DISPC_IRQENABLE, mask); } -EXPORT_SYMBOL(dispc_write_irqenable);
void dispc_enable_sidle(void) { @@ -3802,7 +3781,7 @@ void dispc_disable_sidle(void) REG_FLD_MOD(DISPC_SYSCONFIG, 1, 4, 3); /* SIDLEMODE: no idle */ }
-u32 dispc_mgr_gamma_size(enum omap_channel channel) +static u32 dispc_mgr_gamma_size(enum omap_channel channel) { const struct dispc_gamma_desc *gdesc = &mgr_desc[channel].gamma;
@@ -3811,7 +3790,6 @@ u32 dispc_mgr_gamma_size(enum omap_channel channel)
return gdesc->len; } -EXPORT_SYMBOL(dispc_mgr_gamma_size);
static void dispc_mgr_write_gamma_table(enum omap_channel channel) { @@ -3856,7 +3834,7 @@ static const struct drm_color_lut dispc_mgr_gamma_default_lut[] = { { .red = U16_MAX, .green = U16_MAX, .blue = U16_MAX, }, };
-void dispc_mgr_set_gamma(enum omap_channel channel, +static void dispc_mgr_set_gamma(enum omap_channel channel, const struct drm_color_lut *lut, unsigned int length) { @@ -3902,7 +3880,6 @@ void dispc_mgr_set_gamma(enum omap_channel channel, if (dispc.is_enabled) dispc_mgr_write_gamma_table(channel); } -EXPORT_SYMBOL(dispc_mgr_set_gamma);
static int dispc_init_gamma_tables(void) { @@ -4149,7 +4126,7 @@ static irqreturn_t dispc_irq_handler(int irq, void *arg) return dispc.user_handler(irq, dispc.user_data); }
-int dispc_request_irq(irq_handler_t handler, void *dev_id) +static int dispc_request_irq(irq_handler_t handler, void *dev_id) { int r;
@@ -4171,16 +4148,14 @@ int dispc_request_irq(irq_handler_t handler, void *dev_id)
return r; } -EXPORT_SYMBOL(dispc_request_irq);
-void dispc_free_irq(void *dev_id) +static void dispc_free_irq(void *dev_id) { devm_free_irq(&dispc.pdev->dev, dispc.irq, &dispc);
dispc.user_handler = NULL; dispc.user_data = NULL; } -EXPORT_SYMBOL(dispc_free_irq);
/* * Workaround for errata i734 in DSS dispc diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h index 63bdf38f4b92..54c10c3e5b8b 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.h +++ b/drivers/gpu/drm/omapdrm/dss/dss.h @@ -340,6 +340,9 @@ int dispc_init_platform_driver(void) __init; void dispc_uninit_platform_driver(void); void dispc_dump_clocks(struct seq_file *s);
+int dispc_runtime_get(void); +void dispc_runtime_put(void); + void dispc_enable_sidle(void); void dispc_disable_sidle(void);
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h index 134f153669ea..af06fe46e34f 100644 --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h @@ -852,49 +852,6 @@ void omapdss_set_is_initialized(bool set); struct device_node *dss_of_port_get_parent_device(struct device_node *port); u32 dss_of_port_get_port_number(struct device_node *port);
-u32 dispc_read_irqstatus(void); -void dispc_clear_irqstatus(u32 mask); -u32 dispc_read_irqenable(void); -void dispc_write_irqenable(u32 mask); - -int dispc_request_irq(irq_handler_t handler, void *dev_id); -void dispc_free_irq(void *dev_id); - -int dispc_runtime_get(void); -void dispc_runtime_put(void); - -int dispc_get_num_ovls(void); -int dispc_get_num_mgrs(void); - -void dispc_mgr_enable(enum omap_channel channel, bool enable); -bool dispc_mgr_is_enabled(enum omap_channel channel); -u32 dispc_mgr_get_vsync_irq(enum omap_channel channel); -u32 dispc_mgr_get_framedone_irq(enum omap_channel channel); -u32 dispc_mgr_get_sync_lost_irq(enum omap_channel channel); -bool dispc_mgr_go_busy(enum omap_channel channel); -void dispc_mgr_go(enum omap_channel channel); -void dispc_mgr_set_lcd_config(enum omap_channel channel, - const struct dss_lcd_mgr_config *config); -void dispc_mgr_set_timings(enum omap_channel channel, - const struct videomode *vm); -void dispc_mgr_setup(enum omap_channel channel, - const struct omap_overlay_manager_info *info); -enum omap_dss_output_id dispc_mgr_get_supported_outputs(enum omap_channel channel); -u32 dispc_mgr_gamma_size(enum omap_channel channel); -void dispc_mgr_set_gamma(enum omap_channel channel, - const struct drm_color_lut *lut, - unsigned int length); - -int dispc_ovl_enable(enum omap_plane plane, bool enable); -bool dispc_ovl_enabled(enum omap_plane plane); -void dispc_ovl_set_channel_out(enum omap_plane plane, - enum omap_channel channel); -int dispc_ovl_setup(enum omap_plane plane, const struct omap_overlay_info *oi, - bool replication, const struct videomode *vm, bool mem_to_mem); -enum omap_color_mode dispc_ovl_get_color_modes(enum omap_plane plane); - -enum omap_dss_output_id dispc_mgr_get_supported_outputs(enum omap_channel channel); - struct dss_mgr_ops { int (*connect)(enum omap_channel channel, struct omap_dss_device *dst);
Remove two unused WB functions.
Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/dss/dispc.c | 10 ---------- drivers/gpu/drm/omapdrm/dss/dss.h | 2 -- 2 files changed, 12 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c index cfc6daf2cedf..462d82e74de1 100644 --- a/drivers/gpu/drm/omapdrm/dss/dispc.c +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c @@ -2914,16 +2914,6 @@ static bool dispc_mgr_is_enabled(enum omap_channel channel) return !!mgr_fld_read(channel, DISPC_MGR_FLD_ENABLE); }
-void dispc_wb_enable(bool enable) -{ - dispc_ovl_enable(OMAP_DSS_WB, enable); -} - -bool dispc_wb_is_enabled(void) -{ - return dispc_ovl_enabled(OMAP_DSS_WB); -} - static void dispc_lcd_enable_signal_polarity(bool act_high) { if (!dss_has_feature(FEAT_LCDENABLEPOL)) diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h index 54c10c3e5b8b..878bf69fcda1 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.h +++ b/drivers/gpu/drm/omapdrm/dss/dss.h @@ -376,8 +376,6 @@ void dispc_set_tv_pclk(unsigned long pclk); u32 dispc_wb_get_framedone_irq(void); bool dispc_wb_go_busy(void); void dispc_wb_go(void); -void dispc_wb_enable(bool enable); -bool dispc_wb_is_enabled(void); void dispc_wb_set_channel_in(enum dss_writeback_channel channel); int dispc_wb_setup(const struct omap_dss_writeback_info *wi, bool mem_to_mem, const struct videomode *vm);
DSS uses "replication logic" to convert color components from smaller bit widths to bigger bit widths. Without replication logic, the color component would be shifted and the least significant bits would be left at 0, whereas with replication logic, the least significat bits will be filled with the most significant bit.
For some reason omapdrm leaves replication logic always to off, which, in the most common case, means that showing 16-bit RGB colors on 24-bit display gives a bit darker colors than expected.
The reset value of the replication logic bit is enabled, and it should always be set, as there's no practical reason to disable it. This patch removes the option to disable it from omapdrm, and always sets it to enabled in dispc.
Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/dss/dispc.c | 7 ++++--- drivers/gpu/drm/omapdrm/dss/omapdss.h | 3 +-- drivers/gpu/drm/omapdrm/omap_plane.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c index 462d82e74de1..9034b97240db 100644 --- a/drivers/gpu/drm/omapdrm/dss/dispc.c +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c @@ -2792,11 +2792,12 @@ static int dispc_ovl_setup_common(enum omap_plane plane, }
static int dispc_ovl_setup(enum omap_plane plane, const struct omap_overlay_info *oi, - bool replication, const struct videomode *vm, bool mem_to_mem) + const struct videomode *vm, bool mem_to_mem) { int r; enum omap_overlay_caps caps = dss_feat_get_overlay_caps(plane); enum omap_channel channel; + const bool replication = true;
channel = dispc_ovl_get_channel_out(plane);
@@ -2823,7 +2824,7 @@ int dispc_wb_setup(const struct omap_dss_writeback_info *wi, enum omap_plane plane = OMAP_DSS_WB; const int pos_x = 0, pos_y = 0; const u8 zorder = 0, global_alpha = 0; - const bool replication = false; + const bool replication = true; bool truncation; int in_width = vm->hactive; int in_height = vm->vactive; @@ -4269,7 +4270,7 @@ static void dispc_errata_i734_wa(void)
/* Setup and enable GFX plane */ dispc_ovl_set_channel_out(OMAP_DSS_GFX, OMAP_DSS_CHANNEL_LCD); - dispc_ovl_setup(OMAP_DSS_GFX, &ovli, false, &i734.vm, false); + dispc_ovl_setup(OMAP_DSS_GFX, &ovli, &i734.vm, false); dispc_ovl_enable(OMAP_DSS_GFX, true);
/* Set up and enable display manager for LCD1 */ diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h index af06fe46e34f..00ebf1f71f6b 100644 --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h @@ -931,8 +931,7 @@ struct dispc_ops { void (*ovl_set_channel_out)(enum omap_plane plane, enum omap_channel channel); int (*ovl_setup)(enum omap_plane plane, const struct omap_overlay_info *oi, - bool replication, const struct videomode *vm, - bool mem_to_mem); + const struct videomode *vm, bool mem_to_mem);
enum omap_color_mode (*ovl_get_color_modes)(enum omap_plane plane); }; diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c index b674c5cc77e8..278d079b77da 100644 --- a/drivers/gpu/drm/omapdrm/omap_plane.c +++ b/drivers/gpu/drm/omapdrm/omap_plane.c @@ -130,7 +130,7 @@ static void omap_plane_atomic_update(struct drm_plane *plane, omap_crtc_channel(state->crtc));
/* and finally, update omapdss: */ - ret = priv->dispc_ops->ovl_setup(omap_plane->id, &info, false, + ret = priv->dispc_ops->ovl_setup(omap_plane->id, &info, omap_crtc_timings(state->crtc), false); if (ret) { dev_err(plane->dev->dev, "Failed to setup plane %s\n",
From: Peter Ujfalusi peter.ujfalusi@ti.com
The functions can be used to check a component (by it's of_node) if it is part of the omapdss display or output list. If the component is found, it means that the driver is loaded.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@ti.com Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/dss/display.c | 18 ++++++++++++++++++ drivers/gpu/drm/omapdrm/dss/omapdss.h | 3 +++ drivers/gpu/drm/omapdrm/dss/output.c | 13 +++++++++++++ 3 files changed, 34 insertions(+)
diff --git a/drivers/gpu/drm/omapdrm/dss/display.c b/drivers/gpu/drm/omapdrm/dss/display.c index e567ff68b216..94c012e0584b 100644 --- a/drivers/gpu/drm/omapdrm/dss/display.c +++ b/drivers/gpu/drm/omapdrm/dss/display.c @@ -132,6 +132,24 @@ void omapdss_unregister_display(struct omap_dss_device *dssdev) } EXPORT_SYMBOL(omapdss_unregister_display);
+bool omapdss_component_is_display(struct device_node *node) +{ + struct omap_dss_device *dssdev; + bool found = false; + + mutex_lock(&panel_list_mutex); + list_for_each_entry(dssdev, &panel_list, panel_list) { + if (dssdev->dev->of_node == node) { + found = true; + goto out; + } + } +out: + mutex_unlock(&panel_list_mutex); + return found; +} +EXPORT_SYMBOL(omapdss_component_is_display); + struct omap_dss_device *omap_dss_get_device(struct omap_dss_device *dssdev) { if (!try_module_get(dssdev->owner)) diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h index 00ebf1f71f6b..fa34b68a676b 100644 --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h @@ -939,4 +939,7 @@ struct dispc_ops { void dispc_set_ops(const struct dispc_ops *o); const struct dispc_ops *dispc_get_ops(void);
+bool omapdss_component_is_display(struct device_node *node); +bool omapdss_component_is_output(struct device_node *node); + #endif /* __OMAP_DRM_DSS_H */ diff --git a/drivers/gpu/drm/omapdrm/dss/output.c b/drivers/gpu/drm/omapdrm/dss/output.c index 2b999dc48621..655c5d73eac9 100644 --- a/drivers/gpu/drm/omapdrm/dss/output.c +++ b/drivers/gpu/drm/omapdrm/dss/output.c @@ -107,6 +107,19 @@ void omapdss_unregister_output(struct omap_dss_device *out) } EXPORT_SYMBOL(omapdss_unregister_output);
+bool omapdss_component_is_output(struct device_node *node) +{ + struct omap_dss_device *out; + + list_for_each_entry(out, &output_list, list) { + if (out->dev->of_node == node) + return true; + } + + return false; +} +EXPORT_SYMBOL(omapdss_component_is_output); + struct omap_dss_device *omap_dss_get_output(enum omap_dss_output_id id) { struct omap_dss_device *out;
From: Peter Ujfalusi peter.ujfalusi@ti.com
When omapdss is loaded (all core components are in place) create a list of devices used in the display graph. This list later can be used by omapdrm via the omapdss_stack_is_ready() function to check that these components are loaded. Based on this information, omapdrm can defer probe in case when the omapdss stack is not ready yet.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@ti.com Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/dss/base.c | 107 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/omapdrm/dss/dss.c | 1 + drivers/gpu/drm/omapdrm/dss/omapdss.h | 3 + 3 files changed, 111 insertions(+)
diff --git a/drivers/gpu/drm/omapdrm/dss/base.c b/drivers/gpu/drm/omapdrm/dss/base.c index 7dd447e6c4d7..13e91faaf7a6 100644 --- a/drivers/gpu/drm/omapdrm/dss/base.c +++ b/drivers/gpu/drm/omapdrm/dss/base.c @@ -1,9 +1,21 @@ #include <linux/kernel.h> #include <linux/module.h> +#include <linux/of.h> +#include <linux/of_graph.h> +#include <linux/list.h> +#include "omapdss.h"
static bool dss_initialized; static const struct dispc_ops *ops;
+static struct list_head omapdss_comp_list; + +struct omapdss_comp_node { + struct list_head list; + struct device_node *node; + bool dss_core_component; +}; + void omapdss_set_is_initialized(bool set) { dss_initialized = set; @@ -28,6 +40,101 @@ const struct dispc_ops *dispc_get_ops(void) } EXPORT_SYMBOL(dispc_get_ops);
+static bool omapdss_list_contains(const struct device_node *node) +{ + struct omapdss_comp_node *comp; + + list_for_each_entry(comp, &omapdss_comp_list, list) { + if (comp->node == node) + return true; + } + + return false; +} + +static void omapdss_walk_device(struct device *dev, struct device_node *node, + bool dss_core) +{ + struct device_node *n; + struct omapdss_comp_node *comp = devm_kzalloc(dev, sizeof(*comp), + GFP_KERNEL); + + if (comp) { + comp->node = node; + comp->dss_core_component = dss_core; + list_add(&comp->list, &omapdss_comp_list); + } + + /* + * of_graph_get_remote_port_parent() prints an error if there is no + * port/ports node. To avoid that, check first that there's the node. + */ + n = of_get_child_by_name(node, "ports"); + if (!n) + n = of_get_child_by_name(node, "port"); + if (!n) + return; + + of_node_put(n); + + n = NULL; + while ((n = of_graph_get_next_endpoint(node, n)) != NULL) { + struct device_node *pn = of_graph_get_remote_port_parent(n); + + if (!pn) + continue; + + if (!of_device_is_available(pn) || omapdss_list_contains(pn)) { + of_node_put(pn); + continue; + } + + omapdss_walk_device(dev, pn, false); + } +} + +void omapdss_gather_components(struct device *dev) +{ + struct device_node *child; + + INIT_LIST_HEAD(&omapdss_comp_list); + + omapdss_walk_device(dev, dev->of_node, true); + + for_each_available_child_of_node(dev->of_node, child) { + if (!of_find_property(child, "compatible", NULL)) + continue; + + omapdss_walk_device(dev, child, true); + } +} +EXPORT_SYMBOL(omapdss_gather_components); + +static bool omapdss_component_is_loaded(struct omapdss_comp_node *comp) +{ + if (comp->dss_core_component) + return true; + if (omapdss_component_is_display(comp->node)) + return true; + if (omapdss_component_is_output(comp->node)) + return true; + + return false; +} + +bool omapdss_stack_is_ready(void) +{ + struct omapdss_comp_node *comp; + + list_for_each_entry(comp, &omapdss_comp_list, list) { + if (!omapdss_component_is_loaded(comp)) + return false; + } + + return true; +} +EXPORT_SYMBOL(omapdss_stack_is_ready); + MODULE_AUTHOR("Tomi Valkeinen tomi.valkeinen@ti.com"); MODULE_DESCRIPTION("OMAP Display Subsystem Base"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c index e647cebe7d9d..de81166e0fe4 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.c +++ b/drivers/gpu/drm/omapdrm/dss/dss.c @@ -1259,6 +1259,7 @@ static int dss_bind(struct device *dev)
pm_set_vt_switch(0);
+ omapdss_gather_components(dev); omapdss_set_is_initialized(true);
return 0; diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h index fa34b68a676b..74cba1ef7ee9 100644 --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h @@ -942,4 +942,7 @@ const struct dispc_ops *dispc_get_ops(void); bool omapdss_component_is_display(struct device_node *node); bool omapdss_component_is_output(struct device_node *node);
+bool omapdss_stack_is_ready(void); +void omapdss_gather_components(struct device *dev); + #endif /* __OMAP_DRM_DSS_H */
From: Peter Ujfalusi peter.ujfalusi@ti.com
Instead of 'guessing' based on aliases of the status of the DSS drivers, use the new interface to check that all needed drivers are loaded. In this way we can be sure that all needed drivers are loaded so it is safe to continue the probing of omapdrm. This method will allow the omapdrm to be probed 'headless', without outputs.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@ti.com Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/omap_drv.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c index 4894e09a75f6..eecf8649c0f7 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.c +++ b/drivers/gpu/drm/omapdrm/omap_drv.c @@ -236,7 +236,9 @@ static int omap_connect_dssdevs(void) { int r; struct omap_dss_device *dssdev = NULL; - bool no_displays = true; + + if (!omapdss_stack_is_ready()) + return -EPROBE_DEFER;
for_each_dss_dev(dssdev) { r = dssdev->driver->connect(dssdev); @@ -246,14 +248,9 @@ static int omap_connect_dssdevs(void) } else if (r) { dev_warn(dssdev->dev, "could not connect display: %s\n", dssdev->name); - } else { - no_displays = false; } }
- if (no_displays) - return -EPROBE_DEFER; - return 0;
cleanup:
If omap_plane_atomic_update() is called when the crtc is disabled, and the timings are zero, we'll see the following warning:
omapdss DISPC error: cannot calculate scaling settings: pclk is zero omapdrm omapdrm.0: Failed to setup plane vid2
It shouldn't cause any issues, as the crtc is disabled so the plane is not used by the HW.
To remove the warning, check whether the crtc is enabled at the beginning of omap_plane_atomic_update(), and bail out if not.
Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/omap_plane.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c index 278d079b77da..b3e55496d180 100644 --- a/drivers/gpu/drm/omapdrm/omap_plane.c +++ b/drivers/gpu/drm/omapdrm/omap_plane.c @@ -88,6 +88,11 @@ static void omap_plane_atomic_update(struct drm_plane *plane,
DBG("%s, crtc=%p fb=%p", omap_plane->name, state->crtc, state->fb);
+ if (!state->crtc->state->enable) { + priv->dispc_ops->ovl_enable(omap_plane->id, false); + return; + } + memset(&info, 0, sizeof(info)); info.rotation_type = OMAP_DSS_ROT_DMA; info.rotation = OMAP_DSS_ROT_0;
From: Peter Ujfalusi peter.ujfalusi@ti.com
Keep the panel_list ordered according to aliases. The DRM connectors will be created following the panel_list. By keeping the list ordered the DRM connectors will be created in the same order regardless of the driver probe order.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@ti.com Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/dss/display.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/display.c b/drivers/gpu/drm/omapdrm/dss/display.c index 94c012e0584b..26cb59be045e 100644 --- a/drivers/gpu/drm/omapdrm/dss/display.c +++ b/drivers/gpu/drm/omapdrm/dss/display.c @@ -83,6 +83,7 @@ static int disp_num_counter; int omapdss_register_display(struct omap_dss_device *dssdev) { struct omap_dss_driver *drv = dssdev->driver; + struct list_head *cur; int id;
/* @@ -118,7 +119,14 @@ int omapdss_register_display(struct omap_dss_device *dssdev) drv->get_timings = omapdss_default_get_timings;
mutex_lock(&panel_list_mutex); - list_add_tail(&dssdev->panel_list, &panel_list); + list_for_each(cur, &panel_list) { + struct omap_dss_device *ldev = list_entry(cur, + struct omap_dss_device, + panel_list); + if (strcmp(ldev->alias, dssdev->alias) > 0) + break; + } + list_add_tail(&dssdev->panel_list, cur); mutex_unlock(&panel_list_mutex); return 0; }
From: Peter Ujfalusi peter.ujfalusi@ti.com
Add fbdev emulation only for the first DRM connector. When the fbdev emulation was created for all connectors with different resolution, the lower res display would only be able to show part of the framebuffer. By creating the fbdev emulation only for the first connector we can avoid this.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@ti.com Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/omap_fbdev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/omapdrm/omap_fbdev.c b/drivers/gpu/drm/omapdrm/omap_fbdev.c index 2b045262f8ad..53c547676cfb 100644 --- a/drivers/gpu/drm/omapdrm/omap_fbdev.c +++ b/drivers/gpu/drm/omapdrm/omap_fbdev.c @@ -275,7 +275,9 @@ struct drm_fb_helper *omap_fbdev_init(struct drm_device *dev) goto fail; }
- ret = drm_fb_helper_single_add_all_connectors(helper); + drm_modeset_lock_all(dev); + ret = drm_fb_helper_add_one_connector(helper, priv->connectors[0]); + drm_modeset_unlock_all(dev); if (ret) goto fini;
Maximum framebuffer width on OMAP5+ DSS is 4096, instead of 2048. This patch makes omapdrm ask the respective dispc for the limits.
Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/dss/dispc.c | 9 +++++++++ drivers/gpu/drm/omapdrm/dss/omapdss.h | 1 + drivers/gpu/drm/omapdrm/omap_drv.c | 11 +++++++---- 3 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c index 9034b97240db..1db64edbbbfd 100644 --- a/drivers/gpu/drm/omapdrm/dss/dispc.c +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c @@ -4148,6 +4148,14 @@ static void dispc_free_irq(void *dev_id) dispc.user_data = NULL; }
+static void dispc_get_min_max_size(u32 *min_w, u32 *min_h, u32 *max_w, u32 *max_h) +{ + *min_w = 8; + *min_h = 2; + *max_w = dispc.feat->mgr_width_max; + *max_h = dispc.feat->mgr_height_max; +} + /* * Workaround for errata i734 in DSS dispc * - LCD1 Gamma Correction Is Not Working When GFX Pipe Is Disabled @@ -4321,6 +4329,7 @@ static const struct dispc_ops dispc_ops = {
.get_num_ovls = dispc_get_num_ovls, .get_num_mgrs = dispc_get_num_mgrs, + .get_min_max_size = dispc_get_min_max_size,
.mgr_enable = dispc_mgr_enable, .mgr_is_enabled = dispc_mgr_is_enabled, diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h index 74cba1ef7ee9..8d04b02a7d35 100644 --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h @@ -906,6 +906,7 @@ struct dispc_ops {
int (*get_num_ovls)(void); int (*get_num_mgrs)(void); + void (*get_min_max_size)(u32 *min_w, u32 *min_h, u32 *max_w, u32 *max_h);
void (*mgr_enable)(enum omap_channel channel, bool enable); bool (*mgr_is_enabled)(enum omap_channel channel); diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c index eecf8649c0f7..f53343c24335 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.c +++ b/drivers/gpu/drm/omapdrm/omap_drv.c @@ -315,6 +315,7 @@ static int omap_modeset_init(struct drm_device *dev) int num_crtcs; int i, id = 0; int ret; + u32 min_w, min_h, max_w, max_h;
drm_mode_config_init(dev);
@@ -475,14 +476,16 @@ static int omap_modeset_init(struct drm_device *dev) priv->num_planes, priv->num_crtcs, priv->num_encoders, priv->num_connectors);
- dev->mode_config.min_width = 8; - dev->mode_config.min_height = 2; + priv->dispc_ops->get_min_max_size(&min_w, &min_h, &max_w, &max_h); + + dev->mode_config.min_width = min_w; + dev->mode_config.min_height = min_h;
/* note: eventually will need some cpu_is_omapXYZ() type stuff here * to fill in these limits properly on different OMAP generations.. */ - dev->mode_config.max_width = 2048; - dev->mode_config.max_height = 2048; + dev->mode_config.max_width = max_w; + dev->mode_config.max_height = max_h;
dev->mode_config.funcs = &omap_mode_config_funcs;
From: Peter Ujfalusi peter.ujfalusi@ti.com
When the connector associated detect callback is not provided, we can not detect if the display is connected or disconnected. These displays does not support hot plug, they are always connected. Let DRM know that connectors w/o detect callback should not be polled.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@ti.com Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/omap_connector.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/omap_connector.c b/drivers/gpu/drm/omapdrm/omap_connector.c index 2580e8673908..da53df4811ac 100644 --- a/drivers/gpu/drm/omapdrm/omap_connector.c +++ b/drivers/gpu/drm/omapdrm/omap_connector.c @@ -229,13 +229,11 @@ struct drm_connector *omap_connector_init(struct drm_device *dev, connector_type); drm_connector_helper_add(connector, &omap_connector_helper_funcs);
-#if 0 /* enable when dss2 supports hotplug */ - if (dssdev->caps & OMAP_DSS_DISPLAY_CAP_HPD) - connector->polled = 0; - else -#endif + if (dssdev->driver->detect) connector->polled = DRM_CONNECTOR_POLL_CONNECT | - DRM_CONNECTOR_POLL_DISCONNECT; + DRM_CONNECTOR_POLL_DISCONNECT; + else + connector->polled = 0;
connector->interlace_allowed = 1; connector->doublescan_allowed = 0;
From: Peter Ujfalusi peter.ujfalusi@ti.com
The HPD signal can be used for detecting HDMI cable plug and unplug event without the need for polling the status of the line. This will speed up detecting such event because we do not need to wait for the next poll event to notice the state change.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@ti.com Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/dss/omapdss.h | 13 +++++++++++++ drivers/gpu/drm/omapdrm/omap_connector.c | 30 +++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h index 8d04b02a7d35..a37170bcc3c4 100644 --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h @@ -25,6 +25,7 @@ #include <video/videomode.h> #include <linux/platform_data/omapdss.h> #include <uapi/drm/drm_mode.h> +#include <drm/drm_crtc.h>
#define DISPC_IRQ_FRAMEDONE (1 << 0) #define DISPC_IRQ_VSYNC (1 << 1) @@ -555,6 +556,12 @@ struct omapdss_hdmi_ops { int (*read_edid)(struct omap_dss_device *dssdev, u8 *buf, int len); bool (*detect)(struct omap_dss_device *dssdev);
+ int (*enable_hpd)(struct omap_dss_device *dssdev, + void (*cb)(void *cb_data, + enum drm_connector_status status), + void *cb_data); + void (*disable_hpd)(struct omap_dss_device *dssdev); + int (*set_hdmi_mode)(struct omap_dss_device *dssdev, bool hdmi_mode); int (*set_infoframe)(struct omap_dss_device *dssdev, const struct hdmi_avi_infoframe *avi); @@ -761,6 +768,12 @@ struct omap_dss_driver { int (*read_edid)(struct omap_dss_device *dssdev, u8 *buf, int len); bool (*detect)(struct omap_dss_device *dssdev);
+ int (*enable_hpd)(struct omap_dss_device *dssdev, + void (*cb)(void *cb_data, + enum drm_connector_status status), + void *cb_data); + void (*disable_hpd)(struct omap_dss_device *dssdev); + int (*set_hdmi_mode)(struct omap_dss_device *dssdev, bool hdmi_mode); int (*set_hdmi_infoframe)(struct omap_dss_device *dssdev, const struct hdmi_avi_infoframe *avi); diff --git a/drivers/gpu/drm/omapdrm/omap_connector.c b/drivers/gpu/drm/omapdrm/omap_connector.c index da53df4811ac..60b438431355 100644 --- a/drivers/gpu/drm/omapdrm/omap_connector.c +++ b/drivers/gpu/drm/omapdrm/omap_connector.c @@ -35,6 +35,17 @@ struct omap_connector { bool hdmi_mode; };
+void omap_connector_hpd_cb(void *cb_data, enum drm_connector_status status) +{ + struct omap_connector *omap_connector = cb_data; + struct drm_connector *connector = &omap_connector->base; + + if (connector->status != status) { + connector->status = status; + drm_kms_helper_hotplug_event(omap_connector->base.dev); + } +} + bool omap_connector_get_hdmi_mode(struct drm_connector *connector) { struct omap_connector *omap_connector = to_omap_connector(connector); @@ -75,6 +86,9 @@ static void omap_connector_destroy(struct drm_connector *connector) struct omap_dss_device *dssdev = omap_connector->dssdev;
DBG("%s", omap_connector->dssdev->name); + if (connector->polled == DRM_CONNECTOR_POLL_HPD && + dssdev->driver->disable_hpd) + dssdev->driver->disable_hpd(dssdev); drm_connector_unregister(connector); drm_connector_cleanup(connector); kfree(omap_connector); @@ -212,6 +226,7 @@ struct drm_connector *omap_connector_init(struct drm_device *dev, { struct drm_connector *connector = NULL; struct omap_connector *omap_connector; + bool hpd_supported = false;
DBG("%s", dssdev->name);
@@ -229,7 +244,20 @@ struct drm_connector *omap_connector_init(struct drm_device *dev, connector_type); drm_connector_helper_add(connector, &omap_connector_helper_funcs);
- if (dssdev->driver->detect) + if (dssdev->driver->enable_hpd) { + int ret = dssdev->driver->enable_hpd(dssdev, + omap_connector_hpd_cb, + omap_connector); + if (!ret) + hpd_supported = true; + else if (ret != -ENOTSUPP) + DBG("%s: enable_hpd failed (%d). HPD will be disabled", + dssdev->name, ret); + } + + if (hpd_supported) + connector->polled = DRM_CONNECTOR_POLL_HPD; + else if (dssdev->driver->detect) connector->polled = DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT; else
From: Peter Ujfalusi peter.ujfalusi@ti.com
If the hpd_gpio is valid, use interrupt handler to react to HPD changes. In case the hpd_gpio is not valid, try to enable hpd detection on the encoder if it supports it.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@ti.com Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/displays/connector-hdmi.c | 63 +++++++++++++++++++++++ 1 file changed, 63 insertions(+)
diff --git a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c index 1ef130641bae..4d743e011335 100644 --- a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c +++ b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c @@ -15,6 +15,7 @@ #include <linux/platform_device.h> #include <linux/of.h> #include <linux/of_gpio.h> +#include <linux/spinlock.h>
#include <drm/drm_edid.h> #include <video/omap-panel-data.h> @@ -38,6 +39,9 @@ static const struct videomode hdmic_default_vm = { struct panel_drv_data { struct omap_dss_device dssdev; struct omap_dss_device *in; + void (*hpd_cb)(void *cb_data, enum drm_connector_status status); + void *hpd_cb_data; + struct mutex hpd_lock;
struct device *dev;
@@ -168,6 +172,32 @@ static bool hdmic_detect(struct omap_dss_device *dssdev) return in->ops.hdmi->detect(in); }
+static int hdmic_enable_hpd(struct omap_dss_device *dssdev, + void (*cb)(void *cb_data, + enum drm_connector_status status), + void *cb_data) +{ + struct panel_drv_data *ddata = to_panel_data(dssdev); + struct omap_dss_device *in = ddata->in; + + if (gpio_is_valid(ddata->hpd_gpio)) { + mutex_lock(&ddata->hpd_lock); + ddata->hpd_cb = cb; + ddata->hpd_cb_data = cb_data; + mutex_unlock(&ddata->hpd_lock); + return 0; + } else if (in->ops.hdmi->enable_hpd) { + return in->ops.hdmi->enable_hpd(in, cb, cb_data); + } + + return -ENOTSUPP; +} + +static void hdmic_disable_hpd(struct omap_dss_device *dssdev) +{ + hdmic_enable_hpd(dssdev, NULL, NULL); +} + static int hdmic_set_hdmi_mode(struct omap_dss_device *dssdev, bool hdmi_mode) { struct panel_drv_data *ddata = to_panel_data(dssdev); @@ -200,10 +230,32 @@ static struct omap_dss_driver hdmic_driver = {
.read_edid = hdmic_read_edid, .detect = hdmic_detect, + .enable_hpd = hdmic_enable_hpd, + .disable_hpd = hdmic_disable_hpd, .set_hdmi_mode = hdmic_set_hdmi_mode, .set_hdmi_infoframe = hdmic_set_infoframe, };
+static irqreturn_t hdmic_hpd_isr(int irq, void *data) +{ + struct panel_drv_data *ddata = data; + + mutex_lock(&ddata->hpd_lock); + if (ddata->hpd_cb) { + enum drm_connector_status status; + + if (hdmic_detect(&ddata->dssdev)) + status = connector_status_connected; + else + status = connector_status_disconnected; + + ddata->hpd_cb(ddata->hpd_cb_data, status); + } + mutex_unlock(&ddata->hpd_lock); + + return IRQ_HANDLED; +} + static int hdmic_probe_of(struct platform_device *pdev) { struct panel_drv_data *ddata = platform_get_drvdata(pdev); @@ -249,11 +301,22 @@ static int hdmic_probe(struct platform_device *pdev) if (r) return r;
+ mutex_init(&ddata->hpd_lock); + if (gpio_is_valid(ddata->hpd_gpio)) { r = devm_gpio_request_one(&pdev->dev, ddata->hpd_gpio, GPIOF_DIR_IN, "hdmi_hpd"); if (r) goto err_reg; + + r = devm_request_threaded_irq(&pdev->dev, + gpio_to_irq(ddata->hpd_gpio), + NULL, hdmic_hpd_isr, + IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | + IRQF_ONESHOT, + "hdmic hpd", ddata); + if (r) + goto err_reg; }
ddata->vm = hdmic_default_vm;
From: Peter Ujfalusi peter.ujfalusi@ti.com
Use interrupt handler for hpd GPIO to react to HPD changes.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@ti.com Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- .../gpu/drm/omapdrm/displays/encoder-tpd12s015.c | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+)
diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c index 6d8f79b29af6..8265ec36e068 100644 --- a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c +++ b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c @@ -15,12 +15,16 @@ #include <linux/slab.h> #include <linux/platform_device.h> #include <linux/gpio/consumer.h> +#include <linux/spinlock.h>
#include "../dss/omapdss.h"
struct panel_drv_data { struct omap_dss_device dssdev; struct omap_dss_device *in; + void (*hpd_cb)(void *cb_data, enum drm_connector_status status); + void *hpd_cb_data; + struct mutex hpd_lock;
struct gpio_desc *ct_cp_hpd_gpio; struct gpio_desc *ls_oe_gpio; @@ -162,6 +166,26 @@ static bool tpd_detect(struct omap_dss_device *dssdev) return gpiod_get_value_cansleep(ddata->hpd_gpio); }
+static int tpd_enable_hpd(struct omap_dss_device *dssdev, + void (*cb)(void *cb_data, + enum drm_connector_status status), + void *cb_data) +{ + struct panel_drv_data *ddata = to_panel_data(dssdev); + + mutex_lock(&ddata->hpd_lock); + ddata->hpd_cb = cb; + ddata->hpd_cb_data = cb_data; + mutex_unlock(&ddata->hpd_lock); + + return 0; +} + +static void tpd_disable_hpd(struct omap_dss_device *dssdev) +{ + tpd_enable_hpd(dssdev, NULL, NULL); +} + static int tpd_set_infoframe(struct omap_dss_device *dssdev, const struct hdmi_avi_infoframe *avi) { @@ -193,10 +217,32 @@ static const struct omapdss_hdmi_ops tpd_hdmi_ops = {
.read_edid = tpd_read_edid, .detect = tpd_detect, + .enable_hpd = tpd_enable_hpd, + .disable_hpd = tpd_disable_hpd, .set_infoframe = tpd_set_infoframe, .set_hdmi_mode = tpd_set_hdmi_mode, };
+static irqreturn_t tpd_hpd_isr(int irq, void *data) +{ + struct panel_drv_data *ddata = data; + + mutex_lock(&ddata->hpd_lock); + if (ddata->hpd_cb) { + enum drm_connector_status status; + + if (tpd_detect(&ddata->dssdev)) + status = connector_status_connected; + else + status = connector_status_disconnected; + + ddata->hpd_cb(ddata->hpd_cb_data, status); + } + mutex_unlock(&ddata->hpd_lock); + + return IRQ_HANDLED; +} + static int tpd_probe_of(struct platform_device *pdev) { struct panel_drv_data *ddata = platform_get_drvdata(pdev); @@ -256,6 +302,15 @@ static int tpd_probe(struct platform_device *pdev)
ddata->hpd_gpio = gpio;
+ mutex_init(&ddata->hpd_lock); + + r = devm_request_threaded_irq(&pdev->dev, gpiod_to_irq(ddata->hpd_gpio), + NULL, tpd_hpd_isr, + IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, + "tpd12s015 hpd", ddata); + if (r) + goto err_gpio; + dssdev = &ddata->dssdev; dssdev->ops.hdmi = &tpd_hdmi_ops; dssdev->dev = &pdev->dev;
From: Peter Ujfalusi peter.ujfalusi@ti.com
The associated backlight device can be configured via DT by providing the phandle to the device.
If the backlight device is configured, the driver can manage the backligt along with the panel's power state, iow it can turn on the backlight when the panel is enabled and turn it off when the panel is disabled.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@ti.com Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/displays/panel-dpi.c | 37 ++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dpi.c b/drivers/gpu/drm/omapdrm/displays/panel-dpi.c index 38003208d9ca..51fc78eb212c 100644 --- a/drivers/gpu/drm/omapdrm/displays/panel-dpi.c +++ b/drivers/gpu/drm/omapdrm/displays/panel-dpi.c @@ -16,6 +16,7 @@ #include <linux/of.h> #include <linux/of_gpio.h> #include <linux/regulator/consumer.h> +#include <linux/backlight.h>
#include <video/omap-panel-data.h> #include <video/of_display_timing.h> @@ -30,6 +31,8 @@ struct panel_drv_data {
struct videomode vm;
+ struct backlight_device *backlight; + /* used for non-DT boot, to be removed */ int backlight_gpio;
@@ -97,6 +100,11 @@ static int panel_dpi_enable(struct omap_dss_device *dssdev) if (gpio_is_valid(ddata->backlight_gpio)) gpio_set_value_cansleep(ddata->backlight_gpio, 1);
+ if (ddata->backlight) { + ddata->backlight->props.power = FB_BLANK_UNBLANK; + backlight_update_status(ddata->backlight); + } + dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
return 0; @@ -113,6 +121,11 @@ static void panel_dpi_disable(struct omap_dss_device *dssdev) if (gpio_is_valid(ddata->backlight_gpio)) gpio_set_value_cansleep(ddata->backlight_gpio, 0);
+ if (ddata->backlight) { + ddata->backlight->props.power = FB_BLANK_POWERDOWN; + backlight_update_status(ddata->backlight); + } + gpiod_set_value_cansleep(ddata->enable_gpio, 0); regulator_disable(ddata->vcc_supply);
@@ -209,6 +222,7 @@ static int panel_dpi_probe_of(struct platform_device *pdev) { struct panel_drv_data *ddata = platform_get_drvdata(pdev); struct device_node *node = pdev->dev.of_node; + struct device_node *bl_node; struct omap_dss_device *in; int r; struct display_timing timing; @@ -236,10 +250,19 @@ static int panel_dpi_probe_of(struct platform_device *pdev)
ddata->backlight_gpio = -ENOENT;
+ bl_node = of_parse_phandle(node, "backlight", 0); + if (bl_node) { + ddata->backlight = of_find_backlight_by_node(bl_node); + of_node_put(bl_node); + + if (!ddata->backlight) + return -EPROBE_DEFER; + } + r = of_get_display_timing(node, "panel-timing", &timing); if (r) { dev_err(&pdev->dev, "failed to get video timing\n"); - return r; + goto free_backlight; }
videomode_from_timing(&timing, &ddata->vm); @@ -247,12 +270,19 @@ static int panel_dpi_probe_of(struct platform_device *pdev) in = omapdss_of_find_source_for_first_ep(node); if (IS_ERR(in)) { dev_err(&pdev->dev, "failed to find video source\n"); - return PTR_ERR(in); + r = PTR_ERR(in); + goto free_backlight; }
ddata->in = in;
return 0; + +free_backlight: + if (ddata->backlight) + put_device(&ddata->backlight->dev); + + return r; }
static int panel_dpi_probe(struct platform_device *pdev) @@ -321,6 +351,9 @@ static int __exit panel_dpi_remove(struct platform_device *pdev)
omap_dss_put_device(in);
+ if (ddata->backlight) + put_device(&ddata->backlight->dev); + return 0; }
Instead of printing 0/1 for display flags like vsync high/low, use a tri-state print (-1/0/1) to indicate the "undefined" state.
Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/dss/dispc.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c index 1db64edbbbfd..377bd97ec6c8 100644 --- a/drivers/gpu/drm/omapdrm/dss/dispc.c +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c @@ -3210,6 +3210,16 @@ static void _dispc_mgr_set_lcd_timings(enum omap_channel channel, } }
+static int vm_flag_to_int(enum display_flags flags, enum display_flags high, + enum display_flags low) +{ + if (flags & high) + return 1; + if (flags & low) + return -1; + return 0; +} + /* change name to mode? */ static void dispc_mgr_set_timings(enum omap_channel channel, const struct videomode *vm) @@ -3239,11 +3249,11 @@ static void dispc_mgr_set_timings(enum omap_channel channel, t.hsync_len, t.hfront_porch, t.hback_porch, t.vsync_len, t.vfront_porch, t.vback_porch); DSSDBG("vsync_level %d hsync_level %d data_pclk_edge %d de_level %d sync_pclk_edge %d\n", - !!(t.flags & DISPLAY_FLAGS_VSYNC_HIGH), - !!(t.flags & DISPLAY_FLAGS_HSYNC_HIGH), - !!(t.flags & DISPLAY_FLAGS_PIXDATA_POSEDGE), - !!(t.flags & DISPLAY_FLAGS_DE_HIGH), - !!(t.flags & DISPLAY_FLAGS_SYNC_POSEDGE)); + vm_flag_to_int(t.flags, DISPLAY_FLAGS_VSYNC_HIGH, DISPLAY_FLAGS_VSYNC_LOW), + vm_flag_to_int(t.flags, DISPLAY_FLAGS_HSYNC_HIGH, DISPLAY_FLAGS_HSYNC_LOW), + vm_flag_to_int(t.flags, DISPLAY_FLAGS_PIXDATA_POSEDGE, DISPLAY_FLAGS_PIXDATA_NEGEDGE), + vm_flag_to_int(t.flags, DISPLAY_FLAGS_DE_HIGH, DISPLAY_FLAGS_DE_LOW), + vm_flag_to_int(t.flags, DISPLAY_FLAGS_SYNC_POSEDGE, DISPLAY_FLAGS_SYNC_NEGEDGE));
DSSDBG("hsync %luHz, vsync %luHz\n", ht, vt); } else {
At the moment VSYNC/HSYNC/DE high/low flags set by the panel/encoder drivers get lost when the videotimings are translated to DRM's videomode, as DRM's mode does not have corresponding flags.
DRM has bus-flags for this purpose, and while it lacks a few flags at the moment, it should be used here. However, until we rewrite omapdrm's device model, using bus-flags is rather difficult.
As a short term fix, this patch makes sure that every time the videomode is set in omap_crtc_mode_set_nofb(), the driver asks for the SYNC/DE flags from the panel/encoder drivers, and thus we get the correct flags into use.
Signed-off-by: Tomi Valkeinen tomi.valkeinen@ti.com --- drivers/gpu/drm/omapdrm/omap_connector.c | 2 -- drivers/gpu/drm/omapdrm/omap_crtc.c | 28 +++++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/omap_connector.c b/drivers/gpu/drm/omapdrm/omap_connector.c index 60b438431355..c562409f2568 100644 --- a/drivers/gpu/drm/omapdrm/omap_connector.c +++ b/drivers/gpu/drm/omapdrm/omap_connector.c @@ -160,8 +160,6 @@ static int omap_connector_mode_valid(struct drm_connector *connector, int r, ret = MODE_BAD;
drm_display_mode_to_videomode(mode, &vm); - vm.flags |= DISPLAY_FLAGS_DE_HIGH | DISPLAY_FLAGS_PIXDATA_POSEDGE | - DISPLAY_FLAGS_SYNC_NEGEDGE; mode->vrefresh = drm_mode_vrefresh(mode);
/* diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c index f3fd786de598..ac5f1b6eb583 100644 --- a/drivers/gpu/drm/omapdrm/omap_crtc.c +++ b/drivers/gpu/drm/omapdrm/omap_crtc.c @@ -427,6 +427,11 @@ static void omap_crtc_mode_set_nofb(struct drm_crtc *crtc) { struct omap_crtc *omap_crtc = to_omap_crtc(crtc); struct drm_display_mode *mode = &crtc->state->adjusted_mode; + struct omap_drm_private *priv = crtc->dev->dev_private; + const u32 flags_mask = DISPLAY_FLAGS_DE_HIGH | DISPLAY_FLAGS_DE_LOW | + DISPLAY_FLAGS_PIXDATA_POSEDGE | DISPLAY_FLAGS_PIXDATA_NEGEDGE | + DISPLAY_FLAGS_SYNC_POSEDGE | DISPLAY_FLAGS_SYNC_NEGEDGE; + int i;
DBG("%s: set mode: %d:"%s" %d %d %d %d %d %d %d %d %d %d 0x%x 0x%x", omap_crtc->name, mode->base.id, mode->name, @@ -436,9 +441,26 @@ static void omap_crtc_mode_set_nofb(struct drm_crtc *crtc) mode->type, mode->flags);
drm_display_mode_to_videomode(mode, &omap_crtc->vm); - omap_crtc->vm.flags |= DISPLAY_FLAGS_DE_HIGH | - DISPLAY_FLAGS_PIXDATA_POSEDGE | - DISPLAY_FLAGS_SYNC_NEGEDGE; + + for (i = 0; i < priv->num_encoders; ++i) { + struct drm_encoder *encoder = priv->encoders[i]; + + if (encoder->crtc == crtc) { + struct omap_dss_device *dssdev; + + dssdev = omap_encoder_get_dssdev(encoder); + + if (dssdev) { + struct videomode vm = {0}; + + dssdev->driver->get_timings(dssdev, &vm); + + omap_crtc->vm.flags |= vm.flags & flags_mask; + } + + break; + } + } }
static int omap_crtc_atomic_check(struct drm_crtc *crtc,
dri-devel@lists.freedesktop.org