blob: 4f835490d77a761d11fd859afbf976595c7679ff [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Russell King7e435aa2014-06-15 11:07:12 +01002#ifndef __DRM_OF_H__
3#define __DRM_OF_H__
4
Philipp Zabel4cacf912015-02-24 11:34:01 +01005#include <linux/of_graph.h>
6
Liviu Dudaudf785aa2015-10-20 10:23:12 +01007struct component_master_ops;
Russell King97ac0e42016-10-19 11:28:27 +01008struct component_match;
Liviu Dudaudf785aa2015-10-20 10:23:12 +01009struct device;
Russell King7e435aa2014-06-15 11:07:12 +010010struct drm_device;
Philipp Zabel4cacf912015-02-24 11:34:01 +010011struct drm_encoder;
Rob Herring1f2db302017-03-22 08:26:05 -050012struct drm_panel;
13struct drm_bridge;
Russell King7e435aa2014-06-15 11:07:12 +010014struct device_node;
15
16#ifdef CONFIG_OF
Daniel Vetter91faa042017-03-22 09:36:02 +010017uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
18 struct device_node *port);
19void drm_of_component_match_add(struct device *master,
20 struct component_match **matchptr,
21 int (*compare)(struct device *, void *),
22 struct device_node *node);
23int drm_of_component_probe(struct device *dev,
24 int (*compare_of)(struct device *, void *),
25 const struct component_master_ops *m_ops);
26int drm_of_encoder_active_endpoint(struct device_node *node,
27 struct drm_encoder *encoder,
28 struct of_endpoint *endpoint);
Rob Herring1f2db302017-03-22 08:26:05 -050029int drm_of_find_panel_or_bridge(const struct device_node *np,
30 int port, int endpoint,
31 struct drm_panel **panel,
32 struct drm_bridge **bridge);
Russell King7e435aa2014-06-15 11:07:12 +010033#else
34static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
35 struct device_node *port)
36{
37 return 0;
38}
Liviu Dudaudf785aa2015-10-20 10:23:12 +010039
Arnd Bergmann329f4c82016-10-26 10:57:47 +020040static inline void
41drm_of_component_match_add(struct device *master,
42 struct component_match **matchptr,
43 int (*compare)(struct device *, void *),
44 struct device_node *node)
Russell King97ac0e42016-10-19 11:28:27 +010045{
46}
47
Liviu Dudaudf785aa2015-10-20 10:23:12 +010048static inline int
49drm_of_component_probe(struct device *dev,
50 int (*compare_of)(struct device *, void *),
51 const struct component_master_ops *m_ops)
52{
53 return -EINVAL;
54}
Philipp Zabel4cacf912015-02-24 11:34:01 +010055
56static inline int drm_of_encoder_active_endpoint(struct device_node *node,
57 struct drm_encoder *encoder,
58 struct of_endpoint *endpoint)
59{
60 return -EINVAL;
61}
Rob Herring1f2db302017-03-22 08:26:05 -050062static inline int drm_of_find_panel_or_bridge(const struct device_node *np,
63 int port, int endpoint,
64 struct drm_panel **panel,
65 struct drm_bridge **bridge)
66{
67 return -EINVAL;
68}
Russell King7e435aa2014-06-15 11:07:12 +010069#endif
70
Philipp Zabel4cacf912015-02-24 11:34:01 +010071static inline int drm_of_encoder_active_endpoint_id(struct device_node *node,
72 struct drm_encoder *encoder)
73{
74 struct of_endpoint endpoint;
75 int ret = drm_of_encoder_active_endpoint(node, encoder,
76 &endpoint);
77
78 return ret ?: endpoint.id;
79}
80
81static inline int drm_of_encoder_active_port_id(struct device_node *node,
82 struct drm_encoder *encoder)
83{
84 struct of_endpoint endpoint;
85 int ret = drm_of_encoder_active_endpoint(node, encoder,
86 &endpoint);
87
88 return ret ?: endpoint.port;
89}
90
Russell King7e435aa2014-06-15 11:07:12 +010091#endif /* __DRM_OF_H__ */