saa7146_hlp.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044
  1. #include <linux/kernel.h>
  2. #include <media/saa7146_vv.h>
  3. static void calculate_output_format_register(struct saa7146_dev* saa, u32 palette, u32* clip_format)
  4. {
  5. /* clear out the necessary bits */
  6. *clip_format &= 0x0000ffff;
  7. /* set these bits new */
  8. *clip_format |= (( ((palette&0xf00)>>8) << 30) | ((palette&0x00f) << 24) | (((palette&0x0f0)>>4) << 16));
  9. }
  10. static void calculate_hps_source_and_sync(struct saa7146_dev *dev, int source, int sync, u32* hps_ctrl)
  11. {
  12. *hps_ctrl &= ~(MASK_30 | MASK_31 | MASK_28);
  13. *hps_ctrl |= (source << 30) | (sync << 28);
  14. }
  15. static void calculate_hxo_and_hyo(struct saa7146_vv *vv, u32* hps_h_scale, u32* hps_ctrl)
  16. {
  17. int hyo = 0, hxo = 0;
  18. hyo = vv->standard->v_offset;
  19. hxo = vv->standard->h_offset;
  20. *hps_h_scale &= ~(MASK_B0 | 0xf00);
  21. *hps_h_scale |= (hxo << 0);
  22. *hps_ctrl &= ~(MASK_W0 | MASK_B2);
  23. *hps_ctrl |= (hyo << 12);
  24. }
  25. /* helper functions for the calculation of the horizontal- and vertical
  26. scaling registers, clip-format-register etc ...
  27. these functions take pointers to the (most-likely read-out
  28. original-values) and manipulate them according to the requested
  29. changes.
  30. */
  31. /* hps_coeff used for CXY and CXUV; scale 1/1 -> scale 1/64 */
  32. static struct {
  33. u16 hps_coeff;
  34. u16 weight_sum;
  35. } hps_h_coeff_tab [] = {
  36. {0x00, 2}, {0x02, 4}, {0x00, 4}, {0x06, 8}, {0x02, 8},
  37. {0x08, 8}, {0x00, 8}, {0x1E, 16}, {0x0E, 8}, {0x26, 8},
  38. {0x06, 8}, {0x42, 8}, {0x02, 8}, {0x80, 8}, {0x00, 8},
  39. {0xFE, 16}, {0xFE, 8}, {0x7E, 8}, {0x7E, 8}, {0x3E, 8},
  40. {0x3E, 8}, {0x1E, 8}, {0x1E, 8}, {0x0E, 8}, {0x0E, 8},
  41. {0x06, 8}, {0x06, 8}, {0x02, 8}, {0x02, 8}, {0x00, 8},
  42. {0x00, 8}, {0xFE, 16}, {0xFE, 8}, {0xFE, 8}, {0xFE, 8},
  43. {0xFE, 8}, {0xFE, 8}, {0xFE, 8}, {0xFE, 8}, {0xFE, 8},
  44. {0xFE, 8}, {0xFE, 8}, {0xFE, 8}, {0xFE, 8}, {0xFE, 8},
  45. {0xFE, 8}, {0xFE, 8}, {0xFE, 8}, {0xFE, 8}, {0x7E, 8},
  46. {0x7E, 8}, {0x3E, 8}, {0x3E, 8}, {0x1E, 8}, {0x1E, 8},
  47. {0x0E, 8}, {0x0E, 8}, {0x06, 8}, {0x06, 8}, {0x02, 8},
  48. {0x02, 8}, {0x00, 8}, {0x00, 8}, {0xFE, 16}
  49. };
  50. /* table of attenuation values for horizontal scaling */
  51. static u8 h_attenuation[] = { 1, 2, 4, 8, 2, 4, 8, 16, 0};
  52. /* calculate horizontal scale registers */
  53. static int calculate_h_scale_registers(struct saa7146_dev *dev,
  54. int in_x, int out_x, int flip_lr,
  55. u32* hps_ctrl, u32* hps_v_gain, u32* hps_h_prescale, u32* hps_h_scale)
  56. {
  57. /* horizontal prescaler */
  58. u32 dcgx = 0, xpsc = 0, xacm = 0, cxy = 0, cxuv = 0;
  59. /* horizontal scaler */
  60. u32 xim = 0, xp = 0, xsci =0;
  61. /* vertical scale & gain */
  62. u32 pfuv = 0;
  63. /* helper variables */
  64. u32 h_atten = 0, i = 0;
  65. if ( 0 == out_x ) {
  66. return -EINVAL;
  67. }
  68. /* mask out vanity-bit */
  69. *hps_ctrl &= ~MASK_29;
  70. /* calculate prescale-(xspc)-value: [n .. 1/2) : 1
  71. [1/2 .. 1/3) : 2
  72. [1/3 .. 1/4) : 3
  73. ... */
  74. if (in_x > out_x) {
  75. xpsc = in_x / out_x;
  76. }
  77. else {
  78. /* zooming */
  79. xpsc = 1;
  80. }
  81. /* if flip_lr-bit is set, number of pixels after
  82. horizontal prescaling must be < 384 */
  83. if ( 0 != flip_lr ) {
  84. /* set vanity bit */
  85. *hps_ctrl |= MASK_29;
  86. while (in_x / xpsc >= 384 )
  87. xpsc++;
  88. }
  89. /* if zooming is wanted, number of pixels after
  90. horizontal prescaling must be < 768 */
  91. else {
  92. while ( in_x / xpsc >= 768 )
  93. xpsc++;
  94. }
  95. /* maximum prescale is 64 (p.69) */
  96. if ( xpsc > 64 )
  97. xpsc = 64;
  98. /* keep xacm clear*/
  99. xacm = 0;
  100. /* set horizontal filter parameters (CXY = CXUV) */
  101. cxy = hps_h_coeff_tab[( (xpsc - 1) < 63 ? (xpsc - 1) : 63 )].hps_coeff;
  102. cxuv = cxy;
  103. /* calculate and set horizontal fine scale (xsci) */
  104. /* bypass the horizontal scaler ? */
  105. if ( (in_x == out_x) && ( 1 == xpsc ) )
  106. xsci = 0x400;
  107. else
  108. xsci = ( (1024 * in_x) / (out_x * xpsc) ) + xpsc;
  109. /* set start phase for horizontal fine scale (xp) to 0 */
  110. xp = 0;
  111. /* set xim, if we bypass the horizontal scaler */
  112. if ( 0x400 == xsci )
  113. xim = 1;
  114. else
  115. xim = 0;
  116. /* if the prescaler is bypassed, enable horizontal
  117. accumulation mode (xacm) and clear dcgx */
  118. if( 1 == xpsc ) {
  119. xacm = 1;
  120. dcgx = 0;
  121. } else {
  122. xacm = 0;
  123. /* get best match in the table of attenuations
  124. for horizontal scaling */
  125. h_atten = hps_h_coeff_tab[( (xpsc - 1) < 63 ? (xpsc - 1) : 63 )].weight_sum;
  126. for (i = 0; h_attenuation[i] != 0; i++) {
  127. if (h_attenuation[i] >= h_atten)
  128. break;
  129. }
  130. dcgx = i;
  131. }
  132. /* the horizontal scaling increment controls the UV filter
  133. to reduce the bandwidth to improve the display quality,
  134. so set it ... */
  135. if ( xsci == 0x400)
  136. pfuv = 0x00;
  137. else if ( xsci < 0x600)
  138. pfuv = 0x01;
  139. else if ( xsci < 0x680)
  140. pfuv = 0x11;
  141. else if ( xsci < 0x700)
  142. pfuv = 0x22;
  143. else
  144. pfuv = 0x33;
  145. *hps_v_gain &= MASK_W0|MASK_B2;
  146. *hps_v_gain |= (pfuv << 24);
  147. *hps_h_scale &= ~(MASK_W1 | 0xf000);
  148. *hps_h_scale |= (xim << 31) | (xp << 24) | (xsci << 12);
  149. *hps_h_prescale |= (dcgx << 27) | ((xpsc-1) << 18) | (xacm << 17) | (cxy << 8) | (cxuv << 0);
  150. return 0;
  151. }
  152. static struct {
  153. u16 hps_coeff;
  154. u16 weight_sum;
  155. } hps_v_coeff_tab [] = {
  156. {0x0100, 2}, {0x0102, 4}, {0x0300, 4}, {0x0106, 8}, {0x0502, 8},
  157. {0x0708, 8}, {0x0F00, 8}, {0x011E, 16}, {0x110E, 16}, {0x1926, 16},
  158. {0x3906, 16}, {0x3D42, 16}, {0x7D02, 16}, {0x7F80, 16}, {0xFF00, 16},
  159. {0x01FE, 32}, {0x01FE, 32}, {0x817E, 32}, {0x817E, 32}, {0xC13E, 32},
  160. {0xC13E, 32}, {0xE11E, 32}, {0xE11E, 32}, {0xF10E, 32}, {0xF10E, 32},
  161. {0xF906, 32}, {0xF906, 32}, {0xFD02, 32}, {0xFD02, 32}, {0xFF00, 32},
  162. {0xFF00, 32}, {0x01FE, 64}, {0x01FE, 64}, {0x01FE, 64}, {0x01FE, 64},
  163. {0x01FE, 64}, {0x01FE, 64}, {0x01FE, 64}, {0x01FE, 64}, {0x01FE, 64},
  164. {0x01FE, 64}, {0x01FE, 64}, {0x01FE, 64}, {0x01FE, 64}, {0x01FE, 64},
  165. {0x01FE, 64}, {0x01FE, 64}, {0x01FE, 64}, {0x01FE, 64}, {0x817E, 64},
  166. {0x817E, 64}, {0xC13E, 64}, {0xC13E, 64}, {0xE11E, 64}, {0xE11E, 64},
  167. {0xF10E, 64}, {0xF10E, 64}, {0xF906, 64}, {0xF906, 64}, {0xFD02, 64},
  168. {0xFD02, 64}, {0xFF00, 64}, {0xFF00, 64}, {0x01FE, 128}
  169. };
  170. /* table of attenuation values for vertical scaling */
  171. static u16 v_attenuation[] = { 2, 4, 8, 16, 32, 64, 128, 256, 0};
  172. /* calculate vertical scale registers */
  173. static int calculate_v_scale_registers(struct saa7146_dev *dev, enum v4l2_field field,
  174. int in_y, int out_y, u32* hps_v_scale, u32* hps_v_gain)
  175. {
  176. int lpi = 0;
  177. /* vertical scaling */
  178. u32 yacm = 0, ysci = 0, yacl = 0, ypo = 0, ype = 0;
  179. /* vertical scale & gain */
  180. u32 dcgy = 0, cya_cyb = 0;
  181. /* helper variables */
  182. u32 v_atten = 0, i = 0;
  183. /* error, if vertical zooming */
  184. if ( in_y < out_y ) {
  185. return -EINVAL;
  186. }
  187. /* linear phase interpolation may be used
  188. if scaling is between 1 and 1/2 (both fields used)
  189. or scaling is between 1/2 and 1/4 (if only one field is used) */
  190. if (V4L2_FIELD_HAS_BOTH(field)) {
  191. if( 2*out_y >= in_y) {
  192. lpi = 1;
  193. }
  194. } else if (field == V4L2_FIELD_TOP
  195. || field == V4L2_FIELD_ALTERNATE
  196. || field == V4L2_FIELD_BOTTOM) {
  197. if( 4*out_y >= in_y ) {
  198. lpi = 1;
  199. }
  200. out_y *= 2;
  201. }
  202. if( 0 != lpi ) {
  203. yacm = 0;
  204. yacl = 0;
  205. cya_cyb = 0x00ff;
  206. /* calculate scaling increment */
  207. if ( in_y > out_y )
  208. ysci = ((1024 * in_y) / (out_y + 1)) - 1024;
  209. else
  210. ysci = 0;
  211. dcgy = 0;
  212. /* calculate ype and ypo */
  213. ype = ysci / 16;
  214. ypo = ype + (ysci / 64);
  215. } else {
  216. yacm = 1;
  217. /* calculate scaling increment */
  218. ysci = (((10 * 1024 * (in_y - out_y - 1)) / in_y) + 9) / 10;
  219. /* calculate ype and ypo */
  220. ypo = ype = ((ysci + 15) / 16);
  221. /* the sequence length interval (yacl) has to be set according
  222. to the prescale value, e.g. [n .. 1/2) : 0
  223. [1/2 .. 1/3) : 1
  224. [1/3 .. 1/4) : 2
  225. ... */
  226. if ( ysci < 512) {
  227. yacl = 0;
  228. } else {
  229. yacl = ( ysci / (1024 - ysci) );
  230. }
  231. /* get filter coefficients for cya, cyb from table hps_v_coeff_tab */
  232. cya_cyb = hps_v_coeff_tab[ (yacl < 63 ? yacl : 63 ) ].hps_coeff;
  233. /* get best match in the table of attenuations for vertical scaling */
  234. v_atten = hps_v_coeff_tab[ (yacl < 63 ? yacl : 63 ) ].weight_sum;
  235. for (i = 0; v_attenuation[i] != 0; i++) {
  236. if (v_attenuation[i] >= v_atten)
  237. break;
  238. }
  239. dcgy = i;
  240. }
  241. /* ypo and ype swapped in spec ? */
  242. *hps_v_scale |= (yacm << 31) | (ysci << 21) | (yacl << 15) | (ypo << 8 ) | (ype << 1);
  243. *hps_v_gain &= ~(MASK_W0|MASK_B2);
  244. *hps_v_gain |= (dcgy << 16) | (cya_cyb << 0);
  245. return 0;
  246. }
  247. /* simple bubble-sort algorithm with duplicate elimination */
  248. static int sort_and_eliminate(u32* values, int* count)
  249. {
  250. int low = 0, high = 0, top = 0, temp = 0;
  251. int cur = 0, next = 0;
  252. /* sanity checks */
  253. if( (0 > *count) || (NULL == values) ) {
  254. return -EINVAL;
  255. }
  256. /* bubble sort the first @count items of the array @values */
  257. for( top = *count; top > 0; top--) {
  258. for( low = 0, high = 1; high < top; low++, high++) {
  259. if( values[low] > values[high] ) {
  260. temp = values[low];
  261. values[low] = values[high];
  262. values[high] = temp;
  263. }
  264. }
  265. }
  266. /* remove duplicate items */
  267. for( cur = 0, next = 1; next < *count; next++) {
  268. if( values[cur] != values[next])
  269. values[++cur] = values[next];
  270. }
  271. *count = cur + 1;
  272. return 0;
  273. }
  274. static void calculate_clipping_registers_rect(struct saa7146_dev *dev, struct saa7146_fh *fh,
  275. struct saa7146_video_dma *vdma2, u32* clip_format, u32* arbtr_ctrl, enum v4l2_field field)
  276. {
  277. struct saa7146_vv *vv = dev->vv_data;
  278. __le32 *clipping = vv->d_clipping.cpu_addr;
  279. int width = fh->ov.win.w.width;
  280. int height = fh->ov.win.w.height;
  281. int clipcount = fh->ov.nclips;
  282. u32 line_list[32];
  283. u32 pixel_list[32];
  284. int numdwords = 0;
  285. int i = 0, j = 0;
  286. int cnt_line = 0, cnt_pixel = 0;
  287. int x[32], y[32], w[32], h[32];
  288. /* clear out memory */
  289. memset(&line_list[0], 0x00, sizeof(u32)*32);
  290. memset(&pixel_list[0], 0x00, sizeof(u32)*32);
  291. memset(clipping, 0x00, SAA7146_CLIPPING_MEM);
  292. /* fill the line and pixel-lists */
  293. for(i = 0; i < clipcount; i++) {
  294. int l = 0, r = 0, t = 0, b = 0;
  295. x[i] = fh->ov.clips[i].c.left;
  296. y[i] = fh->ov.clips[i].c.top;
  297. w[i] = fh->ov.clips[i].c.width;
  298. h[i] = fh->ov.clips[i].c.height;
  299. if( w[i] < 0) {
  300. x[i] += w[i]; w[i] = -w[i];
  301. }
  302. if( h[i] < 0) {
  303. y[i] += h[i]; h[i] = -h[i];
  304. }
  305. if( x[i] < 0) {
  306. w[i] += x[i]; x[i] = 0;
  307. }
  308. if( y[i] < 0) {
  309. h[i] += y[i]; y[i] = 0;
  310. }
  311. if( 0 != vv->vflip ) {
  312. y[i] = height - y[i] - h[i];
  313. }
  314. l = x[i];
  315. r = x[i]+w[i];
  316. t = y[i];
  317. b = y[i]+h[i];
  318. /* insert left/right coordinates */
  319. pixel_list[ 2*i ] = min_t(int, l, width);
  320. pixel_list[(2*i)+1] = min_t(int, r, width);
  321. /* insert top/bottom coordinates */
  322. line_list[ 2*i ] = min_t(int, t, height);
  323. line_list[(2*i)+1] = min_t(int, b, height);
  324. }
  325. /* sort and eliminate lists */
  326. cnt_line = cnt_pixel = 2*clipcount;
  327. sort_and_eliminate( &pixel_list[0], &cnt_pixel );
  328. sort_and_eliminate( &line_list[0], &cnt_line );
  329. /* calculate the number of used u32s */
  330. numdwords = max_t(int, (cnt_line+1), (cnt_pixel+1))*2;
  331. numdwords = max_t(int, 4, numdwords);
  332. numdwords = min_t(int, 64, numdwords);
  333. /* fill up cliptable */
  334. for(i = 0; i < cnt_pixel; i++) {
  335. clipping[2*i] |= cpu_to_le32(pixel_list[i] << 16);
  336. }
  337. for(i = 0; i < cnt_line; i++) {
  338. clipping[(2*i)+1] |= cpu_to_le32(line_list[i] << 16);
  339. }
  340. /* fill up cliptable with the display infos */
  341. for(j = 0; j < clipcount; j++) {
  342. for(i = 0; i < cnt_pixel; i++) {
  343. if( x[j] < 0)
  344. x[j] = 0;
  345. if( pixel_list[i] < (x[j] + w[j])) {
  346. if ( pixel_list[i] >= x[j] ) {
  347. clipping[2*i] |= cpu_to_le32(1 << j);
  348. }
  349. }
  350. }
  351. for(i = 0; i < cnt_line; i++) {
  352. if( y[j] < 0)
  353. y[j] = 0;
  354. if( line_list[i] < (y[j] + h[j]) ) {
  355. if( line_list[i] >= y[j] ) {
  356. clipping[(2*i)+1] |= cpu_to_le32(1 << j);
  357. }
  358. }
  359. }
  360. }
  361. /* adjust arbitration control register */
  362. *arbtr_ctrl &= 0xffff00ff;
  363. *arbtr_ctrl |= 0x00001c00;
  364. vdma2->base_even = vv->d_clipping.dma_handle;
  365. vdma2->base_odd = vv->d_clipping.dma_handle;
  366. vdma2->prot_addr = vv->d_clipping.dma_handle+((sizeof(u32))*(numdwords));
  367. vdma2->base_page = 0x04;
  368. vdma2->pitch = 0x00;
  369. vdma2->num_line_byte = (0 << 16 | (sizeof(u32))*(numdwords-1) );
  370. /* set clipping-mode. this depends on the field(s) used */
  371. *clip_format &= 0xfffffff7;
  372. if (V4L2_FIELD_HAS_BOTH(field)) {
  373. *clip_format |= 0x00000008;
  374. } else {
  375. *clip_format |= 0x00000000;
  376. }
  377. }
  378. /* disable clipping */
  379. static void saa7146_disable_clipping(struct saa7146_dev *dev)
  380. {
  381. u32 clip_format = saa7146_read(dev, CLIP_FORMAT_CTRL);
  382. /* mask out relevant bits (=lower word)*/
  383. clip_format &= MASK_W1;
  384. /* upload clipping-registers*/
  385. saa7146_write(dev, CLIP_FORMAT_CTRL,clip_format);
  386. saa7146_write(dev, MC2, (MASK_05 | MASK_21));
  387. /* disable video dma2 */
  388. saa7146_write(dev, MC1, MASK_21);
  389. }
  390. static void saa7146_set_clipping_rect(struct saa7146_fh *fh)
  391. {
  392. struct saa7146_dev *dev = fh->dev;
  393. enum v4l2_field field = fh->ov.win.field;
  394. struct saa7146_video_dma vdma2;
  395. u32 clip_format;
  396. u32 arbtr_ctrl;
  397. /* check clipcount, disable clipping if clipcount == 0*/
  398. if( fh->ov.nclips == 0 ) {
  399. saa7146_disable_clipping(dev);
  400. return;
  401. }
  402. clip_format = saa7146_read(dev, CLIP_FORMAT_CTRL);
  403. arbtr_ctrl = saa7146_read(dev, PCI_BT_V1);
  404. calculate_clipping_registers_rect(dev, fh, &vdma2, &clip_format, &arbtr_ctrl, field);
  405. /* set clipping format */
  406. clip_format &= 0xffff0008;
  407. clip_format |= (SAA7146_CLIPPING_RECT << 4);
  408. /* prepare video dma2 */
  409. saa7146_write(dev, BASE_EVEN2, vdma2.base_even);
  410. saa7146_write(dev, BASE_ODD2, vdma2.base_odd);
  411. saa7146_write(dev, PROT_ADDR2, vdma2.prot_addr);
  412. saa7146_write(dev, BASE_PAGE2, vdma2.base_page);
  413. saa7146_write(dev, PITCH2, vdma2.pitch);
  414. saa7146_write(dev, NUM_LINE_BYTE2, vdma2.num_line_byte);
  415. /* prepare the rest */
  416. saa7146_write(dev, CLIP_FORMAT_CTRL,clip_format);
  417. saa7146_write(dev, PCI_BT_V1, arbtr_ctrl);
  418. /* upload clip_control-register, clipping-registers, enable video dma2 */
  419. saa7146_write(dev, MC2, (MASK_05 | MASK_21 | MASK_03 | MASK_19));
  420. saa7146_write(dev, MC1, (MASK_05 | MASK_21));
  421. }
  422. static void saa7146_set_window(struct saa7146_dev *dev, int width, int height, enum v4l2_field field)
  423. {
  424. struct saa7146_vv *vv = dev->vv_data;
  425. int source = vv->current_hps_source;
  426. int sync = vv->current_hps_sync;
  427. u32 hps_v_scale = 0, hps_v_gain = 0, hps_ctrl = 0, hps_h_prescale = 0, hps_h_scale = 0;
  428. /* set vertical scale */
  429. hps_v_scale = 0; /* all bits get set by the function-call */
  430. hps_v_gain = 0; /* fixme: saa7146_read(dev, HPS_V_GAIN);*/
  431. calculate_v_scale_registers(dev, field, vv->standard->v_field*2, height, &hps_v_scale, &hps_v_gain);
  432. /* set horizontal scale */
  433. hps_ctrl = 0;
  434. hps_h_prescale = 0; /* all bits get set in the function */
  435. hps_h_scale = 0;
  436. calculate_h_scale_registers(dev, vv->standard->h_pixels, width, vv->hflip, &hps_ctrl, &hps_v_gain, &hps_h_prescale, &hps_h_scale);
  437. /* set hyo and hxo */
  438. calculate_hxo_and_hyo(vv, &hps_h_scale, &hps_ctrl);
  439. calculate_hps_source_and_sync(dev, source, sync, &hps_ctrl);
  440. /* write out new register contents */
  441. saa7146_write(dev, HPS_V_SCALE, hps_v_scale);
  442. saa7146_write(dev, HPS_V_GAIN, hps_v_gain);
  443. saa7146_write(dev, HPS_CTRL, hps_ctrl);
  444. saa7146_write(dev, HPS_H_PRESCALE,hps_h_prescale);
  445. saa7146_write(dev, HPS_H_SCALE, hps_h_scale);
  446. /* upload shadow-ram registers */
  447. saa7146_write(dev, MC2, (MASK_05 | MASK_06 | MASK_21 | MASK_22) );
  448. }
  449. /* calculate the new memory offsets for a desired position */
  450. static void saa7146_set_position(struct saa7146_dev *dev, int w_x, int w_y, int w_height, enum v4l2_field field, u32 pixelformat)
  451. {
  452. struct saa7146_vv *vv = dev->vv_data;
  453. struct saa7146_format *sfmt = format_by_fourcc(dev, pixelformat);
  454. int b_depth = vv->ov_fmt->depth;
  455. int b_bpl = vv->ov_fb.fmt.bytesperline;
  456. /* The unsigned long cast is to remove a 64-bit compile warning since
  457. it looks like a 64-bit address is cast to a 32-bit value, even
  458. though the base pointer is really a 32-bit physical address that
  459. goes into a 32-bit DMA register.
  460. FIXME: might not work on some 64-bit platforms, but see the FIXME
  461. in struct v4l2_framebuffer (videodev2.h) for that.
  462. */
  463. u32 base = (u32)(unsigned long)vv->ov_fb.base;
  464. struct saa7146_video_dma vdma1;
  465. /* calculate memory offsets for picture, look if we shall top-down-flip */
  466. vdma1.pitch = 2*b_bpl;
  467. if ( 0 == vv->vflip ) {
  468. vdma1.base_even = base + (w_y * (vdma1.pitch/2)) + (w_x * (b_depth / 8));
  469. vdma1.base_odd = vdma1.base_even + (vdma1.pitch / 2);
  470. vdma1.prot_addr = vdma1.base_even + (w_height * (vdma1.pitch / 2));
  471. }
  472. else {
  473. vdma1.base_even = base + ((w_y+w_height) * (vdma1.pitch/2)) + (w_x * (b_depth / 8));
  474. vdma1.base_odd = vdma1.base_even - (vdma1.pitch / 2);
  475. vdma1.prot_addr = vdma1.base_odd - (w_height * (vdma1.pitch / 2));
  476. }
  477. if (V4L2_FIELD_HAS_BOTH(field)) {
  478. } else if (field == V4L2_FIELD_ALTERNATE) {
  479. /* fixme */
  480. vdma1.base_odd = vdma1.prot_addr;
  481. vdma1.pitch /= 2;
  482. } else if (field == V4L2_FIELD_TOP) {
  483. vdma1.base_odd = vdma1.prot_addr;
  484. vdma1.pitch /= 2;
  485. } else if (field == V4L2_FIELD_BOTTOM) {
  486. vdma1.base_odd = vdma1.base_even;
  487. vdma1.base_even = vdma1.prot_addr;
  488. vdma1.pitch /= 2;
  489. }
  490. if ( 0 != vv->vflip ) {
  491. vdma1.pitch *= -1;
  492. }
  493. vdma1.base_page = sfmt->swap;
  494. vdma1.num_line_byte = (vv->standard->v_field<<16)+vv->standard->h_pixels;
  495. saa7146_write_out_dma(dev, 1, &vdma1);
  496. }
  497. static void saa7146_set_output_format(struct saa7146_dev *dev, unsigned long palette)
  498. {
  499. u32 clip_format = saa7146_read(dev, CLIP_FORMAT_CTRL);
  500. /* call helper function */
  501. calculate_output_format_register(dev,palette,&clip_format);
  502. /* update the hps registers */
  503. saa7146_write(dev, CLIP_FORMAT_CTRL, clip_format);
  504. saa7146_write(dev, MC2, (MASK_05 | MASK_21));
  505. }
  506. /* select input-source */
  507. void saa7146_set_hps_source_and_sync(struct saa7146_dev *dev, int source, int sync)
  508. {
  509. struct saa7146_vv *vv = dev->vv_data;
  510. u32 hps_ctrl = 0;
  511. /* read old state */
  512. hps_ctrl = saa7146_read(dev, HPS_CTRL);
  513. hps_ctrl &= ~( MASK_31 | MASK_30 | MASK_28 );
  514. hps_ctrl |= (source << 30) | (sync << 28);
  515. /* write back & upload register */
  516. saa7146_write(dev, HPS_CTRL, hps_ctrl);
  517. saa7146_write(dev, MC2, (MASK_05 | MASK_21));
  518. vv->current_hps_source = source;
  519. vv->current_hps_sync = sync;
  520. }
  521. EXPORT_SYMBOL_GPL(saa7146_set_hps_source_and_sync);
  522. int saa7146_enable_overlay(struct saa7146_fh *fh)
  523. {
  524. struct saa7146_dev *dev = fh->dev;
  525. struct saa7146_vv *vv = dev->vv_data;
  526. saa7146_set_window(dev, fh->ov.win.w.width, fh->ov.win.w.height, fh->ov.win.field);
  527. saa7146_set_position(dev, fh->ov.win.w.left, fh->ov.win.w.top, fh->ov.win.w.height, fh->ov.win.field, vv->ov_fmt->pixelformat);
  528. saa7146_set_output_format(dev, vv->ov_fmt->trans);
  529. saa7146_set_clipping_rect(fh);
  530. /* enable video dma1 */
  531. saa7146_write(dev, MC1, (MASK_06 | MASK_22));
  532. return 0;
  533. }
  534. void saa7146_disable_overlay(struct saa7146_fh *fh)
  535. {
  536. struct saa7146_dev *dev = fh->dev;
  537. /* disable clipping + video dma1 */
  538. saa7146_disable_clipping(dev);
  539. saa7146_write(dev, MC1, MASK_22);
  540. }
  541. void saa7146_write_out_dma(struct saa7146_dev* dev, int which, struct saa7146_video_dma* vdma)
  542. {
  543. int where = 0;
  544. if( which < 1 || which > 3) {
  545. return;
  546. }
  547. /* calculate starting address */
  548. where = (which-1)*0x18;
  549. saa7146_write(dev, where, vdma->base_odd);
  550. saa7146_write(dev, where+0x04, vdma->base_even);
  551. saa7146_write(dev, where+0x08, vdma->prot_addr);
  552. saa7146_write(dev, where+0x0c, vdma->pitch);
  553. saa7146_write(dev, where+0x10, vdma->base_page);
  554. saa7146_write(dev, where+0x14, vdma->num_line_byte);
  555. /* upload */
  556. saa7146_write(dev, MC2, (MASK_02<<(which-1))|(MASK_18<<(which-1)));
  557. /*
  558. printk("vdma%d.base_even: 0x%08x\n", which,vdma->base_even);
  559. printk("vdma%d.base_odd: 0x%08x\n", which,vdma->base_odd);
  560. printk("vdma%d.prot_addr: 0x%08x\n", which,vdma->prot_addr);
  561. printk("vdma%d.base_page: 0x%08x\n", which,vdma->base_page);
  562. printk("vdma%d.pitch: 0x%08x\n", which,vdma->pitch);
  563. printk("vdma%d.num_line_byte: 0x%08x\n", which,vdma->num_line_byte);
  564. */
  565. }
  566. static int calculate_video_dma_grab_packed(struct saa7146_dev* dev, struct saa7146_buf *buf)
  567. {
  568. struct saa7146_vv *vv = dev->vv_data;
  569. struct saa7146_video_dma vdma1;
  570. struct saa7146_format *sfmt = format_by_fourcc(dev,buf->fmt->pixelformat);
  571. int width = buf->fmt->width;
  572. int height = buf->fmt->height;
  573. int bytesperline = buf->fmt->bytesperline;
  574. enum v4l2_field field = buf->fmt->field;
  575. int depth = sfmt->depth;
  576. DEB_CAP(("[size=%dx%d,fields=%s]\n",
  577. width,height,v4l2_field_names[field]));
  578. if( bytesperline != 0) {
  579. vdma1.pitch = bytesperline*2;
  580. } else {
  581. vdma1.pitch = (width*depth*2)/8;
  582. }
  583. vdma1.num_line_byte = ((vv->standard->v_field<<16) + vv->standard->h_pixels);
  584. vdma1.base_page = buf->pt[0].dma | ME1 | sfmt->swap;
  585. if( 0 != vv->vflip ) {
  586. vdma1.prot_addr = buf->pt[0].offset;
  587. vdma1.base_even = buf->pt[0].offset+(vdma1.pitch/2)*height;
  588. vdma1.base_odd = vdma1.base_even - (vdma1.pitch/2);
  589. } else {
  590. vdma1.base_even = buf->pt[0].offset;
  591. vdma1.base_odd = vdma1.base_even + (vdma1.pitch/2);
  592. vdma1.prot_addr = buf->pt[0].offset+(vdma1.pitch/2)*height;
  593. }
  594. if (V4L2_FIELD_HAS_BOTH(field)) {
  595. } else if (field == V4L2_FIELD_ALTERNATE) {
  596. /* fixme */
  597. if ( vv->last_field == V4L2_FIELD_TOP ) {
  598. vdma1.base_odd = vdma1.prot_addr;
  599. vdma1.pitch /= 2;
  600. } else if ( vv->last_field == V4L2_FIELD_BOTTOM ) {
  601. vdma1.base_odd = vdma1.base_even;
  602. vdma1.base_even = vdma1.prot_addr;
  603. vdma1.pitch /= 2;
  604. }
  605. } else if (field == V4L2_FIELD_TOP) {
  606. vdma1.base_odd = vdma1.prot_addr;
  607. vdma1.pitch /= 2;
  608. } else if (field == V4L2_FIELD_BOTTOM) {
  609. vdma1.base_odd = vdma1.base_even;
  610. vdma1.base_even = vdma1.prot_addr;
  611. vdma1.pitch /= 2;
  612. }
  613. if( 0 != vv->vflip ) {
  614. vdma1.pitch *= -1;
  615. }
  616. saa7146_write_out_dma(dev, 1, &vdma1);
  617. return 0;
  618. }
  619. static int calc_planar_422(struct saa7146_vv *vv, struct saa7146_buf *buf, struct saa7146_video_dma *vdma2, struct saa7146_video_dma *vdma3)
  620. {
  621. int height = buf->fmt->height;
  622. int width = buf->fmt->width;
  623. vdma2->pitch = width;
  624. vdma3->pitch = width;
  625. /* fixme: look at bytesperline! */
  626. if( 0 != vv->vflip ) {
  627. vdma2->prot_addr = buf->pt[1].offset;
  628. vdma2->base_even = ((vdma2->pitch/2)*height)+buf->pt[1].offset;
  629. vdma2->base_odd = vdma2->base_even - (vdma2->pitch/2);
  630. vdma3->prot_addr = buf->pt[2].offset;
  631. vdma3->base_even = ((vdma3->pitch/2)*height)+buf->pt[2].offset;
  632. vdma3->base_odd = vdma3->base_even - (vdma3->pitch/2);
  633. } else {
  634. vdma3->base_even = buf->pt[2].offset;
  635. vdma3->base_odd = vdma3->base_even + (vdma3->pitch/2);
  636. vdma3->prot_addr = (vdma3->pitch/2)*height+buf->pt[2].offset;
  637. vdma2->base_even = buf->pt[1].offset;
  638. vdma2->base_odd = vdma2->base_even + (vdma2->pitch/2);
  639. vdma2->prot_addr = (vdma2->pitch/2)*height+buf->pt[1].offset;
  640. }
  641. return 0;
  642. }
  643. static int calc_planar_420(struct saa7146_vv *vv, struct saa7146_buf *buf, struct saa7146_video_dma *vdma2, struct saa7146_video_dma *vdma3)
  644. {
  645. int height = buf->fmt->height;
  646. int width = buf->fmt->width;
  647. vdma2->pitch = width/2;
  648. vdma3->pitch = width/2;
  649. if( 0 != vv->vflip ) {
  650. vdma2->prot_addr = buf->pt[2].offset;
  651. vdma2->base_even = ((vdma2->pitch/2)*height)+buf->pt[2].offset;
  652. vdma2->base_odd = vdma2->base_even - (vdma2->pitch/2);
  653. vdma3->prot_addr = buf->pt[1].offset;
  654. vdma3->base_even = ((vdma3->pitch/2)*height)+buf->pt[1].offset;
  655. vdma3->base_odd = vdma3->base_even - (vdma3->pitch/2);
  656. } else {
  657. vdma3->base_even = buf->pt[2].offset;
  658. vdma3->base_odd = vdma3->base_even + (vdma3->pitch);
  659. vdma3->prot_addr = (vdma3->pitch/2)*height+buf->pt[2].offset;
  660. vdma2->base_even = buf->pt[1].offset;
  661. vdma2->base_odd = vdma2->base_even + (vdma2->pitch);
  662. vdma2->prot_addr = (vdma2->pitch/2)*height+buf->pt[1].offset;
  663. }
  664. return 0;
  665. }
  666. static int calculate_video_dma_grab_planar(struct saa7146_dev* dev, struct saa7146_buf *buf)
  667. {
  668. struct saa7146_vv *vv = dev->vv_data;
  669. struct saa7146_video_dma vdma1;
  670. struct saa7146_video_dma vdma2;
  671. struct saa7146_video_dma vdma3;
  672. struct saa7146_format *sfmt = format_by_fourcc(dev,buf->fmt->pixelformat);
  673. int width = buf->fmt->width;
  674. int height = buf->fmt->height;
  675. enum v4l2_field field = buf->fmt->field;
  676. BUG_ON(0 == buf->pt[0].dma);
  677. BUG_ON(0 == buf->pt[1].dma);
  678. BUG_ON(0 == buf->pt[2].dma);
  679. DEB_CAP(("[size=%dx%d,fields=%s]\n",
  680. width,height,v4l2_field_names[field]));
  681. /* fixme: look at bytesperline! */
  682. /* fixme: what happens for user space buffers here?. The offsets are
  683. most likely wrong, this version here only works for page-aligned
  684. buffers, modifications to the pagetable-functions are necessary...*/
  685. vdma1.pitch = width*2;
  686. vdma1.num_line_byte = ((vv->standard->v_field<<16) + vv->standard->h_pixels);
  687. vdma1.base_page = buf->pt[0].dma | ME1;
  688. if( 0 != vv->vflip ) {
  689. vdma1.prot_addr = buf->pt[0].offset;
  690. vdma1.base_even = ((vdma1.pitch/2)*height)+buf->pt[0].offset;
  691. vdma1.base_odd = vdma1.base_even - (vdma1.pitch/2);
  692. } else {
  693. vdma1.base_even = buf->pt[0].offset;
  694. vdma1.base_odd = vdma1.base_even + (vdma1.pitch/2);
  695. vdma1.prot_addr = (vdma1.pitch/2)*height+buf->pt[0].offset;
  696. }
  697. vdma2.num_line_byte = 0; /* unused */
  698. vdma2.base_page = buf->pt[1].dma | ME1;
  699. vdma3.num_line_byte = 0; /* unused */
  700. vdma3.base_page = buf->pt[2].dma | ME1;
  701. switch( sfmt->depth ) {
  702. case 12: {
  703. calc_planar_420(vv,buf,&vdma2,&vdma3);
  704. break;
  705. }
  706. case 16: {
  707. calc_planar_422(vv,buf,&vdma2,&vdma3);
  708. break;
  709. }
  710. default: {
  711. return -1;
  712. }
  713. }
  714. if (V4L2_FIELD_HAS_BOTH(field)) {
  715. } else if (field == V4L2_FIELD_ALTERNATE) {
  716. /* fixme */
  717. vdma1.base_odd = vdma1.prot_addr;
  718. vdma1.pitch /= 2;
  719. vdma2.base_odd = vdma2.prot_addr;
  720. vdma2.pitch /= 2;
  721. vdma3.base_odd = vdma3.prot_addr;
  722. vdma3.pitch /= 2;
  723. } else if (field == V4L2_FIELD_TOP) {
  724. vdma1.base_odd = vdma1.prot_addr;
  725. vdma1.pitch /= 2;
  726. vdma2.base_odd = vdma2.prot_addr;
  727. vdma2.pitch /= 2;
  728. vdma3.base_odd = vdma3.prot_addr;
  729. vdma3.pitch /= 2;
  730. } else if (field == V4L2_FIELD_BOTTOM) {
  731. vdma1.base_odd = vdma1.base_even;
  732. vdma1.base_even = vdma1.prot_addr;
  733. vdma1.pitch /= 2;
  734. vdma2.base_odd = vdma2.base_even;
  735. vdma2.base_even = vdma2.prot_addr;
  736. vdma2.pitch /= 2;
  737. vdma3.base_odd = vdma3.base_even;
  738. vdma3.base_even = vdma3.prot_addr;
  739. vdma3.pitch /= 2;
  740. }
  741. if( 0 != vv->vflip ) {
  742. vdma1.pitch *= -1;
  743. vdma2.pitch *= -1;
  744. vdma3.pitch *= -1;
  745. }
  746. saa7146_write_out_dma(dev, 1, &vdma1);
  747. if( (sfmt->flags & FORMAT_BYTE_SWAP) != 0 ) {
  748. saa7146_write_out_dma(dev, 3, &vdma2);
  749. saa7146_write_out_dma(dev, 2, &vdma3);
  750. } else {
  751. saa7146_write_out_dma(dev, 2, &vdma2);
  752. saa7146_write_out_dma(dev, 3, &vdma3);
  753. }
  754. return 0;
  755. }
  756. static void program_capture_engine(struct saa7146_dev *dev, int planar)
  757. {
  758. struct saa7146_vv *vv = dev->vv_data;
  759. int count = 0;
  760. unsigned long e_wait = vv->current_hps_sync == SAA7146_HPS_SYNC_PORT_A ? CMD_E_FID_A : CMD_E_FID_B;
  761. unsigned long o_wait = vv->current_hps_sync == SAA7146_HPS_SYNC_PORT_A ? CMD_O_FID_A : CMD_O_FID_B;
  762. /* wait for o_fid_a/b / e_fid_a/b toggle only if rps register 0 is not set*/
  763. WRITE_RPS0(CMD_PAUSE | CMD_OAN | CMD_SIG0 | o_wait);
  764. WRITE_RPS0(CMD_PAUSE | CMD_OAN | CMD_SIG0 | e_wait);
  765. /* set rps register 0 */
  766. WRITE_RPS0(CMD_WR_REG | (1 << 8) | (MC2/4));
  767. WRITE_RPS0(MASK_27 | MASK_11);
  768. /* turn on video-dma1 */
  769. WRITE_RPS0(CMD_WR_REG_MASK | (MC1/4));
  770. WRITE_RPS0(MASK_06 | MASK_22); /* => mask */
  771. WRITE_RPS0(MASK_06 | MASK_22); /* => values */
  772. if( 0 != planar ) {
  773. /* turn on video-dma2 */
  774. WRITE_RPS0(CMD_WR_REG_MASK | (MC1/4));
  775. WRITE_RPS0(MASK_05 | MASK_21); /* => mask */
  776. WRITE_RPS0(MASK_05 | MASK_21); /* => values */
  777. /* turn on video-dma3 */
  778. WRITE_RPS0(CMD_WR_REG_MASK | (MC1/4));
  779. WRITE_RPS0(MASK_04 | MASK_20); /* => mask */
  780. WRITE_RPS0(MASK_04 | MASK_20); /* => values */
  781. }
  782. /* wait for o_fid_a/b / e_fid_a/b toggle */
  783. if ( vv->last_field == V4L2_FIELD_INTERLACED ) {
  784. WRITE_RPS0(CMD_PAUSE | o_wait);
  785. WRITE_RPS0(CMD_PAUSE | e_wait);
  786. } else if ( vv->last_field == V4L2_FIELD_TOP ) {
  787. WRITE_RPS0(CMD_PAUSE | (vv->current_hps_sync == SAA7146_HPS_SYNC_PORT_A ? MASK_10 : MASK_09));
  788. WRITE_RPS0(CMD_PAUSE | o_wait);
  789. } else if ( vv->last_field == V4L2_FIELD_BOTTOM ) {
  790. WRITE_RPS0(CMD_PAUSE | (vv->current_hps_sync == SAA7146_HPS_SYNC_PORT_A ? MASK_10 : MASK_09));
  791. WRITE_RPS0(CMD_PAUSE | e_wait);
  792. }
  793. /* turn off video-dma1 */
  794. WRITE_RPS0(CMD_WR_REG_MASK | (MC1/4));
  795. WRITE_RPS0(MASK_22 | MASK_06); /* => mask */
  796. WRITE_RPS0(MASK_22); /* => values */
  797. if( 0 != planar ) {
  798. /* turn off video-dma2 */
  799. WRITE_RPS0(CMD_WR_REG_MASK | (MC1/4));
  800. WRITE_RPS0(MASK_05 | MASK_21); /* => mask */
  801. WRITE_RPS0(MASK_21); /* => values */
  802. /* turn off video-dma3 */
  803. WRITE_RPS0(CMD_WR_REG_MASK | (MC1/4));
  804. WRITE_RPS0(MASK_04 | MASK_20); /* => mask */
  805. WRITE_RPS0(MASK_20); /* => values */
  806. }
  807. /* generate interrupt */
  808. WRITE_RPS0(CMD_INTERRUPT);
  809. /* stop */
  810. WRITE_RPS0(CMD_STOP);
  811. }
  812. void saa7146_set_capture(struct saa7146_dev *dev, struct saa7146_buf *buf, struct saa7146_buf *next)
  813. {
  814. struct saa7146_format *sfmt = format_by_fourcc(dev,buf->fmt->pixelformat);
  815. struct saa7146_vv *vv = dev->vv_data;
  816. u32 vdma1_prot_addr;
  817. DEB_CAP(("buf:%p, next:%p\n",buf,next));
  818. vdma1_prot_addr = saa7146_read(dev, PROT_ADDR1);
  819. if( 0 == vdma1_prot_addr ) {
  820. /* clear out beginning of streaming bit (rps register 0)*/
  821. DEB_CAP(("forcing sync to new frame\n"));
  822. saa7146_write(dev, MC2, MASK_27 );
  823. }
  824. saa7146_set_window(dev, buf->fmt->width, buf->fmt->height, buf->fmt->field);
  825. saa7146_set_output_format(dev, sfmt->trans);
  826. saa7146_disable_clipping(dev);
  827. if ( vv->last_field == V4L2_FIELD_INTERLACED ) {
  828. } else if ( vv->last_field == V4L2_FIELD_TOP ) {
  829. vv->last_field = V4L2_FIELD_BOTTOM;
  830. } else if ( vv->last_field == V4L2_FIELD_BOTTOM ) {
  831. vv->last_field = V4L2_FIELD_TOP;
  832. }
  833. if( 0 != IS_PLANAR(sfmt->trans)) {
  834. calculate_video_dma_grab_planar(dev, buf);
  835. program_capture_engine(dev,1);
  836. } else {
  837. calculate_video_dma_grab_packed(dev, buf);
  838. program_capture_engine(dev,0);
  839. }
  840. /*
  841. printk("vdma%d.base_even: 0x%08x\n", 1,saa7146_read(dev,BASE_EVEN1));
  842. printk("vdma%d.base_odd: 0x%08x\n", 1,saa7146_read(dev,BASE_ODD1));
  843. printk("vdma%d.prot_addr: 0x%08x\n", 1,saa7146_read(dev,PROT_ADDR1));
  844. printk("vdma%d.base_page: 0x%08x\n", 1,saa7146_read(dev,BASE_PAGE1));
  845. printk("vdma%d.pitch: 0x%08x\n", 1,saa7146_read(dev,PITCH1));
  846. printk("vdma%d.num_line_byte: 0x%08x\n", 1,saa7146_read(dev,NUM_LINE_BYTE1));
  847. printk("vdma%d => vptr : 0x%08x\n", 1,saa7146_read(dev,PCI_VDP1));
  848. */
  849. /* write the address of the rps-program */
  850. saa7146_write(dev, RPS_ADDR0, dev->d_rps0.dma_handle);
  851. /* turn on rps */
  852. saa7146_write(dev, MC1, (MASK_12 | MASK_28));
  853. }