2.21. V4L2 記憶體到記憶體功能和資料結構

struct v4l2_m2m_ops

mem-to-mem 裝置驅動程式回撥

定義:

struct v4l2_m2m_ops {
    void (*device_run)(void *priv);
    int (*job_ready)(void *priv);
    void (*job_abort)(void *priv);
};

成員

device_run

必需。在此回撥函式內開始實際的作業(事務)。作業不必在此回撥函式返回之前結束(通常情況也確實如此)。當作業結束時,必須呼叫 v4l2_m2m_job_finish()v4l2_m2m_buf_done_and_job_finish()

job_ready

可選。如果驅動程式尚未完全準備好執行的作業(即,它將無法在不休眠的情況下完成事務),則應返回 0。如果未提供,則假定驅動程式執行一個完整事務只需要一個源緩衝區和一個目標緩衝區。此方法可能不會休眠。

job_abort

可選。通知驅動程式必須儘快中止當前正在執行的事務(即,只要它可以安全地停止裝置;例如,在下一個中斷處理程式中),即使事務到那時還沒有完成。在驅動程式執行必要的步驟後,它必須呼叫 v4l2_m2m_job_finish()v4l2_m2m_buf_done_and_job_finish(),就像事務正常結束一樣。此函式不必(並且通常不會)等待裝置進入可以停止的狀態。

struct v4l2_m2m_queue_ctx

表示一個準備好被處理的緩衝區佇列

定義:

struct v4l2_m2m_queue_ctx {
    struct vb2_queue        q;
    struct list_head        rdy_queue;
    spinlock_t rdy_spinlock;
    u8 num_rdy;
    bool buffered;
};

成員

q

指向 struct vb2_queue 的指標

rdy_queue

V4L2 mem-to-mem 佇列列表

rdy_spinlock

自旋鎖以保護結構的使用

num_rdy

準備好被處理的緩衝區數量

buffered

佇列是否被緩衝?

描述

緩衝區佇列準備好在此例項獲得對裝置的訪問許可權後立即處理。

struct v4l2_m2m_ctx

記憶體到記憶體上下文結構

定義:

struct v4l2_m2m_ctx {
    struct mutex                    *q_lock;
    bool new_frame;
    bool is_draining;
    struct vb2_v4l2_buffer          *last_src_buf;
    bool next_buf_last;
    bool has_stopped;
    bool ignore_cap_streaming;
    struct v4l2_m2m_dev             *m2m_dev;
    struct v4l2_m2m_queue_ctx       cap_q_ctx;
    struct v4l2_m2m_queue_ctx       out_q_ctx;
    struct list_head                queue;
    unsigned long                   job_flags;
    wait_queue_head_t finished;
    void *priv;
};

成員

q_lock

struct mutex

new_frame

在 device_run 回撥中有效:如果為 true,則表示這是一個新幀的開始;如果為 false,則表示這是現有幀的新切片。除非設定了 V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF(表示支援切片),否則始終為 true。

is_draining

表示裝置處於耗盡階段

last_src_buf

指示耗盡的最後一個源緩衝區

next_buf_last

下一個捕獲佇列緩衝區將被標記為最後一個

has_stopped

表示裝置已停止

ignore_cap_streaming

如果為 true,即使 CAPTURE 佇列未流式傳輸,也可以呼叫 job_ready。這允許韌體分析在 OUTPUT 佇列上到達的位元流標頭。驅動程式必須正確實現 job_ready 回撥,以確保滿足實際解碼的要求。

m2m_dev

指向處理 M2M 上下文的內部資料的不透明指標

cap_q_ctx

捕獲(輸出到記憶體)佇列上下文

out_q_ctx

輸出(從記憶體輸入)佇列上下文

queue

記憶體到記憶體上下文列表

job_flags

作業佇列標誌,由 v4l2-mem2mem.c 內部使用:TRANS_QUEUEDTRANS_RUNNINGTRANS_ABORT

