media fixes for v4.2-rc8

-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJV11W4AAoJEAhfPr2O5OEVa1MQAIK/eQiD+HSq3ooyIrv0ZR3k
 vXn4zPYVM4CrV6pdLKti/tb2y+QQVLDBY2kSyKquJySGD+5Pg94vQr2EQ3tVx/+H
 6BK69lLUIzjqjf9SATJcgNpDW51vh3GfkSv9nmsQ1VMY8FQxX64AXPgOF2QMrlmI
 YKDVqNY43h/0uctXBiC1epfK139vogKE9P5eHW3QyqGK87ebeyB/yTQC/qF3n77e
 GO3Q8wshPWzuQUSaqinHo7bzVi+kFF6vhvDgVuLo+J6KFKEqC375GN3+Gpe+elcd
 wbaT9r498GRR7hOHKW0w0IrFEKLRzJuj4N1QGX9v338qB3zumVey7dcQzGXGQMdV
 tv56BkbJBq9s+HngZ2vjQEWdM5BSe4FGbSY8TlCtevkA+uIMj1SBaLv4rw5DfTkD
 lA5ijux1xVjqORVxo7yIbJal1nP2FPvzKRRsKn5C/2OHFgt6SX8bTjuiC4JrsfIM
 P6GIM5P7aLth7NX/xr1B9K5GLucJ38KGw1/D9wYeZpXm1Ba1T4KjWzkq9pW5u/Z6
 xa3phHvTvxf7IcoQFEa//D27TmfctvqIxACoW8bOO1sJqX+e0dn29kfP1FmfFmCi
 zqWkSBBCnDBD16+zOozxjQFsuOTKqkjcCbxfkxxR4NjGcwF2Px+3uJY+JazK3QQq
 gCYbyN2rYAQ7hxCRPbP4
 =TqKo
 -----END PGP SIGNATURE-----

Merge tag 'media/v4.2-3' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media

Pull media fixes from Mauro Carvalho Chehab:

 - a regression fix at the videobuf2 core driver

 - fix error handling at mantis probing code

 - revert the IR encode patches, as the API is not mature enough.
   So, better to postpone the changes to a latter Kernel

 - fix Kconfig breakages on some randconfig scenarios.

* tag 'media/v4.2-3' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media:
  [media] mantis: Fix error handling in mantis_dma_init()
  Revert "[media] rc: rc-ir-raw: Add scancode encoder callback"
  Revert "[media] rc: rc-ir-raw: Add Manchester encoder (phase encoder) helper"
  Revert "[media] rc: ir-rc5-decoder: Add encode capability"
  Revert "[media] rc: ir-rc6-decoder: Add encode capability"
  Revert "[media] rc: rc-core: Add support for encode_wakeup drivers"
  Revert "[media] rc: rc-loopback: Add loopback of filter scancodes"
  Revert "[media] rc: nuvoton-cir: Add support for writing wakeup samples via sysfs filter callback"
  [media] vb2: Fix compilation breakage when !CONFIG_BUG
  [media] vb2: Only requeue buffers immediately once streaming is started
  [media] media/pci/cobalt: fix Kconfig and build when SND is not enabled
  [media] media/dvb: fix ts2020.c Kconfig and build
This commit is contained in:
Linus Torvalds 2015-08-21 11:03:06 -07:00
commit 00f7641046
15 changed files with 34 additions and 609 deletions

View file

@ -240,7 +240,7 @@ config DVB_SI21XX
config DVB_TS2020 config DVB_TS2020
tristate "Montage Tehnology TS2020 based tuners" tristate "Montage Tehnology TS2020 based tuners"
depends on DVB_CORE depends on DVB_CORE && I2C
select REGMAP_I2C select REGMAP_I2C
default m if !MEDIA_SUBDRV_AUTOSELECT default m if !MEDIA_SUBDRV_AUTOSELECT
help help

View file

@ -2,6 +2,7 @@ config VIDEO_COBALT
tristate "Cisco Cobalt support" tristate "Cisco Cobalt support"
depends on VIDEO_V4L2 && I2C && MEDIA_CONTROLLER depends on VIDEO_V4L2 && I2C && MEDIA_CONTROLLER
depends on PCI_MSI && MTD_COMPLEX_MAPPINGS && GPIOLIB depends on PCI_MSI && MTD_COMPLEX_MAPPINGS && GPIOLIB
depends on SND
select I2C_ALGOBIT select I2C_ALGOBIT
select VIDEO_ADV7604 select VIDEO_ADV7604
select VIDEO_ADV7511 select VIDEO_ADV7511

