static int fimg2d_check_params(struct fimg2d_blit __user *u) { int w, h, i; struct fimg2d_param *p = &u->param; struct fimg2d_image *img, *buf[MAX_IMAGES] = image_table(u); struct fimg2d_scale *scl; struct fimg2d_clip *clp; struct fimg2d_rect *r; if (!u->dst) return -1; /* DST op makes no effect */ if (u->op < 0 || u->op == BLIT_OP_DST || u->op >= BLIT_OP_END) return -1; for (i = 0; i < MAX_IMAGES; i++) { img = buf[i]; if (!img) continue; w = img->width; h = img->height; r = &img->rect; /* 8000: max width & height */ if (w > 8000 || h > 8000 || r->x1 == r->x2 || r->y1 == r->y2) return -1; } scl = &p->scaling; if (scl->mode) { img = buf[ISRC]; r = &img->rect; /* src_w and src_h of scale must be the equal to src rect */ if (img->addr.type && ((rect_w(r) != scl->src_w) || (rect_h(r) != scl->src_h))) return -1; if (!scl->src_w || !scl->src_h || !scl->dst_w || !scl->dst_h) return -1; } clp = &p->clipping; if (clp->enable) { img = buf[IDST]; r = &img->rect; /* clip rect must be within dst rect */ if (clp->x1 >= r->x2 || clp->x2 <= r->x1 || clp->y1 >= r->y2 || clp->y2 <= r->y1) return -1; } return 0; }
void fimg2d_debug_command(struct fimg2d_bltcmd *cmd) { int i; struct fimg2d_param *p = &cmd->blt.param; struct fimg2d_image *img; struct fimg2d_rect *r; struct fimg2d_dma *c; if (WARN_ON(!cmd->ctx)) return; pr_info("\n[%s] ctx: %p seq_no(%u)\n", __func__, cmd->ctx, cmd->blt.seq_no); pr_info(" op: %s(%d)\n", opname(cmd->blt.op), cmd->blt.op); pr_info(" solid color: 0x%lx\n", p->solid_color); pr_info(" g_alpha: 0x%x\n", p->g_alpha); pr_info(" premultiplied: %d\n", p->premult); if (p->dither) pr_info(" dither: %d\n", p->dither); if (p->rotate) pr_info(" rotate: %d\n", p->rotate); if (p->repeat.mode) { pr_info(" repeat: %d, pad color: 0x%lx\n", p->repeat.mode, p->repeat.pad_color); } if (p->bluscr.mode) { pr_info(" bluescreen mode: %d, bs_color: 0x%lx " \ "bg_color: 0x%lx\n", p->bluscr.mode, p->bluscr.bs_color, p->bluscr.bg_color); } if (p->scaling.mode) { pr_info(" scaling %d, s:%d,%d d:%d,%d\n", p->scaling.mode, p->scaling.src_w, p->scaling.src_h, p->scaling.dst_w, p->scaling.dst_h); } if (p->clipping.enable) { pr_info(" clipping LT(%d,%d) RB(%d,%d) WH(%d,%d)\n", p->clipping.x1, p->clipping.y1, p->clipping.x2, p->clipping.y2, rect_w(&p->clipping), rect_h(&p->clipping)); } for (i = 0; i < MAX_IMAGES; i++) { img = &cmd->image[i]; r = &img->rect; if (!img->addr.type) continue; pr_info(" %s type: %d addr: 0x%lx\n", imagename(i), img->addr.type, img->addr.start); pr_info(" %s width: %d height: %d " \ "stride: %d order: %d format: %s(%d)\n", imagename(i), img->width, img->height, img->stride, img->order, cfname(img->fmt), img->fmt); pr_info(" %s rect LT(%d,%d) RB(%d,%d) WH(%d,%d)\n", imagename(i), r->x1, r->y1, r->x2, r->y2, rect_w(r), rect_h(r)); c = &cmd->dma[i].base; if (c->size) { pr_info(" %s dma base addr: 0x%lx " \ "size: 0x%x cached: 0x%x\n", imagename(i), c->addr, c->size, c->cached); } if (img->plane2.type) { pr_info(" %s plane2 type: %d addr: 0x%lx\n", imagename(i), img->plane2.type, img->plane2.start); } c = &cmd->dma[i].plane2; if (c->size) { pr_info(" %s dma plane2 addr: 0x%lx " \ "size: 0x%x cached: 0x%x\n", imagename(i), c->addr, c->size, c->cached); } } if (cmd->dma_all) pr_info(" dma size all: 0x%x bytes\n", cmd->dma_all); pr_info(" L1: 0x%x L2: 0x%x bytes\n", L1_CACHE_SIZE, L2_CACHE_SIZE); }
void fimg2d_debug_command(struct fimg2d_bltcmd *cmd) { int i; struct fimg2d_blit *blt; struct fimg2d_image *img; struct fimg2d_param *p; struct fimg2d_rect *r; struct fimg2d_dma *c; if (WARN_ON(!cmd->ctx)) return; blt = &cmd->blt; /* Common information */ pr_info("\n[%s] ctx: %p seq_no(%u)\n", __func__, cmd->ctx, cmd->blt.seq_no); pr_info(" use fence: %d\n", blt->use_fence); pr_info(" Update layer : 0x%lx\n", cmd->src_flag); if (blt->dither) pr_info(" dither: %d\n", blt->dither); /* End of common information */ /* Source information */ for (i = 0; i < MAX_SRC; i++) { img = &cmd->image_src[i]; if (!img->addr.type) continue; p = &img->param; r = &img->rect; c = &cmd->dma_src[i].base; pr_info(" SRC[%d] op: %s(%d)\n", i, opname(img->op), img->op); pr_info(" SRC[%d] type: %d addr: 0x%lx\n", i, img->addr.type, img->addr.start); pr_info(" SRC[%d] width: %d height: %d ", i, img->width, img->height); pr_info(" SRC[%d] stride: %d order: %d format: %s(%d)\n", i, img->stride, img->order, cfname(img->fmt), img->fmt); pr_info(" SRC[%d] rect LT(%d,%d) RB(%d,%d) WH(%d,%d)\n", i, r->x1, r->y1, r->x2, r->y2, rect_w(r), rect_h(r)); pr_info(" solid color: 0x%lx\n", p->solid_color); pr_info(" g_alpha: 0x%x\n", p->g_alpha); pr_info(" premultiplied: %d\n", p->premult); if (p->rotate) pr_info(" rotate: %d\n", p->rotate); if (p->repeat.mode) { pr_info(" repeat: %d, pad color: 0x%lx\n", p->repeat.mode, p->repeat.pad_color); } if (p->scaling.mode) { pr_info(" scaling %d, s:%d,%d d:%d,%d\n", p->scaling.mode, p->scaling.src_w, p->scaling.src_h, p->scaling.dst_w, p->scaling.dst_h); } if (p->clipping.enable) { pr_info(" clipping LT(%d,%d) RB(%d,%d) WH(%d,%d)\n", p->clipping.x1, p->clipping.y1, p->clipping.x2, p->clipping.y2, rect_w(&p->clipping), rect_h(&p->clipping)); } if (c->size) { pr_info(" SRC[%d] dma base addr: %#lx size: %zd cached: %zd\n", i, c->addr, c->size, c->cached); pr_info(" SRC[%d] dma iova: %#lx, offset: %zd\n", i, (unsigned long)c->iova, c->offset); } } /* End of source information */ /* Destination information */ img = &cmd->image_dst; p = &img->param; r = &img->rect; c = &cmd->dma_dst.base; pr_info(" DST type: %d addr: 0x%lx\n", img->addr.type, img->addr.start); pr_info(" DST width: %d height: %d stride: %d order: %d format: %s(%d)\n", img->width, img->height, img->stride, img->order, cfname(img->fmt), img->fmt); pr_info(" DST rect LT(%d,%d) RB(%d,%d) WH(%d,%d)\n", r->x1, r->y1, r->x2, r->y2, rect_w(r), rect_h(r)); pr_info(" solid color: 0x%lx\n", p->solid_color); pr_info(" g_alpha: 0x%x\n", p->g_alpha); pr_info(" premultiplied: %d\n", p->premult); if (c->size) { pr_info(" DST dma base addr: %#lx size: %zd cached: %zd\n", c->addr, c->size, c->cached); pr_info(" DST dma iova: %#lx offset: %zd\n", (unsigned long)c->iova, c->offset); } /* End of destination */ if (cmd->dma_all) pr_info(" dma size all: %zd bytes\n", cmd->dma_all); }
static void fimg2d_fixup_params(struct fimg2d_bltcmd *cmd) { struct fimg2d_param *p = &cmd->param; struct fimg2d_scale *scl = &p->scaling; struct fimg2d_repeat *rep = &p->repeat; struct fimg2d_clip *clp = &p->clipping; struct fimg2d_image *img, *src, *dst; struct fimg2d_rect *r, *sr, *dr; unsigned int ow, oh; int i; /* fit dst rect to image width/height */ for (i = 0; i < MAX_IMAGES; i++) { img = &cmd->image[i]; if (!img) continue; r = &img->rect; if (r->x1 < 0) r->x1 = 0; if (r->y1 < 0) r->y2 = 0; if (r->x2 > img->width) r->x2 = img->width; if (r->y2 > img->height) r->y2 = img->height; } /* avoid devided by zero error */ if (scl->mode && (scl->src_w == scl->dst_w && scl->src_h == scl->dst_h)) scl->mode = NO_SCALING; /* avoid src or dst size is error */ if (scl->mode && (scl->src_w == 0 || scl->src_h == 0 || scl->dst_w == 0 || scl->dst_h == 0)) scl->mode = NO_SCALING; src = &cmd->image[ISRC]; dst = &cmd->image[IDST]; sr = &src->rect; dr = &dst->rect; /* fit dst rect to drawing output rect */ if (src->addr.type && !rep->mode) { ow = rect_w(sr); oh = rect_h(sr); if (scl->mode) { ow = scl->dst_w; oh = scl->dst_h; } if (p->rotate == ROT_90 || p->rotate == ROT_270) swap(ow, oh); if (ow < rect_w(dr)) dr->x2 = dr->x1 + ow; if (oh < rect_h(dr)) dr->y2 = dr->y1 + oh; } /* fit clip rect to dst rect */ if (clp->enable) { if (clp->x1 < dr->x1) clp->x1 = dr->x1; if (clp->y1 < dr->y1) clp->y1 = dr->y1; if (clp->x2 > dr->x2) clp->x2 = dr->x2; if (clp->y2 > dr->y2) clp->y2 = dr->y2; } }