Commit 634d2d75 authored by Jiri Slaby's avatar Jiri Slaby Committed by Mauro Carvalho Chehab

V4L/DVB: media: dvb/af9015, factor out remote setting

This is just a code shuffle without functional changes. For easier
review of later changes, i.e. preparation.
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
Acked-by: default avatarAntti Palosaari <crope@iki.fi>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 6c614044
......@@ -732,58 +732,34 @@ static int af9015_download_firmware(struct usb_device *udev,
return ret;
}
static int af9015_read_config(struct usb_device *udev)
static void af9015_set_remote_config(struct usb_device *udev,
struct dvb_usb_device_properties *props)
{
int ret;
u8 val, i, offset = 0;
struct req_t req = {READ_I2C, AF9015_I2C_EEPROM, 0, 0, 1, 1, &val};
char manufacturer[10];
/* IR remote controller */
req.addr = AF9015_EEPROM_IR_MODE;
/* first message will timeout often due to possible hw bug */
for (i = 0; i < 4; i++) {
ret = af9015_rw_udev(udev, &req);
if (!ret)
break;
}
if (ret)
goto error;
ret = af9015_eeprom_hash(udev);
if (ret)
goto error;
deb_info("%s: IR mode:%d\n", __func__, val);
for (i = 0; i < af9015_properties_count; i++) {
if (val == AF9015_IR_MODE_DISABLED) {
af9015_properties[i].rc_key_map = NULL;
af9015_properties[i].rc_key_map_size = 0;
} else if (dvb_usb_af9015_remote) {
if (dvb_usb_af9015_remote) {
/* load remote defined as module param */
switch (dvb_usb_af9015_remote) {
case AF9015_REMOTE_A_LINK_DTU_M:
af9015_properties[i].rc_key_map =
props->rc_key_map =
af9015_rc_keys_a_link;
af9015_properties[i].rc_key_map_size =
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:
af9015_properties[i].rc_key_map =
props->rc_key_map =
af9015_rc_keys_msi;
af9015_properties[i].rc_key_map_size =
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:
af9015_properties[i].rc_key_map =
props->rc_key_map =
af9015_rc_keys_mygictv;
af9015_properties[i].rc_key_map_size =
props->rc_key_map_size =
ARRAY_SIZE(af9015_rc_keys_mygictv);
af9015_config.ir_table =
af9015_ir_table_mygictv;
......@@ -791,9 +767,9 @@ static int af9015_read_config(struct usb_device *udev)
ARRAY_SIZE(af9015_ir_table_mygictv);
break;
case AF9015_REMOTE_DIGITTRADE_DVB_T:
af9015_properties[i].rc_key_map =
props->rc_key_map =
af9015_rc_keys_digittrade;
af9015_properties[i].rc_key_map_size =
props->rc_key_map_size =
ARRAY_SIZE(af9015_rc_keys_digittrade);
af9015_config.ir_table =
af9015_ir_table_digittrade;
......@@ -801,9 +777,9 @@ static int af9015_read_config(struct usb_device *udev)
ARRAY_SIZE(af9015_ir_table_digittrade);
break;
case AF9015_REMOTE_AVERMEDIA_KS:
af9015_properties[i].rc_key_map =
props->rc_key_map =
af9015_rc_keys_avermedia;
af9015_properties[i].rc_key_map_size =
props->rc_key_map_size =
ARRAY_SIZE(af9015_rc_keys_avermedia);
af9015_config.ir_table =
af9015_ir_table_avermedia_ks;
......@@ -814,9 +790,9 @@ static int af9015_read_config(struct usb_device *udev)
} else {
switch (le16_to_cpu(udev->descriptor.idVendor)) {
case USB_VID_LEADTEK:
af9015_properties[i].rc_key_map =
props->rc_key_map =
af9015_rc_keys_leadtek;
af9015_properties[i].rc_key_map_size =
props->rc_key_map_size =
ARRAY_SIZE(af9015_rc_keys_leadtek);
af9015_config.ir_table =
af9015_ir_table_leadtek;
......@@ -824,9 +800,9 @@ static int af9015_read_config(struct usb_device *udev)
ARRAY_SIZE(af9015_ir_table_leadtek);
break;
case USB_VID_VISIONPLUS:
af9015_properties[i].rc_key_map =
props->rc_key_map =
af9015_rc_keys_twinhan;
af9015_properties[i].rc_key_map_size =
props->rc_key_map_size =
ARRAY_SIZE(af9015_rc_keys_twinhan);
af9015_config.ir_table =
af9015_ir_table_twinhan;
......@@ -835,9 +811,9 @@ static int af9015_read_config(struct usb_device *udev)
break;
case USB_VID_KWORLD_2:
/* TODO: use correct rc keys */
af9015_properties[i].rc_key_map =
props->rc_key_map =
af9015_rc_keys_twinhan;
af9015_properties[i].rc_key_map_size =
props->rc_key_map_size =
ARRAY_SIZE(af9015_rc_keys_twinhan);
af9015_config.ir_table = af9015_ir_table_kworld;
af9015_config.ir_table_size =
......@@ -847,15 +823,17 @@ static int af9015_read_config(struct usb_device *udev)
to determine correct remote in case of chip vendor
reference IDs are used. */
case USB_VID_AFATECH:
{
char manufacturer[10];
memset(manufacturer, 0, sizeof(manufacturer));
usb_string(udev, udev->descriptor.iManufacturer,
manufacturer, sizeof(manufacturer));
if (!strcmp("Geniatech", manufacturer)) {
/* iManufacturer 1 Geniatech
iProduct 2 AF9015 */
af9015_properties[i].rc_key_map =
props->rc_key_map =
af9015_rc_keys_mygictv;
af9015_properties[i].rc_key_map_size =
props->rc_key_map_size =
ARRAY_SIZE(af9015_rc_keys_mygictv);
af9015_config.ir_table =
af9015_ir_table_mygictv;
......@@ -864,9 +842,9 @@ static int af9015_read_config(struct usb_device *udev)
} else if (!strcmp("MSI", manufacturer)) {
/* iManufacturer 1 MSI
iProduct 2 MSI K-VOX */
af9015_properties[i].rc_key_map =
props->rc_key_map =
af9015_rc_keys_msi;
af9015_properties[i].rc_key_map_size =
props->rc_key_map_size =
ARRAY_SIZE(af9015_rc_keys_msi);
af9015_config.ir_table =
af9015_ir_table_msi;
......@@ -874,9 +852,9 @@ static int af9015_read_config(struct usb_device *udev)
ARRAY_SIZE(af9015_ir_table_msi);
} else if (udev->descriptor.idProduct ==
cpu_to_le16(USB_PID_TREKSTOR_DVBT)) {
af9015_properties[i].rc_key_map =
props->rc_key_map =
af9015_rc_keys_trekstor;
af9015_properties[i].rc_key_map_size =
props->rc_key_map_size =
ARRAY_SIZE(af9015_rc_keys_trekstor);
af9015_config.ir_table =
af9015_ir_table_trekstor;
......@@ -884,10 +862,11 @@ static int af9015_read_config(struct usb_device *udev)
ARRAY_SIZE(af9015_ir_table_trekstor);
}
break;
}
case USB_VID_AVERMEDIA:
af9015_properties[i].rc_key_map =
props->rc_key_map =
af9015_rc_keys_avermedia;
af9015_properties[i].rc_key_map_size =
props->rc_key_map_size =
ARRAY_SIZE(af9015_rc_keys_avermedia);
af9015_config.ir_table =
af9015_ir_table_avermedia;
......@@ -895,9 +874,9 @@ static int af9015_read_config(struct usb_device *udev)
ARRAY_SIZE(af9015_ir_table_avermedia);
break;
case USB_VID_MSI_2:
af9015_properties[i].rc_key_map =
props->rc_key_map =
af9015_rc_keys_msi_digivox_iii;
af9015_properties[i].rc_key_map_size =
props->rc_key_map_size =
ARRAY_SIZE(af9015_rc_keys_msi_digivox_iii);
af9015_config.ir_table =
af9015_ir_table_msi_digivox_iii;
......@@ -906,6 +885,36 @@ static int af9015_read_config(struct usb_device *udev)
break;
}
}
}
static int af9015_read_config(struct usb_device *udev)
{
int ret;
u8 val, i, offset = 0;
struct req_t req = {READ_I2C, AF9015_I2C_EEPROM, 0, 0, 1, 1, &val};
/* IR remote controller */
req.addr = AF9015_EEPROM_IR_MODE;
/* first message will timeout often due to possible hw bug */
for (i = 0; i < 4; i++) {
ret = af9015_rw_udev(udev, &req);
if (!ret)
break;
}
if (ret)
goto error;
ret = af9015_eeprom_hash(udev);
if (ret)
goto error;
deb_info("%s: IR mode:%d\n", __func__, val);
for (i = 0; i < af9015_properties_count; i++) {
if (val == AF9015_IR_MODE_DISABLED) {
af9015_properties[i].rc_key_map = NULL;
af9015_properties[i].rc_key_map_size = 0;
} else
af9015_set_remote_config(udev, &af9015_properties[i]);
}
/* TS mode - one or two receivers */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment