mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 03:40:35 +09:00
usb: gadget: f_uvc: support uvc and adb use independently
If we use usb gadget as uvc and adb composite function, the adb will be disconnected if the uvc camera apk is closed. I can reproduce this issue by the following steps on rk3399/rk3288 platforms. 1. Set usb gadget as uvc and adb composite function, and open uvc camera apk on rk3399/rk3288 platforms. 2. Connect usb to PC, and use adb shell; 3. Close the uvc camera apk; And then, the adb will also be disconnected. It's because that when close the uvc camera apk, the userspace calls v4l2_release -> uvc_v4l2_release -> uvc_function_disconnect -> usb_gadget_deactivate -> usb_gadget_disconnect -> pullup(gadget, 0), this cause usb controller disconnect the usb connection. This patch adds a uvc_enabled flag to indicate that usb is connected, don't call pullup(gadget, 0) to disconnet usb if we only close uvc camera apk but not plug out usb cable. Change-Id: I0cc5ce8a24e8e06e0dc9215dfd1b92ef702e4311 Signed-off-by: William Wu <william.wu@rock-chips.com>
This commit is contained in:
@@ -501,6 +501,7 @@ uvc_function_disable(struct usb_function *f)
|
||||
v4l2_event_queue(&uvc->vdev, &v4l2_event);
|
||||
|
||||
uvc->state = UVC_STATE_DISCONNECTED;
|
||||
f->config->cdev->gadget->uvc_enabled = false;
|
||||
|
||||
usb_ep_disable(uvc->video.ep);
|
||||
usb_ep_disable(uvc->control_ep);
|
||||
@@ -516,6 +517,8 @@ uvc_function_connect(struct uvc_device *uvc)
|
||||
struct usb_composite_dev *cdev = uvc->func.config->cdev;
|
||||
int ret;
|
||||
|
||||
cdev->gadget->uvc_enabled = true;
|
||||
|
||||
if ((ret = usb_function_activate(&uvc->func)) < 0)
|
||||
INFO(cdev, "UVC connect failed with %d\n", ret);
|
||||
}
|
||||
|
||||
@@ -787,7 +787,7 @@ int usb_gadget_deactivate(struct usb_gadget *gadget)
|
||||
if (!gadget || gadget->deactivated)
|
||||
goto out;
|
||||
|
||||
if (gadget->connected) {
|
||||
if (gadget->connected && !gadget->uvc_enabled) {
|
||||
ret = usb_gadget_disconnect(gadget);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
@@ -448,6 +448,7 @@ struct usb_gadget_ops {
|
||||
* indicates that it supports LPM as per the LPM ECN & errata.
|
||||
* @remote_wakeup: Indicates if the host has enabled the remote_wakeup
|
||||
* feature.
|
||||
* @uvc_enabled: True if uvc function is enabled.
|
||||
*
|
||||
* Gadgets have a mostly-portable "gadget driver" implementing device
|
||||
* functions, handling all usb configurations and interfaces. Gadget
|
||||
@@ -503,6 +504,7 @@ struct usb_gadget {
|
||||
unsigned connected:1;
|
||||
unsigned lpm_capable:1;
|
||||
unsigned remote_wakeup:1;
|
||||
unsigned uvc_enabled:1;
|
||||
|
||||
ANDROID_KABI_RESERVE(1);
|
||||
ANDROID_KABI_RESERVE(2);
|
||||
|
||||
Reference in New Issue
Block a user