2010-01-13 20:00:12

by Jiri Slaby

[permalink] [raw]
Subject: [PATCH 1/1] media: dvb-usb/af9015, add IR support for digivox mini II

MSI digivox mini II works even with remote=2 module parameter. Check
for manufacturer and if it is Afatech, use af9015_ir_table_msi and
af9015_rc_keys_msi.

The device itself is 15a4:9016.

Signed-off-by: Jiri Slaby <[email protected]>
Cc: Antti Palosaari <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: [email protected]
---
drivers/media/dvb/dvb-usb/af9015.c | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/af9015.c b/drivers/media/dvb/dvb-usb/af9015.c
index 8b60a60..f0d5731 100644
--- a/drivers/media/dvb/dvb-usb/af9015.c
+++ b/drivers/media/dvb/dvb-usb/af9015.c
@@ -835,9 +835,15 @@ static int af9015_read_config(struct usb_device *udev)
af9015_ir_table_mygictv;
af9015_config.ir_table_size =
ARRAY_SIZE(af9015_ir_table_mygictv);
- } else if (!strcmp("MSI", manufacturer)) {
- /* iManufacturer 1 MSI
- iProduct 2 MSI K-VOX */
+ } else if (!strcmp("MSI", manufacturer) ||
+ !strcmp("Afatech", manufacturer)) {
+ /*
+ iManufacturer 1 MSI
+ iProduct 2 MSI K-VOX
+ iManufacturer 1 Afatech
+ iProduct 2 DVB-T 2
+ */
+
af9015_properties[i].rc_key_map =
af9015_rc_keys_msi;
af9015_properties[i].rc_key_map_size =
--
1.6.5.7


2010-01-14 19:09:38

by Antti Palosaari

[permalink] [raw]
Subject: Re: [PATCH 1/1] media: dvb-usb/af9015, add IR support for digivox mini II

On 01/13/2010 10:00 PM, Jiri Slaby wrote:
> MSI digivox mini II works even with remote=2 module parameter. Check
> for manufacturer and if it is Afatech, use af9015_ir_table_msi and
> af9015_rc_keys_msi.
>
> The device itself is 15a4:9016.

NACK

Device ID 15a4:9016 is reference design ID and it is used by vary many
devices. Also manufacturer string "Afatech" is chipset default one. This
leads MSI remote in question configured for many devices using default /
reference values which I don't like good idea. Strings and other USB
settings are stored to the device eeprom.

Empia (em28xx) driver uses eeprom hashing for identifying reference ID
devices. This approach is better because it uses all eeprom bytes. I
hope you could implement similar eeprom hashing to af9015.

regards
Antti
--
http://palosaari.fi/

2010-01-22 15:11:07

by Jiri Slaby

[permalink] [raw]
Subject: [PATCH 4/4] media: dvb/af9015, add hashes support

So as a final patch, add support for hash and one hash entry
for MSI digi vox mini II:
iManufacturer 1 Afatech
iProduct 2 DVB-T 2
iSerial 3 010101010600001

It is now handled with proper IR and key map tables.

Signed-off-by: Jiri Slaby <[email protected]>
Cc: Antti Palosaari <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: [email protected]

Signed-off-by: Jiri Slaby <[email protected]>
---
drivers/media/dvb/dvb-usb/af9015.c | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/af9015.c b/drivers/media/dvb/dvb-usb/af9015.c
index 796f9d5..650c913 100644
--- a/drivers/media/dvb/dvb-usb/af9015.c
+++ b/drivers/media/dvb/dvb-usb/af9015.c
@@ -788,6 +788,13 @@ static const struct af9015_setup af9015_setup_usbids[] = {
{ }
};

+static const struct af9015_setup af9015_setup_hashes[] = {
+ { 0xb8feb708,
+ af9015_rc_keys_msi, ARRAY_SIZE(af9015_rc_keys_msi),
+ af9015_ir_table_msi, ARRAY_SIZE(af9015_ir_table_msi) },
+ { }
+};
+
static void af9015_set_remote_config(struct usb_device *udev,
struct dvb_usb_device_properties *props)
{
@@ -800,7 +807,10 @@ static void af9015_set_remote_config(struct usb_device *udev,
} else {
u16 vendor = le16_to_cpu(udev->descriptor.idVendor);

- if (vendor == USB_VID_AFATECH) {
+ table = af9015_setup_match(af9015_config.eeprom_sum,
+ af9015_setup_hashes);
+
+ if (!table && vendor == USB_VID_AFATECH) {
/* Check USB manufacturer and product strings and try
to determine correct remote in case of chip vendor
reference IDs are used.
@@ -831,7 +841,7 @@ static void af9015_set_remote_config(struct usb_device *udev,
ARRAY_SIZE(af9015_ir_table_trekstor)
};
}
- } else
+ } else if (!table)
table = af9015_setup_match(vendor, af9015_setup_usbids);
}

--
1.6.5.7

2010-01-22 15:11:18

by Jiri Slaby

[permalink] [raw]
Subject: [PATCH 3/4] 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 <[email protected]>
Cc: Antti Palosaari <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: [email protected]
---
drivers/media/dvb/dvb-usb/af9015.c | 222 ++++++++++++++---------------------
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 adba90d..796f9d5 100644
--- a/drivers/media/dvb/dvb-usb/af9015.c
+++ b/drivers/media/dvb/dvb-usb/af9015.c
@@ -732,98 +732,80 @@ error:
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,
struct dvb_usb_device_properties *props)
{
+ const struct af9015_setup *table = NULL;
+
if (dvb_usb_af9015_remote) {
/* load remote defined as module param */
- switch (dvb_usb_af9015_remote) {
- case AF9015_REMOTE_A_LINK_DTU_M:
- 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;
- }
+ table = af9015_setup_match(dvb_usb_af9015_remote,
+ af9015_setup_modparam);
} else {
- switch (le16_to_cpu(udev->descriptor.idVendor)) {
- case USB_VID_LEADTEK:
- props->rc_key_map =
- af9015_rc_keys_leadtek;
- props->rc_key_map_size =
- ARRAY_SIZE(af9015_rc_keys_leadtek);
- af9015_config.ir_table =
- 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:
- {
+ u16 vendor = le16_to_cpu(udev->descriptor.idVendor);
+
+ if (vendor == USB_VID_AFATECH) {
+ /* Check USB manufacturer and product strings and try
+ to determine correct remote in case of chip vendor
+ reference IDs are used.
+ DO NOT ADD ANYTHING NEW HERE. Use hashes instead.
+ */
char manufacturer[10];
memset(manufacturer, 0, sizeof(manufacturer));
usb_string(udev, udev->descriptor.iManufacturer,
@@ -831,59 +813,33 @@ static void af9015_set_remote_config(struct usb_device *udev,
if (!strcmp("Geniatech", manufacturer)) {
/* iManufacturer 1 Geniatech
iProduct 2 AF9015 */
- 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);
+ table = af9015_setup_match(
+ AF9015_REMOTE_MYGICTV_U718,
+ af9015_setup_modparam);
} else if (!strcmp("MSI", manufacturer)) {
/* iManufacturer 1 MSI
iProduct 2 MSI K-VOX */
- 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);
+ table = af9015_setup_match(
+ AF9015_REMOTE_MSI_DIGIVOX_MINI_II_V3,
+ af9015_setup_modparam);
} else if (udev->descriptor.idProduct ==
cpu_to_le16(USB_PID_TREKSTOR_DVBT)) {
- props->rc_key_map =
- af9015_rc_keys_trekstor;
- props->rc_key_map_size =
- ARRAY_SIZE(af9015_rc_keys_trekstor);
- af9015_config.ir_table =
- af9015_ir_table_trekstor;
- af9015_config.ir_table_size =
- ARRAY_SIZE(af9015_ir_table_trekstor);
+ table = &(const struct af9015_setup){ 0,
+ af9015_rc_keys_trekstor,
+ ARRAY_SIZE(af9015_rc_keys_trekstor),
+ af9015_ir_table_trekstor,
+ ARRAY_SIZE(af9015_ir_table_trekstor)
+ };
}
- break;
- }
- case USB_VID_AVERMEDIA:
- 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;
- 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;
- }
+ } else
+ table = af9015_setup_match(vendor, af9015_setup_usbids);
+ }
+
+ if (table) {
+ props->rc_key_map = table->rc_key_map;
+ props->rc_key_map_size = table->rc_key_map_size;
+ af9015_config.ir_table = table->ir_table;
+ af9015_config.ir_table_size = table->ir_table_size;
}
}

--
1.6.5.7

2010-01-22 15:11:20

by Jiri Slaby

[permalink] [raw]
Subject: [PATCH 2/4] 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: Jiri Slaby <[email protected]>
Cc: Antti Palosaari <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: [email protected]
---
drivers/media/dvb/dvb-usb/af9015.c | 305 ++++++++++++++++++-----------------
1 files changed, 157 insertions(+), 148 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/af9015.c b/drivers/media/dvb/dvb-usb/af9015.c
index 616b3ba..adba90d 100644
--- a/drivers/media/dvb/dvb-usb/af9015.c
+++ b/drivers/media/dvb/dvb-usb/af9015.c
@@ -732,12 +732,166 @@ error:
return ret;
}

+static void af9015_set_remote_config(struct usb_device *udev,
+ struct dvb_usb_device_properties *props)
+{
+ if (dvb_usb_af9015_remote) {
+ /* load remote defined as module param */
+ switch (dvb_usb_af9015_remote) {
+ case AF9015_REMOTE_A_LINK_DTU_M:
+ 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 {
+ switch (le16_to_cpu(udev->descriptor.idVendor)) {
+ case USB_VID_LEADTEK:
+ props->rc_key_map =
+ af9015_rc_keys_leadtek;
+ props->rc_key_map_size =
+ ARRAY_SIZE(af9015_rc_keys_leadtek);
+ af9015_config.ir_table =
+ 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];
+ memset(manufacturer, 0, sizeof(manufacturer));
+ usb_string(udev, udev->descriptor.iManufacturer,
+ manufacturer, sizeof(manufacturer));
+ if (!strcmp("Geniatech", manufacturer)) {
+ /* iManufacturer 1 Geniatech
+ iProduct 2 AF9015 */
+ 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);
+ } else if (!strcmp("MSI", manufacturer)) {
+ /* iManufacturer 1 MSI
+ iProduct 2 MSI K-VOX */
+ 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);
+ } else if (udev->descriptor.idProduct ==
+ cpu_to_le16(USB_PID_TREKSTOR_DVBT)) {
+ props->rc_key_map =
+ af9015_rc_keys_trekstor;
+ props->rc_key_map_size =
+ ARRAY_SIZE(af9015_rc_keys_trekstor);
+ af9015_config.ir_table =
+ af9015_ir_table_trekstor;
+ af9015_config.ir_table_size =
+ ARRAY_SIZE(af9015_ir_table_trekstor);
+ }
+ break;
+ }
+ case USB_VID_AVERMEDIA:
+ 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;
+ 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;
+ }
+ }
+}
+
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};
- char manufacturer[10];

