patch-src_smi_video_c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. --- xf86-video-siliconmotion-1.7.7.orig/src/smi_video.c 2012-07-17 06:53:21.000000000 +0200
  2. +++ xf86-video-siliconmotion-1.7.7/src/smi_video.c 2014-03-14 18:35:37.546382342 +0100
  3. @@ -275,6 +275,7 @@ static XF86ImageRec SMI_VideoImages[] =
  4. XVIMAGE_YUY2,
  5. XVIMAGE_YV12,
  6. XVIMAGE_I420,
  7. + XVIMAGE_UYVY,
  8. {
  9. FOURCC_RV15, /* id */
  10. XvRGB, /* type */
  11. @@ -1461,6 +1462,117 @@ SMI_QueryBestSize(
  12. LEAVE();
  13. }
  14. +static void myXVCopyYUV12ToPacked(const unsigned char *srcy, const unsigned char *srcv, const unsigned char *srcu,
  15. + unsigned char *dst, int srcPitchy, int srcPitchuv, int dstPitch, int h, int w)
  16. +{
  17. + int i, j;
  18. + unsigned char const *y, *u, *v;
  19. + int dstinc, yinc, uinc, vinc;
  20. +
  21. + y = srcy;
  22. + u = srcu;
  23. + v = srcv;
  24. +
  25. + dstinc = dstPitch - 2*w;
  26. + yinc = srcPitchy - w;
  27. + uinc = srcPitchuv - w/2;
  28. + vinc = srcPitchuv - w/2;
  29. +
  30. + for (i = 0; i < h; i++) {
  31. + asm (
  32. +// ".set arch=loongson2f\n\t"
  33. + ".set noreorder\n\t"
  34. + "move $8, %8 \n\t"
  35. + "1: \n\t"
  36. + "beqz $8, 2f \n\t"
  37. + "xor $f0, $f0, $f0 \n\t"
  38. + "ldc1 $f4, (%0) \n\t"
  39. + "punpcklbh $f2, $f4, $f0 \n\t"
  40. + "punpckhbh $f4, $f4, $f0 \n\t"
  41. + "ldc1 $f16, 8(%0) \n\t"
  42. + "punpcklbh $f14, $f16, $f0 \n\t"
  43. + "punpckhbh $f16, $f16, $f0 \n\t"
  44. +
  45. + "lwc1 $f8, (%1) \n\t"
  46. + "lwc1 $f12, (%2) \n\t"
  47. + "punpcklbh $f8, $f8, $f12 \n\t"
  48. + "punpcklbh $f6, $f0, $f8 \n\t"
  49. + "punpckhbh $f8, $f0, $f8 \n\t"
  50. + "lwc1 $f18, 4(%1) \n\t"
  51. + "lwc1 $f12, 4(%2) \n\t"
  52. + "punpcklbh $f18, $f18, $f12 \n\t"
  53. + "punpcklbh $f10, $f0, $f18 \n\t"
  54. + "punpckhbh $f12, $f0, $f18 \n\t"
  55. +
  56. + "or $f2, $f2, $f6 \n\t"
  57. + "or $f4, $f4, $f8 \n\t"
  58. + "or $f14, $f14, $f10 \n\t"
  59. + "or $f16, $f16, $f12 \n\t"
  60. +
  61. + "sdc1 $f2, (%3) \n\t"
  62. + "sdc1 $f4, 8(%3) \n\t"
  63. + "add %0, 16 \n\t"
  64. + "add %1, 8 \n\t"
  65. + "add %2, 8 \n\t"
  66. + "sdc1 $f14, 0x10(%3) \n\t"
  67. + "sdc1 $f16, 0x18(%3) \n\t"
  68. + "add $8, -1 \n\t"
  69. + "b 1b \n\t"
  70. + "add %3, 32 \n\t"
  71. + "2: \n\t"
  72. + ".set reorder\n\t"
  73. + : "=r" (y), "=r" (u), "=r" (v), "=r" (dst)
  74. + : "0" (y), "1" (u), "2" (v), "3" (dst), "r" (w>>4)
  75. + : "memory","$8"
  76. + );
  77. +
  78. + asm (
  79. +// ".set arch=loongson2f\n\t"
  80. + ".set noreorder\n\t"
  81. + "move $8, %8 \n\t"
  82. + "1: \n\t"
  83. + "beqz $8, 2f \n\t"
  84. + "xor $f0, $f0, $f0 \n\t"
  85. + "ldc1 $f4, (%0) \n\t"
  86. + "punpcklbh $f2, $f4, $f0 \n\t"
  87. + "punpckhbh $f4, $f4, $f0 \n\t"
  88. +
  89. + "lwc1 $f8, (%1) \n\t"
  90. + "lwc1 $f12, (%2) \n\t"
  91. + "punpcklbh $f8, $f8, $f12 \n\t"
  92. + "punpcklbh $f6, $f0, $f8 \n\t"
  93. + "punpckhbh $f8, $f0, $f8 \n\t"
  94. +
  95. + "or $f2, $f2, $f6 \n\t"
  96. + "or $f4, $f4, $f8 \n\t"
  97. +
  98. + "sdc1 $f2, (%3) \n\t"
  99. + "sdc1 $f4, 8(%3) \n\t"
  100. + "add %0, 8 \n\t"
  101. + "add %1, 4 \n\t"
  102. + "add %2, 4 \n\t"
  103. + "add $8, -1 \n\t"
  104. + "b 1b \n\t"
  105. + "add %3, 16 \n\t"
  106. + "2:\n\t"
  107. + ".set reorder\n\t"
  108. + : "=r" (y), "=r" (u), "=r" (v), "=r" (dst)
  109. + : "0" (y), "1" (u), "2" (v), "3" (dst), "r" ((w&0xf)/8)
  110. + : "memory","$8"
  111. + );
  112. +
  113. + for (j = (w&7)/2; j; j--) {
  114. + *dst++ = *y++;
  115. + *dst++ = *u++;
  116. + *dst++ = *y++;
  117. + *dst++ = *v++;
  118. + }
  119. + y += yinc;
  120. + u = (i%2) ? (u + uinc): (u - w/2);
  121. + v = (i%2) ? (v + vinc): (v - w/2);
  122. + dst += dstinc;
  123. + }
  124. +}
  125. static int
  126. SMI_PutImage(
  127. @@ -1592,7 +1704,7 @@ SMI_PutImage(
  128. offset3 = tmp;
  129. }
  130. nLines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - top;
  131. - xf86XVCopyYUV12ToPacked(buf + (top * srcPitch) + (left >> 1),
  132. + myXVCopyYUV12ToPacked(buf + (top * srcPitch) + (left >> 1),
  133. buf + offset2, buf + offset3, dstStart,
  134. srcPitch, srcPitch2, dstPitch, nLines,
  135. nPixels);