| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * s2255drv.c - a driver for the Sensoray 2255 USB video capture device |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 20 | 21 | * -half size, color mode YUYV or YUV422P: all 4 channels at once |
|---|
| 21 | 22 | * -full size, color mode YUYV or YUV422P 1/2 frame rate: all 4 channels |
|---|
| 22 | 23 | * at once. |
|---|
| 23 | | - * |
|---|
| 24 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 25 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 26 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 27 | | - * (at your option) any later version. |
|---|
| 28 | | - * |
|---|
| 29 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 30 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 31 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 32 | | - * GNU General Public License for more details. |
|---|
| 33 | 24 | */ |
|---|
| 34 | 25 | |
|---|
| 35 | 26 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 282 | 273 | } |
|---|
| 283 | 274 | |
|---|
| 284 | 275 | struct s2255_fmt { |
|---|
| 285 | | - char *name; |
|---|
| 286 | 276 | u32 fourcc; |
|---|
| 287 | 277 | int depth; |
|---|
| 288 | 278 | }; |
|---|
| .. | .. |
|---|
| 394 | 384 | /* JPEG formats must be defined last to support jpeg_enable parameter */ |
|---|
| 395 | 385 | static const struct s2255_fmt formats[] = { |
|---|
| 396 | 386 | { |
|---|
| 397 | | - .name = "4:2:2, packed, YUYV", |
|---|
| 398 | 387 | .fourcc = V4L2_PIX_FMT_YUYV, |
|---|
| 399 | 388 | .depth = 16 |
|---|
| 400 | 389 | |
|---|
| 401 | 390 | }, { |
|---|
| 402 | | - .name = "4:2:2, packed, UYVY", |
|---|
| 403 | 391 | .fourcc = V4L2_PIX_FMT_UYVY, |
|---|
| 404 | 392 | .depth = 16 |
|---|
| 405 | 393 | }, { |
|---|
| 406 | | - .name = "4:2:2, planar, YUV422P", |
|---|
| 407 | 394 | .fourcc = V4L2_PIX_FMT_YUV422P, |
|---|
| 408 | 395 | .depth = 16 |
|---|
| 409 | 396 | |
|---|
| 410 | 397 | }, { |
|---|
| 411 | | - .name = "8bpp GREY", |
|---|
| 412 | 398 | .fourcc = V4L2_PIX_FMT_GREY, |
|---|
| 413 | 399 | .depth = 8 |
|---|
| 414 | 400 | }, { |
|---|
| 415 | | - .name = "JPG", |
|---|
| 416 | 401 | .fourcc = V4L2_PIX_FMT_JPEG, |
|---|
| 417 | 402 | .depth = 24 |
|---|
| 418 | 403 | }, { |
|---|
| 419 | | - .name = "MJPG", |
|---|
| 420 | 404 | .fourcc = V4L2_PIX_FMT_MJPEG, |
|---|
| 421 | 405 | .depth = 24 |
|---|
| 422 | 406 | } |
|---|
| .. | .. |
|---|
| 730 | 714 | struct s2255_vc *vc = video_drvdata(file); |
|---|
| 731 | 715 | struct s2255_dev *dev = vc->dev; |
|---|
| 732 | 716 | |
|---|
| 733 | | - strlcpy(cap->driver, "s2255", sizeof(cap->driver)); |
|---|
| 734 | | - strlcpy(cap->card, "s2255", sizeof(cap->card)); |
|---|
| 717 | + strscpy(cap->driver, "s2255", sizeof(cap->driver)); |
|---|
| 718 | + strscpy(cap->card, "s2255", sizeof(cap->card)); |
|---|
| 735 | 719 | usb_make_path(dev->udev, cap->bus_info, sizeof(cap->bus_info)); |
|---|
| 736 | | - cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING | |
|---|
| 737 | | - V4L2_CAP_READWRITE; |
|---|
| 738 | | - cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; |
|---|
| 739 | 720 | return 0; |
|---|
| 740 | 721 | } |
|---|
| 741 | 722 | |
|---|
| .. | .. |
|---|
| 749 | 730 | if (!jpeg_enable && ((formats[index].fourcc == V4L2_PIX_FMT_JPEG) || |
|---|
| 750 | 731 | (formats[index].fourcc == V4L2_PIX_FMT_MJPEG))) |
|---|
| 751 | 732 | return -EINVAL; |
|---|
| 752 | | - strlcpy(f->description, formats[index].name, sizeof(f->description)); |
|---|
| 753 | 733 | f->pixelformat = formats[index].fourcc; |
|---|
| 754 | 734 | return 0; |
|---|
| 755 | 735 | } |
|---|
| .. | .. |
|---|
| 771 | 751 | f->fmt.pix.bytesperline = f->fmt.pix.width * (vc->fmt->depth >> 3); |
|---|
| 772 | 752 | f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; |
|---|
| 773 | 753 | f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; |
|---|
| 774 | | - f->fmt.pix.priv = 0; |
|---|
| 775 | 754 | return 0; |
|---|
| 776 | 755 | } |
|---|
| 777 | 756 | |
|---|
| .. | .. |
|---|
| 823 | 802 | f->fmt.pix.bytesperline = (f->fmt.pix.width * fmt->depth) >> 3; |
|---|
| 824 | 803 | f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; |
|---|
| 825 | 804 | f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; |
|---|
| 826 | | - f->fmt.pix.priv = 0; |
|---|
| 827 | 805 | dprintk(vc->dev, 50, "%s: set width %d height %d field %d\n", __func__, |
|---|
| 828 | 806 | f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.field); |
|---|
| 829 | 807 | return 0; |
|---|
| .. | .. |
|---|
| 1195 | 1173 | switch (dev->pid) { |
|---|
| 1196 | 1174 | case 0x2255: |
|---|
| 1197 | 1175 | default: |
|---|
| 1198 | | - strlcpy(inp->name, "Composite", sizeof(inp->name)); |
|---|
| 1176 | + strscpy(inp->name, "Composite", sizeof(inp->name)); |
|---|
| 1199 | 1177 | break; |
|---|
| 1200 | 1178 | case 0x2257: |
|---|
| 1201 | | - strlcpy(inp->name, (vc->idx < 2) ? "Composite" : "S-Video", |
|---|
| 1179 | + strscpy(inp->name, (vc->idx < 2) ? "Composite" : "S-Video", |
|---|
| 1202 | 1180 | sizeof(inp->name)); |
|---|
| 1203 | 1181 | break; |
|---|
| 1204 | 1182 | } |
|---|
| .. | .. |
|---|
| 1666 | 1644 | vc->vdev.ctrl_handler = &vc->hdl; |
|---|
| 1667 | 1645 | vc->vdev.lock = &dev->lock; |
|---|
| 1668 | 1646 | vc->vdev.v4l2_dev = &dev->v4l2_dev; |
|---|
| 1647 | + vc->vdev.device_caps = V4L2_CAP_VIDEO_CAPTURE | |
|---|
| 1648 | + V4L2_CAP_STREAMING | V4L2_CAP_READWRITE; |
|---|
| 1669 | 1649 | video_set_drvdata(&vc->vdev, vc); |
|---|
| 1670 | 1650 | if (video_nr == -1) |
|---|
| 1671 | 1651 | ret = video_register_device(&vc->vdev, |
|---|
| 1672 | | - VFL_TYPE_GRABBER, |
|---|
| 1652 | + VFL_TYPE_VIDEO, |
|---|
| 1673 | 1653 | video_nr); |
|---|
| 1674 | 1654 | else |
|---|
| 1675 | 1655 | ret = video_register_device(&vc->vdev, |
|---|
| 1676 | | - VFL_TYPE_GRABBER, |
|---|
| 1656 | + VFL_TYPE_VIDEO, |
|---|
| 1677 | 1657 | cur_nr + i); |
|---|
| 1678 | 1658 | |
|---|
| 1679 | 1659 | if (ret) { |
|---|