Home | History | Annotate | Line # | Download | only in drm
      1 /*	$NetBSD: drm_dp_dual_mode_helper.h,v 1.2 2021/12/18 23:45:45 riastradh Exp $	*/
      2 
      3 /*
      4  * Copyright  2016 Intel Corporation
      5  *
      6  * Permission is hereby granted, free of charge, to any person obtaining a
      7  * copy of this software and associated documentation files (the "Software"),
      8  * to deal in the Software without restriction, including without limitation
      9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     10  * and/or sell copies of the Software, and to permit persons to whom the
     11  * Software is furnished to do so, subject to the following conditions:
     12  *
     13  * The above copyright notice and this permission notice shall be included in
     14  * all copies or substantial portions of the Software.
     15  *
     16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     19  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
     20  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
     21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     22  * OTHER DEALINGS IN THE SOFTWARE.
     23  */
     24 
     25 #ifndef DRM_DP_DUAL_MODE_HELPER_H
     26 #define DRM_DP_DUAL_MODE_HELPER_H
     27 
     28 #include <linux/types.h>
     29 
     30 /*
     31  * Optional for type 1 DVI adaptors
     32  * Mandatory for type 1 HDMI and type 2 adaptors
     33  */
     34 #define DP_DUAL_MODE_HDMI_ID 0x00 /* 00-0f */
     35 #define  DP_DUAL_MODE_HDMI_ID_LEN 16
     36 /*
     37  * Optional for type 1 adaptors
     38  * Mandatory for type 2 adaptors
     39  */
     40 #define DP_DUAL_MODE_ADAPTOR_ID 0x10
     41 #define  DP_DUAL_MODE_REV_MASK 0x07
     42 #define  DP_DUAL_MODE_REV_TYPE2 0x00
     43 #define  DP_DUAL_MODE_TYPE_MASK 0xf0
     44 #define  DP_DUAL_MODE_TYPE_TYPE2 0xa0
     45 /* This field is marked reserved in dual mode spec, used in LSPCON */
     46 #define  DP_DUAL_MODE_TYPE_HAS_DPCD 0x08
     47 #define DP_DUAL_MODE_IEEE_OUI 0x11 /* 11-13*/
     48 #define  DP_DUAL_IEEE_OUI_LEN 3
     49 #define DP_DUAL_DEVICE_ID 0x14 /* 14-19 */
     50 #define  DP_DUAL_DEVICE_ID_LEN 6
     51 #define DP_DUAL_MODE_HARDWARE_REV 0x1a
     52 #define DP_DUAL_MODE_FIRMWARE_MAJOR_REV 0x1b
     53 #define DP_DUAL_MODE_FIRMWARE_MINOR_REV 0x1c
     54 #define DP_DUAL_MODE_MAX_TMDS_CLOCK 0x1d
     55 #define DP_DUAL_MODE_I2C_SPEED_CAP 0x1e
     56 #define DP_DUAL_MODE_TMDS_OEN 0x20
     57 #define  DP_DUAL_MODE_TMDS_DISABLE 0x01
     58 #define DP_DUAL_MODE_HDMI_PIN_CTRL 0x21
     59 #define  DP_DUAL_MODE_CEC_ENABLE 0x01
     60 #define DP_DUAL_MODE_I2C_SPEED_CTRL 0x22
     61 
     62 /* LSPCON specific registers, defined by MCA */
     63 #define DP_DUAL_MODE_LSPCON_MODE_CHANGE		0x40
     64 #define DP_DUAL_MODE_LSPCON_CURRENT_MODE		0x41
     65 #define  DP_DUAL_MODE_LSPCON_MODE_PCON			0x1
     66 
     67 struct i2c_adapter;
     68 
     69 ssize_t drm_dp_dual_mode_read(struct i2c_adapter *adapter,
     70 			      u8 offset, void *buffer, size_t size);
     71 ssize_t drm_dp_dual_mode_write(struct i2c_adapter *adapter,
     72 			       u8 offset, const void *buffer, size_t size);
     73 
     74 /**
     75  * enum drm_lspcon_mode
     76  * @DRM_LSPCON_MODE_INVALID: No LSPCON.
     77  * @DRM_LSPCON_MODE_LS: Level shifter mode of LSPCON
     78  *	which drives DP++ to HDMI 1.4 conversion.
     79  * @DRM_LSPCON_MODE_PCON: Protocol converter mode of LSPCON
     80  *	which drives DP++ to HDMI 2.0 active conversion.
     81  */
     82 enum drm_lspcon_mode {
     83 	DRM_LSPCON_MODE_INVALID,
     84 	DRM_LSPCON_MODE_LS,
     85 	DRM_LSPCON_MODE_PCON,
     86 };
     87 
     88 /**
     89  * enum drm_dp_dual_mode_type - Type of the DP dual mode adaptor
     90  * @DRM_DP_DUAL_MODE_NONE: No DP dual mode adaptor
     91  * @DRM_DP_DUAL_MODE_UNKNOWN: Could be either none or type 1 DVI adaptor
     92  * @DRM_DP_DUAL_MODE_TYPE1_DVI: Type 1 DVI adaptor
     93  * @DRM_DP_DUAL_MODE_TYPE1_HDMI: Type 1 HDMI adaptor
     94  * @DRM_DP_DUAL_MODE_TYPE2_DVI: Type 2 DVI adaptor
     95  * @DRM_DP_DUAL_MODE_TYPE2_HDMI: Type 2 HDMI adaptor
     96  * @DRM_DP_DUAL_MODE_LSPCON: Level shifter / protocol converter
     97  */
     98 enum drm_dp_dual_mode_type {
     99 	DRM_DP_DUAL_MODE_NONE,
    100 	DRM_DP_DUAL_MODE_UNKNOWN,
    101 	DRM_DP_DUAL_MODE_TYPE1_DVI,
    102 	DRM_DP_DUAL_MODE_TYPE1_HDMI,
    103 	DRM_DP_DUAL_MODE_TYPE2_DVI,
    104 	DRM_DP_DUAL_MODE_TYPE2_HDMI,
    105 	DRM_DP_DUAL_MODE_LSPCON,
    106 };
    107 
    108 enum drm_dp_dual_mode_type drm_dp_dual_mode_detect(struct i2c_adapter *adapter);
    109 int drm_dp_dual_mode_max_tmds_clock(enum drm_dp_dual_mode_type type,
    110 				    struct i2c_adapter *adapter);
    111 int drm_dp_dual_mode_get_tmds_output(enum drm_dp_dual_mode_type type,
    112 				     struct i2c_adapter *adapter, bool *enabled);
    113 int drm_dp_dual_mode_set_tmds_output(enum drm_dp_dual_mode_type type,
    114 				     struct i2c_adapter *adapter, bool enable);
    115 const char *drm_dp_get_dual_mode_type_name(enum drm_dp_dual_mode_type type);
    116 
    117 int drm_lspcon_get_mode(struct i2c_adapter *adapter,
    118 			enum drm_lspcon_mode *current_mode);
    119 int drm_lspcon_set_mode(struct i2c_adapter *adapter,
    120 			enum drm_lspcon_mode reqd_mode);
    121 #endif
    122