Skip to content

Commit

Permalink
drm/msm/dp: Allow attaching a drm_panel
Browse files Browse the repository at this point in the history
eDP panels might need some power sequencing and backlight management,
so make it possible to associate a drm_panel with an eDP instance and
prepare and enable the panel accordingly.

Now that we know which hardware instance is DP and which is eDP,
parser->parse() is passed the connector_type and the parser is limited
to only search for a panel in the eDP case.

Signed-off-by: Bjorn Andersson <[email protected]>
Reviewed-by: Stephen Boyd <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Rob Clark <[email protected]>
  • Loading branch information
andersson authored and robclark committed Oct 18, 2021
1 parent 269e92d commit 4b296d1
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 5 deletions.
9 changes: 6 additions & 3 deletions drivers/gpu/drm/msm/dp/dp_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <linux/component.h>
#include <linux/of_irq.h>
#include <linux/delay.h>
#include <drm/drm_panel.h>

#include "msm_drv.h"
#include "msm_kms.h"
Expand Down Expand Up @@ -230,12 +231,14 @@ static int dp_display_bind(struct device *dev, struct device *master,
priv = drm->dev_private;
priv->dp = &(dp->dp_display);

rc = dp->parser->parse(dp->parser);
rc = dp->parser->parse(dp->parser, dp->dp_display.connector_type);
if (rc) {
DRM_ERROR("device tree parsing failed\n");
goto end;
}

dp->dp_display.panel_bridge = dp->parser->panel_bridge;

dp->aux->drm_dev = drm;
rc = dp_aux_register(dp->aux);
if (rc) {
Expand Down Expand Up @@ -822,7 +825,7 @@ static int dp_display_set_mode(struct msm_dp *dp_display,
return 0;
}

static int dp_display_prepare(struct msm_dp *dp)
static int dp_display_prepare(struct msm_dp *dp_display)
{
return 0;
}
Expand Down Expand Up @@ -896,7 +899,7 @@ static int dp_display_disable(struct dp_display_private *dp, u32 data)
return 0;
}

static int dp_display_unprepare(struct msm_dp *dp)
static int dp_display_unprepare(struct msm_dp *dp_display)
{
return 0;
}
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/msm/dp/dp_display.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ struct msm_dp {
struct device *codec_dev;
struct drm_connector *connector;
struct drm_encoder *encoder;
struct drm_bridge *panel_bridge;
bool is_connected;
bool audio_enabled;
bool power_on;
Expand Down
11 changes: 11 additions & 0 deletions drivers/gpu/drm/msm/dp/dp_drm.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <drm/drm_atomic_helper.h>
#include <drm/drm_atomic.h>
#include <drm/drm_bridge.h>
#include <drm/drm_crtc.h>

#include "msm_drv.h"
Expand Down Expand Up @@ -160,5 +161,15 @@ struct drm_connector *dp_drm_connector_init(struct msm_dp *dp_display)

drm_connector_attach_encoder(connector, dp_display->encoder);

if (dp_display->panel_bridge) {
ret = drm_bridge_attach(dp_display->encoder,
dp_display->panel_bridge, NULL,
DRM_BRIDGE_ATTACH_NO_CONNECTOR);
if (ret < 0) {
DRM_ERROR("failed to attach panel bridge: %d\n", ret);
return ERR_PTR(ret);
}
}

return connector;
}
30 changes: 29 additions & 1 deletion drivers/gpu/drm/msm/dp/dp_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <linux/of_gpio.h>
#include <linux/phy/phy.h>

#include <drm/drm_of.h>
#include <drm/drm_print.h>

#include "dp_parser.h"
Expand Down Expand Up @@ -263,7 +264,28 @@ static int dp_parser_clock(struct dp_parser *parser)
return 0;
}

static int dp_parser_parse(struct dp_parser *parser)
static int dp_parser_find_panel(struct dp_parser *parser)
{
struct device *dev = &parser->pdev->dev;
struct drm_panel *panel;
int rc;

rc = drm_of_find_panel_or_bridge(dev->of_node, 1, 0, &panel, NULL);
if (rc) {
DRM_ERROR("failed to acquire DRM panel: %d\n", rc);
return rc;
}

parser->panel_bridge = devm_drm_panel_bridge_add(dev, panel);
if (IS_ERR(parser->panel_bridge)) {
DRM_ERROR("failed to create panel bridge\n");
return PTR_ERR(parser->panel_bridge);
}

return 0;
}

static int dp_parser_parse(struct dp_parser *parser, int connector_type)
{
int rc = 0;

Expand All @@ -284,6 +306,12 @@ static int dp_parser_parse(struct dp_parser *parser)
if (rc)
return rc;

if (connector_type == DRM_MODE_CONNECTOR_eDP) {
rc = dp_parser_find_panel(parser);
if (rc)
return rc;
}

/* Map the corresponding regulator information according to
* version. Currently, since we only have one supported platform,
* mapping the regulator directly.
Expand Down
3 changes: 2 additions & 1 deletion drivers/gpu/drm/msm/dp/dp_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ struct dp_parser {
struct dp_display_data disp_data;
const struct dp_regulator_cfg *regulator_cfg;
u32 max_dp_lanes;
struct drm_bridge *panel_bridge;

int (*parse)(struct dp_parser *parser);
int (*parse)(struct dp_parser *parser, int connector_type);
};

/**
Expand Down

0 comments on commit 4b296d1

Please sign in to comment.