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, ...@@ -732,58 +732,34 @@ static int af9015_download_firmware(struct usb_device *udev,
return ret; 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; if (dvb_usb_af9015_remote) {
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) {
/* load remote defined as module param */ /* load remote defined as module param */
switch (dvb_usb_af9015_remote) { switch (dvb_usb_af9015_remote) {
case AF9015_REMOTE_A_LINK_DTU_M: case AF9015_REMOTE_A_LINK_DTU_M:
af9015_properties[i].rc_key_map = props->rc_key_map =
af9015_rc_keys_a_link; af9015_rc_keys_a_link;
af9015_properties[i].rc_key_map_size = props->rc_key_map_size =
ARRAY_SIZE(af9015_rc_keys_a_link); ARRAY_SIZE(af9015_rc_keys_a_link);
af9015_config.ir_table = af9015_ir_table_a_link; af9015_config.ir_table = af9015_ir_table_a_link;
af9015_config.ir_table_size = af9015_config.ir_table_size =
ARRAY_SIZE(af9015_ir_table_a_link); ARRAY_SIZE(af9015_ir_table_a_link);
break; break;
case AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3: case AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3:
af9015_properties[i].rc_key_map = props->rc_key_map =
af9015_rc_keys_msi; af9015_rc_keys_msi;
af9015_properties[i].rc_key_map_size = props->rc_key_map_size =
ARRAY_SIZE(af9015_rc_keys_msi); ARRAY_SIZE(af9015_rc_keys_msi);
af9015_config.ir_table = af9015_ir_table_msi; af9015_config.ir_table = af9015_ir_table_msi;
af9015_config.ir_table_size = af9015_config.ir_table_size =
ARRAY_SIZE(af9015_ir_table_msi); ARRAY_SIZE(af9015_ir_table_msi);
break; break;
case AF9015_REMOTE_MYGICTV_U718: case AF9015_REMOTE_MYGICTV_U718:
af9015_properties[i].rc_key_map = props->rc_key_map =
af9015_rc_keys_mygictv; af9015_rc_keys_mygictv;
af9015_properties[i].rc_key_map_size = props->rc_key_map_size =
ARRAY_SIZE(af9015_rc_keys_mygictv); ARRAY_SIZE(af9015_rc_keys_mygictv);
af9015_config.ir_table = af9015_config.ir_table =
af9015_ir_table_mygictv; af9015_ir_table_mygictv;
...@@ -791,9 +767,9 @@ static int af9015_read_config(struct usb_device *udev) ...@@ -791,9 +767,9 @@ static int af9015_read_config(struct usb_device *udev)
ARRAY_SIZE(af9015_ir_table_mygictv); ARRAY_SIZE(af9015_ir_table_mygictv);
break; break;
case AF9015_REMOTE_DIGITTRADE_DVB_T: case AF9015_REMOTE_DIGITTRADE_DVB_T:
af9015_properties[i].rc_key_map = props->rc_key_map =
af9015_rc_keys_digittrade; af9015_rc_keys_digittrade;
af9015_properties[i].rc_key_map_size = props->rc_key_map_size =
ARRAY_SIZE(af9015_rc_keys_digittrade); ARRAY_SIZE(af9015_rc_keys_digittrade);
af9015_config.ir_table = af9015_config.ir_table =
af9015_ir_table_digittrade; af9015_ir_table_digittrade;
...@@ -801,9 +777,9 @@ static int af9015_read_config(struct usb_device *udev) ...@@ -801,9 +777,9 @@ static int af9015_read_config(struct usb_device *udev)
ARRAY_SIZE(af9015_ir_table_digittrade); ARRAY_SIZE(af9015_ir_table_digittrade);
break; break;
case AF9015_REMOTE_AVERMEDIA_KS: case AF9015_REMOTE_AVERMEDIA_KS:
af9015_properties[i].rc_key_map = props->rc_key_map =
af9015_rc_keys_avermedia; af9015_rc_keys_avermedia;
af9015_properties[i].rc_key_map_size = props->rc_key_map_size =
ARRAY_SIZE(af9015_rc_keys_avermedia); ARRAY_SIZE(af9015_rc_keys_avermedia);
af9015_config.ir_table = af9015_config.ir_table =
af9015_ir_table_avermedia_ks; af9015_ir_table_avermedia_ks;
...@@ -814,9 +790,9 @@ static int af9015_read_config(struct usb_device *udev) ...@@ -814,9 +790,9 @@ static int af9015_read_config(struct usb_device *udev)
} else { } else {
switch (le16_to_cpu(udev->descriptor.idVendor)) { switch (le16_to_cpu(udev->descriptor.idVendor)) {
case USB_VID_LEADTEK: case USB_VID_LEADTEK:
af9015_properties[i].rc_key_map = props->rc_key_map =
af9015_rc_keys_leadtek; af9015_rc_keys_leadtek;
af9015_properties[i].rc_key_map_size = props->rc_key_map_size =
ARRAY_SIZE(af9015_rc_keys_leadtek); ARRAY_SIZE(af9015_rc_keys_leadtek);
af9015_config.ir_table = af9015_config.ir_table =
af9015_ir_table_leadtek; af9015_ir_table_leadtek;
...@@ -824,9 +800,9 @@ static int af9015_read_config(struct usb_device *udev) ...@@ -824,9 +800,9 @@ static int af9015_read_config(struct usb_device *udev)
ARRAY_SIZE(af9015_ir_table_leadtek); ARRAY_SIZE(af9015_ir_table_leadtek);
break; break;
case USB_VID_VISIONPLUS: case USB_VID_VISIONPLUS:
af9015_properties[i].rc_key_map = props->rc_key_map =
af9015_rc_keys_twinhan; af9015_rc_keys_twinhan;
af9015_properties[i].rc_key_map_size = props->rc_key_map_size =
ARRAY_SIZE(af9015_rc_keys_twinhan); ARRAY_SIZE(af9015_rc_keys_twinhan);
af9015_config.ir_table = af9015_config.ir_table =
af9015_ir_table_twinhan; af9015_ir_table_twinhan;
...@@ -835,9 +811,9 @@ static int af9015_read_config(struct usb_device *udev) ...@@ -835,9 +811,9 @@ static int af9015_read_config(struct usb_device *udev)
break; break;
case USB_VID_KWORLD_2: case USB_VID_KWORLD_2:
/* TODO: use correct rc keys */ /* TODO: use correct rc keys */
af9015_properties[i].rc_key_map = props->rc_key_map =
af9015_rc_keys_twinhan; af9015_rc_keys_twinhan;
af9015_properties[i].rc_key_map_size = props->rc_key_map_size =
ARRAY_SIZE(af9015_rc_keys_twinhan); ARRAY_SIZE(af9015_rc_keys_twinhan);
af9015_config.ir_table = af9015_ir_table_kworld; af9015_config.ir_table = af9015_ir_table_kworld;
af9015_config.ir_table_size = af9015_config.ir_table_size =
...@@ -847,15 +823,17 @@ static int af9015_read_config(struct usb_device *udev) ...@@ -847,15 +823,17 @@ static int af9015_read_config(struct usb_device *udev)
to determine correct remote in case of chip vendor to determine correct remote in case of chip vendor
reference IDs are used. */ reference IDs are used. */
case USB_VID_AFATECH: case USB_VID_AFATECH:
{
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,
manufacturer, sizeof(manufacturer)); manufacturer, sizeof(manufacturer));
if (!strcmp("Geniatech", manufacturer)) { if (!strcmp("Geniatech", manufacturer)) {
/* iManufacturer 1 Geniatech /* iManufacturer 1 Geniatech
iProduct 2 AF9015 */ iProduct 2 AF9015 */
af9015_properties[i].rc_key_map = props->rc_key_map =
af9015_rc_keys_mygictv; af9015_rc_keys_mygictv;
af9015_properties[i].rc_key_map_size = props->rc_key_map_size =
ARRAY_SIZE(af9015_rc_keys_mygictv); ARRAY_SIZE(af9015_rc_keys_mygictv);
af9015_config.ir_table = af9015_config.ir_table =
af9015_ir_table_mygictv; af9015_ir_table_mygictv;
...@@ -864,9 +842,9 @@ static int af9015_read_config(struct usb_device *udev) ...@@ -864,9 +842,9 @@ static int af9015_read_config(struct usb_device *udev)
} 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 */
af9015_properties[i].rc_key_map = props->rc_key_map =
af9015_rc_keys_msi; af9015_rc_keys_msi;
af9015_properties[i].rc_key_map_size = props->rc_key_map_size =
ARRAY_SIZE(af9015_rc_keys_msi); ARRAY_SIZE(af9015_rc_keys_msi);
af9015_config.ir_table = af9015_config.ir_table =
af9015_ir_table_msi; af9015_ir_table_msi;
...@@ -874,9 +852,9 @@ static int af9015_read_config(struct usb_device *udev) ...@@ -874,9 +852,9 @@ static int af9015_read_config(struct usb_device *udev)
ARRAY_SIZE(af9015_ir_table_msi); 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)) {
af9015_properties[i].rc_key_map = props->rc_key_map =
af9015_rc_keys_trekstor; af9015_rc_keys_trekstor;
af9015_properties[i].rc_key_map_size = props->rc_key_map_size =
ARRAY_SIZE(af9015_rc_keys_trekstor); ARRAY_SIZE(af9015_rc_keys_trekstor);
af9015_config.ir_table = af9015_config.ir_table =
af9015_ir_table_trekstor; af9015_ir_table_trekstor;
...@@ -884,10 +862,11 @@ static int af9015_read_config(struct usb_device *udev) ...@@ -884,10 +862,11 @@ static int af9015_read_config(struct usb_device *udev)
ARRAY_SIZE(af9015_ir_table_trekstor); ARRAY_SIZE(af9015_ir_table_trekstor);
} }
break; break;
}
case USB_VID_AVERMEDIA: case USB_VID_AVERMEDIA:
af9015_properties[i].rc_key_map = props->rc_key_map =
af9015_rc_keys_avermedia; af9015_rc_keys_avermedia;
af9015_properties[i].rc_key_map_size = props->rc_key_map_size =
ARRAY_SIZE(af9015_rc_keys_avermedia); ARRAY_SIZE(af9015_rc_keys_avermedia);
af9015_config.ir_table = af9015_config.ir_table =
af9015_ir_table_avermedia; af9015_ir_table_avermedia;
...@@ -895,9 +874,9 @@ static int af9015_read_config(struct usb_device *udev) ...@@ -895,9 +874,9 @@ static int af9015_read_config(struct usb_device *udev)
ARRAY_SIZE(af9015_ir_table_avermedia); ARRAY_SIZE(af9015_ir_table_avermedia);
break; break;
case USB_VID_MSI_2: case USB_VID_MSI_2:
af9015_properties[i].rc_key_map = props->rc_key_map =
af9015_rc_keys_msi_digivox_iii; 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); ARRAY_SIZE(af9015_rc_keys_msi_digivox_iii);
af9015_config.ir_table = af9015_config.ir_table =
af9015_ir_table_msi_digivox_iii; af9015_ir_table_msi_digivox_iii;
...@@ -906,6 +885,36 @@ static int af9015_read_config(struct usb_device *udev) ...@@ -906,6 +885,36 @@ static int af9015_read_config(struct usb_device *udev)
break; 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 */ /* 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