From: Richard Leitner <richard.leitner@linux.dev>
To: Mauro Carvalho Chehab <mchehab@kernel.org>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Dave Stevenson <dave.stevenson@raspberrypi.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Hans de Goede <hansg@kernel.org>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Richard Leitner <richard.leitner@linux.dev>
Subject: [PATCH 1/2] media: v4l2-cci: Add support for custom regmap configuration
Date: Tue, 21 Jul 2026 15:25:28 +0200 [thread overview]
Message-ID: <20260721-cci-single-v1-1-8485171e1393@linux.dev> (raw)
In-Reply-To: <20260721-cci-single-v1-0-8485171e1393@linux.dev>
Some sensors, e.g. OV9282, require custom regmap configuration like setting
use_single_read. Therefore introduce a new custom cci configuration
struct, which exposes optional transport-specific regmap configuration for
I2C devices using the cci_*() register access helpers.
The existing devm_cci_regmap_init_i2c function is changed to use the
newly introduced devm_cci_regmap_init_i2c_cfg and its return value
documentation is fixed.
Signed-off-by: Richard Leitner <richard.leitner@linux.dev>
---
drivers/media/v4l2-core/v4l2-cci.c | 23 +++++++++++++++++++----
include/media/v4l2-cci.h | 37 ++++++++++++++++++++++++++++++++++++-
2 files changed, 55 insertions(+), 5 deletions(-)
diff --git a/drivers/media/v4l2-core/v4l2-cci.c b/drivers/media/v4l2-core/v4l2-cci.c
index e9ecf47859465..584ca080bc6e5 100644
--- a/drivers/media/v4l2-core/v4l2-cci.c
+++ b/drivers/media/v4l2-core/v4l2-cci.c
@@ -183,18 +183,33 @@ int cci_multi_reg_write(struct regmap *map, const struct cci_reg_sequence *regs,
EXPORT_SYMBOL_GPL(cci_multi_reg_write);
#if IS_ENABLED(CONFIG_V4L2_CCI_I2C)
-struct regmap *devm_cci_regmap_init_i2c(struct i2c_client *client,
- int reg_addr_bits)
+struct regmap *devm_cci_regmap_init_i2c_cfg(struct i2c_client *client,
+ const struct cci_regmap_config *cci_cfg)
{
- struct regmap_config config = {
- .reg_bits = reg_addr_bits,
+ const struct regmap_config config = {
+ .reg_bits = cci_cfg->reg_addr_bits,
.val_bits = 8,
.reg_format_endian = REGMAP_ENDIAN_BIG,
.disable_locking = true,
+ .use_single_read = cci_cfg->use_single_read,
+ .use_single_write = cci_cfg->use_single_write,
};
return devm_regmap_init_i2c(client, &config);
}
+EXPORT_SYMBOL_GPL(devm_cci_regmap_init_i2c_cfg);
+
+struct regmap *devm_cci_regmap_init_i2c(struct i2c_client *client,
+ int reg_addr_bits)
+{
+ const struct cci_regmap_config cci_cfg = {
+ .reg_addr_bits = reg_addr_bits,
+ .use_single_read = false,
+ .use_single_write = false,
+ };
+
+ return devm_cci_regmap_init_i2c_cfg(client, &cci_cfg);
+}
EXPORT_SYMBOL_GPL(devm_cci_regmap_init_i2c);
#endif
diff --git a/include/media/v4l2-cci.h b/include/media/v4l2-cci.h
index 4e96e90ee6369..8296a8c122b4d 100644
--- a/include/media/v4l2-cci.h
+++ b/include/media/v4l2-cci.h
@@ -27,6 +27,27 @@ struct cci_reg_sequence {
u64 val;
};
+/**
+ * struct cci_regmap_config - Optional configuration for CCI I2C regmap creation
+ *
+ * @reg_addr_bits: Number of bits in the register address.
+ * @use_single_read: Force single-register read transactions.
+ * @use_single_write: Force single-register write transactions.
+ *
+ * This structure describes optional transport-specific regmap configuration for
+ * I2C devices using the cci_*() register access helpers.
+ *
+ * The CCI helper initializes the underlying regmap with the CCI defaults:
+ * 16-bit or 8-bit register addresses as selected by @reg_addr_bits, 8-bit
+ * register values, big-endian register address formatting, and disabled
+ * regmap locking.
+ */
+struct cci_regmap_config {
+ int reg_addr_bits;
+ bool use_single_read;
+ bool use_single_write;
+};
+
/*
* Macros to define register address with the register width encoded
* into the higher bits.
@@ -123,6 +144,20 @@ int cci_multi_reg_write(struct regmap *map, const struct cci_reg_sequence *regs,
unsigned int num_regs, int *err);
#if IS_ENABLED(CONFIG_V4L2_CCI_I2C)
+/**
+ * devm_cci_regmap_init_i2c_cfg() - Create regmap with a custom config to use
+ * with cci_*() register access functions
+ *
+ * @client: i2c_client to create the regmap for
+ * @config: Configuration for CCI register map.
+ *
+ * Note the memory for the created regmap is devm() managed, tied to the client.
+ *
+ * Return: a pointer to the regmap on success, or an ERR_PTR() encoded error on failure.
+ */
+struct regmap *devm_cci_regmap_init_i2c_cfg(struct i2c_client *client,
+ const struct cci_regmap_config *config);
+
/**
* devm_cci_regmap_init_i2c() - Create regmap to use with cci_*() register
* access functions
@@ -132,7 +167,7 @@ int cci_multi_reg_write(struct regmap *map, const struct cci_reg_sequence *regs,
*
* Note the memory for the created regmap is devm() managed, tied to the client.
*
- * Return: %0 on success or a negative error code on failure.
+ * Return: a pointer to the regmap on success, or an ERR_PTR() encoded error on failure.
*/
struct regmap *devm_cci_regmap_init_i2c(struct i2c_client *client,
int reg_addr_bits);
--
2.53.0
next prev parent reply other threads:[~2026-07-21 13:25 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-21 13:25 [PATCH 0/2] media: v4l2-cci/ov9282: support single-read I2C transactions Richard Leitner
2026-07-21 13:25 ` Richard Leitner [this message]
2026-07-21 13:25 ` [PATCH 2/2] media: ov9282: enable " Richard Leitner
2026-07-21 13:38 ` Alexander Stein
2026-07-21 15:12 ` Laurent Pinchart
2026-07-21 15:15 ` Richard Leitner
2026-07-21 15:32 ` Laurent Pinchart
2026-07-21 15:57 ` Richard Leitner
2026-07-22 8:00 ` Alexander Stein
2026-07-21 13:39 ` Dave Stevenson
2026-07-21 15:16 ` Laurent Pinchart
2026-07-21 15:44 ` Richard Leitner
2026-07-21 15:58 ` Laurent Pinchart
2026-07-21 16:01 ` Richard Leitner
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=20260721-cci-single-v1-1-8485171e1393@linux.dev \
--to=richard.leitner@linux.dev \
--cc=dave.stevenson@raspberrypi.com \
--cc=hansg@kernel.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.intel.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.