Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / gpu / drm / fsl-dcu / fsl_dcu_drm_kms.c
blobd763f53f480c5782d3cb33d9a718b6fd3bacb678
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright 2015 Freescale Semiconductor, Inc.
5 * Freescale DCU drm device driver
6 */
8 #include <drm/drm_atomic_helper.h>
9 #include <drm/drm_fb_cma_helper.h>
10 #include <drm/drm_gem_framebuffer_helper.h>
11 #include <drm/drm_probe_helper.h>
13 #include "fsl_dcu_drm_crtc.h"
14 #include "fsl_dcu_drm_drv.h"
16 static const struct drm_mode_config_funcs fsl_dcu_drm_mode_config_funcs = {
17 .atomic_check = drm_atomic_helper_check,
18 .atomic_commit = drm_atomic_helper_commit,
19 .fb_create = drm_gem_fb_create,
22 int fsl_dcu_drm_modeset_init(struct fsl_dcu_drm_device *fsl_dev)
24 int ret;
26 drm_mode_config_init(fsl_dev->drm);
28 fsl_dev->drm->mode_config.min_width = 0;
29 fsl_dev->drm->mode_config.min_height = 0;
30 fsl_dev->drm->mode_config.max_width = 2031;
31 fsl_dev->drm->mode_config.max_height = 2047;
32 fsl_dev->drm->mode_config.funcs = &fsl_dcu_drm_mode_config_funcs;
34 ret = fsl_dcu_drm_crtc_create(fsl_dev);
35 if (ret)
36 goto err;
38 ret = fsl_dcu_drm_encoder_create(fsl_dev, &fsl_dev->crtc);
39 if (ret)
40 goto err;
42 ret = fsl_dcu_create_outputs(fsl_dev);
43 if (ret)
44 goto err;
46 drm_mode_config_reset(fsl_dev->drm);
47 drm_kms_helper_poll_init(fsl_dev->drm);
49 return 0;
51 err:
52 drm_mode_config_cleanup(fsl_dev->drm);
53 return ret;