drm.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 <linux/module.h>
  10. #include <linux/of_address.h>
  11. #include <linux/of_platform.h>
  12. #include <linux/dma-mapping.h>
  13. #include <asm/dma-iommu.h>
  14. #include "drm.h"
  15. #define DRIVER_NAME "tegra"
  16. #define DRIVER_DESC "NVIDIA Tegra graphics"
  17. #define DRIVER_DATE "20120330"
  18. #define DRIVER_MAJOR 0
  19. #define DRIVER_MINOR 0
  20. #define DRIVER_PATCHLEVEL 0
  21. static int tegra_drm_load(struct drm_device *drm, unsigned long flags)
  22. {
  23. struct device *dev = drm->dev;
  24. struct host1x *host1x;
  25. int err;
  26. host1x = dev_get_drvdata(dev);
  27. drm->dev_private = host1x;
  28. host1x->drm = drm;
  29. drm_mode_config_init(drm);
  30. err = host1x_drm_init(host1x, drm);
  31. if (err < 0)
  32. return err;
  33. err = tegra_drm_fb_init(drm);
  34. if (err < 0)
  35. return err;
  36. drm_kms_helper_poll_init(drm);
  37. return 0;
  38. }
  39. static int tegra_drm_unload(struct drm_device *drm)
  40. {
  41. drm_kms_helper_poll_fini(drm);
  42. tegra_drm_fb_exit(drm);
  43. drm_mode_config_cleanup(drm);
  44. return 0;
  45. }
  46. static int tegra_drm_open(struct drm_device *drm, struct drm_file *filp)
  47. {
  48. return 0;
  49. }
  50. static void tegra_drm_lastclose(struct drm_device *drm)
  51. {
  52. struct host1x *host1x = drm->dev_private;
  53. drm_fbdev_cma_restore_mode(host1x->fbdev);
  54. }
  55. static struct drm_ioctl_desc tegra_drm_ioctls[] = {
  56. };
  57. static const struct file_operations tegra_drm_fops = {
  58. .owner = THIS_MODULE,
  59. .open = drm_open,
  60. .release = drm_release,
  61. .unlocked_ioctl = drm_ioctl,
  62. .mmap = drm_gem_cma_mmap,
  63. .poll = drm_poll,
  64. .fasync = drm_fasync,
  65. .read = drm_read,
  66. #ifdef CONFIG_COMPAT
  67. .compat_ioctl = drm_compat_ioctl,
  68. #endif
  69. .llseek = noop_llseek,
  70. };
  71. struct drm_driver tegra_drm_driver = {
  72. .driver_features = DRIVER_BUS_PLATFORM | DRIVER_MODESET | DRIVER_GEM,
  73. .load = tegra_drm_load,
  74. .unload = tegra_drm_unload,
  75. .open = tegra_drm_open,
  76. .lastclose = tegra_drm_lastclose,
  77. .gem_free_object = drm_gem_cma_free_object,
  78. .gem_vm_ops = &drm_gem_cma_vm_ops,
  79. .dumb_create = drm_gem_cma_dumb_create,
  80. .dumb_map_offset = drm_gem_cma_dumb_map_offset,
  81. .dumb_destroy = drm_gem_cma_dumb_destroy,
  82. .ioctls = tegra_drm_ioctls,
  83. .num_ioctls = ARRAY_SIZE(tegra_drm_ioctls),
  84. .fops = &tegra_drm_fops,
  85. .name = DRIVER_NAME,
  86. .desc = DRIVER_DESC,
  87. .date = DRIVER_DATE,
  88. .major = DRIVER_MAJOR,
  89. .minor = DRIVER_MINOR,
  90. .patchlevel = DRIVER_PATCHLEVEL,
  91. };