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
73 /* REPEAT or REPLAY instruction not needed */
84 arg
|= 0x40; /* for jump instruction 7th bit is 1 */
97 DRM_ERROR("instruction %d does not exist\n", opcode
);
101 arg_tmp
= arg_tmp
- arg
;
103 arg
= ((arg
+ mux
) + data_enable
);
105 instruction
= ((opcode
) << AWG_OPCODE_OFFSET
) | arg
;
106 fwparams
->ram_code
[fwparams
->instruction_offset
] =
107 instruction
& (0x3fff);
108 fwparams
->instruction_offset
++;
113 int sti_awg_generate_code_data_enable_mode(
114 struct awg_code_generation_params
*fwparams
,
115 struct awg_timing
*timing
)
121 if (timing
->trailing_lines
> 0) {
122 /* skip trailing lines */
123 val
= timing
->blanking_level
;
125 ret
|= awg_generate_instr(RPLSET
, val
, 0, data_en
, fwparams
);
127 val
= timing
->trailing_lines
- 1;
129 ret
|= awg_generate_instr(REPLAY
, val
, 0, data_en
, fwparams
);
132 if (timing
->trailing_pixels
> 0) {
133 /* skip trailing pixel */
134 val
= timing
->blanking_level
;
136 ret
|= awg_generate_instr(RPLSET
, val
, 0, data_en
, fwparams
);
138 val
= timing
->trailing_pixels
- 1;
140 ret
|= awg_generate_instr(SKIP
, val
, 0, data_en
, fwparams
);
143 /* set DE signal high */
144 val
= timing
->blanking_level
;
146 ret
|= awg_generate_instr((timing
->trailing_pixels
> 0) ? SET
: RPLSET
,
147 val
, 0, data_en
, fwparams
);
149 if (timing
->blanking_pixels
> 0) {
150 /* skip the number of active pixel */
151 val
= timing
->active_pixels
- 1;
153 ret
|= awg_generate_instr(SKIP
, val
, 0, data_en
, fwparams
);
155 /* set DE signal low */
156 val
= timing
->blanking_level
;
158 ret
|= awg_generate_instr(SET
, val
, 0, data_en
, fwparams
);
161 /* replay the sequence as many active lines defined */
162 val
= timing
->active_lines
- 1;
164 ret
|= awg_generate_instr(REPLAY
, val
, 0, data_en
, fwparams
);
166 if (timing
->blanking_lines
> 0) {
167 /* skip blanking lines */
168 val
= timing
->blanking_level
;
170 ret
|= awg_generate_instr(RPLSET
, val
, 0, data_en
, fwparams
);
172 val
= timing
->blanking_lines
- 1;
174 ret
|= awg_generate_instr(REPLAY
, val
, 0, data_en
, fwparams
);