CHROMIUM: [media] rk3288-vpu: Require kernel mapping only for encoder output
authorTomasz Figa <tfiga@chromium.org>
Mon, 13 Apr 2015 05:49:43 +0000 (14:49 +0900)
committerHuang, Tao <huangtao@rock-chips.com>
Thu, 30 Jun 2016 11:54:29 +0000 (19:54 +0800)
For rk3288-vpu, kernel mapping of video buffers is required only for
encoder bitstream output buffers for additional bistream formatting. Any
other buffers can be allocated without kernel mapping, greatly
conserving the limited pool of vmalloc memory.

This patch modifies the rk3288-vpu driver to use the newly added vb2-dc
interface to create two separate allocation contexts, one for
allocations with kernel mapping and one without.

BUG=chrome-os-partner:38873
TEST=vda/vea unit tests

Signed-off-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/265364
Reviewed-by: Pawel Osciak <posciak@chromium.org>
Change-Id: I4154802dda2329934dea675a242d67e80b925db0
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Signed-off-by: Yakir Yang <ykk@rock-chips.com>
drivers/media/platform/rk3288-vpu/rk3288_vpu.c
drivers/media/platform/rk3288-vpu/rk3288_vpu_common.h
drivers/media/platform/rk3288-vpu/rk3288_vpu_enc.c

index c9ea748148a22e6d1a1184ff4aea1de470d90653..17728371896bed404a0dfe924e0f0fdf34528a19 100644 (file)
@@ -558,6 +558,7 @@ static const struct v4l2_file_operations rk3288_vpu_fops = {
 static int rk3288_vpu_probe(struct platform_device *pdev)
 {
        struct rk3288_vpu_dev *vpu = NULL;
+       DEFINE_DMA_ATTRS(attrs_novm);
        struct video_device *vfd;
        int ret = 0;
 
@@ -580,12 +581,20 @@ static int rk3288_vpu_probe(struct platform_device *pdev)
                goto err_hw_probe;
        }
 
-       vpu->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev);
+       dma_set_attr(DMA_ATTR_NO_KERNEL_MAPPING, &attrs_novm);
+       vpu->alloc_ctx = vb2_dma_contig_init_ctx_attrs(&pdev->dev,
+                                                               &attrs_novm);
        if (IS_ERR(vpu->alloc_ctx)) {
                ret = PTR_ERR(vpu->alloc_ctx);
                goto err_dma_contig;
        }
 
+       vpu->alloc_ctx_vm = vb2_dma_contig_init_ctx(&pdev->dev);
+       if (IS_ERR(vpu->alloc_ctx_vm)) {
+               ret = PTR_ERR(vpu->alloc_ctx_vm);
+               goto err_dma_contig_vm;
+       }
+
        ret = v4l2_device_register(&pdev->dev, &vpu->v4l2_dev);
        if (ret) {
                dev_err(&pdev->dev, "Failed to register v4l2 device\n");
@@ -667,6 +676,8 @@ err_enc_reg:
 err_enc_alloc:
        v4l2_device_unregister(&vpu->v4l2_dev);
 err_v4l2_dev_reg:
+       vb2_dma_contig_cleanup_ctx(vpu->alloc_ctx_vm);
+err_dma_contig_vm:
        vb2_dma_contig_cleanup_ctx(vpu->alloc_ctx);
 err_dma_contig:
        rk3288_vpu_hw_remove(vpu);
@@ -694,6 +705,7 @@ static int rk3288_vpu_remove(struct platform_device *pdev)
        video_unregister_device(vpu->vfd_dec);
        video_unregister_device(vpu->vfd_enc);
        v4l2_device_unregister(&vpu->v4l2_dev);
+       vb2_dma_contig_cleanup_ctx(vpu->alloc_ctx_vm);
        vb2_dma_contig_cleanup_ctx(vpu->alloc_ctx);
        rk3288_vpu_hw_remove(vpu);
 
index a074e2c63d60a650e706d08bac712c9e379adfce..0082e2f57bfdada95e8fe95da3b25c646cc9e658 100644 (file)
@@ -137,7 +137,10 @@ enum rk3288_vpu_state {
  * @pdev:              Pointer to VPU platform device.
  * @dev:               Pointer to device for convenient logging using
  *                     dev_ macros.
- * @alloc_ctx:         VB2 allocator context.
+ * @alloc_ctx:         VB2 allocator context
+ *                     (for allocations without kernel mapping).
+ * @alloc_ctx_vm:      VB2 allocator context
+ *                     (for allocations with kernel mapping).
  * @aclk_vcodec:       Handle of ACLK clock.
  * @hclk_vcodec:       Handle of HCLK clock.
  * @base:              Mapped address of VPU registers.
@@ -161,6 +164,7 @@ struct rk3288_vpu_dev {
        struct platform_device *pdev;
        struct device *dev;
        void *alloc_ctx;
+       void *alloc_ctx_vm;
        struct clk *aclk_vcodec;
        struct clk *hclk_vcodec;
        void __iomem *base;
index bf00ae0d7d7610105bac3df598874de53dc9be87..cee6a5ebbb49de50af3bf7933c8050ed6e2d4249 100644 (file)
@@ -1036,7 +1036,8 @@ static int rk3288_vpu_queue_setup(struct vb2_queue *vq,
                        *buf_count = VIDEO_MAX_FRAME;
 
                psize[0] = ctx->dst_fmt.plane_fmt[0].sizeimage;
-               allocators[0] = ctx->dev->alloc_ctx;
+               /* Kernel mapping necessary for bitstream post processing. */
+               allocators[0] = ctx->dev->alloc_ctx_vm;
                vpu_debug(0, "capture psize[%d]: %d\n", 0, psize[0]);
                break;