#include <linux/module.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/debugfs.h>
#include <linux/component.h>
#include <linux/of_irq.h>
#include <linux/phy/phy.h>
#include <linux/delay.h>
#include <drm/display/drm_dp_aux_bus.h>
#include <drm/drm_edid.h>
#include "msm_drv.h"
#include "msm_kms.h"
#include "dp_ctrl.h"
#include "dp_catalog.h"
#include "dp_aux.h"
#include "dp_reg.h"
#include "dp_link.h"
#include "dp_panel.h"
#include "dp_display.h"
#include "dp_drm.h"
#include "dp_audio.h"
#include "dp_debug.h"
static bool psr_enabled = …;
module_param(psr_enabled, bool, 0);
MODULE_PARM_DESC(…) …;
#define HPD_STRING_SIZE …
enum { … };
enum { … };
enum { … };
#define EVENT_TIMEOUT …
#define DP_EVENT_Q_MAX …
#define DP_TIMEOUT_NONE …
#define WAIT_FOR_RESUME_TIMEOUT_JIFFIES …
struct dp_event { … };
struct dp_display_private { … };
struct msm_dp_desc { … };
static const struct msm_dp_desc sc7180_dp_descs[] = …;
static const struct msm_dp_desc sc7280_dp_descs[] = …;
static const struct msm_dp_desc sc8180x_dp_descs[] = …;
static const struct msm_dp_desc sc8280xp_dp_descs[] = …;
static const struct msm_dp_desc sm8650_dp_descs[] = …;
static const struct msm_dp_desc x1e80100_dp_descs[] = …;
static const struct of_device_id dp_dt_match[] = …;
static struct dp_display_private *dev_get_dp_display_private(struct device *dev)
{ … }
static int dp_add_event(struct dp_display_private *dp_priv, u32 event,
u32 data, u32 delay)
{ … }
static int dp_del_event(struct dp_display_private *dp_priv, u32 event)
{ … }
void dp_display_signal_audio_start(struct msm_dp *dp_display)
{ … }
void dp_display_signal_audio_complete(struct msm_dp *dp_display)
{ … }
static int dp_hpd_event_thread_start(struct dp_display_private *dp_priv);
static int dp_display_bind(struct device *dev, struct device *master,
void *data)
{ … }
static void dp_display_unbind(struct device *dev, struct device *master,
void *data)
{ … }
static const struct component_ops dp_display_comp_ops = …;
static void dp_display_send_hpd_event(struct msm_dp *dp_display)
{ … }
static int dp_display_send_hpd_notification(struct dp_display_private *dp,
bool hpd)
{ … }
static int dp_display_process_hpd_high(struct dp_display_private *dp)
{ … }
static void dp_display_host_phy_init(struct dp_display_private *dp)
{ … }
static void dp_display_host_phy_exit(struct dp_display_private *dp)
{ … }
static void dp_display_host_init(struct dp_display_private *dp)
{ … }
static void dp_display_host_deinit(struct dp_display_private *dp)
{ … }
static int dp_display_usbpd_configure_cb(struct device *dev)
{ … }
static int dp_display_notify_disconnect(struct device *dev)
{ … }
static void dp_display_handle_video_request(struct dp_display_private *dp)
{ … }
static int dp_display_handle_port_status_changed(struct dp_display_private *dp)
{ … }
static int dp_display_handle_irq_hpd(struct dp_display_private *dp)
{ … }
static int dp_display_usbpd_attention_cb(struct device *dev)
{ … }
static int dp_hpd_plug_handle(struct dp_display_private *dp, u32 data)
{
u32 state;
int ret;
struct platform_device *pdev = dp->dp_display.pdev;
dp_aux_enable_xfers(dp->aux, true);
mutex_lock(&dp->event_mutex);
state = dp->hpd_state;
drm_dbg_dp(dp->drm_dev, "Before, type=%d hpd_state=%d\n",
dp->dp_display.connector_type, state);
if (state == ST_DISPLAY_OFF) {
mutex_unlock(&dp->event_mutex);
return 0;
}
if (state == ST_MAINLINK_READY || state == ST_CONNECTED) {
mutex_unlock(&dp->event_mutex);
return 0;
}
if (state == ST_DISCONNECT_PENDING) {
dp_add_event(dp, EV_HPD_PLUG_INT, 0, 1);
mutex_unlock(&dp->event_mutex);
return 0;
}
ret = pm_runtime_resume_and_get(&pdev->dev);
if (ret) {
DRM_ERROR("failed to pm_runtime_resume\n");
mutex_unlock(&dp->event_mutex);
return ret;
}
ret = dp_display_usbpd_configure_cb(&pdev->dev);
if (ret) {
dp->hpd_state = ST_DISCONNECTED;
pm_runtime_put_sync(&pdev->dev);
} else {
dp->hpd_state = ST_MAINLINK_READY;
}
drm_dbg_dp(dp->drm_dev, "After, type=%d hpd_state=%d\n",
dp->dp_display.connector_type, state);
mutex_unlock(&dp->event_mutex);
return 0;
};
static void dp_display_handle_plugged_change(struct msm_dp *dp_display,
bool plugged)
{ … }
static int dp_hpd_unplug_handle(struct dp_display_private *dp, u32 data)
{ … }
static int dp_irq_hpd_handle(struct dp_display_private *dp, u32 data)
{ … }
static void dp_display_deinit_sub_modules(struct dp_display_private *dp)
{ … }
static int dp_init_sub_modules(struct dp_display_private *dp)
{ … }
static int dp_display_set_mode(struct msm_dp *dp_display,
struct dp_display_mode *mode)
{ … }
static int dp_display_enable(struct dp_display_private *dp, bool force_link_train)
{ … }
static int dp_display_post_enable(struct msm_dp *dp_display)
{ … }
static int dp_display_disable(struct dp_display_private *dp)
{ … }
int dp_display_set_plugged_cb(struct msm_dp *dp_display,
hdmi_codec_plugged_cb fn, struct device *codec_dev)
{ … }
enum drm_mode_status dp_bridge_mode_valid(struct drm_bridge *bridge,
const struct drm_display_info *info,
const struct drm_display_mode *mode)
{ … }
int dp_display_get_modes(struct msm_dp *dp)
{ … }
bool dp_display_check_video_test(struct msm_dp *dp)
{ … }
int dp_display_get_test_bpp(struct msm_dp *dp)
{ … }
void msm_dp_snapshot(struct msm_disp_state *disp_state, struct msm_dp *dp)
{ … }
void dp_display_set_psr(struct msm_dp *dp_display, bool enter)
{ … }
static int hpd_event_thread(void *data)
{ … }
static int dp_hpd_event_thread_start(struct dp_display_private *dp_priv)
{ … }
static irqreturn_t dp_display_irq_handler(int irq, void *dev_id)
{ … }
static int dp_display_request_irq(struct dp_display_private *dp)
{ … }
static const struct msm_dp_desc *dp_display_get_desc(struct platform_device *pdev)
{ … }
static int dp_display_probe_tail(struct device *dev)
{ … }
static int dp_auxbus_done_probe(struct drm_dp_aux *aux)
{ … }
static int dp_display_get_connector_type(struct platform_device *pdev,
const struct msm_dp_desc *desc)
{ … }
static int dp_display_probe(struct platform_device *pdev)
{ … }
static void dp_display_remove(struct platform_device *pdev)
{ … }
static int dp_pm_runtime_suspend(struct device *dev)
{ … }
static int dp_pm_runtime_resume(struct device *dev)
{ … }
static const struct dev_pm_ops dp_pm_ops = …;
static struct platform_driver dp_display_driver = …;
int __init msm_dp_register(void)
{ … }
void __exit msm_dp_unregister(void)
{ … }
bool msm_dp_is_yuv_420_enabled(const struct msm_dp *dp_display,
const struct drm_display_mode *mode)
{ … }
bool msm_dp_needs_periph_flush(const struct msm_dp *dp_display,
const struct drm_display_mode *mode)
{ … }
bool msm_dp_wide_bus_available(const struct msm_dp *dp_display)
{ … }
void dp_display_debugfs_init(struct msm_dp *dp_display, struct dentry *root, bool is_edp)
{ … }
int msm_dp_modeset_init(struct msm_dp *dp_display, struct drm_device *dev,
struct drm_encoder *encoder, bool yuv_supported)
{ … }
void dp_bridge_atomic_enable(struct drm_bridge *drm_bridge,
struct drm_bridge_state *old_bridge_state)
{ … }
void dp_bridge_atomic_disable(struct drm_bridge *drm_bridge,
struct drm_bridge_state *old_bridge_state)
{ … }
void dp_bridge_atomic_post_disable(struct drm_bridge *drm_bridge,
struct drm_bridge_state *old_bridge_state)
{ … }
void dp_bridge_mode_set(struct drm_bridge *drm_bridge,
const struct drm_display_mode *mode,
const struct drm_display_mode *adjusted_mode)
{ … }
void dp_bridge_hpd_enable(struct drm_bridge *bridge)
{ … }
void dp_bridge_hpd_disable(struct drm_bridge *bridge)
{ … }
void dp_bridge_hpd_notify(struct drm_bridge *bridge,
enum drm_connector_status status)
{ … }