forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/drivers/media/usb/uvc/uvc_v4l2.c
....@@ -1,14 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * uvc_v4l2.c -- USB Video Class driver - V4L2 API
34 *
45 * Copyright (C) 2005-2010
56 * Laurent Pinchart (laurent.pinchart@ideasonboard.com)
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License as published by
9
- * the Free Software Foundation; either version 2 of the License, or
10
- * (at your option) any later version.
11
- *
127 */
138
149 #include <linux/compat.h>
....@@ -288,7 +283,8 @@
288283 fmt->fmt.pix.sizeimage = probe->dwMaxVideoFrameSize;
289284 fmt->fmt.pix.pixelformat = format->fcc;
290285 fmt->fmt.pix.colorspace = format->colorspace;
291
- fmt->fmt.pix.priv = 0;
286
+ fmt->fmt.pix.xfer_func = format->xfer_func;
287
+ fmt->fmt.pix.ycbcr_enc = format->ycbcr_enc;
292288
293289 if (uvc_format != NULL)
294290 *uvc_format = format;
....@@ -325,7 +321,8 @@
325321 fmt->fmt.pix.bytesperline = uvc_v4l2_get_bytesperline(format, frame);
326322 fmt->fmt.pix.sizeimage = stream->ctrl.dwMaxVideoFrameSize;
327323 fmt->fmt.pix.colorspace = format->colorspace;
328
- fmt->fmt.pix.priv = 0;
324
+ fmt->fmt.pix.xfer_func = format->xfer_func;
325
+ fmt->fmt.pix.ycbcr_enc = format->ycbcr_enc;
329326
330327 done:
331328 mutex_unlock(&stream->mutex);
....@@ -624,8 +621,8 @@
624621 struct uvc_video_chain *chain = handle->chain;
625622 struct uvc_streaming *stream = handle->stream;
626623
627
- strlcpy(cap->driver, "uvcvideo", sizeof(cap->driver));
628
- strlcpy(cap->card, vdev->name, sizeof(cap->card));
624
+ strscpy(cap->driver, "uvcvideo", sizeof(cap->driver));
625
+ strscpy(cap->card, vdev->name, sizeof(cap->card));
629626 usb_make_path(stream->dev->udev, cap->bus_info, sizeof(cap->bus_info));
630627 cap->capabilities = V4L2_CAP_DEVICE_CAPS | V4L2_CAP_STREAMING
631628 | chain->caps;
....@@ -651,7 +648,7 @@
651648 fmt->flags = 0;
652649 if (format->flags & UVC_FMT_FLAG_COMPRESSED)
653650 fmt->flags |= V4L2_FMT_FLAG_COMPRESSED;
654
- strlcpy(fmt->description, format->name, sizeof(fmt->description));
651
+ strscpy(fmt->description, format->name, sizeof(fmt->description));
655652 fmt->description[sizeof(fmt->description) - 1] = 0;
656653 fmt->pixelformat = format->fcc;
657654 return 0;
....@@ -784,7 +781,8 @@
784781 if (!uvc_has_privileges(handle))
785782 return -EBUSY;
786783
787
- return uvc_queue_buffer(&stream->queue, buf);
784
+ return uvc_queue_buffer(&stream->queue,
785
+ stream->vdev.v4l2_dev->mdev, buf);
788786 }
789787
790788 static int uvc_ioctl_expbuf(struct file *file, void *fh,
....@@ -865,34 +863,36 @@
865863 struct uvc_video_chain *chain = handle->chain;
866864 const struct uvc_entity *selector = chain->selector;
867865 struct uvc_entity *iterm = NULL;
866
+ struct uvc_entity *it;
868867 u32 index = input->index;
869
- int pin = 0;
870868
871869 if (selector == NULL ||
872870 (chain->dev->quirks & UVC_QUIRK_IGNORE_SELECTOR_UNIT)) {
873871 if (index != 0)
874872 return -EINVAL;
875
- list_for_each_entry(iterm, &chain->entities, chain) {
876
- if (UVC_ENTITY_IS_ITERM(iterm))
873
+ list_for_each_entry(it, &chain->entities, chain) {
874
+ if (UVC_ENTITY_IS_ITERM(it)) {
875
+ iterm = it;
877876 break;
877
+ }
878878 }
879
- pin = iterm->id;
880879 } else if (index < selector->bNrInPins) {
881
- pin = selector->baSourceID[index];
882
- list_for_each_entry(iterm, &chain->entities, chain) {
883
- if (!UVC_ENTITY_IS_ITERM(iterm))
880
+ list_for_each_entry(it, &chain->entities, chain) {
881
+ if (!UVC_ENTITY_IS_ITERM(it))
884882 continue;
885
- if (iterm->id == pin)
883
+ if (it->id == selector->baSourceID[index]) {
884
+ iterm = it;
886885 break;
886
+ }
887887 }
888888 }
889889
890
- if (iterm == NULL || iterm->id != pin)
890
+ if (iterm == NULL)
891891 return -EINVAL;
892892
893893 memset(input, 0, sizeof(*input));
894894 input->index = index;
895
- strlcpy(input->name, iterm->name, sizeof(input->name));
895
+ strscpy(input->name, iterm->name, sizeof(input->name));
896896 if (UVC_ENTITY_TYPE(iterm) == UVC_ITT_CAMERA)
897897 input->type = V4L2_INPUT_TYPE_CAMERA;
898898
....@@ -984,7 +984,7 @@
984984
985985 qec->id = qc.id;
986986 qec->type = qc.type;
987
- strlcpy(qec->name, qc.name, sizeof(qec->name));
987
+ strscpy(qec->name, qc.name, sizeof(qec->name));
988988 qec->minimum = qc.minimum;
989989 qec->maximum = qc.maximum;
990990 qec->step = qc.step;