devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Adam Ford <aford173@gmail.com>
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 <adam.ford@logicpd.com>
Subject: [RFC PATCH] media: i2c: mt9p031: Add 8-bit support
Date: Tue, 18 Jul 2017 09:00:54 -0500	[thread overview]
Message-ID: <1500386454-27583-1-git-send-email-aford173@gmail.com> (raw)

From: Adam Ford <adam.ford@logicpd.com>

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 <adam.ford@logicpd.com>

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
-- 
2.7.4

             reply	other threads:[~2017-07-18 14:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-18 14:00 Adam Ford [this message]
2017-07-18 14:34 ` [RFC PATCH] media: i2c: mt9p031: Add 8-bit support Laurent Pinchart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1500386454-27583-1-git-send-email-aford173@gmail.com \
    --to=aford173@gmail.com \
    --cc=adam.ford@logicpd.com \
    --cc=devicetree@vger.kernel.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mchehab@kernel.org \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).