nouveau_nvif.c 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright 2014 Red Hat Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. * Authors: Ben Skeggs <[email protected]>
  23. */
  24. /*******************************************************************************
  25. * NVIF client driver - NVKM directly linked
  26. ******************************************************************************/
  27. #include <core/client.h>
  28. #include <core/notify.h>
  29. #include <core/ioctl.h>
  30. #include <nvif/client.h>
  31. #include <nvif/driver.h>
  32. #include <nvif/notify.h>
  33. #include <nvif/event.h>
  34. #include <nvif/ioctl.h>
  35. #include "nouveau_drv.h"
  36. #include "nouveau_usif.h"
  37. static void
  38. nvkm_client_unmap(void *priv, void __iomem *ptr, u32 size)
  39. {
  40. iounmap(ptr);
  41. }
  42. static void __iomem *
  43. nvkm_client_map(void *priv, u64 handle, u32 size)
  44. {
  45. return ioremap(handle, size);
  46. }
  47. static int
  48. nvkm_client_ioctl(void *priv, void *data, u32 size, void **hack)
  49. {
  50. return nvkm_ioctl(priv, data, size, hack);
  51. }
  52. static int
  53. nvkm_client_resume(void *priv)
  54. {
  55. struct nvkm_client *client = priv;
  56. return nvkm_object_init(&client->object);
  57. }
  58. static int
  59. nvkm_client_suspend(void *priv)
  60. {
  61. struct nvkm_client *client = priv;
  62. return nvkm_object_fini(&client->object, true);
  63. }
  64. static int
  65. nvkm_client_driver_init(const char *name, u64 device, const char *cfg,
  66. const char *dbg, void **ppriv)
  67. {
  68. return nvkm_client_new(name, device, cfg, dbg, nvif_notify, (struct nvkm_client **)ppriv);
  69. }
  70. const struct nvif_driver
  71. nvif_driver_nvkm = {
  72. .name = "nvkm",
  73. .init = nvkm_client_driver_init,
  74. .suspend = nvkm_client_suspend,
  75. .resume = nvkm_client_resume,
  76. .ioctl = nvkm_client_ioctl,
  77. .map = nvkm_client_map,
  78. .unmap = nvkm_client_unmap,
  79. .keep = false,
  80. };