Repository navigation
Isp driver fixes #3695
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
Merged
Merged
Isp driver fixes #3695
Changes from all commits
Commits
Show all changes
3 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 |
|---|---|---|
|
|
@@ -1006,15 +1006,32 @@ static int bcm2835_isp_node_s_selection(struct file *file, void *fh, | |
| if (!s->r.width || !s->r.height) | ||
| return -EINVAL; | ||
|
|
||
| /* Adjust the crop window if goes outside the frame dimensions. */ | ||
| s->r.left = min((unsigned int)max(s->r.left, 0), | ||
| node->q_data.width - MIN_DIM); | ||
| s->r.top = min((unsigned int)max(s->r.top, 0), | ||
| node->q_data.height - MIN_DIM); | ||
| s->r.width = max(min(s->r.width, node->q_data.width - s->r.left), | ||
| MIN_DIM); | ||
| s->r.height = max(min(s->r.height, node->q_data.height - s->r.top), | ||
| MIN_DIM); | ||
| /* We can only set crop on the input. */ | ||
| switch (s->target) { | ||
| case V4L2_SEL_TGT_CROP: | ||
| /* | ||
| * Adjust the crop window if it goes outside of the frame | ||
| * dimensions. | ||
| */ | ||
| s->r.left = min((unsigned int)max(s->r.left, 0), | ||
| node->q_data.width - MIN_DIM); | ||
| s->r.top = min((unsigned int)max(s->r.top, 0), | ||
| node->q_data.height - MIN_DIM); | ||
| s->r.width = max(min(s->r.width, | ||
| node->q_data.width - s->r.left), MIN_DIM); | ||
| s->r.height = max(min(s->r.height, | ||
| node->q_data.height - s->r.top), MIN_DIM); | ||
| break; | ||
| case V4L2_SEL_TGT_CROP_DEFAULT: | ||
| /* Default (i.e. no) crop window. */ | ||
| s->r.left = 0; | ||
| s->r.top = 0; | ||
| s->r.width = node->q_data.width; | ||
| s->r.height = node->q_data.height; | ||
| break; | ||
| default: | ||
| return -EINVAL; | ||
| } | ||
|
|
||
| crop.rect.x = s->r.left; | ||
| crop.rect.y = s->r.top; | ||
|
|
@@ -1029,33 +1046,40 @@ static int bcm2835_isp_node_s_selection(struct file *file, void *fh, | |
| static int bcm2835_isp_node_g_selection(struct file *file, void *fh, | ||
| struct v4l2_selection *s) | ||
| { | ||
| struct mmal_parameter_crop crop; | ||
| struct bcm2835_isp_node *node = video_drvdata(file); | ||
| struct bcm2835_isp_dev *dev = node_get_dev(node); | ||
| struct vchiq_mmal_port *port = get_port_data(node); | ||
| struct mmal_parameter_crop crop; | ||
| struct bcm2835_isp_dev *dev = node_get_dev(node); | ||
| u32 crop_size = sizeof(crop); | ||
| int ret; | ||
|
|
||
| /* This return value is required for V4L2 compliance. */ | ||
| if (node_is_stats(node)) | ||
| return -ENOTTY; | ||
|
|
||
| /* We can only return out an input crop. */ | ||
| if (s->target != V4L2_SEL_TGT_CROP) | ||
| return -EINVAL; | ||
|
|
||
| ret = vchiq_mmal_port_parameter_get(dev->mmal_instance, port, | ||
| MMAL_PARAMETER_CROP, | ||
| &crop, &crop_size); | ||
| if (!ret) | ||
| return -EINVAL; | ||
|
|
||
| s->r.left = crop.rect.x; | ||
| s->r.top = crop.rect.y; | ||
| s->r.width = crop.rect.width; | ||
| s->r.height = crop.rect.height; | ||
| switch (s->target) { | ||
| case V4L2_SEL_TGT_CROP: | ||
| ret = vchiq_mmal_port_parameter_get(dev->mmal_instance, port, | ||
| MMAL_PARAMETER_CROP, | ||
| &crop, &crop_size); | ||
| if (!ret) { | ||
| s->r.left = crop.rect.x; | ||
| s->r.top = crop.rect.y; | ||
| s->r.width = crop.rect.width; | ||
| s->r.height = crop.rect.height; | ||
| } | ||
| break; | ||
| case V4L2_SEL_TGT_CROP_DEFAULT: | ||
| case V4L2_SEL_TGT_CROP_BOUNDS: | ||
| /* Default (i.e. no) crop window. */ | ||
| s->r.left = 0; | ||
| s->r.top = 0; | ||
| s->r.width = node->q_data.width; | ||
| s->r.height = node->q_data.height; | ||
| ret = 0; | ||
| break; | ||
| default: | ||
| ret = -EINVAL; | ||
| } | ||
|
Contributor
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. And again, switch / case |
||
|
|
||
| return 0; | ||
| return ret; | ||
| } | ||
|
|
||
| static int bcm3285_isp_subscribe_event(struct v4l2_fh *fh, | ||
|
|
@@ -1218,6 +1242,8 @@ static int register_node(struct bcm2835_isp_dev *dev, | |
| node->vfl_dir = VFL_DIR_RX; | ||
| node->name = "stats"; | ||
| v4l2_disable_ioctl(&node->vfd, VIDIOC_S_CTRL); | ||
| v4l2_disable_ioctl(&node->vfd, VIDIOC_S_SELECTION); | ||
| v4l2_disable_ioctl(&node->vfd, VIDIOC_G_SELECTION); | ||
| break; | ||
| } | ||
|
|
||
|
|
@@ -1269,21 +1295,6 @@ static int register_node(struct bcm2835_isp_dev *dev, | |
| } | ||
| node->queue_init = true; | ||
|
|
||
| /* Define the device names */ | ||
| snprintf(vfd->name, sizeof(node->vfd.name), "%s-%s%d", BCM2835_ISP_NAME, | ||
| node->name, node->id); | ||
|
|
||
| ret = video_register_device(vfd, VFL_TYPE_GRABBER, video_nr + index); | ||
| if (ret) { | ||
| v4l2_err(&dev->v4l2_dev, | ||
| "Failed to register video %s[%d] device node\n", | ||
| node->name, node->id); | ||
| return ret; | ||
| } | ||
|
|
||
| node->registered = true; | ||
| video_set_drvdata(vfd, node); | ||
|
|
||
| /* Set some controls and defaults, but only on the VIDEO_OUTPUT node. */ | ||
| if (node_is_output(node)) { | ||
| unsigned int i; | ||
|
|
@@ -1298,7 +1309,12 @@ static int register_node(struct bcm2835_isp_dev *dev, | |
| .step = 1, | ||
| }; | ||
|
|
||
| v4l2_ctrl_handler_init(&dev->ctrl_handler, 4); | ||
| ret = v4l2_ctrl_handler_init(&dev->ctrl_handler, 12); | ||
| if (ret) { | ||
| v4l2_err(&dev->v4l2_dev, "ctrl_handler init failed (%d)\n", | ||
| ret); | ||
| return ret; | ||
| } | ||
|
|
||
| dev->r_gain = 1000; | ||
| dev->b_gain = 1000; | ||
|
|
@@ -1324,13 +1340,39 @@ static int register_node(struct bcm2835_isp_dev *dev, | |
| } | ||
|
|
||
| node->vfd.ctrl_handler = &dev->ctrl_handler; | ||
| if (dev->ctrl_handler.error) { | ||
| ret = dev->ctrl_handler.error; | ||
| v4l2_err(&dev->v4l2_dev, "controls init failed (%d)\n", | ||
| ret); | ||
| v4l2_ctrl_handler_free(&dev->ctrl_handler); | ||
| goto ctrl_cleanup; | ||
| } | ||
| } | ||
|
|
||
| /* Define the device names */ | ||
| snprintf(vfd->name, sizeof(node->vfd.name), "%s-%s%d", BCM2835_ISP_NAME, | ||
| node->name, node->id); | ||
|
|
||
| ret = video_register_device(vfd, VFL_TYPE_GRABBER, video_nr + index); | ||
| if (ret) { | ||
| v4l2_err(&dev->v4l2_dev, | ||
| "Failed to register video %s[%d] device node\n", | ||
| node->name, node->id); | ||
| goto ctrl_cleanup; | ||
| } | ||
|
|
||
| node->registered = true; | ||
| video_set_drvdata(vfd, node); | ||
|
|
||
| v4l2_info(&dev->v4l2_dev, | ||
| "Device node %s[%d] registered as /dev/video%d\n", | ||
| node->name, node->id, vfd->num); | ||
|
|
||
| return 0; | ||
|
|
||
| ctrl_cleanup: | ||
| v4l2_ctrl_handler_free(&dev->ctrl_handler); | ||
| return ret; | ||
| } | ||
|
|
||
| /* Unregister one of the /dev/video<N> nodes associated with the ISP. */ | ||
|
|
||
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
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.
switch case?