finished

等待佇列,用於在作業佇列完成時發出訊號。

priv

例項私有資料

描述

記憶體到記憶體上下文特定於檔案控制代碼,而不是例如裝置。

struct v4l2_m2m_buffer

記憶體到記憶體緩衝區

定義:

struct v4l2_m2m_buffer {
    struct vb2_v4l2_buffer  vb;
    struct list_head        list;
};

成員

vb

指向 struct vb2_v4l2_buffer 的指標

list

m2m 緩衝區列表

void *v4l2_m2m_get_curr_priv(struct v4l2_m2m_dev *m2m_dev)

返回當前正在執行的例項的驅動程式私有資料,如果沒有例項正在執行,則返回 NULL

引數

struct v4l2_m2m_dev *m2m_dev

指向處理 M2M 上下文的內部資料的不透明指標

struct vb2_queue *v4l2_m2m_get_vq(struct v4l2_m2m_ctx *m2m_ctx, enum v4l2_buf_type type)

返回給定型別的 vb2_queue

引數

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

enum v4l2_buf_type type

V4L2 緩衝區的型別,由 enum v4l2_buf_type 定義

void v4l2_m2m_try_schedule(struct v4l2_m2m_ctx *m2m_ctx)

檢查例項是否已準備好新增到掛起的作業佇列,如果已準備好,則將其新增。

引數

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

描述

例項必須滿足三個基本要求才能執行:1) 必須至少排隊一個源緩衝區,2) 必須至少排隊一個目標緩衝區,3) 必須啟用流式傳輸。

如果佇列被緩衝(例如,必須在 streamoff 之前耗盡的解碼器硬體環形緩衝區),則允許在沒有該佇列上的 v4l2 緩衝區的情況下進行排程。

可能還會有其他自定義要求。在這種情況下,驅動程式應提供自定義回撥(v4l2_m2m_ops 中的 job_ready),如果例項已準備好,則應返回 1。上述情況的一個示例可以是需要每個事務多個 src/dst 緩衝區的例項。

void v4l2_m2m_job_finish(struct v4l2_m2m_dev *m2m_dev, struct v4l2_m2m_ctx *m2m_ctx)

通知框架作業已完成並讓它清理

引數

struct v4l2_m2m_dev *m2m_dev

指向處理 M2M 上下文的內部資料的不透明指標

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

描述

驅動程式在完成裝置後呼叫此函式以將裝置返回。在達到允許其他例項控制裝置的狀態後,應儘快呼叫此函式。

只有在驅動程式上呼叫了 v4l2_m2m_ops->device_run 回撥後,才能呼叫此函式。為了防止遞迴,不應直接從 v4l2_m2m_ops->device_run 回撥中呼叫它。

void v4l2_m2m_buf_done_and_job_finish(struct v4l2_m2m_dev *m2m_dev, struct v4l2_m2m_ctx *m2m_ctx, enum vb2_buffer_state state)

返回具有狀態的源/目標緩衝區,並通知框架作業已完成並讓它清理

引數

struct v4l2_m2m_dev *m2m_dev

指向處理 M2M 上下文的內部資料的不透明指標

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

enum vb2_buffer_state state

傳遞給 v4l2_m2m_buf_done() 的 vb2 緩衝區狀態。

描述

設定 V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF 的驅動程式必須使用此函式而不是 job_finish() 來考慮儲存的緩衝區。 對於其他驅動程式,它是可選的。

此函式從就緒列表中刪除源緩衝區,並以給定狀態返回它。 對目標緩衝區執行相同的操作,除非它被標記為“已儲存”。 在這種情況下,緩衝區保留在就緒列表中。

之後,作業完成(參見 job_finish())。

這允許使用多個輸出緩衝區來填充單個捕獲緩衝區。 這通常由無狀態解碼器使用,其中多個(例如 H.264)切片有助於形成單個解碼幀。

