From patchwork Wed May 19 15:56:50 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: asheeshb@ti.com X-Patchwork-Id: 100910 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4JFw9Pq026151 for ; Wed, 19 May 2010 15:58:09 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753902Ab0ESP5k (ORCPT ); Wed, 19 May 2010 11:57:40 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:51629 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753897Ab0ESP5g (ORCPT ); Wed, 19 May 2010 11:57:36 -0400 Received: from dlep35.itg.ti.com ([157.170.170.118]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id o4JFvauj018890 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 19 May 2010 10:57:36 -0500 Received: from dlep26.itg.ti.com (localhost [127.0.0.1]) by dlep35.itg.ti.com (8.13.7/8.13.7) with ESMTP id o4JFvZmJ029549; Wed, 19 May 2010 10:57:35 -0500 (CDT) Received: from dlee73.ent.ti.com (localhost [127.0.0.1]) by dlep26.itg.ti.com (8.13.8/8.13.8) with ESMTP id o4JFvZmK013416; Wed, 19 May 2010 10:57:35 -0500 (CDT) Received: from localhost.localdomain (158.218.48.84) by dlee73.ent.ti.com (157.170.170.88) with Microsoft SMTP Server (TLS) id 8.1.358.0; Wed, 19 May 2010 10:57:35 -0500 From: To: CC: Asheesh Bhardwaj Subject: [PATCH 6/7] DM365 capture MMAP buffer allocation Date: Wed, 19 May 2010 10:56:50 -0500 Message-ID: <1274284611-13432-6-git-send-email-asheeshb@ti.com> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <1274284611-13432-5-git-send-email-asheeshb@ti.com> References: <1274284611-13432-1-git-send-email-asheeshb@ti.com> <1274284611-13432-2-git-send-email-asheeshb@ti.com> <1274284611-13432-3-git-send-email-asheeshb@ti.com> <1274284611-13432-4-git-send-email-asheeshb@ti.com> <1274284611-13432-5-git-send-email-asheeshb@ti.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 19 May 2010 15:58:09 +0000 (UTC) diff --git a/drivers/media/video/davinci/vpfe_capture.c b/drivers/media/video/davinci/vpfe_capture.c index 7748ce8..aeee5bb 100644 --- a/drivers/media/video/davinci/vpfe_capture.c +++ b/drivers/media/video/davinci/vpfe_capture.c @@ -87,11 +87,15 @@ static int debug; static u32 numbuffers = 3; static u32 bufsize = PAL_IMAGE_SIZE + SECOND_IMAGE_SIZE_MAX; static int interface; +static u32 cont_bufoffset = 0; +static u32 cont_bufsize = 0; module_param(interface, bool, S_IRUGO); module_param(numbuffers, uint, S_IRUGO); module_param(bufsize, uint, S_IRUGO); module_param(debug, bool, 0644); +module_param(cont_bufoffset, uint, S_IRUGO); +module_param(cont_bufsize, uint, S_IRUGO); /** * VPFE capture can be used for capturing video such as from TVP5146 or TVP7002 @@ -107,6 +111,8 @@ MODULE_PARM_DESC(interface, "interface 0-1 (default:0)"); MODULE_PARM_DESC(numbuffers, "buffer count (default:3)"); MODULE_PARM_DESC(bufsize, "buffer size in bytes, (default:1443840 bytes)"); MODULE_PARM_DESC(debug, "Debug level 0-1"); +MODULE_PARM_DESC(cont_bufoffset,"Capture buffer offset(default 0)"); +MODULE_PARM_DESC(cont_bufsize,"Capture buffer size(default 0)"); MODULE_DESCRIPTION("VPFE Video for Linux Capture Driver"); MODULE_LICENSE("GPL"); @@ -1828,10 +1834,14 @@ static int vpfe_videobuf_setup(struct videobuf_queue *vq, *size = config_params.device_bufsize; } - if (*count < config_params.min_numbuffers) - *count = config_params.min_numbuffers; + if ( config_params.video_limit) { + while (*size * *count > config_params.video_limit) + (*count)--; + } - v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, + if (*count < config_params.min_numbuffers) + *count = config_params.min_numbuffers; + v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "count=%d, size=%d\n", *count, *size); return 0; } @@ -2608,8 +2618,10 @@ static __init int vpfe_probe(struct platform_device *pdev) struct vpfe_device *vpfe_dev; struct i2c_adapter *i2c_adap; struct video_device *vfd; - int ret = -ENOMEM, i, j; + int ret = -ENOMEM, i, j, err; int num_subdevs = 0; + unsigned long phys_end_kernel; + size_t size; /* Get the pointer to the device object */ vpfe_dev = vpfe_initialize(); @@ -2622,6 +2634,25 @@ static __init int vpfe_probe(struct platform_device *pdev) vpfe_dev->pdev = &pdev->dev; + if(cont_bufsize) { + /* attempt to determine the end of Linux kernel memory */ + phys_end_kernel = virt_to_phys((void *)PAGE_OFFSET) + + (num_physpages << PAGE_SHIFT); + size = cont_bufsize; + phys_end_kernel += cont_bufoffset; + err = dma_declare_coherent_memory(&pdev->dev, phys_end_kernel, + phys_end_kernel, + size, + DMA_MEMORY_MAP | + DMA_MEMORY_EXCLUSIVE); + if (!err) { + dev_err(&pdev->dev, "Unable to declare MMAP memory.\n"); + ret = -ENOENT; + goto probe_free_dev_mem; + } + config_params.video_limit = size; + } + if (NULL == pdev->dev.platform_data) { v4l2_err(pdev->dev.driver, "Unable to get vpfe config\n"); ret = -ENOENT; diff --git a/include/media/davinci/vpfe_capture.h b/include/media/davinci/vpfe_capture.h index bd0f13a..785157c 100644 --- a/include/media/davinci/vpfe_capture.h +++ b/include/media/davinci/vpfe_capture.h @@ -228,6 +228,7 @@ struct vpfe_config_params { u8 numbuffers; u32 min_bufsize; u32 device_bufsize; + u32 video_limit; }; #endif /* End of __KERNEL__ */