From patchwork Thu Dec 6 19:46:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 53353 X-Patchwork-Delegate: hverkuil@xs4all.nl Received: from vger.kernel.org ([209.132.180.67]) by www.linuxtv.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gUzbo-0007bU-82; Thu, 06 Dec 2018 19:46:52 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725927AbeLFTqu (ORCPT + 1 other); Thu, 6 Dec 2018 14:46:50 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:54918 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725908AbeLFTqu (ORCPT ); Thu, 6 Dec 2018 14:46:50 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id 8348A270D92 From: Ezequiel Garcia To: linux-media@vger.kernel.org Cc: Hans Verkuil , Tomasz Figa , kernel@collabora.com, Ezequiel Garcia , Sakari Ailus Subject: [PATCH v3] v4l2-ioctl: Zero v4l2_plane_pix_format reserved fields Date: Thu, 6 Dec 2018 16:46:39 -0300 Message-Id: <20181206194639.13472-1-ezequiel@collabora.com> X-Mailer: git-send-email 2.20.0.rc1 MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Make the core set the reserved fields to zero in vv4l2_pix_format_mplane.4l2_plane_pix_format, for _MPLANE queue types. Moving this to the core avoids having to do so in each and every driver. Suggested-by: Tomasz Figa Signed-off-by: Ezequiel Garcia Acked-by: Sakari Ailus Reviewed-by: Tomasz Figa --- v3: * s/int/unsigned int, suggested by Sakari v2: * Drop unneeded clear in g_fmt. The sturct was already being cleared here. * Only zero plane_fmt reserved fields. * Use CLEAR_FIELD_MACRO. drivers/media/v4l2-core/v4l2-ioctl.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index e384142d2826..7e8e7915c041 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -1512,6 +1512,7 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, struct v4l2_format *p = arg; struct video_device *vfd = video_devdata(file); int ret = check_fmt(file, p->type); + unsigned int i; if (ret) return ret; @@ -1536,6 +1537,8 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, if (unlikely(!ops->vidioc_s_fmt_vid_cap_mplane)) break; CLEAR_AFTER_FIELD(p, fmt.pix_mp.xfer_func); + for (i = 0; i < p->fmt.pix_mp.num_planes; i++) + CLEAR_AFTER_FIELD(p, fmt.pix_mp.plane_fmt[i].bytesperline); return ops->vidioc_s_fmt_vid_cap_mplane(file, fh, arg); case V4L2_BUF_TYPE_VIDEO_OVERLAY: if (unlikely(!ops->vidioc_s_fmt_vid_overlay)) @@ -1564,6 +1567,8 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, if (unlikely(!ops->vidioc_s_fmt_vid_out_mplane)) break; CLEAR_AFTER_FIELD(p, fmt.pix_mp.xfer_func); + for (i = 0; i < p->fmt.pix_mp.num_planes; i++) + CLEAR_AFTER_FIELD(p, fmt.pix_mp.plane_fmt[i].bytesperline); return ops->vidioc_s_fmt_vid_out_mplane(file, fh, arg); case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: if (unlikely(!ops->vidioc_s_fmt_vid_out_overlay)) @@ -1604,6 +1609,7 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops, { struct v4l2_format *p = arg; int ret = check_fmt(file, p->type); + unsigned int i; if (ret) return ret; @@ -1623,6 +1629,8 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops, if (unlikely(!ops->vidioc_try_fmt_vid_cap_mplane)) break; CLEAR_AFTER_FIELD(p, fmt.pix_mp.xfer_func); + for (i = 0; i < p->fmt.pix_mp.num_planes; i++) + CLEAR_AFTER_FIELD(p, fmt.pix_mp.plane_fmt[i].bytesperline); return ops->vidioc_try_fmt_vid_cap_mplane(file, fh, arg); case V4L2_BUF_TYPE_VIDEO_OVERLAY: if (unlikely(!ops->vidioc_try_fmt_vid_overlay)) @@ -1651,6 +1659,8 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops, if (unlikely(!ops->vidioc_try_fmt_vid_out_mplane)) break; CLEAR_AFTER_FIELD(p, fmt.pix_mp.xfer_func); + for (i = 0; i < p->fmt.pix_mp.num_planes; i++) + CLEAR_AFTER_FIELD(p, fmt.pix_mp.plane_fmt[i].bytesperline); return ops->vidioc_try_fmt_vid_out_mplane(file, fh, arg); case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: if (unlikely(!ops->vidioc_try_fmt_vid_out_overlay))