drm.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /*
  2. * Copyright (C) 2012 Avionic Design GmbH
  3. * Copyright (C) 2012-2013 NVIDIA CORPORATION. All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. */
  9. #ifndef HOST1X_DRM_H
  10. #define HOST1X_DRM_H 1
  11. #include <uapi/drm/tegra_drm.h>
  12. #include <linux/host1x.h>
  13. #include <linux/iova.h>
  14. #include <linux/of_gpio.h>
  15. #include <drm/drmP.h>
  16. #include <drm/drm_atomic.h>
  17. #include <drm/drm_crtc_helper.h>
  18. #include <drm/drm_edid.h>
  19. #include <drm/drm_encoder.h>
  20. #include <drm/drm_fb_helper.h>
  21. #include <drm/drm_fixed.h>
  22. #include "gem.h"
  23. #include "hub.h"
  24. #include "trace.h"
  25. struct reset_control;
  26. #ifdef CONFIG_DRM_FBDEV_EMULATION
  27. struct tegra_fbdev {
  28. struct drm_fb_helper base;
  29. struct drm_framebuffer *fb;
  30. };
  31. #endif
  32. struct tegra_drm {
  33. struct drm_device *drm;
  34. struct iommu_domain *domain;
  35. struct iommu_group *group;
  36. struct mutex mm_lock;
  37. struct drm_mm mm;
  38. struct {
  39. struct iova_domain domain;
  40. unsigned long shift;
  41. unsigned long limit;
  42. } carveout;
  43. struct mutex clients_lock;
  44. struct list_head clients;
  45. #ifdef CONFIG_DRM_FBDEV_EMULATION
  46. struct tegra_fbdev *fbdev;
  47. #endif
  48. unsigned int pitch_align;
  49. struct tegra_display_hub *hub;
  50. struct drm_atomic_state *state;
  51. };
  52. struct tegra_drm_client;
  53. struct tegra_drm_context {
  54. struct tegra_drm_client *client;
  55. struct host1x_channel *channel;
  56. unsigned int id;
  57. };
  58. struct tegra_drm_client_ops {
  59. int (*open_channel)(struct tegra_drm_client *client,
  60. struct tegra_drm_context *context);
  61. void (*close_channel)(struct tegra_drm_context *context);
  62. int (*is_addr_reg)(struct device *dev, u32 class, u32 offset);
  63. int (*is_valid_class)(u32 class);
  64. int (*submit)(struct tegra_drm_context *context,
  65. struct drm_tegra_submit *args, struct drm_device *drm,
  66. struct drm_file *file);
  67. };
  68. int tegra_drm_submit(struct tegra_drm_context *context,
  69. struct drm_tegra_submit *args, struct drm_device *drm,
  70. struct drm_file *file);
  71. struct tegra_drm_client {
  72. struct host1x_client base;
  73. struct list_head list;
  74. unsigned int version;
  75. const struct tegra_drm_client_ops *ops;
  76. };
  77. static inline struct tegra_drm_client *
  78. host1x_to_drm_client(struct host1x_client *client)
  79. {
  80. return container_of(client, struct tegra_drm_client, base);
  81. }
  82. int tegra_drm_register_client(struct tegra_drm *tegra,
  83. struct tegra_drm_client *client);
  84. int tegra_drm_unregister_client(struct tegra_drm *tegra,
  85. struct tegra_drm_client *client);
  86. struct iommu_group *host1x_client_iommu_attach(struct host1x_client *client,
  87. bool shared);
  88. void host1x_client_iommu_detach(struct host1x_client *client,
  89. struct iommu_group *group);
  90. int tegra_drm_init(struct tegra_drm *tegra, struct drm_device *drm);
  91. int tegra_drm_exit(struct tegra_drm *tegra);
  92. void *tegra_drm_alloc(struct tegra_drm *tegra, size_t size, dma_addr_t *iova);
  93. void tegra_drm_free(struct tegra_drm *tegra, size_t size, void *virt,
  94. dma_addr_t iova);
  95. struct cec_notifier;
  96. struct tegra_output {
  97. struct device_node *of_node;
  98. struct device *dev;
  99. struct drm_panel *panel;
  100. struct i2c_adapter *ddc;
  101. const struct edid *edid;
  102. struct cec_notifier *notifier;
  103. unsigned int hpd_irq;
  104. int hpd_gpio;
  105. enum of_gpio_flags hpd_gpio_flags;
  106. struct drm_encoder encoder;
  107. struct drm_connector connector;
  108. };
  109. static inline struct tegra_output *encoder_to_output(struct drm_encoder *e)
  110. {
  111. return container_of(e, struct tegra_output, encoder);
  112. }
  113. static inline struct tegra_output *connector_to_output(struct drm_connector *c)
  114. {
  115. return container_of(c, struct tegra_output, connector);
  116. }
  117. /* from output.c */
  118. int tegra_output_probe(struct tegra_output *output);
  119. void tegra_output_remove(struct tegra_output *output);
  120. int tegra_output_init(struct drm_device *drm, struct tegra_output *output);
  121. void tegra_output_exit(struct tegra_output *output);
  122. void tegra_output_find_possible_crtcs(struct tegra_output *output,
  123. struct drm_device *drm);
  124. int tegra_output_connector_get_modes(struct drm_connector *connector);
  125. enum drm_connector_status
  126. tegra_output_connector_detect(struct drm_connector *connector, bool force);
  127. void tegra_output_connector_destroy(struct drm_connector *connector);
  128. void tegra_output_encoder_destroy(struct drm_encoder *encoder);
  129. /* from dpaux.c */
  130. struct drm_dp_link;
  131. struct drm_dp_aux *drm_dp_aux_find_by_of_node(struct device_node *np);
  132. enum drm_connector_status drm_dp_aux_detect(struct drm_dp_aux *aux);
  133. int drm_dp_aux_attach(struct drm_dp_aux *aux, struct tegra_output *output);
  134. int drm_dp_aux_detach(struct drm_dp_aux *aux);
  135. int drm_dp_aux_enable(struct drm_dp_aux *aux);
  136. int drm_dp_aux_disable(struct drm_dp_aux *aux);
  137. int drm_dp_aux_prepare(struct drm_dp_aux *aux, u8 encoding);
  138. int drm_dp_aux_train(struct drm_dp_aux *aux, struct drm_dp_link *link,
  139. u8 pattern);
  140. /* from fb.c */
  141. struct tegra_bo *tegra_fb_get_plane(struct drm_framebuffer *framebuffer,
  142. unsigned int index);
  143. bool tegra_fb_is_bottom_up(struct drm_framebuffer *framebuffer);
  144. int tegra_fb_get_tiling(struct drm_framebuffer *framebuffer,
  145. struct tegra_bo_tiling *tiling);
  146. struct drm_framebuffer *tegra_fb_create(struct drm_device *drm,
  147. struct drm_file *file,
  148. const struct drm_mode_fb_cmd2 *cmd);
  149. int tegra_drm_fb_prepare(struct drm_device *drm);
  150. void tegra_drm_fb_free(struct drm_device *drm);
  151. int tegra_drm_fb_init(struct drm_device *drm);
  152. void tegra_drm_fb_exit(struct drm_device *drm);
  153. void tegra_drm_fb_suspend(struct drm_device *drm);
  154. void tegra_drm_fb_resume(struct drm_device *drm);
  155. extern struct platform_driver tegra_display_hub_driver;
  156. extern struct platform_driver tegra_dc_driver;
  157. extern struct platform_driver tegra_hdmi_driver;
  158. extern struct platform_driver tegra_dsi_driver;
  159. extern struct platform_driver tegra_dpaux_driver;
  160. extern struct platform_driver tegra_sor_driver;
  161. extern struct platform_driver tegra_gr2d_driver;
  162. extern struct platform_driver tegra_gr3d_driver;
  163. extern struct platform_driver tegra_vic_driver;
  164. #endif /* HOST1X_DRM_H */