Lines Matching +full:input +full:- +full:buffer

4  * SPDX-License-Identifier: Apache-2.0
34 const struct emul_rx_config *cfg = dev->config; in emul_rx_set_ctrl()
37 return video_set_ctrl(cfg->source_dev, cid, value); in emul_rx_set_ctrl()
42 const struct emul_rx_config *cfg = dev->config; in emul_rx_get_ctrl()
45 return video_get_ctrl(cfg->source_dev, cid, value); in emul_rx_get_ctrl()
51 const struct emul_rx_config *cfg = dev->config; in emul_rx_set_frmival()
53 /* Input/output timing is driven by the source */ in emul_rx_set_frmival()
55 return -EINVAL; in emul_rx_set_frmival()
57 return video_set_frmival(cfg->source_dev, VIDEO_EP_OUT, frmival); in emul_rx_set_frmival()
63 const struct emul_rx_config *cfg = dev->config; in emul_rx_get_frmival()
65 /* Input/output timing is driven by the source */ in emul_rx_get_frmival()
67 return -EINVAL; in emul_rx_get_frmival()
69 return video_get_frmival(cfg->source_dev, VIDEO_EP_OUT, frmival); in emul_rx_get_frmival()
75 const struct emul_rx_config *cfg = dev->config; in emul_rx_enum_frmival()
77 /* Input/output timing is driven by the source */ in emul_rx_enum_frmival()
79 return -EINVAL; in emul_rx_enum_frmival()
81 return video_enum_frmival(cfg->source_dev, VIDEO_EP_OUT, fie); in emul_rx_enum_frmival()
87 const struct emul_rx_config *cfg = dev->config; in emul_rx_set_fmt()
88 struct emul_rx_data *data = dev->data; in emul_rx_set_fmt()
91 /* The same format is shared between input and output: data is just passed through */ in emul_rx_set_fmt()
93 return -EINVAL; in emul_rx_set_fmt()
97 ret = video_set_format(cfg->source_dev, VIDEO_EP_OUT, fmt); in emul_rx_set_fmt()
99 LOG_DBG("Failed to set %s format to %x %ux%u", cfg->source_dev->name, in emul_rx_set_fmt()
100 fmt->pixelformat, fmt->width, fmt->height); in emul_rx_set_fmt()
101 return -EINVAL; in emul_rx_set_fmt()
104 /* Cache the format selected locally to use it for getting the size of the buffer */ in emul_rx_set_fmt()
105 data->fmt = *fmt; in emul_rx_set_fmt()
112 struct emul_rx_data *data = dev->data; in emul_rx_get_fmt()
114 /* Input/output caps are the same as the source: data is just passed through */ in emul_rx_get_fmt()
116 return -EINVAL; in emul_rx_get_fmt()
118 *fmt = data->fmt; in emul_rx_get_fmt()
125 const struct emul_rx_config *cfg = dev->config; in emul_rx_get_caps()
127 /* Input/output caps are the same as the source: data is just passed through */ in emul_rx_get_caps()
129 return -EINVAL; in emul_rx_get_caps()
131 return video_get_caps(cfg->source_dev, VIDEO_EP_OUT, caps); in emul_rx_get_caps()
136 const struct emul_rx_config *cfg = dev->config; in emul_rx_stream_start()
139 return video_stream_start(cfg->source_dev); in emul_rx_stream_start()
144 const struct emul_rx_config *cfg = dev->config; in emul_rx_stream_stop()
146 return video_stream_stop(cfg->source_dev); in emul_rx_stream_stop()
153 const struct device *dev = data->dev; in emul_rx_worker()
154 const struct emul_rx_config *cfg = dev->config; in emul_rx_worker()
155 struct video_format *fmt = &data->fmt; in emul_rx_worker()
158 LOG_DBG("Queueing a frame of %u bytes in format %x %ux%u", fmt->pitch * fmt->height, in emul_rx_worker()
159 fmt->pixelformat, fmt->width, fmt->height); in emul_rx_worker()
161 while ((vbuf = k_fifo_get(&data->fifo_in, K_NO_WAIT)) != NULL) { in emul_rx_worker()
162 vbuf->bytesused = fmt->pitch * fmt->height; in emul_rx_worker()
163 vbuf->line_offset = 0; in emul_rx_worker()
165 LOG_DBG("Inserting %u bytes into buffer %p", vbuf->bytesused, vbuf->buffer); in emul_rx_worker()
168 * video buffer memory using DMA. The vbuf->size is checked in emul_rx_enqueue(). in emul_rx_worker()
170 memcpy(vbuf->buffer, cfg->source_dev->data, vbuf->bytesused); in emul_rx_worker()
172 /* Once the buffer is completed, submit it to the video buffer */ in emul_rx_worker()
173 k_fifo_put(&data->fifo_out, vbuf); in emul_rx_worker()
180 struct emul_rx_data *data = dev->data; in emul_rx_enqueue()
181 struct video_format *fmt = &data->fmt; in emul_rx_enqueue()
183 /* Can only enqueue a buffer to get data out, data input is from hardware */ in emul_rx_enqueue()
185 return -EINVAL; in emul_rx_enqueue()
188 if (vbuf->size < fmt->pitch * fmt->height) { in emul_rx_enqueue()
189 LOG_ERR("Buffer too small for a full frame"); in emul_rx_enqueue()
190 return -ENOMEM; in emul_rx_enqueue()
193 /* The buffer has not been filled yet: flag as emtpy */ in emul_rx_enqueue()
194 vbuf->bytesused = 0; in emul_rx_enqueue()
196 /* Submit the buffer for processing in the worker, where everything happens */ in emul_rx_enqueue()
197 k_fifo_put(&data->fifo_in, vbuf); in emul_rx_enqueue()
198 k_work_submit(&data->work); in emul_rx_enqueue()
206 struct emul_rx_data *data = dev->data; in emul_rx_dequeue()
208 /* Can only dequeue a buffer to get data out, data input is from hardware */ in emul_rx_dequeue()
210 return -EINVAL; in emul_rx_dequeue()
214 *vbufp = k_fifo_get(&data->fifo_out, timeout); in emul_rx_dequeue()
216 return -EAGAIN; in emul_rx_dequeue()
224 struct emul_rx_data *data = dev->data; in emul_rx_flush()
227 /* Can only flush the buffer going out, data input is from hardware */ in emul_rx_flush()
229 return -EINVAL; in emul_rx_flush()
239 k_work_cancel(&data->work); in emul_rx_flush()
242 k_work_flush(&data->work, &sync); in emul_rx_flush()
245 while ((vbuf = k_fifo_get(&data->fifo_in, K_NO_WAIT))) { in emul_rx_flush()
246 k_fifo_put(&data->fifo_out, vbuf); in emul_rx_flush()
250 k_work_flush(&data->work, &sync); in emul_rx_flush()
274 struct emul_rx_data *data = dev->data; in emul_rx_init()
275 const struct emul_rx_config *cfg = dev->config; in emul_rx_init()
278 data->dev = dev; in emul_rx_init()
280 if (!device_is_ready(cfg->source_dev)) { in emul_rx_init()
281 LOG_ERR("Source device %s is not ready", cfg->source_dev->name); in emul_rx_init()
282 return -ENODEV; in emul_rx_init()
285 ret = video_get_format(cfg->source_dev, VIDEO_EP_OUT, &data->fmt); in emul_rx_init()
290 k_fifo_init(&data->fifo_in); in emul_rx_init()
291 k_fifo_init(&data->fifo_out); in emul_rx_init()
292 k_work_init(&data->work, &emul_rx_worker); in emul_rx_init()