>From 4599750d1c6fd11672d7f8182bd9443795911e22 Mon Sep 17 00:00:00 2001 From: Hao Wu <[email protected]> Date: Sun, 28 Nov 2010 15:05:03 +0800 Subject: [PATCH] usb: add support for MHL-USB coexistence
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 <[email protected]> --- include/linux/usb/otg.h | 72 +++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 72 insertions(+), 0 deletions(-) diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h index 685943f..070d039 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 { @@ -73,6 +76,7 @@ struct otg_transceiver { u8 default_a; enum usb_otg_state state; + struct mutex state_mutex; struct usb_bus *host; struct usb_gadget *gadget; @@ -119,6 +123,17 @@ struct otg_transceiver { /* detect a charger */ int (*detect_charger)(struct otg_transceiver *otg) __deprecated; + + /* 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; }; @@ -237,6 +252,63 @@ otg_detect_charger(struct otg_transceiver *otg) return 0; } +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
0001-usb-add-support-for-MHL-USB-coexistence.patch
Description: 0001-usb-add-support-for-MHL-USB-coexistence.patch
_______________________________________________ MeeGo-kernel mailing list [email protected] http://lists.meego.com/listinfo/meego-kernel
