tinydrm.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * Copyright (C) 2016 Noralf Trønnes
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. */
  9. #ifndef __LINUX_TINYDRM_H
  10. #define __LINUX_TINYDRM_H
  11. #include <drm/drm_gem_cma_helper.h>
  12. #include <drm/drm_fb_cma_helper.h>
  13. #include <drm/drm_simple_kms_helper.h>
  14. /**
  15. * struct tinydrm_device - tinydrm device
  16. */
  17. struct tinydrm_device {
  18. /**
  19. * @drm: DRM device
  20. */
  21. struct drm_device *drm;
  22. /**
  23. * @pipe: Display pipe structure
  24. */
  25. struct drm_simple_display_pipe pipe;
  26. /**
  27. * @dirty_lock: Serializes framebuffer flushing
  28. */
  29. struct mutex dirty_lock;
  30. /**
  31. * @fb_funcs: Framebuffer functions used when creating framebuffers
  32. */
  33. const struct drm_framebuffer_funcs *fb_funcs;
  34. /**
  35. * @fb_dirty: Framebuffer dirty callback
  36. */
  37. int (*fb_dirty)(struct drm_framebuffer *framebuffer,
  38. struct drm_file *file_priv, unsigned flags,
  39. unsigned color, struct drm_clip_rect *clips,
  40. unsigned num_clips);
  41. };
  42. static inline struct tinydrm_device *
  43. pipe_to_tinydrm(struct drm_simple_display_pipe *pipe)
  44. {
  45. return container_of(pipe, struct tinydrm_device, pipe);
  46. }
  47. /**
  48. * TINYDRM_GEM_DRIVER_OPS - default tinydrm gem operations
  49. *
  50. * This macro provides a shortcut for setting the tinydrm GEM operations in
  51. * the &drm_driver structure.
  52. */
  53. #define TINYDRM_GEM_DRIVER_OPS \
  54. .gem_free_object_unlocked = tinydrm_gem_cma_free_object, \
  55. .gem_print_info = drm_gem_cma_print_info, \
  56. .gem_vm_ops = &drm_gem_cma_vm_ops, \
  57. .prime_handle_to_fd = drm_gem_prime_handle_to_fd, \
  58. .prime_fd_to_handle = drm_gem_prime_fd_to_handle, \
  59. .gem_prime_import = drm_gem_prime_import, \
  60. .gem_prime_export = drm_gem_prime_export, \
  61. .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table, \
  62. .gem_prime_import_sg_table = tinydrm_gem_cma_prime_import_sg_table, \
  63. .gem_prime_vmap = drm_gem_cma_prime_vmap, \
  64. .gem_prime_vunmap = drm_gem_cma_prime_vunmap, \
  65. .gem_prime_mmap = drm_gem_cma_prime_mmap, \
  66. .dumb_create = drm_gem_cma_dumb_create
  67. /**
  68. * TINYDRM_MODE - tinydrm display mode
  69. * @hd: Horizontal resolution, width
  70. * @vd: Vertical resolution, height
  71. * @hd_mm: Display width in millimeters
  72. * @vd_mm: Display height in millimeters
  73. *
  74. * This macro creates a &drm_display_mode for use with tinydrm.
  75. */
  76. #define TINYDRM_MODE(hd, vd, hd_mm, vd_mm) \
  77. .hdisplay = (hd), \
  78. .hsync_start = (hd), \
  79. .hsync_end = (hd), \
  80. .htotal = (hd), \
  81. .vdisplay = (vd), \
  82. .vsync_start = (vd), \
  83. .vsync_end = (vd), \
  84. .vtotal = (vd), \
  85. .width_mm = (hd_mm), \
  86. .height_mm = (vd_mm), \
  87. .type = DRM_MODE_TYPE_DRIVER, \
  88. .clock = 1 /* pass validation */
  89. void tinydrm_gem_cma_free_object(struct drm_gem_object *gem_obj);
  90. struct drm_gem_object *
  91. tinydrm_gem_cma_prime_import_sg_table(struct drm_device *drm,
  92. struct dma_buf_attachment *attach,
  93. struct sg_table *sgt);
  94. int devm_tinydrm_init(struct device *parent, struct tinydrm_device *tdev,
  95. const struct drm_framebuffer_funcs *fb_funcs,
  96. struct drm_driver *driver);
  97. int devm_tinydrm_register(struct tinydrm_device *tdev);
  98. void tinydrm_shutdown(struct tinydrm_device *tdev);
  99. void tinydrm_display_pipe_update(struct drm_simple_display_pipe *pipe,
  100. struct drm_plane_state *old_state);
  101. int
  102. tinydrm_display_pipe_init(struct tinydrm_device *tdev,
  103. const struct drm_simple_display_pipe_funcs *funcs,
  104. int connector_type,
  105. const uint32_t *formats,
  106. unsigned int format_count,
  107. const struct drm_display_mode *mode,
  108. unsigned int rotation);
  109. #endif /* __LINUX_TINYDRM_H */