diff mbox series

[v4,3/7] drm/msm/dp: Allow specifying connector_type per controller

Message ID 20211005231323.2663520-4-bjorn.andersson@linaro.org
State Accepted
Commit 269e92d84cd223b3bc32b752a0bcf639c2cb3bd9
Headers show
Series drm/msm/dp: Support multiple DP instances and add sc8180x | expand

Commit Message

Bjorn Andersson Oct. 5, 2021, 11:13 p.m. UTC
As the following patches introduced support for multiple DP blocks in a
platform and some of those block might be eDP it becomes useful to be
able to specify the connector type per block.

Although there's only a single block at this point, the array of descs
and the search in dp_display_get_desc() are introduced here to simplify
the next patch, that does introduce support for multiple DP blocks.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>

---

Changes since v3:
- New patch
- Extended msm_dp_config with connector_type, wrapped in inner struct
- Refactored out of the next patch
- Pass the connector_type to drm_connector_init(), from yet another patch
- Dropped double newline and unnecessary {}

 drivers/gpu/drm/msm/dp/dp_display.c | 43 ++++++++++++++++++++++++++++-
 drivers/gpu/drm/msm/dp/dp_display.h |  1 +
 drivers/gpu/drm/msm/dp/dp_drm.c     |  2 +-
 3 files changed, 44 insertions(+), 2 deletions(-)

-- 
2.29.2

Comments

Stephen Boyd Oct. 6, 2021, 12:15 a.m. UTC | #1
Quoting Bjorn Andersson (2021-10-05 16:13:19)
> diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c

> index 5d3ee5ef07c2..eaf08f9e7d87 100644

> --- a/drivers/gpu/drm/msm/dp/dp_display.c

> +++ b/drivers/gpu/drm/msm/dp/dp_display.c

> @@ -115,8 +115,25 @@ struct dp_display_private {

>         struct dp_audio *audio;

>  };

>

> +struct msm_dp_desc {

> +       phys_addr_t io_start;

> +       int connector_type;

> +};

> +

> +struct msm_dp_config {

> +       struct msm_dp_desc *descs;


const?

> +       size_t num_descs;

> +};

> +

> +static const struct msm_dp_config sc7180_dp_cfg = {

> +       .descs = (struct msm_dp_desc[]) {


const?

> +               { .io_start = 0x0ae90000, .connector_type = DRM_MODE_CONNECTOR_DisplayPort },

> +       },

> +       .num_descs = 1,

> +};

> +

>  static const struct of_device_id dp_dt_match[] = {

> -       {.compatible = "qcom,sc7180-dp"},

> +       { .compatible = "qcom,sc7180-dp", .data = &sc7180_dp_cfg },

>         {}

>  };

>

> @@ -1180,10 +1197,29 @@ int dp_display_request_irq(struct msm_dp *dp_display)

>         return 0;

>  }

>

> +static struct msm_dp_desc *dp_display_get_desc(struct platform_device *pdev)


const msm_dp_desc?

> +{

> +       const struct msm_dp_config *cfg = of_device_get_match_data(&pdev->dev);

> +       struct resource *res;

> +       int i;

> +

> +       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);

> +       if (!res)

> +               return NULL;

> +

> +       for (i = 0; i < cfg->num_descs; i++)

> +               if (cfg->descs[i].io_start == res->start)

> +                       return &cfg->descs[i];

> +

> +       dev_err(&pdev->dev, "unknown displayport instance\n");

> +       return NULL;

> +}

> +

>  static int dp_display_probe(struct platform_device *pdev)

