From patchwork Sat Apr 15 10:05:03 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: 9682177 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 36CF260389 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 176EF285AB for ; Sat, 15 Apr 2017 10:05:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 01991285F7; 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 70609285B3 for ; Sat, 15 Apr 2017 10:05:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753472AbdDOKFp (ORCPT ); Sat, 15 Apr 2017 06:05:45 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:36710 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753432AbdDOKFo (ORCPT ); Sat, 15 Apr 2017 06:05:44 -0400 Received: by mail-wm0-f66.google.com with SMTP id q125so1908646wmd.3 for ; Sat, 15 Apr 2017 03:05:43 -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=rh4f2+yiEEnwG/NgBzvQ9E9eRYBdg+dzbim0KCNRYlI=; b=o2Q2IwSg/mJVjC+zeQK5dPZcqzTi0RF6yvVHjhsP52SDAMm/bmumFB5EW+VdJgg/F/ qVTiwpmEg9gNIMZrev77MedAOx7YkohQp1hCxte6J5UeJruoGavebAmpkIWg34M5Q01d 7WUBunycLsceN4d2xD6c2L2RnhFCnbUfBGiG6xGOUEoQglUrWiK4tMNc4eU+dZXO4pZV RiXh9/68z3EvQUX+OChLXW6dzzic+Mj/HjopOLbqMm3A7XrfFC6pJJZHcCyOhol3842s T1OEY5X9/M9UNDOtfJ1lfic4UbpDosSNHOyOTuk0+6DaUxtcWPktQ/1AnNvcVO7t9mCo gqaA== 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=rh4f2+yiEEnwG/NgBzvQ9E9eRYBdg+dzbim0KCNRYlI=; b=AUDMBb5ZzRS2G0Kxg8RYBCbaqLyol3xOnGRAZGcl/W2ghY/TTMfIUzHjDgPf39THwn EynT34ssT5kRXOH6nCCISZwH0eHwmUgN9u7wmty0ydMKRTxo8ZKlH02GWe0p+LASQ4Ur ZiDfcFIrStW4LXkv0RjZHTQgBpi841M3hv1+DfI0l6G3Zn3zf7tSoxskJlIeWmqeSkiQ JmPzjjyvGaktlsWw4DOmL3mFoig5dtsyhirQEkaGiWOsj0tBsPGrmlX3lKifndGv+tUw rKd69zB3MQ/h3Is/MJG/gTf9Hd7xtNdxcQDXGpwwnuHWoTRM2EfOx5t9GzBvbVSxi1uD pQmA== X-Gm-Message-State: AN3rC/5tdTUz3vjHNOJoBdmW+2Q83+1QytJLI+qZypIR85Vx/Sr+IlN8 NwzCrfdtgUwtQQ== X-Received: by 10.28.13.71 with SMTP id 68mr1974797wmn.124.1492250742622; Sat, 15 Apr 2017 03:05:42 -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.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 15 Apr 2017 03:05:41 -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 4/5] em28xx: shed some light on video input formats Date: Sat, 15 Apr 2017 12:05:03 +0200 Message-Id: <20170415100504.3076-4-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 CbYCrY has been identified by looking into the tvp5150 driver and the saa7115 datasheet. YUV formats have been verified with em2765 + ov2640 (VAD Laplace webcam). RGB8 formats have been verified with em2710/em2820 + mt9v011 (Silvercrest webcam 1.3mpix). I also did some cross-checking with these two camera devices and 0x08-0x0b are at least 16 bits per pixel formats on em2710/em2820, too, and 0x0c-0x0f are at least 8 bits per pixel formats on em2765, too. Signed-off-by: Frank Schäfer --- drivers/media/usb/em28xx/em28xx-camera.c | 10 ++++------ drivers/media/usb/em28xx/em28xx-reg.h | 18 ++++++++++++++++++ drivers/media/usb/em28xx/em28xx-video.c | 2 +- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/drivers/media/usb/em28xx/em28xx-camera.c b/drivers/media/usb/em28xx/em28xx-camera.c index d43f630050bb..95eaa55356a9 100644 --- a/drivers/media/usb/em28xx/em28xx-camera.c +++ b/drivers/media/usb/em28xx/em28xx-camera.c @@ -364,8 +364,7 @@ int em28xx_init_camera(struct em28xx *dev) v4l2_i2c_new_subdev_board(&v4l2->v4l2_dev, adap, &mt9v011_info, NULL)) return -ENODEV; - /* probably means GRGB 16 bit bayer */ - v4l2->vinmode = 0x0d; + v4l2->vinmode = EM28XX_VINMODE_RGB8_GRBG; v4l2->vinctl = 0x00; break; @@ -376,8 +375,7 @@ int em28xx_init_camera(struct em28xx *dev) em28xx_initialize_mt9m001(dev); - /* probably means BGGR 16 bit bayer */ - v4l2->vinmode = 0x0c; + v4l2->vinmode = EM28XX_VINMODE_RGB8_BGGR; v4l2->vinctl = 0x00; break; @@ -389,7 +387,7 @@ int em28xx_init_camera(struct em28xx *dev) em28xx_write_reg(dev, EM28XX_R0F_XCLK, dev->board.xclk); em28xx_initialize_mt9m111(dev); - v4l2->vinmode = 0x0a; + v4l2->vinmode = EM28XX_VINMODE_YUV422_UYVY; v4l2->vinctl = 0x00; break; @@ -430,7 +428,7 @@ int em28xx_init_camera(struct em28xx *dev) /* NOTE: for UXGA=1600x1200 switch to 12MHz */ dev->board.xclk = EM28XX_XCLK_FREQUENCY_24MHZ; em28xx_write_reg(dev, EM28XX_R0F_XCLK, dev->board.xclk); - v4l2->vinmode = 0x08; + v4l2->vinmode = EM28XX_VINMODE_YUV422_YUYV; v4l2->vinctl = 0x00; break; diff --git a/drivers/media/usb/em28xx/em28xx-reg.h b/drivers/media/usb/em28xx/em28xx-reg.h index afe7a66d7dc8..747525ca7ed5 100644 --- a/drivers/media/usb/em28xx/em28xx-reg.h +++ b/drivers/media/usb/em28xx/em28xx-reg.h @@ -93,6 +93,24 @@ #define EM28XX_XCLK_FREQUENCY_24MHZ 0x0b #define EM28XX_R10_VINMODE 0x10 + /* used by all non-camera devices: */ +#define EM28XX_VINMODE_YUV422_CbYCrY 0x10 + /* used by camera devices: */ +#define EM28XX_VINMODE_YUV422_YUYV 0x08 +#define EM28XX_VINMODE_YUV422_YVYU 0x09 +#define EM28XX_VINMODE_YUV422_UYVY 0x0a +#define EM28XX_VINMODE_YUV422_VYUY 0x0b +#define EM28XX_VINMODE_RGB8_BGGR 0x0c +#define EM28XX_VINMODE_RGB8_GRBG 0x0d +#define EM28XX_VINMODE_RGB8_GBRG 0x0e +#define EM28XX_VINMODE_RGB8_RGGB 0x0f + /* + * apparently: + * bit 0: swap component 1+2 with 3+4 + * => e.g.: YUYV => YVYU, BGGR => GRBG + * bit 1: swap component 1 with 2 and 3 with 4 + * => e.g.: YUYV => UYVY, BGGR => GBRG + */ #define EM28XX_R11_VINCTRL 0x11 diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c index 3cbc3d4270a3..aaa83f9e5c1a 100644 --- a/drivers/media/usb/em28xx/em28xx-video.c +++ b/drivers/media/usb/em28xx/em28xx-video.c @@ -2459,7 +2459,7 @@ static int em28xx_v4l2_init(struct em28xx *dev) /* * Default format, used for tvp5150 or saa711x output formats */ - v4l2->vinmode = 0x10; + v4l2->vinmode = EM28XX_VINMODE_YUV422_CbYCrY; v4l2->vinctl = EM28XX_VINCTRL_INTERLACED | EM28XX_VINCTRL_CCIR656_ENABLE;