Commit cb48ae89 authored by Hans de Goede's avatar Hans de Goede Committed by Mauro Carvalho Chehab

media: atomisp: Convert to videobuf2

Convert atomisp to use videobuf2.

This fixes mmap not working and in general moving over to
the more modern videobuf2 is a good plan.
Reviewed-by: default avatarAndy Shevchenko <andy@kernel.org>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent 9a29f5fc
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include <asm/iosf_mbi.h> #include <asm/iosf_mbi.h>
#include <media/v4l2-event.h> #include <media/v4l2-event.h>
#include <media/videobuf-vmalloc.h>
#define CREATE_TRACE_POINTS #define CREATE_TRACE_POINTS
#include "atomisp_trace_event.h" #include "atomisp_trace_event.h"
...@@ -662,23 +661,6 @@ void dump_sp_dmem(struct atomisp_device *isp, unsigned int addr, ...@@ -662,23 +661,6 @@ void dump_sp_dmem(struct atomisp_device *isp, unsigned int addr,
} while (--size32); } while (--size32);
} }
static struct videobuf_buffer *atomisp_css_frame_to_vbuf(
struct atomisp_video_pipe *pipe, struct ia_css_frame *frame)
{
struct videobuf_vmalloc_memory *vm_mem;
struct ia_css_frame *handle;
int i;
for (i = 0; pipe->capq.bufs[i]; i++) {
vm_mem = pipe->capq.bufs[i]->priv;
handle = vm_mem->vaddr;
if (handle && handle->data == frame->data)
return pipe->capq.bufs[i];
}
return NULL;
}
int atomisp_buffers_in_css(struct atomisp_video_pipe *pipe) int atomisp_buffers_in_css(struct atomisp_video_pipe *pipe)
{ {
unsigned long irqflags; unsigned long irqflags;
...@@ -695,37 +677,40 @@ int atomisp_buffers_in_css(struct atomisp_video_pipe *pipe) ...@@ -695,37 +677,40 @@ int atomisp_buffers_in_css(struct atomisp_video_pipe *pipe)
return buffers_in_css; return buffers_in_css;
} }
void atomisp_buffer_done(struct atomisp_video_pipe *pipe, struct videobuf_buffer *vb, void atomisp_buffer_done(struct ia_css_frame *frame, enum vb2_buffer_state state)
int state)
{ {
struct atomisp_video_pipe *pipe = vb_to_pipe(&frame->vb.vb2_buf);
lockdep_assert_held(&pipe->irq_lock); lockdep_assert_held(&pipe->irq_lock);
vb->ts = ktime_get_ns(); frame->vb.vb2_buf.timestamp = ktime_get_ns();
vb->field_count = atomic_read(&pipe->asd->sequence) << 1; frame->vb.field = pipe->pix.field;
vb->state = state; frame->vb.sequence = atomic_read(&pipe->asd->sequence);
list_del(&vb->queue); list_del(&frame->queue);
wake_up(&vb->done); if (state == VB2_BUF_STATE_DONE)
vb2_set_plane_payload(&frame->vb.vb2_buf, 0, pipe->pix.sizeimage);
vb2_buffer_done(&frame->vb.vb2_buf, state);
} }
void atomisp_flush_video_pipe(struct atomisp_video_pipe *pipe, bool warn_on_css_frames) void atomisp_flush_video_pipe(struct atomisp_video_pipe *pipe, bool warn_on_css_frames)
{ {
struct videobuf_buffer *_vb, *vb; struct ia_css_frame *frame, *_frame;
unsigned long irqflags; unsigned long irqflags;
spin_lock_irqsave(&pipe->irq_lock, irqflags); spin_lock_irqsave(&pipe->irq_lock, irqflags);
list_for_each_entry_safe(vb, _vb, &pipe->buffers_in_css, queue) { list_for_each_entry_safe(frame, _frame, &pipe->buffers_in_css, queue) {
if (warn_on_css_frames) if (warn_on_css_frames)
dev_warn(pipe->isp->dev, "Warning: CSS frames queued on flush\n"); dev_warn(pipe->isp->dev, "Warning: CSS frames queued on flush\n");
atomisp_buffer_done(pipe, vb, VIDEOBUF_ERROR); atomisp_buffer_done(frame, VB2_BUF_STATE_ERROR);
} }
list_for_each_entry_safe(vb, _vb, &pipe->activeq, queue) list_for_each_entry_safe(frame, _frame, &pipe->activeq, queue)
atomisp_buffer_done(pipe, vb, VIDEOBUF_ERROR); atomisp_buffer_done(frame, VB2_BUF_STATE_ERROR);
list_for_each_entry_safe(vb, _vb, &pipe->buffers_waiting_for_param, queue) { list_for_each_entry_safe(frame, _frame, &pipe->buffers_waiting_for_param, queue) {
pipe->frame_request_config_id[vb->i] = 0; pipe->frame_request_config_id[frame->vb.vb2_buf.index] = 0;
atomisp_buffer_done(pipe, vb, VIDEOBUF_ERROR); atomisp_buffer_done(frame, VB2_BUF_STATE_ERROR);
} }
spin_unlock_irqrestore(&pipe->irq_lock, irqflags); spin_unlock_irqrestore(&pipe->irq_lock, irqflags);
...@@ -874,7 +859,6 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, int error, ...@@ -874,7 +859,6 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, int error,
enum ia_css_pipe_id css_pipe_id, enum ia_css_pipe_id css_pipe_id,
bool q_buffers, enum atomisp_input_stream_id stream_id) bool q_buffers, enum atomisp_input_stream_id stream_id)
{ {
struct videobuf_buffer *vb = NULL;
struct atomisp_video_pipe *pipe = NULL; struct atomisp_video_pipe *pipe = NULL;
struct atomisp_css_buffer buffer; struct atomisp_css_buffer buffer;
bool requeue = false; bool requeue = false;
...@@ -1027,10 +1011,7 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, int error, ...@@ -1027,10 +1011,7 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, int error,
dev_dbg(isp->dev, "%s thumb no flash in this frame\n", dev_dbg(isp->dev, "%s thumb no flash in this frame\n",
__func__); __func__);
} }
vb = atomisp_css_frame_to_vbuf(pipe, frame); pipe->frame_config_id[frame->vb.vb2_buf.index] = frame->isp_config_id;
WARN_ON(!vb);
if (vb)
pipe->frame_config_id[vb->i] = frame->isp_config_id;
if (css_pipe_id == IA_CSS_PIPE_ID_CAPTURE && if (css_pipe_id == IA_CSS_PIPE_ID_CAPTURE &&
asd->pending_capture_request > 0) { asd->pending_capture_request > 0) {
err = atomisp_css_offline_capture_configure(asd, err = atomisp_css_offline_capture_configure(asd,
...@@ -1066,13 +1047,8 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, int error, ...@@ -1066,13 +1047,8 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, int error,
dev_dbg(isp->dev, "%s: main frame with exp_id %d is ready\n", dev_dbg(isp->dev, "%s: main frame with exp_id %d is ready\n",
__func__, frame->exp_id); __func__, frame->exp_id);
vb = atomisp_css_frame_to_vbuf(pipe, frame);
if (!vb) {
WARN_ON(1);
break;
}
i = vb->i; i = frame->vb.vb2_buf.index;
/* free the parameters */ /* free the parameters */
if (pipe->frame_params[i]) { if (pipe->frame_params[i]) {
...@@ -1183,9 +1159,9 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, int error, ...@@ -1183,9 +1159,9 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, int error,
default: default:
break; break;
} }
if (vb) { if (frame) {
spin_lock_irqsave(&pipe->irq_lock, irqflags); spin_lock_irqsave(&pipe->irq_lock, irqflags);
atomisp_buffer_done(pipe, vb, error ? VIDEOBUF_ERROR : VIDEOBUF_DONE); atomisp_buffer_done(frame, error ? VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE);
spin_unlock_irqrestore(&pipe->irq_lock, irqflags); spin_unlock_irqrestore(&pipe->irq_lock, irqflags);
} }
...@@ -3656,6 +3632,18 @@ void atomisp_free_css_parameters(struct atomisp_css_params *css_param) ...@@ -3656,6 +3632,18 @@ void atomisp_free_css_parameters(struct atomisp_css_params *css_param)
} }
} }
static void atomisp_move_frame_to_activeq(struct ia_css_frame *frame,
struct atomisp_css_params_with_list *param)
{
struct atomisp_video_pipe *pipe = vb_to_pipe(&frame->vb.vb2_buf);
unsigned long irqflags;
pipe->frame_params[frame->vb.vb2_buf.index] = param;
spin_lock_irqsave(&pipe->irq_lock, irqflags);
list_move_tail(&frame->queue, &pipe->activeq);
spin_unlock_irqrestore(&pipe->irq_lock, irqflags);
}
/* /*
* Check parameter queue list and buffer queue list to find out if matched items * Check parameter queue list and buffer queue list to find out if matched items
* and then set parameter to CSS and enqueue buffer to CSS. * and then set parameter to CSS and enqueue buffer to CSS.
...@@ -3666,11 +3654,10 @@ void atomisp_free_css_parameters(struct atomisp_css_params *css_param) ...@@ -3666,11 +3654,10 @@ void atomisp_free_css_parameters(struct atomisp_css_params *css_param)
void atomisp_handle_parameter_and_buffer(struct atomisp_video_pipe *pipe) void atomisp_handle_parameter_and_buffer(struct atomisp_video_pipe *pipe)
{ {
struct atomisp_sub_device *asd = pipe->asd; struct atomisp_sub_device *asd = pipe->asd;
struct videobuf_buffer *vb = NULL, *vb_tmp; struct ia_css_frame *frame = NULL, *frame_tmp;
struct atomisp_css_params_with_list *param = NULL, *param_tmp; struct atomisp_css_params_with_list *param = NULL, *param_tmp;
struct videobuf_vmalloc_memory *vm_mem = NULL;
unsigned long irqflags;
bool need_to_enqueue_buffer = false; bool need_to_enqueue_buffer = false;
int i;
if (!asd) { if (!asd) {
dev_err(pipe->isp->dev, "%s(): asd is NULL, device is %s\n", dev_err(pipe->isp->dev, "%s(): asd is NULL, device is %s\n",
...@@ -3694,44 +3681,32 @@ void atomisp_handle_parameter_and_buffer(struct atomisp_video_pipe *pipe) ...@@ -3694,44 +3681,32 @@ void atomisp_handle_parameter_and_buffer(struct atomisp_video_pipe *pipe)
list_empty(&pipe->buffers_waiting_for_param)) list_empty(&pipe->buffers_waiting_for_param))
return; return;
list_for_each_entry_safe(vb, vb_tmp, list_for_each_entry_safe(frame, frame_tmp,
&pipe->buffers_waiting_for_param, queue) { &pipe->buffers_waiting_for_param, queue) {
if (pipe->frame_request_config_id[vb->i]) { i = frame->vb.vb2_buf.index;
if (pipe->frame_request_config_id[i]) {
list_for_each_entry_safe(param, param_tmp, list_for_each_entry_safe(param, param_tmp,
&pipe->per_frame_params, list) { &pipe->per_frame_params, list) {
if (pipe->frame_request_config_id[vb->i] != if (pipe->frame_request_config_id[i] != param->params.isp_config_id)
param->params.isp_config_id)
continue; continue;
list_del(&param->list); list_del(&param->list);
list_del(&vb->queue);
/* /*
* clear the request config id as the buffer * clear the request config id as the buffer
* will be handled and enqueued into CSS soon * will be handled and enqueued into CSS soon
*/ */
pipe->frame_request_config_id[vb->i] = 0; pipe->frame_request_config_id[i] = 0;
pipe->frame_params[vb->i] = param; atomisp_move_frame_to_activeq(frame, param);
vm_mem = vb->priv; need_to_enqueue_buffer = true;
BUG_ON(!vm_mem);
break; break;
} }
if (vm_mem) { /* If this is the end, stop further loop */
spin_lock_irqsave(&pipe->irq_lock, irqflags); if (list_entry_is_head(param, &pipe->per_frame_params, list))
list_add_tail(&vb->queue, &pipe->activeq);
spin_unlock_irqrestore(&pipe->irq_lock, irqflags);
vm_mem = NULL;
need_to_enqueue_buffer = true;
} else {
/* The is the end, stop further loop */
break; break;
}
} else { } else {
list_del(&vb->queue); atomisp_move_frame_to_activeq(frame, NULL);
pipe->frame_params[vb->i] = NULL;
spin_lock_irqsave(&pipe->irq_lock, irqflags);
list_add_tail(&vb->queue, &pipe->activeq);
spin_unlock_irqrestore(&pipe->irq_lock, irqflags);
need_to_enqueue_buffer = true; need_to_enqueue_buffer = true;
} }
} }
...@@ -5538,8 +5513,6 @@ int atomisp_set_fmt(struct file *file, void *unused, struct v4l2_format *f) ...@@ -5538,8 +5513,6 @@ int atomisp_set_fmt(struct file *file, void *unused, struct v4l2_format *f)
f->fmt.pix.priv = PAGE_ALIGN(pipe->pix.width * f->fmt.pix.priv = PAGE_ALIGN(pipe->pix.width *
pipe->pix.height * 2); pipe->pix.height * 2);
pipe->capq.field = f->fmt.pix.field;
/* /*
* If in video 480P case, no GFX throttle * If in video 480P case, no GFX throttle
*/ */
......
...@@ -56,8 +56,7 @@ struct camera_mipi_info *atomisp_to_sensor_mipi_info(struct v4l2_subdev *sd); ...@@ -56,8 +56,7 @@ struct camera_mipi_info *atomisp_to_sensor_mipi_info(struct v4l2_subdev *sd);
struct atomisp_video_pipe *atomisp_to_video_pipe(struct video_device *dev); struct atomisp_video_pipe *atomisp_to_video_pipe(struct video_device *dev);
int atomisp_reset(struct atomisp_device *isp); int atomisp_reset(struct atomisp_device *isp);
int atomisp_buffers_in_css(struct atomisp_video_pipe *pipe); int atomisp_buffers_in_css(struct atomisp_video_pipe *pipe);
void atomisp_buffer_done(struct atomisp_video_pipe *pipe, struct videobuf_buffer *buf, void atomisp_buffer_done(struct ia_css_frame *frame, enum vb2_buffer_state state);
int state);
void atomisp_flush_video_pipe(struct atomisp_video_pipe *pipe, bool warn_on_css_frames); void atomisp_flush_video_pipe(struct atomisp_video_pipe *pipe, bool warn_on_css_frames);
void atomisp_flush_bufs_and_wakeup(struct atomisp_sub_device *asd); void atomisp_flush_bufs_and_wakeup(struct atomisp_sub_device *asd);
void atomisp_clear_css_buffer_counters(struct atomisp_sub_device *asd); void atomisp_clear_css_buffer_counters(struct atomisp_sub_device *asd);
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include <linux/v4l2-mediabus.h> #include <linux/v4l2-mediabus.h>
#include <media/videobuf-core.h> #include <media/videobuf2-v4l2.h>
#include "atomisp_compat.h" #include "atomisp_compat.h"
...@@ -64,8 +64,4 @@ struct atomisp_fmt { ...@@ -64,8 +64,4 @@ struct atomisp_fmt {
u32 bayer_order; u32 bayer_order;
}; };
struct atomisp_buffer {
struct videobuf_buffer vb;
};
#endif #endif
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include "atomisp_compat_css20.h" #include "atomisp_compat_css20.h"
#include "../../include/linux/atomisp.h" #include "../../include/linux/atomisp.h"
#include <media/videobuf-vmalloc.h>
struct atomisp_device; struct atomisp_device;
struct atomisp_sub_device; struct atomisp_sub_device;
...@@ -61,7 +60,7 @@ int atomisp_css_irq_enable(struct atomisp_device *isp, ...@@ -61,7 +60,7 @@ int atomisp_css_irq_enable(struct atomisp_device *isp,
enum ia_css_irq_info info, bool enable); enum ia_css_irq_info info, bool enable);
int atomisp_q_video_buffer_to_css(struct atomisp_sub_device *asd, int atomisp_q_video_buffer_to_css(struct atomisp_sub_device *asd,
struct videobuf_vmalloc_memory *vm_mem, struct ia_css_frame *frame,
enum atomisp_input_stream_id stream_id, enum atomisp_input_stream_id stream_id,
enum ia_css_buffer_type css_buf_type, enum ia_css_buffer_type css_buf_type,
enum ia_css_pipe_id css_pipe_id); enum ia_css_pipe_id css_pipe_id);
......
...@@ -996,7 +996,7 @@ void atomisp_css_init_struct(struct atomisp_sub_device *asd) ...@@ -996,7 +996,7 @@ void atomisp_css_init_struct(struct atomisp_sub_device *asd)
} }
int atomisp_q_video_buffer_to_css(struct atomisp_sub_device *asd, int atomisp_q_video_buffer_to_css(struct atomisp_sub_device *asd,
struct videobuf_vmalloc_memory *vm_mem, struct ia_css_frame *frame,
enum atomisp_input_stream_id stream_id, enum atomisp_input_stream_id stream_id,
enum ia_css_buffer_type css_buf_type, enum ia_css_buffer_type css_buf_type,
enum ia_css_pipe_id css_pipe_id) enum ia_css_pipe_id css_pipe_id)
...@@ -1006,7 +1006,7 @@ int atomisp_q_video_buffer_to_css(struct atomisp_sub_device *asd, ...@@ -1006,7 +1006,7 @@ int atomisp_q_video_buffer_to_css(struct atomisp_sub_device *asd,
int err; int err;
css_buf.type = css_buf_type; css_buf.type = css_buf_type;
css_buf.data.frame = vm_mem->vaddr; css_buf.data.frame = frame;
err = ia_css_pipe_enqueue_buffer( err = ia_css_pipe_enqueue_buffer(
stream_env->pipes[css_pipe_id], &css_buf); stream_env->pipes[css_pipe_id], &css_buf);
......
...@@ -29,13 +29,6 @@ unsigned int atomisp_sub_dev_users(struct atomisp_sub_device *asd); ...@@ -29,13 +29,6 @@ unsigned int atomisp_sub_dev_users(struct atomisp_sub_device *asd);
* Memory help functions for image frame and private parameters * Memory help functions for image frame and private parameters
*/ */
int atomisp_videobuf_mmap_mapper(struct videobuf_queue *q,
struct vm_area_struct *vma);
int atomisp_qbuf_to_css(struct atomisp_device *isp,
struct atomisp_video_pipe *pipe,
struct videobuf_buffer *vb);
int atomisp_qbuffers_to_css(struct atomisp_sub_device *asd); int atomisp_qbuffers_to_css(struct atomisp_sub_device *asd);
extern const struct v4l2_file_operations atomisp_fops; extern const struct v4l2_file_operations atomisp_fops;
......
...@@ -39,14 +39,12 @@ int atomisp_pipe_check(struct atomisp_video_pipe *pipe, bool streaming_ok); ...@@ -39,14 +39,12 @@ int atomisp_pipe_check(struct atomisp_video_pipe *pipe, bool streaming_ok);
int atomisp_alloc_css_stat_bufs(struct atomisp_sub_device *asd, int atomisp_alloc_css_stat_bufs(struct atomisp_sub_device *asd,
uint16_t stream_id); uint16_t stream_id);
int atomisp_streamoff(struct file *file, void *fh, enum v4l2_buf_type type); int atomisp_start_streaming(struct vb2_queue *vq, unsigned int count);
int atomisp_reqbufs(struct file *file, void *fh, struct v4l2_requestbuffers *req); void atomisp_stop_streaming(struct vb2_queue *vq);
enum ia_css_pipe_id atomisp_get_css_pipe_id(struct atomisp_sub_device enum ia_css_pipe_id atomisp_get_css_pipe_id(struct atomisp_sub_device
*asd); *asd);
void atomisp_videobuf_free_buf(struct videobuf_buffer *vb);
extern const struct v4l2_ioctl_ops atomisp_ioctl_ops; extern const struct v4l2_ioctl_ops atomisp_ioctl_ops;
unsigned int atomisp_streaming_count(struct atomisp_device *isp); unsigned int atomisp_streaming_count(struct atomisp_device *isp);
...@@ -57,4 +55,8 @@ long atomisp_compat_ioctl32(struct file *file, ...@@ -57,4 +55,8 @@ long atomisp_compat_ioctl32(struct file *file,
int atomisp_stream_on_master_slave_sensor(struct atomisp_device *isp, int atomisp_stream_on_master_slave_sensor(struct atomisp_device *isp,
bool isp_timeout); bool isp_timeout);
int atomisp_start_streaming(struct vb2_queue *vq, unsigned int count);
void atomisp_stop_streaming(struct vb2_queue *vq);
#endif /* __ATOMISP_IOCTL_H__ */ #endif /* __ATOMISP_IOCTL_H__ */
...@@ -1064,6 +1064,7 @@ static void atomisp_init_subdev_pipe(struct atomisp_sub_device *asd, ...@@ -1064,6 +1064,7 @@ static void atomisp_init_subdev_pipe(struct atomisp_sub_device *asd,
pipe->asd = asd; pipe->asd = asd;
pipe->isp = asd->isp; pipe->isp = asd->isp;
spin_lock_init(&pipe->irq_lock); spin_lock_init(&pipe->irq_lock);
mutex_init(&pipe->vb_queue_mutex);
INIT_LIST_HEAD(&pipe->buffers_in_css); INIT_LIST_HEAD(&pipe->buffers_in_css);
INIT_LIST_HEAD(&pipe->activeq); INIT_LIST_HEAD(&pipe->activeq);
INIT_LIST_HEAD(&pipe->buffers_waiting_for_param); INIT_LIST_HEAD(&pipe->buffers_waiting_for_param);
......
...@@ -21,8 +21,7 @@ ...@@ -21,8 +21,7 @@
#include <media/v4l2-ctrls.h> #include <media/v4l2-ctrls.h>
#include <media/v4l2-device.h> #include <media/v4l2-device.h>
#include <media/v4l2-subdev.h> #include <media/v4l2-subdev.h>
#include <media/videobuf-core.h> #include <media/videobuf2-v4l2.h>
#include "atomisp_common.h" #include "atomisp_common.h"
#include "atomisp_compat.h" #include "atomisp_compat.h"
#include "atomisp_v4l2.h" #include "atomisp_v4l2.h"
...@@ -69,7 +68,9 @@ struct atomisp_video_pipe { ...@@ -69,7 +68,9 @@ struct atomisp_video_pipe {
struct video_device vdev; struct video_device vdev;
enum v4l2_buf_type type; enum v4l2_buf_type type;
struct media_pad pad; struct media_pad pad;
struct videobuf_queue capq; struct vb2_queue vb_queue;
/* Lock for vb_queue, when also taking isp->mutex this must be taken first! */
struct mutex vb_queue_mutex;
/* List of video-buffers handed over to the CSS */ /* List of video-buffers handed over to the CSS */
struct list_head buffers_in_css; struct list_head buffers_in_css;
/* List of video-buffers handed over to the driver, but not yet to the CSS */ /* List of video-buffers handed over to the driver, but not yet to the CSS */
...@@ -82,6 +83,9 @@ struct atomisp_video_pipe { ...@@ -82,6 +83,9 @@ struct atomisp_video_pipe {
/* the link list to store per_frame parameters */ /* the link list to store per_frame parameters */
struct list_head per_frame_params; struct list_head per_frame_params;
/* Filled through atomisp_get_css_frame_info() on queue setup */
struct ia_css_frame_info frame_info;
/* Store here the initial run mode */ /* Store here the initial run mode */
unsigned int default_run_mode; unsigned int default_run_mode;
/* Set from streamoff to disallow queuing further buffers in CSS */ /* Set from streamoff to disallow queuing further buffers in CSS */
...@@ -113,6 +117,11 @@ struct atomisp_video_pipe { ...@@ -113,6 +117,11 @@ struct atomisp_video_pipe {
struct atomisp_css_params_with_list *frame_params[VIDEO_MAX_FRAME]; struct atomisp_css_params_with_list *frame_params[VIDEO_MAX_FRAME];
}; };
#define vq_to_pipe(queue) \
container_of(queue, struct atomisp_video_pipe, vb_queue)
#define vb_to_pipe(vb) vq_to_pipe((vb)->vb2_queue)
struct atomisp_pad_format { struct atomisp_pad_format {
struct v4l2_mbus_framefmt fmt; struct v4l2_mbus_framefmt fmt;
struct v4l2_rect crop; struct v4l2_rect crop;
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
* This file contains structs to describe various frame-formats supported by the ISP. * This file contains structs to describe various frame-formats supported by the ISP.
*/ */
#include <media/videobuf2-v4l2.h>
#include <type_support.h> #include <type_support.h>
#include "ia_css_err.h" #include "ia_css_err.h"
#include "ia_css_types.h" #include "ia_css_types.h"
...@@ -146,6 +147,17 @@ enum ia_css_frame_flash_state { ...@@ -146,6 +147,17 @@ enum ia_css_frame_flash_state {
* This is the main structure used for all input and output images. * This is the main structure used for all input and output images.
*/ */
struct ia_css_frame { struct ia_css_frame {
/*
* The videobuf2 core will allocate buffers including room for private
* data (the rest of struct ia_css_frame). The vb2_v4l2_buffer must
* be the first member for this to work!
* Note the atomisp code also uses ia_css_frame-s which are not used
* as v4l2-buffers in some places. In this case the vb2 member will
* be unused.
*/
struct vb2_v4l2_buffer vb;
/* List-head for linking into the activeq or buffers_waiting_for_param list */
struct list_head queue;
struct ia_css_frame_info frame_info; /** info struct describing the frame */ struct ia_css_frame_info frame_info; /** info struct describing the frame */
ia_css_ptr data; /** pointer to start of image data */ ia_css_ptr data; /** pointer to start of image data */
unsigned int data_bytes; /** size of image data in bytes */ unsigned int data_bytes; /** size of image data in bytes */
...@@ -183,6 +195,9 @@ struct ia_css_frame { ...@@ -183,6 +195,9 @@ struct ia_css_frame {
info.format */ info.format */
}; };
#define vb_to_frame(vb2) \
container_of(to_vb2_v4l2_buffer(vb2), struct ia_css_frame, vb)
#define DEFAULT_FRAME { \ #define DEFAULT_FRAME { \
.frame_info = IA_CSS_BINARY_DEFAULT_FRAME_INFO, \ .frame_info = IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
.dynamic_queue_id = SH_CSS_INVALID_QUEUE_ID, \ .dynamic_queue_id = SH_CSS_INVALID_QUEUE_ID, \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment