From: "André Apitzsch via B4 Relay" <devnull+git.apitzsch.eu@kernel.org>
To: Ricardo Ribalda <ribalda@kernel.org>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: ~postmarketos/upstreaming@lists.sr.ht,
phone-devel@vger.kernel.org, linux-media@vger.kernel.org,
linux-kernel@vger.kernel.org,
"Dave Stevenson" <dave.stevenson@raspberrypi.com>,
"Vincent Knecht" <vincent.knecht@mailoo.org>,
"André Apitzsch" <git@apitzsch.eu>,
"Ricardo Ribalda" <ribalda@chromium.org>
Subject: [PATCH v4 11/13] media: i2c: imx214: Add test pattern control
Date: Mon, 16 Dec 2024 22:00:57 +0100 [thread overview]
Message-ID: <20241216-imx214-v4-11-8cbda160fbce@apitzsch.eu> (raw)
In-Reply-To: <20241216-imx214-v4-0-8cbda160fbce@apitzsch.eu>
From: André Apitzsch <git@apitzsch.eu>
This adds V4L2_CID_TEST_PATTERN control support.
Acked-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: André Apitzsch <git@apitzsch.eu>
---
drivers/media/i2c/imx214.c | 77 ++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 75 insertions(+), 2 deletions(-)
diff --git a/drivers/media/i2c/imx214.c b/drivers/media/i2c/imx214.c
index 4779439974add96b0fcf5089ae40d8d3126d0ffa..d15422873e7ba0588914d78d3d26374d2769541c 100644
--- a/drivers/media/i2c/imx214.c
+++ b/drivers/media/i2c/imx214.c
@@ -177,6 +177,23 @@
#define IMX214_REG_ATR_FAST_MOVE CCI_REG8(0x9300)
+/* Test Pattern Control */
+#define IMX214_REG_TEST_PATTERN CCI_REG16(0x0600)
+#define IMX214_TEST_PATTERN_DISABLE 0
+#define IMX214_TEST_PATTERN_SOLID_COLOR 1
+#define IMX214_TEST_PATTERN_COLOR_BARS 2
+#define IMX214_TEST_PATTERN_GREY_COLOR 3
+#define IMX214_TEST_PATTERN_PN9 4
+
+/* Test pattern colour components */
+#define IMX214_REG_TESTP_RED CCI_REG16(0x0602)
+#define IMX214_REG_TESTP_GREENR CCI_REG16(0x0604)
+#define IMX214_REG_TESTP_BLUE CCI_REG16(0x0606)
+#define IMX214_REG_TESTP_GREENB CCI_REG16(0x0608)
+#define IMX214_TESTP_COLOUR_MIN 0
+#define IMX214_TESTP_COLOUR_MAX 0x03ff
+#define IMX214_TESTP_COLOUR_STEP 1
+
/* IMX214 native and active pixel array size */
#define IMX214_NATIVE_WIDTH 4224U
#define IMX214_NATIVE_HEIGHT 3136U
@@ -209,6 +226,22 @@ static const u32 imx214_mbus_formats[] = {
MEDIA_BUS_FMT_SBGGR10_1X10,
};
+static const char * const imx214_test_pattern_menu[] = {
+ "Disabled",
+ "Color Bars",
+ "Solid Color",
+ "Grey Color Bars",
+ "PN9"
+};
+
+static const int imx214_test_pattern_val[] = {
+ IMX214_TEST_PATTERN_DISABLE,
+ IMX214_TEST_PATTERN_COLOR_BARS,
+ IMX214_TEST_PATTERN_SOLID_COLOR,
+ IMX214_TEST_PATTERN_GREY_COLOR,
+ IMX214_TEST_PATTERN_PN9,
+};
+
struct imx214 {
struct device *dev;
struct clk *xclk;
@@ -811,6 +844,26 @@ static int imx214_set_ctrl(struct v4l2_ctrl *ctrl)
cci_write(imx214->regmap, IMX214_REG_FRM_LENGTH_LINES,
format->height + ctrl->val, &ret);
break;
+ case V4L2_CID_TEST_PATTERN:
+ cci_write(imx214->regmap, IMX214_REG_TEST_PATTERN,
+ imx214_test_pattern_val[ctrl->val], &ret);
+ break;
+ case V4L2_CID_TEST_PATTERN_RED:
+ cci_write(imx214->regmap, IMX214_REG_TESTP_RED,
+ ctrl->val, &ret);
+ break;
+ case V4L2_CID_TEST_PATTERN_GREENR:
+ cci_write(imx214->regmap, IMX214_REG_TESTP_GREENR,
+ ctrl->val, &ret);
+ break;
+ case V4L2_CID_TEST_PATTERN_BLUE:
+ cci_write(imx214->regmap, IMX214_REG_TESTP_BLUE,
+ ctrl->val, &ret);
+ break;
+ case V4L2_CID_TEST_PATTERN_GREENB:
+ cci_write(imx214->regmap, IMX214_REG_TESTP_GREENB,
+ ctrl->val, &ret);
+ break;
default:
ret = -EINVAL;
}
@@ -838,14 +891,14 @@ static int imx214_ctrls_init(struct imx214 *imx214)
struct v4l2_ctrl_handler *ctrl_hdlr;
int exposure_max, exposure_def;
int hblank;
- int ret;
+ int i, ret;
ret = v4l2_fwnode_device_parse(imx214->dev, &props);
if (ret < 0)
return ret;
ctrl_hdlr = &imx214->ctrls;
- ret = v4l2_ctrl_handler_init(&imx214->ctrls, 12);
+ ret = v4l2_ctrl_handler_init(&imx214->ctrls, 13);
if (ret)
return ret;
@@ -914,6 +967,26 @@ static int imx214_ctrls_init(struct imx214 *imx214)
v4l2_ctrl_cluster(2, &imx214->hflip);
+ v4l2_ctrl_new_std_menu_items(ctrl_hdlr, &imx214_ctrl_ops,
+ V4L2_CID_TEST_PATTERN,
+ ARRAY_SIZE(imx214_test_pattern_menu) - 1,
+ 0, 0, imx214_test_pattern_menu);
+ for (i = 0; i < 4; i++) {
+ /*
+ * The assumption is that
+ * V4L2_CID_TEST_PATTERN_GREENR == V4L2_CID_TEST_PATTERN_RED + 1
+ * V4L2_CID_TEST_PATTERN_BLUE == V4L2_CID_TEST_PATTERN_RED + 2
+ * V4L2_CID_TEST_PATTERN_GREENB == V4L2_CID_TEST_PATTERN_RED + 3
+ */
+ v4l2_ctrl_new_std(ctrl_hdlr, &imx214_ctrl_ops,
+ V4L2_CID_TEST_PATTERN_RED + i,
+ IMX214_TESTP_COLOUR_MIN,
+ IMX214_TESTP_COLOUR_MAX,
+ IMX214_TESTP_COLOUR_STEP,
+ IMX214_TESTP_COLOUR_MAX);
+ /* The "Solid color" pattern is white by default */
+ }
+
imx214->unit_size = v4l2_ctrl_new_std_compound(ctrl_hdlr,
NULL,
V4L2_CID_UNIT_CELL_SIZE,
--
2.47.1
next prev parent reply other threads:[~2024-12-16 21:01 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-16 21:00 [PATCH v4 00/13] media: i2c: imx214: Miscellaneous cleanups and improvements André Apitzsch via B4 Relay
2024-12-16 21:00 ` [PATCH v4 01/13] media: i2c: imx214: Use subdev active state André Apitzsch via B4 Relay
2024-12-16 21:20 ` Ricardo Ribalda Delgado
2024-12-17 9:55 ` Sakari Ailus
2024-12-16 21:00 ` [PATCH v4 02/13] media: i2c: imx214: Simplify with dev_err_probe() André Apitzsch via B4 Relay
2024-12-16 21:00 ` [PATCH v4 03/13] media: i2c: imx214: Convert to CCI register access helpers André Apitzsch via B4 Relay
2024-12-16 21:00 ` [PATCH v4 04/13] media: i2c: imx214: Replace register addresses with macros André Apitzsch via B4 Relay
2024-12-16 21:00 ` [PATCH v4 05/13] media: i2c: imx214: Drop IMX214_REG_EXPOSURE from mode reg arrays André Apitzsch via B4 Relay
2024-12-16 21:00 ` [PATCH v4 06/13] media: i2c: imx214: Check number of lanes from device tree André Apitzsch via B4 Relay
2024-12-16 21:00 ` [PATCH v4 07/13] media: i2c: imx214: Add vblank and hblank controls André Apitzsch via B4 Relay
2024-12-16 21:00 ` [PATCH v4 08/13] media: i2c: imx214: Implement vflip/hflip controls André Apitzsch via B4 Relay
2024-12-16 21:00 ` [PATCH v4 09/13] media: i2c: imx214: Add analogue/digital gain control André Apitzsch via B4 Relay
2024-12-16 21:00 ` [PATCH v4 10/13] media: i2c: imx214: Verify chip ID André Apitzsch via B4 Relay
2024-12-16 21:00 ` André Apitzsch via B4 Relay [this message]
2024-12-16 21:00 ` [PATCH v4 12/13] media: i2c: imx214: Fix clock handling on probe error or remove André Apitzsch via B4 Relay
2024-12-16 21:00 ` [PATCH v4 13/13] media: i2c: imx214: Fix link frequency validation André Apitzsch via B4 Relay
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=20241216-imx214-v4-11-8cbda160fbce@apitzsch.eu \
--to=devnull+git.apitzsch.eu@kernel.org \
--cc=dave.stevenson@raspberrypi.com \
--cc=git@apitzsch.eu \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=phone-devel@vger.kernel.org \
--cc=ribalda@chromium.org \
--cc=ribalda@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=vincent.knecht@mailoo.org \
--cc=~postmarketos/upstreaming@lists.sr.ht \
/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
all inboxes | Powered by JetHome®