All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
To: LMML <linux-media@vger.kernel.org>,
	Hans Verkuil <hans.verkuil@cisco.com>
Cc: DLOS <davinci-linux-open-source@linux.davincidsp.com>,
	LKML <linux-kernel@vger.kernel.org>,
	"Lad, Prabhakar" <prabhakar.csengg@gmail.com>
Subject: [PATCH v5 01/49] media: davinci: vpif_display: initalize vb2 queue and DMA context during probe
Date: Fri, 16 May 2014 19:03:05 +0530	[thread overview]
Message-ID: <1400247235-31434-2-git-send-email-prabhakar.csengg@gmail.com> (raw)
In-Reply-To: <1400247235-31434-1-git-send-email-prabhakar.csengg@gmail.com>

From: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>

this patch moves the initalization of vb2 queue and
the DMA context to probe() and clean up in remove()
callback respectively.

Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
---
 drivers/media/platform/davinci/vpif_display.c |   86 ++++++++++++-------------
 1 file changed, 41 insertions(+), 45 deletions(-)

diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c
index d03487f..dbd4f0f 100644
--- a/drivers/media/platform/davinci/vpif_display.c
+++ b/drivers/media/platform/davinci/vpif_display.c
@@ -74,12 +74,12 @@ static void vpif_config_addr(struct channel_obj *ch, int muxmode);
  */
 static int vpif_buffer_prepare(struct vb2_buffer *vb)
 {
-	struct vpif_fh *fh = vb2_get_drv_priv(vb->vb2_queue);
 	struct vb2_queue *q = vb->vb2_queue;
+	struct channel_obj *ch = vb2_get_drv_priv(q);
 	struct common_obj *common;
 	unsigned long addr;
 
-	common = &fh->channel->common[VPIF_VIDEO_INDEX];
+	common = &ch->common[VPIF_VIDEO_INDEX];
 	if (vb->state != VB2_BUF_STATE_ACTIVE &&
 		vb->state != VB2_BUF_STATE_PREPARED) {
 		vb2_set_plane_payload(vb, 0, common->fmt.fmt.pix.sizeimage);
@@ -112,8 +112,7 @@ static int vpif_buffer_queue_setup(struct vb2_queue *vq,
 				unsigned int *nbuffers, unsigned int *nplanes,
 				unsigned int sizes[], void *alloc_ctxs[])
 {
-	struct vpif_fh *fh = vb2_get_drv_priv(vq);
-	struct channel_obj *ch = fh->channel;
+	struct channel_obj *ch = vb2_get_drv_priv(vq);
 	struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX];
 	unsigned long size;
 
@@ -154,10 +153,9 @@ static int vpif_buffer_queue_setup(struct vb2_queue *vq,
  */
 static void vpif_buffer_queue(struct vb2_buffer *vb)
 {
-	struct vpif_fh *fh = vb2_get_drv_priv(vb->vb2_queue);
 	struct vpif_disp_buffer *buf = container_of(vb,
 				struct vpif_disp_buffer, vb);
-	struct channel_obj *ch = fh->channel;
+	struct channel_obj *ch = vb2_get_drv_priv(vb->vb2_queue);
 	struct common_obj *common;
 	unsigned long flags;
 
@@ -175,10 +173,9 @@ static void vpif_buffer_queue(struct vb2_buffer *vb)
  */
 static void vpif_buf_cleanup(struct vb2_buffer *vb)
 {
-	struct vpif_fh *fh = vb2_get_drv_priv(vb->vb2_queue);
 	struct vpif_disp_buffer *buf = container_of(vb,
 					struct vpif_disp_buffer, vb);
-	struct channel_obj *ch = fh->channel;
+	struct channel_obj *ch = vb2_get_drv_priv(vb->vb2_queue);
 	struct common_obj *common;
 	unsigned long flags;
 
@@ -192,8 +189,7 @@ static void vpif_buf_cleanup(struct vb2_buffer *vb)
 
 static void vpif_wait_prepare(struct vb2_queue *vq)
 {
-	struct vpif_fh *fh = vb2_get_drv_priv(vq);
-	struct channel_obj *ch = fh->channel;
+	struct channel_obj *ch = vb2_get_drv_priv(vq);
 	struct common_obj *common;
 
 	common = &ch->common[VPIF_VIDEO_INDEX];
@@ -202,8 +198,7 @@ static void vpif_wait_prepare(struct vb2_queue *vq)
 
 static void vpif_wait_finish(struct vb2_queue *vq)
 {
-	struct vpif_fh *fh = vb2_get_drv_priv(vq);
-	struct channel_obj *ch = fh->channel;
+	struct channel_obj *ch = vb2_get_drv_priv(vq);
 	struct common_obj *common;
 
 	common = &ch->common[VPIF_VIDEO_INDEX];
@@ -226,8 +221,7 @@ static int vpif_start_streaming(struct vb2_queue *vq, unsigned int count)
 {
 	struct vpif_display_config *vpif_config_data =
 					vpif_dev->platform_data;
-	struct vpif_fh *fh = vb2_get_drv_priv(vq);
-	struct channel_obj *ch = fh->channel;
+	struct channel_obj *ch = vb2_get_drv_priv(vq);
 	struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX];
 	struct vpif_params *vpif = &ch->vpifparams;
 	unsigned long addr = 0;
@@ -310,8 +304,7 @@ static int vpif_start_streaming(struct vb2_queue *vq, unsigned int count)
 /* abort streaming and wait for last buffer */
 static void vpif_stop_streaming(struct vb2_queue *vq)
 {
-	struct vpif_fh *fh = vb2_get_drv_priv(vq);
-	struct channel_obj *ch = fh->channel;
+	struct channel_obj *ch = vb2_get_drv_priv(vq);
 	struct common_obj *common;
 	unsigned long flags;
 
@@ -794,10 +787,6 @@ static int vpif_release(struct file *filep)
 	if (fh->io_allowed[VPIF_VIDEO_INDEX]) {
 		/* Reset io_usrs member of channel object */
 		common->io_usrs = 0;
-		/* Free buffers allocated */
-		vb2_queue_release(&common->buffer_queue);
-		vb2_dma_contig_cleanup_ctx(common->alloc_ctx);
-
 		common->numbuffers =
 		    config_params.numbuffers[ch->channel_id];
 	}
@@ -939,9 +928,7 @@ static int vpif_reqbufs(struct file *file, void *priv,
 	struct channel_obj *ch = fh->channel;
 	struct common_obj *common;
 	enum v4l2_field field;
-	struct vb2_queue *q;
 	u8 index = 0;
-	int ret;
 
 	/* This file handle has not initialized the channel,
 	   It is not allowed to do settings */
@@ -973,35 +960,12 @@ static int vpif_reqbufs(struct file *file, void *priv,
 	} else {
 		field = V4L2_VBI_INTERLACED;
 	}
-	/* Initialize videobuf2 queue as per the buffer type */
-	common->alloc_ctx = vb2_dma_contig_init_ctx(vpif_dev);
-	if (IS_ERR(common->alloc_ctx)) {
-		vpif_err("Failed to get the context\n");
-		return PTR_ERR(common->alloc_ctx);
-	}
-	q = &common->buffer_queue;
-	q->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
-	q->io_modes = VB2_MMAP | VB2_USERPTR;
-	q->drv_priv = fh;
-	q->ops = &video_qops;
-	q->mem_ops = &vb2_dma_contig_memops;
-	q->buf_struct_size = sizeof(struct vpif_disp_buffer);
-	q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
-	q->min_buffers_needed = 1;
-
-	ret = vb2_queue_init(q);
-	if (ret) {
-		vpif_err("vpif_display: vb2_queue_init() failed\n");
-		vb2_dma_contig_cleanup_ctx(common->alloc_ctx);
-		return ret;
-	}
 	/* Set io allowed member of file handle to TRUE */
 	fh->io_allowed[index] = 1;
 	/* Increment io usrs member of channel object to 1 */
 	common->io_usrs = 1;
 	/* Store type of memory requested in channel object */
 	common->memory = reqbuf->memory;
-	INIT_LIST_HEAD(&common->dma_queue);
 	/* Allocate buffers */
 	return vb2_reqbufs(&common->buffer_queue, reqbuf);
 }
@@ -1637,6 +1601,7 @@ static int vpif_probe_complete(void)
 {
 	struct common_obj *common;
 	struct channel_obj *ch;
+	struct vb2_queue *q;
 	int j, err, k;
 
 	for (j = 0; j < VPIF_DISPLAY_MAX_DEVICES; j++) {
@@ -1685,6 +1650,32 @@ static int vpif_probe_complete(void)
 		if (err)
 			goto probe_out;
 
+		/* Initialize vb2 queue */
+		q = &common->buffer_queue;
+		q->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
+		q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
+		q->drv_priv = ch;
+		q->ops = &video_qops;
+		q->mem_ops = &vb2_dma_contig_memops;
+		q->buf_struct_size = sizeof(struct vpif_disp_buffer);
+		q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+		q->min_buffers_needed = 1;
+
+		err = vb2_queue_init(q);
+		if (err) {
+			vpif_err("vpif_display: vb2_queue_init() failed\n");
+			goto probe_out;
+		}
+
+		common->alloc_ctx = vb2_dma_contig_init_ctx(vpif_dev);
+		if (IS_ERR(common->alloc_ctx)) {
+			vpif_err("Failed to get the context\n");
+			err = PTR_ERR(common->alloc_ctx);
+			goto probe_out;
+		}
+
+		INIT_LIST_HEAD(&common->dma_queue);
+
 		/* register video device */
 		vpif_dbg(1, debug, "channel=%x,channel->video_dev=%x\n",
 			 (int)ch, (int)&ch->video_dev);
@@ -1700,6 +1691,8 @@ static int vpif_probe_complete(void)
 probe_out:
 	for (k = 0; k < j; k++) {
 		ch = vpif_obj.dev[k];
+		common = &ch->common[k];
+		vb2_dma_contig_cleanup_ctx(common->alloc_ctx);
 		video_unregister_device(ch->video_dev);
 		video_device_release(ch->video_dev);
 		ch->video_dev = NULL;
@@ -1865,6 +1858,7 @@ vpif_unregister:
  */
 static int vpif_remove(struct platform_device *device)
 {
+	struct common_obj *common;
 	struct channel_obj *ch;
 	int i;
 
@@ -1875,6 +1869,8 @@ static int vpif_remove(struct platform_device *device)
 	for (i = 0; i < VPIF_DISPLAY_MAX_DEVICES; i++) {
 		/* Get the pointer to the channel object */
 		ch = vpif_obj.dev[i];
+		common = &ch->common[i];
+		vb2_dma_contig_cleanup_ctx(common->alloc_ctx);
 		/* Unregister video device */
 		video_unregister_device(ch->video_dev);
 
-- 
1.7.9.5


  reply	other threads:[~2014-05-16 13:35 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-16 13:33 [PATCH v5 00/49] DaVinci: vpif: upgrade with v4l helpers and v4l compliance fixes Lad, Prabhakar
2014-05-16 13:33 ` Lad, Prabhakar [this message]
2014-05-16 13:33 ` [PATCH v5 01/49] media: davinci: vpif_display: initialize vb2 queue and DMA context during probe Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 02/49] media: davinci: vpif_display: drop buf_init() callback Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 03/49] media: davinci: vpif_display: use vb2_ops_wait_prepare/finish helper functions Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 04/49] media: davinci: vpif_display: release buffers in case start_streaming() call back fails Lad, Prabhakar
2014-05-23  8:35   ` Hans Verkuil
2014-05-24  4:02     ` Prabhakar Lad
2014-05-16 13:33 ` [PATCH v5 05/49] media: davinci: vpif_display: drop buf_cleanup() callback Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 06/49] media: davinci: vpif_display: improve vpif_buffer_prepare() callback Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 07/49] media: davinci: vpif_display: improve vpif_buffer_queue_setup() function Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 08/49] media: davinci: vpif_display: improve start/stop_streaming callbacks Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 09/49] media: davinci: vpif_display: use vb2_fop_mmap/poll Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 10/49] media: davinci: vpif_display: use v4l2_fh_open and vb2_fop_release Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 11/49] media: davinci: vpif_display: use vb2_ioctl_* helpers Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 12/49] media: davinci: vpif_display: drop unused member fbuffers Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 13/49] media: davinci: vpif_display: drop reserving memory for device Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 14/49] media: davinci: vpif_display: drop unnecessary field memory Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 15/49] media: davinci: vpif_display: drop numbuffers field from common_obj Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 16/49] media: davinic: vpif_display: drop started member from struct common_obj Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 17/49] media: davinci: vpif_display: initialize the video device in single place Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 18/49] media: davinci: vpif_display: drop unneeded module params Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 19/49] media: davinci: vpif_display: drop cropcap Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 20/49] media: davinci: vpif_display: group v4l2_ioctl_ops Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 21/49] media: davinci: vpif_display: use SIMPLE_DEV_PM_OPS Lad, Prabhakar
2014-05-23  8:48   ` Hans Verkuil
2014-05-16 13:33 ` [PATCH v5 22/49] media: davinci: vpif_display: return -ENODATA for *dv_timings calls Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 23/49] media: davinci: vpif_display: return -ENODATA for *std calls Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 24/49] media: davinci; vpif_display: fix checkpatch error Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 25/49] media: davinci: vpif_display: fix v4l-complinace issues Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 26/49] media: davinci: vpif_capture: initalize vb2 queue and DMA context during probe Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 27/49] media: davinci: vpif_capture: drop buf_init() callback Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 28/49] media: davinci: vpif_capture: use vb2_ops_wait_prepare/finish helper functions Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 28/49] media: davinci: vpif_display: " Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 29/49] media: davinci: vpif_capture: release buffers in case start_streaming() call back fails Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 30/49] media: davinci: vpif_capture: drop buf_cleanup() callback Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 31/49] media: davinci: vpif_capture: improve vpif_buffer_prepare() callback Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 32/49] media: davinci: vpif_capture: improve vpif_buffer_queue_setup() function Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 33/49] media: davinci: vpif_capture: improve start/stop_streaming callbacks Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 34/49] media: davinci: vpif_capture: use vb2_fop_mmap/poll Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 35/49] media: davinci: vpif_capture: use v4l2_fh_open and vb2_fop_release Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 36/49] media: davinci: vpif_capture: use vb2_ioctl_* helpers Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 37/49] media: davinci: vpif_capture: drop reserving memory for device Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 38/49] media: davinci: vpif_capture: drop unnecessary field memory Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 39/49] media: davinic: vpif_capture: drop started member from struct common_obj Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 40/49] media: davinci: vpif_capture: initialize the video device in single place Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 41/49] media: davinci: vpif_capture: drop unneeded module params Lad, Prabhakar
2014-05-23 22:38   ` Mauro Carvalho Chehab
2014-05-24  4:27     ` Prabhakar Lad
2014-05-16 13:33 ` [PATCH v5 42/49] media: davinci: vpif_capture: drop cropcap Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 43/49] media: davinci: vpif_capture: group v4l2_ioctl_ops Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 44/49] media: davinci: vpif_capture: use SIMPLE_DEV_PM_OPS Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 45/49] media: davinci: vpif_capture: return -ENODATA for *dv_timings calls Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 46/49] media: davinci: vpif_capture: return -ENODATA for *std calls Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 47/49] media: davinci: vpif_capture: drop check __KERNEL__ Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 48/49] media: davinci: vpif_capture: fix v4l-complinace issues Lad, Prabhakar
2014-05-16 13:33 ` [PATCH v5 49/49] media: davinci: vpif: add Copyright message Lad, Prabhakar
2014-05-23  8:30 ` [PATCH v5 00/49] DaVinci: vpif: upgrade with v4l helpers and v4l compliance fixes Hans Verkuil
2014-05-24  4:09   ` Prabhakar Lad
2014-05-23  9:05 ` Hans Verkuil

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=1400247235-31434-2-git-send-email-prabhakar.csengg@gmail.com \
    --to=prabhakar.csengg@gmail.com \
    --cc=davinci-linux-open-source@linux.davincidsp.com \
    --cc=hans.verkuil@cisco.com \
    --cc=linux-kernel@vger.kernel.org \
    --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.