vc4_drv.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * Copyright (C) 2015 Broadcom
  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 version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #include "drmP.h"
  9. #include "drm_gem_cma_helper.h"
  10. struct vc4_dev {
  11. struct drm_device *dev;
  12. struct vc4_hdmi *hdmi;
  13. struct vc4_hvs *hvs;
  14. struct vc4_crtc *crtc[3];
  15. struct drm_fbdev_cma *fbdev;
  16. };
  17. static inline struct vc4_dev *
  18. to_vc4_dev(struct drm_device *dev)
  19. {
  20. return (struct vc4_dev *)dev->dev_private;
  21. }
  22. struct vc4_bo {
  23. struct drm_gem_cma_object base;
  24. };
  25. static inline struct vc4_bo *
  26. to_vc4_bo(struct drm_gem_object *bo)
  27. {
  28. return (struct vc4_bo *)bo;
  29. }
  30. struct vc4_hvs {
  31. struct platform_device *pdev;
  32. void __iomem *regs;
  33. void __iomem *dlist;
  34. };
  35. struct vc4_plane {
  36. struct drm_plane base;
  37. };
  38. static inline struct vc4_plane *
  39. to_vc4_plane(struct drm_plane *plane)
  40. {
  41. return (struct vc4_plane *)plane;
  42. }
  43. enum vc4_encoder_type {
  44. VC4_ENCODER_TYPE_HDMI,
  45. VC4_ENCODER_TYPE_VEC,
  46. VC4_ENCODER_TYPE_DSI0,
  47. VC4_ENCODER_TYPE_DSI1,
  48. VC4_ENCODER_TYPE_SMI,
  49. VC4_ENCODER_TYPE_DPI,
  50. };
  51. struct vc4_encoder {
  52. struct drm_encoder base;
  53. enum vc4_encoder_type type;
  54. u32 clock_select;
  55. };
  56. static inline struct vc4_encoder *
  57. to_vc4_encoder(struct drm_encoder *encoder)
  58. {
  59. return container_of(encoder, struct vc4_encoder, base);
  60. }
  61. #define HVS_READ(offset) readl(vc4->hvs->regs + offset)
  62. #define HVS_WRITE(offset, val) writel(val, vc4->hvs->regs + offset)
  63. /**
  64. * _wait_for - magic (register) wait macro
  65. *
  66. * Does the right thing for modeset paths when run under kdgb or similar atomic
  67. * contexts. Note that it's important that we check the condition again after
  68. * having timed out, since the timeout could be due to preemption or similar and
  69. * we've never had a chance to check the condition before the timeout.
  70. */
  71. #define _wait_for(COND, MS, W) ({ \
  72. unsigned long timeout__ = jiffies + msecs_to_jiffies(MS) + 1; \
  73. int ret__ = 0; \
  74. while (!(COND)) { \
  75. if (time_after(jiffies, timeout__)) { \
  76. if (!(COND)) \
  77. ret__ = -ETIMEDOUT; \
  78. break; \
  79. } \
  80. if (W && drm_can_sleep()) { \
  81. msleep(W); \
  82. } else { \
  83. cpu_relax(); \
  84. } \
  85. } \
  86. ret__; \
  87. })
  88. #define wait_for(COND, MS) _wait_for(COND, MS, 1)
  89. /* vc4_bo.c */
  90. void vc4_free_object(struct drm_gem_object *gem_obj);
  91. struct vc4_bo *vc4_bo_create(struct drm_device *dev, size_t size);
  92. int vc4_dumb_create(struct drm_file *file_priv,
  93. struct drm_device *dev,
  94. struct drm_mode_create_dumb *args);
  95. struct dma_buf *vc4_prime_export(struct drm_device *dev,
  96. struct drm_gem_object *obj, int flags);
  97. /* vc4_crtc.c */
  98. extern struct platform_driver vc4_crtc_driver;
  99. int vc4_enable_vblank(struct drm_device *dev, unsigned int crtc_id);
  100. void vc4_disable_vblank(struct drm_device *dev, unsigned int crtc_id);
  101. void vc4_cancel_page_flip(struct drm_crtc *crtc, struct drm_file *file);
  102. int vc4_crtc_debugfs_regs(struct seq_file *m, void *arg);
  103. /* vc4_debugfs.c */
  104. int vc4_debugfs_init(struct drm_minor *minor);
  105. void vc4_debugfs_cleanup(struct drm_minor *minor);
  106. /* vc4_drv.c */
  107. void __iomem *vc4_ioremap_regs(struct platform_device *dev, int index);
  108. /* vc4_hdmi.c */
  109. extern struct platform_driver vc4_hdmi_driver;
  110. int vc4_hdmi_debugfs_regs(struct seq_file *m, void *unused);
  111. /* vc4_hvs.c */
  112. extern struct platform_driver vc4_hvs_driver;
  113. void vc4_hvs_dump_state(struct drm_device *dev);
  114. int vc4_hvs_debugfs_regs(struct seq_file *m, void *unused);
  115. /* vc4_kms.c */
  116. int vc4_kms_load(struct drm_device *dev);
  117. /* vc4_plane.c */
  118. struct drm_plane *vc4_plane_init(struct drm_device *dev,
  119. enum drm_plane_type type);
  120. u32 vc4_plane_write_dlist(struct drm_plane *plane, u32 __iomem *dlist);
  121. u32 vc4_plane_dlist_size(struct drm_plane_state *state);