Home | History | Annotate | Line # | Download | only in inc
      1 /*	$NetBSD: dc_link_ddc.h,v 1.2 2021/12/18 23:45:05 riastradh Exp $	*/
      2 
      3 /*
      4  * Copyright 2012-15 Advanced Micro Devices, Inc.
      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  * Authors: AMD
     25  *
     26  */
     27 
     28 #ifndef __DAL_DDC_SERVICE_H__
     29 #define __DAL_DDC_SERVICE_H__
     30 
     31 #include "include/ddc_service_types.h"
     32 #include "include/i2caux_interface.h"
     33 
     34 #define EDID_SEGMENT_SIZE 256
     35 
     36 /* Address range from 0x00 to 0x1F.*/
     37 #define DP_ADAPTOR_TYPE2_SIZE 0x20
     38 #define DP_ADAPTOR_TYPE2_REG_ID 0x10
     39 #define DP_ADAPTOR_TYPE2_REG_MAX_TMDS_CLK 0x1D
     40 /* Identifies adaptor as Dual-mode adaptor */
     41 #define DP_ADAPTOR_TYPE2_ID 0xA0
     42 /* MHz*/
     43 #define DP_ADAPTOR_TYPE2_MAX_TMDS_CLK 600
     44 /* MHz*/
     45 #define DP_ADAPTOR_TYPE2_MIN_TMDS_CLK 25
     46 /* kHZ*/
     47 #define DP_ADAPTOR_DVI_MAX_TMDS_CLK 165000
     48 /* kHZ*/
     49 #define DP_ADAPTOR_HDMI_SAFE_MAX_TMDS_CLK 165000
     50 
     51 #define DDC_I2C_COMMAND_ENGINE I2C_COMMAND_ENGINE_SW
     52 
     53 struct ddc_service;
     54 struct graphics_object_id;
     55 enum ddc_result;
     56 struct av_sync_data;
     57 struct dp_receiver_id_info;
     58 
     59 struct i2c_payloads;
     60 struct aux_payloads;
     61 
     62 void dal_ddc_i2c_payloads_add(
     63 		struct i2c_payloads *payloads,
     64 		uint32_t address,
     65 		uint32_t len,
     66 		uint8_t *data,
     67 		bool write);
     68 
     69 struct ddc_service_init_data {
     70 	struct graphics_object_id id;
     71 	struct dc_context *ctx;
     72 	struct dc_link *link;
     73 };
     74 
     75 struct ddc_service *dal_ddc_service_create(
     76 		struct ddc_service_init_data *ddc_init_data);
     77 
     78 void dal_ddc_service_destroy(struct ddc_service **ddc);
     79 
     80 enum ddc_service_type dal_ddc_service_get_type(struct ddc_service *ddc);
     81 
     82 void dal_ddc_service_set_transaction_type(
     83 		struct ddc_service *ddc,
     84 		enum ddc_transaction_type type);
     85 
     86 bool dal_ddc_service_is_in_aux_transaction_mode(struct ddc_service *ddc);
     87 
     88 void dal_ddc_service_i2c_query_dp_dual_mode_adaptor(
     89 		struct ddc_service *ddc,
     90 		struct display_sink_capability *sink_cap);
     91 
     92 bool dal_ddc_service_query_ddc_data(
     93 		struct ddc_service *ddc,
     94 		uint32_t address,
     95 		uint8_t *write_buf,
     96 		uint32_t write_size,
     97 		uint8_t *read_buf,
     98 		uint32_t read_size);
     99 
    100 bool dal_ddc_submit_aux_command(struct ddc_service *ddc,
    101 		struct aux_payload *payload);
    102 
    103 int dc_link_aux_transfer_raw(struct ddc_service *ddc,
    104 		struct aux_payload *payload,
    105 		enum aux_channel_operation_result *operation_result);
    106 
    107 bool dc_link_aux_transfer_with_retries(struct ddc_service *ddc,
    108 		struct aux_payload *payload);
    109 
    110 uint32_t dc_link_aux_configure_timeout(struct ddc_service *ddc,
    111 		uint32_t timeout);
    112 
    113 void dal_ddc_service_write_scdc_data(
    114 		struct ddc_service *ddc_service,
    115 		uint32_t pix_clk,
    116 		bool lte_340_scramble);
    117 
    118 void dal_ddc_service_read_scdc_data(
    119 		struct ddc_service *ddc_service);
    120 
    121 void ddc_service_set_dongle_type(struct ddc_service *ddc,
    122 		enum display_dongle_type dongle_type);
    123 
    124 void dal_ddc_service_set_ddc_pin(
    125 		struct ddc_service *ddc_service,
    126 		struct ddc *ddc);
    127 
    128 struct ddc *dal_ddc_service_get_ddc_pin(struct ddc_service *ddc_service);
    129 
    130 uint32_t get_defer_delay(struct ddc_service *ddc);
    131 
    132 #endif /* __DAL_DDC_SERVICE_H__ */
    133 
    134