CHROMIUM: [media] rk3288-vpu: Require kernel mapping only for encoder output

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>
This commit is contained in:
Tomasz Figa
2015-04-13 14:49:43 +09:00
committed by Huang, Tao
parent f76d4881d1
commit be0b8e30b1
3 changed files with 20 additions and 3 deletions

View 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);

View 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;

View 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;