void v4l2_m2m_clear_state(struct v4l2_m2m_ctx *m2m_ctx)

清除編碼/解碼狀態

引數

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

void v4l2_m2m_mark_stopped(struct v4l2_m2m_ctx *m2m_ctx)

將當前編碼/解碼狀態設定為已停止

引數

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

bool v4l2_m2m_dst_buf_is_last(struct v4l2_m2m_ctx *m2m_ctx)

返回下一個排隊的捕獲緩衝區的當前編碼/解碼會話耗盡管理狀態

引數

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

描述

此最後一個捕獲緩衝區應使用 V4L2_BUF_FLAG_LAST 標記,以通知捕獲會話的結束。

bool v4l2_m2m_has_stopped(struct v4l2_m2m_ctx *m2m_ctx)

返回當前編碼/解碼會話的停止狀態

引數

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

bool v4l2_m2m_is_last_draining_src_buf(struct v4l2_m2m_ctx *m2m_ctx, struct vb2_v4l2_buffer *vbuf)

返回當前編碼/解碼會話中的輸出緩衝區排空狀態

引數

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

struct vb2_v4l2_buffer *vbuf

指向 v4l2_buffer 結構的指標

描述

這將標識在需要停止會話之前排隊的最後一個輸出緩衝區,從而導致在處理後編碼/解碼過程中實際的編碼/解碼會話停止狀態。

void v4l2_m2m_last_buffer_done(struct v4l2_m2m_ctx *m2m_ctx, struct vb2_v4l2_buffer *vbuf)

用 LAST 標誌標記緩衝區並完成

引數

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

struct vb2_v4l2_buffer *vbuf

指向 v4l2_buffer 結構的指標

void v4l2_m2m_suspend(struct v4l2_m2m_dev *m2m_dev)

停止執行新作業並等待當前作業完成

引數

struct v4l2_m2m_dev *m2m_dev

指向處理 M2M 上下文的內部資料的不透明指標

描述

由驅動程式在掛起鉤子中呼叫。停止執行新作業,並等待當前正在執行的作業完成。

void v4l2_m2m_resume(struct v4l2_m2m_dev *m2m_dev)

恢復作業執行並嘗試執行排隊的作業

引數

struct v4l2_m2m_dev *m2m_dev

指向處理 M2M 上下文的內部資料的不透明指標

描述

由驅動程式在恢復鉤子中呼叫。這將恢復 v4l2_m2m_suspend() 的操作並允許執行作業。如果存在任何排隊的作業,也嘗試執行它。

int v4l2_m2m_reqbufs(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, struct v4l2_requestbuffers *reqbufs)

多佇列感知 REQBUFS 多路複用器

引數

struct file *file

指向 file 結構的指標

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

struct v4l2_requestbuffers *reqbufs

指向 v4l2_requestbuffers 結構的指標

int v4l2_m2m_querybuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, struct v4l2_buffer *buf)

多佇列感知 QUERYBUF 多路複用器

引數

struct file *file

指向 file 結構的指標

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

struct v4l2_buffer *buf

指向 v4l2_buffer 結構的指標

描述

有關詳細資訊,請參閱 v4l2_m2m_mmap() 文件。

int v4l2_m2m_qbuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, struct v4l2_buffer *buf)

根據型別,將源緩衝區或目標緩衝區排隊

引數

struct file *file

指向 file 結構的指標

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

struct v4l2_buffer *buf

指向 v4l2_buffer 結構的指標

int v4l2_m2m_dqbuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, struct v4l2_buffer *buf)

根據型別,將源緩衝區或目標緩衝區出隊

引數

struct file *file

指向 file 結構的指標

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

struct v4l2_buffer *buf

指向 v4l2_buffer 結構的指標

int v4l2_m2m_prepare_buf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, struct v4l2_buffer *buf)

根據型別,準備源緩衝區或目標緩衝區

引數

struct file *file

指向 file 結構的指標

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

struct v4l2_buffer *buf