>  {

>         int rc = 0;

>         struct dp_display_private *dp;

> +       struct msm_dp_desc *desc;


const?

>

>         if (!pdev || !pdev->dev.of_node) {

>                 DRM_ERROR("pdev not found\n");

> @@ -1194,8 +1230,13 @@ static int dp_display_probe(struct platform_device *pdev)

>         if (!dp)

>                 return -ENOMEM;

>

> +       desc = dp_display_get_desc(pdev);

> +       if (!desc)

> +               return -EINVAL;

> +

>         dp->pdev = pdev;

>         dp->name = "drm_dp";

> +       dp->dp_display.connector_type = desc->connector_type;

>

>         rc = dp_init_sub_modules(dp);

>         if (rc) {
Stephen Boyd Oct. 6, 2021, 12:29 a.m. UTC | #2
Quoting Bjorn Andersson (2021-10-05 16:13:19)
> As the following patches introduced support for multiple DP blocks in a

> platform and some of those block might be eDP it becomes useful to be

> able to specify the connector type per block.

>

> Although there's only a single block at this point, the array of descs

> and the search in dp_display_get_desc() are introduced here to simplify

> the next patch, that does introduce support for multiple DP blocks.

>

> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>

> ---

>

> Changes since v3:

> - New patch

> - Extended msm_dp_config with connector_type, wrapped in inner struct

> - Refactored out of the next patch

> - Pass the connector_type to drm_connector_init(), from yet another patch

> - Dropped double newline and unnecessary {}


BTW, I see that we check for the connector type in debugfs.

$ git grep DRM_MODE_CONNECTOR_DisplayPort -- drivers/gpu/drm/msm/dp/
drivers/gpu/drm/msm/dp/dp_debug.c:
DRM_MODE_CONNECTOR_DisplayPort)
drivers/gpu/drm/msm/dp/dp_debug.c:
DRM_MODE_CONNECTOR_DisplayPort)
drivers/gpu/drm/msm/dp/dp_debug.c:
DRM_MODE_CONNECTOR_DisplayPort)
drivers/gpu/drm/msm/dp/dp_debug.c:
DRM_MODE_CONNECTOR_DisplayPort)

So do those need to be updated to handle either connector type?
Stephen Boyd Oct. 6, 2021, 12:31 a.m. UTC | #3
Quoting Bjorn Andersson (2021-10-05 16:13:19)
> diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c

> index 5d3ee5ef07c2..eaf08f9e7d87 100644

> --- a/drivers/gpu/drm/msm/dp/dp_display.c

> +++ b/drivers/gpu/drm/msm/dp/dp_display.c

> @@ -115,8 +115,25 @@ struct dp_display_private {

>         struct dp_audio *audio;

>  };

>

> +struct msm_dp_desc {

> +       phys_addr_t io_start;

> +       int connector_type;


unsigned?

> +};

> +
Bjorn Andersson Oct. 6, 2021, 3:35 a.m. UTC | #4
On Tue 05 Oct 19:29 CDT 2021, Stephen Boyd wrote:

> Quoting Bjorn Andersson (2021-10-05 16:13:19)

> > As the following patches introduced support for multiple DP blocks in a

> > platform and some of those block might be eDP it becomes useful to be

> > able to specify the connector type per block.

> >

> > Although there's only a single block at this point, the array of descs

> > and the search in dp_display_get_desc() are introduced here to simplify

> > the next patch, that does introduce support for multiple DP blocks.

> >

> > Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>

> > ---

> >

> > Changes since v3:

> > - New patch

> > - Extended msm_dp_config with connector_type, wrapped in inner struct

> > - Refactored out of the next patch

> > - Pass the connector_type to drm_connector_init(), from yet another patch

> > - Dropped double newline and unnecessary {}

> 

> BTW, I see that we check for the connector type in debugfs.

> 

> $ git grep DRM_MODE_CONNECTOR_DisplayPort -- drivers/gpu/drm/msm/dp/

> drivers/gpu/drm/msm/dp/dp_debug.c:

> DRM_MODE_CONNECTOR_DisplayPort)

> drivers/gpu/drm/msm/dp/dp_debug.c:

> DRM_MODE_CONNECTOR_DisplayPort)

> drivers/gpu/drm/msm/dp/dp_debug.c:

> DRM_MODE_CONNECTOR_DisplayPort)

> drivers/gpu/drm/msm/dp/dp_debug.c:

> DRM_MODE_CONNECTOR_DisplayPort)

> 

> So do those need to be updated to handle either connector type?


