hc
2024-05-14 bedbef8ad3e75a304af6361af235302bcc61d06b
kernel/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c
....@@ -1,18 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
2
- *
33 *
44 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
55 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License as published by
9
- * the Free Software Foundation; either version 2 of the License
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
- *
166 */
177
188 #include <linux/kernel.h>
....@@ -121,24 +111,13 @@
121111 struct pvr2_v4l2_fh *fh = file->private_data;
122112 struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
123113
124
- strlcpy(cap->driver, "pvrusb2", sizeof(cap->driver));
125
- strlcpy(cap->bus_info, pvr2_hdw_get_bus_info(hdw),
126
- sizeof(cap->bus_info));
127
- strlcpy(cap->card, pvr2_hdw_get_desc(hdw), sizeof(cap->card));
114
+ strscpy(cap->driver, "pvrusb2", sizeof(cap->driver));
115
+ strscpy(cap->bus_info, pvr2_hdw_get_bus_info(hdw),
116
+ sizeof(cap->bus_info));
117
+ strscpy(cap->card, pvr2_hdw_get_desc(hdw), sizeof(cap->card));
128118 cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_TUNER |
129119 V4L2_CAP_AUDIO | V4L2_CAP_RADIO |
130120 V4L2_CAP_READWRITE | V4L2_CAP_DEVICE_CAPS;
131
- switch (fh->pdi->devbase.vfl_type) {
132
- case VFL_TYPE_GRABBER:
133
- cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_AUDIO;
134
- break;
135
- case VFL_TYPE_RADIO:
136
- cap->device_caps = V4L2_CAP_RADIO;
137
- break;
138
- default:
139
- return -EINVAL;
140
- }
141
- cap->device_caps |= V4L2_CAP_TUNER | V4L2_CAP_READWRITE;
142121 return 0;
143122 }
144123
....@@ -284,7 +263,7 @@
284263
285264 if (vin->index > 0)
286265 return -EINVAL;
287
- strncpy(vin->name, "PVRUSB2 Audio", 14);
266
+ strscpy(vin->name, "PVRUSB2 Audio", sizeof(vin->name));
288267 vin->capability = V4L2_AUDCAP_STEREO;
289268 return 0;
290269 }
....@@ -293,7 +272,7 @@
293272 {
294273 /* pkt: FIXME: see above comment (VIDIOC_ENUMAUDIO) */
295274 vin->index = 0;
296
- strncpy(vin->name, "PVRUSB2 Audio", 14);
275
+ strscpy(vin->name, "PVRUSB2 Audio", sizeof(vin->name));
297276 vin->capability = V4L2_AUDCAP_STEREO;
298277 return 0;
299278 }
....@@ -545,7 +524,7 @@
545524 "QUERYCTRL id=0x%x mapping name=%s (%s)",
546525 vc->id, pvr2_ctrl_get_name(cptr),
547526 pvr2_ctrl_get_desc(cptr));
548
- strlcpy(vc->name, pvr2_ctrl_get_desc(cptr), sizeof(vc->name));
527
+ strscpy(vc->name, pvr2_ctrl_get_desc(cptr), sizeof(vc->name));
549528 vc->flags = pvr2_ctrl_get_v4lflags(cptr);
550529 pvr2_ctrl_get_def(cptr, &val);
551530 vc->default_value = val;
....@@ -703,16 +682,19 @@
703682 return 0;
704683 }
705684
706
-static int pvr2_cropcap(struct file *file, void *priv, struct v4l2_cropcap *cap)
685
+static int pvr2_g_pixelaspect(struct file *file, void *priv,
686
+ int type, struct v4l2_fract *f)
707687 {
708688 struct pvr2_v4l2_fh *fh = file->private_data;
709689 struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
690
+ struct v4l2_cropcap cap = { .type = type };
710691 int ret;
711692
712
- if (cap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
693
+ if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
713694 return -EINVAL;
714
- ret = pvr2_hdw_get_cropcap(hdw, cap);
715
- cap->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; /* paranoia */
695
+ ret = pvr2_hdw_get_cropcap(hdw, &cap);
696
+ if (!ret)
697
+ *f = cap.pixelaspect;
716698 return ret;
717699 }
718700
....@@ -815,7 +797,7 @@
815797 .vidioc_g_audio = pvr2_g_audio,
816798 .vidioc_enumaudio = pvr2_enumaudio,
817799 .vidioc_enum_input = pvr2_enum_input,
818
- .vidioc_cropcap = pvr2_cropcap,
800
+ .vidioc_g_pixelaspect = pvr2_g_pixelaspect,
819801 .vidioc_s_selection = pvr2_s_selection,
820802 .vidioc_g_selection = pvr2_g_selection,
821803 .vidioc_g_input = pvr2_g_input,
....@@ -869,7 +851,7 @@
869851 are gone. */
870852 video_unregister_device(&dip->devbase);
871853
872
- printk(KERN_INFO "%s\n", msg);
854
+ pr_info("%s\n", msg);
873855
874856 }
875857
....@@ -1026,7 +1008,7 @@
10261008 input_mask &= pvr2_hdw_get_input_available(hdw);
10271009 input_cnt = 0;
10281010 for (idx = 0; idx < (sizeof(input_mask) << 3); idx++) {
1029
- if (input_mask & (1 << idx)) input_cnt++;
1011
+ if (input_mask & (1UL << idx)) input_cnt++;
10301012 }
10311013 fhp->input_cnt = input_cnt;
10321014 fhp->input_map = kzalloc(input_cnt,GFP_KERNEL);
....@@ -1041,7 +1023,7 @@
10411023 }
10421024 input_cnt = 0;
10431025 for (idx = 0; idx < (sizeof(input_mask) << 3); idx++) {
1044
- if (!(input_mask & (1 << idx))) continue;
1026
+ if (!(input_mask & (1UL << idx))) continue;
10451027 fhp->input_map[input_cnt++] = idx;
10461028 }
10471029
....@@ -1207,16 +1189,19 @@
12071189 int unit_number;
12081190 struct pvr2_hdw *hdw;
12091191 int *nr_ptr = NULL;
1192
+ u32 caps = V4L2_CAP_TUNER | V4L2_CAP_READWRITE;
1193
+
12101194 dip->v4lp = vp;
12111195
12121196 hdw = vp->channel.mc_head->hdw;
12131197 dip->v4l_type = v4l_type;
12141198 switch (v4l_type) {
1215
- case VFL_TYPE_GRABBER:
1199
+ case VFL_TYPE_VIDEO:
12161200 dip->stream = &vp->channel.mc_head->video_stream;
12171201 dip->config = pvr2_config_mpeg;
12181202 dip->minor_type = pvr2_v4l_type_video;
12191203 nr_ptr = video_nr;
1204
+ caps |= V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_AUDIO;
12201205 if (!dip->stream) {
12211206 pr_err(KBUILD_MODNAME
12221207 ": Failed to set up pvrusb2 v4l video dev due to missing stream instance\n");
....@@ -1227,12 +1212,14 @@
12271212 dip->config = pvr2_config_vbi;
12281213 dip->minor_type = pvr2_v4l_type_vbi;
12291214 nr_ptr = vbi_nr;
1215
+ caps |= V4L2_CAP_VBI_CAPTURE;
12301216 break;
12311217 case VFL_TYPE_RADIO:
12321218 dip->stream = &vp->channel.mc_head->video_stream;
12331219 dip->config = pvr2_config_mpeg;
12341220 dip->minor_type = pvr2_v4l_type_radio;
12351221 nr_ptr = radio_nr;
1222
+ caps |= V4L2_CAP_RADIO;
12361223 break;
12371224 default:
12381225 /* Bail out (this should be impossible) */
....@@ -1243,6 +1230,7 @@
12431230 dip->devbase = vdev_template;
12441231 dip->devbase.release = pvr2_video_device_release;
12451232 dip->devbase.ioctl_ops = &pvr2_ioctl_ops;
1233
+ dip->devbase.device_caps = caps;
12461234 {
12471235 int val;
12481236 pvr2_ctrl_get_value(
....@@ -1265,7 +1253,7 @@
12651253 ": Failed to register pvrusb2 v4l device\n");
12661254 }
12671255
1268
- printk(KERN_INFO "pvrusb2: registered device %s [%s]\n",
1256
+ pr_info("pvrusb2: registered device %s [%s]\n",
12691257 video_device_node_name(&dip->devbase),
12701258 pvr2_config_get_name(dip->config));
12711259
....@@ -1288,7 +1276,7 @@
12881276 /* register streams */
12891277 vp->dev_video = kzalloc(sizeof(*vp->dev_video),GFP_KERNEL);
12901278 if (!vp->dev_video) goto fail;
1291
- pvr2_v4l2_dev_init(vp->dev_video,vp,VFL_TYPE_GRABBER);
1279
+ pvr2_v4l2_dev_init(vp->dev_video,vp,VFL_TYPE_VIDEO);
12921280 if (pvr2_hdw_get_input_available(vp->channel.mc_head->hdw) &
12931281 (1 << PVR2_CVAL_INPUT_RADIO)) {
12941282 vp->dev_radio = kzalloc(sizeof(*vp->dev_radio),GFP_KERNEL);