aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/imx/imx-drm-core.c
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2014-07-03 12:52:57 -0400
committerPhilipp Zabel <p.zabel@pengutronix.de>2015-01-06 11:36:14 -0500
commit6457b9716bca99b95a07e85ff8b00f9bf471ac2c (patch)
tree2af79c79f73c7d76f7bebe51a45568753335e74f /drivers/gpu/drm/imx/imx-drm-core.c
parentf4876ffea6f310e1c7ee015687f913248a0d5f9c (diff)
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: Russell King <rmk+kernel@arm.linux.org.uk> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Diffstat (limited to 'drivers/gpu/drm/imx/imx-drm-core.c')
-rw-r--r--drivers/gpu/drm/imx/imx-drm-core.c84
1 files changed, 19 insertions, 65 deletions
diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c
index b250130debc8..06cd2e516db6 100644
--- a/drivers/gpu/drm/imx/imx-drm-core.c
+++ b/drivers/gpu/drm/imx/imx-drm-core.c
@@ -25,6 +25,7 @@
25#include <drm/drm_gem_cma_helper.h> 25#include <drm/drm_gem_cma_helper.h>
26#include <drm/drm_fb_cma_helper.h> 26#include <drm/drm_fb_cma_helper.h>
27#include <drm/drm_plane_helper.h> 27#include <drm/drm_plane_helper.h>
28#include <drm/drm_of.h>
28 29
29#include "imx-drm.h" 30#include "imx-drm.h"
30 31
@@ -46,7 +47,6 @@ struct imx_drm_crtc {
46 struct drm_crtc *crtc; 47 struct drm_crtc *crtc;
47 int pipe; 48 int pipe;
48 struct imx_drm_crtc_helper_funcs imx_drm_helper_funcs; 49 struct imx_drm_crtc_helper_funcs imx_drm_helper_funcs;
49 struct device_node *port;
50}; 50};
51 51
52static int legacyfb_depth = 16; 52static int legacyfb_depth = 16;
@@ -365,9 +365,10 @@ int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc,
365 365
366 imx_drm_crtc->imx_drm_helper_funcs = *imx_drm_helper_funcs; 366 imx_drm_crtc->imx_drm_helper_funcs = *imx_drm_helper_funcs;
367 imx_drm_crtc->pipe = imxdrm->pipes++; 367 imx_drm_crtc->pipe = imxdrm->pipes++;
368 imx_drm_crtc->port = port;
369 imx_drm_crtc->crtc = crtc; 368 imx_drm_crtc->crtc = crtc;
370 369
370 crtc->port = port;
371
371 imxdrm->crtc[imx_drm_crtc->pipe] = imx_drm_crtc; 372 imxdrm->crtc[imx_drm_crtc->pipe] = imx_drm_crtc;
372 373
373 *new_crtc = imx_drm_crtc; 374 *new_crtc = imx_drm_crtc;
@@ -408,33 +409,28 @@ int imx_drm_remove_crtc(struct imx_drm_crtc *imx_drm_crtc)
408} 409}
409EXPORT_SYMBOL_GPL(imx_drm_remove_crtc); 410EXPORT_SYMBOL_GPL(imx_drm_remove_crtc);
410 411
411/* 412int imx_drm_encoder_parse_of(struct drm_device *drm,
412 * Find the DRM CRTC possible mask for the connected endpoint. 413 struct drm_encoder *encoder, struct device_node *np)
413 *
414 * The encoder possible masks are defined by their position in the
415 * mode_config crtc_list. This means that CRTCs must not be added
416 * or removed once the DRM device has been fully initialised.
417 */
418static uint32_t imx_drm_find_crtc_mask(struct imx_drm_device *imxdrm,
419 struct device_node *endpoint)
420{ 414{
421 struct device_node *port; 415 uint32_t crtc_mask = drm_of_find_possible_crtcs(drm, np);
422 unsigned i;
423 416
424 port = of_graph_get_remote_port(endpoint); 417 /*
425 if (!port) 418 * If we failed to find the CRTC(s) which this encoder is
426 return 0; 419 * supposed to be connected to, it's because the CRTC has
427 of_node_put(port); 420 * not been registered yet. Defer probing, and hope that
421 * the required CRTC is added later.
422 */
423 if (crtc_mask == 0)
424 return -EPROBE_DEFER;
428 425
429 for (i = 0; i < MAX_CRTC; i++) { 426 encoder->possible_crtcs = crtc_mask;
430 struct imx_drm_crtc *imx_drm_crtc = imxdrm->crtc[i];
431 427
432 if (imx_drm_crtc && imx_drm_crtc->port == port) 428 /* FIXME: this is the mask of outputs which can clone this output. */
433 return drm_crtc_mask(imx_drm_crtc->crtc); 429 encoder->possible_clones = ~0;
434 }
435 430
436 return 0; 431 return 0;
437} 432}
433EXPORT_SYMBOL_GPL(imx_drm_encoder_parse_of);
438 434
439static struct device_node *imx_drm_of_get_next_endpoint( 435static struct device_node *imx_drm_of_get_next_endpoint(
440 const struct device_node *parent, struct device_node *prev) 436 const struct device_node *parent, struct device_node *prev)
@@ -445,48 +441,6 @@ static struct device_node *imx_drm_of_get_next_endpoint(
445 return node; 441 return node;
446} 442}
447 443
448int imx_drm_encoder_parse_of(struct drm_device *drm,
449 struct drm_encoder *encoder, struct device_node *np)
450{
451 struct imx_drm_device *imxdrm = drm->dev_private;
452 struct device_node *ep = NULL;
453 uint32_t crtc_mask = 0;
454 int i;
455
456 for (i = 0; ; i++) {
457 u32 mask;
458
459 ep = imx_drm_of_get_next_endpoint(np, ep);
460 if (!ep)
461 break;
462
463 mask = imx_drm_find_crtc_mask(imxdrm, ep);
464
465 /*
466 * If we failed to find the CRTC(s) which this encoder is
467 * supposed to be connected to, it's because the CRTC has
468 * not been registered yet. Defer probing, and hope that
469 * the required CRTC is added later.
470 */
471 if (mask == 0)
472 return -EPROBE_DEFER;
473
474 crtc_mask |= mask;
475 }
476
477 of_node_put(ep);
478 if (i == 0)
479 return -ENOENT;
480
481 encoder->possible_crtcs = crtc_mask;
482
483 /* FIXME: this is the mask of outputs which can clone this output. */
484 encoder->possible_clones = ~0;
485
486 return 0;
487}
488EXPORT_SYMBOL_GPL(imx_drm_encoder_parse_of);
489
490/* 444/*
491 * @node: device tree node containing encoder input ports 445 * @node: device tree node containing encoder input ports
492 * @encoder: drm_encoder 446 * @encoder: drm_encoder
@@ -510,7 +464,7 @@ int imx_drm_encoder_get_mux_id(struct device_node *node,
510 464
511 port = of_graph_get_remote_port(ep); 465 port = of_graph_get_remote_port(ep);
512 of_node_put(port); 466 of_node_put(port);
513 if (port == imx_crtc->port) { 467 if (port == imx_crtc->crtc->port) {
514 ret = of_graph_parse_endpoint(ep, &endpoint); 468 ret = of_graph_parse_endpoint(ep, &endpoint);
515 return ret ? ret : endpoint.port; 469 return ret ? ret : endpoint.port;
516 } 470 }