-
Notifications
You must be signed in to change notification settings - Fork 5.2k
IMX500: Add support for rotation and image flip #6584
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
Open
katsuykk
wants to merge
2
commits into
raspberrypi:rpi-6.6.y
Choose a base branch
from
midokura:imx500-rotate-flip
base: rpi-6.6.y
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -214,6 +214,9 @@ | |
#define IMX500_COLOUR_BALANCE_STEP 0x0001 | ||
#define IMX500_COLOUR_BALANCE_DEFAULT 0x0100 | ||
|
||
/* Rotate angle */ | ||
#define IMX500_REG_ADDR_ROTATION CCI_REG8(0xD680) | ||
|
||
/* Embedded sizes */ | ||
#define IMX500_MAX_EMBEDDED_SIZE \ | ||
(2 * ((((IMX500_PIXEL_ARRAY_WIDTH * 10) >> 3) + 15) & ~15)) | ||
|
@@ -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) | ||
|
||
#define ONE_MIB (1024 * 1024) | ||
|
||
|
@@ -1974,6 +1978,9 @@ static int imx500_set_ctrl(struct v4l2_ctrl *ctrl) | |
sizeof(struct v4l2_rect)); | ||
ret = imx500_set_inference_window(imx500); | ||
break; | ||
case V4L2_CID_USER_IMX500_ROTATION: | ||
ret = cci_write(imx500->regmap, IMX500_REG_ADDR_ROTATION, ctrl->val, NULL); | ||
break; | ||
default: | ||
dev_info(&client->dev, | ||
"ctrl(id:0x%x,val:0x%x) is not handled\n", ctrl->id, | ||
|
@@ -2828,6 +2835,19 @@ static const struct v4l2_ctrl_config network_fw_fd = { | |
.def = -1, | ||
}; | ||
|
||
/* Custom control for rotation angle */ | ||
static const struct v4l2_ctrl_config rotation_angle = { | ||
.name = "IMX500 Rotation Angle", | ||
.id = V4L2_CID_USER_IMX500_ROTATION, | ||
.ops = &imx500_ctrl_ops, | ||
.type = V4L2_CTRL_TYPE_INTEGER, | ||
.flags = V4L2_CTRL_FLAG_EXECUTE_ON_WRITE, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
.min = 0, | ||
.max = 3, | ||
.step = 1, | ||
.def = 0, | ||
}; | ||
|
||
/* Initialize control handlers */ | ||
static int imx500_init_controls(struct imx500 *imx500) | ||
{ | ||
|
@@ -2891,6 +2911,7 @@ static int imx500_init_controls(struct imx500 *imx500) | |
v4l2_ctrl_new_custom(ctrl_hdlr, &inf_window_ctrl, NULL); | ||
imx500->network_fw_ctrl = | ||
v4l2_ctrl_new_custom(ctrl_hdlr, &network_fw_fd, NULL); | ||
v4l2_ctrl_new_custom(ctrl_hdlr, &rotation_angle, NULL); | ||
|
||
if (ctrl_hdlr->error) { | ||
ret = ctrl_hdlr->error; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.