From patchwork Wed Dec 4 14:14:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hans Verkuil (hansverk)" X-Patchwork-Id: 20908 X-Patchwork-Delegate: hverkuil@xs4all.nl Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1VoDF5-000138-Ro; Wed, 04 Dec 2013 15:15:55 +0100 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.72/mailfrontend-5) with esmtp id 1VoDF3-00024C-8q; Wed, 04 Dec 2013 15:15:55 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932605Ab3LDOPv (ORCPT + 1 other); Wed, 4 Dec 2013 09:15:51 -0500 Received: from aer-iport-1.cisco.com ([173.38.203.51]:49297 "EHLO aer-iport-1.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932452Ab3LDOPr (ORCPT ); Wed, 4 Dec 2013 09:15:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=2203; q=dns/txt; s=iport; t=1386166547; x=1387376147; h=message-id:date:from:mime-version:to:cc:subject: content-transfer-encoding; bh=8Asg+cx42AkGlvcd8WcY1y03PlrINhtLMNLLx+Lbvvg=; b=FgY2tnO9dAg/8wlZF6y/dKmq1iX0oGouJ6WB5Fo86y4KYisEMXukGQaj R+T2GuDM9fz4VJvCwdttHmxFwdi1hwy27UvOLUnNM6f6pGdqxXMQ3Kbrl 9qHv9d5G43JlsHCBcdLGxjrTB0unKyNWPRD5egyqXxZSM4fqhMO6mAQOi 8=; X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjoFAMQ3n1KQ/khR/2dsb2JhbABagwe5cYEiFnSCU1EBPBYYAwIBAgFLDQEFAgKHfsIEjhpkhDoDmBSGRYtOgyo7gSw X-IronPort-AV: E=Sophos;i="4.93,824,1378857600"; d="scan'208";a="1672658" Received: from ams-core-1.cisco.com ([144.254.72.81]) by aer-iport-1.cisco.com with ESMTP; 04 Dec 2013 14:15:45 +0000 Received: from [10.54.92.107] (dhcp-10-54-92-107.cisco.com [10.54.92.107]) (authenticated bits=0) by ams-core-1.cisco.com (8.14.5/8.14.5) with ESMTP id rB4EFcuW008850 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 4 Dec 2013 14:15:40 GMT Message-ID: <529F38AD.7030703@cisco.com> Date: Wed, 04 Dec 2013 15:14:05 +0100 From: Hans Verkuil User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131103 Icedove/17.0.10 MIME-Version: 1.0 To: linux-media CC: Philipp Zabel , Marek Szyprowski , Pawel Osciak Subject: [PATCH for 3.13] vb2: regression fix: always set length field. X-Authenticated-User: hansverk Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2013.12.4.140615 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_2000_2999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, DKIM_SIGNATURE 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_URI_IN_BODY 0, __CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILING_LIST 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __MOZILLA_MSGID 0, __MOZILLA_USER_AGENT 0, __MULTIPLE_RCPTS_CC_X2 0, __SANE_MSGID 0, __STOCK_PHRASE_7 0, __TO_MALFORMED_2 0, __URI_NO_WWW 0, __URI_NS , __USER_AGENT 0' Commit dc77523c5da5513df1bbc74db2a522a94f4cec0e ensured that m.offset is only set for the MMAP memory mode by calling __setup_offsets only for that mode. However, __setup_offsets also initializes the length fields, and that should be done regardless of the memory mode. Because of that change the v4l2-ctl test application fails for the USERPTR mode. This fix creates a __setup_lengths function that sets the length, and __setup_offsets just sets the offset and no longer touches the length. Signed-off-by: Hans Verkuil Acked-by: Marek Szyprowski --- drivers/media/v4l2-core/videobuf2-core.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index 57ba131..0edc165 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -145,6 +145,25 @@ static void __vb2_buf_dmabuf_put(struct vb2_buffer *vb) } /** + * __setup_lengths() - setup initial lengths for every plane in + * every buffer on the queue + */ +static void __setup_lengths(struct vb2_queue *q, unsigned int n) +{ + unsigned int buffer, plane; + struct vb2_buffer *vb; + + for (buffer = q->num_buffers; buffer < q->num_buffers + n; ++buffer) { + vb = q->bufs[buffer]; + if (!vb) + continue; + + for (plane = 0; plane < vb->num_planes; ++plane) + vb->v4l2_planes[plane].length = q->plane_sizes[plane]; + } +} + +/** * __setup_offsets() - setup unique offsets ("cookies") for every plane in * every buffer on the queue */ @@ -169,7 +188,6 @@ static void __setup_offsets(struct vb2_queue *q, unsigned int n) continue; for (plane = 0; plane < vb->num_planes; ++plane) { - vb->v4l2_planes[plane].length = q->plane_sizes[plane]; vb->v4l2_planes[plane].m.mem_offset = off; dprintk(3, "Buffer %d, plane %d offset 0x%08lx\n", @@ -241,6 +259,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum v4l2_memory memory, q->bufs[q->num_buffers + buffer] = vb; } + __setup_lengths(q, buffer); if (memory == V4L2_MEMORY_MMAP) __setup_offsets(q, buffer);