Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp502726pxb; Wed, 3 Nov 2021 07:44:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7uEHx8EqUUDkFm7Pomgt3yrKA2ub6o11BH6HDdDKXCse+kx5PKspDsbBN6xp4os03rAPy X-Received: by 2002:a17:907:1c25:: with SMTP id nc37mr39958975ejc.333.1635950649395; Wed, 03 Nov 2021 07:44:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635950649; cv=none; d=google.com; s=arc-20160816; b=xdSF7fz+c1rTpoXZBJDS5b6L5yKjK3/H5EHobwPVr0qwpe+EYxSf+RzmetBWbPZmhE 5UKY4BzTJPoxGqVcNkYxDZDLtpL/N9TYqmAMfe5Sym5iMxcLt6k7PXLpkjg9gVp/dBAs 81HqZhb5RX0EpdjqbeIZiljOTlA7ZolAFMEsKlPMr0X2NBQX3F+QfD6VPElcgleMgEKz DchGN3iJOGYekrrWX4LCwpjtoqxT0z1uTqjYfPEo1kZKhnrRZHTRI6eQJZ01sAv/uFXk TIMsCZAD4AW+c4kGCKqZgsHGenzSycwf8RjyVemdWcsqv2C0C7aqFYUHsYZYGL2/st+1 1chg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=mTi5xjveIrNzJpzGo7W+EniN/yKcDn5XZYVjrsVnD5Y=; b=rnPox0sV3nI1daLBpQZpYWgdlajcVt0Aq0KYBQmZlHpmMFLnSMm9+E7Eo0kezlcgYf E69tG440dmWRKaPpGkMhRcgdsDCEPBj3bc51vppYffl8gevBWLBXFBFgK/5UjdOR8G8P +lioPikl39KO/XFYElLn1BhNwtdx4fEjKrYtBaf2WpCSsoH3UjLbLNQ/FXoKDA4XaMrN bP4y59nMyLHepP8bI4kI6cD0ByhZnkwPkxNZWdu7jzanlCY0QjCi23l7JN/DcQoEawdA 7jdRaCVtv7PYMZpWNW+YVnisuNQDlDVFbaIyKsSklHqAFRmBNplBCvY5DTLaos1cqLSS 1SyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xs4all.nl header.s=s2 header.b=W9pKuFCF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qk18si4424167ejc.684.2021.11.03.07.43.44; Wed, 03 Nov 2021 07:44:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@xs4all.nl header.s=s2 header.b=W9pKuFCF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231925AbhKCOny (ORCPT + 99 others); Wed, 3 Nov 2021 10:43:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231510AbhKCOny (ORCPT ); Wed, 3 Nov 2021 10:43:54 -0400 Received: from lb1-smtp-cloud9.xs4all.net (lb1-smtp-cloud9.xs4all.net [IPv6:2001:888:0:108::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D021C061714; Wed, 3 Nov 2021 07:41:17 -0700 (PDT) Received: from cust-b5b5937f ([IPv6:fc0c:c16d:66b8:757f:c639:739b:9d66:799d]) by smtp-cloud9.xs4all.net with ESMTPA id iHRpmXJkf030KiHRqmUq6J; Wed, 03 Nov 2021 15:41:14 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xs4all.nl; s=s2; t=1635950474; bh=mTi5xjveIrNzJpzGo7W+EniN/yKcDn5XZYVjrsVnD5Y=; h=Subject:To:From:Message-ID:Date:MIME-Version:Content-Type:From: Subject; b=W9pKuFCFrRGoY2QghPvwQ9w8qV4xsc0ZQ0splH1OsjWc6tBqi3ZSQWfAKARQeZx0f ZyoyXehjJHhp2gVhxa0PiSwX+EcG0GXBeABivSb+ZdFfULgW/3A1BrBEF6mxfv7D8Z eLa6A7Yc1MfY+R+2a3J6E3ByY3bpZRBld7RwMeEbT9AkTKUnlv23RqmG8EPX6SQ5h3 yOAxSJO/NUaj9ffdP+8hcfUTw012gxgZK8aN+Jwx3mzNf3C6qGArxEHD2UuRtuNMar wbwZjBxkqhx4k4K3tVCdfoLULIw4kguzSpZgY5JiM11eJbCS9XtldjNd9lVTwBjJKG jSpiToV9tBO7w== Subject: Re: atomisp current issues To: Mauro Carvalho Chehab , Linux Media Mailing List Cc: Tsuchiya Yuto , Hans de Goede , Patrik Gfeller , Mauro Carvalho Chehab , Sakari Ailus , Greg Kroah-Hartman , Kaixu Xia , Laurent Pinchart , Yang Li , Tomi Valkeinen , Alex Dewar , Aline Santana Cordeiro , Arnd Bergmann , Alan , Peter Zijlstra , Ingo Molnar , linux-staging@lists.linux.dev, Linux Kernel Mailing List , Andy Shevchenko References: <20211103135418.496f75d5@sal.lan> From: Hans Verkuil Message-ID: Date: Wed, 3 Nov 2021 15:41:05 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <20211103135418.496f75d5@sal.lan> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4xfFNhMDZeI7N4foSXsMu9uUUt//3oWRGwV84zMApTzO8seWl0tZMnhG4Srvk/1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hi, > > From what I've seen so far, those are the main issues with regards to V4L2 API, > in order to allow a generic V4L2 application to work with it. > > MMAP support > ============ > > Despite having some MMAP code on it, the current implementation is broken. > Fixing it is not trivial, as it would require fixing the HMM support on it, > which does several tricks. > > The best would be to replace it by something simpler. If this is similar > enough to IPU3, perhaps one idea would be to replace the HMM code on it by > videodev2 + IPU3 HMM code. > > As this is not trivial, I'm postponing such task. If someone has enough > time, it would be great to have this fixed. > > From my side, I opted to add support for USERPTR on camorama: > > https://github.com/alessio/camorama > > As this is something I wanted to do anyway, and it allowed me to cleanup > several things in camorama's code. > > Support for USERPTR is not autodetected. So, this should be selected You can autodetect this: the capabilities field returned by VIDIOC_REQBUFS or VIDIOC_CREATE_BUFS will indicate support for this. This works with any vb2-based driver. Just thought I should mention this... Regards, Hans > via a command line parameter. Here (Fedora), I installed the build > dependencies on my test device with: > > $ sudo dnf builddep camorama > $ sudo dnf install gnome-common # for gnome-autogen.sh > > Testing it with atomisp would be: > > $ git clone https://github.com/alessio/camorama > $ cd camorama && ./autogen.sh > $ make && ./src/camorama -d /dev/video2 --debug -U -D > > In time: > -------- > > Camorama currently doesn't work due to some other API bugs. See below. > > > VIDIOC_G_FMT/VIDIOC_S_FMT/VIDIOC_TRY_FMT issues > =============================================== > > The implementation for VIDIOC_G_FMT/VIDIOC_S_FMT/VIDIOC_TRY_FMT are not > properly implemented. It has several issues. > > The main one is related to padding. Based on the comments inside the code, > the ISP 2 seems to require padding to work, both vertically an horizontally. > > Those are controlled by two modprobe parameters: pad_h and pad_w. > The default for both is 16. > > There are some other padding logic inside the function which sets the > video formats at atomisp_cmd: atomisp_set_fmt(). This function is quite > complex, being big and it calls several other atomisp kAPIs. > > It basically queries the sensor, and then it mounts a pipeline that > will have the sensor + ISP blocks. Those ISP blocks convert the format > from Bayer into YUYV or RGB and scale down the resolution in order to > match the request. > > It also adjusts the padding. The padding code there is very complex, > as it not only uses pad_h/pad_w, having things like: > > if (!atomisp_subdev_format_conversion(asd, source_pad)) { > padding_w = 0; > padding_h = 0; > } else if (IS_BYT) { > padding_w = 12; > padding_h = 12; > } > ... > atomisp_get_dis_envelop(asd, f->fmt.pix.width, f->fmt.pix.height, > &dvs_env_w, &dvs_env_h); > ... > /* > * set format info to sensor > * In continuous mode, resolution is set only if it is higher than > * existing value. This because preview pipe will be configured after > * capture pipe and usually has lower resolution than capture pipe. > */ > if (!asd->continuous_mode->val || > isp_sink_fmt->width < (f->fmt.pix.width + padding_w + dvs_env_w) || > isp_sink_fmt->height < (f->fmt.pix.height + padding_h + > dvs_env_h)) { > > Due to that, the sensors are set to have those extra 16 columns/lines. > Those extra data are consumed internally at the driver, so the output > buffer won't contain those. > > Yet, the buffer size to be allocated by userspace on USERPTR mode is not just > width x height x bpp, but it may need extra space for such pads and/or other > things. > > In practice, when VIDIOC_S_FMT asks for a 1600x1200 resolution, it > actually sets 1616x1216 at the sensor (at the pad source), but the > pad sink provides the requested resolution: 1600x1200. > > However, the resolution returned by VIDIOC_G_FMT/VIDIOC_S_FMT/VIDIOC_TRY_FMT > is not always the sink resolution. Sometimes, it returns the sensor format. > > Fixing it has been challenging. > > - > > Another related issue is that, when a resolution bigger than the maximum > resolution is requested, the driver doesn't return 1600x1200, but, instead, > a smaller one. > > On other words, setting to YUYV 1600x1200 gives: > > $ v4l2-ctl --set-fmt-video pixelformat=YUYV,width=1600,height=1200 -d /dev/video2 --verbose > VIDIOC_QUERYCAP: ok > VIDIOC_G_FMT: ok > VIDIOC_S_FMT: ok > Format Video Capture: > Width/Height : 1600/1200 > Pixel Format : 'YUYV' (YUYV 4:2:2) > Field : None > Bytes per Line : 3200 > Size Image : 3842048 > Colorspace : Rec. 709 > Transfer Function : Rec. 709 > YCbCr/HSV Encoding: Rec. 709 > Quantization : Default (maps to Limited Range) > Flags : > > Setting to a higher resolution (which is a method that some apps use to test > for the max resolution, when VIDIOC_ENUM_FRAMESIZES is not available or > broken) produces: > > $ v4l2-ctl --set-fmt-video pixelformat=YUYV,width=10000,height=10000 -d /dev/video2 --verbose > VIDIOC_QUERYCAP: ok > VIDIOC_G_FMT: ok > VIDIOC_S_FMT: ok > Format Video Capture: > Width/Height : 1600/900 > Pixel Format : 'YUYV' (YUYV 4:2:2) > Field : None > Bytes per Line : 3200 > Size Image : 2883584 > Colorspace : Rec. 709 > Transfer Function : Rec. 709 > YCbCr/HSV Encoding: Rec. 709 > Quantization : Default (maps to Limited Range) > Flags : > > Trying to set to the sensor resolution is even worse, as it returns EINVAL: > > $ v4l2-ctl --set-fmt-video pixelformat=YUYV,width=1616,height=1216 -d /dev/video2 --verbose > VIDIOC_QUERYCAP: ok > VIDIOC_G_FMT: ok > VIDIOC_S_FMT: failed: Invalid argument > > The logs for such case are: > > [ 4799.594724] atomisp-isp2 0000:00:03.0: can't create streams > [ 4799.594757] atomisp-isp2 0000:00:03.0: __get_frame_info 1616x1216 (padded to 0) returned -22 > [ 4799.594781] atomisp-isp2 0000:00:03.0: Can't set format on ISP. Error -22 > > Video devices > ============= > > Currently, 10 video? devices are created: > > $ for i in $(ls /dev/video*|sort -k2 -to -n); do echo -n $i:; v4l2-ctl -D -d $i|grep Name; done > /dev/video0: Name : ATOMISP ISP CAPTURE output > /dev/video1: Name : ATOMISP ISP VIEWFINDER output > /dev/video2: Name : ATOMISP ISP PREVIEW output > /dev/video3: Name : ATOMISP ISP VIDEO output > /dev/video4: Name : ATOMISP ISP ACC > /dev/video5: Name : ATOMISP ISP MEMORY input > /dev/video6: Name : ATOMISP ISP CAPTURE output > /dev/video7: Name : ATOMISP ISP VIEWFINDER output > /dev/video8: Name : ATOMISP ISP PREVIEW output > /dev/video9: Name : ATOMISP ISP VIDEO output > /dev/video10: Name : ATOMISP ISP ACC > > That seems to be written to satisfy some Android-based app, but we don't > really need all of those. > > I'm thinking to comment out the part of the code which creates all of those, > keeping just "ATOMISP ISP PREVIEW output", as I don't think we need all > of those. > > Comments? > > Regards, > Mauro >