Commit 6457b971 authored by Russell King's avatar Russell King Committed by Philipp Zabel

drm/imx: convert imx-drm to use the generic DRM OF helper

Use the generic DRM OF helper to locate the possible CRTCs for the
encoder, thereby shrinking the imx-drm driver some more.
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
parent f4876ffe
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <drm/drm_gem_cma_helper.h> #include <drm/drm_gem_cma_helper.h>
#include <drm/drm_fb_cma_helper.h> #include <drm/drm_fb_cma_helper.h>
#include <drm/drm_plane_helper.h> #include <drm/drm_plane_helper.h>
#include <drm/drm_of.h>
#include "imx-drm.h" #include "imx-drm.h"
...@@ -46,7 +47,6 @@ struct imx_drm_crtc { ...@@ -46,7 +47,6 @@ struct imx_drm_crtc {
struct drm_crtc *crtc; struct drm_crtc *crtc;
int pipe; int pipe;
struct imx_drm_crtc_helper_funcs imx_drm_helper_funcs; struct imx_drm_crtc_helper_funcs imx_drm_helper_funcs;
struct device_node *port;
}; };
static int legacyfb_depth = 16; static int legacyfb_depth = 16;
...@@ -365,9 +365,10 @@ int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc, ...@@ -365,9 +365,10 @@ int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc,
imx_drm_crtc->imx_drm_helper_funcs = *imx_drm_helper_funcs; imx_drm_crtc->imx_drm_helper_funcs = *imx_drm_helper_funcs;
imx_drm_crtc->pipe = imxdrm->pipes++; imx_drm_crtc->pipe = imxdrm->pipes++;
imx_drm_crtc->port = port;
imx_drm_crtc->crtc = crtc; imx_drm_crtc->crtc = crtc;
crtc->port = port;
imxdrm->crtc[imx_drm_crtc->pipe] = imx_drm_crtc; imxdrm->crtc[imx_drm_crtc->pipe] = imx_drm_crtc;
*new_crtc = imx_drm_crtc; *new_crtc = imx_drm_crtc;
...@@ -408,33 +409,28 @@ int imx_drm_remove_crtc(struct imx_drm_crtc *imx_drm_crtc) ...@@ -408,33 +409,28 @@ int imx_drm_remove_crtc(struct imx_drm_crtc *imx_drm_crtc)
} }
EXPORT_SYMBOL_GPL(imx_drm_remove_crtc); EXPORT_SYMBOL_GPL(imx_drm_remove_crtc);
/* int imx_drm_encoder_parse_of(struct drm_device *drm,
* Find the DRM CRTC possible mask for the connected endpoint. struct drm_encoder *encoder, struct device_node *np)
*
* The encoder possible masks are defined by their position in the
* mode_config crtc_list. This means that CRTCs must not be added
* or removed once the DRM device has been fully initialised.
*/
static uint32_t imx_drm_find_crtc_mask(struct imx_drm_device *imxdrm,
struct device_node *endpoint)
{ {
struct device_node *port; uint32_t crtc_mask = drm_of_find_possible_crtcs(drm, np);
unsigned i;
port = of_graph_get_remote_port(endpoint); /*
if (!port) * If we failed to find the CRTC(s) which this encoder is
return 0; * supposed to be connected to, it's because the CRTC has
of_node_put(port); * not been registered yet. Defer probing, and hope that
* the required CRTC is added later.
*/
if (crtc_mask == 0)
return -EPROBE_DEFER;
for (i = 0; i < MAX_CRTC; i++) { encoder->possible_crtcs = crtc_mask;
struct imx_drm_crtc *imx_drm_crtc = imxdrm->crtc[i];
if (imx_drm_crtc && imx_drm_crtc->port == port) /* FIXME: this is the mask of outputs which can clone this output. */
return drm_crtc_mask(imx_drm_crtc->crtc); encoder->possible_clones = ~0;
}
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(imx_drm_encoder_parse_of);
static struct device_node *imx_drm_of_get_next_endpoint( static struct device_node *imx_drm_of_get_next_endpoint(
const struct device_node *parent, struct device_node *prev) const struct device_node *parent, struct device_node *prev)
...@@ -445,48 +441,6 @@ static struct device_node *imx_drm_of_get_next_endpoint( ...@@ -445,48 +441,6 @@ static struct device_node *imx_drm_of_get_next_endpoint(
return node; return node;
} }
int imx_drm_encoder_parse_of(struct drm_device *drm,
struct drm_encoder *encoder, struct device_node *np)
{
struct imx_drm_device *imxdrm = drm->dev_private;
struct device_node *ep = NULL;
uint32_t crtc_mask = 0;
int i;
for (i = 0; ; i++) {
u32 mask;
ep = imx_drm_of_get_next_endpoint(np, ep);
if (!ep)
break;
mask = imx_drm_find_crtc_mask(imxdrm, ep);
/*
* If we failed to find the CRTC(s) which this encoder is
* supposed to be connected to, it's because the CRTC has
* not been registered yet. Defer probing, and hope that
* the required CRTC is added later.
*/
if (mask == 0)
return -EPROBE_DEFER;
crtc_mask |= mask;
}
of_node_put(ep);
if (i == 0)
return -ENOENT;
encoder->possible_crtcs = crtc_mask;
/* FIXME: this is the mask of outputs which can clone this output. */
encoder->possible_clones = ~0;
return 0;
}
EXPORT_SYMBOL_GPL(imx_drm_encoder_parse_of);
/* /*
* @node: device tree node containing encoder input ports * @node: device tree node containing encoder input ports
* @encoder: drm_encoder * @encoder: drm_encoder
...@@ -510,7 +464,7 @@ int imx_drm_encoder_get_mux_id(struct device_node *node, ...@@ -510,7 +464,7 @@ int imx_drm_encoder_get_mux_id(struct device_node *node,
port = of_graph_get_remote_port(ep); port = of_graph_get_remote_port(ep);
of_node_put(port); of_node_put(port);
if (port == imx_crtc->port) { if (port == imx_crtc->crtc->port) {
ret = of_graph_parse_endpoint(ep, &endpoint); ret = of_graph_parse_endpoint(ep, &endpoint);
return ret ? ret : endpoint.port; return ret ? ret : endpoint.port;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment