Skip to content

Commit 020f602

Browse files
bingbucaohverkuil
authored andcommitted
media: hi556: correct the test pattern configuration
Hynix hi556 support 8 test pattern modes: hi556_test_pattern_menu[] = { { "Disabled", "Solid Colour", "100% Colour Bars", "Fade To Grey Colour Bars", "PN9", "Gradient Horizontal", "Gradient Vertical", "Check Board", "Slant Pattern", } The test pattern is set by a 8-bit register according to the specification. +--------+-------------------------------+ | BIT[0] | Solid color | +--------+-------------------------------+ | BIT[1] | Color bar | +--------+-------------------------------+ | BIT[2] | Fade to grey color bar | +--------+-------------------------------+ | BIT[3] | PN9 | +--------+-------------------------------+ | BIT[4] | Gradient horizontal | +--------+-------------------------------+ | BIT[5] | Gradient vertical | +--------+-------------------------------+ | BIT[6] | Check board | +--------+-------------------------------+ | BIT[7] | Slant pattern | +--------+-------------------------------+ Based on function above, current test pattern programming is wrong. This patch fixes it by 'BIT(pattern - 1)'. If pattern is 0, driver will disable the test pattern generation and set the pattern to 0. Fixes: e621384 ("media: hi556: Add support for Hi-556 sensor") Cc: [email protected] Signed-off-by: Bingbu Cao <[email protected]> Signed-off-by: Sakari Ailus <[email protected]> Signed-off-by: Hans Verkuil <[email protected]>
1 parent 871a99f commit 020f602

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

drivers/media/i2c/hi556.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -762,21 +762,23 @@ static int hi556_test_pattern(struct hi556 *hi556, u32 pattern)
762762
int ret;
763763
u32 val;
764764

765-
if (pattern) {
766-
ret = hi556_read_reg(hi556, HI556_REG_ISP,
767-
HI556_REG_VALUE_08BIT, &val);
768-
if (ret)
769-
return ret;
765+
ret = hi556_read_reg(hi556, HI556_REG_ISP,
766+
HI556_REG_VALUE_08BIT, &val);
767+
if (ret)
768+
return ret;
770769

771-
ret = hi556_write_reg(hi556, HI556_REG_ISP,
772-
HI556_REG_VALUE_08BIT,
773-
val | HI556_REG_ISP_TPG_EN);
774-
if (ret)
775-
return ret;
776-
}
770+
val = pattern ? (val | HI556_REG_ISP_TPG_EN) :
771+
(val & ~HI556_REG_ISP_TPG_EN);
772+
773+
ret = hi556_write_reg(hi556, HI556_REG_ISP,
774+
HI556_REG_VALUE_08BIT, val);
775+
if (ret)
776+
return ret;
777+
778+
val = pattern ? BIT(pattern - 1) : 0;
777779

778780
return hi556_write_reg(hi556, HI556_REG_TEST_PATTERN,
779-
HI556_REG_VALUE_08BIT, pattern);
781+
HI556_REG_VALUE_08BIT, val);
780782
}
781783

782784
static int hi556_set_ctrl(struct v4l2_ctrl *ctrl)

0 commit comments

Comments
 (0)