| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * STK1160 driver |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 7 | 8 | * Based on Easycap driver by R.M. Thomas |
|---|
| 8 | 9 | * Copyright (C) 2010 R.M. Thomas |
|---|
| 9 | 10 | * <rmthomas--a.t--sciolus.org> |
|---|
| 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 | | - * GNU General Public License for more details. |
|---|
| 20 | | - * |
|---|
| 21 | 11 | */ |
|---|
| 22 | 12 | |
|---|
| 23 | 13 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 56 | 46 | /* supported video standards */ |
|---|
| 57 | 47 | static struct stk1160_fmt format[] = { |
|---|
| 58 | 48 | { |
|---|
| 59 | | - .name = "16 bpp YUY2, 4:2:2, packed", |
|---|
| 60 | 49 | .fourcc = V4L2_PIX_FMT_UYVY, |
|---|
| 61 | 50 | .depth = 16, |
|---|
| 62 | 51 | } |
|---|
| .. | .. |
|---|
| 269 | 258 | stk1160_uninit_isoc(dev); |
|---|
| 270 | 259 | out_stop_hw: |
|---|
| 271 | 260 | usb_set_interface(dev->udev, 0, 0); |
|---|
| 272 | | - stk1160_clear_queue(dev); |
|---|
| 261 | + stk1160_clear_queue(dev, VB2_BUF_STATE_QUEUED); |
|---|
| 273 | 262 | |
|---|
| 274 | 263 | mutex_unlock(&dev->v4l_lock); |
|---|
| 275 | 264 | |
|---|
| .. | .. |
|---|
| 317 | 306 | |
|---|
| 318 | 307 | stk1160_stop_hw(dev); |
|---|
| 319 | 308 | |
|---|
| 320 | | - stk1160_clear_queue(dev); |
|---|
| 309 | + stk1160_clear_queue(dev, VB2_BUF_STATE_ERROR); |
|---|
| 321 | 310 | |
|---|
| 322 | 311 | stk1160_dbg("streaming stopped\n"); |
|---|
| 323 | 312 | |
|---|
| .. | .. |
|---|
| 344 | 333 | { |
|---|
| 345 | 334 | struct stk1160 *dev = video_drvdata(file); |
|---|
| 346 | 335 | |
|---|
| 347 | | - strcpy(cap->driver, "stk1160"); |
|---|
| 348 | | - strcpy(cap->card, "stk1160"); |
|---|
| 336 | + strscpy(cap->driver, "stk1160", sizeof(cap->driver)); |
|---|
| 337 | + strscpy(cap->card, "stk1160", sizeof(cap->card)); |
|---|
| 349 | 338 | usb_make_path(dev->udev, cap->bus_info, sizeof(cap->bus_info)); |
|---|
| 350 | | - cap->device_caps = |
|---|
| 351 | | - V4L2_CAP_VIDEO_CAPTURE | |
|---|
| 352 | | - V4L2_CAP_STREAMING | |
|---|
| 353 | | - V4L2_CAP_READWRITE; |
|---|
| 354 | | - cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; |
|---|
| 355 | 339 | return 0; |
|---|
| 356 | 340 | } |
|---|
| 357 | 341 | |
|---|
| .. | .. |
|---|
| 361 | 345 | if (f->index != 0) |
|---|
| 362 | 346 | return -EINVAL; |
|---|
| 363 | 347 | |
|---|
| 364 | | - strlcpy(f->description, format[f->index].name, sizeof(f->description)); |
|---|
| 365 | 348 | f->pixelformat = format[f->index].fourcc; |
|---|
| 366 | 349 | return 0; |
|---|
| 367 | 350 | } |
|---|
| .. | .. |
|---|
| 762 | 745 | /********************************************************************/ |
|---|
| 763 | 746 | |
|---|
| 764 | 747 | /* Must be called with both v4l_lock and vb_queue_lock hold */ |
|---|
| 765 | | -void stk1160_clear_queue(struct stk1160 *dev) |
|---|
| 748 | +void stk1160_clear_queue(struct stk1160 *dev, enum vb2_buffer_state vb2_state) |
|---|
| 766 | 749 | { |
|---|
| 767 | 750 | struct stk1160_buffer *buf; |
|---|
| 768 | 751 | unsigned long flags; |
|---|
| .. | .. |
|---|
| 773 | 756 | buf = list_first_entry(&dev->avail_bufs, |
|---|
| 774 | 757 | struct stk1160_buffer, list); |
|---|
| 775 | 758 | list_del(&buf->list); |
|---|
| 776 | | - vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); |
|---|
| 759 | + vb2_buffer_done(&buf->vb.vb2_buf, vb2_state); |
|---|
| 777 | 760 | stk1160_dbg("buffer [%p/%d] aborted\n", |
|---|
| 778 | 761 | buf, buf->vb.vb2_buf.index); |
|---|
| 779 | 762 | } |
|---|
| .. | .. |
|---|
| 783 | 766 | buf = dev->isoc_ctl.buf; |
|---|
| 784 | 767 | dev->isoc_ctl.buf = NULL; |
|---|
| 785 | 768 | |
|---|
| 786 | | - vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); |
|---|
| 769 | + vb2_buffer_done(&buf->vb.vb2_buf, vb2_state); |
|---|
| 787 | 770 | stk1160_dbg("buffer [%p/%d] aborted\n", |
|---|
| 788 | 771 | buf, buf->vb.vb2_buf.index); |
|---|
| 789 | 772 | } |
|---|
| .. | .. |
|---|
| 831 | 814 | |
|---|
| 832 | 815 | /* This will be used to set video_device parent */ |
|---|
| 833 | 816 | dev->vdev.v4l2_dev = &dev->v4l2_dev; |
|---|
| 817 | + dev->vdev.device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING | |
|---|
| 818 | + V4L2_CAP_READWRITE; |
|---|
| 834 | 819 | |
|---|
| 835 | 820 | /* NTSC is default */ |
|---|
| 836 | 821 | dev->norm = V4L2_STD_NTSC_M; |
|---|
| .. | .. |
|---|
| 845 | 830 | dev->norm); |
|---|
| 846 | 831 | |
|---|
| 847 | 832 | video_set_drvdata(&dev->vdev, dev); |
|---|
| 848 | | - rc = video_register_device(&dev->vdev, VFL_TYPE_GRABBER, -1); |
|---|
| 833 | + rc = video_register_device(&dev->vdev, VFL_TYPE_VIDEO, -1); |
|---|
| 849 | 834 | if (rc < 0) { |
|---|
| 850 | 835 | stk1160_err("video_register_device failed (%d)\n", rc); |
|---|
| 851 | 836 | return rc; |
|---|