[PATCH] [media] s5p-fimc: fix main scaler SFRs depends on FIMC version
The main scaler has four SFRs for main scaler ratio depends on FIMC version. FIMC 4.x has only two SFRs and FIMC 5.x has four SFRs for main scaler. Those are MainHorRatio, MainHorRatio_ext, MainVerRatio and MainverRatio_ext. The FIMC 5.x has 15 bit resolution for scaling ratio as below. {MainHorRatio,MainHorRatio_ext} = {[14:6],[5:0]}. {MainVerRatio,MainVerRatio_ext} = {[14:6],[5:0]}. MainHorRatio = CISCCTRL[24:16], MainHorRatio_ext = CIEXTEN[15:10] MainVerRatio = CISCCTRL[8:0], MainVerRatio_ext = CIEXTEN[5:0] This patch supports FIMC 4.x and FIMC 5.x using platform_device_id::driver_data. Signed-off-by: Hyunwoong Kim khw0178@samsung.com Reviewed-by: Jonghun Han jonghun@samsung.com --- drivers/media/video/s5p-fimc/fimc-capture.c |7 +++- drivers/media/video/s5p-fimc/fimc-core.c| 21 ++-- drivers/media/video/s5p-fimc/fimc-core.h|5 ++- drivers/media/video/s5p-fimc/fimc-reg.c | 48 -- drivers/media/video/s5p-fimc/regs-fimc.h| 10 +- 5 files changed, 81 insertions(+), 10 deletions(-) diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c b/drivers/media/video/s5p-fimc/fimc-capture.c index b216530..ca48e02 100644 --- a/drivers/media/video/s5p-fimc/fimc-capture.c +++ b/drivers/media/video/s5p-fimc/fimc-capture.c @@ -208,6 +208,7 @@ static int start_streaming(struct vb2_queue *q) struct fimc_ctx *ctx = q-drv_priv; struct fimc_dev *fimc = ctx-fimc_dev; struct s3c_fimc_isp_info *isp_info; + struct samsung_fimc_variant *variant = ctx-fimc_dev-variant; int ret; ret = v4l2_subdev_call(fimc-vid_cap.sd, video, s_stream, 1); @@ -230,7 +231,11 @@ static int start_streaming(struct vb2_queue *q) return ret; } fimc_hw_set_input_path(ctx); - fimc_hw_set_scaler(ctx); + fimc_hw_set_prescaler(ctx); + if (!variant-has_mainscaler_ext) + fimc_hw_set_mainscaler(ctx); + else + fimc_hw_set_mainscaler_ext(ctx); fimc_hw_set_target_format(ctx); fimc_hw_set_rotation(ctx); fimc_hw_set_effect(ctx); diff --git a/drivers/media/video/s5p-fimc/fimc-core.c b/drivers/media/video/s5p-fimc/fimc-core.c index 7f56987..3cfa4b6 100644 --- a/drivers/media/video/s5p-fimc/fimc-core.c +++ b/drivers/media/video/s5p-fimc/fimc-core.c @@ -246,6 +246,7 @@ int fimc_set_scaler_info(struct fimc_ctx *ctx) struct fimc_scaler *sc = ctx-scaler; struct fimc_frame *s_frame = ctx-s_frame; struct fimc_frame *d_frame = ctx-d_frame; + struct samsung_fimc_variant *variant = ctx-fimc_dev-variant; int tx, ty, sx, sy; int ret; @@ -284,8 +285,13 @@ int fimc_set_scaler_info(struct fimc_ctx *ctx) sc-pre_dst_width = sx / sc-pre_hratio; sc-pre_dst_height = sy / sc-pre_vratio; - sc-main_hratio = (sx 8) / (tx sc-hfactor); - sc-main_vratio = (sy 8) / (ty sc-vfactor); + if (!variant-has_mainscaler_ext) { + sc-main_hratio = (sx 8) / (tx sc-hfactor); + sc-main_vratio = (sy 8) / (ty sc-vfactor); + } else { + sc-main_hratio = (sx 14) / (tx sc-hfactor); + sc-main_vratio = (sy 14) / (ty sc-vfactor); + } sc-scaleup_h = (tx = sx) ? 1 : 0; sc-scaleup_v = (ty = sy) ? 1 : 0; @@ -569,6 +575,7 @@ static void fimc_dma_run(void *priv) { struct fimc_ctx *ctx = priv; struct fimc_dev *fimc; + struct samsung_fimc_variant *variant = ctx-fimc_dev-variant; unsigned long flags; u32 ret; @@ -601,7 +608,12 @@ static void fimc_dma_run(void *priv) err(Scaler setup error); goto dma_unlock; } - fimc_hw_set_scaler(ctx); + + fimc_hw_set_prescaler(ctx); + if (!variant-has_mainscaler_ext) + fimc_hw_set_mainscaler(ctx); + else + fimc_hw_set_mainscaler_ext(ctx); fimc_hw_set_target_format(ctx); fimc_hw_set_rotation(ctx); fimc_hw_set_effect(ctx); @@ -1722,6 +1734,7 @@ static struct samsung_fimc_variant fimc1_variant_s5pv210 = { .pix_hoff= 1, .has_inp_rot = 1, .has_out_rot = 1, + .has_mainscaler_ext = 1, .min_inp_pixsize = 16, .min_out_pixsize = 16, .hor_offs_align = 1, @@ -1743,6 +1756,7 @@ static struct samsung_fimc_variant fimc0_variant_s5pv310 = { .has_inp_rot = 1, .has_out_rot = 1, .has_cistatus2 = 1, + .has_mainscaler_ext = 1, .min_inp_pixsize = 16, .min_out_pixsize = 16, .hor_offs_align = 1, @@ -1753,6 +1767,7 @@ static struct samsung_fimc_variant fimc0_variant_s5pv310 = { static struct samsung_fimc_variant
Re: [PATCH] [media] s5p-fimc: fix main scaler SFRs depends on FIMC version
On Fri, Dec 17, 2010 at 4:43 PM, Hyunwoong Kim khw0178@samsung.com wrote: The main scaler has four SFRs for main scaler ratio depends on FIMC version. FIMC 4.x has only two SFRs and FIMC 5.x has four SFRs for main scaler. Those are MainHorRatio, MainHorRatio_ext, MainVerRatio and MainverRatio_ext. The FIMC 5.x has 15 bit resolution for scaling ratio as below. {MainHorRatio,MainHorRatio_ext} = {[14:6],[5:0]}. {MainVerRatio,MainVerRatio_ext} = {[14:6],[5:0]}. MainHorRatio = CISCCTRL[24:16], MainHorRatio_ext = CIEXTEN[15:10] MainVerRatio = CISCCTRL[8:0], MainVerRatio_ext = CIEXTEN[5:0] This patch supports FIMC 4.x and FIMC 5.x using platform_device_id::driver_data. Signed-off-by: Hyunwoong Kim khw0178@samsung.com Reviewed-by: Jonghun Han jonghun@samsung.com --- drivers/media/video/s5p-fimc/fimc-capture.c | 7 +++- drivers/media/video/s5p-fimc/fimc-core.c | 21 ++-- drivers/media/video/s5p-fimc/fimc-core.h | 5 ++- drivers/media/video/s5p-fimc/fimc-reg.c | 48 -- drivers/media/video/s5p-fimc/regs-fimc.h | 10 +- 5 files changed, 81 insertions(+), 10 deletions(-) diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c b/drivers/media/video/s5p-fimc/fimc-capture.c index b216530..ca48e02 100644 --- a/drivers/media/video/s5p-fimc/fimc-capture.c +++ b/drivers/media/video/s5p-fimc/fimc-capture.c @@ -208,6 +208,7 @@ static int start_streaming(struct vb2_queue *q) struct fimc_ctx *ctx = q-drv_priv; struct fimc_dev *fimc = ctx-fimc_dev; struct s3c_fimc_isp_info *isp_info; + struct samsung_fimc_variant *variant = ctx-fimc_dev-variant; int ret; ret = v4l2_subdev_call(fimc-vid_cap.sd, video, s_stream, 1); @@ -230,7 +231,11 @@ static int start_streaming(struct vb2_queue *q) return ret; } fimc_hw_set_input_path(ctx); - fimc_hw_set_scaler(ctx); + fimc_hw_set_prescaler(ctx); + if (!variant-has_mainscaler_ext) + fimc_hw_set_mainscaler(ctx); + else + fimc_hw_set_mainscaler_ext(ctx); It's just personal preference, I don't like the negative variable check, how about this? if (variant-has_mainscaler_ext) fimc_hw_set_mainscaler_ext(ctx); else fimc_hw_set_mainscaler(ctx); fimc_hw_set_target_format(ctx); fimc_hw_set_rotation(ctx); fimc_hw_set_effect(ctx); diff --git a/drivers/media/video/s5p-fimc/fimc-core.c b/drivers/media/video/s5p-fimc/fimc-core.c index 7f56987..3cfa4b6 100644 --- a/drivers/media/video/s5p-fimc/fimc-core.c +++ b/drivers/media/video/s5p-fimc/fimc-core.c @@ -246,6 +246,7 @@ int fimc_set_scaler_info(struct fimc_ctx *ctx) struct fimc_scaler *sc = ctx-scaler; struct fimc_frame *s_frame = ctx-s_frame; struct fimc_frame *d_frame = ctx-d_frame; + struct samsung_fimc_variant *variant = ctx-fimc_dev-variant; int tx, ty, sx, sy; int ret; @@ -284,8 +285,13 @@ int fimc_set_scaler_info(struct fimc_ctx *ctx) sc-pre_dst_width = sx / sc-pre_hratio; sc-pre_dst_height = sy / sc-pre_vratio; - sc-main_hratio = (sx 8) / (tx sc-hfactor); - sc-main_vratio = (sy 8) / (ty sc-vfactor); + if (!variant-has_mainscaler_ext) { + sc-main_hratio = (sx 8) / (tx sc-hfactor); + sc-main_vratio = (sy 8) / (ty sc-vfactor); + } else { + sc-main_hratio = (sx 14) / (tx sc-hfactor); + sc-main_vratio = (sy 14) / (ty sc-vfactor); + } Ditto sc-scaleup_h = (tx = sx) ? 1 : 0; sc-scaleup_v = (ty = sy) ? 1 : 0; @@ -569,6 +575,7 @@ static void fimc_dma_run(void *priv) { struct fimc_ctx *ctx = priv; struct fimc_dev *fimc; + struct samsung_fimc_variant *variant = ctx-fimc_dev-variant; unsigned long flags; u32 ret; @@ -601,7 +608,12 @@ static void fimc_dma_run(void *priv) err(Scaler setup error); goto dma_unlock; } - fimc_hw_set_scaler(ctx); + + fimc_hw_set_prescaler(ctx); + if (!variant-has_mainscaler_ext) + fimc_hw_set_mainscaler(ctx); + else + fimc_hw_set_mainscaler_ext(ctx); ditto fimc_hw_set_target_format(ctx); fimc_hw_set_rotation(ctx); fimc_hw_set_effect(ctx); @@ -1722,6 +1734,7 @@ static struct samsung_fimc_variant fimc1_variant_s5pv210 = { .pix_hoff = 1, .has_inp_rot = 1, .has_out_rot = 1, + .has_mainscaler_ext = 1, .min_inp_pixsize = 16, .min_out_pixsize = 16, .hor_offs_align =
Re: [PATCH] [media] s5p-fimc: fix main scaler SFRs depends on FIMC version
Hello, On 12/17/2010 08:43 AM, Hyunwoong Kim wrote: The main scaler has four SFRs for main scaler ratio depends on FIMC version. FIMC 4.x has only two SFRs and FIMC 5.x has four SFRs for main scaler. Those are MainHorRatio, MainHorRatio_ext, MainVerRatio and MainverRatio_ext. The FIMC 5.x has 15 bit resolution for scaling ratio as below. {MainHorRatio,MainHorRatio_ext} = {[14:6],[5:0]}. {MainVerRatio,MainVerRatio_ext} = {[14:6],[5:0]}. MainHorRatio = CISCCTRL[24:16], MainHorRatio_ext = CIEXTEN[15:10] MainVerRatio = CISCCTRL[8:0], MainVerRatio_ext = CIEXTEN[5:0] This patch supports FIMC 4.x and FIMC 5.x using platform_device_id::driver_data. Signed-off-by: Hyunwoong Kim khw0178@samsung.com Reviewed-by: Jonghun Han jonghun@samsung.com --- drivers/media/video/s5p-fimc/fimc-capture.c |7 +++- drivers/media/video/s5p-fimc/fimc-core.c| 21 ++-- drivers/media/video/s5p-fimc/fimc-core.h|5 ++- drivers/media/video/s5p-fimc/fimc-reg.c | 48 -- drivers/media/video/s5p-fimc/regs-fimc.h| 10 +- 5 files changed, 81 insertions(+), 10 deletions(-) diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c b/drivers/media/video/s5p-fimc/fimc-capture.c index b216530..ca48e02 100644 --- a/drivers/media/video/s5p-fimc/fimc-capture.c +++ b/drivers/media/video/s5p-fimc/fimc-capture.c @@ -208,6 +208,7 @@ static int start_streaming(struct vb2_queue *q) struct fimc_ctx *ctx = q-drv_priv; struct fimc_dev *fimc = ctx-fimc_dev; struct s3c_fimc_isp_info *isp_info; + struct samsung_fimc_variant *variant = ctx-fimc_dev-variant; int ret; ret = v4l2_subdev_call(fimc-vid_cap.sd, video, s_stream, 1); @@ -230,7 +231,11 @@ static int start_streaming(struct vb2_queue *q) return ret; } fimc_hw_set_input_path(ctx); - fimc_hw_set_scaler(ctx); + fimc_hw_set_prescaler(ctx); + if (!variant-has_mainscaler_ext) + fimc_hw_set_mainscaler(ctx); + else + fimc_hw_set_mainscaler_ext(ctx); fimc_hw_set_target_format(ctx); fimc_hw_set_rotation(ctx); fimc_hw_set_effect(ctx); diff --git a/drivers/media/video/s5p-fimc/fimc-core.c b/drivers/media/video/s5p-fimc/fimc-core.c index 7f56987..3cfa4b6 100644 --- a/drivers/media/video/s5p-fimc/fimc-core.c +++ b/drivers/media/video/s5p-fimc/fimc-core.c @@ -246,6 +246,7 @@ int fimc_set_scaler_info(struct fimc_ctx *ctx) struct fimc_scaler *sc = ctx-scaler; struct fimc_frame *s_frame = ctx-s_frame; struct fimc_frame *d_frame = ctx-d_frame; + struct samsung_fimc_variant *variant = ctx-fimc_dev-variant; int tx, ty, sx, sy; int ret; @@ -284,8 +285,13 @@ int fimc_set_scaler_info(struct fimc_ctx *ctx) sc-pre_dst_width = sx / sc-pre_hratio; sc-pre_dst_height = sy / sc-pre_vratio; - sc-main_hratio = (sx 8) / (tx sc-hfactor); - sc-main_vratio = (sy 8) / (ty sc-vfactor); + if (!variant-has_mainscaler_ext) { + sc-main_hratio = (sx 8) / (tx sc-hfactor); + sc-main_vratio = (sy 8) / (ty sc-vfactor); + } else { + sc-main_hratio = (sx 14) / (tx sc-hfactor); + sc-main_vratio = (sy 14) / (ty sc-vfactor); + } sc-scaleup_h = (tx = sx) ? 1 : 0; sc-scaleup_v = (ty = sy) ? 1 : 0; @@ -569,6 +575,7 @@ static void fimc_dma_run(void *priv) { struct fimc_ctx *ctx = priv; struct fimc_dev *fimc; + struct samsung_fimc_variant *variant = ctx-fimc_dev-variant; unsigned long flags; u32 ret; @@ -601,7 +608,12 @@ static void fimc_dma_run(void *priv) err(Scaler setup error); goto dma_unlock; } - fimc_hw_set_scaler(ctx); + + fimc_hw_set_prescaler(ctx); + if (!variant-has_mainscaler_ext) + fimc_hw_set_mainscaler(ctx); + else + fimc_hw_set_mainscaler_ext(ctx); fimc_hw_set_target_format(ctx); fimc_hw_set_rotation(ctx); fimc_hw_set_effect(ctx); @@ -1722,6 +1734,7 @@ static struct samsung_fimc_variant fimc1_variant_s5pv210 = { .pix_hoff= 1, .has_inp_rot = 1, .has_out_rot = 1, + .has_mainscaler_ext = 1, .min_inp_pixsize = 16, .min_out_pixsize = 16, .hor_offs_align = 1, @@ -1743,6 +1756,7 @@ static struct samsung_fimc_variant fimc0_variant_s5pv310 = { .has_inp_rot = 1, .has_out_rot = 1, .has_cistatus2 = 1, + .has_mainscaler_ext = 1, .min_inp_pixsize = 16, .min_out_pixsize = 16, .hor_offs_align = 1, @@ -1753,6 +1767,7 @@ static struct samsung_fimc_variant fimc0_variant_s5pv310 = { static