From patchwork Sat Aug 4 12:45:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 10555727 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6C70B13AC for ; Sat, 4 Aug 2018 12:45:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E3362A13A for ; Sat, 4 Aug 2018 12:45:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 52CFA2A146; Sat, 4 Aug 2018 12:45:49 +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 01FF32A13A for ; Sat, 4 Aug 2018 12:45:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729686AbeHDOqY (ORCPT ); Sat, 4 Aug 2018 10:46:24 -0400 Received: from lb2-smtp-cloud7.xs4all.net ([194.109.24.28]:47161 "EHLO lb2-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729602AbeHDOqM (ORCPT ); Sat, 4 Aug 2018 10:46:12 -0400 Received: from tschai.fritz.box ([212.251.195.8]) by smtp-cloud7.xs4all.net with ESMTPA id lvvyfCzUl6brUlvw6fFM5l; Sat, 04 Aug 2018 14:45:34 +0200 From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil Subject: [PATCHv17 21/34] vb2: add init_buffer buffer op Date: Sat, 4 Aug 2018 14:45:13 +0200 Message-Id: <20180804124526.46206-22-hverkuil@xs4all.nl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180804124526.46206-1-hverkuil@xs4all.nl> References: <20180804124526.46206-1-hverkuil@xs4all.nl> X-CMAE-Envelope: MS4wfMadgiGnrAFDSnyZd82caPdOOkZv8eRDOpCHxTTqZEKaG10CKCtOghaQBRbJ/CT//ci+XbYtBlEX3IXOZoo4zOc2kiFKgOV8/Wpe1nqGlLSBUkujBhN7 0JRwzQVKeIEubXF20xXiawWpxsRDyp9Z0bcfm8ufL+ms8bg8Ax0qils9WNIkxyxNokcG0G8li1PWsJkNsAZuaOKb15eOyNUrXKU= 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 Reviewed-by: Mauro Carvalho Chehab --- 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 eead693ba619..230f83d6d094 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);