指向 v4l2_buffer 結構的指標

int v4l2_m2m_create_bufs(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, struct v4l2_create_buffers *create)

根據型別,建立源緩衝區或目標緩衝區

引數

struct file *file

指向 file 結構的指標

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

struct v4l2_create_buffers *create

指向 v4l2_create_buffers 結構的指標

int v4l2_m2m_expbuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, struct v4l2_exportbuffer *eb)

根據型別,匯出源緩衝區或目標緩衝區

引數

struct file *file

指向 file 結構的指標

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

struct v4l2_exportbuffer *eb

指向 v4l2_exportbuffer 結構的指標

int v4l2_m2m_streamon(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, enum v4l2_buf_type type)

開啟影片佇列的流

引數

struct file *file

指向 file 結構的指標

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

enum v4l2_buf_type type

V4L2 緩衝區的型別,由 enum v4l2_buf_type 定義

int v4l2_m2m_streamoff(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, enum v4l2_buf_type type)

關閉影片佇列的流

引數

struct file *file

指向 file 結構的指標

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

enum v4l2_buf_type type

V4L2 緩衝區的型別,由 enum v4l2_buf_type 定義

void v4l2_m2m_update_start_streaming_state(struct v4l2_m2m_ctx *m2m_ctx, struct vb2_queue *q)

當請求啟動影片佇列的流時,更新編碼/解碼會話狀態

引數

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

struct vb2_queue *q

queue

void v4l2_m2m_update_stop_streaming_state(struct v4l2_m2m_ctx *m2m_ctx, struct vb2_queue *q)

當請求停止影片佇列的流時,更新編碼/解碼會話狀態

引數

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

struct vb2_queue *q

queue

int v4l2_m2m_encoder_cmd(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, struct v4l2_encoder_cmd *ec)

執行編碼器命令

引數

struct file *file

指向 file 結構的指標

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

struct v4l2_encoder_cmd *ec

指向編碼器命令的指標

int v4l2_m2m_decoder_cmd(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, struct v4l2_decoder_cmd *dc)

執行解碼器命令

引數

struct file *file

指向 file 結構的指標

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

struct v4l2_decoder_cmd *dc

指向解碼器命令的指標

__poll_t v4l2_m2m_poll(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, struct poll_table_struct *wait)

poll 替換,僅用於目標緩衝區

引數

struct file *file

指向 file 結構的指標

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

struct poll_table_struct *wait

指向 poll_table_struct 結構的指標

描述

從驅動程式的 poll() 函式呼叫。將輪詢兩個佇列。如果源佇列中有一個緩衝區可以透過 dqbuf 出隊,則表明可以執行非阻塞寫入,如果目標佇列有資料,則將返回可讀。

int v4l2_m2m_mmap(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, struct vm_area_struct *vma)

源佇列和目標佇列感知的 mmap 多路複用器

引數

struct file *file

指向 file 結構的指標

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

struct vm_area_struct *vma

指向 vm_area_struct 結構的指標

描述

從驅動程式的 mmap() 函式呼叫。將無縫處理影片緩衝區的兩個佇列的 mmap(),這將接收正常的每個佇列偏移量和正確的 vb2 佇列指標。 透過將預定義的偏移量新增到其中一個佇列的緩衝區,並在將其傳遞迴 vb2 之前減去它,可以在 vb2 之外進行區分。只有驅動程式(以及因此應用程式)才會收到修改後的偏移量。

struct v4l2_m2m_dev *v4l2_m2m_init(const struct v4l2_m2m_ops *m2m_ops)

初始化每個驅動程式的 m2m 資料

引數

const struct v4l2_m2m_ops *m2m_ops

指向 struct v4l2_m2m_ops 的指標

描述

通常從驅動程式的 probe() 函式呼叫。

返回值

返回指向內部資料的不透明指標,用於處理 M2M 上下文

void v4l2_m2m_release(struct v4l2_m2m_dev *m2m_dev)

