forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c
....@@ -1,22 +1,20 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright 2015 Freescale Semiconductor, Inc.
34 *
45 * Freescale DCU drm device driver
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version.
106 */
117
128 #include <linux/clk.h>
139 #include <linux/regmap.h>
1410
15
-#include <drm/drmP.h>
11
+#include <video/videomode.h>
12
+
1613 #include <drm/drm_atomic.h>
1714 #include <drm/drm_atomic_helper.h>
1815 #include <drm/drm_crtc.h>
19
-#include <drm/drm_crtc_helper.h>
16
+#include <drm/drm_probe_helper.h>
17
+#include <drm/drm_vblank.h>
2018
2119 #include "fsl_dcu_drm_crtc.h"
2220 #include "fsl_dcu_drm_drv.h"
....@@ -85,40 +83,34 @@
8583 struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
8684 struct drm_connector *con = &fsl_dev->connector.base;
8785 struct drm_display_mode *mode = &crtc->state->mode;
88
- unsigned int hbp, hfp, hsw, vbp, vfp, vsw, index, pol = 0;
86
+ unsigned int pol = 0;
87
+ struct videomode vm;
8988
90
- index = drm_crtc_index(crtc);
9189 clk_set_rate(fsl_dev->pix_clk, mode->clock * 1000);
9290
93
- /* Configure timings: */
94
- hbp = mode->htotal - mode->hsync_end;
95
- hfp = mode->hsync_start - mode->hdisplay;
96
- hsw = mode->hsync_end - mode->hsync_start;
97
- vbp = mode->vtotal - mode->vsync_end;
98
- vfp = mode->vsync_start - mode->vdisplay;
99
- vsw = mode->vsync_end - mode->vsync_start;
91
+ drm_display_mode_to_videomode(mode, &vm);
10092
10193 /* INV_PXCK as default (most display sample data on rising edge) */
102
- if (!(con->display_info.bus_flags & DRM_BUS_FLAG_PIXDATA_POSEDGE))
94
+ if (!(con->display_info.bus_flags & DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE))
10395 pol |= DCU_SYN_POL_INV_PXCK;
10496
105
- if (mode->flags & DRM_MODE_FLAG_NHSYNC)
97
+ if (vm.flags & DISPLAY_FLAGS_HSYNC_LOW)
10698 pol |= DCU_SYN_POL_INV_HS_LOW;
10799
108
- if (mode->flags & DRM_MODE_FLAG_NVSYNC)
100
+ if (vm.flags & DISPLAY_FLAGS_VSYNC_LOW)
109101 pol |= DCU_SYN_POL_INV_VS_LOW;
110102
111103 regmap_write(fsl_dev->regmap, DCU_HSYN_PARA,
112
- DCU_HSYN_PARA_BP(hbp) |
113
- DCU_HSYN_PARA_PW(hsw) |
114
- DCU_HSYN_PARA_FP(hfp));
104
+ DCU_HSYN_PARA_BP(vm.hback_porch) |
105
+ DCU_HSYN_PARA_PW(vm.hsync_len) |
106
+ DCU_HSYN_PARA_FP(vm.hfront_porch));
115107 regmap_write(fsl_dev->regmap, DCU_VSYN_PARA,
116
- DCU_VSYN_PARA_BP(vbp) |
117
- DCU_VSYN_PARA_PW(vsw) |
118
- DCU_VSYN_PARA_FP(vfp));
108
+ DCU_VSYN_PARA_BP(vm.vback_porch) |
109
+ DCU_VSYN_PARA_PW(vm.vsync_len) |
110
+ DCU_VSYN_PARA_FP(vm.vfront_porch));
119111 regmap_write(fsl_dev->regmap, DCU_DISP_SIZE,
120
- DCU_DISP_SIZE_DELTA_Y(mode->vdisplay) |
121
- DCU_DISP_SIZE_DELTA_X(mode->hdisplay));
112
+ DCU_DISP_SIZE_DELTA_Y(vm.vactive) |
113
+ DCU_DISP_SIZE_DELTA_X(vm.hactive));
122114 regmap_write(fsl_dev->regmap, DCU_SYN_POL, pol);
123115 regmap_write(fsl_dev->regmap, DCU_BGND, DCU_BGND_R(0) |
124116 DCU_BGND_G(0) | DCU_BGND_B(0));