From: Dominic Curran <dcurran@xxxxxx> Subject: [PATCH] CAM: Alloc ISP Workaround buffer at driver init. This patch allows the ISP Workaround buffer to be allocated at boot time. Previously the buffer was being allocated everytime a handle to the driver was opened. Because the ISP Workaround buffer can be very large then there is significant benefit for the buffer to be allocated only once during camera driver initialization. Signed-off-by: Pallavi Kulkarni <p-kulkarni@xxxxxx> Signed-off-by: Sergio Aguirre <saaguirre@xxxxxx> Signed-off-by: Dominic Curran <dcurran@xxxxxx> --- arch/arm/configs/omap_3430sdp_defconfig | 1 + arch/arm/configs/omap_zoom2_defconfig | 1 + drivers/media/video/Kconfig | 8 ++++++++ drivers/media/video/isp/isp.c | 30 +++++++++++++++++++++++++++++- 4 files changed, 39 insertions(+), 1 deletion(-) ================================================================================ Index: omapzoom04/arch/arm/configs/omap_3430sdp_defconfig =================================================================== --- omapzoom04.orig/arch/arm/configs/omap_3430sdp_defconfig +++ omapzoom04/arch/arm/configs/omap_3430sdp_defconfig @@ -1077,6 +1077,7 @@ CONFIG_VIDEO_OMAP24XX_TVOUT=y CONFIG_VIDEO_OMAP3=y CONFIG_VIDEO_OMAP34XX_ISP_PREVIEWER=y CONFIG_VIDEO_OMAP34XX_ISP_RESIZER=y +CONFIG_VIDEO_OMAP3_BUFFALLOC=y # CONFIG_VIDEO_OMAP2 is not set # CONFIG_V4L_USB_DRIVERS is not set # CONFIG_SOC_CAMERA is not set Index: omapzoom04/arch/arm/configs/omap_zoom2_defconfig =================================================================== --- omapzoom04.orig/arch/arm/configs/omap_zoom2_defconfig +++ omapzoom04/arch/arm/configs/omap_zoom2_defconfig @@ -1032,6 +1032,7 @@ CONFIG_VIDEO_OMAP24XX_TVOUT=y CONFIG_VIDEO_OMAP3=y CONFIG_VIDEO_OMAP34XX_ISP_PREVIEWER=y CONFIG_VIDEO_OMAP34XX_ISP_RESIZER=y +CONFIG_VIDEO_OMAP3_BUFFALLOC=y # CONFIG_VIDEO_OMAP2 is not set # CONFIG_SOC_CAMERA is not set # CONFIG_VIDEO_SH_MOBILE_CEU is not set Index: omapzoom04/drivers/media/video/Kconfig =================================================================== --- omapzoom04.orig/drivers/media/video/Kconfig +++ omapzoom04/drivers/media/video/Kconfig @@ -842,6 +842,14 @@ config VIDEO_OMAP3 source "drivers/media/video/isp/Kconfig" +config VIDEO_OMAP3_BUFFALLOC + bool "OMAP3430 ISP Workaround: Allocate memory at driver init" + depends on VIDEO_OMAP3 && ARCH_OMAP3430 + default y + ---help--- + This option is for allocating the workaround buffer at + camera init time. + config VIDEO_OMAP2 tristate "OMAP 2 Camera support (EXPERIMENTAL)" select VIDEOBUF_GEN Index: omapzoom04/drivers/media/video/isp/isp.c =================================================================== --- omapzoom04.orig/drivers/media/video/isp/isp.c +++ omapzoom04/drivers/media/video/isp/isp.c @@ -1185,6 +1185,15 @@ u32 isp_buf_allocation(void) return -ENOMEM; } num_sc = dma_map_sg(NULL, sglist_alloc, ISP_BUFFER_MAX_PAGES, 1); + return 0; +} + +/** + * isp_buf_mmap - Create MMU scatter-gather list. + * + **/ +u32 isp_buf_mmap(void) +{ buff_addr_mapped = ispmmu_map_sg(sglist_alloc, ISP_BUFFER_MAX_PAGES); if (!buff_addr_mapped) { printk(KERN_ERR "ispmmu_map_sg mapping failed "); @@ -1340,9 +1349,14 @@ u32 isp_calc_pipeline(struct v4l2_pix_fo isppreview_config_datapath(PRV_RAW_CCDC, PREVIEW_MEM); ispresizer_config_datapath(RSZ_MEM_YUV); if (alloc_done == 0) { +#if !defined(CONFIG_VIDEO_OMAP3_BUFFALLOC) rval = isp_buf_allocation(); if (rval) return -EINVAL; +#endif + rval = isp_buf_mmap(); + if (rval) + return -EINVAL; } #else isppreview_config_datapath(PRV_RAW_CCDC, PREVIEW_RSZ); @@ -2367,7 +2381,7 @@ int isp_put(void) if (--isp_obj.ref_count == 0) { isp_save_ctx(); off_mode = 1; -#if ISP_WORKAROUND +#if ISP_WORKAROUND && !defined(CONFIG_VIDEO_OMAP3_BUFFALLOC) isp_buf_free(); #endif isp_release_resources(); @@ -2420,6 +2434,9 @@ EXPORT_SYMBOL(isp_restore_context); **/ static int __init isp_init(void) { +#if ISP_WORKAROUND && defined(CONFIG_VIDEO_OMAP3_BUFFALLOC) + int rval; +#endif DPRINTK_ISPCTRL("+isp_init for Omap 3430 Camera ISP\n"); isp_obj.ref_count = 0; @@ -2427,6 +2444,14 @@ static int __init isp_init(void) spin_lock_init(&isp_obj.isp_temp_buf_lock); spin_lock_init(&isp_obj.lock); +#if ISP_WORKAROUND && defined(CONFIG_VIDEO_OMAP3_BUFFALLOC) + if (alloc_done == 0) { + rval = isp_buf_allocation(); + if (rval) + return -EINVAL; + } +#endif + if (request_irq(INT_34XX_CAM_IRQ, omap34xx_isp_isr, IRQF_SHARED, "Omap 34xx Camera ISP", &ispirq_obj)) { DPRINTK_ISPCTRL("Could not install ISR\n"); @@ -2459,6 +2484,9 @@ static void __exit isp_cleanup(void) isp_hist_cleanup(); isp_ccdc_cleanup(); free_irq(INT_34XX_CAM_IRQ, &ispirq_obj); +#if ISP_WORKAROUND && defined(CONFIG_VIDEO_OMAP3_BUFFALLOC) + isp_buf_free(); +#endif } /** -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html