From patchwork Thu Jul 5 16:03:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 10509727 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B58BE603D7 for ; Thu, 5 Jul 2018 16:04:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A508528F2F for ; Thu, 5 Jul 2018 16:04:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 990F6292FA; Thu, 5 Jul 2018 16:04:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44B0D28F2F for ; Thu, 5 Jul 2018 16:04:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754143AbeGEQES (ORCPT ); Thu, 5 Jul 2018 12:04:18 -0400 Received: from lb1-smtp-cloud9.xs4all.net ([194.109.24.22]:41871 "EHLO lb1-smtp-cloud9.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754035AbeGEQDo (ORCPT ); Thu, 5 Jul 2018 12:03:44 -0400 Received: from marune.fritz.box ([IPv6:2001:983:e9a7:1:de5:ba8:3e5e:1644]) by smtp-cloud9.xs4all.net with ESMTPA id b6jJfjrsbEJtcb6jPfBSyz; Thu, 05 Jul 2018 18:03:43 +0200 From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil Subject: [PATCHv16 20/34] vb2: add init_buffer buffer op Date: Thu, 5 Jul 2018 18:03:23 +0200 Message-Id: <20180705160337.54379-21-hverkuil@xs4all.nl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180705160337.54379-1-hverkuil@xs4all.nl> References: <20180705160337.54379-1-hverkuil@xs4all.nl> X-CMAE-Envelope: MS4wfFAMari5IOyv0uMfKPEt4O7/ELOfHGBDTow6YYLk/I7EFWaRPclyVkLGTNr4/9UzcJDaS1FRpvNVey/UqSSd0q52FaZnr9R0S4H67k3tGomwpKWiqZqC a//JsFW0xgjzrvcGOVE7TXDO4ZswDIhH0alqkqgZdKavsofc3e2AXFHxPyOwV66D4rsXO0KMyRsc5rl26XyxgSIWF0ZtV03KgN87gZN5mfsqfTJcmVnxJGE1 wWMRBjrHwipRuhupJJS5W1YxYIOZKQUR1q9itMA+yOk= Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hans Verkuil We need to initialize the request_fd field in struct vb2_v4l2_buffer to -1 instead of the default of 0. So we need to add a new op that is called when struct vb2_v4l2_buffer is allocated. Signed-off-by: Hans Verkuil --- drivers/media/common/videobuf2/videobuf2-core.c | 2 ++ include/media/videobuf2-core.h | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index 997673b62afc..a9e958df8324 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -356,6 +356,8 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory, vb->planes[plane].length = plane_sizes[plane]; vb->planes[plane].min_length = plane_sizes[plane]; } + call_void_bufop(q, init_buffer, vb); + q->bufs[vb->index] = vb; /* Allocate video buffer memory for the MMAP type */ diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index 5e760d5f280a..cbda3968d018 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -408,6 +408,9 @@ struct vb2_ops { * @verify_planes_array: Verify that a given user space structure contains * enough planes for the buffer. This is called * for each dequeued buffer. + * @init_buffer: given a &vb2_buffer initialize the extra data after + * struct vb2_buffer. + * For V4L2 this is a &struct vb2_v4l2_buffer. * @fill_user_buffer: given a &vb2_buffer fill in the userspace structure. * For V4L2 this is a &struct v4l2_buffer. * @fill_vb2_buffer: given a userspace structure, fill in the &vb2_buffer. @@ -418,6 +421,7 @@ struct vb2_ops { */ struct vb2_buf_ops { int (*verify_planes_array)(struct vb2_buffer *vb, const void *pb); + void (*init_buffer)(struct vb2_buffer *vb); void (*fill_user_buffer)(struct vb2_buffer *vb, void *pb); int (*fill_vb2_buffer)(struct vb2_buffer *vb, struct vb2_plane *planes); void (*copy_timestamp)(struct vb2_buffer *vb, const void *pb);