Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] v4l: fix handling of v4l2_input.capabilities

The v4l core sets the v4l2_input.capabilities field based on the supplied
v4l2_ioctl_ops. However, several drivers do a memset or memcpy of the v4l2_input
struct, thus overwriting that field incorrectly.

Either remove the memset (which is already done by the v4l core), or add the
proper capabilities field in case of a memcpy.

The same is also true for v4l2_output, but that only affected the ivtv driver.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
657f2271 3ea2b673

+32 -41
+4
drivers/media/dvb/ttpci/av7110_v4l.c
··· 100 100 .tuner = 0, /* ignored */ 101 101 .std = V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 102 102 .status = 0, 103 + .capabilities = V4L2_IN_CAP_STD, 103 104 }, { 104 105 .index = 1, 105 106 .name = "Television", ··· 109 108 .tuner = 0, 110 109 .std = V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 111 110 .status = 0, 111 + .capabilities = V4L2_IN_CAP_STD, 112 112 }, { 113 113 .index = 2, 114 114 .name = "Video", ··· 118 116 .tuner = 0, 119 117 .std = V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 120 118 .status = 0, 119 + .capabilities = V4L2_IN_CAP_STD, 121 120 }, { 122 121 .index = 3, 123 122 .name = "Y/C", ··· 127 124 .tuner = 0, 128 125 .std = V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 129 126 .status = 0, 127 + .capabilities = V4L2_IN_CAP_STD, 130 128 } 131 129 }; 132 130
+4 -2
drivers/media/dvb/ttpci/budget-av.c
··· 1406 1406 1407 1407 #define KNC1_INPUTS 2 1408 1408 static struct v4l2_input knc1_inputs[KNC1_INPUTS] = { 1409 - {0, "Composite", V4L2_INPUT_TYPE_TUNER, 1, 0, V4L2_STD_PAL_BG | V4L2_STD_NTSC_M, 0}, 1410 - {1, "S-Video", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG | V4L2_STD_NTSC_M, 0}, 1409 + { 0, "Composite", V4L2_INPUT_TYPE_TUNER, 1, 0, 1410 + V4L2_STD_PAL_BG | V4L2_STD_NTSC_M, 0, V4L2_IN_CAP_STD }, 1411 + { 1, "S-Video", V4L2_INPUT_TYPE_CAMERA, 2, 0, 1412 + V4L2_STD_PAL_BG | V4L2_STD_NTSC_M, 0, V4L2_IN_CAP_STD }, 1411 1413 }; 1412 1414 1413 1415 static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *i)
-1
drivers/media/video/cx18/cx18-cards.c
··· 546 546 "Component 1" 547 547 }; 548 548 549 - memset(input, 0, sizeof(*input)); 550 549 if (index >= cx->nof_inputs) 551 550 return -EINVAL; 552 551 input->index = index;
-1
drivers/media/video/cx23885/cx23885-video.c
··· 1126 1126 if (0 == INPUT(n)->type) 1127 1127 return -EINVAL; 1128 1128 1129 - memset(i, 0, sizeof(*i)); 1130 1129 i->index = n; 1131 1130 i->type = V4L2_INPUT_TYPE_CAMERA; 1132 1131 strcpy(i->name, iname[INPUT(n)->type]);
+1
drivers/media/video/et61x251/et61x251_core.c
··· 1610 1610 memset(&i, 0, sizeof(i)); 1611 1611 strcpy(i.name, "Camera"); 1612 1612 i.type = V4L2_INPUT_TYPE_CAMERA; 1613 + i.capabilities = V4L2_IN_CAP_STD; 1613 1614 1614 1615 if (copy_to_user(arg, &i, sizeof(i))) 1615 1616 return -EFAULT;
+9 -9
drivers/media/video/hexium_gemini.c
··· 37 37 38 38 #define HEXIUM_INPUTS 9 39 39 static struct v4l2_input hexium_inputs[HEXIUM_INPUTS] = { 40 - { 0, "CVBS 1", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 }, 41 - { 1, "CVBS 2", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 }, 42 - { 2, "CVBS 3", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 }, 43 - { 3, "CVBS 4", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 }, 44 - { 4, "CVBS 5", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 }, 45 - { 5, "CVBS 6", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 }, 46 - { 6, "Y/C 1", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 }, 47 - { 7, "Y/C 2", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 }, 48 - { 8, "Y/C 3", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 }, 40 + { 0, "CVBS 1", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0, V4L2_IN_CAP_STD }, 41 + { 1, "CVBS 2", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0, V4L2_IN_CAP_STD }, 42 + { 2, "CVBS 3", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0, V4L2_IN_CAP_STD }, 43 + { 3, "CVBS 4", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0, V4L2_IN_CAP_STD }, 44 + { 4, "CVBS 5", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0, V4L2_IN_CAP_STD }, 45 + { 5, "CVBS 6", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0, V4L2_IN_CAP_STD }, 46 + { 6, "Y/C 1", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0, V4L2_IN_CAP_STD }, 47 + { 7, "Y/C 2", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0, V4L2_IN_CAP_STD }, 48 + { 8, "Y/C 3", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0, V4L2_IN_CAP_STD }, 49 49 }; 50 50 51 51 #define HEXIUM_AUDIOS 0
+9 -9
drivers/media/video/hexium_orion.c
··· 38 38 39 39 #define HEXIUM_INPUTS 9 40 40 static struct v4l2_input hexium_inputs[HEXIUM_INPUTS] = { 41 - { 0, "CVBS 1", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 }, 42 - { 1, "CVBS 2", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 }, 43 - { 2, "CVBS 3", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 }, 44 - { 3, "CVBS 4", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 }, 45 - { 4, "CVBS 5", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 }, 46 - { 5, "CVBS 6", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 }, 47 - { 6, "Y/C 1", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 }, 48 - { 7, "Y/C 2", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 }, 49 - { 8, "Y/C 3", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 }, 41 + { 0, "CVBS 1", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0, V4L2_IN_CAP_STD }, 42 + { 1, "CVBS 2", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0, V4L2_IN_CAP_STD }, 43 + { 2, "CVBS 3", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0, V4L2_IN_CAP_STD }, 44 + { 3, "CVBS 4", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0, V4L2_IN_CAP_STD }, 45 + { 4, "CVBS 5", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0, V4L2_IN_CAP_STD }, 46 + { 5, "CVBS 6", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0, V4L2_IN_CAP_STD }, 47 + { 6, "Y/C 1", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0, V4L2_IN_CAP_STD }, 48 + { 7, "Y/C 2", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0, V4L2_IN_CAP_STD }, 49 + { 8, "Y/C 3", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0, V4L2_IN_CAP_STD }, 50 50 }; 51 51 52 52 #define HEXIUM_AUDIOS 0
-2
drivers/media/video/ivtv/ivtv-cards.c
··· 1313 1313 "Composite 3" 1314 1314 }; 1315 1315 1316 - memset(input, 0, sizeof(*input)); 1317 1316 if (index >= itv->nof_inputs) 1318 1317 return -EINVAL; 1319 1318 input->index = index; ··· 1330 1331 { 1331 1332 const struct ivtv_card_output *card_output = itv->card->video_outputs + index; 1332 1333 1333 - memset(output, 0, sizeof(*output)); 1334 1334 if (index >= itv->card->nof_outputs) 1335 1335 return -EINVAL; 1336 1336 output->index = index;
+4 -4
drivers/media/video/mxb.c
··· 59 59 enum { TUNER, AUX1, AUX3, AUX3_YC }; 60 60 61 61 static struct v4l2_input mxb_inputs[MXB_INPUTS] = { 62 - { TUNER, "Tuner", V4L2_INPUT_TYPE_TUNER, 1, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 }, 63 - { AUX1, "AUX1", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 }, 64 - { AUX3, "AUX3 Composite", V4L2_INPUT_TYPE_CAMERA, 4, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 }, 65 - { AUX3_YC, "AUX3 S-Video", V4L2_INPUT_TYPE_CAMERA, 4, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0 }, 62 + { TUNER, "Tuner", V4L2_INPUT_TYPE_TUNER, 1, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0, V4L2_IN_CAP_STD }, 63 + { AUX1, "AUX1", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0, V4L2_IN_CAP_STD }, 64 + { AUX3, "AUX3 Composite", V4L2_INPUT_TYPE_CAMERA, 4, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0, V4L2_IN_CAP_STD }, 65 + { AUX3_YC, "AUX3 S-Video", V4L2_INPUT_TYPE_CAMERA, 4, 0, V4L2_STD_PAL_BG|V4L2_STD_NTSC_M, 0, V4L2_IN_CAP_STD }, 66 66 }; 67 67 68 68 /* this array holds the information, which port of the saa7146 each
-1
drivers/media/video/saa7134/saa7134-video.c
··· 1748 1748 return -EINVAL; 1749 1749 if (NULL == card_in(dev, i->index).name) 1750 1750 return -EINVAL; 1751 - memset(i, 0, sizeof(*i)); 1752 1751 i->index = n; 1753 1752 i->type = V4L2_INPUT_TYPE_CAMERA; 1754 1753 strcpy(i->name, card_in(dev, n).name);
+1
drivers/media/video/sn9c102/sn9c102_core.c
··· 2189 2189 memset(&i, 0, sizeof(i)); 2190 2190 strcpy(i.name, "Camera"); 2191 2191 i.type = V4L2_INPUT_TYPE_CAMERA; 2192 + i.capabilities = V4L2_IN_CAP_STD; 2192 2193 2193 2194 if (copy_to_user(arg, &i, sizeof(i))) 2194 2195 return -EFAULT;
-1
drivers/media/video/timblogiw.c
··· 369 369 if (inp->index != 0) 370 370 return -EINVAL; 371 371 372 - memset(inp, 0, sizeof(*inp)); 373 372 inp->index = 0; 374 373 375 374 strncpy(inp->name, "Timb input 1", sizeof(inp->name) - 1);
-3
drivers/media/video/vino.c
··· 2954 2954 if (input == VINO_INPUT_NONE) 2955 2955 return -EINVAL; 2956 2956 2957 - memset(i, 0, sizeof(struct v4l2_input)); 2958 - 2959 - i->index = index; 2960 2957 i->type = V4L2_INPUT_TYPE_CAMERA; 2961 2958 i->std = vino_inputs[input].std; 2962 2959 strcpy(i->name, vino_inputs[input].name);
-6
drivers/media/video/zoran/zoran_driver.c
··· 2449 2449 2450 2450 if (inp->index >= zr->card.inputs) 2451 2451 return -EINVAL; 2452 - else { 2453 - int id = inp->index; 2454 - memset(inp, 0, sizeof(*inp)); 2455 - inp->index = id; 2456 - } 2457 2452 2458 2453 strncpy(inp->name, zr->card.input[inp->index].name, 2459 2454 sizeof(inp->name) - 1); ··· 2498 2503 if (outp->index != 0) 2499 2504 return -EINVAL; 2500 2505 2501 - memset(outp, 0, sizeof(*outp)); 2502 2506 outp->index = 0; 2503 2507 outp->type = V4L2_OUTPUT_TYPE_ANALOGVGAOVERLAY; 2504 2508 strncpy(outp->name, "Autodetect", sizeof(outp->name)-1);
-2
drivers/staging/cx25821/cx25821-video.c
··· 1272 1272 if (0 == INPUT(n)->type) 1273 1273 return -EINVAL; 1274 1274 1275 - memset(i, 0, sizeof(*i)); 1276 - i->index = n; 1277 1275 i->type = V4L2_INPUT_TYPE_CAMERA; 1278 1276 strcpy(i->name, iname[INPUT(n)->type]); 1279 1277