diff options
author | Sylwester Nawrocki <s.nawrocki@samsung.com> | 2012-03-19 09:02:41 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-04-10 14:23:59 -0400 |
commit | 935b1892d81fbf1a4426ca5140ea3fd32dce1614 (patch) | |
tree | a10bea56dd8293e4738151a0e7c862f586b21a55 /drivers/media/video/s5p-fimc | |
parent | efb13c3d4d969199eaaae3b3540b919f7f149448 (diff) |
[media] s5p-fimc: Refactor hardware setup for m2m transaction
Remove redundant H/W setup logic by merging fimc_prepare_config()
and the device_run() callback.
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-core.c | 77 | ||||
-rw-r--r-- | drivers/media/video/s5p-fimc/fimc-core.h | 2 |
2 files changed, 21 insertions, 58 deletions
diff --git a/drivers/media/video/s5p-fimc/fimc-core.c b/drivers/media/video/s5p-fimc/fimc-core.c index 8a5951f54d7d..21691e4ee553 100644 --- a/drivers/media/video/s5p-fimc/fimc-core.c +++ b/drivers/media/video/s5p-fimc/fimc-core.c | |||
@@ -582,55 +582,11 @@ void fimc_prepare_dma_offset(struct fimc_ctx *ctx, struct fimc_frame *f) | |||
582 | f->fmt->color, f->dma_offset.y_h, f->dma_offset.y_v); | 582 | f->fmt->color, f->dma_offset.y_h, f->dma_offset.y_v); |
583 | } | 583 | } |
584 | 584 | ||
585 | /** | ||
586 | * fimc_prepare_config - check dimensions, operation and color mode | ||
587 | * and pre-calculate offset and the scaling coefficients. | ||
588 | * | ||
589 | * @ctx: hardware context information | ||
590 | * @flags: flags indicating which parameters to check/update | ||
591 | * | ||
592 | * Return: 0 if dimensions are valid or non zero otherwise. | ||
593 | */ | ||
594 | int fimc_prepare_config(struct fimc_ctx *ctx, u32 flags) | ||
595 | { | ||
596 | struct fimc_frame *s_frame, *d_frame; | ||
597 | struct vb2_buffer *vb = NULL; | ||
598 | int ret = 0; | ||
599 | |||
600 | s_frame = &ctx->s_frame; | ||
601 | d_frame = &ctx->d_frame; | ||
602 | |||
603 | if (flags & FIMC_PARAMS) { | ||
604 | /* Prepare the DMA offset ratios for scaler. */ | ||
605 | fimc_prepare_dma_offset(ctx, &ctx->s_frame); | ||
606 | fimc_prepare_dma_offset(ctx, &ctx->d_frame); | ||
607 | |||
608 | if (s_frame->height > (SCALER_MAX_VRATIO * d_frame->height) || | ||
609 | s_frame->width > (SCALER_MAX_HRATIO * d_frame->width)) { | ||
610 | err("out of scaler range"); | ||
611 | return -EINVAL; | ||
612 | } | ||
613 | fimc_set_yuv_order(ctx); | ||
614 | } | ||
615 | |||
616 | if (flags & FIMC_SRC_ADDR) { | ||
617 | vb = v4l2_m2m_next_src_buf(ctx->m2m_ctx); | ||
618 | ret = fimc_prepare_addr(ctx, vb, s_frame, &s_frame->paddr); | ||
619 | if (ret) | ||
620 | return ret; | ||
621 | } | ||
622 | |||
623 | if (flags & FIMC_DST_ADDR) { | ||
624 | vb = v4l2_m2m_next_dst_buf(ctx->m2m_ctx); | ||
625 | ret = fimc_prepare_addr(ctx, vb, d_frame, &d_frame->paddr); | ||
626 | } | ||
627 | |||
628 | return ret; | ||
629 | } | ||
630 | |||
631 | static void fimc_dma_run(void *priv) | 585 | static void fimc_dma_run(void *priv) |
632 | { | 586 | { |
587 | struct vb2_buffer *vb = NULL; | ||
633 | struct fimc_ctx *ctx = priv; | 588 | struct fimc_ctx *ctx = priv; |
589 | struct fimc_frame *sf, *df; | ||
634 | struct fimc_dev *fimc; | 590 | struct fimc_dev *fimc; |
635 | unsigned long flags; | 591 | unsigned long flags; |
636 | u32 ret; | 592 | u32 ret; |
@@ -641,9 +597,22 @@ static void fimc_dma_run(void *priv) | |||
641 | fimc = ctx->fimc_dev; | 597 | fimc = ctx->fimc_dev; |
642 | spin_lock_irqsave(&fimc->slock, flags); | 598 | spin_lock_irqsave(&fimc->slock, flags); |
643 | set_bit(ST_M2M_PEND, &fimc->state); | 599 | set_bit(ST_M2M_PEND, &fimc->state); |
600 | sf = &ctx->s_frame; | ||
601 | df = &ctx->d_frame; | ||
602 | |||
603 | if (ctx->state & FIMC_PARAMS) { | ||
604 | /* Prepare the DMA offsets for scaler */ | ||
605 | fimc_prepare_dma_offset(ctx, sf); | ||
606 | fimc_prepare_dma_offset(ctx, df); | ||
607 | } | ||
644 | 608 | ||
645 | ctx->state |= (FIMC_SRC_ADDR | FIMC_DST_ADDR); | 609 | vb = v4l2_m2m_next_src_buf(ctx->m2m_ctx); |
646 | ret = fimc_prepare_config(ctx, ctx->state); | 610 | ret = fimc_prepare_addr(ctx, vb, sf, &sf->paddr); |
611 | if (ret) | ||
612 | goto dma_unlock; | ||
613 | |||
614 | vb = v4l2_m2m_next_dst_buf(ctx->m2m_ctx); | ||
615 | ret = fimc_prepare_addr(ctx, vb, df, &df->paddr); | ||
647 | if (ret) | 616 | if (ret) |
648 | goto dma_unlock; | 617 | goto dma_unlock; |
649 | 618 | ||
@@ -652,9 +621,9 @@ static void fimc_dma_run(void *priv) | |||
652 | ctx->state |= FIMC_PARAMS; | 621 | ctx->state |= FIMC_PARAMS; |
653 | fimc->m2m.ctx = ctx; | 622 | fimc->m2m.ctx = ctx; |
654 | } | 623 | } |
655 | fimc_hw_set_input_addr(fimc, &ctx->s_frame.paddr); | ||
656 | 624 | ||
657 | if (ctx->state & FIMC_PARAMS) { | 625 | if (ctx->state & FIMC_PARAMS) { |
626 | fimc_set_yuv_order(ctx); | ||
658 | fimc_hw_set_input_path(ctx); | 627 | fimc_hw_set_input_path(ctx); |
659 | fimc_hw_set_in_dma(ctx); | 628 | fimc_hw_set_in_dma(ctx); |
660 | ret = fimc_set_scaler_info(ctx); | 629 | ret = fimc_set_scaler_info(ctx); |
@@ -665,17 +634,13 @@ static void fimc_dma_run(void *priv) | |||
665 | fimc_hw_set_target_format(ctx); | 634 | fimc_hw_set_target_format(ctx); |
666 | fimc_hw_set_rotation(ctx); | 635 | fimc_hw_set_rotation(ctx); |
667 | fimc_hw_set_effect(ctx, false); | 636 | fimc_hw_set_effect(ctx, false); |
668 | } | ||
669 | |||
670 | fimc_hw_set_output_path(ctx); | ||
671 | if (ctx->state & (FIMC_DST_ADDR | FIMC_PARAMS)) | ||
672 | fimc_hw_set_output_addr(fimc, &ctx->d_frame.paddr, -1); | ||
673 | |||
674 | if (ctx->state & FIMC_PARAMS) { | ||
675 | fimc_hw_set_out_dma(ctx); | 637 | fimc_hw_set_out_dma(ctx); |
676 | if (fimc->variant->has_alpha) | 638 | if (fimc->variant->has_alpha) |
677 | fimc_hw_set_rgb_alpha(ctx); | 639 | fimc_hw_set_rgb_alpha(ctx); |
640 | fimc_hw_set_output_path(ctx); | ||
678 | } | 641 | } |
642 | fimc_hw_set_input_addr(fimc, &sf->paddr); | ||
643 | fimc_hw_set_output_addr(fimc, &df->paddr, -1); | ||
679 | 644 | ||
680 | fimc_activate_capture(ctx); | 645 | fimc_activate_capture(ctx); |
681 | 646 | ||
diff --git a/drivers/media/video/s5p-fimc/fimc-core.h b/drivers/media/video/s5p-fimc/fimc-core.h index 54198c781fe1..101c930f08b8 100644 --- a/drivers/media/video/s5p-fimc/fimc-core.h +++ b/drivers/media/video/s5p-fimc/fimc-core.h | |||
@@ -119,8 +119,6 @@ enum fimc_color_fmt { | |||
119 | 119 | ||
120 | /* The hardware context state. */ | 120 | /* The hardware context state. */ |
121 | #define FIMC_PARAMS (1 << 0) | 121 | #define FIMC_PARAMS (1 << 0) |
122 | #define FIMC_SRC_ADDR (1 << 1) | ||
123 | #define FIMC_DST_ADDR (1 << 2) | ||
124 | #define FIMC_SRC_FMT (1 << 3) | 122 | #define FIMC_SRC_FMT (1 << 3) |
125 | #define FIMC_DST_FMT (1 << 4) | 123 | #define FIMC_DST_FMT (1 << 4) |
126 | #define FIMC_DST_CROP (1 << 5) | 124 | #define FIMC_DST_CROP (1 << 5) |