1 // Copyright 2018 The Fuchsia Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #pragma once
6 
7 // clang-format off
8 #define OVL_STA                         (0x0000)
9 #define OVL_INTEN                       (0x0004)
10 #define OVL_INTSTA                      (0x0008)
11 #define OVL_EN                          (0x000C)
12 #define OVL_TRIG                        (0x0010)
13 #define OVL_RST                         (0x0014)
14 #define OVL_ROI_SIZE                    (0x0020)
15 #define OVL_DATAPATH_CON                (0x0024)
16 #define OVL_ROI_BGCLR                   (0x0028)
17 #define OVL_SRC_CON                     (0x002C)
18 #define OVL_Lx_CON(x)                   (0x0030 + (0x20 * x))
19 #define OVL_Lx_SRCKEY(x)                (0x0034 + (0x20 * x))
20 #define OVL_Lx_SRC_SIZE(x)              (0x0038 + (0x20 * x))
21 #define OVL_Lx_OFFSET(x)                (0x003C + (0x20 * x))
22 #define OVL_Lx_ADDR(x)                  (0x0F40 + (0x20 * x))
23 #define OVL_Lx_PITCH(x)                 (0x0044 + (0x20 * x))
24 #define OVL_Lx_TILE(x)                  (0x0048 + (0x20 * x))
25 #define OVL_RDMAx_CTRL(x)               (0x00C0 + (0x20 * x))
26 #define OVL_RDMAx_MEM_GMC_SETTING(x)    (0x00C8 + (0x20 * x))
27 #define OVL_RDMAx_MEM_SLOW_CON(x)       (0x00CC + (0x20 * x))
28 #define OVL_RDMAx_FIFO_CTRL(x)          (0x00D0 + (0x20 * x))
29 #define OVL_Lx_Y2R_PARA_R0(x)           (0x0134 + (0x20 * x))
30 #define OVL_Lx_Y2R_PARA_R1(x)           (0x0138 + (0x20 * x))
31 #define OVL_Lx_Y2R_PARA_G0(x)           (0x013C + (0x20 * x))
32 #define OVL_Lx_Y2R_PARA_G1(x)           (0x0140 + (0x20 * x))
33 #define OVL_Lx_Y2R_PARA_B0(x)           (0x0144 + (0x20 * x))
34 #define OVL_Lx_Y2R_PARA_B1(x)           (0x0148 + (0x20 * x))
35 #define OVL_Lx_Y2R_PARA_YUV_A_0(x)      (0x014C + (0x20 * x))
36 #define OVL_Lx_Y2R_PARA_YUV_A_1(x)      (0x0150 + (0x20 * x))
37 #define OVL_Lx_Y2R_PARA_RGB_A_0(x)      (0x0154 + (0x20 * x))
38 #define OVL_Lx_Y2R_PARA_RGB_A_1(x)      (0x0158 + (0x20 * x))
39 #define OVL_DEBUG_MON_SEL               (0x01D4)
40 #define OVL_RDMAx_MEM_GMC_S2(x)         (0x01E0 + (0x04 * x))
41 #define OVL_DUMMY_REG                   (0x0200)
42 #define OVL_SMI_DBG                     (0x0230)
43 #define OVL_GREQ_LAYER_CNT              (0x0234)
44 #define OVL_FLOW_CTRL_DBG               (0x0240)
45 #define OVL_ADDCON_DBG                  (0x0244)
46 #define OVL_RDMAx_DBG(x)                (0x024C + (0x04 * x))
47 #define OVL_Lx_CLR(x)                   (0x025C + (0x04 * x))
48 
49 // OVL_INTEN Bit Definitions
50 #define INT_FRAME_COMPLETE              (1 << 1)
51 
52 // OVL_FLOW_CTRL_DBG Bit Definitions
53 #define OVL_IDLE                        (0x1)
54 
55 // OVL_SRC_CON Bit Definitions
56 #define SRC_CON_ENABLE_LAYER(x)         (1 << x)
57 
58 // OVL_Lx_CON Bit Definitions
59 #define Lx_CON_BYTE_SWAP                (1 << 24)
60 #define Lx_CON_CLRFMT(x)                (x << 12)
61 #define Lx_CON_AEN                      (1 << 8)
62 #define Lx_CON_ALPHA(x)                 (x << 0)
63 
64 // OVL_Lx_PITCH Bit Definitions
65 #define Lx_PITCH_SRFL_EN                (1 << 31)
66 #define Lx_PITCH_DST_ALPHA(x)           (x << 20)
67 #define Lx_PITCH_SRC_ALPHA(x)           (x << 16)
68 #define Lx_PITCH_PITCH(x)               (x << 0)
69 
70 #define NO_SRC_ALPHA                    (0x0)
71 #define SRC_ALPHA                       (0x5)
72 #define INV_SRC_ALPHA                   (0xA)
73 
74 
75 // Color Format based on OVL_Lx_CON Register definition
76 enum {
77     RGB565 = 0,
78     RGB888 = 1,
79     RGBA8888 = 2,
80     BGRA8888 = 2, // same as RGBA8888
81     ARGB8888 = 3,
82     ABGR8888 = 3, // same as ABGR8888
83     UVVY = 4,
84     VYUY = 4, // same as UVVY
85     YUYV = 5,
86     YVYU = 5, // same as YUYV
87     UNKNOWN_FORMAT = 0xFFFFFFFF,
88 };
89 
90 // Color Matrix Table based on OVL_Lx_CON Register definition
91 // TODO(payamm): This is only really needed if we ever support YUV
92 enum {
93     JPEG_TO_RGB = 4, // for YUV space
94     BT601_TO_RGB = 6,
95     BT709_TO_RGB = 7,
96 };
97