forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/gpu/drm/exynos/exynos7_drm_decon.c
....@@ -1,18 +1,11 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /* drivers/gpu/drm/exynos/exynos7_drm_decon.c
23 *
34 * Copyright (C) 2014 Samsung Electronics Co.Ltd
45 * Authors:
56 * Akshu Agarwal <akshua@gmail.com>
67 * Ajay Kumar <ajaykumar.rs@samsung.com>
7
- *
8
- * This program is free software; you can redistribute it and/or modify it
9
- * under the terms of the GNU General Public License as published by the
10
- * Free Software Foundation; either version 2 of the License, or (at your
11
- * option) any later version.
12
- *
138 */
14
-#include <drm/drmP.h>
15
-#include <drm/exynos_drm.h>
169
1710 #include <linux/clk.h>
1811 #include <linux/component.h>
....@@ -26,11 +19,14 @@
2619 #include <video/of_display_timing.h>
2720 #include <video/of_videomode.h>
2821
22
+#include <drm/drm_fourcc.h>
23
+#include <drm/drm_vblank.h>
24
+#include <drm/exynos_drm.h>
25
+
2926 #include "exynos_drm_crtc.h"
30
-#include "exynos_drm_plane.h"
3127 #include "exynos_drm_drv.h"
3228 #include "exynos_drm_fb.h"
33
-#include "exynos_drm_iommu.h"
29
+#include "exynos_drm_plane.h"
3430 #include "regs-decon7.h"
3531
3632 /*
....@@ -44,6 +40,7 @@
4440 struct decon_context {
4541 struct device *dev;
4642 struct drm_device *drm_dev;
43
+ void *dma_priv;
4744 struct exynos_drm_crtc *crtc;
4845 struct exynos_drm_plane planes[WINDOWS_NR];
4946 struct exynos_drm_plane_config configs[WINDOWS_NR];
....@@ -100,15 +97,13 @@
10097 if (!wait_event_timeout(ctx->wait_vsync_queue,
10198 !atomic_read(&ctx->wait_vsync_event),
10299 HZ/20))
103
- DRM_DEBUG_KMS("vblank wait timed out.\n");
100
+ DRM_DEV_DEBUG_KMS(ctx->dev, "vblank wait timed out.\n");
104101 }
105102
106103 static void decon_clear_channels(struct exynos_drm_crtc *crtc)
107104 {
108105 struct decon_context *ctx = crtc->ctx;
109106 unsigned int win, ch_enabled = 0;
110
-
111
- DRM_DEBUG_KMS("%s\n", __FILE__);
112107
113108 /* Check if any channel is enabled. */
114109 for (win = 0; win < WINDOWS_NR; win++) {
....@@ -133,19 +128,19 @@
133128
134129 decon_clear_channels(ctx->crtc);
135130
136
- return drm_iommu_attach_device(drm_dev, ctx->dev);
131
+ return exynos_drm_register_dma(drm_dev, ctx->dev, &ctx->dma_priv);
137132 }
138133
139134 static void decon_ctx_remove(struct decon_context *ctx)
140135 {
141136 /* detach this sub driver from iommu mapping if supported. */
142
- drm_iommu_detach_device(ctx->drm_dev, ctx->dev);
137
+ exynos_drm_unregister_dma(ctx->drm_dev, ctx->dev, &ctx->dma_priv);
143138 }
144139
145140 static u32 decon_calc_clkdiv(struct decon_context *ctx,
146141 const struct drm_display_mode *mode)
147142 {
148
- unsigned long ideal_clk = mode->htotal * mode->vtotal * mode->vrefresh;
143
+ unsigned long ideal_clk = mode->clock;
149144 u32 clkdiv;
150145
151146 /* Find the clock divider value that gets us closest to ideal_clk */
....@@ -316,7 +311,7 @@
316311 break;
317312 }
318313
319
- DRM_DEBUG_KMS("cpp = %d\n", fb->format->cpp[0]);
314
+ DRM_DEV_DEBUG_KMS(ctx->dev, "cpp = %d\n", fb->format->cpp[0]);
320315
321316 /*
322317 * In case of exynos, setting dma-burst to 16Word causes permanent
....@@ -423,9 +418,9 @@
423418 writel(state->src.x, ctx->regs + VIDW_OFFSET_X(win));
424419 writel(state->src.y, ctx->regs + VIDW_OFFSET_Y(win));
425420
426
- DRM_DEBUG_KMS("start addr = 0x%lx\n",
421
+ DRM_DEV_DEBUG_KMS(ctx->dev, "start addr = 0x%lx\n",
427422 (unsigned long)val);
428
- DRM_DEBUG_KMS("ovl_width = %d, ovl_height = %d\n",
423
+ DRM_DEV_DEBUG_KMS(ctx->dev, "ovl_width = %d, ovl_height = %d\n",
429424 state->crtc.w, state->crtc.h);
430425
431426 val = VIDOSDxA_TOPLEFT_X(state->crtc.x) |
....@@ -443,7 +438,7 @@
443438
444439 writel(val, ctx->regs + VIDOSD_B(win));
445440
446
- DRM_DEBUG_KMS("osd pos: tx = %d, ty = %d, bx = %d, by = %d\n",
441
+ DRM_DEV_DEBUG_KMS(ctx->dev, "osd pos: tx = %d, ty = %d, bx = %d, by = %d\n",
447442 state->crtc.x, state->crtc.y, last_x, last_y);
448443
449444 /* OSD alpha */
....@@ -532,7 +527,7 @@
532527 writel(VIDCON1_VCLK_HOLD, ctx->regs + VIDCON1(0));
533528 }
534529
535
-static void decon_enable(struct exynos_drm_crtc *crtc)
530
+static void decon_atomic_enable(struct exynos_drm_crtc *crtc)
536531 {
537532 struct decon_context *ctx = crtc->ctx;
538533
....@@ -552,7 +547,7 @@
552547 ctx->suspended = false;
553548 }
554549
555
-static void decon_disable(struct exynos_drm_crtc *crtc)
550
+static void decon_atomic_disable(struct exynos_drm_crtc *crtc)
556551 {
557552 struct decon_context *ctx = crtc->ctx;
558553 int i;
....@@ -574,8 +569,8 @@
574569 }
575570
576571 static const struct exynos_drm_crtc_ops decon_crtc_ops = {
577
- .enable = decon_enable,
578
- .disable = decon_disable,
572
+ .atomic_enable = decon_atomic_enable,
573
+ .atomic_disable = decon_atomic_disable,
579574 .enable_vblank = decon_enable_vblank,
580575 .disable_vblank = decon_disable_vblank,
581576 .atomic_begin = decon_atomic_begin,
....@@ -623,7 +618,7 @@
623618
624619 ret = decon_ctx_initialize(ctx, drm_dev);
625620 if (ret) {
626
- DRM_ERROR("decon_ctx_initialize failed.\n");
621
+ DRM_DEV_ERROR(dev, "decon_ctx_initialize failed.\n");
627622 return ret;
628623 }
629624
....@@ -659,7 +654,7 @@
659654 {
660655 struct decon_context *ctx = dev_get_drvdata(dev);
661656
662
- decon_disable(ctx->crtc);
657
+ decon_atomic_disable(ctx->crtc);
663658
664659 if (ctx->encoder)
665660 exynos_dpi_remove(ctx->encoder);
....@@ -803,29 +798,42 @@
803798
804799 ret = clk_prepare_enable(ctx->pclk);
805800 if (ret < 0) {
806
- DRM_ERROR("Failed to prepare_enable the pclk [%d]\n", ret);
807
- return ret;
801
+ DRM_DEV_ERROR(dev, "Failed to prepare_enable the pclk [%d]\n",
802
+ ret);
803
+ goto err_pclk_enable;
808804 }
809805
810806 ret = clk_prepare_enable(ctx->aclk);
811807 if (ret < 0) {
812
- DRM_ERROR("Failed to prepare_enable the aclk [%d]\n", ret);
813
- return ret;
808
+ DRM_DEV_ERROR(dev, "Failed to prepare_enable the aclk [%d]\n",
809
+ ret);
810
+ goto err_aclk_enable;
814811 }
815812
816813 ret = clk_prepare_enable(ctx->eclk);
817814 if (ret < 0) {
818
- DRM_ERROR("Failed to prepare_enable the eclk [%d]\n", ret);
819
- return ret;
815
+ DRM_DEV_ERROR(dev, "Failed to prepare_enable the eclk [%d]\n",
816
+ ret);
817
+ goto err_eclk_enable;
820818 }
821819
822820 ret = clk_prepare_enable(ctx->vclk);
823821 if (ret < 0) {
824
- DRM_ERROR("Failed to prepare_enable the vclk [%d]\n", ret);
825
- return ret;
822
+ DRM_DEV_ERROR(dev, "Failed to prepare_enable the vclk [%d]\n",
823
+ ret);
824
+ goto err_vclk_enable;
826825 }
827826
828827 return 0;
828
+
829
+err_vclk_enable:
830
+ clk_disable_unprepare(ctx->eclk);
831
+err_eclk_enable:
832
+ clk_disable_unprepare(ctx->aclk);
833
+err_aclk_enable:
834
+ clk_disable_unprepare(ctx->pclk);
835
+err_pclk_enable:
836
+ return ret;
829837 }
830838 #endif
831839