blob: 3fd87b386ed7ccb65b1c8caa318ab6dfb368b401 [file] [log] [blame]
Russell King7e435aa2014-06-15 11:07:12 +01001#ifndef __DRM_OF_H__
2#define __DRM_OF_H__
3
Philipp Zabel4cacf912015-02-24 11:34:01 +01004#include <linux/of_graph.h>
5
Liviu Dudaudf785aa2015-10-20 10:23:12 +01006struct component_master_ops;
7struct device;
Russell King7e435aa2014-06-15 11:07:12 +01008struct drm_device;
Philipp Zabel4cacf912015-02-24 11:34:01 +01009struct drm_encoder;
Russell King7e435aa2014-06-15 11:07:12 +010010struct device_node;
11
12#ifdef CONFIG_OF
13extern uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
14 struct device_node *port);
Liviu Dudaudf785aa2015-10-20 10:23:12 +010015extern int drm_of_component_probe(struct device *dev,
16 int (*compare_of)(struct device *, void *),
17 const struct component_master_ops *m_ops);
Philipp Zabel4cacf912015-02-24 11:34:01 +010018extern int drm_of_encoder_active_endpoint(struct device_node *node,
19 struct drm_encoder *encoder,
20 struct of_endpoint *endpoint);
Russell King7e435aa2014-06-15 11:07:12 +010021#else
22static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
23 struct device_node *port)
24{
25 return 0;
26}
Liviu Dudaudf785aa2015-10-20 10:23:12 +010027
28static inline int
29drm_of_component_probe(struct device *dev,
30 int (*compare_of)(struct device *, void *),
31 const struct component_master_ops *m_ops)
32{
33 return -EINVAL;
34}
Philipp Zabel4cacf912015-02-24 11:34:01 +010035
36static inline int drm_of_encoder_active_endpoint(struct device_node *node,
37 struct drm_encoder *encoder,
38 struct of_endpoint *endpoint)
39{
40 return -EINVAL;
41}
Russell King7e435aa2014-06-15 11:07:12 +010042#endif
43
Philipp Zabel4cacf912015-02-24 11:34:01 +010044static inline int drm_of_encoder_active_endpoint_id(struct device_node *node,
45 struct drm_encoder *encoder)
46{
47 struct of_endpoint endpoint;
48 int ret = drm_of_encoder_active_endpoint(node, encoder,
49 &endpoint);
50
51 return ret ?: endpoint.id;
52}
53
54static inline int drm_of_encoder_active_port_id(struct device_node *node,
55 struct drm_encoder *encoder)
56{
57 struct of_endpoint endpoint;
58 int ret = drm_of_encoder_active_endpoint(node, encoder,
59 &endpoint);
60
61 return ret ?: endpoint.port;
62}
63
Russell King7e435aa2014-06-15 11:07:12 +010064#endif /* __DRM_OF_H__ */