Lines Matching +full:hw +full:- +full:rx +full:- +full:buffer +full:- +full:offset
5 * SPDX-License-Identifier: Apache-2.0
31 if (data->signal_out) { \
32 k_poll_signal_raise(data->signal_out, result); \
78 const struct video_esp32_config *cfg = data->config; in video_esp32_reload_dma()
81 if (data->active_vbuf == NULL) { in video_esp32_reload_dma()
82 LOG_ERR("No video buffer available. Enqueue some buffers first."); in video_esp32_reload_dma()
83 return -EAGAIN; in video_esp32_reload_dma()
86 ret = dma_reload(cfg->dma_dev, cfg->rx_dma_channel, 0, (uint32_t)data->active_vbuf->buffer, in video_esp32_reload_dma()
87 data->active_vbuf->bytesused); in video_esp32_reload_dma()
93 ret = dma_start(cfg->dma_dev, cfg->rx_dma_channel); in video_esp32_reload_dma()
118 if (data->active_vbuf == NULL) { in video_esp32_dma_rx_done()
120 LOG_ERR("No video buffer available. Enque some buffers first."); in video_esp32_dma_rx_done()
124 k_fifo_put(&data->fifo_out, data->active_vbuf); in video_esp32_dma_rx_done()
126 data->active_vbuf = k_fifo_get(&data->fifo_in, K_NO_WAIT); in video_esp32_dma_rx_done()
128 if (data->active_vbuf == NULL) { in video_esp32_dma_rx_done()
129 LOG_WRN("Frame dropped. No buffer available"); in video_esp32_dma_rx_done()
138 const struct video_esp32_config *cfg = dev->config; in video_esp32_stream_start()
139 struct video_esp32_data *data = dev->data; in video_esp32_stream_start()
142 struct dma_block_config *dma_block_iter = data->dma_blocks; in video_esp32_stream_start()
146 if (data->is_streaming) { in video_esp32_stream_start()
147 return -EBUSY; in video_esp32_stream_start()
152 error = dma_get_status(cfg->dma_dev, cfg->rx_dma_channel, &dma_status); in video_esp32_stream_start()
155 LOG_ERR("Unable to get Rx status (%d)", error); in video_esp32_stream_start()
160 LOG_ERR("Rx DMA Channel %d is busy", cfg->rx_dma_channel); in video_esp32_stream_start()
161 return -EBUSY; in video_esp32_stream_start()
164 data->active_vbuf = k_fifo_get(&data->fifo_in, K_NO_WAIT); in video_esp32_stream_start()
165 if (!data->active_vbuf) { in video_esp32_stream_start()
167 return -EAGAIN; in video_esp32_stream_start()
170 buffer_size = data->active_vbuf->bytesused; in video_esp32_stream_start()
171 memset(data->dma_blocks, 0, sizeof(data->dma_blocks)); in video_esp32_stream_start()
173 dma_block_iter->dest_address = in video_esp32_stream_start()
174 (uint32_t)data->active_vbuf->buffer + (i * VIDEO_ESP32_DMA_BUFFER_MAX_SIZE); in video_esp32_stream_start()
176 dma_block_iter->block_size = buffer_size; in video_esp32_stream_start()
177 dma_block_iter->next_block = NULL; in video_esp32_stream_start()
181 dma_block_iter->block_size = VIDEO_ESP32_DMA_BUFFER_MAX_SIZE; in video_esp32_stream_start()
182 dma_block_iter->next_block = dma_block_iter + 1; in video_esp32_stream_start()
184 buffer_size -= VIDEO_ESP32_DMA_BUFFER_MAX_SIZE; in video_esp32_stream_start()
187 if (dma_block_iter->next_block) { in video_esp32_stream_start()
190 return -ENOBUFS; in video_esp32_stream_start()
198 dma_cfg.head_block = &data->dma_blocks[0]; in video_esp32_stream_start()
200 error = dma_config(cfg->dma_dev, cfg->rx_dma_channel, &dma_cfg); in video_esp32_stream_start()
206 error = dma_start(cfg->dma_dev, cfg->rx_dma_channel); in video_esp32_stream_start()
212 cam_hal_start_streaming(&data->hal); in video_esp32_stream_start()
214 if (video_stream_start(cfg->source_dev)) { in video_esp32_stream_start()
215 return -EIO; in video_esp32_stream_start()
217 data->is_streaming = true; in video_esp32_stream_start()
224 const struct video_esp32_config *cfg = dev->config; in video_esp32_stream_stop()
225 struct video_esp32_data *data = dev->data; in video_esp32_stream_stop()
230 if (video_stream_stop(cfg->source_dev)) { in video_esp32_stream_stop()
231 return -EIO; in video_esp32_stream_stop()
234 data->is_streaming = false; in video_esp32_stream_stop()
235 ret = dma_stop(cfg->dma_dev, cfg->rx_dma_channel); in video_esp32_stream_stop()
241 cam_hal_stop_streaming(&data->hal); in video_esp32_stream_stop()
248 const struct video_esp32_config *config = dev->config; in video_esp32_get_caps()
251 return -EINVAL; in video_esp32_get_caps()
255 caps->min_line_count = caps->max_line_count = LINE_COUNT_HEIGHT; in video_esp32_get_caps()
258 return video_get_caps(config->source_dev, ep, caps); in video_esp32_get_caps()
264 const struct video_esp32_config *cfg = dev->config; in video_esp32_get_fmt()
270 return -EINVAL; in video_esp32_get_fmt()
273 ret = video_get_format(cfg->source_dev, ep, fmt); in video_esp32_get_fmt()
285 const struct video_esp32_config *cfg = dev->config; in video_esp32_set_fmt()
286 struct video_esp32_data *data = dev->data; in video_esp32_set_fmt()
289 return -EINVAL; in video_esp32_set_fmt()
292 data->video_format = *fmt; in video_esp32_set_fmt()
294 return video_set_format(cfg->source_dev, ep, fmt); in video_esp32_set_fmt()
300 struct video_esp32_data *data = dev->data; in video_esp32_enqueue()
303 return -EINVAL; in video_esp32_enqueue()
306 vbuf->bytesused = data->video_format.pitch * data->video_format.height; in video_esp32_enqueue()
307 vbuf->line_offset = 0; in video_esp32_enqueue()
309 k_fifo_put(&data->fifo_in, vbuf); in video_esp32_enqueue()
317 struct video_esp32_data *data = dev->data; in video_esp32_dequeue()
320 return -EINVAL; in video_esp32_dequeue()
323 *vbuf = k_fifo_get(&data->fifo_out, timeout); in video_esp32_dequeue()
326 return -EAGAIN; in video_esp32_dequeue()
334 const struct video_esp32_config *cfg = dev->config; in video_esp32_set_ctrl()
336 return video_set_ctrl(cfg->source_dev, cid, value); in video_esp32_set_ctrl()
341 const struct video_esp32_config *cfg = dev->config; in video_esp32_get_ctrl()
343 return video_get_ctrl(cfg->source_dev, cid, value); in video_esp32_get_ctrl()
350 struct video_esp32_data *data = dev->data; in video_esp32_set_signal()
354 return -EINVAL; in video_esp32_set_signal()
356 data->signal_out = sig; in video_esp32_set_signal()
363 const struct video_esp32_config *cfg = dev->config; in video_esp32_cam_ctrl_init()
364 struct video_esp32_data *data = dev->data; in video_esp32_cam_ctrl_init()
368 .byte_swap_en = cfg->invert_byte_order, in video_esp32_cam_ctrl_init()
371 cam_hal_init(&data->hal, &hal_cfg); in video_esp32_cam_ctrl_init()
373 cam_ll_reverse_dma_data_bit_order(data->hal.hw, cfg->invert_bit_order); in video_esp32_cam_ctrl_init()
374 cam_ll_enable_invert_pclk(data->hal.hw, cfg->invert_pclk); in video_esp32_cam_ctrl_init()
375 cam_ll_set_input_data_width(data->hal.hw, cfg->data_width); in video_esp32_cam_ctrl_init()
376 cam_ll_enable_invert_de(data->hal.hw, cfg->invert_de); in video_esp32_cam_ctrl_init()
377 cam_ll_enable_invert_vsync(data->hal.hw, cfg->invert_vsync); in video_esp32_cam_ctrl_init()
378 cam_ll_enable_invert_hsync(data->hal.hw, cfg->invert_hsync); in video_esp32_cam_ctrl_init()
383 const struct video_esp32_config *cfg = dev->config; in video_esp32_init()
384 struct video_esp32_data *data = dev->data; in video_esp32_init()
386 k_fifo_init(&data->fifo_in); in video_esp32_init()
387 k_fifo_init(&data->fifo_out); in video_esp32_init()
388 data->config = cfg; in video_esp32_init()
391 if (!device_is_ready(cfg->dma_dev)) { in video_esp32_init()
393 return -ENODEV; in video_esp32_init()
422 .dma_dev = ESP32_DT_INST_DMA_CTLR(0, rx),
423 .rx_dma_channel = DT_INST_DMAS_CELL_BY_NAME(0, rx, channel),
433 .clock_subsys = (clock_control_subsys_t)DT_INST_CLOCKS_CELL(0, offset),
453 return -ENODEV; in video_esp32_cam_init_master_clock()
460 return -EINVAL; in video_esp32_cam_init_master_clock()
465 return -EINVAL; in video_esp32_cam_init_master_clock()