aboutsummaryrefslogtreecommitdiffstats
path: root/include/drm
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2014-02-26 23:30:08 -0500
committerDave Airlie <airlied@redhat.com>2014-02-26 23:30:08 -0500
commit6ba6b7cdaf1a48b24c23c303871ffe1640a866e8 (patch)
tree0e67c7aad3b51a879c8d6ae07ae8276c29514b38 /include/drm
parentcfbf8d4857c26a8a307fb7cd258074c9dcd8c691 (diff)
parent88759686c702f1fbbb8e737e6231b64a9880db73 (diff)
Merge tag 'drm/dp-aux-for-3.15-rc1' of git://anongit.freedesktop.org/tegra/linux into drm-next
drm: DisplayPort AUX framework for v3.15-rc1 This series of patches implements a small framework that abstracts away some of the functionality that the DisplayPort AUX channel provides. It comes with a set of generic helpers that use the driver implementations to reduce code duplication. * tag 'drm/dp-aux-for-3.15-rc1' of git://anongit.freedesktop.org/tegra/linux: drm/dp: Allow registering AUX channels as I2C busses drm/dp: Add DisplayPort link helpers drm/dp: Add drm_dp_dpcd_read_link_status() drm/dp: Add AUX channel infrastructure
Diffstat (limited to 'include/drm')
-rw-r--r--include/drm/drm_dp_helper.h111
1 files changed, 111 insertions, 0 deletions
diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
index 1d09050a8c00..b7488c9849ad 100644
--- a/include/drm/drm_dp_helper.h
+++ b/include/drm/drm_dp_helper.h
@@ -291,6 +291,7 @@
291#define DP_SET_POWER 0x600 291#define DP_SET_POWER 0x600
292# define DP_SET_POWER_D0 0x1 292# define DP_SET_POWER_D0 0x1
293# define DP_SET_POWER_D3 0x2 293# define DP_SET_POWER_D3 0x2
294# define DP_SET_POWER_MASK 0x3
294 295
295#define DP_PSR_ERROR_STATUS 0x2006 /* XXX 1.2? */ 296#define DP_PSR_ERROR_STATUS 0x2006 /* XXX 1.2? */
296# define DP_PSR_LINK_CRC_ERROR (1 << 0) 297# define DP_PSR_LINK_CRC_ERROR (1 << 0)
@@ -398,4 +399,114 @@ drm_dp_enhanced_frame_cap(const u8 dpcd[DP_RECEIVER_CAP_SIZE])
398 (dpcd[DP_MAX_LANE_COUNT] & DP_ENHANCED_FRAME_CAP); 399 (dpcd[DP_MAX_LANE_COUNT] & DP_ENHANCED_FRAME_CAP);
399} 400}
400 401
402/*
403 * DisplayPort AUX channel
404 */
405
406/**
407 * struct drm_dp_aux_msg - DisplayPort AUX channel transaction
408 * @address: address of the (first) register to access
409 * @request: contains the type of transaction (see DP_AUX_* macros)
410 * @reply: upon completion, contains the reply type of the transaction
411 * @buffer: pointer to a transmission or reception buffer
412 * @size: size of @buffer
413 */
414struct drm_dp_aux_msg {
415 unsigned int address;
416 u8 request;
417 u8 reply;
418 void *buffer;
419 size_t size;
420};
421
422/**
423 * struct drm_dp_aux - DisplayPort AUX channel
424 * @ddc: I2C adapter that can be used for I2C-over-AUX communication
425 * @dev: pointer to struct device that is the parent for this AUX channel
426 * @transfer: transfers a message representing a single AUX transaction
427 *
428 * The .dev field should be set to a pointer to the device that implements
429 * the AUX channel.
430 *
431 * Drivers provide a hardware-specific implementation of how transactions
432 * are executed via the .transfer() function. A pointer to a drm_dp_aux_msg
433 * structure describing the transaction is passed into this function. Upon
434 * success, the implementation should return the number of payload bytes
435 * that were transferred, or a negative error-code on failure. Helpers
436 * propagate errors from the .transfer() function, with the exception of
437 * the -EBUSY error, which causes a transaction to be retried. On a short,
438 * helpers will return -EPROTO to make it simpler to check for failure.
439 *
440 * An AUX channel can also be used to transport I2C messages to a sink. A
441 * typical application of that is to access an EDID that's present in the
442 * sink device. The .transfer() function can also be used to execute such
443 * transactions. The drm_dp_aux_register_i2c_bus() function registers an
444 * I2C adapter that can be passed to drm_probe_ddc(). Upon removal, drivers
445 * should call drm_dp_aux_unregister_i2c_bus() to remove the I2C adapter.
446 */
447struct drm_dp_aux {
448 struct i2c_adapter ddc;
449 struct device *dev;
450
451 ssize_t (*transfer)(struct drm_dp_aux *aux,
452 struct drm_dp_aux_msg *msg);
453};
454
455ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset,
456 void *buffer, size_t size);
457ssize_t drm_dp_dpcd_write(struct drm_dp_aux *aux, unsigned int offset,
458 void *buffer, size_t size);
459
460/**
461 * drm_dp_dpcd_readb() - read a single byte from the DPCD
462 * @aux: DisplayPort AUX channel
463 * @offset: address of the register to read
464 * @valuep: location where the value of the register will be stored
465 *
466 * Returns the number of bytes transferred (1) on success, or a negative
467 * error code on failure.
468 */
469static inline ssize_t drm_dp_dpcd_readb(struct drm_dp_aux *aux,
470 unsigned int offset, u8 *valuep)
471{
472 return drm_dp_dpcd_read(aux, offset, valuep, 1);
473}
474
475/**
476 * drm_dp_dpcd_writeb() - write a single byte to the DPCD
477 * @aux: DisplayPort AUX channel
478 * @offset: address of the register to write
479 * @value: value to write to the register
480 *
481 * Returns the number of bytes transferred (1) on success, or a negative
482 * error code on failure.
483 */
484static inline ssize_t drm_dp_dpcd_writeb(struct drm_dp_aux *aux,
485 unsigned int offset, u8 value)
486{
487 return drm_dp_dpcd_write(aux, offset, &value, 1);
488}
489
490int drm_dp_dpcd_read_link_status(struct drm_dp_aux *aux,
491 u8 status[DP_LINK_STATUS_SIZE]);
492
493/*
494 * DisplayPort link
495 */
496#define DP_LINK_CAP_ENHANCED_FRAMING (1 << 0)
497
498struct drm_dp_link {
499 unsigned char revision;
500 unsigned int rate;
501 unsigned int num_lanes;
502 unsigned long capabilities;
503};
504
505int drm_dp_link_probe(struct drm_dp_aux *aux, struct drm_dp_link *link);
506int drm_dp_link_power_up(struct drm_dp_aux *aux, struct drm_dp_link *link);
507int drm_dp_link_configure(struct drm_dp_aux *aux, struct drm_dp_link *link);
508
509int drm_dp_aux_register_i2c_bus(struct drm_dp_aux *aux);
510void drm_dp_aux_unregister_i2c_bus(struct drm_dp_aux *aux);
511
401#endif /* _DRM_DP_HELPER_H_ */ 512#endif /* _DRM_DP_HELPER_H_ */