forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/drivers/media/usb/stk1160/stk1160-v4l.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * STK1160 driver
34 *
....@@ -7,17 +8,6 @@
78 * Based on Easycap driver by R.M. Thomas
89 * Copyright (C) 2010 R.M. Thomas
910 * <rmthomas--a.t--sciolus.org>
10
- *
11
- * This program is free software; you can redistribute it and/or modify
12
- * it under the terms of the GNU General Public License as published by
13
- * the Free Software Foundation; either version 2 of the License, or
14
- * (at your option) any later version.
15
- *
16
- * This program is distributed in the hope that it will be useful,
17
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- * GNU General Public License for more details.
20
- *
2111 */
2212
2313 #include <linux/module.h>
....@@ -56,7 +46,6 @@
5646 /* supported video standards */
5747 static struct stk1160_fmt format[] = {
5848 {
59
- .name = "16 bpp YUY2, 4:2:2, packed",
6049 .fourcc = V4L2_PIX_FMT_UYVY,
6150 .depth = 16,
6251 }
....@@ -269,7 +258,7 @@
269258 stk1160_uninit_isoc(dev);
270259 out_stop_hw:
271260 usb_set_interface(dev->udev, 0, 0);
272
- stk1160_clear_queue(dev);
261
+ stk1160_clear_queue(dev, VB2_BUF_STATE_QUEUED);
273262
274263 mutex_unlock(&dev->v4l_lock);
275264
....@@ -317,7 +306,7 @@
317306
318307 stk1160_stop_hw(dev);
319308
320
- stk1160_clear_queue(dev);
309
+ stk1160_clear_queue(dev, VB2_BUF_STATE_ERROR);
321310
322311 stk1160_dbg("streaming stopped\n");
323312
....@@ -344,14 +333,9 @@
344333 {
345334 struct stk1160 *dev = video_drvdata(file);
346335
347
- strcpy(cap->driver, "stk1160");
348
- strcpy(cap->card, "stk1160");
336
+ strscpy(cap->driver, "stk1160", sizeof(cap->driver));
337
+ strscpy(cap->card, "stk1160", sizeof(cap->card));
349338 usb_make_path(dev->udev, cap->bus_info, sizeof(cap->bus_info));
350
- cap->device_caps =
351
- V4L2_CAP_VIDEO_CAPTURE |
352
- V4L2_CAP_STREAMING |
353
- V4L2_CAP_READWRITE;
354
- cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
355339 return 0;
356340 }
357341
....@@ -361,7 +345,6 @@
361345 if (f->index != 0)
362346 return -EINVAL;
363347
364
- strlcpy(f->description, format[f->index].name, sizeof(f->description));
365348 f->pixelformat = format[f->index].fourcc;
366349 return 0;
367350 }
....@@ -762,7 +745,7 @@
762745 /********************************************************************/
763746
764747 /* Must be called with both v4l_lock and vb_queue_lock hold */
765
-void stk1160_clear_queue(struct stk1160 *dev)
748
+void stk1160_clear_queue(struct stk1160 *dev, enum vb2_buffer_state vb2_state)
766749 {
767750 struct stk1160_buffer *buf;
768751 unsigned long flags;
....@@ -773,7 +756,7 @@
773756 buf = list_first_entry(&dev->avail_bufs,
774757 struct stk1160_buffer, list);
775758 list_del(&buf->list);
776
- vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
759
+ vb2_buffer_done(&buf->vb.vb2_buf, vb2_state);
777760 stk1160_dbg("buffer [%p/%d] aborted\n",
778761 buf, buf->vb.vb2_buf.index);
779762 }
....@@ -783,7 +766,7 @@
783766 buf = dev->isoc_ctl.buf;
784767 dev->isoc_ctl.buf = NULL;
785768
786
- vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
769
+ vb2_buffer_done(&buf->vb.vb2_buf, vb2_state);
787770 stk1160_dbg("buffer [%p/%d] aborted\n",
788771 buf, buf->vb.vb2_buf.index);
789772 }
....@@ -831,6 +814,8 @@
831814
832815 /* This will be used to set video_device parent */
833816 dev->vdev.v4l2_dev = &dev->v4l2_dev;
817
+ dev->vdev.device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING |
818
+ V4L2_CAP_READWRITE;
834819
835820 /* NTSC is default */
836821 dev->norm = V4L2_STD_NTSC_M;
....@@ -845,7 +830,7 @@
845830 dev->norm);
846831
847832 video_set_drvdata(&dev->vdev, dev);
848
- rc = video_register_device(&dev->vdev, VFL_TYPE_GRABBER, -1);
833
+ rc = video_register_device(&dev->vdev, VFL_TYPE_VIDEO, -1);
849834 if (rc < 0) {
850835 stk1160_err("video_register_device failed (%d)\n", rc);
851836 return rc;