vc4_drv.h 3.7 KB

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