/* IR remote controller */
req.addr = AF9015_EEPROM_IR_MODE;
@@ -759,153 +913,8 @@ static int af9015_read_config(struct usb_device *udev)
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 */
- switch (dvb_usb_af9015_remote) {
- case AF9015_REMOTE_A_LINK_DTU_M:
- af9015_properties[i].rc_key_map =
- af9015_rc_keys_a_link;
- af9015_properties[i].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 =
- af9015_rc_keys_msi;
- af9015_properties[i].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 =
- af9015_rc_keys_mygictv;
- af9015_properties[i].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:
- af9015_properties[i].rc_key_map =
- af9015_rc_keys_digittrade;
- af9015_properties[i].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:
- af9015_properties[i].rc_key_map =
- af9015_rc_keys_avermedia;
- af9015_properties[i].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 {
- switch (le16_to_cpu(udev->descriptor.idVendor)) {
- case USB_VID_LEADTEK:
- af9015_properties[i].rc_key_map =
- af9015_rc_keys_leadtek;
- af9015_properties[i].rc_key_map_size =
- ARRAY_SIZE(af9015_rc_keys_leadtek);
- af9015_config.ir_table =
- af9015_ir_table_leadtek;
- af9015_config.ir_table_size =
- ARRAY_SIZE(af9015_ir_table_leadtek);
- break;
- case USB_VID_VISIONPLUS:
- af9015_properties[i].rc_key_map =
- af9015_rc_keys_twinhan;
- af9015_properties[i].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 */
- af9015_properties[i].rc_key_map =
- af9015_rc_keys_twinhan;
- af9015_properties[i].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:
- 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 =
- af9015_rc_keys_mygictv;
- af9015_properties[i].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);
- } else if (!strcmp("MSI", manufacturer)) {
- /* iManufacturer 1 MSI
- iProduct 2 MSI K-VOX */
- af9015_properties[i].rc_key_map =
- af9015_rc_keys_msi;
- af9015_properties[i].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);
- } else if (udev->descriptor.idProduct ==
- cpu_to_le16(USB_PID_TREKSTOR_DVBT)) {
- af9015_properties[i].rc_key_map =
- af9015_rc_keys_trekstor;
- af9015_properties[i].rc_key_map_size =
- ARRAY_SIZE(af9015_rc_keys_trekstor);
- af9015_config.ir_table =
- af9015_ir_table_trekstor;
- af9015_config.ir_table_size =
- ARRAY_SIZE(af9015_ir_table_trekstor);
- }
- break;
- case USB_VID_AVERMEDIA:
- af9015_properties[i].rc_key_map =
- af9015_rc_keys_avermedia;
- af9015_properties[i].rc_key_map_size =
- ARRAY_SIZE(af9015_rc_keys_avermedia);
- af9015_config.ir_table =
- af9015_ir_table_avermedia;
- af9015_config.ir_table_size =
- ARRAY_SIZE(af9015_ir_table_avermedia);
- break;
- case USB_VID_MSI_2:
- af9015_properties[i].rc_key_map =
- af9015_rc_keys_msi_digivox_iii;
- af9015_properties[i].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;
- }
- }
+ } else
+ af9015_set_remote_config(udev, &af9015_properties[i]);
}

