From patchwork Wed Apr 24 13:56:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Almeida?= X-Patchwork-Id: 10914877 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 A39C813B5 for ; Wed, 24 Apr 2019 13:59:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 937C82892E for ; Wed, 24 Apr 2019 13:59:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8766C28A15; Wed, 24 Apr 2019 13:59:11 +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,UNPARSEABLE_RELAY 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 2A0E82892E for ; Wed, 24 Apr 2019 13:59:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730476AbfDXN7K (ORCPT ); Wed, 24 Apr 2019 09:59:10 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:57102 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727435AbfDXN7K (ORCPT ); Wed, 24 Apr 2019 09:59:10 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: tonyk) with ESMTPSA id D0283282C19 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: linux-media@vger.kernel.org Cc: mchehab@kernel.org, hverkuil@xs4all.nl, helen.koike@collabora.com, kernel@collabora.com, lucmaga@gmail.com, lkcamp@lists.libreplanetbr.org, =?utf-8?q?Andr=C3=A9_Almeida?= Subject: [PATCH v3 13/14] media: vimc: cap: Add support for multiplanar formats Date: Wed, 24 Apr 2019 10:56:41 -0300 Message-Id: <20190424135642.31973-14-andrealmeid@collabora.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190424135642.31973-1-andrealmeid@collabora.com> References: <20190424135642.31973-1-andrealmeid@collabora.com> MIME-Version: 1.0 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 Adapt vimc-capture to support multiplanar formats, copying each plane to the correct buffer. Signed-off-by: André Almeida --- Change in v3: - Adapt to new vimc_frame Change in v2: none drivers/media/platform/vimc/vimc-capture.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/vimc/vimc-capture.c b/drivers/media/platform/vimc/vimc-capture.c index d5b72c858af7..2592ea982ff8 100644 --- a/drivers/media/platform/vimc/vimc-capture.c +++ b/drivers/media/platform/vimc/vimc-capture.c @@ -485,6 +485,8 @@ static struct vimc_frame *vimc_cap_process_frame(struct vimc_ent_device *ved, struct vimc_cap_device *vcap = container_of(ved, struct vimc_cap_device, ved); struct vimc_cap_buffer *vimc_buf; + unsigned long plane_size; + unsigned int i; void *vbuf; spin_lock(&vcap->qlock); @@ -507,13 +509,17 @@ static struct vimc_frame *vimc_cap_process_frame(struct vimc_ent_device *ved, vimc_buf->vb2.sequence = vcap->sequence++; vimc_buf->vb2.field = vcap->format.fmt.pix.field; - vbuf = vb2_plane_vaddr(&vimc_buf->vb2.vb2_buf, 0); + /* For each plane, copy the pixels */ + for (i = 0; i < vimc_buf->vb2.vb2_buf.num_planes; i++) { + vbuf = vb2_plane_vaddr(&vimc_buf->vb2.vb2_buf, i); + plane_size = frame->fmt.plane_fmt[i].sizeimage; + + memcpy(vbuf, frame->plane_addr[i], plane_size); - memcpy(vbuf, frame->plane_addr[0], vcap->format.fmt.pix.sizeimage); + /* Set it as ready */ + vb2_set_plane_payload(&vimc_buf->vb2.vb2_buf, i, plane_size); + } - /* Set it as ready */ - vb2_set_plane_payload(&vimc_buf->vb2.vb2_buf, 0, - vcap->format.fmt.pix.sizeimage); vb2_buffer_done(&vimc_buf->vb2.vb2_buf, VB2_BUF_STATE_DONE); return NULL; }