2 * Coda multi-standard codec IP
4 * Copyright (C) 2014 Philipp Zabel, Pengutronix
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
12 #include <linux/bitops.h>
15 #define XY2_INVERT BIT(7)
16 #define XY2_ZERO BIT(6)
17 #define XY2_TB_XOR BIT(5)
18 #define XY2_XYSEL BIT(4)
19 #define XY2_Y (1 << 4)
20 #define XY2_X (0 << 4)
22 #define XY2(luma_sel, luma_bit, chroma_sel, chroma_bit) \
23 (((XY2_##luma_sel) | (luma_bit)) << 8 | \
24 (XY2_##chroma_sel) | (chroma_bit))
26 static const u16 xy2ca_zero_map
[16] = {
27 XY2(ZERO
, 0, ZERO
, 0),
28 XY2(ZERO
, 0, ZERO
, 0),
29 XY2(ZERO
, 0, ZERO
, 0),
30 XY2(ZERO
, 0, ZERO
, 0),
31 XY2(ZERO
, 0, ZERO
, 0),
32 XY2(ZERO
, 0, ZERO
, 0),
33 XY2(ZERO
, 0, ZERO
, 0),
34 XY2(ZERO
, 0, ZERO
, 0),
35 XY2(ZERO
, 0, ZERO
, 0),
36 XY2(ZERO
, 0, ZERO
, 0),
37 XY2(ZERO
, 0, ZERO
, 0),
38 XY2(ZERO
, 0, ZERO
, 0),
39 XY2(ZERO
, 0, ZERO
, 0),
40 XY2(ZERO
, 0, ZERO
, 0),
41 XY2(ZERO
, 0, ZERO
, 0),
42 XY2(ZERO
, 0, ZERO
, 0),
45 static const u16 xy2ca_tiled_map
[16] = {
51 XY2(ZERO
, 0, ZERO
, 0),
52 XY2(ZERO
, 0, ZERO
, 0),
53 XY2(ZERO
, 0, ZERO
, 0),
54 XY2(ZERO
, 0, ZERO
, 0),
55 XY2(ZERO
, 0, ZERO
, 0),
56 XY2(ZERO
, 0, ZERO
, 0),
57 XY2(ZERO
, 0, ZERO
, 0),
58 XY2(ZERO
, 0, ZERO
, 0),
59 XY2(ZERO
, 0, ZERO
, 0),
60 XY2(ZERO
, 0, ZERO
, 0),
61 XY2(ZERO
, 0, ZERO
, 0),
65 * RA[15:0], CA[15:8] are hardwired to contain the 24-bit macroblock
66 * start offset (macroblock size is 16x16 for luma, 16x8 for chroma).
67 * Bits CA[4:0] are set using XY2CA above. BA[3:0] seems to be unused.
70 #define RBC_CA (0 << 4)
71 #define RBC_BA (1 << 4)
72 #define RBC_RA (2 << 4)
73 #define RBC_ZERO (3 << 4)
75 #define RBC(luma_sel, luma_bit, chroma_sel, chroma_bit) \
76 (((RBC_##luma_sel) | (luma_bit)) << 6 | \
77 (RBC_##chroma_sel) | (chroma_bit))
79 static const u16 rbc2axi_tiled_map
[32] = {
80 RBC(ZERO
, 0, ZERO
, 0),
81 RBC(ZERO
, 0, ZERO
, 0),
82 RBC(ZERO
, 0, ZERO
, 0),
111 RBC(RA
, 15, ZERO
, 0),
114 void coda_set_gdi_regs(struct coda_ctx
*ctx
)
116 struct coda_dev
*dev
= ctx
->dev
;
117 const u16
*xy2ca_map
;
121 switch (ctx
->tiled_map_type
) {
122 case GDI_LINEAR_FRAME_MAP
:
124 xy2ca_map
= xy2ca_zero_map
;
127 case GDI_TILED_FRAME_MB_RASTER_MAP
:
128 xy2ca_map
= xy2ca_tiled_map
;
129 xy2rbc_config
= CODA9_XY2RBC_TILED_MAP
|
130 CODA9_XY2RBC_CA_INC_HOR
|
131 (16 - 1) << 12 | (8 - 1) << 4;
135 for (i
= 0; i
< 16; i
++)
136 coda_write(dev
, xy2ca_map
[i
],
137 CODA9_GDI_XY2_CAS_0
+ 4 * i
);
138 for (i
= 0; i
< 4; i
++)
139 coda_write(dev
, XY2(ZERO
, 0, ZERO
, 0),
140 CODA9_GDI_XY2_BA_0
+ 4 * i
);
141 for (i
= 0; i
< 16; i
++)
142 coda_write(dev
, XY2(ZERO
, 0, ZERO
, 0),
143 CODA9_GDI_XY2_RAS_0
+ 4 * i
);
144 coda_write(dev
, xy2rbc_config
, CODA9_GDI_XY2_RBC_CONFIG
);
146 for (i
= 0; i
< 32; i
++)
147 coda_write(dev
, rbc2axi_tiled_map
[i
],
148 CODA9_GDI_RBC2_AXI_0
+ 4 * i
);