xf86-video-siliconmotion-1.7.3-fix-loongson.patch 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. diff -ur orig/src/smi_video.c mod/src/smi_video.c
  2. --- xf86-video-siliconmotion-1.7.3.orig/src/smi_video.c 2009-07-27 05:42:44.000000000 +0200
  3. +++ xf86-video-siliconmotion-1.7.3/src/smi_video.c 2010-06-03 16:55:59.169793245 +0200
  4. @@ -276,6 +276,7 @@ static XF86ImageRec SMI_VideoImages[] =
  5. XVIMAGE_YUY2,
  6. XVIMAGE_YV12,
  7. XVIMAGE_I420,
  8. + XVIMAGE_UYVY,
  9. {
  10. FOURCC_RV15, /* id */
  11. XvRGB, /* type */
  12. @@ -1103,7 +1104,7 @@ SMI_PutVideo(
  13. vpr00 |= 0x0010000E;
  14. } else {
  15. /*
  16. - Bit 21 = 10: Vertical Interpolation = enabled
  17. + Bit 21 = 1: Vertical Interpolation = enabled
  18. Bit 24 = 1: Select Video Window I Source Addr = 1
  19. 1= Video window I source addr = capture port buffer ?
  20. */
  21. @@ -1464,6 +1465,117 @@ SMI_QueryBestSize(
  22. LEAVE();
  23. }
  24. +static void myXVCopyYUV12ToPacked(const unsigned char *srcy, const unsigned char *srcv, const unsigned char *srcu,
  25. + unsigned char *dst, int srcPitchy, int srcPitchuv, int dstPitch, int h, int w)
  26. +{
  27. + int i, j;
  28. + unsigned char const *y, *u, *v;
  29. + int dstinc, yinc, uinc, vinc;
  30. +
  31. + y = srcy;
  32. + u = srcu;
  33. + v = srcv;
  34. +
  35. + dstinc = dstPitch - 2*w;
  36. + yinc = srcPitchy - w;
  37. + uinc = srcPitchuv - w/2;
  38. + vinc = srcPitchuv - w/2;
  39. +
  40. + for (i = 0; i < h; i++) {
  41. + asm (
  42. +// ".set arch=loongson2f\n\t"
  43. + ".set noreorder\n\t"
  44. + "move $8, %8 \n\t"
  45. + "1: \n\t"
  46. + "beqz $8, 2f \n\t"
  47. + "xor $f0, $f0, $f0 \n\t"
  48. + "ldc1 $f4, (%0) \n\t"
  49. + "punpcklbh $f2, $f4, $f0 \n\t"
  50. + "punpckhbh $f4, $f4, $f0 \n\t"
  51. + "ldc1 $f16, 8(%0) \n\t"
  52. + "punpcklbh $f14, $f16, $f0 \n\t"
  53. + "punpckhbh $f16, $f16, $f0 \n\t"
  54. +
  55. + "lwc1 $f8, (%1) \n\t"
  56. + "lwc1 $f12, (%2) \n\t"
  57. + "punpcklbh $f8, $f8, $f12 \n\t"
  58. + "punpcklbh $f6, $f0, $f8 \n\t"
  59. + "punpckhbh $f8, $f0, $f8 \n\t"
  60. + "lwc1 $f18, 4(%1) \n\t"
  61. + "lwc1 $f12, 4(%2) \n\t"
  62. + "punpcklbh $f18, $f18, $f12 \n\t"
  63. + "punpcklbh $f10, $f0, $f18 \n\t"
  64. + "punpckhbh $f12, $f0, $f18 \n\t"
  65. +
  66. + "or $f2, $f2, $f6 \n\t"
  67. + "or $f4, $f4, $f8 \n\t"
  68. + "or $f14, $f14, $f10 \n\t"
  69. + "or $f16, $f16, $f12 \n\t"
  70. +
  71. + "sdc1 $f2, (%3) \n\t"
  72. + "sdc1 $f4, 8(%3) \n\t"
  73. + "add %0, 16 \n\t"
  74. + "add %1, 8 \n\t"
  75. + "add %2, 8 \n\t"
  76. + "sdc1 $f14, 0x10(%3) \n\t"
  77. + "sdc1 $f16, 0x18(%3) \n\t"
  78. + "add $8, -1 \n\t"
  79. + "b 1b \n\t"
  80. + "add %3, 32 \n\t"
  81. + "2: \n\t"
  82. + ".set reorder\n\t"
  83. + : "=r" (y), "=r" (u), "=r" (v), "=r" (dst)
  84. + : "0" (y), "1" (u), "2" (v), "3" (dst), "r" (w>>4)
  85. + : "memory","$8"
  86. + );
  87. +
  88. + asm (
  89. +// ".set arch=loongson2f\n\t"
  90. + ".set noreorder\n\t"
  91. + "move $8, %8 \n\t"
  92. + "1: \n\t"
  93. + "beqz $8, 2f \n\t"
  94. + "xor $f0, $f0, $f0 \n\t"
  95. + "ldc1 $f4, (%0) \n\t"
  96. + "punpcklbh $f2, $f4, $f0 \n\t"
  97. + "punpckhbh $f4, $f4, $f0 \n\t"
  98. +
  99. + "lwc1 $f8, (%1) \n\t"
  100. + "lwc1 $f12, (%2) \n\t"
  101. + "punpcklbh $f8, $f8, $f12 \n\t"
  102. + "punpcklbh $f6, $f0, $f8 \n\t"
  103. + "punpckhbh $f8, $f0, $f8 \n\t"
  104. +
  105. + "or $f2, $f2, $f6 \n\t"
  106. + "or $f4, $f4, $f8 \n\t"
  107. +
  108. + "sdc1 $f2, (%3) \n\t"
  109. + "sdc1 $f4, 8(%3) \n\t"
  110. + "add %0, 8 \n\t"
  111. + "add %1, 4 \n\t"
  112. + "add %2, 4 \n\t"
  113. + "add $8, -1 \n\t"
  114. + "b 1b \n\t"
  115. + "add %3, 16 \n\t"
  116. + "2:\n\t"
  117. + ".set reorder\n\t"
  118. + : "=r" (y), "=r" (u), "=r" (v), "=r" (dst)
  119. + : "0" (y), "1" (u), "2" (v), "3" (dst), "r" ((w&0xf)/8)
  120. + : "memory","$8"
  121. + );
  122. +
  123. + for (j = (w&7)/2; j; j--) {
  124. + *dst++ = *y++;
  125. + *dst++ = *u++;
  126. + *dst++ = *y++;
  127. + *dst++ = *v++;
  128. + }
  129. + y += yinc;
  130. + u = (i%2) ? (u + uinc): (u - w/2);
  131. + v = (i%2) ? (v + vinc): (v - w/2);
  132. + dst += dstinc;
  133. + }
  134. +}
  135. static int
  136. SMI_PutImage(
  137. @@ -1592,7 +1704,7 @@ SMI_PutImage(
  138. offset3 = tmp;
  139. }
  140. nLines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - top;
  141. - xf86XVCopyYUV12ToPacked(buf + (top * srcPitch) + (left >> 1),
  142. + myXVCopyYUV12ToPacked(buf + (top * srcPitch) + (left >> 1),
  143. buf + offset2, buf + offset3, dstStart,
  144. srcPitch, srcPitch2, dstPitch, nLines,
  145. nPixels);
  146. @@ -1747,7 +1859,7 @@ SMI_DisplayVideo(
  147. {
  148. SMIPtr pSmi = SMIPTR(pScrn);
  149. CARD32 vpr00;
  150. - int hstretch, vstretch;
  151. + uint_least32_t hstretch, vstretch;
  152. ENTER();
  153. @@ -1774,13 +1886,13 @@ SMI_DisplayVideo(
  154. }
  155. if (drw_w > vid_w) {
  156. - hstretch = (2560 * vid_w / drw_w + 5) / 10;
  157. + hstretch = ((uint_least32_t)(vid_w - 1) << 16) / (drw_w - 1);
  158. } else {
  159. hstretch = 0;
  160. }
  161. if (drw_h > vid_h) {
  162. - vstretch = (2560 * vid_h / drw_h + 5) / 10;
  163. + vstretch = ((uint_least32_t)(vid_h - 1) << 16) / (drw_h - 1);
  164. vpr00 |= 1 << 21;
  165. } else {
  166. vstretch = 0;
  167. @@ -1791,7 +1903,8 @@ SMI_DisplayVideo(
  168. WRITE_VPR(pSmi, 0x18, (dstBox->x2) | (dstBox->y2 << 16));
  169. WRITE_VPR(pSmi, 0x1C, offset >> 3);
  170. WRITE_VPR(pSmi, 0x20, (pitch >> 3) | ((pitch >> 3) << 16));
  171. - WRITE_VPR(pSmi, 0x24, (hstretch << 8) | vstretch);
  172. + WRITE_VPR(pSmi, 0x24, (hstretch & 0xff00) | ((vstretch & 0xff00) >> 8));
  173. + WRITE_VPR(pSmi, 0x68, ((hstretch & 0xff) << 8) | (vstretch & 0xff));
  174. LEAVE();
  175. }