linux/drivers/gpu/drm/msm/dp/dp_link.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0-only */
   2/*
   3 * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
   4 */
   5
   6#ifndef _DP_LINK_H_
   7#define _DP_LINK_H_
   8
   9#include "dp_aux.h"
  10
  11#define DS_PORT_STATUS_CHANGED 0x200
  12#define DP_TEST_BIT_DEPTH_UNKNOWN 0xFFFFFFFF
  13#define DP_LINK_CAP_ENHANCED_FRAMING (1 << 0)
  14
  15struct dp_link_info {
  16        unsigned char revision;
  17        unsigned int rate;
  18        unsigned int num_lanes;
  19        unsigned long capabilities;
  20};
  21
  22enum dp_link_voltage_level {
  23        DP_TRAIN_VOLTAGE_SWING_LVL_0    = 0,
  24        DP_TRAIN_VOLTAGE_SWING_LVL_1    = 1,
  25        DP_TRAIN_VOLTAGE_SWING_LVL_2    = 2,
  26        DP_TRAIN_VOLTAGE_SWING_MAX      = DP_TRAIN_VOLTAGE_SWING_LVL_2,
  27};
  28
  29enum dp_link_preemaphasis_level {
  30        DP_TRAIN_PRE_EMPHASIS_LVL_0     = 0,
  31        DP_TRAIN_PRE_EMPHASIS_LVL_1     = 1,
  32        DP_TRAIN_PRE_EMPHASIS_LVL_2     = 2,
  33        DP_TRAIN_PRE_EMPHASIS_MAX       = DP_TRAIN_PRE_EMPHASIS_LVL_2,
  34};
  35
  36struct dp_link_test_video {
  37        u32 test_video_pattern;
  38        u32 test_bit_depth;
  39        u32 test_dyn_range;
  40        u32 test_h_total;
  41        u32 test_v_total;
  42        u32 test_h_start;
  43        u32 test_v_start;
  44        u32 test_hsync_pol;
  45        u32 test_hsync_width;
  46        u32 test_vsync_pol;
  47        u32 test_vsync_width;
  48        u32 test_h_width;
  49        u32 test_v_height;
  50        u32 test_rr_d;
  51        u32 test_rr_n;
  52};
  53
  54struct dp_link_test_audio {
  55        u32 test_audio_sampling_rate;
  56        u32 test_audio_channel_count;
  57        u32 test_audio_pattern_type;
  58        u32 test_audio_period_ch_1;
  59        u32 test_audio_period_ch_2;
  60        u32 test_audio_period_ch_3;
  61        u32 test_audio_period_ch_4;
  62        u32 test_audio_period_ch_5;
  63        u32 test_audio_period_ch_6;
  64        u32 test_audio_period_ch_7;
  65        u32 test_audio_period_ch_8;
  66};
  67
  68struct dp_link_phy_params {
  69        u32 phy_test_pattern_sel;
  70        u8 v_level;
  71        u8 p_level;
  72};
  73
  74struct dp_link {
  75        u32 sink_request;
  76        u32 test_response;
  77        bool psm_enabled;
  78
  79        u8 sink_count;
  80        struct dp_link_test_video test_video;
  81        struct dp_link_test_audio test_audio;
  82        struct dp_link_phy_params phy_params;
  83        struct dp_link_info link_params;
  84};
  85
  86/**
  87 * mdss_dp_test_bit_depth_to_bpp() - convert test bit depth to bpp
  88 * @tbd: test bit depth
  89 *
  90 * Returns the bits per pixel (bpp) to be used corresponding to the
  91 * git bit depth value. This function assumes that bit depth has
  92 * already been validated.
  93 */
  94static inline u32 dp_link_bit_depth_to_bpp(u32 tbd)
  95{
  96        /*
  97         * Few simplistic rules and assumptions made here:
  98         *    1. Bit depth is per color component
  99         *    2. If bit depth is unknown return 0
 100         *    3. Assume 3 color components
 101         */
 102        switch (tbd) {
 103        case DP_TEST_BIT_DEPTH_6:
 104                return 18;
 105        case DP_TEST_BIT_DEPTH_8:
 106                return 24;
 107        case DP_TEST_BIT_DEPTH_10:
 108                return 30;
 109        case DP_TEST_BIT_DEPTH_UNKNOWN:
 110        default:
 111                return 0;
 112        }
 113}
 114
 115/**
 116 * dp_test_bit_depth_to_bpc() - convert test bit depth to bpc
 117 * @tbd: test bit depth
 118 *
 119 * Returns the bits per comp (bpc) to be used corresponding to the
 120 * bit depth value. This function assumes that bit depth has
 121 * already been validated.
 122 */
 123static inline u32 dp_link_bit_depth_to_bpc(u32 tbd)
 124{
 125        switch (tbd) {
 126        case DP_TEST_BIT_DEPTH_6:
 127                return 6;
 128        case DP_TEST_BIT_DEPTH_8:
 129                return 8;
 130        case DP_TEST_BIT_DEPTH_10:
 131                return 10;
 132        case DP_TEST_BIT_DEPTH_UNKNOWN:
 133        default:
 134                return 0;
 135        }
 136}
 137
 138void dp_link_reset_phy_params_vx_px(struct dp_link *dp_link);
 139u32 dp_link_get_test_bits_depth(struct dp_link *dp_link, u32 bpp);
 140int dp_link_process_request(struct dp_link *dp_link);
 141int dp_link_get_colorimetry_config(struct dp_link *dp_link);
 142int dp_link_adjust_levels(struct dp_link *dp_link, u8 *link_status);
 143bool dp_link_send_test_response(struct dp_link *dp_link);
 144int dp_link_psm_config(struct dp_link *dp_link,
 145                struct dp_link_info *link_info, bool enable);
 146bool dp_link_send_edid_checksum(struct dp_link *dp_link, u8 checksum);
 147
 148/**
 149 * dp_link_get() - get the functionalities of dp test module
 150 *
 151 *
 152 * return: a pointer to dp_link struct
 153 */
 154struct dp_link *dp_link_get(struct device *dev, struct drm_dp_aux *aux);
 155
 156#endif /* _DP_LINK_H_ */
 157