Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp834975ybi; Fri, 12 Jul 2019 05:26:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqwl1axxYZ0+X5J8cUcCo0SzAEqvDE5MC1L65FyVpT07mhXMt/Cq/3MxfiH/J3Kic6y5HLbT X-Received: by 2002:a63:714a:: with SMTP id b10mr10933979pgn.25.1562934389776; Fri, 12 Jul 2019 05:26:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562934389; cv=none; d=google.com; s=arc-20160816; b=KHVDBm2Ku+0cmdxekBHYzhvmH1x0AbTetykqLLfpN4k9Ba028w4Dvy638qfU2moW+W YbUsdyiqcgPSW3iCtTz62IrCukJyHIkEyNFEpKbm9kGVWJb6fcyB6zcMVNhehZl26/ZI X4+8P5IazipKZUBMyfmXSYeDe009BnRwbjT1cyPN43MpT+uK6p4klp8YmF4iKWa7Y39G iM3SpdI4yeveIZ6BmIZQOlHx1sMcDB+/hUQpUcQFZBD6JQq+uY07oSTRK/TyOd1DUPP7 NGYx5NNo+f/O7POqkXRW5CJSLNOqBL0Wm57vA5b2sgqDbQelDjSKmwDjTMXZvVNsUkju VKGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CWMGYCV83C3eHwL8YfGrvIrB4SN7TF/T7SDKIApbmpI=; b=xzZj6JAW0pR+od38Orz1W4LF4i+O8Ncvoi6gVSGC3beFvtZRXmLpcgsPaPAIc6cDWy 4fDqg59n+/oCUow8+NnwTz3l/LTHBXuqYFyvZzy6CwPLBKOEqsYAEQfcqhp7m/FynGQB b/rgZnuVI9dhdW7kNEapfHtXMx2OBdZbsGiVvZ63g/UsTvPo5ZNFRuYMiqBZzdxdkDbA RmQnTQqmL6v7GzET2Eo1nHKmKJAl2Rw2r5syFCXrL22cLHUmU4UvdVMRmXXHdQHlR8/8 puVNSD9HvpBYiWRcewnVMF1xYHg8EQ4xItDJCH3awg5+WekIE3BBlZFxWnnIl1vNnsZ+ RmDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vBOrYqNO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 78si7863149pga.411.2019.07.12.05.26.14; Fri, 12 Jul 2019 05:26:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vBOrYqNO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728143AbfGLMYe (ORCPT + 99 others); Fri, 12 Jul 2019 08:24:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:33222 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727349AbfGLMYb (ORCPT ); Fri, 12 Jul 2019 08:24:31 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A3CA7208E4; Fri, 12 Jul 2019 12:24:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562934271; bh=spKQvzBkCz2p7uUyWcQ59xxgGjgybE/oLIuwZnEgBBg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vBOrYqNO7r8hqpT1ObMqn54NS7Qx9rVtgdP5lOtkL5toWNIfQavMjRUcY9093Suyj ufM5NoiVclKbCUlQQ+3vw5P8Evo4cK8OT3ZEt2rwRDbWTSVLfP3xkwYfvN1CjBQckL LTjExfmTh8BCdiDF0P8cB3Wocjvukxiq7DX/jKNQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dave Stevenson , Stefan Wahren , Hans Verkuil , Mauro Carvalho Chehab Subject: [PATCH 4.19 90/91] staging: bcm2835-camera: Handle empty EOS buffers whilst streaming Date: Fri, 12 Jul 2019 14:19:33 +0200 Message-Id: <20190712121626.527633294@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190712121621.422224300@linuxfoundation.org> References: <20190712121621.422224300@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dave Stevenson commit a26be06d6d96c10a9ab005e99d93fbb5d3babd98 upstream. The change to mapping V4L2 to MMAL buffers 1:1 didn't handle the condition we get with raw pixel buffers (eg YUV and RGB) direct from the camera's stills port. That sends the pixel buffer and then an empty buffer with the EOS flag set. The EOS buffer wasn't handled and returned an error up the stack. Handle the condition correctly by returning it to the component if streaming, or returning with an error if stopping streaming. Fixes: 938416707071 ("staging: bcm2835-camera: Remove V4L2/MMAL buffer remapping") Signed-off-by: Dave Stevenson Signed-off-by: Stefan Wahren Acked-by: Hans Verkuil Acked-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c | 21 +++++----- drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c | 5 +- 2 files changed, 15 insertions(+), 11 deletions(-) --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -342,16 +342,13 @@ static void buffer_cb(struct vchiq_mmal_ return; } else if (length == 0) { /* stream ended */ - if (buf) { - /* this should only ever happen if the port is - * disabled and there are buffers still queued + if (dev->capture.frame_count) { + /* empty buffer whilst capturing - expected to be an + * EOS, so grab another frame */ - vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); - pr_debug("Empty buffer"); - } else if (dev->capture.frame_count) { - /* grab another frame */ if (is_capturing(dev)) { - pr_debug("Grab another frame"); + v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, + "Grab another frame"); vchiq_mmal_port_parameter_set( instance, dev->capture.camera_port, @@ -359,8 +356,14 @@ static void buffer_cb(struct vchiq_mmal_ &dev->capture.frame_count, sizeof(dev->capture.frame_count)); } + if (vchiq_mmal_submit_buffer(instance, port, buf)) + v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, + "Failed to return EOS buffer"); } else { - /* signal frame completion */ + /* stopping streaming. + * return buffer, and signal frame completion + */ + vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); complete(&dev->capture.frame_cmplt); } } else { --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c @@ -291,8 +291,6 @@ static int bulk_receive(struct vchiq_mma /* store length */ msg_context->u.bulk.buffer_used = rd_len; - msg_context->u.bulk.mmal_flags = - msg->u.buffer_from_host.buffer_header.flags; msg_context->u.bulk.dts = msg->u.buffer_from_host.buffer_header.dts; msg_context->u.bulk.pts = msg->u.buffer_from_host.buffer_header.pts; @@ -453,6 +451,9 @@ static void buffer_to_host_cb(struct vch return; } + msg_context->u.bulk.mmal_flags = + msg->u.buffer_from_host.buffer_header.flags; + if (msg->h.status != MMAL_MSG_STATUS_SUCCESS) { /* message reception had an error */ pr_warn("error %d in reply\n", msg->h.status);