Skip to content

Commit

Permalink
drm/omap: Add support for drm_panel
Browse files Browse the repository at this point in the history
Hook up drm_panel support in the omapdrm driver. The change is
relatively simply as the way has been paved by drm_bridge support
already. In addition to looking up, attaching to and detaching from the
panel, we only need to add panel support in the connector .get_modes()
handler, take connector bus flags (set by the panel) into account, and
enable/disable the panel in the encoder enable/disable operations
handlers.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Tested-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
  • Loading branch information
Laurent Pinchart authored and Tomi Valkeinen committed Mar 18, 2019
1 parent 79107f2 commit 30b7176
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 20 deletions.
12 changes: 7 additions & 5 deletions drivers/gpu/drm/omapdrm/dss/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ struct omap_dss_device *omapdss_device_next_output(struct omap_dss_device *from)
goto done;
}

if (dssdev->id && (dssdev->next || dssdev->bridge))
if (dssdev->id &&
(dssdev->next || dssdev->bridge || dssdev->panel))
goto done;
}

Expand Down Expand Up @@ -192,10 +193,11 @@ int omapdss_device_connect(struct dss_device *dss,
if (!dst) {
/*
* The destination is NULL when the source is connected to a
* bridge instead of a DSS device. Stop here, we will attach the
* bridge later when we will have a DRM encoder.
* bridge or panel instead of a DSS device. Stop here, we will
* attach the bridge or panel later when we will have a DRM
* encoder.
*/
return src && src->bridge ? 0 : -EINVAL;
return src && (src->bridge || src->panel) ? 0 : -EINVAL;
}

if (omapdss_device_is_connected(dst))
Expand Down Expand Up @@ -223,7 +225,7 @@ void omapdss_device_disconnect(struct omap_dss_device *src,
dst ? dev_name(dst->dev) : "NULL");

if (!dst) {
WARN_ON(!src->bridge);
WARN_ON(!src->bridge && !src->panel);
return;
}

Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/omapdrm/dss/omapdss.h
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ struct omap_dss_device {
struct dss_device *dss;
struct omap_dss_device *next;
struct drm_bridge *bridge;
struct drm_panel *panel;

struct list_head list;

Expand Down
7 changes: 6 additions & 1 deletion drivers/gpu/drm/omapdrm/dss/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <linux/of.h>
#include <linux/of_graph.h>

#include <drm/drm_panel.h>

#include "dss.h"
#include "omapdss.h"

Expand All @@ -37,6 +39,9 @@ int omapdss_device_init_output(struct omap_dss_device *out)

out->next = omapdss_find_device_by_node(remote_node);
out->bridge = of_drm_find_bridge(remote_node);
out->panel = of_drm_find_panel(remote_node);
if (IS_ERR(out->panel))
out->panel = NULL;

of_node_put(remote_node);

Expand All @@ -47,7 +52,7 @@ int omapdss_device_init_output(struct omap_dss_device *out)
return -EINVAL;
}

return out->next || out->bridge ? 0 : -EPROBE_DEFER;
return out->next || out->bridge || out->panel ? 0 : -EPROBE_DEFER;
}
EXPORT_SYMBOL(omapdss_device_init_output);

Expand Down
9 changes: 9 additions & 0 deletions drivers/gpu/drm/omapdrm/omap_connector.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <drm/drm_atomic_helper.h>
#include <drm/drm_crtc.h>
#include <drm/drm_panel.h>
#include <drm/drm_probe_helper.h>

