aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/radeon/evergreen_blit_kms.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/radeon/evergreen_blit_kms.c')
-rw-r--r--drivers/gpu/drm/radeon/evergreen_blit_kms.c43
1 files changed, 37 insertions, 6 deletions
diff --git a/drivers/gpu/drm/radeon/evergreen_blit_kms.c b/drivers/gpu/drm/radeon/evergreen_blit_kms.c
index b758dc7f2f2c..a1ba4b3053d0 100644
--- a/drivers/gpu/drm/radeon/evergreen_blit_kms.c
+++ b/drivers/gpu/drm/radeon/evergreen_blit_kms.c
@@ -232,7 +232,7 @@ draw_auto(struct radeon_device *rdev)
232 232
233} 233}
234 234
235/* emits 30 */ 235/* emits 36 */
236static void 236static void
237set_default_state(struct radeon_device *rdev) 237set_default_state(struct radeon_device *rdev)
238{ 238{
@@ -245,6 +245,8 @@ set_default_state(struct radeon_device *rdev)
245 int num_hs_threads, num_ls_threads; 245 int num_hs_threads, num_ls_threads;
246 int num_ps_stack_entries, num_vs_stack_entries, num_gs_stack_entries, num_es_stack_entries; 246 int num_ps_stack_entries, num_vs_stack_entries, num_gs_stack_entries, num_es_stack_entries;
247 int num_hs_stack_entries, num_ls_stack_entries; 247 int num_hs_stack_entries, num_ls_stack_entries;
248 u64 gpu_addr;
249 int dwords;
248 250
249 switch (rdev->family) { 251 switch (rdev->family) {
250 case CHIP_CEDAR: 252 case CHIP_CEDAR:
@@ -497,6 +499,18 @@ set_default_state(struct radeon_device *rdev)
497 radeon_ring_write(rdev, 0x00000000); 499 radeon_ring_write(rdev, 0x00000000);
498 radeon_ring_write(rdev, 0x00000000); 500 radeon_ring_write(rdev, 0x00000000);
499 501
502 /* set to DX10/11 mode */
503 radeon_ring_write(rdev, PACKET3(PACKET3_MODE_CONTROL, 0));
504 radeon_ring_write(rdev, 1);
505
506 /* emit an IB pointing at default state */
507 dwords = ALIGN(rdev->r600_blit.state_len, 0x10);
508 gpu_addr = rdev->r600_blit.shader_gpu_addr + rdev->r600_blit.state_offset;
509 radeon_ring_write(rdev, PACKET3(PACKET3_INDIRECT_BUFFER, 2));
510 radeon_ring_write(rdev, gpu_addr & 0xFFFFFFFC);
511 radeon_ring_write(rdev, upper_32_bits(gpu_addr) & 0xFF);
512 radeon_ring_write(rdev, dwords);
513
500} 514}
501 515
502static inline uint32_t i2f(uint32_t input) 516static inline uint32_t i2f(uint32_t input)
@@ -527,8 +541,10 @@ static inline uint32_t i2f(uint32_t input)
527int evergreen_blit_init(struct radeon_device *rdev) 541int evergreen_blit_init(struct radeon_device *rdev)
528{ 542{
529 u32 obj_size; 543 u32 obj_size;
530 int r; 544 int r, dwords;
531 void *ptr; 545 void *ptr;
546 u32 packet2s[16];
547 int num_packet2s = 0;
532 548
533 /* pin copy shader into vram if already initialized */ 549 /* pin copy shader into vram if already initialized */
534 if (rdev->r600_blit.shader_obj) 550 if (rdev->r600_blit.shader_obj)
@@ -536,8 +552,17 @@ int evergreen_blit_init(struct radeon_device *rdev)
536 552
537 mutex_init(&rdev->r600_blit.mutex); 553 mutex_init(&rdev->r600_blit.mutex);
538 rdev->r600_blit.state_offset = 0; 554 rdev->r600_blit.state_offset = 0;
539 rdev->r600_blit.state_len = 0; 555
540 obj_size = 0; 556 rdev->r600_blit.state_len = evergreen_default_size;
557
558 dwords = rdev->r600_blit.state_len;
559 while (dwords & 0xf) {
560 packet2s[num_packet2s++] = PACKET2(0);
561 dwords++;
562 }
563
564 obj_size = dwords * 4;
565 obj_size = ALIGN(obj_size, 256);
541 566
542 rdev->r600_blit.vs_offset = obj_size; 567 rdev->r600_blit.vs_offset = obj_size;
543 obj_size += evergreen_vs_size * 4; 568 obj_size += evergreen_vs_size * 4;
@@ -567,6 +592,12 @@ int evergreen_blit_init(struct radeon_device *rdev)
567 return r; 592 return r;
568 } 593 }
569 594
595 memcpy_toio(ptr + rdev->r600_blit.state_offset,
596 evergreen_default_state, rdev->r600_blit.state_len * 4);
597
598 if (num_packet2s)
599 memcpy_toio(ptr + rdev->r600_blit.state_offset + (rdev->r600_blit.state_len * 4),
600 packet2s, num_packet2s * 4);
570 memcpy(ptr + rdev->r600_blit.vs_offset, evergreen_vs, evergreen_vs_size * 4); 601 memcpy(ptr + rdev->r600_blit.vs_offset, evergreen_vs, evergreen_vs_size * 4);
571 memcpy(ptr + rdev->r600_blit.ps_offset, evergreen_ps, evergreen_ps_size * 4); 602 memcpy(ptr + rdev->r600_blit.ps_offset, evergreen_ps, evergreen_ps_size * 4);
572 radeon_bo_kunmap(rdev->r600_blit.shader_obj); 603 radeon_bo_kunmap(rdev->r600_blit.shader_obj);
@@ -652,7 +683,7 @@ int evergreen_blit_prepare_copy(struct radeon_device *rdev, int size_bytes)
652 /* calculate number of loops correctly */ 683 /* calculate number of loops correctly */
653 ring_size = num_loops * dwords_per_loop; 684 ring_size = num_loops * dwords_per_loop;
654 /* set default + shaders */ 685 /* set default + shaders */
655 ring_size += 46; /* shaders + def state */ 686 ring_size += 52; /* shaders + def state */
656 ring_size += 10; /* fence emit for VB IB */ 687 ring_size += 10; /* fence emit for VB IB */
657 ring_size += 5; /* done copy */ 688 ring_size += 5; /* done copy */
658 ring_size += 10; /* fence emit for done copy */ 689 ring_size += 10; /* fence emit for done copy */
@@ -660,7 +691,7 @@ int evergreen_blit_prepare_copy(struct radeon_device *rdev, int size_bytes)
660 if (r) 691 if (r)
661 return r; 692 return r;
662 693
663 set_default_state(rdev); /* 30 */ 694 set_default_state(rdev); /* 36 */
664 set_shaders(rdev); /* 16 */ 695 set_shaders(rdev); /* 16 */
665 return 0; 696 return 0;
666} 697}