drm/omap: dss: Replace omap_dss_device port number with bitmask
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Sun, 4 Mar 2018 19:49:28 +0000 (21:49 +0200)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Mon, 3 Sep 2018 13:13:27 +0000 (16:13 +0300)
The omap_dss_device port_num field stores the DT port number associated
with the device. The field is used in different ways depending on the
device type:

- For DPI outputs, the port number is used as an identifier of the DPI
instance

- For sources, the port number is used to look up the omap_dss_device by
DT port node

As omap_dss_device instances are only looked up as sources by sinks,
setting the field to the number of the source port works for both use
cases.

However, to enable looking up sinks, we need to record all the ports
associated with an omap_dss_device. Do so by turning the port_num field
into an of_ports bitmask. For DPI outputs the port number is
additionally stored in the dpi_data structure as the output ID.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
22 files changed:
drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c
drivers/gpu/drm/omapdrm/displays/connector-dvi.c
drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
drivers/gpu/drm/omapdrm/displays/encoder-opa362.c
drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
drivers/gpu/drm/omapdrm/displays/panel-dpi.c
drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c
drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c
drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c
drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c
drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c
drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c
drivers/gpu/drm/omapdrm/dss/base.c
drivers/gpu/drm/omapdrm/dss/dpi.c
drivers/gpu/drm/omapdrm/dss/dsi.c
drivers/gpu/drm/omapdrm/dss/hdmi4.c
drivers/gpu/drm/omapdrm/dss/hdmi5.c
drivers/gpu/drm/omapdrm/dss/omapdss.h
drivers/gpu/drm/omapdrm/dss/sdi.c
drivers/gpu/drm/omapdrm/dss/venc.c

index e416e9e1566a64ffd9adab962a908948223b068a..5b151b88e1c1bee5ec3fda5e6fff0b693afb684b 100644 (file)
@@ -169,6 +169,7 @@ static int tvc_probe(struct platform_device *pdev)
        dssdev->dev = &pdev->dev;
        dssdev->type = OMAP_DISPLAY_TYPE_VENC;
        dssdev->owner = THIS_MODULE;
+       dssdev->of_ports = BIT(0);
 
        omapdss_display_init(dssdev);
        omapdss_device_register(dssdev);
index a35d39f6cca99535e3c3dddeb0b616ab99f7d381..14f7941eb83a8c321743128be82b2cdf6c214efd 100644 (file)
@@ -389,6 +389,7 @@ static int dvic_probe(struct platform_device *pdev)
        dssdev->dev = &pdev->dev;
        dssdev->type = OMAP_DISPLAY_TYPE_DVI;
        dssdev->owner = THIS_MODULE;
+       dssdev->of_ports = BIT(0);
 
        omapdss_display_init(dssdev);
        omapdss_device_register(dssdev);
index dd6e67f9ae475535e6b5922f29855b1733f2ee36..005b1b0cbc466bd867fd5142bf7c5cbddbb62834 100644 (file)
@@ -349,6 +349,7 @@ static int hdmic_probe(struct platform_device *pdev)
        dssdev->dev = &pdev->dev;
        dssdev->type = OMAP_DISPLAY_TYPE_HDMI;
        dssdev->owner = THIS_MODULE;
+       dssdev->of_ports = BIT(0);
 
        omapdss_display_init(dssdev);
        omapdss_device_register(dssdev);
index 41a51364c9852f2de838ef433c8ca56734062b26..d74b90961c68a72fb9f7e10a0a1809f632cfe83e 100644 (file)
@@ -167,6 +167,7 @@ static int opa362_probe(struct platform_device *pdev)
        dssdev->type = OMAP_DISPLAY_TYPE_VENC;
        dssdev->output_type = OMAP_DISPLAY_TYPE_VENC;
        dssdev->owner = THIS_MODULE;
+       dssdev->of_ports = BIT(1) | BIT(0);
 
        omapdss_device_register(dssdev);
 
