xref: /linux/drivers/media/pci/intel/ipu6/ipu6-isys-subdev.h (revision 2a6b6c9a226279b4f6668450ddb21ae655558087)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Copyright (C) 2013--2024 Intel Corporation */
3 
4 #ifndef IPU6_ISYS_SUBDEV_H
5 #define IPU6_ISYS_SUBDEV_H
6 
7 #include <linux/container_of.h>
8 
9 #include <media/media-entity.h>
10 #include <media/v4l2-ctrls.h>
11 #include <media/v4l2-subdev.h>
12 
13 struct ipu6_isys;
14 
15 struct ipu6_isys_subdev {
16 	struct v4l2_subdev sd;
17 	struct ipu6_isys *isys;
18 	u32 const *supported_codes;
19 	struct media_pad *pad;
20 	struct v4l2_ctrl_handler ctrl_handler;
21 	void (*ctrl_init)(struct v4l2_subdev *sd);
22 	int source;	/* SSI stream source; -1 if unset */
23 };
24 
25 #define to_ipu6_isys_subdev(__sd) \
26 	container_of(__sd, struct ipu6_isys_subdev, sd)
27 
28 unsigned int ipu6_isys_mbus_code_to_bpp(u32 code);
29 unsigned int ipu6_isys_mbus_code_to_mipi(u32 code);
30 bool ipu6_isys_is_bayer_format(u32 code);
31 u32 ipu6_isys_convert_bayer_order(u32 code, int x, int y);
32 
33 int ipu6_isys_subdev_set_fmt(struct v4l2_subdev *sd,
34 			     struct v4l2_subdev_state *state,
35 			     struct v4l2_subdev_format *fmt);
36 int ipu6_isys_subdev_enum_mbus_code(struct v4l2_subdev *sd,
37 				    struct v4l2_subdev_state *state,
38 				    struct v4l2_subdev_mbus_code_enum
39 				    *code);
40 int ipu6_isys_subdev_link_validate(struct v4l2_subdev *sd,
41 				   struct media_link *link,
42 				   struct v4l2_subdev_format *source_fmt,
43 				   struct v4l2_subdev_format *sink_fmt);
44 u32 ipu6_isys_get_src_stream_by_src_pad(struct v4l2_subdev *sd, u32 pad);
45 int ipu6_isys_get_stream_pad_fmt(struct v4l2_subdev *sd, u32 pad, u32 stream,
46 				 struct v4l2_mbus_framefmt *format);
47 int ipu6_isys_get_stream_pad_crop(struct v4l2_subdev *sd, u32 pad, u32 stream,
48 				  struct v4l2_rect *crop);
49 int ipu6_isys_subdev_set_routing(struct v4l2_subdev *sd,
50 				 struct v4l2_subdev_state *state,
51 				 enum v4l2_subdev_format_whence which,
52 				 struct v4l2_subdev_krouting *routing);
53 int ipu6_isys_subdev_init(struct ipu6_isys_subdev *asd,
54 			  const struct v4l2_subdev_ops *ops,
55 			  unsigned int nr_ctrls,
56 			  unsigned int num_sink_pads,
57 			  unsigned int num_source_pads);
58 void ipu6_isys_subdev_cleanup(struct ipu6_isys_subdev *asd);
59 #endif /* IPU6_ISYS_SUBDEV_H */
60