[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241025221638.127457-1-tarang.raval@siliconsignals.io>
Date: Sat, 26 Oct 2024 03:45:40 +0530
From: Tarang Raval <tarang.raval@...iconsignals.io>
To: laurent.pinchart@...asonboard.com
Cc: Tarang Raval <tarang.raval@...iconsignals.io>,
Sakari Ailus <sakari.ailus@...ux.intel.com>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
linux-media@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v2] media: mt9p031: Refactor format handling for different sensor models
Add new structure 'mt9p031_model_info' to encapsulate format codes for
the mt9p031 camera sensor family. This approach enhances code clarity
and maintainability.
Signed-off-by: Tarang Raval <tarang.raval@...iconsignals.io>
---
drivers/media/i2c/mt9p031.c | 31 ++++++++++++++++++++++++++++---
1 file changed, 28 insertions(+), 3 deletions(-)
diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
index f2f52f484044..3576d3066738 100644
--- a/drivers/media/i2c/mt9p031.c
+++ b/drivers/media/i2c/mt9p031.c
@@ -112,6 +112,24 @@
#define MT9P031_TEST_PATTERN_RED 0xa2
#define MT9P031_TEST_PATTERN_BLUE 0xa3
+struct mt9p031_model_info {
+ u32 code;
+};
+
+enum mt9p031_model {
+ MT9P031_MODEL_BAYER,
+ MT9P031_MODEL_MONO,
+};
+
+static const struct mt9p031_model_info mt9p031_models[] = {
+ [MT9P031_MODEL_BAYER] = {
+ .code = MEDIA_BUS_FMT_SGRBG12_1X12,
+ },
+ [MT9P031_MODEL_MONO] = {
+ .code = MEDIA_BUS_FMT_Y12_1X12,
+ },
+};
+
struct mt9p031 {
struct v4l2_subdev subdev;
struct media_pad pad;
@@ -1209,9 +1227,16 @@ static void mt9p031_remove(struct i2c_client *client)
}
static const struct of_device_id mt9p031_of_match[] = {
- { .compatible = "aptina,mt9p006", .data = (void *)MEDIA_BUS_FMT_SGRBG12_1X12 },
- { .compatible = "aptina,mt9p031", .data = (void *)MEDIA_BUS_FMT_SGRBG12_1X12 },
- { .compatible = "aptina,mt9p031m", .data = (void *)MEDIA_BUS_FMT_Y12_1X12 },
+ {
+ .compatible = "aptina,mt9p006",
+ .data = &mt9p031_models[MT9P031_MODEL_BAYER]
+ }, {
+ .compatible = "aptina,mt9p031",
+ .data = &mt9p031_models[MT9P031_MODEL_BAYER]
+ }, {
+ .compatible = "aptina,mt9p031m",
+ .data = &mt9p031_models[MT9P031_MODEL_MONO]
+ },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, mt9p031_of_match);
--
2.43.0
Powered by blists - more mailing lists