清理並釋放 m2m_dev 結構

引數

struct v4l2_m2m_dev *m2m_dev

指向處理 M2M 上下文的內部資料的不透明指標

描述

通常從驅動程式的 remove() 函式呼叫。

struct v4l2_m2m_ctx *v4l2_m2m_ctx_init(struct v4l2_m2m_dev *m2m_dev, void *drv_priv, int (*queue_init)(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_vq))

分配並初始化 m2m 上下文

引數

struct v4l2_m2m_dev *m2m_dev

指向處理 M2M 上下文的內部資料的不透明指標

void *drv_priv

驅動程式的例項私有資料

int (*queue_init)(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_vq)

用於初始化 vb2_queues 的佇列型別特定初始化函式的回撥

描述

通常從驅動程式的 open() 函式呼叫。

void v4l2_m2m_ctx_release(struct v4l2_m2m_ctx *m2m_ctx)

釋放 m2m 上下文

引數

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

描述

通常從驅動程式的 release() 函式呼叫。

void v4l2_m2m_buf_queue(struct v4l2_m2m_ctx *m2m_ctx, struct vb2_v4l2_buffer *vbuf)

將緩衝區新增到適當的就緒緩衝區列表。

引數

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

struct vb2_v4l2_buffer *vbuf

指向 struct vb2_v4l2_buffer 的指標

描述

從 vb2_queue_ops->ops->buf_queue, vb2_queue_ops 回撥呼叫。

unsigned int v4l2_m2m_num_src_bufs_ready(struct v4l2_m2m_ctx *m2m_ctx)

返回可供使用的源緩衝區的數量

引數

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

unsigned int v4l2_m2m_num_dst_bufs_ready(struct v4l2_m2m_ctx *m2m_ctx)

返回可供使用的目標緩衝區的數量

引數

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

struct vb2_v4l2_buffer *v4l2_m2m_next_buf(struct v4l2_m2m_queue_ctx *q_ctx)

從就緒緩衝區列表中返回下一個緩衝區

引數

struct v4l2_m2m_queue_ctx *q_ctx

指向 v4l2_m2m_queue_ctx 結構的指標

struct vb2_v4l2_buffer *v4l2_m2m_next_src_buf(struct v4l2_m2m_ctx *m2m_ctx)

從就緒緩衝區列表中返回下一個源緩衝區

引數

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

struct vb2_v4l2_buffer *v4l2_m2m_next_dst_buf(struct v4l2_m2m_ctx *m2m_ctx)

從就緒緩衝區列表中返回下一個目標緩衝區

引數

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

struct vb2_v4l2_buffer *v4l2_m2m_last_buf(struct v4l2_m2m_queue_ctx *q_ctx)

從就緒緩衝區列表中返回最後一個緩衝區

引數

struct v4l2_m2m_queue_ctx *q_ctx

指向 v4l2_m2m_queue_ctx 結構的指標

struct vb2_v4l2_buffer *v4l2_m2m_last_src_buf(struct v4l2_m2m_ctx *m2m_ctx)

從就緒緩衝區列表中返回最後一個源緩衝區

引數

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

struct vb2_v4l2_buffer *v4l2_m2m_last_dst_buf(struct v4l2_m2m_ctx *m2m_ctx)

從就緒緩衝區列表中返回最後一個目標緩衝區

引數

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

v4l2_m2m_for_each_dst_buf

v4l2_m2m_for_each_dst_buf (m2m_ctx, b)

迭代目標就緒緩衝區的列表

引數

m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

b

型別為 struct v4l2_m2m_buffer 的當前緩衝區

v4l2_m2m_for_each_src_buf

v4l2_m2m_for_each_src_buf (m2m_ctx, b)

迭代源就緒緩衝區的列表

引數

m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

b

型別為 struct v4l2_m2m_buffer 的當前緩衝區

v4l2_m2m_for_each_dst_buf_safe

