This source file includes following definitions.
- lpt_size_alignment
- lpt_memory_control_config
- is_source_bigger_than_epanel_size
- align_to_chunks_number_per_line
- wait_for_fbc_state_changed
- dce112_compressor_power_up_fbc
- dce112_compressor_enable_fbc
- dce112_compressor_disable_fbc
- dce112_compressor_is_fbc_enabled_in_hw
- dce112_compressor_is_lpt_enabled_in_hw
- dce112_compressor_program_compressed_surface_address_and_pitch
- dce112_compressor_disable_lpt
- dce112_compressor_enable_lpt
- dce112_compressor_program_lpt_control
- dce112_compressor_set_fbc_invalidation_triggers
- dce112_compressor_construct
- dce112_compressor_create
- dce112_compressor_destroy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 #include <linux/delay.h>
27 #include <linux/slab.h>
28
29 #include "dm_services.h"
30
31 #include "dce/dce_11_2_d.h"
32 #include "dce/dce_11_2_sh_mask.h"
33 #include "gmc/gmc_8_1_sh_mask.h"
34 #include "gmc/gmc_8_1_d.h"
35
36 #include "include/logger_interface.h"
37
38 #include "dce112_compressor.h"
39 #define DC_LOGGER \
40 cp110->base.ctx->logger
41 #define DCP_REG(reg)\
42 (reg + cp110->offsets.dcp_offset)
43 #define DMIF_REG(reg)\
44 (reg + cp110->offsets.dmif_offset)
45
46 static const struct dce112_compressor_reg_offsets reg_offsets[] = {
47 {
48 .dcp_offset = (mmDCP0_GRPH_CONTROL - mmDCP0_GRPH_CONTROL),
49 .dmif_offset =
50 (mmDMIF_PG0_DPG_PIPE_DPM_CONTROL
51 - mmDMIF_PG0_DPG_PIPE_DPM_CONTROL),
52 },
53 {
54 .dcp_offset = (mmDCP1_GRPH_CONTROL - mmDCP0_GRPH_CONTROL),
55 .dmif_offset =
56 (mmDMIF_PG1_DPG_PIPE_DPM_CONTROL
57 - mmDMIF_PG0_DPG_PIPE_DPM_CONTROL),
58 },
59 {
60 .dcp_offset = (mmDCP2_GRPH_CONTROL - mmDCP0_GRPH_CONTROL),
61 .dmif_offset =
62 (mmDMIF_PG2_DPG_PIPE_DPM_CONTROL
63 - mmDMIF_PG0_DPG_PIPE_DPM_CONTROL),
64 }
65 };
66
67 static const uint32_t dce11_one_lpt_channel_max_resolution = 2560 * 1600;
68
69 enum fbc_idle_force {
70
71 FBC_IDLE_FORCE_DISPLAY_REGISTER_UPDATE = 0x00000001,
72
73
74 FBC_IDLE_FORCE_GRPH_COMP_EN = 0x00000002,
75
76 FBC_IDLE_FORCE_SRC_SEL_CHANGE = 0x00000004,
77
78 FBC_IDLE_FORCE_MIN_COMPRESSION_CHANGE = 0x00000008,
79
80 FBC_IDLE_FORCE_ALPHA_COMP_EN = 0x00000010,
81
82 FBC_IDLE_FORCE_ZERO_ALPHA_CHUNK_SKIP_EN = 0x00000020,
83
84 FBC_IDLE_FORCE_FORCE_COPY_TO_COMP_BUF = 0x00000040,
85
86
87 FBC_IDLE_FORCE_MEMORY_WRITE_TO_REGION0 = 0x01000000,
88
89 FBC_IDLE_FORCE_MEMORY_WRITE_TO_REGION1 = 0x02000000,
90
91 FBC_IDLE_FORCE_MEMORY_WRITE_TO_REGION2 = 0x04000000,
92
93 FBC_IDLE_FORCE_MEMORY_WRITE_TO_REGION3 = 0x08000000,
94
95
96 FBC_IDLE_FORCE_MEMORY_WRITE_OTHER_THAN_MCIF = 0x10000000,
97
98 FBC_IDLE_FORCE_CG_STATIC_SCREEN_IS_INACTIVE = 0x20000000,
99 };
100
101 static uint32_t lpt_size_alignment(struct dce112_compressor *cp110)
102 {
103
104 return cp110->base.raw_size * cp110->base.banks_num *
105 cp110->base.dram_channels_num;
106 }
107
108 static uint32_t lpt_memory_control_config(struct dce112_compressor *cp110,
109 uint32_t lpt_control)
110 {
111
112 if (cp110->base.options.bits.LPT_MC_CONFIG == 1) {
113
114
115
116
117
118
119
120 switch (cp110->base.dram_channels_num) {
121 case 2:
122 set_reg_field_value(
123 lpt_control,
124 1,
125 LOW_POWER_TILING_CONTROL,
126 LOW_POWER_TILING_NUM_PIPES);
127 break;
128 case 1:
129 set_reg_field_value(
130 lpt_control,
131 0,
132 LOW_POWER_TILING_CONTROL,
133 LOW_POWER_TILING_NUM_PIPES);
134 break;
135 default:
136 DC_LOG_WARNING(
137 "%s: Invalid LPT NUM_PIPES!!!",
138 __func__);
139 break;
140 }
141
142
143
144
145
146
147
148
149
150
151 switch (cp110->base.banks_num) {
152 case 16:
153 set_reg_field_value(
154 lpt_control,
155 3,
156 LOW_POWER_TILING_CONTROL,
157 LOW_POWER_TILING_NUM_BANKS);
158 break;
159 case 8:
160 set_reg_field_value(
161 lpt_control,
162 2,
163 LOW_POWER_TILING_CONTROL,
164 LOW_POWER_TILING_NUM_BANKS);
165 break;
166 case 4:
167 set_reg_field_value(
168 lpt_control,
169 1,
170 LOW_POWER_TILING_CONTROL,
171 LOW_POWER_TILING_NUM_BANKS);
172 break;
173 case 2:
174 set_reg_field_value(
175 lpt_control,
176 0,
177 LOW_POWER_TILING_CONTROL,
178 LOW_POWER_TILING_NUM_BANKS);
179 break;
180 default:
181 DC_LOG_WARNING(
182 "%s: Invalid LPT NUM_BANKS!!!",
183 __func__);
184 break;
185 }
186
187
188
189
190
191
192
193
194
195
196
197
198 switch (cp110->base.channel_interleave_size) {
199 case 256:
200 set_reg_field_value(
201 lpt_control,
202 0,
203 LOW_POWER_TILING_CONTROL,
204 LOW_POWER_TILING_PIPE_INTERLEAVE_SIZE);
205 break;
206 case 512:
207 set_reg_field_value(
208 lpt_control,
209 1,
210 LOW_POWER_TILING_CONTROL,
211 LOW_POWER_TILING_PIPE_INTERLEAVE_SIZE);
212 break;
213 default:
214 DC_LOG_WARNING(
215 "%s: Invalid LPT INTERLEAVE_SIZE!!!",
216 __func__);
217 break;
218 }
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234 switch (cp110->base.raw_size) {
235 case 4096:
236 set_reg_field_value(
237 lpt_control,
238 2,
239 LOW_POWER_TILING_CONTROL,
240 LOW_POWER_TILING_ROW_SIZE);
241 break;
242 case 2048:
243 set_reg_field_value(
244 lpt_control,
245 1,
246 LOW_POWER_TILING_CONTROL,
247 LOW_POWER_TILING_ROW_SIZE);
248 break;
249 case 1024:
250 set_reg_field_value(
251 lpt_control,
252 0,
253 LOW_POWER_TILING_CONTROL,
254 LOW_POWER_TILING_ROW_SIZE);
255 break;
256 default:
257 DC_LOG_WARNING(
258 "%s: Invalid LPT ROW_SIZE!!!",
259 __func__);
260 break;
261 }
262 } else {
263 DC_LOG_WARNING(
264 "%s: LPT MC Configuration is not provided",
265 __func__);
266 }
267
268 return lpt_control;
269 }
270
271 static bool is_source_bigger_than_epanel_size(
272 struct dce112_compressor *cp110,
273 uint32_t source_view_width,
274 uint32_t source_view_height)
275 {
276 if (cp110->base.embedded_panel_h_size != 0 &&
277 cp110->base.embedded_panel_v_size != 0 &&
278 ((source_view_width * source_view_height) >
279 (cp110->base.embedded_panel_h_size *
280 cp110->base.embedded_panel_v_size)))
281 return true;
282
283 return false;
284 }
285
286 static uint32_t align_to_chunks_number_per_line(
287 struct dce112_compressor *cp110,
288 uint32_t pixels)
289 {
290 return 256 * ((pixels + 255) / 256);
291 }
292
293 static void wait_for_fbc_state_changed(
294 struct dce112_compressor *cp110,
295 bool enabled)
296 {
297 uint8_t counter = 0;
298 uint32_t addr = mmFBC_STATUS;
299 uint32_t value;
300
301 while (counter < 10) {
302 value = dm_read_reg(cp110->base.ctx, addr);
303 if (get_reg_field_value(
304 value,
305 FBC_STATUS,
306 FBC_ENABLE_STATUS) == enabled)
307 break;
308 udelay(10);
309 counter++;
310 }
311
312 if (counter == 10) {
313 DC_LOG_WARNING(
314 "%s: wait counter exceeded, changes to HW not applied",
315 __func__);
316 }
317 }
318
319 void dce112_compressor_power_up_fbc(struct compressor *compressor)
320 {
321 uint32_t value;
322 uint32_t addr;
323
324 addr = mmFBC_CNTL;
325 value = dm_read_reg(compressor->ctx, addr);
326 set_reg_field_value(value, 0, FBC_CNTL, FBC_GRPH_COMP_EN);
327 set_reg_field_value(value, 1, FBC_CNTL, FBC_EN);
328 set_reg_field_value(value, 2, FBC_CNTL, FBC_COHERENCY_MODE);
329 if (compressor->options.bits.CLK_GATING_DISABLED == 1) {
330
331 set_reg_field_value(
332 value,
333 0,
334 FBC_CNTL,
335 FBC_COMP_CLK_GATE_EN);
336 }
337 dm_write_reg(compressor->ctx, addr, value);
338
339 addr = mmFBC_COMP_MODE;
340 value = dm_read_reg(compressor->ctx, addr);
341 set_reg_field_value(value, 1, FBC_COMP_MODE, FBC_RLE_EN);
342 set_reg_field_value(value, 1, FBC_COMP_MODE, FBC_DPCM4_RGB_EN);
343 set_reg_field_value(value, 1, FBC_COMP_MODE, FBC_IND_EN);
344 dm_write_reg(compressor->ctx, addr, value);
345
346 addr = mmFBC_COMP_CNTL;
347 value = dm_read_reg(compressor->ctx, addr);
348 set_reg_field_value(value, 1, FBC_COMP_CNTL, FBC_DEPTH_RGB08_EN);
349 dm_write_reg(compressor->ctx, addr, value);
350
351
352
353
354 set_reg_field_value(value, 0xF, FBC_COMP_CNTL, FBC_MIN_COMPRESSION);
355 dm_write_reg(compressor->ctx, addr, value);
356 compressor->min_compress_ratio = FBC_COMPRESS_RATIO_1TO1;
357
358 value = 0;
359 dm_write_reg(compressor->ctx, mmFBC_IND_LUT0, value);
360
361 value = 0xFFFFFF;
362 dm_write_reg(compressor->ctx, mmFBC_IND_LUT1, value);
363 }
364
365 void dce112_compressor_enable_fbc(
366 struct compressor *compressor,
367 uint32_t paths_num,
368 struct compr_addr_and_pitch_params *params)
369 {
370 struct dce112_compressor *cp110 = TO_DCE112_COMPRESSOR(compressor);
371
372 if (compressor->options.bits.FBC_SUPPORT &&
373 (compressor->options.bits.DUMMY_BACKEND == 0) &&
374 (!dce112_compressor_is_fbc_enabled_in_hw(compressor, NULL)) &&
375 (!is_source_bigger_than_epanel_size(
376 cp110,
377 params->source_view_width,
378 params->source_view_height))) {
379
380 uint32_t addr;
381 uint32_t value;
382
383
384
385
386 if (compressor->options.bits.LPT_SUPPORT && (paths_num < 2) &&
387 (params->source_view_width *
388 params->source_view_height <=
389 dce11_one_lpt_channel_max_resolution)) {
390 dce112_compressor_enable_lpt(compressor);
391 }
392
393 addr = mmFBC_CNTL;
394 value = dm_read_reg(compressor->ctx, addr);
395 set_reg_field_value(value, 1, FBC_CNTL, FBC_GRPH_COMP_EN);
396 set_reg_field_value(
397 value,
398 params->inst,
399 FBC_CNTL, FBC_SRC_SEL);
400 dm_write_reg(compressor->ctx, addr, value);
401
402
403 compressor->is_enabled = true;
404 compressor->attached_inst = params->inst;
405 cp110->offsets = reg_offsets[params->inst];
406
407
408 set_reg_field_value(value, 0, FBC_CNTL, FBC_GRPH_COMP_EN);
409 dm_write_reg(compressor->ctx, addr, value);
410 set_reg_field_value(value, 1, FBC_CNTL, FBC_GRPH_COMP_EN);
411 dm_write_reg(compressor->ctx, addr, value);
412
413 wait_for_fbc_state_changed(cp110, true);
414 }
415 }
416
417 void dce112_compressor_disable_fbc(struct compressor *compressor)
418 {
419 struct dce112_compressor *cp110 = TO_DCE112_COMPRESSOR(compressor);
420
421 if (compressor->options.bits.FBC_SUPPORT &&
422 dce112_compressor_is_fbc_enabled_in_hw(compressor, NULL)) {
423 uint32_t reg_data;
424
425 reg_data = dm_read_reg(compressor->ctx, mmFBC_CNTL);
426 set_reg_field_value(reg_data, 0, FBC_CNTL, FBC_GRPH_COMP_EN);
427 dm_write_reg(compressor->ctx, mmFBC_CNTL, reg_data);
428
429
430 compressor->attached_inst = 0;
431 compressor->is_enabled = false;
432
433
434
435 if (compressor->options.bits.LPT_SUPPORT)
436 dce112_compressor_disable_lpt(compressor);
437
438 wait_for_fbc_state_changed(cp110, false);
439 }
440 }
441
442 bool dce112_compressor_is_fbc_enabled_in_hw(
443 struct compressor *compressor,
444 uint32_t *inst)
445 {
446
447 uint32_t value;
448
449 value = dm_read_reg(compressor->ctx, mmFBC_STATUS);
450 if (get_reg_field_value(value, FBC_STATUS, FBC_ENABLE_STATUS)) {
451 if (inst != NULL)
452 *inst = compressor->attached_inst;
453 return true;
454 }
455
456 value = dm_read_reg(compressor->ctx, mmFBC_MISC);
457 if (get_reg_field_value(value, FBC_MISC, FBC_STOP_ON_HFLIP_EVENT)) {
458 value = dm_read_reg(compressor->ctx, mmFBC_CNTL);
459
460 if (get_reg_field_value(value, FBC_CNTL, FBC_GRPH_COMP_EN)) {
461 if (inst != NULL)
462 *inst =
463 compressor->attached_inst;
464 return true;
465 }
466 }
467 return false;
468 }
469
470 bool dce112_compressor_is_lpt_enabled_in_hw(struct compressor *compressor)
471 {
472
473 uint32_t value = dm_read_reg(compressor->ctx,
474 mmLOW_POWER_TILING_CONTROL);
475
476 return get_reg_field_value(
477 value,
478 LOW_POWER_TILING_CONTROL,
479 LOW_POWER_TILING_ENABLE);
480 }
481
482 void dce112_compressor_program_compressed_surface_address_and_pitch(
483 struct compressor *compressor,
484 struct compr_addr_and_pitch_params *params)
485 {
486 struct dce112_compressor *cp110 = TO_DCE112_COMPRESSOR(compressor);
487 uint32_t value = 0;
488 uint32_t fbc_pitch = 0;
489 uint32_t compressed_surf_address_low_part =
490 compressor->compr_surface_address.addr.low_part;
491
492
493 dm_write_reg(
494 compressor->ctx,
495 DCP_REG(mmGRPH_COMPRESS_SURFACE_ADDRESS_HIGH),
496 0);
497 dm_write_reg(compressor->ctx,
498 DCP_REG(mmGRPH_COMPRESS_SURFACE_ADDRESS), 0);
499
500 if (compressor->options.bits.LPT_SUPPORT) {
501 uint32_t lpt_alignment = lpt_size_alignment(cp110);
502
503 if (lpt_alignment != 0) {
504 compressed_surf_address_low_part =
505 ((compressed_surf_address_low_part
506 + (lpt_alignment - 1)) / lpt_alignment)
507 * lpt_alignment;
508 }
509 }
510
511
512 dm_write_reg(compressor->ctx,
513 DCP_REG(mmGRPH_COMPRESS_SURFACE_ADDRESS_HIGH),
514 compressor->compr_surface_address.addr.high_part);
515 dm_write_reg(compressor->ctx,
516 DCP_REG(mmGRPH_COMPRESS_SURFACE_ADDRESS),
517 compressed_surf_address_low_part);
518
519 fbc_pitch = align_to_chunks_number_per_line(
520 cp110,
521 params->source_view_width);
522
523 if (compressor->min_compress_ratio == FBC_COMPRESS_RATIO_1TO1)
524 fbc_pitch = fbc_pitch / 8;
525 else
526 DC_LOG_WARNING(
527 "%s: Unexpected DCE11 compression ratio",
528 __func__);
529
530
531 dm_write_reg(compressor->ctx, DCP_REG(mmGRPH_COMPRESS_PITCH), 0);
532
533
534 set_reg_field_value(
535 value,
536 fbc_pitch,
537 GRPH_COMPRESS_PITCH,
538 GRPH_COMPRESS_PITCH);
539 dm_write_reg(compressor->ctx, DCP_REG(mmGRPH_COMPRESS_PITCH), value);
540
541 }
542
543 void dce112_compressor_disable_lpt(struct compressor *compressor)
544 {
545 struct dce112_compressor *cp110 = TO_DCE112_COMPRESSOR(compressor);
546 uint32_t value;
547 uint32_t addr;
548 uint32_t inx;
549
550
551 for (inx = 0; inx < 3; inx++) {
552 value =
553 dm_read_reg(
554 compressor->ctx,
555 DMIF_REG(mmDPG_PIPE_STUTTER_CONTROL_NONLPTCH));
556 set_reg_field_value(
557 value,
558 0,
559 DPG_PIPE_STUTTER_CONTROL_NONLPTCH,
560 STUTTER_ENABLE_NONLPTCH);
561 dm_write_reg(
562 compressor->ctx,
563 DMIF_REG(mmDPG_PIPE_STUTTER_CONTROL_NONLPTCH),
564 value);
565 }
566
567 addr = mmDPGV0_PIPE_STUTTER_CONTROL_NONLPTCH;
568 value = dm_read_reg(compressor->ctx, addr);
569 set_reg_field_value(
570 value,
571 0,
572 DPGV0_PIPE_STUTTER_CONTROL_NONLPTCH,
573 STUTTER_ENABLE_NONLPTCH);
574 dm_write_reg(compressor->ctx, addr, value);
575
576
577 addr = mmLOW_POWER_TILING_CONTROL;
578 value = dm_read_reg(compressor->ctx, addr);
579 set_reg_field_value(
580 value,
581 0,
582 LOW_POWER_TILING_CONTROL,
583 LOW_POWER_TILING_ENABLE);
584 dm_write_reg(compressor->ctx, addr, value);
585
586
587 addr = mmGMCON_LPT_TARGET;
588 value = dm_read_reg(compressor->ctx, addr);
589 set_reg_field_value(
590 value,
591 0xFFFFFFFF,
592 GMCON_LPT_TARGET,
593 STCTRL_LPT_TARGET);
594 dm_write_reg(compressor->ctx, mmGMCON_LPT_TARGET, value);
595 }
596
597 void dce112_compressor_enable_lpt(struct compressor *compressor)
598 {
599 struct dce112_compressor *cp110 = TO_DCE112_COMPRESSOR(compressor);
600 uint32_t value;
601 uint32_t addr;
602 uint32_t value_control;
603 uint32_t channels;
604
605
606 value = dm_read_reg(compressor->ctx,
607 DMIF_REG(mmDPG_PIPE_STUTTER_CONTROL_NONLPTCH));
608 set_reg_field_value(
609 value,
610 1,
611 DPG_PIPE_STUTTER_CONTROL_NONLPTCH,
612 STUTTER_ENABLE_NONLPTCH);
613 dm_write_reg(compressor->ctx,
614 DMIF_REG(mmDPG_PIPE_STUTTER_CONTROL_NONLPTCH), value);
615
616
617 addr = mmDPGV0_PIPE_STUTTER_CONTROL_NONLPTCH;
618 value = dm_read_reg(compressor->ctx, addr);
619 set_reg_field_value(
620 value,
621 1,
622 DPGV0_PIPE_STUTTER_CONTROL_NONLPTCH,
623 STUTTER_ENABLE_NONLPTCH);
624 dm_write_reg(compressor->ctx, addr, value);
625
626
627
628
629 addr = mmLOW_POWER_TILING_CONTROL;
630 value_control = dm_read_reg(compressor->ctx, addr);
631 channels = get_reg_field_value(value_control,
632 LOW_POWER_TILING_CONTROL,
633 LOW_POWER_TILING_MODE);
634
635 addr = mmGMCON_LPT_TARGET;
636 value = dm_read_reg(compressor->ctx, addr);
637 set_reg_field_value(
638 value,
639 channels + 1,
640
641 GMCON_LPT_TARGET,
642 STCTRL_LPT_TARGET);
643 dm_write_reg(compressor->ctx, addr, value);
644
645
646 addr = mmLOW_POWER_TILING_CONTROL;
647 value = dm_read_reg(compressor->ctx, addr);
648 set_reg_field_value(
649 value,
650 1,
651 LOW_POWER_TILING_CONTROL,
652 LOW_POWER_TILING_ENABLE);
653 dm_write_reg(compressor->ctx, addr, value);
654 }
655
656 void dce112_compressor_program_lpt_control(
657 struct compressor *compressor,
658 struct compr_addr_and_pitch_params *params)
659 {
660 struct dce112_compressor *cp110 = TO_DCE112_COMPRESSOR(compressor);
661 uint32_t rows_per_channel;
662 uint32_t lpt_alignment;
663 uint32_t source_view_width;
664 uint32_t source_view_height;
665 uint32_t lpt_control = 0;
666
667 if (!compressor->options.bits.LPT_SUPPORT)
668 return;
669
670 lpt_control = dm_read_reg(compressor->ctx,
671 mmLOW_POWER_TILING_CONTROL);
672
673
674
675
676
677
678 switch (compressor->lpt_channels_num) {
679
680
681 case 1:
682
683 set_reg_field_value(
684 lpt_control,
685 0,
686 LOW_POWER_TILING_CONTROL,
687 LOW_POWER_TILING_MODE);
688 break;
689 default:
690 DC_LOG_WARNING(
691 "%s: Invalid selected DRAM channels for LPT!!!",
692 __func__);
693 break;
694 }
695
696 lpt_control = lpt_memory_control_config(cp110, lpt_control);
697
698
699
700
701
702
703 rows_per_channel = 0;
704 lpt_alignment = lpt_size_alignment(cp110);
705 source_view_width =
706 align_to_chunks_number_per_line(
707 cp110,
708 params->source_view_width);
709 source_view_height = (params->source_view_height + 1) & (~0x1);
710
711 if (lpt_alignment != 0) {
712 rows_per_channel = source_view_width * source_view_height * 4;
713 rows_per_channel =
714 (rows_per_channel % lpt_alignment) ?
715 (rows_per_channel / lpt_alignment + 1) :
716 rows_per_channel / lpt_alignment;
717 }
718
719 set_reg_field_value(
720 lpt_control,
721 rows_per_channel,
722 LOW_POWER_TILING_CONTROL,
723 LOW_POWER_TILING_ROWS_PER_CHAN);
724
725 dm_write_reg(compressor->ctx,
726 mmLOW_POWER_TILING_CONTROL, lpt_control);
727 }
728
729
730
731
732
733 void dce112_compressor_set_fbc_invalidation_triggers(
734 struct compressor *compressor,
735 uint32_t fbc_trigger)
736 {
737
738
739
740 uint32_t addr = mmFBC_CLIENT_REGION_MASK;
741 uint32_t value = dm_read_reg(compressor->ctx, addr);
742
743 set_reg_field_value(
744 value,
745 0,
746 FBC_CLIENT_REGION_MASK,
747 FBC_MEMORY_REGION_MASK);
748 dm_write_reg(compressor->ctx, addr, value);
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774 addr = mmFBC_IDLE_FORCE_CLEAR_MASK;
775 value = dm_read_reg(compressor->ctx, addr);
776 set_reg_field_value(
777 value,
778 fbc_trigger |
779 FBC_IDLE_FORCE_GRPH_COMP_EN |
780 FBC_IDLE_FORCE_SRC_SEL_CHANGE |
781 FBC_IDLE_FORCE_MIN_COMPRESSION_CHANGE |
782 FBC_IDLE_FORCE_ALPHA_COMP_EN |
783 FBC_IDLE_FORCE_ZERO_ALPHA_CHUNK_SKIP_EN |
784 FBC_IDLE_FORCE_FORCE_COPY_TO_COMP_BUF,
785 FBC_IDLE_FORCE_CLEAR_MASK,
786 FBC_IDLE_FORCE_CLEAR_MASK);
787 dm_write_reg(compressor->ctx, addr, value);
788 }
789
790 void dce112_compressor_construct(struct dce112_compressor *compressor,
791 struct dc_context *ctx)
792 {
793 struct dc_bios *bp = ctx->dc_bios;
794 struct embedded_panel_info panel_info;
795
796 compressor->base.options.raw = 0;
797 compressor->base.options.bits.FBC_SUPPORT = true;
798 compressor->base.options.bits.LPT_SUPPORT = true;
799
800 compressor->base.lpt_channels_num = 1;
801 compressor->base.options.bits.DUMMY_BACKEND = false;
802
803
804
805 if (compressor->base.memory_bus_width == 64)
806 compressor->base.options.bits.LPT_SUPPORT = false;
807
808 compressor->base.options.bits.CLK_GATING_DISABLED = false;
809
810 compressor->base.ctx = ctx;
811 compressor->base.embedded_panel_h_size = 0;
812 compressor->base.embedded_panel_v_size = 0;
813 compressor->base.memory_bus_width = ctx->asic_id.vram_width;
814 compressor->base.allocated_size = 0;
815 compressor->base.preferred_requested_size = 0;
816 compressor->base.min_compress_ratio = FBC_COMPRESS_RATIO_INVALID;
817 compressor->base.banks_num = 0;
818 compressor->base.raw_size = 0;
819 compressor->base.channel_interleave_size = 0;
820 compressor->base.dram_channels_num = 0;
821 compressor->base.lpt_channels_num = 0;
822 compressor->base.attached_inst = 0;
823 compressor->base.is_enabled = false;
824
825 if (BP_RESULT_OK ==
826 bp->funcs->get_embedded_panel_info(bp, &panel_info)) {
827 compressor->base.embedded_panel_h_size =
828 panel_info.lcd_timing.horizontal_addressable;
829 compressor->base.embedded_panel_v_size =
830 panel_info.lcd_timing.vertical_addressable;
831 }
832 }
833
834 struct compressor *dce112_compressor_create(struct dc_context *ctx)
835 {
836 struct dce112_compressor *cp110 =
837 kzalloc(sizeof(struct dce112_compressor), GFP_KERNEL);
838
839 if (!cp110)
840 return NULL;
841
842 dce112_compressor_construct(cp110, ctx);
843 return &cp110->base;
844 }
845
846 void dce112_compressor_destroy(struct compressor **compressor)
847 {
848 kfree(TO_DCE112_COMPRESSOR(*compressor));
849 *compressor = NULL;
850 }