ARM: pmu: add support for interrupt-affinity property
[linux/fpc-iii.git] / drivers / gpu / drm / drm_of.c
blob16150a00c23728585d50ebc59747286633bca51a
1 #include <linux/export.h>
2 #include <linux/list.h>
3 #include <linux/of_graph.h>
4 #include <drm/drmP.h>
5 #include <drm/drm_crtc.h>
6 #include <drm/drm_of.h>
8 /**
9 * drm_crtc_port_mask - find the mask of a registered CRTC by port OF node
10 * @dev: DRM device
11 * @port: port OF node
13 * Given a port OF node, return the possible mask of the corresponding
14 * CRTC within a device's list of CRTCs. Returns zero if not found.
16 static uint32_t drm_crtc_port_mask(struct drm_device *dev,
17 struct device_node *port)
19 unsigned int index = 0;
20 struct drm_crtc *tmp;
22 list_for_each_entry(tmp, &dev->mode_config.crtc_list, head) {
23 if (tmp->port == port)
24 return 1 << index;
26 index++;
29 return 0;
32 /**
33 * drm_of_find_possible_crtcs - find the possible CRTCs for an encoder port
34 * @dev: DRM device
35 * @port: encoder port to scan for endpoints
37 * Scan all endpoints attached to a port, locate their attached CRTCs,
38 * and generate the DRM mask of CRTCs which may be attached to this
39 * encoder.
41 * See Documentation/devicetree/bindings/graph.txt for the bindings.
43 uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
44 struct device_node *port)
46 struct device_node *remote_port, *ep = NULL;
47 uint32_t possible_crtcs = 0;
49 do {
50 ep = of_graph_get_next_endpoint(port, ep);
51 if (!ep)
52 break;
54 remote_port = of_graph_get_remote_port(ep);
55 if (!remote_port) {
56 of_node_put(ep);
57 return 0;
60 possible_crtcs |= drm_crtc_port_mask(dev, remote_port);
62 of_node_put(remote_port);
63 } while (1);
65 return possible_crtcs;
67 EXPORT_SYMBOL(drm_of_find_possible_crtcs);