/* TS mode - one or two receivers */
--
1.6.5.7

2010-01-22 15:11:36

by Jiri Slaby

[permalink] [raw]
Subject: Re: [PATCH 1/1] media: dvb-usb/af9015, add IR support for digivox mini II

On 01/14/2010 08:09 PM, Antti Palosaari wrote:
> Device ID 15a4:9016 is reference design ID and it is used by vary many
> devices. Also manufacturer string "Afatech" is chipset default one. This
> leads MSI remote in question configured for many devices using default /
> reference values which I don't like good idea. Strings and other USB
> settings are stored to the device eeprom.

What do you think about the following patches?

thanks,
--
js

2010-01-22 15:11:59

by Jiri Slaby

[permalink] [raw]
Subject: [PATCH 1/4] media: dvb/af9015, implement eeprom hashing

This will be useful for matching of IR tables later.

We read the eeprom anyway for dumping. Switch the dumping to
print_hex_dump_bytes and compute hash above that by
hash = 0;
for (u32 VAL) in (eeprom):
hash *= GOLDEN_RATIO_PRIME_32
hash += VAL; // while preserving endinaness

The computation is moved earlier to the flow, namely from
af9015_af9013_frontend_attach to af9015_read_config, so that
we can access the sum in af9015_read_config already.

