All of lore.kernel.org
 help / color / mirror / Atom feed
From: <asheeshb@ti.com>
To: <linux-media@vger.kernel.org>
Cc: Asheesh Bhardwaj <asheesh@lab1.dmlab>
Subject: [PATCH 5/7] DM365 MMAP buffer allocation for display driver
Date: Wed, 19 May 2010 10:56:49 -0500	[thread overview]
Message-ID: <1274284611-13432-5-git-send-email-asheeshb@ti.com> (raw)
In-Reply-To: <1274284611-13432-4-git-send-email-asheeshb@ti.com>

From: Asheesh Bhardwaj <asheesh@lab1.dmlab>

---
 drivers/media/video/davinci/davinci_display.c |   79 ++++++++++++++++++++++++-
 include/media/davinci/davinci_display.h       |    1 +
 2 files changed, 77 insertions(+), 3 deletions(-)

diff --git a/drivers/media/video/davinci/davinci_display.c b/drivers/media/video/davinci/davinci_display.c
index 4c4efef..8eb98c4 100644
--- a/drivers/media/video/davinci/davinci_display.c
+++ b/drivers/media/video/davinci/davinci_display.c
@@ -45,11 +45,15 @@
 
 static u32 video2_numbuffers = 3;
 static u32 video3_numbuffers = 3;
+static u32 cont2_bufoffset = 0;
+static u32 cont2_bufsize = 0;
+static u32 cont3_bufoffset = 0;
+static u32 cont3_bufsize = 0;
 
 #define DAVINCI_DISPLAY_HD_BUF_SIZE (1280*720*2)
 #define DAVINCI_DISPLAY_SD_BUF_SIZE (720*576*2)
 
-static u32 video2_bufsize = DAVINCI_DISPLAY_SD_BUF_SIZE;
+static u32 video2_bufsize = DAVINCI_DISPLAY_HD_BUF_SIZE;
 static u32 video3_bufsize = DAVINCI_DISPLAY_SD_BUF_SIZE;
 
 module_param(video2_numbuffers, uint, S_IRUGO);
@@ -57,15 +61,24 @@ module_param(video3_numbuffers, uint, S_IRUGO);
 
 module_param(video2_bufsize, uint, S_IRUGO);
 module_param(video3_bufsize, uint, S_IRUGO);
+module_param(cont2_bufoffset, uint, S_IRUGO);
+module_param(cont2_bufsize, uint, S_IRUGO);
+module_param(cont3_bufoffset, uint, S_IRUGO);
+module_param(cont3_bufsize, uint, S_IRUGO);
+
+MODULE_PARM_DESC(cont2_bufoffset,"Display offset(default 0)");
+MODULE_PARM_DESC(cont2_bufsize,"Display buffer size(default 0)");
+MODULE_PARM_DESC(cont3_bufoffset,"Display offset(default 0)");
+MODULE_PARM_DESC(cont3_bufsize,"Display buffer size(default 0)");
 
 #define DAVINCI_DEFAULT_NUM_BUFS 3
 static struct buf_config_params display_buf_config_params = {
 	.min_numbuffers = DAVINCI_DEFAULT_NUM_BUFS,
 	.numbuffers[0] = DAVINCI_DEFAULT_NUM_BUFS,
 	.numbuffers[1] = DAVINCI_DEFAULT_NUM_BUFS,
-	.min_bufsize[0] = DAVINCI_DISPLAY_SD_BUF_SIZE,
+	.min_bufsize[0] = DAVINCI_DISPLAY_HD_BUF_SIZE,
 	.min_bufsize[1] = DAVINCI_DISPLAY_SD_BUF_SIZE,
-	.layer_bufsize[0] = DAVINCI_DISPLAY_SD_BUF_SIZE,
+	.layer_bufsize[0] = DAVINCI_DISPLAY_HD_BUF_SIZE,
 	.layer_bufsize[1] = DAVINCI_DISPLAY_SD_BUF_SIZE,
 };
 
@@ -167,10 +180,17 @@ static int davinci_buffer_setup(struct videobuf_queue *q, unsigned int *count,
 		if (*size > buf_size)
 			*size = buf_size;
 
+        /*Checking if the buffer size exceeds the available buffer*/
+	if (display_buf_config_params.video_limit[layer->device_id]) {
+		while (*size * *count > ( display_buf_config_params.video_limit[layer->device_id]))
+			(*count)--;
+        }
+      
 	/* Store number of buffers allocated in numbuffer member */
 	if (*count < display_buf_config_params.min_numbuffers)
 		*count = layer->numbuffers = display_buf_config_params.numbuffers[layer->device_id];
 	dev_dbg(davinci_display_dev, "</davinci_buffer_setup>\n");
+
 	return 0;
 }
 
@@ -1577,6 +1597,8 @@ static __init int davinci_probe(struct device *device)
 	struct video_device *vbd = NULL;
 	struct display_obj *layer = NULL;
 	struct platform_device *pdev;
+	unsigned long phys_end_kernel;
+	size_t size;
 
 	davinci_display_dev = device;
 
