2 * linux/drivers/media/video/samsung/mfc5x/mfc_shm.c
4 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com/
7 * Shared memory interface file for Samsung MFC (Multi Function Codec - FIMV) driver
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
15 #ifdef CONFIG_ARCH_S5PV210
16 #include <linux/dma-mapping.h>
24 int init_shm(struct mfc_inst_ctx *ctx)
26 struct mfc_alloc_buffer *alloc;
28 alloc = _mfc_alloc_buf(ctx, MFC_SHM_SIZE, ALIGN_4B, MBT_SHM | PORT_A);
31 ctx->shm = alloc->addr;
32 ctx->shmofs = mfc_mem_base_ofs(alloc->real);
34 memset((void *)ctx->shm, 0, MFC_SHM_SIZE);
36 mfc_mem_cache_clean((void *)ctx->shm, MFC_SHM_SIZE);
41 mfc_err("failed alloc shared memory buffer\n");
49 void write_shm(struct mfc_inst_ctx *ctx, unsigned int data, unsigned int offset)
51 writel(data, (ctx->shm + offset));
53 #if defined(CONFIG_ARCH_S5PV210)
54 dma_cache_maint((void *)(ctx->shm + offset), 4, DMA_TO_DEVICE);
55 #elif defined(CONFIG_CPU_S5PV310)
56 mfc_mem_cache_clean((void *)((unsigned int)(ctx->shm) + offset), 4);
60 unsigned int read_shm(struct mfc_inst_ctx *ctx, unsigned int offset)
62 #if defined(CONFIG_ARCH_S5PV210)
63 dma_cache_maint((void *)(ctx->shm + offset), 4, DMA_FROM_DEVICE);
64 #elif defined(CONFIG_CPU_S5PV310)
65 mfc_mem_cache_inv((void *)((unsigned int)(ctx->shm) + offset), 4);
67 return readl(ctx->shm + offset);