void fimg2d4x_set_msk_scaling(struct fimg2d_control *info, struct fimg2d_scale *s) { int src_w, src_h, dst_w, dst_h; unsigned long wcfg, hcfg; unsigned long mode; /* scaling algorithm */ if (s->mode == SCALING_NEAREST) mode = FIMG2D_SCALE_MODE_NEAREST; else mode = FIMG2D_SCALE_MODE_BILINEAR; writel(mode, info->regs + FIMG2D_MSK_SCALE_CTRL_REG); if (s->factor == SCALING_PERCENTAGE) { /* * percental scaling factor * e.g scale-up: 200% --> msk scaling factor: 0.5 (0x000080000) * e.g scale-down: 50% --> msk scaling factor: 2.0 (0x00020000) */ src_w = 100; src_h = 100; dst_w = s->scale_w; dst_h = s->scale_h; } else { /* * pixels scaling factor * e.g scale-up: src(1,1)-->dst(2,2), msk scaling factor: 0.5 (0x000080000) * e.g scale-down: src(2,2)-->dst(1,1), msk scaling factor: 2.0 (0x000200000) */ src_w = s->src_w * 100; src_h = s->src_h * 100; dst_w = s->dst_w * 100; dst_h = s->dst_h * 100; } /* inversed scaling factor: src is numerator */ wcfg = scale_factor_to_fixed16(src_w, dst_w); hcfg = scale_factor_to_fixed16(src_h, dst_h); writel(wcfg, info->regs + FIMG2D_MSK_XSCALE_REG); writel(hcfg, info->regs + FIMG2D_MSK_YSCALE_REG); }
void fimg2d4x_set_msk_scaling(struct fimg2d_control *info, struct fimg2d_scale *scl, struct fimg2d_repeat *rep) { unsigned long wcfg, hcfg; unsigned long mode; /* * scaling ratio in pixels * e.g scale-up: src(1,1)-->dst(2,2), msk factor: 0.5 (0x000080000) * scale-down: src(2,2)-->dst(1,1), msk factor: 2.0 (0x000200000) */ /* inversed scaling factor: src is numerator */ wcfg = scale_factor_to_fixed16(scl->src_w, scl->dst_w); hcfg = scale_factor_to_fixed16(scl->src_h, scl->dst_h); if (wcfg == DEFAULT_SCALE_RATIO && hcfg == DEFAULT_SCALE_RATIO) return; wr(wcfg, FIMG2D_MSK_XSCALE_REG); wr(hcfg, FIMG2D_MSK_YSCALE_REG); /* scaling algorithm */ if (scl->mode == SCALING_NEAREST) mode = FIMG2D_SCALE_MODE_NEAREST; else { /* 0x3: ignore repeat mode at boundary */ if (rep->mode == REPEAT_PAD || rep->mode == REPEAT_CLAMP) mode = 0x3; /* hidden */ else mode = FIMG2D_SCALE_MODE_BILINEAR; } wr(mode, FIMG2D_MSK_SCALE_CTRL_REG); }