View file

@ -139,7 +139,7 @@ static void cobalt_dma_stream_queue_handler(struct cobalt_stream *s)
also know about dropped frames. */ also know about dropped frames. */
cb->vb.v4l2_buf.sequence = s->sequence++; cb->vb.v4l2_buf.sequence = s->sequence++;
vb2_buffer_done(&cb->vb, (skip || s->unstable_frame) ? vb2_buffer_done(&cb->vb, (skip || s->unstable_frame) ?
VB2_BUF_STATE_QUEUED : VB2_BUF_STATE_DONE); VB2_BUF_STATE_REQUEUEING : VB2_BUF_STATE_DONE);
} }
irqreturn_t cobalt_irq_handler(int irq, void *dev_id) irqreturn_t cobalt_irq_handler(int irq, void *dev_id)

View file

@ -130,10 +130,11 @@ static inline int mantis_alloc_buffers(struct mantis_pci *mantis)
int mantis_dma_init(struct mantis_pci *mantis) int mantis_dma_init(struct mantis_pci *mantis)
{ {
int err = 0; int err;
dprintk(MANTIS_DEBUG, 1, "Mantis DMA init"); dprintk(MANTIS_DEBUG, 1, "Mantis DMA init");
if (mantis_alloc_buffers(mantis) < 0) { err = mantis_alloc_buffers(mantis);
if (err < 0) {
dprintk(MANTIS_ERROR, 1, "Error allocating DMA buffer"); dprintk(MANTIS_ERROR, 1, "Error allocating DMA buffer");
/* Stop RISC Engine */ /* Stop RISC Engine */

View file

@ -184,125 +184,9 @@ static int ir_rc5_decode(struct rc_dev *dev, struct ir_raw_event ev)
return -EINVAL; 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 = { static struct ir_raw_handler rc5_handler = {
.protocols = RC_BIT_RC5 | RC_BIT_RC5X | RC_BIT_RC5_SZ, .protocols = RC_BIT_RC5 | RC_BIT_RC5X | RC_BIT_RC5_SZ,
.decode = ir_rc5_decode, .decode = ir_rc5_decode,
.encode = ir_rc5_encode,
}; };
static int __init ir_rc5_decode_init(void) static int __init ir_rc5_decode_init(void)

View file

@ -291,133 +291,11 @@ static int ir_rc6_decode(struct rc_dev *dev, struct ir_raw_event ev)
return -EINVAL; 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 = { static struct ir_raw_handler rc6_handler = {
.protocols = RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 | .protocols = RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 |
RC_BIT_RC6_6A_24 | RC_BIT_RC6_6A_32 | RC_BIT_RC6_6A_24 | RC_BIT_RC6_6A_32 |
RC_BIT_RC6_MCE, RC_BIT_RC6_MCE,
.decode = ir_rc6_decode, .decode = ir_rc6_decode,
.encode = ir_rc6_encode,
}; };
static int __init ir_rc6_decode_init(void) static int __init ir_rc6_decode_init(void)

View file

@ -526,130 +526,6 @@ static int nvt_set_tx_carrier(struct rc_dev *dev, u32 carrier)
return 0; 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 * 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 */ /* Set up the rc device */
rdev->priv = nvt; rdev->priv = nvt;
rdev->driver_type = RC_DRIVER_IR_RAW; rdev->driver_type = RC_DRIVER_IR_RAW;
rdev->encode_wakeup = true;
rdev->allowed_protocols = RC_BIT_ALL; rdev->allowed_protocols = RC_BIT_ALL;
rdev->open = nvt_open; rdev->open = nvt_open;
rdev->close = nvt_close; rdev->close = nvt_close;
rdev->tx_ir = nvt_tx_ir; rdev->tx_ir = nvt_tx_ir;
rdev->s_tx_carrier = nvt_set_tx_carrier; 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_name = "Nuvoton w836x7hg Infrared Remote Transceiver";
rdev->input_phys = "nuvoton/cir0"; rdev->input_phys = "nuvoton/cir0";
rdev->input_id.bustype = BUS_HOST; rdev->input_id.bustype = BUS_HOST;

View file

@ -63,7 +63,6 @@ static int debug;
*/ */
#define TX_BUF_LEN 256 #define TX_BUF_LEN 256
#define RX_BUF_LEN 32 #define RX_BUF_LEN 32
#define WAKE_FIFO_LEN 67
struct nvt_dev { struct nvt_dev {
struct pnp_dev *pdev; struct pnp_dev *pdev;

View file

@ -25,8 +25,6 @@ struct ir_raw_handler {
u64 protocols; /* which are handled by this handler */ u64 protocols; /* which are handled by this handler */
int (*decode)(struct rc_dev *dev, struct ir_raw_event event); 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 */ /* These two should only be used by the lirc decoder */
int (*raw_register)(struct rc_dev *dev); int (*raw_register)(struct rc_dev *dev);
@ -152,44 +150,10 @@ static inline bool is_timing_event(struct ir_raw_event ev)
#define TO_US(duration) DIV_ROUND_CLOSEST((duration), 1000) #define TO_US(duration) DIV_ROUND_CLOSEST((duration), 1000)
#define TO_STR(is_pulse) ((is_pulse) ? "pulse" : "space") #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 * Routines from rc-raw.c to be used internally and by decoders
*/ */
u64 ir_raw_get_allowed_protocols(void); u64 ir_raw_get_allowed_protocols(void);
u64 ir_raw_get_encode_protocols(void);
int ir_raw_event_register(struct rc_dev *dev); int ir_raw_event_register(struct rc_dev *dev);
void ir_raw_event_unregister(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); int ir_raw_handler_register(struct ir_raw_handler *ir_raw_handler);

View file

@ -30,7 +30,6 @@ static LIST_HEAD(ir_raw_client_list);
static DEFINE_MUTEX(ir_raw_handler_lock); static DEFINE_MUTEX(ir_raw_handler_lock);
static LIST_HEAD(ir_raw_handler_list); static LIST_HEAD(ir_raw_handler_list);
static u64 available_protocols; static u64 available_protocols;
static u64 encode_protocols;
static int ir_raw_event_thread(void *data) static int ir_raw_event_thread(void *data)
{ {
@ -241,146 +240,12 @@ ir_raw_get_allowed_protocols(void)
return protocols; 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) static int change_protocol(struct rc_dev *dev, u64 *rc_type)
{ {
/* the caller will update dev->enabled_protocols */ /* the caller will update dev->enabled_protocols */
return 0; return 0;
} }
/**
* ir_raw_gen_manchester() - Encode data with Manchester (bi-phase) modulation.
* @ev: Pointer to pointer to next free event. *@ev is incremented for
* each raw event filled.
* @max: Maximum number of raw events to fill.
* @timings: Manchester modulation timings.
* @n: Number of bits of data.
* @data: Data bits to encode.
*
* Encodes the @n least significant bits of @data using Manchester (bi-phase)
* modulation with the timing characteristics described by @timings, writing up
* to @max raw IR events using the *@ev pointer.
*
* Returns: 0 on success.
* -ENOBUFS if there isn't enough space in the array to fit the
* full encoded data. In this case all @max events will have been
* written.
*/
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)
{
bool need_pulse;
unsigned int i;
int ret = -ENOBUFS;
i = 1 << (n - 1);
if (timings->leader) {
if (!max--)
return ret;
if (timings->pulse_space_start) {
init_ir_raw_event_duration((*ev)++, 1, timings->leader);
if (!max--)
return ret;
init_ir_raw_event_duration((*ev), 0, timings->leader);
} else {
init_ir_raw_event_duration((*ev), 1, timings->leader);
}
i >>= 1;
} else {
/* continue existing signal */
--(*ev);
}
/* from here on *ev will point to the last event rather than the next */
while (n && i > 0) {
need_pulse = !(data & i);
if (timings->invert)
need_pulse = !need_pulse;
if (need_pulse == !!(*ev)->pulse) {
(*ev)->duration += timings->clock;
} else {
if (!max--)
goto nobufs;
init_ir_raw_event_duration(++(*ev), need_pulse,
timings->clock);
}
if (!max--)
goto nobufs;
init_ir_raw_event_duration(++(*ev), !need_pulse,
timings->clock);
i >>= 1;
}
if (timings->trailer_space) {
if (!(*ev)->pulse)
(*ev)->duration += timings->trailer_space;
else if (!max--)
goto nobufs;
else
init_ir_raw_event_duration(++(*ev), 0,
timings->trailer_space);
}
ret = 0;
nobufs:
/* point to the next event rather than last event before returning */
++(*ev);
return ret;
}
EXPORT_SYMBOL(ir_raw_gen_manchester);
/**
* 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 * Used to (un)register raw event clients
*/ */
@ -463,8 +328,6 @@ int ir_raw_handler_register(struct ir_raw_handler *ir_raw_handler)
list_for_each_entry(raw, &ir_raw_client_list, list) list_for_each_entry(raw, &ir_raw_client_list, list)
ir_raw_handler->raw_register(raw->dev); ir_raw_handler->raw_register(raw->dev);
available_protocols |= ir_raw_handler->protocols; available_protocols |= ir_raw_handler->protocols;
if (ir_raw_handler->encode)
encode_protocols |= ir_raw_handler->protocols;
mutex_unlock(&ir_raw_handler_lock); mutex_unlock(&ir_raw_handler_lock);
return 0; return 0;
@ -481,8 +344,6 @@ void ir_raw_handler_unregister(struct ir_raw_handler *ir_raw_handler)
list_for_each_entry(raw, &ir_raw_client_list, list) list_for_each_entry(raw, &ir_raw_client_list, list)
ir_raw_handler->raw_unregister(raw->dev); ir_raw_handler->raw_unregister(raw->dev);
available_protocols &= ~ir_raw_handler->protocols; available_protocols &= ~ir_raw_handler->protocols;
if (ir_raw_handler->encode)
encode_protocols &= ~ir_raw_handler->protocols;
mutex_unlock(&ir_raw_handler_lock); mutex_unlock(&ir_raw_handler_lock);
} }
EXPORT_SYMBOL(ir_raw_handler_unregister); EXPORT_SYMBOL(ir_raw_handler_unregister);

View file

@ -26,7 +26,6 @@
#include <linux/device.h> #include <linux/device.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/slab.h>
#include <media/rc-core.h> #include <media/rc-core.h>
#define DRIVER_NAME "rc-loopback" #define DRIVER_NAME "rc-loopback"
@ -177,39 +176,6 @@ static int loop_set_carrier_report(struct rc_dev *dev, int enable)
return 0; 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) static int __init loop_init(void)
{ {
struct rc_dev *rc; struct rc_dev *rc;
@ -229,7 +195,6 @@ static int __init loop_init(void)
rc->map_name = RC_MAP_EMPTY; rc->map_name = RC_MAP_EMPTY;
rc->priv = &loopdev; rc->priv = &loopdev;
rc->driver_type = RC_DRIVER_IR_RAW; rc->driver_type = RC_DRIVER_IR_RAW;
rc->encode_wakeup = true;
rc->allowed_protocols = RC_BIT_ALL; rc->allowed_protocols = RC_BIT_ALL;
rc->timeout = 100 * 1000 * 1000; /* 100 ms */ rc->timeout = 100 * 1000 * 1000; /* 100 ms */
rc->min_timeout = 1; rc->min_timeout = 1;
@ -244,7 +209,6 @@ static int __init loop_init(void)
rc->s_idle = loop_set_idle; rc->s_idle = loop_set_idle;
rc->s_learning_mode = loop_set_learning_mode; rc->s_learning_mode = loop_set_learning_mode;
rc->s_carrier_report = loop_set_carrier_report; rc->s_carrier_report = loop_set_carrier_report;
rc->s_wakeup_filter = loop_set_wakeup_filter;
loopdev.txmask = RXMASK_REGULAR; loopdev.txmask = RXMASK_REGULAR;
loopdev.txcarrier = 36000; loopdev.txcarrier = 36000;

View file

@ -865,8 +865,6 @@ static ssize_t show_protocols(struct device *device,
} else { } else {
enabled = dev->enabled_wakeup_protocols; enabled = dev->enabled_wakeup_protocols;
allowed = dev->allowed_wakeup_protocols; allowed = dev->allowed_wakeup_protocols;
if (dev->encode_wakeup && !allowed)
allowed = ir_raw_get_encode_protocols();
} }
mutex_unlock(&dev->lock); mutex_unlock(&dev->lock);
@ -1408,16 +1406,13 @@ int rc_register_device(struct rc_dev *dev)
path ? path : "N/A"); path ? path : "N/A");
kfree(path); 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 */ /* Load raw decoders, if they aren't already */
if (!raw_init) { if (!raw_init) {
IR_dprintk(1, "Loading raw decoders\n"); IR_dprintk(1, "Loading raw decoders\n");
ir_raw_init(); ir_raw_init();
raw_init = true; raw_init = true;
} }
}
if (dev->driver_type == RC_DRIVER_IR_RAW) {
/* calls ir_register_device so unlock mutex here*/ /* calls ir_register_device so unlock mutex here*/
mutex_unlock(&dev->lock); mutex_unlock(&dev->lock);
rc = ir_raw_event_register(dev); rc = ir_raw_event_register(dev);

View file

@ -715,6 +715,7 @@ static void __fill_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b)
break; break;
case VB2_BUF_STATE_PREPARING: case VB2_BUF_STATE_PREPARING:
case VB2_BUF_STATE_DEQUEUED: case VB2_BUF_STATE_DEQUEUED:
case VB2_BUF_STATE_REQUEUEING:
/* nothing */ /* nothing */
break; break;
} }
@ -1182,7 +1183,8 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state)
if (WARN_ON(state != VB2_BUF_STATE_DONE && if (WARN_ON(state != VB2_BUF_STATE_DONE &&
state != VB2_BUF_STATE_ERROR && state != VB2_BUF_STATE_ERROR &&
state != VB2_BUF_STATE_QUEUED)) state != VB2_BUF_STATE_QUEUED &&
state != VB2_BUF_STATE_REQUEUEING))
state = VB2_BUF_STATE_ERROR; state = VB2_BUF_STATE_ERROR;
#ifdef CONFIG_VIDEO_ADV_DEBUG #ifdef CONFIG_VIDEO_ADV_DEBUG
@ -1199,22 +1201,30 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state)
for (plane = 0; plane < vb->num_planes; ++plane) for (plane = 0; plane < vb->num_planes; ++plane)
call_void_memop(vb, finish, vb->planes[plane].mem_priv); call_void_memop(vb, finish, vb->planes[plane].mem_priv);
/* Add the buffer to the done buffers list */
spin_lock_irqsave(&q->done_lock, flags); spin_lock_irqsave(&q->done_lock, flags);
vb->state = state; if (state == VB2_BUF_STATE_QUEUED ||
if (state != VB2_BUF_STATE_QUEUED) state == VB2_BUF_STATE_REQUEUEING) {
vb->state = VB2_BUF_STATE_QUEUED;
} else {
/* Add the buffer to the done buffers list */
list_add_tail(&vb->done_entry, &q->done_list); list_add_tail(&vb->done_entry, &q->done_list);
vb->state = state;
}
atomic_dec(&q->owned_by_drv_count); atomic_dec(&q->owned_by_drv_count);
spin_unlock_irqrestore(&q->done_lock, flags); spin_unlock_irqrestore(&q->done_lock, flags);
if (state == VB2_BUF_STATE_QUEUED) { switch (state) {
case VB2_BUF_STATE_QUEUED:
return;
case VB2_BUF_STATE_REQUEUEING:
if (q->start_streaming_called) if (q->start_streaming_called)
__enqueue_in_driver(vb); __enqueue_in_driver(vb);
return; return;
default:
/* Inform any processes that may be waiting for buffers */
wake_up(&q->done_wq);
break;
} }
/* Inform any processes that may be waiting for buffers */
wake_up(&q->done_wq);
} }
EXPORT_SYMBOL_GPL(vb2_buffer_done); EXPORT_SYMBOL_GPL(vb2_buffer_done);
@ -1244,19 +1254,19 @@ EXPORT_SYMBOL_GPL(vb2_discard_done);
static void vb2_warn_zero_bytesused(struct vb2_buffer *vb) static void vb2_warn_zero_bytesused(struct vb2_buffer *vb)
{ {
static bool __check_once __read_mostly; static bool check_once;
if (__check_once) if (check_once)
return; return;
__check_once = true; check_once = true;
__WARN(); WARN_ON(1);
pr_warn_once("use of bytesused == 0 is deprecated and will be removed in the future,\n"); pr_warn("use of bytesused == 0 is deprecated and will be removed in the future,\n");
if (vb->vb2_queue->allow_zero_bytesused) if (vb->vb2_queue->allow_zero_bytesused)
pr_warn_once("use VIDIOC_DECODER_CMD(V4L2_DEC_CMD_STOP) instead.\n"); pr_warn("use VIDIOC_DECODER_CMD(V4L2_DEC_CMD_STOP) instead.\n");
else else
pr_warn_once("use the actual size instead.\n"); pr_warn("use the actual size instead.\n");
} }
/** /**

View file

@ -74,8 +74,6 @@ enum rc_filter_type {
* @input_dev: the input child device used to communicate events to userspace * @input_dev: the input child device used to communicate events to userspace
* @driver_type: specifies if protocol decoding is done in hardware or software * @driver_type: specifies if protocol decoding is done in hardware or software
* @idle: used to keep track of RX state * @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 * @allowed_protocols: bitmask with the supported RC_BIT_* protocols
* @enabled_protocols: bitmask with the enabled RC_BIT_* protocols * @enabled_protocols: bitmask with the enabled RC_BIT_* protocols
* @allowed_wakeup_protocols: bitmask with the supported RC_BIT_* wakeup protocols * @allowed_wakeup_protocols: bitmask with the supported RC_BIT_* wakeup protocols
@ -136,7 +134,6 @@ struct rc_dev {
struct input_dev *input_dev; struct input_dev *input_dev;
enum rc_driver_type driver_type; enum rc_driver_type driver_type;
bool idle; bool idle;
bool encode_wakeup;
u64 allowed_protocols; u64 allowed_protocols;
u64 enabled_protocols; u64 enabled_protocols;
u64 allowed_wakeup_protocols; u64 allowed_wakeup_protocols;
@ -246,7 +243,6 @@ static inline void init_ir_raw_event(struct ir_raw_event *ev)
#define US_TO_NS(usec) ((usec) * 1000) #define US_TO_NS(usec) ((usec) * 1000)
#define MS_TO_US(msec) ((msec) * 1000) #define MS_TO_US(msec) ((msec) * 1000)
#define MS_TO_NS(msec) ((msec) * 1000 * 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); void ir_raw_event_handle(struct rc_dev *dev);
int ir_raw_event_store(struct rc_dev *dev, struct ir_raw_event *ev); int ir_raw_event_store(struct rc_dev *dev, struct ir_raw_event *ev);
@ -254,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, int ir_raw_event_store_with_filter(struct rc_dev *dev,
struct ir_raw_event *ev); struct ir_raw_event *ev);
void ir_raw_event_set_idle(struct rc_dev *dev, bool idle); 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) static inline void ir_raw_event_reset(struct rc_dev *dev)
{ {

View file

@ -139,6 +139,7 @@ enum vb2_io_modes {
* @VB2_BUF_STATE_PREPARING: buffer is being prepared in videobuf * @VB2_BUF_STATE_PREPARING: buffer is being prepared in videobuf
* @VB2_BUF_STATE_PREPARED: buffer prepared in videobuf and by the driver * @VB2_BUF_STATE_PREPARED: buffer prepared in videobuf and by the driver
* @VB2_BUF_STATE_QUEUED: buffer queued in videobuf, but not in driver * @VB2_BUF_STATE_QUEUED: buffer queued in videobuf, but not in driver
* @VB2_BUF_STATE_REQUEUEING: re-queue a buffer to the driver
* @VB2_BUF_STATE_ACTIVE: buffer queued in driver and possibly used * @VB2_BUF_STATE_ACTIVE: buffer queued in driver and possibly used
* in a hardware operation * in a hardware operation
* @VB2_BUF_STATE_DONE: buffer returned from driver to videobuf, but * @VB2_BUF_STATE_DONE: buffer returned from driver to videobuf, but
@ -152,6 +153,7 @@ enum vb2_buffer_state {
VB2_BUF_STATE_PREPARING, VB2_BUF_STATE_PREPARING,
VB2_BUF_STATE_PREPARED, VB2_BUF_STATE_PREPARED,
VB2_BUF_STATE_QUEUED, VB2_BUF_STATE_QUEUED,
VB2_BUF_STATE_REQUEUEING,
VB2_BUF_STATE_ACTIVE, VB2_BUF_STATE_ACTIVE,
VB2_BUF_STATE_DONE, VB2_BUF_STATE_DONE,
VB2_BUF_STATE_ERROR, VB2_BUF_STATE_ERROR,