[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20241029062952.8534-1-tarang.raval@siliconsignals.io>
Date: Tue, 29 Oct 2024 11:59:16 +0530
From: Tarang Raval <tarang.raval@...iconsignals.io>
To: sakari.ailus@...ux.intel.com,
laurent.pinchart@...asonboard.com
Cc: Tarang Raval <tarang.raval@...iconsignals.io>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
linux-media@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v3] 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>
Reviewed-by: Laurent Pinchart <laurent.pinchart@...asonboard.com>
---
Change in V2:
- same entry for both the MT9P006 and MT9P031
- use enum mt9p031_model
Change in V3:
- Instead of using an index into an array, use separate structures
---
Sakari,this patch is on top of series "[PATCH v2 0/3] media: mt9p031: Drop
legacy platform data" provided by laurent
Link: https://lore.kernel.org/linux-media/20241028204443.22426-1-laurent.pinchart@ideasonboard.com/
Laurent, I dont think so but if a v3 version of that series is needed, you
could add these changes directly into the second patch of the series,
"[PATCH v2 2/3] media: i2c: mt9p031: Drop I2C device ID table." This would
simplify tracking for everyone.
---
drivers/media/i2c/mt9p031.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
index da1b90f03253..29af1df3ac46 100644
--- a/drivers/media/i2c/mt9p031.c
+++ b/drivers/media/i2c/mt9p031.c
@@ -111,6 +111,10 @@
#define MT9P031_TEST_PATTERN_RED 0xa2
#define MT9P031_TEST_PATTERN_BLUE 0xa3
+struct mt9p031_model_info {
+ u32 code;
+};
+
struct mt9p031 {
struct v4l2_subdev subdev;
struct media_pad pad;
@@ -1204,10 +1208,18 @@ static void mt9p031_remove(struct i2c_client *client)
mutex_destroy(&mt9p031->power_lock);
}
+static const struct mt9p031_model_info mt9p031_models_bayer = {
+ .code = MEDIA_BUS_FMT_SGRBG12_1X12
+};
+
+static const struct mt9p031_model_info mt9p031_models_mono = {
+ .code = MEDIA_BUS_FMT_Y12_1X12
+};
+
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_bayer },
+ { .compatible = "aptina,mt9p031", .data = &mt9p031_models_bayer },
+ { .compatible = "aptina,mt9p031m", .data = &mt9p031_models_mono },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, mt9p031_of_match);
--
2.43.0
Powered by blists - more mailing lists