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 a DP instance and
prepare and enable the panel accordingly.

Link: https://lore.kernel.org/linux-arm-msm/20210726231351.655302-1-bjorn.andersson@linaro.org/
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
  • Loading branch information
andersson authored and 0x011011110 committed Aug 5, 2021
1 parent b8b957b commit e0cc923
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
14 changes: 12 additions & 2 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 @@ -253,6 +254,7 @@ static int dp_display_bind(struct device *dev, struct device *master,
}

dp->aux->drm_dev = drm;
dp->dp_display.drm_panel = dp->parser->drm_panel;
rc = dp_aux_register(dp->aux, drm);
if (rc) {
DRM_ERROR("DRM DP AUX register failed\n");
Expand Down Expand Up @@ -867,8 +869,10 @@ 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)
{
drm_panel_prepare(dp_display->drm_panel);

return 0;
}

Expand All @@ -886,6 +890,8 @@ static int dp_display_enable(struct dp_display_private *dp, u32 data)
if (!rc)
dp_display->power_on = true;

drm_panel_enable(dp_display->drm_panel);

return rc;
}

Expand Down Expand Up @@ -915,6 +921,8 @@ static int dp_display_disable(struct dp_display_private *dp, u32 data)
if (!dp_display->power_on)
return 0;

drm_panel_disable(dp_display->drm_panel);

/* wait only if audio was enabled */
if (dp_display->audio_enabled) {
/* signal the disconnect event */
Expand All @@ -939,8 +947,10 @@ 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)
{
drm_panel_unprepare(dp_display->drm_panel);

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_panel *drm_panel;
bool is_connected;
bool audio_enabled;
bool power_on;
Expand Down
19 changes: 19 additions & 0 deletions 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 @@ -276,6 +277,20 @@ static int dp_parser_clock(struct dp_parser *parser)
return 0;
}

static int dp_parser_find_panel(struct dp_parser *parser)
{
struct device_node *np = parser->pdev->dev.of_node;
int rc;

rc = drm_of_find_panel_or_bridge(np, 2, 0, &parser->drm_panel, NULL);
if (rc == -ENODEV)
rc = 0;
else if (rc)
DRM_ERROR("failed to acquire DRM panel: %d\n", rc);

return rc;
}

static int dp_parser_parse(struct dp_parser *parser)
{
int rc = 0;
Expand All @@ -297,6 +312,10 @@ static int dp_parser_parse(struct dp_parser *parser)
if (rc)
return rc;

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
1 change: 1 addition & 0 deletions drivers/gpu/drm/msm/dp/dp_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ struct dp_parser {
struct dp_display_data disp_data;
const struct dp_regulator_cfg *regulator_cfg;
u32 max_dp_lanes;
struct drm_panel *drm_panel;

int (*parse)(struct dp_parser *parser);
};
Expand Down

0 comments on commit e0cc923

Please sign in to comment.