[PATCH 20/21] usb: otg: add support for MHL-USB coexistence

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Hao Wu <hao.wu@xxxxxxxxx>

MHL (Mobile High-Definition Link) shares the same port with USB OTG
to connect mobile device to HDMI and MHL enabled external devices
such as HDTVs. Communication with USB OTG drivers is a must to
decide who (MHL or USB OTG) takes control of the USB OTG port.

This patch adds members to otg data structure to support MHL.

Signed-off-by: Hao Wu <hao.wu@xxxxxxxxx>
---
 include/linux/usb/otg.h |   71 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 71 insertions(+), 0 deletions(-)

diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
index 0a5b371..12b0495 100644
--- a/include/linux/usb/otg.h
+++ b/include/linux/usb/otg.h
@@ -33,6 +33,9 @@ enum usb_otg_state {
 	OTG_STATE_A_PERIPHERAL,
 	OTG_STATE_A_WAIT_VFALL,
 	OTG_STATE_A_VBUS_ERR,
+
+	/* MHL mode */
+	OTG_STATE_MHL,
 };
 
 enum usb_xceiv_events {
@@ -66,6 +69,7 @@ struct otg_transceiver {
 
 	u8			default_a;
 	enum usb_otg_state	state;
+	struct mutex		state_mutex;
 
 	struct usb_bus		*host;
 	struct usb_gadget	*gadget;
@@ -110,6 +114,16 @@ struct otg_transceiver {
 	/* start or continue HNP role switch */
 	int	(*start_hnp)(struct otg_transceiver *otg);
 
+	/* enter/exit MHL mode */
+	int	(*enter_mhl_mode)(struct otg_transceiver *otg);
+	int	(*exit_mhl_mode)(struct otg_transceiver *otg);
+
+	/* MHL support */
+	struct mutex		mhl_mutex;
+	/* call this function with mhl_lock held */
+	int	(*mhl_notify)(struct otg_transceiver *otg,
+					int event, void *mhldata);
+	void			*mhl_data;
 };
 
 
@@ -230,6 +244,63 @@ otg_start_srp(struct otg_transceiver *otg)
 	return otg->start_srp(otg);
 }
 
+static inline int
+otg_enter_mhl_mode(struct otg_transceiver *otg)
+{
+	if (otg->enter_mhl_mode)
+		return otg->enter_mhl_mode(otg);
+
+	return -EINVAL;
+}
+
+static inline int
+otg_exit_mhl_mode(struct otg_transceiver *otg)
+{
+	if (otg->exit_mhl_mode)
+		return otg->exit_mhl_mode(otg);
+
+	return -EINVAL;
+}
+
+static inline int
+otg_register_mhl_notify(struct otg_transceiver *otg,
+	int (*mhl_notify)(struct otg_transceiver *, int, void *), void *mhldata)
+{
+	if (mhl_notify == NULL)
+		return -EINVAL;
+
+	mutex_lock(&otg->mhl_mutex);
+	otg->mhl_notify = mhl_notify;
+	otg->mhl_data = mhldata;
+	mutex_unlock(&otg->mhl_mutex);
+
+	return 0;
+}
+
+static inline void
+otg_unregister_mhl_notify(struct otg_transceiver *otg)
+{
+	mutex_lock(&otg->mhl_mutex);
+	if (otg->mhl_notify) {
+		otg->mhl_notify = NULL;
+		otg->mhl_data = NULL;
+	}
+	mutex_unlock(&otg->mhl_mutex);
+}
+
+static inline int
+otg_mhl_notify(struct otg_transceiver *otg, int event)
+{
+	int	retval = -EINVAL;
+
+	mutex_lock(&otg->mhl_mutex);
+	if (otg->mhl_notify)
+		retval = otg->mhl_notify(otg, event, otg->mhl_data);
+	mutex_unlock(&otg->mhl_mutex);
+
+	return retval;
+}
+
 /* notifiers */
 static inline int
 otg_register_notifier(struct otg_transceiver *otg, struct notifier_block *nb)
-- 
1.6.0.6

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux