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