vidc_fill.S 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /*
  2. * linux/drivers/sound/vidc_fill.S
  3. *
  4. * Copyright (C) 1997 Russell King
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * Filler routines for DMA buffers
  11. */
  12. #include <linux/linkage.h>
  13. #include <asm/assembler.h>
  14. #include <mach/hardware.h>
  15. #include <asm/hardware/iomd.h>
  16. .text
  17. ENTRY(vidc_fill_1x8_u)
  18. mov ip, #0xff00
  19. 1: cmp r0, r1
  20. bge vidc_clear
  21. ldrb r4, [r0], #1
  22. eor r4, r4, #0x80
  23. and r4, ip, r4, lsl #8
  24. orr r4, r4, r4, lsl #16
  25. str r4, [r2], #4
  26. cmp r2, r3
  27. blt 1b
  28. mov pc, lr
  29. ENTRY(vidc_fill_2x8_u)
  30. mov ip, #0xff00
  31. 1: cmp r0, r1
  32. bge vidc_clear
  33. ldr r4, [r0], #2
  34. and r5, r4, ip
  35. and r4, ip, r4, lsl #8
  36. orr r4, r4, r5, lsl #16
  37. orr r4, r4, r4, lsr #8
  38. str r4, [r2], #4
  39. cmp r2, r3
  40. blt 1b
  41. mov pc, lr
  42. ENTRY(vidc_fill_1x8_s)
  43. mov ip, #0xff00
  44. 1: cmp r0, r1
  45. bge vidc_clear
  46. ldrb r4, [r0], #1
  47. and r4, ip, r4, lsl #8
  48. orr r4, r4, r4, lsl #16
  49. str r4, [r2], #4
  50. cmp r2, r3
  51. blt 1b
  52. mov pc, lr
  53. ENTRY(vidc_fill_2x8_s)
  54. mov ip, #0xff00
  55. 1: cmp r0, r1
  56. bge vidc_clear
  57. ldr r4, [r0], #2
  58. and r5, r4, ip
  59. and r4, ip, r4, lsl #8
  60. orr r4, r4, r5, lsl #16
  61. orr r4, r4, r4, lsr #8
  62. str r4, [r2], #4
  63. cmp r2, r3
  64. blt 1b
  65. mov pc, lr
  66. ENTRY(vidc_fill_1x16_s)
  67. mov ip, #0xff00
  68. orr ip, ip, ip, lsr #8
  69. 1: cmp r0, r1
  70. bge vidc_clear
  71. ldr r5, [r0], #2
  72. and r4, r5, ip
  73. orr r4, r4, r4, lsl #16
  74. str r4, [r2], #4
  75. cmp r0, r1
  76. addlt r0, r0, #2
  77. andlt r4, r5, ip, lsl #16
  78. orrlt r4, r4, r4, lsr #16
  79. strlt r4, [r2], #4
  80. cmp r2, r3
  81. blt 1b
  82. mov pc, lr
  83. ENTRY(vidc_fill_2x16_s)
  84. mov ip, #0xff00
  85. orr ip, ip, ip, lsr #8
  86. 1: cmp r0, r1
  87. bge vidc_clear
  88. ldr r4, [r0], #4
  89. str r4, [r2], #4
  90. cmp r0, r1
  91. ldrlt r4, [r0], #4
  92. strlt r4, [r2], #4
  93. cmp r2, r3
  94. blt 1b
  95. mov pc, lr
  96. ENTRY(vidc_fill_noaudio)
  97. mov r0, #0
  98. mov r1, #0
  99. 2: mov r4, #0
  100. mov r5, #0
  101. 1: cmp r2, r3
  102. stmltia r2!, {r0, r1, r4, r5}
  103. blt 1b
  104. mov pc, lr
  105. ENTRY(vidc_clear)
  106. mov r0, #0
  107. mov r1, #0
  108. tst r2, #4
  109. str r0, [r2], #4
  110. tst r2, #8
  111. stmia r2!, {r0, r1}
  112. b 2b
  113. /*
  114. * Call filler routines with:
  115. * r0 = phys address
  116. * r1 = phys end
  117. * r2 = buffer
  118. * Returns:
  119. * r0 = new buffer address
  120. * r2 = new buffer finish
  121. * r4 = corrupted
  122. * r5 = corrupted
  123. * ip = corrupted
  124. */
  125. ENTRY(vidc_sound_dma_irq)
  126. stmfd sp!, {r4 - r8, lr}
  127. ldr r8, =dma_start
  128. ldmia r8, {r0, r1, r2, r3, r4, r5}
  129. teq r1, #0
  130. adreq r4, vidc_fill_noaudio
  131. moveq r7, #1 << 31
  132. movne r7, #0
  133. mov ip, #IOMD_BASE & 0xff000000
  134. orr ip, ip, #IOMD_BASE & 0x00ff0000
  135. ldrb r6, [ip, #IOMD_SD0ST]
  136. tst r6, #DMA_ST_OFL @ Check for overrun
  137. eorne r6, r6, #DMA_ST_AB
  138. tst r6, #DMA_ST_AB
  139. moveq r2, r3 @ DMAing A, update B
  140. add r3, r2, r5 @ End of DMA buffer
  141. add r1, r1, r0 @ End of virtual DMA buffer
  142. mov lr, pc
  143. mov pc, r4 @ Call fill routine (uses r4, ip)
  144. sub r1, r1, r0 @ Remaining length
  145. stmia r8, {r0, r1}
  146. mov r0, #0
  147. tst r2, #4 @ Round buffer up to 4 words
  148. strne r0, [r2], #4
  149. tst r2, #8
  150. strne r0, [r2], #4
  151. strne r0, [r2], #4
  152. sub r2, r2, #16
  153. mov r2, r2, lsl #20
  154. movs r2, r2, lsr #20
  155. orreq r2, r2, #1 << 30 @ Set L bit
  156. orr r2, r2, r7
  157. ldmdb r8, {r3, r4, r5}
  158. tst r6, #DMA_ST_AB
  159. mov ip, #IOMD_BASE & 0xff000000
  160. orr ip, ip, #IOMD_BASE & 0x00ff0000
  161. streq r4, [ip, #IOMD_SD0CURB]
  162. strne r5, [ip, #IOMD_SD0CURA]
  163. streq r2, [ip, #IOMD_SD0ENDB]
  164. strne r2, [ip, #IOMD_SD0ENDA]
  165. ldr lr, [ip, #IOMD_SD0ST]
  166. tst lr, #DMA_ST_OFL
  167. bne 1f
  168. tst r6, #DMA_ST_AB
  169. strne r4, [ip, #IOMD_SD0CURB]
  170. streq r5, [ip, #IOMD_SD0CURA]
  171. strne r2, [ip, #IOMD_SD0ENDB]
  172. streq r2, [ip, #IOMD_SD0ENDA]
  173. 1: teq r7, #0
  174. mov r0, #0x10
  175. strneb r0, [ip, #IOMD_SD0CR]
  176. ldmfd sp!, {r4 - r8, lr}
  177. mov r0, #1 @ IRQ_HANDLED
  178. teq r1, #0 @ If we have no more
  179. movne pc, lr
  180. teq r3, #0
  181. movne pc, r3 @ Call interrupt routine
  182. mov pc, lr
  183. .data
  184. .globl dma_interrupt
  185. dma_interrupt:
  186. .long 0 @ r3
  187. .globl dma_pbuf
  188. dma_pbuf:
  189. .long 0 @ r4
  190. .long 0 @ r5
  191. .globl dma_start
  192. dma_start:
  193. .long 0 @ r0
  194. .globl dma_count
  195. dma_count:
  196. .long 0 @ r1
  197. .globl dma_buf
  198. dma_buf:
  199. .long 0 @ r2
  200. .long 0 @ r3
  201. .globl vidc_filler
  202. vidc_filler:
  203. .long vidc_fill_noaudio @ r4
  204. .globl dma_bufsize
  205. dma_bufsize:
  206. .long 0x1000 @ r5