diff options
author | Maxim Levitsky <maximlevitsky@gmail.com> | 2010-10-16 18:56:29 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-10-21 09:02:15 -0400 |
commit | e1b1ddbe8f415343ed8da323964498f4f0e1b693 (patch) | |
tree | 25c6ac01a29d085a56e5fa443e49701527db48e4 /drivers/media/IR | |
parent | 4651918a4afdd49bdea21d2f919b189ef17a6399 (diff) |
[media] IR: ene_ir: add support for carrier reports
Signed-off-by: Maxim Levitsky <maximlevitsky@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/IR')
-rw-r--r-- | drivers/media/IR/ene_ir.c | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/drivers/media/IR/ene_ir.c b/drivers/media/IR/ene_ir.c index 0795872ff5de..d546b5ef331b 100644 --- a/drivers/media/IR/ene_ir.c +++ b/drivers/media/IR/ene_ir.c | |||
@@ -193,10 +193,11 @@ static int ene_hw_detect(struct ene_device *dev) | |||
193 | /* Sense current received carrier */ | 193 | /* Sense current received carrier */ |
194 | void ene_rx_sense_carrier(struct ene_device *dev) | 194 | void ene_rx_sense_carrier(struct ene_device *dev) |
195 | { | 195 | { |
196 | DEFINE_IR_RAW_EVENT(ev); | ||
197 | |||
198 | int carrier, duty_cycle; | ||
196 | int period = ene_read_reg(dev, ENE_CIRCAR_PRD); | 199 | int period = ene_read_reg(dev, ENE_CIRCAR_PRD); |
197 | int hperiod = ene_read_reg(dev, ENE_CIRCAR_HPRD); | 200 | int hperiod = ene_read_reg(dev, ENE_CIRCAR_HPRD); |
198 | int carrier, duty_cycle; | ||
199 | |||
200 | 201 | ||
201 | if (!(period & ENE_CIRCAR_PRD_VALID)) | 202 | if (!(period & ENE_CIRCAR_PRD_VALID)) |
202 | return; | 203 | return; |
@@ -209,13 +210,16 @@ void ene_rx_sense_carrier(struct ene_device *dev) | |||
209 | dbg("RX: hardware carrier period = %02x", period); | 210 | dbg("RX: hardware carrier period = %02x", period); |
210 | dbg("RX: hardware carrier pulse period = %02x", hperiod); | 211 | dbg("RX: hardware carrier pulse period = %02x", hperiod); |
211 | 212 | ||
212 | |||
213 | carrier = 2000000 / period; | 213 | carrier = 2000000 / period; |
214 | duty_cycle = (hperiod * 100) / period; | 214 | duty_cycle = (hperiod * 100) / period; |
215 | dbg("RX: sensed carrier = %d Hz, duty cycle %d%%", | 215 | dbg("RX: sensed carrier = %d Hz, duty cycle %d%%", |
216 | carrier, duty_cycle); | 216 | carrier, duty_cycle); |
217 | 217 | if (dev->carrier_detect_enabled) { | |
218 | /* TODO: Send carrier & duty cycle to IR layer */ | 218 | ev.carrier_report = true; |
219 | ev.carrier = carrier; | ||
220 | ev.duty_cycle = duty_cycle; | ||
221 | ir_raw_event_store(dev->idev, &ev); | ||
222 | } | ||
219 | } | 223 | } |
220 | 224 | ||
221 | /* this enables/disables the CIR RX engine */ | 225 | /* this enables/disables the CIR RX engine */ |
@@ -724,7 +728,7 @@ static irqreturn_t ene_isr(int irq, void *data) | |||
724 | 728 | ||
725 | dbg_verbose("RX interrupt"); | 729 | dbg_verbose("RX interrupt"); |
726 | 730 | ||
727 | if (dev->carrier_detect_enabled || debug) | 731 | if (dev->hw_learning_and_tx_capable) |
728 | ene_rx_sense_carrier(dev); | 732 | ene_rx_sense_carrier(dev); |
729 | 733 | ||
730 | /* On hardware that don't support extra buffer we need to trust | 734 | /* On hardware that don't support extra buffer we need to trust |
@@ -897,6 +901,23 @@ static int ene_set_learning_mode(void *data, int enable) | |||
897 | return 0; | 901 | return 0; |
898 | } | 902 | } |
899 | 903 | ||
904 | static int ene_set_carrier_report(void *data, int enable) | ||
905 | { | ||
906 | struct ene_device *dev = (struct ene_device *)data; | ||
907 | unsigned long flags; | ||
908 | |||
909 | if (enable == dev->carrier_detect_enabled) | ||
910 | return 0; | ||
911 | |||
912 | spin_lock_irqsave(&dev->hw_lock, flags); | ||
913 | dev->carrier_detect_enabled = enable; | ||
914 | ene_rx_disable(dev); | ||
915 | ene_rx_setup(dev); | ||
916 | ene_rx_enable(dev); | ||
917 | spin_unlock_irqrestore(&dev->hw_lock, flags); | ||
918 | return 0; | ||
919 | } | ||
920 | |||
900 | /* outside interface: enable or disable idle mode */ | 921 | /* outside interface: enable or disable idle mode */ |
901 | static void ene_rx_set_idle(void *data, bool idle) | 922 | static void ene_rx_set_idle(void *data, bool idle) |
902 | { | 923 | { |
@@ -1029,7 +1050,7 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id) | |||
1029 | ir_props->s_tx_mask = ene_set_tx_mask; | 1050 | ir_props->s_tx_mask = ene_set_tx_mask; |
1030 | ir_props->s_tx_carrier = ene_set_tx_carrier; | 1051 | ir_props->s_tx_carrier = ene_set_tx_carrier; |
1031 | ir_props->s_tx_duty_cycle = ene_set_tx_duty_cycle; | 1052 | ir_props->s_tx_duty_cycle = ene_set_tx_duty_cycle; |
1032 | /* ir_props->s_carrier_report = ene_set_carrier_report; */ | 1053 | ir_props->s_carrier_report = ene_set_carrier_report; |
1033 | } | 1054 | } |
1034 | 1055 | ||
1035 | ene_setup_hw_buffer(dev); | 1056 | ene_setup_hw_buffer(dev); |