static int mhl_pf_switch_device_discovery(void *data, int id, void (*usb_notify_cb)(void *, int), void *ctx) { int rc = MHL_USB_NON_INUSE; pr_info("%s()\n", __func__); if (id) { /* todo : this logic can be reused in 8620? */ pr_debug("%s: USB ID pin high. id=%d\n", __func__, id); return id; } if (!usb_notify_cb) { pr_warn("%s: cb || ctrl is NULL\n", __func__); return -EINVAL; } isDiscoveryCalled = true; usb_ctx = ctx; /* switch gpio to MHL from USB */ /* todo : must use dtsi for gpio */ gpio_set_value(GPIO_MHL_SWITCH_SEL_1, 1); gpio_set_value(GPIO_MHL_SWITCH_SEL_2, 1); pr_debug("%s: gpio(%d) : %d", __func__, GPIO_MHL_SWITCH_SEL_1, gpio_get_value(GPIO_MHL_SWITCH_SEL_1)); pr_debug("%s: gpio(%d) : %d", __func__, GPIO_MHL_SWITCH_SEL_2, gpio_get_value(GPIO_MHL_SWITCH_SEL_2)); msleep(20); if (!notify_usb_online) notify_usb_online = usb_notify_cb; if (device_discovery_cb) { rc = device_discovery_cb(context_cb); if (rc == MHL_USB_INUSE) { if (notify_usb_online) notify_usb_online(usb_ctx, 1); } } else { /* * Even if there is no registerred call back, * MHL_USB_INUSE must be returned since the * MHL ko object is supposed to be installed * at boot timing and immediately registerring * its call back. So this API must return INUSE * to usb. */ pr_warn("%s: no registerred cb.\n", __func__); rc = MHL_USB_INUSE; } pr_info("%s: mhl is inuse ? : %d\n", __func__, (rc == MHL_USB_INUSE)); return rc; }
/** * mhl_pf_switch_register_cb: register * a call back for notifying device discovery. * The client should start device discovery * when call the callback and must notify the * result. Only one registration is acceptable. * When the register API is called before unregister, * the previous call back and context will be * replace with new registration. * * @device_discovery - call back API. Must not be NULL. * @context - it can be NULL. It is notified through the call back API. * */ void mhl_pf_switch_register_cb(int (*device_discovery)(void *context), void *context) { pr_info("%s:\n", __func__); device_discovery_cb = device_discovery; context_cb = context; if (isDiscoveryCalled) device_discovery_cb(context_cb); }
/** * mhl_pf_switch_register_cb: register * a call back for notifying device discovery. * The client should start device discovery * when call the callback and must notify the * result. Only one registration is acceptable. * When the register API is called before unregister, * the previous call back and context will be * replace with new registration. * * @device_discovery - call back API. Must not be NULL. * @context - it can be NULL. It is notified through the call back API. * */ void mhl_pf_switch_register_cb(int (*device_discovery)(void *context), void *context) { int rc = MHL_USB_NON_INUSE; pr_info("%s:\n", __func__); device_discovery_cb = device_discovery; context_cb = context; if (isDiscoveryCalled) { rc = device_discovery_cb(context_cb); if (rc == MHL_USB_INUSE) { if (notify_usb_online) notify_usb_online(usb_ctx, 1); } } }
static int mhl_pf_switch_device_discovery(void *data, int id, void (*usb_notify_cb)(void *, int), void *ctx) { int rc = MHL_USB_NON_INUSE; pr_info("%s()\n", __func__); if (id) { /* todo : this logic can be reused in 8620? */ pr_debug("%s: USB ID pin high. id=%d\n", __func__, id); return id; } if (!usb_notify_cb) { pr_warn("%s: cb || ctrl is NULL\n", __func__); return -EINVAL; } isDiscoveryCalled = true; usb_ctx = ctx; mhl_pf_switch_gpio_to_mhl(); if (!notify_usb_online) notify_usb_online = usb_notify_cb; if (device_discovery_cb) { rc = device_discovery_cb(context_cb); } else { /* * Even if there is no registerred call back, * MHL_USB_INUSE must be returned since the * MHL ko object is supposed to be installed * at boot timing and immediately registerring * its call back. So this API must return INUSE * to usb. */ pr_warn("%s: no registerred cb.\n", __func__); rc = MHL_USB_INUSE; } pr_info("%s: mhl is inuse ? : %d\n", __func__, (rc == MHL_USB_INUSE)); if (rc != MHL_USB_INUSE) mhl_pf_switch_gpio_to_usb(); return rc; }
/** * mhl_pf_switch_register_cb: register * a call back for notifying device discovery. * The client should start device discovery * when call the callback and must notify the * result. Only one registration is acceptable. * When the register API is called before unregister, * the previous call back and context will be * replace with new registration. * * @device_discovery - call back API. Must not be NULL. * @context - it can be NULL. It is notified through the call back API. * */ void mhl_pf_switch_register_cb(int (*device_discovery)(void *context), void *context) { int rc = MHL_USB_NON_INUSE; pr_debug("%s:\n", __func__); device_discovery_cb = device_discovery; context_cb = context; if (isDiscoveryCalled) { rc = device_discovery_cb(context_cb); if (rc == MHL_USB_INUSE) { if (notify_usb_online) { /* Found MHL device */ qpnp_chg_notify_mhl_state(1); notify_usb_online(usb_ctx, 1); } } } }