Merge branch 'pm-cpufreq-fixes'
[deliverable/linux.git] / drivers / media / platform / exynos4-is / fimc-isp-video.c
CommitLineData
34947b8a
SN
1/*
2 * Samsung EXYNOS4x12 FIMC-IS (Imaging Subsystem) driver
3 *
4 * FIMC-IS ISP video input and video output DMA interface driver
5 *
6 * Copyright (C) 2013 Samsung Electronics Co., Ltd.
7 * Author: Sylwester Nawrocki <s.nawrocki@samsung.com>
8 *
9 * The hardware handling code derived from a driver written by
10 * Younghwan Joo <yhwan.joo@samsung.com>.
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
15 */
16
17#include <linux/bitops.h>
18#include <linux/device.h>
19#include <linux/delay.h>
20#include <linux/errno.h>
21#include <linux/kernel.h>
22#include <linux/module.h>
23#include <linux/types.h>
24#include <linux/printk.h>
25#include <linux/pm_runtime.h>
26#include <linux/slab.h>
27#include <linux/videodev2.h>
28
29#include <media/v4l2-device.h>
30#include <media/v4l2-ioctl.h>
c139990e 31#include <media/videobuf2-v4l2.h>
34947b8a 32#include <media/videobuf2-dma-contig.h>
d647f0b7 33#include <media/drv-intf/exynos-fimc.h>
34947b8a
SN
34
35#include "common.h"
36#include "media-dev.h"
37#include "fimc-is.h"
38#include "fimc-isp-video.h"
39#include "fimc-is-param.h"
40
41static int isp_video_capture_queue_setup(struct vb2_queue *vq,
34947b8a
SN
42 unsigned int *num_buffers, unsigned int *num_planes,
43 unsigned int sizes[], void *allocators[])
44{
45 struct fimc_isp *isp = vb2_get_drv_priv(vq);
46 struct v4l2_pix_format_mplane *vid_fmt = &isp->video_capture.pixfmt;
df9ecb0c 47 const struct fimc_fmt *fmt = isp->video_capture.format;
34947b8a
SN
48 unsigned int wh, i;
49
df9ecb0c 50 wh = vid_fmt->width * vid_fmt->height;
34947b8a
SN
51
52 if (fmt == NULL)
53 return -EINVAL;
54
55 *num_buffers = clamp_t(u32, *num_buffers, FIMC_ISP_REQ_BUFS_MIN,
56 FIMC_ISP_REQ_BUFS_MAX);
df9ecb0c
HV
57 if (*num_planes) {
58 if (*num_planes != fmt->memplanes)
59 return -EINVAL;
60 for (i = 0; i < *num_planes; i++) {
61 if (sizes[i] < (wh * fmt->depth[i]) / 8)
62 return -EINVAL;
63 allocators[i] = isp->alloc_ctx;
64 }
65 return 0;
66 }
67
34947b8a
SN
68 *num_planes = fmt->memplanes;
69
70 for (i = 0; i < fmt->memplanes; i++) {
df9ecb0c 71 sizes[i] = (wh * fmt->depth[i]) / 8;
34947b8a
SN
72 allocators[i] = isp->alloc_ctx;
73 }
74
75 return 0;
76}
77
78static inline struct param_dma_output *__get_isp_dma2(struct fimc_is *is)
79{
80 return &__get_curr_is_config(is)->isp.dma2_output;
81}
82
83static int isp_video_capture_start_streaming(struct vb2_queue *q,
84 unsigned int count)
85{
86 struct fimc_isp *isp = vb2_get_drv_priv(q);
87 struct fimc_is *is = fimc_isp_to_is(isp);
88 struct param_dma_output *dma = __get_isp_dma2(is);
89 struct fimc_is_video *video = &isp->video_capture;
90 int ret;
91
92 if (!test_bit(ST_ISP_VID_CAP_BUF_PREP, &isp->state) ||
93 test_bit(ST_ISP_VID_CAP_STREAMING, &isp->state))
94 return 0;
95
96
97 dma->cmd = DMA_OUTPUT_COMMAND_ENABLE;
98 dma->notify_dma_done = DMA_OUTPUT_NOTIFY_DMA_DONE_ENABLE;
99 dma->buffer_address = is->is_dma_p_region +
100 DMA2_OUTPUT_ADDR_ARRAY_OFFS;
101 dma->buffer_number = video->reqbufs_count;
102 dma->dma_out_mask = video->buf_mask;
103
104 isp_dbg(2, &video->ve.vdev,
105 "buf_count: %d, planes: %d, dma addr table: %#x\n",
106 video->buf_count, video->format->memplanes,
107 dma->buffer_address);
108
109 fimc_is_mem_barrier();
110
111 fimc_is_set_param_bit(is, PARAM_ISP_DMA2_OUTPUT);
112 __fimc_is_hw_update_param(is, PARAM_ISP_DMA2_OUTPUT);
113
114 ret = fimc_is_itf_s_param(is, false);
115 if (ret < 0)
116 return ret;
117
118 ret = fimc_pipeline_call(&video->ve, set_stream, 1);
119 if (ret < 0)
120 return ret;
121
122 set_bit(ST_ISP_VID_CAP_STREAMING, &isp->state);
123 return ret;
124}
125
e37559b2 126static void isp_video_capture_stop_streaming(struct vb2_queue *q)
34947b8a
SN
127{
128 struct fimc_isp *isp = vb2_get_drv_priv(q);
129 struct fimc_is *is = fimc_isp_to_is(isp);
130 struct param_dma_output *dma = __get_isp_dma2(is);
131 int ret;
132
133 ret = fimc_pipeline_call(&isp->video_capture.ve, set_stream, 0);
134 if (ret < 0)
e37559b2 135 return;
34947b8a
SN
136
137 dma->cmd = DMA_OUTPUT_COMMAND_DISABLE;
138 dma->notify_dma_done = DMA_OUTPUT_NOTIFY_DMA_DONE_DISABLE;
139 dma->buffer_number = 0;
140 dma->buffer_address = 0;
141 dma->dma_out_mask = 0;
142
143 fimc_is_set_param_bit(is, PARAM_ISP_DMA2_OUTPUT);
144 __fimc_is_hw_update_param(is, PARAM_ISP_DMA2_OUTPUT);
145
146 ret = fimc_is_itf_s_param(is, false);
147 if (ret < 0)
148 dev_warn(&is->pdev->dev, "%s: DMA stop failed\n", __func__);
149
150 fimc_is_hw_set_isp_buf_mask(is, 0);
151
152 clear_bit(ST_ISP_VID_CAP_BUF_PREP, &isp->state);
153 clear_bit(ST_ISP_VID_CAP_STREAMING, &isp->state);
154
155 isp->video_capture.buf_count = 0;
34947b8a
SN
156}
157
158static int isp_video_capture_buffer_prepare(struct vb2_buffer *vb)
159{
160 struct fimc_isp *isp = vb2_get_drv_priv(vb->vb2_queue);
161 struct fimc_is_video *video = &isp->video_capture;
162 int i;
163
164 if (video->format == NULL)
165 return -EINVAL;
166
167 for (i = 0; i < video->format->memplanes; i++) {
168 unsigned long size = video->pixfmt.plane_fmt[i].sizeimage;
169
170 if (vb2_plane_size(vb, i) < size) {
171 v4l2_err(&video->ve.vdev,
172 "User buffer too small (%ld < %ld)\n",
173 vb2_plane_size(vb, i), size);
174 return -EINVAL;
175 }
176 vb2_set_plane_payload(vb, i, size);
177 }
178
179 /* Check if we get one of the already known buffers. */
180 if (test_bit(ST_ISP_VID_CAP_BUF_PREP, &isp->state)) {
181 dma_addr_t dma_addr = vb2_dma_contig_plane_dma_addr(vb, 0);
182 int i;
183
184 for (i = 0; i < video->buf_count; i++)
185 if (video->buffers[i]->dma_addr[0] == dma_addr)
186 return 0;
187 return -ENXIO;
188 }
189
190 return 0;
191}
192
193static void isp_video_capture_buffer_queue(struct vb2_buffer *vb)
194{
2d700715 195 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
34947b8a
SN
196 struct fimc_isp *isp = vb2_get_drv_priv(vb->vb2_queue);
197 struct fimc_is_video *video = &isp->video_capture;
198 struct fimc_is *is = fimc_isp_to_is(isp);
2d700715 199 struct isp_video_buf *ivb = to_isp_video_buf(vbuf);
34947b8a
SN
200 unsigned long flags;
201 unsigned int i;
202
203 if (test_bit(ST_ISP_VID_CAP_BUF_PREP, &isp->state)) {
204 spin_lock_irqsave(&is->slock, flags);
205 video->buf_mask |= BIT(ivb->index);
206 spin_unlock_irqrestore(&is->slock, flags);
207 } else {
208 unsigned int num_planes = video->format->memplanes;
209
210 ivb->index = video->buf_count;
211 video->buffers[ivb->index] = ivb;
212
213 for (i = 0; i < num_planes; i++) {
214 int buf_index = ivb->index * num_planes + i;
215
216 ivb->dma_addr[i] = vb2_dma_contig_plane_dma_addr(vb, i);
217 is->is_p_region->shared[32 + buf_index] =
218 ivb->dma_addr[i];
219
220 isp_dbg(2, &video->ve.vdev,
76a56367
RV
221 "dma_buf %d (%d/%d/%d) addr: %pad\n",
222 buf_index, ivb->index, i, vb->index,
7d4020c3 223 &ivb->dma_addr[i]);
34947b8a
SN
224 }
225
226 if (++video->buf_count < video->reqbufs_count)
227 return;
228
229 video->buf_mask = (1UL << video->buf_count) - 1;
230 set_bit(ST_ISP_VID_CAP_BUF_PREP, &isp->state);
231 }
232
233 if (!test_bit(ST_ISP_VID_CAP_STREAMING, &isp->state))
234 isp_video_capture_start_streaming(vb->vb2_queue, 0);
235}
236
237/*
238 * FIMC-IS ISP input and output DMA interface interrupt handler.
239 * Locking: called with is->slock spinlock held.
240 */
241void fimc_isp_video_irq_handler(struct fimc_is *is)
242{
243 struct fimc_is_video *video = &is->isp.video_capture;
2d700715 244 struct vb2_v4l2_buffer *vbuf;
34947b8a
SN
245 int buf_index;
246
247 /* TODO: Ensure the DMA is really stopped in stop_streaming callback */
248 if (!test_bit(ST_ISP_VID_CAP_STREAMING, &is->isp.state))
249 return;
250
251 buf_index = (is->i2h_cmd.args[1] - 1) % video->buf_count;
2d700715 252 vbuf = &video->buffers[buf_index]->vb;
34947b8a 253
d6dd645e 254 vbuf->vb2_buf.timestamp = ktime_get_ns();
2d700715 255 vb2_buffer_done(&vbuf->vb2_buf, VB2_BUF_STATE_DONE);
34947b8a
SN
256
257 video->buf_mask &= ~BIT(buf_index);
258 fimc_is_hw_set_isp_buf_mask(is, video->buf_mask);
259}
260
261static const struct vb2_ops isp_video_capture_qops = {
262 .queue_setup = isp_video_capture_queue_setup,
263 .buf_prepare = isp_video_capture_buffer_prepare,
264 .buf_queue = isp_video_capture_buffer_queue,
265 .wait_prepare = vb2_ops_wait_prepare,
266 .wait_finish = vb2_ops_wait_finish,
267 .start_streaming = isp_video_capture_start_streaming,
268 .stop_streaming = isp_video_capture_stop_streaming,
269};
270
271static int isp_video_open(struct file *file)
272{
273 struct fimc_isp *isp = video_drvdata(file);
274 struct exynos_video_entity *ve = &isp->video_capture.ve;
275 struct media_entity *me = &ve->vdev.entity;
276 int ret;
277
278 if (mutex_lock_interruptible(&isp->video_lock))
279 return -ERESTARTSYS;
280
281 ret = v4l2_fh_open(file);
282 if (ret < 0)
283 goto unlock;
284
285 ret = pm_runtime_get_sync(&isp->pdev->dev);
286 if (ret < 0)
287 goto rel_fh;
288
289 if (v4l2_fh_is_singular_file(file)) {
d10c9894 290 mutex_lock(&me->graph_obj.mdev->graph_mutex);
34947b8a
SN
291
292 ret = fimc_pipeline_call(ve, open, me, true);
293
294 /* Mark the video pipeline as in use. */
295 if (ret == 0)
296 me->use_count++;
297
d10c9894 298 mutex_unlock(&me->graph_obj.mdev->graph_mutex);
34947b8a
SN
299 }
300 if (!ret)
301 goto unlock;
302rel_fh:
303 v4l2_fh_release(file);
304unlock:
305 mutex_unlock(&isp->video_lock);
306 return ret;
307}
308
309static int isp_video_release(struct file *file)
310{
311 struct fimc_isp *isp = video_drvdata(file);
312 struct fimc_is_video *ivc = &isp->video_capture;
313 struct media_entity *entity = &ivc->ve.vdev.entity;
d10c9894 314 struct media_device *mdev = entity->graph_obj.mdev;
34947b8a
SN
315
316 mutex_lock(&isp->video_lock);
317
318 if (v4l2_fh_is_singular_file(file) && ivc->streaming) {
319 media_entity_pipeline_stop(entity);
320 ivc->streaming = 0;
321 }
322
323 vb2_fop_release(file);
324
325 if (v4l2_fh_is_singular_file(file)) {
326 fimc_pipeline_call(&ivc->ve, close);
327
328 mutex_lock(&mdev->graph_mutex);
329 entity->use_count--;
330 mutex_unlock(&mdev->graph_mutex);
331 }
332
333 pm_runtime_put(&isp->pdev->dev);
334 mutex_unlock(&isp->video_lock);
335
6cf77d18 336 return 0;
34947b8a
SN
337}
338
339static const struct v4l2_file_operations isp_video_fops = {
340 .owner = THIS_MODULE,
341 .open = isp_video_open,
342 .release = isp_video_release,
343 .poll = vb2_fop_poll,
344 .unlocked_ioctl = video_ioctl2,
345 .mmap = vb2_fop_mmap,
346};
347
348/*
349 * Video node ioctl operations
350 */
351static int isp_video_querycap(struct file *file, void *priv,
352 struct v4l2_capability *cap)
353{
354 struct fimc_isp *isp = video_drvdata(file);
355
356 __fimc_vidioc_querycap(&isp->pdev->dev, cap, V4L2_CAP_STREAMING);
357 return 0;
358}
359
360static int isp_video_enum_fmt_mplane(struct file *file, void *priv,
361 struct v4l2_fmtdesc *f)
362{
363 const struct fimc_fmt *fmt;
364
365 if (f->index >= FIMC_ISP_NUM_FORMATS)
366 return -EINVAL;
367
368 fmt = fimc_isp_find_format(NULL, NULL, f->index);
369 if (WARN_ON(fmt == NULL))
370 return -EINVAL;
371
372 strlcpy(f->description, fmt->name, sizeof(f->description));
373 f->pixelformat = fmt->fourcc;
374
375 return 0;
376}
377
378static int isp_video_g_fmt_mplane(struct file *file, void *fh,
379 struct v4l2_format *f)
380{
381 struct fimc_isp *isp = video_drvdata(file);
382
383 f->fmt.pix_mp = isp->video_capture.pixfmt;
384 return 0;
385}
386
387static void __isp_video_try_fmt(struct fimc_isp *isp,
388 struct v4l2_pix_format_mplane *pixm,
389 const struct fimc_fmt **fmt)
390{
391 *fmt = fimc_isp_find_format(&pixm->pixelformat, NULL, 2);
392
393 pixm->colorspace = V4L2_COLORSPACE_SRGB;
394 pixm->field = V4L2_FIELD_NONE;
395 pixm->num_planes = (*fmt)->memplanes;
396 pixm->pixelformat = (*fmt)->fourcc;
397 /*
398 * TODO: double check with the docmentation these width/height
399 * constraints are correct.
400 */
401 v4l_bound_align_image(&pixm->width, FIMC_ISP_SOURCE_WIDTH_MIN,
402 FIMC_ISP_SOURCE_WIDTH_MAX, 3,
403 &pixm->height, FIMC_ISP_SOURCE_HEIGHT_MIN,
404 FIMC_ISP_SOURCE_HEIGHT_MAX, 0, 0);
405}
406
407static int isp_video_try_fmt_mplane(struct file *file, void *fh,
408 struct v4l2_format *f)
409{
410 struct fimc_isp *isp = video_drvdata(file);
411
412 __isp_video_try_fmt(isp, &f->fmt.pix_mp, NULL);
413 return 0;
414}
415
416static int isp_video_s_fmt_mplane(struct file *file, void *priv,
417 struct v4l2_format *f)
418{
419 struct fimc_isp *isp = video_drvdata(file);
420 struct fimc_is *is = fimc_isp_to_is(isp);
421 struct v4l2_pix_format_mplane *pixm = &f->fmt.pix_mp;
422 const struct fimc_fmt *ifmt = NULL;
423 struct param_dma_output *dma = __get_isp_dma2(is);
424
425 __isp_video_try_fmt(isp, pixm, &ifmt);
426
427 if (WARN_ON(ifmt == NULL))
428 return -EINVAL;
429
430 dma->format = DMA_OUTPUT_FORMAT_BAYER;
431 dma->order = DMA_OUTPUT_ORDER_GB_BG;
432 dma->plane = ifmt->memplanes;
433 dma->bitwidth = ifmt->depth[0];
434 dma->width = pixm->width;
435 dma->height = pixm->height;
436
437 fimc_is_mem_barrier();
438
439 isp->video_capture.format = ifmt;
440 isp->video_capture.pixfmt = *pixm;
441
442 return 0;
443}
444
445/*
446 * Check for source/sink format differences at each link.
447 * Return 0 if the formats match or -EPIPE otherwise.
448 */
449static int isp_video_pipeline_validate(struct fimc_isp *isp)
450{
451 struct v4l2_subdev *sd = &isp->subdev;
452 struct v4l2_subdev_format sink_fmt, src_fmt;
453 struct media_pad *pad;
454 int ret;
455
456 while (1) {
457 /* Retrieve format at the sink pad */
458 pad = &sd->entity.pads[0];
459 if (!(pad->flags & MEDIA_PAD_FL_SINK))
460 break;
461 sink_fmt.pad = pad->index;
462 sink_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
463 ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, &sink_fmt);
464 if (ret < 0 && ret != -ENOIOCTLCMD)
465 return -EPIPE;
466
467 /* Retrieve format at the source pad */
468 pad = media_entity_remote_pad(pad);
3efdf62c 469 if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
34947b8a
SN
470 break;
471
472 sd = media_entity_to_v4l2_subdev(pad->entity);
473 src_fmt.pad = pad->index;
474 src_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
475 ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, &src_fmt);
476 if (ret < 0 && ret != -ENOIOCTLCMD)
477 return -EPIPE;
478
479 if (src_fmt.format.width != sink_fmt.format.width ||
480 src_fmt.format.height != sink_fmt.format.height ||
481 src_fmt.format.code != sink_fmt.format.code)
482 return -EPIPE;
483 }
484
485 return 0;
486}
487
488static int isp_video_streamon(struct file *file, void *priv,
489 enum v4l2_buf_type type)
490{
491 struct fimc_isp *isp = video_drvdata(file);
492 struct exynos_video_entity *ve = &isp->video_capture.ve;
493 struct media_entity *me = &ve->vdev.entity;
494 int ret;
495
496 ret = media_entity_pipeline_start(me, &ve->pipe->mp);
497 if (ret < 0)
498 return ret;
499
500 ret = isp_video_pipeline_validate(isp);
501 if (ret < 0)
502 goto p_stop;
503
504 ret = vb2_ioctl_streamon(file, priv, type);
505 if (ret < 0)
506 goto p_stop;
507
508 isp->video_capture.streaming = 1;
509 return 0;
510p_stop:
511 media_entity_pipeline_stop(me);
512 return ret;
513}
514
515static int isp_video_streamoff(struct file *file, void *priv,
516 enum v4l2_buf_type type)
517{
518 struct fimc_isp *isp = video_drvdata(file);
519 struct fimc_is_video *video = &isp->video_capture;
520 int ret;
521
522 ret = vb2_ioctl_streamoff(file, priv, type);
523 if (ret < 0)
524 return ret;
525
526 media_entity_pipeline_stop(&video->ve.vdev.entity);
527 video->streaming = 0;
528 return 0;
529}
530
531static int isp_video_reqbufs(struct file *file, void *priv,
532 struct v4l2_requestbuffers *rb)
533{
534 struct fimc_isp *isp = video_drvdata(file);
535 int ret;
536
537 ret = vb2_ioctl_reqbufs(file, priv, rb);
538 if (ret < 0)
539 return ret;
540
541 if (rb->count && rb->count < FIMC_ISP_REQ_BUFS_MIN) {
542 rb->count = 0;
543 vb2_ioctl_reqbufs(file, priv, rb);
544 ret = -ENOMEM;
545 }
546
547 isp->video_capture.reqbufs_count = rb->count;
548 return ret;
549}
550
551static const struct v4l2_ioctl_ops isp_video_ioctl_ops = {
552 .vidioc_querycap = isp_video_querycap,
553 .vidioc_enum_fmt_vid_cap_mplane = isp_video_enum_fmt_mplane,
554 .vidioc_try_fmt_vid_cap_mplane = isp_video_try_fmt_mplane,
555 .vidioc_s_fmt_vid_cap_mplane = isp_video_s_fmt_mplane,
556 .vidioc_g_fmt_vid_cap_mplane = isp_video_g_fmt_mplane,
557 .vidioc_reqbufs = isp_video_reqbufs,
558 .vidioc_querybuf = vb2_ioctl_querybuf,
559 .vidioc_prepare_buf = vb2_ioctl_prepare_buf,
560 .vidioc_create_bufs = vb2_ioctl_create_bufs,
561 .vidioc_qbuf = vb2_ioctl_qbuf,
562 .vidioc_dqbuf = vb2_ioctl_dqbuf,
563 .vidioc_streamon = isp_video_streamon,
564 .vidioc_streamoff = isp_video_streamoff,
565};
566
567int fimc_isp_video_device_register(struct fimc_isp *isp,
568 struct v4l2_device *v4l2_dev,
569 enum v4l2_buf_type type)
570{
571 struct vb2_queue *q = &isp->video_capture.vb_queue;
572 struct fimc_is_video *iv;
573 struct video_device *vdev;
574 int ret;
575
576 if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
577 iv = &isp->video_capture;
578 else
579 return -ENOSYS;
580
581 mutex_init(&isp->video_lock);
582 INIT_LIST_HEAD(&iv->pending_buf_q);
583 INIT_LIST_HEAD(&iv->active_buf_q);
584 iv->format = fimc_isp_find_format(NULL, NULL, 0);
585 iv->pixfmt.width = IS_DEFAULT_WIDTH;
586 iv->pixfmt.height = IS_DEFAULT_HEIGHT;
587 iv->pixfmt.pixelformat = iv->format->fourcc;
588 iv->pixfmt.colorspace = V4L2_COLORSPACE_SRGB;
589 iv->reqbufs_count = 0;
590
591 memset(q, 0, sizeof(*q));
592 q->type = type;
593 q->io_modes = VB2_MMAP | VB2_USERPTR;
594 q->ops = &isp_video_capture_qops;
595 q->mem_ops = &vb2_dma_contig_memops;
596 q->buf_struct_size = sizeof(struct isp_video_buf);
597 q->drv_priv = isp;
598 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
599 q->lock = &isp->video_lock;
600
601 ret = vb2_queue_init(q);
602 if (ret < 0)
603 return ret;
604
605 vdev = &iv->ve.vdev;
606 memset(vdev, 0, sizeof(*vdev));
607 snprintf(vdev->name, sizeof(vdev->name), "fimc-is-isp.%s",
608 type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE ?
609 "capture" : "output");
610 vdev->queue = q;
611 vdev->fops = &isp_video_fops;
612 vdev->ioctl_ops = &isp_video_ioctl_ops;
613 vdev->v4l2_dev = v4l2_dev;
614 vdev->minor = -1;
615 vdev->release = video_device_release_empty;
616 vdev->lock = &isp->video_lock;
617
618 iv->pad.flags = MEDIA_PAD_FL_SINK;
ab22e77c 619 ret = media_entity_pads_init(&vdev->entity, 1, &iv->pad);
34947b8a
SN
620 if (ret < 0)
621 return ret;
622
623 video_set_drvdata(vdev, isp);
624
625 ret = video_register_device(vdev, VFL_TYPE_GRABBER, -1);
626 if (ret < 0) {
627 media_entity_cleanup(&vdev->entity);
628 return ret;
629 }
630
631 v4l2_info(v4l2_dev, "Registered %s as /dev/%s\n",
632 vdev->name, video_device_node_name(vdev));
633
634 return 0;
635}
636
637void fimc_isp_video_device_unregister(struct fimc_isp *isp,
638 enum v4l2_buf_type type)
639{
640 struct exynos_video_entity *ve;
641
642 if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
643 ve = &isp->video_capture.ve;
644 else
645 return;
646
647 mutex_lock(&isp->video_lock);
648
649 if (video_is_registered(&ve->vdev)) {
650 video_unregister_device(&ve->vdev);
651 media_entity_cleanup(&ve->vdev.entity);
652 ve->pipe = NULL;
653 }
654
655 mutex_unlock(&isp->video_lock);
656}
This page took 0.166612 seconds and 5 git commands to generate.