diff options
Diffstat (limited to 'drivers/media/video/cx88/cx88-blackbird.c')
-rw-r--r-- | drivers/media/video/cx88/cx88-blackbird.c | 677 |
1 files changed, 596 insertions, 81 deletions
diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c index 0c0c59e94774..4ae3f78cccf2 100644 --- a/drivers/media/video/cx88/cx88-blackbird.c +++ b/drivers/media/video/cx88/cx88-blackbird.c | |||
@@ -38,7 +38,7 @@ MODULE_AUTHOR("Jelle Foks <jelle@foks.8m.com>"); | |||
38 | MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); | 38 | MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); |
39 | MODULE_LICENSE("GPL"); | 39 | MODULE_LICENSE("GPL"); |
40 | 40 | ||
41 | static unsigned int mpegbufs = 8; | 41 | static unsigned int mpegbufs = 32; |
42 | module_param(mpegbufs,int,0644); | 42 | module_param(mpegbufs,int,0644); |
43 | MODULE_PARM_DESC(mpegbufs,"number of mpeg buffers, range 2-32"); | 43 | MODULE_PARM_DESC(mpegbufs,"number of mpeg buffers, range 2-32"); |
44 | 44 | ||
@@ -436,7 +436,7 @@ static int memory_write(struct cx88_core *core, u32 address, u32 value) | |||
436 | 436 | ||
437 | static int memory_read(struct cx88_core *core, u32 address, u32 *value) | 437 | static int memory_read(struct cx88_core *core, u32 address, u32 *value) |
438 | { | 438 | { |
439 | int retval; | 439 | int retval; |
440 | u32 val; | 440 | u32 val; |
441 | 441 | ||
442 | /* Warning: address is dword address (4 bytes) */ | 442 | /* Warning: address is dword address (4 bytes) */ |
@@ -605,11 +605,11 @@ static int blackbird_load_firmware(struct cx8802_dev *dev) | |||
605 | u32 *dataptr; | 605 | u32 *dataptr; |
606 | 606 | ||
607 | retval = register_write(dev->core, IVTV_REG_VPU, 0xFFFFFFED); | 607 | retval = register_write(dev->core, IVTV_REG_VPU, 0xFFFFFFED); |
608 | retval |= register_write(dev->core, IVTV_REG_HW_BLOCKS, IVTV_CMD_HW_BLOCKS_RST); | 608 | retval |= register_write(dev->core, IVTV_REG_HW_BLOCKS, IVTV_CMD_HW_BLOCKS_RST); |
609 | retval |= register_write(dev->core, IVTV_REG_ENC_SDRAM_REFRESH, 0x80000640); | 609 | retval |= register_write(dev->core, IVTV_REG_ENC_SDRAM_REFRESH, 0x80000640); |
610 | retval |= register_write(dev->core, IVTV_REG_ENC_SDRAM_PRECHARGE, 0x1A); | 610 | retval |= register_write(dev->core, IVTV_REG_ENC_SDRAM_PRECHARGE, 0x1A); |
611 | msleep(1); | 611 | msleep(1); |
612 | retval |= register_write(dev->core, IVTV_REG_APU, 0); | 612 | retval |= register_write(dev->core, IVTV_REG_APU, 0); |
613 | 613 | ||
614 | if (retval < 0) | 614 | if (retval < 0) |
615 | dprintk(0, "Error with register_write\n"); | 615 | dprintk(0, "Error with register_write\n"); |
@@ -657,13 +657,13 @@ static int blackbird_load_firmware(struct cx8802_dev *dev) | |||
657 | release_firmware(firmware); | 657 | release_firmware(firmware); |
658 | dprintk(0, "Firmware upload successful.\n"); | 658 | dprintk(0, "Firmware upload successful.\n"); |
659 | 659 | ||
660 | retval |= register_write(dev->core, IVTV_REG_HW_BLOCKS, IVTV_CMD_HW_BLOCKS_RST); | 660 | retval |= register_write(dev->core, IVTV_REG_HW_BLOCKS, IVTV_CMD_HW_BLOCKS_RST); |
661 | retval |= register_read(dev->core, IVTV_REG_SPU, &value); | 661 | retval |= register_read(dev->core, IVTV_REG_SPU, &value); |
662 | retval |= register_write(dev->core, IVTV_REG_SPU, value & 0xFFFFFFFE); | 662 | retval |= register_write(dev->core, IVTV_REG_SPU, value & 0xFFFFFFFE); |
663 | msleep(1); | 663 | msleep(1); |
664 | 664 | ||
665 | retval |= register_read(dev->core, IVTV_REG_VPU, &value); | 665 | retval |= register_read(dev->core, IVTV_REG_VPU, &value); |
666 | retval |= register_write(dev->core, IVTV_REG_VPU, value & 0xFFFFFFE8); | 666 | retval |= register_write(dev->core, IVTV_REG_VPU, value & 0xFFFFFFE8); |
667 | 667 | ||
668 | if (retval < 0) | 668 | if (retval < 0) |
669 | dprintk(0, "Error with register_write\n"); | 669 | dprintk(0, "Error with register_write\n"); |
@@ -683,84 +683,560 @@ DB* DVD | MPEG2 | 720x576PAL | CBR | 600 :Good | 6000 Kbps | 25fps | M | |||
683 | ================================================================================================================= | 683 | ================================================================================================================= |
684 | *DB: "DirectBurn" | 684 | *DB: "DirectBurn" |
685 | */ | 685 | */ |
686 | static void blackbird_codec_settings(struct cx8802_dev *dev) | 686 | |
687 | static struct blackbird_dnr default_dnr_params = { | ||
688 | .mode = BLACKBIRD_DNR_BITS_MANUAL, | ||
689 | .type = BLACKBIRD_MEDIAN_FILTER_DISABLED, | ||
690 | .spatial = 0, | ||
691 | .temporal = 0 | ||
692 | }; | ||
693 | static struct v4l2_mpeg_compression default_mpeg_params = { | ||
694 | .st_type = V4L2_MPEG_PS_2, | ||
695 | .st_bitrate = { | ||
696 | .mode = V4L2_BITRATE_CBR, | ||
697 | .min = 0, | ||
698 | .target = 0, | ||
699 | .max = 0 | ||
700 | }, | ||
701 | .ts_pid_pmt = 16, | ||
702 | .ts_pid_audio = 260, | ||
703 | .ts_pid_video = 256, | ||
704 | .ts_pid_pcr = 259, | ||
705 | .ps_size = 0, | ||
706 | .au_type = V4L2_MPEG_AU_2_II, | ||
707 | .au_bitrate = { | ||
708 | .mode = V4L2_BITRATE_CBR, | ||
709 | .min = 224, | ||
710 | .target = 224, | ||
711 | .max = 224 | ||
712 | }, | ||
713 | .au_sample_rate = 44100, | ||
714 | .au_pesid = 0, | ||
715 | .vi_type = V4L2_MPEG_VI_2, | ||
716 | .vi_aspect_ratio = V4L2_MPEG_ASPECT_4_3, | ||
717 | .vi_bitrate = { | ||
718 | .mode = V4L2_BITRATE_CBR, | ||
719 | .min = 4000, | ||
720 | .target = 4500, | ||
721 | .max = 6000 | ||
722 | }, | ||
723 | .vi_frame_rate = 25, | ||
724 | .vi_frames_per_gop = 15, | ||
725 | .vi_bframes_count = 2, | ||
726 | .vi_pesid = 0, | ||
727 | .closed_gops = 0, | ||
728 | .pulldown = 0 | ||
729 | }; | ||
730 | |||
731 | static enum blackbird_stream_type mpeg_stream_types[] = { | ||
732 | [V4L2_MPEG_SS_1] = BLACKBIRD_STREAM_MPEG1, | ||
733 | [V4L2_MPEG_PS_2] = BLACKBIRD_STREAM_PROGRAM, | ||
734 | [V4L2_MPEG_TS_2] = BLACKBIRD_STREAM_TRANSPORT, | ||
735 | [V4L2_MPEG_PS_DVD] = BLACKBIRD_STREAM_DVD, | ||
736 | }; | ||
737 | static enum blackbird_aspect_ratio mpeg_stream_ratios[] = { | ||
738 | [V4L2_MPEG_ASPECT_SQUARE] = BLACKBIRD_ASPECT_RATIO_1_1_SQUARE, | ||
739 | [V4L2_MPEG_ASPECT_4_3] = BLACKBIRD_ASPECT_RATIO_4_3, | ||
740 | [V4L2_MPEG_ASPECT_16_9] = BLACKBIRD_ASPECT_RATIO_16_9, | ||
741 | [V4L2_MPEG_ASPECT_1_221] = BLACKBIRD_ASPECT_RATIO_221_100, | ||
742 | }; | ||
743 | static enum blackbird_video_bitrate_type mpeg_video_bitrates[] = { | ||
744 | [V4L2_BITRATE_NONE] = BLACKBIRD_VIDEO_CBR, | ||
745 | [V4L2_BITRATE_CBR] = BLACKBIRD_VIDEO_CBR, | ||
746 | [V4L2_BITRATE_VBR] = BLACKBIRD_VIDEO_VBR, | ||
747 | }; | ||
748 | /* find the best layer I/II bitrate to fit a given numeric value */ | ||
749 | struct bitrate_bits { | ||
750 | u32 bits; /* layer bits for the best fit */ | ||
751 | u32 rate; /* actual numeric value for the layer best fit */ | ||
752 | }; | ||
753 | struct bitrate_approximation { | ||
754 | u32 target; /* numeric value of the rate we want */ | ||
755 | struct bitrate_bits layer[2]; | ||
756 | }; | ||
757 | static struct bitrate_approximation mpeg_audio_bitrates[] = { | ||
758 | /* target layer[0].bits layer[0].rate layer[1].bits layer[1].rate */ | ||
759 | { 0, { { 0, 0, }, { 0, 0, }, }, }, | ||
760 | { 32, { { BLACKBIRD_AUDIO_BITS_LAYER_1_32 , 32, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_32 , 32, }, }, }, | ||
761 | { 48, { { BLACKBIRD_AUDIO_BITS_LAYER_1_64 , 64, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_48 , 48, }, }, }, | ||
762 | { 56, { { BLACKBIRD_AUDIO_BITS_LAYER_1_64 , 64, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_56 , 56, }, }, }, | ||
763 | { 64, { { BLACKBIRD_AUDIO_BITS_LAYER_1_64 , 64, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_64 , 64, }, }, }, | ||
764 | { 80, { { BLACKBIRD_AUDIO_BITS_LAYER_1_96 , 96, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_80 , 80, }, }, }, | ||
765 | { 96, { { BLACKBIRD_AUDIO_BITS_LAYER_1_96 , 96, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_96 , 96, }, }, }, | ||
766 | { 112, { { BLACKBIRD_AUDIO_BITS_LAYER_1_128, 128, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_112, 112, }, }, }, | ||
767 | { 128, { { BLACKBIRD_AUDIO_BITS_LAYER_1_128, 128, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_128, 128, }, }, }, | ||
768 | { 160, { { BLACKBIRD_AUDIO_BITS_LAYER_1_160, 160, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_160, 160, }, }, }, | ||
769 | { 192, { { BLACKBIRD_AUDIO_BITS_LAYER_1_192, 192, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_192, 192, }, }, }, | ||
770 | { 224, { { BLACKBIRD_AUDIO_BITS_LAYER_1_224, 224, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_224, 224, }, }, }, | ||
771 | { 256, { { BLACKBIRD_AUDIO_BITS_LAYER_1_256, 256, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_256, 256, }, }, }, | ||
772 | { 288, { { BLACKBIRD_AUDIO_BITS_LAYER_1_288, 288, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_320, 320, }, }, }, | ||
773 | { 320, { { BLACKBIRD_AUDIO_BITS_LAYER_1_320, 320, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_320, 320, }, }, }, | ||
774 | { 352, { { BLACKBIRD_AUDIO_BITS_LAYER_1_352, 352, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_384, 384, }, }, }, | ||
775 | { 384, { { BLACKBIRD_AUDIO_BITS_LAYER_1_384, 384, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_384, 384, }, }, }, | ||
776 | { 416, { { BLACKBIRD_AUDIO_BITS_LAYER_1_416, 416, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_384, 384, }, }, }, | ||
777 | { 448, { { BLACKBIRD_AUDIO_BITS_LAYER_1_448, 448, }, { BLACKBIRD_AUDIO_BITS_LAYER_2_384, 384, }, }, }, | ||
778 | }; | ||
779 | static const int BITRATES_SIZE = ARRAY_SIZE(mpeg_audio_bitrates); | ||
780 | |||
781 | static void blackbird_set_default_params(struct cx8802_dev *dev) | ||
687 | { | 782 | { |
688 | int bitrate_mode = 1; | 783 | struct v4l2_mpeg_compression *params = &dev->params; |
689 | int bitrate = 7500000; | 784 | u32 au_params; |
690 | int bitrate_peak = 7500000; | ||
691 | bitrate_mode = BLACKBIRD_VIDEO_CBR; | ||
692 | bitrate = 4000*1024; | ||
693 | bitrate_peak = 4000*1024; | ||
694 | 785 | ||
695 | /* assign stream type */ | 786 | /* assign stream type */ |
696 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_STREAM_TYPE, 1, 0, BLACKBIRD_STREAM_PROGRAM); | 787 | if( params->st_type >= ARRAY_SIZE(mpeg_stream_types) ) |
697 | 788 | params->st_type = V4L2_MPEG_PS_2; | |
698 | /* assign output port */ | 789 | if( params->st_type == V4L2_MPEG_SS_1 ) |
699 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_OUTPUT_PORT, 1, 0, BLACKBIRD_OUTPUT_PORT_STREAMING); /* Host */ | 790 | params->vi_type = V4L2_MPEG_VI_1; |
791 | else | ||
792 | params->vi_type = V4L2_MPEG_VI_2; | ||
793 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_STREAM_TYPE, 1, 0, mpeg_stream_types[params->st_type]); | ||
700 | 794 | ||
701 | /* assign framerate */ | 795 | /* assign framerate */ |
702 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_FRAMERATE, 1, 0, BLACKBIRD_FRAMERATE_PAL_25); | 796 | if( params->vi_frame_rate <= 25 ) |
703 | 797 | { | |
704 | /* assign frame size */ | 798 | params->vi_frame_rate = 25; |
705 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_RESOLUTION, 2, 0, | 799 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_FRAMERATE, 1, 0, BLACKBIRD_FRAMERATE_PAL_25); |
706 | dev->height, dev->width); | 800 | } |
801 | else | ||
802 | { | ||
803 | params->vi_frame_rate = 30; | ||
804 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_FRAMERATE, 1, 0, BLACKBIRD_FRAMERATE_NTSC_30); | ||
805 | } | ||
707 | 806 | ||
708 | /* assign aspect ratio */ | 807 | /* assign aspect ratio */ |
709 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_ASPECT_RATIO, 1, 0, BLACKBIRD_ASPECT_RATIO_4_3); | 808 | if( params->vi_aspect_ratio >= ARRAY_SIZE(mpeg_stream_ratios) ) |
710 | 809 | params->vi_aspect_ratio = V4L2_MPEG_ASPECT_4_3; | |
711 | /* assign bitrates */ | 810 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_ASPECT_RATIO, 1, 0, mpeg_stream_ratios[params->vi_aspect_ratio]); |
712 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_VIDEO_BITRATE, 5, 0, | ||
713 | bitrate_mode, /* mode */ | ||
714 | bitrate, /* bps */ | ||
715 | bitrate_peak / BLACKBIRD_PEAK_RATE_DIVISOR, /* peak/400 */ | ||
716 | BLACKBIRD_MUX_RATE_DEFAULT /*, 0x70*/); /* encoding buffer, ckennedy */ | ||
717 | 811 | ||
718 | /* assign gop properties */ | 812 | /* assign gop properties */ |
719 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_GOP_STRUCTURE, 2, 0, 15, 3); | 813 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_GOP_STRUCTURE, 2, 0, params->vi_frames_per_gop, params->vi_bframes_count+1); |
814 | |||
815 | /* assign gop closure */ | ||
816 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_GOP_CLOSURE, 1, 0, params->closed_gops); | ||
720 | 817 | ||
721 | /* assign 3 2 pulldown */ | 818 | /* assign 3 2 pulldown */ |
722 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_3_2_PULLDOWN, 1, 0, BLACKBIRD_3_2_PULLDOWN_DISABLED); | 819 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_3_2_PULLDOWN, 1, 0, params->pulldown); |
820 | |||
821 | /* make sure the params are within bounds */ | ||
822 | if( params->st_bitrate.mode >= ARRAY_SIZE(mpeg_video_bitrates) ) | ||
823 | params->vi_bitrate.mode = V4L2_BITRATE_NONE; | ||
824 | if( params->vi_bitrate.mode >= ARRAY_SIZE(mpeg_video_bitrates) ) | ||
825 | params->vi_bitrate.mode = V4L2_BITRATE_NONE; | ||
826 | if( params->au_bitrate.mode >= ARRAY_SIZE(mpeg_video_bitrates) ) | ||
827 | params->au_bitrate.mode = V4L2_BITRATE_NONE; | ||
723 | 828 | ||
724 | /* assign audio properties */ | 829 | /* assign audio properties */ |
725 | /* note: it's not necessary to set the samplerate, the mpeg encoder seems to autodetect/adjust */ | 830 | /* note: it's not necessary to set the samplerate, the mpeg encoder seems to autodetect/adjust */ |
726 | /* blackbird_api_cmd(dev, IVTV_API_ASSIGN_AUDIO_PROPERTIES, 1, 0, (2<<2) | (8<<4)); | 831 | au_params = BLACKBIRD_AUDIO_BITS_STEREO | |
727 | blackbird_api_cmd(dev, IVTV_API_ASSIGN_AUDIO_PROPERTIES, 1, 0, 0 | (2 << 2) | (14 << 4)); */ | ||
728 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_AUDIO_PARAMS, 1, 0, | ||
729 | BLACKBIRD_AUDIO_BITS_44100HZ | | ||
730 | BLACKBIRD_AUDIO_BITS_LAYER_2 | | ||
731 | BLACKBIRD_AUDIO_BITS_LAYER_2_224 | | ||
732 | BLACKBIRD_AUDIO_BITS_STEREO | | ||
733 | /* BLACKBIRD_AUDIO_BITS_BOUND_4 | */ | 832 | /* BLACKBIRD_AUDIO_BITS_BOUND_4 | */ |
734 | BLACKBIRD_AUDIO_BITS_EMPHASIS_NONE | | 833 | BLACKBIRD_AUDIO_BITS_EMPHASIS_NONE | |
735 | BLACKBIRD_AUDIO_BITS_CRC_OFF | | 834 | BLACKBIRD_AUDIO_BITS_CRC_OFF | |
736 | BLACKBIRD_AUDIO_BITS_COPYRIGHT_OFF | | 835 | BLACKBIRD_AUDIO_BITS_COPYRIGHT_OFF | |
737 | BLACKBIRD_AUDIO_BITS_COPY | 836 | BLACKBIRD_AUDIO_BITS_COPY | |
738 | ); | 837 | 0; |
838 | if( params->au_sample_rate <= 32000 ) | ||
839 | { | ||
840 | params->au_sample_rate = 32000; | ||
841 | au_params |= BLACKBIRD_AUDIO_BITS_32000HZ; | ||
842 | } | ||
843 | else if( params->au_sample_rate <= 44100 ) | ||
844 | { | ||
845 | params->au_sample_rate = 44100; | ||
846 | au_params |= BLACKBIRD_AUDIO_BITS_44100HZ; | ||
847 | } | ||
848 | else | ||
849 | { | ||
850 | params->au_sample_rate = 48000; | ||
851 | au_params |= BLACKBIRD_AUDIO_BITS_48000HZ; | ||
852 | } | ||
853 | if( params->au_type == V4L2_MPEG_AU_2_I ) | ||
854 | { | ||
855 | au_params |= BLACKBIRD_AUDIO_BITS_LAYER_1; | ||
856 | } | ||
857 | else | ||
858 | { | ||
859 | /* TODO: try to handle the other formats more gracefully */ | ||
860 | params->au_type = V4L2_MPEG_AU_2_II; | ||
861 | au_params |= BLACKBIRD_AUDIO_BITS_LAYER_2; | ||
862 | } | ||
863 | if( params->au_bitrate.mode ) | ||
864 | { | ||
865 | int layer; | ||
866 | |||
867 | if( params->au_bitrate.mode == V4L2_BITRATE_CBR ) | ||
868 | params->au_bitrate.max = params->vi_bitrate.target; | ||
869 | else | ||
870 | params->au_bitrate.target = params->vi_bitrate.max; | ||
871 | |||
872 | layer = params->au_type; | ||
873 | if( params->au_bitrate.target == 0 ) | ||
874 | { | ||
875 | /* TODO: use the minimum possible bitrate instead of 0 ? */ | ||
876 | au_params |= 0; | ||
877 | } | ||
878 | else if( params->au_bitrate.target >= | ||
879 | mpeg_audio_bitrates[BITRATES_SIZE-1].layer[layer].rate ) | ||
880 | { | ||
881 | /* clamp the bitrate to the max supported by the standard */ | ||
882 | params->au_bitrate.target = mpeg_audio_bitrates[BITRATES_SIZE-1].layer[layer].rate; | ||
883 | params->au_bitrate.max = params->au_bitrate.target; | ||
884 | au_params |= mpeg_audio_bitrates[BITRATES_SIZE-1].layer[layer].bits; | ||
885 | } | ||
886 | else | ||
887 | { | ||
888 | /* round up to the nearest supported bitrate */ | ||
889 | int i; | ||
890 | for(i = 1; i < BITRATES_SIZE; i++) | ||
891 | { | ||
892 | if( params->au_bitrate.target > mpeg_audio_bitrates[i-1].layer[layer].rate && | ||
893 | params->au_bitrate.target <= mpeg_audio_bitrates[i].layer[layer].rate ) | ||
894 | { | ||
895 | params->au_bitrate.target = mpeg_audio_bitrates[i].layer[layer].rate; | ||
896 | params->au_bitrate.max = params->au_bitrate.target; | ||
897 | au_params |= mpeg_audio_bitrates[i].layer[layer].bits; | ||
898 | break; | ||
899 | } | ||
900 | } | ||
901 | } | ||
902 | } | ||
903 | else | ||
904 | { | ||
905 | /* TODO: ??? */ | ||
906 | params->au_bitrate.target = params->au_bitrate.max = 0; | ||
907 | au_params |= 0; | ||
908 | } | ||
909 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_AUDIO_PARAMS, 1, 0, au_params ); | ||
910 | |||
911 | /* assign bitrates */ | ||
912 | if( params->vi_bitrate.mode ) | ||
913 | { | ||
914 | /* bitrate is set, let's figure out the cbr/vbr mess */ | ||
915 | if( params->vi_bitrate.max < params->vi_bitrate.target ) | ||
916 | { | ||
917 | if( params->vi_bitrate.mode == V4L2_BITRATE_CBR ) | ||
918 | params->vi_bitrate.max = params->vi_bitrate.target; | ||
919 | else | ||
920 | params->vi_bitrate.target = params->vi_bitrate.max; | ||
921 | } | ||
922 | } | ||
923 | else | ||
924 | { | ||
925 | if( params->st_bitrate.max < params->st_bitrate.target ) | ||
926 | { | ||
927 | if( params->st_bitrate.mode == V4L2_BITRATE_VBR ) | ||
928 | params->st_bitrate.target = params->st_bitrate.max; | ||
929 | else | ||
930 | params->st_bitrate.max = params->st_bitrate.target; | ||
931 | } | ||
932 | /* calculate vi_bitrate = st_bitrate - au_bitrate */ | ||
933 | params->vi_bitrate.max = params->st_bitrate.max - params->au_bitrate.max; | ||
934 | params->vi_bitrate.target = params->st_bitrate.target - params->au_bitrate.target; | ||
935 | } | ||
936 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_VIDEO_BITRATE, 4, 0, | ||
937 | mpeg_video_bitrates[params->vi_bitrate.mode], | ||
938 | params->vi_bitrate.target * 1000, /* kbps -> bps */ | ||
939 | params->vi_bitrate.max * 1000 / BLACKBIRD_PEAK_RATE_DIVISOR, /* peak/400 */ | ||
940 | BLACKBIRD_MUX_RATE_DEFAULT /*, 0x70*/); /* encoding buffer, ckennedy */ | ||
941 | |||
942 | /* TODO: implement the stream ID stuff: | ||
943 | ts_pid_pmt, ts_pid_audio, ts_pid_video, ts_pid_pcr, | ||
944 | ps_size, au_pesid, vi_pesid | ||
945 | */ | ||
946 | } | ||
947 | #define CHECK_PARAM( name ) ( dev->params.name != params->name ) | ||
948 | #define IF_PARAM( name ) if( CHECK_PARAM( name ) ) | ||
949 | #define UPDATE_PARAM( name ) dev->params.name = params->name | ||
950 | void blackbird_set_params(struct cx8802_dev *dev, struct v4l2_mpeg_compression *params) | ||
951 | { | ||
952 | u32 au_params; | ||
953 | |||
954 | /* assign stream type */ | ||
955 | if( params->st_type >= ARRAY_SIZE(mpeg_stream_types) ) | ||
956 | params->st_type = V4L2_MPEG_PS_2; | ||
957 | if( params->st_type == V4L2_MPEG_SS_1 ) | ||
958 | params->vi_type = V4L2_MPEG_VI_1; | ||
959 | else | ||
960 | params->vi_type = V4L2_MPEG_VI_2; | ||
961 | if( CHECK_PARAM( st_type ) || CHECK_PARAM( vi_type ) ) | ||
962 | { | ||
963 | UPDATE_PARAM( st_type ); | ||
964 | UPDATE_PARAM( vi_type ); | ||
965 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_STREAM_TYPE, 1, 0, mpeg_stream_types[params->st_type]); | ||
966 | } | ||
967 | |||
968 | /* assign framerate */ | ||
969 | if( params->vi_frame_rate <= 25 ) | ||
970 | params->vi_frame_rate = 25; | ||
971 | else | ||
972 | params->vi_frame_rate = 30; | ||
973 | IF_PARAM( vi_frame_rate ) | ||
974 | { | ||
975 | UPDATE_PARAM( vi_frame_rate ); | ||
976 | if( params->vi_frame_rate == 25 ) | ||
977 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_FRAMERATE, 1, 0, BLACKBIRD_FRAMERATE_PAL_25); | ||
978 | else | ||
979 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_FRAMERATE, 1, 0, BLACKBIRD_FRAMERATE_NTSC_30); | ||
980 | } | ||
981 | |||
982 | /* assign aspect ratio */ | ||
983 | if( params->vi_aspect_ratio >= ARRAY_SIZE(mpeg_stream_ratios) ) | ||
984 | params->vi_aspect_ratio = V4L2_MPEG_ASPECT_4_3; | ||
985 | IF_PARAM( vi_aspect_ratio ) | ||
986 | { | ||
987 | UPDATE_PARAM( vi_aspect_ratio ); | ||
988 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_ASPECT_RATIO, 1, 0, mpeg_stream_ratios[params->vi_aspect_ratio]); | ||
989 | } | ||
990 | |||
991 | /* assign gop properties */ | ||
992 | if( CHECK_PARAM( vi_frames_per_gop ) || CHECK_PARAM( vi_bframes_count ) ) | ||
993 | { | ||
994 | UPDATE_PARAM( vi_frames_per_gop ); | ||
995 | UPDATE_PARAM( vi_bframes_count ); | ||
996 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_GOP_STRUCTURE, 2, 0, params->vi_frames_per_gop, params->vi_bframes_count+1); | ||
997 | } | ||
739 | 998 | ||
740 | /* assign gop closure */ | 999 | /* assign gop closure */ |
741 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_GOP_CLOSURE, 1, 0, BLACKBIRD_GOP_CLOSURE_OFF); | 1000 | IF_PARAM( closed_gops ) |
1001 | { | ||
1002 | UPDATE_PARAM( closed_gops ); | ||
1003 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_GOP_CLOSURE, 1, 0, params->closed_gops); | ||
1004 | } | ||
1005 | |||
1006 | /* assign 3 2 pulldown */ | ||
1007 | IF_PARAM( pulldown ) | ||
1008 | { | ||
1009 | UPDATE_PARAM( pulldown ); | ||
1010 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_3_2_PULLDOWN, 1, 0, params->pulldown); | ||
1011 | } | ||
1012 | |||
1013 | /* make sure the params are within bounds */ | ||
1014 | if( params->st_bitrate.mode >= ARRAY_SIZE(mpeg_video_bitrates) ) | ||
1015 | params->vi_bitrate.mode = V4L2_BITRATE_NONE; | ||
1016 | if( params->vi_bitrate.mode >= ARRAY_SIZE(mpeg_video_bitrates) ) | ||
1017 | params->vi_bitrate.mode = V4L2_BITRATE_NONE; | ||
1018 | if( params->au_bitrate.mode >= ARRAY_SIZE(mpeg_video_bitrates) ) | ||
1019 | params->au_bitrate.mode = V4L2_BITRATE_NONE; | ||
1020 | |||
1021 | /* assign audio properties */ | ||
1022 | /* note: it's not necessary to set the samplerate, the mpeg encoder seems to autodetect/adjust */ | ||
1023 | au_params = BLACKBIRD_AUDIO_BITS_STEREO | | ||
1024 | /* BLACKBIRD_AUDIO_BITS_BOUND_4 | */ | ||
1025 | BLACKBIRD_AUDIO_BITS_EMPHASIS_NONE | | ||
1026 | BLACKBIRD_AUDIO_BITS_CRC_OFF | | ||
1027 | BLACKBIRD_AUDIO_BITS_COPYRIGHT_OFF | | ||
1028 | BLACKBIRD_AUDIO_BITS_COPY | | ||
1029 | 0; | ||
1030 | if( params->au_sample_rate < 32000 ) | ||
1031 | { | ||
1032 | params->au_sample_rate = 32000; | ||
1033 | au_params |= BLACKBIRD_AUDIO_BITS_32000HZ; | ||
1034 | } | ||
1035 | else if( params->au_sample_rate < 44100 ) | ||
1036 | { | ||
1037 | params->au_sample_rate = 44100; | ||
1038 | au_params |= BLACKBIRD_AUDIO_BITS_44100HZ; | ||
1039 | } | ||
1040 | else | ||
1041 | { | ||
1042 | params->au_sample_rate = 48000; | ||
1043 | au_params |= BLACKBIRD_AUDIO_BITS_48000HZ; | ||
1044 | } | ||
1045 | if( params->au_type == V4L2_MPEG_AU_2_I ) | ||
1046 | { | ||
1047 | au_params |= BLACKBIRD_AUDIO_BITS_LAYER_1; | ||
1048 | } | ||
1049 | else | ||
1050 | { | ||
1051 | /* TODO: try to handle the other formats more gracefully */ | ||
1052 | params->au_type = V4L2_MPEG_AU_2_II; | ||
1053 | au_params |= BLACKBIRD_AUDIO_BITS_LAYER_2; | ||
1054 | } | ||
1055 | if( params->au_bitrate.mode ) | ||
1056 | { | ||
1057 | int layer; | ||
1058 | |||
1059 | if( params->au_bitrate.mode == V4L2_BITRATE_CBR ) | ||
1060 | params->au_bitrate.max = params->vi_bitrate.target; | ||
1061 | else | ||
1062 | params->au_bitrate.target = params->vi_bitrate.max; | ||
1063 | |||
1064 | layer = params->au_type; | ||
1065 | if( params->au_bitrate.target == 0 ) | ||
1066 | { | ||
1067 | /* TODO: use the minimum possible bitrate instead of 0 ? */ | ||
1068 | au_params |= 0; | ||
1069 | } | ||
1070 | else if( params->au_bitrate.target >= | ||
1071 | mpeg_audio_bitrates[BITRATES_SIZE-1].layer[layer].rate ) | ||
1072 | { | ||
1073 | /* clamp the bitrate to the max supported by the standard */ | ||
1074 | params->au_bitrate.target = mpeg_audio_bitrates[BITRATES_SIZE-1].layer[layer].rate; | ||
1075 | params->au_bitrate.max = params->au_bitrate.target; | ||
1076 | au_params |= mpeg_audio_bitrates[BITRATES_SIZE-1].layer[layer].bits; | ||
1077 | } | ||
1078 | else | ||
1079 | { | ||
1080 | /* round up to the nearest supported bitrate */ | ||
1081 | int i; | ||
1082 | for(i = 1; i < BITRATES_SIZE; i++) | ||
1083 | { | ||
1084 | if( params->au_bitrate.target > mpeg_audio_bitrates[i-1].layer[layer].rate && | ||
1085 | params->au_bitrate.target <= mpeg_audio_bitrates[i].layer[layer].rate ) | ||
1086 | { | ||
1087 | params->au_bitrate.target = mpeg_audio_bitrates[i].layer[layer].rate; | ||
1088 | params->au_bitrate.max = params->au_bitrate.target; | ||
1089 | au_params |= mpeg_audio_bitrates[i].layer[layer].bits; | ||
1090 | break; | ||
1091 | } | ||
1092 | } | ||
1093 | } | ||
1094 | } | ||
1095 | else | ||
1096 | { | ||
1097 | /* TODO: ??? */ | ||
1098 | params->au_bitrate.target = params->au_bitrate.max = 0; | ||
1099 | au_params |= 0; | ||
1100 | } | ||
1101 | if( CHECK_PARAM( au_type ) || CHECK_PARAM( au_sample_rate ) | ||
1102 | || CHECK_PARAM( au_bitrate.mode ) || CHECK_PARAM( au_bitrate.max ) | ||
1103 | || CHECK_PARAM( au_bitrate.target ) | ||
1104 | ) | ||
1105 | { | ||
1106 | UPDATE_PARAM( au_type ); | ||
1107 | UPDATE_PARAM( au_sample_rate ); | ||
1108 | UPDATE_PARAM( au_bitrate ); | ||
1109 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_AUDIO_PARAMS, 1, 0, au_params ); | ||
1110 | } | ||
1111 | |||
1112 | /* assign bitrates */ | ||
1113 | if( params->vi_bitrate.mode ) | ||
1114 | { | ||
1115 | /* bitrate is set, let's figure out the cbr/vbr mess */ | ||
1116 | if( params->vi_bitrate.max < params->vi_bitrate.target ) | ||
1117 | { | ||
1118 | if( params->vi_bitrate.mode == V4L2_BITRATE_CBR ) | ||
1119 | params->vi_bitrate.max = params->vi_bitrate.target; | ||
1120 | else | ||
1121 | params->vi_bitrate.target = params->vi_bitrate.max; | ||
1122 | } | ||
1123 | } | ||
1124 | else | ||
1125 | { | ||
1126 | if( params->st_bitrate.max < params->st_bitrate.target ) | ||
1127 | { | ||
1128 | if( params->st_bitrate.mode == V4L2_BITRATE_VBR ) | ||
1129 | params->st_bitrate.target = params->st_bitrate.max; | ||
1130 | else | ||
1131 | params->st_bitrate.max = params->st_bitrate.target; | ||
1132 | } | ||
1133 | /* calculate vi_bitrate = st_bitrate - au_bitrate */ | ||
1134 | params->vi_bitrate.max = params->st_bitrate.max - params->au_bitrate.max; | ||
1135 | params->vi_bitrate.target = params->st_bitrate.target - params->au_bitrate.target; | ||
1136 | } | ||
1137 | UPDATE_PARAM( st_bitrate ); | ||
1138 | if( CHECK_PARAM( vi_bitrate.mode ) || CHECK_PARAM( vi_bitrate.max ) | ||
1139 | || CHECK_PARAM( vi_bitrate.target ) | ||
1140 | ) | ||
1141 | { | ||
1142 | UPDATE_PARAM( vi_bitrate ); | ||
1143 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_VIDEO_BITRATE, 4, 0, | ||
1144 | mpeg_video_bitrates[params->vi_bitrate.mode], | ||
1145 | params->vi_bitrate.target * 1000, /* kbps -> bps */ | ||
1146 | params->vi_bitrate.max * 1000 / BLACKBIRD_PEAK_RATE_DIVISOR, /* peak/400 */ | ||
1147 | BLACKBIRD_MUX_RATE_DEFAULT /*, 0x70*/); /* encoding buffer, ckennedy */ | ||
1148 | } | ||
742 | 1149 | ||
1150 | /* TODO: implement the stream ID stuff: | ||
1151 | ts_pid_pmt, ts_pid_audio, ts_pid_video, ts_pid_pcr, | ||
1152 | ps_size, au_pesid, vi_pesid | ||
1153 | */ | ||
1154 | UPDATE_PARAM( ts_pid_pmt ); | ||
1155 | UPDATE_PARAM( ts_pid_audio ); | ||
1156 | UPDATE_PARAM( ts_pid_video ); | ||
1157 | UPDATE_PARAM( ts_pid_pcr ); | ||
1158 | UPDATE_PARAM( ps_size ); | ||
1159 | UPDATE_PARAM( au_pesid ); | ||
1160 | UPDATE_PARAM( vi_pesid ); | ||
1161 | } | ||
743 | 1162 | ||
1163 | static void blackbird_set_default_dnr_params(struct cx8802_dev *dev) | ||
1164 | { | ||
744 | /* assign dnr filter mode */ | 1165 | /* assign dnr filter mode */ |
1166 | if( dev->dnr_params.mode > BLACKBIRD_DNR_BITS_AUTO ) | ||
1167 | dev->dnr_params.mode = BLACKBIRD_DNR_BITS_MANUAL; | ||
1168 | if( dev->dnr_params.type > BLACKBIRD_MEDIAN_FILTER_DIAGONAL ) | ||
1169 | dev->dnr_params.type = BLACKBIRD_MEDIAN_FILTER_DISABLED; | ||
745 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_DNR_MODE, 2, 0, | 1170 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_DNR_MODE, 2, 0, |
746 | BLACKBIRD_DNR_BITS_MANUAL, | 1171 | dev->dnr_params.mode, |
747 | BLACKBIRD_MEDIAN_FILTER_DISABLED | 1172 | dev->dnr_params.type |
748 | ); | 1173 | ); |
749 | 1174 | ||
750 | /* assign dnr filter props*/ | 1175 | /* assign dnr filter props*/ |
751 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_MANUAL_DNR, 2, 0, 0, 0); | 1176 | if( dev->dnr_params.spatial > 15 ) |
1177 | dev->dnr_params.spatial = 15; | ||
1178 | if( dev->dnr_params.temporal > 31 ) | ||
1179 | dev->dnr_params.temporal = 31; | ||
1180 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_MANUAL_DNR, 2, 0, | ||
1181 | dev->dnr_params.spatial, | ||
1182 | dev->dnr_params.temporal | ||
1183 | ); | ||
1184 | } | ||
1185 | #define CHECK_DNR_PARAM( name ) ( dev->dnr_params.name != dnr_params->name ) | ||
1186 | #define UPDATE_DNR_PARAM( name ) dev->dnr_params.name = dnr_params->name | ||
1187 | void blackbird_set_dnr_params(struct cx8802_dev *dev, struct blackbird_dnr* dnr_params) | ||
1188 | { | ||
1189 | /* assign dnr filter mode */ | ||
1190 | /* clamp values */ | ||
1191 | if( dnr_params->mode > BLACKBIRD_DNR_BITS_AUTO ) | ||
1192 | dnr_params->mode = BLACKBIRD_DNR_BITS_MANUAL; | ||
1193 | if( dnr_params->type > BLACKBIRD_MEDIAN_FILTER_DIAGONAL ) | ||
1194 | dnr_params->type = BLACKBIRD_MEDIAN_FILTER_DISABLED; | ||
1195 | /* check if the params actually changed */ | ||
1196 | if( CHECK_DNR_PARAM( mode ) || CHECK_DNR_PARAM( type ) ) | ||
1197 | { | ||
1198 | UPDATE_DNR_PARAM( mode ); | ||
1199 | UPDATE_DNR_PARAM( type ); | ||
1200 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_DNR_MODE, 2, 0, dnr_params->mode, dnr_params->type); | ||
1201 | } | ||
1202 | |||
1203 | /* assign dnr filter props*/ | ||
1204 | if( dnr_params->spatial > 15 ) | ||
1205 | dnr_params->spatial = 15; | ||
1206 | if( dnr_params->temporal > 31 ) | ||
1207 | dnr_params->temporal = 31; | ||
1208 | if( CHECK_DNR_PARAM( spatial ) || CHECK_DNR_PARAM( temporal ) ) | ||
1209 | { | ||
1210 | UPDATE_DNR_PARAM( spatial ); | ||
1211 | UPDATE_DNR_PARAM( temporal ); | ||
1212 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_MANUAL_DNR, 2, 0, dnr_params->spatial, dnr_params->temporal); | ||
1213 | } | ||
1214 | } | ||
1215 | |||
1216 | static void blackbird_codec_settings(struct cx8802_dev *dev) | ||
1217 | { | ||
1218 | |||
1219 | /* assign output port */ | ||
1220 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_OUTPUT_PORT, 1, 0, BLACKBIRD_OUTPUT_PORT_STREAMING); /* Host */ | ||
1221 | |||
1222 | /* assign frame size */ | ||
1223 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_RESOLUTION, 2, 0, | ||
1224 | dev->height, dev->width); | ||
752 | 1225 | ||
753 | /* assign coring levels (luma_h, luma_l, chroma_h, chroma_l) */ | 1226 | /* assign coring levels (luma_h, luma_l, chroma_h, chroma_l) */ |
754 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_DNR_MEDIAN, 4, 0, 0, 255, 0, 255); | 1227 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_DNR_MEDIAN, 4, 0, 0, 255, 0, 255); |
755 | 1228 | ||
756 | /* assign spatial filter type: luma_t: horiz_only, chroma_t: horiz_only */ | 1229 | /* assign spatial filter type: luma_t: horiz_only, chroma_t: horiz_only */ |
757 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_SPATIAL_FILTER, 2, 0, | 1230 | blackbird_api_cmd(dev, BLACKBIRD_API_SET_SPATIAL_FILTER, 2, 0, |
758 | BLACKBIRD_SPATIAL_FILTER_LUMA_1D_HORIZ, | 1231 | BLACKBIRD_SPATIAL_FILTER_LUMA_1D_HORIZ, |
759 | BLACKBIRD_SPATIAL_FILTER_CHROMA_1D_HORIZ | 1232 | BLACKBIRD_SPATIAL_FILTER_CHROMA_1D_HORIZ |
760 | ); | 1233 | ); |
761 | 1234 | ||
762 | /* assign frame drop rate */ | 1235 | /* assign frame drop rate */ |
763 | /* blackbird_api_cmd(dev, IVTV_API_ASSIGN_FRAME_DROP_RATE, 1, 0, 0); */ | 1236 | /* blackbird_api_cmd(dev, IVTV_API_ASSIGN_FRAME_DROP_RATE, 1, 0, 0); */ |
1237 | |||
1238 | blackbird_set_default_params(dev); | ||
1239 | blackbird_set_default_dnr_params(dev); | ||
764 | } | 1240 | } |
765 | 1241 | ||
766 | static int blackbird_initialize_codec(struct cx8802_dev *dev) | 1242 | static int blackbird_initialize_codec(struct cx8802_dev *dev) |
@@ -851,15 +1327,10 @@ static int bb_buf_setup(struct videobuf_queue *q, | |||
851 | struct cx8802_fh *fh = q->priv_data; | 1327 | struct cx8802_fh *fh = q->priv_data; |
852 | 1328 | ||
853 | fh->dev->ts_packet_size = 188 * 4; /* was: 512 */ | 1329 | fh->dev->ts_packet_size = 188 * 4; /* was: 512 */ |
854 | fh->dev->ts_packet_count = 32; /* was: 100 */ | 1330 | fh->dev->ts_packet_count = mpegbufs; /* was: 100 */ |
855 | 1331 | ||
856 | *size = fh->dev->ts_packet_size * fh->dev->ts_packet_count; | 1332 | *size = fh->dev->ts_packet_size * fh->dev->ts_packet_count; |
857 | if (0 == *count) | 1333 | *count = fh->dev->ts_packet_count; |
858 | *count = mpegbufs; | ||
859 | if (*count < 2) | ||
860 | *count = 2; | ||
861 | if (*count > 32) | ||
862 | *count = 32; | ||
863 | return 0; | 1334 | return 0; |
864 | } | 1335 | } |
865 | 1336 | ||
@@ -868,7 +1339,7 @@ bb_buf_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb, | |||
868 | enum v4l2_field field) | 1339 | enum v4l2_field field) |
869 | { | 1340 | { |
870 | struct cx8802_fh *fh = q->priv_data; | 1341 | struct cx8802_fh *fh = q->priv_data; |
871 | return cx8802_buf_prepare(fh->dev, (struct cx88_buffer*)vb); | 1342 | return cx8802_buf_prepare(fh->dev, (struct cx88_buffer*)vb, field); |
872 | } | 1343 | } |
873 | 1344 | ||
874 | static void | 1345 | static void |
@@ -920,8 +1391,6 @@ static int mpeg_do_ioctl(struct inode *inode, struct file *file, | |||
920 | V4L2_CAP_VIDEO_CAPTURE | | 1391 | V4L2_CAP_VIDEO_CAPTURE | |
921 | V4L2_CAP_READWRITE | | 1392 | V4L2_CAP_READWRITE | |
922 | V4L2_CAP_STREAMING | | 1393 | V4L2_CAP_STREAMING | |
923 | V4L2_CAP_VBI_CAPTURE | | ||
924 | V4L2_CAP_VIDEO_OVERLAY | | ||
925 | 0; | 1394 | 0; |
926 | if (UNSET != core->tuner_type) | 1395 | if (UNSET != core->tuner_type) |
927 | cap->capabilities |= V4L2_CAP_TUNER; | 1396 | cap->capabilities |= V4L2_CAP_TUNER; |
@@ -941,27 +1410,52 @@ static int mpeg_do_ioctl(struct inode *inode, struct file *file, | |||
941 | 1410 | ||
942 | memset(f,0,sizeof(*f)); | 1411 | memset(f,0,sizeof(*f)); |
943 | f->index = index; | 1412 | f->index = index; |
944 | strlcpy(f->description, "MPEG TS", sizeof(f->description)); | 1413 | strlcpy(f->description, "MPEG", sizeof(f->description)); |
945 | f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 1414 | f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
946 | f->pixelformat = V4L2_PIX_FMT_MPEG; | 1415 | f->pixelformat = V4L2_PIX_FMT_MPEG; |
947 | return 0; | 1416 | return 0; |
948 | } | 1417 | } |
949 | case VIDIOC_G_FMT: | 1418 | case VIDIOC_G_FMT: |
950 | case VIDIOC_S_FMT: | ||
951 | case VIDIOC_TRY_FMT: | ||
952 | { | 1419 | { |
953 | /* FIXME -- quick'n'dirty for exactly one size ... */ | ||
954 | struct v4l2_format *f = arg; | 1420 | struct v4l2_format *f = arg; |
955 | 1421 | ||
956 | memset(f,0,sizeof(*f)); | 1422 | memset(f,0,sizeof(*f)); |
957 | f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 1423 | f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
1424 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; | ||
1425 | f->fmt.pix.bytesperline = 0; | ||
1426 | f->fmt.pix.sizeimage = dev->ts_packet_size * dev->ts_packet_count; /* 188 * 4 * 1024; */ | ||
1427 | f->fmt.pix.colorspace = 0; | ||
958 | f->fmt.pix.width = dev->width; | 1428 | f->fmt.pix.width = dev->width; |
959 | f->fmt.pix.height = dev->height; | 1429 | f->fmt.pix.height = dev->height; |
1430 | f->fmt.pix.field = fh->mpegq.field; | ||
1431 | dprintk(0,"VIDIOC_G_FMT: w: %d, h: %d, f: %d\n", | ||
1432 | dev->width, dev->height, fh->mpegq.field ); | ||
1433 | return 0; | ||
1434 | } | ||
1435 | case VIDIOC_TRY_FMT: | ||
1436 | { | ||
1437 | struct v4l2_format *f = arg; | ||
1438 | |||
1439 | f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
1440 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; | ||
1441 | f->fmt.pix.bytesperline = 0; | ||
1442 | f->fmt.pix.sizeimage = dev->ts_packet_size * dev->ts_packet_count; /* 188 * 4 * 1024; */; | ||
1443 | f->fmt.pix.colorspace = 0; | ||
1444 | dprintk(0,"VIDIOC_TRY_FMT: w: %d, h: %d, f: %d\n", | ||
1445 | dev->width, dev->height, fh->mpegq.field ); | ||
1446 | return 0; | ||
1447 | } | ||
1448 | case VIDIOC_S_FMT: | ||
1449 | { | ||
1450 | struct v4l2_format *f = arg; | ||
1451 | |||
1452 | f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
960 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; | 1453 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; |
961 | f->fmt.pix.field = V4L2_FIELD_NONE; | ||
962 | f->fmt.pix.bytesperline = 0; | 1454 | f->fmt.pix.bytesperline = 0; |
963 | f->fmt.pix.sizeimage = 188 * 4 * 1024; /* 1024 * 512 */ /* FIXME: BUFFER_SIZE */; | 1455 | f->fmt.pix.sizeimage = dev->ts_packet_size * dev->ts_packet_count; /* 188 * 4 * 1024; */; |
964 | f->fmt.pix.colorspace = 0; | 1456 | f->fmt.pix.colorspace = 0; |
1457 | dprintk(0,"VIDIOC_S_FMT: w: %d, h: %d, f: %d\n", | ||
1458 | f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.field ); | ||
965 | return 0; | 1459 | return 0; |
966 | } | 1460 | } |
967 | 1461 | ||
@@ -985,6 +1479,22 @@ static int mpeg_do_ioctl(struct inode *inode, struct file *file, | |||
985 | case VIDIOC_STREAMOFF: | 1479 | case VIDIOC_STREAMOFF: |
986 | return videobuf_streamoff(&fh->mpegq); | 1480 | return videobuf_streamoff(&fh->mpegq); |
987 | 1481 | ||
1482 | /* --- mpeg compression -------------------------------------- */ | ||
1483 | case VIDIOC_G_MPEGCOMP: | ||
1484 | { | ||
1485 | struct v4l2_mpeg_compression *f = arg; | ||
1486 | |||
1487 | memcpy(f,&dev->params,sizeof(*f)); | ||
1488 | return 0; | ||
1489 | } | ||
1490 | case VIDIOC_S_MPEGCOMP: | ||
1491 | { | ||
1492 | struct v4l2_mpeg_compression *f = arg; | ||
1493 | |||
1494 | blackbird_set_params(dev, f); | ||
1495 | return 0; | ||
1496 | } | ||
1497 | |||
988 | default: | 1498 | default: |
989 | return cx88_do_ioctl( inode, file, 0, dev->core, cmd, arg, cx88_ioctl_hook ); | 1499 | return cx88_do_ioctl( inode, file, 0, dev->core, cmd, arg, cx88_ioctl_hook ); |
990 | } | 1500 | } |
@@ -1034,16 +1544,17 @@ static int mpeg_open(struct inode *inode, struct file *file) | |||
1034 | file->private_data = fh; | 1544 | file->private_data = fh; |
1035 | fh->dev = dev; | 1545 | fh->dev = dev; |
1036 | 1546 | ||
1037 | /* FIXME: locking against other video device */ | ||
1038 | cx88_set_scale(dev->core, dev->width, dev->height, | ||
1039 | V4L2_FIELD_INTERLACED); | ||
1040 | |||
1041 | videobuf_queue_init(&fh->mpegq, &blackbird_qops, | 1547 | videobuf_queue_init(&fh->mpegq, &blackbird_qops, |
1042 | dev->pci, &dev->slock, | 1548 | dev->pci, &dev->slock, |
1043 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | 1549 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
1044 | V4L2_FIELD_TOP, | 1550 | V4L2_FIELD_INTERLACED, |
1045 | sizeof(struct cx88_buffer), | 1551 | sizeof(struct cx88_buffer), |
1046 | fh); | 1552 | fh); |
1553 | |||
1554 | /* FIXME: locking against other video device */ | ||
1555 | cx88_set_scale(dev->core, dev->width, dev->height, | ||
1556 | fh->mpegq.field); | ||
1557 | |||
1047 | return 0; | 1558 | return 0; |
1048 | } | 1559 | } |
1049 | 1560 | ||
@@ -1173,6 +1684,8 @@ static int __devinit blackbird_probe(struct pci_dev *pci_dev, | |||
1173 | dev->core = core; | 1684 | dev->core = core; |
1174 | dev->width = 720; | 1685 | dev->width = 720; |
1175 | dev->height = 576; | 1686 | dev->height = 576; |
1687 | memcpy(&dev->params,&default_mpeg_params,sizeof(default_mpeg_params)); | ||
1688 | memcpy(&dev->dnr_params,&default_dnr_params,sizeof(default_dnr_params)); | ||
1176 | 1689 | ||
1177 | err = cx8802_init_common(dev); | 1690 | err = cx8802_init_common(dev); |
1178 | if (0 != err) | 1691 | if (0 != err) |
@@ -1199,7 +1712,7 @@ static int __devinit blackbird_probe(struct pci_dev *pci_dev, | |||
1199 | 1712 | ||
1200 | static void __devexit blackbird_remove(struct pci_dev *pci_dev) | 1713 | static void __devexit blackbird_remove(struct pci_dev *pci_dev) |
1201 | { | 1714 | { |
1202 | struct cx8802_dev *dev = pci_get_drvdata(pci_dev); | 1715 | struct cx8802_dev *dev = pci_get_drvdata(pci_dev); |
1203 | 1716 | ||
1204 | /* blackbird */ | 1717 | /* blackbird */ |
1205 | blackbird_unregister_video(dev); | 1718 | blackbird_unregister_video(dev); |
@@ -1215,8 +1728,8 @@ static struct pci_device_id cx8802_pci_tbl[] = { | |||
1215 | { | 1728 | { |
1216 | .vendor = 0x14f1, | 1729 | .vendor = 0x14f1, |
1217 | .device = 0x8802, | 1730 | .device = 0x8802, |
1218 | .subvendor = PCI_ANY_ID, | 1731 | .subvendor = PCI_ANY_ID, |
1219 | .subdevice = PCI_ANY_ID, | 1732 | .subdevice = PCI_ANY_ID, |
1220 | },{ | 1733 | },{ |
1221 | /* --- end of list --- */ | 1734 | /* --- end of list --- */ |
1222 | } | 1735 | } |
@@ -1224,10 +1737,10 @@ static struct pci_device_id cx8802_pci_tbl[] = { | |||
1224 | MODULE_DEVICE_TABLE(pci, cx8802_pci_tbl); | 1737 | MODULE_DEVICE_TABLE(pci, cx8802_pci_tbl); |
1225 | 1738 | ||
1226 | static struct pci_driver blackbird_pci_driver = { | 1739 | static struct pci_driver blackbird_pci_driver = { |
1227 | .name = "cx88-blackbird", | 1740 | .name = "cx88-blackbird", |
1228 | .id_table = cx8802_pci_tbl, | 1741 | .id_table = cx8802_pci_tbl, |
1229 | .probe = blackbird_probe, | 1742 | .probe = blackbird_probe, |
1230 | .remove = __devexit_p(blackbird_remove), | 1743 | .remove = __devexit_p(blackbird_remove), |
1231 | .suspend = cx8802_suspend_common, | 1744 | .suspend = cx8802_suspend_common, |
1232 | .resume = cx8802_resume_common, | 1745 | .resume = cx8802_resume_common, |
1233 | }; | 1746 | }; |
@@ -1257,6 +1770,8 @@ module_exit(blackbird_fini); | |||
1257 | 1770 | ||
1258 | EXPORT_SYMBOL(cx88_ioctl_hook); | 1771 | EXPORT_SYMBOL(cx88_ioctl_hook); |
1259 | EXPORT_SYMBOL(cx88_ioctl_translator); | 1772 | EXPORT_SYMBOL(cx88_ioctl_translator); |
1773 | EXPORT_SYMBOL(blackbird_set_params); | ||
1774 | EXPORT_SYMBOL(blackbird_set_dnr_params); | ||
1260 | 1775 | ||
1261 | /* ----------------------------------------------------------- */ | 1776 | /* ----------------------------------------------------------- */ |
1262 | /* | 1777 | /* |