Skip to content

Commit

Permalink
media: imx290: Add module parameter to allow selection of HCG mode
Browse files Browse the repository at this point in the history
The sensor has Low Conversion Gain (HCG) and High Conversion Gain (HCG)
modes, with the supposedly the HCG mode having better noise performance
at high gains.

As this parameter changes the gain range of the sensor, it isn't
possible to make this an automatic property, and there is no
suitable V4L2 control to set it, so just add it as a module parameter.

Signed-off-by: Dave Stevenson <[email protected]>
  • Loading branch information
6by9 committed Oct 19, 2024
1 parent 527d6f5 commit 2040a7c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion drivers/media/i2c/imx290.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/of.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
Expand Down Expand Up @@ -41,6 +42,9 @@
#define IMX290_WINMODE_720P (1 << 4)
#define IMX290_WINMODE_CROP (4 << 4)
#define IMX290_FR_FDG_SEL CCI_REG8(0x3009)
#define IMX290_FDG_HCG BIT(4)
#define IMX290_FRSEL_60FPS BIT(0)
#define IMX290_FDG_LCG 0
#define IMX290_BLKLEVEL CCI_REG16_LE(0x300a)
#define IMX290_GAIN CCI_REG8(0x3014)
#define IMX290_VMAX CCI_REG24_LE(0x3018)
Expand Down Expand Up @@ -162,6 +166,10 @@

#define IMX290_NUM_SUPPLIES 3

static bool hcg_mode;
module_param(hcg_mode, bool, 0664);
MODULE_PARM_DESC(hcg_mode, "Enable HCG mode");

enum imx290_colour_variant {
IMX290_VARIANT_COLOUR,
IMX290_VARIANT_MONO,
Expand Down Expand Up @@ -649,7 +657,6 @@ static int imx290_set_data_lanes(struct imx290 *imx290)
&ret);
cci_write(imx290->regmap, IMX290_CSI_LANE_MODE, imx290->nlanes - 1,
&ret);
cci_write(imx290->regmap, IMX290_FR_FDG_SEL, 0x01, &ret);

return ret;
}
Expand Down Expand Up @@ -763,6 +770,10 @@ static int imx290_set_ctrl(struct v4l2_ctrl *ctrl)
switch (ctrl->id) {
case V4L2_CID_ANALOGUE_GAIN:
ret = cci_write(imx290->regmap, IMX290_GAIN, ctrl->val, NULL);

cci_write(imx290->regmap, IMX290_FR_FDG_SEL,
IMX290_FRSEL_60FPS | hcg_mode ?
IMX290_FDG_HCG : IMX290_FDG_LCG, &ret);
break;

case V4L2_CID_VBLANK:
Expand Down

0 comments on commit 2040a7c

Please sign in to comment.