nouveau_connector.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /*
  2. * Copyright (C) 2008 Maarten Maathuis.
  3. * All Rights Reserved.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining
  6. * a copy of this software and associated documentation files (the
  7. * "Software"), to deal in the Software without restriction, including
  8. * without limitation the rights to use, copy, modify, merge, publish,
  9. * distribute, sublicense, and/or sell copies of the Software, and to
  10. * permit persons to whom the Software is furnished to do so, subject to
  11. * the following conditions:
  12. *
  13. * The above copyright notice and this permission notice (including the
  14. * next paragraph) shall be included in all copies or substantial
  15. * portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  18. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  20. * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
  21. * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  22. * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  23. * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24. *
  25. */
  26. #ifndef __NOUVEAU_CONNECTOR_H__
  27. #define __NOUVEAU_CONNECTOR_H__
  28. #include <nvif/notify.h>
  29. #include <drm/drm_crtc.h>
  30. #include <drm/drm_edid.h>
  31. #include <drm/drm_encoder.h>
  32. #include <drm/drm_dp_helper.h>
  33. #include "nouveau_crtc.h"
  34. #include "nouveau_encoder.h"
  35. struct nvkm_i2c_port;
  36. #define nouveau_conn_atom(p) \
  37. container_of((p), struct nouveau_conn_atom, state)
  38. struct nouveau_conn_atom {
  39. struct drm_connector_state state;
  40. struct {
  41. /* The enum values specifically defined here match nv50/gf119
  42. * hw values, and the code relies on this.
  43. */
  44. enum {
  45. DITHERING_MODE_OFF = 0x00,
  46. DITHERING_MODE_ON = 0x01,
  47. DITHERING_MODE_DYNAMIC2X2 = 0x10 | DITHERING_MODE_ON,
  48. DITHERING_MODE_STATIC2X2 = 0x18 | DITHERING_MODE_ON,
  49. DITHERING_MODE_TEMPORAL = 0x20 | DITHERING_MODE_ON,
  50. DITHERING_MODE_AUTO
  51. } mode;
  52. enum {
  53. DITHERING_DEPTH_6BPC = 0x00,
  54. DITHERING_DEPTH_8BPC = 0x02,
  55. DITHERING_DEPTH_AUTO
  56. } depth;
  57. } dither;
  58. struct {
  59. int mode; /* DRM_MODE_SCALE_* */
  60. struct {
  61. enum {
  62. UNDERSCAN_OFF,
  63. UNDERSCAN_ON,
  64. UNDERSCAN_AUTO,
  65. } mode;
  66. u32 hborder;
  67. u32 vborder;
  68. } underscan;
  69. bool full;
  70. } scaler;
  71. struct {
  72. int color_vibrance;
  73. int vibrant_hue;
  74. } procamp;
  75. union {
  76. struct {
  77. bool dither:1;
  78. bool scaler:1;
  79. bool procamp:1;
  80. };
  81. u8 mask;
  82. } set;
  83. };
  84. struct nouveau_connector {
  85. struct drm_connector base;
  86. enum dcb_connector_type type;
  87. u8 index;
  88. u8 *dcb;
  89. struct nvif_notify hpd;
  90. struct drm_dp_aux aux;
  91. int dithering_mode;
  92. int scaling_mode;
  93. struct nouveau_encoder *detected_encoder;
  94. struct edid *edid;
  95. struct drm_display_mode *native_mode;
  96. };
  97. static inline struct nouveau_connector *nouveau_connector(
  98. struct drm_connector *con)
  99. {
  100. return container_of(con, struct nouveau_connector, base);
  101. }
  102. static inline bool
  103. nouveau_connector_is_mst(struct drm_connector *connector)
  104. {
  105. const struct nouveau_encoder *nv_encoder;
  106. const struct drm_encoder *encoder;
  107. if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort)
  108. return false;
  109. nv_encoder = find_encoder(connector, DCB_OUTPUT_ANY);
  110. if (!nv_encoder)
  111. return false;
  112. encoder = &nv_encoder->base.base;
  113. return encoder->encoder_type == DRM_MODE_ENCODER_DPMST;
  114. }
  115. #define nouveau_for_each_non_mst_connector_iter(connector, iter) \
  116. drm_for_each_connector_iter(connector, iter) \
  117. for_each_if(!nouveau_connector_is_mst(connector))
  118. static inline struct nouveau_connector *
  119. nouveau_crtc_connector_get(struct nouveau_crtc *nv_crtc)
  120. {
  121. struct drm_device *dev = nv_crtc->base.dev;
  122. struct drm_connector *connector;
  123. struct drm_connector_list_iter conn_iter;
  124. struct nouveau_connector *nv_connector = NULL;
  125. struct drm_crtc *crtc = to_drm_crtc(nv_crtc);
  126. drm_connector_list_iter_begin(dev, &conn_iter);
  127. nouveau_for_each_non_mst_connector_iter(connector, &conn_iter) {
  128. if (connector->encoder && connector->encoder->crtc == crtc) {
  129. nv_connector = nouveau_connector(connector);
  130. break;
  131. }
  132. }
  133. drm_connector_list_iter_end(&conn_iter);
  134. return nv_connector;
  135. }
  136. struct drm_connector *
  137. nouveau_connector_create(struct drm_device *, int index);
  138. extern int nouveau_tv_disable;
  139. extern int nouveau_ignorelid;
  140. extern int nouveau_duallink;
  141. extern int nouveau_hdmimhz;
  142. void nouveau_conn_attach_properties(struct drm_connector *);
  143. void nouveau_conn_reset(struct drm_connector *);
  144. struct drm_connector_state *
  145. nouveau_conn_atomic_duplicate_state(struct drm_connector *);
  146. void nouveau_conn_atomic_destroy_state(struct drm_connector *,
  147. struct drm_connector_state *);
  148. int nouveau_conn_atomic_set_property(struct drm_connector *,
  149. struct drm_connector_state *,
  150. struct drm_property *, u64);
  151. int nouveau_conn_atomic_get_property(struct drm_connector *,
  152. const struct drm_connector_state *,
  153. struct drm_property *, u64 *);
  154. struct drm_display_mode *nouveau_conn_native_mode(struct drm_connector *);
  155. #endif /* __NOUVEAU_CONNECTOR_H__ */