From patchwork Sun Feb 3 16:03:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 10794773 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 A997713BF for ; Sun, 3 Feb 2019 16:04:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97AB728C79 for ; Sun, 3 Feb 2019 16:04:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8AAE129010; Sun, 3 Feb 2019 16:04:32 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 307CF28C79 for ; Sun, 3 Feb 2019 16:04:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mGmIecImapKnsQnR984DXpFYSjO+TMck/uzPChED+0o=; b=qxS51UA2fob6fJ 7dgpBXEl/PhKIM7sF7LjB5sd5ulhsvJ6QzFclSdTF+Z4DbBCebGQBynSBIW0yqY5QaauyTV2yaaCm bNDtfyPNXyKCDMRr46LUqvaFqbyVGLkh/fO3tp05gKUqteSDM7RxrV4M48POm00MZfcBIc1eHRC8c romFHisQnG62+7GgJIqESQcFq1bU1Ph5Zd0XiTCprHn7C96Jc9LvEurwA4JJM7JC/enRQWmSwVHmu JalW8fsxxSFaUn6U1ref1TA21lvUq2VBd2PVAMy4KXWlV1CaZgL8iG5yIWr5/J3qY6KL3FJNkbIsV hgBr6IMqZ6CVHk24TySw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gqKFx-0004Nw-69; Sun, 03 Feb 2019 16:04:29 +0000 Received: from mirror2.csie.ntu.edu.tw ([140.112.30.76] helo=wens.csie.org) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gqKFX-0003xR-62 for linux-arm-kernel@lists.infradead.org; Sun, 03 Feb 2019 16:04:05 +0000 Received: by wens.csie.org (Postfix, from userid 1000) id B2ADE5FD5E; Mon, 4 Feb 2019 00:04:01 +0800 (CST) From: Chen-Yu Tsai To: Yong Deng , Maxime Ripard , Mauro Carvalho Chehab , Sakari Ailus Subject: [PATCH 3/3] media: sun6i: Add support for JPEG media bus format Date: Mon, 4 Feb 2019 00:03:58 +0800 Message-Id: <20190203160358.21050-4-wens@csie.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190203160358.21050-1-wens@csie.org> References: <20190203160358.21050-1-wens@csie.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190203_080403_354022_DFBE0EE5 X-CRM114-Status: GOOD ( 11.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chen-Yu Tsai , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The CSI controller can take raw data from the data bus and output it directly to capture buffers. This can be used to support the JPEG media bus format. While the controller can report minimum and maximum bytes per line, it has no way to report how many lines were captured in the last frame. Thus, even when the on-bus data is framed correctly, we have no way to accertain the actual amount of data captured, unless we scan the buffer for JPEG EOI markers, or sequential zeros. For now we leave bytesused alone, and leave it up to userspace applications to parse the data. Signed-off-by: Chen-Yu Tsai --- drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c | 6 ++++++ drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h | 1 + drivers/media/platform/sunxi/sun6i-csi/sun6i_video.c | 1 + 3 files changed, 8 insertions(+) diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c index 969762db30dd..c06776f652c8 100644 --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c @@ -149,6 +149,9 @@ bool sun6i_csi_is_format_supported(struct sun6i_csi *csi, case V4L2_PIX_FMT_RGB565X: return (mbus_code == MEDIA_BUS_FMT_RGB565_2X8_BE); + case V4L2_PIX_FMT_JPEG: + return (mbus_code == MEDIA_BUS_FMT_JPEG_1X8); + default: dev_dbg(sdev->dev, "Unsupported pixformat: 0x%x\n", pixformat); break; @@ -279,6 +282,9 @@ static enum csi_output_fmt get_csi_output_format(struct sun6i_csi_dev *sdev, case V4L2_PIX_FMT_RGB565X: return buf_interlaced ? CSI_FRAME_RGB565 : CSI_FIELD_RGB565; + case V4L2_PIX_FMT_JPEG: + return buf_interlaced ? CSI_FRAME_RAW_8 : CSI_FIELD_RAW_8; + default: dev_warn(sdev->dev, "Unsupported pixformat: 0x%x\n", pixformat); break; diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h index 585cd9669417..f30a210e9caa 100644 --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h @@ -94,6 +94,7 @@ static inline int sun6i_csi_get_bpp(unsigned int pixformat) case V4L2_PIX_FMT_SGBRG8: case V4L2_PIX_FMT_SGRBG8: case V4L2_PIX_FMT_SRGGB8: + case V4L2_PIX_FMT_JPEG: return 8; case V4L2_PIX_FMT_SBGGR10: case V4L2_PIX_FMT_SGBRG10: diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_video.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_video.c index bff6fe832803..1fd16861f111 100644 --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_video.c +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_video.c @@ -58,6 +58,7 @@ static const u32 supported_pixformats[] = { V4L2_PIX_FMT_YUV422P, V4L2_PIX_FMT_RGB565, V4L2_PIX_FMT_RGB565X, + V4L2_PIX_FMT_JPEG, }; static bool is_pixformat_valid(unsigned int pixformat)