本文整理汇总了C++中V4L2_TYPE_IS_OUTPUT函数的典型用法代码示例。如果您正苦于以下问题:C++ V4L2_TYPE_IS_OUTPUT函数的具体用法?C++ V4L2_TYPE_IS_OUTPUT怎么用?C++ V4L2_TYPE_IS_OUTPUT使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了V4L2_TYPE_IS_OUTPUT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: __fill_vb2_buffer
/**
* __fill_vb2_buffer() - fill a vb2_buffer with information provided in
* a v4l2_buffer by the userspace
*/
static int __fill_vb2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b,
struct v4l2_plane *v4l2_planes)
{
unsigned int plane;
int ret;
if (V4L2_TYPE_IS_MULTIPLANAR(b->type)) {
/*
* Verify that the userspace gave us a valid array for
* plane information.
*/
ret = __verify_planes_array(vb, b);
if (ret)
return ret;
/* Fill in driver-provided information for OUTPUT types */
if (V4L2_TYPE_IS_OUTPUT(b->type)) {
/*
* Will have to go up to b->length when API starts
* accepting variable number of planes.
*/
for (plane = 0; plane < vb->num_planes; ++plane) {
v4l2_planes[plane].bytesused =
b->m.planes[plane].bytesused;
v4l2_planes[plane].data_offset =
b->m.planes[plane].data_offset;
}
}
if (b->memory == V4L2_MEMORY_USERPTR) {
for (plane = 0; plane < vb->num_planes; ++plane) {
v4l2_planes[plane].m.userptr =
b->m.planes[plane].m.userptr;
v4l2_planes[plane].length =
b->m.planes[plane].length;
}
}
} else {
/*
* Single-planar buffers do not use planes array,
* so fill in relevant v4l2_buffer struct fields instead.
* In videobuf we use our internal V4l2_planes struct for
* single-planar buffers as well, for simplicity.
*/
if (V4L2_TYPE_IS_OUTPUT(b->type))
v4l2_planes[0].bytesused = b->bytesused;
if (b->memory == V4L2_MEMORY_USERPTR) {
v4l2_planes[0].m.userptr = b->m.userptr;
v4l2_planes[0].length = b->length;
}
}
vb->v4l2_buf.field = b->field;
vb->v4l2_buf.timestamp = b->timestamp;
vb->v4l2_buf.input = b->input;
vb->v4l2_buf.flags = b->flags & ~V4L2_BUFFER_STATE_FLAGS;
return 0;
}
示例2: vb2_poll
/**
* vb2_poll() - implements poll userspace operation
* @q: videobuf2 queue
* @file: file argument passed to the poll file operation handler
* @wait: wait argument passed to the poll file operation handler
*
* This function implements poll file operation handler for a driver.
* For CAPTURE queues, if a buffer is ready to be dequeued, the userspace will
* be informed that the file descriptor of a video device is available for
* reading.
* For OUTPUT queues, if a buffer is ready to be dequeued, the file descriptor
* will be reported as available for writing.
*
* The return values from this function are intended to be directly returned
* from poll handler in driver.
*/
unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait)
{
unsigned long flags;
unsigned int ret;
struct vb2_buffer *vb = NULL;
/*
* Start file I/O emulator only if streaming API has not been used yet.
*/
if (q->num_buffers == 0 && q->fileio == NULL) {
if (!V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_READ)) {
ret = __vb2_init_fileio(q, 1);
if (ret)
return POLLERR;
}
if (V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_WRITE)) {
ret = __vb2_init_fileio(q, 0);
if (ret)
return POLLERR;
/*
* Write to OUTPUT queue can be done immediately.
*/
return POLLOUT | POLLWRNORM;
}
}
/*
* There is nothing to wait for if no buffers have already been queued.
*/
if (list_empty(&q->queued_list))
return POLLERR;
poll_wait(file, &q->done_wq, wait);
/*
* Take first buffer available for dequeuing.
*/
spin_lock_irqsave(&q->done_lock, flags);
if (!list_empty(&q->done_list))
vb = list_first_entry(&q->done_list, struct vb2_buffer,
done_entry);
spin_unlock_irqrestore(&q->done_lock, flags);
if (vb && (vb->state == VB2_BUF_STATE_DONE
|| vb->state == VB2_BUF_STATE_ERROR)) {
return (V4L2_TYPE_IS_OUTPUT(q->type)) ? POLLOUT | POLLWRNORM :
POLLIN | POLLRDNORM;
}
return 0;
}
示例3: fimc_querybuf
static int fimc_querybuf(struct file *filp, void *fh, struct v4l2_buffer *b)
{
struct fimc_control *ctrl = ((struct fimc_prv_data *)fh)->ctrl;
int ret = -1;
#ifdef CONFIG_SLP_DMABUF
if (V4L2_TYPE_IS_OUTPUT(b->type)) {
ret = fimc_querybuf_output(fh, b);
} else if (b->type == V4L2_BUF_TYPE_VIDEO_CAPTURE
|| b->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
ret = fimc_querybuf_capture(ctrl, b);
} else {
fimc_err("V4L2_BUF_TYPE_VIDEO_CAPTURE and "
"V4L2_BUF_TYPE_VIDEO_OUTPUT are only supported\n");
ret = -EINVAL;
}
#else
if (b->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
ret = fimc_querybuf_capture(ctrl, b);
} else if (b->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
ret = fimc_querybuf_output(fh, b);
} else {
fimc_err("V4L2_BUF_TYPE_VIDEO_CAPTURE and "
"V4L2_BUF_TYPE_VIDEO_OUTPUT are only supported\n");
ret = -EINVAL;
}
#endif
return ret;
}
示例4: fimc_streamoff
static int fimc_streamoff(struct file *filp, void *fh, enum v4l2_buf_type i)
{
struct fimc_control *ctrl = ((struct fimc_prv_data *)fh)->ctrl;
int ret = -1;
#ifdef CONFIG_SLP_DMABUF
if (V4L2_TYPE_IS_OUTPUT(i)) {
ret = fimc_streamoff_output(fh);
} else if (i == V4L2_BUF_TYPE_VIDEO_CAPTURE
|| i == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
ret = fimc_streamoff_capture(ctrl);
} else {
fimc_err("V4L2_BUF_TYPE_VIDEO_CAPTURE and "
"V4L2_BUF_TYPE_VIDEO_OUTPUT are only supported\n");
ret = -EINVAL;
}
#else
if (i == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
ret = fimc_streamoff_capture(ctrl);
} else if (i == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
ret = fimc_streamoff_output(fh);
} else {
fimc_err("V4L2_BUF_TYPE_VIDEO_CAPTURE and "
"V4L2_BUF_TYPE_VIDEO_OUTPUT are only supported\n");
ret = -EINVAL;
}
#endif
return ret;
}
示例5: vb2_queue_init
/**
* vb2_queue_init() - initialize a videobuf2 queue
* @q: videobuf2 queue; this structure should be allocated in driver
*
* The vb2_queue structure should be allocated by the driver. The driver is
* responsible of clearing it's content and setting initial values for some
* required entries before calling this function.
* q->ops, q->mem_ops, q->type and q->io_modes are mandatory. Please refer
* to the struct vb2_queue description in include/media/videobuf2-core.h
* for more information.
*/
int vb2_queue_init(struct vb2_queue *q)
{
/*
* Sanity check
*/
if (WARN_ON(!q) ||
WARN_ON(q->timestamp_flags &
~(V4L2_BUF_FLAG_TIMESTAMP_MASK |
V4L2_BUF_FLAG_TSTAMP_SRC_MASK)))
return -EINVAL;
/* Warn that the driver should choose an appropriate timestamp type */
WARN_ON((q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) ==
V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN);
/* Warn that vb2_memory should match with v4l2_memory */
if (WARN_ON(VB2_MEMORY_MMAP != (int)V4L2_MEMORY_MMAP)
|| WARN_ON(VB2_MEMORY_USERPTR != (int)V4L2_MEMORY_USERPTR)
|| WARN_ON(VB2_MEMORY_DMABUF != (int)V4L2_MEMORY_DMABUF))
return -EINVAL;
if (q->buf_struct_size == 0)
q->buf_struct_size = sizeof(struct vb2_v4l2_buffer);
q->buf_ops = &v4l2_buf_ops;
q->is_multiplanar = V4L2_TYPE_IS_MULTIPLANAR(q->type);
q->is_output = V4L2_TYPE_IS_OUTPUT(q->type);
q->copy_timestamp = (q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK)
== V4L2_BUF_FLAG_TIMESTAMP_COPY;
return vb2_core_queue_init(q);
}
示例6: fimc_is_3a1_video_reqbufs
static int fimc_is_3a1_video_reqbufs(struct file *file, void *priv,
struct v4l2_requestbuffers *buf)
{
int ret = 0;
struct fimc_is_video_ctx *vctx = file->private_data;
struct fimc_is_device_ischain *device;
BUG_ON(!vctx);
mdbgv_3a1("%s(buffers : %d)\n", vctx, __func__, buf->count);
device = vctx->device;
if (!device) {
merr("device is NULL", vctx);
ret = -EINVAL;
goto p_err;
}
if (V4L2_TYPE_IS_OUTPUT(buf->type)) {
ret = fimc_is_ischain_3a1_reqbufs(device, buf->count);
if (ret) {
merr("3a1_reqbufs is fail(%d)", vctx, ret);
goto p_err;
}
}
ret = fimc_is_video_reqbufs(file, vctx, buf);
if (ret)
merr("fimc_is_video_reqbufs is fail(error %d)", vctx, ret);
p_err:
return ret;
}
示例7: fimc_is_3a1_buffer_finish
static int fimc_is_3a1_buffer_finish(struct vb2_buffer *vb)
{
int ret = 0;
u32 index = vb->v4l2_buf.index;
struct fimc_is_video_ctx *vctx = vb->vb2_queue->drv_priv;
struct fimc_is_device_ischain *device = vctx->device;
struct fimc_is_group *group = &device->group_3ax;
struct fimc_is_subdev *subdev = &group->leader;
struct fimc_is_queue *queue;
BUG_ON(!vctx);
BUG_ON(!device);
#ifdef DBG_STREAMING
mdbgv_3a1("%s(%02d:%d)\n", vctx, __func__, vb->v4l2_buf.type, index);
#endif
if (V4L2_TYPE_IS_OUTPUT(vb->v4l2_buf.type)) {
queue = &vctx->q_src;
fimc_is_ischain_3a1_buffer_finish(device, index);
} else {
queue = &vctx->q_dst;
fimc_is_subdev_buffer_finish(subdev, index);
}
return ret;
}
示例8: __verify_length
/**
* __verify_length() - Verify that the bytesused value for each plane fits in
* the plane length and that the data offset doesn't exceed the bytesused value.
*/
static int __verify_length(struct vb2_buffer *vb, const struct v4l2_buffer *b)
{
unsigned int length;
unsigned int bytesused;
unsigned int plane;
if (!V4L2_TYPE_IS_OUTPUT(b->type))
return 0;
if (V4L2_TYPE_IS_MULTIPLANAR(b->type)) {
for (plane = 0; plane < vb->num_planes; ++plane) {
length = (b->memory == VB2_MEMORY_USERPTR ||
b->memory == VB2_MEMORY_DMABUF)
? b->m.planes[plane].length
: vb->planes[plane].length;
bytesused = b->m.planes[plane].bytesused
? b->m.planes[plane].bytesused : length;
if (b->m.planes[plane].bytesused > length)
return -EINVAL;
if (b->m.planes[plane].data_offset > 0 &&
b->m.planes[plane].data_offset >= bytesused)
return -EINVAL;
}
} else {
length = (b->memory == VB2_MEMORY_USERPTR)
? b->length : vb->planes[0].length;
if (b->bytesused > length)
return -EINVAL;
}
return 0;
}
示例9: gsc_m2m_streamon
static int gsc_m2m_streamon(struct file *file, void *fh,
enum v4l2_buf_type type)
{
struct gsc_ctx *ctx = fh_to_ctx(fh);
struct gsc_dev *gsc = ctx->gsc_dev;
struct exynos_platform_gscaler *pdata = gsc->pdata;
/* The source and target color format need to be set */
if (V4L2_TYPE_IS_OUTPUT(type)) {
if (!gsc_ctx_state_is_set(GSC_SRC_FMT, ctx))
return -EINVAL;
} else if (!gsc_ctx_state_is_set(GSC_DST_FMT, ctx)) {
return -EINVAL;
}
gsc_pm_qos_ctrl(gsc, GSC_QOS_ON, pdata->mif_min, pdata->int_min);
if (gsc->protected_content) {
int id = gsc->id + 3;
exynos_smc(SMC_PROTECTION_SET, 0, id, 1);
gsc_dbg("DRM enable");
}
return v4l2_m2m_streamon(file, ctx->m2m_ctx, type);
}
示例10: fimc_is_3a1_buffer_queue
static void fimc_is_3a1_buffer_queue(struct vb2_buffer *vb)
{
u32 index;
struct fimc_is_video_ctx *vctx = vb->vb2_queue->drv_priv;
struct fimc_is_device_ischain *device;
struct fimc_is_subdev *leader;
struct fimc_is_video *video;
struct fimc_is_queue *queue;
BUG_ON(!vctx);
index = vb->v4l2_buf.index;
#ifdef DBG_STREAMING
mdbgv_3a1("%s(%02d:%d)\n", vctx, __func__, vb->v4l2_buf.type, index);
#endif
video = vctx->video;
device = vctx->device;
leader = &device->group_3ax.leader;
if (V4L2_TYPE_IS_OUTPUT(vb->v4l2_buf.type)) {
queue = GET_SRC_QUEUE(vctx);
fimc_is_queue_buffer_queue(queue, video->vb2, vb);
fimc_is_ischain_3a1_buffer_queue(device, queue, index);
} else {
queue = GET_DST_QUEUE(vctx);
fimc_is_queue_buffer_queue(queue, video->vb2, vb);
fimc_is_subdev_buffer_queue(leader, index);
}
}
示例11: fimc_is_3a1_video_set_crop
static int fimc_is_3a1_video_set_crop(struct file *file, void *fh,
struct v4l2_crop *crop)
{
struct fimc_is_video_ctx *vctx = file->private_data;
struct fimc_is_device_ischain *ischain;
struct fimc_is_group *group;
struct fimc_is_subdev *subdev;
BUG_ON(!vctx);
mdbgv_3a1("%s\n", vctx, __func__);
ischain = vctx->device;
BUG_ON(!ischain);
group = &ischain->group_3ax;
BUG_ON(!group);
subdev = &group->leader;
if (V4L2_TYPE_IS_OUTPUT(crop->type))
fimc_is_ischain_3a1_s_format(ischain,
crop->c.width, crop->c.height);
else
fimc_is_subdev_s_format(subdev,
crop->c.width, crop->c.height);
return 0;
}
示例12: hva_stop_streaming
static void hva_stop_streaming(struct vb2_queue *vq)
{
struct hva_ctx *ctx = vb2_get_drv_priv(vq);
struct hva_dev *hva = ctx_to_hdev(ctx);
struct device *dev = ctx_to_dev(ctx);
const struct hva_enc *enc = ctx->enc;
struct vb2_v4l2_buffer *vbuf;
dev_dbg(dev, "%s %s stop streaming\n", ctx->name,
to_type_str(vq->type));
if (vq->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
/* return of all pending buffers to vb2 (in error state) */
ctx->frame_num = 0;
while ((vbuf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx)))
v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR);
} else {
/* return of all pending buffers to vb2 (in error state) */
ctx->stream_num = 0;
while ((vbuf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx)))
v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR);
}
if ((V4L2_TYPE_IS_OUTPUT(vq->type) &&
vb2_is_streaming(&ctx->fh.m2m_ctx->cap_q_ctx.q)) ||
(!V4L2_TYPE_IS_OUTPUT(vq->type) &&
vb2_is_streaming(&ctx->fh.m2m_ctx->out_q_ctx.q))) {
dev_dbg(dev, "%s %s out=%d cap=%d\n",
ctx->name, to_type_str(vq->type),
vb2_is_streaming(&ctx->fh.m2m_ctx->out_q_ctx.q),
vb2_is_streaming(&ctx->fh.m2m_ctx->cap_q_ctx.q));
return;
}
/* close encoder when both stop_streaming have been called */
if (enc) {
dev_dbg(dev, "%s %s encoder closed\n", ctx->name, enc->name);
enc->close(ctx);
ctx->enc = NULL;
/* clear instance context in instances array */
hva->instances[ctx->id] = NULL;
hva->nb_of_instances--;
}
ctx->aborting = false;
}
示例13:
static struct mtk_q_data *mtk_venc_get_q_data(struct mtk_vcodec_ctx *ctx,
enum v4l2_buf_type type)
{
if (V4L2_TYPE_IS_OUTPUT(type))
return &ctx->q_data[MTK_Q_DATA_SRC];
return &ctx->q_data[MTK_Q_DATA_DST];
}
示例14: __fill_vb2_buffer
static int __fill_vb2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b,
struct v4l2_plane *v4l2_planes)
{
unsigned int plane;
int ret;
if (V4L2_TYPE_IS_MULTIPLANAR(b->type)) {
ret = __verify_planes_array(vb, b);
if (ret)
return ret;
if (V4L2_TYPE_IS_OUTPUT(b->type)) {
for (plane = 0; plane < vb->num_planes; ++plane) {
v4l2_planes[plane].bytesused =
b->m.planes[plane].bytesused;
v4l2_planes[plane].data_offset =
b->m.planes[plane].data_offset;
}
}
if (b->memory == V4L2_MEMORY_USERPTR) {
for (plane = 0; plane < vb->num_planes; ++plane) {
v4l2_planes[plane].m.userptr =
b->m.planes[plane].m.userptr;
v4l2_planes[plane].length =
b->m.planes[plane].length;
}
}
} else {
if (V4L2_TYPE_IS_OUTPUT(b->type))
v4l2_planes[0].bytesused = b->bytesused;
if (b->memory == V4L2_MEMORY_USERPTR) {
v4l2_planes[0].m.userptr = b->m.userptr;
v4l2_planes[0].length = b->length;
}
}
vb->v4l2_buf.field = b->field;
vb->v4l2_buf.timestamp = b->timestamp;
vb->v4l2_buf.input = b->input;
vb->v4l2_buf.flags = b->flags & ~V4L2_BUFFER_STATE_FLAGS;
return 0;
}
示例15:
static struct v4l2_m2m_queue_ctx *get_queue_ctx(struct v4l2_m2m_ctx *m2m_ctx,
enum v4l2_buf_type type)
{
if (V4L2_TYPE_IS_OUTPUT(type))
return &m2m_ctx->out_q_ctx;
else
return &m2m_ctx->cap_q_ctx;
}