tinydrm.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. * @drm: DRM device
  17. * @pipe: Display pipe structure
  18. * @dirty_lock: Serializes framebuffer flushing
  19. * @fb_funcs: Framebuffer functions used when creating framebuffers
  20. */
  21. struct tinydrm_device {
  22. struct drm_device *drm;
  23. struct drm_simple_display_pipe pipe;
  24. struct mutex dirty_lock;
  25. const struct drm_framebuffer_funcs *fb_funcs;
  26. int (*fb_dirty)(struct drm_framebuffer *framebuffer,
  27. struct drm_file *file_priv, unsigned flags,
  28. unsigned color, struct drm_clip_rect *clips,
  29. unsigned num_clips);
  30. };
  31. static inline struct tinydrm_device *
  32. pipe_to_tinydrm(struct drm_simple_display_pipe *pipe)
  33. {
  34. return container_of(pipe, struct tinydrm_device, pipe);
  35. }
  36. /**
  37. * TINYDRM_GEM_DRIVER_OPS - default tinydrm gem operations
  38. *
  39. * This macro provides a shortcut for setting the tinydrm GEM operations in
  40. * the &drm_driver structure.
  41. */
  42. #define TINYDRM_GEM_DRIVER_OPS \
  43. .gem_free_object_unlocked = tinydrm_gem_cma_free_object, \
  44. .gem_print_info = drm_gem_cma_print_info, \
  45. .gem_vm_ops = &drm_gem_cma_vm_ops, \
  46. .prime_handle_to_fd = drm_gem_prime_handle_to_fd, \
  47. .prime_fd_to_handle = drm_gem_prime_fd_to_handle, \
  48. .gem_prime_import = drm_gem_prime_import, \
  49. .gem_prime_export = drm_gem_prime_export, \
  50. .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table, \
  51. .gem_prime_import_sg_table = tinydrm_gem_cma_prime_import_sg_table, \
  52. .gem_prime_vmap = drm_gem_cma_prime_vmap, \
  53. .gem_prime_vunmap = drm_gem_cma_prime_vunmap, \
  54. .gem_prime_mmap = drm_gem_cma_prime_mmap, \
  55. .dumb_create = drm_gem_cma_dumb_create
  56. /**
  57. * TINYDRM_MODE - tinydrm display mode
  58. * @hd: Horizontal resolution, width
  59. * @vd: Vertical resolution, height
  60. * @hd_mm: Display width in millimeters
  61. * @vd_mm: Display height in millimeters
  62. *
  63. * This macro creates a &drm_display_mode for use with tinydrm.
  64. */
  65. #define TINYDRM_MODE(hd, vd, hd_mm, vd_mm) \
  66. .hdisplay = (hd), \
  67. .hsync_start = (hd), \
  68. .hsync_end = (hd), \
  69. .htotal = (hd), \
  70. .vdisplay = (vd), \
  71. .vsync_start = (vd), \
  72. .vsync_end = (vd), \
  73. .vtotal = (vd), \
  74. .width_mm = (hd_mm), \
  75. .height_mm = (vd_mm), \
  76. .type = DRM_MODE_TYPE_DRIVER, \
  77. .clock = 1 /* pass validation */
  78. void tinydrm_gem_cma_free_object(struct drm_gem_object *gem_obj);
  79. struct drm_gem_object *
  80. tinydrm_gem_cma_prime_import_sg_table(struct drm_device *drm,
  81. struct dma_buf_attachment *attach,
  82. struct sg_table *sgt);
  83. int devm_tinydrm_init(struct device *parent, struct tinydrm_device *tdev,
  84. const struct drm_framebuffer_funcs *fb_funcs,
  85. struct drm_driver *driver);
  86. int devm_tinydrm_register(struct tinydrm_device *tdev);
  87. void tinydrm_shutdown(struct tinydrm_device *tdev);
  88. void tinydrm_display_pipe_update(struct drm_simple_display_pipe *pipe,
  89. struct drm_plane_state *old_state);
  90. int
  91. tinydrm_display_pipe_init(struct tinydrm_device *tdev,
  92. const struct drm_simple_display_pipe_funcs *funcs,
  93. int connector_type,
  94. const uint32_t *formats,
  95. unsigned int format_count,
  96. const struct drm_display_mode *mode,
  97. unsigned int rotation);
  98. #endif /* __LINUX_TINYDRM_H */