From patchwork Fri Oct 25 13:32:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 2220 Return-Path: Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 918F461375 for ; Fri, 25 Oct 2019 15:32:28 +0200 (CEST) Received: by mail-lf1-x142.google.com with SMTP id f5so1794073lfp.1 for ; Fri, 25 Oct 2019 06:32:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=kSSd3q8kcXla/aTMCijrzaYKxW56S3yJu/GkNoRa3wA=; b=U0SVYjzXi9rROaWbwoqeS4bYzBJKjN1J1zYrZS1mlGya8P1EZ+u1v9GE+okRKvN0iQ Elg7Px+lZmD1tCT2ahhRgiaNOSzKpOk4UeUq2D5jrlrWuGDTe3rH6vqx9RoEK+x+h0cg QefR3Wbrpiy+Hj/l1MBGYY8lGDHODTSeAajmRduEkjCsIxsyMS1ARdTt5nXW4WGsMGla b49iW8ojvBc4QfFv3fdi+/xuYIAC+gUVVGx7A9AZgdVmsgjSX3/lAdHiWR0ThKHEozVj ijcCyl2qYhA8lji0RsLRcWpGv04YK8lX2qk5gjxcGM3uGMPd54s48dTQ/+8me+YTsRGj qObQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=kSSd3q8kcXla/aTMCijrzaYKxW56S3yJu/GkNoRa3wA=; b=Xmf5uuOEzmpWVyVxaIUDkcKvkGWNpc4PpJybku3R32/4boPz7WMNDLz1VMQtvAOHMa vP/A5XYKhRuts53zcfiXXq/k6D2fSbGxiiGisbaoYdbbX/37Ty359vphZAL3Til3P0hF 9PH9enRI0KZ8GfcXENp9oZkuTCKg5GsVaZNGi3eXh+8YsCO75vByDbbDhYY6SWdJ+gii k5qZekZiq/C93jk3Iy1yptcG2vSZBMmYvdGPKzT3Zl7grl86lwCIZIlKIdHakCMsNqtP Pm+sd9GtIzTN83ibRv+4Lkc9kRczESl5p7g3S1uw0DOIm6KFVzeEz32T3bt0cjQLBr+M O3+Q== X-Gm-Message-State: APjAAAVV7bFAfF0Nd/RgwxPw2KkgCZG+XemAmQsg9FQlCMoLdm9aUptq XvjK2MsAER4dvcydfEItEIuDu+TcoVY= X-Google-Smtp-Source: APXvYqxytrmVpc7mTOY9i+cV+wuSS26f7DdOXfAvE4Keu3fAldVEHc2rfK9m6AhLdqzeh1JewlnA6w== X-Received: by 2002:a19:41d7:: with SMTP id o206mr2782316lfa.188.1572010347391; Fri, 25 Oct 2019 06:32:27 -0700 (PDT) Received: from TM-8481.Dlink (office.dev.rtsoft.ru. [62.117.114.130]) by smtp.googlemail.com with ESMTPSA id c76sm900098lfg.11.2019.10.25.06.32.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2019 06:32:26 -0700 (PDT) From: Andrey Konovalov To: libcamera-devel@lists.libcamera.org Date: Fri, 25 Oct 2019 16:32:08 +0300 Message-Id: <20191025133208.22637-1-andrey.konovalov@linaro.org> X-Mailer: git-send-email 2.17.1 Subject: [libcamera-devel] [PATCH] libcamera: v4l2_subdevice: use G_FORMAT if ENUM_FRAME_SIZE isn't implemented X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Oct 2019 13:32:28 -0000 Many camera sensor drivers support only one frame size, and don't implement VIDIOC_SUBDEV_ENUM_FRAME_SIZE ioctl. And libcamera fails to enumerate such cameras as it doesn't get the list of resolutions the sensor driver supports. Fix this by using VIDIOC_SUBDEV_G_FORMAT to get the size of the sensor's active format when the ENUM_FRAME_SIZE ioctl isn't implemented by the sensor driver. Signed-off-by: Andrey Konovalov --- src/libcamera/v4l2_subdevice.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index f2bcd7f..fac7586 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -317,7 +317,25 @@ std::vector V4L2Subdevice::enumPadSizes(unsigned int pad, sizeEnum.max_width, sizeEnum.max_height); } - if (ret < 0 && ret != -EINVAL && ret != -ENOTTY) { + if (ret == -ENOTTY) { + struct v4l2_subdev_format format = {}; + + LOG(V4L2, Debug) + << "VIDIOC_SUBDEV_ENUM_FRAME_SIZE not implemented " + << "- trying VIDIOC_SUBDEV_G_FMT"; + format.pad = pad; + format.which = V4L2_SUBDEV_FORMAT_ACTIVE; + + ret = ioctl(VIDIOC_SUBDEV_G_FMT, &format); + if (ret == 0) { + sizes.emplace_back(format.format.width, + format.format.height, + format.format.width, + format.format.height); + } + } + + if (ret < 0 && ret != -EINVAL) { LOG(V4L2, Error) << "Unable to enumerate sizes on pad " << pad << ": " << strerror(-ret);