Commit b24bc3ab authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab
Browse files

media: adv7511-v4l2: correctly report EDIDs of 1 block



If the EDID has an odd number of blocks (usually just 1, but the
same problem occurs with 3 blocks), then VIDIOC_G_EDID reported 2
(or 4) blocks. Fix this.

Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent c730ff32
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -1196,18 +1196,18 @@ static int adv7511_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
		return -EINVAL;

	if (edid->start_block == 0 && edid->blocks == 0) {
		edid->blocks = state->edid.segments * 2;
		edid->blocks = state->edid.blocks;
		return 0;
	}

	if (state->edid.segments == 0)
	if (state->edid.blocks == 0)
		return -ENODATA;

	if (edid->start_block >= state->edid.segments * 2)
	if (edid->start_block >= state->edid.blocks)
		return -EINVAL;

	if (edid->start_block + edid->blocks > state->edid.segments * 2)
		edid->blocks = state->edid.segments * 2 - edid->start_block;
	if (edid->start_block + edid->blocks > state->edid.blocks)
		edid->blocks = state->edid.blocks - edid->start_block;

	memcpy(edid->edid, &state->edid.data[edid->start_block * 128],
	       128 * edid->blocks);