static void redrat3_process_ir_data(struct redrat3_dev *rr3) { DEFINE_IR_RAW_EVENT(rawir); struct device *dev; unsigned int i, sig_size, single_len, offset, val; u32 mod_freq; dev = rr3->dev; mod_freq = redrat3_val_to_mod_freq(&rr3->irdata); dev_dbg(dev, "Got mod_freq of %u\n", mod_freq); if (mod_freq && rr3->wideband) { DEFINE_IR_RAW_EVENT(ev); ev.carrier_report = 1; ev.carrier = mod_freq; ir_raw_event_store(rr3->rc, &ev); } /* process each rr3 encoded byte into an int */ sig_size = be16_to_cpu(rr3->irdata.sig_size); for (i = 0; i < sig_size; i++) { offset = rr3->irdata.sigdata[i]; val = get_unaligned_be16(&rr3->irdata.lens[offset]); single_len = redrat3_len_to_us(val); /* we should always get pulse/space/pulse/space samples */ if (i % 2) rawir.pulse = false; else rawir.pulse = true; rawir.duration = US_TO_NS(single_len); /* cap the value to IR_MAX_DURATION */ rawir.duration = (rawir.duration > IR_MAX_DURATION) ? IR_MAX_DURATION : rawir.duration; dev_dbg(dev, "storing %s with duration %d (i: %d)\n", rawir.pulse ? "pulse" : "space", rawir.duration, i); ir_raw_event_store_with_filter(rr3->rc, &rawir); } /* add a trailing space */ rawir.pulse = false; rawir.timeout = true; rawir.duration = rr3->rc->timeout; dev_dbg(dev, "storing trailing timeout with duration %d\n", rawir.duration); ir_raw_event_store_with_filter(rr3->rc, &rawir); dev_dbg(dev, "calling ir_raw_event_handle\n"); ir_raw_event_handle(rr3->rc); }
static void redrat3_process_ir_data(struct redrat3_dev *rr3) { DEFINE_IR_RAW_EVENT(rawir); struct redrat3_signal_header header; struct device *dev; int i, trailer = 0; unsigned long delay; u32 mod_freq, single_len; u16 *len_vals; u8 *data_vals; u32 tmp32; u16 tmp16; char *sig_data; if (!rr3) { pr_err("%s called with no context!\n", __func__); return; } rr3_ftr(rr3->dev, "Entered %s\n", __func__); dev = rr3->dev; sig_data = rr3->pbuf; header.length = rr3->pktlen; header.transfer_type = rr3->pkttype; /* */ if (!(header.length >= RR3_HEADER_LENGTH)) dev_warn(dev, "read returned less than rr3 header len\n"); /* */ delay = usecs_to_jiffies(rr3->hw_timeout); mod_timer(&rr3->rx_timeout, jiffies + delay); memcpy(&tmp32, sig_data + RR3_PAUSE_OFFSET, sizeof(tmp32)); header.pause = be32_to_cpu(tmp32); memcpy(&tmp16, sig_data + RR3_FREQ_COUNT_OFFSET, sizeof(tmp16)); header.mod_freq_count = be16_to_cpu(tmp16); memcpy(&tmp16, sig_data + RR3_NUM_PERIOD_OFFSET, sizeof(tmp16)); header.no_periods = be16_to_cpu(tmp16); header.max_lengths = sig_data[RR3_MAX_LENGTHS_OFFSET]; header.no_lengths = sig_data[RR3_NUM_LENGTHS_OFFSET]; memcpy(&tmp16, sig_data + RR3_MAX_SIGS_OFFSET, sizeof(tmp16)); header.max_sig_size = be16_to_cpu(tmp16); memcpy(&tmp16, sig_data + RR3_NUM_SIGS_OFFSET, sizeof(tmp16)); header.sig_size = be16_to_cpu(tmp16); header.no_repeats= sig_data[RR3_REPEATS_OFFSET]; if (debug) { redrat3_dump_signal_header(&header); redrat3_dump_signal_data(sig_data, header.sig_size); } mod_freq = redrat3_val_to_mod_freq(&header); rr3_dbg(dev, "Got mod_freq of %u\n", mod_freq); /* */ len_vals = (u16 *)(sig_data + RR3_HEADER_LENGTH); data_vals = sig_data + RR3_HEADER_LENGTH + (header.max_lengths * sizeof(u16)); /* */ for (i = 0; i < header.sig_size; i++) { u16 val = len_vals[data_vals[i]]; single_len = redrat3_len_to_us((u32)be16_to_cpu(val)); /* */ if (i % 2) rawir.pulse = false; else rawir.pulse = true; rawir.duration = US_TO_NS(single_len); /* */ if (i == 0) trailer = rawir.duration; /* */ rawir.duration &= IR_MAX_DURATION; rr3_dbg(dev, "storing %s with duration %d (i: %d)\n", rawir.pulse ? "pulse" : "space", rawir.duration, i); ir_raw_event_store_with_filter(rr3->rc, &rawir); } /* */ if (i % 2) { rawir.pulse = false; /* */ if (trailer < US_TO_NS(1000)) rawir.duration = US_TO_NS(2800); else rawir.duration = trailer; rr3_dbg(dev, "storing trailing space with duration %d\n", rawir.duration); ir_raw_event_store_with_filter(rr3->rc, &rawir); } rr3_dbg(dev, "calling ir_raw_event_handle\n"); ir_raw_event_handle(rr3->rc); return; }
static void redrat3_process_ir_data(struct redrat3_dev *rr3) { DEFINE_IR_RAW_EVENT(rawir); struct device *dev; unsigned i, trailer = 0; unsigned sig_size, single_len, offset, val; unsigned long delay; u32 mod_freq; if (!rr3) { pr_err("%s called with no context!\n", __func__); return; } rr3_ftr(rr3->dev, "Entered %s\n", __func__); dev = rr3->dev; /* Make sure we reset the IR kfifo after a bit of inactivity */ delay = usecs_to_jiffies(rr3->hw_timeout); mod_timer(&rr3->rx_timeout, jiffies + delay); mod_freq = redrat3_val_to_mod_freq(&rr3->irdata); rr3_dbg(dev, "Got mod_freq of %u\n", mod_freq); /* process each rr3 encoded byte into an int */ sig_size = be16_to_cpu(rr3->irdata.sig_size); for (i = 0; i < sig_size; i++) { offset = rr3->irdata.sigdata[i]; val = get_unaligned_be16(&rr3->irdata.lens[offset]); single_len = redrat3_len_to_us(val); /* we should always get pulse/space/pulse/space samples */ if (i % 2) rawir.pulse = false; else rawir.pulse = true; rawir.duration = US_TO_NS(single_len); /* Save initial pulse length to fudge trailer */ if (i == 0) trailer = rawir.duration; /* cap the value to IR_MAX_DURATION */ rawir.duration &= IR_MAX_DURATION; rr3_dbg(dev, "storing %s with duration %d (i: %d)\n", rawir.pulse ? "pulse" : "space", rawir.duration, i); ir_raw_event_store_with_filter(rr3->rc, &rawir); } /* add a trailing space, if need be */ if (i % 2) { rawir.pulse = false; /* this duration is made up, and may not be ideal... */ if (trailer < US_TO_NS(1000)) rawir.duration = US_TO_NS(2800); else rawir.duration = trailer; rr3_dbg(dev, "storing trailing space with duration %d\n", rawir.duration); ir_raw_event_store_with_filter(rr3->rc, &rawir); } rr3_dbg(dev, "calling ir_raw_event_handle\n"); ir_raw_event_handle(rr3->rc); }
static void redrat3_process_ir_data(struct redrat3_dev *rr3) { DEFINE_IR_RAW_EVENT(rawir); struct redrat3_signal_header header; struct device *dev; int i; unsigned long delay; u32 mod_freq, single_len; u16 *len_vals; u8 *data_vals; u32 tmp32; u16 tmp16; char *sig_data; if (!rr3) { pr_err("%s called with no context!\n", __func__); return; } rr3_ftr(rr3->dev, "Entered %s\n", __func__); dev = rr3->dev; sig_data = rr3->pbuf; header.length = rr3->pktlen; header.transfer_type = rr3->pkttype; /* Sanity check */ if (!(header.length >= RR3_HEADER_LENGTH)) dev_warn(dev, "read returned less than rr3 header len\n"); delay = usecs_to_jiffies(rr3->rc->timeout / 1000); mod_timer(&rr3->rx_timeout, jiffies + delay); memcpy(&tmp32, sig_data + RR3_PAUSE_OFFSET, sizeof(tmp32)); header.pause = be32_to_cpu(tmp32); memcpy(&tmp16, sig_data + RR3_FREQ_COUNT_OFFSET, sizeof(tmp16)); header.mod_freq_count = be16_to_cpu(tmp16); memcpy(&tmp16, sig_data + RR3_NUM_PERIOD_OFFSET, sizeof(tmp16)); header.no_periods = be16_to_cpu(tmp16); header.max_lengths = sig_data[RR3_MAX_LENGTHS_OFFSET]; header.no_lengths = sig_data[RR3_NUM_LENGTHS_OFFSET]; memcpy(&tmp16, sig_data + RR3_MAX_SIGS_OFFSET, sizeof(tmp16)); header.max_sig_size = be16_to_cpu(tmp16); memcpy(&tmp16, sig_data + RR3_NUM_SIGS_OFFSET, sizeof(tmp16)); header.sig_size = be16_to_cpu(tmp16); header.no_repeats= sig_data[RR3_REPEATS_OFFSET]; if (debug) { redrat3_dump_signal_header(&header); redrat3_dump_signal_data(sig_data, header.sig_size); } mod_freq = redrat3_val_to_mod_freq(&header); rr3_dbg(dev, "Got mod_freq of %u\n", mod_freq); /* Here we pull out the 'length' values from the signal */ len_vals = (u16 *)(sig_data + RR3_HEADER_LENGTH); data_vals = sig_data + RR3_HEADER_LENGTH + (header.max_lengths * sizeof(u16)); /* process each rr3 encoded byte into an int */ for (i = 0; i < header.sig_size; i++) { u16 val = len_vals[data_vals[i]]; single_len = redrat3_len_to_us((u32)be16_to_cpu(val)); /* cap the value to IR_MAX_DURATION */ single_len &= IR_MAX_DURATION; /* we should always get pulse/space/pulse/space samples */ if (i % 2) rawir.pulse = false; else rawir.pulse = true; rawir.duration = US_TO_NS(single_len); rr3_dbg(dev, "storing %s with duration %d (i: %d)\n", rawir.pulse ? "pulse" : "space", rawir.duration, i); ir_raw_event_store_with_filter(rr3->rc, &rawir); } /* add a trailing space, if need be */ if (i % 2) { rawir.pulse = false; /* this duration is made up, and may not be ideal... */ rawir.duration = rr3->rc->timeout / 2; rr3_dbg(dev, "storing trailing space with duration %d\n", rawir.duration); ir_raw_event_store_with_filter(rr3->rc, &rawir); } rr3_dbg(dev, "calling ir_raw_event_handle\n"); ir_raw_event_handle(rr3->rc); return; }