index cadb8f52aa88e5ee30feea793c7c4c25ae382e51..2bb1af8f815f5a6488f7c7dd7196bd93b0ddd6d9 100644 (file)
@@ -190,7 +190,7 @@ static int tfp410_probe(struct platform_device *pdev)
        dssdev->type = OMAP_DISPLAY_TYPE_DPI;
        dssdev->output_type = OMAP_DISPLAY_TYPE_DVI;
        dssdev->owner = THIS_MODULE;
-       dssdev->port_num = 1;
+       dssdev->of_ports = BIT(1) | BIT(0);
 
        omapdss_device_register(dssdev);
 
index 4f671dc272a0121faee5bbce5a55c51668f01d69..e33f73f06e004ef4ee49c930cbd821290ca582f7 100644 (file)
@@ -299,7 +299,7 @@ static int tpd_probe(struct platform_device *pdev)
        dssdev->type = OMAP_DISPLAY_TYPE_HDMI;
        dssdev->output_type = OMAP_DISPLAY_TYPE_HDMI;
        dssdev->owner = THIS_MODULE;
-       dssdev->port_num = 1;
+       dssdev->of_ports = BIT(1) | BIT(0);
 
        omapdss_device_register(dssdev);
 
index c03986d7df73757edb9860425b4187cfae6dce64..c8cd2f663ddf8d1ba46d415b40ab479fc5d32c9e 100644 (file)
@@ -217,6 +217,7 @@ static int panel_dpi_probe(struct platform_device *pdev)
        dssdev->driver = &panel_dpi_ops;
        dssdev->type = OMAP_DISPLAY_TYPE_DPI;
        dssdev->owner = THIS_MODULE;
+       dssdev->of_ports = BIT(0);
 
        omapdss_display_init(dssdev);
        omapdss_device_register(dssdev);
index aeeec81f8fcfd58fac33835fcb063db5baa7defb..febb20961dc5ced016c1cf2d2055ea3767f904a3 100644 (file)
@@ -1324,6 +1324,7 @@ static int dsicm_probe(struct platform_device *pdev)
        dssdev->driver = &dsicm_ops;
        dssdev->type = OMAP_DISPLAY_TYPE_DSI;
        dssdev->owner = THIS_MODULE;
+       dssdev->of_ports = BIT(0);
 
        dssdev->caps = OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE |
                OMAP_DSS_DISPLAY_CAP_TEAR_ELIM;
index d4a7925e3f16e8a4753e7176cc6657f5875b9bbf..52e30bd1ed4aeeed5d646598db8271a7333fbf37 100644 (file)
@@ -269,6 +269,7 @@ static int lb035q02_panel_spi_probe(struct spi_device *spi)
        dssdev->driver = &lb035q02_ops;
        dssdev->type = OMAP_DISPLAY_TYPE_DPI;
        dssdev->owner = THIS_MODULE;
+       dssdev->of_ports = BIT(0);
 
        omapdss_display_init(dssdev);
        omapdss_device_register(dssdev);
index b0fe60aba729185ace09ec8d6e71f7d6a750720e..3f88407fe3c08dca1258918660a5a8b2fcbedb50 100644 (file)
@@ -292,6 +292,7 @@ static int nec_8048_probe(struct spi_device *spi)
        dssdev->driver = &nec_8048_ops;
        dssdev->type = OMAP_DISPLAY_TYPE_DPI;
        dssdev->owner = THIS_MODULE;
+       dssdev->of_ports = BIT(0);
 
        omapdss_display_init(dssdev);
        omapdss_device_register(dssdev);
index d96eb1a1397f3a08dfaf5d6d89c5cad0cf77e87c..08576ae94d5543dab868fc1de066c7053e938a80 100644 (file)
@@ -268,6 +268,7 @@ static int sharp_ls_probe(struct platform_device *pdev)
        dssdev->driver = &sharp_ls_ops;
        dssdev->type = OMAP_DISPLAY_TYPE_DPI;
        dssdev->owner = THIS_MODULE;
+       dssdev->of_ports = BIT(0);
 
        omapdss_display_init(dssdev);
        omapdss_device_register(dssdev);
