Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/sunxi Add support for video layer scaling and c...



details:   https://anonhg.NetBSD.org/src/rev/319af1ec3a2c
branches:  trunk
changeset: 448536:319af1ec3a2c
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Tue Feb 05 00:21:35 2019 +0000

description:
Add support for video layer scaling and colour space conversion.

diffstat:

 sys/arch/arm/sunxi/sunxi_mixer.c |  523 ++++++++++++++++++++++++++++++++++++++-
 1 files changed, 511 insertions(+), 12 deletions(-)

diffs (truncated from 614 to 300 lines):

diff -r 6d76af687069 -r 319af1ec3a2c sys/arch/arm/sunxi/sunxi_mixer.c
--- a/sys/arch/arm/sunxi/sunxi_mixer.c  Mon Feb 04 22:07:41 2019 +0000
+++ b/sys/arch/arm/sunxi/sunxi_mixer.c  Tue Feb 05 00:21:35 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_mixer.c,v 1.3 2019/02/04 12:10:13 jmcneill Exp $ */
+/* $NetBSD: sunxi_mixer.c,v 1.4 2019/02/05 00:21:35 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunxi_mixer.c,v 1.3 2019/02/04 12:10:13 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_mixer.c,v 1.4 2019/02/05 00:21:35 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -54,6 +54,8 @@
 #define        OVL_BASE(n)             (0x02000 + (n) * 0x1000)
 #define        OVL_V_BASE              OVL_BASE(0)
 #define        OVL_UI_BASE             OVL_BASE(1)
+#define        VSU_BASE                0x20000
+#define        CSC_BASE(n)             ((n) == 0 ? 0xaa050 : 0xa0000)
 
 /* GLB registers */
 #define        GLB_CTL                 0x000
@@ -120,6 +122,38 @@
 #define         OVL_UI_TOP_HADD_LAYER0 __BITS(7,0)
 #define        OVL_UI_SIZE             0x088
 
+/* VSU registers */
+#define        VS_CTRL_REG             0x000
+#define         VS_CTRL_COEF_SWITCH_EN                 __BIT(4)
+#define         VS_CTRL_EN                             __BIT(0)
+#define        VS_STATUS_REG           0x008
+#define        VS_FIELD_CTRL_REG       0x00c
+#define        VS_OUT_SIZE_REG         0x040
+#define        VS_Y_SIZE_REG           0x080
+#define        VS_Y_HSTEP_REG          0x088
+#define        VS_Y_VSTEP_REG          0x08c
+#define        VS_Y_HPHASE_REG         0x090
+#define        VS_Y_VPHASE0_REG        0x098
+#define        VS_Y_VPHASE1_REG        0x09c
+#define        VS_C_SIZE_REG           0x0c0
+#define        VS_C_HSTEP_REG          0x0c8
+#define        VS_C_VSTEP_REG          0x0cc
+#define        VS_C_HPHASE_REG         0x0d0
+#define        VS_C_VPHASE0_REG        0x0d8
+#define        VS_C_VPHASE1_REG        0x0dc
+#define        VS_Y_HCOEF0_REG(n)      (0x200 + (n) * 0x4)
+#define        VS_Y_HCOEF1_REG(n)      (0x300 + (n) * 0x4)
+#define        VS_Y_VCOEF_REG(n)       (0x400 + (n) * 0x4)
+#define        VS_C_HCOEF0_REG(n)      (0x600 + (n) * 0x4)
+#define        VS_C_HCOEF1_REG(n)      (0x700 + (n) * 0x4)
+#define        VS_C_VCOEF_REG(n)       (0x800 + (n) * 0x4)
+
+/* CSC registers */
+#define        CSC_BYPASS_REG          0x000
+#define         CSC_BYPASS_DISABLE                     __BIT(0)
+#define        CSC_COEFF0_REG(n)       (0x10 + 0x10 * (n))
+#define        GLB_ALPHA_REG           0x040
+
 enum {
        MIXER_PORT_OUTPUT = 1,
 };
@@ -175,6 +209,16 @@
 #define        OVL_UI_WRITE(sc, reg, val)                      \
        bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, OVL_UI_BASE + (reg), (val))
 
