1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Copyright (C) 2013--2024 Intel Corporation */
4 #ifndef IPU6_ISYS_VIDEO_H
5 #define IPU6_ISYS_VIDEO_H
7 #include <linux/atomic.h>
8 #include <linux/completion.h>
9 #include <linux/container_of.h>
10 #include <linux/list.h>
11 #include <linux/mutex.h>
13 #include <media/media-entity.h>
14 #include <media/v4l2-dev.h>
16 #include "ipu6-isys-queue.h"
18 #define IPU6_ISYS_OUTPUT_PINS 11
19 #define IPU6_ISYS_MAX_PARALLEL_SOF 2
23 struct ipu6_isys_csi2
;
24 struct ipu6_isys_subdev
;
26 struct ipu6_isys_pixelformat
{
35 struct sequence_info
{
36 unsigned int sequence
;
40 struct output_pin_data
{
41 void (*pin_ready
)(struct ipu6_isys_stream
*stream
,
42 struct ipu6_fw_isys_resp_info_abi
*info
);
43 struct ipu6_isys_queue
*aq
;
47 * Align with firmware stream. Each stream represents a CSI virtual channel.
48 * May map to multiple video devices
50 struct ipu6_isys_stream
{
52 struct media_entity
*source_entity
;
54 unsigned int seq_index
;
55 struct sequence_info seq
[IPU6_ISYS_MAX_PARALLEL_SOF
];
58 unsigned int nr_output_pins
;
59 struct ipu6_isys_subdev
*asd
;
61 int nr_queues
; /* Number of capture queues */
63 int streaming
; /* Has streaming been really started? */
64 struct list_head queues
;
65 struct completion stream_open_completion
;
66 struct completion stream_close_completion
;
67 struct completion stream_start_completion
;
68 struct completion stream_stop_completion
;
69 struct ipu6_isys
*isys
;
71 struct output_pin_data output_pins
[IPU6_ISYS_OUTPUT_PINS
];
76 struct video_stream_watermark
{
85 struct list_head stream_node
;
88 struct ipu6_isys_video
{
89 struct ipu6_isys_queue aq
;
90 /* Serialise access to other fields in the struct. */
93 struct video_device vdev
;
94 struct v4l2_pix_format pix_fmt
;
95 struct v4l2_meta_format meta_fmt
;
96 struct ipu6_isys
*isys
;
97 struct ipu6_isys_csi2
*csi2
;
98 struct ipu6_isys_stream
*stream
;
99 unsigned int streaming
;
100 struct video_stream_watermark watermark
;
106 #define ipu6_isys_queue_to_video(__aq) \
107 container_of(__aq, struct ipu6_isys_video, aq)
109 extern const struct ipu6_isys_pixelformat ipu6_isys_pfmts
[];
110 extern const struct ipu6_isys_pixelformat ipu6_isys_pfmts_packed
[];
112 const struct ipu6_isys_pixelformat
*
113 ipu6_isys_get_isys_format(u32 pixelformat
, u32 code
);
114 int ipu6_isys_video_prepare_stream(struct ipu6_isys_video
*av
,
115 struct media_entity
*source_entity
,
117 int ipu6_isys_video_set_streaming(struct ipu6_isys_video
*av
, int state
,
118 struct ipu6_isys_buffer_list
*bl
);
119 int ipu6_isys_fw_open(struct ipu6_isys
*isys
);
120 void ipu6_isys_fw_close(struct ipu6_isys
*isys
);
121 int ipu6_isys_setup_video(struct ipu6_isys_video
*av
,
122 struct media_entity
**source_entity
, int *nr_queues
);
123 int ipu6_isys_video_init(struct ipu6_isys_video
*av
);
124 void ipu6_isys_video_cleanup(struct ipu6_isys_video
*av
);
125 void ipu6_isys_put_stream(struct ipu6_isys_stream
*stream
);
126 struct ipu6_isys_stream
*
127 ipu6_isys_query_stream_by_handle(struct ipu6_isys
*isys
, u8 stream_handle
);
128 struct ipu6_isys_stream
*
129 ipu6_isys_query_stream_by_source(struct ipu6_isys
*isys
, int source
, u8 vc
);
131 void ipu6_isys_configure_stream_watermark(struct ipu6_isys_video
*av
,
133 void ipu6_isys_update_stream_watermark(struct ipu6_isys_video
*av
, bool state
);
135 u32
ipu6_isys_get_format(struct ipu6_isys_video
*av
);
136 u32
ipu6_isys_get_data_size(struct ipu6_isys_video
*av
);
137 u32
ipu6_isys_get_bytes_per_line(struct ipu6_isys_video
*av
);
138 u32
ipu6_isys_get_frame_width(struct ipu6_isys_video
*av
);
139 u32
ipu6_isys_get_frame_height(struct ipu6_isys_video
*av
);
141 #endif /* IPU6_ISYS_VIDEO_H */