diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2008-11-29 17:38:23 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-12-30 06:38:44 -0500 |
commit | 67ec09fdf5e05d4670b617256c696348b5df080b (patch) | |
tree | fdf5f16f9b20280f83ce10e435d557bcb371934f /drivers/media/video/ivtv/ivtv-driver.c | |
parent | ca085fb900265b525e3f9fb95fb6d7fd27a302ea (diff) |
V4L/DVB (9835): ivtv/ivtvfb: convert to v4l2_device/v4l2_subdev.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/ivtv/ivtv-driver.c')
-rw-r--r-- | drivers/media/video/ivtv/ivtv-driver.c | 214 |
1 files changed, 66 insertions, 148 deletions
diff --git a/drivers/media/video/ivtv/ivtv-driver.c b/drivers/media/video/ivtv/ivtv-driver.c index b69cc1d55e5b..08b762951759 100644 --- a/drivers/media/video/ivtv/ivtv-driver.c +++ b/drivers/media/video/ivtv/ivtv-driver.c | |||
@@ -60,9 +60,6 @@ | |||
60 | #include <media/v4l2-chip-ident.h> | 60 | #include <media/v4l2-chip-ident.h> |
61 | #include "tuner-xc2028.h" | 61 | #include "tuner-xc2028.h" |
62 | 62 | ||
63 | /* var to keep track of the number of array elements in use */ | ||
64 | int ivtv_cards_active; | ||
65 | |||
66 | /* If you have already X v4l cards, then set this to X. This way | 63 | /* If you have already X v4l cards, then set this to X. This way |
67 | the device numbers stay matched. Example: you have a WinTV card | 64 | the device numbers stay matched. Example: you have a WinTV card |
68 | without radio and a PVR-350 with. Normally this would give a | 65 | without radio and a PVR-350 with. Normally this would give a |
@@ -70,12 +67,6 @@ int ivtv_cards_active; | |||
70 | setting this to 1 you ensure that radio0 is now also radio1. */ | 67 | setting this to 1 you ensure that radio0 is now also radio1. */ |
71 | int ivtv_first_minor; | 68 | int ivtv_first_minor; |
72 | 69 | ||
73 | /* Master variable for all ivtv info */ | ||
74 | struct ivtv *ivtv_cards[IVTV_MAX_CARDS]; | ||
75 | |||
76 | /* Protects ivtv_cards_active */ | ||
77 | DEFINE_SPINLOCK(ivtv_cards_lock); | ||
78 | |||
79 | /* add your revision and whatnot here */ | 70 | /* add your revision and whatnot here */ |
80 | static struct pci_device_id ivtv_pci_tbl[] __devinitdata = { | 71 | static struct pci_device_id ivtv_pci_tbl[] __devinitdata = { |
81 | {PCI_VENDOR_ID_ICOMP, PCI_DEVICE_ID_IVTV15, | 72 | {PCI_VENDOR_ID_ICOMP, PCI_DEVICE_ID_IVTV15, |
@@ -87,6 +78,9 @@ static struct pci_device_id ivtv_pci_tbl[] __devinitdata = { | |||
87 | 78 | ||
88 | MODULE_DEVICE_TABLE(pci,ivtv_pci_tbl); | 79 | MODULE_DEVICE_TABLE(pci,ivtv_pci_tbl); |
89 | 80 | ||
81 | /* ivtv instance counter */ | ||
82 | static atomic_t ivtv_instance = ATOMIC_INIT(0); | ||
83 | |||
90 | /* Parameter declarations */ | 84 | /* Parameter declarations */ |
91 | static int cardtype[IVTV_MAX_CARDS]; | 85 | static int cardtype[IVTV_MAX_CARDS]; |
92 | static int tuner[IVTV_MAX_CARDS] = { -1, -1, -1, -1, -1, -1, -1, -1, | 86 | static int tuner[IVTV_MAX_CARDS] = { -1, -1, -1, -1, -1, -1, -1, -1, |
@@ -599,9 +593,9 @@ static void ivtv_process_options(struct ivtv *itv) | |||
599 | itv->options.kilobytes[IVTV_DEC_STREAM_TYPE_MPG] = dec_mpg_buffers * 1024; | 593 | itv->options.kilobytes[IVTV_DEC_STREAM_TYPE_MPG] = dec_mpg_buffers * 1024; |
600 | itv->options.kilobytes[IVTV_DEC_STREAM_TYPE_YUV] = dec_yuv_buffers * 1024; | 594 | itv->options.kilobytes[IVTV_DEC_STREAM_TYPE_YUV] = dec_yuv_buffers * 1024; |
601 | itv->options.kilobytes[IVTV_DEC_STREAM_TYPE_VBI] = dec_vbi_buffers; | 595 | itv->options.kilobytes[IVTV_DEC_STREAM_TYPE_VBI] = dec_vbi_buffers; |
602 | itv->options.cardtype = cardtype[itv->num]; | 596 | itv->options.cardtype = cardtype[itv->instance]; |
603 | itv->options.tuner = tuner[itv->num]; | 597 | itv->options.tuner = tuner[itv->instance]; |
604 | itv->options.radio = radio[itv->num]; | 598 | itv->options.radio = radio[itv->instance]; |
605 | itv->options.newi2c = newi2c; | 599 | itv->options.newi2c = newi2c; |
606 | if (tunertype < -1 || tunertype > 1) { | 600 | if (tunertype < -1 || tunertype > 1) { |
607 | IVTV_WARN("Invalid tunertype argument, will autodetect instead\n"); | 601 | IVTV_WARN("Invalid tunertype argument, will autodetect instead\n"); |
@@ -688,7 +682,7 @@ static int __devinit ivtv_init_struct1(struct ivtv *itv) | |||
688 | spin_lock_init(&itv->lock); | 682 | spin_lock_init(&itv->lock); |
689 | spin_lock_init(&itv->dma_reg_lock); | 683 | spin_lock_init(&itv->dma_reg_lock); |
690 | 684 | ||
691 | itv->irq_work_queues = create_singlethread_workqueue(itv->name); | 685 | itv->irq_work_queues = create_singlethread_workqueue(itv->device.name); |
692 | if (itv->irq_work_queues == NULL) { | 686 | if (itv->irq_work_queues == NULL) { |
693 | IVTV_ERR("Could not create ivtv workqueue\n"); | 687 | IVTV_ERR("Could not create ivtv workqueue\n"); |
694 | return -1; | 688 | return -1; |
@@ -770,12 +764,6 @@ static void __devinit ivtv_init_struct2(struct ivtv *itv) | |||
770 | i = 0; | 764 | i = 0; |
771 | itv->active_input = i; | 765 | itv->active_input = i; |
772 | itv->audio_input = itv->card->video_inputs[i].audio_index; | 766 | itv->audio_input = itv->card->video_inputs[i].audio_index; |
773 | if (itv->card->hw_all & IVTV_HW_CX25840) | ||
774 | itv->video_dec_func = ivtv_cx25840; | ||
775 | else if (itv->card->hw_all & IVTV_HW_SAA717X) | ||
776 | itv->video_dec_func = ivtv_saa717x; | ||
777 | else | ||
778 | itv->video_dec_func = ivtv_saa7115; | ||
779 | } | 767 | } |
780 | 768 | ||
781 | static int ivtv_setup_pci(struct ivtv *itv, struct pci_dev *dev, | 769 | static int ivtv_setup_pci(struct ivtv *itv, struct pci_dev *dev, |
@@ -788,21 +776,21 @@ static int ivtv_setup_pci(struct ivtv *itv, struct pci_dev *dev, | |||
788 | IVTV_DEBUG_INFO("Enabling pci device\n"); | 776 | IVTV_DEBUG_INFO("Enabling pci device\n"); |
789 | 777 | ||
790 | if (pci_enable_device(dev)) { | 778 | if (pci_enable_device(dev)) { |
791 | IVTV_ERR("Can't enable device %d!\n", itv->num); | 779 | IVTV_ERR("Can't enable device!\n"); |
792 | return -EIO; | 780 | return -EIO; |
793 | } | 781 | } |
794 | if (pci_set_dma_mask(dev, 0xffffffff)) { | 782 | if (pci_set_dma_mask(dev, 0xffffffff)) { |
795 | IVTV_ERR("No suitable DMA available on card %d.\n", itv->num); | 783 | IVTV_ERR("No suitable DMA available.\n"); |
796 | return -EIO; | 784 | return -EIO; |
797 | } | 785 | } |
798 | if (!request_mem_region(itv->base_addr, IVTV_ENCODER_SIZE, "ivtv encoder")) { | 786 | if (!request_mem_region(itv->base_addr, IVTV_ENCODER_SIZE, "ivtv encoder")) { |
799 | IVTV_ERR("Cannot request encoder memory region on card %d.\n", itv->num); | 787 | IVTV_ERR("Cannot request encoder memory region.\n"); |
800 | return -EIO; | 788 | return -EIO; |
801 | } | 789 | } |
802 | 790 | ||
803 | if (!request_mem_region(itv->base_addr + IVTV_REG_OFFSET, | 791 | if (!request_mem_region(itv->base_addr + IVTV_REG_OFFSET, |
804 | IVTV_REG_SIZE, "ivtv registers")) { | 792 | IVTV_REG_SIZE, "ivtv registers")) { |
805 | IVTV_ERR("Cannot request register memory region on card %d.\n", itv->num); | 793 | IVTV_ERR("Cannot request register memory region.\n"); |
806 | release_mem_region(itv->base_addr, IVTV_ENCODER_SIZE); | 794 | release_mem_region(itv->base_addr, IVTV_ENCODER_SIZE); |
807 | return -EIO; | 795 | return -EIO; |
808 | } | 796 | } |
@@ -810,7 +798,7 @@ static int ivtv_setup_pci(struct ivtv *itv, struct pci_dev *dev, | |||
810 | if (itv->has_cx23415 && | 798 | if (itv->has_cx23415 && |
811 | !request_mem_region(itv->base_addr + IVTV_DECODER_OFFSET, | 799 | !request_mem_region(itv->base_addr + IVTV_DECODER_OFFSET, |
812 | IVTV_DECODER_SIZE, "ivtv decoder")) { | 800 | IVTV_DECODER_SIZE, "ivtv decoder")) { |
813 | IVTV_ERR("Cannot request decoder memory region on card %d.\n", itv->num); | 801 | IVTV_ERR("Cannot request decoder memory region.\n"); |
814 | release_mem_region(itv->base_addr, IVTV_ENCODER_SIZE); | 802 | release_mem_region(itv->base_addr, IVTV_ENCODER_SIZE); |
815 | release_mem_region(itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE); | 803 | release_mem_region(itv->base_addr + IVTV_REG_OFFSET, IVTV_REG_SIZE); |
816 | return -EIO; | 804 | return -EIO; |
@@ -853,69 +841,11 @@ static int ivtv_setup_pci(struct ivtv *itv, struct pci_dev *dev, | |||
853 | return 0; | 841 | return 0; |
854 | } | 842 | } |
855 | 843 | ||
856 | #ifdef MODULE | ||
857 | static u32 ivtv_request_module(struct ivtv *itv, u32 hw, | ||
858 | const char *name, u32 id) | ||
859 | { | ||
860 | if ((hw & id) == 0) | ||
861 | return hw; | ||
862 | if (request_module(name) != 0) { | ||
863 | IVTV_ERR("Failed to load module %s\n", name); | ||
864 | return hw & ~id; | ||
865 | } | ||
866 | IVTV_DEBUG_INFO("Loaded module %s\n", name); | ||
867 | return hw; | ||
868 | } | ||
869 | #endif | ||
870 | |||
871 | static void ivtv_load_and_init_modules(struct ivtv *itv) | 844 | static void ivtv_load_and_init_modules(struct ivtv *itv) |
872 | { | 845 | { |
873 | u32 hw = itv->card->hw_all; | 846 | u32 hw = itv->card->hw_all; |
874 | unsigned i; | 847 | unsigned i; |
875 | 848 | ||
876 | #ifdef MODULE | ||
877 | /* load modules */ | ||
878 | #ifdef CONFIG_MEDIA_TUNER_MODULE | ||
879 | hw = ivtv_request_module(itv, hw, "tuner", IVTV_HW_TUNER); | ||
880 | #endif | ||
881 | #ifdef CONFIG_VIDEO_CX25840_MODULE | ||
882 | hw = ivtv_request_module(itv, hw, "cx25840", IVTV_HW_CX25840); | ||
883 | #endif | ||
884 | #ifdef CONFIG_VIDEO_SAA711X_MODULE | ||
885 | hw = ivtv_request_module(itv, hw, "saa7115", IVTV_HW_SAA711X); | ||
886 | #endif | ||
887 | #ifdef CONFIG_VIDEO_SAA7127_MODULE | ||
888 | hw = ivtv_request_module(itv, hw, "saa7127", IVTV_HW_SAA7127); | ||
889 | #endif | ||
890 | #ifdef CONFIG_VIDEO_SAA717X_MODULE | ||
891 | hw = ivtv_request_module(itv, hw, "saa717x", IVTV_HW_SAA717X); | ||
892 | #endif | ||
893 | #ifdef CONFIG_VIDEO_UPD64031A_MODULE | ||
894 | hw = ivtv_request_module(itv, hw, "upd64031a", IVTV_HW_UPD64031A); | ||
895 | #endif | ||
896 | #ifdef CONFIG_VIDEO_UPD64083_MODULE | ||
897 | hw = ivtv_request_module(itv, hw, "upd64083", IVTV_HW_UPD6408X); | ||
898 | #endif | ||
899 | #ifdef CONFIG_VIDEO_MSP3400_MODULE | ||
900 | hw = ivtv_request_module(itv, hw, "msp3400", IVTV_HW_MSP34XX); | ||
901 | #endif | ||
902 | #ifdef CONFIG_VIDEO_VP27SMPX_MODULE | ||
903 | hw = ivtv_request_module(itv, hw, "vp27smpx", IVTV_HW_VP27SMPX); | ||
904 | #endif | ||
905 | #ifdef CONFIG_VIDEO_WM8775_MODULE | ||
906 | hw = ivtv_request_module(itv, hw, "wm8775", IVTV_HW_WM8775); | ||
907 | #endif | ||
908 | #ifdef CONFIG_VIDEO_WM8739_MODULE | ||
909 | hw = ivtv_request_module(itv, hw, "wm8739", IVTV_HW_WM8739); | ||
910 | #endif | ||
911 | #ifdef CONFIG_VIDEO_CS53L32A_MODULE | ||
912 | hw = ivtv_request_module(itv, hw, "cs53l32a", IVTV_HW_CS53L32A); | ||
913 | #endif | ||
914 | #ifdef CONFIG_VIDEO_M52790_MODULE | ||
915 | hw = ivtv_request_module(itv, hw, "m52790", IVTV_HW_M52790); | ||
916 | #endif | ||
917 | #endif | ||
918 | |||
919 | /* check which i2c devices are actually found */ | 849 | /* check which i2c devices are actually found */ |
920 | for (i = 0; i < 32; i++) { | 850 | for (i = 0; i < 32; i++) { |
921 | u32 device = 1 << i; | 851 | u32 device = 1 << i; |
@@ -927,11 +857,21 @@ static void ivtv_load_and_init_modules(struct ivtv *itv) | |||
927 | itv->hw_flags |= device; | 857 | itv->hw_flags |= device; |
928 | continue; | 858 | continue; |
929 | } | 859 | } |
930 | ivtv_i2c_register(itv, i); | 860 | if (ivtv_i2c_register(itv, i) == 0) |
931 | if (ivtv_i2c_hw_addr(itv, device) > 0) | ||
932 | itv->hw_flags |= device; | 861 | itv->hw_flags |= device; |
933 | } | 862 | } |
934 | 863 | ||
864 | if (itv->card->hw_all & IVTV_HW_CX25840) | ||
865 | itv->sd_video = ivtv_find_hw(itv, IVTV_HW_CX25840); | ||
866 | else if (itv->card->hw_all & IVTV_HW_SAA717X) | ||
867 | itv->sd_video = ivtv_find_hw(itv, IVTV_HW_SAA717X); | ||
868 | else if (itv->card->hw_all & IVTV_HW_SAA7114) | ||
869 | itv->sd_video = ivtv_find_hw(itv, IVTV_HW_SAA7114); | ||
870 | else | ||
871 | itv->sd_video = ivtv_find_hw(itv, IVTV_HW_SAA7115); | ||
872 | itv->sd_audio = ivtv_find_hw(itv, itv->card->hw_audio_ctrl); | ||
873 | itv->sd_muxer = ivtv_find_hw(itv, itv->card->hw_muxer); | ||
874 | |||
935 | hw = itv->hw_flags; | 875 | hw = itv->hw_flags; |
936 | 876 | ||
937 | if (itv->card->type == IVTV_CARD_CX23416GYC) { | 877 | if (itv->card->type == IVTV_CARD_CX23416GYC) { |
@@ -949,7 +889,7 @@ static void ivtv_load_and_init_modules(struct ivtv *itv) | |||
949 | /* The crystal frequency of GVMVPRX is 24.576MHz */ | 889 | /* The crystal frequency of GVMVPRX is 24.576MHz */ |
950 | crystal_freq.freq = SAA7115_FREQ_24_576_MHZ; | 890 | crystal_freq.freq = SAA7115_FREQ_24_576_MHZ; |
951 | crystal_freq.flags = SAA7115_FREQ_FL_UCGC; | 891 | crystal_freq.flags = SAA7115_FREQ_FL_UCGC; |
952 | itv->video_dec_func(itv, VIDIOC_INT_S_CRYSTAL_FREQ, &crystal_freq); | 892 | v4l2_subdev_call(itv->sd_video, video, s_crystal_freq, &crystal_freq); |
953 | } | 893 | } |
954 | 894 | ||
955 | if (hw & IVTV_HW_CX25840) { | 895 | if (hw & IVTV_HW_CX25840) { |
@@ -967,7 +907,7 @@ static void ivtv_load_and_init_modules(struct ivtv *itv) | |||
967 | /* determine the exact saa711x model */ | 907 | /* determine the exact saa711x model */ |
968 | itv->hw_flags &= ~IVTV_HW_SAA711X; | 908 | itv->hw_flags &= ~IVTV_HW_SAA711X; |
969 | 909 | ||
970 | ivtv_saa7115(itv, VIDIOC_G_CHIP_IDENT, &v); | 910 | ivtv_call_hw(itv, IVTV_HW_SAA711X, core, g_chip_ident, &v); |
971 | if (v.ident == V4L2_IDENT_SAA7114) { | 911 | if (v.ident == V4L2_IDENT_SAA7114) { |
972 | itv->hw_flags |= IVTV_HW_SAA7114; | 912 | itv->hw_flags |= IVTV_HW_SAA7114; |
973 | /* VBI is not yet supported by the saa7114 driver. */ | 913 | /* VBI is not yet supported by the saa7114 driver. */ |
@@ -1001,28 +941,20 @@ static int __devinit ivtv_probe(struct pci_dev *dev, | |||
1001 | int vbi_buf_size; | 941 | int vbi_buf_size; |
1002 | struct ivtv *itv; | 942 | struct ivtv *itv; |
1003 | 943 | ||
1004 | spin_lock(&ivtv_cards_lock); | ||
1005 | |||
1006 | /* Make sure we've got a place for this card */ | ||
1007 | if (ivtv_cards_active == IVTV_MAX_CARDS) { | ||
1008 | printk(KERN_ERR "ivtv: Maximum number of cards detected (%d)\n", | ||
1009 | ivtv_cards_active); | ||
1010 | spin_unlock(&ivtv_cards_lock); | ||
1011 | return -ENOMEM; | ||
1012 | } | ||
1013 | |||
1014 | itv = kzalloc(sizeof(struct ivtv), GFP_ATOMIC); | 944 | itv = kzalloc(sizeof(struct ivtv), GFP_ATOMIC); |
1015 | if (itv == NULL) { | 945 | if (itv == NULL) |
1016 | spin_unlock(&ivtv_cards_lock); | ||
1017 | return -ENOMEM; | 946 | return -ENOMEM; |
1018 | } | ||
1019 | ivtv_cards[ivtv_cards_active] = itv; | ||
1020 | itv->dev = dev; | 947 | itv->dev = dev; |
1021 | itv->num = ivtv_cards_active++; | 948 | itv->instance = atomic_inc_return(&ivtv_instance) - 1; |
1022 | snprintf(itv->name, sizeof(itv->name), "ivtv%d", itv->num); | ||
1023 | IVTV_INFO("Initializing card #%d\n", itv->num); | ||
1024 | 949 | ||
1025 | spin_unlock(&ivtv_cards_lock); | 950 | retval = v4l2_device_register(&dev->dev, &itv->device); |
951 | if (retval) | ||
952 | return retval; | ||
953 | /* "ivtv + PCI ID" is a bit of a mouthful, so use | ||
954 | "ivtv + instance" instead. */ | ||
955 | snprintf(itv->device.name, sizeof(itv->device.name), | ||
956 | "ivtv%d", itv->instance); | ||
957 | IVTV_INFO("Initializing card %d\n", itv->instance); | ||
1026 | 958 | ||
1027 | ivtv_process_options(itv); | 959 | ivtv_process_options(itv); |
1028 | if (itv->options.cardtype == -1) { | 960 | if (itv->options.cardtype == -1) { |
@@ -1043,8 +975,6 @@ static int __devinit ivtv_probe(struct pci_dev *dev, | |||
1043 | else if (retval == -ENXIO) | 975 | else if (retval == -ENXIO) |
1044 | goto free_mem; | 976 | goto free_mem; |
1045 | } | 977 | } |
1046 | /* save itv in the pci struct for later use */ | ||
1047 | pci_set_drvdata(dev, itv); | ||
1048 | 978 | ||
1049 | /* map io memory */ | 979 | /* map io memory */ |
1050 | IVTV_DEBUG_INFO("attempting ioremap at 0x%08x len 0x%08x\n", | 980 | IVTV_DEBUG_INFO("attempting ioremap at 0x%08x len 0x%08x\n", |
@@ -1086,7 +1016,9 @@ static int __devinit ivtv_probe(struct pci_dev *dev, | |||
1086 | goto free_io; | 1016 | goto free_io; |
1087 | } | 1017 | } |
1088 | 1018 | ||
1089 | ivtv_gpio_init(itv); | 1019 | retval = ivtv_gpio_init(itv); |
1020 | if (retval) | ||
1021 | goto free_io; | ||
1090 | 1022 | ||
1091 | /* active i2c */ | 1023 | /* active i2c */ |
1092 | IVTV_DEBUG_INFO("activating i2c...\n"); | 1024 | IVTV_DEBUG_INFO("activating i2c...\n"); |
@@ -1095,8 +1027,6 @@ static int __devinit ivtv_probe(struct pci_dev *dev, | |||
1095 | goto free_io; | 1027 | goto free_io; |
1096 | } | 1028 | } |
1097 | 1029 | ||
1098 | IVTV_DEBUG_INFO("Active card count: %d.\n", ivtv_cards_active); | ||
1099 | |||
1100 | if (itv->card->hw_all & IVTV_HW_TVEEPROM) { | 1030 | if (itv->card->hw_all & IVTV_HW_TVEEPROM) { |
1101 | /* Based on the model number the cardtype may be changed. | 1031 | /* Based on the model number the cardtype may be changed. |
1102 | The PCI IDs are not always reliable. */ | 1032 | The PCI IDs are not always reliable. */ |
@@ -1191,7 +1121,7 @@ static int __devinit ivtv_probe(struct pci_dev *dev, | |||
1191 | setup.mode_mask = T_ANALOG_TV; /* matches TV tuners */ | 1121 | setup.mode_mask = T_ANALOG_TV; /* matches TV tuners */ |
1192 | setup.tuner_callback = (setup.type == TUNER_XC2028) ? | 1122 | setup.tuner_callback = (setup.type == TUNER_XC2028) ? |
1193 | ivtv_reset_tuner_gpio : NULL; | 1123 | ivtv_reset_tuner_gpio : NULL; |
1194 | ivtv_call_i2c_clients(itv, TUNER_SET_TYPE_ADDR, &setup); | 1124 | ivtv_call_all(itv, tuner, s_type_addr, &setup); |
1195 | if (setup.type == TUNER_XC2028) { | 1125 | if (setup.type == TUNER_XC2028) { |
1196 | static struct xc2028_ctrl ctrl = { | 1126 | static struct xc2028_ctrl ctrl = { |
1197 | .fname = XC2028_DEFAULT_FIRMWARE, | 1127 | .fname = XC2028_DEFAULT_FIRMWARE, |
@@ -1201,7 +1131,7 @@ static int __devinit ivtv_probe(struct pci_dev *dev, | |||
1201 | .tuner = itv->options.tuner, | 1131 | .tuner = itv->options.tuner, |
1202 | .priv = &ctrl, | 1132 | .priv = &ctrl, |
1203 | }; | 1133 | }; |
1204 | ivtv_call_i2c_clients(itv, TUNER_SET_CONFIG, &cfg); | 1134 | ivtv_call_all(itv, tuner, s_config, &cfg); |
1205 | } | 1135 | } |
1206 | } | 1136 | } |
1207 | 1137 | ||
@@ -1210,11 +1140,11 @@ static int __devinit ivtv_probe(struct pci_dev *dev, | |||
1210 | itv->tuner_std = itv->std; | 1140 | itv->tuner_std = itv->std; |
1211 | 1141 | ||
1212 | if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) { | 1142 | if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) { |
1213 | ivtv_call_i2c_clients(itv, VIDIOC_INT_S_STD_OUTPUT, &itv->std); | 1143 | ivtv_call_all(itv, video, s_std_output, itv->std); |
1214 | /* Turn off the output signal. The mpeg decoder is not yet | 1144 | /* Turn off the output signal. The mpeg decoder is not yet |
1215 | active so without this you would get a green image until the | 1145 | active so without this you would get a green image until the |
1216 | mpeg decoder becomes active. */ | 1146 | mpeg decoder becomes active. */ |
1217 | ivtv_saa7127(itv, VIDIOC_STREAMOFF, NULL); | 1147 | ivtv_call_hw(itv, IVTV_HW_SAA7127, video, s_stream, 0); |
1218 | } | 1148 | } |
1219 | 1149 | ||
1220 | /* clear interrupt mask, effectively disabling interrupts */ | 1150 | /* clear interrupt mask, effectively disabling interrupts */ |
@@ -1222,7 +1152,7 @@ static int __devinit ivtv_probe(struct pci_dev *dev, | |||
1222 | 1152 | ||
1223 | /* Register IRQ */ | 1153 | /* Register IRQ */ |
1224 | retval = request_irq(itv->dev->irq, ivtv_irq_handler, | 1154 | retval = request_irq(itv->dev->irq, ivtv_irq_handler, |
1225 | IRQF_SHARED | IRQF_DISABLED, itv->name, (void *)itv); | 1155 | IRQF_SHARED | IRQF_DISABLED, itv->device.name, (void *)itv); |
1226 | if (retval) { | 1156 | if (retval) { |
1227 | IVTV_ERR("Failed to register irq %d\n", retval); | 1157 | IVTV_ERR("Failed to register irq %d\n", retval); |
1228 | goto free_i2c; | 1158 | goto free_i2c; |
@@ -1238,7 +1168,7 @@ static int __devinit ivtv_probe(struct pci_dev *dev, | |||
1238 | IVTV_ERR("Error %d registering devices\n", retval); | 1168 | IVTV_ERR("Error %d registering devices\n", retval); |
1239 | goto free_streams; | 1169 | goto free_streams; |
1240 | } | 1170 | } |
1241 | IVTV_INFO("Initialized card #%d: %s\n", itv->num, itv->card_name); | 1171 | IVTV_INFO("Initialized card: %s\n", itv->card_name); |
1242 | return 0; | 1172 | return 0; |
1243 | 1173 | ||
1244 | free_streams: | 1174 | free_streams: |
@@ -1261,10 +1191,8 @@ err: | |||
1261 | retval = -ENODEV; | 1191 | retval = -ENODEV; |
1262 | IVTV_ERR("Error %d on initialization\n", retval); | 1192 | IVTV_ERR("Error %d on initialization\n", retval); |
1263 | 1193 | ||
1264 | spin_lock(&ivtv_cards_lock); | 1194 | v4l2_device_unregister(&itv->device); |
1265 | kfree(ivtv_cards[ivtv_cards_active]); | 1195 | kfree(itv); |
1266 | ivtv_cards[ivtv_cards_active] = NULL; | ||
1267 | spin_unlock(&ivtv_cards_lock); | ||
1268 | return retval; | 1196 | return retval; |
1269 | } | 1197 | } |
1270 | 1198 | ||
@@ -1304,10 +1232,11 @@ int ivtv_init_on_first_open(struct ivtv *itv) | |||
1304 | if (itv->card->hw_all & IVTV_HW_CX25840) { | 1232 | if (itv->card->hw_all & IVTV_HW_CX25840) { |
1305 | struct v4l2_control ctrl; | 1233 | struct v4l2_control ctrl; |
1306 | 1234 | ||
1235 | v4l2_subdev_call(itv->sd_video, core, init, 0); | ||
1307 | /* CX25840_CID_ENABLE_PVR150_WORKAROUND */ | 1236 | /* CX25840_CID_ENABLE_PVR150_WORKAROUND */ |
1308 | ctrl.id = V4L2_CID_PRIVATE_BASE; | 1237 | ctrl.id = V4L2_CID_PRIVATE_BASE; |
1309 | ctrl.value = itv->pvr150_workaround; | 1238 | ctrl.value = itv->pvr150_workaround; |
1310 | itv->video_dec_func(itv, VIDIOC_S_CTRL, &ctrl); | 1239 | v4l2_subdev_call(itv->sd_video, core, s_ctrl, &ctrl); |
1311 | } | 1240 | } |
1312 | 1241 | ||
1313 | vf.tuner = 0; | 1242 | vf.tuner = 0; |
@@ -1337,7 +1266,7 @@ int ivtv_init_on_first_open(struct ivtv *itv) | |||
1337 | /* Turn on the TV-out: ivtv_init_mpeg_decoder() initializes | 1266 | /* Turn on the TV-out: ivtv_init_mpeg_decoder() initializes |
1338 | the mpeg decoder so now the saa7127 receives a proper | 1267 | the mpeg decoder so now the saa7127 receives a proper |
1339 | signal. */ | 1268 | signal. */ |
1340 | ivtv_saa7127(itv, VIDIOC_STREAMON, NULL); | 1269 | ivtv_call_hw(itv, IVTV_HW_SAA7127, video, s_stream, 1); |
1341 | ivtv_init_mpeg_decoder(itv); | 1270 | ivtv_init_mpeg_decoder(itv); |
1342 | } | 1271 | } |
1343 | ivtv_s_std(NULL, &fh, &itv->tuner_std); | 1272 | ivtv_s_std(NULL, &fh, &itv->tuner_std); |
@@ -1362,9 +1291,11 @@ int ivtv_init_on_first_open(struct ivtv *itv) | |||
1362 | 1291 | ||
1363 | static void ivtv_remove(struct pci_dev *pci_dev) | 1292 | static void ivtv_remove(struct pci_dev *pci_dev) |
1364 | { | 1293 | { |
1365 | struct ivtv *itv = pci_get_drvdata(pci_dev); | 1294 | struct v4l2_device *dev = dev_get_drvdata(&pci_dev->dev); |
1295 | struct ivtv *itv = to_ivtv(dev); | ||
1296 | int i; | ||
1366 | 1297 | ||
1367 | IVTV_DEBUG_INFO("Removing Card #%d\n", itv->num); | 1298 | IVTV_DEBUG_INFO("Removing card\n"); |
1368 | 1299 | ||
1369 | if (test_bit(IVTV_F_I_INITED, &itv->i_flags)) { | 1300 | if (test_bit(IVTV_F_I_INITED, &itv->i_flags)) { |
1370 | /* Stop all captures */ | 1301 | /* Stop all captures */ |
@@ -1377,7 +1308,7 @@ static void ivtv_remove(struct pci_dev *pci_dev) | |||
1377 | 1308 | ||
1378 | /* Turn off the TV-out */ | 1309 | /* Turn off the TV-out */ |
1379 | if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) | 1310 | if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) |
1380 | ivtv_saa7127(itv, VIDIOC_STREAMOFF, NULL); | 1311 | ivtv_call_hw(itv, IVTV_HW_SAA7127, video, s_stream, 0); |
1381 | if (atomic_read(&itv->decoding) > 0) { | 1312 | if (atomic_read(&itv->decoding) > 0) { |
1382 | int type; | 1313 | int type; |
1383 | 1314 | ||
@@ -1402,6 +1333,8 @@ static void ivtv_remove(struct pci_dev *pci_dev) | |||
1402 | ivtv_streams_cleanup(itv, 1); | 1333 | ivtv_streams_cleanup(itv, 1); |
1403 | ivtv_udma_free(itv); | 1334 | ivtv_udma_free(itv); |
1404 | 1335 | ||
1336 | v4l2_device_unregister(&itv->device); | ||
1337 | |||
1405 | exit_ivtv_i2c(itv); | 1338 | exit_ivtv_i2c(itv); |
1406 | 1339 | ||
1407 | free_irq(itv->dev->irq, (void *)itv); | 1340 | free_irq(itv->dev->irq, (void *)itv); |
@@ -1413,8 +1346,11 @@ static void ivtv_remove(struct pci_dev *pci_dev) | |||
1413 | release_mem_region(itv->base_addr + IVTV_DECODER_OFFSET, IVTV_DECODER_SIZE); | 1346 | release_mem_region(itv->base_addr + IVTV_DECODER_OFFSET, IVTV_DECODER_SIZE); |
1414 | 1347 | ||
1415 | pci_disable_device(itv->dev); | 1348 | pci_disable_device(itv->dev); |
1349 | for (i = 0; i < IVTV_VBI_FRAMES; i++) | ||
1350 | kfree(itv->vbi.sliced_mpeg_data[i]); | ||
1416 | 1351 | ||
1417 | IVTV_INFO("Removed %s, card #%d\n", itv->card_name, itv->num); | 1352 | printk(KERN_INFO "ivtv: Removed %s\n", itv->card_name); |
1353 | kfree(itv); | ||
1418 | } | 1354 | } |
1419 | 1355 | ||
1420 | /* define a pci_driver for card detection */ | 1356 | /* define a pci_driver for card detection */ |
@@ -1427,54 +1363,36 @@ static struct pci_driver ivtv_pci_driver = { | |||
1427 | 1363 | ||
1428 | static int module_start(void) | 1364 | static int module_start(void) |
1429 | { | 1365 | { |
1430 | printk(KERN_INFO "ivtv: Start initialization, version %s\n", IVTV_VERSION); | 1366 | printk(KERN_INFO "ivtv: Start initialization, version %s\n", IVTV_VERSION); |
1431 | |||
1432 | memset(ivtv_cards, 0, sizeof(ivtv_cards)); | ||
1433 | 1367 | ||
1434 | /* Validate parameters */ | 1368 | /* Validate parameters */ |
1435 | if (ivtv_first_minor < 0 || ivtv_first_minor >= IVTV_MAX_CARDS) { | 1369 | if (ivtv_first_minor < 0 || ivtv_first_minor >= IVTV_MAX_CARDS) { |
1436 | printk(KERN_ERR "ivtv: Exiting, ivtv_first_minor must be between 0 and %d\n", | 1370 | printk(KERN_ERR "ivtv: Exiting, ivtv_first_minor must be between 0 and %d\n", |
1437 | IVTV_MAX_CARDS - 1); | 1371 | IVTV_MAX_CARDS - 1); |
1438 | return -1; | 1372 | return -1; |
1439 | } | 1373 | } |
1440 | 1374 | ||
1441 | if (ivtv_debug < 0 || ivtv_debug > 2047) { | 1375 | if (ivtv_debug < 0 || ivtv_debug > 2047) { |
1442 | ivtv_debug = 0; | 1376 | ivtv_debug = 0; |
1443 | printk(KERN_INFO "ivtv: Debug value must be >= 0 and <= 2047\n"); | 1377 | printk(KERN_INFO "ivtv: Debug value must be >= 0 and <= 2047\n"); |
1444 | } | 1378 | } |
1445 | 1379 | ||
1446 | if (pci_register_driver(&ivtv_pci_driver)) { | 1380 | if (pci_register_driver(&ivtv_pci_driver)) { |
1447 | printk(KERN_ERR "ivtv: Error detecting PCI card\n"); | 1381 | printk(KERN_ERR "ivtv: Error detecting PCI card\n"); |
1448 | return -ENODEV; | 1382 | return -ENODEV; |
1449 | } | 1383 | } |
1450 | printk(KERN_INFO "ivtv: End initialization\n"); | 1384 | printk(KERN_INFO "ivtv: End initialization\n"); |
1451 | return 0; | 1385 | return 0; |
1452 | } | 1386 | } |
1453 | 1387 | ||
1454 | static void module_cleanup(void) | 1388 | static void module_cleanup(void) |
1455 | { | 1389 | { |
1456 | int i, j; | ||
1457 | |||
1458 | pci_unregister_driver(&ivtv_pci_driver); | 1390 | pci_unregister_driver(&ivtv_pci_driver); |
1459 | |||
1460 | spin_lock(&ivtv_cards_lock); | ||
1461 | for (i = 0; i < ivtv_cards_active; i++) { | ||
1462 | if (ivtv_cards[i] == NULL) | ||
1463 | continue; | ||
1464 | for (j = 0; j < IVTV_VBI_FRAMES; j++) { | ||
1465 | kfree(ivtv_cards[i]->vbi.sliced_mpeg_data[j]); | ||
1466 | } | ||
1467 | kfree(ivtv_cards[i]); | ||
1468 | } | ||
1469 | spin_unlock(&ivtv_cards_lock); | ||
1470 | } | 1391 | } |
1471 | 1392 | ||
1472 | /* Note: These symbols are exported because they are used by the ivtvfb | 1393 | /* Note: These symbols are exported because they are used by the ivtvfb |
1473 | framebuffer module and an infrared module for the IR-blaster. */ | 1394 | framebuffer module and an infrared module for the IR-blaster. */ |
1474 | EXPORT_SYMBOL(ivtv_set_irq_mask); | 1395 | EXPORT_SYMBOL(ivtv_set_irq_mask); |
1475 | EXPORT_SYMBOL(ivtv_cards_active); | ||
1476 | EXPORT_SYMBOL(ivtv_cards); | ||
1477 | EXPORT_SYMBOL(ivtv_cards_lock); | ||
1478 | EXPORT_SYMBOL(ivtv_api); | 1396 | EXPORT_SYMBOL(ivtv_api); |
1479 | EXPORT_SYMBOL(ivtv_vapi); | 1397 | EXPORT_SYMBOL(ivtv_vapi); |
1480 | EXPORT_SYMBOL(ivtv_vapi_result); | 1398 | EXPORT_SYMBOL(ivtv_vapi_result); |