aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2010-01-22 10:10:54 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-02-26 13:10:52 -0500
commit26c3b8b060b3a06f912e5c50bc8ef6ed96195458 (patch)
tree2db13158c01660cc23a5567ad5e6cb4356bbf4d2 /drivers/media/dvb
parent634d2d757a435037576bac465a84a02a72c747b6 (diff)
V4L/DVB: media: dvb/af9015, refactor remote setting
Add af9015_setup structure to hold (right now only remote) setup of distinct receivers. Add af9015_setup_match for matching ids against tables. This is for easier matching different kind of ids against tables to obtain setups. Currently module parameters and usb vendor ids are switched into and matched against tables. Hashes will follow. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Acked-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r--drivers/media/dvb/dvb-usb/af9015.c222
1 files changed, 89 insertions, 133 deletions
diff --git a/drivers/media/dvb/dvb-usb/af9015.c b/drivers/media/dvb/dvb-usb/af9015.c
index 9a799d2e8792..03ba2fdee834 100644
--- a/drivers/media/dvb/dvb-usb/af9015.c
+++ b/drivers/media/dvb/dvb-usb/af9015.c
@@ -732,98 +732,80 @@ error:
732 return ret; 732 return ret;
733} 733}
734 734
735struct af9015_setup {
736 unsigned int id;
737 struct dvb_usb_rc_key *rc_key_map;
738 unsigned int rc_key_map_size;
739 u8 *ir_table;
740 unsigned int ir_table_size;
741};
742
743static const struct af9015_setup *af9015_setup_match(unsigned int id,
744 const struct af9015_setup *table)
745{
746 for (; table->rc_key_map; table++)
747 if (table->id == id)
748 return table;
749 return NULL;
750}
751
752static const struct af9015_setup af9015_setup_modparam[] = {
753 { AF9015_REMOTE_A_LINK_DTU_M,
754 af9015_rc_keys_a_link, ARRAY_SIZE(af9015_rc_keys_a_link),
755 af9015_ir_table_a_link, ARRAY_SIZE(af9015_ir_table_a_link) },
756 { AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3,
757 af9015_rc_keys_msi, ARRAY_SIZE(af9015_rc_keys_msi),
758 af9015_ir_table_msi, ARRAY_SIZE(af9015_ir_table_msi) },
759 { AF9015_REMOTE_MYGICTV_U718,
760 af9015_rc_keys_mygictv, ARRAY_SIZE(af9015_rc_keys_mygictv),
761 af9015_ir_table_mygictv, ARRAY_SIZE(af9015_ir_table_mygictv) },
762 { AF9015_REMOTE_DIGITTRADE_DVB_T,
763 af9015_rc_keys_digittrade, ARRAY_SIZE(af9015_rc_keys_digittrade),
764 af9015_ir_table_digittrade, ARRAY_SIZE(af9015_ir_table_digittrade) },
765 { AF9015_REMOTE_AVERMEDIA_KS,
766 af9015_rc_keys_avermedia, ARRAY_SIZE(af9015_rc_keys_avermedia),
767 af9015_ir_table_avermedia_ks, ARRAY_SIZE(af9015_ir_table_avermedia_ks) },
768 { }
769};
770
771/* don't add new entries here anymore, use hashes instead */
772static const struct af9015_setup af9015_setup_usbids[] = {
773 { USB_VID_LEADTEK,
774 af9015_rc_keys_leadtek, ARRAY_SIZE(af9015_rc_keys_leadtek),
775 af9015_ir_table_leadtek, ARRAY_SIZE(af9015_ir_table_leadtek) },
776 { USB_VID_VISIONPLUS,
777 af9015_rc_keys_twinhan, ARRAY_SIZE(af9015_rc_keys_twinhan),
778 af9015_ir_table_twinhan, ARRAY_SIZE(af9015_ir_table_twinhan) },
779 { USB_VID_KWORLD_2, /* TODO: use correct rc keys */
780 af9015_rc_keys_twinhan, ARRAY_SIZE(af9015_rc_keys_twinhan),
781 af9015_ir_table_kworld, ARRAY_SIZE(af9015_ir_table_kworld) },
782 { USB_VID_AVERMEDIA,
783 af9015_rc_keys_avermedia, ARRAY_SIZE(af9015_rc_keys_avermedia),
784 af9015_ir_table_avermedia, ARRAY_SIZE(af9015_ir_table_avermedia) },
785 { USB_VID_MSI_2,
786 af9015_rc_keys_msi_digivox_iii, ARRAY_SIZE(af9015_rc_keys_msi_digivox_iii),
787 af9015_ir_table_msi_digivox_iii, ARRAY_SIZE(af9015_ir_table_msi_digivox_iii) },
788 { }
789};
790
735static void af9015_set_remote_config(struct usb_device *udev, 791static void af9015_set_remote_config(struct usb_device *udev,
736 struct dvb_usb_device_properties *props) 792 struct dvb_usb_device_properties *props)
737{ 793{
794 const struct af9015_setup *table = NULL;
795
738 if (dvb_usb_af9015_remote) { 796 if (dvb_usb_af9015_remote) {
739 /* load remote defined as module param */ 797 /* load remote defined as module param */
740 switch (dvb_usb_af9015_remote) { 798 table = af9015_setup_match(dvb_usb_af9015_remote,
741 case AF9015_REMOTE_A_LINK_DTU_M: 799 af9015_setup_modparam);
742 props->rc_key_map =
743 af9015_rc_keys_a_link;
744 props->rc_key_map_size =
745 ARRAY_SIZE(af9015_rc_keys_a_link);
746 af9015_config.ir_table = af9015_ir_table_a_link;
747 af9015_config.ir_table_size =
748 ARRAY_SIZE(af9015_ir_table_a_link);
749 break;
750 case AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3:
751 props->rc_key_map =
752 af9015_rc_keys_msi;
753 props->rc_key_map_size =
754 ARRAY_SIZE(af9015_rc_keys_msi);
755 af9015_config.ir_table = af9015_ir_table_msi;
756 af9015_config.ir_table_size =
757 ARRAY_SIZE(af9015_ir_table_msi);
758 break;
759 case AF9015_REMOTE_MYGICTV_U718:
760 props->rc_key_map =
761 af9015_rc_keys_mygictv;
762 props->rc_key_map_size =
763 ARRAY_SIZE(af9015_rc_keys_mygictv);
764 af9015_config.ir_table =
765 af9015_ir_table_mygictv;
766 af9015_config.ir_table_size =
767 ARRAY_SIZE(af9015_ir_table_mygictv);
768 break;
769 case AF9015_REMOTE_DIGITTRADE_DVB_T:
770 props->rc_key_map =
771 af9015_rc_keys_digittrade;
772 props->rc_key_map_size =
773 ARRAY_SIZE(af9015_rc_keys_digittrade);
774 af9015_config.ir_table =
775 af9015_ir_table_digittrade;
776 af9015_config.ir_table_size =
777 ARRAY_SIZE(af9015_ir_table_digittrade);
778 break;
779 case AF9015_REMOTE_AVERMEDIA_KS:
780 props->rc_key_map =
781 af9015_rc_keys_avermedia;
782 props->rc_key_map_size =
783 ARRAY_SIZE(af9015_rc_keys_avermedia);
784 af9015_config.ir_table =
785 af9015_ir_table_avermedia_ks;
786 af9015_config.ir_table_size =
787 ARRAY_SIZE(af9015_ir_table_avermedia_ks);
788 break;
789 }
790 } else { 800 } else {
791 switch (le16_to_cpu(udev->descriptor.idVendor)) { 801 u16 vendor = le16_to_cpu(udev->descriptor.idVendor);
792 case USB_VID_LEADTEK: 802
793 props->rc_key_map = 803 if (vendor == USB_VID_AFATECH) {
794 af9015_rc_keys_leadtek; 804 /* Check USB manufacturer and product strings and try
795 props->rc_key_map_size = 805 to determine correct remote in case of chip vendor
796 ARRAY_SIZE(af9015_rc_keys_leadtek); 806 reference IDs are used.
797 af9015_config.ir_table = 807 DO NOT ADD ANYTHING NEW HERE. Use hashes instead.
798 af9015_ir_table_leadtek; 808 */
799 af9015_config.ir_table_size =
800 ARRAY_SIZE(af9015_ir_table_leadtek);
801 break;
802 case USB_VID_VISIONPLUS:
803 props->rc_key_map =
804 af9015_rc_keys_twinhan;
805 props->rc_key_map_size =
806 ARRAY_SIZE(af9015_rc_keys_twinhan);
807 af9015_config.ir_table =
808 af9015_ir_table_twinhan;
809 af9015_config.ir_table_size =
810 ARRAY_SIZE(af9015_ir_table_twinhan);
811 break;
812 case USB_VID_KWORLD_2:
813 /* TODO: use correct rc keys */
814 props->rc_key_map =
815 af9015_rc_keys_twinhan;
816 props->rc_key_map_size =
817 ARRAY_SIZE(af9015_rc_keys_twinhan);
818 af9015_config.ir_table = af9015_ir_table_kworld;
819 af9015_config.ir_table_size =
820 ARRAY_SIZE(af9015_ir_table_kworld);
821 break;
822 /* Check USB manufacturer and product strings and try
823 to determine correct remote in case of chip vendor
824 reference IDs are used. */
825 case USB_VID_AFATECH:
826 {
827 char manufacturer[10]; 809 char manufacturer[10];
828 memset(manufacturer, 0, sizeof(manufacturer)); 810 memset(manufacturer, 0, sizeof(manufacturer));
829 usb_string(udev, udev->descriptor.iManufacturer, 811 usb_string(udev, udev->descriptor.iManufacturer,
@@ -831,59 +813,33 @@ static void af9015_set_remote_config(struct usb_device *udev,
831 if (!strcmp("Geniatech", manufacturer)) { 813 if (!strcmp("Geniatech", manufacturer)) {
832 /* iManufacturer 1 Geniatech 814 /* iManufacturer 1 Geniatech
833 iProduct 2 AF9015 */ 815 iProduct 2 AF9015 */
834 props->rc_key_map = 816 table = af9015_setup_match(
835 af9015_rc_keys_mygictv; 817 AF9015_REMOTE_MYGICTV_U718,
836 props->rc_key_map_size = 818 af9015_setup_modparam);
837 ARRAY_SIZE(af9015_rc_keys_mygictv);
838 af9015_config.ir_table =
839 af9015_ir_table_mygictv;
840 af9015_config.ir_table_size =
841 ARRAY_SIZE(af9015_ir_table_mygictv);
842 } else if (!strcmp("MSI", manufacturer)) { 819 } else if (!strcmp("MSI", manufacturer)) {
843 /* iManufacturer 1 MSI 820 /* iManufacturer 1 MSI
844 iProduct 2 MSI K-VOX */ 821 iProduct 2 MSI K-VOX */
845 props->rc_key_map = 822 table = af9015_setup_match(
846 af9015_rc_keys_msi; 823 AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3,
847 props->rc_key_map_size = 824 af9015_setup_modparam);
848 ARRAY_SIZE(af9015_rc_keys_msi);
849 af9015_config.ir_table =
850 af9015_ir_table_msi;
851 af9015_config.ir_table_size =
852 ARRAY_SIZE(af9015_ir_table_msi);
853 } else if (udev->descriptor.idProduct == 825 } else if (udev->descriptor.idProduct ==
854 cpu_to_le16(USB_PID_TREKSTOR_DVBT)) { 826 cpu_to_le16(USB_PID_TREKSTOR_DVBT)) {
855 props->rc_key_map = 827 table = &(const struct af9015_setup){ 0,
856 af9015_rc_keys_trekstor; 828 af9015_rc_keys_trekstor,
857 props->rc_key_map_size = 829 ARRAY_SIZE(af9015_rc_keys_trekstor),
858 ARRAY_SIZE(af9015_rc_keys_trekstor); 830 af9015_ir_table_trekstor,
859 af9015_config.ir_table = 831 ARRAY_SIZE(af9015_ir_table_trekstor)
860 af9015_ir_table_trekstor; 832 };
861 af9015_config.ir_table_size =
862 ARRAY_SIZE(af9015_ir_table_trekstor);
863 } 833 }
864 break; 834 } else
865 } 835 table = af9015_setup_match(vendor, af9015_setup_usbids);
866 case USB_VID_AVERMEDIA: 836 }
867 props->rc_key_map = 837
868 af9015_rc_keys_avermedia; 838 if (table) {
869 props->rc_key_map_size = 839 props->rc_key_map = table->rc_key_map;
870 ARRAY_SIZE(af9015_rc_keys_avermedia); 840 props->rc_key_map_size = table->rc_key_map_size;
871 af9015_config.ir_table = 841 af9015_config.ir_table = table->ir_table;
872 af9015_ir_table_avermedia; 842 af9015_config.ir_table_size = table->ir_table_size;
873 af9015_config.ir_table_size =
874 ARRAY_SIZE(af9015_ir_table_avermedia);
875 break;
876 case USB_VID_MSI_2:
877 props->rc_key_map =
878 af9015_rc_keys_msi_digivox_iii;
879 props->rc_key_map_size =
880 ARRAY_SIZE(af9015_rc_keys_msi_digivox_iii);
881 af9015_config.ir_table =
882 af9015_ir_table_msi_digivox_iii;
883 af9015_config.ir_table_size =
884 ARRAY_SIZE(af9015_ir_table_msi_digivox_iii);
885 break;
886 }
887 } 843 }
888} 844}
889 845