saa7146_hlp.c 30 KB

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