From patchwork Tue Apr 25 11:23:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Machek X-Patchwork-Id: 9697967 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A574560224 for ; Tue, 25 Apr 2017 11:23:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 948052845C for ; Tue, 25 Apr 2017 11:23:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 88CF92857D; Tue, 25 Apr 2017 11:23:46 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 032A22845C for ; Tue, 25 Apr 2017 11:23:45 +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-Type:Cc: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: In-Reply-To:MIME-Version:References:Message-ID:Subject:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=6sNmzy3fqVlbNDLKO8uLH5Y5X6gWm2OD74Q+ld9bHmE=; b=j4MWSFvorQlUB0QwGGZeQwGO5 4QQDfqATn7+r7YIQCMzE9vXJOSotnZKE6vLibyqh4uuKEaVPWvFAsQNSX+mnPN5oi1EjF5MCyIW5K hNzMh85ynnhZhIJBFSjbeQJog8m4qMPevkH5090jeuvV+1dAs0C9GXinnvzg16OoQigUTHc7RBU3+ auOS5k/QJlB3rXlk5qN0nogb7J8b0HL51TqsyII4oge/tzh5pnMARXKUcP/jwOT503RiAkD23ISN+ XxEUAezcQhes+taYC+zLJlLNGa9o5/0dx2PcQgVLEqk/173Imvb8Sn2KJTQQXuyHw0w32qcRVJqAd Bmy+SbuBQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1d2yZL-0002xr-Jt; Tue, 25 Apr 2017 11:23:43 +0000 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d2yZG-0002if-8k for linux-arm-kernel@lists.infradead.org; Tue, 25 Apr 2017 11:23:41 +0000 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id DF022823AC; Tue, 25 Apr 2017 13:23:10 +0200 (CEST) Date: Tue, 25 Apr 2017 13:23:10 +0200 From: Pavel Machek To: Mauro Carvalho Chehab Subject: Re: support autofocus / autogain in libv4l2 Message-ID: <20170425112310.GA7926@amd> References: <1487074823-28274-1-git-send-email-sakari.ailus@linux.intel.com> <1487074823-28274-2-git-send-email-sakari.ailus@linux.intel.com> <20170414232332.63850d7b@vento.lan> <20170416091209.GB7456@valkosipuli.retiisi.org.uk> <20170419105118.72b8e284@vento.lan> <20170424093059.GA20427@amd> <20170424103802.00d3b554@vento.lan> <20170424220701.GA27846@amd> <20170424225731.7532e368@vento.lan> MIME-Version: 1.0 In-Reply-To: <20170424225731.7532e368@vento.lan> User-Agent: Mutt/1.5.23 (2014-03-12) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170425_042338_657813_8E573FF0 X-CRM114-Status: GOOD ( 20.24 ) 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: ivo.g.dimitrov.75@gmail.com, linux-media@vger.kernel.org, khilman@kernel.org, tony@atomide.com, aaro.koskinen@iki.fi, kernel list , sre@kernel.org, hdegoede@redhat.com, abcloriens@gmail.com, Sakari Ailus , pali.rohar@gmail.com, Sakari Ailus , linux-omap@vger.kernel.org, patrikbachan@gmail.com, linux-arm-kernel , serge@hallyn.com 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 Hi! > > Umm, and it looks like libv4l can not automatically convert from > > GRBG10.. and if it could, going through RGB24 would probably be too > > slow on this device :-(. > > I suspect it shouldn't be hard to add support for GRBG10. It already > supports 8 and 16 bits Bayer formats, at lib/libv4lconvert/bayer.c > (to both RGB and YUV formats). Proper format for 16 bit bayer would be tricky, AFAICT. Anyway, does this look reasonable? It does not work too well here, since omap3isp driver does not seem to support ENUM_FMT. (And I get just half of the vertical image, strange. Interlacing?) Best regards, Pavel diff --git a/lib/libv4lconvert/libv4lconvert.c b/lib/libv4lconvert/libv4lconvert.c index d3d8936..2a469b2 100644 --- a/lib/libv4lconvert/libv4lconvert.c +++ b/lib/libv4lconvert/libv4lconvert.c @@ -123,6 +126,8 @@ static const struct v4lconvert_pixfmt supported_src_pixfmts[] = { { V4L2_PIX_FMT_SGRBG8, 8, 8, 8, 1 }, { V4L2_PIX_FMT_SRGGB8, 8, 8, 8, 1 }, { V4L2_PIX_FMT_STV0680, 8, 8, 8, 1 }, + + { V4L2_PIX_FMT_SGRBG10, 16, 8, 8, 1 }, /* compressed bayer */ { V4L2_PIX_FMT_SPCA561, 0, 9, 9, 1 }, { V4L2_PIX_FMT_SN9C10X, 0, 9, 9, 1 }, @@ -668,6 +680,7 @@ static int v4lconvert_processing_needs_double_conversion( case V4L2_PIX_FMT_SGRBG8: case V4L2_PIX_FMT_SRGGB8: case V4L2_PIX_FMT_STV0680: + case V4L2_PIX_FMT_SGRBG10: return 0; } switch (dest_pix_fmt) { @@ -694,6 +707,17 @@ unsigned char *v4lconvert_alloc_buffer(int needed, return *buf; } +static void v4lconvert_10to8(void *_src, unsigned char *dst, int width, int height) +{ + int i; + uint16_t *src = _src; + + printf("sizes %d x %d\n", width, height); + for (i=0; i> 2; + } +} + int v4lconvert_oom_error(struct v4lconvert_data *data) { V4LCONVERT_ERR("could not allocate memory\n"); @@ -867,7 +893,8 @@ static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data, #endif case V4L2_PIX_FMT_SN9C2028: case V4L2_PIX_FMT_SQ905C: - case V4L2_PIX_FMT_STV0680: { /* Not compressed but needs some shuffling */ + case V4L2_PIX_FMT_STV0680: + case V4L2_PIX_FMT_SGRBG10: { /* Not compressed but needs some shuffling */ unsigned char *tmpbuf; struct v4l2_format tmpfmt = *fmt; @@ -877,6 +904,11 @@ static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data, return v4lconvert_oom_error(data); switch (src_pix_fmt) { + case V4L2_PIX_FMT_SGRBG10: + v4lconvert_10to8(src, tmpbuf, width, height); + + tmpfmt.fmt.pix.pixelformat = V4L2_PIX_FMT_SGRBG8; + break; case V4L2_PIX_FMT_SPCA561: v4lconvert_decode_spca561(src, tmpbuf, width, height); tmpfmt.fmt.pix.pixelformat = V4L2_PIX_FMT_SGBRG8; @@ -949,6 +981,7 @@ static int v4lconvert_convert_pixfmt(struct v4lconvert_data *data, V4LCONVERT_ERR("short raw bayer data frame\n"); errno = EPIPE; result = -1; + /* FIXME: but then we proceed anyway?! */ } switch (dest_pix_fmt) { case V4L2_PIX_FMT_RGB24: