From patchwork Sat Apr 15 10:05:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Frank_Sch=C3=A4fer?= X-Patchwork-Id: 9682175 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1FF7460388 for ; Sat, 15 Apr 2017 10:05:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1FBF285AB for ; Sat, 15 Apr 2017 10:05:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E693B285C9; Sat, 15 Apr 2017 10:05:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50428285B2 for ; Sat, 15 Apr 2017 10:05:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753441AbdDOKFo (ORCPT ); Sat, 15 Apr 2017 06:05:44 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:33546 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752840AbdDOKFm (ORCPT ); Sat, 15 Apr 2017 06:05:42 -0400 Received: by mail-wr0-f196.google.com with SMTP id l28so14869846wre.0 for ; Sat, 15 Apr 2017 03:05:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=k13AMXP3YChlVnfIFgUDVpWnOvFEk7TpezBLtFodF1A=; b=mfakuhXqB6lxt3+ZUempuqSy0mG0D4ICQWnWQ5OmXVZvuSrMcBGH1637wVRnaXBPVN iilM3f6W3CMUUGWnJZBwvRwBgWXf51fubcYv7xQjPak4SErfV/7h/62Zzef11yP5kQlV 5CZepv/WbiIBUKw/rPiqzFFfvCzcfvUi43LAhCqoNv7AY3jHxIcC5h9u3lSsOdVxBJY3 pa9D0L+THjGJnYayLvaBHlJ0pxqobYgzR/yiKO59ILVRNQpijz1Y/kY5gpeHN6Q90XB9 er6dy0+Rab9nSCV90AvzcpdrlZYbGrvIEQ8D0WeZaYPzwaLItQe+VoP2T5D+l9RSIZvn /T9Q== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=k13AMXP3YChlVnfIFgUDVpWnOvFEk7TpezBLtFodF1A=; b=S6CSbXLsflz0PJkAMw+1qjESWsMW5I3nC9OjoMUKxhh6er6XJWVvhaOVsc1cv06LcE 7Os/OLUfgH1+YoFwGNhtku6Bow9Zx9qsoM9SPGWTBMP3q+lPCxZD6Jyz1vNDuTfuZ2ob rna5n0XH/92AL6BiHx3FschCERojULPd+Wx+ORdf2bQgtIQqrjQp1gScIyVGw24U2BnS 8mmXin5J6O8s7kopw4dLFrzdBW4TUwB0p/YQzzyRfxsAR3eBeJdMgkNLehqIxYS8gJEq f3JMm4NcjAp/3/WOS+6G0RhgW/0AXWssXaxDg6LjYJxbgqFeTaYVmH2aVexcWAoL8EK7 3M+g== X-Gm-Message-State: AN3rC/6Q5le2VnTphOjrPX5Tny6L6/J/vb8ybBUs6o8v7w12STEzSaYB /6BH6NlN5lRTH94R X-Received: by 10.223.180.81 with SMTP id v17mr2310504wrd.101.1492250741258; Sat, 15 Apr 2017 03:05:41 -0700 (PDT) Received: from Athlon64X2-5000.lan (ip-178-201-166-194.hsi08.unitymediagroup.de. [178.201.166.194]) by smtp.googlemail.com with ESMTPSA id b73sm5753639wrd.29.2017.04.15.03.05.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 15 Apr 2017 03:05:40 -0700 (PDT) From: =?UTF-8?q?Frank=20Sch=C3=A4fer?= To: linux-media@vger.kernel.org Cc: mchehab@kernel.org, =?UTF-8?q?Frank=20Sch=C3=A4fer?= Subject: [PATCH 3/5] em28xx: don't treat device as webcam if an unknown sensor is detected Date: Sat, 15 Apr 2017 12:05:02 +0200 Message-Id: <20170415100504.3076-3-fschaefer.oss@googlemail.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170415100504.3076-1-fschaefer.oss@googlemail.com> References: <20170415100504.3076-1-fschaefer.oss@googlemail.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP With an unknown sensor, norm_maxw() and norm_maxh() return 0 as max. height and width values, which causes a devide by zero in size_to_scale(). Of course we could use speculative default values for unknown sensors, but the chance that the device works at this resolution without any driver/setup is very low and therefore not worth the efforts. Instead, just don't treat the device as camera. A message will then be printed to the log that the device isn't supported. Signed-off-by: Frank Schäfer --- drivers/media/usb/em28xx/em28xx-cards.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c index 5f80a1b2fb8c..48c7fec47509 100644 --- a/drivers/media/usb/em28xx/em28xx-cards.c +++ b/drivers/media/usb/em28xx/em28xx-cards.c @@ -2917,7 +2917,9 @@ static void em28xx_card_setup(struct em28xx *dev) * If sensor is not found, then it isn't a webcam. */ if (dev->board.is_webcam) { - if (em28xx_detect_sensor(dev) < 0) + em28xx_detect_sensor(dev); + if (dev->em28xx_sensor == EM28XX_NOSENSOR) + /* NOTE: error/unknown sensor/no sensor */ dev->board.is_webcam = 0; } @@ -3665,9 +3667,11 @@ static int em28xx_usb_probe(struct usb_interface *interface, try_bulk = usb_xfer_mode > 0; } - /* Disable V4L2 if the device doesn't have a decoder */ + /* Disable V4L2 if the device doesn't have a decoder or image sensor */ if (has_video && - dev->board.decoder == EM28XX_NODECODER && !dev->board.is_webcam) { + dev->board.decoder == EM28XX_NODECODER && + dev->em28xx_sensor == EM28XX_NOSENSOR) { + dev_err(&interface->dev, "Currently, V4L2 is not supported on this model\n"); has_video = false;