#include "omap_drv.h"
Expand Down Expand Up @@ -211,6 +212,7 @@ static int omap_connector_get_modes_edid(struct drm_connector *connector,

static int omap_connector_get_modes(struct drm_connector *connector)
{
struct omap_connector *omap_connector = to_omap_connector(connector);
struct omap_dss_device *dssdev;

DBG("%s", connector->name);
Expand All @@ -233,6 +235,13 @@ static int omap_connector_get_modes(struct drm_connector *connector)
if (dssdev)
return dssdev->ops->get_modes(dssdev, connector);

/*
* Otherwise if the display pipeline uses a drm_panel, we delegate the
* operation to the panel API.
*/
if (omap_connector->output->panel)
return drm_panel_get_modes(omap_connector->output->panel);

/*
* We can't retrieve modes, which can happen for instance for a DVI or
* VGA output with the DDC bus unconnected. The KMS core will add the
Expand Down
15 changes: 14 additions & 1 deletion drivers/gpu/drm/omapdrm/omap_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <drm/drm_atomic_helper.h>
#include <drm/drm_fb_helper.h>
#include <drm/drm_probe_helper.h>
#include <drm/drm_panel.h>

#include "omap_dmm_tiler.h"
#include "omap_drv.h"
Expand Down Expand Up @@ -137,6 +138,9 @@ static void omap_disconnect_pipelines(struct drm_device *ddev)
for (i = 0; i < priv->num_pipes; i++) {
struct omap_drm_pipeline *pipe = &priv->pipes[i];

if (pipe->output->panel)
drm_panel_detach(pipe->output->panel);

omapdss_device_disconnect(NULL, pipe->output);

omapdss_device_put(pipe->output);
Expand Down Expand Up @@ -214,13 +218,15 @@ static int omap_display_id(struct omap_dss_device *output)
display = omapdss_display_get(output);
node = display->dev->of_node;
omapdss_device_put(display);
} else {
} else if (output->bridge) {
struct drm_bridge *bridge = output->bridge;

while (bridge->next)
bridge = bridge->next;

node = bridge->of_node;
} else if (output->panel) {
node = output->panel->dev->of_node;
}

return node ? of_alias_get_id(node, "display") : -ENODEV;
Expand Down Expand Up @@ -335,6 +341,13 @@ static int omap_modeset_init(struct drm_device *dev)
return -ENOMEM;

drm_connector_attach_encoder(pipe->connector, encoder);

if (pipe->output->panel) {
ret = drm_panel_attach(pipe->output->panel,
pipe->connector);
if (ret < 0)
return ret;
}
}

crtc = omap_crtc_init(dev, pipe, priv->planes[i]);
Expand Down
41 changes: 28 additions & 13 deletions drivers/gpu/drm/omapdrm/omap_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <drm/drm_crtc.h>
#include <drm/drm_modeset_helper_vtables.h>
#include <drm/drm_edid.h>
#include <drm/drm_panel.h>

#include "omap_drv.h"

Expand Down Expand Up @@ -79,22 +80,15 @@ static void omap_encoder_update_videomode_flags(struct videomode *vm,
}
}

static void omap_encoder_hdmi_mode_set(struct drm_encoder *encoder,
static void omap_encoder_hdmi_mode_set(struct drm_connector *connector,
struct drm_encoder *encoder,
struct drm_display_mode *adjusted_mode)
{
struct drm_device *dev = encoder->dev;
struct omap_encoder *omap_encoder = to_omap_encoder(encoder);
struct omap_dss_device *dssdev = omap_encoder->output;
struct drm_connector *connector;
bool hdmi_mode;

hdmi_mode = false;
list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
if (connector->encoder == encoder) {
hdmi_mode = omap_connector_get_hdmi_mode(connector);
break;
}
}
hdmi_mode = omap_connector_get_hdmi_mode(connector);

if (dssdev->ops->hdmi.set_hdmi_mode)
dssdev->ops->hdmi.set_hdmi_mode(dssdev, hdmi_mode);
Expand All @@ -117,8 +111,16 @@ static void omap_encoder_mode_set(struct drm_encoder *encoder,
struct omap_encoder *omap_encoder = to_omap_encoder(encoder);
struct omap_dss_device *output = omap_encoder->output;
struct omap_dss_device *dssdev;
struct drm_device *dev = encoder->dev;
struct drm_connector *connector;
struct drm_bridge *bridge;
struct videomode vm = { 0 };
u32 bus_flags;

list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
if (connector->encoder == encoder)
break;
}

drm_display_mode_to_videomode(adjusted_mode, &vm);

Expand All @@ -135,15 +137,16 @@ static void omap_encoder_mode_set(struct drm_encoder *encoder,
omap_encoder_update_videomode_flags(&vm, dssdev->bus_flags);

for (bridge = output->bridge; bridge; bridge = bridge->next) {
u32 bus_flags;

if (!bridge->timings)
continue;

bus_flags = bridge->timings->input_bus_flags;
omap_encoder_update_videomode_flags(&vm, bus_flags);
}

bus_flags = connector->display_info.bus_flags;
omap_encoder_update_videomode_flags(&vm, bus_flags);

/* Set timings for all devices in the display pipeline. */
dss_mgr_set_timings(output, &vm);

Expand All @@ -154,7 +157,7 @@ static void omap_encoder_mode_set(struct drm_encoder *encoder,

/* Set the HDMI mode and HDMI infoframe if applicable. */
if (output->type == OMAP_DISPLAY_TYPE_HDMI)
omap_encoder_hdmi_mode_set(encoder, adjusted_mode);
omap_encoder_hdmi_mode_set(connector, encoder, adjusted_mode);
}

static void omap_encoder_disable(struct drm_encoder *encoder)
Expand All @@ -165,6 +168,12 @@ static void omap_encoder_disable(struct drm_encoder *encoder)

dev_dbg(dev->dev, "disable(%s)\n", dssdev->name);

/* Disable the panel if present. */
if (dssdev->panel) {
drm_panel_disable(dssdev->panel);
drm_panel_unprepare(dssdev->panel);
}

/*
* Disable the chain of external devices, starting at the one at the
* internal encoder's output.
Expand Down Expand Up @@ -214,6 +223,12 @@ static void omap_encoder_enable(struct drm_encoder *encoder)
* internal encoder's output.
*/
omapdss_device_enable(dssdev->next);

/* Enable the panel if present. */
if (dssdev->panel) {
drm_panel_prepare(dssdev->panel);
drm_panel_enable(dssdev->panel);
}
}

static int omap_encoder_atomic_check(struct drm_encoder *encoder,
Expand Down

0 comments on commit 30b7176

Please sign in to comment.