Line data Source code
1 : #ifndef IPU4_COMPAT_H
2 : #define IPU4_COMPAT_H
3 :
4 : #include <linux/version.h>
5 : #include <media/media-entity.h>
6 : #include <media/v4l2-subdev.h>
7 :
8 : #if KERNEL_VERSION(6, 18, 0) > LINUX_VERSION_CODE
9 : // https://github.com/torvalds/linux/commit/683342ce3c0dae068bf0ee157ee12c13088193f7
10 1 : static __maybe_unused s64 ambu_v4l2_get_link_freq(struct media_pad *src_pad, unsigned int mul,
11 : unsigned int div) {
12 1 : struct v4l2_subdev *ext_sd = media_entity_to_v4l2_subdev(src_pad->entity);
13 :
14 1 : if (WARN(!ext_sd, "Failed to get subdev"))
15 0 : return -ENODEV;
16 :
17 1 : return v4l2_get_link_freq(ext_sd->ctrl_handler, 0, 0);
18 : }
19 : #undef v4l2_get_link_freq
20 : #define v4l2_get_link_freq(PAD, MUL, DIV) ambu_v4l2_get_link_freq(PAD, MUL, DIV)
21 : #endif
22 :
23 : #if KERNEL_VERSION(6, 14, 0) <= LINUX_VERSION_CODE
24 : #define INTEL_IPU_BRIDGE "INTEL_IPU_BRIDGE"
25 : #define INTEL_IPU6 "INTEL_IPU6"
26 : #endif
27 :
28 : #if LINUX_VERSION_CODE < KERNEL_VERSION(6, 11, 0)
29 : // https://github.com/torvalds/linux/commit/dbbe7eaf0e4795bf003ac06872aaf52b6b6b1310
30 :
31 : /* Simple helper for dev_err_probe() when ERR_CAST() is to be returned. */
32 : #define dev_err_cast_probe(dev, ___err_ptr, fmt, ...) \
33 : ERR_PTR(dev_err_probe(dev, PTR_ERR(___err_ptr), fmt, ##__VA_ARGS__))
34 :
35 : #endif // 6.11
36 :
37 :
38 : #if LINUX_VERSION_CODE < KERNEL_VERSION(6, 10, 0)
39 :
40 : // From include/uapi/linux/media-bus-format.h
41 : /* Generic line based metadata formats for serial buses. Next is 0x8008. */
42 : #define MEDIA_BUS_FMT_META_8 0x8001
43 : #define MEDIA_BUS_FMT_META_10 0x8002
44 : #define MEDIA_BUS_FMT_META_12 0x8003
45 : #define MEDIA_BUS_FMT_META_14 0x8004
46 : #define MEDIA_BUS_FMT_META_16 0x8005
47 : #define MEDIA_BUS_FMT_META_20 0x8006
48 : #define MEDIA_BUS_FMT_META_24 0x8007
49 :
50 : // commit d0fde6aae2bacdc024fff43461ba0f325375fa97
51 : // Author: Sakari Ailus <sakari.ailus@linux.intel.com>
52 : // Date: Fri Oct 13 10:16:06 2023 +0200
53 : //
54 : // media: v4l: subdev: Rename sub-device state information access functions
55 :
56 : #define v4l2_subdev_state_get_format(state, pad, stream) \
57 : v4l2_subdev_state_get_stream_format(state, pad, stream)
58 :
59 : #define v4l2_subdev_state_get_crop(state, pad, stream) \
60 : v4l2_subdev_state_get_stream_crop(state, pad, stream)
61 :
62 : #else // >= 6.10
63 : // Converting old call to new, because old takes 3 args
64 : #define v4l2_subdev_get_pad_format(e1, e2, e3) \
65 : v4l2_subdev_state_get_format(e2, e3)
66 :
67 : #endif // 6.10
68 :
69 :
70 : #if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 103)
71 : // Before 6.9, pm_runtime_get_if_active took an extra argument.
72 : // See https://github.com/torvalds/linux/commit/c0ef3df8dbaef51ee4cfd58a471adf2eaee6f6b3
73 : // It was backported in 6.6.103.
74 : // See https://github.com/gregkh/linux/commit/ac2e62cab0977960420a0f4b3197932591a104f8
75 : #define pm_runtime_get_if_active(DEV) pm_runtime_get_if_active(DEV, true)
76 : #endif // 6.9
77 :
78 : #endif // IPU4_COMPAT_H
|