diff options
Diffstat (limited to 'drivers/media/video/s5p-fimc/fimc-capture.c')
-rw-r--r-- | drivers/media/video/s5p-fimc/fimc-capture.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c b/drivers/media/video/s5p-fimc/fimc-capture.c index b06efd208328..7e9b2c612b03 100644 --- a/drivers/media/video/s5p-fimc/fimc-capture.c +++ b/drivers/media/video/s5p-fimc/fimc-capture.c | |||
@@ -246,28 +246,37 @@ int fimc_capture_resume(struct fimc_dev *fimc) | |||
246 | 246 | ||
247 | } | 247 | } |
248 | 248 | ||
249 | static unsigned int get_plane_size(struct fimc_frame *fr, unsigned int plane) | 249 | static int queue_setup(struct vb2_queue *vq, const struct v4l2_format *pfmt, |
250 | { | ||
251 | if (!fr || plane >= fr->fmt->memplanes) | ||
252 | return 0; | ||
253 | return fr->f_width * fr->f_height * fr->fmt->depth[plane] / 8; | ||
254 | } | ||
255 | |||
256 | static int queue_setup(struct vb2_queue *vq, const struct v4l2_format *pfmt, | ||
257 | unsigned int *num_buffers, unsigned int *num_planes, | 250 | unsigned int *num_buffers, unsigned int *num_planes, |
258 | unsigned int sizes[], void *allocators[]) | 251 | unsigned int sizes[], void *allocators[]) |
259 | { | 252 | { |
253 | const struct v4l2_pix_format_mplane *pixm = NULL; | ||
260 | struct fimc_ctx *ctx = vq->drv_priv; | 254 | struct fimc_ctx *ctx = vq->drv_priv; |
261 | struct fimc_fmt *fmt = ctx->d_frame.fmt; | 255 | struct fimc_frame *frame = &ctx->d_frame; |
256 | struct fimc_fmt *fmt = frame->fmt; | ||
257 | unsigned long wh; | ||
262 | int i; | 258 | int i; |
263 | 259 | ||
264 | if (!fmt) | 260 | if (pfmt) { |
261 | pixm = &pfmt->fmt.pix_mp; | ||
262 | fmt = fimc_find_format(&pixm->pixelformat, NULL, | ||
263 | FMT_FLAGS_CAM | FMT_FLAGS_M2M, -1); | ||
264 | wh = pixm->width * pixm->height; | ||
265 | } else { | ||
266 | wh = frame->f_width * frame->f_height; | ||
267 | } | ||
268 | |||
269 | if (fmt == NULL) | ||
265 | return -EINVAL; | 270 | return -EINVAL; |
266 | 271 | ||
267 | *num_planes = fmt->memplanes; | 272 | *num_planes = fmt->memplanes; |
268 | 273 | ||
269 | for (i = 0; i < fmt->memplanes; i++) { | 274 | for (i = 0; i < fmt->memplanes; i++) { |
270 | sizes[i] = get_plane_size(&ctx->d_frame, i); | 275 | unsigned int size = (wh * fmt->depth[i]) / 8; |
276 | if (pixm) | ||
277 | sizes[i] = max(size, pixm->plane_fmt[i].sizeimage); | ||
278 | else | ||
279 | sizes[i] = size; | ||
271 | allocators[i] = ctx->fimc_dev->alloc_ctx; | 280 | allocators[i] = ctx->fimc_dev->alloc_ctx; |
272 | } | 281 | } |
273 | 282 | ||
@@ -1383,7 +1392,7 @@ static int fimc_subdev_set_crop(struct v4l2_subdev *sd, | |||
1383 | fimc_capture_try_crop(ctx, r, crop->pad); | 1392 | fimc_capture_try_crop(ctx, r, crop->pad); |
1384 | 1393 | ||
1385 | if (crop->which == V4L2_SUBDEV_FORMAT_TRY) { | 1394 | if (crop->which == V4L2_SUBDEV_FORMAT_TRY) { |
1386 | mutex_lock(&fimc->lock); | 1395 | mutex_unlock(&fimc->lock); |
1387 | *v4l2_subdev_get_try_crop(fh, crop->pad) = *r; | 1396 | *v4l2_subdev_get_try_crop(fh, crop->pad) = *r; |
1388 | return 0; | 1397 | return 0; |
1389 | } | 1398 | } |