Lines Matching +full:video +full:- +full:scaler
1 // SPDX-License-Identifier: GPL-2.0-only
8 * Based on drivers/media/platform/s5p-fimc,
9 * Copyright (C) 2010 - 2012 Samsung Electronics Co., Ltd.
30 #include <media/media-device.h>
31 #include <media/v4l2-ctrls.h>
32 #include <media/v4l2-event.h>
33 #include <media/v4l2-ioctl.h>
34 #include <media/videobuf2-v4l2.h>
35 #include <media/videobuf2-dma-contig.h>
37 #include "camif-core.h"
38 #include "camif-regs.h"
43 /* Locking: called with vp->camif->slock spinlock held */
46 WARN_ON(s3c_camif_get_scaler_config(vp, &vp->scaler)); in camif_cfg_video_path()
55 struct camif_frame *f = &vp->out_frame; in camif_prepare_dma_offset()
57 f->dma_offset.initial = f->rect.top * f->f_width + f->rect.left; in camif_prepare_dma_offset()
58 f->dma_offset.line = f->f_width - (f->rect.left + f->rect.width); in camif_prepare_dma_offset()
61 f->dma_offset.initial, f->dma_offset.line); in camif_prepare_dma_offset()
64 /* Locking: called with camif->slock spinlock held */
67 const struct s3c_camif_variant *variant = camif->variant; in s3c_camif_hw_init()
69 if (camif->sensor.sd == NULL || vp->out_fmt == NULL) in s3c_camif_hw_init()
70 return -EINVAL; in s3c_camif_hw_init()
72 if (variant->ip_revision == S3C244X_CAMIF_IP_REV) in s3c_camif_hw_init()
77 camif_hw_set_test_pattern(camif, camif->test_pattern); in s3c_camif_hw_init()
78 if (variant->has_img_effect) in s3c_camif_hw_init()
79 camif_hw_set_effect(camif, camif->colorfx, in s3c_camif_hw_init()
80 camif->colorfx_cr, camif->colorfx_cb); in s3c_camif_hw_init()
81 if (variant->ip_revision == S3C6410_CAMIF_IP_REV) in s3c_camif_hw_init()
84 vp->state &= ~ST_VP_CONFIG; in s3c_camif_hw_init()
90 * Initialize the video path, only up from the scaler stage. The camera
92 * video paths when the other is already running.
93 * Locking: called with camif->slock spinlock held.
97 unsigned int ip_rev = camif->variant->ip_revision; in s3c_camif_hw_vp_init()
99 if (vp->out_fmt == NULL) in s3c_camif_hw_vp_init()
100 return -EINVAL; in s3c_camif_hw_vp_init()
106 vp->state &= ~ST_VP_CONFIG; in s3c_camif_hw_vp_init()
112 struct cam_sensor *sensor = &camif->sensor; in sensor_set_power()
115 if (camif->sensor.power_count == !on) in sensor_set_power()
116 err = v4l2_subdev_call(sensor->sd, core, s_power, on); in sensor_set_power()
117 if (err == -ENOIOCTLCMD) in sensor_set_power()
120 sensor->power_count += on ? 1 : -1; in sensor_set_power()
123 on, sensor->power_count, err); in sensor_set_power()
130 struct cam_sensor *sensor = &camif->sensor; in sensor_set_streaming()
133 if (camif->sensor.stream_count == !on) in sensor_set_streaming()
134 err = v4l2_subdev_call(sensor->sd, video, s_stream, on); in sensor_set_streaming()
136 sensor->stream_count += on ? 1 : -1; in sensor_set_streaming()
139 on, sensor->stream_count, err); in sensor_set_streaming()
151 struct camif_dev *camif = vp->camif; in camif_reinitialize()
156 spin_lock_irqsave(&camif->slock, flags); in camif_reinitialize()
157 streaming = vp->state & ST_VP_SENSOR_STREAMING; in camif_reinitialize()
159 vp->state &= ~(ST_VP_PENDING | ST_VP_RUNNING | ST_VP_OFF | in camif_reinitialize()
164 while (!list_empty(&vp->pending_buf_q)) { in camif_reinitialize()
166 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); in camif_reinitialize()
169 while (!list_empty(&vp->active_buf_q)) { in camif_reinitialize()
171 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); in camif_reinitialize()
174 spin_unlock_irqrestore(&camif->slock, flags); in camif_reinitialize()
184 struct camif_dev *camif = vp->camif; in s3c_vp_active()
188 spin_lock_irqsave(&camif->slock, flags); in s3c_vp_active()
189 ret = (vp->state & ST_VP_RUNNING) || (vp->state & ST_VP_PENDING); in s3c_vp_active()
190 spin_unlock_irqrestore(&camif->slock, flags); in s3c_vp_active()
200 spin_lock_irqsave(&camif->slock, flags); in camif_is_streaming()
201 status = camif->stream_count > 0; in camif_is_streaming()
202 spin_unlock_irqrestore(&camif->slock, flags); in camif_is_streaming()
209 struct camif_dev *camif = vp->camif; in camif_stop_capture()
216 spin_lock_irqsave(&camif->slock, flags); in camif_stop_capture()
217 vp->state &= ~(ST_VP_OFF | ST_VP_LASTIRQ); in camif_stop_capture()
218 vp->state |= ST_VP_ABORTING; in camif_stop_capture()
219 spin_unlock_irqrestore(&camif->slock, flags); in camif_stop_capture()
221 ret = wait_event_timeout(vp->irq_queue, in camif_stop_capture()
222 !(vp->state & ST_VP_ABORTING), in camif_stop_capture()
225 spin_lock_irqsave(&camif->slock, flags); in camif_stop_capture()
227 if (ret == 0 && !(vp->state & ST_VP_OFF)) { in camif_stop_capture()
229 vp->state &= ~(ST_VP_OFF | ST_VP_ABORTING | in camif_stop_capture()
236 spin_unlock_irqrestore(&camif->slock, flags); in camif_stop_capture()
244 struct camif_frame *frame = &vp->out_frame; in camif_prepare_addr()
248 return -EINVAL; in camif_prepare_addr()
250 pix_size = frame->rect.width * frame->rect.height; in camif_prepare_addr()
253 vp->out_fmt->colplanes, pix_size); in camif_prepare_addr()
255 paddr->y = vb2_dma_contig_plane_dma_addr(vb, 0); in camif_prepare_addr()
257 switch (vp->out_fmt->colplanes) { in camif_prepare_addr()
259 paddr->cb = 0; in camif_prepare_addr()
260 paddr->cr = 0; in camif_prepare_addr()
264 paddr->cb = (u32)(paddr->y + pix_size); in camif_prepare_addr()
265 paddr->cr = 0; in camif_prepare_addr()
268 paddr->cb = (u32)(paddr->y + pix_size); in camif_prepare_addr()
270 if (vp->out_fmt->color == IMG_FMT_YCBCR422P) in camif_prepare_addr()
271 paddr->cr = (u32)(paddr->cb + (pix_size >> 1)); in camif_prepare_addr()
273 paddr->cr = (u32)(paddr->cb + (pix_size >> 2)); in camif_prepare_addr()
275 if (vp->out_fmt->color == IMG_FMT_YCRCB420) in camif_prepare_addr()
276 swap(paddr->cb, paddr->cr); in camif_prepare_addr()
279 return -EINVAL; in camif_prepare_addr()
283 &paddr->y, &paddr->cb, &paddr->cr); in camif_prepare_addr()
291 struct camif_dev *camif = vp->camif; in s3c_camif_irq_handler()
292 unsigned int ip_rev = camif->variant->ip_revision; in s3c_camif_irq_handler()
295 spin_lock(&camif->slock); in s3c_camif_irq_handler()
307 if (vp->state & ST_VP_ABORTING) { in s3c_camif_irq_handler()
308 if (vp->state & ST_VP_OFF) { in s3c_camif_irq_handler()
310 vp->state &= ~(ST_VP_OFF | ST_VP_ABORTING | in s3c_camif_irq_handler()
312 wake_up(&vp->irq_queue); in s3c_camif_irq_handler()
314 } else if (vp->state & ST_VP_LASTIRQ) { in s3c_camif_irq_handler()
318 vp->state |= ST_VP_OFF; in s3c_camif_irq_handler()
322 vp->state |= ST_VP_LASTIRQ; in s3c_camif_irq_handler()
326 if (!list_empty(&vp->pending_buf_q) && (vp->state & ST_VP_RUNNING) && in s3c_camif_irq_handler()
327 !list_empty(&vp->active_buf_q)) { in s3c_camif_irq_handler()
340 vbuf->vb.vb2_buf.timestamp = ktime_get_ns(); in s3c_camif_irq_handler()
341 vbuf->vb.sequence = vp->frame_sequence++; in s3c_camif_irq_handler()
342 vb2_buffer_done(&vbuf->vb.vb2_buf, VB2_BUF_STATE_DONE); in s3c_camif_irq_handler()
346 vbuf->index = index; in s3c_camif_irq_handler()
347 camif_hw_set_output_addr(vp, &vbuf->paddr, index); in s3c_camif_irq_handler()
348 camif_hw_set_output_addr(vp, &vbuf->paddr, index + 2); in s3c_camif_irq_handler()
353 } else if (!(vp->state & ST_VP_ABORTING) && in s3c_camif_irq_handler()
354 (vp->state & ST_VP_PENDING)) { in s3c_camif_irq_handler()
355 vp->state |= ST_VP_RUNNING; in s3c_camif_irq_handler()
358 if (vp->state & ST_VP_CONFIG) { in s3c_camif_irq_handler()
363 camif_hw_set_test_pattern(camif, camif->test_pattern); in s3c_camif_irq_handler()
364 if (camif->variant->has_img_effect) in s3c_camif_irq_handler()
365 camif_hw_set_effect(camif, camif->colorfx, in s3c_camif_irq_handler()
366 camif->colorfx_cr, camif->colorfx_cb); in s3c_camif_irq_handler()
367 vp->state &= ~ST_VP_CONFIG; in s3c_camif_irq_handler()
370 spin_unlock(&camif->slock); in s3c_camif_irq_handler()
377 struct camif_dev *camif = vp->camif; in start_streaming()
387 spin_lock_irqsave(&camif->slock, flags); in start_streaming()
389 if (camif->stream_count == 0) { in start_streaming()
395 spin_unlock_irqrestore(&camif->slock, flags); in start_streaming()
402 spin_lock_irqsave(&camif->slock, flags); in start_streaming()
403 vp->frame_sequence = 0; in start_streaming()
404 vp->state |= ST_VP_PENDING; in start_streaming()
406 if (!list_empty(&vp->pending_buf_q) && in start_streaming()
407 (!(vp->state & ST_VP_STREAMING) || in start_streaming()
408 !(vp->state & ST_VP_SENSOR_STREAMING))) { in start_streaming()
410 camif_hw_enable_scaler(vp, vp->scaler.enable); in start_streaming()
412 vp->state |= ST_VP_STREAMING; in start_streaming()
414 if (!(vp->state & ST_VP_SENSOR_STREAMING)) { in start_streaming()
415 vp->state |= ST_VP_SENSOR_STREAMING; in start_streaming()
416 spin_unlock_irqrestore(&camif->slock, flags); in start_streaming()
419 v4l2_err(&vp->vdev, "Sensor s_stream failed\n"); in start_streaming()
427 spin_unlock_irqrestore(&camif->slock, flags); in start_streaming()
442 struct camif_frame *frame = &vp->out_frame; in queue_setup()
443 const struct camif_fmt *fmt = vp->out_fmt; in queue_setup()
447 return -EINVAL; in queue_setup()
449 size = (frame->f_width * frame->f_height * fmt->depth) / 8; in queue_setup()
452 return sizes[0] < size ? -EINVAL : 0; in queue_setup()
463 struct camif_vp *vp = vb2_get_drv_priv(vb->vb2_queue); in buffer_prepare()
465 if (vp->out_fmt == NULL) in buffer_prepare()
466 return -EINVAL; in buffer_prepare()
468 if (vb2_plane_size(vb, 0) < vp->payload) { in buffer_prepare()
469 v4l2_err(&vp->vdev, "buffer too small: %lu, required: %u\n", in buffer_prepare()
470 vb2_plane_size(vb, 0), vp->payload); in buffer_prepare()
471 return -EINVAL; in buffer_prepare()
473 vb2_set_plane_payload(vb, 0, vp->payload); in buffer_prepare()
482 struct camif_vp *vp = vb2_get_drv_priv(vb->vb2_queue); in buffer_queue()
483 struct camif_dev *camif = vp->camif; in buffer_queue()
486 spin_lock_irqsave(&camif->slock, flags); in buffer_queue()
487 WARN_ON(camif_prepare_addr(vp, &buf->vb.vb2_buf, &buf->paddr)); in buffer_queue()
489 if (!(vp->state & ST_VP_STREAMING) && vp->active_buffers < 2) { in buffer_queue()
491 buf->index = vp->buf_index; in buffer_queue()
493 camif_hw_set_output_addr(vp, &buf->paddr, buf->index); in buffer_queue()
494 camif_hw_set_output_addr(vp, &buf->paddr, buf->index + 2); in buffer_queue()
497 vp->buf_index = !vp->buf_index; in buffer_queue()
502 if (vb2_is_streaming(&vp->vb_queue) && !list_empty(&vp->pending_buf_q) in buffer_queue()
503 && !(vp->state & ST_VP_STREAMING)) { in buffer_queue()
505 vp->state |= ST_VP_STREAMING; in buffer_queue()
506 camif_hw_enable_scaler(vp, vp->scaler.enable); in buffer_queue()
508 spin_unlock_irqrestore(&camif->slock, flags); in buffer_queue()
510 if (!(vp->state & ST_VP_SENSOR_STREAMING)) { in buffer_queue()
512 vp->state |= ST_VP_SENSOR_STREAMING; in buffer_queue()
514 v4l2_err(&vp->vdev, "Sensor s_stream failed\n"); in buffer_queue()
521 spin_unlock_irqrestore(&camif->slock, flags); in buffer_queue()
537 struct camif_dev *camif = vp->camif; in s3c_camif_open()
540 pr_debug("[vp%d] state: %#x, owner: %p, pid: %d\n", vp->id, in s3c_camif_open()
541 vp->state, vp->owner, task_pid_nr(current)); in s3c_camif_open()
543 if (mutex_lock_interruptible(&camif->lock)) in s3c_camif_open()
544 return -ERESTARTSYS; in s3c_camif_open()
550 ret = pm_runtime_resume_and_get(camif->dev); in s3c_camif_open()
558 pm_runtime_put(camif->dev); in s3c_camif_open()
562 mutex_unlock(&camif->lock); in s3c_camif_open()
569 struct camif_dev *camif = vp->camif; in s3c_camif_close()
572 pr_debug("[vp%d] state: %#x, owner: %p, pid: %d\n", vp->id, in s3c_camif_close()
573 vp->state, vp->owner, task_pid_nr(current)); in s3c_camif_close()
575 mutex_lock(&camif->lock); in s3c_camif_close()
577 if (vp->owner == file->private_data) { in s3c_camif_close()
579 vb2_queue_release(&vp->vb_queue); in s3c_camif_close()
580 vp->owner = NULL; in s3c_camif_close()
585 pm_runtime_put(camif->dev); in s3c_camif_close()
588 mutex_unlock(&camif->lock); in s3c_camif_close()
596 struct camif_dev *camif = vp->camif; in s3c_camif_poll()
599 mutex_lock(&camif->lock); in s3c_camif_poll()
600 if (vp->owner && vp->owner != file->private_data) in s3c_camif_poll()
603 ret = vb2_poll(&vp->vb_queue, file, wait); in s3c_camif_poll()
605 mutex_unlock(&camif->lock); in s3c_camif_poll()
614 if (vp->owner && vp->owner != file->private_data) in s3c_camif_mmap()
615 ret = -EBUSY; in s3c_camif_mmap()
617 ret = vb2_mmap(&vp->vb_queue, vma); in s3c_camif_mmap()
632 * Video node IOCTLs
640 strscpy(cap->driver, S3C_CAMIF_DRIVER_NAME, sizeof(cap->driver)); in s3c_camif_vidioc_querycap()
641 strscpy(cap->card, S3C_CAMIF_DRIVER_NAME, sizeof(cap->card)); in s3c_camif_vidioc_querycap()
642 snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s.%d", in s3c_camif_vidioc_querycap()
643 dev_name(vp->camif->dev), vp->id); in s3c_camif_vidioc_querycap()
651 struct v4l2_subdev *sensor = vp->camif->sensor.sd; in s3c_camif_vidioc_enum_input()
653 if (input->index || sensor == NULL) in s3c_camif_vidioc_enum_input()
654 return -EINVAL; in s3c_camif_vidioc_enum_input()
656 input->type = V4L2_INPUT_TYPE_CAMERA; in s3c_camif_vidioc_enum_input()
657 strscpy(input->name, sensor->name, sizeof(input->name)); in s3c_camif_vidioc_enum_input()
664 return i == 0 ? 0 : -EINVAL; in s3c_camif_vidioc_s_input()
680 fmt = s3c_camif_find_format(vp, NULL, f->index); in s3c_camif_vidioc_enum_fmt()
682 return -EINVAL; in s3c_camif_vidioc_enum_fmt()
684 f->pixelformat = fmt->fourcc; in s3c_camif_vidioc_enum_fmt()
692 struct v4l2_pix_format *pix = &f->fmt.pix; in s3c_camif_vidioc_g_fmt()
693 struct camif_frame *frame = &vp->out_frame; in s3c_camif_vidioc_g_fmt()
694 const struct camif_fmt *fmt = vp->out_fmt; in s3c_camif_vidioc_g_fmt()
696 pix->bytesperline = frame->f_width * fmt->ybpp; in s3c_camif_vidioc_g_fmt()
697 pix->sizeimage = vp->payload; in s3c_camif_vidioc_g_fmt()
699 pix->pixelformat = fmt->fourcc; in s3c_camif_vidioc_g_fmt()
700 pix->width = frame->f_width; in s3c_camif_vidioc_g_fmt()
701 pix->height = frame->f_height; in s3c_camif_vidioc_g_fmt()
702 pix->field = V4L2_FIELD_NONE; in s3c_camif_vidioc_g_fmt()
703 pix->colorspace = V4L2_COLORSPACE_JPEG; in s3c_camif_vidioc_g_fmt()
712 struct camif_dev *camif = vp->camif; in __camif_video_try_format()
713 struct v4l2_rect *crop = &camif->camif_crop; in __camif_video_try_format()
718 fmt = s3c_camif_find_format(vp, &pix->pixelformat, 0); in __camif_video_try_format()
721 return -EINVAL; in __camif_video_try_format()
726 pix_lim = &camif->variant->vp_pix_limits[vp->id]; in __camif_video_try_format()
729 pix->width, pix->height, crop->width, crop->height, in __camif_video_try_format()
730 pix->bytesperline); in __camif_video_try_format()
735 sc_hrmax = min(SCALER_MAX_RATIO, 1 << (ffs(crop->width) - 3)); in __camif_video_try_format()
736 sc_vrmax = min(SCALER_MAX_RATIO, 1 << (ffs(crop->height) - 1)); in __camif_video_try_format()
738 wmin = max_t(u32, pix_lim->min_out_width, crop->width / sc_hrmax); in __camif_video_try_format()
739 wmin = round_up(wmin, pix_lim->out_width_align); in __camif_video_try_format()
740 hmin = max_t(u32, 8, crop->height / sc_vrmax); in __camif_video_try_format()
743 v4l_bound_align_image(&pix->width, wmin, pix_lim->max_sc_out_width, in __camif_video_try_format()
744 ffs(pix_lim->out_width_align) - 1, in __camif_video_try_format()
745 &pix->height, hmin, pix_lim->max_height, 0, 0); in __camif_video_try_format()
747 pix->bytesperline = pix->width * fmt->ybpp; in __camif_video_try_format()
748 pix->sizeimage = (pix->width * pix->height * fmt->depth) / 8; in __camif_video_try_format()
749 pix->pixelformat = fmt->fourcc; in __camif_video_try_format()
750 pix->colorspace = V4L2_COLORSPACE_JPEG; in __camif_video_try_format()
751 pix->field = V4L2_FIELD_NONE; in __camif_video_try_format()
754 pix->width, pix->height, wmin, hmin, sc_hrmax, sc_vrmax); in __camif_video_try_format()
763 return __camif_video_try_format(vp, &f->fmt.pix, NULL); in s3c_camif_vidioc_try_fmt()
769 struct v4l2_pix_format *pix = &f->fmt.pix; in s3c_camif_vidioc_s_fmt()
771 struct camif_frame *out_frame = &vp->out_frame; in s3c_camif_vidioc_s_fmt()
775 pr_debug("[vp%d]\n", vp->id); in s3c_camif_vidioc_s_fmt()
777 if (vb2_is_busy(&vp->vb_queue)) in s3c_camif_vidioc_s_fmt()
778 return -EBUSY; in s3c_camif_vidioc_s_fmt()
780 ret = __camif_video_try_format(vp, &f->fmt.pix, &fmt); in s3c_camif_vidioc_s_fmt()
784 vp->out_fmt = fmt; in s3c_camif_vidioc_s_fmt()
785 vp->payload = pix->sizeimage; in s3c_camif_vidioc_s_fmt()
786 out_frame->f_width = pix->width; in s3c_camif_vidioc_s_fmt()
787 out_frame->f_height = pix->height; in s3c_camif_vidioc_s_fmt()
790 out_frame->rect.width = pix->width; in s3c_camif_vidioc_s_fmt()
791 out_frame->rect.height = pix->height; in s3c_camif_vidioc_s_fmt()
792 out_frame->rect.left = 0; in s3c_camif_vidioc_s_fmt()
793 out_frame->rect.top = 0; in s3c_camif_vidioc_s_fmt()
795 if (vp->owner == NULL) in s3c_camif_vidioc_s_fmt()
796 vp->owner = priv; in s3c_camif_vidioc_s_fmt()
799 out_frame->f_width, out_frame->f_height, vp->payload, in s3c_camif_vidioc_s_fmt()
800 fmt->fourcc, pix->width * pix->height * fmt->depth, in s3c_camif_vidioc_s_fmt()
801 fmt->depth, pix->sizeimage, pix->bytesperline); in s3c_camif_vidioc_s_fmt()
816 pad = media_pad_remote_pad_first(&camif->pads[0]); in camif_pipeline_validate()
817 if (!pad || !is_media_entity_v4l2_subdev(pad->entity)) in camif_pipeline_validate()
818 return -EPIPE; in camif_pipeline_validate()
820 src_fmt.pad = pad->index; in camif_pipeline_validate()
821 ret = v4l2_subdev_call(camif->sensor.sd, pad, get_fmt, NULL, &src_fmt); in camif_pipeline_validate()
822 if (ret < 0 && ret != -ENOIOCTLCMD) in camif_pipeline_validate()
823 return -EPIPE; in camif_pipeline_validate()
825 if (src_fmt.format.width != camif->mbus_fmt.width || in camif_pipeline_validate()
826 src_fmt.format.height != camif->mbus_fmt.height || in camif_pipeline_validate()
827 src_fmt.format.code != camif->mbus_fmt.code) in camif_pipeline_validate()
828 return -EPIPE; in camif_pipeline_validate()
837 struct camif_dev *camif = vp->camif; in s3c_camif_streamon()
838 struct media_entity *sensor = &camif->sensor.sd->entity; in s3c_camif_streamon()
841 pr_debug("[vp%d]\n", vp->id); in s3c_camif_streamon()
844 return -EINVAL; in s3c_camif_streamon()
846 if (vp->owner && vp->owner != priv) in s3c_camif_streamon()
847 return -EBUSY; in s3c_camif_streamon()
852 ret = media_pipeline_start(sensor->pads, camif->m_pipeline); in s3c_camif_streamon()
858 media_pipeline_stop(sensor->pads); in s3c_camif_streamon()
862 return vb2_streamon(&vp->vb_queue, type); in s3c_camif_streamon()
869 struct camif_dev *camif = vp->camif; in s3c_camif_streamoff()
872 pr_debug("[vp%d]\n", vp->id); in s3c_camif_streamoff()
875 return -EINVAL; in s3c_camif_streamoff()
877 if (vp->owner && vp->owner != priv) in s3c_camif_streamoff()
878 return -EBUSY; in s3c_camif_streamoff()
880 ret = vb2_streamoff(&vp->vb_queue, type); in s3c_camif_streamoff()
882 media_pipeline_stop(camif->sensor.sd->entity.pads); in s3c_camif_streamoff()
893 vp->id, rb->count, vp->owner, priv); in s3c_camif_reqbufs()
895 if (vp->owner && vp->owner != priv) in s3c_camif_reqbufs()
896 return -EBUSY; in s3c_camif_reqbufs()
898 if (rb->count) in s3c_camif_reqbufs()
899 rb->count = max_t(u32, CAMIF_REQ_BUFS_MIN, rb->count); in s3c_camif_reqbufs()
901 vp->owner = NULL; in s3c_camif_reqbufs()
903 ret = vb2_reqbufs(&vp->vb_queue, rb); in s3c_camif_reqbufs()
907 if (rb->count && rb->count < CAMIF_REQ_BUFS_MIN) { in s3c_camif_reqbufs()
908 rb->count = 0; in s3c_camif_reqbufs()
909 vb2_reqbufs(&vp->vb_queue, rb); in s3c_camif_reqbufs()
910 ret = -ENOMEM; in s3c_camif_reqbufs()
913 vp->reqbufs_count = rb->count; in s3c_camif_reqbufs()
914 if (vp->owner == NULL && rb->count > 0) in s3c_camif_reqbufs()
915 vp->owner = priv; in s3c_camif_reqbufs()
924 return vb2_querybuf(&vp->vb_queue, buf); in s3c_camif_querybuf()
932 pr_debug("[vp%d]\n", vp->id); in s3c_camif_qbuf()
934 if (vp->owner && vp->owner != priv) in s3c_camif_qbuf()
935 return -EBUSY; in s3c_camif_qbuf()
937 return vb2_qbuf(&vp->vb_queue, vp->vdev.v4l2_dev->mdev, buf); in s3c_camif_qbuf()
945 pr_debug("[vp%d] sequence: %d\n", vp->id, vp->frame_sequence); in s3c_camif_dqbuf()
947 if (vp->owner && vp->owner != priv) in s3c_camif_dqbuf()
948 return -EBUSY; in s3c_camif_dqbuf()
950 return vb2_dqbuf(&vp->vb_queue, buf, file->f_flags & O_NONBLOCK); in s3c_camif_dqbuf()
959 if (vp->owner && vp->owner != priv) in s3c_camif_create_bufs()
960 return -EBUSY; in s3c_camif_create_bufs()
962 create->count = max_t(u32, 1, create->count); in s3c_camif_create_bufs()
963 ret = vb2_create_bufs(&vp->vb_queue, create); in s3c_camif_create_bufs()
965 if (!ret && vp->owner == NULL) in s3c_camif_create_bufs()
966 vp->owner = priv; in s3c_camif_create_bufs()
975 return vb2_prepare_buf(&vp->vb_queue, vp->vdev.v4l2_dev->mdev, b); in s3c_camif_prepare_buf()
983 if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) in s3c_camif_g_selection()
984 return -EINVAL; in s3c_camif_g_selection()
986 switch (sel->target) { in s3c_camif_g_selection()
989 sel->r.left = 0; in s3c_camif_g_selection()
990 sel->r.top = 0; in s3c_camif_g_selection()
991 sel->r.width = vp->out_frame.f_width; in s3c_camif_g_selection()
992 sel->r.height = vp->out_frame.f_height; in s3c_camif_g_selection()
996 sel->r = vp->out_frame.rect; in s3c_camif_g_selection()
1000 return -EINVAL; in s3c_camif_g_selection()
1007 if (camif->variant->ip_revision == S3C244X_CAMIF_IP_REV) { in __camif_try_compose()
1008 *r = vp->out_frame.rect; in __camif_try_compose()
1019 struct camif_dev *camif = vp->camif; in s3c_camif_s_selection()
1020 struct v4l2_rect rect = sel->r; in s3c_camif_s_selection()
1023 if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || in s3c_camif_s_selection()
1024 sel->target != V4L2_SEL_TGT_COMPOSE) in s3c_camif_s_selection()
1025 return -EINVAL; in s3c_camif_s_selection()
1029 sel->r = rect; in s3c_camif_s_selection()
1030 spin_lock_irqsave(&camif->slock, flags); in s3c_camif_s_selection()
1031 vp->out_frame.rect = rect; in s3c_camif_s_selection()
1032 vp->state |= ST_VP_CONFIG; in s3c_camif_s_selection()
1033 spin_unlock_irqrestore(&camif->slock, flags); in s3c_camif_s_selection()
1036 sel->type, sel->target, sel->flags, in s3c_camif_s_selection()
1037 sel->r.left, sel->r.top, sel->r.width, sel->r.height); in s3c_camif_s_selection()
1067 * Video node controls
1071 struct camif_vp *vp = ctrl->priv; in s3c_camif_video_s_ctrl()
1072 struct camif_dev *camif = vp->camif; in s3c_camif_video_s_ctrl()
1075 pr_debug("[vp%d] ctrl: %s, value: %d\n", vp->id, in s3c_camif_video_s_ctrl()
1076 ctrl->name, ctrl->val); in s3c_camif_video_s_ctrl()
1078 spin_lock_irqsave(&camif->slock, flags); in s3c_camif_video_s_ctrl()
1080 switch (ctrl->id) { in s3c_camif_video_s_ctrl()
1082 vp->hflip = ctrl->val; in s3c_camif_video_s_ctrl()
1086 vp->vflip = ctrl->val; in s3c_camif_video_s_ctrl()
1090 vp->state |= ST_VP_CONFIG; in s3c_camif_video_s_ctrl()
1091 spin_unlock_irqrestore(&camif->slock, flags); in s3c_camif_video_s_ctrl()
1095 /* Codec and preview video node control ops */
1102 struct camif_vp *vp = &camif->vp[idx]; in s3c_camif_register_video_node()
1103 struct vb2_queue *q = &vp->vb_queue; in s3c_camif_register_video_node()
1104 struct video_device *vfd = &vp->vdev; in s3c_camif_register_video_node()
1109 snprintf(vfd->name, sizeof(vfd->name), "camif-%s", in s3c_camif_register_video_node()
1110 vp->id == 0 ? "codec" : "preview"); in s3c_camif_register_video_node()
1112 vfd->fops = &s3c_camif_fops; in s3c_camif_register_video_node()
1113 vfd->ioctl_ops = &s3c_camif_ioctl_ops; in s3c_camif_register_video_node()
1114 vfd->v4l2_dev = &camif->v4l2_dev; in s3c_camif_register_video_node()
1115 vfd->minor = -1; in s3c_camif_register_video_node()
1116 vfd->release = video_device_release_empty; in s3c_camif_register_video_node()
1117 vfd->lock = &camif->lock; in s3c_camif_register_video_node()
1118 vp->reqbufs_count = 0; in s3c_camif_register_video_node()
1120 INIT_LIST_HEAD(&vp->pending_buf_q); in s3c_camif_register_video_node()
1121 INIT_LIST_HEAD(&vp->active_buf_q); in s3c_camif_register_video_node()
1124 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; in s3c_camif_register_video_node()
1125 q->io_modes = VB2_MMAP | VB2_USERPTR; in s3c_camif_register_video_node()
1126 q->ops = &s3c_camif_qops; in s3c_camif_register_video_node()
1127 q->mem_ops = &vb2_dma_contig_memops; in s3c_camif_register_video_node()
1128 q->buf_struct_size = sizeof(struct camif_buffer); in s3c_camif_register_video_node()
1129 q->drv_priv = vp; in s3c_camif_register_video_node()
1130 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; in s3c_camif_register_video_node()
1131 q->lock = &vp->camif->lock; in s3c_camif_register_video_node()
1132 q->dev = camif->v4l2_dev.dev; in s3c_camif_register_video_node()
1138 vp->pad.flags = MEDIA_PAD_FL_SINK; in s3c_camif_register_video_node()
1139 ret = media_entity_pads_init(&vfd->entity, 1, &vp->pad); in s3c_camif_register_video_node()
1145 v4l2_ctrl_handler_init(&vp->ctrl_handler, 1); in s3c_camif_register_video_node()
1146 ctrl = v4l2_ctrl_new_std(&vp->ctrl_handler, &s3c_camif_video_ctrl_ops, in s3c_camif_register_video_node()
1149 ctrl->priv = vp; in s3c_camif_register_video_node()
1150 ctrl = v4l2_ctrl_new_std(&vp->ctrl_handler, &s3c_camif_video_ctrl_ops, in s3c_camif_register_video_node()
1153 ctrl->priv = vp; in s3c_camif_register_video_node()
1155 ret = vp->ctrl_handler.error; in s3c_camif_register_video_node()
1159 vfd->ctrl_handler = &vp->ctrl_handler; in s3c_camif_register_video_node()
1160 vfd->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_CAPTURE; in s3c_camif_register_video_node()
1162 ret = video_register_device(vfd, VFL_TYPE_VIDEO, -1); in s3c_camif_register_video_node()
1166 v4l2_info(&camif->v4l2_dev, "registered %s as /dev/%s\n", in s3c_camif_register_video_node()
1167 vfd->name, video_device_node_name(vfd)); in s3c_camif_register_video_node()
1171 v4l2_ctrl_handler_free(&vp->ctrl_handler); in s3c_camif_register_video_node()
1173 media_entity_cleanup(&vfd->entity); in s3c_camif_register_video_node()
1179 struct video_device *vfd = &camif->vp[idx].vdev; in s3c_camif_unregister_video_node()
1183 media_entity_cleanup(&vfd->entity); in s3c_camif_unregister_video_node()
1184 v4l2_ctrl_handler_free(vfd->ctrl_handler); in s3c_camif_unregister_video_node()
1204 if (code->index >= ARRAY_SIZE(camif_mbus_formats)) in s3c_camif_subdev_enum_mbus_code()
1205 return -EINVAL; in s3c_camif_subdev_enum_mbus_code()
1207 code->code = camif_mbus_formats[code->index]; in s3c_camif_subdev_enum_mbus_code()
1216 struct v4l2_mbus_framefmt *mf = &fmt->format; in s3c_camif_subdev_get_fmt()
1218 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { in s3c_camif_subdev_get_fmt()
1219 mf = v4l2_subdev_state_get_format(sd_state, fmt->pad); in s3c_camif_subdev_get_fmt()
1220 fmt->format = *mf; in s3c_camif_subdev_get_fmt()
1224 mutex_lock(&camif->lock); in s3c_camif_subdev_get_fmt()
1226 switch (fmt->pad) { in s3c_camif_subdev_get_fmt()
1229 *mf = camif->mbus_fmt; in s3c_camif_subdev_get_fmt()
1234 mf->width = camif->camif_crop.width; in s3c_camif_subdev_get_fmt()
1235 mf->height = camif->camif_crop.height; in s3c_camif_subdev_get_fmt()
1236 mf->code = camif->mbus_fmt.code; in s3c_camif_subdev_get_fmt()
1240 mutex_unlock(&camif->lock); in s3c_camif_subdev_get_fmt()
1241 mf->field = V4L2_FIELD_NONE; in s3c_camif_subdev_get_fmt()
1242 mf->colorspace = V4L2_COLORSPACE_JPEG; in s3c_camif_subdev_get_fmt()
1249 const struct s3c_camif_variant *variant = camif->variant; in __camif_subdev_try_format()
1254 pix_lim = &variant->vp_pix_limits[VP_CODEC]; in __camif_subdev_try_format()
1257 if (camif_mbus_formats[i] == mf->code) in __camif_subdev_try_format()
1261 mf->code = camif_mbus_formats[0]; in __camif_subdev_try_format()
1264 v4l_bound_align_image(&mf->width, 8, CAMIF_MAX_PIX_WIDTH, in __camif_subdev_try_format()
1265 ffs(pix_lim->out_width_align) - 1, in __camif_subdev_try_format()
1266 &mf->height, 8, CAMIF_MAX_PIX_HEIGHT, 0, in __camif_subdev_try_format()
1269 struct v4l2_rect *crop = &camif->camif_crop; in __camif_subdev_try_format()
1270 v4l_bound_align_image(&mf->width, 8, crop->width, in __camif_subdev_try_format()
1271 ffs(pix_lim->out_width_align) - 1, in __camif_subdev_try_format()
1272 &mf->height, 8, crop->height, in __camif_subdev_try_format()
1276 v4l2_dbg(1, debug, &camif->subdev, "%ux%u\n", mf->width, mf->height); in __camif_subdev_try_format()
1284 struct v4l2_mbus_framefmt *mf = &fmt->format; in s3c_camif_subdev_set_fmt()
1285 struct v4l2_rect *crop = &camif->camif_crop; in s3c_camif_subdev_set_fmt()
1289 fmt->pad, mf->code, mf->width, mf->height); in s3c_camif_subdev_set_fmt()
1291 mf->field = V4L2_FIELD_NONE; in s3c_camif_subdev_set_fmt()
1292 mf->colorspace = V4L2_COLORSPACE_JPEG; in s3c_camif_subdev_set_fmt()
1293 mutex_lock(&camif->lock); in s3c_camif_subdev_set_fmt()
1299 if (vb2_is_busy(&camif->vp[VP_CODEC].vb_queue) || in s3c_camif_subdev_set_fmt()
1300 vb2_is_busy(&camif->vp[VP_PREVIEW].vb_queue)) { in s3c_camif_subdev_set_fmt()
1301 mutex_unlock(&camif->lock); in s3c_camif_subdev_set_fmt()
1302 return -EBUSY; in s3c_camif_subdev_set_fmt()
1305 __camif_subdev_try_format(camif, mf, fmt->pad); in s3c_camif_subdev_set_fmt()
1307 if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { in s3c_camif_subdev_set_fmt()
1308 mf = v4l2_subdev_state_get_format(sd_state, fmt->pad); in s3c_camif_subdev_set_fmt()
1309 *mf = fmt->format; in s3c_camif_subdev_set_fmt()
1310 mutex_unlock(&camif->lock); in s3c_camif_subdev_set_fmt()
1314 switch (fmt->pad) { in s3c_camif_subdev_set_fmt()
1316 camif->mbus_fmt = *mf; in s3c_camif_subdev_set_fmt()
1318 crop->width = mf->width; in s3c_camif_subdev_set_fmt()
1319 crop->height = mf->height; in s3c_camif_subdev_set_fmt()
1320 crop->left = 0; in s3c_camif_subdev_set_fmt()
1321 crop->top = 0; in s3c_camif_subdev_set_fmt()
1324 * and the video output resolution. in s3c_camif_subdev_set_fmt()
1327 struct camif_frame *frame = &camif->vp[i].out_frame; in s3c_camif_subdev_set_fmt()
1328 frame->rect = *crop; in s3c_camif_subdev_set_fmt()
1329 frame->f_width = mf->width; in s3c_camif_subdev_set_fmt()
1330 frame->f_height = mf->height; in s3c_camif_subdev_set_fmt()
1336 mf->code = camif->mbus_fmt.code; in s3c_camif_subdev_set_fmt()
1337 mf->width = crop->width; in s3c_camif_subdev_set_fmt()
1338 mf->height = crop->height; in s3c_camif_subdev_set_fmt()
1342 mutex_unlock(&camif->lock); in s3c_camif_subdev_set_fmt()
1351 struct v4l2_rect *crop = &camif->camif_crop; in s3c_camif_subdev_get_selection()
1352 struct v4l2_mbus_framefmt *mf = &camif->mbus_fmt; in s3c_camif_subdev_get_selection()
1354 if ((sel->target != V4L2_SEL_TGT_CROP && in s3c_camif_subdev_get_selection()
1355 sel->target != V4L2_SEL_TGT_CROP_BOUNDS) || in s3c_camif_subdev_get_selection()
1356 sel->pad != CAMIF_SD_PAD_SINK) in s3c_camif_subdev_get_selection()
1357 return -EINVAL; in s3c_camif_subdev_get_selection()
1359 if (sel->which == V4L2_SUBDEV_FORMAT_TRY) { in s3c_camif_subdev_get_selection()
1360 sel->r = *v4l2_subdev_state_get_crop(sd_state, sel->pad); in s3c_camif_subdev_get_selection()
1364 mutex_lock(&camif->lock); in s3c_camif_subdev_get_selection()
1366 if (sel->target == V4L2_SEL_TGT_CROP) { in s3c_camif_subdev_get_selection()
1367 sel->r = *crop; in s3c_camif_subdev_get_selection()
1369 sel->r.width = mf->width; in s3c_camif_subdev_get_selection()
1370 sel->r.height = mf->height; in s3c_camif_subdev_get_selection()
1371 sel->r.left = 0; in s3c_camif_subdev_get_selection()
1372 sel->r.top = 0; in s3c_camif_subdev_get_selection()
1375 mutex_unlock(&camif->lock); in s3c_camif_subdev_get_selection()
1378 __func__, crop->left, crop->top, crop->width, in s3c_camif_subdev_get_selection()
1379 crop->height, mf->width, mf->height); in s3c_camif_subdev_get_selection()
1386 struct v4l2_mbus_framefmt *mf = &camif->mbus_fmt; in __camif_try_crop()
1387 const struct camif_pix_limits *pix_lim = &camif->variant->pix_limits; in __camif_try_crop()
1388 unsigned int left = 2 * r->left; in __camif_try_crop()
1389 unsigned int top = 2 * r->top; in __camif_try_crop()
1393 * - r->width + 2 * r->left = mf->width; in __camif_try_crop()
1394 * - r->height + 2 * r->top = mf->height; in __camif_try_crop()
1395 * - crop rectangle size and position must be aligned in __camif_try_crop()
1398 v4l_bound_align_image(&r->width, 0, mf->width, in __camif_try_crop()
1399 ffs(pix_lim->win_hor_offset_align) - 1, in __camif_try_crop()
1400 &r->height, 0, mf->height, 1, 0); in __camif_try_crop()
1402 v4l_bound_align_image(&left, 0, mf->width - r->width, in __camif_try_crop()
1403 ffs(pix_lim->win_hor_offset_align), in __camif_try_crop()
1404 &top, 0, mf->height - r->height, 2, 0); in __camif_try_crop()
1406 r->left = left / 2; in __camif_try_crop()
1407 r->top = top / 2; in __camif_try_crop()
1408 r->width = mf->width - left; in __camif_try_crop()
1409 r->height = mf->height - top; in __camif_try_crop()
1413 * this scaler constraint is not met. in __camif_try_crop()
1415 if (camif->variant->ip_revision == S3C244X_CAMIF_IP_REV && in __camif_try_crop()
1420 struct v4l2_rect *or = &camif->vp[i].out_frame.rect; in __camif_try_crop()
1421 if ((or->width > r->width) == (or->height > r->height)) in __camif_try_crop()
1423 *r = camif->camif_crop; in __camif_try_crop()
1429 v4l2_dbg(1, debug, &camif->v4l2_dev, "crop: (%d,%d)/%dx%d, fmt: %ux%u\n", in __camif_try_crop()
1430 r->left, r->top, r->width, r->height, mf->width, mf->height); in __camif_try_crop()
1438 struct v4l2_rect *crop = &camif->camif_crop; in s3c_camif_subdev_set_selection()
1439 struct camif_scaler scaler; in s3c_camif_subdev_set_selection() local
1441 if (sel->target != V4L2_SEL_TGT_CROP || sel->pad != CAMIF_SD_PAD_SINK) in s3c_camif_subdev_set_selection()
1442 return -EINVAL; in s3c_camif_subdev_set_selection()
1444 mutex_lock(&camif->lock); in s3c_camif_subdev_set_selection()
1445 __camif_try_crop(camif, &sel->r); in s3c_camif_subdev_set_selection()
1447 if (sel->which == V4L2_SUBDEV_FORMAT_TRY) { in s3c_camif_subdev_set_selection()
1448 *v4l2_subdev_state_get_crop(sd_state, sel->pad) = sel->r; in s3c_camif_subdev_set_selection()
1453 spin_lock_irqsave(&camif->slock, flags); in s3c_camif_subdev_set_selection()
1454 *crop = sel->r; in s3c_camif_subdev_set_selection()
1457 struct camif_vp *vp = &camif->vp[i]; in s3c_camif_subdev_set_selection()
1458 scaler = vp->scaler; in s3c_camif_subdev_set_selection()
1459 if (s3c_camif_get_scaler_config(vp, &scaler)) in s3c_camif_subdev_set_selection()
1461 vp->scaler = scaler; in s3c_camif_subdev_set_selection()
1462 vp->state |= ST_VP_CONFIG; in s3c_camif_subdev_set_selection()
1465 spin_unlock_irqrestore(&camif->slock, flags); in s3c_camif_subdev_set_selection()
1467 mutex_unlock(&camif->lock); in s3c_camif_subdev_set_selection()
1470 __func__, crop->left, crop->top, crop->width, crop->height, in s3c_camif_subdev_set_selection()
1471 camif->mbus_fmt.width, camif->mbus_fmt.height); in s3c_camif_subdev_set_selection()
1490 struct camif_dev *camif = container_of(ctrl->handler, struct camif_dev, in s3c_camif_subdev_s_ctrl()
1494 spin_lock_irqsave(&camif->slock, flags); in s3c_camif_subdev_s_ctrl()
1496 switch (ctrl->id) { in s3c_camif_subdev_s_ctrl()
1498 camif->colorfx = camif->ctrl_colorfx->val; in s3c_camif_subdev_s_ctrl()
1500 switch (ctrl->val) { in s3c_camif_subdev_s_ctrl()
1502 camif->colorfx_cb = 115; in s3c_camif_subdev_s_ctrl()
1503 camif->colorfx_cr = 145; in s3c_camif_subdev_s_ctrl()
1506 camif->colorfx_cb = camif->ctrl_colorfx_cbcr->val >> 8; in s3c_camif_subdev_s_ctrl()
1507 camif->colorfx_cr = camif->ctrl_colorfx_cbcr->val & 0xff; in s3c_camif_subdev_s_ctrl()
1511 camif->colorfx_cb = 128; in s3c_camif_subdev_s_ctrl()
1512 camif->colorfx_cr = 128; in s3c_camif_subdev_s_ctrl()
1516 camif->test_pattern = camif->ctrl_test_pattern->val; in s3c_camif_subdev_s_ctrl()
1522 camif->vp[VP_CODEC].state |= ST_VP_CONFIG; in s3c_camif_subdev_s_ctrl()
1523 camif->vp[VP_PREVIEW].state |= ST_VP_CONFIG; in s3c_camif_subdev_s_ctrl()
1524 spin_unlock_irqrestore(&camif->slock, flags); in s3c_camif_subdev_s_ctrl()
1542 struct v4l2_ctrl_handler *handler = &camif->ctrl_handler; in s3c_camif_create_subdev()
1543 struct v4l2_subdev *sd = &camif->subdev; in s3c_camif_create_subdev()
1547 sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in s3c_camif_create_subdev()
1548 strscpy(sd->name, "S3C-CAMIF", sizeof(sd->name)); in s3c_camif_create_subdev()
1550 camif->pads[CAMIF_SD_PAD_SINK].flags = MEDIA_PAD_FL_SINK; in s3c_camif_create_subdev()
1551 camif->pads[CAMIF_SD_PAD_SOURCE_C].flags = MEDIA_PAD_FL_SOURCE; in s3c_camif_create_subdev()
1552 camif->pads[CAMIF_SD_PAD_SOURCE_P].flags = MEDIA_PAD_FL_SOURCE; in s3c_camif_create_subdev()
1554 ret = media_entity_pads_init(&sd->entity, CAMIF_SD_PADS_NUM, in s3c_camif_create_subdev()
1555 camif->pads); in s3c_camif_create_subdev()
1560 camif->ctrl_test_pattern = v4l2_ctrl_new_std_menu_items(handler, in s3c_camif_create_subdev()
1562 ARRAY_SIZE(s3c_camif_test_pattern_menu) - 1, 0, 0, in s3c_camif_create_subdev()
1565 if (camif->variant->has_img_effect) { in s3c_camif_create_subdev()
1566 camif->ctrl_colorfx = v4l2_ctrl_new_std_menu(handler, in s3c_camif_create_subdev()
1571 camif->ctrl_colorfx_cbcr = v4l2_ctrl_new_std(handler, in s3c_camif_create_subdev()
1576 if (handler->error) { in s3c_camif_create_subdev()
1578 media_entity_cleanup(&sd->entity); in s3c_camif_create_subdev()
1579 return handler->error; in s3c_camif_create_subdev()
1582 if (camif->variant->has_img_effect) in s3c_camif_create_subdev()
1583 v4l2_ctrl_auto_cluster(2, &camif->ctrl_colorfx, in s3c_camif_create_subdev()
1586 sd->ctrl_handler = handler; in s3c_camif_create_subdev()
1594 struct v4l2_subdev *sd = &camif->subdev; in s3c_camif_unregister_subdev()
1601 media_entity_cleanup(&sd->entity); in s3c_camif_unregister_subdev()
1602 v4l2_ctrl_handler_free(&camif->ctrl_handler); in s3c_camif_unregister_subdev()
1608 unsigned int ip_rev = camif->variant->ip_revision; in s3c_camif_set_defaults()
1612 struct camif_vp *vp = &camif->vp[i]; in s3c_camif_set_defaults()
1613 struct camif_frame *f = &vp->out_frame; in s3c_camif_set_defaults()
1615 vp->camif = camif; in s3c_camif_set_defaults()
1616 vp->id = i; in s3c_camif_set_defaults()
1617 vp->offset = camif->variant->vp_offset; in s3c_camif_set_defaults()
1620 vp->fmt_flags = i ? FMT_FL_S3C24XX_PREVIEW : in s3c_camif_set_defaults()
1623 vp->fmt_flags = FMT_FL_S3C64XX; in s3c_camif_set_defaults()
1625 vp->out_fmt = s3c_camif_find_format(vp, NULL, 0); in s3c_camif_set_defaults()
1626 BUG_ON(vp->out_fmt == NULL); in s3c_camif_set_defaults()
1629 f->f_width = CAMIF_DEF_WIDTH; in s3c_camif_set_defaults()
1630 f->f_height = CAMIF_DEF_HEIGHT; in s3c_camif_set_defaults()
1631 f->rect.width = CAMIF_DEF_WIDTH; in s3c_camif_set_defaults()
1632 f->rect.height = CAMIF_DEF_HEIGHT; in s3c_camif_set_defaults()
1634 /* Scaler is always enabled */ in s3c_camif_set_defaults()
1635 vp->scaler.enable = 1; in s3c_camif_set_defaults()
1637 vp->payload = (f->f_width * f->f_height * in s3c_camif_set_defaults()
1638 vp->out_fmt->depth) / 8; in s3c_camif_set_defaults()
1641 memset(&camif->mbus_fmt, 0, sizeof(camif->mbus_fmt)); in s3c_camif_set_defaults()
1642 camif->mbus_fmt.width = CAMIF_DEF_WIDTH; in s3c_camif_set_defaults()
1643 camif->mbus_fmt.height = CAMIF_DEF_HEIGHT; in s3c_camif_set_defaults()
1644 camif->mbus_fmt.code = camif_mbus_formats[0]; in s3c_camif_set_defaults()
1646 memset(&camif->camif_crop, 0, sizeof(camif->camif_crop)); in s3c_camif_set_defaults()
1647 camif->camif_crop.width = CAMIF_DEF_WIDTH; in s3c_camif_set_defaults()
1648 camif->camif_crop.height = CAMIF_DEF_HEIGHT; in s3c_camif_set_defaults()