forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/media/platform/xilinx/xilinx-dma.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Xilinx Video DMA
34 *
....@@ -6,10 +7,6 @@
67 *
78 * Contacts: Hyun Kwon <hyun.kwon@xilinx.com>
89 * Laurent Pinchart <laurent.pinchart@ideasonboard.com>
9
- *
10
- * This program is free software; you can redistribute it and/or modify
11
- * it under the terms of the GNU General Public License version 2 as
12
- * published by the Free Software Foundation.
1310 */
1411
1512 #include <linux/dma/xilinx_dma.h>
....@@ -494,20 +491,13 @@
494491 struct v4l2_fh *vfh = file->private_data;
495492 struct xvip_dma *dma = to_xvip_dma(vfh->vdev);
496493
497
- cap->device_caps = V4L2_CAP_STREAMING;
494
+ cap->capabilities = dma->xdev->v4l2_caps | V4L2_CAP_STREAMING |
495
+ V4L2_CAP_DEVICE_CAPS;
498496
499
- if (dma->queue.type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
500
- cap->device_caps |= V4L2_CAP_VIDEO_CAPTURE;
501
- else
502
- cap->device_caps |= V4L2_CAP_VIDEO_OUTPUT;
503
-
504
- cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS
505
- | dma->xdev->v4l2_caps;
506
-
507
- strlcpy(cap->driver, "xilinx-vipp", sizeof(cap->driver));
508
- strlcpy(cap->card, dma->video.name, sizeof(cap->card));
509
- snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s:%u",
510
- dma->xdev->dev->of_node->name, dma->port);
497
+ strscpy(cap->driver, "xilinx-vipp", sizeof(cap->driver));
498
+ strscpy(cap->card, dma->video.name, sizeof(cap->card));
499
+ snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%pOFn:%u",
500
+ dma->xdev->dev->of_node, dma->port);
511501
512502 return 0;
513503 }
....@@ -527,8 +517,6 @@
527517 return -EINVAL;
528518
529519 f->pixelformat = dma->format.pixelformat;
530
- strlcpy(f->description, dma->fmtinfo->description,
531
- sizeof(f->description));
532520
533521 return 0;
534522 }
....@@ -693,16 +681,21 @@
693681 dma->video.fops = &xvip_dma_fops;
694682 dma->video.v4l2_dev = &xdev->v4l2_dev;
695683 dma->video.queue = &dma->queue;
696
- snprintf(dma->video.name, sizeof(dma->video.name), "%s %s %u",
697
- xdev->dev->of_node->name,
684
+ snprintf(dma->video.name, sizeof(dma->video.name), "%pOFn %s %u",
685
+ xdev->dev->of_node,
698686 type == V4L2_BUF_TYPE_VIDEO_CAPTURE ? "output" : "input",
699687 port);
700
- dma->video.vfl_type = VFL_TYPE_GRABBER;
688
+ dma->video.vfl_type = VFL_TYPE_VIDEO;
701689 dma->video.vfl_dir = type == V4L2_BUF_TYPE_VIDEO_CAPTURE
702690 ? VFL_DIR_RX : VFL_DIR_TX;
703691 dma->video.release = video_device_release_empty;
704692 dma->video.ioctl_ops = &xvip_dma_ioctl_ops;
705693 dma->video.lock = &dma->lock;
694
+ dma->video.device_caps = V4L2_CAP_STREAMING;
695
+ if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
696
+ dma->video.device_caps |= V4L2_CAP_VIDEO_CAPTURE;
697
+ else
698
+ dma->video.device_caps |= V4L2_CAP_VIDEO_OUTPUT;
706699
707700 video_set_drvdata(&dma->video, dma);
708701
....@@ -732,16 +725,17 @@
732725
733726 /* ... and the DMA channel. */
734727 snprintf(name, sizeof(name), "port%u", port);
735
- dma->dma = dma_request_slave_channel(dma->xdev->dev, name);
736
- if (dma->dma == NULL) {
737
- dev_err(dma->xdev->dev, "no VDMA channel found\n");
738
- ret = -ENODEV;
728
+ dma->dma = dma_request_chan(dma->xdev->dev, name);
729
+ if (IS_ERR(dma->dma)) {
730
+ ret = PTR_ERR(dma->dma);
731
+ if (ret != -EPROBE_DEFER)
732
+ dev_err(dma->xdev->dev, "no VDMA channel found\n");
739733 goto error;
740734 }
741735
742736 dma->align = 1 << dma->dma->device->copy_align;
743737
744
- ret = video_register_device(&dma->video, VFL_TYPE_GRABBER, -1);
738
+ ret = video_register_device(&dma->video, VFL_TYPE_VIDEO, -1);
745739 if (ret < 0) {
746740 dev_err(dma->xdev->dev, "failed to register video device\n");
747741 goto error;
....@@ -759,7 +753,7 @@
759753 if (video_is_registered(&dma->video))
760754 video_unregister_device(&dma->video);
761755
762
- if (dma->dma)
756
+ if (!IS_ERR_OR_NULL(dma->dma))
763757 dma_release_channel(dma->dma);
764758
765759 media_entity_cleanup(&dma->video.entity);