drm.c 2.5 KB

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