v4l2_m2m_for_each_dst_buf_safe (m2m_ctx, b, n)

安全地迭代目標就緒緩衝區的列表

引數

m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

b

型別為 struct v4l2_m2m_buffer 的當前緩衝區

n

用作臨時儲存

v4l2_m2m_for_each_src_buf_safe

v4l2_m2m_for_each_src_buf_safe (m2m_ctx, b, n)

安全地迭代源就緒緩衝區的列表

引數

m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

b

型別為 struct v4l2_m2m_buffer 的當前緩衝區

n

用作臨時儲存

struct vb2_queue *v4l2_m2m_get_src_vq(struct v4l2_m2m_ctx *m2m_ctx)

返回源緩衝區的 vb2_queue

引數

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

struct vb2_queue *v4l2_m2m_get_dst_vq(struct v4l2_m2m_ctx *m2m_ctx)

返回目標緩衝區的 vb2_queue

引數

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

struct vb2_v4l2_buffer *v4l2_m2m_buf_remove(struct v4l2_m2m_queue_ctx *q_ctx)

從就緒緩衝區列表中取出一個緩衝區並返回它

引數

struct v4l2_m2m_queue_ctx *q_ctx

指向 v4l2_m2m_queue_ctx 結構的指標

struct vb2_v4l2_buffer *v4l2_m2m_src_buf_remove(struct v4l2_m2m_ctx *m2m_ctx)

從就緒緩衝區列表中取出一個源緩衝區並返回它

引數

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

struct vb2_v4l2_buffer *v4l2_m2m_dst_buf_remove(struct v4l2_m2m_ctx *m2m_ctx)

從就緒緩衝區列表中移除一個目標緩衝區並返回它

引數

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

void v4l2_m2m_buf_remove_by_buf(struct v4l2_m2m_queue_ctx *q_ctx, struct vb2_v4l2_buffer *vbuf)

從就緒緩衝區列表中移除指定的緩衝區

引數

struct v4l2_m2m_queue_ctx *q_ctx

指向 v4l2_m2m_queue_ctx 結構的指標

struct vb2_v4l2_buffer *vbuf

要移除的緩衝區

void v4l2_m2m_src_buf_remove_by_buf(struct v4l2_m2m_ctx *m2m_ctx, struct vb2_v4l2_buffer *vbuf)

從就緒緩衝區列表中移除指定的源緩衝區

引數

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

struct vb2_v4l2_buffer *vbuf

要移除的緩衝區

void v4l2_m2m_dst_buf_remove_by_buf(struct v4l2_m2m_ctx *m2m_ctx, struct vb2_v4l2_buffer *vbuf)

從就緒緩衝區列表中移除指定的目標緩衝區

引數

struct v4l2_m2m_ctx *m2m_ctx

分配給 struct v4l2_m2m_ctx 給出的例項的 m2m 上下文

struct vb2_v4l2_buffer *vbuf

要移除的緩衝區

void v4l2_m2m_buf_copy_metadata(const struct vb2_v4l2_buffer *out_vb, struct vb2_v4l2_buffer *cap_vb, bool copy_frame_flags)

將緩衝區元資料從輸出緩衝區複製到捕獲緩衝區

引數

const struct vb2_v4l2_buffer *out_vb

作為元資料來源的輸出緩衝區。

struct vb2_v4l2_buffer *cap_vb

將接收元資料的捕獲緩衝區。

bool copy_frame_flags

同時複製 KEY/B/PFRAME 標誌。

描述

此輔助函式將時間戳、時間碼(如果設定了 TIMECODE 緩衝區標誌)、場以及 TIMECODE、KEYFRAME、BFRAME、PFRAME 和 TSTAMP_SRC_MASK 標誌從 out_vb 複製到 cap_vb

如果 copy_frame_flags 為 false,則不復制 KEYFRAME、BFRAME 和 PFRAME 標誌。 對於顯式設定此位的編碼器,通常需要這樣做。