From patchwork Fri Jun 10 18:36:43 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sylwester Nawrocki/Kernel \\(PLT\\) /SRPOL/Staff Engineer/Samsung Electronics" X-Patchwork-Id: 870212 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5AIbHZH017691 for ; Fri, 10 Jun 2011 18:37:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758046Ab1FJShP (ORCPT ); Fri, 10 Jun 2011 14:37:15 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:49667 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758012Ab1FJShH (ORCPT ); Fri, 10 Jun 2011 14:37:07 -0400 Received: from spt2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by mailout2.w1.samsung.com (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTP id <0LML009JO7PTE0@mailout2.w1.samsung.com>; Fri, 10 Jun 2011 19:37:06 +0100 (BST) Received: from linux.samsung.com ([106.116.38.10]) by spt2.w1.samsung.com (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTPA id <0LML007QK7PRCU@spt2.w1.samsung.com>; Fri, 10 Jun 2011 19:37:03 +0100 (BST) Received: from mcdsrvbld02.digital.local (unknown [106.116.37.23]) by linux.samsung.com (Postfix) with ESMTP id DFB7D270051; Fri, 10 Jun 2011 20:37:23 +0200 (CEST) Date: Fri, 10 Jun 2011 20:36:43 +0200 From: Sylwester Nawrocki Subject: [PATCH/RFC 02/19] s5p-fimc: Add media entity initialization In-reply-to: <1307731020-7100-1-git-send-email-s.nawrocki@samsung.com> To: linux-media@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: hans.verkuil@cisco.com, laurent.pinchart@ideasonboard.com, m.szyprowski@samsung.com, kyungmin.park@samsung.com, s.nawrocki@samsung.com, sw0312.kim@samsung.com, riverful.kim@samsung.com Message-id: <1307731020-7100-3-git-send-email-s.nawrocki@samsung.com> MIME-version: 1.0 X-Mailer: git-send-email 1.7.2.5 Content-type: TEXT/PLAIN Content-transfer-encoding: 7BIT References: <1307731020-7100-1-git-send-email-s.nawrocki@samsung.com> 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.6 (demeter1.kernel.org [140.211.167.41]); Fri, 10 Jun 2011 18:37:17 +0000 (UTC) Add intialization of the media entities for video capture and mem-to-mem video nodes. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park --- drivers/media/video/s5p-fimc/fimc-capture.c | 28 ++++++++++++++++---------- drivers/media/video/s5p-fimc/fimc-core.c | 27 +++++++++++++++---------- drivers/media/video/s5p-fimc/fimc-core.h | 4 +++ 3 files changed, 37 insertions(+), 22 deletions(-) diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c b/drivers/media/video/s5p-fimc/fimc-capture.c index 9432ea8..2748cca 100644 --- a/drivers/media/video/s5p-fimc/fimc-capture.c +++ b/drivers/media/video/s5p-fimc/fimc-capture.c @@ -842,9 +842,8 @@ int fimc_register_capture_device(struct fimc_dev *fimc) fr->width = fr->f_width = fr->o_width = 640; fr->height = fr->f_height = fr->o_height = 480; - if (!v4l2_dev->name[0]) - snprintf(v4l2_dev->name, sizeof(v4l2_dev->name), - "%s.capture", dev_name(&fimc->pdev->dev)); + snprintf(v4l2_dev->name, sizeof(v4l2_dev->name), + "%s.capture", dev_name(&fimc->pdev->dev)); ret = v4l2_device_register(NULL, v4l2_dev); if (ret) @@ -856,11 +855,11 @@ int fimc_register_capture_device(struct fimc_dev *fimc) goto err_v4l2_reg; } - snprintf(vfd->name, sizeof(vfd->name), "%s:cap", - dev_name(&fimc->pdev->dev)); + strlcpy(vfd->name, v4l2_dev->name, sizeof(vfd->name)); vfd->fops = &fimc_capture_fops; vfd->ioctl_ops = &fimc_capture_ioctl_ops; + vfd->v4l2_dev = v4l2_dev; vfd->minor = -1; vfd->release = video_device_release; vfd->lock = &fimc->lock; @@ -890,6 +889,11 @@ int fimc_register_capture_device(struct fimc_dev *fimc) vb2_queue_init(q); + fimc->vid_cap.vd_pad.flags = MEDIA_PAD_FL_SINK; + ret = media_entity_init(&vfd->entity, 1, &fimc->vid_cap.vd_pad, 0); + if (ret) + goto err_ent; + ret = video_register_device(vfd, VFL_TYPE_GRABBER, -1); if (ret) { v4l2_err(v4l2_dev, "Failed to register video device\n"); @@ -899,10 +903,11 @@ int fimc_register_capture_device(struct fimc_dev *fimc) v4l2_info(v4l2_dev, "FIMC capture driver registered as /dev/video%d\n", vfd->num); - return 0; err_vd_reg: + media_entity_cleanup(&vfd->entity); +err_ent: video_device_release(vfd); err_v4l2_reg: v4l2_device_unregister(v4l2_dev); @@ -914,10 +919,11 @@ err_info: void fimc_unregister_capture_device(struct fimc_dev *fimc) { - struct fimc_vid_cap *capture = &fimc->vid_cap; + struct video_device *vfd = fimc->vid_cap.vfd; - if (capture->vfd) - video_unregister_device(capture->vfd); - - kfree(capture->ctx); + if (vfd) { + media_entity_cleanup(&vfd->entity); + video_unregister_device(vfd); + } + kfree(fimc->vid_cap.ctx); } diff --git a/drivers/media/video/s5p-fimc/fimc-core.c b/drivers/media/video/s5p-fimc/fimc-core.c index 4540280..ad15d46 100644 --- a/drivers/media/video/s5p-fimc/fimc-core.c +++ b/drivers/media/video/s5p-fimc/fimc-core.c @@ -1504,10 +1504,8 @@ static int fimc_register_m2m_device(struct fimc_dev *fimc) pdev = fimc->pdev; v4l2_dev = &fimc->m2m.v4l2_dev; - /* set name if it is empty */ - if (!v4l2_dev->name[0]) - snprintf(v4l2_dev->name, sizeof(v4l2_dev->name), - "%s.m2m", dev_name(&pdev->dev)); + snprintf(v4l2_dev->name, sizeof(v4l2_dev->name), + "%s.m2m", dev_name(&pdev->dev)); ret = v4l2_device_register(&pdev->dev, v4l2_dev); if (ret) @@ -1521,6 +1519,7 @@ static int fimc_register_m2m_device(struct fimc_dev *fimc) vfd->fops = &fimc_m2m_fops; vfd->ioctl_ops = &fimc_m2m_ioctl_ops; + vfd->v4l2_dev = v4l2_dev; vfd->minor = -1; vfd->release = video_device_release; vfd->lock = &fimc->lock; @@ -1538,17 +1537,22 @@ static int fimc_register_m2m_device(struct fimc_dev *fimc) goto err_m2m_r2; } + ret = media_entity_init(&vfd->entity, 0, NULL, 0); + if (ret) + goto err_m2m_r3; + ret = video_register_device(vfd, VFL_TYPE_GRABBER, -1); if (ret) { v4l2_err(v4l2_dev, "%s(): failed to register video device\n", __func__); - goto err_m2m_r3; + goto err_m2m_r4; } v4l2_info(v4l2_dev, "FIMC m2m driver registered as /dev/video%d\n", vfd->num); return 0; - +err_m2m_r4: + media_entity_cleanup(&vfd->entity); err_m2m_r3: v4l2_m2m_release(fimc->m2m.m2m_dev); err_m2m_r2: @@ -1561,12 +1565,13 @@ err_m2m_r1: void fimc_unregister_m2m_device(struct fimc_dev *fimc) { - if (fimc) { - v4l2_m2m_release(fimc->m2m.m2m_dev); - video_unregister_device(fimc->m2m.vfd); + if (fimc == NULL) + return; - v4l2_device_unregister(&fimc->m2m.v4l2_dev); - } + v4l2_m2m_release(fimc->m2m.m2m_dev); + v4l2_device_unregister(&fimc->m2m.v4l2_dev); + media_entity_cleanup(&fimc->m2m.vfd->entity); + video_unregister_device(fimc->m2m.vfd); } static void fimc_clk_put(struct fimc_dev *fimc) diff --git a/drivers/media/video/s5p-fimc/fimc-core.h b/drivers/media/video/s5p-fimc/fimc-core.h index 21dfcac..55c1410 100644 --- a/drivers/media/video/s5p-fimc/fimc-core.h +++ b/drivers/media/video/s5p-fimc/fimc-core.h @@ -16,6 +16,8 @@ #include #include #include + +#include #include #include #include @@ -298,6 +300,7 @@ struct fimc_m2m_device { * @vfd: video device node for camera capture mode * @v4l2_dev: v4l2_device struct to manage subdevs * @sd: pointer to camera sensor subdevice currently in use + * @vd_pad: fimc video capture node pad * @fmt: Media Bus format configured at selected image sensor * @pending_buf_q: the pending buffer queue head * @active_buf_q: the queue head of buffers scheduled in hardware @@ -315,6 +318,7 @@ struct fimc_vid_cap { struct video_device *vfd; struct v4l2_device v4l2_dev; struct v4l2_subdev *sd;; + struct media_pad vd_pad; struct v4l2_mbus_framefmt fmt; struct list_head pending_buf_q; struct list_head active_buf_q;