From patchwork Wed Aug 6 20:50:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Zabel X-Patchwork-Id: 4688551 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2F93EC0338 for ; Wed, 6 Aug 2014 20:50:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 43E6F20170 for ; Wed, 6 Aug 2014 20:50:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2A8C120103 for ; Wed, 6 Aug 2014 20:50:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753317AbaHFUuz (ORCPT ); Wed, 6 Aug 2014 16:50:55 -0400 Received: from mail-wg0-f43.google.com ([74.125.82.43]:63466 "EHLO mail-wg0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752588AbaHFUuy (ORCPT ); Wed, 6 Aug 2014 16:50:54 -0400 Received: by mail-wg0-f43.google.com with SMTP id l18so3118891wgh.26 for ; Wed, 06 Aug 2014 13:50:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=4U3kLBpnMtj+73APAy8Rdt0K62b+BQOFgNTqVRb6KiA=; b=LUdCD2XQ+slMnpOWogrmKc951nXtUMz5lYJeiY9ivOPDAZg1CmU/dcGeol0FxW3jdF 9yAPcRGqmrNBOQMuBh3EuNyKjLu7hthhcXI2L9KVCcHXx0NqJniJ0CNxsiZMrhAzIfxa /PuTr4lABJGWTiegxjDuVH2I1ImjmIYPdBMnaCClyc8iQQLMRbXN4lLXFoxv0pyhfbg8 9BvGlJMshT8OkpDNEV+qqeGsu3jnQYTmsFAKv1ocgDjxd78McyoNxsdSci/YaIvbnvEH KDvywmaldDQ4bog+dC95UxZ4yZB5/PRhxeYQ7YUmUXcDmTYfT/njsVgq8tuBm/UT5h9v q3BQ== X-Received: by 10.194.62.67 with SMTP id w3mr18805300wjr.32.1407358253037; Wed, 06 Aug 2014 13:50:53 -0700 (PDT) Received: from flow.hitronhub.home ([2a02:8108:8840:128c:222:15ff:fe78:43c2]) by mx.google.com with ESMTPSA id pj6sm4924860wjb.21.2014.08.06.13.50.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 06 Aug 2014 13:50:51 -0700 (PDT) From: Philipp Zabel To: Laurent Pinchart Cc: linux-media@vger.kernel.org, Philipp Zabel Subject: [PATCH v2] [media] uvcvideo: Add quirk to force the Oculus DK2 IR tracker to grayscale Date: Wed, 6 Aug 2014 22:50:49 +0200 Message-Id: <1407358249-19605-1-git-send-email-philipp.zabel@gmail.com> X-Mailer: git-send-email 2.0.1 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds a quirk to force Y8 pixel format even if the camera reports half-width YUYV. Signed-off-by: Philipp Zabel --- drivers/media/usb/uvc/uvc_driver.c | 29 ++++++++++++++++++++++++++++- drivers/media/usb/uvc/uvcvideo.h | 1 + 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index c3bb250..90a8f10 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -311,6 +311,7 @@ static int uvc_parse_format(struct uvc_device *dev, struct uvc_format_desc *fmtdesc; struct uvc_frame *frame; const unsigned char *start = buffer; + bool force_yuy2_to_y8 = false; unsigned int interval; unsigned int i, n; __u8 ftype; @@ -333,6 +334,22 @@ static int uvc_parse_format(struct uvc_device *dev, /* Find the format descriptor from its GUID. */ fmtdesc = uvc_format_by_guid(&buffer[5]); + format->bpp = buffer[21]; + + if (dev->quirks & UVC_QUIRK_FORCE_Y8) { + if (fmtdesc && fmtdesc->fcc == V4L2_PIX_FMT_YUYV && + format->bpp == 16) { + force_yuy2_to_y8 = true; + fmtdesc = &uvc_fmts[9]; + format->bpp = 8; + } else { + uvc_printk(KERN_WARNING, + "Forcing %d-bit %s to %s not supported", + format->bpp, fmtdesc->name, + uvc_fmts[9].name); + } + } + if (fmtdesc != NULL) { strlcpy(format->name, fmtdesc->name, sizeof format->name); @@ -345,7 +362,6 @@ static int uvc_parse_format(struct uvc_device *dev, format->fcc = 0; } - format->bpp = buffer[21]; if (buffer[2] == UVC_VS_FORMAT_UNCOMPRESSED) { ftype = UVC_VS_FRAME_UNCOMPRESSED; } else { @@ -455,6 +471,8 @@ static int uvc_parse_format(struct uvc_device *dev, frame->bFrameIndex = buffer[3]; frame->bmCapabilities = buffer[4]; frame->wWidth = get_unaligned_le16(&buffer[5]); + if (force_yuy2_to_y8) + frame->wWidth *= 2; frame->wHeight = get_unaligned_le16(&buffer[7]); frame->dwMinBitRate = get_unaligned_le32(&buffer[9]); frame->dwMaxBitRate = get_unaligned_le32(&buffer[13]); @@ -2467,6 +2485,15 @@ static struct usb_device_id uvc_ids[] = { .bInterfaceProtocol = 0, .driver_info = UVC_QUIRK_PROBE_MINMAX | UVC_QUIRK_IGNORE_SELECTOR_UNIT }, + /* Oculus VR Positional Tracker DK2 */ + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE + | USB_DEVICE_ID_MATCH_INT_INFO, + .idVendor = 0x2833, + .idProduct = 0x0201, + .bInterfaceClass = USB_CLASS_VIDEO, + .bInterfaceSubClass = 1, + .bInterfaceProtocol = 0, + .driver_info = UVC_QUIRK_FORCE_Y8 }, /* Generic USB Video Class */ { USB_INTERFACE_INFO(USB_CLASS_VIDEO, 1, 0) }, {} diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index 9e35982..1dd78c0 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -137,6 +137,7 @@ #define UVC_QUIRK_FIX_BANDWIDTH 0x00000080 #define UVC_QUIRK_PROBE_DEF 0x00000100 #define UVC_QUIRK_RESTRICT_FRAME_RATE 0x00000200 +#define UVC_QUIRK_FORCE_Y8 0x00000400 /* Format flags */ #define UVC_FMT_FLAG_COMPRESSED 0x00000001