aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2018-09-12 12:41:31 -0400
committerTomi Valkeinen <tomi.valkeinen@ti.com>2019-03-18 05:42:12 -0400
commitd17eb4537a7eb16da9eafbfd5717e12b45b77251 (patch)
tree0979073a2e064898c47bef159eb1c3694a89f135
parent56c9818d5c89b2655c6b4c65b99829faf5b4f544 (diff)
drm/omap: Factor out common init/cleanup code for output devices
All the internal encoders share common init and cleanup code. Factor it out to separate functions. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com> Tested-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
-rw-r--r--drivers/gpu/drm/omapdrm/dss/dpi.c17
-rw-r--r--drivers/gpu/drm/omapdrm/dss/dsi.c17
-rw-r--r--drivers/gpu/drm/omapdrm/dss/hdmi4.c17
-rw-r--r--drivers/gpu/drm/omapdrm/dss/hdmi5.c17
-rw-r--r--drivers/gpu/drm/omapdrm/dss/omapdss.h3
-rw-r--r--drivers/gpu/drm/omapdrm/dss/output.c18
-rw-r--r--drivers/gpu/drm/omapdrm/dss/sdi.c17
-rw-r--r--drivers/gpu/drm/omapdrm/dss/venc.c17
8 files changed, 36 insertions, 87 deletions
diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c
index 74e841a2b4eb..0db01cadf09f 100644
--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -641,19 +641,9 @@ static int dpi_init_output_port(struct dpi_data *dpi, struct device_node *port)
641 out->ops = &dpi_ops; 641 out->ops = &dpi_ops;
642 out->owner = THIS_MODULE; 642 out->owner = THIS_MODULE;
643 643
644 out->next = omapdss_of_find_connected_device(out->dev->of_node, 0); 644 r = omapdss_device_init_output(out);
645 if (IS_ERR(out->next)) { 645 if (r < 0)
646 if (PTR_ERR(out->next) != -EPROBE_DEFER)
647 dev_err(out->dev, "failed to find video sink\n");
648 return PTR_ERR(out->next);
649 }
650
651 r = omapdss_output_validate(out);
652 if (r) {
653 omapdss_device_put(out->next);
654 out->next = NULL;
655 return r; 646 return r;
656 }
657 647
658 omapdss_device_register(out); 648 omapdss_device_register(out);
659 649
@@ -665,9 +655,8 @@ static void dpi_uninit_output_port(struct device_node *port)
665 struct dpi_data *dpi = port->data; 655 struct dpi_data *dpi = port->data;
666 struct omap_dss_device *out = &dpi->output; 656 struct omap_dss_device *out = &dpi->output;
667 657
668 if (out->next)
669 omapdss_device_put(out->next);
670 omapdss_device_unregister(out); 658 omapdss_device_unregister(out);
659 omapdss_device_cleanup_output(out);
671} 660}
672 661
673static const struct soc_device_attribute dpi_soc_devices[] = { 662static const struct soc_device_attribute dpi_soc_devices[] = {
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c
index 4dad2bf6b551..4ac325e664b5 100644
--- a/drivers/gpu/drm/omapdrm/dss/dsi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
@@ -5131,19 +5131,9 @@ static int dsi_init_output(struct dsi_data *dsi)
5131 | DRM_BUS_FLAG_DE_HIGH 5131 | DRM_BUS_FLAG_DE_HIGH
5132 | DRM_BUS_FLAG_SYNC_NEGEDGE; 5132 | DRM_BUS_FLAG_SYNC_NEGEDGE;
5133 5133
5134 out->next = omapdss_of_find_connected_device(out->dev->of_node, 0); 5134 r = omapdss_device_init_output(out);
5135 if (IS_ERR(out->next)) { 5135 if (r < 0)
5136 if (PTR_ERR(out->next) != -EPROBE_DEFER)
5137 dev_err(out->dev, "failed to find video sink\n");
5138 return PTR_ERR(out->next);
5139 }
5140
5141 r = omapdss_output_validate(out);
5142 if (r) {
5143 omapdss_device_put(out->next);
5144 out->next = NULL;
5145 return r; 5136 return r;
5146 }
5147 5137
5148 omapdss_device_register(out); 5138 omapdss_device_register(out);
5149 5139
@@ -5154,9 +5144,8 @@ static void dsi_uninit_output(struct dsi_data *dsi)
5154{ 5144{
5155 struct omap_dss_device *out = &dsi->output; 5145 struct omap_dss_device *out = &dsi->output;
5156 5146
5157 if (out->next)
5158 omapdss_device_put(out->next);
5159 omapdss_device_unregister(out); 5147 omapdss_device_unregister(out);
5148 omapdss_device_cleanup_output(out);
5160} 5149}
5161 5150
5162static int dsi_probe_of(struct dsi_data *dsi) 5151static int dsi_probe_of(struct dsi_data *dsi)
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
index 6f88fb4d6344..60792981a33f 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c
@@ -687,19 +687,9 @@ static int hdmi4_init_output(struct omap_hdmi *hdmi)
687 out->of_ports = BIT(0); 687 out->of_ports = BIT(0);
688 out->ops_flags = OMAP_DSS_DEVICE_OP_EDID; 688 out->ops_flags = OMAP_DSS_DEVICE_OP_EDID;
689 689
690 out->next = omapdss_of_find_connected_device(out->dev->of_node, 0); 690 r = omapdss_device_init_output(out);
691 if (IS_ERR(out->next)) { 691 if (r < 0)
692 if (PTR_ERR(out->next) != -EPROBE_DEFER)
693 dev_err(out->dev, "failed to find video sink\n");
694 return PTR_ERR(out->next);
695 }
696
697 r = omapdss_output_validate(out);
698 if (r) {
699 omapdss_device_put(out->next);
700 out->next = NULL;
701 return r; 692 return r;
702 }
703 693
704 omapdss_device_register(out); 694 omapdss_device_register(out);
705 695
@@ -710,9 +700,8 @@ static void hdmi4_uninit_output(struct omap_hdmi *hdmi)
710{ 700{
711 struct omap_dss_device *out = &hdmi->output; 701 struct omap_dss_device *out = &hdmi->output;
712 702
713 if (out->next)
714 omapdss_device_put(out->next);
715 omapdss_device_unregister(out); 703 omapdss_device_unregister(out);
704 omapdss_device_cleanup_output(out);
716} 705}
717 706
718static int hdmi4_probe_of(struct omap_hdmi *hdmi) 707static int hdmi4_probe_of(struct omap_hdmi *hdmi)
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
index 28cf1c32b158..d7d33b4d2bed 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c
@@ -671,19 +671,9 @@ static int hdmi5_init_output(struct omap_hdmi *hdmi)
671 out->of_ports = BIT(0); 671 out->of_ports = BIT(0);
672 out->ops_flags = OMAP_DSS_DEVICE_OP_EDID; 672 out->ops_flags = OMAP_DSS_DEVICE_OP_EDID;
673 673
674 out->next = omapdss_of_find_connected_device(out->dev->of_node, 0); 674 r = omapdss_device_init_output(out);
675 if (IS_ERR(out->next)) { 675 if (r < 0)
676 if (PTR_ERR(out->next) != -EPROBE_DEFER)
677 dev_err(out->dev, "failed to find video sink\n");
678 return PTR_ERR(out->next);
679 }
680
681 r = omapdss_output_validate(out);
682 if (r) {
683 omapdss_device_put(out->next);
684 out->next = NULL;
685 return r; 676 return r;
686 }
687 677
688 omapdss_device_register(out); 678 omapdss_device_register(out);
689 679
@@ -694,9 +684,8 @@ static void hdmi5_uninit_output(struct omap_hdmi *hdmi)
694{ 684{
695 struct omap_dss_device *out = &hdmi->output; 685 struct omap_dss_device *out = &hdmi->output;
696 686
697 if (out->next)
698 omapdss_device_put(out->next);
699 omapdss_device_unregister(out); 687 omapdss_device_unregister(out);
688 omapdss_device_cleanup_output(out);
700} 689}
701 690
702static int hdmi5_probe_of(struct omap_hdmi *hdmi) 691static int hdmi5_probe_of(struct omap_hdmi *hdmi)
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
index fc82b8f545ae..fbdeeaa521d6 100644
--- a/drivers/gpu/drm/omapdrm/dss/omapdss.h
+++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h
@@ -493,7 +493,8 @@ int omap_dss_get_num_overlays(void);
493#define for_each_dss_output(d) \ 493#define for_each_dss_output(d) \
494 while ((d = omapdss_device_next_output(d)) != NULL) 494 while ((d = omapdss_device_next_output(d)) != NULL)
495struct omap_dss_device *omapdss_device_next_output(struct omap_dss_device *from); 495struct omap_dss_device *omapdss_device_next_output(struct omap_dss_device *from);
496int omapdss_output_validate(struct omap_dss_device *out); 496int omapdss_device_init_output(struct omap_dss_device *out);
497void omapdss_device_cleanup_output(struct omap_dss_device *out);
497 498
498typedef void (*omap_dispc_isr_t) (void *arg, u32 mask); 499typedef void (*omap_dispc_isr_t) (void *arg, u32 mask);
499int omap_dispc_register_isr(omap_dispc_isr_t isr, void *arg, u32 mask); 500int omap_dispc_register_isr(omap_dispc_isr_t isr, void *arg, u32 mask);
diff --git a/drivers/gpu/drm/omapdrm/dss/output.c b/drivers/gpu/drm/omapdrm/dss/output.c
index 18505bc70f7e..0ac400a521f3 100644
--- a/drivers/gpu/drm/omapdrm/dss/output.c
+++ b/drivers/gpu/drm/omapdrm/dss/output.c
@@ -24,8 +24,15 @@
24#include "dss.h" 24#include "dss.h"
25#include "omapdss.h" 25#include "omapdss.h"
26 26
27int omapdss_output_validate(struct omap_dss_device *out) 27int omapdss_device_init_output(struct omap_dss_device *out)
28{ 28{
29 out->next = omapdss_of_find_connected_device(out->dev->of_node, 0);
30 if (IS_ERR(out->next)) {
31 if (PTR_ERR(out->next) != -EPROBE_DEFER)
32 dev_err(out->dev, "failed to find video sink\n");
33 return PTR_ERR(out->next);
34 }
35
29 if (out->next && out->output_type != out->next->type) { 36 if (out->next && out->output_type != out->next->type) {
30 dev_err(out->dev, "output type and display type don't match\n"); 37 dev_err(out->dev, "output type and display type don't match\n");
31 return -EINVAL; 38 return -EINVAL;
@@ -33,7 +40,14 @@ int omapdss_output_validate(struct omap_dss_device *out)
33 40
34 return 0; 41 return 0;
35} 42}
36EXPORT_SYMBOL(omapdss_output_validate); 43EXPORT_SYMBOL(omapdss_device_init_output);
44
45void omapdss_device_cleanup_output(struct omap_dss_device *out)
46{
47 if (out->next)
48 omapdss_device_put(out->next);
49}
50EXPORT_SYMBOL(omapdss_device_cleanup_output);
37 51
38int dss_install_mgr_ops(struct dss_device *dss, 52int dss_install_mgr_ops(struct dss_device *dss,
39 const struct dss_mgr_ops *mgr_ops, 53 const struct dss_mgr_ops *mgr_ops,
diff --git a/drivers/gpu/drm/omapdrm/dss/sdi.c b/drivers/gpu/drm/omapdrm/dss/sdi.c
index 20e88c6e3d98..58c17566a4cb 100644
--- a/drivers/gpu/drm/omapdrm/dss/sdi.c
+++ b/drivers/gpu/drm/omapdrm/dss/sdi.c
@@ -281,19 +281,9 @@ static int sdi_init_output(struct sdi_device *sdi)
281 out->bus_flags = DRM_BUS_FLAG_PIXDATA_POSEDGE /* 15.5.9.1.2 */ 281 out->bus_flags = DRM_BUS_FLAG_PIXDATA_POSEDGE /* 15.5.9.1.2 */
282 | DRM_BUS_FLAG_SYNC_POSEDGE; 282 | DRM_BUS_FLAG_SYNC_POSEDGE;
283 283
284 out->next = omapdss_of_find_connected_device(out->dev->of_node, 1); 284 r = omapdss_device_init_output(out);
285 if (IS_ERR(out->next)) { 285 if (r < 0)
286 if (PTR_ERR(out->next) != -EPROBE_DEFER)
287 dev_err(out->dev, "failed to find video sink\n");
288 return PTR_ERR(out->next);
289 }
290
291 r = omapdss_output_validate(out);
292 if (r) {
293 omapdss_device_put(out->next);
294 out->next = NULL;
295 return r; 286 return r;
296 }
297 287
298 omapdss_device_register(out); 288 omapdss_device_register(out);
299 289
@@ -302,9 +292,8 @@ static int sdi_init_output(struct sdi_device *sdi)
302 292
303static void sdi_uninit_output(struct sdi_device *sdi) 293static void sdi_uninit_output(struct sdi_device *sdi)
304{ 294{
305 if (sdi->output.next)
306 omapdss_device_put(sdi->output.next);
307 omapdss_device_unregister(&sdi->output); 295 omapdss_device_unregister(&sdi->output);
296 omapdss_device_cleanup_output(&sdi->output);
308} 297}
309 298
310int sdi_init_port(struct dss_device *dss, struct platform_device *pdev, 299int sdi_init_port(struct dss_device *dss, struct platform_device *pdev,
diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c
index dc4133718875..3fc776c45c4f 100644
--- a/drivers/gpu/drm/omapdrm/dss/venc.c
+++ b/drivers/gpu/drm/omapdrm/dss/venc.c
@@ -752,19 +752,9 @@ static int venc_init_output(struct venc_device *venc)
752 out->owner = THIS_MODULE; 752 out->owner = THIS_MODULE;
753 out->of_ports = BIT(0); 753 out->of_ports = BIT(0);
754 754
755 out->next = omapdss_of_find_connected_device(out->dev->of_node, 0); 755 r = omapdss_device_init_output(out);
756 if (IS_ERR(out->next)) { 756 if (r < 0)
757 if (PTR_ERR(out->next) != -EPROBE_DEFER)
758 dev_err(out->dev, "failed to find video sink\n");
759 return PTR_ERR(out->next);
760 }
761
762 r = omapdss_output_validate(out);
763 if (r) {
764 omapdss_device_put(out->next);
765 out->next = NULL;
766 return r; 757 return r;
767 }
768 758
769 omapdss_device_register(out); 759 omapdss_device_register(out);
770 760
@@ -773,9 +763,8 @@ static int venc_init_output(struct venc_device *venc)
773 763
774static void venc_uninit_output(struct venc_device *venc) 764static void venc_uninit_output(struct venc_device *venc)
775{ 765{
776 if (venc->output.next)
777 omapdss_device_put(venc->output.next);
778 omapdss_device_unregister(&venc->output); 766 omapdss_device_unregister(&venc->output);
767 omapdss_device_cleanup_output(&venc->output);
779} 768}
780 769
781static int venc_probe_of(struct venc_device *venc) 770static int venc_probe_of(struct venc_device *venc)