From patchwork Thu Jan 26 12:04:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martin X-Patchwork-Id: 9683 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1RqO4w-0004Vl-IS for patchwork@linuxtv.org; Thu, 26 Jan 2012 13:05:22 +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.75/mailfrontend-3) with esmtp for id 1RqO4w-0001za-D6; Thu, 26 Jan 2012 13:05:22 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752283Ab2AZMFE (ORCPT ); Thu, 26 Jan 2012 07:05:04 -0500 Received: from mail-wi0-f174.google.com ([209.85.212.174]:50057 "EHLO mail-wi0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752322Ab2AZMEw (ORCPT ); Thu, 26 Jan 2012 07:04:52 -0500 Received: by wics10 with SMTP id s10so312494wic.19 for ; Thu, 26 Jan 2012 04:04:51 -0800 (PST) Received: by 10.180.93.193 with SMTP id cw1mr3010228wib.5.1327579491033; Thu, 26 Jan 2012 04:04:51 -0800 (PST) Received: from localhost.localdomain (182.50.18.95.dynamic.jazztel.es. [95.18.50.182]) by mx.google.com with ESMTPS id m8sm11842094wia.11.2012.01.26.04.04.49 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 26 Jan 2012 04:04:50 -0800 (PST) From: Javier Martin To: linux-media@vger.kernel.org Cc: g.liakhovetski@gmx.de, s.hauer@pengutronix.de, baruch@tkos.co.il, Javier Martin Subject: [PATCH v2 4/4] media i.MX27 camera: handle overflows properly. Date: Thu, 26 Jan 2012 13:04:32 +0100 Message-Id: <1327579472-31597-4-git-send-email-javier.martin@vista-silicon.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1327579472-31597-1-git-send-email-javier.martin@vista-silicon.com> References: <1327579472-31597-1-git-send-email-javier.martin@vista-silicon.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.1.26.115714 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, BODY_SIZE_3000_3999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, __ANY_URI 0, __CP_MEDIA_BODY 0, __CP_URI_IN_BODY 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_CC_X2 0, __SANE_MSGID 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS ' Signed-off-by: Javier Martin --- Changes since v1: - Make ifs in irq callback mutually exclusive. - Add new argument to mx27_camera_frame_done_emma() to handle errors. --- drivers/media/video/mx2_camera.c | 38 ++++++++++++++++---------------------- 1 files changed, 16 insertions(+), 22 deletions(-) diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c index 71054ab..1759673 100644 --- a/drivers/media/video/mx2_camera.c +++ b/drivers/media/video/mx2_camera.c @@ -1213,7 +1213,7 @@ static struct soc_camera_host_ops mx2_soc_camera_host_ops = { }; static void mx27_camera_frame_done_emma(struct mx2_camera_dev *pcdev, - int bufnum) + int bufnum, bool err) { struct mx2_buffer *buf; struct vb2_buffer *vb; @@ -1262,7 +1262,10 @@ static void mx27_camera_frame_done_emma(struct mx2_camera_dev *pcdev, list_del_init(&buf->queue); do_gettimeofday(&vb->v4l2_buf.timestamp); vb->v4l2_buf.sequence = pcdev->frame_count; - vb2_buffer_done(vb, VB2_BUF_STATE_DONE); + if (err) + vb2_buffer_done(vb, VB2_BUF_STATE_ERROR); + else + vb2_buffer_done(vb, VB2_BUF_STATE_DONE); } pcdev->frame_count++; @@ -1297,21 +1300,12 @@ static irqreturn_t mx27_camera_emma_irq(int irq_emma, void *data) struct mx2_buffer *buf; if (status & (1 << 7)) { /* overflow */ - u32 cntl; - /* - * We only disable channel 1 here since this is the only - * enabled channel - * - * FIXME: the correct DMA overflow handling should be resetting - * the buffer, returning an error frame, and continuing with - * the next one. - */ - cntl = readl(pcdev->base_emma + PRP_CNTL); - writel(cntl & ~(PRP_CNTL_CH1EN | PRP_CNTL_CH2EN), - pcdev->base_emma + PRP_CNTL); - writel(cntl, pcdev->base_emma + PRP_CNTL); - } - if ((((status & (3 << 5)) == (3 << 5)) || + buf = list_entry(pcdev->active_bufs.next, + struct mx2_buffer, queue); + mx27_camera_frame_done_emma(pcdev, + buf->bufnum, 1); + status &= ~(1 << 7); + } else if ((((status & (3 << 5)) == (3 << 5)) || ((status & (3 << 3)) == (3 << 3))) && !list_empty(&pcdev->active_bufs)) { /* @@ -1320,13 +1314,13 @@ static irqreturn_t mx27_camera_emma_irq(int irq_emma, void *data) */ buf = list_entry(pcdev->active_bufs.next, struct mx2_buffer, queue); - mx27_camera_frame_done_emma(pcdev, buf->bufnum); + mx27_camera_frame_done_emma(pcdev, buf->bufnum, 0); status &= ~(1 << (6 - buf->bufnum)); /* mark processed */ + } else if ((status & (1 << 6)) || (status & (1 << 4))) { + mx27_camera_frame_done_emma(pcdev, 0, 0); + } else if ((status & (1 << 5)) || (status & (1 << 3))) { + mx27_camera_frame_done_emma(pcdev, 1, 0); } - if ((status & (1 << 6)) || (status & (1 << 4))) - mx27_camera_frame_done_emma(pcdev, 0); - if ((status & (1 << 5)) || (status & (1 << 3))) - mx27_camera_frame_done_emma(pcdev, 1); writel(status, pcdev->base_emma + PRP_INTRSTATUS);