aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/drm/drm_irq.c10
-rw-r--r--drivers/gpu/drm/rockchip/rockchip_drm_drv.c81
-rw-r--r--include/uapi/drm/drm_fourcc.h2
3 files changed, 85 insertions, 8 deletions
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index eba6337f5860..2151ea551d3b 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -616,10 +616,18 @@ int drm_control(struct drm_device *dev, void *data,
616void drm_calc_timestamping_constants(struct drm_crtc *crtc, 616void drm_calc_timestamping_constants(struct drm_crtc *crtc,
617 const struct drm_display_mode *mode) 617 const struct drm_display_mode *mode)
618{ 618{
619 struct drm_vblank_crtc *vblank = &crtc->dev->vblank[drm_crtc_index(crtc)]; 619 struct drm_device *dev = crtc->dev;
620 unsigned int pipe = drm_crtc_index(crtc);
621 struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
620 int linedur_ns = 0, framedur_ns = 0; 622 int linedur_ns = 0, framedur_ns = 0;
621 int dotclock = mode->crtc_clock; 623 int dotclock = mode->crtc_clock;
622 624
625 if (!dev->num_crtcs)
626 return;
627
628 if (WARN_ON(pipe >= dev->num_crtcs))
629 return;
630
623 /* Valid dotclock? */ 631 /* Valid dotclock? */
624 if (dotclock > 0) { 632 if (dotclock > 0) {
625 int frame_size = mode->crtc_htotal * mode->crtc_vtotal; 633 int frame_size = mode->crtc_htotal * mode->crtc_vtotal;
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index d26e0cc7dc4b..f22e1e1ee64a 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -19,7 +19,6 @@
19#include <drm/drmP.h> 19#include <drm/drmP.h>
20#include <drm/drm_crtc_helper.h> 20#include <drm/drm_crtc_helper.h>
21#include <drm/drm_fb_helper.h> 21#include <drm/drm_fb_helper.h>
22#include <drm/drm_of.h>
23#include <linux/dma-mapping.h> 22#include <linux/dma-mapping.h>
24#include <linux/pm_runtime.h> 23#include <linux/pm_runtime.h>
25#include <linux/module.h> 24#include <linux/module.h>
@@ -419,6 +418,29 @@ static int compare_of(struct device *dev, void *data)
419 return dev->of_node == np; 418 return dev->of_node == np;
420} 419}
421 420
421static void rockchip_add_endpoints(struct device *dev,
422 struct component_match **match,
423 struct device_node *port)
424{
425 struct device_node *ep, *remote;
426
427 for_each_child_of_node(port, ep) {
428 remote = of_graph_get_remote_port_parent(ep);
429 if (!remote || !of_device_is_available(remote)) {
430 of_node_put(remote);
431 continue;
432 } else if (!of_device_is_available(remote->parent)) {
433 dev_warn(dev, "parent device of %s is not available\n",
434 remote->full_name);
435 of_node_put(remote);
436 continue;
437 }
438
439 component_match_add(dev, match, compare_of, remote);
440 of_node_put(remote);
441 }
442}
443
422static int rockchip_drm_bind(struct device *dev) 444static int rockchip_drm_bind(struct device *dev)
423{ 445{
424 struct drm_device *drm; 446 struct drm_device *drm;
@@ -461,14 +483,61 @@ static const struct component_master_ops rockchip_drm_ops = {
461 483
462static int rockchip_drm_platform_probe(struct platform_device *pdev) 484static int rockchip_drm_platform_probe(struct platform_device *pdev)
463{ 485{
464 int ret = drm_of_component_probe(&pdev->dev, compare_of, 486 struct device *dev = &pdev->dev;
465 &rockchip_drm_ops); 487 struct component_match *match = NULL;
488 struct device_node *np = dev->of_node;
489 struct device_node *port;
490 int i;
466 491
467 /* keep compatibility with old code that was returning -ENODEV */ 492 if (!np)
468 if (ret == -EINVAL)
469 return -ENODEV; 493 return -ENODEV;
494 /*
495 * Bind the crtc ports first, so that
496 * drm_of_find_possible_crtcs called from encoder .bind callbacks
497 * works as expected.
498 */
499 for (i = 0;; i++) {
500 port = of_parse_phandle(np, "ports", i);
501 if (!port)
502 break;
503
504 if (!of_device_is_available(port->parent)) {
505 of_node_put(port);
506 continue;
507 }
470 508
471 return ret; 509 component_match_add(dev, &match, compare_of, port->parent);
510 of_node_put(port);
511 }
512
513 if (i == 0) {
514 dev_err(dev, "missing 'ports' property\n");
515 return -ENODEV;
516 }
517
518 if (!match) {
519 dev_err(dev, "No available vop found for display-subsystem.\n");
520 return -ENODEV;
521 }
522 /*
523 * For each bound crtc, bind the encoders attached to its
524 * remote endpoint.
525 */
526 for (i = 0;; i++) {
527 port = of_parse_phandle(np, "ports", i);
528 if (!port)
529 break;
530
531 if (!of_device_is_available(port->parent)) {
532 of_node_put(port);
533 continue;
534 }
535
536 rockchip_add_endpoints(dev, &match, port);
537 of_node_put(port);
538 }
539
540 return component_master_add_with_match(dev, &rockchip_drm_ops, match);
472} 541}
473 542
474static int rockchip_drm_platform_remove(struct platform_device *pdev) 543static int rockchip_drm_platform_remove(struct platform_device *pdev)
diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h
index 8c5e8b91a3cb..0b69a7753558 100644
--- a/include/uapi/drm/drm_fourcc.h
+++ b/include/uapi/drm/drm_fourcc.h
@@ -158,7 +158,7 @@
158/* add more to the end as needed */ 158/* add more to the end as needed */
159 159
160#define fourcc_mod_code(vendor, val) \ 160#define fourcc_mod_code(vendor, val) \
161 ((((u64)DRM_FORMAT_MOD_VENDOR_## vendor) << 56) | (val & 0x00ffffffffffffffULL)) 161 ((((__u64)DRM_FORMAT_MOD_VENDOR_## vendor) << 56) | (val & 0x00ffffffffffffffULL))
162 162
163/* 163/*
164 * Format Modifier tokens: 164 * Format Modifier tokens: