2 * Copyright (C) STMicroelectronics SA 2014
3 * Author: Vincent Abriou <vincent.abriou@st.com> for STMicroelectronics.
4 * License terms: GNU General Public License (GPL), version 2
7 #include "sti_awg_utils.h"
9 #define AWG_OPCODE_OFFSET 10
23 static int awg_generate_instr(enum opcode opcode
,
27 struct awg_code_generation_params
*fwparams
)
30 u32 mux
= (mux_sel
<< 8) & 0x1ff;
31 u32 data_enable
= (data_en
<< 9) & 0x2ff;
32 long int arg_tmp
= arg
;
34 /* skip, repeat and replay arg should not exceed 1023.
35 * If user wants to exceed this value, the instruction should be
36 * duplicate and arg should be adjust for each duplicated instruction.
41 if (fwparams
->instruction_offset
>= AWG_MAX_INST
) {
42 DRM_ERROR("too many number of instructions\n");
48 /* leave 'arg' + 1 pixel elapsing without changing
50 arg
--; /* pixel adjustment */
54 /* SKIP instruction not needed */
59 /* SKIP 0 not permitted but we want to skip 1
60 * pixel. So we transform SKIP into SET
68 arg
= (arg
<< 22) >> 22;
74 /* REPEAT or REPLAY instruction not needed */
80 arg
= (arg
<< 22) >> 22;
86 arg
|= 0x40; /* for jump instruction 7th bit is 1 */
87 arg
= (arg
<< 22) >> 22;
97 arg
= (arg
<< 24) >> 24;
101 DRM_ERROR("instruction %d does not exist\n", opcode
);
105 arg_tmp
= arg_tmp
- arg
;
107 arg
= ((arg
+ mux
) + data_enable
);
109 instruction
= ((opcode
) << AWG_OPCODE_OFFSET
) | arg
;
110 fwparams
->ram_code
[fwparams
->instruction_offset
] =
111 instruction
& (0x3fff);
112 fwparams
->instruction_offset
++;
117 int sti_awg_generate_code_data_enable_mode(
118 struct awg_code_generation_params
*fwparams
,
119 struct awg_timing
*timing
)
125 if (timing
->trailing_lines
> 0) {
126 /* skip trailing lines */
127 val
= timing
->blanking_level
;
129 ret
|= awg_generate_instr(RPLSET
, val
, 0, data_en
, fwparams
);
131 val
= timing
->trailing_lines
- 1;
133 ret
|= awg_generate_instr(REPLAY
, val
, 0, data_en
, fwparams
);
136 if (timing
->trailing_pixels
> 0) {
137 /* skip trailing pixel */
138 val
= timing
->blanking_level
;
140 ret
|= awg_generate_instr(RPLSET
, val
, 0, data_en
, fwparams
);
142 val
= timing
->trailing_pixels
- 1;
144 ret
|= awg_generate_instr(SKIP
, val
, 0, data_en
, fwparams
);
147 /* set DE signal high */
148 val
= timing
->blanking_level
;
150 ret
|= awg_generate_instr((timing
->trailing_pixels
> 0) ? SET
: RPLSET
,
151 val
, 0, data_en
, fwparams
);
153 if (timing
->blanking_pixels
> 0) {
154 /* skip the number of active pixel */
155 val
= timing
->active_pixels
- 1;
157 ret
|= awg_generate_instr(SKIP
, val
, 0, data_en
, fwparams
);
159 /* set DE signal low */
160 val
= timing
->blanking_level
;
162 ret
|= awg_generate_instr(SET
, val
, 0, data_en
, fwparams
);
165 /* replay the sequence as many active lines defined */
166 val
= timing
->active_lines
- 1;
168 ret
|= awg_generate_instr(REPLAY
, val
, 0, data_en
, fwparams
);
170 if (timing
->blanking_lines
> 0) {
171 /* skip blanking lines */
172 val
= timing
->blanking_level
;
174 ret
|= awg_generate_instr(RPLSET
, val
, 0, data_en
, fwparams
);
176 val
= timing
->blanking_lines
- 1;
178 ret
|= awg_generate_instr(REPLAY
, val
, 0, data_en
, fwparams
);