blob: 410cee75959ee65bea73d2c55ac57dedc7a7b900 [file] [log] [blame]
Rishabh Bhatnagare9a05bb2018-12-10 11:09:45 -08001/* SPDX-License-Identifier: GPL-2.0-only */
Samantha Tran1eae18f2018-10-15 14:04:01 -07002/*
Samantha Tran052d69b2019-01-03 14:08:30 -08003 * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
Samantha Tran1eae18f2018-10-15 14:04:01 -07004 */
5
6#ifndef _DP_DISPLAY_H_
7#define _DP_DISPLAY_H_
8
9#include <linux/list.h>
10#include <drm/drmP.h>
11#include <drm/msm_drm.h>
12
13#include "dp_panel.h"
14
Satya Rama Aditya Pinapala10ffbfa2019-01-21 11:02:56 -080015#define DP_MST_SIM_MAX_PORTS 2
16
17enum dp_drv_state {
18 PM_DEFAULT,
19 PM_SUSPEND,
20};
21
22struct dp_mst_hpd_info {
Samantha Tran1eae18f2018-10-15 14:04:01 -070023 bool mst_protocol;
Satya Rama Aditya Pinapala10ffbfa2019-01-21 11:02:56 -080024 bool mst_hpd_sim;
25 u32 mst_port_cnt;
Samantha Tran1eae18f2018-10-15 14:04:01 -070026 u8 *edid;
27};
28
29struct dp_mst_drm_cbs {
30 void (*hpd)(void *display, bool hpd_status,
Satya Rama Aditya Pinapala10ffbfa2019-01-21 11:02:56 -080031 struct dp_mst_hpd_info *info);
32 void (*hpd_irq)(void *display, struct dp_mst_hpd_info *info);
33 void (*set_drv_state)(void *dp_display,
34 enum dp_drv_state mst_state);
Samantha Tran1eae18f2018-10-15 14:04:01 -070035};
36
37struct dp_mst_drm_install_info {
38 void *dp_mst_prv_info;
39 const struct dp_mst_drm_cbs *cbs;
40};
41
42struct dp_mst_caps {
43 bool has_mst;
44 u32 max_streams_supported;
45 u32 max_dpcd_transaction_bytes;
46 struct drm_dp_aux *drm_aux;
47};
48
49struct dp_mst_connector {
50 bool debug_en;
51 int con_id;
52 int hdisplay;
53 int vdisplay;
54 int vrefresh;
55 int aspect_ratio;
56 struct drm_connector *conn;
57 struct mutex lock;
58 struct list_head list;
Satya Rama Aditya Pinapala10ffbfa2019-01-21 11:02:56 -080059 enum drm_connector_status state;
Samantha Tran1eae18f2018-10-15 14:04:01 -070060};
61
62struct dp_display {
63 struct drm_device *drm_dev;
64 struct dp_bridge *bridge;
65 struct drm_connector *base_connector;
66 void *base_dp_panel;
67 bool is_sst_connected;
Satya Rama Aditya Pinapala10ffbfa2019-01-21 11:02:56 -080068 bool is_mst_supported;
Samantha Tran1eae18f2018-10-15 14:04:01 -070069 u32 max_pclk_khz;
70 void *dp_mst_prv_info;
71
72 int (*enable)(struct dp_display *dp_display, void *panel);
73 int (*post_enable)(struct dp_display *dp_display, void *panel);
74
75 int (*pre_disable)(struct dp_display *dp_display, void *panel);
76 int (*disable)(struct dp_display *dp_display, void *panel);
77
78 int (*set_mode)(struct dp_display *dp_display, void *panel,
79 struct dp_display_mode *mode);
80 enum drm_mode_status (*validate_mode)(struct dp_display *dp_display,
81 void *panel, struct drm_display_mode *mode);
82 int (*get_modes)(struct dp_display *dp_display, void *panel,
83 struct dp_display_mode *dp_mode);
84 int (*prepare)(struct dp_display *dp_display, void *panel);
85 int (*unprepare)(struct dp_display *dp_display, void *panel);
86 int (*request_irq)(struct dp_display *dp_display);
87 struct dp_debug *(*get_debug)(struct dp_display *dp_display);
88 void (*post_open)(struct dp_display *dp_display);
89 int (*config_hdr)(struct dp_display *dp_display, void *panel,
Steve Cohen3ad08882019-02-01 19:05:41 -050090 struct drm_msm_ext_hdr_metadata *hdr_meta,
91 bool dhdr_update);
Samantha Tran1eae18f2018-10-15 14:04:01 -070092 int (*post_init)(struct dp_display *dp_display);
93 int (*mst_install)(struct dp_display *dp_display,
94 struct dp_mst_drm_install_info *mst_install_info);
95 int (*mst_uninstall)(struct dp_display *dp_display);
96 int (*mst_connector_install)(struct dp_display *dp_display,
97 struct drm_connector *connector);
98 int (*mst_connector_uninstall)(struct dp_display *dp_display,
99 struct drm_connector *connector);
100 int (*mst_connector_update_edid)(struct dp_display *dp_display,
101 struct drm_connector *connector,
102 struct edid *edid);
Satya Rama Aditya Pinapala10ffbfa2019-01-21 11:02:56 -0800103 int (*mst_get_connector_info)(struct dp_display *dp_display,
104 struct drm_connector *connector,
105 struct dp_mst_connector *mst_conn);
Samantha Tran1eae18f2018-10-15 14:04:01 -0700106 int (*get_mst_caps)(struct dp_display *dp_display,
107 struct dp_mst_caps *mst_caps);
108 int (*set_stream_info)(struct dp_display *dp_display, void *panel,
109 u32 strm_id, u32 start_slot, u32 num_slots, u32 pbn);
110 void (*convert_to_dp_mode)(struct dp_display *dp_display, void *panel,
111 const struct drm_display_mode *drm_mode,
112 struct dp_display_mode *dp_mode);
Satya Rama Aditya Pinapala10ffbfa2019-01-21 11:02:56 -0800113 int (*update_pps)(struct dp_display *dp_display,
114 struct drm_connector *connector, char *pps_cmd);
Samantha Tran1eae18f2018-10-15 14:04:01 -0700115};
116
Samantha Tran052d69b2019-01-03 14:08:30 -0800117#ifdef CONFIG_DRM_MSM_DP
Samantha Tran1eae18f2018-10-15 14:04:01 -0700118int dp_display_get_num_of_displays(void);
119int dp_display_get_displays(void **displays, int count);
120int dp_display_get_num_of_streams(void);
Samantha Tran052d69b2019-01-03 14:08:30 -0800121#else
122static inline int dp_display_get_num_of_displays(void)
123{
124 return 0;
125}
126static inline int dp_display_get_displays(void **displays, int count)
127{
128 return 0;
129}
130static inline int dp_display_get_num_of_streams(void)
131{
132 return 0;
133}
Satya Rama Aditya Pinapala10ffbfa2019-01-21 11:02:56 -0800134static inline int dp_connector_update_pps(struct drm_connector *connector,
135 char *pps_cmd, void *display)
136{
137 return 0;
138}
Samantha Tran052d69b2019-01-03 14:08:30 -0800139#endif
Samantha Tran1eae18f2018-10-15 14:04:01 -0700140#endif /* _DP_DISPLAY_H_ */