nouveau_connector.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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_edid.h>
  30. #include <drm/drm_encoder.h>
  31. #include <drm/drm_dp_helper.h>
  32. #include <drm/drm_util.h>
  33. #include "nouveau_crtc.h"
  34. #include "nouveau_encoder.h"
  35. struct nvkm_i2c_port;
  36. #ifdef CONFIG_DRM_NOUVEAU_BACKLIGHT
  37. struct nouveau_backlight;
  38. #endif
  39. struct nouveau_connector {
  40. struct drm_connector base;
  41. enum dcb_connector_type type;
  42. u8 index;
  43. u8 *dcb;
  44. struct nvif_notify hpd;
  45. struct drm_dp_aux aux;
  46. int dithering_mode;
  47. int scaling_mode;
  48. struct nouveau_encoder *detected_encoder;
  49. struct edid *edid;
  50. struct drm_display_mode *native_mode;
  51. #ifdef CONFIG_DRM_NOUVEAU_BACKLIGHT
  52. struct nouveau_backlight *backlight;
  53. #endif
  54. };
  55. static inline struct nouveau_connector *nouveau_connector(
  56. struct drm_connector *con)
  57. {
  58. return container_of(con, struct nouveau_connector, base);
  59. }
  60. static inline bool
  61. nouveau_connector_is_mst(struct drm_connector *connector)
  62. {
  63. const struct nouveau_encoder *nv_encoder;
  64. const struct drm_encoder *encoder;
  65. if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort)
  66. return false;
  67. nv_encoder = find_encoder(connector, DCB_OUTPUT_ANY);
  68. if (!nv_encoder)
  69. return false;
  70. encoder = &nv_encoder->base.base;
  71. return encoder->encoder_type == DRM_MODE_ENCODER_DPMST;
  72. }
  73. #define nouveau_for_each_non_mst_connector_iter(connector, iter) \
  74. drm_for_each_connector_iter(connector, iter) \
  75. for_each_if(!nouveau_connector_is_mst(connector))
  76. static inline struct nouveau_connector *
  77. nouveau_crtc_connector_get(struct nouveau_crtc *nv_crtc)
  78. {
  79. struct drm_device *dev = nv_crtc->base.dev;
  80. struct drm_connector *connector;
  81. struct drm_connector_list_iter conn_iter;
  82. struct nouveau_connector *nv_connector = NULL;
  83. struct drm_crtc *crtc = to_drm_crtc(nv_crtc);
  84. drm_connector_list_iter_begin(dev, &conn_iter);
  85. nouveau_for_each_non_mst_connector_iter(connector, &conn_iter) {
  86. if (connector->encoder && connector->encoder->crtc == crtc) {
  87. nv_connector = nouveau_connector(connector);
  88. break;
  89. }
  90. }
  91. drm_connector_list_iter_end(&conn_iter);
  92. return nv_connector;
  93. }
  94. struct drm_connector *
  95. nouveau_connector_create(struct drm_device *, int index);
  96. extern int nouveau_tv_disable;
  97. extern int nouveau_ignorelid;
  98. extern int nouveau_duallink;
  99. extern int nouveau_hdmimhz;
  100. #include <drm/drm_crtc.h>
  101. #define nouveau_conn_atom(p) \
  102. container_of((p), struct nouveau_conn_atom, state)
  103. struct nouveau_conn_atom {
  104. struct drm_connector_state state;
  105. struct {
  106. /* The enum values specifically defined here match nv50/gf119
  107. * hw values, and the code relies on this.
  108. */
  109. enum {
  110. DITHERING_MODE_OFF = 0x00,
  111. DITHERING_MODE_ON = 0x01,
  112. DITHERING_MODE_DYNAMIC2X2 = 0x10 | DITHERING_MODE_ON,
  113. DITHERING_MODE_STATIC2X2 = 0x18 | DITHERING_MODE_ON,
  114. DITHERING_MODE_TEMPORAL = 0x20 | DITHERING_MODE_ON,
  115. DITHERING_MODE_AUTO
  116. } mode;
  117. enum {
  118. DITHERING_DEPTH_6BPC = 0x00,
  119. DITHERING_DEPTH_8BPC = 0x02,
  120. DITHERING_DEPTH_AUTO
  121. } depth;
  122. } dither;
  123. struct {
  124. int mode; /* DRM_MODE_SCALE_* */
  125. struct {
  126. enum {
  127. UNDERSCAN_OFF,
  128. UNDERSCAN_ON,
  129. UNDERSCAN_AUTO,
  130. } mode;
  131. u32 hborder;
  132. u32 vborder;
  133. } underscan;
  134. bool full;
  135. } scaler;
  136. struct {
  137. int color_vibrance;
  138. int vibrant_hue;
  139. } procamp;
  140. union {
  141. struct {
  142. bool dither:1;
  143. bool scaler:1;
  144. bool procamp:1;
  145. };
  146. u8 mask;
  147. } set;
  148. };
  149. void nouveau_conn_attach_properties(struct drm_connector *);
  150. void nouveau_conn_reset(struct drm_connector *);
  151. struct drm_connector_state *
  152. nouveau_conn_atomic_duplicate_state(struct drm_connector *);
  153. void nouveau_conn_atomic_destroy_state(struct drm_connector *,
  154. struct drm_connector_state *);
  155. int nouveau_conn_atomic_set_property(struct drm_connector *,
  156. struct drm_connector_state *,
  157. struct drm_property *, u64);
  158. int nouveau_conn_atomic_get_property(struct drm_connector *,
  159. const struct drm_connector_state *,
  160. struct drm_property *, u64 *);
  161. struct drm_display_mode *nouveau_conn_native_mode(struct drm_connector *);
  162. #ifdef CONFIG_DRM_NOUVEAU_BACKLIGHT
  163. extern int nouveau_backlight_init(struct drm_connector *);
  164. extern void nouveau_backlight_fini(struct drm_connector *);
  165. extern void nouveau_backlight_ctor(void);
  166. extern void nouveau_backlight_dtor(void);
  167. #else
  168. static inline int
  169. nouveau_backlight_init(struct drm_connector *connector)
  170. {
  171. return 0;
  172. }
  173. static inline void
  174. nouveau_backlight_fini(struct drm_connector *connector) {
  175. }
  176. static inline void
  177. nouveau_backlight_ctor(void) {
  178. }
  179. static inline void
  180. nouveau_backlight_dtor(void) {
  181. }
  182. #endif
  183. #endif /* __NOUVEAU_CONNECTOR_H__ */