linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] media: ov02c10: fix orientation on Thinkpad T14s Gen6 (Snapdragon)
@ 2025-08-20  0:13 Sebastian Reichel
  2025-08-20  0:13 ` [PATCH 1/2] media: ov02c10: Fix default vertical flip Sebastian Reichel
  2025-08-20  0:13 ` [PATCH 2/2] media: ov02c10: Support hflip and vflip Sebastian Reichel
  0 siblings, 2 replies; 5+ messages in thread
From: Sebastian Reichel @ 2025-08-20  0:13 UTC (permalink / raw)
  To: Hans de Goede, Bryan O'Donoghue, Sakari Ailus,
	Mauro Carvalho Chehab, Heimir Thor Sverrisson, Hans Verkuil
  Cc: Frederic Stuyk, linux-media, linux-kernel, Sebastian Reichel

When testing the camera patches for Snapdragon X1E I noticed the
image is upside-down on my T14s Gen6. After some investigation
it looks like issues with the sensor driver have recently been
reported, but not yet been fixed. It seems sensible to do this
ASAP (while the driver is not yet used much) to avoid potential
regressions when changing the VFLIP default.

P.S.: I accidentally sent this from my private mail address first
and apparently the server address was listed by spamhaus.org (whole
subnet). It does not look like anything came through due to this,
so I'm resending as v1 from my kernel.org account. Sorry if anyone
received multiple copies now :)

Signed-off-by: Sebastian Reichel <sre@kernel.org>
---
Sebastian Reichel (2):
      media: ov02c10: Fix default vertical flip
      media: ov02c10: Support hflip and vflip

 drivers/media/i2c/ov02c10.c | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)
---
base-commit: 8f5ae30d69d7543eee0d70083daf4de8fe15d585
change-id: 20250817-ov02c10-fix-c682031a454a

Best regards,
-- 
Sebastian Reichel <sre@kernel.org>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] media: ov02c10: Fix default vertical flip
  2025-08-20  0:13 [PATCH 0/2] media: ov02c10: fix orientation on Thinkpad T14s Gen6 (Snapdragon) Sebastian Reichel
@ 2025-08-20  0:13 ` Sebastian Reichel
  2025-08-21  8:31   ` Bryan O'Donoghue
  2025-08-20  0:13 ` [PATCH 2/2] media: ov02c10: Support hflip and vflip Sebastian Reichel
  1 sibling, 1 reply; 5+ messages in thread
From: Sebastian Reichel @ 2025-08-20  0:13 UTC (permalink / raw)
  To: Hans de Goede, Bryan O'Donoghue, Sakari Ailus,
	Mauro Carvalho Chehab, Heimir Thor Sverrisson, Hans Verkuil
  Cc: Frederic Stuyk, linux-media, linux-kernel, Sebastian Reichel

The driver right now defaults to setting the vertical flip bit. This
conflicts with proper handling of the rotation property defined in
ACPI or device tree, so drop the VFLIP bit. It should be handled via
V4L2_CID_VFLIP instead.

Reported-by: Frederic Stuyk <fstuyk@runbox.com>
Closes: https://lore.kernel.org/all/b6df9ae7-ea9f-4e5a-8065-5b130f534f37@runbox.com/
Fixes: 44f89010dae0 ("media: i2c: Add Omnivision OV02C10 sensor driver")
Signed-off-by: Sebastian Reichel <sre@kernel.org>
---
 drivers/media/i2c/ov02c10.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/ov02c10.c b/drivers/media/i2c/ov02c10.c
index 089a4fd9627cf6c13efa65c104caeac370b53bc0..3a02fce0a9bc0ca3ab87defe3eefd04efb4012e7 100644
--- a/drivers/media/i2c/ov02c10.c
+++ b/drivers/media/i2c/ov02c10.c
@@ -175,7 +175,7 @@ static const struct reg_sequence sensor_1928x1092_30fps_setting[] = {
 	{0x3816, 0x01},
 	{0x3817, 0x01},
 
-	{0x3820, 0xb0},
+	{0x3820, 0xa0},
 	{0x3821, 0x00},
 	{0x3822, 0x80},
 	{0x3823, 0x08},

-- 
2.50.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] media: ov02c10: Support hflip and vflip
  2025-08-20  0:13 [PATCH 0/2] media: ov02c10: fix orientation on Thinkpad T14s Gen6 (Snapdragon) Sebastian Reichel
  2025-08-20  0:13 ` [PATCH 1/2] media: ov02c10: Fix default vertical flip Sebastian Reichel
@ 2025-08-20  0:13 ` Sebastian Reichel
  2025-08-21  8:33   ` Bryan O'Donoghue
  1 sibling, 1 reply; 5+ messages in thread
From: Sebastian Reichel @ 2025-08-20  0:13 UTC (permalink / raw)
  To: Hans de Goede, Bryan O'Donoghue, Sakari Ailus,
	Mauro Carvalho Chehab, Heimir Thor Sverrisson, Hans Verkuil
  Cc: Frederic Stuyk, linux-media, linux-kernel, Sebastian Reichel

Support horizontal and vertical flip, which is necessary to handle
upside-down mounted sensors.

