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_fb_cma_helper.h> 10 #include <drm/drm_gem_framebuffer_helper.h> 11 #include <drm/drm_probe_helper.h> 12 13 #include "fsl_dcu_drm_crtc.h" 14 #include "fsl_dcu_drm_drv.h" 15 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, 20 }; 21 22 int fsl_dcu_drm_modeset_init(struct fsl_dcu_drm_device *fsl_dev) 23 { 24 int ret; 25 26 drm_mode_config_init(fsl_dev->drm); 27 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; 33 34 ret = fsl_dcu_drm_crtc_create(fsl_dev); 35 if (ret) 36 goto err; 37 38 ret = fsl_dcu_drm_encoder_create(fsl_dev, &fsl_dev->crtc); 39 if (ret) 40 goto err; 41 42 ret = fsl_dcu_create_outputs(fsl_dev); 43 if (ret) 44 goto err; 45 46 drm_mode_config_reset(fsl_dev->drm); 47 drm_kms_helper_poll_init(fsl_dev->drm); 48 49 return 0; 50 51 err: 52 drm_mode_config_cleanup(fsl_dev->drm); 53 return ret; 54 } 55