mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 02:50:49 +09:00
UPSTREAM: usb: gadget: uvc: move video disable logic to its own function
This patch refactors the video disable logic in uvcg_video_enable into its own separate function 'uvcg_video_disable'. This function is now used anywhere uvcg_video_enable(video, 0) was used. Change-Id: Ifba331485eee8b671126d92f5af7a2f71d79ecc2 Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com> Suggested-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Signed-off-by: Avichal Rakesh <arakesh@google.com> Link: https://lore.kernel.org/r/20231109004104.3467968-3-arakesh@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: William Wu <william.wu@rock-chips.com> (cherry picked from commit 2079b60bda3257146a4e8ed7525513865f7e6b3e)
This commit is contained in:
committed by
Tao Huang
parent
5762defe3b
commit
c5a3634277
@@ -453,7 +453,7 @@ uvc_v4l2_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
|
||||
return -ENODEV;
|
||||
|
||||
/* Enable UVC video. */
|
||||
ret = uvcg_video_enable(video, 1);
|
||||
ret = uvcg_video_enable(video);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
@@ -488,7 +488,7 @@ uvc_v4l2_streamoff(struct file *file, void *fh, enum v4l2_buf_type type)
|
||||
return -EINVAL;
|
||||
|
||||
uvc->state = UVC_STATE_CONNECTED;
|
||||
ret = uvcg_video_enable(video, 0);
|
||||
ret = uvcg_video_disable(video);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
@@ -534,7 +534,7 @@ static void uvc_v4l2_disable(struct uvc_device *uvc)
|
||||
if (uvc->state == UVC_STATE_STREAMING)
|
||||
uvc->state = UVC_STATE_CONNECTED;
|
||||
|
||||
uvcg_video_enable(&uvc->video, 0);
|
||||
uvcg_video_disable(&uvc->video);
|
||||
uvcg_free_buffers(&uvc->video.queue);
|
||||
uvc->func_connected = false;
|
||||
wake_up_interruptible(&uvc->func_connected_queue);
|
||||
|
||||
@@ -541,15 +541,48 @@ static void uvcg_video_pump(struct work_struct *work)
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable or disable the video stream.
|
||||
* Disable the video stream
|
||||
*/
|
||||
int uvcg_video_enable(struct uvc_video *video, int enable)
|
||||
int
|
||||
uvcg_video_disable(struct uvc_video *video)
|
||||
{
|
||||
int ret;
|
||||
struct uvc_request *ureq;
|
||||
struct uvc_device *uvc;
|
||||
struct f_uvc_opts *opts;
|
||||
|
||||
if (video->ep == NULL) {
|
||||
uvcg_info(&video->uvc->func,
|
||||
"Video disable failed, device is uninitialized.\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
uvc = container_of(video, struct uvc_device, video);
|
||||
opts = fi_to_f_uvc_opts(uvc->func.fi);
|
||||
if (cpu_latency_qos_request_active(&uvc->pm_qos))
|
||||
cpu_latency_qos_remove_request(&uvc->pm_qos);
|
||||
|
||||
cancel_work_sync(&video->pump);
|
||||
uvcg_queue_cancel(&video->queue, 0);
|
||||
|
||||
list_for_each_entry(ureq, &video->ureqs, list) {
|
||||
if (ureq->req)
|
||||
usb_ep_dequeue(video->ep, ureq->req);
|
||||
}
|
||||
|
||||
uvc_video_free_requests(video);
|
||||
uvcg_queue_enable(&video->queue, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable the video stream.
|
||||
*/
|
||||
int uvcg_video_enable(struct uvc_video *video)
|
||||
{
|
||||
struct uvc_device *uvc;
|
||||
struct f_uvc_opts *opts;
|
||||
int ret;
|
||||
|
||||
if (video->ep == NULL) {
|
||||
uvcg_info(&video->uvc->func,
|
||||
"Video enable failed, device is uninitialized.\n");
|
||||
@@ -558,24 +591,8 @@ int uvcg_video_enable(struct uvc_video *video, int enable)
|
||||
|
||||
uvc = container_of(video, struct uvc_device, video);
|
||||
opts = fi_to_f_uvc_opts(uvc->func.fi);
|
||||
|
||||
if (!enable) {
|
||||
cancel_work_sync(&video->pump);
|
||||
uvcg_queue_cancel(&video->queue, 0);
|
||||
|
||||
list_for_each_entry(ureq, &video->ureqs, list) {
|
||||
if (ureq->req)
|
||||
usb_ep_dequeue(video->ep, ureq->req);
|
||||
}
|
||||
|
||||
uvc_video_free_requests(video);
|
||||
uvcg_queue_enable(&video->queue, 0);
|
||||
if (cpu_latency_qos_request_active(&uvc->pm_qos))
|
||||
cpu_latency_qos_remove_request(&uvc->pm_qos);
|
||||
return 0;
|
||||
}
|
||||
|
||||
cpu_latency_qos_add_request(&uvc->pm_qos, opts->pm_qos_latency);
|
||||
|
||||
if ((ret = uvcg_queue_enable(&video->queue, 1)) < 0)
|
||||
return ret;
|
||||
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
|
||||
struct uvc_video;
|
||||
|
||||
int uvcg_video_enable(struct uvc_video *video, int enable);
|
||||
int uvcg_video_enable(struct uvc_video *video);
|
||||
int uvcg_video_disable(struct uvc_video *video);
|
||||
|
||||
int uvcg_video_init(struct uvc_video *video, struct uvc_device *uvc);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user