From patchwork Thu Sep 12 12:43:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Krzysztof_Ha=C5=82asa?= X-Patchwork-Id: 2878271 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3D467BF43F for ; Thu, 12 Sep 2013 12:43:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F36C8201EA for ; Thu, 12 Sep 2013 12:43:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 56A04201B8 for ; Thu, 12 Sep 2013 12:43:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754181Ab3ILMng (ORCPT ); Thu, 12 Sep 2013 08:43:36 -0400 Received: from ni.piap.pl ([195.187.100.4]:37090 "EHLO ni.piap.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753578Ab3ILMng convert rfc822-to-8bit (ORCPT ); Thu, 12 Sep 2013 08:43:36 -0400 Received: from ni.piap.pl (localhost.localdomain [127.0.0.1]) by ni.piap.pl (Postfix) with ESMTP id 51DCD442124; Thu, 12 Sep 2013 14:43:34 +0200 (CEST) Received: by ni.piap.pl (Postfix, from userid 1015) id 4D2F5442125; Thu, 12 Sep 2013 14:43:34 +0200 (CEST) From: khalasa@piap.pl (Krzysztof =?utf-8?Q?Ha=C5=82asa?=) To: linux-media Cc: Hans Verkuil , ismael.luceno@corp.bluecherry.net Date: Thu, 12 Sep 2013 14:43:34 +0200 MIME-Version: 1.0 Message-ID: Subject: [PATCH] SOLO6x10: Fix video headers on certain hardware. X-Anti-Virus: Kaspersky Anti-Virus for Linux Mail Server 5.6.44/RELEASE, bases: 20130912 #11042881, check: 20130912 clean Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On certain platforms a sequence of dma_map_sg() and dma_unmap_sg() discards data previously stored in the buffers. Build video headers only after the DMA is completed. Signed-off-by: Krzysztof Ha?asa Acked-by: Ismael Luceno --- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c b/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c index e501287..7a2fd98 100644 --- a/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c +++ b/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c @@ -472,14 +472,11 @@ static int solo_fill_jpeg(struct solo_enc_dev *solo_enc, if (vb2_plane_size(vb, 0) < vop_jpeg_size(vh) + solo_enc->jpeg_len) return -EIO; - sg_copy_from_buffer(vbuf->sglist, vbuf->num_pages, - solo_enc->jpeg_header, - solo_enc->jpeg_len); - frame_size = (vop_jpeg_size(vh) + solo_enc->jpeg_len + (DMA_ALIGN - 1)) & ~(DMA_ALIGN - 1); vb2_set_plane_payload(vb, 0, vop_jpeg_size(vh) + solo_enc->jpeg_len); + /* may discard all previous data in vbuf->sglist */ dma_map_sg(&solo_dev->pdev->dev, vbuf->sglist, vbuf->num_pages, DMA_FROM_DEVICE); ret = solo_send_desc(solo_enc, solo_enc->jpeg_len, vbuf, @@ -488,6 +485,11 @@ static int solo_fill_jpeg(struct solo_enc_dev *solo_enc, SOLO_JPEG_EXT_SIZE(solo_dev)); dma_unmap_sg(&solo_dev->pdev->dev, vbuf->sglist, vbuf->num_pages, DMA_FROM_DEVICE); + + /* add the header only after dma_unmap_sg() */ + sg_copy_from_buffer(vbuf->sglist, vbuf->num_pages, + solo_enc->jpeg_header, solo_enc->jpeg_len); + return ret; } @@ -505,12 +507,7 @@ static int solo_fill_mpeg(struct solo_enc_dev *solo_enc, /* If this is a key frame, add extra header */ if (!vop_type(vh)) { - sg_copy_from_buffer(vbuf->sglist, vbuf->num_pages, - solo_enc->vop, - solo_enc->vop_len); - skip = solo_enc->vop_len; - vb->v4l2_buf.flags |= V4L2_BUF_FLAG_KEYFRAME; vb2_set_plane_payload(vb, 0, vop_mpeg_size(vh) + solo_enc->vop_len); } else { @@ -524,6 +521,7 @@ static int solo_fill_mpeg(struct solo_enc_dev *solo_enc, frame_size = (vop_mpeg_size(vh) + skip + (DMA_ALIGN - 1)) & ~(DMA_ALIGN - 1); + /* may discard all previous data in vbuf->sglist */ dma_map_sg(&solo_dev->pdev->dev, vbuf->sglist, vbuf->num_pages, DMA_FROM_DEVICE); ret = solo_send_desc(solo_enc, skip, vbuf, frame_off, frame_size, @@ -531,6 +529,11 @@ static int solo_fill_mpeg(struct solo_enc_dev *solo_enc, SOLO_MP4E_EXT_SIZE(solo_dev)); dma_unmap_sg(&solo_dev->pdev->dev, vbuf->sglist, vbuf->num_pages, DMA_FROM_DEVICE); + + /* add the header only after dma_unmap_sg() */ + if (!vop_type(vh)) + sg_copy_from_buffer(vbuf->sglist, vbuf->num_pages, + solo_enc->vop, solo_enc->vop_len); return ret; }