fb.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (C) 2012 Avionic Design GmbH
  3. * Copyright (C) 2012 NVIDIA CORPORATION. All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. */
  9. #include "drm.h"
  10. static void tegra_drm_fb_output_poll_changed(struct drm_device *drm)
  11. {
  12. struct host1x *host1x = drm->dev_private;
  13. drm_fbdev_cma_hotplug_event(host1x->fbdev);
  14. }
  15. static const struct drm_mode_config_funcs tegra_drm_mode_funcs = {
  16. .fb_create = drm_fb_cma_create,
  17. .output_poll_changed = tegra_drm_fb_output_poll_changed,
  18. };
  19. int tegra_drm_fb_init(struct drm_device *drm)
  20. {
  21. struct host1x *host1x = drm->dev_private;
  22. struct drm_fbdev_cma *fbdev;
  23. drm->mode_config.min_width = 0;
  24. drm->mode_config.min_height = 0;
  25. drm->mode_config.max_width = 4096;
  26. drm->mode_config.max_height = 4096;
  27. drm->mode_config.funcs = &tegra_drm_mode_funcs;
  28. fbdev = drm_fbdev_cma_init(drm, 32, drm->mode_config.num_crtc,
  29. drm->mode_config.num_connector);
  30. if (IS_ERR(fbdev))
  31. return PTR_ERR(fbdev);
  32. #ifndef CONFIG_FRAMEBUFFER_CONSOLE
  33. drm_fbdev_cma_restore_mode(fbdev);
  34. #endif
  35. host1x->fbdev = fbdev;
  36. return 0;
  37. }
  38. void tegra_drm_fb_exit(struct drm_device *drm)
  39. {
  40. struct host1x *host1x = drm->dev_private;
  41. drm_fbdev_cma_fini(host1x->fbdev);
  42. }