The debugfs code loops over all the connectors for the DRM device and
skips those that aren't DisplayPort ones. So fixing this up to properly
support multiple instances in the dp_debugfs code as well should resolve
this.

Regards,
Bjorn
diff mbox series

Patch

diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c
index 5d3ee5ef07c2..eaf08f9e7d87 100644
--- a/drivers/gpu/drm/msm/dp/dp_display.c
+++ b/drivers/gpu/drm/msm/dp/dp_display.c
@@ -115,8 +115,25 @@  struct dp_display_private {
 	struct dp_audio *audio;
 };
 
+struct msm_dp_desc {
+	phys_addr_t io_start;
+	int connector_type;
+};
+
+struct msm_dp_config {
+	struct msm_dp_desc *descs;
+	size_t num_descs;
+};
+
+static const struct msm_dp_config sc7180_dp_cfg = {
+	.descs = (struct msm_dp_desc[]) {
+		{ .io_start = 0x0ae90000, .connector_type = DRM_MODE_CONNECTOR_DisplayPort },
+	},
+	.num_descs = 1,
+};
+
 static const struct of_device_id dp_dt_match[] = {
-	{.compatible = "qcom,sc7180-dp"},
+	{ .compatible = "qcom,sc7180-dp", .data = &sc7180_dp_cfg },
 	{}
 };
 
@@ -1180,10 +1197,29 @@  int dp_display_request_irq(struct msm_dp *dp_display)
 	return 0;
 }
 
+static struct msm_dp_desc *dp_display_get_desc(struct platform_device *pdev)
+{
+	const struct msm_dp_config *cfg = of_device_get_match_data(&pdev->dev);
+	struct resource *res;
+	int i;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return NULL;
+
+	for (i = 0; i < cfg->num_descs; i++)
+		if (cfg->descs[i].io_start == res->start)
+			return &cfg->descs[i];
+
+	dev_err(&pdev->dev, "unknown displayport instance\n");
+	return NULL;
+}
+
 static int dp_display_probe(struct platform_device *pdev)
 {
 	int rc = 0;
 	struct dp_display_private *dp;
+	struct msm_dp_desc *desc;
 
 	if (!pdev || !pdev->dev.of_node) {
 		DRM_ERROR("pdev not found\n");
@@ -1194,8 +1230,13 @@  static int dp_display_probe(struct platform_device *pdev)
 	if (!dp)
 		return -ENOMEM;
 
+	desc = dp_display_get_desc(pdev);
+	if (!desc)
+		return -EINVAL;
+
 	dp->pdev = pdev;
 	dp->name = "drm_dp";
+	dp->dp_display.connector_type = desc->connector_type;
 
 	rc = dp_init_sub_modules(dp);
 	if (rc) {
diff --git a/drivers/gpu/drm/msm/dp/dp_display.h b/drivers/gpu/drm/msm/dp/dp_display.h
index 8b47cdabb67e..02999408c052 100644
--- a/drivers/gpu/drm/msm/dp/dp_display.h
+++ b/drivers/gpu/drm/msm/dp/dp_display.h
@@ -18,6 +18,7 @@  struct msm_dp {
 	bool is_connected;
 	bool audio_enabled;
 	bool power_on;
+	int connector_type;
 
 	hdmi_codec_plugged_cb plugged_cb;
 
diff --git a/drivers/gpu/drm/msm/dp/dp_drm.c b/drivers/gpu/drm/msm/dp/dp_drm.c
index 764f4b81017e..f33e31523f56 100644
--- a/drivers/gpu/drm/msm/dp/dp_drm.c
+++ b/drivers/gpu/drm/msm/dp/dp_drm.c
@@ -147,7 +147,7 @@  struct drm_connector *dp_drm_connector_init(struct msm_dp *dp_display)
 
 	ret = drm_connector_init(dp_display->drm_dev, connector,
 			&dp_connector_funcs,
-			DRM_MODE_CONNECTOR_DisplayPort);
+			dp_display->connector_type);
 	if (ret)
 		return ERR_PTR(ret);