Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp2412359imb; Mon, 4 Mar 2019 04:38:57 -0800 (PST) X-Google-Smtp-Source: APXvYqyiIPphT/GcHZ2wf8TOeMyauw4fOt5TkJyjNDLy53Tvq1+CVClzWg7rl0NikuLT9nu+g/+H X-Received: by 2002:a63:d814:: with SMTP id b20mr18650955pgh.312.1551703137402; Mon, 04 Mar 2019 04:38:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551703137; cv=none; d=google.com; s=arc-20160816; b=jrJ7BbenalMIkjsEnCtB7tqVbwOM6Uk6egZH46i5Y6f60WRwJli8t4uPGXb8cQSbfy ehe4B0meOi7g1rgP1m46P75S6C51Xpl+DSO66VR1T/6TuUd5c+AqJlBe3ah7zIthv16j 4oWl6rUW1DRgDN2gpqftLE/j2GiHxPq/xyL0RGtr67Iw5FFkmynjM49mUfwgCRxWnFDc yOWhY8FixXKIngTAf+jUbpQB5nZ+wnGLDXeKkcH2np1xZ6xbRM3pZG3gE/UygAmyGxUm qURUpimbmBS+mLrIW191VQ0zUS3N7al3C5HZyZPtC7a4hVFBIZHgIFh8sb7/u9E0PCyr Ui/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=ZQOjY64u7q1+5eWh9GvpsYEbuwpMO6wcKRnyPyqb4e4=; b=OrZtwzylbZQDmRJYkPymaPmGLgQQ98bNHGUO4ZHV2EqWOesZgqWDzyILiIHHVZUSdk G+IBcMjtdT3YpC99j/9ZUlQcJu8HIHvSo1AktLM2C6XMq/lfeVn2IjdLTZJ/RPiJGSVY 7EB28KgoqEP1J/Rpj/iBVk0wC0g+qPz2wEpTmmf/ZH1Ncdv7TgHulfSXb+UX1Efp1PXW 3UZTPnUA3SWzsKa0/2JoafUJ6UJ1fkVyYjfKOvcz1/R+J5SoxAVO/UH/4tJmRyXWpxMv 9bzj4i4dk+oZWUT5Mrm47l4g1jBmC15perE9UXi1or0ZqfndVuJos1UAsSRWOdwV0H39 708Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 65si5749325pfg.28.2019.03.04.04.38.42; Mon, 04 Mar 2019 04:38:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726528AbfCDMf5 (ORCPT + 99 others); Mon, 4 Mar 2019 07:35:57 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:21090 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726041AbfCDMf4 (ORCPT ); Mon, 4 Mar 2019 07:35:56 -0500 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x24CVhYw002801; Mon, 4 Mar 2019 13:35:50 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2qyhgakd3m-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 04 Mar 2019 13:35:50 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 78EC538; Mon, 4 Mar 2019 12:35:49 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas21.st.com [10.75.90.44]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 528682A3C; Mon, 4 Mar 2019 12:35:49 +0000 (GMT) Received: from SAFEX1HUBCAS22.st.com (10.75.90.93) by SAFEX1HUBCAS21.st.com (10.75.90.44) with Microsoft SMTP Server (TLS) id 14.3.361.1; Mon, 4 Mar 2019 13:35:49 +0100 Received: from localhost (10.201.23.19) by Webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.361.1; Mon, 4 Mar 2019 13:35:48 +0100 From: Hugues Fruchet To: Laurent Pinchart , "Mauro Carvalho Chehab" CC: , , "Hugues Fruchet" Subject: [PATCH] Support of /dev/video read with USB camera devices Date: Mon, 4 Mar 2019 13:35:24 +0100 Message-ID: <1551702925-7739-1-git-send-email-hugues.fruchet@st.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.201.23.19] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-03-04_04:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, read() call from /dev/video entry of an USB camera is returning invalid argument error. This is quite common for userspace application to read compressed data such as JPEG from /dev/video then redirect those data to a multimedia player or any other compressed format consumer, see [1]. There was a tentative of implementation in the past [2] but it was prior to switch on vb2 helpers usage inside uvc. Now that vb2 is in place, we can implement read support using vb2_read() helper. Tested with Logitech HD Webcam C525 using v4l2-ctl to configure camera then GStreamer player to play stream: $> v4l2-ctl -d /dev/video0 --set-fmt-video=width=640,height=480,pixelformat=MJPG $> gst-play-1.0 /dev/video0 [1] http://credentiality2.blogspot.com/2010/04/v4l2-example.html?_sm_au_=ikcQHNZZFn2Rqft5 https://stackoverrun.com/fr/q/4215615 https://stackoverflow.com/questions/36297390/read-function-for-webcam-device-in-v4l2-fails-with-invalid-argument https://stackoverflow.com/questions/31058571/reading-camera-input-from-dev-video0-in-python-or-c [2] https://www.mail-archive.com/linux-uvc-devel@lists.berlios.de/msg01258.html Hugues Fruchet (1): media: uvcvideo: Read support drivers/media/usb/uvc/uvc_queue.c | 15 ++++++++++++++- drivers/media/usb/uvc/uvc_v4l2.c | 11 ++++++++--- drivers/media/usb/uvc/uvcvideo.h | 2 ++ 3 files changed, 24 insertions(+), 4 deletions(-) -- 2.7.4