@@ -1588,6 +1610,51 @@ static __init int davinci_probe(struct device *device)
 		dev_err(davinci_display_dev, "probed for an unknown device\n");
 		return -ENODEV;
 	}
+
+       /* Initialising the memory from the input arguments file for contiguous memory buffers and avoid defragmentation */
+       
+	if(cont2_bufsize) {
+		/* attempt to determine the end of Linux kernel memory */
+		phys_end_kernel = virt_to_phys((void *)PAGE_OFFSET) +
+			(num_physpages << PAGE_SHIFT);
+		phys_end_kernel += cont2_bufoffset; 
+		size = cont2_bufsize;
+                       
+		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");
+			err = -ENOMEM;
+			goto probe_out;
+		display_buf_config_params.video_limit[DAVINCI_DISPLAY_DEVICE_0] = size;
+		}
+	} 
+	
+	if(cont3_bufsize) {
+	    /* attempt to determine the end of Linux kernel memory */
+		phys_end_kernel = virt_to_phys((void *)PAGE_OFFSET) +
+			(num_physpages << PAGE_SHIFT);
+			phys_end_kernel += cont3_bufoffset; 
+			size = cont3_bufsize;
+                       
+		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");
+			err = -ENOMEM;
+			goto probe_out;
+		display_buf_config_params.video_limit[DAVINCI_DISPLAY_DEVICE_1] = size;
+		} 
+	}
+
 	for (i = 0; i < DAVINCI_DISPLAY_MAX_DEVICES; i++) {
 		/* Get the pointer to the layer object */
 		layer = davinci_dm.dev[i];
@@ -1743,6 +1810,12 @@ static __init int davinci_display_init(void)
 	display_buf_config_params.numbuffers[DAVINCI_DISPLAY_DEVICE_1] =
 		video3_numbuffers;
 
+	/*set size of buffers, they could come from bootargs*/
+	display_buf_config_params.layer_bufsize[DAVINCI_DISPLAY_DEVICE_0] =
+		video2_bufsize;
+	display_buf_config_params.layer_bufsize[DAVINCI_DISPLAY_DEVICE_1] =
+		video3_bufsize;
+   
 	if (cpu_is_davinci_dm355()) {
 		strcpy(davinci_display_videocap.card, DM355_EVM_CARD);
 	} else if (cpu_is_davinci_dm365())
diff --git a/include/media/davinci/davinci_display.h b/include/media/davinci/davinci_display.h
index 8524328..d62b849 100644
--- a/include/media/davinci/davinci_display.h
+++ b/include/media/davinci/davinci_display.h
@@ -171,6 +171,7 @@ struct buf_config_params {
 	u8 numbuffers[DAVINCI_DISPLAY_MAX_DEVICES];
 	u32 min_bufsize[DAVINCI_DISPLAY_MAX_DEVICES];
 	u32 layer_bufsize[DAVINCI_DISPLAY_MAX_DEVICES];
+	u32 video_limit[DAVINCI_DISPLAY_MAX_DEVICES];
 };
 
 #endif				/* End of __KERNEL__ */
-- 
1.6.3.3


  reply	other threads:[~2010-05-19 15:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-19 15:56 [PATCH 1/7] changed driver for MMAP buffer asheeshb
2010-05-19 15:56 ` [PATCH 2/7] Patch for adding imagesize corrected for MMAP buffers and behave the same as user allocated buffers. The sizeimage parameter is giving the wrong size from the driver and it has to be corrected in S_FMT and TRY_FMT ioctls asheeshb
2010-05-19 15:56   ` [PATCH 3/7] Patch for capture driver MMAP buffer allocation. The user can specify the size of the buffers with an offset from the kernel images asheeshb
2010-05-19 15:56     ` [PATCH 4/7] Patch for vpif capture driver to get the right size image for the MMAP buffers asheeshb
2010-05-19 15:56       ` asheeshb [this message]
2010-05-19 15:56         ` [PATCH 6/7] DM365 capture MMAP buffer allocation asheeshb
2010-05-19 15:56           ` [PATCH 7/7] Patch MMAP buffer bufsize support upto 1080p resolution on capture driver DM365 asheeshb
  -- strict thread matches above, loose matches on Subject: below --
2010-05-19 16:44 asheeshb
2010-05-19 16:44 ` [PATCH 1/7] changed driver for MMAP buffer asheeshb
2010-05-19 16:44   ` [PATCH 2/7] Patch for adding imagesize corrected for MMAP buffers asheeshb
2010-05-19 16:44     ` [PATCH 3/7] Patch for capture driver MMAP buffer allocation asheeshb
2010-05-19 16:44       ` [PATCH 4/7] Change vpif capture driver to get the right size image for the MMAP buffers asheeshb
2010-05-19 16:44         ` [PATCH 5/7] DM365 MMAP buffer allocation for display driver asheeshb

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1274284611-13432-5-git-send-email-asheeshb@ti.com \
    --to=asheeshb@ti.com \
    --cc=asheesh@lab1.dmlab \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.