rc-core: Revert encoding patchset
Subsystems (2)
cover rc-core: Revert encoding patchset
The current code is not mature enough, the API should allow a single protocol to be specified. Also, the current code contains heuristics that will depend on module load order.
The issues were discussed in this thread:
https://www.mail-archive.com/[email protected]/msg86998.html
And Antti agreed at the end of the thread:
https://www.mail-archive.com/[email protected]/msg86998.html
This needs to go in upstream before 4.2 is released.
---
David Härdeman (7):
Revert "[media] rc: nuvoton-cir: Add support for writing wakeup samples via sysfs filter callback" Revert "[media] rc: rc-loopback: Add loopback of filter scancodes"
Revert "[media] rc: rc-core: Add support for encode_wakeup drivers"
Revert "[media] rc: ir-rc6-decoder: Add encode capability"
Revert "[media] rc: ir-rc5-decoder: Add encode capability"
Revert "[media] rc: rc-ir-raw: Add Manchester encoder (phase encoder) helper" Revert "[media] rc: rc-ir-raw: Add scancode encoder callback"
drivers/media/rc/ir-rc5-decoder.c | 116 ------------------------------- drivers/media/rc/ir-rc6-decoder.c | 122 -------------------------------- drivers/media/rc/nuvoton-cir.c | 127 ---------------------------------- drivers/media/rc/nuvoton-cir.h | 1 drivers/media/rc/rc-core-priv.h | 36 ---------- drivers/media/rc/rc-ir-raw.c | 139 ------------------------------------- drivers/media/rc/rc-loopback.c | 36 ---------- drivers/media/rc/rc-main.c | 7 -- include/media/rc-core.h | 7 -- 9 files changed, 1 insertion(+), 590 deletions(-)
--
David Härdeman
PATCH 1/7 Revert "[media] rc: nuvoton-cir: Add support for writing wakeup samples via sysfs filter callback"
This reverts commit da7ee60b03bd66bb10974d7444aa444de6391312.
The current code is not mature enough, the API should allow a single protocol to be specified. Also, the current code contains heuristics that will depend on module load order.
--- drivers/media/rc/nuvoton-cir.c | 127 ---------------------------------------- drivers/media/rc/nuvoton-cir.h | 1 include/media/rc-core.h | 1 3 files changed, 129 deletions(-)
drivers/media/rc/nuvoton-cir.c +0 -127
@@ -526,130 +526,6 @@ static int nvt_set_tx_carrier(struct rc_dev *dev, u32 carrier)return 0 ; } -static int nvt_write_wakeup_codes (struct rc_dev *dev, -const u8 *wakeup_sample_buf,int count) -{ -int i =0 ; -u8 reg, reg_learn_mode; -unsigned long flags; -struct nvt_dev *nvt = dev->priv; - -nvt_dbg_wake ("writing wakeup samples" ); - - reg =nvt_cir_wake_reg_read (nvt,CIR_WAKE_IRCON ); - reg_learn_mode = reg & ~CIR_WAKE_IRCON_MODE0 ; - reg_learn_mode |=CIR_WAKE_IRCON_MODE1 ; - -/* Lock the learn area to prevent racing with wake-isr */ -spin_lock_irqsave (&nvt->nvt_lock, flags); - -/* Enable fifo writes */ -nvt_cir_wake_reg_write (nvt, reg_learn_mode,CIR_WAKE_IRCON ); - -/* Clear cir wake rx fifo */ -nvt_clear_cir_wake_fifo (nvt); - -if (count >WAKE_FIFO_LEN ) { -nvt_dbg_wake ("HW FIFO too small for all wake samples" ); - count =WAKE_FIFO_LEN ; - } - -if (count) -pr_info ("Wake samples (%d) =" , count); -else -pr_info ("Wake sample fifo cleared" ); - -/* Write wake samples to fifo */ -for (i =0 ; i < count; i++) { -pr_cont (" %02x" , wakeup_sample_buf[i]); -nvt_cir_wake_reg_write (nvt, wakeup_sample_buf[i], -CIR_WAKE_WR_FIFO_DATA ); - } -pr_cont ("\n" ); - -/* Switch cir to wakeup mode and disable fifo writing */ -nvt_cir_wake_reg_write (nvt, reg,CIR_WAKE_IRCON ); - -/* Set number of bytes needed for wake */ -nvt_cir_wake_reg_write (nvt, count ? count : -CIR_WAKE_FIFO_CMP_BYTES , -CIR_WAKE_FIFO_CMP_DEEP ); - -spin_unlock_irqrestore (&nvt->nvt_lock, flags); - -return 0 ; -} - -static int nvt_ir_raw_set_wakeup_filter (struct rc_dev *dev, -struct rc_scancode_filter *sc_filter) -{ -u8 *reg_buf; -u8 buf_val; -int i, ret, count; -unsigned int val; -struct ir_raw_event *raw; -bool complete; - -/* Require both mask and data to be set before actually committing */ -if (!sc_filter->mask || !sc_filter->data) -return 0 ; - - raw =kmalloc_array (WAKE_FIFO_LEN ,sizeof (*raw),GFP_KERNEL ); -if (!raw) -return -ENOMEM ; - - ret =ir_raw_encode_scancode (dev->enabled_wakeup_protocols, sc_filter, - raw,WAKE_FIFO_LEN ); - complete = (ret != -ENOBUFS ); -if (!complete) - ret =WAKE_FIFO_LEN ; -else if (ret <0 ) - goto out_raw; - - reg_buf =kmalloc_array (WAKE_FIFO_LEN ,sizeof (*reg_buf),GFP_KERNEL ); -if (!reg_buf) { - ret = -ENOMEM ; - goto out_raw; - } - -/* Inspect the ir samples */ -for (i =0 , count =0 ; i < ret && count <WAKE_FIFO_LEN ; ++i) { - val =NS_TO_US ((raw[i]).duration) /SAMPLE_PERIOD ; - -/* Split too large values into several smaller ones */ -while (val >0 && count <WAKE_FIFO_LEN ) { - -/* Skip last value for better comparison tolerance */ -if (complete && i == ret -1 && val <BUF_LEN_MASK ) -break ; - -/* Clamp values to BUF_LEN_MASK at most */ - buf_val = (val >BUF_LEN_MASK ) ?BUF_LEN_MASK : val; - - reg_buf[count] = buf_val; - val -= buf_val; -if ((raw[i]).pulse) - reg_buf[count] |=BUF_PULSE_BIT ; - count++; - } - } - - ret =nvt_write_wakeup_codes (dev, reg_buf, count); - -kfree (reg_buf); -out_raw: -kfree (raw); - -return ret; -} - -/* Dummy implementation. nuvoton is agnostic to the protocol used */ -static int nvt_ir_raw_change_wakeup_protocol (struct rc_dev *dev, -u64 *rc_type) -{ -return 0 ; -} -/* * nvt_tx_ir *
@@ -1167,14 +1043,11 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)/* Set up the rc device */ rdev->priv = nvt; rdev->driver_type =RC_DRIVER_IR_RAW ; - rdev->encode_wakeup = true; rdev->allowed_protocols =RC_BIT_ALL ; rdev->open = nvt_open; rdev->close = nvt_close; rdev->tx_ir = nvt_tx_ir; rdev->s_tx_carrier = nvt_set_tx_carrier; - rdev->s_wakeup_filter = nvt_ir_raw_set_wakeup_filter; - rdev->change_wakeup_protocol = nvt_ir_raw_change_wakeup_protocol; rdev->input_name ="Nuvoton w836x7hg Infrared Remote Transceiver" ; rdev->input_phys ="nuvoton/cir0" ; rdev->input_id.bustype =BUS_HOST ;
drivers/media/rc/nuvoton-cir.h +0 -1
@@ -63,7 +63,6 @@ static int debug;*/ #define TX_BUF_LEN 256#define RX_BUF_LEN 32 -#define WAKE_FIFO_LEN 67struct nvt_dev {struct pnp_dev *pdev;
include/media/rc-core.h +0 -1
@@ -246,7 +246,6 @@ static inline void init_ir_raw_event(struct ir_raw_event *ev)#define US_TO_NS (usec) ((usec) * 1000)#define MS_TO_US (msec) ((msec) * 1000)#define MS_TO_NS (msec) ((msec) * 1000 * 1000) -#define NS_TO_US (nsec) DIV_ROUND_UP(nsec, 1000L)void ir_raw_event_handle (struct rc_dev *dev);int ir_raw_event_store (struct rc_dev *dev,struct ir_raw_event *ev);
PATCH 2/7 Revert "[media] rc: rc-loopback: Add loopback of filter scancodes"
In reply to David HärdemanThis reverts commit 2e4ebde269236da2a41183522127715b6d9d80ce.
The current code is not mature enough, the API should allow a single protocol to be specified. Also, the current code contains heuristics that will depend on module load order.
--- drivers/media/rc/rc-loopback.c | 36 ------------------------------------ 1 file changed, 36 deletions(-)
drivers/media/rc/rc-loopback.c +0 -36
@@ -26,7 +26,6 @@#include <linux/device.h> #include <linux/module.h> #include <linux/sched.h> -#include <linux/slab.h> #include <media/rc-core.h> #define DRIVER_NAME "rc-loopback"
@@ -177,39 +176,6 @@ static int loop_set_carrier_report(struct rc_dev *dev, int enable)return 0 ; } -static int loop_set_wakeup_filter (struct rc_dev *dev, -struct rc_scancode_filter *sc_filter) -{ -static const unsigned int max =512 ; -struct ir_raw_event *raw; -int ret; -int i; - -/* fine to disable filter */ -if (!sc_filter->mask) -return 0 ; - -/* encode the specified filter and loop it back */ - raw =kmalloc_array (max,sizeof (*raw),GFP_KERNEL ); - ret =ir_raw_encode_scancode (dev->enabled_wakeup_protocols, sc_filter, - raw, max); -/* still loop back the partial raw IR even if it's incomplete */ -if (ret == -ENOBUFS ) - ret = max; -if (ret >=0 ) { -/* do the loopback */ -for (i =0 ; i < ret; ++i) -ir_raw_event_store (dev, &raw[i]); -ir_raw_event_handle (dev); - - ret =0 ; - } - -kfree (raw); - -return ret; -} -static int __init loop_init (void ) {struct rc_dev *rc;
@@ -229,7 +195,6 @@ static int __init loop_init(void) rc->map_name =RC_MAP_EMPTY ; rc->priv = &loopdev; rc->driver_type =RC_DRIVER_IR_RAW ; - rc->encode_wakeup = true; rc->allowed_protocols =RC_BIT_ALL ; rc->timeout =100 *1000 *1000 ;/* 100 ms */ rc->min_timeout =1 ;
@@ -244,7 +209,6 @@ static int __init loop_init(void) rc->s_idle = loop_set_idle; rc->s_learning_mode = loop_set_learning_mode; rc->s_carrier_report = loop_set_carrier_report; - rc->s_wakeup_filter = loop_set_wakeup_filter; loopdev.txmask =RXMASK_REGULAR ; loopdev.txcarrier =36000 ;
PATCH 3/7 Revert "[media] rc: rc-core: Add support for encode_wakeup drivers"
In reply to David HärdemanThis reverts commit 0d830b2d1295fee82546d57185da5a6604f11ae2.
The current code is not mature enough, the API should allow a single protocol to be specified. Also, the current code contains heuristics that will depend on module load order.
--- drivers/media/rc/rc-core-priv.h | 1 - drivers/media/rc/rc-ir-raw.c | 17 ----------------- drivers/media/rc/rc-main.c | 7 +------ include/media/rc-core.h | 3 --- 4 files changed, 1 insertion(+), 27 deletions(-)
drivers/media/rc/rc-core-priv.h +0 -1
@@ -189,7 +189,6 @@ int ir_raw_gen_manchester(struct ir_raw_event **ev, unsigned int max,* Routines from rc-raw.c to be used internally and by decoders */ u64 ir_raw_get_allowed_protocols (void ); -u64 ir_raw_get_encode_protocols (void );int ir_raw_event_register (struct rc_dev *dev);void ir_raw_event_unregister (struct rc_dev *dev);int ir_raw_handler_register (struct ir_raw_handler *ir_raw_handler);
drivers/media/rc/rc-ir-raw.c +0 -17
@@ -30,7 +30,6 @@ static LIST_HEAD(ir_raw_client_list);static DEFINE_MUTEX (ir_raw_handler_lock);static LIST_HEAD (ir_raw_handler_list);static u64 available_protocols; -static u64 encode_protocols;static int ir_raw_event_thread (void *data) {
@@ -241,18 +240,6 @@ ir_raw_get_allowed_protocols(void)return protocols; } -/* used internally by the sysfs interface */ -u64 -ir_raw_get_encode_protocols (void ) -{ -u64 protocols; - -mutex_lock (&ir_raw_handler_lock); - protocols = encode_protocols; -mutex_unlock (&ir_raw_handler_lock); -return protocols; -} -static int change_protocol (struct rc_dev *dev,u64 *rc_type) {/* the caller will update dev->enabled_protocols */
@@ -463,8 +450,6 @@ int ir_raw_handler_register(struct ir_raw_handler *ir_raw_handler)list_for_each_entry (raw, &ir_raw_client_list, list) ir_raw_handler->raw_register (raw->dev); available_protocols |= ir_raw_handler->protocols; -if (ir_raw_handler->encode) - encode_protocols |= ir_raw_handler->protocols;mutex_unlock (&ir_raw_handler_lock);return 0 ;
@@ -481,8 +466,6 @@ void ir_raw_handler_unregister(struct ir_raw_handler *ir_raw_handler)list_for_each_entry (raw, &ir_raw_client_list, list) ir_raw_handler->raw_unregister (raw->dev); available_protocols &= ~ir_raw_handler->protocols; -if (ir_raw_handler->encode) - encode_protocols &= ~ir_raw_handler->protocols;mutex_unlock (&ir_raw_handler_lock); }EXPORT_SYMBOL (ir_raw_handler_unregister);
drivers/media/rc/rc-main.c +1 -6
@@ -865,8 +865,6 @@ static ssize_t show_protocols(struct device *device, }else { enabled = dev->enabled_wakeup_protocols; allowed = dev->allowed_wakeup_protocols; -if (dev->encode_wakeup && !allowed) - allowed =ir_raw_get_encode_protocols (); }mutex_unlock (&dev->lock);
@@ -1411,16 +1409,13 @@ int rc_register_device(struct rc_dev *dev) path ? path : "N/A");kfree (path); -if (dev->driver_type ==RC_DRIVER_IR_RAW || dev->encode_wakeup) { +if (dev->driver_type ==RC_DRIVER_IR_RAW ) {/* Load raw decoders, if they aren't already */ if (!raw_init) {IR_dprintk (1 ,"Loading raw decoders\n" );ir_raw_init (); raw_init = true; } - } - -if (dev->driver_type ==RC_DRIVER_IR_RAW ) {/* calls ir_register_device so unlock mutex here*/ mutex_unlock (&dev->lock); rc =ir_raw_event_register (dev);
include/media/rc-core.h +0 -3
@@ -74,8 +74,6 @@ enum rc_filter_type {* @input_dev: the input child device used to communicate events to userspace * @driver_type: specifies if protocol decoding is done in hardware or software * @idle: used to keep track of RX state -* @encode_wakeup: wakeup filtering uses IR encode API, therefore the allowed -* wakeup protocols is the set of all raw encoders * @allowed_protocols: bitmask with the supported RC_BIT_* protocols * @enabled_protocols: bitmask with the enabled RC_BIT_* protocols * @allowed_wakeup_protocols: bitmask with the supported RC_BIT_* wakeup protocols
@@ -136,7 +134,6 @@ struct rc_dev {struct input_dev *input_dev;enum rc_driver_type driver_type;bool idle; -bool encode_wakeup;u64 allowed_protocols;u64 enabled_protocols;u64 allowed_wakeup_protocols;
PATCH 4/7 Revert "[media] rc: ir-rc6-decoder: Add encode capability"
In reply to David HärdemanThis reverts commit cf257e288ad3a134d4bb809c542a3ae6c87ddfa3.
The current code is not mature enough, the API should allow a single protocol to be specified. Also, the current code contains heuristics that will depend on module load order.
--- drivers/media/rc/ir-rc6-decoder.c | 122 ------------------------------------- 1 file changed, 122 deletions(-)
drivers/media/rc/ir-rc6-decoder.c +0 -122
@@ -291,133 +291,11 @@ out:return -EINVAL ; } -static struct ir_raw_timings_manchester ir_rc6_timings[4 ] = { - { - .leader =RC6_PREFIX_PULSE , - .pulse_space_start =0 , - .clock =RC6_UNIT , - .invert =1 , - .trailer_space =RC6_PREFIX_SPACE , - }, - { - .clock =RC6_UNIT , - .invert =1 , - }, - { - .clock =RC6_UNIT *2 , - .invert =1 , - }, - { - .clock =RC6_UNIT , - .invert =1 , - .trailer_space =RC6_SUFFIX_SPACE , - }, -}; - -static int ir_rc6_validate_filter (const struct rc_scancode_filter *scancode, -unsigned int important_bits) -{ -/* all important bits of scancode should be set in mask */ -if (~scancode->mask & important_bits) -return -EINVAL ; -/* extra bits in mask should be zero in data */ -if (scancode->mask & scancode->data & ~important_bits) -return -EINVAL ; -return 0 ; -} - -/** -* ir_rc6_encode() - Encode a scancode as a stream of raw events -* -* @protocols: allowed protocols -* @scancode: scancode filter describing scancode (helps distinguish between -* protocol subtypes when scancode is ambiguous) -* @events: array of raw ir events to write into -* @max: maximum size of @events -* -* Returns: The number of events written. -* -ENOBUFS if there isn't enough space in the array to fit the -* encoding. In this case all @max events will have been written. -* -EINVAL if the scancode is ambiguous or invalid. -*/ -static int ir_rc6_encode (u64 protocols, -const struct rc_scancode_filter *scancode, -struct ir_raw_event *events,unsigned int max) -{ -int ret; -struct ir_raw_event *e = events; - -if (protocols &RC_BIT_RC6_0 && - !ir_rc6_validate_filter (scancode,0xffff )) { - -/* Modulate the preamble */ - ret =ir_raw_gen_manchester (&e, max, &ir_rc6_timings[0 ],0 ,0 ); -if (ret <0 ) -return ret; - -/* Modulate the header (Start Bit & Mode-0) */ - ret =ir_raw_gen_manchester (&e, max - (e - events), - &ir_rc6_timings[1 ], -RC6_HEADER_NBITS , (1 <<3 )); -if (ret <0 ) -return ret; - -/* Modulate Trailer Bit */ - ret =ir_raw_gen_manchester (&e, max - (e - events), - &ir_rc6_timings[2 ],1 ,0 ); -if (ret <0 ) -return ret; - -/* Modulate rest of the data */ - ret =ir_raw_gen_manchester (&e, max - (e - events), - &ir_rc6_timings[3 ],RC6_0_NBITS , - scancode->data); -if (ret <0 ) -return ret; - - }else if (protocols & (RC_BIT_RC6_6A_20 |RC_BIT_RC6_6A_24 | -RC_BIT_RC6_6A_32 |RC_BIT_RC6_MCE ) && - !ir_rc6_validate_filter (scancode,0x8fffffff )) { - -/* Modulate the preamble */ - ret =ir_raw_gen_manchester (&e, max, &ir_rc6_timings[0 ],0 ,0 ); -if (ret <0 ) -return ret; - -/* Modulate the header (Start Bit & Header-version 6 */ - ret =ir_raw_gen_manchester (&e, max - (e - events), - &ir_rc6_timings[1 ], -RC6_HEADER_NBITS , (1 <<3 |6 )); -if (ret <0 ) -return ret; - -/* Modulate Trailer Bit */ - ret =ir_raw_gen_manchester (&e, max - (e - events), - &ir_rc6_timings[2 ],1 ,0 ); -if (ret <0 ) -return ret; - -/* Modulate rest of the data */ - ret =ir_raw_gen_manchester (&e, max - (e - events), - &ir_rc6_timings[3 ], -fls (scancode->mask), - scancode->data); -if (ret <0 ) -return ret; - - }else { -return -EINVAL ; - } - -return e - events; -} -static struct ir_raw_handler rc6_handler = { .protocols =RC_BIT_RC6_0 |RC_BIT_RC6_6A_20 |RC_BIT_RC6_6A_24 |RC_BIT_RC6_6A_32 |RC_BIT_RC6_MCE , .decode = ir_rc6_decode, - .encode = ir_rc6_encode, };static int __init ir_rc6_decode_init (void )
PATCH 5/7 Revert "[media] rc: ir-rc5-decoder: Add encode capability"
In reply to David HärdemanThis reverts commit a0466f15b4654cf1ac9e387d7c1a401eff494b4f.
The current code is not mature enough, the API should allow a single protocol to be specified. Also, the current code contains heuristics that will depend on module load order.
--- drivers/media/rc/ir-rc5-decoder.c | 116 ------------------------------------- 1 file changed, 116 deletions(-)
drivers/media/rc/ir-rc5-decoder.c +0 -116
@@ -184,125 +184,9 @@ out:return -EINVAL ; } -static struct ir_raw_timings_manchester ir_rc5_timings = { - .leader =RC5_UNIT , - .pulse_space_start =0 , - .clock =RC5_UNIT , - .trailer_space =RC5_UNIT *10 , -}; - -static struct ir_raw_timings_manchester ir_rc5x_timings[2 ] = { - { - .leader =RC5_UNIT , - .pulse_space_start =0 , - .clock =RC5_UNIT , - .trailer_space =RC5X_SPACE , - }, - { - .clock =RC5_UNIT , - .trailer_space =RC5_UNIT *10 , - }, -}; - -static struct ir_raw_timings_manchester ir_rc5_sz_timings = { - .leader =RC5_UNIT , - .pulse_space_start =0 , - .clock =RC5_UNIT , - .trailer_space =RC5_UNIT *10 , -}; - -static int ir_rc5_validate_filter (const struct rc_scancode_filter *scancode, -unsigned int important_bits) -{ -/* all important bits of scancode should be set in mask */ -if (~scancode->mask & important_bits) -return -EINVAL ; -/* extra bits in mask should be zero in data */ -if (scancode->mask & scancode->data & ~important_bits) -return -EINVAL ; -return 0 ; -} - -/** -* ir_rc5_encode() - Encode a scancode as a stream of raw events -* -* @protocols: allowed protocols -* @scancode: scancode filter describing scancode (helps distinguish between -* protocol subtypes when scancode is ambiguous) -* @events: array of raw ir events to write into -* @max: maximum size of @events -* -* Returns: The number of events written. -* -ENOBUFS if there isn't enough space in the array to fit the -* encoding. In this case all @max events will have been written. -* -EINVAL if the scancode is ambiguous or invalid. -*/ -static int ir_rc5_encode (u64 protocols, -const struct rc_scancode_filter *scancode, -struct ir_raw_event *events,unsigned int max) -{ -int ret; -struct ir_raw_event *e = events; -unsigned int data, xdata, command, commandx, system; - -/* Detect protocol and convert scancode to raw data */ -if (protocols &RC_BIT_RC5 && - !ir_rc5_validate_filter (scancode,0x1f7f )) { -/* decode scancode */ - command = (scancode->data &0x003f ) >>0 ; - commandx = (scancode->data &0x0040 ) >>6 ; - system = (scancode->data &0x1f00 ) >>8 ; -/* encode data */ - data = !commandx <<12 | system <<6 | command; - -/* Modulate the data */ - ret =ir_raw_gen_manchester (&e, max, &ir_rc5_timings,RC5_NBITS , - data); -if (ret <0 ) -return ret; - }else if (protocols &RC_BIT_RC5X && - !ir_rc5_validate_filter (scancode,0x1f7f3f )) { -/* decode scancode */ - xdata = (scancode->data &0x00003f ) >>0 ; - command = (scancode->data &0x003f00 ) >>8 ; - commandx = (scancode->data &0x004000 ) >>14 ; - system = (scancode->data &0x1f0000 ) >>16 ; -/* commandx and system overlap, bits must match when encoded */ -if (commandx == (system &0x1 )) -return -EINVAL ; -/* encode data */ - data =1 <<18 | system <<12 | command <<6 | xdata; - -/* Modulate the data */ - ret =ir_raw_gen_manchester (&e, max, &ir_rc5x_timings[0 ], -CHECK_RC5X_NBITS , - data >> (RC5X_NBITS -CHECK_RC5X_NBITS )); -if (ret <0 ) -return ret; - ret =ir_raw_gen_manchester (&e, max - (e - events), - &ir_rc5x_timings[1 ], -RC5X_NBITS -CHECK_RC5X_NBITS , - data); -if (ret <0 ) -return ret; - }else if (protocols &RC_BIT_RC5_SZ && - !ir_rc5_validate_filter (scancode,0x2fff )) { -/* RC5-SZ scancode is raw enough for Manchester as it is */ - ret =ir_raw_gen_manchester (&e, max, &ir_rc5_sz_timings, -RC5_SZ_NBITS , scancode->data &0x2fff ); -if (ret <0 ) -return ret; - }else { -return -EINVAL ; - } - -return e - events; -} -static struct ir_raw_handler rc5_handler = { .protocols =RC_BIT_RC5 |RC_BIT_RC5X |RC_BIT_RC5_SZ , .decode = ir_rc5_decode, - .encode = ir_rc5_encode, };static int __init ir_rc5_decode_init (void )
PATCH 6/7 Revert "[media] rc: rc-ir-raw: Add Manchester encoder (phase encoder) helper"
In reply to David HärdemanThis reverts commit 1d971d927efa2e10194c96ed0475b6d6054342d8.
The current code is not mature enough, the API should allow a single protocol to be specified. Also, the current code contains heuristics that will depend on module load order.
--- drivers/media/rc/rc-core-priv.h | 33 --------------- drivers/media/rc/rc-ir-raw.c | 85 --------------------------------------- 2 files changed, 118 deletions(-)
drivers/media/rc/rc-core-priv.h +0 -33
@@ -152,39 +152,6 @@ static inline bool is_timing_event(struct ir_raw_event ev)#define TO_US (duration) DIV_ROUND_CLOSEST((duration), 1000)#define TO_STR (is_pulse) ((is_pulse) ? "pulse" : "space") -/* functions for IR encoders */ - -static inline void init_ir_raw_event_duration (struct ir_raw_event *ev, -unsigned int pulse, -u32 duration) -{ -init_ir_raw_event (ev); - ev->duration = duration; - ev->pulse = pulse; -} - -/** -* struct ir_raw_timings_manchester - Manchester coding timings -* @leader: duration of leader pulse (if any) 0 if continuing -* existing signal (see @pulse_space_start) -* @pulse_space_start: 1 for starting with pulse (0 for starting with space) -* @clock: duration of each pulse/space in ns -* @invert: if set clock logic is inverted -* (0 = space + pulse, 1 = pulse + space) -* @trailer_space: duration of trailer space in ns -*/ -struct ir_raw_timings_manchester { -unsigned int leader; -unsigned int pulse_space_start:1 ; -unsigned int clock; -unsigned int invert:1 ; -unsigned int trailer_space; -}; - -int ir_raw_gen_manchester (struct ir_raw_event **ev,unsigned int max, -const struct ir_raw_timings_manchester *timings, -unsigned int n,unsigned int data); -/* * Routines from rc-raw.c to be used internally and by decoders */
drivers/media/rc/rc-ir-raw.c +0 -85
91 lines not on this page · raw message
PATCH 7/7 Revert "[media] rc: rc-ir-raw: Add scancode encoder callback"
In reply to David HärdemanThis reverts commit 9869da5bacc5c9b865a183bd36c04be76cdd325d.
The current code is not mature enough, the API should allow a single protocol to be specified. Also, the current code contains heuristics that will depend on module load order.
--- drivers/media/rc/rc-core-priv.h | 2 -- drivers/media/rc/rc-ir-raw.c | 37 ------------------------------------- include/media/rc-core.h | 3 --- 3 files changed, 42 deletions(-)
drivers/media/rc/rc-core-priv.h +0 -2
@@ -25,8 +25,6 @@ struct ir_raw_handler {u64 protocols;/* which are handled by this handler */ int (*decode)(struct rc_dev *dev,struct ir_raw_event event); -int (*encode)(u64 protocols,const struct rc_scancode_filter *scancode, -struct ir_raw_event *events,unsigned int max);/* These two should only be used by the lirc decoder */ int (*raw_register)(struct rc_dev *dev);
drivers/media/rc/rc-ir-raw.c +0 -37
@@ -246,43 +246,6 @@ static int change_protocol(struct rc_dev *dev, u64 *rc_type)return 0 ; } -/** -* ir_raw_encode_scancode() - Encode a scancode as raw events -* -* @protocols: permitted protocols -* @scancode: scancode filter describing a single scancode -* @events: array of raw events to write into -* @max: max number of raw events -* -* Attempts to encode the scancode as raw events. -* -* Returns: The number of events written. -* -ENOBUFS if there isn't enough space in the array to fit the -* encoding. In this case all @max events will have been written. -* -EINVAL if the scancode is ambiguous or invalid, or if no -* compatible encoder was found. -*/ -int ir_raw_encode_scancode (u64 protocols, -const struct rc_scancode_filter *scancode, -struct ir_raw_event *events,unsigned int max) -{ -struct ir_raw_handler *handler; -int ret = -EINVAL ; - -mutex_lock (&ir_raw_handler_lock); -list_for_each_entry (handler, &ir_raw_handler_list, list) { -if (handler->protocols & protocols && handler->encode) { - ret = handler->encode (protocols, scancode, events, max); -if (ret >=0 || ret == -ENOBUFS ) -break ; - } - } -mutex_unlock (&ir_raw_handler_lock); - -return ret; -} -EXPORT_SYMBOL (ir_raw_encode_scancode); -/* * Used to (un)register raw event clients */
include/media/rc-core.h +0 -3
@@ -250,9 +250,6 @@ int ir_raw_event_store_edge(struct rc_dev *dev, enum raw_event_type type);int ir_raw_event_store_with_filter (struct rc_dev *dev,struct ir_raw_event *ev);void ir_raw_event_set_idle (struct rc_dev *dev,bool idle); -int ir_raw_encode_scancode (u64 protocols, -const struct rc_scancode_filter *scancode, -struct ir_raw_event *events,unsigned int max);static inline void ir_raw_event_reset (struct rc_dev *dev) {
Quoted 7 lines · David Härdeman
The current code is not mature enough, the API should allow a single protocol to be specified. Also, the current code contains heuristics that will depend on module load order.
The issues were discussed in this thread:
https://www.mail-archive.com/[email protected]/msg86998.html
Quoted 7 lines
And Antti agreed at the end of the thread:
https://www.mail-archive.com/[email protected]/msg86998.htmlThis needs to go in upstream before 4.2 is released.
Signed-off-by David Härdeman <[email protected]>
Almost missed this...
Yes, after discussing with David I think we can do the wakeup with even better API than with the one we currently have.
So without further ado: