vpdma_priv.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. /*
  2. * Copyright (c) 2013 Texas Instruments Inc.
  3. *
  4. * David Griego, <dagriego@biglakesoftware.com>
  5. * Dale Farnsworth, <dale@farnsworth.org>
  6. * Archit Taneja, <archit@ti.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License version 2 as published by
  10. * the Free Software Foundation.
  11. */
  12. #ifndef _TI_VPDMA_PRIV_H_
  13. #define _TI_VPDMA_PRIV_H_
  14. /*
  15. * VPDMA Register offsets
  16. */
  17. /* Top level */
  18. #define VPDMA_PID 0x00
  19. #define VPDMA_LIST_ADDR 0x04
  20. #define VPDMA_LIST_ATTR 0x08
  21. #define VPDMA_LIST_STAT_SYNC 0x0c
  22. #define VPDMA_BG_RGB 0x18
  23. #define VPDMA_BG_YUV 0x1c
  24. #define VPDMA_SETUP 0x30
  25. #define VPDMA_MAX_SIZE1 0x34
  26. #define VPDMA_MAX_SIZE2 0x38
  27. #define VPDMA_MAX_SIZE3 0x3c
  28. #define VPDMA_MAX_SIZE_WIDTH_MASK 0xffff
  29. #define VPDMA_MAX_SIZE_WIDTH_SHFT 16
  30. #define VPDMA_MAX_SIZE_HEIGHT_MASK 0xffff
  31. #define VPDMA_MAX_SIZE_HEIGHT_SHFT 0
  32. /* Interrupts */
  33. #define VPDMA_INT_CHAN_STAT(grp) (0x40 + grp * 8)
  34. #define VPDMA_INT_CHAN_MASK(grp) (VPDMA_INT_CHAN_STAT(grp) + 4)
  35. #define VPDMA_INT_CLIENT0_STAT 0x78
  36. #define VPDMA_INT_CLIENT0_MASK 0x7c
  37. #define VPDMA_INT_CLIENT1_STAT 0x80
  38. #define VPDMA_INT_CLIENT1_MASK 0x84
  39. #define VPDMA_INT_LIST0_STAT 0x88
  40. #define VPDMA_INT_LIST0_MASK 0x8c
  41. #define VPDMA_INTX_OFFSET 0x50
  42. #define VPDMA_PERFMON(i) (0x200 + i * 4)
  43. /* VIP/VPE client registers */
  44. #define VPDMA_DEI_CHROMA1_CSTAT 0x0300
  45. #define VPDMA_DEI_LUMA1_CSTAT 0x0304
  46. #define VPDMA_DEI_LUMA2_CSTAT 0x0308
  47. #define VPDMA_DEI_CHROMA2_CSTAT 0x030c
  48. #define VPDMA_DEI_LUMA3_CSTAT 0x0310
  49. #define VPDMA_DEI_CHROMA3_CSTAT 0x0314
  50. #define VPDMA_DEI_MV_IN_CSTAT 0x0330
  51. #define VPDMA_DEI_MV_OUT_CSTAT 0x033c
  52. #define VPDMA_VIP_LO_Y_CSTAT 0x0388
  53. #define VPDMA_VIP_LO_UV_CSTAT 0x038c
  54. #define VPDMA_VIP_UP_Y_CSTAT 0x0390
  55. #define VPDMA_VIP_UP_UV_CSTAT 0x0394
  56. #define VPDMA_VPI_CTL_CSTAT 0x03d0
  57. /* Reg field info for VPDMA_CLIENT_CSTAT registers */
  58. #define VPDMA_CSTAT_LINE_MODE_MASK 0x03
  59. #define VPDMA_CSTAT_LINE_MODE_SHIFT 8
  60. #define VPDMA_CSTAT_FRAME_START_MASK 0xf
  61. #define VPDMA_CSTAT_FRAME_START_SHIFT 10
  62. #define VPDMA_LIST_NUM_MASK 0x07
  63. #define VPDMA_LIST_NUM_SHFT 24
  64. #define VPDMA_LIST_STOP_SHFT 20
  65. #define VPDMA_LIST_RDY_MASK 0x01
  66. #define VPDMA_LIST_RDY_SHFT 19
  67. #define VPDMA_LIST_TYPE_MASK 0x03
  68. #define VPDMA_LIST_TYPE_SHFT 16
  69. #define VPDMA_LIST_SIZE_MASK 0xffff
  70. /*
  71. * The YUV data type definition below are taken from
  72. * both the TRM and i839 Errata information.
  73. * Use the correct data type considering byte
  74. * reordering of components.
  75. *
  76. * Also since the single use of "C" in the 422 case
  77. * to mean "Cr" (i.e. V component). It was decided
  78. * to explicitly label them CR to remove any confusion.
  79. * Bear in mind that the type label refer to the memory
  80. * packed order (LSB - MSB).
  81. */
  82. #define DATA_TYPE_Y444 0x0
  83. #define DATA_TYPE_Y422 0x1
  84. #define DATA_TYPE_Y420 0x2
  85. #define DATA_TYPE_C444 0x4
  86. #define DATA_TYPE_C422 0x5
  87. #define DATA_TYPE_C420 0x6
  88. #define DATA_TYPE_YC444 0x8
  89. #define DATA_TYPE_YCB422 0x7
  90. #define DATA_TYPE_YCR422 0x17
  91. #define DATA_TYPE_CBY422 0x27
  92. #define DATA_TYPE_CRY422 0x37
  93. /*
  94. * The RGB data type definition below are defined
  95. * to follow Errata i819.
  96. * The initial values were taken from:
  97. * VPDMA_data_type_mapping_v0.2vayu_c.pdf
  98. * But some of the ARGB definition appeared to be wrong
  99. * in the document also. As they would yield RGBA instead.
  100. * They have been corrected based on experimentation.
  101. */
  102. #define DATA_TYPE_RGB16_565 0x10
  103. #define DATA_TYPE_ARGB_1555 0x13
  104. #define DATA_TYPE_ARGB_4444 0x14
  105. #define DATA_TYPE_RGBA_5551 0x11
  106. #define DATA_TYPE_RGBA_4444 0x12
  107. #define DATA_TYPE_ARGB24_6666 0x18
  108. #define DATA_TYPE_RGB24_888 0x16
  109. #define DATA_TYPE_ARGB32_8888 0x17
  110. #define DATA_TYPE_RGBA24_6666 0x15
  111. #define DATA_TYPE_RGBA32_8888 0x19
  112. #define DATA_TYPE_BGR16_565 0x0
  113. #define DATA_TYPE_ABGR_1555 0x3
  114. #define DATA_TYPE_ABGR_4444 0x4
  115. #define DATA_TYPE_BGRA_5551 0x1
  116. #define DATA_TYPE_BGRA_4444 0x2
  117. #define DATA_TYPE_ABGR24_6666 0x8
  118. #define DATA_TYPE_BGR24_888 0x6
  119. #define DATA_TYPE_ABGR32_8888 0x7
  120. #define DATA_TYPE_BGRA24_6666 0x5
  121. #define DATA_TYPE_BGRA32_8888 0x9
  122. #define DATA_TYPE_MV 0x3
  123. /* VPDMA channel numbers, some are common between VIP/VPE and appear twice */
  124. #define VPE_CHAN_NUM_LUMA1_IN 0
  125. #define VPE_CHAN_NUM_CHROMA1_IN 1
  126. #define VPE_CHAN_NUM_LUMA2_IN 2
  127. #define VPE_CHAN_NUM_CHROMA2_IN 3
  128. #define VPE_CHAN_NUM_LUMA3_IN 4
  129. #define VPE_CHAN_NUM_CHROMA3_IN 5
  130. #define VPE_CHAN_NUM_MV_IN 12
  131. #define VPE_CHAN_NUM_MV_OUT 15
  132. #define VIP1_CHAN_NUM_MULT_PORT_A_SRC0 38
  133. #define VIP1_CHAN_NUM_MULT_ANC_A_SRC0 70
  134. #define VPE_CHAN_NUM_LUMA_OUT 102
  135. #define VPE_CHAN_NUM_CHROMA_OUT 103
  136. #define VIP1_CHAN_NUM_PORT_A_LUMA 102
  137. #define VIP1_CHAN_NUM_PORT_A_CHROMA 103
  138. #define VPE_CHAN_NUM_RGB_OUT 106
  139. #define VIP1_CHAN_NUM_PORT_A_RGB 106
  140. #define VIP1_CHAN_NUM_PORT_B_RGB 107
  141. /*
  142. * a VPDMA address data block payload for a configuration descriptor needs to
  143. * have each sub block length as a multiple of 16 bytes. Therefore, the overall
  144. * size of the payload also needs to be a multiple of 16 bytes. The sub block
  145. * lengths should be ensured to be aligned by the VPDMA user.
  146. */
  147. #define VPDMA_ADB_SIZE_ALIGN 0x0f
  148. /*
  149. * data transfer descriptor
  150. */
  151. struct vpdma_dtd {
  152. u32 type_ctl_stride;
  153. union {
  154. u32 xfer_length_height;
  155. u32 w1;
  156. };
  157. dma_addr_t start_addr;
  158. u32 pkt_ctl;
  159. union {
  160. u32 frame_width_height; /* inbound */
  161. dma_addr_t desc_write_addr; /* outbound */
  162. };
  163. union {
  164. u32 start_h_v; /* inbound */
  165. u32 max_width_height; /* outbound */
  166. };
  167. u32 client_attr0;
  168. u32 client_attr1;
  169. };
  170. /* Data Transfer Descriptor specifics */
  171. #define DTD_NO_NOTIFY 0
  172. #define DTD_NOTIFY 1
  173. #define DTD_PKT_TYPE 0xa
  174. #define DTD_DIR_IN 0
  175. #define DTD_DIR_OUT 1
  176. /* type_ctl_stride */
  177. #define DTD_DATA_TYPE_MASK 0x3f
  178. #define DTD_DATA_TYPE_SHFT 26
  179. #define DTD_NOTIFY_MASK 0x01
  180. #define DTD_NOTIFY_SHFT 25
  181. #define DTD_FIELD_MASK 0x01
  182. #define DTD_FIELD_SHFT 24
  183. #define DTD_1D_MASK 0x01
  184. #define DTD_1D_SHFT 23
  185. #define DTD_EVEN_LINE_SKIP_MASK 0x01
  186. #define DTD_EVEN_LINE_SKIP_SHFT 20
  187. #define DTD_ODD_LINE_SKIP_MASK 0x01
  188. #define DTD_ODD_LINE_SKIP_SHFT 16
  189. #define DTD_LINE_STRIDE_MASK 0xffff
  190. #define DTD_LINE_STRIDE_SHFT 0
  191. /* xfer_length_height */
  192. #define DTD_LINE_LENGTH_MASK 0xffff
  193. #define DTD_LINE_LENGTH_SHFT 16
  194. #define DTD_XFER_HEIGHT_MASK 0xffff
  195. #define DTD_XFER_HEIGHT_SHFT 0
  196. /* pkt_ctl */
  197. #define DTD_PKT_TYPE_MASK 0x1f
  198. #define DTD_PKT_TYPE_SHFT 27
  199. #define DTD_MODE_MASK 0x01
  200. #define DTD_MODE_SHFT 26
  201. #define DTD_DIR_MASK 0x01
  202. #define DTD_DIR_SHFT 25
  203. #define DTD_CHAN_MASK 0x01ff
  204. #define DTD_CHAN_SHFT 16
  205. #define DTD_PRI_MASK 0x0f
  206. #define DTD_PRI_SHFT 9
  207. #define DTD_NEXT_CHAN_MASK 0x01ff
  208. #define DTD_NEXT_CHAN_SHFT 0
  209. /* frame_width_height */
  210. #define DTD_FRAME_WIDTH_MASK 0xffff
  211. #define DTD_FRAME_WIDTH_SHFT 16
  212. #define DTD_FRAME_HEIGHT_MASK 0xffff
  213. #define DTD_FRAME_HEIGHT_SHFT 0
  214. /* start_h_v */
  215. #define DTD_H_START_MASK 0xffff
  216. #define DTD_H_START_SHFT 16
  217. #define DTD_V_START_MASK 0xffff
  218. #define DTD_V_START_SHFT 0
  219. #define DTD_DESC_START_MASK 0xffffffe0
  220. #define DTD_DESC_START_SHIFT 5
  221. #define DTD_WRITE_DESC_MASK 0x01
  222. #define DTD_WRITE_DESC_SHIFT 2
  223. #define DTD_DROP_DATA_MASK 0x01
  224. #define DTD_DROP_DATA_SHIFT 1
  225. #define DTD_USE_DESC_MASK 0x01
  226. #define DTD_USE_DESC_SHIFT 0
  227. /* max_width_height */
  228. #define DTD_MAX_WIDTH_MASK 0x07
  229. #define DTD_MAX_WIDTH_SHFT 4
  230. #define DTD_MAX_HEIGHT_MASK 0x07
  231. #define DTD_MAX_HEIGHT_SHFT 0
  232. static inline u32 dtd_type_ctl_stride(int type, bool notify, int field,
  233. bool one_d, bool even_line_skip, bool odd_line_skip,
  234. int line_stride)
  235. {
  236. return (type << DTD_DATA_TYPE_SHFT) | (notify << DTD_NOTIFY_SHFT) |
  237. (field << DTD_FIELD_SHFT) | (one_d << DTD_1D_SHFT) |
  238. (even_line_skip << DTD_EVEN_LINE_SKIP_SHFT) |
  239. (odd_line_skip << DTD_ODD_LINE_SKIP_SHFT) |
  240. line_stride;
  241. }
  242. static inline u32 dtd_xfer_length_height(int line_length, int xfer_height)
  243. {
  244. return (line_length << DTD_LINE_LENGTH_SHFT) | xfer_height;
  245. }
  246. static inline u32 dtd_pkt_ctl(bool mode, bool dir, int chan, int pri,
  247. int next_chan)
  248. {
  249. return (DTD_PKT_TYPE << DTD_PKT_TYPE_SHFT) | (mode << DTD_MODE_SHFT) |
  250. (dir << DTD_DIR_SHFT) | (chan << DTD_CHAN_SHFT) |
  251. (pri << DTD_PRI_SHFT) | next_chan;
  252. }
  253. static inline u32 dtd_frame_width_height(int width, int height)
  254. {
  255. return (width << DTD_FRAME_WIDTH_SHFT) | height;
  256. }
  257. static inline u32 dtd_desc_write_addr(unsigned int addr, bool write_desc,
  258. bool drop_data, bool use_desc)
  259. {
  260. return (addr & DTD_DESC_START_MASK) |
  261. (write_desc << DTD_WRITE_DESC_SHIFT) |
  262. (drop_data << DTD_DROP_DATA_SHIFT) |
  263. use_desc;
  264. }
  265. static inline u32 dtd_start_h_v(int h_start, int v_start)
  266. {
  267. return (h_start << DTD_H_START_SHFT) | v_start;
  268. }
  269. static inline u32 dtd_max_width_height(int max_width, int max_height)
  270. {
  271. return (max_width << DTD_MAX_WIDTH_SHFT) | max_height;
  272. }
  273. static inline int dtd_get_data_type(struct vpdma_dtd *dtd)
  274. {
  275. return dtd->type_ctl_stride >> DTD_DATA_TYPE_SHFT;
  276. }
  277. static inline bool dtd_get_notify(struct vpdma_dtd *dtd)
  278. {
  279. return (dtd->type_ctl_stride >> DTD_NOTIFY_SHFT) & DTD_NOTIFY_MASK;
  280. }
  281. static inline int dtd_get_field(struct vpdma_dtd *dtd)
  282. {
  283. return (dtd->type_ctl_stride >> DTD_FIELD_SHFT) & DTD_FIELD_MASK;
  284. }
  285. static inline bool dtd_get_1d(struct vpdma_dtd *dtd)
  286. {
  287. return (dtd->type_ctl_stride >> DTD_1D_SHFT) & DTD_1D_MASK;
  288. }
  289. static inline bool dtd_get_even_line_skip(struct vpdma_dtd *dtd)
  290. {
  291. return (dtd->type_ctl_stride >> DTD_EVEN_LINE_SKIP_SHFT)
  292. & DTD_EVEN_LINE_SKIP_MASK;
  293. }
  294. static inline bool dtd_get_odd_line_skip(struct vpdma_dtd *dtd)
  295. {
  296. return (dtd->type_ctl_stride >> DTD_ODD_LINE_SKIP_SHFT)
  297. & DTD_ODD_LINE_SKIP_MASK;
  298. }
  299. static inline int dtd_get_line_stride(struct vpdma_dtd *dtd)
  300. {
  301. return dtd->type_ctl_stride & DTD_LINE_STRIDE_MASK;
  302. }
  303. static inline int dtd_get_line_length(struct vpdma_dtd *dtd)
  304. {
  305. return dtd->xfer_length_height >> DTD_LINE_LENGTH_SHFT;
  306. }
  307. static inline int dtd_get_xfer_height(struct vpdma_dtd *dtd)
  308. {
  309. return dtd->xfer_length_height & DTD_XFER_HEIGHT_MASK;
  310. }
  311. static inline int dtd_get_pkt_type(struct vpdma_dtd *dtd)
  312. {
  313. return dtd->pkt_ctl >> DTD_PKT_TYPE_SHFT;
  314. }
  315. static inline bool dtd_get_mode(struct vpdma_dtd *dtd)
  316. {
  317. return (dtd->pkt_ctl >> DTD_MODE_SHFT) & DTD_MODE_MASK;
  318. }
  319. static inline bool dtd_get_dir(struct vpdma_dtd *dtd)
  320. {
  321. return (dtd->pkt_ctl >> DTD_DIR_SHFT) & DTD_DIR_MASK;
  322. }
  323. static inline int dtd_get_chan(struct vpdma_dtd *dtd)
  324. {
  325. return (dtd->pkt_ctl >> DTD_CHAN_SHFT) & DTD_CHAN_MASK;
  326. }
  327. static inline int dtd_get_priority(struct vpdma_dtd *dtd)
  328. {
  329. return (dtd->pkt_ctl >> DTD_PRI_SHFT) & DTD_PRI_MASK;
  330. }
  331. static inline int dtd_get_next_chan(struct vpdma_dtd *dtd)
  332. {
  333. return (dtd->pkt_ctl >> DTD_NEXT_CHAN_SHFT) & DTD_NEXT_CHAN_MASK;
  334. }
  335. static inline int dtd_get_frame_width(struct vpdma_dtd *dtd)
  336. {
  337. return dtd->frame_width_height >> DTD_FRAME_WIDTH_SHFT;
  338. }
  339. static inline int dtd_get_frame_height(struct vpdma_dtd *dtd)
  340. {
  341. return dtd->frame_width_height & DTD_FRAME_HEIGHT_MASK;
  342. }
  343. static inline int dtd_get_desc_write_addr(struct vpdma_dtd *dtd)
  344. {
  345. return dtd->desc_write_addr & DTD_DESC_START_MASK;
  346. }
  347. static inline bool dtd_get_write_desc(struct vpdma_dtd *dtd)
  348. {
  349. return (dtd->desc_write_addr >> DTD_WRITE_DESC_SHIFT) &
  350. DTD_WRITE_DESC_MASK;
  351. }
  352. static inline bool dtd_get_drop_data(struct vpdma_dtd *dtd)
  353. {
  354. return (dtd->desc_write_addr >> DTD_DROP_DATA_SHIFT) &
  355. DTD_DROP_DATA_MASK;
  356. }
  357. static inline bool dtd_get_use_desc(struct vpdma_dtd *dtd)
  358. {
  359. return dtd->desc_write_addr & DTD_USE_DESC_MASK;
  360. }
  361. static inline int dtd_get_h_start(struct vpdma_dtd *dtd)
  362. {
  363. return dtd->start_h_v >> DTD_H_START_SHFT;
  364. }
  365. static inline int dtd_get_v_start(struct vpdma_dtd *dtd)
  366. {
  367. return dtd->start_h_v & DTD_V_START_MASK;
  368. }
  369. static inline int dtd_get_max_width(struct vpdma_dtd *dtd)
  370. {
  371. return (dtd->max_width_height >> DTD_MAX_WIDTH_SHFT) &
  372. DTD_MAX_WIDTH_MASK;
  373. }
  374. static inline int dtd_get_max_height(struct vpdma_dtd *dtd)
  375. {
  376. return (dtd->max_width_height >> DTD_MAX_HEIGHT_SHFT) &
  377. DTD_MAX_HEIGHT_MASK;
  378. }
  379. /*
  380. * configuration descriptor
  381. */
  382. struct vpdma_cfd {
  383. union {
  384. u32 dest_addr_offset;
  385. u32 w0;
  386. };
  387. union {
  388. u32 block_len; /* in words */
  389. u32 w1;
  390. };
  391. u32 payload_addr;
  392. u32 ctl_payload_len; /* in words */
  393. };
  394. /* Configuration descriptor specifics */
  395. #define CFD_PKT_TYPE 0xb
  396. #define CFD_DIRECT 1
  397. #define CFD_INDIRECT 0
  398. #define CFD_CLS_ADB 0
  399. #define CFD_CLS_BLOCK 1
  400. /* block_len */
  401. #define CFD__BLOCK_LEN_MASK 0xffff
  402. #define CFD__BLOCK_LEN_SHFT 0
  403. /* ctl_payload_len */
  404. #define CFD_PKT_TYPE_MASK 0x1f
  405. #define CFD_PKT_TYPE_SHFT 27
  406. #define CFD_DIRECT_MASK 0x01
  407. #define CFD_DIRECT_SHFT 26
  408. #define CFD_CLASS_MASK 0x03
  409. #define CFD_CLASS_SHFT 24
  410. #define CFD_DEST_MASK 0xff
  411. #define CFD_DEST_SHFT 16
  412. #define CFD_PAYLOAD_LEN_MASK 0xffff
  413. #define CFD_PAYLOAD_LEN_SHFT 0
  414. static inline u32 cfd_pkt_payload_len(bool direct, int cls, int dest,
  415. int payload_len)
  416. {
  417. return (CFD_PKT_TYPE << CFD_PKT_TYPE_SHFT) |
  418. (direct << CFD_DIRECT_SHFT) |
  419. (cls << CFD_CLASS_SHFT) |
  420. (dest << CFD_DEST_SHFT) |
  421. payload_len;
  422. }
  423. static inline int cfd_get_pkt_type(struct vpdma_cfd *cfd)
  424. {
  425. return cfd->ctl_payload_len >> CFD_PKT_TYPE_SHFT;
  426. }
  427. static inline bool cfd_get_direct(struct vpdma_cfd *cfd)
  428. {
  429. return (cfd->ctl_payload_len >> CFD_DIRECT_SHFT) & CFD_DIRECT_MASK;
  430. }
  431. static inline bool cfd_get_class(struct vpdma_cfd *cfd)
  432. {
  433. return (cfd->ctl_payload_len >> CFD_CLASS_SHFT) & CFD_CLASS_MASK;
  434. }
  435. static inline int cfd_get_dest(struct vpdma_cfd *cfd)
  436. {
  437. return (cfd->ctl_payload_len >> CFD_DEST_SHFT) & CFD_DEST_MASK;
  438. }
  439. static inline int cfd_get_payload_len(struct vpdma_cfd *cfd)
  440. {
  441. return cfd->ctl_payload_len & CFD_PAYLOAD_LEN_MASK;
  442. }
  443. /*
  444. * control descriptor
  445. */
  446. struct vpdma_ctd {
  447. union {
  448. u32 timer_value;
  449. u32 list_addr;
  450. u32 w0;
  451. };
  452. union {
  453. u32 pixel_line_count;
  454. u32 list_size;
  455. u32 w1;
  456. };
  457. union {
  458. u32 event;
  459. u32 fid_ctl;
  460. u32 w2;
  461. };
  462. u32 type_source_ctl;
  463. };
  464. /* control descriptor types */
  465. #define CTD_TYPE_SYNC_ON_CLIENT 0
  466. #define CTD_TYPE_SYNC_ON_LIST 1
  467. #define CTD_TYPE_SYNC_ON_EXT 2
  468. #define CTD_TYPE_SYNC_ON_LM_TIMER 3
  469. #define CTD_TYPE_SYNC_ON_CHANNEL 4
  470. #define CTD_TYPE_CHNG_CLIENT_IRQ 5
  471. #define CTD_TYPE_SEND_IRQ 6
  472. #define CTD_TYPE_RELOAD_LIST 7
  473. #define CTD_TYPE_ABORT_CHANNEL 8
  474. #define CTD_PKT_TYPE 0xc
  475. /* timer_value */
  476. #define CTD_TIMER_VALUE_MASK 0xffff
  477. #define CTD_TIMER_VALUE_SHFT 0
  478. /* pixel_line_count */
  479. #define CTD_PIXEL_COUNT_MASK 0xffff
  480. #define CTD_PIXEL_COUNT_SHFT 16
  481. #define CTD_LINE_COUNT_MASK 0xffff
  482. #define CTD_LINE_COUNT_SHFT 0
  483. /* list_size */
  484. #define CTD_LIST_SIZE_MASK 0xffff
  485. #define CTD_LIST_SIZE_SHFT 0
  486. /* event */
  487. #define CTD_EVENT_MASK 0x0f
  488. #define CTD_EVENT_SHFT 0
  489. /* fid_ctl */
  490. #define CTD_FID2_MASK 0x03
  491. #define CTD_FID2_SHFT 4
  492. #define CTD_FID1_MASK 0x03
  493. #define CTD_FID1_SHFT 2
  494. #define CTD_FID0_MASK 0x03
  495. #define CTD_FID0_SHFT 0
  496. /* type_source_ctl */
  497. #define CTD_PKT_TYPE_MASK 0x1f
  498. #define CTD_PKT_TYPE_SHFT 27
  499. #define CTD_SOURCE_MASK 0xff
  500. #define CTD_SOURCE_SHFT 16
  501. #define CTD_CONTROL_MASK 0x0f
  502. #define CTD_CONTROL_SHFT 0
  503. static inline u32 ctd_pixel_line_count(int pixel_count, int line_count)
  504. {
  505. return (pixel_count << CTD_PIXEL_COUNT_SHFT) | line_count;
  506. }
  507. static inline u32 ctd_set_fid_ctl(int fid0, int fid1, int fid2)
  508. {
  509. return (fid2 << CTD_FID2_SHFT) | (fid1 << CTD_FID1_SHFT) | fid0;
  510. }
  511. static inline u32 ctd_type_source_ctl(int source, int control)
  512. {
  513. return (CTD_PKT_TYPE << CTD_PKT_TYPE_SHFT) |
  514. (source << CTD_SOURCE_SHFT) | control;
  515. }
  516. static inline u32 ctd_get_pixel_count(struct vpdma_ctd *ctd)
  517. {
  518. return ctd->pixel_line_count >> CTD_PIXEL_COUNT_SHFT;
  519. }
  520. static inline int ctd_get_line_count(struct vpdma_ctd *ctd)
  521. {
  522. return ctd->pixel_line_count & CTD_LINE_COUNT_MASK;
  523. }
  524. static inline int ctd_get_event(struct vpdma_ctd *ctd)
  525. {
  526. return ctd->event & CTD_EVENT_MASK;
  527. }
  528. static inline int ctd_get_fid2_ctl(struct vpdma_ctd *ctd)
  529. {
  530. return (ctd->fid_ctl >> CTD_FID2_SHFT) & CTD_FID2_MASK;
  531. }
  532. static inline int ctd_get_fid1_ctl(struct vpdma_ctd *ctd)
  533. {
  534. return (ctd->fid_ctl >> CTD_FID1_SHFT) & CTD_FID1_MASK;
  535. }
  536. static inline int ctd_get_fid0_ctl(struct vpdma_ctd *ctd)
  537. {
  538. return ctd->fid_ctl & CTD_FID2_MASK;
  539. }
  540. static inline int ctd_get_pkt_type(struct vpdma_ctd *ctd)
  541. {
  542. return ctd->type_source_ctl >> CTD_PKT_TYPE_SHFT;
  543. }
  544. static inline int ctd_get_source(struct vpdma_ctd *ctd)
  545. {
  546. return (ctd->type_source_ctl >> CTD_SOURCE_SHFT) & CTD_SOURCE_MASK;
  547. }
  548. static inline int ctd_get_ctl(struct vpdma_ctd *ctd)
  549. {
  550. return ctd->type_source_ctl & CTD_CONTROL_MASK;
  551. }
  552. #endif