hc
2024-02-20 e636c8d336489bf3eed5878299e6cc045bbad077
kernel/drivers/media/common/saa7146/saa7146_video.c
....@@ -20,62 +20,52 @@
2020 /* format descriptions for capture and preview */
2121 static struct saa7146_format formats[] = {
2222 {
23
- .name = "RGB-8 (3-3-2)",
2423 .pixelformat = V4L2_PIX_FMT_RGB332,
2524 .trans = RGB08_COMPOSED,
2625 .depth = 8,
2726 .flags = 0,
2827 }, {
29
- .name = "RGB-16 (5/B-6/G-5/R)",
3028 .pixelformat = V4L2_PIX_FMT_RGB565,
3129 .trans = RGB16_COMPOSED,
3230 .depth = 16,
3331 .flags = 0,
3432 }, {
35
- .name = "RGB-24 (B-G-R)",
3633 .pixelformat = V4L2_PIX_FMT_BGR24,
3734 .trans = RGB24_COMPOSED,
3835 .depth = 24,
3936 .flags = 0,
4037 }, {
41
- .name = "RGB-32 (B-G-R)",
4238 .pixelformat = V4L2_PIX_FMT_BGR32,
4339 .trans = RGB32_COMPOSED,
4440 .depth = 32,
4541 .flags = 0,
4642 }, {
47
- .name = "RGB-32 (R-G-B)",
4843 .pixelformat = V4L2_PIX_FMT_RGB32,
4944 .trans = RGB32_COMPOSED,
5045 .depth = 32,
5146 .flags = 0,
5247 .swap = 0x2,
5348 }, {
54
- .name = "Greyscale-8",
5549 .pixelformat = V4L2_PIX_FMT_GREY,
5650 .trans = Y8,
5751 .depth = 8,
5852 .flags = 0,
5953 }, {
60
- .name = "YUV 4:2:2 planar (Y-Cb-Cr)",
6154 .pixelformat = V4L2_PIX_FMT_YUV422P,
6255 .trans = YUV422_DECOMPOSED,
6356 .depth = 16,
6457 .flags = FORMAT_BYTE_SWAP|FORMAT_IS_PLANAR,
6558 }, {
66
- .name = "YVU 4:2:0 planar (Y-Cb-Cr)",
6759 .pixelformat = V4L2_PIX_FMT_YVU420,
6860 .trans = YUV420_DECOMPOSED,
6961 .depth = 12,
7062 .flags = FORMAT_BYTE_SWAP|FORMAT_IS_PLANAR,
7163 }, {
72
- .name = "YUV 4:2:0 planar (Y-Cb-Cr)",
7364 .pixelformat = V4L2_PIX_FMT_YUV420,
7465 .trans = YUV420_DECOMPOSED,
7566 .depth = 12,
7667 .flags = FORMAT_IS_PLANAR,
7768 }, {
78
- .name = "YUV 4:2:2 (U-Y-V-Y)",
7969 .pixelformat = V4L2_PIX_FMT_UYVY,
8070 .trans = YUV422_COMPOSED,
8171 .depth = 16,
....@@ -147,10 +137,10 @@
147137 }
148138 vv->ov.win = fmt.fmt.win;
149139
150
- DEB_D("%dx%d+%d+%d %s field=%s\n",
140
+ DEB_D("%dx%d+%d+%d 0x%08x field=%s\n",
151141 vv->ov.win.w.width, vv->ov.win.w.height,
152142 vv->ov.win.w.left, vv->ov.win.w.top,
153
- vv->ov_fmt->name, v4l2_field_names[vv->ov.win.field]);
143
+ vv->ov_fmt->pixelformat, v4l2_field_names[vv->ov.win.field]);
154144
155145 if (0 != (ret = saa7146_enable_overlay(fh))) {
156146 DEB_D("enabling overlay failed: %d\n", ret);
....@@ -257,9 +247,8 @@
257247
258248 /* walk all pages, copy all page addresses to ptr1 */
259249 for (i = 0; i < length; i++, list++) {
260
- for (p = 0; p * 4096 < list->length; p++, ptr1++) {
250
+ for (p = 0; p * 4096 < sg_dma_len(list); p++, ptr1++)
261251 *ptr1 = cpu_to_le32(sg_dma_address(list) - list->offset);
262
- }
263252 }
264253 /*
265254 ptr1 = pt1->cpu;
....@@ -355,7 +344,8 @@
355344
356345 fmt = saa7146_format_by_fourcc(dev, vv->video_fmt.pixelformat);
357346 /* we need to have a valid format set here */
358
- BUG_ON(NULL == fmt);
347
+ if (!fmt)
348
+ return -EINVAL;
359349
360350 if (0 != (fmt->flags & FORMAT_IS_PLANAR)) {
361351 resource = RESOURCE_DMA1_HPS|RESOURCE_DMA2_CLP|RESOURCE_DMA3_BRS;
....@@ -408,7 +398,8 @@
408398
409399 fmt = saa7146_format_by_fourcc(dev, vv->video_fmt.pixelformat);
410400 /* we need to have a valid format set here */
411
- BUG_ON(NULL == fmt);
401
+ if (!fmt)
402
+ return -EINVAL;
412403
413404 if (0 != (fmt->flags & FORMAT_IS_PLANAR)) {
414405 resource = RESOURCE_DMA1_HPS|RESOURCE_DMA2_CLP|RESOURCE_DMA3_BRS;
....@@ -448,25 +439,15 @@
448439
449440 static int vidioc_querycap(struct file *file, void *fh, struct v4l2_capability *cap)
450441 {
451
- struct video_device *vdev = video_devdata(file);
452442 struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev;
453443
454
- strcpy((char *)cap->driver, "saa7146 v4l2");
455
- strlcpy((char *)cap->card, dev->ext->name, sizeof(cap->card));
444
+ strscpy((char *)cap->driver, "saa7146 v4l2", sizeof(cap->driver));
445
+ strscpy((char *)cap->card, dev->ext->name, sizeof(cap->card));
456446 sprintf((char *)cap->bus_info, "PCI:%s", pci_name(dev->pci));
457
- cap->device_caps =
458
- V4L2_CAP_VIDEO_CAPTURE |
459
- V4L2_CAP_VIDEO_OVERLAY |
460
- V4L2_CAP_READWRITE |
461
- V4L2_CAP_STREAMING;
462
- cap->device_caps |= dev->ext_vv_data->capabilities;
463
- cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
464
- if (vdev->vfl_type == VFL_TYPE_GRABBER)
465
- cap->device_caps &=
466
- ~(V4L2_CAP_VBI_CAPTURE | V4L2_CAP_SLICED_VBI_OUTPUT);
467
- else
468
- cap->device_caps &=
469
- ~(V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_OVERLAY | V4L2_CAP_AUDIO);
447
+ cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_OVERLAY |
448
+ V4L2_CAP_READWRITE | V4L2_CAP_STREAMING |
449
+ V4L2_CAP_DEVICE_CAPS;
450
+ cap->capabilities |= dev->ext_vv_data->capabilities;
470451 return 0;
471452 }
472453
....@@ -525,8 +506,6 @@
525506 {
526507 if (f->index >= ARRAY_SIZE(formats))
527508 return -EINVAL;
528
- strlcpy((char *)f->description, formats[f->index].name,
529
- sizeof(f->description));
530509 f->pixelformat = formats[f->index].pixelformat;
531510 return 0;
532511 }
....@@ -796,7 +775,7 @@
796775 return -EFAULT;
797776 }
798777
799
- /* vv->ov.fh is used to indicate that we have valid overlay informations, too */
778
+ /* vv->ov.fh is used to indicate that we have valid overlay information, too */
800779 vv->ov.fh = fh;
801780
802781 /* check if our current overlay is active */