#include <linux/jiffies.h>
#include <linux/kthread.h>
#include <linux/device.h>
+#include <linux/extcon.h>
#include <linux/workqueue.h>
#include <linux/amlogic/media/vout/vout_notify.h>
{
struct am_hdmi_tx *am_hdmi = to_am_hdmi(connector);
+#ifdef CONFIG_EXTCON
+ enum drm_connector_status status;
+
+ if (am_hdmi->hpd_flag == 0 && hdmitx_hpd_hw_op(HPD_READ_HPD_GPIO)) {
+ status = connector_status_connected;
+ } else if (am_hdmi->hpd_flag == 0 && !hdmitx_hpd_hw_op(HPD_READ_HPD_GPIO)) {
+ status = connector_status_disconnected;
+ } else {
+ status = am_hdmi->hpd_flag == 1 ?
+ connector_status_connected : connector_status_disconnected;
+ }
+
+ extcon_set_state_sync(am_hdmi->edev, EXTCON_DISP_HDMI,
+ (status == connector_status_connected ?
+ true : false));
+#endif
+
/* HPD rising */
if (am_hdmi->hpd_flag == 1) {
DRM_INFO("connector_status_connected\n");
return &am_hdmi_info.connector;
}
+#ifdef CONFIG_EXTCON
+static const unsigned int am_hdmi_extcon_cable[] = {
+ EXTCON_DISP_HDMI,
+ EXTCON_NONE,
+};
+#endif
+
static int am_meson_hdmi_bind(struct device *dev,
struct device *master, void *data)
{
DRM_DEBUG_KMS("HDCP init failed, skipping.\n");
}
}
+
+#ifdef CONFIG_EXTCON
+ /* Initialize extcon device */
+ am_hdmi->edev = devm_extcon_dev_allocate(dev, am_hdmi_extcon_cable);
+ if (IS_ERR(am_hdmi->edev)) {
+ dev_err(dev, "failed to allocate memory for extcon\n");
+ return PTR_ERR(am_hdmi->edev);
+ }
+
+ ret = devm_extcon_dev_register(dev, am_hdmi->edev);
+ if (ret) {
+ dev_err(dev, "failed to register extcon device\n");
+ return ret;
+ }
+#endif
DRM_INFO("[%s] out\n", __func__);
return 0;
}
#define VIC_MAX_NUM 512
#define DRM_HDMITX_VER "20180705"
+#ifdef CONFIG_EXTCON
+struct extcon_dev;
+#endif
+
struct am_hdmi_data {
unsigned int vic;
u8 sink_is_hdmi;
unsigned int hdcp_stop_flag;/*turn off hdcp state machine*/
unsigned int hdcp_try_times;
struct task_struct *hdcp_work;
+
+#ifdef CONFIG_EXTCON
+ struct extcon_dev *edev;
+#endif
};
#define to_am_hdmi(x) container_of(x, struct am_hdmi_tx, x)