refactor: simplify PCIES2MM capture backend
This commit is contained in:
@@ -146,16 +146,12 @@ DMA layout,也可以在不改 `gvfg_frame_t` 的情況下支援。
|
||||
位在同一個 native DMA buffer 裡,而且 pitch 是 SDK 依照 known native format
|
||||
推導出來的。Application 必須忽略 `reserved[]`。
|
||||
|
||||
目前 tightly packed layout:
|
||||
板子只提供兩種 native capture layout:
|
||||
|
||||
- `YUY2` / `UYVY`:one plane,`plane_stride[0] = width * 2`。
|
||||
- `YUY2`:one plane,`plane_stride[0] = width * 2`。
|
||||
- `Y210`:one plane,`plane_stride[0] = width * 4`。
|
||||
- `RGB24`:one plane,`plane_stride[0] = width * 3`。
|
||||
- `YUV444`:one plane,8-bit 時 `width * 3`,>8-bit 時 `width * 6`。
|
||||
- `NV12`:two planes,Y 後接 interleaved UV,
|
||||
`plane_stride[0] = plane_stride[1] = width`。
|
||||
- `P010`:two planes,Y 後接 interleaved UV,
|
||||
`plane_stride[0] = plane_stride[1] = width * 2`。
|
||||
|
||||
其他 native input format 不在 SDK 支援範圍,會回傳 `GVFG_ENOTSUP`。
|
||||
|
||||
### `gvfg_convert_frame`
|
||||
|
||||
@@ -264,58 +260,6 @@ gvfg_status_t gvfg_stop(gvfg_handle handle);
|
||||
signal 時 `gvfg_start()` 仍會成功並進入 event monitoring;frame read 會 timeout,收到
|
||||
`GVFG_EVENT_SIGNAL_CONNECTED` 後 SDK 會自動重新讀取格式並啟動 DMA。
|
||||
|
||||
### Callback mode
|
||||
|
||||
```c
|
||||
typedef void (*gvfg_frame_callback_t)(
|
||||
gvfg_handle handle,
|
||||
const gvfg_frame_t *frame,
|
||||
void *user_data);
|
||||
|
||||
typedef void (*gvfg_event_callback_t)(
|
||||
gvfg_handle handle,
|
||||
const gvfg_event_t *event,
|
||||
void *user_data);
|
||||
|
||||
gvfg_status_t gvfg_set_frame_callback(gvfg_handle handle,
|
||||
gvfg_frame_callback_t callback,
|
||||
void *user_data);
|
||||
gvfg_status_t gvfg_set_event_callback(gvfg_handle handle,
|
||||
gvfg_event_callback_t callback,
|
||||
void *user_data);
|
||||
gvfg_status_t gvfg_start_callback_mode(gvfg_handle handle);
|
||||
gvfg_status_t gvfg_stop_callback_mode(gvfg_handle handle);
|
||||
```
|
||||
|
||||
Callback mode 是 optional。它適合想讓 SDK 管理 frame/event dispatch thread 的 application。
|
||||
同一個 handle 只能使用 pull mode 或 callback mode 其中一種;callback mode active
|
||||
時,`gvfg_read_frame()` 和 `gvfg_poll_event()` 會回 `GVFG_ESTATE`。
|
||||
|
||||
Callback mode 規則:
|
||||
|
||||
- `gvfg_start_callback_mode()` 前必須先設定 frame callback。
|
||||
- Frame 與 event callback 由同一條 SDK-owned dispatch thread 呼叫。
|
||||
- 同一個 handle 的 frame/event callback 會序列化,不會彼此併發。
|
||||
- Frame pointer 只在 callback 期間有效;callback return 後 SDK 會自動 release。
|
||||
- Callback 內不要呼叫 `gvfg_destroy()`;`gvfg_stop_callback_mode()` 也應由其他 thread 呼叫。
|
||||
- Event callback 依 SDK 收到事件的順序,和 frame callback 在同一條 thread dispatch。
|
||||
- Heavy work 應 copy/queue 到 application 自己的 worker thread。
|
||||
|
||||
最小 callback flow:
|
||||
|
||||
```c
|
||||
static void on_frame(gvfg_handle h, const gvfg_frame_t *frame, void *user)
|
||||
{
|
||||
/* frame is valid only inside this callback. Copy if needed. */
|
||||
}
|
||||
|
||||
gvfg_set_frame_callback(h, on_frame, user);
|
||||
gvfg_start_callback_mode(h);
|
||||
|
||||
/* later, from another thread */
|
||||
gvfg_stop_callback_mode(h);
|
||||
```
|
||||
|
||||
### `gvfg_read_frame`
|
||||
|
||||
```c
|
||||
|
||||
Reference in New Issue
Block a user