Skip to content

Commit 5cae9cc

Browse files
drivers: media: imx708: Adjust broken line correction parameter
In full-resolution mode, the LPF_INTENSITY_EN and LPF_INTENSITY registers control Quad Bayer Re-mosaic broken line correction. Expose this as a module parameter "qbc_adjust": zero disables the correction and values in the range 2 to 5 set its strength. There is a trade-off between coloured and monochrome patterns. The previous fixed value 4 could produce ladder/spots artefacts in coloured textures. The new default value 2 may suit a wider range of scenes. Signed-off-by: Nick Hollinghurst <[email protected]>
1 parent 686fe77 commit 5cae9cc

File tree

1 file changed

+42
-8
lines changed

1 file changed

+42
-8
lines changed

drivers/media/i2c/imx708.c

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@
2020
#include <media/v4l2-fwnode.h>
2121
#include <media/v4l2-mediabus.h>
2222

23+
/*
24+
* Parameter to adjust Quad Bayer re-mosaic broken line correction
25+
* strength, used in full-resolution mode only. Set zero to disable.
26+
*/
27+
static int qbc_adjust = 2;
28+
module_param(qbc_adjust, int, 0644);
29+
MODULE_PARM_DESC(qbc_adjust, "Quad Bayer broken line correction strength [0,2-5]");
30+
2331
#define IMX708_REG_VALUE_08BIT 1
2432
#define IMX708_REG_VALUE_16BIT 2
2533

@@ -99,11 +107,17 @@
99107

100108
/* HDR exposure ratio (long:med == med:short) */
101109
#define IMX708_HDR_EXPOSURE_RATIO 4
102-
#define IMX708_REG_MID_EXPOSURE 0x3116
103-
#define IMX708_REG_SHT_EXPOSURE 0x0224
110+
#define IMX708_REG_MID_EXPOSURE 0x3116
111+
#define IMX708_REG_SHT_EXPOSURE 0x0224
104112
#define IMX708_REG_MID_ANALOG_GAIN 0x3118
105113
#define IMX708_REG_SHT_ANALOG_GAIN 0x0216
106114

115+
/* QBC Re-mosaic broken line correction registers */
116+
#define IMX708_LPF_INTENSITY_EN 0xC428
117+
#define IMX708_LPF_INTENSITY_ENABLED 0x00
118+
#define IMX708_LPF_INTENSITY_DISABLED 0x01
119+
#define IMX708_LPF_INTENSITY 0xC429
120+
107121
/*
108122
* Metadata buffer holds a variety of data, all sent with the same VC/DT (0x12).
109123
* It comprises two scanlines (of up to 5760 bytes each, for 4608 pixels)
@@ -171,6 +185,9 @@ struct imx708_mode {
171185

172186
/* HDR flag, used for checking if the current mode is HDR */
173187
bool hdr;
188+
189+
/* Quad Bayer Re-mosaic flag */
190+
bool remosaic;
174191
};
175192

176193
/* Default PDAF pixel correction gains */
@@ -363,8 +380,6 @@ static const struct imx708_reg mode_4608x2592_regs[] = {
363380
{0x341f, 0x20},
364381
{0x3420, 0x00},
365382
{0x3421, 0xd8},
366-
{0xC428, 0x00},
367-
{0xC429, 0x04},
368383
{0x3366, 0x00},
369384
{0x3367, 0x00},
370385
{0x3368, 0x00},
@@ -677,7 +692,8 @@ static const struct imx708_mode supported_modes_10bit_no_hdr[] = {
677692
.pixel_rate = 595200000,
678693
.exposure_lines_min = 8,
679694
.exposure_lines_step = 1,
680-
.hdr = false
695+
.hdr = false,
696+
.remosaic = true
681697
},
682698
{
683699
/* regular 2x2 binned. */
@@ -699,7 +715,8 @@ static const struct imx708_mode supported_modes_10bit_no_hdr[] = {
699715
.pixel_rate = 585600000,
700716
.exposure_lines_min = 4,
701717
.exposure_lines_step = 2,
702-
.hdr = false
718+
.hdr = false,
719+
.remosaic = false
703720
},
704721
{
705722
/* 2x2 binned and cropped for 720p. */
@@ -721,7 +738,8 @@ static const struct imx708_mode supported_modes_10bit_no_hdr[] = {
721738
.pixel_rate = 566400000,
722739
.exposure_lines_min = 4,
723740
.exposure_lines_step = 2,
724-
.hdr = false
741+
.hdr = false,
742+
.remosaic = false
725743
},
726744
};
727745

@@ -746,7 +764,8 @@ static const struct imx708_mode supported_modes_10bit_hdr[] = {
746764
.pixel_rate = 777600000,
747765
.exposure_lines_min = 8 * IMX708_HDR_EXPOSURE_RATIO * IMX708_HDR_EXPOSURE_RATIO,
748766
.exposure_lines_step = 2 * IMX708_HDR_EXPOSURE_RATIO * IMX708_HDR_EXPOSURE_RATIO,
749-
.hdr = true
767+
.hdr = true,
768+
.remosaic = false
750769
}
751770
};
752771

@@ -1515,6 +1534,21 @@ static int imx708_start_streaming(struct imx708 *imx708)
15151534
return ret;
15161535
}
15171536

1537+
/* Quad Bayer re-mosaic adjustments (for full-resolution mode only) */
1538+
if (imx708->mode->remosaic && qbc_adjust > 0) {
1539+
imx708_write_reg(imx708, IMX708_LPF_INTENSITY,
1540+
IMX708_REG_VALUE_08BIT, qbc_adjust);
1541+
imx708_write_reg(imx708,
1542+
IMX708_LPF_INTENSITY_EN,
1543+
IMX708_REG_VALUE_08BIT,
1544+
IMX708_LPF_INTENSITY_ENABLED);
1545+
} else {
1546+
imx708_write_reg(imx708,
1547+
IMX708_LPF_INTENSITY_EN,
1548+
IMX708_REG_VALUE_08BIT,
1549+
IMX708_LPF_INTENSITY_DISABLED);
1550+
}
1551+
15181552
/* Apply customized values from user */
15191553
ret = __v4l2_ctrl_handler_setup(imx708->sd.ctrl_handler);
15201554
if (ret)

0 commit comments

Comments
 (0)