| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Hauppauge HD PVR USB driver - video 4 linux 2 interface |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * 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 | | - * |
|---|
| 10 | 6 | */ |
|---|
| 11 | 7 | |
|---|
| 12 | 8 | #include <linux/kernel.h> |
|---|
| .. | .. |
|---|
| 312 | 308 | |
|---|
| 313 | 309 | dev->status = STATUS_STREAMING; |
|---|
| 314 | 310 | |
|---|
| 315 | | - INIT_WORK(&dev->worker, hdpvr_transmit_buffers); |
|---|
| 316 | 311 | schedule_work(&dev->worker); |
|---|
| 317 | 312 | |
|---|
| 318 | 313 | v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev, |
|---|
| .. | .. |
|---|
| 414 | 409 | struct hdpvr_device *dev = video_drvdata(file); |
|---|
| 415 | 410 | struct hdpvr_buffer *buf = NULL; |
|---|
| 416 | 411 | struct urb *urb; |
|---|
| 417 | | - unsigned int ret = 0; |
|---|
| 412 | + int ret = 0; |
|---|
| 418 | 413 | int rem, cnt; |
|---|
| 419 | 414 | |
|---|
| 420 | 415 | if (*pos) |
|---|
| .. | .. |
|---|
| 585 | 580 | { |
|---|
| 586 | 581 | struct hdpvr_device *dev = video_drvdata(file); |
|---|
| 587 | 582 | |
|---|
| 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)); |
|---|
| 590 | 585 | 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; |
|---|
| 594 | 586 | return 0; |
|---|
| 595 | 587 | } |
|---|
| 596 | 588 | |
|---|
| .. | .. |
|---|
| 776 | 768 | |
|---|
| 777 | 769 | i->type = V4L2_INPUT_TYPE_CAMERA; |
|---|
| 778 | 770 | |
|---|
| 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)); |
|---|
| 781 | 772 | |
|---|
| 782 | 773 | i->audioset = 1<<HDPVR_RCA_FRONT | 1<<HDPVR_RCA_BACK | 1<<HDPVR_SPDIF; |
|---|
| 783 | 774 | |
|---|
| .. | .. |
|---|
| 848 | 839 | |
|---|
| 849 | 840 | audio->capability = V4L2_AUDCAP_STEREO; |
|---|
| 850 | 841 | |
|---|
| 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)); |
|---|
| 853 | 843 | |
|---|
| 854 | 844 | return 0; |
|---|
| 855 | 845 | } |
|---|
| .. | .. |
|---|
| 880 | 870 | |
|---|
| 881 | 871 | audio->index = dev->options.audio_input; |
|---|
| 882 | 872 | 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)); |
|---|
| 885 | 874 | return 0; |
|---|
| 886 | 875 | } |
|---|
| 887 | 876 | |
|---|
| .. | .. |
|---|
| 997 | 986 | if (f->index != 0) |
|---|
| 998 | 987 | return -EINVAL; |
|---|
| 999 | 988 | |
|---|
| 1000 | | - f->flags = V4L2_FMT_FLAG_COMPRESSED; |
|---|
| 1001 | | - strncpy(f->description, "MPEG2-TS with AVC/AAC streams", 32); |
|---|
| 1002 | 989 | f->pixelformat = V4L2_PIX_FMT_MPEG; |
|---|
| 1003 | 990 | |
|---|
| 1004 | 991 | return 0; |
|---|
| .. | .. |
|---|
| 1161 | 1148 | .release = hdpvr_device_release, |
|---|
| 1162 | 1149 | .ioctl_ops = &hdpvr_ioctl_ops, |
|---|
| 1163 | 1150 | .tvnorms = V4L2_STD_ALL, |
|---|
| 1151 | + .device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_AUDIO | |
|---|
| 1152 | + V4L2_CAP_READWRITE, |
|---|
| 1164 | 1153 | }; |
|---|
| 1165 | 1154 | |
|---|
| 1166 | 1155 | static const struct v4l2_ctrl_ops hdpvr_ctrl_ops = { |
|---|
| .. | .. |
|---|
| 1174 | 1163 | struct v4l2_ctrl_handler *hdl = &dev->hdl; |
|---|
| 1175 | 1164 | bool ac3 = dev->flags & HDPVR_FLAG_AC3_CAP; |
|---|
| 1176 | 1165 | int res; |
|---|
| 1166 | + |
|---|
| 1167 | + // initialize dev->worker |
|---|
| 1168 | + INIT_WORK(&dev->worker, hdpvr_transmit_buffers); |
|---|
| 1177 | 1169 | |
|---|
| 1178 | 1170 | dev->cur_std = V4L2_STD_525_60; |
|---|
| 1179 | 1171 | dev->width = 720; |
|---|
| .. | .. |
|---|
| 1243 | 1235 | |
|---|
| 1244 | 1236 | /* setup and register video device */ |
|---|
| 1245 | 1237 | 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)); |
|---|
| 1247 | 1240 | dev->video_dev.v4l2_dev = &dev->v4l2_dev; |
|---|
| 1248 | 1241 | video_set_drvdata(&dev->video_dev, dev); |
|---|
| 1249 | 1242 | |
|---|
| 1250 | | - res = video_register_device(&dev->video_dev, VFL_TYPE_GRABBER, devnum); |
|---|
| 1243 | + res = video_register_device(&dev->video_dev, VFL_TYPE_VIDEO, devnum); |
|---|
| 1251 | 1244 | if (res < 0) { |
|---|
| 1252 | 1245 | v4l2_err(&dev->v4l2_dev, "video_device registration failed\n"); |
|---|
| 1253 | 1246 | goto error; |
|---|