forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/drivers/media/usb/go7007/go7007-v4l2.c
....@@ -1,14 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2005-2006 Micronas USA Inc.
3
- *
4
- * This program is free software; you can redistribute it and/or modify
5
- * it under the terms of the GNU General Public License (Version 2) as
6
- * published by the Free Software Foundation.
7
- *
8
- * This program is distributed in the hope that it will be useful,
9
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
- * GNU General Public License for more details.
124 */
135
146 #include <linux/module.h>
....@@ -284,51 +276,31 @@
284276 {
285277 struct go7007 *go = video_drvdata(file);
286278
287
- strlcpy(cap->driver, "go7007", sizeof(cap->driver));
288
- strlcpy(cap->card, go->name, sizeof(cap->card));
289
- strlcpy(cap->bus_info, go->bus_info, sizeof(cap->bus_info));
290
-
291
- cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE |
292
- V4L2_CAP_STREAMING;
293
-
294
- if (go->board_info->num_aud_inputs)
295
- cap->device_caps |= V4L2_CAP_AUDIO;
296
- if (go->board_info->flags & GO7007_BOARD_HAS_TUNER)
297
- cap->device_caps |= V4L2_CAP_TUNER;
298
- cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
279
+ strscpy(cap->driver, "go7007", sizeof(cap->driver));
280
+ strscpy(cap->card, go->name, sizeof(cap->card));
281
+ strscpy(cap->bus_info, go->bus_info, sizeof(cap->bus_info));
299282 return 0;
300283 }
301284
302285 static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
303286 struct v4l2_fmtdesc *fmt)
304287 {
305
- char *desc = NULL;
306
-
307288 switch (fmt->index) {
308289 case 0:
309290 fmt->pixelformat = V4L2_PIX_FMT_MJPEG;
310
- desc = "Motion JPEG";
311291 break;
312292 case 1:
313293 fmt->pixelformat = V4L2_PIX_FMT_MPEG1;
314
- desc = "MPEG-1 ES";
315294 break;
316295 case 2:
317296 fmt->pixelformat = V4L2_PIX_FMT_MPEG2;
318
- desc = "MPEG-2 ES";
319297 break;
320298 case 3:
321299 fmt->pixelformat = V4L2_PIX_FMT_MPEG4;
322
- desc = "MPEG-4 ES";
323300 break;
324301 default:
325302 return -EINVAL;
326303 }
327
- fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
328
- fmt->flags = V4L2_FMT_FLAG_COMPRESSED;
329
-
330
- strncpy(fmt->description, desc, sizeof(fmt->description));
331
-
332304 return 0;
333305 }
334306
....@@ -634,8 +606,8 @@
634606 if (inp->index >= go->board_info->num_inputs)
635607 return -EINVAL;
636608
637
- strlcpy(inp->name, go->board_info->inputs[inp->index].name,
638
- sizeof(inp->name));
609
+ strscpy(inp->name, go->board_info->inputs[inp->index].name,
610
+ sizeof(inp->name));
639611
640612 /* If this board has a tuner, it will be the first input */
641613 if ((go->board_info->flags & GO7007_BOARD_HAS_TUNER) &&
....@@ -673,7 +645,7 @@
673645
674646 if (a->index >= go->board_info->num_aud_inputs)
675647 return -EINVAL;
676
- strlcpy(a->name, go->board_info->aud_inputs[a->index].name,
648
+ strscpy(a->name, go->board_info->aud_inputs[a->index].name,
677649 sizeof(a->name));
678650 a->capability = V4L2_AUDCAP_STEREO;
679651 return 0;
....@@ -684,7 +656,7 @@
684656 struct go7007 *go = video_drvdata(file);
685657
686658 a->index = go->aud_input;
687
- strlcpy(a->name, go->board_info->aud_inputs[go->aud_input].name,
659
+ strscpy(a->name, go->board_info->aud_inputs[go->aud_input].name,
688660 sizeof(a->name));
689661 a->capability = V4L2_AUDCAP_STEREO;
690662 return 0;
....@@ -742,7 +714,7 @@
742714 if (t->index != 0)
743715 return -EINVAL;
744716
745
- strlcpy(t->name, "Tuner", sizeof(t->name));
717
+ strscpy(t->name, "Tuner", sizeof(t->name));
746718 return call_all(&go->v4l2_dev, tuner, g_tuner, t);
747719 }
748720
....@@ -1122,6 +1094,12 @@
11221094 *vdev = go7007_template;
11231095 vdev->lock = &go->serialize_lock;
11241096 vdev->queue = &go->vidq;
1097
+ vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE |
1098
+ V4L2_CAP_STREAMING;
1099
+ if (go->board_info->num_aud_inputs)
1100
+ vdev->device_caps |= V4L2_CAP_AUDIO;
1101
+ if (go->board_info->flags & GO7007_BOARD_HAS_TUNER)
1102
+ vdev->device_caps |= V4L2_CAP_TUNER;
11251103 video_set_drvdata(vdev, go);
11261104 vdev->v4l2_dev = &go->v4l2_dev;
11271105 if (!v4l2_device_has_op(&go->v4l2_dev, 0, video, querystd))
....@@ -1160,7 +1138,7 @@
11601138 go7007_s_input(go);
11611139 if (go->board_info->sensor_flags & GO7007_SENSOR_TV)
11621140 go7007_s_std(go);
1163
- rv = video_register_device(vdev, VFL_TYPE_GRABBER, -1);
1141
+ rv = video_register_device(vdev, VFL_TYPE_VIDEO, -1);
11641142 if (rv < 0)
11651143 return rv;
11661144 dev_info(go->dev, "registered device %s [v4l2]\n",