diff options
author | Sylwester Nawrocki <s.nawrocki@samsung.com> | 2011-06-10 14:36:48 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-09-06 14:53:39 -0400 |
commit | 30c9939d79d6edf64092148842835893d156b672 (patch) | |
tree | da9685402035914a0ff578cd5ac9f75b01730650 /drivers/media/video/s5p-fimc | |
parent | 2319c539e39b9e74f0477887bb8ff45816cb38d9 (diff) |
[media] s5p-fimc: Remove v4l2_device from video capture and m2m driver
Currently there is a v4l2_device instance being registered per each
(capture and memory-to-memory) video node created per FIMC H/W instance.
This patch is a prerequisite for using the top level v4l2_device
instantiated by the media device driver.
To retain current debug trace semantic (so it's possible to distinguish
between the capture and m2m FIMC) the video_device is used in place
of v4l2_device where appropriate.
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/s5p-fimc')
-rw-r--r-- | drivers/media/video/s5p-fimc/fimc-capture.c | 39 | ||||
-rw-r--r-- | drivers/media/video/s5p-fimc/fimc-core.c | 54 | ||||
-rw-r--r-- | drivers/media/video/s5p-fimc/fimc-core.h | 15 | ||||
-rw-r--r-- | drivers/media/video/s5p-fimc/fimc-reg.c | 7 |
4 files changed, 47 insertions, 68 deletions
diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c b/drivers/media/video/s5p-fimc/fimc-capture.c index 40f3330869d4..a1ac986a5e72 100644 --- a/drivers/media/video/s5p-fimc/fimc-capture.c +++ b/drivers/media/video/s5p-fimc/fimc-capture.c | |||
@@ -191,7 +191,6 @@ static int buffer_prepare(struct vb2_buffer *vb) | |||
191 | { | 191 | { |
192 | struct vb2_queue *vq = vb->vb2_queue; | 192 | struct vb2_queue *vq = vb->vb2_queue; |
193 | struct fimc_ctx *ctx = vq->drv_priv; | 193 | struct fimc_ctx *ctx = vq->drv_priv; |
194 | struct v4l2_device *v4l2_dev = &ctx->fimc_dev->m2m.v4l2_dev; | ||
195 | int i; | 194 | int i; |
196 | 195 | ||
197 | if (!ctx->d_frame.fmt || vq->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) | 196 | if (!ctx->d_frame.fmt || vq->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) |
@@ -201,7 +200,8 @@ static int buffer_prepare(struct vb2_buffer *vb) | |||
201 | unsigned long size = get_plane_size(&ctx->d_frame, i); | 200 | unsigned long size = get_plane_size(&ctx->d_frame, i); |
202 | 201 | ||
203 | if (vb2_plane_size(vb, i) < size) { | 202 | if (vb2_plane_size(vb, i) < size) { |
204 | v4l2_err(v4l2_dev, "User buffer too small (%ld < %ld)\n", | 203 | v4l2_err(ctx->fimc_dev->vid_cap.vfd, |
204 | "User buffer too small (%ld < %ld)\n", | ||
205 | vb2_plane_size(vb, i), size); | 205 | vb2_plane_size(vb, i), size); |
206 | return -EINVAL; | 206 | return -EINVAL; |
207 | } | 207 | } |
@@ -413,7 +413,8 @@ static int fimc_cap_s_fmt_mplane(struct file *file, void *priv, | |||
413 | pix = &f->fmt.pix_mp; | 413 | pix = &f->fmt.pix_mp; |
414 | frame->fmt = find_format(f, FMT_FLAGS_M2M | FMT_FLAGS_CAM); | 414 | frame->fmt = find_format(f, FMT_FLAGS_M2M | FMT_FLAGS_CAM); |
415 | if (!frame->fmt) { | 415 | if (!frame->fmt) { |
416 | err("fimc target format not found\n"); | 416 | v4l2_err(fimc->vid_cap.vfd, |
417 | "Not supported capture (FIMC target) color format\n"); | ||
417 | return -EINVAL; | 418 | return -EINVAL; |
418 | } | 419 | } |
419 | 420 | ||
@@ -473,7 +474,7 @@ static int fimc_cap_streamon(struct file *file, void *priv, | |||
473 | return -EBUSY; | 474 | return -EBUSY; |
474 | 475 | ||
475 | if (!(ctx->state & FIMC_DST_FMT)) { | 476 | if (!(ctx->state & FIMC_DST_FMT)) { |
476 | v4l2_err(&fimc->vid_cap.v4l2_dev, "Format is not set\n"); | 477 | v4l2_err(fimc->vid_cap.vfd, "Format is not set\n"); |
477 | return -EINVAL; | 478 | return -EINVAL; |
478 | } | 479 | } |
479 | 480 | ||
@@ -603,9 +604,8 @@ static int fimc_cap_s_crop(struct file *file, void *fh, | |||
603 | return ret; | 604 | return ret; |
604 | 605 | ||
605 | if (!(ctx->state & FIMC_DST_FMT)) { | 606 | if (!(ctx->state & FIMC_DST_FMT)) { |
606 | v4l2_err(&fimc->vid_cap.v4l2_dev, | 607 | v4l2_err(fimc->vid_cap.vfd, "Capture format is not set\n"); |
607 | "Capture color format not set\n"); | 608 | return -EINVAL; |
608 | return -EINVAL; /* TODO: make sure this is the right value */ | ||
609 | } | 609 | } |
610 | 610 | ||
611 | f = &ctx->s_frame; | 611 | f = &ctx->s_frame; |
@@ -614,7 +614,7 @@ static int fimc_cap_s_crop(struct file *file, void *fh, | |||
614 | ctx->d_frame.width, ctx->d_frame.height, | 614 | ctx->d_frame.width, ctx->d_frame.height, |
615 | ctx->rotation); | 615 | ctx->rotation); |
616 | if (ret) { | 616 | if (ret) { |
617 | v4l2_err(&fimc->vid_cap.v4l2_dev, "Out of the scaler range\n"); | 617 | v4l2_err(fimc->vid_cap.vfd, "Out of the scaler range\n"); |
618 | return ret; | 618 | return ret; |
619 | } | 619 | } |
620 | 620 | ||
@@ -658,16 +658,16 @@ static const struct v4l2_ioctl_ops fimc_capture_ioctl_ops = { | |||
658 | }; | 658 | }; |
659 | 659 | ||
660 | /* fimc->lock must be already initialized */ | 660 | /* fimc->lock must be already initialized */ |
661 | int fimc_register_capture_device(struct fimc_dev *fimc) | 661 | int fimc_register_capture_device(struct fimc_dev *fimc, |
662 | struct v4l2_device *v4l2_dev) | ||
662 | { | 663 | { |
663 | struct v4l2_device *v4l2_dev = &fimc->vid_cap.v4l2_dev; | ||
664 | struct video_device *vfd; | 664 | struct video_device *vfd; |
665 | struct fimc_vid_cap *vid_cap; | 665 | struct fimc_vid_cap *vid_cap; |
666 | struct fimc_ctx *ctx; | 666 | struct fimc_ctx *ctx; |
667 | struct v4l2_format f; | 667 | struct v4l2_format f; |
668 | struct fimc_frame *fr; | 668 | struct fimc_frame *fr; |
669 | struct vb2_queue *q; | 669 | struct vb2_queue *q; |
670 | int ret; | 670 | int ret = -ENOMEM; |
671 | 671 | ||
672 | ctx = kzalloc(sizeof *ctx, GFP_KERNEL); | 672 | ctx = kzalloc(sizeof *ctx, GFP_KERNEL); |
673 | if (!ctx) | 673 | if (!ctx) |
@@ -685,20 +685,14 @@ int fimc_register_capture_device(struct fimc_dev *fimc) | |||
685 | fr->width = fr->f_width = fr->o_width = 640; | 685 | fr->width = fr->f_width = fr->o_width = 640; |
686 | fr->height = fr->f_height = fr->o_height = 480; | 686 | fr->height = fr->f_height = fr->o_height = 480; |
687 | 687 | ||
688 | snprintf(v4l2_dev->name, sizeof(v4l2_dev->name), | ||
689 | "%s.capture", dev_name(&fimc->pdev->dev)); | ||
690 | |||
691 | ret = v4l2_device_register(NULL, v4l2_dev); | ||
692 | if (ret) | ||
693 | goto err_info; | ||
694 | |||
695 | vfd = video_device_alloc(); | 688 | vfd = video_device_alloc(); |
696 | if (!vfd) { | 689 | if (!vfd) { |
697 | v4l2_err(v4l2_dev, "Failed to allocate video device\n"); | 690 | v4l2_err(v4l2_dev, "Failed to allocate video device\n"); |
698 | goto err_v4l2_reg; | 691 | goto err_vd_alloc; |
699 | } | 692 | } |
700 | 693 | ||
701 | strlcpy(vfd->name, v4l2_dev->name, sizeof(vfd->name)); | 694 | snprintf(vfd->name, sizeof(vfd->name), "%s.capture", |
695 | dev_name(&fimc->pdev->dev)); | ||
702 | 696 | ||
703 | vfd->fops = &fimc_capture_fops; | 697 | vfd->fops = &fimc_capture_fops; |
704 | vfd->ioctl_ops = &fimc_capture_ioctl_ops; | 698 | vfd->ioctl_ops = &fimc_capture_ioctl_ops; |
@@ -741,11 +735,8 @@ int fimc_register_capture_device(struct fimc_dev *fimc) | |||
741 | 735 | ||
742 | err_ent: | 736 | err_ent: |
743 | video_device_release(vfd); | 737 | video_device_release(vfd); |
744 | err_v4l2_reg: | 738 | err_vd_alloc: |
745 | v4l2_device_unregister(v4l2_dev); | ||
746 | err_info: | ||
747 | kfree(ctx); | 739 | kfree(ctx); |
748 | dev_err(&fimc->pdev->dev, "failed to install\n"); | ||
749 | return ret; | 740 | return ret; |
750 | } | 741 | } |
751 | 742 | ||
diff --git a/drivers/media/video/s5p-fimc/fimc-core.c b/drivers/media/video/s5p-fimc/fimc-core.c index 9809764b5388..3e2143d10854 100644 --- a/drivers/media/video/s5p-fimc/fimc-core.c +++ b/drivers/media/video/s5p-fimc/fimc-core.c | |||
@@ -236,10 +236,11 @@ static int fimc_get_scaler_factor(u32 src, u32 tar, u32 *ratio, u32 *shift) | |||
236 | 236 | ||
237 | int fimc_set_scaler_info(struct fimc_ctx *ctx) | 237 | int fimc_set_scaler_info(struct fimc_ctx *ctx) |
238 | { | 238 | { |
239 | struct samsung_fimc_variant *variant = ctx->fimc_dev->variant; | ||
240 | struct device *dev = &ctx->fimc_dev->pdev->dev; | ||
239 | struct fimc_scaler *sc = &ctx->scaler; | 241 | struct fimc_scaler *sc = &ctx->scaler; |
240 | struct fimc_frame *s_frame = &ctx->s_frame; | 242 | struct fimc_frame *s_frame = &ctx->s_frame; |
241 | struct fimc_frame *d_frame = &ctx->d_frame; | 243 | struct fimc_frame *d_frame = &ctx->d_frame; |
242 | struct samsung_fimc_variant *variant = ctx->fimc_dev->variant; | ||
243 | int tx, ty, sx, sy; | 244 | int tx, ty, sx, sy; |
244 | int ret; | 245 | int ret; |
245 | 246 | ||
@@ -251,15 +252,14 @@ int fimc_set_scaler_info(struct fimc_ctx *ctx) | |||
251 | ty = d_frame->height; | 252 | ty = d_frame->height; |
252 | } | 253 | } |
253 | if (tx <= 0 || ty <= 0) { | 254 | if (tx <= 0 || ty <= 0) { |
254 | v4l2_err(&ctx->fimc_dev->m2m.v4l2_dev, | 255 | dev_err(dev, "Invalid target size: %dx%d", tx, ty); |
255 | "invalid target size: %d x %d", tx, ty); | ||
256 | return -EINVAL; | 256 | return -EINVAL; |
257 | } | 257 | } |
258 | 258 | ||
259 | sx = s_frame->width; | 259 | sx = s_frame->width; |
260 | sy = s_frame->height; | 260 | sy = s_frame->height; |
261 | if (sx <= 0 || sy <= 0) { | 261 | if (sx <= 0 || sy <= 0) { |
262 | err("invalid source size: %d x %d", sx, sy); | 262 | dev_err(dev, "Invalid source size: %dx%d", sx, sy); |
263 | return -EINVAL; | 263 | return -EINVAL; |
264 | } | 264 | } |
265 | sc->real_width = sx; | 265 | sc->real_width = sx; |
@@ -898,7 +898,7 @@ int fimc_vidioc_try_fmt_mplane(struct file *file, void *priv, | |||
898 | mask = is_output ? FMT_FLAGS_M2M : FMT_FLAGS_M2M | FMT_FLAGS_CAM; | 898 | mask = is_output ? FMT_FLAGS_M2M : FMT_FLAGS_M2M | FMT_FLAGS_CAM; |
899 | fmt = find_format(f, mask); | 899 | fmt = find_format(f, mask); |
900 | if (!fmt) { | 900 | if (!fmt) { |
901 | v4l2_err(&fimc->m2m.v4l2_dev, "Fourcc format (0x%X) invalid.\n", | 901 | v4l2_err(fimc->v4l2_dev, "Fourcc format (0x%X) invalid.\n", |
902 | pix->pixelformat); | 902 | pix->pixelformat); |
903 | return -EINVAL; | 903 | return -EINVAL; |
904 | } | 904 | } |
@@ -973,7 +973,7 @@ static int fimc_m2m_s_fmt_mplane(struct file *file, void *priv, | |||
973 | vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type); | 973 | vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type); |
974 | 974 | ||
975 | if (vb2_is_busy(vq)) { | 975 | if (vb2_is_busy(vq)) { |
976 | v4l2_err(&fimc->m2m.v4l2_dev, "queue (%d) busy\n", f->type); | 976 | v4l2_err(fimc->m2m.vfd, "queue (%d) busy\n", f->type); |
977 | return -EBUSY; | 977 | return -EBUSY; |
978 | } | 978 | } |
979 | 979 | ||
@@ -982,7 +982,7 @@ static int fimc_m2m_s_fmt_mplane(struct file *file, void *priv, | |||
982 | } else if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { | 982 | } else if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { |
983 | frame = &ctx->d_frame; | 983 | frame = &ctx->d_frame; |
984 | } else { | 984 | } else { |
985 | v4l2_err(&fimc->m2m.v4l2_dev, | 985 | v4l2_err(fimc->m2m.vfd, |
986 | "Wrong buffer/video queue type (%d)\n", f->type); | 986 | "Wrong buffer/video queue type (%d)\n", f->type); |
987 | return -EINVAL; | 987 | return -EINVAL; |
988 | } | 988 | } |
@@ -1110,7 +1110,7 @@ int fimc_vidioc_g_ctrl(struct file *file, void *priv, | |||
1110 | return v4l2_subdev_call(fimc->vid_cap.sd, core, | 1110 | return v4l2_subdev_call(fimc->vid_cap.sd, core, |
1111 | g_ctrl, ctrl); | 1111 | g_ctrl, ctrl); |
1112 | } else { | 1112 | } else { |
1113 | v4l2_err(&fimc->m2m.v4l2_dev, "Invalid control\n"); | 1113 | v4l2_err(fimc->m2m.vfd, "Invalid control\n"); |
1114 | return -EINVAL; | 1114 | return -EINVAL; |
1115 | } | 1115 | } |
1116 | } | 1116 | } |
@@ -1128,8 +1128,7 @@ int check_ctrl_val(struct fimc_ctx *ctx, struct v4l2_control *ctrl) | |||
1128 | 1128 | ||
1129 | if (ctrl->value < c->minimum || ctrl->value > c->maximum | 1129 | if (ctrl->value < c->minimum || ctrl->value > c->maximum |
1130 | || (c->step != 0 && ctrl->value % c->step != 0)) { | 1130 | || (c->step != 0 && ctrl->value % c->step != 0)) { |
1131 | v4l2_err(&ctx->fimc_dev->m2m.v4l2_dev, | 1131 | v4l2_err(ctx->fimc_dev->m2m.vfd, "Invalid control value\n"); |
1132 | "Invalid control value\n"); | ||
1133 | return -ERANGE; | 1132 | return -ERANGE; |
1134 | } | 1133 | } |
1135 | 1134 | ||
@@ -1165,7 +1164,7 @@ int fimc_s_ctrl(struct fimc_ctx *ctx, struct v4l2_control *ctrl) | |||
1165 | } | 1164 | } |
1166 | 1165 | ||
1167 | if (ret) { | 1166 | if (ret) { |
1168 | v4l2_err(&fimc->m2m.v4l2_dev, "Out of scaler range\n"); | 1167 | v4l2_err(fimc->m2m.vfd, "Out of scaler range\n"); |
1169 | return -EINVAL; | 1168 | return -EINVAL; |
1170 | } | 1169 | } |
1171 | 1170 | ||
@@ -1177,7 +1176,7 @@ int fimc_s_ctrl(struct fimc_ctx *ctx, struct v4l2_control *ctrl) | |||
1177 | break; | 1176 | break; |
1178 | 1177 | ||
1179 | default: | 1178 | default: |
1180 | v4l2_err(&fimc->m2m.v4l2_dev, "Invalid control\n"); | 1179 | v4l2_err(fimc->v4l2_dev, "Invalid control\n"); |
1181 | return -EINVAL; | 1180 | return -EINVAL; |
1182 | } | 1181 | } |
1183 | 1182 | ||
@@ -1245,7 +1244,7 @@ int fimc_try_crop(struct fimc_ctx *ctx, struct v4l2_crop *cr) | |||
1245 | int i; | 1244 | int i; |
1246 | 1245 | ||
1247 | if (cr->c.top < 0 || cr->c.left < 0) { | 1246 | if (cr->c.top < 0 || cr->c.left < 0) { |
1248 | v4l2_err(&fimc->m2m.v4l2_dev, | 1247 | v4l2_err(fimc->m2m.vfd, |
1249 | "doesn't support negative values for top & left\n"); | 1248 | "doesn't support negative values for top & left\n"); |
1250 | return -EINVAL; | 1249 | return -EINVAL; |
1251 | } | 1250 | } |
@@ -1326,7 +1325,7 @@ static int fimc_m2m_s_crop(struct file *file, void *fh, struct v4l2_crop *cr) | |||
1326 | ctx->rotation); | 1325 | ctx->rotation); |
1327 | } | 1326 | } |
1328 | if (ret) { | 1327 | if (ret) { |
1329 | v4l2_err(&fimc->m2m.v4l2_dev, "Out of scaler range\n"); | 1328 | v4l2_err(fimc->m2m.vfd, "Out of scaler range\n"); |
1330 | return -EINVAL; | 1329 | return -EINVAL; |
1331 | } | 1330 | } |
1332 | } | 1331 | } |
@@ -1494,30 +1493,23 @@ static struct v4l2_m2m_ops m2m_ops = { | |||
1494 | .job_abort = fimc_job_abort, | 1493 | .job_abort = fimc_job_abort, |
1495 | }; | 1494 | }; |
1496 | 1495 | ||
1497 | int fimc_register_m2m_device(struct fimc_dev *fimc) | 1496 | int fimc_register_m2m_device(struct fimc_dev *fimc, |
1497 | struct v4l2_device *v4l2_dev) | ||
1498 | { | 1498 | { |
1499 | struct video_device *vfd; | 1499 | struct video_device *vfd; |
1500 | struct platform_device *pdev; | 1500 | struct platform_device *pdev; |
1501 | struct v4l2_device *v4l2_dev; | ||
1502 | int ret = 0; | 1501 | int ret = 0; |
1503 | 1502 | ||
1504 | if (!fimc) | 1503 | if (!fimc) |
1505 | return -ENODEV; | 1504 | return -ENODEV; |
1506 | 1505 | ||
1507 | pdev = fimc->pdev; | 1506 | pdev = fimc->pdev; |
1508 | v4l2_dev = &fimc->m2m.v4l2_dev; | 1507 | fimc->v4l2_dev = v4l2_dev; |
1509 | |||
1510 | snprintf(v4l2_dev->name, sizeof(v4l2_dev->name), | ||
1511 | "%s.m2m", dev_name(&pdev->dev)); | ||
1512 | |||
1513 | ret = v4l2_device_register(&pdev->dev, v4l2_dev); | ||
1514 | if (ret) | ||
1515 | goto err_m2m_r1; | ||
1516 | 1508 | ||
1517 | vfd = video_device_alloc(); | 1509 | vfd = video_device_alloc(); |
1518 | if (!vfd) { | 1510 | if (!vfd) { |
1519 | v4l2_err(v4l2_dev, "Failed to allocate video device\n"); | 1511 | v4l2_err(v4l2_dev, "Failed to allocate video device\n"); |
1520 | goto err_m2m_r1; | 1512 | return -ENOMEM; |
1521 | } | 1513 | } |
1522 | 1514 | ||
1523 | vfd->fops = &fimc_m2m_fops; | 1515 | vfd->fops = &fimc_m2m_fops; |
@@ -1527,17 +1519,15 @@ int fimc_register_m2m_device(struct fimc_dev *fimc) | |||
1527 | vfd->release = video_device_release; | 1519 | vfd->release = video_device_release; |
1528 | vfd->lock = &fimc->lock; | 1520 | vfd->lock = &fimc->lock; |
1529 | 1521 | ||
1530 | snprintf(vfd->name, sizeof(vfd->name), "%s:m2m", dev_name(&pdev->dev)); | 1522 | snprintf(vfd->name, sizeof(vfd->name), "%s.m2m", dev_name(&pdev->dev)); |
1531 | |||
1532 | video_set_drvdata(vfd, fimc); | 1523 | video_set_drvdata(vfd, fimc); |
1533 | platform_set_drvdata(pdev, fimc); | ||
1534 | 1524 | ||
1535 | fimc->m2m.vfd = vfd; | 1525 | fimc->m2m.vfd = vfd; |
1536 | fimc->m2m.m2m_dev = v4l2_m2m_init(&m2m_ops); | 1526 | fimc->m2m.m2m_dev = v4l2_m2m_init(&m2m_ops); |
1537 | if (IS_ERR(fimc->m2m.m2m_dev)) { | 1527 | if (IS_ERR(fimc->m2m.m2m_dev)) { |
1538 | v4l2_err(v4l2_dev, "failed to initialize v4l2-m2m device\n"); | 1528 | v4l2_err(v4l2_dev, "failed to initialize v4l2-m2m device\n"); |
1539 | ret = PTR_ERR(fimc->m2m.m2m_dev); | 1529 | ret = PTR_ERR(fimc->m2m.m2m_dev); |
1540 | goto err_m2m_r2; | 1530 | goto err_init; |
1541 | } | 1531 | } |
1542 | 1532 | ||
1543 | ret = media_entity_init(&vfd->entity, 0, NULL, 0); | 1533 | ret = media_entity_init(&vfd->entity, 0, NULL, 0); |
@@ -1545,11 +1535,8 @@ int fimc_register_m2m_device(struct fimc_dev *fimc) | |||
1545 | return 0; | 1535 | return 0; |
1546 | 1536 | ||
1547 | v4l2_m2m_release(fimc->m2m.m2m_dev); | 1537 | v4l2_m2m_release(fimc->m2m.m2m_dev); |
1548 | err_m2m_r2: | 1538 | err_init: |
1549 | video_device_release(fimc->m2m.vfd); | 1539 | video_device_release(fimc->m2m.vfd); |
1550 | err_m2m_r1: | ||
1551 | v4l2_device_unregister(v4l2_dev); | ||
1552 | |||
1553 | return ret; | 1540 | return ret; |
1554 | } | 1541 | } |
1555 | 1542 | ||
@@ -1560,7 +1547,6 @@ void fimc_unregister_m2m_device(struct fimc_dev *fimc) | |||
1560 | 1547 | ||
1561 | if (fimc->m2m.m2m_dev) | 1548 | if (fimc->m2m.m2m_dev) |
1562 | v4l2_m2m_release(fimc->m2m.m2m_dev); | 1549 | v4l2_m2m_release(fimc->m2m.m2m_dev); |
1563 | v4l2_device_unregister(&fimc->m2m.v4l2_dev); | ||
1564 | if (fimc->m2m.vfd) { | 1550 | if (fimc->m2m.vfd) { |
1565 | media_entity_cleanup(&fimc->m2m.vfd->entity); | 1551 | media_entity_cleanup(&fimc->m2m.vfd->entity); |
1566 | /* Can also be called if video device wasn't registered */ | 1552 | /* Can also be called if video device wasn't registered */ |
diff --git a/drivers/media/video/s5p-fimc/fimc-core.h b/drivers/media/video/s5p-fimc/fimc-core.h index a0d6f81272d9..ec2e83bd2dd9 100644 --- a/drivers/media/video/s5p-fimc/fimc-core.h +++ b/drivers/media/video/s5p-fimc/fimc-core.h | |||
@@ -281,14 +281,12 @@ struct fimc_frame { | |||
281 | /** | 281 | /** |
282 | * struct fimc_m2m_device - v4l2 memory-to-memory device data | 282 | * struct fimc_m2m_device - v4l2 memory-to-memory device data |
283 | * @vfd: the video device node for v4l2 m2m mode | 283 | * @vfd: the video device node for v4l2 m2m mode |
284 | * @v4l2_dev: v4l2 device for m2m mode | ||
285 | * @m2m_dev: v4l2 memory-to-memory device data | 284 | * @m2m_dev: v4l2 memory-to-memory device data |
286 | * @ctx: hardware context data | 285 | * @ctx: hardware context data |
287 | * @refcnt: the reference counter | 286 | * @refcnt: the reference counter |
288 | */ | 287 | */ |
289 | struct fimc_m2m_device { | 288 | struct fimc_m2m_device { |
290 | struct video_device *vfd; | 289 | struct video_device *vfd; |
291 | struct v4l2_device v4l2_dev; | ||
292 | struct v4l2_m2m_dev *m2m_dev; | 290 | struct v4l2_m2m_dev *m2m_dev; |
293 | struct fimc_ctx *ctx; | 291 | struct fimc_ctx *ctx; |
294 | int refcnt; | 292 | int refcnt; |
@@ -298,7 +296,6 @@ struct fimc_m2m_device { | |||
298 | * struct fimc_vid_cap - camera capture device information | 296 | * struct fimc_vid_cap - camera capture device information |
299 | * @ctx: hardware context data | 297 | * @ctx: hardware context data |
300 | * @vfd: video device node for camera capture mode | 298 | * @vfd: video device node for camera capture mode |
301 | * @v4l2_dev: v4l2_device struct to manage subdevs | ||
302 | * @sd: pointer to camera sensor subdevice currently in use | 299 | * @sd: pointer to camera sensor subdevice currently in use |
303 | * @vd_pad: fimc video capture node pad | 300 | * @vd_pad: fimc video capture node pad |
304 | * @fmt: Media Bus format configured at selected image sensor | 301 | * @fmt: Media Bus format configured at selected image sensor |
@@ -316,7 +313,6 @@ struct fimc_vid_cap { | |||
316 | struct fimc_ctx *ctx; | 313 | struct fimc_ctx *ctx; |
317 | struct vb2_alloc_ctx *alloc_ctx; | 314 | struct vb2_alloc_ctx *alloc_ctx; |
318 | struct video_device *vfd; | 315 | struct video_device *vfd; |
319 | struct v4l2_device v4l2_dev; | ||
320 | struct v4l2_subdev *sd;; | 316 | struct v4l2_subdev *sd;; |
321 | struct media_pad vd_pad; | 317 | struct media_pad vd_pad; |
322 | struct v4l2_mbus_framefmt fmt; | 318 | struct v4l2_mbus_framefmt fmt; |
@@ -407,6 +403,7 @@ struct fimc_ctx; | |||
407 | * @regs_res: the resource claimed for IO registers | 403 | * @regs_res: the resource claimed for IO registers |
408 | * @irq: FIMC interrupt number | 404 | * @irq: FIMC interrupt number |
409 | * @irq_queue: interrupt handler waitqueue | 405 | * @irq_queue: interrupt handler waitqueue |
406 | * @v4l2_dev: root v4l2_device | ||
410 | * @m2m: memory-to-memory V4L2 device information | 407 | * @m2m: memory-to-memory V4L2 device information |
411 | * @vid_cap: camera capture device information | 408 | * @vid_cap: camera capture device information |
412 | * @state: flags used to synchronize m2m and capture mode operation | 409 | * @state: flags used to synchronize m2m and capture mode operation |
@@ -425,6 +422,7 @@ struct fimc_dev { | |||
425 | struct resource *regs_res; | 422 | struct resource *regs_res; |
426 | int irq; | 423 | int irq; |
427 | wait_queue_head_t irq_queue; | 424 | wait_queue_head_t irq_queue; |
425 | struct v4l2_device *v4l2_dev; | ||
428 | struct fimc_m2m_device m2m; | 426 | struct fimc_m2m_device m2m; |
429 | struct fimc_vid_cap vid_cap; | 427 | struct fimc_vid_cap vid_cap; |
430 | unsigned long state; | 428 | unsigned long state; |
@@ -569,7 +567,7 @@ static inline struct fimc_frame *ctx_get_frame(struct fimc_ctx *ctx, | |||
569 | } else if (V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE == type) { | 567 | } else if (V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE == type) { |
570 | frame = &ctx->d_frame; | 568 | frame = &ctx->d_frame; |
571 | } else { | 569 | } else { |
572 | v4l2_err(&ctx->fimc_dev->m2m.v4l2_dev, | 570 | v4l2_err(ctx->fimc_dev->v4l2_dev, |
573 | "Wrong buffer/video queue type (%d)\n", type); | 571 | "Wrong buffer/video queue type (%d)\n", type); |
574 | return ERR_PTR(-EINVAL); | 572 | return ERR_PTR(-EINVAL); |
575 | } | 573 | } |
@@ -644,11 +642,14 @@ int fimc_set_scaler_info(struct fimc_ctx *ctx); | |||
644 | int fimc_prepare_config(struct fimc_ctx *ctx, u32 flags); | 642 | int fimc_prepare_config(struct fimc_ctx *ctx, u32 flags); |
645 | int fimc_prepare_addr(struct fimc_ctx *ctx, struct vb2_buffer *vb, | 643 | int fimc_prepare_addr(struct fimc_ctx *ctx, struct vb2_buffer *vb, |
646 | struct fimc_frame *frame, struct fimc_addr *paddr); | 644 | struct fimc_frame *frame, struct fimc_addr *paddr); |
647 | int fimc_register_m2m_device(struct fimc_dev *fimc); | 645 | int fimc_register_m2m_device(struct fimc_dev *fimc, |
646 | struct v4l2_device *v4l2_dev); | ||
647 | void fimc_unregister_m2m_device(struct fimc_dev *fimc); | ||
648 | 648 | ||
649 | /* -----------------------------------------------------*/ | 649 | /* -----------------------------------------------------*/ |
650 | /* fimc-capture.c */ | 650 | /* fimc-capture.c */ |
651 | int fimc_register_capture_device(struct fimc_dev *fimc); | 651 | int fimc_register_capture_device(struct fimc_dev *fimc, |
652 | struct v4l2_device *v4l2_dev); | ||
652 | void fimc_unregister_capture_device(struct fimc_dev *fimc); | 653 | void fimc_unregister_capture_device(struct fimc_dev *fimc); |
653 | int fimc_vid_cap_buf_queue(struct fimc_dev *fimc, | 654 | int fimc_vid_cap_buf_queue(struct fimc_dev *fimc, |
654 | struct fimc_vid_buffer *fimc_vb); | 655 | struct fimc_vid_buffer *fimc_vb); |
diff --git a/drivers/media/video/s5p-fimc/fimc-reg.c b/drivers/media/video/s5p-fimc/fimc-reg.c index 938dadf250f7..c6882636ea94 100644 --- a/drivers/media/video/s5p-fimc/fimc-reg.c +++ b/drivers/media/video/s5p-fimc/fimc-reg.c | |||
@@ -596,7 +596,7 @@ int fimc_hw_set_camera_source(struct fimc_dev *fimc, | |||
596 | } | 596 | } |
597 | 597 | ||
598 | if (i == ARRAY_SIZE(pix_desc)) { | 598 | if (i == ARRAY_SIZE(pix_desc)) { |
599 | v4l2_err(&fimc->vid_cap.v4l2_dev, | 599 | v4l2_err(fimc->vid_cap.vfd, |
600 | "Camera color format not supported: %d\n", | 600 | "Camera color format not supported: %d\n", |
601 | fimc->vid_cap.fmt.code); | 601 | fimc->vid_cap.fmt.code); |
602 | return -EINVAL; | 602 | return -EINVAL; |
@@ -661,8 +661,9 @@ int fimc_hw_set_camera_type(struct fimc_dev *fimc, | |||
661 | if (vid_cap->fmt.code == V4L2_MBUS_FMT_VYUY8_2X8) { | 661 | if (vid_cap->fmt.code == V4L2_MBUS_FMT_VYUY8_2X8) { |
662 | tmp = S5P_CSIIMGFMT_YCBCR422_8BIT; | 662 | tmp = S5P_CSIIMGFMT_YCBCR422_8BIT; |
663 | } else { | 663 | } else { |
664 | err("camera image format not supported: %d", | 664 | v4l2_err(fimc->vid_cap.vfd, |
665 | vid_cap->fmt.code); | 665 | "Not supported camera pixel format: %d", |
666 | vid_cap->fmt.code); | ||
666 | return -EINVAL; | 667 | return -EINVAL; |
667 | } | 668 | } |
668 | tmp |= (cam->csi_data_align == 32) << 8; | 669 | tmp |= (cam->csi_data_align == 32) << 8; |