diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 00f67f4bac3f..759ff5bc151e 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -57,6 +57,8 @@ #include #include #include +#include +#include /* * Export tracepoints that act as a bare tracehook (ie: have no trace event @@ -302,3 +304,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_save_track_hash); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_set_task_comm); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cpufreq_acct_update_power); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_typec_tcpm_log); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_media_device_setup_link); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_clear_reserved_fmt_fields); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_fill_ext_fmtdesc); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_clear_mask_adjust); diff --git a/drivers/media/mc/mc-device.c b/drivers/media/mc/mc-device.c index 9e56d2ad6b94..97baa541c826 100644 --- a/drivers/media/mc/mc-device.c +++ b/drivers/media/mc/mc-device.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -203,6 +204,7 @@ static long media_device_setup_link(struct media_device *mdev, void *arg) struct media_link *link = NULL; struct media_entity *source; struct media_entity *sink; + int ret = 0; /* Find the source and sink entities and link. */ @@ -221,9 +223,12 @@ static long media_device_setup_link(struct media_device *mdev, void *arg) if (link == NULL) return -EINVAL; - memset(linkd->reserved, 0, sizeof(linkd->reserved)); + /* Setup the link on both entities */ + trace_android_vh_media_device_setup_link(link, linkd, &ret); + if (ret) + return ret; - /* Setup the link on both entities. */ + memset(linkd->reserved, 0, sizeof(linkd->reserved)); return __media_entity_setup_link(link, linkd->flags); } diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index 9eda8b91d17a..b0101e08fcdc 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -28,6 +28,8 @@ #include #include +#include + /* Zero out the end of the struct pointed to by p. Everything after, but * not including, the specified field is cleared. */ @@ -76,6 +78,15 @@ static const struct std_descr standards[] = { { 0, "Unknown" } }; +static void clear_reserved(struct v4l2_format *p) +{ + int ret = 0; + + trace_android_vh_clear_reserved_fmt_fields(p, &ret); + if (!ret) + CLEAR_AFTER_FIELD(p, fmt.pix_mp.xfer_func); +} + /* video4linux standard ID conversion to standard name */ const char *v4l2_norm_to_name(v4l2_std_id id) @@ -1452,6 +1463,9 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt) case V4L2_PIX_FMT_MT21C: descr = "Mediatek Compressed Format"; break; case V4L2_PIX_FMT_SUNXI_TILED_NV12: descr = "Sunxi Tiled NV12 Format"; break; default: + trace_android_vh_fill_ext_fmtdesc(fmt, &descr); + if (descr) + break; if (fmt->description[0]) return; WARN(1, "Unknown pixelformat 0x%08x\n", fmt->pixelformat); @@ -1673,7 +1687,7 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: if (unlikely(!ops->vidioc_s_fmt_vid_cap_mplane)) break; - CLEAR_AFTER_FIELD(p, fmt.pix_mp.xfer_func); + clear_reserved(p); for (i = 0; i < p->fmt.pix_mp.num_planes; i++) CLEAR_AFTER_FIELD(&p->fmt.pix_mp.plane_fmt[i], bytesperline); @@ -1704,7 +1718,7 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: if (unlikely(!ops->vidioc_s_fmt_vid_out_mplane)) break; - CLEAR_AFTER_FIELD(p, fmt.pix_mp.xfer_func); + clear_reserved(p); for (i = 0; i < p->fmt.pix_mp.num_planes; i++) CLEAR_AFTER_FIELD(&p->fmt.pix_mp.plane_fmt[i], bytesperline); @@ -1775,7 +1789,7 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops, case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: if (unlikely(!ops->vidioc_try_fmt_vid_cap_mplane)) break; - CLEAR_AFTER_FIELD(p, fmt.pix_mp.xfer_func); + clear_reserved(p); for (i = 0; i < p->fmt.pix_mp.num_planes; i++) CLEAR_AFTER_FIELD(&p->fmt.pix_mp.plane_fmt[i], bytesperline); @@ -1806,7 +1820,7 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops, case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: if (unlikely(!ops->vidioc_try_fmt_vid_out_mplane)) break; - CLEAR_AFTER_FIELD(p, fmt.pix_mp.xfer_func); + clear_reserved(p); for (i = 0; i < p->fmt.pix_mp.num_planes; i++) CLEAR_AFTER_FIELD(&p->fmt.pix_mp.plane_fmt[i], bytesperline); @@ -3167,6 +3181,7 @@ static int video_get_user(void __user *arg, void *parg, unsigned int cmd, if (flags & INFO_FL_CLEAR_MASK) n = (flags & INFO_FL_CLEAR_MASK) >> 16; *always_copy = flags & INFO_FL_ALWAYS_COPY; + trace_android_vh_clear_mask_adjust(v4l2_ioctls[_IOC_NR(cmd)].ioctl, &n); } if (copy_from_user(parg, (void __user *)arg, n)) diff --git a/include/media/media-entity.h b/include/media/media-entity.h index cbdfcb79d0d0..eacba87a6ca7 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -17,6 +17,7 @@ #include #include #include +#include /* Enums used internally at the media controller to represent graphs */ @@ -145,6 +146,7 @@ struct media_link { struct media_link *reverse; unsigned long flags; bool is_backlink; + ANDROID_VENDOR_DATA(1); }; /** diff --git a/include/trace/hooks/v4l2core.h b/include/trace/hooks/v4l2core.h new file mode 100644 index 000000000000..26b49d69f13d --- /dev/null +++ b/include/trace/hooks/v4l2core.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM v4l2core + +#define TRACE_INCLUDE_PATH trace/hooks + +#if !defined(_TRACE_HOOK_V4L2CORE_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_HOOK_V4L2_CORE_H + +#include +#include + +struct v4l2_format; +DECLARE_HOOK(android_vh_clear_reserved_fmt_fields, + TP_PROTO(struct v4l2_format *fmt, int *ret), + TP_ARGS(fmt, ret)); + +struct v4l2_fmtdesc; +DECLARE_HOOK(android_vh_fill_ext_fmtdesc, + TP_PROTO(struct v4l2_fmtdesc *fmtd, const char **descr), + TP_ARGS(fmtd, descr)); + +DECLARE_HOOK(android_vh_clear_mask_adjust, + TP_PROTO(unsigned int ctrl, int *n), + TP_ARGS(ctrl, n)); + +#endif /* _TRACE_HOOK_V4L2CORE_H */ +/* This part must be outside protection */ +#include + diff --git a/include/trace/hooks/v4l2mc.h b/include/trace/hooks/v4l2mc.h new file mode 100644 index 000000000000..8a4653bd4a4d --- /dev/null +++ b/include/trace/hooks/v4l2mc.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM v4l2mc + +#define TRACE_INCLUDE_PATH trace/hooks + +#if !defined(_TRACE_HOOK_V4L2MC_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_HOOK_V4L2MC_H + +#include +#include + +struct media_link; +struct media_link_desc; +DECLARE_HOOK(android_vh_media_device_setup_link, + TP_PROTO(struct media_link *link, struct media_link_desc *linkd, int *ret), + TP_ARGS(link, linkd, ret)); + +#endif /* _TRACE_HOOK_V4L2MC_H */ +/* This part must be outside protection */ +#include +