Rishabh Bhatnagar | e9a05bb | 2018-12-10 11:09:45 -0800 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Samantha Tran | 1eae18f | 2018-10-15 14:04:01 -0700 | [diff] [blame] | 2 | /* |
Samantha Tran | 052d69b | 2019-01-03 14:08:30 -0800 | [diff] [blame] | 3 | * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. |
Samantha Tran | 1eae18f | 2018-10-15 14:04:01 -0700 | [diff] [blame] | 4 | */ |
| 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 Pinapala | 10ffbfa | 2019-01-21 11:02:56 -0800 | [diff] [blame] | 15 | #define DP_MST_SIM_MAX_PORTS 2 |
| 16 | |
| 17 | enum dp_drv_state { |
| 18 | PM_DEFAULT, |
| 19 | PM_SUSPEND, |
| 20 | }; |
| 21 | |
| 22 | struct dp_mst_hpd_info { |
Samantha Tran | 1eae18f | 2018-10-15 14:04:01 -0700 | [diff] [blame] | 23 | bool mst_protocol; |
Satya Rama Aditya Pinapala | 10ffbfa | 2019-01-21 11:02:56 -0800 | [diff] [blame] | 24 | bool mst_hpd_sim; |
| 25 | u32 mst_port_cnt; |
Samantha Tran | 1eae18f | 2018-10-15 14:04:01 -0700 | [diff] [blame] | 26 | u8 *edid; |
| 27 | }; |
| 28 | |
| 29 | struct dp_mst_drm_cbs { |
| 30 | void (*hpd)(void *display, bool hpd_status, |
Satya Rama Aditya Pinapala | 10ffbfa | 2019-01-21 11:02:56 -0800 | [diff] [blame] | 31 | 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 Tran | 1eae18f | 2018-10-15 14:04:01 -0700 | [diff] [blame] | 35 | }; |
| 36 | |
| 37 | struct dp_mst_drm_install_info { |
| 38 | void *dp_mst_prv_info; |
| 39 | const struct dp_mst_drm_cbs *cbs; |
| 40 | }; |
| 41 | |
| 42 | struct 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 | |
| 49 | struct 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 Pinapala | 10ffbfa | 2019-01-21 11:02:56 -0800 | [diff] [blame] | 59 | enum drm_connector_status state; |
Samantha Tran | 1eae18f | 2018-10-15 14:04:01 -0700 | [diff] [blame] | 60 | }; |
| 61 | |
| 62 | struct 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 Pinapala | 10ffbfa | 2019-01-21 11:02:56 -0800 | [diff] [blame] | 68 | bool is_mst_supported; |
Samantha Tran | 1eae18f | 2018-10-15 14:04:01 -0700 | [diff] [blame] | 69 | 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 Cohen | 3ad0888 | 2019-02-01 19:05:41 -0500 | [diff] [blame] | 90 | struct drm_msm_ext_hdr_metadata *hdr_meta, |
| 91 | bool dhdr_update); |
Samantha Tran | 1eae18f | 2018-10-15 14:04:01 -0700 | [diff] [blame] | 92 | 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 Pinapala | 10ffbfa | 2019-01-21 11:02:56 -0800 | [diff] [blame] | 103 | int (*mst_get_connector_info)(struct dp_display *dp_display, |
| 104 | struct drm_connector *connector, |
| 105 | struct dp_mst_connector *mst_conn); |
Samantha Tran | 1eae18f | 2018-10-15 14:04:01 -0700 | [diff] [blame] | 106 | 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 Pinapala | 10ffbfa | 2019-01-21 11:02:56 -0800 | [diff] [blame] | 113 | int (*update_pps)(struct dp_display *dp_display, |
| 114 | struct drm_connector *connector, char *pps_cmd); |
Samantha Tran | 1eae18f | 2018-10-15 14:04:01 -0700 | [diff] [blame] | 115 | }; |
| 116 | |
Samantha Tran | 052d69b | 2019-01-03 14:08:30 -0800 | [diff] [blame] | 117 | #ifdef CONFIG_DRM_MSM_DP |
Samantha Tran | 1eae18f | 2018-10-15 14:04:01 -0700 | [diff] [blame] | 118 | int dp_display_get_num_of_displays(void); |
| 119 | int dp_display_get_displays(void **displays, int count); |
| 120 | int dp_display_get_num_of_streams(void); |
Samantha Tran | 052d69b | 2019-01-03 14:08:30 -0800 | [diff] [blame] | 121 | #else |
| 122 | static inline int dp_display_get_num_of_displays(void) |
| 123 | { |
| 124 | return 0; |
| 125 | } |
| 126 | static inline int dp_display_get_displays(void **displays, int count) |
| 127 | { |
| 128 | return 0; |
| 129 | } |
| 130 | static inline int dp_display_get_num_of_streams(void) |
| 131 | { |
| 132 | return 0; |
| 133 | } |
Satya Rama Aditya Pinapala | 10ffbfa | 2019-01-21 11:02:56 -0800 | [diff] [blame] | 134 | static inline int dp_connector_update_pps(struct drm_connector *connector, |
| 135 | char *pps_cmd, void *display) |
| 136 | { |
| 137 | return 0; |
| 138 | } |
Samantha Tran | 052d69b | 2019-01-03 14:08:30 -0800 | [diff] [blame] | 139 | #endif |
Samantha Tran | 1eae18f | 2018-10-15 14:04:01 -0700 | [diff] [blame] | 140 | #endif /* _DP_DISPLAY_H_ */ |