diff options
| author | kkitayam <[email protected]> | 2021-09-29 22:53:26 +0900 |
|---|---|---|
| committer | kkitayam <[email protected]> | 2021-09-29 22:53:26 +0900 |
| commit | 9bcab53c2cb0b52baf8bc0c768887428ac87fbff (patch) | |
| tree | 2d8a1cf4d8a22211dc438e1a13dc850c8844126b /src | |
| parent | dba5e7b17d4f39c9f74b90142a2e17056f4db6d7 (diff) | |
Implement frame rate settings
Diffstat (limited to 'src')
| -rw-r--r-- | src/class/video/video_device.c | 11 | ||||
| -rw-r--r-- | src/class/video/video_device.h | 27 |
2 files changed, 27 insertions, 11 deletions
diff --git a/src/class/video/video_device.c b/src/class/video/video_device.c index f4ecef446..28ac860e1 100644 --- a/src/class/video/video_device.c +++ b/src/class/video/video_device.c @@ -290,6 +290,9 @@ static inline tusb_desc_cs_video_frm_uncompressed_t const *_find_desc_frame(void _find_desc_3(beg, end, TUSB_DESC_CS_INTERFACE, VIDEO_CS_VS_INTERFACE_FRAME_UNCOMPRESSED, frmnum); } +/** Set uniquely determined values to variables that have not been set + * + * @param[in,out] param Target */ static bool _update_streaming_parameters(videod_streaming_interface_t const *stm, video_probe_and_commit_control_t *param) { @@ -353,6 +356,11 @@ static bool _update_streaming_parameters(videod_streaming_interface_t const *stm return true; } +/** Set the minimum or the maximum values to variables which need to negotiate with the host + * + * @param[in] set_max If true, the maximum values is set, otherwise the minimum value is set. + * @param[in,out] param Target + */ static bool _negotiate_streaming_parameters(videod_streaming_interface_t const *stm, bool set_max, video_probe_and_commit_control_t *param) { @@ -514,6 +522,7 @@ static bool _open_vs_itf(uint8_t rhport, videod_streaming_interface_t *stm, uint stm->max_payload_transfer_size = 0; video_probe_and_commit_control_t *param = (video_probe_and_commit_control_t *)&stm->ep_buf; + tu_memclr(param, sizeof(*param)); return _update_streaming_parameters(stm, param); } /* Open endpoints of the new settings. */ @@ -880,7 +889,7 @@ bool tud_video_n_frame_xfer(uint_fast8_t ctl_idx, uint_fast8_t stm_idx, void *bu if (!stm || !stm->desc.ep[0] || stm->buffer) return false; - /* find EP address */ + /* Find EP address */ void const *desc = _videod_itf[stm->index_vc].beg; uint_fast8_t ep_addr = 0; for (uint_fast8_t i = 0; i < CFG_TUD_VIDEO_STREAMING; ++i) { diff --git a/src/class/video/video_device.h b/src/class/video/video_device.h index 8654b63c5..e5012ca7e 100644 --- a/src/class/video/video_device.h +++ b/src/class/video/video_device.h @@ -43,32 +43,39 @@ extern "C" { * stm_idx instance number of streaming interface */ bool tud_video_n_streaming(uint_fast8_t ctl_idx, uint_fast8_t stm_idx); - -/* ctl_idx instance number of control interface - * stm_idx instance number of streaming interface */ +/** + * @param[in] ctl_idx Destination control interface index + * @param[in] stm_idx Destination streaming interface index + * @param[in] buffer Frame buffer. The caller must not use this buffer until the operation is completed. + * @param[in] bufsize Byte size of the frame buffer */ bool tud_video_n_frame_xfer(uint_fast8_t ctl_idx, uint_fast8_t stm_idx, void *buffer, size_t bufsize); /*------------- Optional callbacks -------------*/ -/* ctl_idx instance number of control interface - * stm_idx instance number of streaming interface */ -TU_ATTR_WEAK int tud_video_frame_xfer_complete_cb(uint_fast8_t ctl_idx, uint_fast8_t stm_idx); +/** Invoked when compeletion of a frame transfer + * + * @param[in] ctl_idx Destination control interface index + * @param[in] stm_idx Destination streaming interface index */ +TU_ATTR_WEAK void tud_video_frame_xfer_complete_cb(uint_fast8_t ctl_idx, uint_fast8_t stm_idx); //--------------------------------------------------------------------+ // Application Callback API (weak is optional) //--------------------------------------------------------------------+ -/* Invoked when SET POWER_MODE request received to +/** Invoked when SET_POWER_MODE request received + * + * @param[in] ctl_idx Destination control interface index + * @param[in] stm_idx Destination streaming interface index * @return video_error_code_t */ TU_ATTR_WEAK int tud_video_power_mode_cb(uint_fast8_t ctl_idx, uint8_t power_mod); -/** +/** Invoked when VS_COMMIT_CONTROL(SET_CUR) request received * + * @param[in] ctl_idx Destination control interface index + * @param[in] stm_idx Destination streaming interface index * @return video_error_code_t */ TU_ATTR_WEAK int tud_video_commit_cb(uint_fast8_t ctl_idx, uint_fast8_t stm_idx, video_probe_and_commit_control_t const *parameters); -/* @return video_error_code_t */ -TU_ATTR_WEAK int tud_video_commit_set_cb(uint_fast8_t ctl_idx, uint_fast8_t stm_idx, video_probe_and_commit_control_t const *settings); //--------------------------------------------------------------------+ // INTERNAL USBD-CLASS DRIVER API //--------------------------------------------------------------------+ |
