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>
This commit is contained in:
parent
634d2d757a
commit
26c3b8b060
@ -732,98 +732,80 @@ static int af9015_download_firmware(struct usb_device *udev,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct af9015_setup {
|
||||||
|
unsigned int id;
|
||||||
|
struct dvb_usb_rc_key *rc_key_map;
|
||||||
|
unsigned int rc_key_map_size;
|
||||||
|
u8 *ir_table;
|
||||||
|
unsigned int ir_table_size;
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct af9015_setup *af9015_setup_match(unsigned int id,
|
||||||
|
const struct af9015_setup *table)
|
||||||
|
{
|
||||||
|
for (; table->rc_key_map; table++)
|
||||||
|
if (table->id == id)
|
||||||
|
return table;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct af9015_setup af9015_setup_modparam[] = {
|
||||||
|
{ AF9015_REMOTE_A_LINK_DTU_M,
|
||||||
|
af9015_rc_keys_a_link, ARRAY_SIZE(af9015_rc_keys_a_link),
|
||||||
|
af9015_ir_table_a_link, ARRAY_SIZE(af9015_ir_table_a_link) },
|
||||||
|
{ AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3,
|
||||||
|
af9015_rc_keys_msi, ARRAY_SIZE(af9015_rc_keys_msi),
|
||||||
|
af9015_ir_table_msi, ARRAY_SIZE(af9015_ir_table_msi) },
|
||||||
|
{ AF9015_REMOTE_MYGICTV_U718,
|
||||||
|
af9015_rc_keys_mygictv, ARRAY_SIZE(af9015_rc_keys_mygictv),
|
||||||
|
af9015_ir_table_mygictv, ARRAY_SIZE(af9015_ir_table_mygictv) },
|
||||||
|
{ AF9015_REMOTE_DIGITTRADE_DVB_T,
|
||||||
|
af9015_rc_keys_digittrade, ARRAY_SIZE(af9015_rc_keys_digittrade),
|
||||||
|
af9015_ir_table_digittrade, ARRAY_SIZE(af9015_ir_table_digittrade) },
|
||||||
|
{ AF9015_REMOTE_AVERMEDIA_KS,
|
||||||
|
af9015_rc_keys_avermedia, ARRAY_SIZE(af9015_rc_keys_avermedia),
|
||||||
|
af9015_ir_table_avermedia_ks, ARRAY_SIZE(af9015_ir_table_avermedia_ks) },
|
||||||
|
{ }
|
||||||
|
};
|
||||||
|
|
||||||
|
/* don't add new entries here anymore, use hashes instead */
|
||||||
|
static const struct af9015_setup af9015_setup_usbids[] = {
|
||||||
|
{ USB_VID_LEADTEK,
|
||||||
|
af9015_rc_keys_leadtek, ARRAY_SIZE(af9015_rc_keys_leadtek),
|
||||||
|
af9015_ir_table_leadtek, ARRAY_SIZE(af9015_ir_table_leadtek) },
|
||||||
|
{ USB_VID_VISIONPLUS,
|
||||||
|
af9015_rc_keys_twinhan, ARRAY_SIZE(af9015_rc_keys_twinhan),
|
||||||
|
af9015_ir_table_twinhan, ARRAY_SIZE(af9015_ir_table_twinhan) },
|
||||||
|
{ USB_VID_KWORLD_2, /* TODO: use correct rc keys */
|
||||||
|
af9015_rc_keys_twinhan, ARRAY_SIZE(af9015_rc_keys_twinhan),
|
||||||
|
af9015_ir_table_kworld, ARRAY_SIZE(af9015_ir_table_kworld) },
|
||||||
|
{ USB_VID_AVERMEDIA,
|
||||||
|
af9015_rc_keys_avermedia, ARRAY_SIZE(af9015_rc_keys_avermedia),
|
||||||
|
af9015_ir_table_avermedia, ARRAY_SIZE(af9015_ir_table_avermedia) },
|
||||||
|
{ USB_VID_MSI_2,
|
||||||
|
af9015_rc_keys_msi_digivox_iii, ARRAY_SIZE(af9015_rc_keys_msi_digivox_iii),
|
||||||
|
af9015_ir_table_msi_digivox_iii, ARRAY_SIZE(af9015_ir_table_msi_digivox_iii) },
|
||||||
|
{ }
|
||||||
|
};
|
||||||
|
|
||||||
static void af9015_set_remote_config(struct usb_device *udev,
|
static void af9015_set_remote_config(struct usb_device *udev,
|
||||||
struct dvb_usb_device_properties *props)
|
struct dvb_usb_device_properties *props)
|
||||||
{
|
{
|
||||||
|
const struct af9015_setup *table = NULL;
|
||||||
|
|
||||||
if (dvb_usb_af9015_remote) {
|
if (dvb_usb_af9015_remote) {
|
||||||
/* load remote defined as module param */
|
/* load remote defined as module param */
|
||||||
switch (dvb_usb_af9015_remote) {
|
table = af9015_setup_match(dvb_usb_af9015_remote,
|
||||||
case AF9015_REMOTE_A_LINK_DTU_M:
|
af9015_setup_modparam);
|
||||||
props->rc_key_map =
|
|
||||||
af9015_rc_keys_a_link;
|
|
||||||
props->rc_key_map_size =
|
|
||||||
ARRAY_SIZE(af9015_rc_keys_a_link);
|
|
||||||
af9015_config.ir_table = af9015_ir_table_a_link;
|
|
||||||
af9015_config.ir_table_size =
|
|
||||||
ARRAY_SIZE(af9015_ir_table_a_link);
|
|
||||||
break;
|
|
||||||
case AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3:
|
|
||||||
props->rc_key_map =
|
|
||||||
af9015_rc_keys_msi;
|
|
||||||
props->rc_key_map_size =
|
|
||||||
ARRAY_SIZE(af9015_rc_keys_msi);
|
|
||||||
af9015_config.ir_table = af9015_ir_table_msi;
|
|
||||||
af9015_config.ir_table_size =
|
|
||||||
ARRAY_SIZE(af9015_ir_table_msi);
|
|
||||||
break;
|
|
||||||
case AF9015_REMOTE_MYGICTV_U718:
|
|
||||||
props->rc_key_map =
|
|
||||||
af9015_rc_keys_mygictv;
|
|
||||||
props->rc_key_map_size =
|
|
||||||
ARRAY_SIZE(af9015_rc_keys_mygictv);
|
|
||||||
af9015_config.ir_table =
|
|
||||||
af9015_ir_table_mygictv;
|
|
||||||
af9015_config.ir_table_size =
|
|
||||||
ARRAY_SIZE(af9015_ir_table_mygictv);
|
|
||||||
break;
|
|
||||||
case AF9015_REMOTE_DIGITTRADE_DVB_T:
|
|
||||||
props->rc_key_map =
|
|
||||||
af9015_rc_keys_digittrade;
|
|
||||||
props->rc_key_map_size =
|
|
||||||
ARRAY_SIZE(af9015_rc_keys_digittrade);
|
|
||||||
af9015_config.ir_table =
|
|
||||||
af9015_ir_table_digittrade;
|
|
||||||
af9015_config.ir_table_size =
|
|
||||||
ARRAY_SIZE(af9015_ir_table_digittrade);
|
|
||||||
break;
|
|
||||||
case AF9015_REMOTE_AVERMEDIA_KS:
|
|
||||||
props->rc_key_map =
|
|
||||||
af9015_rc_keys_avermedia;
|
|
||||||
props->rc_key_map_size =
|
|
||||||
ARRAY_SIZE(af9015_rc_keys_avermedia);
|
|
||||||
af9015_config.ir_table =
|
|
||||||
af9015_ir_table_avermedia_ks;
|
|
||||||
af9015_config.ir_table_size =
|
|
||||||
ARRAY_SIZE(af9015_ir_table_avermedia_ks);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
switch (le16_to_cpu(udev->descriptor.idVendor)) {
|
u16 vendor = le16_to_cpu(udev->descriptor.idVendor);
|
||||||
case USB_VID_LEADTEK:
|
|
||||||
props->rc_key_map =
|
if (vendor == USB_VID_AFATECH) {
|
||||||
af9015_rc_keys_leadtek;
|
/* Check USB manufacturer and product strings and try
|
||||||
props->rc_key_map_size =
|
to determine correct remote in case of chip vendor
|
||||||
ARRAY_SIZE(af9015_rc_keys_leadtek);
|
reference IDs are used.
|
||||||
af9015_config.ir_table =
|
DO NOT ADD ANYTHING NEW HERE. Use hashes instead.
|
||||||
af9015_ir_table_leadtek;
|
*/
|
||||||
af9015_config.ir_table_size =
|
|
||||||
ARRAY_SIZE(af9015_ir_table_leadtek);
|
|
||||||
break;
|
|
||||||
case USB_VID_VISIONPLUS:
|
|
||||||
props->rc_key_map =
|
|
||||||
af9015_rc_keys_twinhan;
|
|
||||||
props->rc_key_map_size =
|
|
||||||
ARRAY_SIZE(af9015_rc_keys_twinhan);
|
|
||||||
af9015_config.ir_table =
|
|
||||||
af9015_ir_table_twinhan;
|
|
||||||
af9015_config.ir_table_size =
|
|
||||||
ARRAY_SIZE(af9015_ir_table_twinhan);
|
|
||||||
break;
|
|
||||||
case USB_VID_KWORLD_2:
|
|
||||||
/* TODO: use correct rc keys */
|
|
||||||
props->rc_key_map =
|
|
||||||
af9015_rc_keys_twinhan;
|
|
||||||
props->rc_key_map_size =
|
|
||||||
ARRAY_SIZE(af9015_rc_keys_twinhan);
|
|
||||||
af9015_config.ir_table = af9015_ir_table_kworld;
|
|
||||||
af9015_config.ir_table_size =
|
|
||||||
ARRAY_SIZE(af9015_ir_table_kworld);
|
|
||||||
break;
|
|
||||||
/* Check USB manufacturer and product strings and try
|
|
||||||
to determine correct remote in case of chip vendor
|
|
||||||
reference IDs are used. */
|
|
||||||
case USB_VID_AFATECH:
|
|
||||||
{
|
|
||||||
char manufacturer[10];
|
char manufacturer[10];
|
||||||
memset(manufacturer, 0, sizeof(manufacturer));
|
memset(manufacturer, 0, sizeof(manufacturer));
|
||||||
usb_string(udev, udev->descriptor.iManufacturer,
|
usb_string(udev, udev->descriptor.iManufacturer,
|
||||||
@ -831,59 +813,33 @@ static void af9015_set_remote_config(struct usb_device *udev,
|
|||||||
if (!strcmp("Geniatech", manufacturer)) {
|
if (!strcmp("Geniatech", manufacturer)) {
|
||||||
/* iManufacturer 1 Geniatech
|
/* iManufacturer 1 Geniatech
|
||||||
iProduct 2 AF9015 */
|
iProduct 2 AF9015 */
|
||||||
props->rc_key_map =
|
table = af9015_setup_match(
|
||||||
af9015_rc_keys_mygictv;
|
AF9015_REMOTE_MYGICTV_U718,
|
||||||
props->rc_key_map_size =
|
af9015_setup_modparam);
|
||||||
ARRAY_SIZE(af9015_rc_keys_mygictv);
|
|
||||||
af9015_config.ir_table =
|
|
||||||
af9015_ir_table_mygictv;
|
|
||||||
af9015_config.ir_table_size =
|
|
||||||
ARRAY_SIZE(af9015_ir_table_mygictv);
|
|
||||||
} else if (!strcmp("MSI", manufacturer)) {
|
} else if (!strcmp("MSI", manufacturer)) {
|
||||||
/* iManufacturer 1 MSI
|
/* iManufacturer 1 MSI
|
||||||
iProduct 2 MSI K-VOX */
|
iProduct 2 MSI K-VOX */
|
||||||
props->rc_key_map =
|
table = af9015_setup_match(
|
||||||
af9015_rc_keys_msi;
|
AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3,
|
||||||
props->rc_key_map_size =
|
af9015_setup_modparam);
|
||||||
ARRAY_SIZE(af9015_rc_keys_msi);
|
|
||||||
af9015_config.ir_table =
|
|
||||||
af9015_ir_table_msi;
|
|
||||||
af9015_config.ir_table_size =
|
|
||||||
ARRAY_SIZE(af9015_ir_table_msi);
|
|
||||||
} else if (udev->descriptor.idProduct ==
|
} else if (udev->descriptor.idProduct ==
|
||||||
cpu_to_le16(USB_PID_TREKSTOR_DVBT)) {
|
cpu_to_le16(USB_PID_TREKSTOR_DVBT)) {
|
||||||
props->rc_key_map =
|
table = &(const struct af9015_setup){ 0,
|
||||||
af9015_rc_keys_trekstor;
|
af9015_rc_keys_trekstor,
|
||||||
props->rc_key_map_size =
|
ARRAY_SIZE(af9015_rc_keys_trekstor),
|
||||||
ARRAY_SIZE(af9015_rc_keys_trekstor);
|
af9015_ir_table_trekstor,
|
||||||
af9015_config.ir_table =
|
ARRAY_SIZE(af9015_ir_table_trekstor)
|
||||||
af9015_ir_table_trekstor;
|
};
|
||||||
af9015_config.ir_table_size =
|
|
||||||
ARRAY_SIZE(af9015_ir_table_trekstor);
|
|
||||||
}
|
}
|
||||||
break;
|
} else
|
||||||
}
|
table = af9015_setup_match(vendor, af9015_setup_usbids);
|
||||||
case USB_VID_AVERMEDIA:
|
}
|
||||||
props->rc_key_map =
|
|
||||||
af9015_rc_keys_avermedia;
|
if (table) {
|
||||||
props->rc_key_map_size =
|
props->rc_key_map = table->rc_key_map;
|
||||||
ARRAY_SIZE(af9015_rc_keys_avermedia);
|
props->rc_key_map_size = table->rc_key_map_size;
|
||||||
af9015_config.ir_table =
|
af9015_config.ir_table = table->ir_table;
|
||||||
af9015_ir_table_avermedia;
|
af9015_config.ir_table_size = table->ir_table_size;
|
||||||
af9015_config.ir_table_size =
|
|
||||||
ARRAY_SIZE(af9015_ir_table_avermedia);
|
|
||||||
break;
|
|
||||||
case USB_VID_MSI_2:
|
|
||||||
props->rc_key_map =
|
|
||||||
af9015_rc_keys_msi_digivox_iii;
|
|
||||||
props->rc_key_map_size =
|
|
||||||
ARRAY_SIZE(af9015_rc_keys_msi_digivox_iii);
|
|
||||||
af9015_config.ir_table =
|
|
||||||
af9015_ir_table_msi_digivox_iii;
|
|
||||||
af9015_config.ir_table_size =
|
|
||||||
ARRAY_SIZE(af9015_ir_table_msi_digivox_iii);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user