ipu.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /*
  2. * Copyright (C) 2008
  3. * Guennadi Liakhovetski, DENX Software Engineering, <lg@denx.de>
  4. *
  5. * Copyright (C) 2005-2007 Freescale Semiconductor, Inc.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #ifndef _IPU_H_
  12. #define _IPU_H_
  13. #include <linux/types.h>
  14. #include <linux/dmaengine.h>
  15. /* IPU DMA Controller channel definitions. */
  16. enum ipu_channel {
  17. IDMAC_IC_0 = 0, /* IC (encoding task) to memory */
  18. IDMAC_IC_1 = 1, /* IC (viewfinder task) to memory */
  19. IDMAC_ADC_0 = 1,
  20. IDMAC_IC_2 = 2,
  21. IDMAC_ADC_1 = 2,
  22. IDMAC_IC_3 = 3,
  23. IDMAC_IC_4 = 4,
  24. IDMAC_IC_5 = 5,
  25. IDMAC_IC_6 = 6,
  26. IDMAC_IC_7 = 7, /* IC (sensor data) to memory */
  27. IDMAC_IC_8 = 8,
  28. IDMAC_IC_9 = 9,
  29. IDMAC_IC_10 = 10,
  30. IDMAC_IC_11 = 11,
  31. IDMAC_IC_12 = 12,
  32. IDMAC_IC_13 = 13,
  33. IDMAC_SDC_0 = 14, /* Background synchronous display data */
  34. IDMAC_SDC_1 = 15, /* Foreground data (overlay) */
  35. IDMAC_SDC_2 = 16,
  36. IDMAC_SDC_3 = 17,
  37. IDMAC_ADC_2 = 18,
  38. IDMAC_ADC_3 = 19,
  39. IDMAC_ADC_4 = 20,
  40. IDMAC_ADC_5 = 21,
  41. IDMAC_ADC_6 = 22,
  42. IDMAC_ADC_7 = 23,
  43. IDMAC_PF_0 = 24,
  44. IDMAC_PF_1 = 25,
  45. IDMAC_PF_2 = 26,
  46. IDMAC_PF_3 = 27,
  47. IDMAC_PF_4 = 28,
  48. IDMAC_PF_5 = 29,
  49. IDMAC_PF_6 = 30,
  50. IDMAC_PF_7 = 31,
  51. };
  52. /* Order significant! */
  53. enum ipu_channel_status {
  54. IPU_CHANNEL_FREE,
  55. IPU_CHANNEL_INITIALIZED,
  56. IPU_CHANNEL_READY,
  57. IPU_CHANNEL_ENABLED,
  58. };
  59. #define IPU_CHANNELS_NUM 32
  60. enum pixel_fmt {
  61. /* 1 byte */
  62. IPU_PIX_FMT_GENERIC,
  63. IPU_PIX_FMT_RGB332,
  64. IPU_PIX_FMT_YUV420P,
  65. IPU_PIX_FMT_YUV422P,
  66. IPU_PIX_FMT_YUV420P2,
  67. IPU_PIX_FMT_YVU422P,
  68. /* 2 bytes */
  69. IPU_PIX_FMT_RGB565,
  70. IPU_PIX_FMT_RGB666,
  71. IPU_PIX_FMT_BGR666,
  72. IPU_PIX_FMT_YUYV,
  73. IPU_PIX_FMT_UYVY,
  74. /* 3 bytes */
  75. IPU_PIX_FMT_RGB24,
  76. IPU_PIX_FMT_BGR24,
  77. /* 4 bytes */
  78. IPU_PIX_FMT_GENERIC_32,
  79. IPU_PIX_FMT_RGB32,
  80. IPU_PIX_FMT_BGR32,
  81. IPU_PIX_FMT_ABGR32,
  82. IPU_PIX_FMT_BGRA32,
  83. IPU_PIX_FMT_RGBA32,
  84. };
  85. enum ipu_color_space {
  86. IPU_COLORSPACE_RGB,
  87. IPU_COLORSPACE_YCBCR,
  88. IPU_COLORSPACE_YUV
  89. };
  90. /*
  91. * Enumeration of IPU rotation modes
  92. */
  93. enum ipu_rotate_mode {
  94. /* Note the enum values correspond to BAM value */
  95. IPU_ROTATE_NONE = 0,
  96. IPU_ROTATE_VERT_FLIP = 1,
  97. IPU_ROTATE_HORIZ_FLIP = 2,
  98. IPU_ROTATE_180 = 3,
  99. IPU_ROTATE_90_RIGHT = 4,
  100. IPU_ROTATE_90_RIGHT_VFLIP = 5,
  101. IPU_ROTATE_90_RIGHT_HFLIP = 6,
  102. IPU_ROTATE_90_LEFT = 7,
  103. };
  104. struct ipu_platform_data {
  105. unsigned int irq_base;
  106. };
  107. /*
  108. * Enumeration of DI ports for ADC.
  109. */
  110. enum display_port {
  111. DISP0,
  112. DISP1,
  113. DISP2,
  114. DISP3
  115. };
  116. struct idmac_video_param {
  117. unsigned short in_width;
  118. unsigned short in_height;
  119. uint32_t in_pixel_fmt;
  120. unsigned short out_width;
  121. unsigned short out_height;
  122. uint32_t out_pixel_fmt;
  123. unsigned short out_stride;
  124. bool graphics_combine_en;
  125. bool global_alpha_en;
  126. bool key_color_en;
  127. enum display_port disp;
  128. unsigned short out_left;
  129. unsigned short out_top;
  130. };
  131. /*
  132. * Union of initialization parameters for a logical channel. So far only video
  133. * parameters are used.
  134. */
  135. union ipu_channel_param {
  136. struct idmac_video_param video;
  137. };
  138. struct idmac_tx_desc {
  139. struct dma_async_tx_descriptor txd;
  140. struct scatterlist *sg; /* scatterlist for this */
  141. unsigned int sg_len; /* tx-descriptor. */
  142. struct list_head list;
  143. };
  144. struct idmac_channel {
  145. struct dma_chan dma_chan;
  146. dma_cookie_t completed; /* last completed cookie */
  147. union ipu_channel_param params;
  148. enum ipu_channel link; /* input channel, linked to the output */
  149. enum ipu_channel_status status;
  150. void *client; /* Only one client per channel */
  151. unsigned int n_tx_desc;
  152. struct idmac_tx_desc *desc; /* allocated tx-descriptors */
  153. struct scatterlist *sg[2]; /* scatterlist elements in buffer-0 and -1 */
  154. struct list_head free_list; /* free tx-descriptors */
  155. struct list_head queue; /* queued tx-descriptors */
  156. spinlock_t lock; /* protects sg[0,1], queue */
  157. struct mutex chan_mutex; /* protects status, cookie, free_list */
  158. bool sec_chan_en;
  159. int active_buffer;
  160. unsigned int eof_irq;
  161. char eof_name[16]; /* EOF IRQ name for request_irq() */
  162. };
  163. #define to_tx_desc(tx) container_of(tx, struct idmac_tx_desc, txd)
  164. #define to_idmac_chan(c) container_of(c, struct idmac_channel, dma_chan)
  165. #endif