aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher R. Palmer <crpalmer@gmail.com>2014-08-25 14:59:34 -0400
committerDan Pasanen <dan.pasanen@gmail.com>2014-08-25 20:47:35 -0500
commit74e34380de750fef5680b644350fe689cdc776e9 (patch)
treef2c00b3ba19b1ac52653501713a67545c361a39d
parentf9d5f6bb61e1119b735549043d9be411b1c69df6 (diff)
jf: consumerir: Convert transmit input from ms to pulses
According to: https://developer.android.com/reference/android/hardware/ConsumerIrManager.html#transmit%28int,%20int[]%29 the pattern is supposed to be in ms. Apparently Samsung and HTC in versions 4.4.2 and earlier of Android were treating this as the number of pulses instead of ms. This is what our HAL is supporting because it mimic'ed what the vendors were doing. However, we should switch to the correct spec of the pattern (ms) and eventually this will cause apps to converge on the right patterns. Currently, this change will break half the existing apps and cause the other half of the apps to stop being broken and to start working. Change-Id: I87cedcc8e0b85d7b96ed63c7d4f82cc53ecb4ecb
-rw-r--r--consumerir/consumerir.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/consumerir/consumerir.c b/consumerir/consumerir.c
index 327beb4..d935118 100644
--- a/consumerir/consumerir.c
+++ b/consumerir/consumerir.c
@@ -47,10 +47,13 @@ static int consumerir_transmit(struct consumerir_device *dev,
/* write the header */
strlen = sprintf(buffer, "%d,", carrier_freq);
+ /* calculate factor of conversion from microseconds to pulses */
+ float factor = 1000000 / carrier_freq;
+
/* write out the timing pattern */
for (i = 0; i < pattern_len; i++)
{
- strlen += sprintf(buffer + strlen, "%d,", pattern[i]);
+ strlen += sprintf(buffer + strlen, "%d,", (int) (pattern[i]/factor));
}
buffer[strlen - 1] = 0;