Suggested-by: Bryan O'Donoghue <bod@kernel.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
---
 drivers/media/i2c/ov02c10.c | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/ov02c10.c b/drivers/media/i2c/ov02c10.c
index 3a02fce0a9bc0ca3ab87defe3eefd04efb4012e7..103d007415348a8bd31a09e518de23f5fd77c618 100644
--- a/drivers/media/i2c/ov02c10.c
+++ b/drivers/media/i2c/ov02c10.c
@@ -384,6 +384,8 @@ struct ov02c10 {
 	struct v4l2_ctrl *vblank;
 	struct v4l2_ctrl *hblank;
 	struct v4l2_ctrl *exposure;
+	struct v4l2_ctrl *hflip;
+	struct v4l2_ctrl *vflip;
 
 	struct clk *img_clk;
 	struct gpio_desc *reset;
@@ -462,6 +464,16 @@ static int ov02c10_set_ctrl(struct v4l2_ctrl *ctrl)
 		ret = ov02c10_test_pattern(ov02c10, ctrl->val);
 		break;
 
+	case V4L2_CID_HFLIP:
+		cci_update_bits(ov02c10->regmap, OV02C10_ROTATE_CONTROL,
+				BIT(3), ov02c10->hflip->val << 3, &ret);
+		break;
+
+	case V4L2_CID_VFLIP:
+		cci_update_bits(ov02c10->regmap, OV02C10_ROTATE_CONTROL,
+				BIT(4), ov02c10->vflip->val << 4, &ret);
+		break;
+
 	default:
 		ret = -EINVAL;
 		break;
@@ -486,7 +498,7 @@ static int ov02c10_init_controls(struct ov02c10 *ov02c10)
 	s64 exposure_max, h_blank, pixel_rate;
 	int ret;
 
-	v4l2_ctrl_handler_init(ctrl_hdlr, 10);
+	v4l2_ctrl_handler_init(ctrl_hdlr, 12);
 
 	ov02c10->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr,
 						    &ov02c10_ctrl_ops,
@@ -537,6 +549,17 @@ static int ov02c10_init_controls(struct ov02c10 *ov02c10)
 					      exposure_max,
 					      OV02C10_EXPOSURE_STEP,
 					      exposure_max);
+
+	ov02c10->hflip = v4l2_ctrl_new_std(ctrl_hdlr, &ov02c10_ctrl_ops,
+					   V4L2_CID_HFLIP, 0, 1, 1, 0);
+	if (ov02c10->hflip)
+		ov02c10->hflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT;
+
+	ov02c10->vflip = v4l2_ctrl_new_std(ctrl_hdlr, &ov02c10_ctrl_ops,
+					   V4L2_CID_VFLIP, 0, 1, 1, 0);
+	if (ov02c10->vflip)
+		ov02c10->vflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT;
+
 	v4l2_ctrl_new_std_menu_items(ctrl_hdlr, &ov02c10_ctrl_ops,
 				     V4L2_CID_TEST_PATTERN,
 				     ARRAY_SIZE(ov02c10_test_pattern_menu) - 1,

-- 
2.50.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] media: ov02c10: Fix default vertical flip
  2025-08-20  0:13 ` [PATCH 1/2] media: ov02c10: Fix default vertical flip Sebastian Reichel
@ 2025-08-21  8:31   ` Bryan O'Donoghue
  0 siblings, 0 replies; 5+ messages in thread
From: Bryan O'Donoghue @ 2025-08-21  8:31 UTC (permalink / raw)
  To: Sebastian Reichel, Hans de Goede, Sakari Ailus,
	Mauro Carvalho Chehab, Heimir Thor Sverrisson, Hans Verkuil
  Cc: Frederic Stuyk, linux-media, linux-kernel

