| .. | .. |
|---|
| 20 | 20 | /* format descriptions for capture and preview */ |
|---|
| 21 | 21 | static struct saa7146_format formats[] = { |
|---|
| 22 | 22 | { |
|---|
| 23 | | - .name = "RGB-8 (3-3-2)", |
|---|
| 24 | 23 | .pixelformat = V4L2_PIX_FMT_RGB332, |
|---|
| 25 | 24 | .trans = RGB08_COMPOSED, |
|---|
| 26 | 25 | .depth = 8, |
|---|
| 27 | 26 | .flags = 0, |
|---|
| 28 | 27 | }, { |
|---|
| 29 | | - .name = "RGB-16 (5/B-6/G-5/R)", |
|---|
| 30 | 28 | .pixelformat = V4L2_PIX_FMT_RGB565, |
|---|
| 31 | 29 | .trans = RGB16_COMPOSED, |
|---|
| 32 | 30 | .depth = 16, |
|---|
| 33 | 31 | .flags = 0, |
|---|
| 34 | 32 | }, { |
|---|
| 35 | | - .name = "RGB-24 (B-G-R)", |
|---|
| 36 | 33 | .pixelformat = V4L2_PIX_FMT_BGR24, |
|---|
| 37 | 34 | .trans = RGB24_COMPOSED, |
|---|
| 38 | 35 | .depth = 24, |
|---|
| 39 | 36 | .flags = 0, |
|---|
| 40 | 37 | }, { |
|---|
| 41 | | - .name = "RGB-32 (B-G-R)", |
|---|
| 42 | 38 | .pixelformat = V4L2_PIX_FMT_BGR32, |
|---|
| 43 | 39 | .trans = RGB32_COMPOSED, |
|---|
| 44 | 40 | .depth = 32, |
|---|
| 45 | 41 | .flags = 0, |
|---|
| 46 | 42 | }, { |
|---|
| 47 | | - .name = "RGB-32 (R-G-B)", |
|---|
| 48 | 43 | .pixelformat = V4L2_PIX_FMT_RGB32, |
|---|
| 49 | 44 | .trans = RGB32_COMPOSED, |
|---|
| 50 | 45 | .depth = 32, |
|---|
| 51 | 46 | .flags = 0, |
|---|
| 52 | 47 | .swap = 0x2, |
|---|
| 53 | 48 | }, { |
|---|
| 54 | | - .name = "Greyscale-8", |
|---|
| 55 | 49 | .pixelformat = V4L2_PIX_FMT_GREY, |
|---|
| 56 | 50 | .trans = Y8, |
|---|
| 57 | 51 | .depth = 8, |
|---|
| 58 | 52 | .flags = 0, |
|---|
| 59 | 53 | }, { |
|---|
| 60 | | - .name = "YUV 4:2:2 planar (Y-Cb-Cr)", |
|---|
| 61 | 54 | .pixelformat = V4L2_PIX_FMT_YUV422P, |
|---|
| 62 | 55 | .trans = YUV422_DECOMPOSED, |
|---|
| 63 | 56 | .depth = 16, |
|---|
| 64 | 57 | .flags = FORMAT_BYTE_SWAP|FORMAT_IS_PLANAR, |
|---|
| 65 | 58 | }, { |
|---|
| 66 | | - .name = "YVU 4:2:0 planar (Y-Cb-Cr)", |
|---|
| 67 | 59 | .pixelformat = V4L2_PIX_FMT_YVU420, |
|---|
| 68 | 60 | .trans = YUV420_DECOMPOSED, |
|---|
| 69 | 61 | .depth = 12, |
|---|
| 70 | 62 | .flags = FORMAT_BYTE_SWAP|FORMAT_IS_PLANAR, |
|---|
| 71 | 63 | }, { |
|---|
| 72 | | - .name = "YUV 4:2:0 planar (Y-Cb-Cr)", |
|---|
| 73 | 64 | .pixelformat = V4L2_PIX_FMT_YUV420, |
|---|
| 74 | 65 | .trans = YUV420_DECOMPOSED, |
|---|
| 75 | 66 | .depth = 12, |
|---|
| 76 | 67 | .flags = FORMAT_IS_PLANAR, |
|---|
| 77 | 68 | }, { |
|---|
| 78 | | - .name = "YUV 4:2:2 (U-Y-V-Y)", |
|---|
| 79 | 69 | .pixelformat = V4L2_PIX_FMT_UYVY, |
|---|
| 80 | 70 | .trans = YUV422_COMPOSED, |
|---|
| 81 | 71 | .depth = 16, |
|---|
| .. | .. |
|---|
| 147 | 137 | } |
|---|
| 148 | 138 | vv->ov.win = fmt.fmt.win; |
|---|
| 149 | 139 | |
|---|
| 150 | | - DEB_D("%dx%d+%d+%d %s field=%s\n", |
|---|
| 140 | + DEB_D("%dx%d+%d+%d 0x%08x field=%s\n", |
|---|
| 151 | 141 | vv->ov.win.w.width, vv->ov.win.w.height, |
|---|
| 152 | 142 | 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]); |
|---|
| 154 | 144 | |
|---|
| 155 | 145 | if (0 != (ret = saa7146_enable_overlay(fh))) { |
|---|
| 156 | 146 | DEB_D("enabling overlay failed: %d\n", ret); |
|---|
| .. | .. |
|---|
| 257 | 247 | |
|---|
| 258 | 248 | /* walk all pages, copy all page addresses to ptr1 */ |
|---|
| 259 | 249 | 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++) |
|---|
| 261 | 251 | *ptr1 = cpu_to_le32(sg_dma_address(list) - list->offset); |
|---|
| 262 | | - } |
|---|
| 263 | 252 | } |
|---|
| 264 | 253 | /* |
|---|
| 265 | 254 | ptr1 = pt1->cpu; |
|---|
| .. | .. |
|---|
| 355 | 344 | |
|---|
| 356 | 345 | fmt = saa7146_format_by_fourcc(dev, vv->video_fmt.pixelformat); |
|---|
| 357 | 346 | /* we need to have a valid format set here */ |
|---|
| 358 | | - BUG_ON(NULL == fmt); |
|---|
| 347 | + if (!fmt) |
|---|
| 348 | + return -EINVAL; |
|---|
| 359 | 349 | |
|---|
| 360 | 350 | if (0 != (fmt->flags & FORMAT_IS_PLANAR)) { |
|---|
| 361 | 351 | resource = RESOURCE_DMA1_HPS|RESOURCE_DMA2_CLP|RESOURCE_DMA3_BRS; |
|---|
| .. | .. |
|---|
| 408 | 398 | |
|---|
| 409 | 399 | fmt = saa7146_format_by_fourcc(dev, vv->video_fmt.pixelformat); |
|---|
| 410 | 400 | /* we need to have a valid format set here */ |
|---|
| 411 | | - BUG_ON(NULL == fmt); |
|---|
| 401 | + if (!fmt) |
|---|
| 402 | + return -EINVAL; |
|---|
| 412 | 403 | |
|---|
| 413 | 404 | if (0 != (fmt->flags & FORMAT_IS_PLANAR)) { |
|---|
| 414 | 405 | resource = RESOURCE_DMA1_HPS|RESOURCE_DMA2_CLP|RESOURCE_DMA3_BRS; |
|---|
| .. | .. |
|---|
| 448 | 439 | |
|---|
| 449 | 440 | static int vidioc_querycap(struct file *file, void *fh, struct v4l2_capability *cap) |
|---|
| 450 | 441 | { |
|---|
| 451 | | - struct video_device *vdev = video_devdata(file); |
|---|
| 452 | 442 | struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; |
|---|
| 453 | 443 | |
|---|
| 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)); |
|---|
| 456 | 446 | 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; |
|---|
| 470 | 451 | return 0; |
|---|
| 471 | 452 | } |
|---|
| 472 | 453 | |
|---|
| .. | .. |
|---|
| 525 | 506 | { |
|---|
| 526 | 507 | if (f->index >= ARRAY_SIZE(formats)) |
|---|
| 527 | 508 | return -EINVAL; |
|---|
| 528 | | - strlcpy((char *)f->description, formats[f->index].name, |
|---|
| 529 | | - sizeof(f->description)); |
|---|
| 530 | 509 | f->pixelformat = formats[f->index].pixelformat; |
|---|
| 531 | 510 | return 0; |
|---|
| 532 | 511 | } |
|---|
| .. | .. |
|---|
| 796 | 775 | return -EFAULT; |
|---|
| 797 | 776 | } |
|---|
| 798 | 777 | |
|---|
| 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 */ |
|---|
| 800 | 779 | vv->ov.fh = fh; |
|---|
| 801 | 780 | |
|---|
| 802 | 781 | /* check if our current overlay is active */ |
|---|