Re: [PATCH v4 1/9] media: v4l2-mem2mem: extend m2m APIs for more accurate buffer management
Hi Hans, On 12/05/2016 01:25 PM, Hans Verkuil wrote: > On 12/01/2016 10:03 AM, Stanimir Varbanov wrote: >> this add functions for: >> - remove buffers from src/dst queue by index >> - remove exact buffer from src/dst queue >> >> also extends m2m API to iterate over a list of src/dst buffers >> in safely and non-safely manner. >> >> Signed-off-by: Stanimir Varbanov >> --- >> drivers/media/v4l2-core/v4l2-mem2mem.c | 37 +++ >> include/media/v4l2-mem2mem.h | 83 >> ++ >> 2 files changed, 120 insertions(+) >> >> diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c >> b/drivers/media/v4l2-core/v4l2-mem2mem.c >> index 6bc27e7b2a33..d689e7bb964f 100644 >> --- a/drivers/media/v4l2-core/v4l2-mem2mem.c >> +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c >> @@ -126,6 +126,43 @@ void *v4l2_m2m_buf_remove(struct v4l2_m2m_queue_ctx >> *q_ctx) >> } >> EXPORT_SYMBOL_GPL(v4l2_m2m_buf_remove); >> >> +void v4l2_m2m_buf_remove_exact(struct v4l2_m2m_queue_ctx *q_ctx, >> + struct vb2_v4l2_buffer *vbuf) > > I'd call this v4l2_m2m_buf_remove_by_buf to be consistent with _by_idx. Thanks, I will rename it. -- regards, Stan -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 1/9] media: v4l2-mem2mem: extend m2m APIs for more accurate buffer management
On 12/01/2016 10:03 AM, Stanimir Varbanov wrote: > this add functions for: > - remove buffers from src/dst queue by index > - remove exact buffer from src/dst queue > > also extends m2m API to iterate over a list of src/dst buffers > in safely and non-safely manner. > > Signed-off-by: Stanimir Varbanov > --- > drivers/media/v4l2-core/v4l2-mem2mem.c | 37 +++ > include/media/v4l2-mem2mem.h | 83 > ++ > 2 files changed, 120 insertions(+) > > diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c > b/drivers/media/v4l2-core/v4l2-mem2mem.c > index 6bc27e7b2a33..d689e7bb964f 100644 > --- a/drivers/media/v4l2-core/v4l2-mem2mem.c > +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c > @@ -126,6 +126,43 @@ void *v4l2_m2m_buf_remove(struct v4l2_m2m_queue_ctx > *q_ctx) > } > EXPORT_SYMBOL_GPL(v4l2_m2m_buf_remove); > > +void v4l2_m2m_buf_remove_exact(struct v4l2_m2m_queue_ctx *q_ctx, > +struct vb2_v4l2_buffer *vbuf) I'd call this v4l2_m2m_buf_remove_by_buf to be consistent with _by_idx. Other than that, this looks OK. Regards, Hans > +{ > + struct v4l2_m2m_buffer *b; > + unsigned long flags; > + > + spin_lock_irqsave(&q_ctx->rdy_spinlock, flags); > + b = container_of(vbuf, struct v4l2_m2m_buffer, vb); > + list_del(&b->list); > + q_ctx->num_rdy--; > + spin_unlock_irqrestore(&q_ctx->rdy_spinlock, flags); > +} > +EXPORT_SYMBOL_GPL(v4l2_m2m_buf_remove_exact); > + > +struct vb2_v4l2_buffer * > +v4l2_m2m_buf_remove_by_idx(struct v4l2_m2m_queue_ctx *q_ctx, unsigned int > idx) > + > +{ > + struct v4l2_m2m_buffer *b, *tmp; > + struct vb2_v4l2_buffer *ret = NULL; > + unsigned long flags; > + > + spin_lock_irqsave(&q_ctx->rdy_spinlock, flags); > + list_for_each_entry_safe(b, tmp, &q_ctx->rdy_queue, list) { > + if (b->vb.vb2_buf.index == idx) { > + list_del(&b->list); > + q_ctx->num_rdy--; > + ret = &b->vb; > + break; > + } > + } > + spin_unlock_irqrestore(&q_ctx->rdy_spinlock, flags); > + > + return ret; > +} > +EXPORT_SYMBOL_GPL(v4l2_m2m_buf_remove_by_idx); > + > /* > * Scheduling handlers > */ > diff --git a/include/media/v4l2-mem2mem.h b/include/media/v4l2-mem2mem.h > index 3ccd01bd245e..c8632c52d5e2 100644 > --- a/include/media/v4l2-mem2mem.h > +++ b/include/media/v4l2-mem2mem.h > @@ -437,6 +437,41 @@ static inline void *v4l2_m2m_next_dst_buf(struct > v4l2_m2m_ctx *m2m_ctx) > } > > /** > + * v4l2_m2m_for_each_dst_buf() - iterate over a list of destination ready > + * buffers > + * > + * @m2m_ctx: m2m context assigned to the instance given by struct > &v4l2_m2m_ctx > + */ > +#define v4l2_m2m_for_each_dst_buf(m2m_ctx, b)\ > + list_for_each_entry(b, &m2m_ctx->cap_q_ctx.rdy_queue, list) > + > +/** > + * v4l2_m2m_for_each_src_buf() - iterate over a list of source ready buffers > + * > + * @m2m_ctx: m2m context assigned to the instance given by struct > &v4l2_m2m_ctx > + */ > +#define v4l2_m2m_for_each_src_buf(m2m_ctx, b)\ > + list_for_each_entry(b, &m2m_ctx->out_q_ctx.rdy_queue, list) > + > +/** > + * v4l2_m2m_for_each_dst_buf_safe() - iterate over a list of destination > ready > + * buffers safely > + * > + * @m2m_ctx: m2m context assigned to the instance given by struct > &v4l2_m2m_ctx > + */ > +#define v4l2_m2m_for_each_dst_buf_safe(m2m_ctx, b, n)\ > + list_for_each_entry_safe(b, n, &m2m_ctx->cap_q_ctx.rdy_queue, list) > + > +/** > + * v4l2_m2m_for_each_src_buf_safe() - iterate over a list of source ready > + * buffers safely > + * > + * @m2m_ctx: m2m context assigned to the instance given by struct > &v4l2_m2m_ctx > + */ > +#define v4l2_m2m_for_each_src_buf_safe(m2m_ctx, b, n)\ > + list_for_each_entry_safe(b, n, &m2m_ctx->out_q_ctx.rdy_queue, list) > + > +/** > * v4l2_m2m_get_src_vq() - return vb2_queue for source buffers > * > * @m2m_ctx: m2m context assigned to the instance given by struct > &v4l2_m2m_ctx > @@ -488,6 +523,54 @@ static inline void *v4l2_m2m_dst_buf_remove(struct > v4l2_m2m_ctx *m2m_ctx) > return v4l2_m2m_buf_remove(&m2m_ctx->cap_q_ctx); > } > > +/** > + * v4l2_m2m_buf_remove_exact() - take off exact buffer from the list of ready > + * buffers > + * > + * @q_ctx: pointer to struct @v4l2_m2m_queue_ctx > + */ > +void v4l2_m2m_buf_remove_exact(struct v4l2_m2m_queue_ctx *q_ctx, > +struct vb2_v4l2_buffer *vbuf); > + > +/** > + * v4l2_m2m_src_buf_remove_exact() - take off exact source buffer from the > list > + * of ready buffers > + * > + * @m2m_ctx: m2m context assigned to the instance given by struct > &v4l2_m2m_ctx > + */ > +static inline void v4l2_m2m_src_buf_remove_exact(struct v4l2_m2m_ctx > *m2m_ctx, > + struct vb2_v4l2_buffer *vbuf) > +{ > + v4l2_m2m_buf_remove_exact(&m2m_ctx->out_q_ctx,
Re: [PATCH v4 1/9] media: v4l2-mem2mem: extend m2m APIs for more accurate buffer management
Hi Stanimir, [auto build test WARNING on linuxtv-media/master] [also build test WARNING on v4.9-rc7 next-20161202] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Stanimir-Varbanov/Qualcomm-video-decoder-encoder-driver/20161203-054705 base: git://linuxtv.org/media_tree.git master reproduce: make htmldocs All warnings (new ones prefixed by >>): make[3]: warning: jobserver unavailable: using -j1. Add '+' to parent make rule. include/linux/init.h:1: warning: no structured comments found include/linux/workqueue.h:392: warning: No description found for parameter '...' include/linux/workqueue.h:392: warning: Excess function parameter 'args' description in 'alloc_workqueue' include/linux/workqueue.h:413: warning: No description found for parameter '...' include/linux/workqueue.h:413: warning: Excess function parameter 'args' description in 'alloc_ordered_workqueue' include/linux/kthread.h:26: warning: No description found for parameter '...' kernel/sys.c:1: warning: no structured comments found drivers/dma-buf/seqno-fence.c:1: warning: no structured comments found include/linux/fence-array.h:61: warning: No description found for parameter 'fence' include/sound/core.h:324: warning: No description found for parameter '...' include/sound/core.h:335: warning: No description found for parameter '...' include/sound/core.h:388: warning: No description found for parameter '...' drivers/media/dvb-core/dvb_frontend.h:677: warning: No description found for parameter 'refcount' include/media/media-entity.h:1054: warning: No description found for parameter '...' >> include/media/v4l2-mem2mem.h:446: warning: No description found for >> parameter 'b' include/media/v4l2-mem2mem.h:454: warning: No description found for parameter 'b' include/media/v4l2-mem2mem.h:463: warning: No description found for parameter 'b' >> include/media/v4l2-mem2mem.h:463: warning: No description found for >> parameter 'n' include/media/v4l2-mem2mem.h:472: warning: No description found for parameter 'b' include/media/v4l2-mem2mem.h:472: warning: No description found for parameter 'n' >> include/media/v4l2-mem2mem.h:533: warning: No description found for >> parameter 'vbuf' include/media/v4l2-mem2mem.h:543: warning: No description found for parameter 'vbuf' include/media/v4l2-mem2mem.h:555: warning: No description found for parameter 'vbuf' include/net/mac80211.h:3207: ERROR: Unexpected indentation. include/net/mac80211.h:3210: WARNING: Block quote ends without a blank line; unexpected unindent. include/net/mac80211.h:3212: ERROR: Unexpected indentation. include/net/mac80211.h:3213: WARNING: Block quote ends without a blank line; unexpected unindent. include/net/mac80211.h:1772: ERROR: Unexpected indentation. include/net/mac80211.h:1776: WARNING: Block quote ends without a blank line; unexpected unindent. kernel/sched/fair.c:7259: WARNING: Inline emphasis start-string without end-string. kernel/time/timer.c:1240: ERROR: Unexpected indentation. kernel/time/timer.c:1242: ERROR: Unexpected indentation. kernel/time/timer.c:1243: WARNING: Block quote ends without a blank line; unexpected unindent. include/linux/wait.h:121: WARNING: Block quote ends without a blank line; unexpected unindent. include/linux/wait.h:124: ERROR: Unexpected indentation. include/linux/wait.h:126: WARNING: Block quote ends without a blank line; unexpected unindent. kernel/time/hrtimer.c:1021: WARNING: Block quote ends without a blank line; unexpected unindent. kernel/signal.c:317: WARNING: Inline literal start-string without end-string. drivers/base/firmware_class.c:1348: WARNING: Bullet list ends without a blank line; unexpected unindent. drivers/message/fusion/mptbase.c:5054: WARNING: Definition list ends without a blank line; unexpected unindent. drivers/tty/serial/serial_core.c:1893: WARNING: Definition list ends without a blank line; unexpected unindent. include/linux/spi/spi.h:369: ERROR: Unexpected indentation. WARNING: dvipng command 'dvipng' cannot be run (needed for math display), check the imgmath_dvipng setting vim +/b +446 include/media/v4l2-mem2mem.h 440 * v4l2_m2m_for_each_dst_buf() - iterate over a list of destination ready 441 * buffers 442 * 443 * @m2m_ctx: m2m context assigned to the instance given by struct &v4l2_m2m_ctx 444 */ 445 #define v4l2_m2m_for_each_dst_buf(m2m_ctx, b) \ > 446 list_for_each_entry(b, &m2m_ctx->cap_q_ctx.rdy_queue, list) 447 448 /** 449 * v4l2_m2m_for_each_src_buf() - iterate over a list of source ready buffers 450 * 451 * @m2m_ctx: m2m context assigned to the instance given by struct &v4l2_m2m_ctx 452 */ 453 #define v4l2_m2m_for_each_src_buf(m2m_ctx, b) \ 454 list_for_each_entry(b, &m2m_ctx->o
[PATCH v4 1/9] media: v4l2-mem2mem: extend m2m APIs for more accurate buffer management
this add functions for: - remove buffers from src/dst queue by index - remove exact buffer from src/dst queue also extends m2m API to iterate over a list of src/dst buffers in safely and non-safely manner. Signed-off-by: Stanimir Varbanov --- drivers/media/v4l2-core/v4l2-mem2mem.c | 37 +++ include/media/v4l2-mem2mem.h | 83 ++ 2 files changed, 120 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c index 6bc27e7b2a33..d689e7bb964f 100644 --- a/drivers/media/v4l2-core/v4l2-mem2mem.c +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c @@ -126,6 +126,43 @@ void *v4l2_m2m_buf_remove(struct v4l2_m2m_queue_ctx *q_ctx) } EXPORT_SYMBOL_GPL(v4l2_m2m_buf_remove); +void v4l2_m2m_buf_remove_exact(struct v4l2_m2m_queue_ctx *q_ctx, + struct vb2_v4l2_buffer *vbuf) +{ + struct v4l2_m2m_buffer *b; + unsigned long flags; + + spin_lock_irqsave(&q_ctx->rdy_spinlock, flags); + b = container_of(vbuf, struct v4l2_m2m_buffer, vb); + list_del(&b->list); + q_ctx->num_rdy--; + spin_unlock_irqrestore(&q_ctx->rdy_spinlock, flags); +} +EXPORT_SYMBOL_GPL(v4l2_m2m_buf_remove_exact); + +struct vb2_v4l2_buffer * +v4l2_m2m_buf_remove_by_idx(struct v4l2_m2m_queue_ctx *q_ctx, unsigned int idx) + +{ + struct v4l2_m2m_buffer *b, *tmp; + struct vb2_v4l2_buffer *ret = NULL; + unsigned long flags; + + spin_lock_irqsave(&q_ctx->rdy_spinlock, flags); + list_for_each_entry_safe(b, tmp, &q_ctx->rdy_queue, list) { + if (b->vb.vb2_buf.index == idx) { + list_del(&b->list); + q_ctx->num_rdy--; + ret = &b->vb; + break; + } + } + spin_unlock_irqrestore(&q_ctx->rdy_spinlock, flags); + + return ret; +} +EXPORT_SYMBOL_GPL(v4l2_m2m_buf_remove_by_idx); + /* * Scheduling handlers */ diff --git a/include/media/v4l2-mem2mem.h b/include/media/v4l2-mem2mem.h index 3ccd01bd245e..c8632c52d5e2 100644 --- a/include/media/v4l2-mem2mem.h +++ b/include/media/v4l2-mem2mem.h @@ -437,6 +437,41 @@ static inline void *v4l2_m2m_next_dst_buf(struct v4l2_m2m_ctx *m2m_ctx) } /** + * v4l2_m2m_for_each_dst_buf() - iterate over a list of destination ready + * buffers + * + * @m2m_ctx: m2m context assigned to the instance given by struct &v4l2_m2m_ctx + */ +#define v4l2_m2m_for_each_dst_buf(m2m_ctx, b) \ + list_for_each_entry(b, &m2m_ctx->cap_q_ctx.rdy_queue, list) + +/** + * v4l2_m2m_for_each_src_buf() - iterate over a list of source ready buffers + * + * @m2m_ctx: m2m context assigned to the instance given by struct &v4l2_m2m_ctx + */ +#define v4l2_m2m_for_each_src_buf(m2m_ctx, b) \ + list_for_each_entry(b, &m2m_ctx->out_q_ctx.rdy_queue, list) + +/** + * v4l2_m2m_for_each_dst_buf_safe() - iterate over a list of destination ready + * buffers safely + * + * @m2m_ctx: m2m context assigned to the instance given by struct &v4l2_m2m_ctx + */ +#define v4l2_m2m_for_each_dst_buf_safe(m2m_ctx, b, n) \ + list_for_each_entry_safe(b, n, &m2m_ctx->cap_q_ctx.rdy_queue, list) + +/** + * v4l2_m2m_for_each_src_buf_safe() - iterate over a list of source ready + * buffers safely + * + * @m2m_ctx: m2m context assigned to the instance given by struct &v4l2_m2m_ctx + */ +#define v4l2_m2m_for_each_src_buf_safe(m2m_ctx, b, n) \ + list_for_each_entry_safe(b, n, &m2m_ctx->out_q_ctx.rdy_queue, list) + +/** * v4l2_m2m_get_src_vq() - return vb2_queue for source buffers * * @m2m_ctx: m2m context assigned to the instance given by struct &v4l2_m2m_ctx @@ -488,6 +523,54 @@ static inline void *v4l2_m2m_dst_buf_remove(struct v4l2_m2m_ctx *m2m_ctx) return v4l2_m2m_buf_remove(&m2m_ctx->cap_q_ctx); } +/** + * v4l2_m2m_buf_remove_exact() - take off exact buffer from the list of ready + * buffers + * + * @q_ctx: pointer to struct @v4l2_m2m_queue_ctx + */ +void v4l2_m2m_buf_remove_exact(struct v4l2_m2m_queue_ctx *q_ctx, + struct vb2_v4l2_buffer *vbuf); + +/** + * v4l2_m2m_src_buf_remove_exact() - take off exact source buffer from the list + * of ready buffers + * + * @m2m_ctx: m2m context assigned to the instance given by struct &v4l2_m2m_ctx + */ +static inline void v4l2_m2m_src_buf_remove_exact(struct v4l2_m2m_ctx *m2m_ctx, +struct vb2_v4l2_buffer *vbuf) +{ + v4l2_m2m_buf_remove_exact(&m2m_ctx->out_q_ctx, vbuf); +} + +/** + * v4l2_m2m_src_buf_remove_exact() - take off exact destination buffer from the + * list of ready buffers + * + * @m2m_ctx: m2m context assigned to the instance given by struct &v4l2_m2m_ctx + */ +static inline void v4l2_m2m_dst_buf_remove_exact(struct v4l2_m2m_ctx *m2m_ctx, +struct vb2_v4l2_buffer *vbuf) +{ + v4l2_m2m_buf_remove_exact(&m2m_ctx->cap_q_ctx, vbuf); +} + +s