drm.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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. struct tegra_fb {
  27. struct drm_framebuffer base;
  28. struct tegra_bo **planes;
  29. unsigned int num_planes;
  30. };
  31. #ifdef CONFIG_DRM_FBDEV_EMULATION
  32. struct tegra_fbdev {
  33. struct drm_fb_helper base;
  34. struct tegra_fb *fb;
  35. };
  36. #endif
  37. struct tegra_atomic_state {
  38. struct drm_atomic_state base;
  39. struct clk *clk_disp;
  40. struct tegra_dc *dc;
  41. unsigned long rate;
  42. };
  43. static inline struct tegra_atomic_state *
  44. to_tegra_atomic_state(struct drm_atomic_state *state)
  45. {
  46. return container_of(state, struct tegra_atomic_state, base);
  47. }
  48. struct tegra_drm {
  49. struct drm_device *drm;
  50. struct iommu_domain *domain;
  51. struct iommu_group *group;
  52. struct mutex mm_lock;
  53. struct drm_mm mm;
  54. struct {
  55. struct iova_domain domain;
  56. unsigned long shift;
  57. unsigned long limit;
  58. } carveout;
  59. struct mutex clients_lock;
  60. struct list_head clients;
  61. #ifdef CONFIG_DRM_FBDEV_EMULATION
  62. struct tegra_fbdev *fbdev;
  63. #endif
  64. unsigned int pitch_align;
  65. struct tegra_display_hub *hub;
  66. struct drm_atomic_state *state;
  67. };
  68. struct tegra_drm_client;
  69. struct tegra_drm_context {
  70. struct tegra_drm_client *client;
  71. struct host1x_channel *channel;
  72. unsigned int id;
  73. };
  74. struct tegra_drm_client_ops {
  75. int (*open_channel)(struct tegra_drm_client *client,
  76. struct tegra_drm_context *context);
  77. void (*close_channel)(struct tegra_drm_context *context);
  78. int (*is_addr_reg)(struct device *dev, u32 class, u32 offset);
  79. int (*is_valid_class)(u32 class);
  80. int (*submit)(struct tegra_drm_context *context,
  81. struct drm_tegra_submit *args, struct drm_device *drm,
  82. struct drm_file *file);
  83. };
  84. int tegra_drm_submit(struct tegra_drm_context *context,
  85. struct drm_tegra_submit *args, struct drm_device *drm,
  86. struct drm_file *file);
  87. struct tegra_drm_client {
  88. struct host1x_client base;
  89. struct list_head list;
  90. const struct tegra_drm_client_ops *ops;
  91. };
  92. static inline struct tegra_drm_client *
  93. host1x_to_drm_client(struct host1x_client *client)
  94. {
  95. return container_of(client, struct tegra_drm_client, base);
  96. }
  97. int tegra_drm_register_client(struct tegra_drm *tegra,
  98. struct tegra_drm_client *client);
  99. int tegra_drm_unregister_client(struct tegra_drm *tegra,
  100. struct tegra_drm_client *client);
  101. int tegra_drm_init(struct tegra_drm *tegra, struct drm_device *drm);
  102. int tegra_drm_exit(struct tegra_drm *tegra);
  103. void *tegra_drm_alloc(struct tegra_drm *tegra, size_t size, dma_addr_t *iova);
  104. void tegra_drm_free(struct tegra_drm *tegra, size_t size, void *virt,
  105. dma_addr_t iova);
  106. struct cec_notifier;
  107. struct tegra_output {
  108. struct device_node *of_node;
  109. struct device *dev;
  110. struct drm_panel *panel;
  111. struct i2c_adapter *ddc;
  112. const struct edid *edid;
  113. struct cec_notifier *notifier;
  114. unsigned int hpd_irq;
  115. int hpd_gpio;
  116. enum of_gpio_flags hpd_gpio_flags;
  117. struct drm_encoder encoder;
  118. struct drm_connector connector;
  119. };
  120. static inline struct tegra_output *encoder_to_output(struct drm_encoder *e)
  121. {
  122. return container_of(e, struct tegra_output, encoder);
  123. }
  124. static inline struct tegra_output *connector_to_output(struct drm_connector *c)
  125. {
  126. return container_of(c, struct tegra_output, connector);
  127. }
  128. /* from output.c */
  129. int tegra_output_probe(struct tegra_output *output);
  130. void tegra_output_remove(struct tegra_output *output);
  131. int tegra_output_init(struct drm_device *drm, struct tegra_output *output);
  132. void tegra_output_exit(struct tegra_output *output);
  133. void tegra_output_find_possible_crtcs(struct tegra_output *output,
  134. struct drm_device *drm);
  135. int tegra_output_connector_get_modes(struct drm_connector *connector);
  136. enum drm_connector_status
  137. tegra_output_connector_detect(struct drm_connector *connector, bool force);
  138. void tegra_output_connector_destroy(struct drm_connector *connector);
  139. void tegra_output_encoder_destroy(struct drm_encoder *encoder);
  140. /* from dpaux.c */
  141. struct drm_dp_link;
  142. struct drm_dp_aux *drm_dp_aux_find_by_of_node(struct device_node *np);
  143. enum drm_connector_status drm_dp_aux_detect(struct drm_dp_aux *aux);
  144. int drm_dp_aux_attach(struct drm_dp_aux *aux, struct tegra_output *output);
  145. int drm_dp_aux_detach(struct drm_dp_aux *aux);
  146. int drm_dp_aux_enable(struct drm_dp_aux *aux);
  147. int drm_dp_aux_disable(struct drm_dp_aux *aux);
  148. int drm_dp_aux_prepare(struct drm_dp_aux *aux, u8 encoding);
  149. int drm_dp_aux_train(struct drm_dp_aux *aux, struct drm_dp_link *link,
  150. u8 pattern);
  151. /* from fb.c */
  152. struct tegra_bo *tegra_fb_get_plane(struct drm_framebuffer *framebuffer,
  153. unsigned int index);
  154. bool tegra_fb_is_bottom_up(struct drm_framebuffer *framebuffer);
  155. int tegra_fb_get_tiling(struct drm_framebuffer *framebuffer,
  156. struct tegra_bo_tiling *tiling);
  157. struct drm_framebuffer *tegra_fb_create(struct drm_device *drm,
  158. struct drm_file *file,
  159. const struct drm_mode_fb_cmd2 *cmd);
  160. int tegra_drm_fb_prepare(struct drm_device *drm);
  161. void tegra_drm_fb_free(struct drm_device *drm);
  162. int tegra_drm_fb_init(struct drm_device *drm);
  163. void tegra_drm_fb_exit(struct drm_device *drm);
  164. void tegra_drm_fb_suspend(struct drm_device *drm);
  165. void tegra_drm_fb_resume(struct drm_device *drm);
  166. extern struct platform_driver tegra_display_hub_driver;
  167. extern struct platform_driver tegra_dc_driver;
  168. extern struct platform_driver tegra_hdmi_driver;
  169. extern struct platform_driver tegra_dsi_driver;
  170. extern struct platform_driver tegra_dpaux_driver;
  171. extern struct platform_driver tegra_sor_driver;
  172. extern struct platform_driver tegra_gr2d_driver;
  173. extern struct platform_driver tegra_gr3d_driver;
  174. extern struct platform_driver tegra_vic_driver;
  175. #endif /* HOST1X_DRM_H */