drm_simple_kms_helper.h 4.0 KB

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