.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | | - * |
---|
3 | 3 | * |
---|
4 | 4 | * Copyright (C) 2005 Mike Isely <isely@pobox.com> |
---|
5 | 5 | * 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 | | - * |
---|
16 | 6 | */ |
---|
17 | 7 | |
---|
18 | 8 | #include <linux/kernel.h> |
---|
.. | .. |
---|
121 | 111 | struct pvr2_v4l2_fh *fh = file->private_data; |
---|
122 | 112 | struct pvr2_hdw *hdw = fh->channel.mc_head->hdw; |
---|
123 | 113 | |
---|
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)); |
---|
128 | 118 | cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_TUNER | |
---|
129 | 119 | V4L2_CAP_AUDIO | V4L2_CAP_RADIO | |
---|
130 | 120 | 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; |
---|
142 | 121 | return 0; |
---|
143 | 122 | } |
---|
144 | 123 | |
---|
.. | .. |
---|
284 | 263 | |
---|
285 | 264 | if (vin->index > 0) |
---|
286 | 265 | return -EINVAL; |
---|
287 | | - strncpy(vin->name, "PVRUSB2 Audio", 14); |
---|
| 266 | + strscpy(vin->name, "PVRUSB2 Audio", sizeof(vin->name)); |
---|
288 | 267 | vin->capability = V4L2_AUDCAP_STEREO; |
---|
289 | 268 | return 0; |
---|
290 | 269 | } |
---|
.. | .. |
---|
293 | 272 | { |
---|
294 | 273 | /* pkt: FIXME: see above comment (VIDIOC_ENUMAUDIO) */ |
---|
295 | 274 | vin->index = 0; |
---|
296 | | - strncpy(vin->name, "PVRUSB2 Audio", 14); |
---|
| 275 | + strscpy(vin->name, "PVRUSB2 Audio", sizeof(vin->name)); |
---|
297 | 276 | vin->capability = V4L2_AUDCAP_STEREO; |
---|
298 | 277 | return 0; |
---|
299 | 278 | } |
---|
.. | .. |
---|
545 | 524 | "QUERYCTRL id=0x%x mapping name=%s (%s)", |
---|
546 | 525 | vc->id, pvr2_ctrl_get_name(cptr), |
---|
547 | 526 | 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)); |
---|
549 | 528 | vc->flags = pvr2_ctrl_get_v4lflags(cptr); |
---|
550 | 529 | pvr2_ctrl_get_def(cptr, &val); |
---|
551 | 530 | vc->default_value = val; |
---|
.. | .. |
---|
703 | 682 | return 0; |
---|
704 | 683 | } |
---|
705 | 684 | |
---|
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) |
---|
707 | 687 | { |
---|
708 | 688 | struct pvr2_v4l2_fh *fh = file->private_data; |
---|
709 | 689 | struct pvr2_hdw *hdw = fh->channel.mc_head->hdw; |
---|
| 690 | + struct v4l2_cropcap cap = { .type = type }; |
---|
710 | 691 | int ret; |
---|
711 | 692 | |
---|
712 | | - if (cap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
---|
| 693 | + if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
---|
713 | 694 | 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; |
---|
716 | 698 | return ret; |
---|
717 | 699 | } |
---|
718 | 700 | |
---|
.. | .. |
---|
815 | 797 | .vidioc_g_audio = pvr2_g_audio, |
---|
816 | 798 | .vidioc_enumaudio = pvr2_enumaudio, |
---|
817 | 799 | .vidioc_enum_input = pvr2_enum_input, |
---|
818 | | - .vidioc_cropcap = pvr2_cropcap, |
---|
| 800 | + .vidioc_g_pixelaspect = pvr2_g_pixelaspect, |
---|
819 | 801 | .vidioc_s_selection = pvr2_s_selection, |
---|
820 | 802 | .vidioc_g_selection = pvr2_g_selection, |
---|
821 | 803 | .vidioc_g_input = pvr2_g_input, |
---|
.. | .. |
---|
869 | 851 | are gone. */ |
---|
870 | 852 | video_unregister_device(&dip->devbase); |
---|
871 | 853 | |
---|
872 | | - printk(KERN_INFO "%s\n", msg); |
---|
| 854 | + pr_info("%s\n", msg); |
---|
873 | 855 | |
---|
874 | 856 | } |
---|
875 | 857 | |
---|
.. | .. |
---|
1026 | 1008 | input_mask &= pvr2_hdw_get_input_available(hdw); |
---|
1027 | 1009 | input_cnt = 0; |
---|
1028 | 1010 | 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++; |
---|
1030 | 1012 | } |
---|
1031 | 1013 | fhp->input_cnt = input_cnt; |
---|
1032 | 1014 | fhp->input_map = kzalloc(input_cnt,GFP_KERNEL); |
---|
.. | .. |
---|
1041 | 1023 | } |
---|
1042 | 1024 | input_cnt = 0; |
---|
1043 | 1025 | for (idx = 0; idx < (sizeof(input_mask) << 3); idx++) { |
---|
1044 | | - if (!(input_mask & (1 << idx))) continue; |
---|
| 1026 | + if (!(input_mask & (1UL << idx))) continue; |
---|
1045 | 1027 | fhp->input_map[input_cnt++] = idx; |
---|
1046 | 1028 | } |
---|
1047 | 1029 | |
---|
.. | .. |
---|
1207 | 1189 | int unit_number; |
---|
1208 | 1190 | struct pvr2_hdw *hdw; |
---|
1209 | 1191 | int *nr_ptr = NULL; |
---|
| 1192 | + u32 caps = V4L2_CAP_TUNER | V4L2_CAP_READWRITE; |
---|
| 1193 | + |
---|
1210 | 1194 | dip->v4lp = vp; |
---|
1211 | 1195 | |
---|
1212 | 1196 | hdw = vp->channel.mc_head->hdw; |
---|
1213 | 1197 | dip->v4l_type = v4l_type; |
---|
1214 | 1198 | switch (v4l_type) { |
---|
1215 | | - case VFL_TYPE_GRABBER: |
---|
| 1199 | + case VFL_TYPE_VIDEO: |
---|
1216 | 1200 | dip->stream = &vp->channel.mc_head->video_stream; |
---|
1217 | 1201 | dip->config = pvr2_config_mpeg; |
---|
1218 | 1202 | dip->minor_type = pvr2_v4l_type_video; |
---|
1219 | 1203 | nr_ptr = video_nr; |
---|
| 1204 | + caps |= V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_AUDIO; |
---|
1220 | 1205 | if (!dip->stream) { |
---|
1221 | 1206 | pr_err(KBUILD_MODNAME |
---|
1222 | 1207 | ": Failed to set up pvrusb2 v4l video dev due to missing stream instance\n"); |
---|
.. | .. |
---|
1227 | 1212 | dip->config = pvr2_config_vbi; |
---|
1228 | 1213 | dip->minor_type = pvr2_v4l_type_vbi; |
---|
1229 | 1214 | nr_ptr = vbi_nr; |
---|
| 1215 | + caps |= V4L2_CAP_VBI_CAPTURE; |
---|
1230 | 1216 | break; |
---|
1231 | 1217 | case VFL_TYPE_RADIO: |
---|
1232 | 1218 | dip->stream = &vp->channel.mc_head->video_stream; |
---|
1233 | 1219 | dip->config = pvr2_config_mpeg; |
---|
1234 | 1220 | dip->minor_type = pvr2_v4l_type_radio; |
---|
1235 | 1221 | nr_ptr = radio_nr; |
---|
| 1222 | + caps |= V4L2_CAP_RADIO; |
---|
1236 | 1223 | break; |
---|
1237 | 1224 | default: |
---|
1238 | 1225 | /* Bail out (this should be impossible) */ |
---|
.. | .. |
---|
1243 | 1230 | dip->devbase = vdev_template; |
---|
1244 | 1231 | dip->devbase.release = pvr2_video_device_release; |
---|
1245 | 1232 | dip->devbase.ioctl_ops = &pvr2_ioctl_ops; |
---|
| 1233 | + dip->devbase.device_caps = caps; |
---|
1246 | 1234 | { |
---|
1247 | 1235 | int val; |
---|
1248 | 1236 | pvr2_ctrl_get_value( |
---|
.. | .. |
---|
1265 | 1253 | ": Failed to register pvrusb2 v4l device\n"); |
---|
1266 | 1254 | } |
---|
1267 | 1255 | |
---|
1268 | | - printk(KERN_INFO "pvrusb2: registered device %s [%s]\n", |
---|
| 1256 | + pr_info("pvrusb2: registered device %s [%s]\n", |
---|
1269 | 1257 | video_device_node_name(&dip->devbase), |
---|
1270 | 1258 | pvr2_config_get_name(dip->config)); |
---|
1271 | 1259 | |
---|
.. | .. |
---|
1288 | 1276 | /* register streams */ |
---|
1289 | 1277 | vp->dev_video = kzalloc(sizeof(*vp->dev_video),GFP_KERNEL); |
---|
1290 | 1278 | 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); |
---|
1292 | 1280 | if (pvr2_hdw_get_input_available(vp->channel.mc_head->hdw) & |
---|
1293 | 1281 | (1 << PVR2_CVAL_INPUT_RADIO)) { |
---|
1294 | 1282 | vp->dev_radio = kzalloc(sizeof(*vp->dev_radio),GFP_KERNEL); |
---|