Lines Matching +full:src +full:- +full:coef

1 // SPDX-License-Identifier: GPL-2.0
10 #include "bdisp-filter.h"
11 #include "bdisp-reg.h"
27 bool cconv; /* RGB - YUV conversion */
34 bool src_interlaced; /* is the src an interlaced buffer */
35 u8 src_nbp; /* nb of planes of the src */
36 bool src_yuv; /* is the src a YUV color format */
37 bool src_420; /* is the src 4:2:0 chroma subsampled */
54 .coef = {
68 .coef = {
82 .coef = {
96 .coef = {
110 .coef = {
124 .coef = {
138 .coef = {
152 .coef = {
166 .coef = {
180 .coef = {
194 .coef = {
208 .coef = {
228 .coef = {
242 .coef = {
256 .coef = {
270 .coef = {
284 .coef = {
298 .coef = {
312 .coef = {
326 .coef = {
340 .coef = {
371 dev_dbg(bdisp->dev, "%s\n", __func__); in bdisp_hw_reset()
374 writel(0, bdisp->regs + BLT_ITM0); in bdisp_hw_reset()
377 writel(readl(bdisp->regs + BLT_CTL) | BLT_CTL_RESET, in bdisp_hw_reset()
378 bdisp->regs + BLT_CTL); in bdisp_hw_reset()
379 writel(0, bdisp->regs + BLT_CTL); in bdisp_hw_reset()
383 if (readl(bdisp->regs + BLT_STA1) & BLT_STA1_IDLE) in bdisp_hw_reset()
388 dev_err(bdisp->dev, "Reset timeout\n"); in bdisp_hw_reset()
390 return (i == POLL_RST_MAX) ? -EAGAIN : 0; in bdisp_hw_reset()
406 its = readl(bdisp->regs + BLT_ITS); in bdisp_hw_get_and_clear_irq()
410 dev_dbg(bdisp->dev, "Unexpected IT status: 0x%08X\n", its); in bdisp_hw_get_and_clear_irq()
411 writel(its, bdisp->regs + BLT_ITS); in bdisp_hw_get_and_clear_irq()
412 return -1; in bdisp_hw_get_and_clear_irq()
416 writel(its, bdisp->regs + BLT_ITS); in bdisp_hw_get_and_clear_irq()
417 writel(0, bdisp->regs + BLT_ITM0); in bdisp_hw_get_and_clear_irq()
433 if (ctx && ctx->node[0]) in bdisp_hw_free_nodes()
434 dma_free_attrs(ctx->bdisp_dev->dev, in bdisp_hw_free_nodes()
436 ctx->node[0], ctx->node_paddr[0], in bdisp_hw_free_nodes()
451 struct device *dev = ctx->bdisp_dev->dev; in bdisp_hw_alloc_nodes()
461 return -ENOMEM; in bdisp_hw_alloc_nodes()
467 ctx->node[i] = base; in bdisp_hw_alloc_nodes()
468 ctx->node_paddr[i] = paddr; in bdisp_hw_alloc_nodes()
469 dev_dbg(dev, "node[%d]=0x%p (paddr=%pad)\n", i, ctx->node[i], in bdisp_hw_alloc_nodes()
516 return -ENOMEM; in bdisp_hw_alloc_filters()
522 memcpy(base, bdisp_h_spec[i].coef, BDISP_HF_NB); in bdisp_hw_alloc_filters()
532 memcpy(base, bdisp_v_spec[i].coef, BDISP_VF_NB); in bdisp_hw_alloc_filters()
555 for (i = NB_H_FILTER - 1; i > 0; i--) in bdisp_hw_get_hf_addr()
576 for (i = NB_V_FILTER - 1; i > 0; i--) in bdisp_hw_get_vf_addr()
600 return -EINVAL; in bdisp_hw_get_inc()
610 return -EINVAL; in bdisp_hw_get_inc()
632 src_w = ctx->src.crop.width; in bdisp_hw_get_hv_inc()
633 src_h = ctx->src.crop.height; in bdisp_hw_get_hv_inc()
634 dst_w = ctx->dst.crop.width; in bdisp_hw_get_hv_inc()
635 dst_h = ctx->dst.crop.height; in bdisp_hw_get_hv_inc()
639 dev_err(ctx->bdisp_dev->dev, in bdisp_hw_get_hv_inc()
640 "scale factors failed (%dx%d)->(%dx%d)\n", in bdisp_hw_get_hv_inc()
642 return -EINVAL; in bdisp_hw_get_hv_inc()
660 struct device *dev = ctx->bdisp_dev->dev; in bdisp_hw_get_op_cfg()
661 struct bdisp_frame *src = &ctx->src; in bdisp_hw_get_op_cfg() local
662 struct bdisp_frame *dst = &ctx->dst; in bdisp_hw_get_op_cfg()
664 if (src->width > MAX_SRC_WIDTH * MAX_VERTICAL_STRIDES) { in bdisp_hw_get_op_cfg()
666 return -EINVAL; in bdisp_hw_get_op_cfg()
669 c->wide = src->width > MAX_SRC_WIDTH; in bdisp_hw_get_op_cfg()
671 c->hflip = ctx->hflip; in bdisp_hw_get_op_cfg()
672 c->vflip = ctx->vflip; in bdisp_hw_get_op_cfg()
674 c->src_interlaced = (src->field == V4L2_FIELD_INTERLACED); in bdisp_hw_get_op_cfg()
676 c->src_nbp = src->fmt->nb_planes; in bdisp_hw_get_op_cfg()
677 c->src_yuv = (src->fmt->pixelformat == V4L2_PIX_FMT_NV12) || in bdisp_hw_get_op_cfg()
678 (src->fmt->pixelformat == V4L2_PIX_FMT_YUV420); in bdisp_hw_get_op_cfg()
679 c->src_420 = c->src_yuv; in bdisp_hw_get_op_cfg()
681 c->dst_nbp = dst->fmt->nb_planes; in bdisp_hw_get_op_cfg()
682 c->dst_yuv = (dst->fmt->pixelformat == V4L2_PIX_FMT_NV12) || in bdisp_hw_get_op_cfg()
683 (dst->fmt->pixelformat == V4L2_PIX_FMT_YUV420); in bdisp_hw_get_op_cfg()
684 c->dst_420 = c->dst_yuv; in bdisp_hw_get_op_cfg()
686 c->cconv = (c->src_yuv != c->dst_yuv); in bdisp_hw_get_op_cfg()
688 if (bdisp_hw_get_hv_inc(ctx, &c->h_inc, &c->v_inc)) { in bdisp_hw_get_op_cfg()
690 return -EINVAL; in bdisp_hw_get_op_cfg()
694 if (c->src_interlaced) in bdisp_hw_get_op_cfg()
695 c->v_inc /= 2; in bdisp_hw_get_op_cfg()
697 if ((c->h_inc != (1 << 10)) || (c->v_inc != (1 << 10))) in bdisp_hw_get_op_cfg()
698 c->scale = true; in bdisp_hw_get_op_cfg()
700 c->scale = false; in bdisp_hw_get_op_cfg()
762 struct bdisp_frame *src = &ctx->src; in bdisp_hw_build_node() local
763 struct bdisp_frame *dst = &ctx->dst; in bdisp_hw_build_node()
765 struct v4l2_rect src_rect = src->crop; in bdisp_hw_build_node()
766 struct v4l2_rect dst_rect = dst->crop; in bdisp_hw_build_node()
768 s32 dst_width = dst->crop.width; in bdisp_hw_build_node()
772 dev_dbg(ctx->bdisp_dev->dev, "%s\n", __func__); in bdisp_hw_build_node()
776 /* Adjust src and dst areas wrt src_x_offset */ in bdisp_hw_build_node()
778 src_rect.width -= src_x_offset; in bdisp_hw_build_node()
781 dst_x_offset = (src_x_offset * dst_width) / ctx->src.crop.width; in bdisp_hw_build_node()
783 dst_rect.width = (src_rect.width * dst_width) / ctx->src.crop.width; in bdisp_hw_build_node()
786 src_fmt = src->fmt->pixelformat; in bdisp_hw_build_node()
787 dst_fmt = dst->fmt->pixelformat; in bdisp_hw_build_node()
789 node->nip = 0; in bdisp_hw_build_node()
790 node->cic = BLT_CIC_ALL_GRP; in bdisp_hw_build_node()
791 node->ack = BLT_ACK_BYPASS_S2S3; in bdisp_hw_build_node()
793 switch (cfg->src_nbp) { in bdisp_hw_build_node()
796 node->ins = BLT_INS_S1_OFF | BLT_INS_S2_MEM | BLT_INS_S3_OFF; in bdisp_hw_build_node()
802 node->ins = BLT_INS_S1_OFF | BLT_INS_S3_MEM; in bdisp_hw_build_node()
804 node->ins |= BLT_INS_S2_CF; in bdisp_hw_build_node()
806 node->ins |= BLT_INS_S2_MEM; in bdisp_hw_build_node()
813 node->ins = BLT_INS_S3_MEM; in bdisp_hw_build_node()
815 node->ins |= BLT_INS_S2_CF | BLT_INS_S1_CF; in bdisp_hw_build_node()
817 node->ins |= BLT_INS_S2_MEM | BLT_INS_S1_MEM; in bdisp_hw_build_node()
822 node->ins |= cfg->cconv ? BLT_INS_IVMX : 0; in bdisp_hw_build_node()
824 node->ins |= (cfg->scale || cfg->src_420 || cfg->dst_420) ? in bdisp_hw_build_node()
828 node->tba = (t_plan == BDISP_CBCR) ? dst->paddr[1] : dst->paddr[0]; in bdisp_hw_build_node()
830 node->tty = dst->bytesperline; in bdisp_hw_build_node()
831 node->tty |= bdisp_hw_color_format(dst_fmt); in bdisp_hw_build_node()
832 node->tty |= BLT_TTY_DITHER; in bdisp_hw_build_node()
833 node->tty |= (t_plan == BDISP_CBCR) ? BLT_TTY_CHROMA : 0; in bdisp_hw_build_node()
834 node->tty |= cfg->hflip ? BLT_TTY_HSO : 0; in bdisp_hw_build_node()
835 node->tty |= cfg->vflip ? BLT_TTY_VSO : 0; in bdisp_hw_build_node()
837 if (cfg->dst_420 && (t_plan == BDISP_CBCR)) { in bdisp_hw_build_node()
847 node->txy = cfg->vflip ? (dst_rect.height - 1) : dst_rect.top; in bdisp_hw_build_node()
848 node->txy <<= 16; in bdisp_hw_build_node()
849 node->txy |= cfg->hflip ? (dst_width - dst_x_offset - 1) : in bdisp_hw_build_node()
852 node->tsz = dst_rect.height << 16 | dst_rect.width; in bdisp_hw_build_node()
854 if (cfg->src_interlaced) { in bdisp_hw_build_node()
860 if (cfg->src_nbp == 1) { in bdisp_hw_build_node()
861 /* Src 2 : RGB */ in bdisp_hw_build_node()
862 node->s2ba = src->paddr[0]; in bdisp_hw_build_node()
864 node->s2ty = src->bytesperline; in bdisp_hw_build_node()
865 if (cfg->src_interlaced) in bdisp_hw_build_node()
866 node->s2ty *= 2; in bdisp_hw_build_node()
868 node->s2ty |= bdisp_hw_color_format(src_fmt); in bdisp_hw_build_node()
870 node->s2xy = src_rect.top << 16 | src_rect.left; in bdisp_hw_build_node()
871 node->s2sz = src_rect.height << 16 | src_rect.width; in bdisp_hw_build_node()
873 /* Src 2 : Cb or CbCr */ in bdisp_hw_build_node()
874 if (cfg->src_420) { in bdisp_hw_build_node()
882 node->s2ba = src->paddr[1]; in bdisp_hw_build_node()
884 node->s2ty = src->bytesperline; in bdisp_hw_build_node()
885 if (cfg->src_nbp == 3) in bdisp_hw_build_node()
886 node->s2ty /= 2; in bdisp_hw_build_node()
887 if (cfg->src_interlaced) in bdisp_hw_build_node()
888 node->s2ty *= 2; in bdisp_hw_build_node()
890 node->s2ty |= bdisp_hw_color_format(src_fmt); in bdisp_hw_build_node()
892 node->s2xy = src_rect.top << 16 | src_rect.left; in bdisp_hw_build_node()
893 node->s2sz = src_rect.height << 16 | src_rect.width; in bdisp_hw_build_node()
895 if (cfg->src_nbp == 3) { in bdisp_hw_build_node()
896 /* Src 1 : Cr */ in bdisp_hw_build_node()
897 node->s1ba = src->paddr[2]; in bdisp_hw_build_node()
899 node->s1ty = node->s2ty; in bdisp_hw_build_node()
900 node->s1xy = node->s2xy; in bdisp_hw_build_node()
903 /* Src 3 : Y */ in bdisp_hw_build_node()
904 node->s3ba = src->paddr[0]; in bdisp_hw_build_node()
906 node->s3ty = src->bytesperline; in bdisp_hw_build_node()
907 if (cfg->src_interlaced) in bdisp_hw_build_node()
908 node->s3ty *= 2; in bdisp_hw_build_node()
909 node->s3ty |= bdisp_hw_color_format(src_fmt); in bdisp_hw_build_node()
911 if ((t_plan != BDISP_CBCR) && cfg->src_420) { in bdisp_hw_build_node()
913 node->s3xy = node->s2xy * 2; in bdisp_hw_build_node()
914 node->s3sz = node->s2sz * 2; in bdisp_hw_build_node()
917 node->s3ty |= BLT_S3TY_BLANK_ACC; in bdisp_hw_build_node()
918 node->s3xy = node->s2xy; in bdisp_hw_build_node()
919 node->s3sz = node->s2sz; in bdisp_hw_build_node()
924 if (node->ins & BLT_INS_SCALE) { in bdisp_hw_build_node()
926 bool skip_y = (t_plan == BDISP_CBCR) && !cfg->src_yuv; in bdisp_hw_build_node()
929 if (cfg->scale) { in bdisp_hw_build_node()
930 node->fctl = BLT_FCTL_HV_SCALE; in bdisp_hw_build_node()
932 node->fctl |= BLT_FCTL_Y_HV_SCALE; in bdisp_hw_build_node()
934 node->fctl = BLT_FCTL_HV_SAMPLE; in bdisp_hw_build_node()
936 node->fctl |= BLT_FCTL_Y_HV_SAMPLE; in bdisp_hw_build_node()
939 /* RSF - Chroma may need to be up/downsampled */ in bdisp_hw_build_node()
940 h_inc = cfg->h_inc; in bdisp_hw_build_node()
941 v_inc = cfg->v_inc; in bdisp_hw_build_node()
942 if (!cfg->src_420 && cfg->dst_420 && (t_plan == BDISP_CBCR)) { in bdisp_hw_build_node()
946 } else if (cfg->src_420 && !cfg->dst_420) { in bdisp_hw_build_node()
951 node->rsf = v_inc << 16 | h_inc; in bdisp_hw_build_node()
954 node->rzi = BLT_RZI_DEFAULT; in bdisp_hw_build_node()
957 node->hfp = bdisp_hw_get_hf_addr(h_inc); in bdisp_hw_build_node()
958 node->vfp = bdisp_hw_get_vf_addr(v_inc); in bdisp_hw_build_node()
962 yh_inc = cfg->h_inc; in bdisp_hw_build_node()
963 yv_inc = cfg->v_inc; in bdisp_hw_build_node()
965 node->y_rsf = yv_inc << 16 | yh_inc; in bdisp_hw_build_node()
966 node->y_rzi = BLT_RZI_DEFAULT; in bdisp_hw_build_node()
967 node->y_hfp = bdisp_hw_get_hf_addr(yh_inc); in bdisp_hw_build_node()
968 node->y_vfp = bdisp_hw_get_vf_addr(yv_inc); in bdisp_hw_build_node()
973 if (cfg->cconv) { in bdisp_hw_build_node()
974 ivmx = cfg->src_yuv ? bdisp_yuv_to_rgb : bdisp_rgb_to_yuv; in bdisp_hw_build_node()
976 node->ivmx0 = ivmx[0]; in bdisp_hw_build_node()
977 node->ivmx1 = ivmx[1]; in bdisp_hw_build_node()
978 node->ivmx2 = ivmx[2]; in bdisp_hw_build_node()
979 node->ivmx3 = ivmx[3]; in bdisp_hw_build_node()
999 if (!ctx->node[i]) { in bdisp_hw_build_all_nodes()
1000 dev_err(ctx->bdisp_dev->dev, "node %d is null\n", i); in bdisp_hw_build_all_nodes()
1001 return -EINVAL; in bdisp_hw_build_all_nodes()
1006 return -EINVAL; in bdisp_hw_build_all_nodes()
1011 bdisp_hw_build_node(ctx, &cfg, ctx->node[nid], in bdisp_hw_build_all_nodes()
1015 ctx->node[nid - 1]->nip = ctx->node_paddr[nid]; in bdisp_hw_build_all_nodes()
1020 bdisp_hw_build_node(ctx, &cfg, ctx->node[nid], in bdisp_hw_build_all_nodes()
1022 ctx->node[nid - 1]->nip = ctx->node_paddr[nid]; in bdisp_hw_build_all_nodes()
1028 if (src_x_offset >= ctx->src.crop.width) in bdisp_hw_build_all_nodes()
1033 ctx->node[nid - 1]->nip = 0; in bdisp_hw_build_all_nodes()
1049 struct bdisp_node **copy_node = ctx->bdisp_dev->dbg.copy_node; in bdisp_hw_save_request()
1050 struct bdisp_request *request = &ctx->bdisp_dev->dbg.copy_request; in bdisp_hw_save_request()
1051 struct bdisp_node **node = ctx->node; in bdisp_hw_save_request()
1055 request->src = ctx->src; in bdisp_hw_save_request()
1056 request->dst = ctx->dst; in bdisp_hw_save_request()
1057 request->hflip = ctx->hflip; in bdisp_hw_save_request()
1058 request->vflip = ctx->vflip; in bdisp_hw_save_request()
1059 request->nb_req++; in bdisp_hw_save_request()
1065 copy_node[i] = devm_kzalloc(ctx->bdisp_dev->dev, in bdisp_hw_save_request()
1087 struct bdisp_dev *bdisp = ctx->bdisp_dev; in bdisp_hw_update()
1088 struct device *dev = bdisp->dev; in bdisp_hw_update()
1104 writel(BLT_AQ1_CTL_CFG, bdisp->regs + BLT_AQ1_CTL); in bdisp_hw_update()
1105 writel(BLT_ITS_AQ1_LNA, bdisp->regs + BLT_ITM0); in bdisp_hw_update()
1108 writel(ctx->node_paddr[0], bdisp->regs + BLT_AQ1_IP); in bdisp_hw_update()
1111 for (node_id = 0; node_id < MAX_NB_NODE - 1; node_id++) { in bdisp_hw_update()
1112 if (!ctx->node[node_id]->nip) in bdisp_hw_update()
1115 writel(ctx->node_paddr[node_id], bdisp->regs + BLT_AQ1_LNA); in bdisp_hw_update()