commandProcessing.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. /*
  2. * linux/arch/arm/mach-omap1/lcd_dma.c
  3. *
  4. * Extracted from arch/arm/plat-omap/dma.c
  5. * Copyright (C) 2003 - 2008 Nokia Corporation
  6. * Author: Juha Yrjölä <juha.yrjola@nokia.com>
  7. * DMA channel linking for 1610 by Samuel Ortiz <samuel.ortiz@nokia.com>
  8. * Graphics DMA and LCD DMA graphics tranformations
  9. * by Imre Deak <imre.deak@nokia.com>
  10. * OMAP2/3 support Copyright (C) 2004-2007 Texas Instruments, Inc.
  11. * Merged to support both OMAP1 and OMAP2 by Tony Lindgren <tony@atomide.com>
  12. * Some functions based on earlier dma-omap.c Copyright (C) 2001 RidgeRun, Inc.
  13. *
  14. * Copyright (C) 2009 Texas Instruments
  15. * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com>
  16. *
  17. * Support functions for the OMAP internal DMA channels.
  18. *
  19. * This program is free software; you can redistribute it and/or modify
  20. * it under the terms of the GNU General Public License version 2 as
  21. * published by the Free Software Foundation.
  22. *
  23. */
  24. #include <linux/module.h>
  25. #include <linux/spinlock.h>
  26. #include <linux/interrupt.h>
  27. #include <linux/io.h>
  28. #include <linux/omap-dma.h>
  29. #include <mach/hardware.h>
  30. #include <mach/lcdc.h>
  31. #include "dma.h"
  32. int omap_lcd_dma_running(void)
  33. {
  34. /*
  35. * On OMAP1510, internal LCD controller will start the transfer
  36. * when it gets enabled, so assume DMA running if LCD enabled.
  37. */
  38. if (cpu_is_omap15xx())
  39. if (omap_readw(OMAP_LCDC_CONTROL) & OMAP_LCDC_CTRL_LCD_EN)
  40. return 1;
  41. /* Check if LCD DMA is running */
  42. if (cpu_is_omap16xx())
  43. if (omap_readw(OMAP1610_DMA_LCD_CCR) & OMAP_DMA_CCR_EN)
  44. return 1;
  45. return 0;
  46. }
  47. static struct lcd_dma_info {
  48. spinlock_t lock;
  49. int reserved;
  50. void (*callback)(u16 status, void *data);
  51. void *cb_data;
  52. int active;
  53. unsigned long addr;
  54. int rotate, data_type, xres, yres;
  55. int vxres;
  56. int mirror;
  57. int xscale, yscale;
  58. int ext_ctrl;
  59. int src_port;
  60. int single_transfer;
  61. } lcd_dma;
  62. void omap_set_lcd_dma_b1(unsigned long addr, u16 fb_xres, u16 fb_yres,
  63. int data_type)
  64. {
  65. lcd_dma.addr = addr;
  66. lcd_dma.data_type = data_type;
  67. lcd_dma.xres = fb_xres;
  68. lcd_dma.yres = fb_yres;
  69. }
  70. EXPORT_SYMBOL(omap_set_lcd_dma_b1);
  71. void omap_set_lcd_dma_ext_controller(int external)
  72. {
  73. lcd_dma.ext_ctrl = external;
  74. }
  75. EXPORT_SYMBOL(omap_set_lcd_dma_ext_controller);
  76. void omap_set_lcd_dma_single_transfer(int single)
  77. {
  78. lcd_dma.single_transfer = single;
  79. }
  80. EXPORT_SYMBOL(omap_set_lcd_dma_single_transfer);
  81. void omap_set_lcd_dma_b1_rotation(int rotate)
  82. {
  83. if (cpu_is_omap15xx()) {
  84. printk(KERN_ERR "DMA rotation is not supported in 1510 mode\n");
  85. BUG();
  86. return;
  87. }
  88. lcd_dma.rotate = rotate;
  89. }
  90. EXPORT_SYMBOL(omap_set_lcd_dma_b1_rotation);
  91. void omap_set_lcd_dma_b1_mirror(int mirror)
  92. {
  93. if (cpu_is_omap15xx()) {
  94. printk(KERN_ERR "DMA mirror is not supported in 1510 mode\n");
  95. BUG();
  96. }
  97. lcd_dma.mirror = mirror;
  98. }
  99. EXPORT_SYMBOL(omap_set_lcd_dma_b1_mirror);
  100. void omap_set_lcd_dma_b1_vxres(unsigned long vxres)
  101. {
  102. if (cpu_is_omap15xx()) {
  103. pr_err("DMA virtual resolution is not supported in 1510 mode\n");
  104. BUG();
  105. }
  106. lcd_dma.vxres = vxres;
  107. }
  108. EXPORT_SYMBOL(omap_set_lcd_dma_b1_vxres);
  109. void omap_set_lcd_dma_b1_scale(unsigned int xscale, unsigned int yscale)
  110. {
  111. if (cpu_is_omap15xx()) {
  112. printk(KERN_ERR "DMA scale is not supported in 1510 mode\n");
  113. BUG();
  114. }
  115. lcd_dma.xscale = xscale;
  116. lcd_dma.yscale = yscale;
  117. }
  118. EXPORT_SYMBOL(omap_set_lcd_dma_b1_scale);
  119. static void set_b1_regs(void)
  120. {
  121. unsigned long top, bottom;
  122. int es;
  123. u16 w;
  124. unsigned long en, fn;
  125. long ei, fi;
  126. unsigned long vxres;
  127. unsigned int xscale, yscale;
  128. switch (lcd_dma.data_type) {
  129. case OMAP_DMA_DATA_TYPE_S8:
  130. es = 1;
  131. break;
  132. case OMAP_DMA_DATA_TYPE_S16:
  133. es = 2;
  134. break;
  135. case OMAP_DMA_DATA_TYPE_S32:
  136. es = 4;
  137. break;
  138. default:
  139. BUG();
  140. return;
  141. }
  142. vxres = lcd_dma.vxres ? lcd_dma.vxres : lcd_dma.xres;
  143. xscale = lcd_dma.xscale ? lcd_dma.xscale : 1;
  144. yscale = lcd_dma.yscale ? lcd_dma.yscale : 1;
  145. BUG_ON(vxres < lcd_dma.xres);
  146. #define PIXADDR(x, y) (lcd_dma.addr + \
  147. ((y) * vxres * yscale + (x) * xscale) * es)
  148. #define PIXSTEP(sx, sy, dx, dy) (PIXADDR(dx, dy) - PIXADDR(sx, sy) - es + 1)
  149. switch (lcd_dma.rotate) {
  150. case 0:
  151. if (!lcd_dma.mirror) {
  152. top = PIXADDR(0, 0);
  153. bottom = PIXADDR(lcd_dma.xres - 1, lcd_dma.yres - 1);
  154. /* 1510 DMA requires the bottom address to be 2 more
  155. * than the actual last memory access location. */
  156. if (cpu_is_omap15xx() &&
  157. lcd_dma.data_type == OMAP_DMA_DATA_TYPE_S32)
  158. bottom += 2;
  159. ei = PIXSTEP(0, 0, 1, 0);
  160. fi = PIXSTEP(lcd_dma.xres - 1, 0, 0, 1);
  161. } else {
  162. top = PIXADDR(lcd_dma.xres - 1, 0);
  163. bottom = PIXADDR(0, lcd_dma.yres - 1);
  164. ei = PIXSTEP(1, 0, 0, 0);
  165. fi = PIXSTEP(0, 0, lcd_dma.xres - 1, 1);
  166. }
  167. en = lcd_dma.xres;
  168. fn = lcd_dma.yres;
  169. break;
  170. case 90:
  171. if (!lcd_dma.mirror) {
  172. top = PIXADDR(0, lcd_dma.yres - 1);
  173. bottom = PIXADDR(lcd_dma.xres - 1, 0);
  174. ei = PIXSTEP(0, 1, 0, 0);
  175. fi = PIXSTEP(0, 0, 1, lcd_dma.yres - 1);
  176. } else {
  177. top = PIXADDR(lcd_dma.xres - 1, lcd_dma.yres - 1);
  178. bottom = PIXADDR(0, 0);
  179. ei = PIXSTEP(0, 1, 0, 0);
  180. fi = PIXSTEP(1, 0, 0, lcd_dma.yres - 1);
  181. }
  182. en = lcd_dma.yres;
  183. fn = lcd_dma.xres;
  184. break;
  185. case 180:
  186. if (!lcd_dma.mirror) {
  187. top = PIXADDR(lcd_dma.xres - 1, lcd_dma.yres - 1);
  188. bottom = PIXADDR(0, 0);
  189. ei = PIXSTEP(1, 0, 0, 0);
  190. fi = PIXSTEP(0, 1, lcd_dma.xres - 1, 0);
  191. } else {
  192. top = PIXADDR(0, lcd_dma.yres - 1);
  193. bottom = PIXADDR(lcd_dma.xres - 1, 0);
  194. ei = PIXSTEP(0, 0, 1, 0);
  195. fi = PIXSTEP(lcd_dma.xres - 1, 1, 0, 0);
  196. }
  197. en = lcd_dma.xres;
  198. fn = lcd_dma.yres;
  199. break;
  200. case 270:
  201. if (!lcd_dma.mirror) {
  202. top = PIXADDR(lcd_dma.xres - 1, 0);
  203. bottom = PIXADDR(0, lcd_dma.yres - 1);
  204. ei = PIXSTEP(0, 0, 0, 1);
  205. fi = PIXSTEP(1, lcd_dma.yres - 1, 0, 0);
  206. } else {
  207. top = PIXADDR(0, 0);
  208. bottom = PIXADDR(lcd_dma.xres - 1, lcd_dma.yres - 1);
  209. ei = PIXSTEP(0, 0, 0, 1);
  210. fi = PIXSTEP(0, lcd_dma.yres - 1, 1, 0);
  211. }
  212. en = lcd_dma.yres;
  213. fn = lcd_dma.xres;
  214. break;
  215. default:
  216. BUG();
  217. return; /* Suppress warning about uninitialized vars */
  218. }
  219. if (cpu_is_omap15xx()) {
  220. omap_writew(top >> 16, OMAP1510_DMA_LCD_TOP_F1_U);
  221. omap_writew(top, OMAP1510_DMA_LCD_TOP_F1_L);
  222. omap_writew(bottom >> 16, OMAP1510_DMA_LCD_BOT_F1_U);