Skip to content

Commit

Permalink
Optimize MFC memory usage, properly
Browse files Browse the repository at this point in the history
- There are several bugs in MFC memory management that needs to be
  fixed for non-equal buffer size to work properly.
- Samsung originally reduced CPB_BUF_SIZE, but it causes mis-decoding
  of some videos. So we increase it back and also slightly increase
  the memory allocation to support it.
- Userspace mmap size needs to be changed to 35328*1024
  (port0_size - firmware_size + port1_size)
  • Loading branch information
pawitp committed Apr 14, 2012
1 parent e97dc8b commit 164a90a
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions arch/arm/mach-s5pv210/mach-aries.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@ static struct s3cfb_lcd s6e63m0 = {
// Disabled to save memory (we can't find where it's used)
//#define S5PV210_VIDEO_SAMSUNG_MEMSIZE_FIMC1 (9900 * SZ_1K)
#define S5PV210_VIDEO_SAMSUNG_MEMSIZE_FIMC2 (12288 * SZ_1K)
#define S5PV210_VIDEO_SAMSUNG_MEMSIZE_MFC0 (32768 * SZ_1K)
#define S5PV210_VIDEO_SAMSUNG_MEMSIZE_MFC1 (32768 * SZ_1K)
#define S5PV210_VIDEO_SAMSUNG_MEMSIZE_MFC0 (14336 * SZ_1K)
#define S5PV210_VIDEO_SAMSUNG_MEMSIZE_MFC1 (21504 * SZ_1K)
#define S5PV210_VIDEO_SAMSUNG_MEMSIZE_FIMD (S5PV210_LCD_WIDTH * \
S5PV210_LCD_HEIGHT * 4 * \
(CONFIG_FB_S3C_NR_BUFFERS + \
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/samsung/mfc50/mfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ static int mfc_mmap(struct file *filp, struct vm_area_struct *vma)
return -EINVAL;
}

mfc_ctx->port0_mmap_size = (vir_size / 2);
mfc_ctx->port0_mmap_size = mfc_port0_memsize - firmware_size;

vma->vm_flags |= VM_RESERVED | VM_IO;
if (mfc_ctx->buf_type != MFC_BUFFER_CACHE)
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/samsung/mfc50/mfc_buffer_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ int mfc_init_buffer(void)
free_node->size = mfc_port1_memsize;
} else {
free_node->start_addr = mfc_get_port0_buff_paddr();
free_node->size = mfc_port1_memsize -
free_node->size = mfc_port0_memsize -
(mfc_get_port0_buff_paddr() - mfc_get_fw_buff_paddr());
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/samsung/mfc50/mfc_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#define IOCTL_MFC_BUF_CACHE 0x00801000

/* MFC H/W support maximum 32 extra DPB */
#define MFC_MAX_EXTRA_DPB 5
#define MFC_MAX_EXTRA_DPB 4

#define ENC_PROFILE_LEVEL(profile, level) ((profile) | ((level) << 8))

Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/samsung/mfc50/mfc_memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* MFC_FW_TOTAL_BUF_SIZE should be aligned to 4KB (page size)
*/
#define MFC_FW_TOTAL_BUF_SIZE (ALIGN_TO_4KB(MFC_FW_MAX_SIZE + MFC_MAX_INSTANCE_NUM * MFC_FW_BUF_SIZE))
#define MFC_FW_MAX_SIZE (2 * 1024 * 1024) /* 2MB : 2x1024x1024 */
#define MFC_FW_MAX_SIZE (512 * 1024) /* 512KB : 512x1024 */
#define MFC_FW_BUF_SIZE (512 * 1024) /* 512KB : 512x1024 size per instance */

#define RISC_BUF_SIZE (0x80000) /* 512KB : 512x1024 size per instance */
Expand Down

0 comments on commit 164a90a

Please sign in to comment.