Lines Matching +full:offset +full:- +full:y

1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * Copyright 2005-2012 Freescale Semiconductor, Inc. All Rights Reserved.
11 #include "ipu-prv.h"
95 struct ipu_cpmem *cpmem = ch->ipu->cpmem_priv; in ipu_get_cpmem()
97 return cpmem->base + ch->num; in ipu_get_cpmem()
108 u32 mask = (1 << size) - 1; in ipu_ch_param_write_field()
113 val = readl(&base->word[word].data[i]); in ipu_ch_param_write_field()
116 writel(val, &base->word[word].data[i]); in ipu_ch_param_write_field()
118 if ((bit + size - 1) / 32 > i) { in ipu_ch_param_write_field()
119 val = readl(&base->word[word].data[i + 1]); in ipu_ch_param_write_field()
120 val &= ~(mask >> (ofs ? (32 - ofs) : 0)); in ipu_ch_param_write_field()
121 val |= v >> (ofs ? (32 - ofs) : 0); in ipu_ch_param_write_field()
122 writel(val, &base->word[word].data[i + 1]); in ipu_ch_param_write_field()
134 u32 mask = (1 << size) - 1; in ipu_ch_param_read_field()
139 val = (readl(&base->word[word].data[i]) >> ofs) & mask; in ipu_ch_param_read_field()
141 if ((bit + size - 1) / 32 > i) { in ipu_ch_param_read_field()
144 tmp = readl(&base->word[word].data[i + 1]); in ipu_ch_param_read_field()
145 tmp &= mask >> (ofs ? (32 - ofs) : 0); in ipu_ch_param_read_field()
146 val |= tmp << (ofs ? (32 - ofs) : 0); in ipu_ch_param_read_field()
154 * point of view of the IPU corresponds to little-endian words with the first
159 * https://linuxtv.org/downloads/v4l-dvb-apis/packed-rgb.html
168 * little-endian 16-bit word with the red component at the most in v4l2_pix_fmt_to_drm_fourcc()
225 return -EINVAL; in v4l2_pix_fmt_to_drm_fourcc()
241 ipu_ch_param_write_field(ch, IPU_FIELD_FW, xres - 1); in ipu_cpmem_set_resolution()
242 ipu_ch_param_write_field(ch, IPU_FIELD_FH, yres - 1); in ipu_cpmem_set_resolution()
254 ipu_ch_param_write_field(ch, IPU_FIELD_SLY, stride - 1); in ipu_cpmem_set_stride()
260 struct ipu_soc *ipu = ch->ipu; in ipu_cpmem_set_high_priority()
263 if (ipu->ipu_type == IPUV3EX) in ipu_cpmem_set_high_priority()
266 val = ipu_idmac_read(ipu, IDMAC_CHA_PRI(ch->num)); in ipu_cpmem_set_high_priority()
267 val |= 1 << (ch->num % 32); in ipu_cpmem_set_high_priority()
268 ipu_idmac_write(ipu, val, IDMAC_CHA_PRI(ch->num)); in ipu_cpmem_set_high_priority()
298 stride = -stride; in ipu_cpmem_interlaced_scan()
299 ilo = 0x100000 - (stride / 8); in ipu_cpmem_interlaced_scan()
304 sly = (stride * 2) - 1; in ipu_cpmem_interlaced_scan()
309 sluv = stride / 2 - 1; in ipu_cpmem_interlaced_scan()
312 sluv = stride - 1; in ipu_cpmem_interlaced_scan()
315 sluv = stride - 1; in ipu_cpmem_interlaced_scan()
318 sluv = stride * 2 - 1; in ipu_cpmem_interlaced_scan()
348 ipu_ch_param_write_field(ch, IPU_FIELD_NPB, burstsize - 1); in ipu_cpmem_set_burstsize()
372 ro = rgb->bits_per_pixel - rgb->red.length - rgb->red.offset; in ipu_cpmem_set_format_rgb()
373 go = rgb->bits_per_pixel - rgb->green.length - rgb->green.offset; in ipu_cpmem_set_format_rgb()
374 bo = rgb->bits_per_pixel - rgb->blue.length - rgb->blue.offset; in ipu_cpmem_set_format_rgb()
375 to = rgb->bits_per_pixel - rgb->transp.length - rgb->transp.offset; in ipu_cpmem_set_format_rgb()
377 ipu_ch_param_write_field(ch, IPU_FIELD_WID0, rgb->red.length - 1); in ipu_cpmem_set_format_rgb()
379 ipu_ch_param_write_field(ch, IPU_FIELD_WID1, rgb->green.length - 1); in ipu_cpmem_set_format_rgb()
381 ipu_ch_param_write_field(ch, IPU_FIELD_WID2, rgb->blue.length - 1); in ipu_cpmem_set_format_rgb()
384 if (rgb->transp.length) { in ipu_cpmem_set_format_rgb()
386 rgb->transp.length - 1); in ipu_cpmem_set_format_rgb()
391 rgb->bits_per_pixel); in ipu_cpmem_set_format_rgb()
394 switch (rgb->bits_per_pixel) { in ipu_cpmem_set_format_rgb()
412 return -EINVAL; in ipu_cpmem_set_format_rgb()
444 return -EINVAL; in ipu_cpmem_set_format_passthrough()
478 ipu_ch_param_write_field(ch, IPU_FIELD_SLUV, uv_stride - 1); in ipu_cpmem_set_yuv_planar_full()
485 .red = { .offset = 16, .length = 8, },
486 .green = { .offset = 8, .length = 8, },
487 .blue = { .offset = 0, .length = 8, },
488 .transp = { .offset = 24, .length = 8, },
493 .red = { .offset = 0, .length = 8, },
494 .green = { .offset = 8, .length = 8, },
495 .blue = { .offset = 16, .length = 8, },
496 .transp = { .offset = 24, .length = 8, },
501 .red = { .offset = 24, .length = 8, },
502 .green = { .offset = 16, .length = 8, },
503 .blue = { .offset = 8, .length = 8, },
504 .transp = { .offset = 0, .length = 8, },
509 .red = { .offset = 8, .length = 8, },
510 .green = { .offset = 16, .length = 8, },
511 .blue = { .offset = 24, .length = 8, },
512 .transp = { .offset = 0, .length = 8, },
517 .red = { .offset = 16, .length = 8, },
518 .green = { .offset = 8, .length = 8, },
519 .blue = { .offset = 0, .length = 8, },
520 .transp = { .offset = 0, .length = 0, },
525 .red = { .offset = 0, .length = 8, },
526 .green = { .offset = 8, .length = 8, },
527 .blue = { .offset = 16, .length = 8, },
528 .transp = { .offset = 0, .length = 0, },
533 .red = { .offset = 11, .length = 5, },
534 .green = { .offset = 5, .length = 6, },
535 .blue = { .offset = 0, .length = 5, },
536 .transp = { .offset = 0, .length = 0, },
541 .red = { .offset = 0, .length = 5, },
542 .green = { .offset = 5, .length = 6, },
543 .blue = { .offset = 11, .length = 5, },
544 .transp = { .offset = 0, .length = 0, },
549 .red = { .offset = 10, .length = 5, },
550 .green = { .offset = 5, .length = 5, },
551 .blue = { .offset = 0, .length = 5, },
552 .transp = { .offset = 15, .length = 1, },
557 .red = { .offset = 8, .length = 4, },
558 .green = { .offset = 4, .length = 4, },
559 .blue = { .offset = 0, .length = 4, },
560 .transp = { .offset = 12, .length = 4, },
565 .red = { .offset = 0, .length = 5, },
566 .green = { .offset = 5, .length = 5, },
567 .blue = { .offset = 10, .length = 5, },
568 .transp = { .offset = 15, .length = 1, },
573 .red = { .offset = 11, .length = 5, },
574 .green = { .offset = 6, .length = 5, },
575 .blue = { .offset = 1, .length = 5, },
576 .transp = { .offset = 0, .length = 1, },
581 .red = { .offset = 1, .length = 5, },
582 .green = { .offset = 6, .length = 5, },
583 .blue = { .offset = 11, .length = 5, },
584 .transp = { .offset = 0, .length = 1, },
588 #define Y_OFFSET(pix, x, y) ((x) + pix->width * (y)) argument
589 #define U_OFFSET(pix, x, y) ((pix->width * pix->height) + \ argument
590 (pix->width * ((y) / 2) / 2) + (x) / 2)
591 #define V_OFFSET(pix, x, y) ((pix->width * pix->height) + \ argument
592 (pix->width * pix->height / 4) + \
593 (pix->width * ((y) / 2) / 2) + (x) / 2)
594 #define U2_OFFSET(pix, x, y) ((pix->width * pix->height) + \ argument
595 (pix->width * (y) / 2) + (x) / 2)
596 #define V2_OFFSET(pix, x, y) ((pix->width * pix->height) + \ argument
597 (pix->width * pix->height / 2) + \
598 (pix->width * (y) / 2) + (x) / 2)
599 #define UV_OFFSET(pix, x, y) ((pix->width * pix->height) + \ argument
600 (pix->width * ((y) / 2)) + (x))
601 #define UV2_OFFSET(pix, x, y) ((pix->width * pix->height) + \ argument
602 (pix->width * y) + (x))
606 /* See Table 37-12. Alpha channels mapping. */
618 return -EINVAL; in ipu_channel_albm()
624 struct ipu_soc *ipu = ch->ipu; in ipu_cpmem_set_separate_alpha()
628 albm = ipu_channel_albm(ch->num); in ipu_cpmem_set_separate_alpha()
637 val |= BIT(ch->num); in ipu_cpmem_set_separate_alpha()
743 return -EINVAL; in ipu_cpmem_set_fmt()
766 struct v4l2_pix_format *pix = &image->pix; in ipu_cpmem_set_image()
767 int offset, u_offset, v_offset; in ipu_cpmem_set_image() local
771 __func__, pix->width, pix->height, in ipu_cpmem_set_image()
772 pix->bytesperline); in ipu_cpmem_set_image()
774 ipu_cpmem_set_resolution(ch, image->rect.width, image->rect.height); in ipu_cpmem_set_image()
775 ipu_cpmem_set_stride(ch, pix->bytesperline); in ipu_cpmem_set_image()
777 ipu_cpmem_set_fmt(ch, v4l2_pix_fmt_to_drm_fourcc(pix->pixelformat)); in ipu_cpmem_set_image()
779 switch (pix->pixelformat) { in ipu_cpmem_set_image()
781 offset = Y_OFFSET(pix, image->rect.left, image->rect.top); in ipu_cpmem_set_image()
782 u_offset = image->u_offset ? in ipu_cpmem_set_image()
783 image->u_offset : U_OFFSET(pix, image->rect.left, in ipu_cpmem_set_image()
784 image->rect.top) - offset; in ipu_cpmem_set_image()
785 v_offset = image->v_offset ? in ipu_cpmem_set_image()
786 image->v_offset : V_OFFSET(pix, image->rect.left, in ipu_cpmem_set_image()
787 image->rect.top) - offset; in ipu_cpmem_set_image()
789 ipu_cpmem_set_yuv_planar_full(ch, pix->bytesperline / 2, in ipu_cpmem_set_image()
793 offset = Y_OFFSET(pix, image->rect.left, image->rect.top); in ipu_cpmem_set_image()
794 u_offset = image->u_offset ? in ipu_cpmem_set_image()
795 image->u_offset : V_OFFSET(pix, image->rect.left, in ipu_cpmem_set_image()
796 image->rect.top) - offset; in ipu_cpmem_set_image()
797 v_offset = image->v_offset ? in ipu_cpmem_set_image()
798 image->v_offset : U_OFFSET(pix, image->rect.left, in ipu_cpmem_set_image()
799 image->rect.top) - offset; in ipu_cpmem_set_image()
801 ipu_cpmem_set_yuv_planar_full(ch, pix->bytesperline / 2, in ipu_cpmem_set_image()
805 offset = Y_OFFSET(pix, image->rect.left, image->rect.top); in ipu_cpmem_set_image()
806 u_offset = image->u_offset ? in ipu_cpmem_set_image()
807 image->u_offset : U2_OFFSET(pix, image->rect.left, in ipu_cpmem_set_image()
808 image->rect.top) - offset; in ipu_cpmem_set_image()
809 v_offset = image->v_offset ? in ipu_cpmem_set_image()
810 image->v_offset : V2_OFFSET(pix, image->rect.left, in ipu_cpmem_set_image()
811 image->rect.top) - offset; in ipu_cpmem_set_image()
813 ipu_cpmem_set_yuv_planar_full(ch, pix->bytesperline / 2, in ipu_cpmem_set_image()
817 offset = Y_OFFSET(pix, image->rect.left, image->rect.top); in ipu_cpmem_set_image()
818 u_offset = image->u_offset ? in ipu_cpmem_set_image()
819 image->u_offset : UV_OFFSET(pix, image->rect.left, in ipu_cpmem_set_image()
820 image->rect.top) - offset; in ipu_cpmem_set_image()
821 v_offset = image->v_offset ? image->v_offset : 0; in ipu_cpmem_set_image()
823 ipu_cpmem_set_yuv_planar_full(ch, pix->bytesperline, in ipu_cpmem_set_image()
827 offset = Y_OFFSET(pix, image->rect.left, image->rect.top); in ipu_cpmem_set_image()
828 u_offset = image->u_offset ? in ipu_cpmem_set_image()
829 image->u_offset : UV2_OFFSET(pix, image->rect.left, in ipu_cpmem_set_image()
830 image->rect.top) - offset; in ipu_cpmem_set_image()
831 v_offset = image->v_offset ? image->v_offset : 0; in ipu_cpmem_set_image()
833 ipu_cpmem_set_yuv_planar_full(ch, pix->bytesperline, in ipu_cpmem_set_image()
839 offset = image->rect.left * 2 + in ipu_cpmem_set_image()
840 image->rect.top * pix->bytesperline; in ipu_cpmem_set_image()
852 offset = image->rect.left * 4 + in ipu_cpmem_set_image()
853 image->rect.top * pix->bytesperline; in ipu_cpmem_set_image()
857 offset = image->rect.left * 3 + in ipu_cpmem_set_image()
858 image->rect.top * pix->bytesperline; in ipu_cpmem_set_image()
865 offset = image->rect.left + image->rect.top * pix->bytesperline; in ipu_cpmem_set_image()
872 offset = image->rect.left * 2 + in ipu_cpmem_set_image()
873 image->rect.top * pix->bytesperline; in ipu_cpmem_set_image()
878 offset = 0; in ipu_cpmem_set_image()
879 ret = -EINVAL; in ipu_cpmem_set_image()
882 ipu_cpmem_set_buffer(ch, 0, image->phys0 + offset); in ipu_cpmem_set_image()
883 ipu_cpmem_set_buffer(ch, 1, image->phys1 + offset); in ipu_cpmem_set_image()
892 struct ipu_soc *ipu = ch->ipu; in ipu_cpmem_dump()
893 int chno = ch->num; in ipu_cpmem_dump()
895 dev_dbg(ipu->dev, "ch %d word 0 - %08X %08X %08X %08X %08X\n", chno, in ipu_cpmem_dump()
896 readl(&p->word[0].data[0]), in ipu_cpmem_dump()
897 readl(&p->word[0].data[1]), in ipu_cpmem_dump()
898 readl(&p->word[0].data[2]), in ipu_cpmem_dump()
899 readl(&p->word[0].data[3]), in ipu_cpmem_dump()
900 readl(&p->word[0].data[4])); in ipu_cpmem_dump()
901 dev_dbg(ipu->dev, "ch %d word 1 - %08X %08X %08X %08X %08X\n", chno, in ipu_cpmem_dump()
902 readl(&p->word[1].data[0]), in ipu_cpmem_dump()
903 readl(&p->word[1].data[1]), in ipu_cpmem_dump()
904 readl(&p->word[1].data[2]), in ipu_cpmem_dump()
905 readl(&p->word[1].data[3]), in ipu_cpmem_dump()
906 readl(&p->word[1].data[4])); in ipu_cpmem_dump()
907 dev_dbg(ipu->dev, "PFS 0x%x, ", in ipu_cpmem_dump()
909 dev_dbg(ipu->dev, "BPP 0x%x, ", in ipu_cpmem_dump()
911 dev_dbg(ipu->dev, "NPB 0x%x\n", in ipu_cpmem_dump()
914 dev_dbg(ipu->dev, "FW %d, ", in ipu_cpmem_dump()
916 dev_dbg(ipu->dev, "FH %d, ", in ipu_cpmem_dump()
918 dev_dbg(ipu->dev, "EBA0 0x%x\n", in ipu_cpmem_dump()
920 dev_dbg(ipu->dev, "EBA1 0x%x\n", in ipu_cpmem_dump()
922 dev_dbg(ipu->dev, "Stride %d\n", in ipu_cpmem_dump()
924 dev_dbg(ipu->dev, "scan_order %d\n", in ipu_cpmem_dump()
926 dev_dbg(ipu->dev, "uv_stride %d\n", in ipu_cpmem_dump()
928 dev_dbg(ipu->dev, "u_offset 0x%x\n", in ipu_cpmem_dump()
930 dev_dbg(ipu->dev, "v_offset 0x%x\n", in ipu_cpmem_dump()
933 dev_dbg(ipu->dev, "Width0 %d+1, ", in ipu_cpmem_dump()
935 dev_dbg(ipu->dev, "Width1 %d+1, ", in ipu_cpmem_dump()
937 dev_dbg(ipu->dev, "Width2 %d+1, ", in ipu_cpmem_dump()
939 dev_dbg(ipu->dev, "Width3 %d+1, ", in ipu_cpmem_dump()
941 dev_dbg(ipu->dev, "Offset0 %d, ", in ipu_cpmem_dump()
943 dev_dbg(ipu->dev, "Offset1 %d, ", in ipu_cpmem_dump()
945 dev_dbg(ipu->dev, "Offset2 %d, ", in ipu_cpmem_dump()
947 dev_dbg(ipu->dev, "Offset3 %d\n", in ipu_cpmem_dump()
958 return -ENOMEM; in ipu_cpmem_init()
960 ipu->cpmem_priv = cpmem; in ipu_cpmem_init()
962 spin_lock_init(&cpmem->lock); in ipu_cpmem_init()
963 cpmem->base = devm_ioremap(dev, base, SZ_128K); in ipu_cpmem_init()
964 if (!cpmem->base) in ipu_cpmem_init()
965 return -ENOMEM; in ipu_cpmem_init()
968 base, cpmem->base); in ipu_cpmem_init()
969 cpmem->ipu = ipu; in ipu_cpmem_init()