forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/drivers/media/usb/hdpvr/hdpvr-video.c
....@@ -1,12 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Hauppauge HD PVR USB driver - video 4 linux 2 interface
34 *
45 * Copyright (C) 2008 Janne Grunau (j@jannau.net)
5
- *
6
- * This program is free software; you can redistribute it and/or
7
- * modify it under the terms of the GNU General Public License as
8
- * published by the Free Software Foundation, version 2.
9
- *
106 */
117
128 #include <linux/kernel.h>
....@@ -312,7 +308,6 @@
312308
313309 dev->status = STATUS_STREAMING;
314310
315
- INIT_WORK(&dev->worker, hdpvr_transmit_buffers);
316311 schedule_work(&dev->worker);
317312
318313 v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev,
....@@ -414,7 +409,7 @@
414409 struct hdpvr_device *dev = video_drvdata(file);
415410 struct hdpvr_buffer *buf = NULL;
416411 struct urb *urb;
417
- unsigned int ret = 0;
412
+ int ret = 0;
418413 int rem, cnt;
419414
420415 if (*pos)
....@@ -585,12 +580,9 @@
585580 {
586581 struct hdpvr_device *dev = video_drvdata(file);
587582
588
- strcpy(cap->driver, "hdpvr");
589
- strcpy(cap->card, "Hauppauge HD PVR");
583
+ strscpy(cap->driver, "hdpvr", sizeof(cap->driver));
584
+ strscpy(cap->card, "Hauppauge HD PVR", sizeof(cap->card));
590585 usb_make_path(dev->udev, cap->bus_info, sizeof(cap->bus_info));
591
- cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_AUDIO |
592
- V4L2_CAP_READWRITE;
593
- cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
594586 return 0;
595587 }
596588
....@@ -776,8 +768,7 @@
776768
777769 i->type = V4L2_INPUT_TYPE_CAMERA;
778770
779
- strncpy(i->name, iname[n], sizeof(i->name) - 1);
780
- i->name[sizeof(i->name) - 1] = '\0';
771
+ strscpy(i->name, iname[n], sizeof(i->name));
781772
782773 i->audioset = 1<<HDPVR_RCA_FRONT | 1<<HDPVR_RCA_BACK | 1<<HDPVR_SPDIF;
783774
....@@ -848,8 +839,7 @@
848839
849840 audio->capability = V4L2_AUDCAP_STEREO;
850841
851
- strncpy(audio->name, audio_iname[n], sizeof(audio->name) - 1);
852
- audio->name[sizeof(audio->name) - 1] = '\0';
842
+ strscpy(audio->name, audio_iname[n], sizeof(audio->name));
853843
854844 return 0;
855845 }
....@@ -880,8 +870,7 @@
880870
881871 audio->index = dev->options.audio_input;
882872 audio->capability = V4L2_AUDCAP_STEREO;
883
- strlcpy(audio->name, audio_iname[audio->index], sizeof(audio->name));
884
- audio->name[sizeof(audio->name) - 1] = '\0';
873
+ strscpy(audio->name, audio_iname[audio->index], sizeof(audio->name));
885874 return 0;
886875 }
887876
....@@ -997,8 +986,6 @@
997986 if (f->index != 0)
998987 return -EINVAL;
999988
1000
- f->flags = V4L2_FMT_FLAG_COMPRESSED;
1001
- strncpy(f->description, "MPEG2-TS with AVC/AAC streams", 32);
1002989 f->pixelformat = V4L2_PIX_FMT_MPEG;
1003990
1004991 return 0;
....@@ -1161,6 +1148,8 @@
11611148 .release = hdpvr_device_release,
11621149 .ioctl_ops = &hdpvr_ioctl_ops,
11631150 .tvnorms = V4L2_STD_ALL,
1151
+ .device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_AUDIO |
1152
+ V4L2_CAP_READWRITE,
11641153 };
11651154
11661155 static const struct v4l2_ctrl_ops hdpvr_ctrl_ops = {
....@@ -1174,6 +1163,9 @@
11741163 struct v4l2_ctrl_handler *hdl = &dev->hdl;
11751164 bool ac3 = dev->flags & HDPVR_FLAG_AC3_CAP;
11761165 int res;
1166
+
1167
+ // initialize dev->worker
1168
+ INIT_WORK(&dev->worker, hdpvr_transmit_buffers);
11771169
11781170 dev->cur_std = V4L2_STD_525_60;
11791171 dev->width = 720;
....@@ -1243,11 +1235,12 @@
12431235
12441236 /* setup and register video device */
12451237 dev->video_dev = hdpvr_video_template;
1246
- strcpy(dev->video_dev.name, "Hauppauge HD PVR");
1238
+ strscpy(dev->video_dev.name, "Hauppauge HD PVR",
1239
+ sizeof(dev->video_dev.name));
12471240 dev->video_dev.v4l2_dev = &dev->v4l2_dev;
12481241 video_set_drvdata(&dev->video_dev, dev);
12491242
1250
- res = video_register_device(&dev->video_dev, VFL_TYPE_GRABBER, devnum);
1243
+ res = video_register_device(&dev->video_dev, VFL_TYPE_VIDEO, devnum);
12511244 if (res < 0) {
12521245 v4l2_err(&dev->v4l2_dev, "video_device registration failed\n");
12531246 goto error;