forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
....@@ -1,30 +1,23 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2012 Texas Instruments
34 * Author: Rob Clark <robdclark@gmail.com>
4
- *
5
- * This program is free software; you can redistribute it and/or modify it
6
- * under the terms of the GNU General Public License version 2 as published by
7
- * the Free Software Foundation.
8
- *
9
- * This program is distributed in the hope that it will be useful, but WITHOUT
10
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
- * more details.
13
- *
14
- * You should have received a copy of the GNU General Public License along with
15
- * this program. If not, see <http://www.gnu.org/licenses/>.
165 */
6
+
7
+#include <linux/delay.h>
8
+#include <linux/dma-mapping.h>
9
+#include <linux/of_graph.h>
10
+#include <linux/pm_runtime.h>
1711
1812 #include <drm/drm_atomic.h>
1913 #include <drm/drm_atomic_helper.h>
2014 #include <drm/drm_crtc.h>
21
-#include <drm/drm_flip_work.h>
22
-#include <drm/drm_plane_helper.h>
23
-#include <linux/workqueue.h>
24
-#include <linux/completion.h>
25
-#include <linux/dma-mapping.h>
26
-#include <linux/of_graph.h>
27
-#include <linux/math64.h>
15
+#include <drm/drm_fb_cma_helper.h>
16
+#include <drm/drm_fourcc.h>
17
+#include <drm/drm_gem_cma_helper.h>
18
+#include <drm/drm_modeset_helper_vtables.h>
19
+#include <drm/drm_print.h>
20
+#include <drm/drm_vblank.h>
2821
2922 #include "tilcdc_drv.h"
3023 #include "tilcdc_regs.h"
....@@ -393,7 +386,7 @@
393386 case DRM_FORMAT_XBGR8888:
394387 case DRM_FORMAT_XRGB8888:
395388 reg |= LCDC_V2_TFT_24BPP_UNPACK;
396
- /* fallthrough */
389
+ fallthrough;
397390 case DRM_FORMAT_BGR888:
398391 case DRM_FORMAT_RGB888:
399392 reg |= LCDC_V2_TFT_24BPP_MODE;
....@@ -525,6 +518,15 @@
525518
526519 drm_crtc_vblank_off(crtc);
527520
521
+ spin_lock_irq(&crtc->dev->event_lock);
522
+
523
+ if (crtc->state->event) {
524
+ drm_crtc_send_vblank_event(crtc, crtc->state->event);
525
+ crtc->state->event = NULL;
526
+ }
527
+
528
+ spin_unlock_irq(&crtc->dev->event_lock);
529
+
528530 tilcdc_crtc_disable_irqs(dev);
529531
530532 pm_runtime_put_sync(dev->dev);
....@@ -542,6 +544,18 @@
542544 struct drm_crtc_state *old_state)
543545 {
544546 tilcdc_crtc_disable(crtc);
547
+}
548
+
549
+static void tilcdc_crtc_atomic_flush(struct drm_crtc *crtc,
550
+ struct drm_crtc_state *old_state)
551
+{
552
+ if (!crtc->state->event)
553
+ return;
554
+
555
+ spin_lock_irq(&crtc->dev->event_lock);
556
+ drm_crtc_send_vblank_event(crtc, crtc->state->event);
557
+ crtc->state->event = NULL;
558
+ spin_unlock_irq(&crtc->dev->event_lock);
545559 }
546560
547561 void tilcdc_crtc_shutdown(struct drm_crtc *crtc)
....@@ -657,9 +671,6 @@
657671 static int tilcdc_crtc_atomic_check(struct drm_crtc *crtc,
658672 struct drm_crtc_state *state)
659673 {
660
- struct drm_display_mode *mode = &state->mode;
661
- int ret;
662
-
663674 /* If we are not active we don't care */
664675 if (!state->active)
665676 return 0;
....@@ -668,12 +679,6 @@
668679 state->state->planes[0].state == NULL ||
669680 state->state->planes[0].state->crtc != crtc) {
670681 dev_dbg(crtc->dev->dev, "CRTC primary plane must be present");
671
- return -EINVAL;
672
- }
673
-
674
- ret = tilcdc_crtc_mode_valid(crtc, mode);
675
- if (ret) {
676
- dev_dbg(crtc->dev->dev, "Mode \"%s\" not valid", mode->name);
677682 return -EINVAL;
678683 }
679684
....@@ -728,13 +733,6 @@
728733 .disable_vblank = tilcdc_crtc_disable_vblank,
729734 };
730735
731
-static const struct drm_crtc_helper_funcs tilcdc_crtc_helper_funcs = {
732
- .mode_fixup = tilcdc_crtc_mode_fixup,
733
- .atomic_check = tilcdc_crtc_atomic_check,
734
- .atomic_enable = tilcdc_crtc_atomic_enable,
735
- .atomic_disable = tilcdc_crtc_atomic_disable,
736
-};
737
-
738736 int tilcdc_crtc_max_width(struct drm_crtc *crtc)
739737 {
740738 struct drm_device *dev = crtc->dev;
....@@ -749,7 +747,9 @@
749747 return max_width;
750748 }
751749
752
-int tilcdc_crtc_mode_valid(struct drm_crtc *crtc, struct drm_display_mode *mode)
750
+static enum drm_mode_status
751
+tilcdc_crtc_mode_valid(struct drm_crtc *crtc,
752
+ const struct drm_display_mode *mode)
753753 {
754754 struct tilcdc_drm_private *priv = crtc->dev->dev_private;
755755 unsigned int bandwidth;
....@@ -837,6 +837,15 @@
837837 return MODE_OK;
838838 }
839839
840
+static const struct drm_crtc_helper_funcs tilcdc_crtc_helper_funcs = {
841
+ .mode_valid = tilcdc_crtc_mode_valid,
842
+ .mode_fixup = tilcdc_crtc_mode_fixup,
843
+ .atomic_check = tilcdc_crtc_atomic_check,
844
+ .atomic_enable = tilcdc_crtc_atomic_enable,
845
+ .atomic_disable = tilcdc_crtc_atomic_disable,
846
+ .atomic_flush = tilcdc_crtc_atomic_flush,
847
+};
848
+
840849 void tilcdc_crtc_set_panel_info(struct drm_crtc *crtc,
841850 const struct tilcdc_panel_info *info)
842851 {