Rev 2997 | Rev 3124 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2997 | Rev 3120 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | #include |
3 | #include |
4 | #include "radeon_drm.h" |
4 | #include "radeon_drm.h" |
5 | #include "radeon.h" |
5 | #include "radeon.h" |
6 | #include "radeon_object.h" |
6 | #include "radeon_object.h" |
7 | #include "display.h" |
7 | #include "drm_fb_helper.h" |
8 | #include "drm_fb_helper.h" |
- | |
9 | 8 | #include "hmm.h" |
|
- | 9 | #include "bitmap.h" |
|
- | 10 | #include "display.h" |
|
- | 11 | ||
Line 10... | Line 12... | ||
10 | struct radeon_fbdev { |
12 | struct radeon_fbdev { |
11 | struct drm_fb_helper helper; |
13 | struct drm_fb_helper helper; |
12 | struct radeon_framebuffer rfb; |
14 | struct radeon_framebuffer rfb; |
13 | struct list_head fbdev_list; |
15 | struct list_head fbdev_list; |
Line 526... | Line 528... | ||
526 | radeon_show_cursor_kms(rdisplay->crtc); |
528 | radeon_show_cursor_kms(rdisplay->crtc); |
527 | }; |
529 | }; |
528 | safe_sti(ifl); |
530 | safe_sti(ifl); |
529 | 531 | ||
Line -... | Line 532... | ||
- | 532 | init_bitmaps(); |
|
- | 533 | ||
530 | LEAVE(); |
534 | LEAVE(); |
Line 531... | Line 535... | ||
531 | 535 | ||
532 | return retval; |
536 | return retval; |
Line 671... | Line 675... | ||
671 | return 0; |
675 | return 0; |
672 | }><>>=><=>><>><>><>><>><>><>><>>>><>><>><>><>><>><>><>><> |
676 | } |
673 | 677 | ||
Line -... | Line 678... | ||
- | 678 | ||
- | 679 | typedef struct |
|
- | 680 | { |
|
- | 681 | int left; |
|
- | 682 | int top; |
|
- | 683 | int right; |
|
- | 684 | int bottom; |
|
- | 685 | }rect_t; |
|
- | 686 | ||
- | 687 | extern struct hmm bm_mm; |
|
- | 688 | struct drm_device *main_drm_device; |
|
- | 689 | ||
- | 690 | void FASTCALL GetWindowRect(rect_t *rc)__asm__("GetWindowRect"); |
|
- | 691 | ||
- | 692 | #define CURRENT_TASK (0x80003000) |
|
- | 693 | ||
- | 694 | static u32_t get_display_map() |
|
- | 695 | { |
|
- | 696 | u32_t addr; |
|
- | 697 | ||
- | 698 | addr = (u32_t)rdisplay; |
|
- | 699 | addr+= sizeof(display_t); /* shoot me */ |
|
- | 700 | return *(u32_t*)addr; |
|
- | 701 | } |
|
- | 702 | ||
- | 703 | #include "clip.inc" |
|
- | 704 | #include "r100d.h" |
|
- | 705 | ||
- | 706 | # define PACKET3_BITBLT 0x92 |
|
- | 707 | ||
- | 708 | ||
- | 709 | int srv_blit_bitmap(u32 hbitmap, int dst_x, int dst_y, |
|
- | 710 | int src_x, int src_y, u32 w, u32 h) |
|
- | 711 | { |
|
- | 712 | struct context *context; |
|
- | 713 | ||
- | 714 | bitmap_t *bitmap; |
|
- | 715 | rect_t winrc; |
|
- | 716 | clip_t dst_clip; |
|
- | 717 | clip_t src_clip; |
|
- | 718 | u32_t width; |
|
- | 719 | u32_t height; |
|
- | 720 | ||
- | 721 | u32_t br13, cmd, slot_mask, *b; |
|
- | 722 | u32_t offset; |
|
- | 723 | u8 slot; |
|
- | 724 | int n=0; |
|
- | 725 | int ret; |
|
- | 726 | ||
- | 727 | if(unlikely(hbitmap==0)) |
|
- | 728 | return -1; |
|
- | 729 | ||
- | 730 | bitmap = (bitmap_t*)hmm_get_data(&bm_mm, hbitmap); |
|
- | 731 | ||
- | 732 | if(unlikely(bitmap==NULL)) |
|
- | 733 | return -1; |
|
- | 734 | ||
- | 735 | context = get_context(main_drm_device); |
|
- | 736 | if(unlikely(context == NULL)) |
|
- | 737 | return -1; |
|
- | 738 | ||
- | 739 | GetWindowRect(&winrc); |
|
- | 740 | { |
|
- | 741 | static warn_count; |
|
- | 742 | ||
- | 743 | if(warn_count < 1) |
|
- | 744 | { |
|
- | 745 | printf("left %d top %d right %d bottom %d\n", |
|
- | 746 | winrc.left, winrc.top, winrc.right, winrc.bottom); |
|
- | 747 | printf("bitmap width %d height %d\n", w, h); |
|
- | 748 | warn_count++; |
|
- | 749 | }; |
|
- | 750 | }; |
|
- | 751 | ||
- | 752 | ||
- | 753 | dst_clip.xmin = 0; |
|
- | 754 | dst_clip.ymin = 0; |
|
- | 755 | dst_clip.xmax = winrc.right-winrc.left; |
|
- | 756 | dst_clip.ymax = winrc.bottom -winrc.top; |
|
- | 757 | ||
- | 758 | src_clip.xmin = 0; |
|
- | 759 | src_clip.ymin = 0; |
|
- | 760 | src_clip.xmax = bitmap->width - 1; |
|
- | 761 | src_clip.ymax = bitmap->height - 1; |
|
- | 762 | ||
- | 763 | width = w; |
|
- | 764 | height = h; |
|
- | 765 | ||
- | 766 | if( blit_clip(&dst_clip, &dst_x, &dst_y, |
|
- | 767 | &src_clip, &src_x, &src_y, |
|
- | 768 | &width, &height) ) |
|
- | 769 | return 0; |
|
- | 770 | ||
- | 771 | dst_x+= winrc.left; |
|
- | 772 | dst_y+= winrc.top; |
|
- | 773 | ||
- | 774 | slot = *((u8*)CURRENT_TASK); |
|
- | 775 | ||
- | 776 | slot_mask = (u32_t)slot<<24; |
|
- | 777 | ||
- | 778 | { |
|
- | 779 | #if 1 |
|
- | 780 | #else |
|
- | 781 | u8* src_offset; |
|
- | 782 | u8* dst_offset; |
|
- | 783 | u32 ifl; |
|
- | 784 | ||
- | 785 | src_offset = (u8*)(src_y*bitmap->pitch + src_x*4); |
|
- | 786 | src_offset += (u32)bitmap->uaddr; |
|
- | 787 | ||
- | 788 | dst_offset = (u8*)(dst_y*rdisplay->width + dst_x); |
|
- | 789 | dst_offset+= get_display_map(); |
|
- | 790 | ||
- | 791 | u32_t tmp_h = height; |
|
- | 792 | ||
- | 793 | ifl = safe_cli(); |
|
- | 794 | while( tmp_h--) |
|
- | 795 | { |
|
- | 796 | u32_t tmp_w = width; |
|
- | 797 | ||
- | 798 | u8* tmp_src = src_offset; |
|
- | 799 | u8* tmp_dst = dst_offset; |
|
- | 800 | ||
- | 801 | src_offset+= bitmap->pitch; |
|
- | 802 | dst_offset+= rdisplay->width; |
|
- | 803 | ||
- | 804 | while( tmp_w--) |
|
- | 805 | { |
|
- | 806 | *(tmp_src+3) = (*tmp_dst==slot)?0xFF:0x00; |
|
- | 807 | tmp_src+=4; |
|
- | 808 | tmp_dst++; |
|
- | 809 | }; |
|
- | 810 | }; |
|
- | 811 | safe_sti(ifl); |
|
- | 812 | #endif |
|
- | 813 | } |
|
- | 814 | ||
- | 815 | { |
|
- | 816 | static warn_count; |
|
- | 817 | ||
- | 818 | if(warn_count < 1) |
|
- | 819 | { |
|
- | 820 | printf("blit width %d height %d\n", |
|
- | 821 | width, height); |
|
- | 822 | warn_count++; |
|
- | 823 | }; |
|
- | 824 | }; |
|
- | 825 | ||
- | 826 | ||
- | 827 | // if((context->cmd_buffer & 0xFC0)==0xFC0) |
|
- | 828 | // context->cmd_buffer&= 0xFFFFF000; |
|
- | 829 | ||
- | 830 | // b = (u32_t*)ALIGN(context->cmd_buffer,64); |
|
- | 831 | ||
- | 832 | // offset = context->cmd_offset + ((u32_t)b & 0xFFF); |
|
- | 833 | ||
- | 834 | ||
- | 835 | // context->cmd_buffer+= n*4; |
|
- | 836 | ||
- | 837 | struct radeon_device *rdev = main_drm_device->dev_private; |
|
- | 838 | struct radeon_ib *ib = &context->ib; |
|
- | 839 | ||
- | 840 | ib->ptr[0] = PACKET3(PACKET3_BITBLT, 8); |
|
- | 841 | ib->ptr[1] = RADEON_GMC_SRC_PITCH_OFFSET_CNTL | |
|
- | 842 | RADEON_GMC_DST_PITCH_OFFSET_CNTL | |
|
- | 843 | RADEON_GMC_SRC_CLIPPING | |
|
- | 844 | RADEON_GMC_DST_CLIPPING | |
|
- | 845 | RADEON_GMC_BRUSH_NONE | |
|
- | 846 | (RADEON_COLOR_FORMAT_ARGB8888 << 8) | |
|
- | 847 | RADEON_GMC_SRC_DATATYPE_COLOR | |
|
- | 848 | RADEON_ROP3_S | |
|
- | 849 | RADEON_DP_SRC_SOURCE_MEMORY | |
|
- | 850 | RADEON_GMC_CLR_CMP_CNTL_DIS | |
|
- | 851 | RADEON_GMC_WR_MSK_DIS; |
|
- | 852 | ||
- | 853 | ib->ptr[2] = ((bitmap->pitch/64) << 22) | (bitmap->gaddr >> 10); |
|
- | 854 | ib->ptr[3] = ((rdisplay->pitch/64) << 22) | (rdev->mc.vram_start >> 10); |
|
- | 855 | ib->ptr[4] = (0x1fff) | (0x1fff << 16); |
|
- | 856 | ib->ptr[5] = 0; |
|
- | 857 | ib->ptr[6] = (0x1fff) | (0x1fff << 16); |
|
- | 858 | ||
- | 859 | ib->ptr[7] = (src_x << 16) | src_y; |
|
- | 860 | ib->ptr[8] = (dst_x << 16) | dst_y; |
|
- | 861 | ib->ptr[9] = (width << 16) | height; |
|
- | 862 | ||
- | 863 | ib->ptr[10] = PACKET2(0); |
|
- | 864 | ib->ptr[11] = PACKET2(0); |
|
- | 865 | ib->ptr[12] = PACKET2(0); |
|
- | 866 | ib->ptr[13] = PACKET2(0); |
|
- | 867 | ib->ptr[14] = PACKET2(0); |
|
- | 868 | ib->ptr[15] = PACKET2(0); |
|
- | 869 | ||
- | 870 | ib->length_dw = 16; |
|
- | 871 | ||
- | 872 | ret = radeon_ib_schedule(rdev, ib, NULL); |
|
- | 873 | if (ret) { |
|
- | 874 | DRM_ERROR("radeon: failed to schedule ib (%d).\n", ret); |
|
- | 875 | goto fail; |
|
- | 876 | } |
|
- | 877 | ||
- | 878 | ret = radeon_fence_wait(ib->fence, false); |
|
- | 879 | if (ret) { |
|
- | 880 | DRM_ERROR("radeon: fence wait failed (%d).\n", ret); |
|
- | 881 | goto fail; |
|
- | 882 | } |
|
- | 883 | ||
- | 884 | fail: |
|
- | 885 | return ret; |
|
- | 886 | };><>><>><>><>><>><>><>><>>24; |