Signed-off-by: Jiri Slaby <[email protected]>
Cc: Antti Palosaari <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: [email protected]
---
drivers/media/dvb/dvb-usb/af9015.c | 65 +++++++++++++++++++++++------------
drivers/media/dvb/dvb-usb/af9015.h | 1 +
2 files changed, 44 insertions(+), 22 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/af9015.c b/drivers/media/dvb/dvb-usb/af9015.c
index a365c05..616b3ba 100644
--- a/drivers/media/dvb/dvb-usb/af9015.c
+++ b/drivers/media/dvb/dvb-usb/af9015.c
@@ -21,6 +21,8 @@
*
*/

+#include <linux/hash.h>
+
#include "af9015.h"
#include "af9013.h"
#include "mt2060.h"
@@ -553,26 +555,45 @@ exit:
return ret;
}

-/* dump eeprom */
-static int af9015_eeprom_dump(struct dvb_usb_device *d)
+/* hash (and dump) eeprom */
+static int af9015_eeprom_hash(struct usb_device *udev)
{
- u8 reg, val;
+ static const unsigned int eeprom_size = 256;
+ unsigned int reg;
+ int ret;
+ u8 val, *eeprom;
+ struct req_t req = {READ_I2C, AF9015_I2C_EEPROM, 0, 0, 1, 1, &val};

- for (reg = 0; ; reg++) {
- if (reg % 16 == 0) {
- if (reg)
- deb_info(KERN_CONT "\n");
- deb_info(KERN_DEBUG "%02x:", reg);
- }
- if (af9015_read_reg_i2c(d, AF9015_I2C_EEPROM, reg, &val) == 0)
- deb_info(KERN_CONT " %02x", val);
- else
- deb_info(KERN_CONT " --");
- if (reg == 0xff)
- break;
+ eeprom = kmalloc(eeprom_size, GFP_KERNEL);
+ if (eeprom == NULL)
+ return -ENOMEM;
+
+ for (reg = 0; reg < eeprom_size; reg++) {
+ req.addr = reg;
+ ret = af9015_rw_udev(udev, &req);
+ if (ret)
+ goto free;
+ eeprom[reg] = val;
}
- deb_info(KERN_CONT "\n");
- return 0;
+
+ if (dvb_usb_af9015_debug & 0x01)
+ print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, eeprom,
+ eeprom_size);
+
+ BUG_ON(eeprom_size % 4);
+
+ af9015_config.eeprom_sum = 0;
+ for (reg = 0; reg < eeprom_size / sizeof(u32); reg++) {
+ af9015_config.eeprom_sum *= GOLDEN_RATIO_PRIME_32;
+ af9015_config.eeprom_sum += le32_to_cpu(((u32 *)eeprom)[reg]);
+ }
+
+ deb_info("%s: eeprom sum=%.8x\n", __func__, af9015_config.eeprom_sum);
+
+ ret = 0;
+free:
+ kfree(eeprom);
+ return ret;
}

