Commit 574e1717 authored by Sylwester Nawrocki's avatar Sylwester Nawrocki Committed by Mauro Carvalho Chehab

[media] s5p-fimc: Add media entity initialization

Add intialization of the media entities for video capture
and mem-to-mem video nodes. The mem-to-mem entity has no pads
whereas the capture entity has single sink pad.
Also clean up the video node naming for consistency.
Signed-off-by: default avatarSylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent d4d4e3c9
...@@ -853,9 +853,8 @@ int fimc_register_capture_device(struct fimc_dev *fimc) ...@@ -853,9 +853,8 @@ int fimc_register_capture_device(struct fimc_dev *fimc)
fr->width = fr->f_width = fr->o_width = 640; fr->width = fr->f_width = fr->o_width = 640;
fr->height = fr->f_height = fr->o_height = 480; fr->height = fr->f_height = fr->o_height = 480;
if (!v4l2_dev->name[0]) snprintf(v4l2_dev->name, sizeof(v4l2_dev->name),
snprintf(v4l2_dev->name, sizeof(v4l2_dev->name), "%s.capture", dev_name(&fimc->pdev->dev));
"%s.capture", dev_name(&fimc->pdev->dev));
ret = v4l2_device_register(NULL, v4l2_dev); ret = v4l2_device_register(NULL, v4l2_dev);
if (ret) if (ret)
...@@ -867,11 +866,11 @@ int fimc_register_capture_device(struct fimc_dev *fimc) ...@@ -867,11 +866,11 @@ int fimc_register_capture_device(struct fimc_dev *fimc)
goto err_v4l2_reg; goto err_v4l2_reg;
} }
snprintf(vfd->name, sizeof(vfd->name), "%s:cap", strlcpy(vfd->name, v4l2_dev->name, sizeof(vfd->name));
dev_name(&fimc->pdev->dev));
vfd->fops = &fimc_capture_fops; vfd->fops = &fimc_capture_fops;
vfd->ioctl_ops = &fimc_capture_ioctl_ops; vfd->ioctl_ops = &fimc_capture_ioctl_ops;
vfd->v4l2_dev = v4l2_dev;
vfd->minor = -1; vfd->minor = -1;
vfd->release = video_device_release; vfd->release = video_device_release;
vfd->lock = &fimc->lock; vfd->lock = &fimc->lock;
...@@ -901,6 +900,11 @@ int fimc_register_capture_device(struct fimc_dev *fimc) ...@@ -901,6 +900,11 @@ int fimc_register_capture_device(struct fimc_dev *fimc)
vb2_queue_init(q); 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); ret = video_register_device(vfd, VFL_TYPE_GRABBER, -1);
if (ret) { if (ret) {
v4l2_err(v4l2_dev, "Failed to register video device\n"); v4l2_err(v4l2_dev, "Failed to register video device\n");
...@@ -910,10 +914,11 @@ int fimc_register_capture_device(struct fimc_dev *fimc) ...@@ -910,10 +914,11 @@ int fimc_register_capture_device(struct fimc_dev *fimc)
v4l2_info(v4l2_dev, v4l2_info(v4l2_dev,
"FIMC capture driver registered as /dev/video%d\n", "FIMC capture driver registered as /dev/video%d\n",
vfd->num); vfd->num);
return 0; return 0;
err_vd_reg: err_vd_reg:
media_entity_cleanup(&vfd->entity);
err_ent:
video_device_release(vfd); video_device_release(vfd);
err_v4l2_reg: err_v4l2_reg:
v4l2_device_unregister(v4l2_dev); v4l2_device_unregister(v4l2_dev);
...@@ -925,10 +930,11 @@ int fimc_register_capture_device(struct fimc_dev *fimc) ...@@ -925,10 +930,11 @@ int fimc_register_capture_device(struct fimc_dev *fimc)
void fimc_unregister_capture_device(struct fimc_dev *fimc) 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) if (vfd) {
video_unregister_device(capture->vfd); media_entity_cleanup(&vfd->entity);
video_unregister_device(vfd);
kfree(capture->ctx); }
kfree(fimc->vid_cap.ctx);
} }
...@@ -1507,10 +1507,8 @@ static int fimc_register_m2m_device(struct fimc_dev *fimc) ...@@ -1507,10 +1507,8 @@ static int fimc_register_m2m_device(struct fimc_dev *fimc)
pdev = fimc->pdev; pdev = fimc->pdev;
v4l2_dev = &fimc->m2m.v4l2_dev; v4l2_dev = &fimc->m2m.v4l2_dev;
/* set name if it is empty */ snprintf(v4l2_dev->name, sizeof(v4l2_dev->name),
if (!v4l2_dev->name[0]) "%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); ret = v4l2_device_register(&pdev->dev, v4l2_dev);
if (ret) if (ret)
...@@ -1524,6 +1522,7 @@ static int fimc_register_m2m_device(struct fimc_dev *fimc) ...@@ -1524,6 +1522,7 @@ static int fimc_register_m2m_device(struct fimc_dev *fimc)
vfd->fops = &fimc_m2m_fops; vfd->fops = &fimc_m2m_fops;
vfd->ioctl_ops = &fimc_m2m_ioctl_ops; vfd->ioctl_ops = &fimc_m2m_ioctl_ops;
vfd->v4l2_dev = v4l2_dev;
vfd->minor = -1; vfd->minor = -1;
vfd->release = video_device_release; vfd->release = video_device_release;
vfd->lock = &fimc->lock; vfd->lock = &fimc->lock;
...@@ -1541,17 +1540,22 @@ static int fimc_register_m2m_device(struct fimc_dev *fimc) ...@@ -1541,17 +1540,22 @@ static int fimc_register_m2m_device(struct fimc_dev *fimc)
goto err_m2m_r2; 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); ret = video_register_device(vfd, VFL_TYPE_GRABBER, -1);
if (ret) { if (ret) {
v4l2_err(v4l2_dev, v4l2_err(v4l2_dev,
"%s(): failed to register video device\n", __func__); "%s(): failed to register video device\n", __func__);
goto err_m2m_r3; goto err_m2m_r4;
} }
v4l2_info(v4l2_dev, v4l2_info(v4l2_dev,
"FIMC m2m driver registered as /dev/video%d\n", vfd->num); "FIMC m2m driver registered as /dev/video%d\n", vfd->num);
return 0; return 0;
err_m2m_r4:
media_entity_cleanup(&vfd->entity);
err_m2m_r3: err_m2m_r3:
v4l2_m2m_release(fimc->m2m.m2m_dev); v4l2_m2m_release(fimc->m2m.m2m_dev);
err_m2m_r2: err_m2m_r2:
...@@ -1564,12 +1568,13 @@ static int fimc_register_m2m_device(struct fimc_dev *fimc) ...@@ -1564,12 +1568,13 @@ static int fimc_register_m2m_device(struct fimc_dev *fimc)
static void fimc_unregister_m2m_device(struct fimc_dev *fimc) static void fimc_unregister_m2m_device(struct fimc_dev *fimc)
{ {
if (fimc) { if (fimc == NULL)
v4l2_m2m_release(fimc->m2m.m2m_dev); return;
video_unregister_device(fimc->m2m.vfd);
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) static void fimc_clk_put(struct fimc_dev *fimc)
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/videodev2.h> #include <linux/videodev2.h>
#include <linux/io.h> #include <linux/io.h>
#include <media/media-entity.h>
#include <media/videobuf2-core.h> #include <media/videobuf2-core.h>
#include <media/v4l2-device.h> #include <media/v4l2-device.h>
#include <media/v4l2-mem2mem.h> #include <media/v4l2-mem2mem.h>
...@@ -298,6 +300,7 @@ struct fimc_m2m_device { ...@@ -298,6 +300,7 @@ struct fimc_m2m_device {
* @vfd: video device node for camera capture mode * @vfd: video device node for camera capture mode
* @v4l2_dev: v4l2_device struct to manage subdevs * @v4l2_dev: v4l2_device struct to manage subdevs
* @sd: pointer to camera sensor subdevice currently in use * @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 * @fmt: Media Bus format configured at selected image sensor
* @pending_buf_q: the pending buffer queue head * @pending_buf_q: the pending buffer queue head
* @active_buf_q: the queue head of buffers scheduled in hardware * @active_buf_q: the queue head of buffers scheduled in hardware
...@@ -315,6 +318,7 @@ struct fimc_vid_cap { ...@@ -315,6 +318,7 @@ struct fimc_vid_cap {
struct video_device *vfd; struct video_device *vfd;
struct v4l2_device v4l2_dev; struct v4l2_device v4l2_dev;
struct v4l2_subdev *sd;; struct v4l2_subdev *sd;;
struct media_pad vd_pad;
struct v4l2_mbus_framefmt fmt; struct v4l2_mbus_framefmt fmt;
struct list_head pending_buf_q; struct list_head pending_buf_q;
struct list_head active_buf_q; struct list_head active_buf_q;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment