From patchwork Tue Jul 18 14:00:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Ford X-Patchwork-Id: 9848423 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 51599600CC for ; Tue, 18 Jul 2017 14:01:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3FBA828583 for ; Tue, 18 Jul 2017 14:01:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 34826285B5; Tue, 18 Jul 2017 14:01:16 +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 97FA928583 for ; Tue, 18 Jul 2017 14:01:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751457AbdGROBN (ORCPT ); Tue, 18 Jul 2017 10:01:13 -0400 Received: from mail-io0-f193.google.com ([209.85.223.193]:34884 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751415AbdGROBG (ORCPT ); Tue, 18 Jul 2017 10:01:06 -0400 Received: by mail-io0-f193.google.com with SMTP id f1so879251ioj.2; Tue, 18 Jul 2017 07:01:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=/xQD0HFGhYC1eQWBTzJgIw/YcAVCvKMfWo7du3SJQuA=; b=MBDNaRxNhD6nfCXm6pc/G13ZQroXmV5ljmB14EsSCtphqGeVelpqWPQNmK2GvcYWP3 T8BpUTKFwGVTexgoJosyLKxztAUjzRF8f25egqxPKEqhX/nfn27EPnrd/OdErj0mvpuB revs1qF/z1tj7umvCzTyV6xduHyjsCWsv+gVOXnDyp+WhmSXKMjLHruX77Ukv7T8WGLn SOwT5D9wCZ2OWxKEaW5Vr2RWiGPZpDZ5VL0ig7YvJ9GKFqwXJpO5LGahFjqcjZYedOPp 0Bv0HXaJWyowIdMCab4zfbIuW7yTPRWwPJlo3q8vo8EjYO5h99W0QVdgI+oVWEq8mL5i cAog== 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; bh=/xQD0HFGhYC1eQWBTzJgIw/YcAVCvKMfWo7du3SJQuA=; b=GeRQozu2ASHGAD3u2aFYqbWcTUzL0hzoAz9Gh9amVoXKKXC4+rKN6ejgJe9pCsV0Zh zgIbj3T9LhFOOe55+yAaqWrMHI8YD3FKjz/BU4CFalz1AjA0jjmNzrUQSSbNeSpz2TDD DSW6MOnES/sPUDq0QgYWjopr/lkgmb6zTs+yfpaouAyh2T+5oIOi+RdPmtreHhBOIiuj Sl37toTxDV0dlELG4SEKtxzhLoeQzj/lSHz7Mg/7F9rMvK8ra4s7zT8V0Cb8pp+Ag6fb wjkqMoSv5XVRk68x2jP8P1Um2kXX6XMlhAvW7PVWPumEmVg3t7ngxVBOewrfZWijtCc6 TtoA== X-Gm-Message-State: AIVw113DEFZu3p0JJQa6sRrUsEuVmSJpCppbgWgvqIRnAFya9Ys2qfNv ZgEu9xCzVCAxYIMoo+M= X-Received: by 10.107.169.80 with SMTP id s77mr1627044ioe.219.1500386465345; Tue, 18 Jul 2017 07:01:05 -0700 (PDT) Received: from aford-linux.logicpd.com ([174.46.170.158]) by smtp.gmail.com with ESMTPSA id 9sm1186910iop.9.2017.07.18.07.01.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Jul 2017 07:01:04 -0700 (PDT) From: Adam Ford To: mchehab@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, laurent.pinchart@ideasonboard.com, linux-media@vger.kernel.org, devicetree@vger.kernel.org Cc: Adam Ford Subject: [RFC PATCH] media: i2c: mt9p031: Add 8-bit support Date: Tue, 18 Jul 2017 09:00:54 -0500 Message-Id: <1500386454-27583-1-git-send-email-aford173@gmail.com> X-Mailer: git-send-email 2.7.4 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 From: Adam Ford By default the camera driver only supports monochrome or color at 12-bit. This patch will allow the camera to choose between 12-bit or 8-bit resolution. Tested on Logic PD DM3730 Torpedo Development Kit. Signed-off-by: Adam Ford diff --git a/Documentation/devicetree/bindings/media/i2c/mt9p031.txt b/Documentation/devicetree/bindings/media/i2c/mt9p031.txt index cb60443..77b0dc1 100644 --- a/Documentation/devicetree/bindings/media/i2c/mt9p031.txt +++ b/Documentation/devicetree/bindings/media/i2c/mt9p031.txt @@ -15,6 +15,7 @@ Required Properties: Optional Properties: - reset-gpios: Chip reset GPIO +- resolution: Empty (12-bit) or 8 bit resolution For further reading on port node refer to Documentation/devicetree/bindings/media/video-interfaces.txt. diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c index 91d822f..355791d 100644 --- a/drivers/media/i2c/mt9p031.c +++ b/drivers/media/i2c/mt9p031.c @@ -1024,6 +1024,7 @@ mt9p031_get_pdata(struct i2c_client *client) of_property_read_u32(np, "input-clock-frequency", &pdata->ext_freq); of_property_read_u32(np, "pixel-clock-frequency", &pdata->target_freq); + of_property_read_u32(np, "resolution", &pdata->resolution); done: of_node_put(np); @@ -1058,6 +1059,7 @@ static int mt9p031_probe(struct i2c_client *client, mt9p031->output_control = MT9P031_OUTPUT_CONTROL_DEF; mt9p031->mode2 = MT9P031_READ_MODE_2_ROW_BLC; mt9p031->model = did->driver_data; + mt9p031->resolution = pdata->resolution; mt9p031->regulators[0].supply = "vdd"; mt9p031->regulators[1].supply = "vdd_io"; @@ -1123,11 +1125,18 @@ static int mt9p031_probe(struct i2c_client *client, mt9p031->crop.left = MT9P031_COLUMN_START_DEF; mt9p031->crop.top = MT9P031_ROW_START_DEF; - if (mt9p031->model == MT9P031_MODEL_MONOCHROME) - mt9p031->format.code = MEDIA_BUS_FMT_Y12_1X12; - else - mt9p031->format.code = MEDIA_BUS_FMT_SGRBG12_1X12; - + if (mt9p031->model == MT9P031_MODEL_MONOCHROME) { + if (mt9p031->resolution == 8) + mt9p031->format.code = MEDIA_BUS_FMT_Y8_1X8; + else + mt9p031->format.code = MEDIA_BUS_FMT_Y12_1X12; + } + else { + if (mt9p031->resolution == 8) + mt9p031->format.code = MEDIA_BUS_FMT_SGRBG8_1X8; + else + mt9p031->format.code = MEDIA_BUS_FMT_SGRBG12_1X12; + } mt9p031->format.width = MT9P031_WINDOW_WIDTH_DEF; mt9p031->format.height = MT9P031_WINDOW_HEIGHT_DEF; mt9p031->format.field = V4L2_FIELD_NONE; diff --git a/include/media/i2c/mt9p031.h b/include/media/i2c/mt9p031.h index 1ba3612..84335cb 100644 --- a/include/media/i2c/mt9p031.h +++ b/include/media/i2c/mt9p031.h @@ -11,6 +11,7 @@ struct v4l2_subdev; struct mt9p031_platform_data { int ext_freq; int target_freq; + int resolution; }; #endif