drm_dp_helper.h 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033
  1. /*
  2. * Copyright © 2008 Keith Packard
  3. *
  4. * Permission to use, copy, modify, distribute, and sell this software and its
  5. * documentation for any purpose is hereby granted without fee, provided that
  6. * the above copyright notice appear in all copies and that both that copyright
  7. * notice and this permission notice appear in supporting documentation, and
  8. * that the name of the copyright holders not be used in advertising or
  9. * publicity pertaining to distribution of the software without specific,
  10. * written prior permission. The copyright holders make no representations
  11. * about the suitability of this software for any purpose. It is provided "as
  12. * is" without express or implied warranty.
  13. *
  14. * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15. * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  16. * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  17. * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  18. * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  19. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  20. * OF THIS SOFTWARE.
  21. */
  22. #ifndef _DRM_DP_HELPER_H_
  23. #define _DRM_DP_HELPER_H_
  24. #include <linux/delay.h>
  25. #include <linux/i2c.h>
  26. #include <drm/display/drm_dp.h>
  27. #include <drm/drm_connector.h>
  28. struct drm_device;
  29. struct drm_dp_aux;
  30. struct drm_panel;
  31. bool drm_dp_channel_eq_ok(const u8 link_status[DP_LINK_STATUS_SIZE],
  32. int lane_count);
  33. bool drm_dp_clock_recovery_ok(const u8 link_status[DP_LINK_STATUS_SIZE],
  34. int lane_count);
  35. bool drm_dp_post_lt_adj_req_in_progress(const u8 link_status[DP_LINK_STATUS_SIZE]);
  36. u8 drm_dp_get_adjust_request_voltage(const u8 link_status[DP_LINK_STATUS_SIZE],
  37. int lane);
  38. u8 drm_dp_get_adjust_request_pre_emphasis(const u8 link_status[DP_LINK_STATUS_SIZE],
  39. int lane);
  40. u8 drm_dp_get_adjust_tx_ffe_preset(const u8 link_status[DP_LINK_STATUS_SIZE],
  41. int lane);
  42. int drm_dp_read_clock_recovery_delay(struct drm_dp_aux *aux, const u8 dpcd[DP_RECEIVER_CAP_SIZE],
  43. enum drm_dp_phy dp_phy, bool uhbr);
  44. int drm_dp_read_channel_eq_delay(struct drm_dp_aux *aux, const u8 dpcd[DP_RECEIVER_CAP_SIZE],
  45. enum drm_dp_phy dp_phy, bool uhbr);
  46. void drm_dp_link_train_clock_recovery_delay(const struct drm_dp_aux *aux,
  47. const u8 dpcd[DP_RECEIVER_CAP_SIZE]);
  48. void drm_dp_lttpr_link_train_clock_recovery_delay(void);
  49. void drm_dp_link_train_channel_eq_delay(const struct drm_dp_aux *aux,
  50. const u8 dpcd[DP_RECEIVER_CAP_SIZE]);
  51. void drm_dp_lttpr_link_train_channel_eq_delay(const struct drm_dp_aux *aux,
  52. const u8 caps[DP_LTTPR_PHY_CAP_SIZE]);
  53. int drm_dp_128b132b_read_aux_rd_interval(struct drm_dp_aux *aux);
  54. bool drm_dp_128b132b_lane_channel_eq_done(const u8 link_status[DP_LINK_STATUS_SIZE],
  55. int lane_count);
  56. bool drm_dp_128b132b_lane_symbol_locked(const u8 link_status[DP_LINK_STATUS_SIZE],
  57. int lane_count);
  58. bool drm_dp_128b132b_eq_interlane_align_done(const u8 link_status[DP_LINK_STATUS_SIZE]);
  59. bool drm_dp_128b132b_cds_interlane_align_done(const u8 link_status[DP_LINK_STATUS_SIZE]);
  60. bool drm_dp_128b132b_link_training_failed(const u8 link_status[DP_LINK_STATUS_SIZE]);
  61. u8 drm_dp_link_rate_to_bw_code(int link_rate);
  62. int drm_dp_bw_code_to_link_rate(u8 link_bw);
  63. const char *drm_dp_phy_name(enum drm_dp_phy dp_phy);
  64. /**
  65. * struct drm_dp_vsc_sdp - drm DP VSC SDP
  66. *
  67. * This structure represents a DP VSC SDP of drm
  68. * It is based on DP 1.4 spec [Table 2-116: VSC SDP Header Bytes] and
  69. * [Table 2-117: VSC SDP Payload for DB16 through DB18]
  70. *
  71. * @sdp_type: secondary-data packet type
  72. * @revision: revision number
  73. * @length: number of valid data bytes
  74. * @pixelformat: pixel encoding format
  75. * @colorimetry: colorimetry format
  76. * @bpc: bit per color
  77. * @dynamic_range: dynamic range information
  78. * @content_type: CTA-861-G defines content types and expected processing by a sink device
  79. */
  80. struct drm_dp_vsc_sdp {
  81. unsigned char sdp_type;
  82. unsigned char revision;
  83. unsigned char length;
  84. enum dp_pixelformat pixelformat;
  85. enum dp_colorimetry colorimetry;
  86. int bpc;
  87. enum dp_dynamic_range dynamic_range;
  88. enum dp_content_type content_type;
  89. };
  90. /**
  91. * struct drm_dp_as_sdp - drm DP Adaptive Sync SDP
  92. *
  93. * This structure represents a DP AS SDP of drm
  94. * It is based on DP 2.1 spec [Table 2-126: Adaptive-Sync SDP Header Bytes] and
  95. * [Table 2-127: Adaptive-Sync SDP Payload for DB0 through DB8]
  96. *
  97. * @sdp_type: Secondary-data packet type
  98. * @revision: Revision Number
  99. * @length: Number of valid data bytes
  100. * @vtotal: Minimum Vertical Vtotal
  101. * @target_rr: Target Refresh
  102. * @duration_incr_ms: Successive frame duration increase
  103. * @duration_decr_ms: Successive frame duration decrease
  104. * @target_rr_divider: Target refresh rate divider
  105. * @mode: Adaptive Sync Operation Mode
  106. */
  107. struct drm_dp_as_sdp {
  108. unsigned char sdp_type;
  109. unsigned char revision;
  110. unsigned char length;
  111. int vtotal;
  112. int target_rr;
  113. int duration_incr_ms;
  114. int duration_decr_ms;
  115. bool target_rr_divider;
  116. enum operation_mode mode;
  117. };
  118. void drm_dp_as_sdp_log(struct drm_printer *p,
  119. const struct drm_dp_as_sdp *as_sdp);
  120. void drm_dp_vsc_sdp_log(struct drm_printer *p, const struct drm_dp_vsc_sdp *vsc);
  121. bool drm_dp_vsc_sdp_supported(struct drm_dp_aux *aux, const u8 dpcd[DP_RECEIVER_CAP_SIZE]);
  122. bool drm_dp_as_sdp_supported(struct drm_dp_aux *aux, const u8 dpcd[DP_RECEIVER_CAP_SIZE]);
  123. int drm_dp_psr_setup_time(const u8 psr_cap[EDP_PSR_RECEIVER_CAP_SIZE]);
  124. static inline int
  125. drm_dp_max_link_rate(const u8 dpcd[DP_RECEIVER_CAP_SIZE])
  126. {
  127. return drm_dp_bw_code_to_link_rate(dpcd[DP_MAX_LINK_RATE]);
  128. }
  129. static inline u8
  130. drm_dp_max_lane_count(const u8 dpcd[DP_RECEIVER_CAP_SIZE])
  131. {
  132. return dpcd[DP_MAX_LANE_COUNT] & DP_MAX_LANE_COUNT_MASK;
  133. }
  134. static inline bool
  135. drm_dp_enhanced_frame_cap(const u8 dpcd[DP_RECEIVER_CAP_SIZE])
  136. {
  137. return dpcd[DP_DPCD_REV] >= 0x11 &&
  138. (dpcd[DP_MAX_LANE_COUNT] & DP_ENHANCED_FRAME_CAP);
  139. }
  140. static inline bool
  141. drm_dp_post_lt_adj_req_supported(const u8 dpcd[DP_RECEIVER_CAP_SIZE])
  142. {
  143. return dpcd[DP_DPCD_REV] >= 0x13 &&
  144. (dpcd[DP_MAX_LANE_COUNT] & DP_POST_LT_ADJ_REQ_SUPPORTED);
  145. }
  146. static inline bool
  147. drm_dp_fast_training_cap(const u8 dpcd[DP_RECEIVER_CAP_SIZE])
  148. {
  149. return dpcd[DP_DPCD_REV] >= 0x11 &&
  150. (dpcd[DP_MAX_DOWNSPREAD] & DP_NO_AUX_HANDSHAKE_LINK_TRAINING);
  151. }
  152. static inline bool
  153. drm_dp_tps3_supported(const u8 dpcd[DP_RECEIVER_CAP_SIZE])
  154. {
  155. return dpcd[DP_DPCD_REV] >= 0x12 &&
  156. dpcd[DP_MAX_LANE_COUNT] & DP_TPS3_SUPPORTED;
  157. }
  158. static inline bool
  159. drm_dp_max_downspread(const u8 dpcd[DP_RECEIVER_CAP_SIZE])
  160. {
  161. return dpcd[DP_DPCD_REV] >= 0x11 ||
  162. dpcd[DP_MAX_DOWNSPREAD] & DP_MAX_DOWNSPREAD_0_5;
  163. }
  164. static inline bool
  165. drm_dp_tps4_supported(const u8 dpcd[DP_RECEIVER_CAP_SIZE])
  166. {
  167. return dpcd[DP_DPCD_REV] >= 0x14 &&
  168. dpcd[DP_MAX_DOWNSPREAD] & DP_TPS4_SUPPORTED;
  169. }
  170. static inline u8
  171. drm_dp_training_pattern_mask(const u8 dpcd[DP_RECEIVER_CAP_SIZE])
  172. {
  173. return (dpcd[DP_DPCD_REV] >= 0x14) ? DP_TRAINING_PATTERN_MASK_1_4 :
  174. DP_TRAINING_PATTERN_MASK;
  175. }
  176. static inline bool
  177. drm_dp_is_branch(const u8 dpcd[DP_RECEIVER_CAP_SIZE])
  178. {
  179. return dpcd[DP_DOWNSTREAMPORT_PRESENT] & DP_DWN_STRM_PORT_PRESENT;
  180. }
  181. /* DP/eDP DSC support */
  182. u8 drm_dp_dsc_sink_bpp_incr(const u8 dsc_dpcd[DP_DSC_RECEIVER_CAP_SIZE]);
  183. u32 drm_dp_dsc_slice_count_to_mask(int slice_count);
  184. u32 drm_dp_dsc_sink_slice_count_mask(const u8 dsc_dpcd[DP_DSC_RECEIVER_CAP_SIZE],
  185. bool is_edp);
  186. u8 drm_dp_dsc_sink_max_slice_count(const u8 dsc_dpcd[DP_DSC_RECEIVER_CAP_SIZE],
  187. bool is_edp);
  188. u8 drm_dp_dsc_sink_line_buf_depth(const u8 dsc_dpcd[DP_DSC_RECEIVER_CAP_SIZE]);
  189. int drm_dp_dsc_sink_supported_input_bpcs(const u8 dsc_dpc[DP_DSC_RECEIVER_CAP_SIZE],
  190. u8 dsc_bpc[3]);
  191. int drm_dp_dsc_sink_max_slice_throughput(const u8 dsc_dpcd[DP_DSC_RECEIVER_CAP_SIZE],
  192. int peak_pixel_rate, bool is_rgb_yuv444);
  193. int drm_dp_dsc_branch_max_overall_throughput(const u8 dsc_branch_dpcd[DP_DSC_BRANCH_CAP_SIZE],
  194. bool is_rgb_yuv444);
  195. int drm_dp_dsc_branch_max_line_width(const u8 dsc_branch_dpcd[DP_DSC_BRANCH_CAP_SIZE]);
  196. static inline bool
  197. drm_dp_sink_supports_dsc(const u8 dsc_dpcd[DP_DSC_RECEIVER_CAP_SIZE])
  198. {
  199. return dsc_dpcd[DP_DSC_SUPPORT - DP_DSC_SUPPORT] &
  200. DP_DSC_DECOMPRESSION_IS_SUPPORTED;
  201. }
  202. static inline u16
  203. drm_edp_dsc_sink_output_bpp(const u8 dsc_dpcd[DP_DSC_RECEIVER_CAP_SIZE])
  204. {
  205. return dsc_dpcd[DP_DSC_MAX_BITS_PER_PIXEL_LOW - DP_DSC_SUPPORT] |
  206. ((dsc_dpcd[DP_DSC_MAX_BITS_PER_PIXEL_HI - DP_DSC_SUPPORT] &
  207. DP_DSC_MAX_BITS_PER_PIXEL_HI_MASK) << 8);
  208. }
  209. static inline u32
  210. drm_dp_dsc_sink_max_slice_width(const u8 dsc_dpcd[DP_DSC_RECEIVER_CAP_SIZE])
  211. {
  212. /* Max Slicewidth = Number of Pixels * 320 */
  213. return dsc_dpcd[DP_DSC_MAX_SLICE_WIDTH - DP_DSC_SUPPORT] *
  214. DP_DSC_SLICE_WIDTH_MULTIPLIER;
  215. }
  216. /**
  217. * drm_dp_dsc_sink_supports_format() - check if sink supports DSC with given output format
  218. * @dsc_dpcd : DSC-capability DPCDs of the sink
  219. * @output_format: output_format which is to be checked
  220. *
  221. * Returns true if the sink supports DSC with the given output_format, false otherwise.
  222. */
  223. static inline bool
  224. drm_dp_dsc_sink_supports_format(const u8 dsc_dpcd[DP_DSC_RECEIVER_CAP_SIZE], u8 output_format)
  225. {
  226. return dsc_dpcd[DP_DSC_DEC_COLOR_FORMAT_CAP - DP_DSC_SUPPORT] & output_format;
  227. }
  228. /* Forward Error Correction Support on DP 1.4 */
  229. static inline bool
  230. drm_dp_sink_supports_fec(const u8 fec_capable)
  231. {
  232. return fec_capable & DP_FEC_CAPABLE;
  233. }
  234. static inline bool
  235. drm_dp_channel_coding_supported(const u8 dpcd[DP_RECEIVER_CAP_SIZE])
  236. {
  237. return dpcd[DP_MAIN_LINK_CHANNEL_CODING] & DP_CAP_ANSI_8B10B;
  238. }
  239. static inline bool
  240. drm_dp_128b132b_supported(const u8 dpcd[DP_RECEIVER_CAP_SIZE])
  241. {
  242. return dpcd[DP_MAIN_LINK_CHANNEL_CODING] & DP_CAP_ANSI_128B132B;
  243. }
  244. static inline bool
  245. drm_dp_alternate_scrambler_reset_cap(const u8 dpcd[DP_RECEIVER_CAP_SIZE])
  246. {
  247. return dpcd[DP_EDP_CONFIGURATION_CAP] &
  248. DP_ALTERNATE_SCRAMBLER_RESET_CAP;
  249. }
  250. /* Ignore MSA timing for Adaptive Sync support on DP 1.4 */
  251. static inline bool
  252. drm_dp_sink_can_do_video_without_timing_msa(const u8 dpcd[DP_RECEIVER_CAP_SIZE])
  253. {
  254. return dpcd[DP_DOWN_STREAM_PORT_COUNT] &
  255. DP_MSA_TIMING_PAR_IGNORED;
  256. }
  257. /**
  258. * drm_edp_backlight_supported() - Check an eDP DPCD for VESA backlight support
  259. * @edp_dpcd: The DPCD to check
  260. *
  261. * Note that currently this function will return %false for panels which support various DPCD
  262. * backlight features but which require the brightness be set through PWM, and don't support setting
  263. * the brightness level via the DPCD.
  264. *
  265. * Returns: %True if @edp_dpcd indicates that VESA backlight controls are supported, %false
  266. * otherwise
  267. */
  268. static inline bool
  269. drm_edp_backlight_supported(const u8 edp_dpcd[EDP_DISPLAY_CTL_CAP_SIZE])
  270. {
  271. return !!(edp_dpcd[1] & DP_EDP_TCON_BACKLIGHT_ADJUSTMENT_CAP);
  272. }
  273. /**
  274. * drm_dp_is_uhbr_rate - Determine if a link rate is UHBR
  275. * @link_rate: link rate in 10kbits/s units
  276. *
  277. * Determine if the provided link rate is an UHBR rate.
  278. *
  279. * Returns: %True if @link_rate is an UHBR rate.
  280. */
  281. static inline bool drm_dp_is_uhbr_rate(int link_rate)
  282. {
  283. return link_rate >= 1000000;
  284. }
  285. /*
  286. * DisplayPort AUX channel
  287. */
  288. /**
  289. * struct drm_dp_aux_msg - DisplayPort AUX channel transaction
  290. * @address: address of the (first) register to access
  291. * @request: contains the type of transaction (see DP_AUX_* macros)
  292. * @reply: upon completion, contains the reply type of the transaction
  293. * @buffer: pointer to a transmission or reception buffer
  294. * @size: size of @buffer
  295. */
  296. struct drm_dp_aux_msg {
  297. unsigned int address;
  298. u8 request;
  299. u8 reply;
  300. void *buffer;
  301. size_t size;
  302. };
  303. struct cec_adapter;
  304. struct drm_connector;
  305. struct drm_edid;
  306. /**
  307. * struct drm_dp_aux_cec - DisplayPort CEC-Tunneling-over-AUX
  308. * @lock: mutex protecting this struct
  309. * @adap: the CEC adapter for CEC-Tunneling-over-AUX support.
  310. * @connector: the connector this CEC adapter is associated with
  311. * @unregister_work: unregister the CEC adapter
  312. */
  313. struct drm_dp_aux_cec {
  314. struct mutex lock;
  315. struct cec_adapter *adap;
  316. struct drm_connector *connector;
  317. struct delayed_work unregister_work;
  318. };
  319. /**
  320. * struct drm_dp_aux - DisplayPort AUX channel
  321. *
  322. * An AUX channel can also be used to transport I2C messages to a sink. A
  323. * typical application of that is to access an EDID that's present in the sink
  324. * device. The @transfer() function can also be used to execute such
  325. * transactions. The drm_dp_aux_register() function registers an I2C adapter
  326. * that can be passed to drm_probe_ddc(). Upon removal, drivers should call
  327. * drm_dp_aux_unregister() to remove the I2C adapter. The I2C adapter uses long
  328. * transfers by default; if a partial response is received, the adapter will
  329. * drop down to the size given by the partial response for this transaction
  330. * only.
  331. */
  332. struct drm_dp_aux {
  333. /**
  334. * @name: user-visible name of this AUX channel and the
  335. * I2C-over-AUX adapter.
  336. *
  337. * It's also used to specify the name of the I2C adapter. If set
  338. * to %NULL, dev_name() of @dev will be used.
  339. */
  340. const char *name;
  341. /**
  342. * @ddc: I2C adapter that can be used for I2C-over-AUX
  343. * communication
  344. */
  345. struct i2c_adapter ddc;
  346. /**
  347. * @dev: pointer to struct device that is the parent for this
  348. * AUX channel.
  349. */
  350. struct device *dev;
  351. /**
  352. * @drm_dev: pointer to the &drm_device that owns this AUX channel.
  353. * Beware, this may be %NULL before drm_dp_aux_register() has been
  354. * called.
  355. *
  356. * It should be set to the &drm_device that will be using this AUX
  357. * channel as early as possible. For many graphics drivers this should
  358. * happen before drm_dp_aux_init(), however it's perfectly fine to set
  359. * this field later so long as it's assigned before calling
  360. * drm_dp_aux_register().
  361. */
  362. struct drm_device *drm_dev;
  363. /**
  364. * @crtc: backpointer to the crtc that is currently using this
  365. * AUX channel
  366. */
  367. struct drm_crtc *crtc;
  368. /**
  369. * @hw_mutex: internal mutex used for locking transfers.
  370. *
  371. * Note that if the underlying hardware is shared among multiple
  372. * channels, the driver needs to do additional locking to
  373. * prevent concurrent access.
  374. */
  375. struct mutex hw_mutex;
  376. /**
  377. * @crc_work: worker that captures CRCs for each frame
  378. */
  379. struct work_struct crc_work;
  380. /**
  381. * @crc_count: counter of captured frame CRCs
  382. */
  383. u8 crc_count;
  384. /**
  385. * @transfer: transfers a message representing a single AUX
  386. * transaction.
  387. *
  388. * This is a hardware-specific implementation of how
  389. * transactions are executed that the drivers must provide.
  390. *
  391. * A pointer to a &drm_dp_aux_msg structure describing the
  392. * transaction is passed into this function. Upon success, the
  393. * implementation should return the number of payload bytes that
  394. * were transferred, or a negative error-code on failure.
  395. *
  396. * Helpers will propagate these errors, with the exception of
  397. * the %-EBUSY error, which causes a transaction to be retried.
  398. * On a short, helpers will return %-EPROTO to make it simpler
  399. * to check for failure.
  400. *
  401. * The @transfer() function must only modify the reply field of
  402. * the &drm_dp_aux_msg structure. The retry logic and i2c
  403. * helpers assume this is the case.
  404. *
  405. * Also note that this callback can be called no matter the
  406. * state @dev is in and also no matter what state the panel is
  407. * in. It's expected:
  408. *
  409. * - If the @dev providing the AUX bus is currently unpowered then
  410. * it will power itself up for the transfer.
  411. *
  412. * - If we're on eDP (using a drm_panel) and the panel is not in a
  413. * state where it can respond (it's not powered or it's in a
  414. * low power state) then this function may return an error, but
  415. * not crash. It's up to the caller of this code to make sure that
  416. * the panel is powered on if getting an error back is not OK. If a
  417. * drm_panel driver is initiating a DP AUX transfer it may power
  418. * itself up however it wants. All other code should ensure that
  419. * the pre_enable() bridge chain (which eventually calls the
  420. * drm_panel prepare function) has powered the panel.
  421. */
  422. ssize_t (*transfer)(struct drm_dp_aux *aux,
  423. struct drm_dp_aux_msg *msg);
  424. /**
  425. * @wait_hpd_asserted: wait for HPD to be asserted
  426. *
  427. * This is mainly useful for eDP panels drivers to wait for an eDP
  428. * panel to finish powering on. It is optional for DP AUX controllers
  429. * to implement this function. It is required for DP AUX endpoints
  430. * (panel drivers) to call this function after powering up but before
  431. * doing AUX transfers unless the DP AUX endpoint driver knows that
  432. * we're not using the AUX controller's HPD. One example of the panel
  433. * driver not needing to call this is if HPD is hooked up to a GPIO
  434. * that the panel driver can read directly.
  435. *
  436. * If a DP AUX controller does not implement this function then it
  437. * may still support eDP panels that use the AUX controller's built-in
  438. * HPD signal by implementing a long wait for HPD in the transfer()
  439. * callback, though this is deprecated.
  440. *
  441. * This function will efficiently wait for the HPD signal to be
  442. * asserted. The `wait_us` parameter that is passed in says that we
  443. * know that the HPD signal is expected to be asserted within `wait_us`
  444. * microseconds. This function could wait for longer than `wait_us` if
  445. * the logic in the DP controller has a long debouncing time. The
  446. * important thing is that if this function returns success that the
  447. * DP controller is ready to send AUX transactions.
  448. *
  449. * This function returns 0 if HPD was asserted or -ETIMEDOUT if time
  450. * expired and HPD wasn't asserted. This function should not print
  451. * timeout errors to the log.
  452. *
  453. * The semantics of this function are designed to match the
  454. * readx_poll_timeout() function. That means a `wait_us` of 0 means
  455. * to wait forever. Like readx_poll_timeout(), this function may sleep.
  456. *
  457. * NOTE: this function specifically reports the state of the HPD pin
  458. * that's associated with the DP AUX channel. This is different from
  459. * the HPD concept in much of the rest of DRM which is more about
  460. * physical presence of a display. For eDP, for instance, a display is
  461. * assumed always present even if the HPD pin is deasserted.
  462. */
  463. int (*wait_hpd_asserted)(struct drm_dp_aux *aux, unsigned long wait_us);
  464. /**
  465. * @i2c_nack_count: Counts I2C NACKs, used for DP validation.
  466. */
  467. unsigned i2c_nack_count;
  468. /**
  469. * @i2c_defer_count: Counts I2C DEFERs, used for DP validation.
  470. */
  471. unsigned i2c_defer_count;
  472. /**
  473. * @cec: struct containing fields used for CEC-Tunneling-over-AUX.
  474. */
  475. struct drm_dp_aux_cec cec;
  476. /**
  477. * @is_remote: Is this AUX CH actually using sideband messaging.
  478. */
  479. bool is_remote;
  480. /**
  481. * @powered_down: If true then the remote endpoint is powered down.
  482. */
  483. bool powered_down;
  484. /**
  485. * @no_zero_sized: If the hw can't use zero sized transfers (NVIDIA)
  486. */
  487. bool no_zero_sized;
  488. /**
  489. * @dpcd_probe_disabled: If probing before a DPCD access is disabled.
  490. */
  491. bool dpcd_probe_disabled;
  492. };
  493. int drm_dp_dpcd_probe(struct drm_dp_aux *aux, unsigned int offset);
  494. void drm_dp_dpcd_set_powered(struct drm_dp_aux *aux, bool powered);
  495. void drm_dp_dpcd_set_probe(struct drm_dp_aux *aux, bool enable);
  496. ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset,
  497. void *buffer, size_t size);
  498. ssize_t drm_dp_dpcd_write(struct drm_dp_aux *aux, unsigned int offset,
  499. void *buffer, size_t size);
  500. /**
  501. * drm_dp_dpcd_readb() - read a single byte from the DPCD
  502. * @aux: DisplayPort AUX channel
  503. * @offset: address of the register to read
  504. * @valuep: location where the value of the register will be stored
  505. *
  506. * Returns the number of bytes transferred (1) on success, or a negative
  507. * error code on failure. In most of the cases you should be using
  508. * drm_dp_dpcd_read_byte() instead.
  509. */
  510. static inline ssize_t drm_dp_dpcd_readb(struct drm_dp_aux *aux,
  511. unsigned int offset, u8 *valuep)
  512. {
  513. return drm_dp_dpcd_read(aux, offset, valuep, 1);
  514. }
  515. /**
  516. * drm_dp_dpcd_read_data() - read a series of bytes from the DPCD
  517. * @aux: DisplayPort AUX channel (SST or MST)
  518. * @offset: address of the (first) register to read
  519. * @buffer: buffer to store the register values
  520. * @size: number of bytes in @buffer
  521. *
  522. * Returns zero (0) on success, or a negative error
  523. * code on failure. -EIO is returned if the request was NAKed by the sink or
  524. * if the retry count was exceeded. If not all bytes were transferred, this
  525. * function returns -EPROTO. Errors from the underlying AUX channel transfer
  526. * function, with the exception of -EBUSY (which causes the transaction to
  527. * be retried), are propagated to the caller.
  528. */
  529. static inline int drm_dp_dpcd_read_data(struct drm_dp_aux *aux,
  530. unsigned int offset,
  531. void *buffer, size_t size)
  532. {
  533. int ret;
  534. size_t i;
  535. u8 *buf = buffer;
  536. ret = drm_dp_dpcd_read(aux, offset, buffer, size);
  537. if (ret >= 0) {
  538. if (ret < size)
  539. return -EPROTO;
  540. return 0;
  541. }
  542. /*
  543. * Workaround for USB-C hubs/adapters with buggy firmware that fail
  544. * multi-byte AUX reads but work with single-byte reads.
  545. * Known affected devices:
  546. * - Lenovo USB-C to VGA adapter (VIA VL817, idVendor=17ef, idProduct=7217)
  547. * - Dell DA310 USB-C hub (idVendor=413c, idProduct=c010)
  548. * Attempt byte-by-byte reading as a fallback.
  549. */
  550. for (i = 0; i < size; i++) {
  551. ret = drm_dp_dpcd_readb(aux, offset + i, &buf[i]);
  552. if (ret < 0)
  553. return ret;
  554. }
  555. return 0;
  556. }
  557. /**
  558. * drm_dp_dpcd_write_data() - write a series of bytes to the DPCD
  559. * @aux: DisplayPort AUX channel (SST or MST)
  560. * @offset: address of the (first) register to write
  561. * @buffer: buffer containing the values to write
  562. * @size: number of bytes in @buffer
  563. *
  564. * Returns zero (0) on success, or a negative error
  565. * code on failure. -EIO is returned if the request was NAKed by the sink or
  566. * if the retry count was exceeded. If not all bytes were transferred, this
  567. * function returns -EPROTO. Errors from the underlying AUX channel transfer
  568. * function, with the exception of -EBUSY (which causes the transaction to
  569. * be retried), are propagated to the caller.
  570. */
  571. static inline int drm_dp_dpcd_write_data(struct drm_dp_aux *aux,
  572. unsigned int offset,
  573. void *buffer, size_t size)
  574. {
  575. int ret;
  576. ret = drm_dp_dpcd_write(aux, offset, buffer, size);
  577. if (ret < 0)
  578. return ret;
  579. if (ret < size)
  580. return -EPROTO;
  581. return 0;
  582. }
  583. /**
  584. * drm_dp_dpcd_writeb() - write a single byte to the DPCD
  585. * @aux: DisplayPort AUX channel
  586. * @offset: address of the register to write
  587. * @value: value to write to the register
  588. *
  589. * Returns the number of bytes transferred (1) on success, or a negative
  590. * error code on failure. In most of the cases you should be using
  591. * drm_dp_dpcd_write_byte() instead.
  592. */
  593. static inline ssize_t drm_dp_dpcd_writeb(struct drm_dp_aux *aux,
  594. unsigned int offset, u8 value)
  595. {
  596. return drm_dp_dpcd_write(aux, offset, &value, 1);
  597. }
  598. /**
  599. * drm_dp_dpcd_read_byte() - read a single byte from the DPCD
  600. * @aux: DisplayPort AUX channel
  601. * @offset: address of the register to read
  602. * @valuep: location where the value of the register will be stored
  603. *
  604. * Returns zero (0) on success, or a negative error code on failure.
  605. */
  606. static inline int drm_dp_dpcd_read_byte(struct drm_dp_aux *aux,
  607. unsigned int offset, u8 *valuep)
  608. {
  609. return drm_dp_dpcd_read_data(aux, offset, valuep, 1);
  610. }
  611. /**
  612. * drm_dp_dpcd_write_byte() - write a single byte to the DPCD
  613. * @aux: DisplayPort AUX channel
  614. * @offset: address of the register to write
  615. * @value: value to write to the register
  616. *
  617. * Returns zero (0) on success, or a negative error code on failure.
  618. */
  619. static inline int drm_dp_dpcd_write_byte(struct drm_dp_aux *aux,
  620. unsigned int offset, u8 value)
  621. {
  622. return drm_dp_dpcd_write_data(aux, offset, &value, 1);
  623. }
  624. int drm_dp_read_dpcd_caps(struct drm_dp_aux *aux,
  625. u8 dpcd[DP_RECEIVER_CAP_SIZE]);
  626. int drm_dp_dpcd_read_link_status(struct drm_dp_aux *aux,
  627. u8 status[DP_LINK_STATUS_SIZE]);
  628. int drm_dp_dpcd_read_phy_link_status(struct drm_dp_aux *aux,
  629. enum drm_dp_phy dp_phy,
  630. u8 link_status[DP_LINK_STATUS_SIZE]);
  631. int drm_dp_link_power_up(struct drm_dp_aux *aux, unsigned char revision);
  632. int drm_dp_link_power_down(struct drm_dp_aux *aux, unsigned char revision);
  633. int drm_dp_dpcd_write_payload(struct drm_dp_aux *aux,
  634. int vcpid, u8 start_time_slot, u8 time_slot_count);
  635. int drm_dp_dpcd_clear_payload(struct drm_dp_aux *aux);
  636. int drm_dp_dpcd_poll_act_handled(struct drm_dp_aux *aux, int timeout_ms);
  637. bool drm_dp_send_real_edid_checksum(struct drm_dp_aux *aux,
  638. u8 real_edid_checksum);
  639. int drm_dp_read_downstream_info(struct drm_dp_aux *aux,
  640. const u8 dpcd[DP_RECEIVER_CAP_SIZE],
  641. u8 downstream_ports[DP_MAX_DOWNSTREAM_PORTS]);
  642. bool drm_dp_downstream_is_type(const u8 dpcd[DP_RECEIVER_CAP_SIZE],
  643. const u8 port_cap[4], u8 type);
  644. bool drm_dp_downstream_is_tmds(const u8 dpcd[DP_RECEIVER_CAP_SIZE],
  645. const u8 port_cap[4],
  646. const struct drm_edid *drm_edid);
  647. int drm_dp_downstream_max_dotclock(const u8 dpcd[DP_RECEIVER_CAP_SIZE],
  648. const u8 port_cap[4]);
  649. int drm_dp_downstream_max_tmds_clock(const u8 dpcd[DP_RECEIVER_CAP_SIZE],
  650. const u8 port_cap[4],
  651. const struct drm_edid *drm_edid);
  652. int drm_dp_downstream_min_tmds_clock(const u8 dpcd[DP_RECEIVER_CAP_SIZE],
  653. const u8 port_cap[4],
  654. const struct drm_edid *drm_edid);
  655. int drm_dp_downstream_max_bpc(const u8 dpcd[DP_RECEIVER_CAP_SIZE],
  656. const u8 port_cap[4],
  657. const struct drm_edid *drm_edid);
  658. bool drm_dp_downstream_420_passthrough(const u8 dpcd[DP_RECEIVER_CAP_SIZE],
  659. const u8 port_cap[4]);
  660. bool drm_dp_downstream_444_to_420_conversion(const u8 dpcd[DP_RECEIVER_CAP_SIZE],
  661. const u8 port_cap[4]);
  662. struct drm_display_mode *drm_dp_downstream_mode(struct drm_device *dev,
  663. const u8 dpcd[DP_RECEIVER_CAP_SIZE],
  664. const u8 port_cap[4]);
  665. int drm_dp_downstream_id(struct drm_dp_aux *aux, char id[6]);
  666. void drm_dp_downstream_debug(struct seq_file *m,
  667. const u8 dpcd[DP_RECEIVER_CAP_SIZE],
  668. const u8 port_cap[4],
  669. const struct drm_edid *drm_edid,
  670. struct drm_dp_aux *aux);
  671. enum drm_mode_subconnector
  672. drm_dp_subconnector_type(const u8 dpcd[DP_RECEIVER_CAP_SIZE],
  673. const u8 port_cap[4]);
  674. void drm_dp_set_subconnector_property(struct drm_connector *connector,
  675. enum drm_connector_status status,
  676. const u8 *dpcd,
  677. const u8 port_cap[4]);
  678. struct drm_dp_desc;
  679. bool drm_dp_read_sink_count_cap(struct drm_connector *connector,
  680. const u8 dpcd[DP_RECEIVER_CAP_SIZE],
  681. const struct drm_dp_desc *desc);
  682. int drm_dp_read_sink_count(struct drm_dp_aux *aux);
  683. int drm_dp_read_lttpr_common_caps(struct drm_dp_aux *aux,
  684. const u8 dpcd[DP_RECEIVER_CAP_SIZE],
  685. u8 caps[DP_LTTPR_COMMON_CAP_SIZE]);
  686. int drm_dp_read_lttpr_phy_caps(struct drm_dp_aux *aux,
  687. const u8 dpcd[DP_RECEIVER_CAP_SIZE],
  688. enum drm_dp_phy dp_phy,
  689. u8 caps[DP_LTTPR_PHY_CAP_SIZE]);
  690. int drm_dp_lttpr_count(const u8 cap[DP_LTTPR_COMMON_CAP_SIZE]);
  691. int drm_dp_lttpr_max_link_rate(const u8 caps[DP_LTTPR_COMMON_CAP_SIZE]);
  692. int drm_dp_lttpr_set_transparent_mode(struct drm_dp_aux *aux, bool enable);
  693. int drm_dp_lttpr_init(struct drm_dp_aux *aux, int lttpr_count);
  694. int drm_dp_lttpr_max_lane_count(const u8 caps[DP_LTTPR_COMMON_CAP_SIZE]);
  695. bool drm_dp_lttpr_voltage_swing_level_3_supported(const u8 caps[DP_LTTPR_PHY_CAP_SIZE]);
  696. bool drm_dp_lttpr_pre_emphasis_level_3_supported(const u8 caps[DP_LTTPR_PHY_CAP_SIZE]);
  697. void drm_dp_lttpr_wake_timeout_setup(struct drm_dp_aux *aux, bool transparent_mode);
  698. void drm_dp_remote_aux_init(struct drm_dp_aux *aux);
  699. void drm_dp_aux_init(struct drm_dp_aux *aux);
  700. int drm_dp_aux_register(struct drm_dp_aux *aux);
  701. void drm_dp_aux_unregister(struct drm_dp_aux *aux);
  702. int drm_dp_start_crc(struct drm_dp_aux *aux, struct drm_crtc *crtc);
  703. int drm_dp_stop_crc(struct drm_dp_aux *aux);
  704. struct drm_dp_dpcd_ident {
  705. u8 oui[3];
  706. u8 device_id[6];
  707. u8 hw_rev;
  708. u8 sw_major_rev;
  709. u8 sw_minor_rev;
  710. } __packed;
  711. /**
  712. * struct drm_dp_desc - DP branch/sink device descriptor
  713. * @ident: DP device identification from DPCD 0x400 (sink) or 0x500 (branch).
  714. * @quirks: Quirks; use drm_dp_has_quirk() to query for the quirks.
  715. */
  716. struct drm_dp_desc {
  717. struct drm_dp_dpcd_ident ident;
  718. u32 quirks;
  719. };
  720. int drm_dp_read_desc(struct drm_dp_aux *aux, struct drm_dp_desc *desc,
  721. bool is_branch);
  722. int drm_dp_dump_lttpr_desc(struct drm_dp_aux *aux, enum drm_dp_phy dp_phy);
  723. /**
  724. * enum drm_dp_quirk - Display Port sink/branch device specific quirks
  725. *
  726. * Display Port sink and branch devices in the wild have a variety of bugs, try
  727. * to collect them here. The quirks are shared, but it's up to the drivers to
  728. * implement workarounds for them.
  729. */
  730. enum drm_dp_quirk {
  731. /**
  732. * @DP_DPCD_QUIRK_CONSTANT_N:
  733. *
  734. * The device requires main link attributes Mvid and Nvid to be limited
  735. * to 16 bits. So will give a constant value (0x8000) for compatability.
  736. */
  737. DP_DPCD_QUIRK_CONSTANT_N,
  738. /**
  739. * @DP_DPCD_QUIRK_NO_PSR:
  740. *
  741. * The device does not support PSR even if reports that it supports or
  742. * driver still need to implement proper handling for such device.
  743. */
  744. DP_DPCD_QUIRK_NO_PSR,
  745. /**
  746. * @DP_DPCD_QUIRK_NO_SINK_COUNT:
  747. *
  748. * The device does not set SINK_COUNT to a non-zero value.
  749. * The driver should ignore SINK_COUNT during detection. Note that
  750. * drm_dp_read_sink_count_cap() automatically checks for this quirk.
  751. */
  752. DP_DPCD_QUIRK_NO_SINK_COUNT,
  753. /**
  754. * @DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD:
  755. *
  756. * The device supports MST DSC despite not supporting Virtual DPCD.
  757. * The DSC caps can be read from the physical aux instead.
  758. */
  759. DP_DPCD_QUIRK_DSC_WITHOUT_VIRTUAL_DPCD,
  760. /**
  761. * @DP_DPCD_QUIRK_CAN_DO_MAX_LINK_RATE_3_24_GBPS:
  762. *
  763. * The device supports a link rate of 3.24 Gbps (multiplier 0xc) despite
  764. * the DP_MAX_LINK_RATE register reporting a lower max multiplier.
  765. */
  766. DP_DPCD_QUIRK_CAN_DO_MAX_LINK_RATE_3_24_GBPS,
  767. /**
  768. * @DP_DPCD_QUIRK_HBLANK_EXPANSION_REQUIRES_DSC:
  769. *
  770. * The device applies HBLANK expansion for some modes, but this
  771. * requires enabling DSC.
  772. */
  773. DP_DPCD_QUIRK_HBLANK_EXPANSION_REQUIRES_DSC,
  774. /**
  775. * @DP_DPCD_QUIRK_DSC_THROUGHPUT_BPP_LIMIT:
  776. *
  777. * The device doesn't support DSC decompression at the maximum DSC
  778. * pixel throughput and compressed bpp it indicates via its DPCD DSC
  779. * capabilities. The compressed bpp must be limited above a device
  780. * specific DSC pixel throughput.
  781. */
  782. DP_DPCD_QUIRK_DSC_THROUGHPUT_BPP_LIMIT,
  783. };
  784. /**
  785. * drm_dp_has_quirk() - does the DP device have a specific quirk
  786. * @desc: Device descriptor filled by drm_dp_read_desc()
  787. * @quirk: Quirk to query for
  788. *
  789. * Return true if DP device identified by @desc has @quirk.
  790. */
  791. static inline bool
  792. drm_dp_has_quirk(const struct drm_dp_desc *desc, enum drm_dp_quirk quirk)
  793. {
  794. return desc->quirks & BIT(quirk);
  795. }
  796. /**
  797. * struct drm_edp_backlight_info - Probed eDP backlight info struct
  798. * @pwmgen_bit_count: The pwmgen bit count
  799. * @pwm_freq_pre_divider: The PWM frequency pre-divider value being used for this backlight, if any
  800. * @max: The maximum backlight level that may be set
  801. * @lsb_reg_used: Do we also write values to the DP_EDP_BACKLIGHT_BRIGHTNESS_LSB register?
  802. * @aux_enable: Does the panel support the AUX enable cap?
  803. * @aux_set: Does the panel support setting the brightness through AUX?
  804. * @luminance_set: Does the panel support setting the brightness through AUX using luminance values?
  805. *
  806. * This structure contains various data about an eDP backlight, which can be populated by using
  807. * drm_edp_backlight_init().
  808. */
  809. struct drm_edp_backlight_info {
  810. u8 pwmgen_bit_count;
  811. u8 pwm_freq_pre_divider;
  812. u32 max;
  813. bool lsb_reg_used : 1;
  814. bool aux_enable : 1;
  815. bool aux_set : 1;
  816. bool luminance_set : 1;
  817. };
  818. int
  819. drm_edp_backlight_init(struct drm_dp_aux *aux, struct drm_edp_backlight_info *bl,
  820. u32 max_luminance,
  821. u16 driver_pwm_freq_hz, const u8 edp_dpcd[EDP_DISPLAY_CTL_CAP_SIZE],
  822. u32 *current_level, u8 *current_mode, bool need_luminance);
  823. int drm_edp_backlight_set_level(struct drm_dp_aux *aux, const struct drm_edp_backlight_info *bl,
  824. u32 level);
  825. int drm_edp_backlight_enable(struct drm_dp_aux *aux, const struct drm_edp_backlight_info *bl,
  826. u32 level);
  827. int drm_edp_backlight_disable(struct drm_dp_aux *aux, const struct drm_edp_backlight_info *bl);
  828. #if IS_ENABLED(CONFIG_DRM_KMS_HELPER) && (IS_BUILTIN(CONFIG_BACKLIGHT_CLASS_DEVICE) || \
  829. (IS_MODULE(CONFIG_DRM_KMS_HELPER) && IS_MODULE(CONFIG_BACKLIGHT_CLASS_DEVICE)))
  830. int drm_panel_dp_aux_backlight(struct drm_panel *panel, struct drm_dp_aux *aux);
  831. #else
  832. static inline int drm_panel_dp_aux_backlight(struct drm_panel *panel,
  833. struct drm_dp_aux *aux)
  834. {
  835. return 0;
  836. }
  837. #endif
  838. #ifdef CONFIG_DRM_DISPLAY_DP_AUX_CEC
  839. void drm_dp_cec_irq(struct drm_dp_aux *aux);
  840. void drm_dp_cec_register_connector(struct drm_dp_aux *aux,
  841. struct drm_connector *connector);
  842. void drm_dp_cec_unregister_connector(struct drm_dp_aux *aux);
  843. void drm_dp_cec_attach(struct drm_dp_aux *aux, u16 source_physical_address);
  844. void drm_dp_cec_set_edid(struct drm_dp_aux *aux, const struct edid *edid);
  845. void drm_dp_cec_unset_edid(struct drm_dp_aux *aux);
  846. #else
  847. static inline void drm_dp_cec_irq(struct drm_dp_aux *aux)
  848. {
  849. }
  850. static inline void
  851. drm_dp_cec_register_connector(struct drm_dp_aux *aux,
  852. struct drm_connector *connector)
  853. {
  854. }
  855. static inline void drm_dp_cec_unregister_connector(struct drm_dp_aux *aux)
  856. {
  857. }
  858. static inline void drm_dp_cec_attach(struct drm_dp_aux *aux,
  859. u16 source_physical_address)
  860. {
  861. }
  862. static inline void drm_dp_cec_set_edid(struct drm_dp_aux *aux,
  863. const struct edid *edid)
  864. {
  865. }
  866. static inline void drm_dp_cec_unset_edid(struct drm_dp_aux *aux)
  867. {
  868. }
  869. #endif
  870. /**
  871. * struct drm_dp_phy_test_params - DP Phy Compliance parameters
  872. * @link_rate: Requested Link rate from DPCD 0x219
  873. * @num_lanes: Number of lanes requested by sing through DPCD 0x220
  874. * @phy_pattern: DP Phy test pattern from DPCD 0x248
  875. * @hbr2_reset: DP HBR2_COMPLIANCE_SCRAMBLER_RESET from DCPD 0x24A and 0x24B
  876. * @custom80: DP Test_80BIT_CUSTOM_PATTERN from DPCDs 0x250 through 0x259
  877. * @enhanced_frame_cap: flag for enhanced frame capability.
  878. */
  879. struct drm_dp_phy_test_params {
  880. int link_rate;
  881. u8 num_lanes;
  882. u8 phy_pattern;
  883. u8 hbr2_reset[2];
  884. u8 custom80[10];
  885. bool enhanced_frame_cap;
  886. };
  887. int drm_dp_get_phy_test_pattern(struct drm_dp_aux *aux,
  888. struct drm_dp_phy_test_params *data);
  889. int drm_dp_set_phy_test_pattern(struct drm_dp_aux *aux,
  890. struct drm_dp_phy_test_params *data, u8 dp_rev);
  891. int drm_dp_get_pcon_max_frl_bw(const u8 dpcd[DP_RECEIVER_CAP_SIZE],
  892. const u8 port_cap[4]);
  893. int drm_dp_pcon_frl_prepare(struct drm_dp_aux *aux, bool enable_frl_ready_hpd);
  894. bool drm_dp_pcon_is_frl_ready(struct drm_dp_aux *aux);
  895. int drm_dp_pcon_frl_configure_1(struct drm_dp_aux *aux, int max_frl_gbps,
  896. u8 frl_mode);
  897. int drm_dp_pcon_frl_configure_2(struct drm_dp_aux *aux, int max_frl_mask,
  898. u8 frl_type);
  899. int drm_dp_pcon_reset_frl_config(struct drm_dp_aux *aux);
  900. int drm_dp_pcon_frl_enable(struct drm_dp_aux *aux);
  901. bool drm_dp_pcon_hdmi_link_active(struct drm_dp_aux *aux);
  902. int drm_dp_pcon_hdmi_link_mode(struct drm_dp_aux *aux, u8 *frl_trained_mask);
  903. void drm_dp_pcon_hdmi_frl_link_error_count(struct drm_dp_aux *aux,
  904. struct drm_connector *connector);
  905. bool drm_dp_pcon_enc_is_dsc_1_2(const u8 pcon_dsc_dpcd[DP_PCON_DSC_ENCODER_CAP_SIZE]);
  906. int drm_dp_pcon_dsc_max_slices(const u8 pcon_dsc_dpcd[DP_PCON_DSC_ENCODER_CAP_SIZE]);
  907. int drm_dp_pcon_dsc_max_slice_width(const u8 pcon_dsc_dpcd[DP_PCON_DSC_ENCODER_CAP_SIZE]);
  908. int drm_dp_pcon_dsc_bpp_incr(const u8 pcon_dsc_dpcd[DP_PCON_DSC_ENCODER_CAP_SIZE]);
  909. int drm_dp_pcon_pps_default(struct drm_dp_aux *aux);
  910. int drm_dp_pcon_pps_override_buf(struct drm_dp_aux *aux, u8 pps_buf[128]);
  911. int drm_dp_pcon_pps_override_param(struct drm_dp_aux *aux, u8 pps_param[6]);
  912. bool drm_dp_downstream_rgb_to_ycbcr_conversion(const u8 dpcd[DP_RECEIVER_CAP_SIZE],
  913. const u8 port_cap[4], u8 color_spc);
  914. int drm_dp_pcon_convert_rgb_to_ycbcr(struct drm_dp_aux *aux, u8 color_spc);
  915. #define DRM_DP_BW_OVERHEAD_MST BIT(0)
  916. #define DRM_DP_BW_OVERHEAD_UHBR BIT(1)
  917. #define DRM_DP_BW_OVERHEAD_SSC_REF_CLK BIT(2)
  918. #define DRM_DP_BW_OVERHEAD_FEC BIT(3)
  919. #define DRM_DP_BW_OVERHEAD_DSC BIT(4)
  920. int drm_dp_bw_overhead(int lane_count, int hactive,
  921. int dsc_slice_count,
  922. int bpp_x16, unsigned long flags);
  923. int drm_dp_bw_channel_coding_efficiency(bool is_uhbr);
  924. int drm_dp_max_dprx_data_rate(int max_link_rate, int max_lanes);
  925. ssize_t drm_dp_vsc_sdp_pack(const struct drm_dp_vsc_sdp *vsc, struct dp_sdp *sdp);
  926. int drm_dp_link_symbol_cycles(int lane_count, int pixels, int dsc_slice_count,
  927. int bpp_x16, int symbol_size, bool is_mst);
  928. #endif /* _DRM_DP_HELPER_H_ */