index 65068eea0647150a256b1164b182039cf3b192eb..181c3c2719180f8c0d86db789430575676e23e44 100644 (file)
@@ -797,6 +797,7 @@ static int acx565akm_probe(struct spi_device *spi)
        dssdev->driver = &acx565akm_ops;
        dssdev->type = OMAP_DISPLAY_TYPE_SDI;
        dssdev->owner = THIS_MODULE;
+       dssdev->of_ports = BIT(0);
 
        omapdss_display_init(dssdev);
        omapdss_device_register(dssdev);
index 96e2e30dd999024e3ea08291b90760222cc3bdb9..39234f5db144c5b91c017bcf42fdaee39f4c98e8 100644 (file)
@@ -393,6 +393,7 @@ static int td028ttec1_panel_probe(struct spi_device *spi)
        dssdev->driver = &td028ttec1_ops;
        dssdev->type = OMAP_DISPLAY_TYPE_DPI;
        dssdev->owner = THIS_MODULE;
+       dssdev->of_ports = BIT(0);
 
        omapdss_display_init(dssdev);
        omapdss_device_register(dssdev);
index 5845f9e6c6bab4b4e9d24dd5873031bac06287b5..61fcf228638731c7988039b6457c5c94cebfee15 100644 (file)
@@ -535,6 +535,7 @@ static int tpo_td043_probe(struct spi_device *spi)
        dssdev->driver = &tpo_td043_ops;
        dssdev->type = OMAP_DISPLAY_TYPE_DPI;
        dssdev->owner = THIS_MODULE;
+       dssdev->of_ports = BIT(0);
 
        omapdss_display_init(dssdev);
        omapdss_device_register(dssdev);