static int af9015_download_ir_table(struct dvb_usb_device *d)
@@ -728,6 +749,11 @@ static int af9015_read_config(struct usb_device *udev)
}
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) {
@@ -1125,11 +1151,6 @@ static int af9015_af9013_frontend_attach(struct dvb_usb_adapter *adap)

deb_info("%s: init I2C\n", __func__);
ret = af9015_i2c_init(adap->dev);
-
- /* dump eeprom (debug) */
- ret = af9015_eeprom_dump(adap->dev);
- if (ret)
- return ret;
} else {
/* select I2C adapter */
i2c_adap = &state->i2c_adap;
diff --git a/drivers/media/dvb/dvb-usb/af9015.h b/drivers/media/dvb/dvb-usb/af9015.h
index 931c851..ef36b18 100644
--- a/drivers/media/dvb/dvb-usb/af9015.h
+++ b/drivers/media/dvb/dvb-usb/af9015.h
@@ -107,6 +107,7 @@ struct af9015_config {
u16 mt2060_if1[2];
u16 firmware_size;
u16 firmware_checksum;
+ u32 eeprom_sum;
u8 *ir_table;
u16 ir_table_size;
};
--
1.6.5.7

2010-01-24 16:16:36

by Antti Palosaari

[permalink] [raw]
Subject: Re: [PATCH 1/4] media: dvb/af9015, implement eeprom hashing

Hei,
Comments below.

On 01/22/2010 05:10 PM, Jiri Slaby wrote:
> We read the eeprom anyway for dumping. Switch the dumping to
> print_hex_dump_bytes and compute hash above that by
> hash = 0;
> for (u32 VAL) in (eeprom):
> hash *= GOLDEN_RATIO_PRIME_32
> hash += VAL; // while preserving endinaness
>
> The computation is moved earlier to the flow, namely from
> af9015_af9013_frontend_attach to af9015_read_config, so that
> we can access the sum in af9015_read_config already.
>
> Signed-off-by: Jiri Slaby<[email protected]>
> Cc: Antti Palosaari<[email protected]>
> Cc: Mauro Carvalho Chehab<[email protected]>
> Cc: [email protected]
> ---
> drivers/media/dvb/dvb-usb/af9015.c | 65 +++++++++++++++++++++++------------
> drivers/media/dvb/dvb-usb/af9015.h | 1 +
> 2 files changed, 44 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/media/dvb/dvb-usb/af9015.c b/drivers/media/dvb/dvb-usb/af9015.c
> index a365c05..616b3ba 100644
> --- a/drivers/media/dvb/dvb-usb/af9015.c
> +++ b/drivers/media/dvb/dvb-usb/af9015.c
> @@ -21,6 +21,8 @@
> *
> */
>
> +#include<linux/hash.h>
> +
> #include "af9015.h"
> #include "af9013.h"
> #include "mt2060.h"
> @@ -553,26 +555,45 @@ exit:
> return ret;
> }
>
> -/* dump eeprom */
> -static int af9015_eeprom_dump(struct dvb_usb_device *d)
> +/* hash (and dump) eeprom */
> +static int af9015_eeprom_hash(struct usb_device *udev)
> {
> - u8 reg, val;
> + static const unsigned int eeprom_size = 256;
> + unsigned int reg;
> + int ret;
> + u8 val, *eeprom;
> + struct req_t req = {READ_I2C, AF9015_I2C_EEPROM, 0, 0, 1, 1,&val};
>
> - for (reg = 0; ; reg++) {
> - if (reg % 16 == 0) {
> - if (reg)
> - deb_info(KERN_CONT "\n");
> - deb_info(KERN_DEBUG "%02x:", reg);
> - }
> - if (af9015_read_reg_i2c(d, AF9015_I2C_EEPROM, reg,&val) == 0)
> - deb_info(KERN_CONT " %02x", val);
> - else
> - deb_info(KERN_CONT " --");
> - if (reg == 0xff)
> - break;
> + eeprom = kmalloc(eeprom_size, GFP_KERNEL);
> + if (eeprom == NULL)
> + return -ENOMEM;
> +
> + for (reg = 0; reg< eeprom_size; reg++) {
> + req.addr = reg;
> + ret = af9015_rw_udev(udev,&req);
> + if (ret)
> + goto free;
> + eeprom[reg] = val;
> }
> - deb_info(KERN_CONT "\n");
> - return 0;
> +
> + if (dvb_usb_af9015_debug& 0x01)
> + print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, eeprom,
> + eeprom_size);
> +
> + BUG_ON(eeprom_size % 4);
> +
> + af9015_config.eeprom_sum = 0;
> + for (reg = 0; reg< eeprom_size / sizeof(u32); reg++) {
> + af9015_config.eeprom_sum *= GOLDEN_RATIO_PRIME_32;
> + af9015_config.eeprom_sum += le32_to_cpu(((u32 *)eeprom)[reg]);
> + }
> +
> + deb_info("%s: eeprom sum=%.8x\n", __func__, af9015_config.eeprom_sum);

Does this sum contain all 256 bytes from EEPROM? 256/4 is 64.

regards
Antti
--
http://palosaari.fi/

2010-01-24 16:35:19

by Jiri Slaby

[permalink] [raw]
Subject: Re: [PATCH 1/4] media: dvb/af9015, implement eeprom hashing

On 01/24/2010 05:16 PM, Antti Palosaari wrote:
>> + af9015_config.eeprom_sum = 0;
>> + for (reg = 0; reg< eeprom_size / sizeof(u32); reg++) {
>> + af9015_config.eeprom_sum *= GOLDEN_RATIO_PRIME_32;
>> + af9015_config.eeprom_sum += le32_to_cpu(((u32 *)eeprom)[reg]);
>> + }
>> +
>> + deb_info("%s: eeprom sum=%.8x\n", __func__,
>> af9015_config.eeprom_sum);
>
> Does this sum contain all 256 bytes from EEPROM? 256/4 is 64.

Yes it does. It is computed as a hashed sum of 32-bit numbers (4 bytes)
-- speed (does not matter) and larger space of hashes. Hence the
division by 4. The cast does the trick: ((u32 *)eeprom)[reg] -- reg
index is on a 4-byte basis.

regards,
--
js

2010-01-24 23:52:52

by Antti Palosaari

[permalink] [raw]
Subject: Re: [PATCH 1/4] media: dvb/af9015, implement eeprom hashing

On 01/24/2010 06:35 PM, Jiri Slaby wrote:
> On 01/24/2010 05:16 PM, Antti Palosaari wrote:
>>> + af9015_config.eeprom_sum = 0;
>>> + for (reg = 0; reg< eeprom_size / sizeof(u32); reg++) {
>>> + af9015_config.eeprom_sum *= GOLDEN_RATIO_PRIME_32;
>>> + af9015_config.eeprom_sum += le32_to_cpu(((u32 *)eeprom)[reg]);
>>> + }
>>> +
>>> + deb_info("%s: eeprom sum=%.8x\n", __func__,
>>> af9015_config.eeprom_sum);
>>
>> Does this sum contain all 256 bytes from EEPROM? 256/4 is 64.
>
> Yes it does. It is computed as a hashed sum of 32-bit numbers (4 bytes)
> -- speed (does not matter) and larger space of hashes. Hence the
> division by 4. The cast does the trick: ((u32 *)eeprom)[reg] -- reg
> index is on a 4-byte basis.


OK, true. Anyhow, I don't know if this hashing formula is good enough -
changing it later could be really pain. I compared it to the one used
for em28xx driver and it was different. Could someone with better
knowledge check that?

Generally it is good and ready for submission.

Acked-by: Antti Palosaari <[email protected]>

regards
Antti
--
http://palosaari.fi/

2010-01-24 23:54:12

by Antti Palosaari

[permalink] [raw]
Subject: Re: [PATCH 2/4] media: dvb/af9015, factor out remote setting

On 01/22/2010 05:10 PM, Jiri Slaby wrote:
> This is just a code shuffle without functional changes. For easier
> review of later changes, i.e. preparation.
>
> Signed-off-by: Jiri Slaby<[email protected]>
> Cc: Antti Palosaari<[email protected]>
> Cc: Mauro Carvalho Chehab<[email protected]>
> Cc: [email protected]

Acked-by: Antti Palosaari <[email protected]>

--
http://palosaari.fi/

2010-01-24 23:54:56

by Antti Palosaari

[permalink] [raw]
Subject: Re: [PATCH 3/4] media: dvb/af9015, refactor remote setting

On 01/22/2010 05:10 PM, Jiri Slaby wrote:
> 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<[email protected]>
> Cc: Antti Palosaari<[email protected]>
> Cc: Mauro Carvalho Chehab<[email protected]>
> Cc: [email protected]
> ---
> drivers/media/dvb/dvb-usb/af9015.c | 222 ++++++++++++++---------------------
> 1 files changed, 89 insertions(+), 133 deletions(-)

Acked-by: Antti Palosaari <[email protected]>
--
http://palosaari.fi/

2010-01-24 23:55:45

by Antti Palosaari

[permalink] [raw]
Subject: Re: [PATCH 4/4] media: dvb/af9015, add hashes support

On 01/22/2010 05:10 PM, Jiri Slaby wrote:
> So as a final patch, add support for hash and one hash entry
> for MSI digi vox mini II:
> iManufacturer 1 Afatech
> iProduct 2 DVB-T 2
> iSerial 3 010101010600001
>
> It is now handled with proper IR and key map tables.
>
> Signed-off-by: Jiri Slaby<[email protected]>
> Cc: Antti Palosaari<[email protected]>
> Cc: Mauro Carvalho Chehab<[email protected]>
> Cc: [email protected]
>
> Signed-off-by: Jiri Slaby<[email protected]>
> ---
> drivers/media/dvb/dvb-usb/af9015.c | 14 ++++++++++++--
> 1 files changed, 12 insertions(+), 2 deletions(-)

Acked-by: Antti Palosaari <[email protected]>
--
http://palosaari.fi/