Commit 3c1dfb5a authored by Bingbu Cao's avatar Bingbu Cao Committed by Hans Verkuil

media: intel/ipu6: input system video nodes and buffer queues

Register V4L2 video device and setup the VB2 queues to support video
capture. Video streaming callback will trigger the input system driver to
construct a input system stream configuration for firmware based on data
type and stream ID and then queue buffers to firmware to do capture.
Signed-off-by: default avatarBingbu Cao <bingbu.cao@intel.com>
Co-developed-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
parent 1e7eeb30
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0-only */
/* Copyright (C) 2013--2024 Intel Corporation */
#ifndef IPU6_ISYS_QUEUE_H
#define IPU6_ISYS_QUEUE_H
#include <linux/container_of.h>
#include <linux/atomic.h>
#include <linux/device.h>
#include <linux/list.h>
#include <linux/spinlock_types.h>
#include <media/videobuf2-v4l2.h>
#include "ipu6-fw-isys.h"
#include "ipu6-isys-video.h"
struct ipu6_isys_stream;
struct ipu6_isys_queue {
struct vb2_queue vbq;
struct list_head node;
struct device *dev;
/*
* @lock: serialise access to queued and pre_streamon_queued
*/
spinlock_t lock;
struct list_head active;
struct list_head incoming;
unsigned int fw_output;
};
struct ipu6_isys_buffer {
struct list_head head;
atomic_t str2mmio_flag;
};
struct ipu6_isys_video_buffer {
struct vb2_v4l2_buffer vb_v4l2;
struct ipu6_isys_buffer ib;
};
#define IPU6_ISYS_BUFFER_LIST_FL_INCOMING BIT(0)
#define IPU6_ISYS_BUFFER_LIST_FL_ACTIVE BIT(1)
#define IPU6_ISYS_BUFFER_LIST_FL_SET_STATE BIT(2)
struct ipu6_isys_buffer_list {
struct list_head head;
unsigned int nbufs;
};
#define vb2_queue_to_isys_queue(__vb2) \
container_of(__vb2, struct ipu6_isys_queue, vbq)
#define ipu6_isys_to_isys_video_buffer(__ib) \
container_of(__ib, struct ipu6_isys_video_buffer, ib)
#define vb2_buffer_to_ipu6_isys_video_buffer(__vvb) \
container_of(__vvb, struct ipu6_isys_video_buffer, vb_v4l2)
#define ipu6_isys_buffer_to_vb2_buffer(__ib) \
(&ipu6_isys_to_isys_video_buffer(__ib)->vb_v4l2.vb2_buf)
void ipu6_isys_buffer_list_queue(struct ipu6_isys_buffer_list *bl,
unsigned long op_flags,
enum vb2_buffer_state state);
void
ipu6_isys_buf_to_fw_frame_buf(struct ipu6_fw_isys_frame_buff_set_abi *set,
struct ipu6_isys_stream *stream,
struct ipu6_isys_buffer_list *bl);
void
ipu6_isys_buf_calc_sequence_time(struct ipu6_isys_buffer *ib,
struct ipu6_fw_isys_resp_info_abi *info);
void ipu6_isys_queue_buf_done(struct ipu6_isys_buffer *ib);
void ipu6_isys_queue_buf_ready(struct ipu6_isys_stream *stream,
struct ipu6_fw_isys_resp_info_abi *info);
int ipu6_isys_queue_init(struct ipu6_isys_queue *aq);
#endif /* IPU6_ISYS_QUEUE_H */
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0-only */
/* Copyright (C) 2013--2024 Intel Corporation */
#ifndef IPU6_ISYS_VIDEO_H
#define IPU6_ISYS_VIDEO_H
#include <linux/atomic.h>
#include <linux/completion.h>
#include <linux/container_of.h>
#include <linux/list.h>
#include <linux/mutex.h>
#include <media/media-entity.h>
#include <media/v4l2-dev.h>
#include "ipu6-isys-queue.h"
#define IPU6_ISYS_OUTPUT_PINS 11
#define IPU6_ISYS_MAX_PARALLEL_SOF 2
struct file;
struct ipu6_isys;
struct ipu6_isys_csi2;
struct ipu6_isys_subdev;
struct ipu6_isys_pixelformat {
u32 pixelformat;
u32 bpp;
u32 bpp_packed;
u32 code;
u32 css_pixelformat;
};
struct sequence_info {
unsigned int sequence;
u64 timestamp;
};
struct output_pin_data {
void (*pin_ready)(struct ipu6_isys_stream *stream,
struct ipu6_fw_isys_resp_info_abi *info);
struct ipu6_isys_queue *aq;
};
/*
* Align with firmware stream. Each stream represents a CSI virtual channel.
* May map to multiple video devices
*/
struct ipu6_isys_stream {
struct mutex mutex;
struct media_entity *source_entity;
atomic_t sequence;
unsigned int seq_index;
struct sequence_info seq[IPU6_ISYS_MAX_PARALLEL_SOF];
int stream_source;
int stream_handle;
unsigned int nr_output_pins;
struct ipu6_isys_subdev *asd;
int nr_queues; /* Number of capture queues */
int nr_streaming;
int streaming; /* Has streaming been really started? */
struct list_head queues;
struct completion stream_open_completion;
struct completion stream_close_completion;
struct completion stream_start_completion;
struct completion stream_stop_completion;
struct ipu6_isys *isys;
struct output_pin_data output_pins[IPU6_ISYS_OUTPUT_PINS];
int error;
u8 vc;
};
struct video_stream_watermark {
u32 width;
u32 height;
u32 hblank;
u32 frame_rate;
u64 pixel_rate;
u64 stream_data_rate;
u16 sram_gran_shift;
u16 sram_gran_size;
struct list_head stream_node;
};
struct ipu6_isys_video {
struct ipu6_isys_queue aq;
/* Serialise access to other fields in the struct. */
struct mutex mutex;
struct media_pad pad;
struct video_device vdev;
struct v4l2_pix_format pix_fmt;
const struct ipu6_isys_pixelformat *pfmt;
struct ipu6_isys *isys;
struct ipu6_isys_csi2 *csi2;
struct ipu6_isys_stream *stream;
unsigned int streaming;
struct video_stream_watermark watermark;
u32 source_stream;
u8 vc;
u8 dt;
};
#define ipu6_isys_queue_to_video(__aq) \
container_of(__aq, struct ipu6_isys_video, aq)
extern const struct ipu6_isys_pixelformat ipu6_isys_pfmts[];
extern const struct ipu6_isys_pixelformat ipu6_isys_pfmts_packed[];
int ipu6_isys_video_prepare_stream(struct ipu6_isys_video *av,
struct media_entity *source_entity,
int nr_queues);
int ipu6_isys_video_set_streaming(struct ipu6_isys_video *av, int state,
struct ipu6_isys_buffer_list *bl);
int ipu6_isys_fw_open(struct ipu6_isys *isys);
void ipu6_isys_fw_close(struct ipu6_isys *isys);
int ipu6_isys_setup_video(struct ipu6_isys_video *av,
struct media_entity **source_entity, int *nr_queues);
int ipu6_isys_video_init(struct ipu6_isys_video *av);
void ipu6_isys_video_cleanup(struct ipu6_isys_video *av);
void ipu6_isys_put_stream(struct ipu6_isys_stream *stream);
struct ipu6_isys_stream *
ipu6_isys_query_stream_by_handle(struct ipu6_isys *isys, u8 stream_handle);
struct ipu6_isys_stream *
ipu6_isys_query_stream_by_source(struct ipu6_isys *isys, int source, u8 vc);
void ipu6_isys_configure_stream_watermark(struct ipu6_isys_video *av,
bool state);
void ipu6_isys_update_stream_watermark(struct ipu6_isys_video *av, bool state);
#endif /* IPU6_ISYS_VIDEO_H */
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