xref: /linux/drivers/media/platform/amd/isp4/isp4_video.h (revision 8c13415c8a4383447c21ec832b20b3b283f0e01a)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright (C) 2025 Advanced Micro Devices, Inc.
4  */
5 
6 #ifndef _ISP4_VIDEO_H_
7 #define _ISP4_VIDEO_H_
8 
9 #include <media/v4l2-dev.h>
10 #include <media/videobuf2-memops.h>
11 
12 #include "isp4_interface.h"
13 
14 struct isp4vid_capture_buffer {
15 	/*
16 	 * struct vb2_v4l2_buffer must be the first element
17 	 * the videobuf2 framework will allocate this struct based on
18 	 * buf_struct_size and use the first sizeof(struct vb2_buffer) bytes of
19 	 * memory as a vb2_buffer
20 	 */
21 	struct vb2_v4l2_buffer vb2;
22 	struct isp4if_img_buf_info img_buf;
23 	struct list_head list;
24 	struct dma_buf *dbuf;
25 	void *bo;
26 	u64 gpu_addr;
27 };
28 
29 struct isp4vid_dev {
30 	struct video_device vdev;
31 	struct media_pad vdev_pad;
32 	struct v4l2_pix_format format;
33 
34 	/* mutex that protects vbq */
35 	struct mutex vbq_lock;
36 	struct vb2_queue vbq;
37 
38 	/* mutex that protects buf_list */
39 	struct mutex buf_list_lock;
40 	struct list_head buf_list;
41 
42 	u32 sequence;
43 	bool stream_started;
44 
45 	struct device *dev;
46 	struct v4l2_subdev *isp_sdev;
47 	struct v4l2_fract timeperframe;
48 };
49 
50 int isp4vid_dev_init(struct isp4vid_dev *isp_vdev, struct v4l2_subdev *isp_sd);
51 
52 void isp4vid_dev_deinit(struct isp4vid_dev *isp_vdev);
53 
54 void isp4vid_handle_frame_done(struct isp4vid_dev *isp_vdev,
55 			       const struct isp4if_img_buf_info *img_buf);
56 
57 #endif /* _ISP4_VIDEO_H_ */
58