index 2728589724961f2d8b8124d6c5d7d524c1f32d18..67086cbb3e24f12ef207be4762bcdd325a4f6a60 100644 (file)
@@ -118,7 +118,7 @@ struct omap_dss_device *omapdss_find_device_by_port(struct device_node *src,
        struct omap_dss_device *dssdev;
 
        list_for_each_entry(dssdev, &omapdss_devices_list, list) {
-               if (dssdev->dev->of_node == src && dssdev->port_num == port)
+               if (dssdev->dev->of_node == src && dssdev->of_ports & BIT(port))
                        return omapdss_device_get(dssdev);
        }
 
index 372f1070bd6969e85b2338f58ac9207e53e96566..0c11d17f23a4f56cf1a448e69395e812fa38e641 100644 (file)
@@ -39,6 +39,7 @@ struct dpi_data {
        struct platform_device *pdev;
        enum dss_model dss_model;
        struct dss_device *dss;
+       unsigned int id;
 
        struct regulator *vdds_dsi_reg;
        enum dss_clk_source clk_src;
@@ -413,7 +414,7 @@ static int dpi_display_enable(struct omap_dss_device *dssdev)
        if (r)
                goto err_get_dispc;
 
-       r = dss_dpi_select_source(dpi->dss, out->port_num, out->dispc_channel);
+       r = dss_dpi_select_source(dpi->dss, dpi->id, out->dispc_channel);
        if (r)
                goto err_src_sel;
 
@@ -609,7 +610,7 @@ static void dpi_init_pll(struct dpi_data *dpi)
  * the channel in some more dynamic manner, or get the channel as a user
  * parameter.
  */
-static enum omap_channel dpi_get_channel(struct dpi_data *dpi, int port_num)
+static enum omap_channel dpi_get_channel(struct dpi_data *dpi)
 {
        switch (dpi->dss_model) {
        case DSS_MODEL_OMAP2:
@@ -617,7 +618,7 @@ static enum omap_channel dpi_get_channel(struct dpi_data *dpi, int port_num)
                return OMAP_DSS_CHANNEL_LCD;
 
        case DSS_MODEL_DRA7:
-               switch (port_num) {
+               switch (dpi->id) {
                case 2:
                        return OMAP_DSS_CHANNEL_LCD3;
                case 1:
@@ -690,12 +691,10 @@ static const struct omap_dss_device_ops dpi_ops = {
 static void dpi_init_output_port(struct dpi_data *dpi, struct device_node *port)
 {
        struct omap_dss_device *out = &dpi->output;
-       int r;
-       u32 port_num;
+       u32 port_num = 0;
 
-       r = of_property_read_u32(port, "reg", &port_num);
-       if (r)
-               port_num = 0;
+       of_property_read_u32(port, "reg", &port_num);
+       dpi->id = port_num <= 2 ? port_num : 0;
 
        switch (port_num) {
        case 2:
@@ -713,8 +712,8 @@ static void dpi_init_output_port(struct dpi_data *dpi, struct device_node *port)
        out->dev = &dpi->pdev->dev;
        out->id = OMAP_DSS_OUTPUT_DPI;
        out->output_type = OMAP_DISPLAY_TYPE_DPI;
-       out->dispc_channel = dpi_get_channel(dpi, port_num);
-       out->port_num = port_num;
+       out->dispc_channel = dpi_get_channel(dpi);
+       out->of_ports = BIT(port_num);
        out->ops = &dpi_ops;
        out->owner = THIS_MODULE;
 
index e061816e5381d7bba7db0b85fda6386186f344aa..ee260353b9ca97855fbcf6547d847b7d74fb873c 100644 (file)
@@ -4994,6 +4994,7 @@ static void dsi_init_output(struct dsi_data *dsi)
        out->dispc_channel = dsi_get_channel(dsi);
        out->ops = &dsi_ops;
        out->owner = THIS_MODULE;
+       out->of_ports = BIT(0);
 
        omapdss_device_register(out);
 }
index fa818033f3f332a2ed22a75cf42d255063b3db44..bf800cede2ad5f1f27ae0a3858de3ce93b9659fe 100644 (file)
@@ -564,6 +564,7 @@ static void hdmi_init_output(struct omap_hdmi *hdmi)
        out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT;
        out->ops = &hdmi_ops;
        out->owner = THIS_MODULE;
+       out->of_ports = BIT(0);
 
        omapdss_device_register(out);
 }
index ef4a48f397d284deba1c000790b74bf3bfe10e51..e5d23dd19f997747c8cb515a90553db100c5d06b 100644 (file)
@@ -555,6 +555,7 @@ static void hdmi_init_output(struct omap_hdmi *hdmi)
        out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT;
        out->ops = &hdmi_ops;
        out->owner = THIS_MODULE;
+       out->of_ports = BIT(0);
 
        omapdss_device_register(out);
 }
index 121bc953ba3161168ccd91a95a28ac374020f965..c2d9ebdec3d14cb3d7c450757c98e8f45582baa3 100644 (file)
@@ -423,8 +423,8 @@ struct omap_dss_device {
        /* output instance */
        enum omap_dss_output_id id;
 
-       /* the port number in the DT node */
-       int port_num;
+       /* bitmask of port numbers in DT */
+       unsigned int of_ports;
 };
 
 struct omap_dss_driver {
index 2f39e1f47990193221839298ed06adb05683eb3a..4b70a3044dd64c5c10afe3473e773c7ed64285dd 100644 (file)
@@ -327,7 +327,7 @@ static void sdi_init_output(struct sdi_device *sdi)
        out->name = "sdi.0";
        out->dispc_channel = OMAP_DSS_CHANNEL_LCD;
        /* We have SDI only on OMAP3, where it's on port 1 */
-       out->port_num = 1;
+       out->of_ports = BIT(1);
        out->ops = &sdi_ops;
        out->owner = THIS_MODULE;
 
index 70418cf4eea24e46061c12e599cd4388fabca9f8..dd9af335dba068f262c85d8a90ef8542629625b6 100644 (file)
@@ -767,6 +767,7 @@ static void venc_init_output(struct venc_device *venc)
        out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT;
        out->ops = &venc_ops;
        out->owner = THIS_MODULE;
+       out->of_ports = BIT(0);
 
        omapdss_device_register(out);
 }