2 * linux/drivers/media/video/s5p-mfc/s5p_mfc_shm.c
4 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com/
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
13 #ifdef CONFIG_ARCH_EXYNOS4
14 #include <linux/dma-mapping.h>
17 #include "s5p_mfc_common.h"
18 #include "s5p_mfc_debug.h"
20 int s5p_mfc_init_shm(struct s5p_mfc_ctx
*ctx
)
22 struct s5p_mfc_dev
*dev
= ctx
->dev
;
23 void *shm_alloc_ctx
= dev
->alloc_ctx
[MFC_BANK1_ALLOC_CTX
];
25 ctx
->shm_alloc
= vb2_dma_contig_memops
.alloc(shm_alloc_ctx
,
27 if (IS_ERR(ctx
->shm_alloc
)) {
28 mfc_err("failed to allocate shared memory\n");
29 return PTR_ERR(ctx
->shm_alloc
);
31 /* shm_ofs only keeps the offset from base (port a) */
32 ctx
->shm_ofs
= s5p_mfc_mem_cookie(shm_alloc_ctx
, ctx
->shm_alloc
)
34 BUG_ON(ctx
->shm_ofs
& ((1 << MFC_BANK1_ALIGN_ORDER
) - 1));
35 ctx
->shm
= vb2_dma_contig_memops
.vaddr(ctx
->shm_alloc
);
37 vb2_dma_contig_memops
.put(ctx
->shm_alloc
);
39 ctx
->shm_alloc
= NULL
;
40 mfc_err("failed to virt addr of shared memory\n");
43 memset((void *)ctx
->shm
, 0, SHARED_BUF_SIZE
);