Skip to content

Commit

Permalink
drm/msm/dsi: switch to DRM_PANEL_BRIDGE
Browse files Browse the repository at this point in the history
Currently the DSI driver has two separate paths: one if the next device
in a chain is a bridge and another one if the panel is connected
directly to the DSI host. Simplify the code path by using panel-bridge
driver (already selected in Kconfig) and dropping support for
handling the panel directly.

Signed-off-by: Dmitry Baryshkov <[email protected]>
Reviewed-by: Abhinav Kumar <[email protected]>
Patchwork: https://patchwork.freedesktop.org/patch/493608/
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Dmitry Baryshkov <[email protected]>
Signed-off-by: Rob Clark <[email protected]>
  • Loading branch information
lumag authored and robclark committed Sep 18, 2022
1 parent 549eae2 commit 007ac02
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 323 deletions.
35 changes: 2 additions & 33 deletions drivers/gpu/drm/msm/dsi/dsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@
#include "dsi.h"
#include "dsi_cfg.h"

struct drm_encoder *msm_dsi_get_encoder(struct msm_dsi *msm_dsi)
{
if (!msm_dsi || !msm_dsi_device_connected(msm_dsi))
return NULL;

return msm_dsi->encoder;
}

bool msm_dsi_is_cmd_mode(struct msm_dsi *msm_dsi)
{
unsigned long host_flags = msm_dsi_host_get_mode_flags(msm_dsi->host);
Expand Down Expand Up @@ -220,7 +212,6 @@ int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct drm_device *dev,
struct drm_encoder *encoder)
{
struct msm_drm_private *priv;
struct drm_bridge *ext_bridge;
int ret;

if (WARN_ON(!encoder) || WARN_ON(!msm_dsi) || WARN_ON(!dev))
Expand Down Expand Up @@ -254,26 +245,10 @@ int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct drm_device *dev,
goto fail;
}

/*
* check if the dsi encoder output is connected to a panel or an
* external bridge. We create a connector only if we're connected to a
* drm_panel device. When we're connected to an external bridge, we
* assume that the drm_bridge driver will create the connector itself.
*/
ext_bridge = msm_dsi_host_get_bridge(msm_dsi->host);

if (ext_bridge)
msm_dsi->connector =
msm_dsi_manager_ext_bridge_init(msm_dsi->id);
else
msm_dsi->connector =
msm_dsi_manager_connector_init(msm_dsi->id);

if (IS_ERR(msm_dsi->connector)) {
ret = PTR_ERR(msm_dsi->connector);
ret = msm_dsi_manager_ext_bridge_init(msm_dsi->id);
if (ret) {
DRM_DEV_ERROR(dev->dev,
"failed to create dsi connector: %d\n", ret);
msm_dsi->connector = NULL;
goto fail;
}

Expand All @@ -287,12 +262,6 @@ int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct drm_device *dev,
msm_dsi->bridge = NULL;
}

/* don't destroy connector if we didn't make it */
if (msm_dsi->connector && !msm_dsi->external_bridge)
msm_dsi->connector->funcs->destroy(msm_dsi->connector);

msm_dsi->connector = NULL;

return ret;
}

Expand Down
16 changes: 3 additions & 13 deletions drivers/gpu/drm/msm/dsi/dsi.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <drm/drm_bridge.h>
#include <drm/drm_crtc.h>
#include <drm/drm_mipi_dsi.h>
#include <drm/drm_panel.h>

