diff options
| author | Sylwester Nawrocki <s.nawrocki@samsung.com> | 2012-05-08 14:51:24 -0400 |
|---|---|---|
| committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-05-20 08:15:10 -0400 |
| commit | 97d974226575227ebafdf3ab009f0212d8a7e223 (patch) | |
| tree | 15776cc9f7081d54367b0d2e2e33a32070e0be59 | |
| parent | 41df5bf088a10e54c0613ec4d7350b74d5ab8252 (diff) | |
[media] s5p-fimc: Move m2m node driver into separate file
Virtually no functional changes, just code reordering. This let us to
clearly separate all logical functions available in the driver: fimc
capture, mem-to-mem, and later fimc-lite capture, ISP features, etc.
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>
| -rw-r--r-- | drivers/media/video/s5p-fimc/Makefile | 2 | ||||
| -rw-r--r-- | drivers/media/video/s5p-fimc/fimc-capture.c | 68 | ||||
| -rw-r--r-- | drivers/media/video/s5p-fimc/fimc-core.c | 859 | ||||
| -rw-r--r-- | drivers/media/video/s5p-fimc/fimc-core.h | 10 | ||||
| -rw-r--r-- | drivers/media/video/s5p-fimc/fimc-m2m.c | 812 |
5 files changed, 894 insertions, 857 deletions
diff --git a/drivers/media/video/s5p-fimc/Makefile b/drivers/media/video/s5p-fimc/Makefile index 33dec7f890e7..1da3c6ae7fa8 100644 --- a/drivers/media/video/s5p-fimc/Makefile +++ b/drivers/media/video/s5p-fimc/Makefile | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | s5p-fimc-objs := fimc-core.o fimc-reg.o fimc-capture.o fimc-mdevice.o | 1 | s5p-fimc-objs := fimc-core.o fimc-reg.o fimc-m2m.o fimc-capture.o fimc-mdevice.o |
| 2 | s5p-csis-objs := mipi-csis.o | 2 | s5p-csis-objs := mipi-csis.o |
| 3 | 3 | ||
| 4 | obj-$(CONFIG_VIDEO_S5P_MIPI_CSIS) += s5p-csis.o | 4 | obj-$(CONFIG_VIDEO_S5P_MIPI_CSIS) += s5p-csis.o |
diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c b/drivers/media/video/s5p-fimc/fimc-capture.c index be5e4e237297..0051d8161c6c 100644 --- a/drivers/media/video/s5p-fimc/fimc-capture.c +++ b/drivers/media/video/s5p-fimc/fimc-capture.c | |||
| @@ -139,7 +139,7 @@ static int fimc_stop_capture(struct fimc_dev *fimc, bool suspend) | |||
| 139 | * spinlock held. It updates the camera pixel crop, rotation and | 139 | * spinlock held. It updates the camera pixel crop, rotation and |
| 140 | * image flip in H/W. | 140 | * image flip in H/W. |
| 141 | */ | 141 | */ |
| 142 | int fimc_capture_config_update(struct fimc_ctx *ctx) | 142 | static int fimc_capture_config_update(struct fimc_ctx *ctx) |
| 143 | { | 143 | { |
| 144 | struct fimc_dev *fimc = ctx->fimc_dev; | 144 | struct fimc_dev *fimc = ctx->fimc_dev; |
| 145 | int ret; | 145 | int ret; |
| @@ -166,6 +166,70 @@ int fimc_capture_config_update(struct fimc_ctx *ctx) | |||
| 166 | return ret; | 166 | return ret; |
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | void fimc_capture_irq_handler(struct fimc_dev *fimc, int deq_buf) | ||
| 170 | { | ||
| 171 | struct fimc_vid_cap *cap = &fimc->vid_cap; | ||
| 172 | struct fimc_vid_buffer *v_buf; | ||
| 173 | struct timeval *tv; | ||
| 174 | struct timespec ts; | ||
| 175 | |||
| 176 | if (test_and_clear_bit(ST_CAPT_SHUT, &fimc->state)) { | ||
| 177 | wake_up(&fimc->irq_queue); | ||
| 178 | goto done; | ||
| 179 | } | ||
| 180 | |||
| 181 | if (!list_empty(&cap->active_buf_q) && | ||
| 182 | test_bit(ST_CAPT_RUN, &fimc->state) && deq_buf) { | ||
| 183 | ktime_get_real_ts(&ts); | ||
| 184 | |||
| 185 | v_buf = fimc_active_queue_pop(cap); | ||
| 186 | |||
| 187 | tv = &v_buf->vb.v4l2_buf.timestamp; | ||
| 188 | tv->tv_sec = ts.tv_sec; | ||
| 189 | tv->tv_usec = ts.tv_nsec / NSEC_PER_USEC; | ||
| 190 | v_buf->vb.v4l2_buf.sequence = cap->frame_count++; | ||
| 191 | |||
| 192 | vb2_buffer_done(&v_buf->vb, VB2_BUF_STATE_DONE); | ||
| 193 | } | ||
| 194 | |||
| 195 | if (!list_empty(&cap->pending_buf_q)) { | ||
| 196 | |||
| 197 | v_buf = fimc_pending_queue_pop(cap); | ||
| 198 | fimc_hw_set_output_addr(fimc, &v_buf->paddr, cap->buf_index); | ||
| 199 | v_buf->index = cap->buf_index; | ||
| 200 | |||
| 201 | /* Move the buffer to the capture active queue */ | ||
| 202 | fimc_active_queue_add(cap, v_buf); | ||
| 203 | |||
| 204 | dbg("next frame: %d, done frame: %d", | ||
| 205 | fimc_hw_get_frame_index(fimc), v_buf->index); | ||
| 206 | |||
| 207 | if (++cap->buf_index >= FIMC_MAX_OUT_BUFS) | ||
| 208 | cap->buf_index = 0; | ||
| 209 | } | ||
| 210 | |||
| 211 | if (cap->active_buf_cnt == 0) { | ||
| 212 | if (deq_buf) | ||
| 213 | clear_bit(ST_CAPT_RUN, &fimc->state); | ||
| 214 | |||
| 215 | if (++cap->buf_index >= FIMC_MAX_OUT_BUFS) | ||
| 216 | cap->buf_index = 0; | ||
| 217 | } else { | ||
| 218 | set_bit(ST_CAPT_RUN, &fimc->state); | ||
| 219 | } | ||
| 220 | |||
| 221 | fimc_capture_config_update(cap->ctx); | ||
| 222 | done: | ||
| 223 | if (cap->active_buf_cnt == 1) { | ||
| 224 | fimc_deactivate_capture(fimc); | ||
| 225 | clear_bit(ST_CAPT_STREAM, &fimc->state); | ||
| 226 | } | ||
| 227 | |||
| 228 | dbg("frame: %d, active_buf_cnt: %d", | ||
| 229 | fimc_hw_get_frame_index(fimc), cap->active_buf_cnt); | ||
| 230 | } | ||
| 231 | |||
| 232 | |||
| 169 | static int start_streaming(struct vb2_queue *q, unsigned int count) | 233 | static int start_streaming(struct vb2_queue *q, unsigned int count) |
| 170 | { | 234 | { |
| 171 | struct fimc_ctx *ctx = q->drv_priv; | 235 | struct fimc_ctx *ctx = q->drv_priv; |
| @@ -1245,7 +1309,7 @@ void fimc_sensor_notify(struct v4l2_subdev *sd, unsigned int notification, | |||
| 1245 | struct fimc_vid_buffer, list); | 1309 | struct fimc_vid_buffer, list); |
| 1246 | vb2_set_plane_payload(&buf->vb, 0, *((u32 *)arg)); | 1310 | vb2_set_plane_payload(&buf->vb, 0, *((u32 *)arg)); |
| 1247 | } | 1311 | } |
| 1248 | fimc_capture_irq_handler(fimc, true); | 1312 | fimc_capture_irq_handler(fimc, 1); |
| 1249 | fimc_deactivate_capture(fimc); | 1313 | fimc_deactivate_capture(fimc); |
| 1250 | spin_unlock_irqrestore(&fimc->slock, irq_flags); | 1314 | spin_unlock_irqrestore(&fimc->slock, irq_flags); |
| 1251 | } | 1315 | } |
diff --git a/drivers/media/video/s5p-fimc/fimc-core.c b/drivers/media/video/s5p-fimc/fimc-core.c index f6b9060a0c0f..749db4deefcb 100644 --- a/drivers/media/video/s5p-fimc/fimc-core.c +++ b/drivers/media/video/s5p-fimc/fimc-core.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Samsung S5P/EXYNOS4 SoC series camera interface (video postprocessor) driver | 2 | * Samsung S5P/EXYNOS4 SoC series FIMC (CAMIF) driver |
| 3 | * | 3 | * |
| 4 | * Copyright (C) 2010-2011 Samsung Electronics Co., Ltd. | 4 | * Copyright (C) 2010-2011 Samsung Electronics Co., Ltd. |
| 5 | * Contact: Sylwester Nawrocki, <s.nawrocki@samsung.com> | 5 | * Contact: Sylwester Nawrocki, <s.nawrocki@samsung.com> |
| @@ -187,12 +187,12 @@ static struct fimc_fmt fimc_formats[] = { | |||
| 187 | }, | 187 | }, |
| 188 | }; | 188 | }; |
| 189 | 189 | ||
| 190 | static unsigned int get_m2m_fmt_flags(unsigned int stream_type) | 190 | struct fimc_fmt * fimc_get_format(unsigned int index) |
| 191 | { | 191 | { |
| 192 | if (stream_type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) | 192 | if (index >= ARRAY_SIZE(fimc_formats)) |
| 193 | return FMT_FLAGS_M2M_IN; | 193 | return NULL; |
| 194 | else | 194 | |
| 195 | return FMT_FLAGS_M2M_OUT; | 195 | return &fimc_formats[index]; |
| 196 | } | 196 | } |
| 197 | 197 | ||
| 198 | int fimc_check_scaler_ratio(struct fimc_ctx *ctx, int sw, int sh, | 198 | int fimc_check_scaler_ratio(struct fimc_ctx *ctx, int sw, int sh, |
| @@ -293,126 +293,9 @@ int fimc_set_scaler_info(struct fimc_ctx *ctx) | |||
| 293 | return 0; | 293 | return 0; |
| 294 | } | 294 | } |
| 295 | 295 | ||
| 296 | static void fimc_m2m_job_finish(struct fimc_ctx *ctx, int vb_state) | ||
| 297 | { | ||
| 298 | struct vb2_buffer *src_vb, *dst_vb; | ||
| 299 | |||
| 300 | if (!ctx || !ctx->m2m_ctx) | ||
| 301 | return; | ||
| 302 | |||
| 303 | src_vb = v4l2_m2m_src_buf_remove(ctx->m2m_ctx); | ||
| 304 | dst_vb = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx); | ||
| 305 | |||
| 306 | if (src_vb && dst_vb) { | ||
| 307 | v4l2_m2m_buf_done(src_vb, vb_state); | ||
| 308 | v4l2_m2m_buf_done(dst_vb, vb_state); | ||
| 309 | v4l2_m2m_job_finish(ctx->fimc_dev->m2m.m2m_dev, | ||
| 310 | ctx->m2m_ctx); | ||
| 311 | } | ||
| 312 | } | ||
| 313 | |||
| 314 | /* Complete the transaction which has been scheduled for execution. */ | ||
| 315 | static int fimc_m2m_shutdown(struct fimc_ctx *ctx) | ||
| 316 | { | ||
| 317 | struct fimc_dev *fimc = ctx->fimc_dev; | ||
| 318 | int ret; | ||
| 319 | |||
| 320 | if (!fimc_m2m_pending(fimc)) | ||
| 321 | return 0; | ||
| 322 | |||
| 323 | fimc_ctx_state_set(FIMC_CTX_SHUT, ctx); | ||
| 324 | |||
| 325 | ret = wait_event_timeout(fimc->irq_queue, | ||
| 326 | !fimc_ctx_state_is_set(FIMC_CTX_SHUT, ctx), | ||
| 327 | FIMC_SHUTDOWN_TIMEOUT); | ||
| 328 | |||
