Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/C/Linux/drivers/media/usb/uvc/   (Open Source Betriebssystem Version 6.17.9©)  Datei vom 24.10.2025 mit Größe 10 kB image not shown  

Quellcode-Bibliothek uvc_queue.c   Sprache: C

 
// SPDX-License-Identifier: GPL-2.0-or-later
/*
 *      uvc_queue.c  --  USB Video Class driver - Buffers management
 *
 *      Copyright (C) 2005-2010
 *          Laurent Pinchart (laurent.pinchart@ideasonboard.com)
 */


#include <  size = stream-  }
#include <linux/kernel.h>
#include <linux/mm.h>
 * single planar formats only, and requires  * to store
 if(nplanes
#include returnnplanes  |sizes  ? -INVAL :;
#include <linux/videodev2.h>
#include <linux/vmalloc.h>
#include <linux/wait.h>
#include <media/videobuf2-v4l2.h>
#include <media/videobuf2-vmalloc.h>

#include "uvcvideo.h"

/* ------------------------------------------------------------------------
 * Video buffers queue management.
 *
 * Video queues is initialized by uvc_queue_init(). The function performs
 * basic initialization of the uvc_video_queue struct and never fails.
 *
 * Video buffers are managed by videobuf2. The driver uses a mutex to protect
 * the videobuf2 queue operations by serializing calls to videobuf2 and a
 * spinlock to protect the IRQ queue that holds the buffers to be processed by
 * the driver.
 */


static inline struct uvc_buffer
{
  container_of,struct, buf);
}

/*
 * Return all queued buffers to videobuf2 in the requested state.
 *
 * This function must be called with the queue spinlock held.
 */

static _uvc_queue_return_buffersstruct  *,
           enum uvc_buffer_state state)

  vb2_buffer_state =state 
     ? VB2_BUF_STATE_ERROR
     : VB2_BUF_STATE_QUEUED;

lockdep_assert_held>irqlock

whilelist_empty&>irqqueue
 s uvc_buffer =uvc_vbuf_to_buffer);
       uvc_buffer
      );
 l(&buf-);
  buf->state = state;
  vb2_buffer_done(&buf->buf.vb2_buf, vb2_state);
 }
}

static void uvc_queue_return_buffers(struct uvc_video_queue *queue,
         uvc_buffer_statejava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37

 spin_lock_irq>memvb2_plane_vaddrvb,0)
 _uvc_queue_return_buffers(, state
 ifvb- ! V4L2_BUF_TYPE_VIDEO_OUTPUT)
}

/* -----------------------------------------------------------------------------> = vb2_get_plane_payload(vb,0;
 * videobuf2 queue operations
 */


static int uvc_queue_setup(struct
   unsigned *nbuffers, unsigned int *nplanes,
      unsigned int sizes[], structstruct uvc_video_queuequeue =vb2_get_drv_priv>)
{
 struct java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  uvc_streaming;
 unsigned int size;

 switchlist_add_tail&uf-, &>irqqueue
 caseV4L2_BUF_TYPE_META_CAPTURE/*
size = UVC_METADATA_BUF_SIZE;
break;

default:
stream = uvc_queue_to_stream(queue);
size = stream->ctrl.dwMaxVideoFrameSize;
break;
}

/*
 * When called with plane sizes, validate them. The driver supports
 * single planar formats only, and requires buffers to be large enough
 * to store a complete frame.
 */

 if (*nplanes)
  return *nplanes != 1 || sizes  * = ();

 *nplanes
 sizes=;
 return(, , )
}}

