46 int y_pages, uv_pages;
47 unsigned long y_buffer_offset, uv_buffer_offset;
48 int y_decode_height, uv_decode_height, y_size;
53 y_decode_height = uv_decode_height = f->
src_h + f->
src_y;
56 y_buffer_offset += 720 * 16;
58 if (y_decode_height & 15)
59 y_decode_height = (y_decode_height + 16) & ~15;
61 if (uv_decode_height & 31)
62 uv_decode_height = (uv_decode_height + 32) & ~31;
64 y_size = 720 * y_decode_height;
69 (
"prep_user_dma: SG_length %d page_count %d still full?\n",
81 if (y_pages == y_dma.page_count) {
83 uv_dma.uaddr, uv_dma.page_count, 0, 1,
88 if (y_pages != y_dma.page_count || uv_pages != uv_dma.page_count) {
91 if (y_pages == y_dma.page_count) {
93 (
"failed to map uv user pages, returned %d "
94 "expecting %d\n", uv_pages, uv_dma.page_count);
97 for (i = 0; i < uv_pages; i++)
105 (
"failed to map y user pages, returned %d "
106 "expecting %d\n", y_pages, y_dma.page_count);
109 for (i = 0; i < y_pages; i++)
127 IVTV_DEBUG_WARN(
"could not allocate bounce buffers for highmem userspace buffers\n");
150 ivtv_udma_sync_for_device(itv);
159 for (i = 0, y = 16, uv = 4; i < 16; i++, y += 24, uv += 12) {
162 IVTV_WARN (
"YUV filter table not found in firmware.\n");
169 static void ivtv_yuv_filter(
struct ivtv *itv,
int h_filter,
int v_filter_1,
int v_filter_2)
178 for (line = 0; line < 16; line++) {
200 if (v_filter_1 > -1) {
204 for (line = 0; line < 16; line++) {
214 if (v_filter_2 > -1) {
218 for (line = 0; line < 16; line++) {
241 (
"Adjust to width %d src_w %d dst_w %d src_x %d dst_x %d\n",
263 if (f->
vis_w == 720) {
270 reg_2870 = reg_2870 << 16 |
reg_2870;
272 reg_2870 = ((reg_2870 & ~1) << 15) | (reg_2870 & ~1);
285 master_width = (f->
src_w * 0x00200000) / (f->
dst_w);
286 if (master_width * f->
dst_w != f->
src_w * 0x00200000)
288 reg_2834 = (reg_2834 << 16) | x_cutoff;
289 reg_2838 = (reg_2838 << 16) | x_cutoff;
290 reg_283c = master_width >> 2;
291 reg_2844 = master_width >> 2;
292 reg_2854 = master_width;
293 reg_285c = master_width >> 1;
294 reg_2864 = master_width >> 1;
303 reg_2870 += (((reg_2870_offset << 14) & 0xFFFF0000) | reg_2870_offset >> 2) + (reg_2870_base << 17 | reg_2870_base);
306 master_width = (f->
src_w * 0x00080000) / f->
dst_w;
309 reg_2834 = (reg_2834 << 16) | x_cutoff;
310 reg_2838 = (reg_2838 << 16) | x_cutoff;
311 reg_283c = master_width >> 2;
312 reg_2844 = master_width >> 1;
313 reg_2854 = master_width;
314 reg_285c = master_width >> 1;
315 reg_2864 = master_width >> 1;
316 reg_2870 += ((reg_2870_offset << 15) & 0xFFFF0000) | reg_2870_offset;
318 reg_2874 = 0x00000012;
320 master_width = (f->
src_w * 0x00100000) / f->
dst_w;
323 reg_2834 = (reg_2834 << 16) | x_cutoff;
324 reg_2838 = (reg_2838 << 16) | x_cutoff;
325 reg_283c = master_width >> 2;
326 reg_2844 = master_width >> 1;
327 reg_2854 = master_width;
328 reg_285c = master_width >> 1;
329 reg_2864 = master_width >> 1;
330 reg_2870 += ((reg_2870_offset << 14) & 0xFFFF0000) | reg_2870_offset >> 1;
331 reg_2870 += (5 - (((f->
src_w * 3) - 1) / f->
dst_w)) << 16;
332 reg_2874 = 0x00000001;
341 h_filter = ((f->
src_w << 16) / f->
dst_w) >> 15;
342 h_filter = (h_filter >> 1) + (h_filter & 1);
349 IVTV_DEBUG_YUV(
"Update reg 0x2834 %08x->%08x 0x2838 %08x->%08x\n",
355 IVTV_DEBUG_YUV(
"Update reg 0x283c %08x->%08x 0x2844 %08x->%08x\n",
360 IVTV_DEBUG_YUV(
"Update reg 0x2840 %08x->%08x 0x2848 %08x->%08x\n",
369 IVTV_DEBUG_YUV(
"Update reg 0x285c %08x->%08x 0x2864 %08x->%08x\n",
386 ivtv_yuv_filter(itv, h_filter, -1, -1);
401 u32 src_major_y, src_minor_y;
402 u32 src_major_uv, src_minor_uv;
403 u32 reg_2964_base, reg_2968_base;
407 (
"Adjust to height %d src_h %d dst_h %d src_y %d dst_y %d\n",
419 f->
interlaced ?
"Interlaced" :
"Progressive");
424 src_minor_uv = f->
src_y;
428 src_major_uv = f->
src_y - 8;
431 src_minor_y = src_minor_uv;
432 src_major_y = src_major_uv;
438 reg_2918 = (f->
dst_h << 16) | (f->
src_h + src_minor_y);
440 reg_2918 = (f->
dst_h << 16) | ((f->
src_h + src_minor_y) << 1);
443 reg_291c = (f->
dst_h << 16) | ((f->
src_h + src_minor_uv) >> 1);
445 reg_291c = (f->
dst_h << 16) | (f->
src_h + src_minor_uv);
447 reg_2964_base = (src_minor_y * ((f->
dst_h << 16) / f->
src_h)) >> 14;
448 reg_2968_base = (src_minor_uv * ((f->
dst_h << 16) / f->
src_h)) >> 14;
451 master_height = (f->
src_h * 0x00400000) / f->
dst_h;
454 reg_2920 = master_height >> 2;
455 reg_2928 = master_height >> 3;
456 reg_2930 = master_height;
457 reg_2940 = master_height >> 1;
460 reg_296c = 0x00000000;
462 master_height = (f->
src_h * 0x00400000) / f->
dst_h;
463 master_height = (master_height >> 1) + (master_height & 1);
464 reg_2920 = master_height >> 2;
465 reg_2928 = master_height >> 2;
466 reg_2930 = master_height;
467 reg_2940 = master_height >> 1;
468 reg_296c = 0x00000000;
479 master_height = (f->
src_h * 0x00200000) / f->
dst_h;
480 master_height = (master_height >> 1) + (master_height & 1);
481 reg_2920 = master_height >> 2;
482 reg_2928 = master_height >> 2;
483 reg_2930 = master_height;
484 reg_2940 = master_height;
485 reg_296c = 0x00000101;
496 master_height = (f->
src_h * 0x00100000) / f->
dst_h;
497 master_height = (master_height >> 1) + (master_height & 1);
498 reg_2920 = master_height >> 2;
499 reg_2928 = master_height >> 2;
500 reg_2930 = master_height;
501 reg_2940 = master_height;
504 reg_296c = 0x00000102;
510 reg_2934 = 0x00020000;
511 reg_293c = 0x00100000;
512 reg_2944 = 0x00040000;
513 reg_294c = 0x000b0000;
515 reg_2934 = 0x00000FF0;
516 reg_293c = 0x00000FF0;
517 reg_2944 = 0x00000FF0;
518 reg_294c = 0x00000FF0;
522 reg_2950 = 0x00010000 + src_major_y;
524 reg_2950 += 0x00010000;
525 reg_2954 = reg_2950 + 1;
527 reg_2958 = 0x00010000 + (src_major_y >> 1);
529 reg_2958 += 0x00010000;
530 reg_295c = reg_2958 + 1;
533 reg_289c = 0x011e0017;
535 reg_289c = 0x01500017;
538 reg_289c = (reg_289c - ((f->
dst_y & ~1)<<15))-(f->
dst_y >>1);
540 reg_289c = (reg_289c + ((f->
dst_y & ~1)<<15))+(f->
dst_y >>1);
544 reg_2960 = ((src_minor_y + f->
src_h + src_major_y) - 1) |
545 (((src_minor_uv + f->
src_h + src_major_uv - 1) & ~1) << 15);
552 reg_2964 = (reg_2964 >> 1) + (reg_2964 & 1);
554 reg_2968 = (reg_2964 << 16) + reg_2964 + (reg_2964 >> 1);
555 reg_2964 = (reg_2964 << 16) + reg_2964 + (reg_2964 * 46 / 94);
560 reg_2964 = 0x00010001 + ((reg_2964 & 0x0000FFFF) - (reg_2964 >> 16));
561 reg_2968 = 0x00010001 + ((reg_2968 & 0x0000FFFF) - (reg_2968 >> 16));
566 if ((reg_2964 != 0x00010001) && (f->
dst_h / 2 <= f->
src_h))
567 reg_2964 = (reg_2964 & 0xFFFF0000) + ((reg_2964 & 0x0000FFFF) / 2);
570 reg_2964 -= 0x00010001;
572 reg_2968 -= 0x00010001;
574 reg_2964 += ((reg_2964_base << 16) | reg_2964_base);
575 reg_2968 += ((reg_2968_base << 16) | reg_2968_base);
584 v_filter_1 = ((f->
src_h << 16) / f->
dst_h) >> 15;
585 v_filter_1 = (v_filter_1 >> 1) + (v_filter_1 & 1);
593 IVTV_DEBUG_YUV(
"Update reg 0x2934 %08x->%08x 0x293c %08x->%08x\n",
597 IVTV_DEBUG_YUV(
"Update reg 0x2944 %08x->%08x 0x294c %08x->%08x\n",
606 IVTV_DEBUG_YUV(
"Update reg 0x2930 %08x->%08x 0x2938 %08x->%08x\n",
611 IVTV_DEBUG_YUV(
"Update reg 0x2928 %08x->%08x 0x292c %08x->%08x\n",
616 IVTV_DEBUG_YUV(
"Update reg 0x2920 %08x->%08x 0x2924 %08x->%08x\n",
621 IVTV_DEBUG_YUV(
"Update reg 0x2918 %08x->%08x 0x291C %08x->%08x\n",
630 IVTV_DEBUG_YUV(
"Update reg 0x2940 %08x->%08x 0x2948 %08x->%08x\n",
635 IVTV_DEBUG_YUV(
"Update reg 0x2950 %08x->%08x 0x2954 %08x->%08x\n",
640 IVTV_DEBUG_YUV(
"Update reg 0x2958 %08x->%08x 0x295C %08x->%08x\n",
649 IVTV_DEBUG_YUV(
"Update reg 0x2964 %08x->%08x 0x2968 %08x->%08x\n",
658 ivtv_yuv_filter(itv, -1, v_filter_1, -1);
664 ivtv_yuv_filter(itv, -1, -1, v_filter_2);
684 if ((osd_crop = f->
src_w - 4 * f->
dst_w) > 0) {
685 f->
src_x += osd_crop / 2;
697 if ((osd_crop = f->
src_h - 4 * f->
dst_h) > 0) {
699 f->
src_y += osd_crop / 2;
717 f->
src_y += (osd_scale * osd_crop) >> 16;
718 f->
src_h -= (osd_scale * osd_crop) >> 16;
719 f->
dst_h -= osd_crop;
727 f->
dst_h -= osd_crop;
728 f->
src_h -= (osd_scale * osd_crop) >> 16;
735 f->
src_x += (osd_scale * osd_crop) >> 16;
736 f->
src_w -= (osd_scale * osd_crop) >> 16;
737 f->
dst_w -= osd_crop;
745 f->
dst_w -= osd_crop;
746 f->
src_w -= (osd_scale * osd_crop) >> 16;
840 if (!(yuv_update = ivtv_yuv_window_setup(itv, &f)))
845 }
else if (yuv_update) {
849 ivtv_yuv_handle_horizontal(itv, &f);
852 ivtv_yuv_handle_vertical(itv, &f);
857 static void ivtv_yuv_init(
struct ivtv *itv)
931 IVTV_DEBUG_WARN(
"Clipping yuv output - fb size (%d) exceeds video standard limit (%d)\n",
955 static void ivtv_yuv_next_free(
struct ivtv *itv)
1013 if (lace_threshold < 0)
1034 if ((nf->
tru_h < 512) ||
1085 if ((rc = ivtv_yuv_prep_user_dma(itv, &itv->
udma, args)) != 0) {
1098 got_sig = signal_pending(
current);
1127 ivtv_yuv_next_free(itv);
1132 dma_args.
src.left = 0;
1133 dma_args.
src.top = 0;
1141 ivtv_yuv_setup_frame(itv, &dma_args);
1163 res = ivtv_yuv_udma_frame(itv, &dma_args);
1174 ivtv_yuv_next_free(itv);
1175 ivtv_yuv_setup_frame(itv, args);
1180 res = ivtv_yuv_udma_frame(itv, args);
1253 h_filter = (h_filter >> 1) + (h_filter & 1);
1266 v_filter_1 = (v_filter_1 >> 1) + (v_filter_1 & 1);
1273 ivtv_yuv_filter(itv, h_filter, v_filter_1, v_filter_2);