hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/media/dvb-frontends/rtl2832_sdr.c
....@@ -1,25 +1,11 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Realtek RTL2832U SDR driver
34 *
45 * Copyright (C) 2013 Antti Palosaari <crope@iki.fi>
56 *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License along
17
- * with this program; if not, write to the Free Software Foundation, Inc.,
18
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
- *
207 * GNU Radio plugin "gr-kernel" for device usage will be on:
21
- * http://git.linuxtv.org/anttip/gr-kernel.git
22
- *
8
+ * https://git.linuxtv.org/anttip/gr-kernel.git
239 */
2410
2511 #include "rtl2832_sdr.h"
....@@ -95,11 +81,9 @@
9581
9682 static struct rtl2832_sdr_format formats[] = {
9783 {
98
- .name = "Complex U8",
9984 .pixelformat = V4L2_SDR_FMT_CU8,
10085 .buffersize = BULK_BUFFER_SIZE,
10186 }, {
102
- .name = "Complex U16LE (emulated)",
10387 .pixelformat = V4L2_SDR_FMT_CU16LE,
10488 .buffersize = BULK_BUFFER_SIZE * 2,
10589 },
....@@ -439,12 +423,9 @@
439423
440424 dev_dbg(&pdev->dev, "\n");
441425
442
- strlcpy(cap->driver, KBUILD_MODNAME, sizeof(cap->driver));
443
- strlcpy(cap->card, dev->vdev.name, sizeof(cap->card));
426
+ strscpy(cap->driver, KBUILD_MODNAME, sizeof(cap->driver));
427
+ strscpy(cap->card, dev->vdev.name, sizeof(cap->card));
444428 usb_make_path(dev->udev, cap->bus_info, sizeof(cap->bus_info));
445
- cap->device_caps = V4L2_CAP_SDR_CAPTURE | V4L2_CAP_STREAMING |
446
- V4L2_CAP_READWRITE | V4L2_CAP_TUNER;
447
- cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
448429 return 0;
449430 }
450431
....@@ -471,7 +452,7 @@
471452 {
472453 struct rtl2832_sdr_dev *dev = vb2_get_drv_priv(vb->vb2_queue);
473454
474
- /* Don't allow queing new buffers after device disconnection */
455
+ /* Don't allow queueing new buffers after device disconnection */
475456 if (!dev->udev)
476457 return -ENODEV;
477458
....@@ -976,7 +957,7 @@
976957 dev_dbg(&pdev->dev, "index=%d type=%d\n", v->index, v->type);
977958
978959 if (v->index == 0) {
979
- strlcpy(v->name, "ADC: Realtek RTL2832", sizeof(v->name));
960
+ strscpy(v->name, "ADC: Realtek RTL2832", sizeof(v->name));
980961 v->type = V4L2_TUNER_ADC;
981962 v->capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS;
982963 v->rangelow = 300000;
....@@ -986,7 +967,7 @@
986967 V4L2_SUBDEV_HAS_OP(dev->v4l2_subdev, tuner, g_tuner)) {
987968 ret = v4l2_subdev_call(dev->v4l2_subdev, tuner, g_tuner, v);
988969 } else if (v->index == 1) {
989
- strlcpy(v->name, "RF: <unknown>", sizeof(v->name));
970
+ strscpy(v->name, "RF: <unknown>", sizeof(v->name));
990971 v->type = V4L2_TUNER_RF;
991972 v->capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS;
992973 v->rangelow = 50000000;
....@@ -1133,7 +1114,6 @@
11331114 if (f->index >= dev->num_formats)
11341115 return -EINVAL;
11351116
1136
- strlcpy(f->description, formats[f->index].name, sizeof(f->description));
11371117 f->pixelformat = formats[f->index].pixelformat;
11381118
11391119 return 0;
....@@ -1256,6 +1236,8 @@
12561236 .release = video_device_release_empty,
12571237 .fops = &rtl2832_sdr_fops,
12581238 .ioctl_ops = &rtl2832_sdr_ioctl_ops,
1239
+ .device_caps = V4L2_CAP_SDR_CAPTURE | V4L2_CAP_STREAMING |
1240
+ V4L2_CAP_READWRITE | V4L2_CAP_TUNER,
12591241 };
12601242
12611243 static int rtl2832_sdr_s_ctrl(struct v4l2_ctrl *ctrl)
....@@ -1394,7 +1376,8 @@
13941376 case RTL2832_SDR_TUNER_E4000:
13951377 v4l2_ctrl_handler_init(&dev->hdl, 9);
13961378 if (subdev)
1397
- v4l2_ctrl_add_handler(&dev->hdl, subdev->ctrl_handler, NULL);
1379
+ v4l2_ctrl_add_handler(&dev->hdl, subdev->ctrl_handler,
1380
+ NULL, true);
13981381 break;
13991382 case RTL2832_SDR_TUNER_R820T:
14001383 case RTL2832_SDR_TUNER_R828D:
....@@ -1423,11 +1406,12 @@
14231406 v4l2_ctrl_handler_init(&dev->hdl, 2);
14241407 if (subdev)
14251408 v4l2_ctrl_add_handler(&dev->hdl, subdev->ctrl_handler,
1426
- NULL);
1409
+ NULL, true);
14271410 break;
14281411 default:
14291412 v4l2_ctrl_handler_init(&dev->hdl, 0);
14301413 dev_err(&pdev->dev, "Unsupported tuner\n");
1414
+ ret = -ENODEV;
14311415 goto err_v4l2_ctrl_handler_free;
14321416 }
14331417 if (dev->hdl.error) {