forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/media/pci/cx25821/cx25821-video.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Driver for the Conexant CX25821 PCIe bridge
34 *
....@@ -6,18 +7,6 @@
67 * Based on Steven Toth <stoth@linuxtv.org> cx25821 driver
78 * Parts adapted/taken from Eduardo Moscoso Rubino
89 * Copyright (C) 2009 Eduardo Moscoso Rubino <moscoso@TopoLogica.com>
9
- *
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
- *
20
- * GNU General Public License for more details.
2110 */
2211
2312 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
....@@ -46,12 +35,10 @@
4635
4736 static const struct cx25821_fmt formats[] = {
4837 {
49
- .name = "4:1:1, packed, Y41P",
5038 .fourcc = V4L2_PIX_FMT_Y41P,
5139 .depth = 12,
5240 .flags = FORMAT_FLAGS_PACKED,
5341 }, {
54
- .name = "4:2:2, packed, YUYV",
5542 .fourcc = V4L2_PIX_FMT_YUYV,
5643 .depth = 16,
5744 .flags = FORMAT_FLAGS_PACKED,
....@@ -226,9 +213,9 @@
226213 break;
227214 }
228215
229
- dprintk(2, "[%p/%d] buffer_prep - %dx%d %dbpp \"%s\" - dma=0x%08lx\n",
216
+ dprintk(2, "[%p/%d] buffer_prep - %dx%d %dbpp 0x%08x - dma=0x%08lx\n",
230217 buf, buf->vb.vb2_buf.index, chan->width, chan->height,
231
- chan->fmt->depth, chan->fmt->name,
218
+ chan->fmt->depth, chan->fmt->fourcc,
232219 (unsigned long)buf->risc.dma);
233220
234221 return ret;
....@@ -322,7 +309,6 @@
322309 if (unlikely(f->index >= ARRAY_SIZE(formats)))
323310 return -EINVAL;
324311
325
- strlcpy(f->description, formats[f->index].name, sizeof(f->description));
326312 f->pixelformat = formats[f->index].fourcc;
327313
328314 return 0;
....@@ -437,18 +423,13 @@
437423 {
438424 struct cx25821_channel *chan = video_drvdata(file);
439425 struct cx25821_dev *dev = chan->dev;
440
- const u32 cap_input = V4L2_CAP_VIDEO_CAPTURE |
441
- V4L2_CAP_READWRITE | V4L2_CAP_STREAMING;
442
- const u32 cap_output = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_READWRITE;
443426
444
- strcpy(cap->driver, "cx25821");
445
- strlcpy(cap->card, cx25821_boards[dev->board].name, sizeof(cap->card));
427
+ strscpy(cap->driver, "cx25821", sizeof(cap->driver));
428
+ strscpy(cap->card, cx25821_boards[dev->board].name, sizeof(cap->card));
446429 sprintf(cap->bus_info, "PCIe:%s", pci_name(dev->pci));
447
- if (chan->id >= VID_CHANNEL_NUM)
448
- cap->device_caps = cap_output;
449
- else
450
- cap->device_caps = cap_input;
451
- cap->capabilities = cap_input | cap_output | V4L2_CAP_DEVICE_CAPS;
430
+ cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_OUTPUT |
431
+ V4L2_CAP_READWRITE | V4L2_CAP_STREAMING |
432
+ V4L2_CAP_DEVICE_CAPS;
452433 return 0;
453434 }
454435
....@@ -486,7 +467,7 @@
486467
487468 i->type = V4L2_INPUT_TYPE_CAMERA;
488469 i->std = CX25821_NORMS;
489
- strcpy(i->name, "Composite");
470
+ strscpy(i->name, "Composite", sizeof(i->name));
490471 return 0;
491472 }
492473
....@@ -534,7 +515,7 @@
534515
535516 o->type = V4L2_INPUT_TYPE_CAMERA;
536517 o->std = CX25821_NORMS;
537
- strcpy(o->name, "Composite");
518
+ strscpy(o->name, "Composite", sizeof(o->name));
538519 return 0;
539520 }
540521
....@@ -635,6 +616,8 @@
635616 .minor = -1,
636617 .ioctl_ops = &video_ioctl_ops,
637618 .tvnorms = CX25821_NORMS,
619
+ .device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE |
620
+ V4L2_CAP_STREAMING,
638621 };
639622
640623 static const struct v4l2_file_operations video_out_fops = {
....@@ -668,6 +651,7 @@
668651 .minor = -1,
669652 .ioctl_ops = &video_out_ioctl_ops,
670653 .tvnorms = CX25821_NORMS,
654
+ .device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_READWRITE,
671655 };
672656
673657 void cx25821_video_unregister(struct cx25821_dev *dev, int chan_num)
....@@ -773,7 +757,7 @@
773757 snprintf(vdev->name, sizeof(vdev->name), "%s #%d", dev->name, i);
774758 video_set_drvdata(vdev, chan);
775759
776
- err = video_register_device(vdev, VFL_TYPE_GRABBER,
760
+ err = video_register_device(vdev, VFL_TYPE_VIDEO,
777761 video_nr[dev->nr]);
778762
779763 if (err < 0)