#include "msm_drv.h"
#include "disp/msm_disp_snapshot.h"
Expand All @@ -36,19 +35,15 @@ struct msm_dsi {
struct drm_device *dev;
struct platform_device *pdev;

/* connector managed by us when we're connected to a drm_panel */
struct drm_connector *connector;
/* internal dsi bridge attached to MDP interface */
struct drm_bridge *bridge;

struct mipi_dsi_host *host;
struct msm_dsi_phy *phy;

/*
* panel/external_bridge connected to dsi bridge output, only one of the
* two can be valid at a time
* external_bridge connected to dsi bridge output
*/
struct drm_panel *panel;
struct drm_bridge *external_bridge;

struct device *phy_dev;
Expand All @@ -63,8 +58,7 @@ struct msm_dsi {
/* dsi manager */
struct drm_bridge *msm_dsi_manager_bridge_init(u8 id);
void msm_dsi_manager_bridge_destroy(struct drm_bridge *bridge);
struct drm_connector *msm_dsi_manager_connector_init(u8 id);
struct drm_connector *msm_dsi_manager_ext_bridge_init(u8 id);
int msm_dsi_manager_ext_bridge_init(u8 id);
int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg);
bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 dma_base, u32 len);
int msm_dsi_manager_register(struct msm_dsi *msm_dsi);
Expand All @@ -74,11 +68,9 @@ void msm_dsi_manager_tpg_enable(void);
/* msm dsi */
static inline bool msm_dsi_device_connected(struct msm_dsi *msm_dsi)
{
return msm_dsi->panel || msm_dsi->external_bridge;
return msm_dsi->external_bridge;
}

struct drm_encoder *msm_dsi_get_encoder(struct msm_dsi *msm_dsi);

/* dsi host */
struct msm_dsi_host;
int msm_dsi_host_xfer_prepare(struct mipi_dsi_host *host,
Expand All @@ -103,9 +95,7 @@ int msm_dsi_host_set_display_mode(struct mipi_dsi_host *host,
const struct drm_display_mode *mode);
enum drm_mode_status msm_dsi_host_check_dsc(struct mipi_dsi_host *host,
const struct drm_display_mode *mode);
struct drm_panel *msm_dsi_host_get_panel(struct mipi_dsi_host *host);
unsigned long msm_dsi_host_get_mode_flags(struct mipi_dsi_host *host);
struct drm_bridge *msm_dsi_host_get_bridge(struct mipi_dsi_host *host);
int msm_dsi_host_register(struct mipi_dsi_host *host);
void msm_dsi_host_unregister(struct mipi_dsi_host *host);
void msm_dsi_host_set_phy_mode(struct mipi_dsi_host *host,
Expand Down
25 changes: 0 additions & 25 deletions drivers/gpu/drm/msm/dsi/dsi_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ struct msm_dsi_host {
struct drm_dsc_config *dsc;

/* connected device info */
struct device_node *device_node;
unsigned int channel;
unsigned int lanes;
enum mipi_dsi_pixel_format format;
Expand Down Expand Up @@ -1628,8 +1627,6 @@ static int dsi_host_detach(struct mipi_dsi_host *host,

dsi_dev_detach(msm_host->pdev);

msm_host->device_node = NULL;

DBG("id=%d", msm_host->id);

return 0;
Expand Down Expand Up @@ -1893,16 +1890,6 @@ static int dsi_host_parse_dt(struct msm_dsi_host *msm_host)
goto err;
}

/* Get panel node from the output port's endpoint data */
device_node = of_graph_get_remote_node(np, 1, 0);
if (!device_node) {
DRM_DEV_DEBUG(dev, "%s: no valid device\n", __func__);
ret = -ENODEV;
goto err;
}

msm_host->device_node = device_node;

if (of_property_read_bool(np, "syscon-sfpb")) {
msm_host->sfpb = syscon_regmap_lookup_by_phandle(np,
"syscon-sfpb");
Expand Down Expand Up @@ -2587,23 +2574,11 @@ enum drm_mode_status msm_dsi_host_check_dsc(struct mipi_dsi_host *host,
return MODE_OK;
}

struct drm_panel *msm_dsi_host_get_panel(struct mipi_dsi_host *host)
{
return of_drm_find_panel(to_msm_dsi_host(host)->device_node);
}

unsigned long msm_dsi_host_get_mode_flags(struct mipi_dsi_host *host)
{
return to_msm_dsi_host(host)->mode_flags;
}

struct drm_bridge *msm_dsi_host_get_bridge(struct mipi_dsi_host *host)
{
struct msm_dsi_host *msm_host = to_msm_dsi_host(host);

return of_drm_find_bridge(msm_host->device_node);
}

void msm_dsi_host_snapshot(struct msm_disp_state *disp_state, struct mipi_dsi_host *host)
{
struct msm_dsi_host *msm_host = to_msm_dsi_host(host);
Expand Down
Loading

0 comments on commit 007ac02

Please sign in to comment.