drm_simple_kms_helper.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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_DRM_SIMPLE_KMS_HELPER_H
  10. #define __LINUX_DRM_SIMPLE_KMS_HELPER_H
  11. #include <drm/drm_crtc.h>
  12. #include <drm/drm_encoder.h>
  13. #include <drm/drm_plane.h>
  14. struct drm_simple_display_pipe;
  15. /**
  16. * struct drm_simple_display_pipe_funcs - helper operations for a simple
  17. * display pipeline
  18. */
  19. struct drm_simple_display_pipe_funcs {
  20. /**
  21. * @enable:
  22. *
  23. * This function should be used to enable the pipeline.
  24. * It is called when the underlying crtc is enabled.
  25. * This hook is optional.
  26. */
  27. void (*enable)(struct drm_simple_display_pipe *pipe,
  28. struct drm_crtc_state *crtc_state);
  29. /**
  30. * @disable:
  31. *
  32. * This function should be used to disable the pipeline.
  33. * It is called when the underlying crtc is disabled.
  34. * This hook is optional.
  35. */
  36. void (*disable)(struct drm_simple_display_pipe *pipe);
  37. /**
  38. * @check:
  39. *
  40. * This function is called in the check phase of an atomic update,
  41. * specifically when the underlying plane is checked.
  42. * The simple display pipeline helpers already check that the plane is
  43. * not scaled, fills the entire visible area and is always enabled
  44. * when the crtc is also enabled.
  45. * This hook is optional.
  46. *
  47. * RETURNS:
  48. *
  49. * 0 on success, -EINVAL if the state or the transition can't be
  50. * supported, -ENOMEM on memory allocation failure and -EDEADLK if an
  51. * attempt to obtain another state object ran into a &drm_modeset_lock
  52. * deadlock.
  53. */
  54. int (*check)(struct drm_simple_display_pipe *pipe,
  55. struct drm_plane_state *plane_state,
  56. struct drm_crtc_state *crtc_state);
  57. /**
  58. * @update:
  59. *
  60. * This function is called when the underlying plane state is updated.
  61. * This hook is optional.
  62. *
  63. * This is the function drivers should submit the
  64. * &drm_pending_vblank_event from. Using either
  65. * drm_crtc_arm_vblank_event(), when the driver supports vblank
  66. * interrupt handling, or drm_crtc_send_vblank_event() directly in case
  67. * the hardware lacks vblank support entirely.
  68. */
  69. void (*update)(struct drm_simple_display_pipe *pipe,
  70. struct drm_plane_state *old_plane_state);
  71. /**
  72. * @prepare_fb:
  73. *
  74. * Optional, called by &drm_plane_helper_funcs.prepare_fb. Please read
  75. * the documentation for the &drm_plane_helper_funcs.prepare_fb hook for
  76. * more details.
  77. */
  78. int (*prepare_fb)(struct drm_simple_display_pipe *pipe,
  79. struct drm_plane_state *plane_state);
  80. /**
  81. * @cleanup_fb:
  82. *
  83. * Optional, called by &drm_plane_helper_funcs.cleanup_fb. Please read
  84. * the documentation for the &drm_plane_helper_funcs.cleanup_fb hook for
  85. * more details.
  86. */
  87. void (*cleanup_fb)(struct drm_simple_display_pipe *pipe,
  88. struct drm_plane_state *plane_state);
  89. };
  90. /**
  91. * struct drm_simple_display_pipe - simple display pipeline
  92. * @crtc: CRTC control structure
  93. * @plane: Plane control structure
  94. * @encoder: Encoder control structure
  95. * @connector: Connector control structure
  96. * @funcs: Pipeline control functions (optional)
  97. *
  98. * Simple display pipeline with plane, crtc and encoder collapsed into one
  99. * entity. It should be initialized by calling drm_simple_display_pipe_init().
  100. */
  101. struct drm_simple_display_pipe {
  102. struct drm_crtc crtc;
  103. struct drm_plane plane;
  104. struct drm_encoder encoder;
  105. struct drm_connector *connector;
  106. const struct drm_simple_display_pipe_funcs *funcs;
  107. };
  108. int drm_simple_display_pipe_attach_bridge(struct drm_simple_display_pipe *pipe,
  109. struct drm_bridge *bridge);
  110. int drm_simple_display_pipe_init(struct drm_device *dev,
  111. struct drm_simple_display_pipe *pipe,
  112. const struct drm_simple_display_pipe_funcs *funcs,
  113. const uint32_t *formats, unsigned int format_count,
  114. const uint64_t *format_modifiers,
  115. struct drm_connector *connector);
  116. #endif /* __LINUX_DRM_SIMPLE_KMS_HELPER_H */