STG4000OverlayDevice.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. /*
  2. * linux/drivers/video/kyro/STG4000OverlayDevice.c
  3. *
  4. * Copyright (C) 2000 Imagination Technologies Ltd
  5. * Copyright (C) 2002 STMicroelectronics
  6. *
  7. * This file is subject to the terms and conditions of the GNU General Public
  8. * License. See the file COPYING in the main directory of this archive
  9. * for more details.
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/errno.h>
  13. #include <linux/types.h>
  14. #include "STG4000Reg.h"
  15. #include "STG4000Interface.h"
  16. /* HW Defines */
  17. #define STG4000_NO_SCALING 0x800
  18. #define STG4000_NO_DECIMATION 0xFFFFFFFF
  19. /* Primary surface */
  20. #define STG4000_PRIM_NUM_PIX 5
  21. #define STG4000_PRIM_ALIGN 4
  22. #define STG4000_PRIM_ADDR_BITS 20
  23. #define STG4000_PRIM_MIN_WIDTH 640
  24. #define STG4000_PRIM_MAX_WIDTH 1600
  25. #define STG4000_PRIM_MIN_HEIGHT 480
  26. #define STG4000_PRIM_MAX_HEIGHT 1200
  27. /* Overlay surface */
  28. #define STG4000_OVRL_NUM_PIX 4
  29. #define STG4000_OVRL_ALIGN 2
  30. #define STG4000_OVRL_ADDR_BITS 20
  31. #define STG4000_OVRL_NUM_MODES 5
  32. #define STG4000_OVRL_MIN_WIDTH 0
  33. #define STG4000_OVRL_MAX_WIDTH 720
  34. #define STG4000_OVRL_MIN_HEIGHT 0
  35. #define STG4000_OVRL_MAX_HEIGHT 576
  36. /* Decimation and Scaling */
  37. static u32 adwDecim8[33] = {
  38. 0xffffffff, 0xfffeffff, 0xffdffbff, 0xfefefeff, 0xfdf7efbf,
  39. 0xfbdf7bdf, 0xf7bbddef, 0xeeeeeeef, 0xeeddbb77, 0xedb76db7,
  40. 0xdb6db6db, 0xdb5b5b5b, 0xdab5ad6b, 0xd5ab55ab, 0xd555aaab,
  41. 0xaaaaaaab, 0xaaaa5555, 0xaa952a55, 0xa94a5295, 0xa5252525,
  42. 0xa4924925, 0x92491249, 0x91224489, 0x91111111, 0x90884211,
  43. 0x88410821, 0x88102041, 0x81010101, 0x80800801, 0x80010001,
  44. 0x80000001, 0x00000001, 0x00000000
  45. };
  46. typedef struct _OVRL_SRC_DEST {
  47. /*clipped on-screen pixel position of overlay */
  48. u32 ulDstX1;
  49. u32 ulDstY1;
  50. u32 ulDstX2;
  51. u32 ulDstY2;
  52. /*clipped pixel pos of source data within buffer thses need to be 128 bit word aligned */
  53. u32 ulSrcX1;
  54. u32 ulSrcY1;
  55. u32 ulSrcX2;
  56. u32 ulSrcY2;
  57. /* on-screen pixel position of overlay */
  58. s32 lDstX1;
  59. s32 lDstY1;
  60. s32 lDstX2;
  61. s32 lDstY2;
  62. } OVRL_SRC_DEST;
  63. static u32 ovlWidth, ovlHeight, ovlStride;
  64. static int ovlLinear;
  65. void ResetOverlayRegisters(volatile STG4000REG __iomem *pSTGReg)
  66. {
  67. u32 tmp;
  68. /* Set Overlay address to default */
  69. tmp = STG_READ_REG(DACOverlayAddr);
  70. CLEAR_BITS_FRM_TO(0, 20);
  71. CLEAR_BIT(31);
  72. STG_WRITE_REG(DACOverlayAddr, tmp);
  73. /* Set Overlay U address */
  74. tmp = STG_READ_REG(DACOverlayUAddr);
  75. CLEAR_BITS_FRM_TO(0, 20);
  76. STG_WRITE_REG(DACOverlayUAddr, tmp);
  77. /* Set Overlay V address */
  78. tmp = STG_READ_REG(DACOverlayVAddr);
  79. CLEAR_BITS_FRM_TO(0, 20);
  80. STG_WRITE_REG(DACOverlayVAddr, tmp);
  81. /* Set Overlay Size */
  82. tmp = STG_READ_REG(DACOverlaySize);
  83. CLEAR_BITS_FRM_TO(0, 10);
  84. CLEAR_BITS_FRM_TO(12, 31);
  85. STG_WRITE_REG(DACOverlaySize, tmp);
  86. /* Set Overlay Vt Decimation */
  87. tmp = STG4000_NO_DECIMATION;
  88. STG_WRITE_REG(DACOverlayVtDec, tmp);
  89. /* Set Overlay format to default value */
  90. tmp = STG_READ_REG(DACPixelFormat);
  91. CLEAR_BITS_FRM_TO(4, 7);
  92. CLEAR_BITS_FRM_TO(16, 22);
  93. STG_WRITE_REG(DACPixelFormat, tmp);
  94. /* Set Vertical scaling to default */
  95. tmp = STG_READ_REG(DACVerticalScal);
  96. CLEAR_BITS_FRM_TO(0, 11);
  97. CLEAR_BITS_FRM_TO(16, 22);
  98. tmp |= STG4000_NO_SCALING; /* Set to no scaling */
  99. STG_WRITE_REG(DACVerticalScal, tmp);
  100. /* Set Horizontal Scaling to default */
  101. tmp = STG_READ_REG(DACHorizontalScal);
  102. CLEAR_BITS_FRM_TO(0, 11);
  103. CLEAR_BITS_FRM_TO(16, 17);
  104. tmp |= STG4000_NO_SCALING; /* Set to no scaling */
  105. STG_WRITE_REG(DACHorizontalScal, tmp);
  106. /* Set Blend mode to Alpha Blend */
  107. /* ????? SG 08/11/2001 Surely this isn't the alpha blend mode,
  108. hopefully its overwrite
  109. */
  110. tmp = STG_READ_REG(DACBlendCtrl);
  111. CLEAR_BITS_FRM_TO(0, 30);
  112. tmp = (GRAPHICS_MODE << 28);
  113. STG_WRITE_REG(DACBlendCtrl, tmp);
  114. }
  115. int CreateOverlaySurface(volatile STG4000REG __iomem *pSTGReg,
  116. u32 inWidth,
  117. u32 inHeight,
  118. int bLinear,
  119. u32 ulOverlayOffset,
  120. u32 * retStride, u32 * retUVStride)
  121. {
  122. u32 tmp;
  123. u32 ulStride;
  124. if (inWidth > STG4000_OVRL_MAX_WIDTH ||
  125. inHeight > STG4000_OVRL_MAX_HEIGHT) {
  126. return -EINVAL;
  127. }
  128. /* Stride in 16 byte words - 16Bpp */
  129. if (bLinear) {
  130. /* Format is 16bits so num 16 byte words is width/8 */
  131. if ((inWidth & 0x7) == 0) { /* inWidth % 8 */
  132. ulStride = (inWidth / 8);
  133. } else {
  134. /* Round up to next 16byte boundary */
  135. ulStride = ((inWidth + 8) / 8);
  136. }
  137. } else {
  138. /* Y component is 8bits so num 16 byte words is width/16 */
  139. if ((inWidth & 0xf) == 0) { /* inWidth % 16 */
  140. ulStride = (inWidth / 16);
  141. } else {
  142. /* Round up to next 16byte boundary */
  143. ulStride = ((inWidth + 16) / 16);
  144. }
  145. }
  146. /* Set Overlay address and Format mode */
  147. tmp = STG_READ_REG(DACOverlayAddr);
  148. CLEAR_BITS_FRM_TO(0, 20);
  149. if (bLinear) {
  150. CLEAR_BIT(31); /* Overlay format to Linear */
  151. } else {
  152. tmp |= SET_BIT(31); /* Overlay format to Planer */
  153. }
  154. /* Only bits 24:4 of the Overlay address */
  155. tmp |= (ulOverlayOffset >> 4);
  156. STG_WRITE_REG(DACOverlayAddr, tmp);
  157. if (!bLinear) {
  158. u32 uvSize =
  159. (inWidth & 0x1) ? (inWidth + 1 / 2) : (inWidth / 2);
  160. u32 uvStride;
  161. u32 ulOffset;
  162. /* Y component is 8bits so num 32 byte words is width/32 */
  163. if ((uvSize & 0xf) == 0) { /* inWidth % 16 */
  164. uvStride = (uvSize / 16);
  165. } else {
  166. /* Round up to next 32byte boundary */
  167. uvStride = ((uvSize + 16) / 16);
  168. }
  169. ulOffset = ulOverlayOffset + (inHeight * (ulStride * 16));
  170. /* Align U,V data to 32byte boundary */
  171. if ((ulOffset & 0x1f) != 0)
  172. ulOffset = (ulOffset + 32L) & 0xffffffE0L;
  173. tmp = STG_READ_REG(DACOverlayUAddr);
  174. CLEAR_BITS_FRM_TO(0, 20);
  175. tmp |= (ulOffset >> 4);
  176. STG_WRITE_REG(DACOverlayUAddr, tmp);
  177. ulOffset += (inHeight / 2) * (uvStride * 16);
  178. /* Align U,V data to 32byte boundary */
  179. if ((ulOffset & 0x1f) != 0)
  180. ulOffset = (ulOffset + 32L) & 0xffffffE0L;
  181. tmp = STG_READ_REG(DACOverlayVAddr);
  182. CLEAR_BITS_FRM_TO(0, 20);
  183. tmp |= (ulOffset >> 4);
  184. STG_WRITE_REG(DACOverlayVAddr, tmp);
  185. *retUVStride = uvStride * 16;
  186. }
  187. /* Set Overlay YUV pixel format
  188. * Make sure that LUT not used - ??????
  189. */
  190. tmp = STG_READ_REG(DACPixelFormat);
  191. /* Only support Planer or UYVY linear formats */
  192. CLEAR_BITS_FRM_TO(4, 9);
  193. STG_WRITE_REG(DACPixelFormat, tmp);
  194. ovlWidth = inWidth;
  195. ovlHeight = inHeight;
  196. ovlStride = ulStride;
  197. ovlLinear = bLinear;
  198. *retStride = ulStride << 4; /* In bytes */
  199. return 0;
  200. }
  201. int SetOverlayBlendMode(volatile STG4000REG __iomem *pSTGReg,
  202. OVRL_BLEND_MODE mode,
  203. u32 ulAlpha, u32 ulColorKey)
  204. {
  205. u32 tmp;
  206. tmp = STG_READ_REG(DACBlendCtrl);
  207. CLEAR_BITS_FRM_TO(28, 30);
  208. tmp |= (mode << 28);
  209. switch (mode) {
  210. case COLOR_KEY:
  211. CLEAR_BITS_FRM_TO(0, 23);
  212. tmp |= (ulColorKey & 0x00FFFFFF);
  213. break;
  214. case GLOBAL_ALPHA:
  215. CLEAR_BITS_FRM_TO(24, 27);
  216. tmp |= ((ulAlpha & 0xF) << 24);
  217. break;
  218. case CK_PIXEL_ALPHA:
  219. CLEAR_BITS_FRM_TO(0, 23);
  220. tmp |= (ulColorKey & 0x00FFFFFF);
  221. break;
  222. case CK_GLOBAL_ALPHA:
  223. CLEAR_BITS_FRM_TO(0, 23);
  224. tmp |= (ulColorKey & 0x00FFFFFF);
  225. CLEAR_BITS_FRM_TO(24, 27);
  226. tmp |= ((ulAlpha & 0xF) << 24);
  227. break;
  228. case GRAPHICS_MODE:
  229. case PER_PIXEL_ALPHA:
  230. break;
  231. default:
  232. return -EINVAL;
  233. }
  234. STG_WRITE_REG(DACBlendCtrl, tmp);
  235. return 0;
  236. }
  237. void EnableOverlayPlane(volatile STG4000REG __iomem *pSTGReg)
  238. {
  239. u32 tmp;
  240. /* Enable Overlay */
  241. tmp = STG_READ_REG(DACPixelFormat);
  242. tmp |= SET_BIT(7);
  243. STG_WRITE_REG(DACPixelFormat, tmp);
  244. /* Set video stream control */
  245. tmp = STG_READ_REG(DACStreamCtrl);
  246. tmp |= SET_BIT(1); /* video stream */
  247. STG_WRITE_REG(DACStreamCtrl, tmp);
  248. }
  249. static u32 Overlap(u32 ulBits, u32 ulPattern)
  250. {
  251. u32 ulCount = 0;
  252. while (ulBits) {
  253. if (!(ulPattern & 1))
  254. ulCount++;
  255. ulBits--;
  256. ulPattern = ulPattern >> 1;
  257. }
  258. return ulCount;
  259. }
  260. int SetOverlayViewPort(volatile STG4000REG __iomem *pSTGReg,
  261. u32 left, u32 top,
  262. u32 right, u32 bottom)
  263. {
  264. OVRL_SRC_DEST srcDest;
  265. u32 ulSrcTop, ulSrcBottom;
  266. u32 ulSrc, ulDest;
  267. u32 ulFxScale, ulFxOffset;
  268. u32 ulHeight, ulWidth;
  269. u32 ulPattern;
  270. u32 ulDecimate, ulDecimated;
  271. u32 ulApplied;
  272. u32 ulDacXScale, ulDacYScale;
  273. u32 ulScale;
  274. u32 ulLeft, ulRight;
  275. u32 ulSrcLeft, ulSrcRight;
  276. u32 ulScaleLeft, ulScaleRight;
  277. u32 ulhDecim;
  278. u32 ulsVal;
  279. u32 ulVertDecFactor;
  280. int bResult;
  281. u32 ulClipOff = 0;
  282. u32 ulBits = 0;
  283. u32 ulsAdd = 0;
  284. u32 tmp, ulStride;
  285. u32 ulExcessPixels, ulClip, ulExtraLines;
  286. srcDest.ulSrcX1 = 0;
  287. srcDest.ulSrcY1 = 0;
  288. srcDest.ulSrcX2 = ovlWidth - 1;
  289. srcDest.ulSrcY2 = ovlHeight - 1;
  290. srcDest.ulDstX1 = left;
  291. srcDest.ulDstY1 = top;
  292. srcDest.ulDstX2 = right;
  293. srcDest.ulDstY2 = bottom;
  294. srcDest.lDstX1 = srcDest.ulDstX1;
  295. srcDest.lDstY1 = srcDest.ulDstY1;
  296. srcDest.lDstX2 = srcDest.ulDstX2;
  297. srcDest.lDstY2 = srcDest.ulDstY2;
  298. /************* Vertical decimation/scaling ******************/
  299. /* Get Src Top and Bottom */
  300. ulSrcTop = srcDest.ulSrcY1;
  301. ulSrcBottom = srcDest.ulSrcY2;
  302. ulSrc = ulSrcBottom - ulSrcTop;
  303. ulDest = srcDest.lDstY2 - srcDest.lDstY1; /* on-screen overlay */
  304. if (ulSrc <= 1)
  305. return -EINVAL;
  306. /* First work out the position we are to display as offset from the
  307. * source of the buffer
  308. */
  309. ulFxScale = (ulDest << 11) / ulSrc; /* fixed point scale factor */
  310. ulFxOffset = (srcDest.lDstY2 - srcDest.ulDstY2) << 11;
  311. ulSrcBottom = ulSrcBottom - (ulFxOffset / ulFxScale);
  312. ulSrc = ulSrcBottom - ulSrcTop;
  313. ulHeight = ulSrc;
  314. ulDest = srcDest.ulDstY2 - (srcDest.ulDstY1 - 1);
  315. ulPattern = adwDecim8[ulBits];
  316. /* At this point ulSrc represents the input decimator */
  317. if (ulSrc > ulDest) {
  318. ulDecimate = ulSrc - ulDest;
  319. ulBits = 0;
  320. ulApplied = ulSrc / 32;
  321. while (((ulBits * ulApplied) +
  322. Overlap((ulSrc % 32),
  323. adwDecim8[ulBits])) < ulDecimate)
  324. ulBits++;
  325. ulPattern = adwDecim8[ulBits];
  326. ulDecimated =
  327. (ulBits * ulApplied) + Overlap((ulSrc % 32),
  328. ulPattern);
  329. ulSrc = ulSrc - ulDecimated; /* the number number of lines that will go into the scaler */
  330. }
  331. if (ulBits && (ulBits != 32)) {
  332. ulVertDecFactor = (63 - ulBits) / (32 - ulBits); /* vertical decimation factor scaled up to nearest integer */
  333. } else {
  334. ulVertDecFactor = 1;
  335. }
  336. ulDacYScale = ((ulSrc - 1) * 2048) / (ulDest + 1);
  337. tmp = STG_READ_REG(DACOverlayVtDec); /* Decimation */
  338. CLEAR_BITS_FRM_TO(0, 31);
  339. tmp = ulPattern;
  340. STG_WRITE_REG(DACOverlayVtDec, tmp);
  341. /***************** Horizontal decimation/scaling ***************************/
  342. /*
  343. * Now we handle the horizontal case, this is a simplified version of
  344. * the vertical case in that we decimate by factors of 2. as we are
  345. * working in words we should always be able to decimate by these
  346. * factors. as we always have to have a buffer which is aligned to a
  347. * whole number of 128 bit words, we must align the left side to the
  348. * lowest to the next lowest 128 bit boundary, and the right hand edge
  349. * to the next largets boundary, (in a similar way to how we didi it in
  350. * PMX1) as the left and right hand edges are aligned to these
  351. * boundaries normally this only becomes an issue when we are chopping
  352. * of one of the sides We shall work out vertical stuff first
  353. */
  354. ulSrc = srcDest.ulSrcX2 - srcDest.ulSrcX1;
  355. ulDest = srcDest.lDstX2 - srcDest.lDstX1;
  356. #ifdef _OLDCODE
  357. ulLeft = srcDest.ulDstX1;
  358. ulRight = srcDest.ulDstX2;
  359. #else
  360. if (srcDest.ulDstX1 > 2) {
  361. ulLeft = srcDest.ulDstX1 + 2;
  362. ulRight = srcDest.ulDstX2 + 1;
  363. } else {
  364. ulLeft = srcDest.ulDstX1;
  365. ulRight = srcDest.ulDstX2 + 1;
  366. }
  367. #endif
  368. /* first work out the position we are to display as offset from the source of the buffer */
  369. bResult = 1;
  370. do {
  371. if (ulDest == 0)
  372. return -EINVAL;
  373. /* source pixels per dest pixel <<11 */
  374. ulFxScale = ((ulSrc - 1) << 11) / (ulDest);
  375. /* then number of destination pixels out we are */
  376. ulFxOffset = ulFxScale * ((srcDest.ulDstX1 - srcDest.lDstX1) + ulClipOff);
  377. ulFxOffset >>= 11;
  378. /* this replaces the code which was making a decision as to use either ulFxOffset or ulSrcX1 */
  379. ulSrcLeft = srcDest.ulSrcX1 + ulFxOffset;
  380. /* then number of destination pixels out we are */
  381. ulFxOffset = ulFxScale * (srcDest.lDstX2 - srcDest.ulDstX2);
  382. ulFxOffset >>= 11;
  383. ulSrcRight = srcDest.ulSrcX2 - ulFxOffset;
  384. /*
  385. * we must align these to our 128 bit boundaries. we shall
  386. * round down the pixel pos to the nearest 8 pixels.
  387. */
  388. ulScaleLeft = ulSrcLeft;
  389. ulScaleRight = ulSrcRight;
  390. /* shift fxscale until it is in the range of the scaler */
  391. ulhDecim = 0;
  392. ulScale = (((ulSrcRight - ulSrcLeft) - 1) << (11 - ulhDecim)) / (ulRight - ulLeft + 2);
  393. while (ulScale > 0x800) {
  394. ulhDecim++;
  395. ulScale = (((ulSrcRight - ulSrcLeft) - 1) << (11 - ulhDecim)) / (ulRight - ulLeft + 2);
  396. }
  397. /*
  398. * to try and get the best values We first try and use
  399. * src/dwdest for the scale factor, then we move onto src-1
  400. *
  401. * we want to check to see if we will need to clip data, if so
  402. * then we should clip our source so that we don't need to
  403. */
  404. if (!ovlLinear) {
  405. ulSrcLeft &= ~0x1f;
  406. /*
  407. * we must align the right hand edge to the next 32
  408. * pixel` boundary, must be on a 256 boundary so u, and
  409. * v are 128 bit aligned
  410. */
  411. ulSrcRight = (ulSrcRight + 0x1f) & ~0x1f;
  412. } else {
  413. ulSrcLeft &= ~0x7;
  414. /*
  415. * we must align the right hand edge to the next
  416. * 8pixel` boundary
  417. */
  418. ulSrcRight = (ulSrcRight + 0x7) & ~0x7;
  419. }
  420. /* this is the input size line store needs to cope with */
  421. ulWidth = ulSrcRight - ulSrcLeft;
  422. /*
  423. * use unclipped value to work out scale factror this is the
  424. * scale factor we want we shall now work out the horizonal
  425. * decimation and scaling
  426. */
  427. ulsVal = ((ulWidth / 8) >> ulhDecim);
  428. if ((ulWidth != (ulsVal << ulhDecim) * 8))
  429. ulsAdd = 1;
  430. /* input pixels to scaler; */
  431. ulSrc = ulWidth >> ulhDecim;
  432. if (ulSrc <= 2)
  433. return -EINVAL;
  434. ulExcessPixels = ((((ulScaleLeft - ulSrcLeft)) << (11 - ulhDecim)) / ulScale);
  435. ulClip = (ulSrc << 11) / ulScale;
  436. ulClip -= (ulRight - ulLeft);
  437. ulClip += ulExcessPixels;
  438. if (ulClip)
  439. ulClip--;
  440. /* We may need to do more here if we really have a HW rev < 5 */
  441. } while (!bResult);
  442. ulExtraLines = (1 << ulhDecim) * ulVertDecFactor;
  443. ulExtraLines += 64;
  444. ulHeight += ulExtraLines;
  445. ulDacXScale = ulScale;
  446. tmp = STG_READ_REG(DACVerticalScal);
  447. CLEAR_BITS_FRM_TO(0, 11);
  448. CLEAR_BITS_FRM_TO(16, 22); /* Vertical Scaling */
  449. /* Calculate new output line stride, this is always the number of 422
  450. words in the line buffer, so it doesn't matter if the
  451. mode is 420. Then set the vertical scale register.
  452. */
  453. ulStride = (ulWidth >> (ulhDecim + 3)) + ulsAdd;
  454. tmp |= ((ulStride << 16) | (ulDacYScale)); /* DAC_LS_CTRL = stride */
  455. STG_WRITE_REG(DACVerticalScal, tmp);
  456. /* Now set up the overlay size using the modified width and height
  457. from decimate and scaling calculations
  458. */
  459. tmp = STG_READ_REG(DACOverlaySize);
  460. CLEAR_BITS_FRM_TO(0, 10);
  461. CLEAR_BITS_FRM_TO(12, 31);
  462. if (ovlLinear) {
  463. tmp |=
  464. (ovlStride | ((ulHeight + 1) << 12) |
  465. (((ulWidth / 8) - 1) << 23));
  466. } else {
  467. tmp |=
  468. (ovlStride | ((ulHeight + 1) << 12) |
  469. (((ulWidth / 32) - 1) << 23));
  470. }
  471. STG_WRITE_REG(DACOverlaySize, tmp);
  472. /* Set Video Window Start */
  473. tmp = ((ulLeft << 16)) | (srcDest.ulDstY1);
  474. STG_WRITE_REG(DACVidWinStart, tmp);
  475. /* Set Video Window End */
  476. tmp = ((ulRight) << 16) | (srcDest.ulDstY2);
  477. STG_WRITE_REG(DACVidWinEnd, tmp);
  478. /* Finally set up the rest of the overlay regs in the order
  479. done in the IMG driver
  480. */
  481. tmp = STG_READ_REG(DACPixelFormat);
  482. tmp = ((ulExcessPixels << 16) | tmp) & 0x7fffffff;
  483. STG_WRITE_REG(DACPixelFormat, tmp);
  484. tmp = STG_READ_REG(DACHorizontalScal);
  485. CLEAR_BITS_FRM_TO(0, 11);
  486. CLEAR_BITS_FRM_TO(16, 17);
  487. tmp |= ((ulhDecim << 16) | (ulDacXScale));
  488. STG_WRITE_REG(DACHorizontalScal, tmp);
  489. return 0;
  490. }