Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
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_PANEL_H_
7#define _DP_PANEL_H_
8
9#include <drm/msm_drm.h>
10
11#include "dp_aux.h"
12#include "dp_link.h"
13#include "dp_hpd.h"
14
15struct edid;
16
17#define DPRX_EXTENDED_DPCD_FIELD 0x2200
18
19#define DP_DOWNSTREAM_PORTS 4
20#define DP_DOWNSTREAM_CAP_SIZE 4
21
22struct dp_display_mode {
23 struct drm_display_mode drm_mode;
24 u32 capabilities;
25 u32 bpp;
26 u32 h_active_low;
27 u32 v_active_low;
28};
29
30struct dp_panel_in {
31 struct device *dev;
32 struct drm_dp_aux *aux;
33 struct dp_link *link;
34 struct dp_catalog *catalog;
35};
36
37struct dp_panel_psr {
38 u8 version;
39 u8 capabilities;
40};
41
42struct dp_panel {
43 /* dpcd raw data */
44 u8 dpcd[DP_RECEIVER_CAP_SIZE + 1];
45 u8 ds_cap_info[DP_DOWNSTREAM_PORTS * DP_DOWNSTREAM_CAP_SIZE];
46 u32 ds_port_cnt;
47 u32 dfp_present;
48
49 struct dp_link_info link_info;
50 struct drm_dp_desc desc;
51 struct edid *edid;
52 struct drm_connector *connector;
53 struct dp_display_mode dp_mode;
54 struct dp_panel_psr psr_cap;
55 bool video_test;
56
57 u32 vic;
58 u32 max_dp_lanes;
59 u32 max_dp_link_rate;
60
61 u32 max_bw_code;
62};
63
64int dp_panel_init_panel_info(struct dp_panel *dp_panel);
65int dp_panel_deinit(struct dp_panel *dp_panel);
66int dp_panel_timing_cfg(struct dp_panel *dp_panel);
67void dp_panel_dump_regs(struct dp_panel *dp_panel);
68int dp_panel_read_sink_caps(struct dp_panel *dp_panel,
69 struct drm_connector *connector);
70u32 dp_panel_get_mode_bpp(struct dp_panel *dp_panel, u32 mode_max_bpp,
71 u32 mode_pclk_khz);
72int dp_panel_get_modes(struct dp_panel *dp_panel,
73 struct drm_connector *connector);
74void dp_panel_handle_sink_request(struct dp_panel *dp_panel);
75void dp_panel_tpg_config(struct dp_panel *dp_panel, bool enable);
76
77/**
78 * is_link_rate_valid() - validates the link rate
79 * @lane_rate: link rate requested by the sink
80 *
81 * Returns true if the requested link rate is supported.
82 */
83static inline bool is_link_rate_valid(u32 bw_code)
84{
85 return (bw_code == DP_LINK_BW_1_62 ||
86 bw_code == DP_LINK_BW_2_7 ||
87 bw_code == DP_LINK_BW_5_4 ||
88 bw_code == DP_LINK_BW_8_1);
89}
90
91/**
92 * dp_link_is_lane_count_valid() - validates the lane count
93 * @lane_count: lane count requested by the sink
94 *
95 * Returns true if the requested lane count is supported.
96 */
97static inline bool is_lane_count_valid(u32 lane_count)
98{
99 return (lane_count == 1 ||
100 lane_count == 2 ||
101 lane_count == 4);
102}
103
104struct dp_panel *dp_panel_get(struct dp_panel_in *in);
105void dp_panel_put(struct dp_panel *dp_panel);
106#endif /* _DP_PANEL_H_ */