1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright 2015 Freescale Semiconductor, Inc.
4  *
5  * Freescale DCU drm device driver
6  */
7 
8 #include <drm/drm_atomic_helper.h>
9 #include <drm/drm_gem_framebuffer_helper.h>
10 #include <drm/drm_probe_helper.h>
11 
12 #include "fsl_dcu_drm_crtc.h"
13 #include "fsl_dcu_drm_drv.h"
14 
15 static const struct drm_mode_config_funcs fsl_dcu_drm_mode_config_funcs = {
16 	.atomic_check = drm_atomic_helper_check,
17 	.atomic_commit = drm_atomic_helper_commit,
18 	.fb_create = drm_gem_fb_create,
19 };
20 
21 int fsl_dcu_drm_modeset_init(struct fsl_dcu_drm_device *fsl_dev)
22 {
23 	int ret;
24 
25 	drm_mode_config_init(fsl_dev->drm);
26 
27 	fsl_dev->drm->mode_config.min_width = 0;
28 	fsl_dev->drm->mode_config.min_height = 0;
29 	fsl_dev->drm->mode_config.max_width = 2031;
30 	fsl_dev->drm->mode_config.max_height = 2047;
31 	fsl_dev->drm->mode_config.funcs = &fsl_dcu_drm_mode_config_funcs;
32 
33 	ret = fsl_dcu_drm_crtc_create(fsl_dev);
34 	if (ret)
35 		goto err;
36 
37 	ret = fsl_dcu_drm_encoder_create(fsl_dev, &fsl_dev->crtc);
38 	if (ret)
39 		goto err;
40 
41 	ret = fsl_dcu_create_outputs(fsl_dev);
42 	if (ret)
43 		goto err;
44 
45 	drm_mode_config_reset(fsl_dev->drm);
46 	drm_kms_helper_poll_init(fsl_dev->drm);
47 
48 	return 0;
49 
50 err:
51 	drm_mode_config_cleanup(fsl_dev->drm);
52 	return ret;
53 }
54