fsl_dcu_drm_kms.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright 2015 Freescale Semiconductor, Inc.
  3. *
  4. * 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. */
  11. #include <drm/drmP.h>
  12. #include <drm/drm_atomic_helper.h>
  13. #include <drm/drm_crtc_helper.h>
  14. #include <drm/drm_fb_cma_helper.h>
  15. #include "fsl_dcu_drm_crtc.h"
  16. #include "fsl_dcu_drm_drv.h"
  17. static const struct drm_mode_config_funcs fsl_dcu_drm_mode_config_funcs = {
  18. .atomic_check = drm_atomic_helper_check,
  19. .atomic_commit = drm_atomic_helper_commit,
  20. .fb_create = drm_fb_cma_create,
  21. };
  22. int fsl_dcu_drm_modeset_init(struct fsl_dcu_drm_device *fsl_dev)
  23. {
  24. int ret;
  25. drm_mode_config_init(fsl_dev->drm);
  26. fsl_dev->drm->mode_config.min_width = 0;
  27. fsl_dev->drm->mode_config.min_height = 0;
  28. fsl_dev->drm->mode_config.max_width = 2031;
  29. fsl_dev->drm->mode_config.max_height = 2047;
  30. fsl_dev->drm->mode_config.funcs = &fsl_dcu_drm_mode_config_funcs;
  31. ret = fsl_dcu_drm_crtc_create(fsl_dev);
  32. if (ret)
  33. goto err;
  34. ret = fsl_dcu_drm_encoder_create(fsl_dev, &fsl_dev->crtc);
  35. if (ret)
  36. goto err;
  37. ret = fsl_dcu_create_outputs(fsl_dev);
  38. if (ret)
  39. goto err;
  40. drm_mode_config_reset(fsl_dev->drm);
  41. drm_kms_helper_poll_init(fsl_dev->drm);
  42. return 0;
  43. err:
  44. drm_mode_config_cleanup(fsl_dev->drm);
  45. return ret;
  46. }