.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright 2015 Freescale Semiconductor, Inc. |
---|
3 | 4 | * |
---|
4 | 5 | * 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. |
---|
10 | 6 | */ |
---|
11 | 7 | |
---|
12 | 8 | #include <linux/clk.h> |
---|
13 | 9 | #include <linux/regmap.h> |
---|
14 | 10 | |
---|
15 | | -#include <drm/drmP.h> |
---|
| 11 | +#include <video/videomode.h> |
---|
| 12 | + |
---|
16 | 13 | #include <drm/drm_atomic.h> |
---|
17 | 14 | #include <drm/drm_atomic_helper.h> |
---|
18 | 15 | #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> |
---|
20 | 18 | |
---|
21 | 19 | #include "fsl_dcu_drm_crtc.h" |
---|
22 | 20 | #include "fsl_dcu_drm_drv.h" |
---|
.. | .. |
---|
85 | 83 | struct fsl_dcu_drm_device *fsl_dev = dev->dev_private; |
---|
86 | 84 | struct drm_connector *con = &fsl_dev->connector.base; |
---|
87 | 85 | 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; |
---|
89 | 88 | |
---|
90 | | - index = drm_crtc_index(crtc); |
---|
91 | 89 | clk_set_rate(fsl_dev->pix_clk, mode->clock * 1000); |
---|
92 | 90 | |
---|
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); |
---|
100 | 92 | |
---|
101 | 93 | /* 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)) |
---|
103 | 95 | pol |= DCU_SYN_POL_INV_PXCK; |
---|
104 | 96 | |
---|
105 | | - if (mode->flags & DRM_MODE_FLAG_NHSYNC) |
---|
| 97 | + if (vm.flags & DISPLAY_FLAGS_HSYNC_LOW) |
---|
106 | 98 | pol |= DCU_SYN_POL_INV_HS_LOW; |
---|
107 | 99 | |
---|
108 | | - if (mode->flags & DRM_MODE_FLAG_NVSYNC) |
---|
| 100 | + if (vm.flags & DISPLAY_FLAGS_VSYNC_LOW) |
---|
109 | 101 | pol |= DCU_SYN_POL_INV_VS_LOW; |
---|
110 | 102 | |
---|
111 | 103 | 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)); |
---|
115 | 107 | 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)); |
---|
119 | 111 | 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)); |
---|
122 | 114 | regmap_write(fsl_dev->regmap, DCU_SYN_POL, pol); |
---|
123 | 115 | regmap_write(fsl_dev->regmap, DCU_BGND, DCU_BGND_R(0) | |
---|
124 | 116 | DCU_BGND_G(0) | DCU_BGND_B(0)); |
---|