blob: 74d597048628a6541e781b28293a59a2c651d7f3 [file] [log] [blame]
Nico Huber7ad2d652016-12-07 15:19:32 +01001--
Nico Huberabb16d92018-05-29 01:44:26 +02002-- Copyright (C) 2015-2018 secunet Security Networks AG
Nico Huber7ad2d652016-12-07 15:19:32 +01003--
4-- This program is free software; you can redistribute it and/or modify
5-- it under the terms of the GNU General Public License as published by
6-- the Free Software Foundation; either version 2 of the License, or
7-- (at your option) any later version.
8--
9-- This program is distributed in the hope that it will be useful,
10-- but WITHOUT ANY WARRANTY; without even the implied warranty of
11-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-- GNU General Public License for more details.
13--
14
15with HW.Debug;
16with GNAT.Source_Info;
17
Tim Wawrzynczak4be2e752022-09-09 10:37:06 -060018with HW.GFX.GMA.Config_Helpers;
Nico Huber7ad2d652016-12-07 15:19:32 +010019with HW.GFX.GMA.DP_Info;
20
21package body HW.GFX.GMA.Transcoder is
22
23 type Default_Transcoder_Array is array (Pipe_Index) of Transcoder_Index;
24 Default_Transcoder : constant Default_Transcoder_Array :=
25 (Primary => Trans_A,
26 Secondary => Trans_B,
27 Tertiary => Trans_C);
28
29 function Get_Idx (Pipe : Pipe_Index; Port : GPU_Port) return Transcoder_Index
30 is
31 begin
32 return
33 (if Config.Has_EDP_Transcoder and then Port = DIGI_A then
34 Trans_EDP
35 else
36 Default_Transcoder (Pipe));
37 end Get_Idx;
38
39 ----------------------------------------------------------------------------
40
41 TRANS_CLK_SEL_PORT_NONE : constant := 0 * 2 ** 29;
Tim Wawrzynczak4be2e752022-09-09 10:37:06 -060042 TRANS_CLK_SEL_MASK : constant := 16#f000_0000#;
Nico Huber7ad2d652016-12-07 15:19:32 +010043
44 type TRANS_CLK_SEL_PORT_Array is
45 array (Digital_Port) of Word32;
46 TRANS_CLK_SEL_PORT : constant TRANS_CLK_SEL_PORT_Array :=
47 (DIGI_A => 0 * 2 ** 29, -- DDI A is not selectable
48 DIGI_B => 2 * 2 ** 29,
49 DIGI_C => 3 * 2 ** 29,
50 DIGI_D => 4 * 2 ** 29,
51 DIGI_E => 5 * 2 ** 29);
52
Nico Huber09472732026-04-20 22:33:33 +020053 function TGL_TRANS_CLK_SEL_PORT (Port : TGL_Digital_Port) return Word32
54 is
55 (case Port is
56 when DIGI_A => 1 * 2 ** 28,
57 when DIGI_B => 2 * 2 ** 28,
58 when DIGI_C => 3 * 2 ** 28,
59 when DDI_TC1 => 4 * 2 ** 28,
60 when DDI_TC2 => 5 * 2 ** 28,
61 when DDI_TC3 => 6 * 2 ** 28,
62 when DDI_TC4 => 7 * 2 ** 28,
63 when DDI_TC5 => 8 * 2 ** 28,
64 when DDI_TC6 => 9 * 2 ** 28,
65 when others => 0);
66
67 function XELPD_TRANS_CLK_SEL_PORT (Port : XELPD_Digital_Port) return Word32
68 is
69 (case Port is
70 when DIGI_A => 1 * 2 ** 28,
71 when DIGI_B => 2 * 2 ** 28,
72 when DIGI_C => 3 * 2 ** 28,
73 when DIGI_D => 4 * 2 ** 28,
74 when DIGI_E => 5 * 2 ** 28,
75 when DDI_TC1 => 6 * 2 ** 28,
76 when DDI_TC2 => 7 * 2 ** 28,
77 when DDI_TC3 => 8 * 2 ** 28,
78 when DDI_TC4 => 9 * 2 ** 28);
Tim Wawrzynczak4be2e752022-09-09 10:37:06 -060079
Nico Huber7ad2d652016-12-07 15:19:32 +010080 TRANS_CONF_ENABLE : constant := 1 * 2 ** 31;
81 TRANS_CONF_ENABLED_STATUS : constant := 1 * 2 ** 30;
82 TRANS_CONF_ENABLE_DITHER : constant := 1 * 2 ** 4;
83
84 type BPC_Array is array (BPC_Type) of Word32;
85 TRANS_CONF_BPC : constant BPC_Array :=
86 (6 => 2 * 2 ** 5,
87 8 => 0 * 2 ** 5,
88 10 => 1 * 2 ** 5,
89 12 => 3 * 2 ** 5,
90 others => 0 * 2 ** 5); -- default to 8 BPC
91
92 function BPC_Conf (BPC : BPC_Type; Dither : Boolean) return Word32 is
93 begin
94 return
95 (if Config.Has_Pipeconf_BPC then TRANS_CONF_BPC (BPC) else 0) or
96 (if Dither then TRANS_CONF_ENABLE_DITHER else 0);
97 end BPC_Conf;
98
99 ----------------------------------------------------------------------------
100
101 DDI_FUNC_CTL_ENABLE : constant := 1 * 2 ** 31;
102 DDI_FUNC_CTL_MODE_SELECT_MASK : constant := 7 * 2 ** 24;
103 DDI_FUNC_CTL_MODE_SELECT_HDMI : constant := 0 * 2 ** 24;
104 DDI_FUNC_CTL_MODE_SELECT_DVI : constant := 1 * 2 ** 24;
105 DDI_FUNC_CTL_MODE_SELECT_DP_SST : constant := 2 * 2 ** 24;
106 DDI_FUNC_CTL_MODE_SELECT_DP_MST : constant := 3 * 2 ** 24;
107 DDI_FUNC_CTL_MODE_SELECT_FDI : constant := 4 * 2 ** 24;
Nico Huber7ad2d652016-12-07 15:19:32 +0100108
109 type DDI_Select_Array is array (Digital_Port) of Word32;
110 DDI_FUNC_CTL_DDI_SELECT : constant DDI_Select_Array :=
111 (DIGI_A => 0 * 2 ** 28,
112 DIGI_B => 1 * 2 ** 28,
113 DIGI_C => 2 * 2 ** 28,
114 DIGI_D => 3 * 2 ** 28,
115 DIGI_E => 4 * 2 ** 28);
116
Nico Huber09472732026-04-20 22:33:33 +0200117 function TGL_DDI_FUNC_CTL_DDI_SELECT (Port : DDI_Port) return Word32
Tim Wawrzynczak4be2e752022-09-09 10:37:06 -0600118 is
119 (case Port is
Nico Huber09472732026-04-20 22:33:33 +0200120 when DIGI_A => 1 * 2 ** 27,
121 when DIGI_B => 2 * 2 ** 27,
122 when DIGI_C => 3 * 2 ** 27,
123 when DIGI_D => 8 * 2 ** 27, -- n/a on TGL, repositioned since ADL-P
124 when DIGI_E => 9 * 2 ** 27, -- n/a on TGL, repositioned since ADL-P
125 when DDI_TC1 => 4 * 2 ** 27,
126 when DDI_TC2 => 5 * 2 ** 27,
127 when DDI_TC3 => 6 * 2 ** 27,
128 when DDI_TC4 => 7 * 2 ** 27,
129 when DDI_TC5 => 8 * 2 ** 27,
130 when DDI_TC6 => 9 * 2 ** 27);
Tim Wawrzynczak4be2e752022-09-09 10:37:06 -0600131
Nico Huber7ad2d652016-12-07 15:19:32 +0100132 type DDI_Mode_Array is array (Display_Type) of Word32;
133 DDI_FUNC_CTL_MODE_SELECT : constant DDI_Mode_Array :=
134 (VGA => DDI_FUNC_CTL_MODE_SELECT_FDI,
135 HDMI => DDI_FUNC_CTL_MODE_SELECT_DVI,
136 DP => DDI_FUNC_CTL_MODE_SELECT_DP_SST,
137 others => 0);
138
139 type HV_Sync_Array is array (Boolean) of Word32;
140 DDI_FUNC_CTL_VSYNC : constant HV_Sync_Array :=
141 (False => 0 * 2 ** 17,
142 True => 1 * 2 ** 17);
143 DDI_FUNC_CTL_HSYNC : constant HV_Sync_Array :=
144 (False => 0 * 2 ** 16,
145 True => 1 * 2 ** 16);
146
Nico Huberabb16d92018-05-29 01:44:26 +0200147 DDI_FUNC_CTL_EDP_SELECT_MASK : constant := 7 * 2 ** 12;
148 DDI_FUNC_CTL_EDP_SELECT_ALWAYS_ON : constant := 0 * 2 ** 12;
149 DDI_FUNC_CTL_EDP_SELECT : constant array (Pipe_Index) of Word32 :=
150 (Primary => 4 * 2 ** 12,
151 Secondary => 5 * 2 ** 12,
152 Tertiary => 6 * 2 ** 12);
Nico Huber7ad2d652016-12-07 15:19:32 +0100153
154 type Port_Width_Array is array (DP_Lane_Count) of Word32;
155 DDI_FUNC_CTL_PORT_WIDTH : constant Port_Width_Array :=
156 (DP_Lane_Count_1 => 0 * 2 ** 1,
157 DP_Lane_Count_2 => 1 * 2 ** 1,
158 DP_Lane_Count_4 => 3 * 2 ** 1);
159
160 DDI_FUNC_CTL_BPC : constant BPC_Array :=
161 (6 => 2 * 2 ** 20,
162 8 => 0 * 2 ** 20,
163 10 => 1 * 2 ** 20,
164 12 => 3 * 2 ** 20,
165 others => 0 * 2 ** 20); -- default to 8 BPC
166
167 ----------------------------------------------------------------------------
168
169 TRANS_MSA_MISC_SYNC_CLK : constant := 1 * 2 ** 0;
170 TRANS_MSA_MISC_BPC : constant BPC_Array :=
171 (6 => 0 * 2 ** 5,
172 8 => 1 * 2 ** 5,
173 10 => 2 * 2 ** 5,
174 12 => 3 * 2 ** 5,
175 16 => 4 * 2 ** 5,
176 others => 1 * 2 ** 5); -- default to 8 BPC
177
178 function TRANS_DATA_M_TU (Transfer_Unit : Positive) return Word32 is
179 begin
180 return Shift_Left (Word32 (Transfer_Unit - 1), 25);
181 end TRANS_DATA_M_TU;
182
183 ----------------------------------------------------------------------------
184
Nico Huberc5c767a2018-06-03 01:09:04 +0200185 function Encode (LSW, MSW : Pos32) return Word32 is
Nico Huber7ad2d652016-12-07 15:19:32 +0100186 begin
187 return Shift_Left (Word32 (MSW - 1), 16) or Word32 (LSW - 1);
188 end Encode;
189
190 ----------------------------------------------------------------------------
191
192 procedure Setup_Link
193 (Trans : Transcoder_Regs;
194 Link : DP_Link;
195 Mode : Mode_Type)
196 with
197 Global => (In_Out => Registers.Register_State),
198 Depends => (Registers.Register_State =>+ (Trans, Link, Mode))
199 is
200 Data_M, Link_M : DP_Info.M_Type;
201 Data_N, Link_N : DP_Info.N_Type;
202 begin
203 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
204
205 DP_Info.Calculate_M_N
206 (Link => Link,
207 Mode => Mode,
208 Data_M => Data_M,
209 Data_N => Data_N,
210 Link_M => Link_M,
211 Link_N => Link_N);
212
213 Registers.Write
214 (Register => Trans.DATA_M1,
215 Value => TRANS_DATA_M_TU (64) or
216 Word32 (Data_M));
217 Registers.Write
218 (Register => Trans.DATA_N1,
219 Value => Word32 (Data_N));
220
221 Registers.Write
222 (Register => Trans.LINK_M1,
223 Value => Word32 (Link_M));
224 Registers.Write
225 (Register => Trans.LINK_N1,
226 Value => Word32 (Link_N));
227
228 if Config.Has_Pipe_MSA_Misc then
229 Registers.Write
230 (Register => Trans.MSA_MISC,
231 Value => TRANS_MSA_MISC_SYNC_CLK or
232 TRANS_MSA_MISC_BPC (Mode.BPC));
233 end if;
234 end Setup_Link;
235
236 ----------------------------------------------------------------------------
237
238 procedure Setup
239 (Pipe : Pipe_Index;
240 Port_Cfg : Port_Config)
241 is
242 use type HW.GFX.GMA.Registers.Registers_Invalid_Index;
243
244 Trans : Transcoder_Regs renames
245 Transcoders (Get_Idx (Pipe, Port_Cfg.Port));
246 M : constant Mode_Type := Port_Cfg.Mode;
247 begin
248 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
249
250 if Config.Has_Trans_Clk_Sel and then
Tim Wawrzynczak4be2e752022-09-09 10:37:06 -0600251 not Config.Need_Early_Transcoder_Setup and then
Arthur Heymans5d08a932018-03-28 17:00:18 +0200252 Trans.CLK_SEL /= Registers.Invalid_Register and then
253 Port_Cfg.Port in Digital_Port
Nico Huber7ad2d652016-12-07 15:19:32 +0100254 then
255 Registers.Write
256 (Register => Trans.CLK_SEL,
257 Value => TRANS_CLK_SEL_PORT (Port_Cfg.Port));
258 end if;
259
260 if Port_Cfg.Is_FDI then
261 Setup_Link (Trans, Port_Cfg.FDI, Port_Cfg.Mode);
262 elsif Port_Cfg.Display = DP then
263 Setup_Link (Trans, Port_Cfg.DP, Port_Cfg.Mode);
264 end if;
265
266 Registers.Write (Trans.HTOTAL, Encode (M.H_Visible, M.H_Total));
267 Registers.Write (Trans.HBLANK, Encode (M.H_Visible, M.H_Total));
268 Registers.Write (Trans.HSYNC, Encode (M.H_Sync_Begin, M.H_Sync_End));
269 Registers.Write (Trans.VTOTAL, Encode (M.V_Visible, M.V_Total));
270 Registers.Write (Trans.VBLANK, Encode (M.V_Visible, M.V_Total));
271 Registers.Write (Trans.VSYNC, Encode (M.V_Sync_Begin, M.V_Sync_End));
272 end Setup;
273
274 ----------------------------------------------------------------------------
275
Tim Wawrzynczak4be2e752022-09-09 10:37:06 -0600276 procedure Enable_Pipe_Clock (Pipe : Pipe_Index; Port_Cfg : Port_Config)
277 is
278 use type HW.GFX.GMA.Registers.Registers_Invalid_Index;
279
280 Trans : Transcoder_Regs renames
281 Transcoders (Get_Idx (Pipe, Port_Cfg.Port));
282 begin
283 if Config.Need_Early_Transcoder_Setup and then
Nico Huber09472732026-04-20 22:33:33 +0200284 Trans.CLK_SEL /= Registers.Invalid_Register
Nico Huberac2a1412026-07-02 10:41:59 +0200285 then
Nico Huber09472732026-04-20 22:33:33 +0200286 if Config.Continuous_Port_Select then
287 if Port_Cfg.Port in XELPD_Digital_Port then
288 Registers.Unset_And_Set_Mask
289 (Register => Trans.CLK_SEL,
290 Mask_Unset => TRANS_CLK_SEL_MASK,
291 Mask_Set => XELPD_TRANS_CLK_SEL_PORT (Port_Cfg.Port));
292 end if;
293 else
294 if Port_Cfg.Port in TGL_Digital_Port then
295 Registers.Unset_And_Set_Mask
296 (Register => Trans.CLK_SEL,
297 Mask_Unset => TRANS_CLK_SEL_MASK,
298 Mask_Set => TGL_TRANS_CLK_SEL_PORT (Port_Cfg.Port));
299 end if;
300 end if;
Tim Wawrzynczak4be2e752022-09-09 10:37:06 -0600301 end if;
302 end Enable_Pipe_Clock;
303
304 ----------------------------------------------------------------------------
305
306 procedure Configure (Pipe : Pipe_Index; Port_Cfg : Port_Config; Scale : Boolean)
307 is
308 Trans : Transcoder_Regs renames
309 Transcoders (Get_Idx (Pipe, Port_Cfg.Port));
310 Lane_Count : constant DP_Lane_Count :=
311 (if Port_Cfg.Is_FDI then Port_Cfg.FDI.Lane_Count else Port_Cfg.DP.Lane_Count);
312 EDP_Select : constant Word32 :=
313 (if Config.Has_TGL_DDI_Select
314 then 0
315 else
316 (if Pipe = Primary and
317 (not Config.Use_PDW_For_EDP_Scaling or else not Scale)
318 then
319 DDI_FUNC_CTL_EDP_SELECT_ALWAYS_ON
320 else
321 DDI_FUNC_CTL_EDP_SELECT (Pipe)));
322 DDI_Select : constant Word32 :=
Nico Huber09472732026-04-20 22:33:33 +0200323 (if Config.Has_TGL_DDI_Select and then Port_Cfg.Port in DDI_Port then
Tim Wawrzynczak4be2e752022-09-09 10:37:06 -0600324 TGL_DDI_FUNC_CTL_DDI_SELECT (Port_Cfg.Port)
325 else
326 (if Port_Cfg.Port in Digital_Port
327 then
328 DDI_FUNC_CTL_DDI_SELECT (Port_Cfg.Port)
329 else 0));
330 begin
331 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
332 if Config.Has_Pipe_DDI_Func then
Nico Huber177fc662026-04-25 14:49:06 +0200333 if Port_Cfg.Port in DDI_Port then
Tim Wawrzynczak4be2e752022-09-09 10:37:06 -0600334 Registers.Write
335 (Register => Trans.DDI_FUNC_CTL,
336 Value => DDI_Select or
337 DDI_FUNC_CTL_MODE_SELECT (Port_Cfg.Display) or
338 DDI_FUNC_CTL_BPC (Port_Cfg.Mode.BPC) or
339 DDI_FUNC_CTL_VSYNC (Port_Cfg.Mode.V_Sync_Active_High) or
340 DDI_FUNC_CTL_HSYNC (Port_Cfg.Mode.H_Sync_Active_High) or
341 EDP_Select or
342 DDI_FUNC_CTL_PORT_WIDTH (Lane_Count));
343 end if;
344 end if;
345 end Configure;
346
347 ----------------------------------------------------------------------------
348
Nico Huber7ad2d652016-12-07 15:19:32 +0100349 procedure On
350 (Pipe : Pipe_Index;
351 Port_Cfg : Port_Config;
Nico Huberabb16d92018-05-29 01:44:26 +0200352 Dither : Boolean;
353 Scale : Boolean)
Nico Huber7ad2d652016-12-07 15:19:32 +0100354 is
Tim Wawrzynczak0da761a2022-09-09 10:42:36 -0600355 use type HW.GFX.GMA.Registers.Registers_Invalid_Index;
Nico Huber7ad2d652016-12-07 15:19:32 +0100356 Trans : Transcoder_Regs renames
357 Transcoders (Get_Idx (Pipe, Port_Cfg.Port));
Tim Wawrzynczak0da761a2022-09-09 10:42:36 -0600358 PIPE_ARB_USE_PROG_SLOTS : constant := 1 * 2 ** 13;
Nico Huber7ad2d652016-12-07 15:19:32 +0100359 begin
Tim Wawrzynczak4be2e752022-09-09 10:37:06 -0600360 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
361 if not Config.Need_Early_Transcoder_Setup then
362 Configure (Pipe, Port_Cfg, Scale);
363 end if;
364
Nico Huber177fc662026-04-25 14:49:06 +0200365 if Config.Has_Pipe_DDI_Func and then Port_Cfg.Port in DDI_Port then
Tim Wawrzynczak4be2e752022-09-09 10:37:06 -0600366 Registers.Set_Mask
Nico Huber7ad2d652016-12-07 15:19:32 +0100367 (Register => Trans.DDI_FUNC_CTL,
Tim Wawrzynczak4be2e752022-09-09 10:37:06 -0600368 Mask => DDI_FUNC_CTL_ENABLE);
Nico Huber7ad2d652016-12-07 15:19:32 +0100369 end if;
370
Tim Wawrzynczak0da761a2022-09-09 10:42:36 -0600371 if Config.Need_Pipe_Arb_Slots and then
372 Trans.PIPE_ARB_CTL /= Registers.Invalid_Register
373 then
374 Registers.Set_Mask
375 (Register => Trans.PIPE_ARB_CTL,
376 Mask => PIPE_ARB_USE_PROG_SLOTS);
377 end if;
378
Nico Huber7ad2d652016-12-07 15:19:32 +0100379 Registers.Write
380 (Register => Trans.CONF,
381 Value => TRANS_CONF_ENABLE or
382 (if not Config.Has_Pipeconf_Misc then
383 BPC_Conf (Port_Cfg.Mode.BPC, Dither) else 0));
384 Registers.Posting_Read (Trans.CONF);
385 end On;
386
387 ----------------------------------------------------------------------------
388
389 procedure Trans_Off (Trans : Transcoder_Regs)
390 is
391 Enabled : Boolean;
392 begin
393 Registers.Is_Set_Mask (Trans.CONF, TRANS_CONF_ENABLE, Enabled);
394
395 if Enabled then
396 Registers.Unset_Mask (Trans.CONF, TRANS_CONF_ENABLE);
397 end if;
398
399 -- Workaround for Broadwell:
400 -- Status may be wrong if pipe hasn't been enabled since reset.
401 if not Config.Pipe_Enabled_Workaround or else Enabled then
402 -- synchronously wait until pipe is truly off
403 Registers.Wait_Unset_Mask
404 (Register => Trans.CONF,
405 Mask => TRANS_CONF_ENABLED_STATUS,
406 TOut_MS => 40);
407 end if;
408
409 if Config.Has_Pipe_DDI_Func then
Nico Huber6489f3d2024-07-15 15:28:47 +0000410 Registers.Is_Set_Mask (Trans.DDI_FUNC_CTL, DDI_FUNC_CTL_ENABLE, Enabled);
411 if Enabled then
412 Registers.Write (Trans.DDI_FUNC_CTL, 0);
413 end if;
Nico Huber7ad2d652016-12-07 15:19:32 +0100414 end if;
415 end Trans_Off;
416
417 procedure Off (Pipe : Pipe_Index)
418 is
419 DDI_Func_Ctl : Word32;
420 begin
421 if Config.Has_EDP_Transcoder then
422 Registers.Read (Registers.PIPE_EDP_DDI_FUNC_CTL, DDI_Func_Ctl);
423 DDI_Func_Ctl := DDI_Func_Ctl and DDI_FUNC_CTL_EDP_SELECT_MASK;
424
425 if (Pipe = Primary and
426 DDI_Func_Ctl = DDI_FUNC_CTL_EDP_SELECT_ALWAYS_ON) or
Nico Huberabb16d92018-05-29 01:44:26 +0200427 DDI_Func_Ctl = DDI_FUNC_CTL_EDP_SELECT (Pipe)
Nico Huber7ad2d652016-12-07 15:19:32 +0100428 then
429 Trans_Off (Transcoders (Trans_EDP));
430 end if;
431 end if;
432
433 Trans_Off (Transcoders (Default_Transcoder (Pipe)));
434 end Off;
435
436 procedure Clk_Off (Pipe : Pipe_Index)
437 is
438 use type Registers.Registers_Invalid_Index;
439
440 Trans : Transcoder_Regs renames Transcoders (Default_Transcoder (Pipe));
441 begin
442 if Config.Has_Trans_Clk_Sel and then
443 Trans.CLK_SEL /= Registers.Invalid_Register
444 then
445 Registers.Write (Trans.CLK_SEL, TRANS_CLK_SEL_PORT_NONE);
446 end if;
447 end Clk_Off;
448
Angel Pons3f86b0b2020-07-18 00:22:32 +0200449 ----------------------------------------------------------------------------
450
451 SRD_CTL_ENABLE : constant := 1 * 2 ** 31;
452 SRD_STATUS_STATE_MASK : constant := 7 * 2 ** 29;
453
454 type SRD_Regs is record
455 CTL : Registers.Registers_Index;
456 STATUS : Registers.Registers_Index;
457 end record;
458 type SRD_Per_Pipe_Regs is array (Transcoder_Index) of SRD_Regs;
459
460 SRD : constant SRD_Per_Pipe_Regs := SRD_Per_Pipe_Regs'
461 (Trans_EDP => SRD_Regs'
462 (CTL => Registers.SRD_CTL_EDP,
463 STATUS => Registers.SRD_STATUS_EDP),
464 Trans_A => SRD_Regs'
465 (CTL => Registers.SRD_CTL_A,
466 STATUS => Registers.SRD_STATUS_A),
467 Trans_B => SRD_Regs'
468 (CTL => Registers.SRD_CTL_B,
469 STATUS => Registers.SRD_STATUS_B),
470 Trans_C => SRD_Regs'
471 (CTL => Registers.SRD_CTL_C,
472 STATUS => Registers.SRD_STATUS_C));
473
474 ----------------------------------------------------------------------------
475
476 procedure PSR_Off
477 is
478 Enabled : Boolean;
479 begin
480 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
481
482 if Config.Has_Per_Pipe_SRD then
Tim Wawrzynczak4be2e752022-09-09 10:37:06 -0600483 declare
484 First_Transcoder : constant Transcoder_Index :=
485 (if Config.Has_EDP_Transcoder then Trans_EDP else Trans_A);
486 begin
487 for P in Transcoder_Index range First_Transcoder .. Transcoder_Index'Last loop
488 Registers.Is_Set_Mask (SRD (P).CTL, SRD_CTL_ENABLE, Enabled);
489 if Enabled then
490 Registers.Unset_Mask (SRD (P).CTL, SRD_CTL_ENABLE);
491 Registers.Wait_Unset_Mask (SRD (P).STATUS, SRD_STATUS_STATE_MASK);
Angel Pons3f86b0b2020-07-18 00:22:32 +0200492
Tim Wawrzynczak4be2e752022-09-09 10:37:06 -0600493 pragma Debug (Debug.Put_Line ("Disabled PSR."));
494 end if;
495 end loop;
496 end;
Angel Pons3f86b0b2020-07-18 00:22:32 +0200497 else
498 Registers.Is_Set_Mask (Registers.SRD_CTL, SRD_CTL_ENABLE, Enabled);
499 if Enabled then
500 Registers.Unset_Mask (Registers.SRD_CTL, SRD_CTL_ENABLE);
501 Registers.Wait_Unset_Mask (Registers.SRD_STATUS, SRD_STATUS_STATE_MASK);
502
503 pragma Debug (Debug.Put_Line ("Disabled PSR."));
504 end if;
505 end if;
506 end PSR_Off;
507
508 ----------------------------------------------------------------------------
509
Nico Huber7ad2d652016-12-07 15:19:32 +0100510end HW.GFX.GMA.Transcoder;