On 20/08/2025 01:13, Sebastian Reichel wrote:
> The driver right now defaults to setting the vertical flip bit. This
> conflicts with proper handling of the rotation property defined in
> ACPI or device tree, so drop the VFLIP bit. It should be handled via
> V4L2_CID_VFLIP instead.
> 
> Reported-by: Frederic Stuyk <fstuyk@runbox.com>
> Closes: https://lore.kernel.org/all/b6df9ae7-ea9f-4e5a-8065-5b130f534f37@runbox.com/
> Fixes: 44f89010dae0 ("media: i2c: Add Omnivision OV02C10 sensor driver")
> Signed-off-by: Sebastian Reichel <sre@kernel.org>
> ---
>   drivers/media/i2c/ov02c10.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/i2c/ov02c10.c b/drivers/media/i2c/ov02c10.c
> index 089a4fd9627cf6c13efa65c104caeac370b53bc0..3a02fce0a9bc0ca3ab87defe3eefd04efb4012e7 100644
> --- a/drivers/media/i2c/ov02c10.c
> +++ b/drivers/media/i2c/ov02c10.c
> @@ -175,7 +175,7 @@ static const struct reg_sequence sensor_1928x1092_30fps_setting[] = {
>   	{0x3816, 0x01},
>   	{0x3817, 0x01},
> 
> -	{0x3820, 0xb0},
> +	{0x3820, 0xa0},
>   	{0x3821, 0x00},
>   	{0x3822, 0x80},
>   	{0x3823, 0x08},
> 
> --
> 2.50.1
> 
Reviewed-by: Bryan O'Donoghue <bod@kernel.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] media: ov02c10: Support hflip and vflip
  2025-08-20  0:13 ` [PATCH 2/2] media: ov02c10: Support hflip and vflip Sebastian Reichel
@ 2025-08-21  8:33   ` Bryan O'Donoghue
  0 siblings, 0 replies; 5+ messages in thread
From: Bryan O'Donoghue @ 2025-08-21  8:33 UTC (permalink / raw)
  To: Sebastian Reichel, Hans de Goede, Sakari Ailus,
	Mauro Carvalho Chehab, Heimir Thor Sverrisson, Hans Verkuil
  Cc: Frederic Stuyk, linux-media, linux-kernel

On 20/08/2025 01:13, Sebastian Reichel wrote:
> Support horizontal and vertical flip, which is necessary to handle
> upside-down mounted sensors.
> 
> Suggested-by: Bryan O'Donoghue <bod@kernel.org>
> Signed-off-by: Sebastian Reichel <sre@kernel.org>
> ---
>   drivers/media/i2c/ov02c10.c | 25 ++++++++++++++++++++++++-
>   1 file changed, 24 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/i2c/ov02c10.c b/drivers/media/i2c/ov02c10.c
> index 3a02fce0a9bc0ca3ab87defe3eefd04efb4012e7..103d007415348a8bd31a09e518de23f5fd77c618 100644
> --- a/drivers/media/i2c/ov02c10.c
> +++ b/drivers/media/i2c/ov02c10.c
> @@ -384,6 +384,8 @@ struct ov02c10 {
>   	struct v4l2_ctrl *vblank;
>   	struct v4l2_ctrl *hblank;
>   	struct v4l2_ctrl *exposure;
> +	struct v4l2_ctrl *hflip;
> +	struct v4l2_ctrl *vflip;
> 
>   	struct clk *img_clk;
>   	struct gpio_desc *reset;
> @@ -462,6 +464,16 @@ static int ov02c10_set_ctrl(struct v4l2_ctrl *ctrl)
>   		ret = ov02c10_test_pattern(ov02c10, ctrl->val);
>   		break;
> 
> +	case V4L2_CID_HFLIP:
> +		cci_update_bits(ov02c10->regmap, OV02C10_ROTATE_CONTROL,
> +				BIT(3), ov02c10->hflip->val << 3, &ret);
> +		break;
> +
> +	case V4L2_CID_VFLIP:
> +		cci_update_bits(ov02c10->regmap, OV02C10_ROTATE_CONTROL,
> +				BIT(4), ov02c10->vflip->val << 4, &ret);
> +		break;
> +
>   	default:
>   		ret = -EINVAL;
>   		break;
> @@ -486,7 +498,7 @@ static int ov02c10_init_controls(struct ov02c10 *ov02c10)
>   	s64 exposure_max, h_blank, pixel_rate;
>   	int ret;
> 
> -	v4l2_ctrl_handler_init(ctrl_hdlr, 10);
> +	v4l2_ctrl_handler_init(ctrl_hdlr, 12);
> 
>   	ov02c10->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr,
>   						    &ov02c10_ctrl_ops,
> @@ -537,6 +549,17 @@ static int ov02c10_init_controls(struct ov02c10 *ov02c10)
>   					      exposure_max,
>   					      OV02C10_EXPOSURE_STEP,
>   					      exposure_max);
> +
> +	ov02c10->hflip = v4l2_ctrl_new_std(ctrl_hdlr, &ov02c10_ctrl_ops,
> +					   V4L2_CID_HFLIP, 0, 1, 1, 0);
> +	if (ov02c10->hflip)
> +		ov02c10->hflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT;
> +
> +	ov02c10->vflip = v4l2_ctrl_new_std(ctrl_hdlr, &ov02c10_ctrl_ops,
> +					   V4L2_CID_VFLIP, 0, 1, 1, 0);
> +	if (ov02c10->vflip)
> +		ov02c10->vflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT;
> +
>   	v4l2_ctrl_new_std_menu_items(ctrl_hdlr, &ov02c10_ctrl_ops,
>   				     V4L2_CID_TEST_PATTERN,
>   				     ARRAY_SIZE(ov02c10_test_pattern_menu) - 1,
> 
> --
> 2.50.1
> 
Reviewed-by: Bryan O'Donoghue <bod@kernel.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-08-21  8:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-20  0:13 [PATCH 0/2] media: ov02c10: fix orientation on Thinkpad T14s Gen6 (Snapdragon) Sebastian Reichel
2025-08-20  0:13 ` [PATCH 1/2] media: ov02c10: Fix default vertical flip Sebastian Reichel
2025-08-21  8:31   ` Bryan O'Donoghue
2025-08-20  0:13 ` [PATCH 2/2] media: ov02c10: Support hflip and vflip Sebastian Reichel
2025-08-21  8:33   ` Bryan O'Donoghue

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).