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

Fixes for video-mux with Pi5 #6410

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions drivers/media/platform/video-mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ static int video_mux_link_setup(struct media_entity *entity,
const struct media_pad *remote, u32 flags)
{
struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
struct v4l2_subdev *source_sd;
struct v4l2_subdev_state *sd_state;
struct video_mux *vmux = v4l2_subdev_to_video_mux(sd);
u16 source_pad = entity->num_pads - 1;
int ret = 0;
Expand All @@ -84,10 +86,10 @@ static int video_mux_link_setup(struct media_entity *entity,
remote->entity->name, remote->index, local->entity->name,
local->index, flags & MEDIA_LNK_FL_ENABLED);

sd_state = v4l2_subdev_lock_and_get_active_state(sd);
mutex_lock(&vmux->lock);

if (flags & MEDIA_LNK_FL_ENABLED) {
struct v4l2_subdev_state *sd_state;
struct v4l2_mbus_framefmt *source_mbusformat;

if (vmux->active == local->index)
Expand All @@ -105,23 +107,28 @@ static int video_mux_link_setup(struct media_entity *entity,
vmux->active = local->index;

/* Propagate the active format to the source */
sd_state = v4l2_subdev_lock_and_get_active_state(sd);
source_mbusformat = v4l2_subdev_get_pad_format(sd, sd_state,
source_pad);
*source_mbusformat = *v4l2_subdev_get_pad_format(sd, sd_state,
vmux->active);
v4l2_subdev_unlock_state(sd_state);

source_sd = media_entity_to_v4l2_subdev(remote->entity);
vmux->subdev.ctrl_handler = source_sd->ctrl_handler;

} else {
if (vmux->active != local->index)
goto out;

dev_dbg(sd->dev, "going inactive\n");
mux_control_deselect(vmux->mux);
vmux->active = -1;

vmux->subdev.ctrl_handler = NULL;
}

out:
mutex_unlock(&vmux->lock);
v4l2_subdev_unlock_state(sd_state);
return ret;
}

Expand Down