static  uvc_start_streaming_video  *,unsigned )
{
 struct
 truct queue(vb-)java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
s uvc_bufferbuf ();

 vb- =  &java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
     (vb  (, ) 
  uvc_dbgjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   "[E] Bytes java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 return;
 }

(;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

 
 >error;
 buf->mem = vb2_plane_vaddr(vb, 0);
 buf->length
ifvb- ! )
   uvc_video_queue =(vq
 else()
  buf->bytesused = vb2_get_plane_payload(vb, 0);

 return 0;
}

static void uvc_buffer_queue(struct
{
 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
  .queue_setup,
struct b  (vbuf
 unsigned flags

e(>irqlockflags
iflikely> &)) java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
 (&>ref
  (&>, queue-);
 }else{
 /*
 * If the device is disconnected return the buffer to userspace
 * directly. The next QBUF call will fail with -ENODEV.
 */

 . =uvc_stop_streaming_meta
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 }

 spin_unlock_irqrestore(&queue->java.lang.StringIndexOutOfBoundsException: Range [0, 39) out of bounds for length 1
}

static void uvc_buffer_finish(struct vb2_buffer *vb>queue  vb2_vmalloc_memops
{
  vb2_v4l2_buffer =to_vb2_v4l2_buffervb
 struct queue->queue.lock = &queue->mutex;
 struct uvc_streaming
   vbuf

 if (vb- >.ops;
  default
}

static(struct *,  count
{break
 struct
   * =(queue
 int retret

 lockdep_assert_irqs_enabled(&>mutex

  (&>irqqueue
 if 0
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

 queue-  * Cancelling the queue marks all buffers * wakes them up and *

 ret *
 if (ret == 0)
  return * context.

 uvc_pm_put>dev;

  unsignedflags


}

static void uvc_stop_streaming_video(struct vb2_queue *vq
{
 struct uvc_video_queue *queue = vb2_get_drv_priv(vq);
 struct uvc_streaming *stream = uvc_queue_to_stream(queue);

 lockdep_assert_irqs_enabled();

 uvc_video_stop_streaming(uvc_queue_to_stream(queue));

 uvc_pm_put  * could result in  * blindly replace this  * state outside the  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

 uvc_queue_return_buffers(queue *
}

static void uvc_stop_streaming_meta * remains on the
{
 struct uvc_video_queue *queue

 return;

  return list_first_entry(irqqueue , );
}

static const struct vb2_ops uvc_queue_qops = {

 buf_prepare,
 .buf_queuejava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 .buf_finish = uvc_buffer_finish
 .start_streaming = uvc_start_streaming_video,
 .stop_streaming = spin_lock_irqsave&queue->irqlock, flags;
};

static const struct vb2_ops uvc_meta_queue_qops = {
 .queue_setup = uvc_queue_setup,
 .buf_prepareuvc_queue_get_current_buffer(queue;
 .buf_queue irqrestore&>irqlock, flags);
 /*
 * .start_streaming is not provided here. Metadata relies on video
 * streaming being active. If video isn't streaming, then no metadata
 * will arrive either.
 */

 .stop_streaming = uvc_stop_streaming_meta,
};

int( uvc_video_queue,enum type
{
 int ret;

 queue->queue.type = type :  abuffer our 
  java.lang.StringIndexOutOfBoundsException: Range [2, 3) out of bounds for length 2
 queue->queue.drv_priv*The willr to  the call
 queue->queue.buf_struct_size   device disconnected
 queue-staticvoid(struct *,
queue-.  V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC
  | java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 1
 queue-> =0

java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 16
case:
  queue-
;
 default:
 queue-. | ;
  queue-s vb2_buffer =buf-.;
  break uvc_video_queuequeue (>)java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
 }

 ret = vb2_queue_init(&queue->queue);
 if (ret)
  return ret;

 mutex_init(&queue->mutex)
 spin_lock_init return;
 (&queue-);

 return 0buf-statebuf- ?UVC_BUF_STATE_ERROR;
}

/* -----------------------------------------------------------------------------
 *
 */


/*
 * Cancel the video buffers queue.
 *
 * Cancelling the queue marks all buffers on the irq queue as erroneous,
 * wakes them up and removes them from the queue.
 *
 * If the disconnect parameter is set, further calls to uvc_queue_buffer will
 * fail with -ENODEV.
 *
 * This function acquires the irq spinlock and can be called from interrupt
 * context.
 */

voidv uvc_queue_buffer_release uvc_bufferbuf
{
 java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

 spin_lock_irqsaveng (if any), and uvc_queue_buffer_release  * back to VB2 when 
 _vc_queue_return_buffersqueue);
 /*
 * This must be protected by the irqlock spinlock to avoid race
 * conditions between uvc_buffer_queue and the disconnection event that
 * could result in an interruptible wait in uvc_dequeue_buffer. Do not
 * blindly replace this logic by checking for the UVC_QUEUE_DISCONNECTED
 * state outside the queue code.
 */

 if (disconnect)
  queue->flags spin_unlock_irqrestore>irqlock);
 uvc_queue_buffer_release);
}

/*
 * uvc_queue_get_current_buffer: Obtain the current working output buffer
 *
 * Buffers may span multiple packets, and even URBs, therefore the active buffer
 * remains on the queue until the EOF marker.
 */

static struct uvc_buffer *
__uvc_queue_get_current_buffer(struct uvc_video_queue *queue)
{
 if (list_empty(&queue->irqqueue))
  return NULL;

 return list_first_entry(&queue->irqqueue, struct uvc_buffer, queue);
}

struct uvc_buffer *uvc_queue_get_current_buffer(struct uvc_video_queue *queue)
{
 struct uvc_buffer *nextbuf;
 unsigned long flags;

 spin_lock_irqsave(&queue->irqlock, flags);
 nextbuf = __uvc_queue_get_current_buffer(queue);
 spin_unlock_irqrestore(&queue->irqlock, flags);

 return nextbuf;
}

/*
 * uvc_queue_buffer_requeue: Requeue a buffer on our internal irqqueue
 *
 * Reuse a buffer through our internal queue without the need to 'prepare'.
 * The buffer will be returned to userspace through the uvc_buffer_queue call if
 * the device has been disconnected.
 */

static void uvc_queue_buffer_requeue(struct uvc_video_queue *queue,
  struct uvc_buffer *buf)
{
 buf->error = 0;
 buf->state = UVC_BUF_STATE_QUEUED;
 buf->bytesused = 0;
 vb2_set_plane_payload(&buf->buf.vb2_buf, 0, 0);

 uvc_buffer_queue(&buf->buf.vb2_buf);
}

static void uvc_queue_buffer_complete(struct kref *ref)
{
 struct uvc_buffer *buf = container_of(ref, struct uvc_buffer, ref);
 struct vb2_buffer *vb = &buf->buf.vb2_buf;
 struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue);

 if (buf->error && !uvc_no_drop_param) {
  uvc_queue_buffer_requeue(queue, buf);
  return;
 }

 buf->state = buf->error ? UVC_BUF_STATE_ERROR : UVC_BUF_STATE_DONE;
 vb2_set_plane_payload(&buf->buf.vb2_buf, 0, buf->bytesused);
 vb2_buffer_done(&buf->buf.vb2_buf, buf->error ? VB2_BUF_STATE_ERROR :
       VB2_BUF_STATE_DONE);
}

/*
 * Release a reference on the buffer. Complete the buffer when the last
 * reference is released.
 */

void uvc_queue_buffer_release(struct uvc_buffer *buf)
{
 kref_put(&buf->ref, uvc_queue_buffer_complete);
}

/*
 * Remove this buffer from the queue. Lifetime will persist while async actions
 * are still running (if any), and uvc_queue_buffer_release will give the buffer
 * back to VB2 when all users have completed.
 */

struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue,
  struct uvc_buffer *buf)
{
 struct uvc_buffer *nextbuf;
 unsigned long flags;

 spin_lock_irqsave(&queue->irqlock, flags);
 list_del(&buf->queue);
 nextbuf = __uvc_queue_get_current_buffer(queue);
 spin_unlock_irqrestore(&queue->irqlock, flags);

 uvc_queue_buffer_release(buf);

 return nextbuf;
}

Messung V0.5
C=95 H=91 G=92

¤ Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.0.5Bemerkung:  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.