+#define        VSU_READ(sc, reg)                               \
+       bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, VSU_BASE + (reg))
+#define        VSU_WRITE(sc, reg, val)                 \
+       bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, VSU_BASE + (reg), (val))
+
+#define        CSC_READ(sc, n, reg)                            \
+       bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, CSC_BASE(n) + (reg))
+#define        CSC_WRITE(sc, n, reg, val)                      \
+       bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, CSC_BASE(n) + (reg), (val))
+
 #define        to_sunxi_mixer_crtc(x)          container_of(x, struct sunxi_mixer_crtc, base)
 #define        to_sunxi_mixer_overlay(x)       container_of(x, struct sunxi_mixer_overlay, base)
 
@@ -346,7 +390,7 @@
 }
 
 static bool
-sunxi_mixer_overlay_ui(uint32_t drm_format)
+sunxi_mixer_overlay_rgb(uint32_t drm_format)
 {
        switch (drm_format) {
        case DRM_FORMAT_XRGB8888:
@@ -372,6 +416,448 @@
        }
 }
 
+static const uint32_t lan3coefftab32_left[512] = {
+       0x40000000, 0x40fe0000, 0x3ffd0100, 0x3efc0100,
+       0x3efb0100, 0x3dfa0200, 0x3cf90200, 0x3bf80200,
+       0x39f70200, 0x37f70200, 0x35f70200, 0x33f70200,
+       0x31f70200, 0x2ef70200, 0x2cf70200, 0x2af70200,
+       0x27f70200, 0x24f80100, 0x22f80100, 0x1ef90100,
+       0x1cf90100, 0x19fa0100, 0x17fa0100, 0x14fb0100,
+       0x11fc0000, 0x0ffc0000, 0x0cfd0000, 0x0afd0000,
+       0x08fe0000, 0x05ff0000, 0x03ff0000, 0x02000000,
+
+       0x40000000, 0x40fe0000, 0x3ffd0100, 0x3efc0100,
+       0x3efb0100, 0x3dfa0200, 0x3cf90200, 0x3bf80200,
+       0x39f70200, 0x37f70200, 0x35f70200, 0x33f70200,
+       0x31f70200, 0x2ef70200, 0x2cf70200, 0x2af70200,
+       0x27f70200, 0x24f80100, 0x22f80100, 0x1ef90100,
+       0x1cf90100, 0x19fa0100, 0x17fa0100, 0x14fb0100,
+       0x11fc0000, 0x0ffc0000, 0x0cfd0000, 0x0afd0000,
+       0x08fe0000, 0x05ff0000, 0x03ff0000, 0x02000000,
+
+       0x3806fc02, 0x3805fc02, 0x3803fd01, 0x3801fe01,
+       0x3700fe01, 0x35ffff01, 0x35fdff01, 0x34fc0001,
+       0x34fb0000, 0x33fa0000, 0x31fa0100, 0x2ff90100,
+       0x2df80200, 0x2bf80200, 0x2af70200, 0x28f70200,
+       0x27f70200, 0x24f70300, 0x22f70300, 0x1ff70300,
+       0x1ef70300, 0x1cf70300, 0x1af70300, 0x18f70300,
+       0x16f80300, 0x13f80300, 0x11f90300, 0x0ef90300,
+       0x0efa0200, 0x0cfa0200, 0x0afb0200, 0x08fb0200,
+
+       0x320bfa02, 0x3309fa02, 0x3208fb02, 0x3206fb02,
+       0x3205fb02, 0x3104fc02, 0x3102fc01, 0x3001fd01,
+       0x3000fd01, 0x2ffffd01, 0x2efefe01, 0x2dfdfe01,
+       0x2bfcff01, 0x29fcff01, 0x28fbff01, 0x27fa0001,
+       0x26fa0000, 0x24f90000, 0x22f90100, 0x20f90100,
+       0x1ff80100, 0x1ef80100, 0x1cf80100, 0x1af80200,
+       0x18f80200, 0x17f80200, 0x15f80200, 0x12f80200,
+       0x11f90200, 0x0ff90200, 0x0df90200, 0x0cfa0200,
+
+       0x2e0efa01, 0x2f0dfa01, 0x2f0bfa01, 0x2e0afa01,
+       0x2e09fa01, 0x2e07fb01, 0x2d06fb01, 0x2d05fb01,
+       0x2c04fb01, 0x2b03fc01, 0x2a02fc01, 0x2a01fc01,
+       0x2800fd01, 0x28fffd01, 0x26fefd01, 0x25fefe01,
+       0x24fdfe01, 0x23fcfe01, 0x21fcff01, 0x20fbff01,
+       0x1efbff01, 0x1efbff00, 0x1cfa0000, 0x1bfa0000,
+       0x19fa0000, 0x18fa0000, 0x17f90000, 0x15f90100,
+       0x14f90100, 0x12f90100, 0x11f90100, 0x0ff90100,
+
+       0x2b10fa00, 0x2b0ffa00, 0x2b0efa00, 0x2b0cfa00,
+       0x2b0bfa00, 0x2a0afb01, 0x2a09fb01, 0x2908fb01,
+       0x2807fb01, 0x2806fb01, 0x2805fb01, 0x2604fc01,
+       0x2503fc01, 0x2502fc01, 0x2401fc01, 0x2301fc01,
+       0x2100fd01, 0x21fffd01, 0x21fffd01, 0x20fefd01,
+       0x1dfefe01, 0x1cfdfe01, 0x1cfdfe00, 0x1bfcfe00,
+       0x19fcff00, 0x19fbff00, 0x17fbff00, 0x16fbff00,
+       0x15fbff00, 0x14fb0000, 0x13fa0000, 0x11fa0000,
+
+       0x2811fcff, 0x2810fcff, 0x280ffbff, 0x280efbff,
+       0x270dfb00, 0x270cfb00, 0x270bfb00, 0x260afb00,
+       0x2609fb00, 0x2508fb00, 0x2507fb00, 0x2407fb00,
+       0x2406fc00, 0x2305fc00, 0x2204fc00, 0x2203fc00,
+       0x2103fc00, 0x2002fc00, 0x1f01fd00, 0x1e01fd00,
+       0x1d00fd00, 0x1dfffd00, 0x1cfffd00, 0x1bfefd00,
+       0x1afefe00, 0x19fefe00, 0x18fdfe00, 0x17fdfe00,
+       0x16fdfe00, 0x15fcff00, 0x13fcff00, 0x12fcff00,
+
+       0x2512fdfe, 0x2511fdff, 0x2410fdff, 0x240ffdff,
+       0x240efcff, 0x240dfcff, 0x240dfcff, 0x240cfcff,
+       0x230bfcff, 0x230afc00, 0x2209fc00, 0x2108fc00,
+       0x2108fc00, 0x2007fc00, 0x2006fc00, 0x2005fc00,
+       0x1f05fc00, 0x1e04fc00, 0x1e03fc00, 0x1c03fd00,
+       0x1c02fd00, 0x1b02fd00, 0x1b01fd00, 0x1a00fd00,
+       0x1900fd00, 0x1800fd00, 0x17fffe00, 0x16fffe00,
+       0x16fefe00, 0x14fefe00, 0x13fefe00, 0x13fdfe00,
+
+       0x2212fffe, 0x2211fefe, 0x2211fefe, 0x2110fefe,
+       0x210ffeff, 0x220efdff, 0x210dfdff, 0x210dfdff,
+       0x210cfdff, 0x210bfdff, 0x200afdff, 0x200afdff,
+       0x1f09fdff, 0x1f08fdff, 0x1d08fd00, 0x1c07fd00,
+       0x1d06fd00, 0x1b06fd00, 0x1b05fd00, 0x1c04fd00,
+       0x1b04fd00, 0x1a03fd00, 0x1a03fd00, 0x1902fd00,
+       0x1802fd00, 0x1801fd00, 0x1701fd00, 0x1600fd00,
+       0x1400fe00, 0x1400fe00, 0x14fffe00, 0x13fffe00,
+
+       0x201200fe, 0x201100fe, 0x1f11fffe, 0x2010fffe,
+       0x1f0ffffe, 0x1e0ffffe, 0x1f0efeff, 0x1f0dfeff,
+       0x1f0dfeff, 0x1e0cfeff, 0x1e0bfeff, 0x1d0bfeff,
+       0x1d0afeff, 0x1d09fdff, 0x1d09fdff, 0x1c08fdff,
+       0x1c07fdff, 0x1b07fd00, 0x1b06fd00, 0x1a06fd00,
+       0x1a05fd00, 0x1805fd00, 0x1904fd00, 0x1804fd00,
+       0x1703fd00, 0x1703fd00, 0x1602fe00, 0x1502fe00,
+       0x1501fe00, 0x1401fe00, 0x1301fe00, 0x1300fe00,
+
+       0x1c1202fe, 0x1c1102fe, 0x1b1102fe, 0x1c1001fe,
+       0x1b1001fe, 0x1b0f01ff, 0x1b0e00ff, 0x1b0e00ff,
+       0x1b0d00ff, 0x1a0d00ff, 0x1a0c00ff, 0x1a0cffff,
+       0x1a0bffff, 0x1a0bffff, 0x1a0affff, 0x180affff,
+       0x1909ffff, 0x1809ffff, 0x1808ffff, 0x1808feff,
+       0x1807feff, 0x1707fe00, 0x1606fe00, 0x1506fe00,
+       0x1605fe00, 0x1505fe00, 0x1504fe00, 0x1304fe00,
+       0x1304fe00, 0x1303fe00, 0x1203fe00, 0x1203fe00,
+
+       0x181104ff, 0x191103ff, 0x191003ff, 0x181003ff,
+       0x180f03ff, 0x190f02ff, 0x190e02ff, 0x180e02ff,
+       0x180d02ff, 0x180d01ff, 0x180d01ff, 0x180c01ff,
+       0x180c01ff, 0x180b00ff, 0x170b00ff, 0x170a00ff,
+       0x170a00ff, 0x170900ff, 0x160900ff, 0x160900ff,
+       0x1608ffff, 0x1508ffff, 0x1507ff00, 0x1507ff00,
+       0x1407ff00, 0x1306ff00, 0x1306ff00, 0x1305ff00,
+       0x1205ff00, 0x1105ff00, 0x1204ff00, 0x1104ff00,
+
+       0x171005ff, 0x171005ff, 0x171004ff, 0x170f04ff,
+       0x160f04ff, 0x170f03ff, 0x170e03ff, 0x160e03ff,
+       0x160d03ff, 0x160d02ff, 0x160d02ff, 0x160c02ff,
+       0x160c02ff, 0x160c02ff, 0x160b01ff, 0x150b01ff,
+       0x150a01ff, 0x150a01ff, 0x150a01ff, 0x140901ff,
+       0x14090000, 0x14090000, 0x14080000, 0x13080000,
+       0x13070000, 0x12070000, 0x12070000, 0x12060000,
+       0x11060000, 0x11060000, 0x11050000, 0x1105ff00,
+
+       0x14100600, 0x15100500, 0x150f0500, 0x150f0500,
+       0x140f0500, 0x150e0400, 0x140e0400, 0x130e0400,
+       0x140d0400, 0x150d0300, 0x130d0300, 0x140c0300,
+       0x140c0300, 0x140c0200, 0x140b0200, 0x130b0200,
+       0x120b0200, 0x130a0200, 0x130a0200, 0x130a0100,
+       0x13090100, 0x12090100, 0x11090100, 0x12080100,
+       0x11080100, 0x10080100, 0x11070100, 0x11070000,
+       0x10070000, 0x11060000, 0x10060000, 0x10060000,
+
+       0x140f0600, 0x140f0600, 0x130f0600, 0x140f0500,
+       0x140e0500, 0x130e0500, 0x130e0500, 0x140d0400,
+       0x140d0400, 0x130d0400, 0x120d0400, 0x130c0400,
+       0x130c0300, 0x130c0300, 0x130b0300, 0x130b0300,
+       0x110b0300, 0x130a0200, 0x120a0200, 0x120a0200,
+       0x120a0200, 0x12090200, 0x10090200, 0x11090100,
+       0x11080100, 0x11080100, 0x10080100, 0x10080100,
+       0x10070100, 0x10070100, 0x0f070100, 0x10060100,
+
+       0x120f0701, 0x130f0601, 0x130e0601, 0x130e0601,
+       0x120e0601, 0x130e0501, 0x130e0500, 0x130d0500,
+       0x120d0500, 0x120d0500, 0x130c0400, 0x130c0400,
+       0x120c0400, 0x110c0400, 0x120b0400, 0x120b0300,
+       0x120b0300, 0x120b0300, 0x120a0300, 0x110a0300,
+       0x110a0200, 0x11090200, 0x11090200, 0x10090200,
+       0x10090200, 0x10080200, 0x10080200, 0x10080100,
+       0x0f080100, 0x10070100, 0x0f070100, 0x0f070100
+};
+
+static const uint32_t lan3coefftab32_right[512] = {
+       0x00000000, 0x00000002, 0x0000ff04, 0x0000ff06,
+       0x0000fe08, 0x0000fd0a, 0x0000fd0c, 0x0000fc0f,
+       0x0000fc12, 0x0001fb14, 0x0001fa17, 0x0001fa19,
+       0x0001f91c, 0x0001f91f, 0x0001f822, 0x0001f824,
+       0x0002f727, 0x0002f72a, 0x0002f72c, 0x0002f72f,
+       0x0002f731, 0x0002f733, 0x0002f735, 0x0002f737,
+       0x0002f73a, 0x0002f83b, 0x0002f93c, 0x0002fa3d,
+       0x0001fb3e, 0x0001fc3f, 0x0001fd40, 0x0000fe40,
+
+       0x00000000, 0x00000002, 0x0000ff04, 0x0000ff06,
+       0x0000fe08, 0x0000fd0a, 0x0000fd0c, 0x0000fc0f,
+       0x0000fc12, 0x0001fb14, 0x0001fa17, 0x0001fa19,
+       0x0001f91c, 0x0001f91f, 0x0001f822, 0x0001f824,
+       0x0002f727, 0x0002f72a, 0x0002f72c, 0x0002f72f,
+       0x0002f731, 0x0002f733, 0x0002f735, 0x0002f737,
+       0x0002f73a, 0x0002f83b, 0x0002f93c, 0x0002fa3d,
+       0x0001fb3e, 0x0001fc3f, 0x0001fd40, 0x0000fe40,
+
+       0x0002fc06, 0x0002fb08, 0x0002fb0a, 0x0002fa0c,
+       0x0002fa0e, 0x0003f910, 0x0003f912, 0x0003f814,
+       0x0003f816, 0x0003f719, 0x0003f71a, 0x0003f71d,
+       0x0003f71f, 0x0003f721, 0x0003f723, 0x0003f725,
+       0x0002f727, 0x0002f729, 0x0002f72b, 0x0002f82d,
+       0x0002f82e, 0x0001f930, 0x0001fa31, 0x0000fa34,
+       0x0000fb34, 0x0100fc35, 0x01fffd36, 0x01ffff37,
+       0x01fe0037, 0x01fe0138, 0x01fd0338, 0x02fc0538,
+
+       0x0002fa0b, 0x0002fa0c, 0x0002f90e, 0x0002f910,
+       0x0002f911, 0x0002f813, 0x0002f816, 0x0002f817,
+       0x0002f818, 0x0002f81a, 0x0001f81c, 0x0001f81e,
+       0x0001f820, 0x0001f921, 0x0001f923, 0x0000f925,
+       0x0000fa26, 0x0100fa28, 0x01fffb29, 0x01fffc2a,
+       0x01fffc2c, 0x01fefd2d, 0x01fefe2e, 0x01fdff2f,
+       0x01fd0030, 0x01fd0130, 0x01fc0232, 0x02fc0432,
+       0x02fb0532, 0x02fb0633, 0x02fb0833, 0x02fa0933,
+
+       0x0001fa0e, 0x0001f90f, 0x0001f911, 0x0001f913,
+       0x0001f914, 0x0001f915, 0x0000f918, 0x0000fa18,
+       0x0000fa1a, 0x0000fa1b, 0x0000fa1d, 0x00fffb1e,
+       0x01fffb1f, 0x01fffb20, 0x01fffc22, 0x01fefc23,
+       0x01fefd24, 0x01fefe25, 0x01fdfe27, 0x01fdff28,
+       0x01fd0029, 0x01fc012a, 0x01fc022b, 0x01fc032b,
+       0x01fb042d, 0x01fb052d, 0x01fb062e, 0x01fb072e,
+       0x01fa092e, 0x01fa0a2f, 0x01fa0b2f, 0x01fa0d2f,
+
+       0x0000fa11, 0x0000fa12, 0x0000fa13, 0x0000fb14,
+       0x00fffb16, 0x00fffb16, 0x00fffb17, 0x00fffb19,
+       0x00fffc1a, 0x00fefc1c, 0x00fefd1c, 0x01fefd1d,
+       0x01fefe1e, 0x01fdfe20, 0x01fdff21, 0x01fdff22,
+       0x01fd0023, 0x01fc0124, 0x01fc0124, 0x01fc0225,
+       0x01fc0326, 0x01fc0427, 0x01fb0528, 0x01fb0629,
+       0x01fb0729, 0x01fb0829, 0x01fb092a, 0x01fb0a2a,
+       0x00fa0b2c, 0x00fa0c2b, 0x00fa0e2b, 0x00fa0f2c,
+
+       0x00fffc11, 0x00fffc12, 0x00fffc14, 0x00fffc15,
+       0x00fefd16, 0x00fefd17, 0x00fefd18, 0x00fefe19,
+       0x00fefe1a, 0x00fdfe1d, 0x00fdff1d, 0x00fdff1e,



Home | Main Index | Thread Index | Old Index