From patchwork Mon Aug 4 20:02:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Zabel X-Patchwork-Id: 4673401 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 64B089F373 for ; Mon, 4 Aug 2014 20:02:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8970920149 for ; Mon, 4 Aug 2014 20:02:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A78B92013D for ; Mon, 4 Aug 2014 20:02:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751328AbaHDUCY (ORCPT ); Mon, 4 Aug 2014 16:02:24 -0400 Received: from mail-we0-f170.google.com ([74.125.82.170]:60473 "EHLO mail-we0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750831AbaHDUCX (ORCPT ); Mon, 4 Aug 2014 16:02:23 -0400 Received: by mail-we0-f170.google.com with SMTP id w62so8314331wes.29 for ; Mon, 04 Aug 2014 13:02:19 -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=GKij0Y/nUEqk1dyiEZ8/RFDtOJMv6gGbY8IVE/dicMY=; b=YQKXDxsd3afTciRb7ytnOsWH8AEBFx0sD7IJHl3jwfUnQui3LaZNepntTrDI34j5lo OlyexINMzrEVI3GJWPQWyDdQ4SO1wXpV9iCz5eXYAJGYsIpQ617Qjm9X+LZnRS2PY+Rm jqwzyDMaQKvBsA7kl67byjaOFy6uWo7hdxvYvqx5ClJxeqmMDhNTpEFX5mwmCoHx3xNs YMpST+KJYih9aOl0SpYyLR7vygzq3qArD+ZzZF9K5MTFHiJWBoKJFgT69qE2KO8UTDeV kQb7wuVaUWtv8dPoKHSt/Bm9TR36Q51QDt+pgxa4B4fd4cOHW9YsDmUWWuPe8OcRR08R udHw== X-Received: by 10.180.38.84 with SMTP id e20mr8058637wik.43.1407182538702; Mon, 04 Aug 2014 13:02:18 -0700 (PDT) Received: from flow.hitronhub.home ([2a02:8108:8840:128c:222:15ff:fe78:43c2]) by mx.google.com with ESMTPSA id je3sm184633wic.11.2014.08.04.13.02.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Aug 2014 13:02:17 -0700 (PDT) From: Philipp Zabel To: Laurent Pinchart Cc: linux-media@vger.kernel.org, Philipp Zabel Subject: [RFC PATCH] uvcvideo: Add quirk to force the Oculus DK2 IR tracker to grayscale Date: Mon, 4 Aug 2014 22:02:15 +0200 Message-Id: <1407182535-7622-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 --- The Oculus Rift DK2 comes with an IR webcam that lies about the pixel format and frame size it produces. This is a quick hack to make it produce proper greyscale images. --- drivers/media/usb/uvc/uvc_driver.c | 19 +++++++++++++++++++ drivers/media/usb/uvc/uvcvideo.h | 1 + 2 files changed, 20 insertions(+) diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index f8135f4..322a674 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -352,6 +352,10 @@ static int uvc_parse_format(struct uvc_device *dev, /* Find the format descriptor from its GUID. */ fmtdesc = uvc_format_by_guid(&buffer[5]); + if (dev->quirks & UVC_QUIRK_FORCE_Y8) { + WARN_ON(!fmtdesc || fmtdesc->fcc != V4L2_PIX_FMT_YUYV); + fmtdesc = &uvc_fmts[9]; + } if (fmtdesc != NULL) { strlcpy(format->name, fmtdesc->name, @@ -366,6 +370,10 @@ static int uvc_parse_format(struct uvc_device *dev, } format->bpp = buffer[21]; + if (dev->quirks & UVC_QUIRK_FORCE_Y8) { + WARN_ON(format->bpp != 16); + format->bpp /= 2; + } if (buffer[2] == UVC_VS_FORMAT_UNCOMPRESSED) { ftype = UVC_VS_FRAME_UNCOMPRESSED; } else { @@ -475,6 +483,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 (dev->quirks & UVC_QUIRK_FORCE_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]); @@ -2486,6 +2496,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 b1f69a6..1252040 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -147,6 +147,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