From patchwork Mon Jun 8 08:05:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 3985 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D73A3603C7 for ; Mon, 8 Jun 2020 10:05:41 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="F5SZCXAA"; dkim-atps=neutral Received: from emerald.amanokami.net (fs76eef344.knge213.ap.nuro.jp [118.238.243.68]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 580C22C9; Mon, 8 Jun 2020 10:05:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1591603541; bh=iX6pspRxv2u1u41BmBgQeHT3gpV/0AHUbBIYb+RbQ24=; h=From:To:Cc:Subject:Date:From; b=F5SZCXAA5BSiuqnyWu9XqtSkm3D3l6Po6W92NFdisDHawvocCrZzDtrKmicDYPcFx qycdXUwJ+ofT+d5z9DAsdbkkzBXfmLbE85+9iD2UuURwwGsB8hsBclMtauea81ULmc I88Bz8ncVZqlePLlPVbH1rVeC/a34MUzR5vxDedA= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Mon, 8 Jun 2020 17:05:29 +0900 Message-Id: <20200608080529.7727-1-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2] v4l2: v4l2_camera_proxy: Support MJPEG 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: Mon, 08 Jun 2020 08:05:42 -0000 Add an entry for MJPEG in V4L2CameraProxy's PixelFormatInfo list to allow proper calculation of sizeimage for MJPEG, such that the parameters to mmap can align properly instead of failing. This allows MJPEG to be used in the V4L2 compatibility layer. Signed-off-by: Paul Elder Reviewed-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- Changes in v2: - add todo for better MJPEG sizeimage estimate - update comment that the warning will only be printed if the set format has zero sizeimage at the time of reqbufs --- src/v4l2/v4l2_camera_proxy.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp index 059f3cbe..07e746b4 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -358,8 +358,9 @@ int V4L2CameraProxy::vidioc_reqbufs(struct v4l2_requestbuffers *arg) * don't support streaming mmap. Since we don't support readwrite and * userptr either, the application will get confused and think that * we don't support anything. - * On the other hand, if a format has a zero sizeimage (eg. MJPEG), - * we'll get a floating point exception when we try to stream it. + * On the other hand, if the set format at the time of reqbufs has a + * zero sizeimage we'll get a floating point exception when we try to + * stream it. */ if (sizeimage_ == 0) LOG(V4L2Compat, Warning) @@ -556,7 +557,7 @@ struct PixelFormatInfo { namespace { -static const std::array pixelFormatInfo = {{ +static const std::array pixelFormatInfo = {{ /* RGB formats. */ { PixelFormat(DRM_FORMAT_RGB888), V4L2_PIX_FMT_BGR24, 1, {{ { 24, 1, 1 }, { 0, 0, 0 }, { 0, 0, 0 } }} }, { PixelFormat(DRM_FORMAT_BGR888), V4L2_PIX_FMT_RGB24, 1, {{ { 24, 1, 1 }, { 0, 0, 0 }, { 0, 0, 0 } }} }, @@ -573,6 +574,9 @@ static const std::array pixelFormatInfo = {{ { PixelFormat(DRM_FORMAT_NV61), V4L2_PIX_FMT_NV61, 2, {{ { 8, 1, 1 }, { 16, 2, 1 }, { 0, 0, 0 } }} }, { PixelFormat(DRM_FORMAT_NV24), V4L2_PIX_FMT_NV24, 2, {{ { 8, 1, 1 }, { 16, 2, 1 }, { 0, 0, 0 } }} }, { PixelFormat(DRM_FORMAT_NV42), V4L2_PIX_FMT_NV42, 2, {{ { 8, 1, 1 }, { 16, 1, 1 }, { 0, 0, 0 } }} }, + /* Compressed formats. */ + /* \todo Get better estimate from UVC device, via StreamConfiguration. */ + { PixelFormat(DRM_FORMAT_MJPEG), V4L2_PIX_FMT_MJPEG, 1, {{ { 16, 1, 1 }, { 0, 0, 0 }, { 0, 0, 0 } }} }, }}; } /* namespace */