Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IMX500: Add support for rotation and image flip #6584

Open
wants to merge 2 commits into
base: rpi-6.6.y
Choose a base branch
from

Conversation

katsuykk
Copy link

@katsuykk katsuykk commented Jan 7, 2025

This PR adds support for rotation and image flip functionality for the IMX500.

Rotation Support

  • 0: 0 degrees
  • 1: 90 degrees
  • 2: 180 degrees
  • 3: 270 degrees

Image Flip Support

  • 0: No flip
  • 1: Flip horizontal
  • 2: Flip vertical
  • 3: Flip horizontal and vertical

Adds rotation support for the IMX500. Supported angles:
- 0: 0 degrees
- 1: 90 degrees
- 2: 180 degrees
- 3: 270 degrees

Signed-off-by: Katsu Nakamura <[email protected]>
Adds image flip support for IMX500. Supported modes:

0: No flip
1: Flip horizontal
2: Flip vertical
3: Flip horizontal and vertical

Signed-off-by: Katsu Nakamura <[email protected]>
Copy link
Contributor

@6by9 6by9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flips patch looks like a straight NAK as flips are already implemented via V4L2_CID_HFLIP and V4L2_CID_VFLIP. There is no need for a custom control that would conflict with that.

Questions over implementing rotation.

@@ -235,6 +238,7 @@ enum pad_types { IMAGE_PAD, METADATA_PAD, NUM_PADS };

#define V4L2_CID_USER_IMX500_INFERENCE_WINDOW (V4L2_CID_USER_IMX500_BASE + 0)
#define V4L2_CID_USER_IMX500_NETWORK_FW_FD (V4L2_CID_USER_IMX500_BASE + 1)
#define V4L2_CID_USER_IMX500_ROTATION (V4L2_CID_USER_IMX500_BASE + 2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this need to be a custom control rather than V4L2_CID_ROTATE? (Documented in https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/control.html)

How does this affect the resolution of the output image? Normally you'd rotate the 4056x3040 image to give a 3040x4056 output, so the output format needs to change.

.id = V4L2_CID_USER_IMX500_ROTATION,
.ops = &imx500_ctrl_ops,
.type = V4L2_CTRL_TYPE_INTEGER,
.flags = V4L2_CTRL_FLAG_EXECUTE_ON_WRITE,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really need to rewrite the register even if setting it to the same value?

@@ -217,6 +217,9 @@
/* Rotate angle */
#define IMX500_REG_ADDR_ROTATION CCI_REG8(0xD680)

/* Flip vertical/horizontal */
#define IMX500_REG_ADDR_IMG_ORIENTATION CCI_REG8(0x0101)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already defined and used as IMX500_REG_ORIENTATION

@@ -239,6 +242,7 @@ enum pad_types { IMAGE_PAD, METADATA_PAD, NUM_PADS };
#define V4L2_CID_USER_IMX500_INFERENCE_WINDOW (V4L2_CID_USER_IMX500_BASE + 0)
#define V4L2_CID_USER_IMX500_NETWORK_FW_FD (V4L2_CID_USER_IMX500_BASE + 1)
#define V4L2_CID_USER_IMX500_ROTATION (V4L2_CID_USER_IMX500_BASE + 2)
#define V4L2_CID_USER_IMX500_IMG_FLIP (V4L2_CID_USER_IMX500_BASE + 3)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again why a custom control? V4L2_CID_HFLIP and V4L2_CIF_VFLIP exist and are already implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants