• Home
  • Raw
  • Download

Lines Matching +full:0 +full:- +full:128

1 // SPDX-License-Identifier: GPL-2.0+
3 * i.MX Pixel Pipeline (PXP) mem-to-mem scaler/CSC/rotator driver
9 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
15 #include <linux/dma-mapping.h>
25 #include <media/v4l2-mem2mem.h>
26 #include <media/v4l2-device.h>
27 #include <media/v4l2-ioctl.h>
28 #include <media/v4l2-ctrls.h>
29 #include <media/v4l2-event.h>
30 #include <media/videobuf2-dma-contig.h>
32 #include "imx-pxp.h"
46 #define MEM2MEM_CAPTURE (1 << 0)
52 #define MEM2MEM_HFLIP (1 << 0)
56 v4l2_dbg(1, debug, &dev->v4l2_dev, "%s: " fmt, __func__, ## arg)
74 /* Capture-only format */
107 /* Output-only format */
154 /* Per-queue, driver-specific private data */
167 V4L2_M2M_SRC = 0,
176 for (k = 0; k < NUM_FORMATS; k++) { in find_format()
178 if (fmt->fourcc == f->fmt.pix.pixelformat) in find_format()
224 return container_of(file->private_data, struct pxp_ctx, fh); in file2ctx()
231 return &ctx->q_data[V4L2_M2M_SRC]; in get_q_data()
233 return &ctx->q_data[V4L2_M2M_DST]; in get_q_data()
311 struct pxp_dev *dev = ctx->dev; in pxp_setup_csc()
315 if (pxp_v4l2_pix_fmt_is_yuv(ctx->q_data[V4L2_M2M_SRC].fmt->fourcc) && in pxp_setup_csc()
316 !pxp_v4l2_pix_fmt_is_yuv(ctx->q_data[V4L2_M2M_DST].fmt->fourcc)) { in pxp_setup_csc()
320 * |R| |C0 0 C1| |Y + Yoffset | in pxp_setup_csc()
322 * |B| |C0 C4 0 | |Cr + UVoffset| in pxp_setup_csc()
324 * Results are clamped to 0..255. in pxp_setup_csc()
328 * |R| |1.1644 0.0000 1.5960| |Y - 16 | in pxp_setup_csc()
329 * |G| = |1.1644 -0.3917 -0.8129| * |Cb - 128| in pxp_setup_csc()
330 * |B| |1.1644 2.0172 0.0000| |Cr - 128| in pxp_setup_csc()
334 BF_PXP_CSC1_COEF0_C0(0x12a) | /* 1.1641 (-0.03 %) */ in pxp_setup_csc()
335 BF_PXP_CSC1_COEF0_UV_OFFSET(-128) | in pxp_setup_csc()
336 BF_PXP_CSC1_COEF0_Y_OFFSET(-16), in pxp_setup_csc()
337 BF_PXP_CSC1_COEF1_C1(0x198) | /* 1.5938 (-0.23 %) */ in pxp_setup_csc()
338 BF_PXP_CSC1_COEF1_C4(0x204), /* 2.0156 (-0.16 %) */ in pxp_setup_csc()
339 BF_PXP_CSC1_COEF2_C2(0x730) | /* -0.8125 (+0.04 %) */ in pxp_setup_csc()
340 BF_PXP_CSC1_COEF2_C3(0x79c), /* -0.3906 (+0.11 %) */ in pxp_setup_csc()
345 * |R| |1.0000 0.0000 1.4020| |Y + 0 | in pxp_setup_csc()
346 * |G| = |1.0000 -0.3441 -0.7141| * |Cb - 128| in pxp_setup_csc()
347 * |B| |1.0000 1.7720 0.0000| |Cr - 128| in pxp_setup_csc()
351 BF_PXP_CSC1_COEF0_C0(0x100) | /* 1.0000 (+0.00 %) */ in pxp_setup_csc()
352 BF_PXP_CSC1_COEF0_UV_OFFSET(-128) | in pxp_setup_csc()
353 BF_PXP_CSC1_COEF0_Y_OFFSET(0), in pxp_setup_csc()
354 BF_PXP_CSC1_COEF1_C1(0x166) | /* 1.3984 (-0.36 %) */ in pxp_setup_csc()
355 BF_PXP_CSC1_COEF1_C4(0x1c5), /* 1.7695 (-0.25 %) */ in pxp_setup_csc()
356 BF_PXP_CSC1_COEF2_C2(0x74a) | /* -0.7109 (+0.32 %) */ in pxp_setup_csc()
357 BF_PXP_CSC1_COEF2_C3(0x7a8), /* -0.3438 (+0.04 %) */ in pxp_setup_csc()
362 * |R| |1.1644 0.0000 1.7927| |Y - 16 | in pxp_setup_csc()
363 * |G| = |1.1644 -0.2132 -0.5329| * |Cb - 128| in pxp_setup_csc()
364 * |B| |1.1644 2.1124 0.0000| |Cr - 128| in pxp_setup_csc()
368 BF_PXP_CSC1_COEF0_C0(0x12a) | /* 1.1641 (-0.03 %) */ in pxp_setup_csc()
369 BF_PXP_CSC1_COEF0_UV_OFFSET(-128) | in pxp_setup_csc()
370 BF_PXP_CSC1_COEF0_Y_OFFSET(-16), in pxp_setup_csc()
371 BF_PXP_CSC1_COEF1_C1(0x1ca) | /* 1.7891 (-0.37 %) */ in pxp_setup_csc()
372 BF_PXP_CSC1_COEF1_C4(0x21c), /* 2.1094 (-0.30 %) */ in pxp_setup_csc()
373 BF_PXP_CSC1_COEF2_C2(0x778) | /* -0.5312 (+0.16 %) */ in pxp_setup_csc()
374 BF_PXP_CSC1_COEF2_C3(0x7ca), /* -0.2109 (+0.23 %) */ in pxp_setup_csc()
379 * |R| |1.0000 0.0000 1.5748| |Y + 0 | in pxp_setup_csc()
380 * |G| = |1.0000 -0.1873 -0.4681| * |Cb - 128| in pxp_setup_csc()
381 * |B| |1.0000 1.8556 0.0000| |Cr - 128| in pxp_setup_csc()
385 BF_PXP_CSC1_COEF0_C0(0x100) | /* 1.0000 (+0.00 %) */ in pxp_setup_csc()
386 BF_PXP_CSC1_COEF0_UV_OFFSET(-128) | in pxp_setup_csc()
387 BF_PXP_CSC1_COEF0_Y_OFFSET(0), in pxp_setup_csc()
388 BF_PXP_CSC1_COEF1_C1(0x193) | /* 1.5742 (-0.06 %) */ in pxp_setup_csc()
389 BF_PXP_CSC1_COEF1_C4(0x1db), /* 1.8555 (-0.01 %) */ in pxp_setup_csc()
390 BF_PXP_CSC1_COEF2_C2(0x789) | /* -0.4648 (+0.33 %) */ in pxp_setup_csc()
391 BF_PXP_CSC1_COEF2_C3(0x7d1), /* -0.1836 (+0.37 %) */ in pxp_setup_csc()
396 * |R| |1.1644 0.0000 1.6787| |Y - 16 | in pxp_setup_csc()
397 * |G| = |1.1644 -0.1874 -0.6505| * |Cb - 128| in pxp_setup_csc()
398 * |B| |1.1644 2.1418 0.0000| |Cr - 128| in pxp_setup_csc()
402 BF_PXP_CSC1_COEF0_C0(0x12a) | /* 1.1641 (-0.03 %) */ in pxp_setup_csc()
403 BF_PXP_CSC1_COEF0_UV_OFFSET(-128) | in pxp_setup_csc()
404 BF_PXP_CSC1_COEF0_Y_OFFSET(-16), in pxp_setup_csc()
405 BF_PXP_CSC1_COEF1_C1(0x1ad) | /* 1.6758 (-0.29 %) */ in pxp_setup_csc()
406 BF_PXP_CSC1_COEF1_C4(0x224), /* 2.1406 (-0.11 %) */ in pxp_setup_csc()
407 BF_PXP_CSC1_COEF2_C2(0x75a) | /* -0.6484 (+0.20 %) */ in pxp_setup_csc()
408 BF_PXP_CSC1_COEF2_C3(0x7d1), /* -0.1836 (+0.38 %) */ in pxp_setup_csc()
413 * |R| |1.0000 0.0000 1.4746| |Y + 0 | in pxp_setup_csc()
414 * |G| = |1.0000 -0.1646 -0.5714| * |Cb - 128| in pxp_setup_csc()
415 * |B| |1.0000 1.8814 0.0000| |Cr - 128| in pxp_setup_csc()
419 BF_PXP_CSC1_COEF0_C0(0x100) | /* 1.0000 (+0.00 %) */ in pxp_setup_csc()
420 BF_PXP_CSC1_COEF0_UV_OFFSET(-128) | in pxp_setup_csc()
421 BF_PXP_CSC1_COEF0_Y_OFFSET(0), in pxp_setup_csc()
422 BF_PXP_CSC1_COEF1_C1(0x179) | /* 1.4727 (-0.19 %) */ in pxp_setup_csc()
423 BF_PXP_CSC1_COEF1_C4(0x1e1), /* 1.8789 (-0.25 %) */ in pxp_setup_csc()
424 BF_PXP_CSC1_COEF2_C2(0x76e) | /* -0.5703 (+0.11 %) */ in pxp_setup_csc()
425 BF_PXP_CSC1_COEF2_C3(0x7d6), /* -0.1641 (+0.05 %) */ in pxp_setup_csc()
430 * |R| |1.1644 0.0000 1.7937| |Y - 16 | in pxp_setup_csc()
431 * |G| = |1.1644 -0.2565 -0.5427| * |Cb - 128| in pxp_setup_csc()
432 * |B| |1.1644 2.0798 0.0000| |Cr - 128| in pxp_setup_csc()
436 BF_PXP_CSC1_COEF0_C0(0x12a) | /* 1.1641 (-0.03 %) */ in pxp_setup_csc()
437 BF_PXP_CSC1_COEF0_UV_OFFSET(-128) | in pxp_setup_csc()
438 BF_PXP_CSC1_COEF0_Y_OFFSET(-16), in pxp_setup_csc()
439 BF_PXP_CSC1_COEF1_C1(0x1cb) | /* 1.7930 (-0.07 %) */ in pxp_setup_csc()
440 BF_PXP_CSC1_COEF1_C4(0x214), /* 2.0781 (-0.17 %) */ in pxp_setup_csc()
441 BF_PXP_CSC1_COEF2_C2(0x776) | /* -0.5391 (+0.36 %) */ in pxp_setup_csc()
442 BF_PXP_CSC1_COEF2_C3(0x7bf), /* -0.2539 (+0.26 %) */ in pxp_setup_csc()
447 * |R| |1.0000 0.0000 1.5756| |Y + 0 | in pxp_setup_csc()
448 * |G| = |1.0000 -0.2253 -0.4767| * |Cb - 128| in pxp_setup_csc()
449 * |B| |1.0000 1.8270 0.0000| |Cr - 128| in pxp_setup_csc()
453 BF_PXP_CSC1_COEF0_C0(0x100) | /* 1.0000 (+0.00 %) */ in pxp_setup_csc()
454 BF_PXP_CSC1_COEF0_UV_OFFSET(-128) | in pxp_setup_csc()
455 BF_PXP_CSC1_COEF0_Y_OFFSET(0), in pxp_setup_csc()
456 BF_PXP_CSC1_COEF1_C1(0x193) | /* 1.5742 (-0.14 %) */ in pxp_setup_csc()
457 BF_PXP_CSC1_COEF1_C4(0x1d3), /* 1.8242 (-0.28 %) */ in pxp_setup_csc()
458 BF_PXP_CSC1_COEF2_C2(0x786) | /* -0.4766 (+0.01 %) */ in pxp_setup_csc()
459 BF_PXP_CSC1_COEF2_C3(0x7c7), /* -0.2227 (+0.26 %) */ in pxp_setup_csc()
463 ycbcr_enc = ctx->q_data[V4L2_M2M_SRC].ycbcr_enc; in pxp_setup_csc()
464 quantization = ctx->q_data[V4L2_M2M_SRC].quant; in pxp_setup_csc()
488 writel(csc1_coef[0], dev->mmio + HW_PXP_CSC1_COEF0); in pxp_setup_csc()
489 writel(csc1_coef[1], dev->mmio + HW_PXP_CSC1_COEF1); in pxp_setup_csc()
490 writel(csc1_coef[2], dev->mmio + HW_PXP_CSC1_COEF2); in pxp_setup_csc()
492 writel(BM_PXP_CSC1_COEF0_BYPASS, dev->mmio + HW_PXP_CSC1_COEF0); in pxp_setup_csc()
495 if (!pxp_v4l2_pix_fmt_is_yuv(ctx->q_data[V4L2_M2M_SRC].fmt->fourcc) && in pxp_setup_csc()
496 pxp_v4l2_pix_fmt_is_yuv(ctx->q_data[V4L2_M2M_DST].fmt->fourcc)) { in pxp_setup_csc()
504 * Results are clamped to 0..255. in pxp_setup_csc()
509 * |Cb| = |-0.1482 -0.2910 0.4392| * |G| + |128| in pxp_setup_csc()
510 * |Cr| | 0.4392 0.4392 -0.3678| |B| |128| in pxp_setup_csc()
513 BF_PXP_CSC2_COEF0_A2(0x081) | /* 0.5039 (-0.02 %) */ in pxp_setup_csc()
514 BF_PXP_CSC2_COEF0_A1(0x041), /* 0.2539 (-0.29 %) */ in pxp_setup_csc()
515 BF_PXP_CSC2_COEF1_B1(0x7db) | /* -0.1445 (+0.37 %) */ in pxp_setup_csc()
516 BF_PXP_CSC2_COEF1_A3(0x019), /* 0.0977 (-0.02 %) */ in pxp_setup_csc()
517 BF_PXP_CSC2_COEF2_B3(0x070) | /* 0.4375 (-0.17 %) */ in pxp_setup_csc()
518 BF_PXP_CSC2_COEF2_B2(0x7b6), /* -0.2891 (+0.20 %) */ in pxp_setup_csc()
519 BF_PXP_CSC2_COEF3_C2(0x7a2) | /* -0.3672 (+0.06 %) */ in pxp_setup_csc()
520 BF_PXP_CSC2_COEF3_C1(0x070), /* 0.4375 (-0.17 %) */ in pxp_setup_csc()
522 BF_PXP_CSC2_COEF4_C3(0x7ee), /* -0.0703 (+0.11 %) */ in pxp_setup_csc()
523 BF_PXP_CSC2_COEF5_D3(128) | in pxp_setup_csc()
524 BF_PXP_CSC2_COEF5_D2(128), in pxp_setup_csc()
529 * |Y | | 0.2990 0.5870 0.1140| |R| |0 | in pxp_setup_csc()
530 * |Cb| = |-0.1687 -0.3313 0.5000| * |G| + |128| in pxp_setup_csc()
531 * |Cr| | 0.5000 0.5000 -0.4187| |B| |128| in pxp_setup_csc()
534 BF_PXP_CSC2_COEF0_A2(0x096) | /* 0.5859 (-0.11 %) */ in pxp_setup_csc()
535 BF_PXP_CSC2_COEF0_A1(0x04c), /* 0.2969 (-0.21 %) */ in pxp_setup_csc()
536 BF_PXP_CSC2_COEF1_B1(0x7d5) | /* -0.1680 (+0.07 %) */ in pxp_setup_csc()
537 BF_PXP_CSC2_COEF1_A3(0x01d), /* 0.1133 (-0.07 %) */ in pxp_setup_csc()
538 BF_PXP_CSC2_COEF2_B3(0x080) | /* 0.5000 (+0.00 %) */ in pxp_setup_csc()
539 BF_PXP_CSC2_COEF2_B2(0x7ac), /* -0.3281 (+0.32 %) */ in pxp_setup_csc()
540 BF_PXP_CSC2_COEF3_C2(0x795) | /* -0.4180 (+0.07 %) */ in pxp_setup_csc()
541 BF_PXP_CSC2_COEF3_C1(0x080), /* 0.5000 (+0.00 %) */ in pxp_setup_csc()
542 BF_PXP_CSC2_COEF4_D1(0) | in pxp_setup_csc()
543 BF_PXP_CSC2_COEF4_C3(0x7ec), /* -0.0781 (+0.32 %) */ in pxp_setup_csc()
544 BF_PXP_CSC2_COEF5_D3(128) | in pxp_setup_csc()
545 BF_PXP_CSC2_COEF5_D2(128), in pxp_setup_csc()
551 * |Cb| = |-0.1007 -0.3385 0.4392| * |G| + |128| in pxp_setup_csc()
552 * |Cr| | 0.4392 0.4392 -0.3990| |B| |128| in pxp_setup_csc()
555 BF_PXP_CSC2_COEF0_A2(0x09d) | /* 0.6133 (-0.09 %) */ in pxp_setup_csc()
556 BF_PXP_CSC2_COEF0_A1(0x02e), /* 0.1797 (-0.29 %) */ in pxp_setup_csc()
557 BF_PXP_CSC2_COEF1_B1(0x7e7) | /* -0.0977 (+0.30 %) */ in pxp_setup_csc()
558 BF_PXP_CSC2_COEF1_A3(0x00f), /* 0.0586 (-0.34 %) */ in pxp_setup_csc()
559 BF_PXP_CSC2_COEF2_B3(0x070) | /* 0.4375 (-0.17 %) */ in pxp_setup_csc()
560 BF_PXP_CSC2_COEF2_B2(0x7aa), /* -0.3359 (+0.26 %) */ in pxp_setup_csc()
561 BF_PXP_CSC2_COEF3_C2(0x79a) | /* -0.3984 (+0.05 %) */ in pxp_setup_csc()
562 BF_PXP_CSC2_COEF3_C1(0x070), /* 0.4375 (-0.17 %) */ in pxp_setup_csc()
564 BF_PXP_CSC2_COEF4_C3(0x7f6), /* -0.0391 (+0.12 %) */ in pxp_setup_csc()
565 BF_PXP_CSC2_COEF5_D3(128) | in pxp_setup_csc()
566 BF_PXP_CSC2_COEF5_D2(128), in pxp_setup_csc()
571 * |Y | | 0.2126 0.7152 0.0722| |R| |0 | in pxp_setup_csc()
572 * |Cb| = |-0.1146 -0.3854 0.5000| * |G| + |128| in pxp_setup_csc()
573 * |Cr| | 0.5000 0.5000 -0.4542| |B| |128| in pxp_setup_csc()
576 BF_PXP_CSC2_COEF0_A2(0x0b7) | /* 0.7148 (-0.04 %) */ in pxp_setup_csc()
577 BF_PXP_CSC2_COEF0_A1(0x036), /* 0.2109 (-0.17 %) */ in pxp_setup_csc()
578 BF_PXP_CSC2_COEF1_B1(0x7e3) | /* -0.1133 (+0.13 %) */ in pxp_setup_csc()
579 BF_PXP_CSC2_COEF1_A3(0x012), /* 0.0703 (-0.19 %) */ in pxp_setup_csc()
580 BF_PXP_CSC2_COEF2_B3(0x080) | /* 0.5000 (+0.00 %) */ in pxp_setup_csc()
581 BF_PXP_CSC2_COEF2_B2(0x79e), /* -0.3828 (+0.26 %) */ in pxp_setup_csc()
582 BF_PXP_CSC2_COEF3_C2(0x78c) | /* -0.4531 (+0.11 %) */ in pxp_setup_csc()
583 BF_PXP_CSC2_COEF3_C1(0x080), /* 0.5000 (+0.00 %) */ in pxp_setup_csc()
584 BF_PXP_CSC2_COEF4_D1(0) | in pxp_setup_csc()
585 BF_PXP_CSC2_COEF4_C3(0x7f5), /* -0.0430 (+0.28 %) */ in pxp_setup_csc()
586 BF_PXP_CSC2_COEF5_D3(128) | in pxp_setup_csc()
587 BF_PXP_CSC2_COEF5_D2(128), in pxp_setup_csc()
593 * |Cb| = |-0.1226 -0.3166 0.4392| * |G| + |128| in pxp_setup_csc()
594 * |Cr| | 0.4392 0.4392 -0.4039| |B| |128| in pxp_setup_csc()
597 BF_PXP_CSC2_COEF0_A2(0x095) | /* 0.5820 (-0.03 %) */ in pxp_setup_csc()
598 BF_PXP_CSC2_COEF0_A1(0x039), /* 0.2227 (-0.30 %) */ in pxp_setup_csc()
599 BF_PXP_CSC2_COEF1_B1(0x7e1) | /* -0.1211 (+0.15 %) */ in pxp_setup_csc()
600 BF_PXP_CSC2_COEF1_A3(0x00d), /* 0.0508 (-0.01 %) */ in pxp_setup_csc()
601 BF_PXP_CSC2_COEF2_B3(0x070) | /* 0.4375 (-0.17 %) */ in pxp_setup_csc()
602 BF_PXP_CSC2_COEF2_B2(0x7af), /* -0.3164 (+0.02 %) */ in pxp_setup_csc()
603 BF_PXP_CSC2_COEF3_C2(0x799) | /* -0.4023 (+0.16 %) */ in pxp_setup_csc()
604 BF_PXP_CSC2_COEF3_C1(0x070), /* 0.4375 (-0.17 %) */ in pxp_setup_csc()
606 BF_PXP_CSC2_COEF4_C3(0x7f7), /* -0.0352 (+0.02 %) */ in pxp_setup_csc()
607 BF_PXP_CSC2_COEF5_D3(128) | in pxp_setup_csc()
608 BF_PXP_CSC2_COEF5_D2(128), in pxp_setup_csc()
613 * |Y | | 0.2627 0.6780 0.0593| |R| |0 | in pxp_setup_csc()
614 * |Cb| = |-0.1396 -0.3604 0.5000| * |G| + |128| in pxp_setup_csc()
615 * |Cr| | 0.5000 0.5000 -0.4598| |B| |128| in pxp_setup_csc()
618 BF_PXP_CSC2_COEF0_A2(0x0ad) | /* 0.6758 (-0.22 %) */ in pxp_setup_csc()
619 BF_PXP_CSC2_COEF0_A1(0x043), /* 0.2617 (-0.10 %) */ in pxp_setup_csc()
620 BF_PXP_CSC2_COEF1_B1(0x7dd) | /* -0.1367 (+0.29 %) */ in pxp_setup_csc()
621 BF_PXP_CSC2_COEF1_A3(0x00f), /* 0.0586 (-0.07 %) */ in pxp_setup_csc()
622 BF_PXP_CSC2_COEF2_B3(0x080) | /* 0.5000 (+0.00 %) */ in pxp_setup_csc()
623 BF_PXP_CSC2_COEF2_B2(0x7a4), /* -0.3594 (+0.10 %) */ in pxp_setup_csc()
624 BF_PXP_CSC2_COEF3_C2(0x78b) | /* -0.4570 (+0.28 %) */ in pxp_setup_csc()
625 BF_PXP_CSC2_COEF3_C1(0x080), /* 0.5000 (+0.00 %) */ in pxp_setup_csc()
626 BF_PXP_CSC2_COEF4_D1(0) | in pxp_setup_csc()
627 BF_PXP_CSC2_COEF4_C3(0x7f6), /* -0.0391 (+0.11 %) */ in pxp_setup_csc()
628 BF_PXP_CSC2_COEF5_D3(128) | in pxp_setup_csc()
629 BF_PXP_CSC2_COEF5_D2(128), in pxp_setup_csc()
635 * |Cb| = |-0.1019 -0.3373 0.4392| * |G| + |128| in pxp_setup_csc()
636 * |Cr| | 0.4392 0.4392 -0.3909| |B| |128| in pxp_setup_csc()
639 BF_PXP_CSC2_COEF0_A2(0x09a) | /* 0.6016 (-0.05 %) */ in pxp_setup_csc()
640 BF_PXP_CSC2_COEF0_A1(0x02e), /* 0.1797 (-0.24 %) */ in pxp_setup_csc()
641 BF_PXP_CSC2_COEF1_B1(0x7e6) | /* -0.1016 (+0.03 %) */ in pxp_setup_csc()
642 BF_PXP_CSC2_COEF1_A3(0x013), /* 0.0742 (-0.05 %) */ in pxp_setup_csc()
643 BF_PXP_CSC2_COEF2_B3(0x070) | /* 0.4375 (-0.17 %) */ in pxp_setup_csc()
644 BF_PXP_CSC2_COEF2_B2(0x7aa), /* -0.3359 (+0.14 %) */ in pxp_setup_csc()
645 BF_PXP_CSC2_COEF3_C2(0x79c) | /* -0.3906 (+0.03 %) */ in pxp_setup_csc()
646 BF_PXP_CSC2_COEF3_C1(0x070), /* 0.4375 (-0.17 %) */ in pxp_setup_csc()
648 BF_PXP_CSC2_COEF4_C3(0x7f4), /* -0.0469 (+0.14 %) */ in pxp_setup_csc()
649 BF_PXP_CSC2_COEF5_D3(128) | in pxp_setup_csc()
650 BF_PXP_CSC2_COEF5_D2(128), in pxp_setup_csc()
655 * |Y | | 0.2120 0.7010 0.0870| |R| |0 | in pxp_setup_csc()
656 * |Cb| = |-0.1160 -0.3840 0.5000| * |G| + |128| in pxp_setup_csc()
657 * |Cr| | 0.5000 0.5000 -0.4450| |B| |128| in pxp_setup_csc()
660 BF_PXP_CSC2_COEF0_A2(0x0b3) | /* 0.6992 (-0.18 %) */ in pxp_setup_csc()
661 BF_PXP_CSC2_COEF0_A1(0x036), /* 0.2109 (-0.11 %) */ in pxp_setup_csc()
662 BF_PXP_CSC2_COEF1_B1(0x7e3) | /* -0.1133 (+0.27 %) */ in pxp_setup_csc()
663 BF_PXP_CSC2_COEF1_A3(0x016), /* 0.0859 (-0.11 %) */ in pxp_setup_csc()
664 BF_PXP_CSC2_COEF2_B3(0x080) | /* 0.5000 (+0.00 %) */ in pxp_setup_csc()
665 BF_PXP_CSC2_COEF2_B2(0x79e), /* -0.3828 (+0.12 %) */ in pxp_setup_csc()
666 BF_PXP_CSC2_COEF3_C2(0x78f) | /* -0.4414 (+0.36 %) */ in pxp_setup_csc()
667 BF_PXP_CSC2_COEF3_C1(0x080), /* 0.5000 (+0.00 %) */ in pxp_setup_csc()
668 BF_PXP_CSC2_COEF4_D1(0) | in pxp_setup_csc()
669 BF_PXP_CSC2_COEF4_C3(0x7f2), /* -0.0547 (+0.03 %) */ in pxp_setup_csc()
670 BF_PXP_CSC2_COEF5_D3(128) | in pxp_setup_csc()
671 BF_PXP_CSC2_COEF5_D2(128), in pxp_setup_csc()
676 ycbcr_enc = ctx->q_data[V4L2_M2M_DST].ycbcr_enc; in pxp_setup_csc()
677 quantization = ctx->q_data[V4L2_M2M_DST].quant; in pxp_setup_csc()
708 writel(csc2_ctrl, dev->mmio + HW_PXP_CSC2_CTRL); in pxp_setup_csc()
709 writel(csc2_coef[0], dev->mmio + HW_PXP_CSC2_COEF0); in pxp_setup_csc()
710 writel(csc2_coef[1], dev->mmio + HW_PXP_CSC2_COEF1); in pxp_setup_csc()
711 writel(csc2_coef[2], dev->mmio + HW_PXP_CSC2_COEF2); in pxp_setup_csc()
712 writel(csc2_coef[3], dev->mmio + HW_PXP_CSC2_COEF3); in pxp_setup_csc()
713 writel(csc2_coef[4], dev->mmio + HW_PXP_CSC2_COEF4); in pxp_setup_csc()
714 writel(csc2_coef[5], dev->mmio + HW_PXP_CSC2_COEF5); in pxp_setup_csc()
716 writel(BM_PXP_CSC2_CTRL_BYPASS, dev->mmio + HW_PXP_CSC2_CTRL); in pxp_setup_csc()
723 struct pxp_dev *dev = ctx->dev; in pxp_start()
737 src_width = ctx->q_data[V4L2_M2M_SRC].width; in pxp_start()
738 dst_width = ctx->q_data[V4L2_M2M_DST].width; in pxp_start()
739 src_height = ctx->q_data[V4L2_M2M_SRC].height; in pxp_start()
740 dst_height = ctx->q_data[V4L2_M2M_DST].height; in pxp_start()
741 src_stride = ctx->q_data[V4L2_M2M_SRC].bytesperline; in pxp_start()
742 dst_stride = ctx->q_data[V4L2_M2M_DST].bytesperline; in pxp_start()
743 src_fourcc = ctx->q_data[V4L2_M2M_SRC].fmt->fourcc; in pxp_start()
744 dst_fourcc = ctx->q_data[V4L2_M2M_DST].fmt->fourcc; in pxp_start()
746 p_in = vb2_dma_contig_plane_dma_addr(&in_vb->vb2_buf, 0); in pxp_start()
747 p_out = vb2_dma_contig_plane_dma_addr(&out_vb->vb2_buf, 0); in pxp_start()
750 v4l2_err(&dev->v4l2_dev, in pxp_start()
752 return -EFAULT; in pxp_start()
755 out_vb->sequence = in pxp_start()
756 get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE)->sequence++; in pxp_start()
757 in_vb->sequence = q_data->sequence++; in pxp_start()
758 out_vb->vb2_buf.timestamp = in_vb->vb2_buf.timestamp; in pxp_start()
760 if (in_vb->flags & V4L2_BUF_FLAG_TIMECODE) in pxp_start()
761 out_vb->timecode = in_vb->timecode; in pxp_start()
762 out_vb->field = in_vb->field; in pxp_start()
763 out_vb->flags = in_vb->flags & in pxp_start()
771 ctrl = BF_PXP_CTRL_VFLIP0(!!(ctx->mode & MEM2MEM_VFLIP)) | in pxp_start()
772 BF_PXP_CTRL_HFLIP0(!!(ctx->mode & MEM2MEM_HFLIP)); in pxp_start()
774 out_ctrl = BF_PXP_OUT_CTRL_ALPHA(ctx->alpha_component) | in pxp_start()
786 out_buf2 = 0; in pxp_start()
790 out_lrc = BF_PXP_OUT_LRC_X(dst_width - 1) | in pxp_start()
791 BF_PXP_OUT_LRC_Y(dst_height - 1); in pxp_start()
793 out_ps_ulc = BF_PXP_OUT_PS_ULC_X(0) | BF_PXP_OUT_PS_ULC_Y(0); in pxp_start()
794 out_ps_lrc = BF_PXP_OUT_PS_LRC_X(dst_width - 1) | in pxp_start()
795 BF_PXP_OUT_PS_LRC_Y(dst_height - 1); in pxp_start()
798 as_lrc = BF_PXP_OUT_AS_LRC_X(0) | BF_PXP_OUT_AS_LRC_Y(0); in pxp_start()
800 decx = (src_width <= dst_width) ? 0 : ilog2(src_width / dst_width); in pxp_start()
801 decy = (src_height <= dst_height) ? 0 : ilog2(src_height / dst_height); in pxp_start()
820 ps_vbuf = 0; in pxp_start()
824 ps_ubuf = 0; in pxp_start()
826 ps_vbuf = 0x8080; in pxp_start()
829 ps_ubuf = 0; in pxp_start()
830 ps_vbuf = 0; in pxp_start()
835 xscale = (src_width >> decx) * 0x1000 / dst_width; in pxp_start()
852 xscale = (src_width - 2) * 0x1000 / (dst_width - 1); in pxp_start()
855 xscale = (src_width - 1) * 0x1000 / (dst_width - 1); in pxp_start()
860 yscale = (src_height >> decy) * 0x1000 / dst_height; in pxp_start()
862 yscale = (src_height - 1) * 0x1000 / (dst_height - 1); in pxp_start()
865 ps_offset = BF_PXP_PS_OFFSET_YOFFSET(0) | BF_PXP_PS_OFFSET_XOFFSET(0); in pxp_start()
867 writel(ctrl, dev->mmio + HW_PXP_CTRL); in pxp_start()
869 writel(out_ctrl, dev->mmio + HW_PXP_OUT_CTRL); in pxp_start()
870 writel(out_buf, dev->mmio + HW_PXP_OUT_BUF); in pxp_start()
871 writel(out_buf2, dev->mmio + HW_PXP_OUT_BUF2); in pxp_start()
872 writel(out_pitch, dev->mmio + HW_PXP_OUT_PITCH); in pxp_start()
873 writel(out_lrc, dev->mmio + HW_PXP_OUT_LRC); in pxp_start()
874 writel(out_ps_ulc, dev->mmio + HW_PXP_OUT_PS_ULC); in pxp_start()
875 writel(out_ps_lrc, dev->mmio + HW_PXP_OUT_PS_LRC); in pxp_start()
876 writel(as_ulc, dev->mmio + HW_PXP_OUT_AS_ULC); in pxp_start()
877 writel(as_lrc, dev->mmio + HW_PXP_OUT_AS_LRC); in pxp_start()
878 writel(ps_ctrl, dev->mmio + HW_PXP_PS_CTRL); in pxp_start()
879 writel(ps_buf, dev->mmio + HW_PXP_PS_BUF); in pxp_start()
880 writel(ps_ubuf, dev->mmio + HW_PXP_PS_UBUF); in pxp_start()
881 writel(ps_vbuf, dev->mmio + HW_PXP_PS_VBUF); in pxp_start()
882 writel(ps_pitch, dev->mmio + HW_PXP_PS_PITCH); in pxp_start()
883 writel(0x00ffffff, dev->mmio + HW_PXP_PS_BACKGROUND_0); in pxp_start()
884 writel(ps_scale, dev->mmio + HW_PXP_PS_SCALE); in pxp_start()
885 writel(ps_offset, dev->mmio + HW_PXP_PS_OFFSET); in pxp_start()
887 writel(0x00ffffff, dev->mmio + HW_PXP_PS_CLRKEYLOW_0); in pxp_start()
888 writel(0x00000000, dev->mmio + HW_PXP_PS_CLRKEYHIGH_0); in pxp_start()
891 writel(0x00ffffff, dev->mmio + HW_PXP_AS_CLRKEYLOW_0); in pxp_start()
892 writel(0x00000000, dev->mmio + HW_PXP_AS_CLRKEYHIGH_0); in pxp_start()
898 writel(BM_PXP_LUT_CTRL_BYPASS, dev->mmio + HW_PXP_LUT_CTRL); in pxp_start()
900 writel(BF_PXP_DATA_PATH_CTRL0_MUX15_SEL(0)| in pxp_start()
902 BF_PXP_DATA_PATH_CTRL0_MUX13_SEL(0)| in pxp_start()
903 BF_PXP_DATA_PATH_CTRL0_MUX12_SEL(0)| in pxp_start()
904 BF_PXP_DATA_PATH_CTRL0_MUX11_SEL(0)| in pxp_start()
905 BF_PXP_DATA_PATH_CTRL0_MUX10_SEL(0)| in pxp_start()
907 BF_PXP_DATA_PATH_CTRL0_MUX8_SEL(0)| in pxp_start()
908 BF_PXP_DATA_PATH_CTRL0_MUX7_SEL(0)| in pxp_start()
909 BF_PXP_DATA_PATH_CTRL0_MUX6_SEL(0)| in pxp_start()
910 BF_PXP_DATA_PATH_CTRL0_MUX5_SEL(0)| in pxp_start()
911 BF_PXP_DATA_PATH_CTRL0_MUX4_SEL(0)| in pxp_start()
912 BF_PXP_DATA_PATH_CTRL0_MUX3_SEL(0)| in pxp_start()
913 BF_PXP_DATA_PATH_CTRL0_MUX2_SEL(0)| in pxp_start()
914 BF_PXP_DATA_PATH_CTRL0_MUX1_SEL(0)| in pxp_start()
915 BF_PXP_DATA_PATH_CTRL0_MUX0_SEL(0), in pxp_start()
916 dev->mmio + HW_PXP_DATA_PATH_CTRL0); in pxp_start()
919 dev->mmio + HW_PXP_DATA_PATH_CTRL1); in pxp_start()
921 writel(0xffff, dev->mmio + HW_PXP_IRQ_MASK); in pxp_start()
924 writel(BM_PXP_CTRL_IRQ_ENABLE, dev->mmio + HW_PXP_CTRL_SET); in pxp_start()
927 BM_PXP_CTRL_ENABLE_PS_AS_OUT, dev->mmio + HW_PXP_CTRL_SET); in pxp_start()
929 return 0; in pxp_start()
938 curr_ctx = v4l2_m2m_get_curr_priv(dev->m2m_dev); in pxp_job_finish()
945 src_vb = v4l2_m2m_src_buf_remove(curr_ctx->fh.m2m_ctx); in pxp_job_finish()
946 dst_vb = v4l2_m2m_dst_buf_remove(curr_ctx->fh.m2m_ctx); in pxp_job_finish()
948 spin_lock_irqsave(&dev->irqlock, flags); in pxp_job_finish()
951 spin_unlock_irqrestore(&dev->irqlock, flags); in pxp_job_finish()
953 dprintk(curr_ctx->dev, "Finishing transaction\n"); in pxp_job_finish()
954 v4l2_m2m_job_finish(dev->m2m_dev, curr_ctx->fh.m2m_ctx); in pxp_job_finish()
965 src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); in pxp_device_run()
966 dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); in pxp_device_run()
975 if (v4l2_m2m_num_src_bufs_ready(ctx->fh.m2m_ctx) < 1 || in pxp_job_ready()
976 v4l2_m2m_num_dst_bufs_ready(ctx->fh.m2m_ctx) < 1) { in pxp_job_ready()
977 dprintk(ctx->dev, "Not enough buffers available\n"); in pxp_job_ready()
978 return 0; in pxp_job_ready()
989 ctx->aborting = 1; in pxp_job_abort()
1000 stat = readl(dev->mmio + HW_PXP_STAT); in pxp_irq_handler()
1003 /* we expect x = 0, y = height, irq0 = 1 */ in pxp_irq_handler()
1006 dprintk(dev, "%s: stat = 0x%08x\n", __func__, stat); in pxp_irq_handler()
1007 writel(BM_PXP_STAT_IRQ0, dev->mmio + HW_PXP_STAT_CLR); in pxp_irq_handler()
1011 u32 irq = readl(dev->mmio + HW_PXP_IRQ); in pxp_irq_handler()
1013 dprintk(dev, "%s: stat = 0x%08x\n", __func__, stat); in pxp_irq_handler()
1014 dprintk(dev, "%s: irq = 0x%08x\n", __func__, irq); in pxp_irq_handler()
1016 writel(irq, dev->mmio + HW_PXP_IRQ_CLR); in pxp_irq_handler()
1028 strscpy(cap->driver, MEM2MEM_NAME, sizeof(cap->driver)); in pxp_querycap()
1029 strscpy(cap->card, MEM2MEM_NAME, sizeof(cap->card)); in pxp_querycap()
1030 snprintf(cap->bus_info, sizeof(cap->bus_info), in pxp_querycap()
1032 return 0; in pxp_querycap()
1040 num = 0; in pxp_enum_fmt()
1042 for (i = 0; i < NUM_FORMATS; ++i) { in pxp_enum_fmt()
1044 /* index-th format of type type found ? */ in pxp_enum_fmt()
1045 if (num == f->index) in pxp_enum_fmt()
1049 * just increment per-type index in pxp_enum_fmt()
1058 f->pixelformat = fmt->fourcc; in pxp_enum_fmt()
1059 return 0; in pxp_enum_fmt()
1063 return -EINVAL; in pxp_enum_fmt()
1083 vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type); in pxp_g_fmt()
1085 return -EINVAL; in pxp_g_fmt()
1087 q_data = get_q_data(ctx, f->type); in pxp_g_fmt()
1089 f->fmt.pix.width = q_data->width; in pxp_g_fmt()
1090 f->fmt.pix.height = q_data->height; in pxp_g_fmt()
1091 f->fmt.pix.field = V4L2_FIELD_NONE; in pxp_g_fmt()
1092 f->fmt.pix.pixelformat = q_data->fmt->fourcc; in pxp_g_fmt()
1093 f->fmt.pix.bytesperline = q_data->bytesperline; in pxp_g_fmt()
1094 f->fmt.pix.sizeimage = q_data->sizeimage; in pxp_g_fmt()
1095 f->fmt.pix.colorspace = ctx->colorspace; in pxp_g_fmt()
1096 f->fmt.pix.xfer_func = ctx->xfer_func; in pxp_g_fmt()
1097 f->fmt.pix.ycbcr_enc = q_data->ycbcr_enc; in pxp_g_fmt()
1098 f->fmt.pix.quantization = q_data->quant; in pxp_g_fmt()
1100 return 0; in pxp_g_fmt()
1117 switch (fmt->fourcc) { in pxp_bytesperline()
1126 return (width * fmt->depth) >> 3; in pxp_bytesperline()
1132 return (fmt->depth * width * height) >> 3; in pxp_sizeimage()
1137 v4l_bound_align_image(&f->fmt.pix.width, MIN_W, MAX_W, ALIGN_W, in pxp_try_fmt()
1138 &f->fmt.pix.height, MIN_H, MAX_H, ALIGN_H, 0); in pxp_try_fmt()
1140 f->fmt.pix.bytesperline = pxp_bytesperline(fmt, f->fmt.pix.width); in pxp_try_fmt()
1141 f->fmt.pix.sizeimage = pxp_sizeimage(fmt, f->fmt.pix.width, in pxp_try_fmt()
1142 f->fmt.pix.height); in pxp_try_fmt()
1143 f->fmt.pix.field = V4L2_FIELD_NONE; in pxp_try_fmt()
1145 return 0; in pxp_try_fmt()
1155 if (pxp_v4l2_pix_fmt_is_yuv(ctx->q_data[V4L2_M2M_SRC].fmt->fourcc) == in pxp_fixup_colorimetry_cap()
1161 *ycbcr_enc = ctx->q_data[V4L2_M2M_SRC].ycbcr_enc; in pxp_fixup_colorimetry_cap()
1162 *quantization = ctx->q_data[V4L2_M2M_SRC].quant; in pxp_fixup_colorimetry_cap()
1164 *ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(ctx->colorspace); in pxp_fixup_colorimetry_cap()
1166 ctx->colorspace, in pxp_fixup_colorimetry_cap()
1179 f->fmt.pix.pixelformat = formats[0].fourcc; in pxp_try_fmt_vid_cap()
1182 if (!(fmt->types & MEM2MEM_CAPTURE)) { in pxp_try_fmt_vid_cap()
1183 v4l2_err(&ctx->dev->v4l2_dev, in pxp_try_fmt_vid_cap()
1184 "Fourcc format (0x%08x) invalid.\n", in pxp_try_fmt_vid_cap()
1185 f->fmt.pix.pixelformat); in pxp_try_fmt_vid_cap()
1186 return -EINVAL; in pxp_try_fmt_vid_cap()
1189 f->fmt.pix.colorspace = ctx->colorspace; in pxp_try_fmt_vid_cap()
1190 f->fmt.pix.xfer_func = ctx->xfer_func; in pxp_try_fmt_vid_cap()
1192 pxp_fixup_colorimetry_cap(ctx, fmt->fourcc, in pxp_try_fmt_vid_cap()
1193 &f->fmt.pix.ycbcr_enc, in pxp_try_fmt_vid_cap()
1194 &f->fmt.pix.quantization); in pxp_try_fmt_vid_cap()
1207 f->fmt.pix.pixelformat = formats[0].fourcc; in pxp_try_fmt_vid_out()
1210 if (!(fmt->types & MEM2MEM_OUTPUT)) { in pxp_try_fmt_vid_out()
1211 v4l2_err(&ctx->dev->v4l2_dev, in pxp_try_fmt_vid_out()
1212 "Fourcc format (0x%08x) invalid.\n", in pxp_try_fmt_vid_out()
1213 f->fmt.pix.pixelformat); in pxp_try_fmt_vid_out()
1214 return -EINVAL; in pxp_try_fmt_vid_out()
1217 if (!f->fmt.pix.colorspace) in pxp_try_fmt_vid_out()
1218 f->fmt.pix.colorspace = V4L2_COLORSPACE_REC709; in pxp_try_fmt_vid_out()
1228 vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type); in pxp_s_fmt()
1230 return -EINVAL; in pxp_s_fmt()
1232 q_data = get_q_data(ctx, f->type); in pxp_s_fmt()
1234 return -EINVAL; in pxp_s_fmt()
1237 v4l2_err(&ctx->dev->v4l2_dev, "%s queue busy\n", __func__); in pxp_s_fmt()
1238 return -EBUSY; in pxp_s_fmt()
1241 q_data->fmt = find_format(f); in pxp_s_fmt()
1242 q_data->width = f->fmt.pix.width; in pxp_s_fmt()
1243 q_data->height = f->fmt.pix.height; in pxp_s_fmt()
1244 q_data->bytesperline = f->fmt.pix.bytesperline; in pxp_s_fmt()
1245 q_data->sizeimage = f->fmt.pix.sizeimage; in pxp_s_fmt()
1247 dprintk(ctx->dev, in pxp_s_fmt()
1249 f->type, q_data->width, q_data->height, q_data->fmt->fourcc); in pxp_s_fmt()
1251 return 0; in pxp_s_fmt()
1268 ctx->q_data[V4L2_M2M_DST].ycbcr_enc = f->fmt.pix.ycbcr_enc; in pxp_s_fmt_vid_cap()
1269 ctx->q_data[V4L2_M2M_DST].quant = f->fmt.pix.quantization; in pxp_s_fmt_vid_cap()
1271 return 0; in pxp_s_fmt_vid_cap()
1288 ctx->colorspace = f->fmt.pix.colorspace; in pxp_s_fmt_vid_out()
1289 ctx->xfer_func = f->fmt.pix.xfer_func; in pxp_s_fmt_vid_out()
1290 ctx->q_data[V4L2_M2M_SRC].ycbcr_enc = f->fmt.pix.ycbcr_enc; in pxp_s_fmt_vid_out()
1291 ctx->q_data[V4L2_M2M_SRC].quant = f->fmt.pix.quantization; in pxp_s_fmt_vid_out()
1293 pxp_fixup_colorimetry_cap(ctx, ctx->q_data[V4L2_M2M_DST].fmt->fourcc, in pxp_s_fmt_vid_out()
1294 &ctx->q_data[V4L2_M2M_DST].ycbcr_enc, in pxp_s_fmt_vid_out()
1295 &ctx->q_data[V4L2_M2M_DST].quant); in pxp_s_fmt_vid_out()
1297 return 0; in pxp_s_fmt_vid_out()
1303 container_of(ctrl->handler, struct pxp_ctx, hdl); in pxp_s_ctrl()
1305 switch (ctrl->id) { in pxp_s_ctrl()
1307 if (ctrl->val) in pxp_s_ctrl()
1308 ctx->mode |= MEM2MEM_HFLIP; in pxp_s_ctrl()
1310 ctx->mode &= ~MEM2MEM_HFLIP; in pxp_s_ctrl()
1314 if (ctrl->val) in pxp_s_ctrl()
1315 ctx->mode |= MEM2MEM_VFLIP; in pxp_s_ctrl()
1317 ctx->mode &= ~MEM2MEM_VFLIP; in pxp_s_ctrl()
1321 ctx->alpha_component = ctrl->val; in pxp_s_ctrl()
1325 v4l2_err(&ctx->dev->v4l2_dev, "Invalid control\n"); in pxp_s_ctrl()
1326 return -EINVAL; in pxp_s_ctrl()
1329 return 0; in pxp_s_ctrl()
1375 q_data = get_q_data(ctx, vq->type); in pxp_queue_setup()
1377 size = q_data->sizeimage; in pxp_queue_setup()
1382 return sizes[0] < size ? -EINVAL : 0; in pxp_queue_setup()
1385 sizes[0] = size; in pxp_queue_setup()
1387 dprintk(ctx->dev, "get %d buffer(s) of size %d each.\n", count, size); in pxp_queue_setup()
1389 return 0; in pxp_queue_setup()
1395 struct pxp_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); in pxp_buf_prepare()
1396 struct pxp_dev *dev = ctx->dev; in pxp_buf_prepare()
1399 dprintk(ctx->dev, "type: %d\n", vb->vb2_queue->type); in pxp_buf_prepare()
1401 q_data = get_q_data(ctx, vb->vb2_queue->type); in pxp_buf_prepare()
1402 if (V4L2_TYPE_IS_OUTPUT(vb->vb2_queue->type)) { in pxp_buf_prepare()
1403 if (vbuf->field == V4L2_FIELD_ANY) in pxp_buf_prepare()
1404 vbuf->field = V4L2_FIELD_NONE; in pxp_buf_prepare()
1405 if (vbuf->field != V4L2_FIELD_NONE) { in pxp_buf_prepare()
1407 return -EINVAL; in pxp_buf_prepare()
1411 if (vb2_plane_size(vb, 0) < q_data->sizeimage) { in pxp_buf_prepare()
1413 __func__, vb2_plane_size(vb, 0), in pxp_buf_prepare()
1414 (long)q_data->sizeimage); in pxp_buf_prepare()
1415 return -EINVAL; in pxp_buf_prepare()
1418 vb2_set_plane_payload(vb, 0, q_data->sizeimage); in pxp_buf_prepare()
1420 return 0; in pxp_buf_prepare()
1426 struct pxp_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); in pxp_buf_queue()
1428 v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vbuf); in pxp_buf_queue()
1434 struct pxp_q_data *q_data = get_q_data(ctx, q->type); in pxp_start_streaming()
1436 q_data->sequence = 0; in pxp_start_streaming()
1437 return 0; in pxp_start_streaming()
1447 if (V4L2_TYPE_IS_OUTPUT(q->type)) in pxp_stop_streaming()
1448 vbuf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); in pxp_stop_streaming()
1450 vbuf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); in pxp_stop_streaming()
1453 spin_lock_irqsave(&ctx->dev->irqlock, flags); in pxp_stop_streaming()
1455 spin_unlock_irqrestore(&ctx->dev->irqlock, flags); in pxp_stop_streaming()
1475 src_vq->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; in queue_init()
1476 src_vq->io_modes = VB2_MMAP | VB2_DMABUF; in queue_init()
1477 src_vq->drv_priv = ctx; in queue_init()
1478 src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); in queue_init()
1479 src_vq->ops = &pxp_qops; in queue_init()
1480 src_vq->mem_ops = &vb2_dma_contig_memops; in queue_init()
1481 src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; in queue_init()
1482 src_vq->lock = &ctx->dev->dev_mutex; in queue_init()
1483 src_vq->dev = ctx->dev->v4l2_dev.dev; in queue_init()
1489 dst_vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; in queue_init()
1490 dst_vq->io_modes = VB2_MMAP | VB2_DMABUF; in queue_init()
1491 dst_vq->drv_priv = ctx; in queue_init()
1492 dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); in queue_init()
1493 dst_vq->ops = &pxp_qops; in queue_init()
1494 dst_vq->mem_ops = &vb2_dma_contig_memops; in queue_init()
1495 dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; in queue_init()
1496 dst_vq->lock = &ctx->dev->dev_mutex; in queue_init()
1497 dst_vq->dev = ctx->dev->v4l2_dev.dev; in queue_init()
1510 int rc = 0; in pxp_open()
1512 if (mutex_lock_interruptible(&dev->dev_mutex)) in pxp_open()
1513 return -ERESTARTSYS; in pxp_open()
1516 rc = -ENOMEM; in pxp_open()
1520 v4l2_fh_init(&ctx->fh, video_devdata(file)); in pxp_open()
1521 file->private_data = &ctx->fh; in pxp_open()
1522 ctx->dev = dev; in pxp_open()
1523 hdl = &ctx->hdl; in pxp_open()
1525 v4l2_ctrl_new_std(hdl, &pxp_ctrl_ops, V4L2_CID_HFLIP, 0, 1, 1, 0); in pxp_open()
1526 v4l2_ctrl_new_std(hdl, &pxp_ctrl_ops, V4L2_CID_VFLIP, 0, 1, 1, 0); in pxp_open()
1528 0, 255, 1, 255); in pxp_open()
1529 if (hdl->error) { in pxp_open()
1530 rc = hdl->error; in pxp_open()
1535 ctx->fh.ctrl_handler = hdl; in pxp_open()
1538 ctx->q_data[V4L2_M2M_SRC].fmt = &formats[0]; in pxp_open()
1539 ctx->q_data[V4L2_M2M_SRC].width = 640; in pxp_open()
1540 ctx->q_data[V4L2_M2M_SRC].height = 480; in pxp_open()
1541 ctx->q_data[V4L2_M2M_SRC].bytesperline = in pxp_open()
1542 pxp_bytesperline(&formats[0], 640); in pxp_open()
1543 ctx->q_data[V4L2_M2M_SRC].sizeimage = in pxp_open()
1544 pxp_sizeimage(&formats[0], 640, 480); in pxp_open()
1545 ctx->q_data[V4L2_M2M_DST] = ctx->q_data[V4L2_M2M_SRC]; in pxp_open()
1546 ctx->colorspace = V4L2_COLORSPACE_REC709; in pxp_open()
1548 ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, ctx, &queue_init); in pxp_open()
1550 if (IS_ERR(ctx->fh.m2m_ctx)) { in pxp_open()
1551 rc = PTR_ERR(ctx->fh.m2m_ctx); in pxp_open()
1554 v4l2_fh_exit(&ctx->fh); in pxp_open()
1559 v4l2_fh_add(&ctx->fh); in pxp_open()
1560 atomic_inc(&dev->num_inst); in pxp_open()
1563 ctx, ctx->fh.m2m_ctx); in pxp_open()
1566 mutex_unlock(&dev->dev_mutex); in pxp_open()
1577 v4l2_fh_del(&ctx->fh); in pxp_release()
1578 v4l2_fh_exit(&ctx->fh); in pxp_release()
1579 v4l2_ctrl_handler_free(&ctx->hdl); in pxp_release()
1580 mutex_lock(&dev->dev_mutex); in pxp_release()
1581 v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); in pxp_release()
1582 mutex_unlock(&dev->dev_mutex); in pxp_release()
1585 atomic_dec(&dev->num_inst); in pxp_release()
1587 return 0; in pxp_release()
1605 .minor = -1,
1620 writel(BM_PXP_CTRL_SFTRST, dev->mmio + HW_PXP_CTRL_CLR); in pxp_soft_reset()
1621 writel(BM_PXP_CTRL_CLKGATE, dev->mmio + HW_PXP_CTRL_CLR); in pxp_soft_reset()
1623 writel(BM_PXP_CTRL_SFTRST, dev->mmio + HW_PXP_CTRL_SET); in pxp_soft_reset()
1625 ret = readl_poll_timeout(dev->mmio + HW_PXP_CTRL, val, in pxp_soft_reset()
1626 val & BM_PXP_CTRL_CLKGATE, 0, 100); in pxp_soft_reset()
1627 if (ret < 0) in pxp_soft_reset()
1630 writel(BM_PXP_CTRL_SFTRST, dev->mmio + HW_PXP_CTRL_CLR); in pxp_soft_reset()
1631 writel(BM_PXP_CTRL_CLKGATE, dev->mmio + HW_PXP_CTRL_CLR); in pxp_soft_reset()
1633 return 0; in pxp_soft_reset()
1644 dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); in pxp_probe()
1646 return -ENOMEM; in pxp_probe()
1648 dev->clk = devm_clk_get(&pdev->dev, "axi"); in pxp_probe()
1649 if (IS_ERR(dev->clk)) { in pxp_probe()
1650 ret = PTR_ERR(dev->clk); in pxp_probe()
1651 dev_err(&pdev->dev, "Failed to get clk: %d\n", ret); in pxp_probe()
1655 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); in pxp_probe()
1656 dev->mmio = devm_ioremap_resource(&pdev->dev, res); in pxp_probe()
1657 if (IS_ERR(dev->mmio)) { in pxp_probe()
1658 ret = PTR_ERR(dev->mmio); in pxp_probe()
1659 dev_err(&pdev->dev, "Failed to map register space: %d\n", ret); in pxp_probe()
1663 irq = platform_get_irq(pdev, 0); in pxp_probe()
1664 if (irq < 0) in pxp_probe()
1667 spin_lock_init(&dev->irqlock); in pxp_probe()
1669 ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, pxp_irq_handler, in pxp_probe()
1670 IRQF_ONESHOT, dev_name(&pdev->dev), dev); in pxp_probe()
1671 if (ret < 0) { in pxp_probe()
1672 dev_err(&pdev->dev, "Failed to request irq: %d\n", ret); in pxp_probe()
1676 ret = clk_prepare_enable(dev->clk); in pxp_probe()
1677 if (ret < 0) in pxp_probe()
1681 if (ret < 0) { in pxp_probe()
1682 dev_err(&pdev->dev, "PXP reset timeout: %d\n", ret); in pxp_probe()
1686 ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev); in pxp_probe()
1690 atomic_set(&dev->num_inst, 0); in pxp_probe()
1691 mutex_init(&dev->dev_mutex); in pxp_probe()
1693 dev->vfd = pxp_videodev; in pxp_probe()
1694 vfd = &dev->vfd; in pxp_probe()
1695 vfd->lock = &dev->dev_mutex; in pxp_probe()
1696 vfd->v4l2_dev = &dev->v4l2_dev; in pxp_probe()
1699 snprintf(vfd->name, sizeof(vfd->name), "%s", pxp_videodev.name); in pxp_probe()
1700 v4l2_info(&dev->v4l2_dev, in pxp_probe()
1701 "Device registered as /dev/video%d\n", vfd->num); in pxp_probe()
1705 dev->m2m_dev = v4l2_m2m_init(&m2m_ops); in pxp_probe()
1706 if (IS_ERR(dev->m2m_dev)) { in pxp_probe()
1707 v4l2_err(&dev->v4l2_dev, "Failed to init mem2mem device\n"); in pxp_probe()
1708 ret = PTR_ERR(dev->m2m_dev); in pxp_probe()
1712 ret = video_register_device(vfd, VFL_TYPE_VIDEO, 0); in pxp_probe()
1714 v4l2_err(&dev->v4l2_dev, "Failed to register video device\n"); in pxp_probe()
1718 return 0; in pxp_probe()
1721 v4l2_m2m_release(dev->m2m_dev); in pxp_probe()
1723 v4l2_device_unregister(&dev->v4l2_dev); in pxp_probe()
1725 clk_disable_unprepare(dev->clk); in pxp_probe()
1734 writel(BM_PXP_CTRL_CLKGATE, dev->mmio + HW_PXP_CTRL_SET); in pxp_remove()
1735 writel(BM_PXP_CTRL_SFTRST, dev->mmio + HW_PXP_CTRL_SET); in pxp_remove()
1737 clk_disable_unprepare(dev->clk); in pxp_remove()
1739 v4l2_info(&dev->v4l2_dev, "Removing " MEM2MEM_NAME); in pxp_remove()
1740 video_unregister_device(&dev->vfd); in pxp_remove()
1741 v4l2_m2m_release(dev->m2m_dev); in pxp_remove()
1742 v4l2_device_unregister(&dev->v4l2_dev); in pxp_remove()
1744 return 0; in pxp_remove()
1748 { .compatible = "fsl,imx6ull-pxp", .data = NULL },