mirror of
https://github.com/torvalds/linux.git
synced 2024-12-04 18:13:04 +00:00
7416f4e33b
Using the for_each_... macro should make the code a bit shorter and easier to read. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
64 lines
1.5 KiB
C
64 lines
1.5 KiB
C
#include <linux/export.h>
|
|
#include <linux/list.h>
|
|
#include <linux/of_graph.h>
|
|
#include <drm/drmP.h>
|
|
#include <drm/drm_crtc.h>
|
|
#include <drm/drm_of.h>
|
|
|
|
/**
|
|
* drm_crtc_port_mask - find the mask of a registered CRTC by port OF node
|
|
* @dev: DRM device
|
|
* @port: port OF node
|
|
*
|
|
* Given a port OF node, return the possible mask of the corresponding
|
|
* CRTC within a device's list of CRTCs. Returns zero if not found.
|
|
*/
|
|
static uint32_t drm_crtc_port_mask(struct drm_device *dev,
|
|
struct device_node *port)
|
|
{
|
|
unsigned int index = 0;
|
|
struct drm_crtc *tmp;
|
|
|
|
list_for_each_entry(tmp, &dev->mode_config.crtc_list, head) {
|
|
if (tmp->port == port)
|
|
return 1 << index;
|
|
|
|
index++;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* drm_of_find_possible_crtcs - find the possible CRTCs for an encoder port
|
|
* @dev: DRM device
|
|
* @port: encoder port to scan for endpoints
|
|
*
|
|
* Scan all endpoints attached to a port, locate their attached CRTCs,
|
|
* and generate the DRM mask of CRTCs which may be attached to this
|
|
* encoder.
|
|
*
|
|
* See Documentation/devicetree/bindings/graph.txt for the bindings.
|
|
*/
|
|
uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
|
|
struct device_node *port)
|
|
{
|
|
struct device_node *remote_port, *ep;
|
|
uint32_t possible_crtcs = 0;
|
|
|
|
for_each_endpoint_of_node(port, ep) {
|
|
remote_port = of_graph_get_remote_port(ep);
|
|
if (!remote_port) {
|
|
of_node_put(ep);
|
|
return 0;
|
|
}
|
|
|
|
possible_crtcs |= drm_crtc_port_mask(dev, remote_port);
|
|
|
|
of_node_put(remote_port);
|
|
}
|
|
|
|
return possible_crtcs;
|
|
}
|
|
EXPORT_SYMBOL(drm_of_find_possible_crtcs);
|