24 #define DLOG(x...) do {} while (0)
26 #define MDP_DOWNSCALE_BLUR (MDP_DOWNSCALE_MAX + 1)
65 static uint32_t bytes_per_pixel[] = {
119 rotate_dst_addr_x(req, regs);
124 rotate_dst_addr_y(req, regs);
132 if (req->
src.format == req->
dst.format)
143 #define GET_BIT_RANGE(value, high, low) \
144 (((1 << (high - low + 1)) - 1) & (value >> low))
203 regs->
op |= bg_op_chroma[req->
dst.format];
206 #define ONE_HALF (1LL << 32)
207 #define ONE (1LL << 33)
208 #define TWO (2LL << 33)
209 #define THREE (3LL << 33)
210 #define FRAC_MASK (ONE - 1)
211 #define INT_MASK (~FRAC_MASK)
223 if (dim_out % 3 == 0)
224 rpa = !(dim_in % (dim_out / 3));
232 if ((k3 >> 4) < (1LL << 27) || (k3 >> 4) > (1
LL << 31)) {
233 DLOG(
"crap bad scale\n");
242 k2 = (k1 -
ONE) >> 1;
244 *phase_init = (
int)(k2 >> 4);
245 k4 = (k3 -
ONE) >> 1;
256 od = (((k3 *
os) >> 1) + k4);
270 os_p = ((k1 * (od_p >> 33)) + k2);
276 delta = ((int64_t)(origin) << 33) - oreq;
279 delta = (ip64 & (1
LL << 63)) ? 4 : -4;
281 while (
abs((
int)(ip64 >> 33)) > 4)
283 *phase_init = (
int)(ip64 >> 4);
288 static void load_scale_table(
const struct mdp_info *
mdp,
292 for (i = 0; i < len; i++)
311 }
else if (src == 3 * dst) {
316 }
else if (src > dst && src < 3 * dst) {
321 }
else if (src == dst) {
332 *interp1 += src_coord;
333 *interp2 += src_coord;
363 &luma_repeat[IMG_TOP], &luma_repeat[IMG_BOTTOM]);
366 &luma_repeat[IMG_LEFT], &luma_repeat[IMG_RIGHT]);
438 uint32_t phase_init_x, phase_init_y, phase_step_x, phase_step_y;
439 uint32_t scale_factor_x, scale_factor_y;
459 if (scale_params(req->
src_rect.w, dst_w, 1, &phase_init_x,
461 scale_params(req->
src_rect.h, dst_h, 1, &phase_init_y,
465 scale_factor_x = (dst_w * 10) / req->
src_rect.w;
466 scale_factor_y = (dst_h * 10) / req->
src_rect.h;
468 if (scale_factor_x > 8)
470 else if (scale_factor_x > 6)
472 else if (scale_factor_x > 4)
476 if (downscale != downscale_x_table) {
478 downscale_x_table = downscale;
481 if (scale_factor_y > 8)
483 else if (scale_factor_y > 6)
485 else if (scale_factor_y > 4)
489 if (downscale != downscale_y_table) {
491 downscale_y_table = downscale;
520 #define IMG_LEN(rect_h, w, rect_w, bpp) (((rect_h) * w) * bpp)
522 #define Y_TO_CRCB_RATIO(format) \
523 ((format == MDP_Y_CBCR_H2V2 || format == MDP_Y_CRCB_H2V2) ? 2 :\
524 (format == MDP_Y_CBCR_H2V1 || format == MDP_Y_CRCB_H2V1) ? 1 : 1)
536 static int valid_src_dst(
unsigned long src_start,
unsigned long src_len,
537 unsigned long dst_start,
unsigned long dst_len,
540 unsigned long src_min_ok = src_start;
541 unsigned long src_max_ok = src_start + src_len;
542 unsigned long dst_min_ok = dst_start;
543 unsigned long dst_max_ok = dst_start + dst_len;
544 uint32_t src0_len, src1_len, dst0_len, dst1_len;
550 if (regs->
src0 < src_min_ok || regs->
src0 > src_max_ok ||
551 regs->
src0 + src0_len > src_max_ok) {
552 DLOG(
"invalid_src %x %x %lx %lx\n", regs->
src0,
553 src0_len, src_min_ok, src_max_ok);
557 if (regs->
src1 < src_min_ok || regs->
src1 > src_max_ok ||
558 regs->
src1 + src1_len > src_max_ok) {
559 DLOG(
"invalid_src1");
563 if (regs->
dst0 < dst_min_ok || regs->
dst0 > dst_max_ok ||
564 regs->
dst0 + dst0_len > dst_max_ok) {
569 if (regs->
dst1 < dst_min_ok || regs->
dst1 > dst_max_ok ||
570 regs->
dst1 + dst1_len > dst_max_ok) {
571 DLOG(
"invalid_dst1");
580 struct file *src_file,
struct file *dst_file)
584 static void get_chroma_addr(
struct mdp_img *img,
struct mdp_rect *rect,
593 offset = (rect->
x / compress_h) * compress_h;
594 offset += rect->
y == 0 ? 0 :
595 ((rect->
y + 1) / compress_v) * img->
width;
597 *addr += offset *
bpp;
598 *ystride |= *ystride << 16;
606 struct file *dst_file)
641 flush_imgs(req, regs, src_file, dst_file);
647 struct file *src_file,
unsigned long src_start,
unsigned long src_len,
648 struct file *dst_file,
unsigned long dst_start,
unsigned long dst_len)
679 regs.
src_bpp = bytes_per_pixel[req->
src.format];
680 regs.
src0 = src_start + req->
src.offset;
688 regs.
dst_bpp = bytes_per_pixel[req->
dst.format];
689 regs.
dst0 = dst_start + req->
dst.offset;
696 if (!valid_src_dst(src_start, src_len, dst_start, dst_len, req,
699 "invalid, are you trying to make an image too large "
700 "or to place it outside the screen?\n");
706 blit_rotate(req, ®s);
707 blit_convert(req, ®s);
710 blit_blend(req, ®s);
711 if (blit_scale(mdp, req, ®s)) {
715 blit_blur(mdp, req, ®s);
716 regs.
op |= dst_op_chroma[req->
dst.format] |
717 src_op_chroma[req->
src.format];
726 if (get_edge_cond(req, ®s))
729 send_blit(mdp, req, ®s, src_file, dst_file);