From patchwork Tue Jan 21 10:21:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 13946082 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0782F1EE7D6 for ; Tue, 21 Jan 2025 10:25:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737455106; cv=none; b=TulOHeB9O0zVJc9WbnE9cLDJOUgODzhsi2Bsjc2OaYQG4Y04ykVzr7qzGpKyMLLJ7kqOiHzvnWk+uW3F2p24csDv3bV2qWAaGjVtslEA3rkMfBYkWDZnpj5w+E5mUGS+oaf202TJ2+O9JUXVSQsDLztL5/A2WT6HGVn/yKPjVgg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737455106; c=relaxed/simple; bh=eyBf1XNyXzl+Xm0C/gTGK/kpxWbD/yc6f/K/JrLz1yM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JScEcNWSWMQLJRRBEKUlhHGzKcUsxkGFSQCPcNkrBb8PE1CKEA2VloZBsHefCgP99Umb7u1CFBrR2avubN3/9D4kC6TJMYaAJgnm0aOhEbgoqhyu2opsh3LK0p7BfpKz32UcjCn9T6VfbGyfgfOfx/xnu9CwutNoEK4bFb8qZLM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4B09C4CEE2; Tue, 21 Jan 2025 10:25:04 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil Subject: [PATCH 1/2] media: v4l2-dv-timings: add v4l2_num_edid_blocks() helper Date: Tue, 21 Jan 2025 11:21:41 +0100 Message-ID: X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This new function determines how many blocks the EDID has. Traditionally the number of extension blocks is read from the EDID at offset 126, but this can be overridden by the HDMI Forum EDID Extension Override Data Block. So check that as well in this helper. Signed-off-by: Hans Verkuil --- drivers/media/v4l2-core/v4l2-dv-timings.c | 29 +++++++++++++++++++++++ include/media/v4l2-dv-timings.h | 1 + 2 files changed, 30 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-dv-timings.c b/drivers/media/v4l2-core/v4l2-dv-timings.c index d26edf157e64..f17766b2d800 100644 --- a/drivers/media/v4l2-core/v4l2-dv-timings.c +++ b/drivers/media/v4l2-core/v4l2-dv-timings.c @@ -1017,6 +1017,35 @@ v4l2_hdmi_rx_colorimetry(const struct hdmi_avi_infoframe *avi, } EXPORT_SYMBOL_GPL(v4l2_hdmi_rx_colorimetry); +/** + * v4l2_num_edid_blocks() - return the number of EDID blocks + * + * @edid: pointer to the EDID data + * @max_blocks: maximum number of supported EDID blocks + * + * Return: the number of EDID blocks based on the contents of the EDID. + * This supports the HDMI Forum EDID Extension Override Data Block. + */ +unsigned int v4l2_num_edid_blocks(const u8 *edid, unsigned int max_blocks) +{ + unsigned int blocks = 0; + + if (edid && max_blocks) { + blocks = edid[126] + 1; + // Check for HDMI Forum EDID Extension Override Data Block + if (blocks >= 2 && + max_blocks >= 3 && + edid[128] == 2 && + edid[133] == 0x78 && + (edid[132] & 0xe0) == 0xe0 && + (edid[132] & 0x1f) >= 2 && + edid[134] > 1) + blocks = edid[134] + 1; + } + return blocks > max_blocks ? max_blocks : blocks; +} +EXPORT_SYMBOL_GPL(v4l2_num_edid_blocks); + /** * v4l2_get_edid_phys_addr() - find and return the physical address * diff --git a/include/media/v4l2-dv-timings.h b/include/media/v4l2-dv-timings.h index ff07dc6b103c..714075c72f77 100644 --- a/include/media/v4l2-dv-timings.h +++ b/include/media/v4l2-dv-timings.h @@ -252,6 +252,7 @@ v4l2_hdmi_rx_colorimetry(const struct hdmi_avi_infoframe *avi, const struct hdmi_vendor_infoframe *hdmi, unsigned int height); +unsigned int v4l2_num_edid_blocks(const u8 *edid, unsigned int max_blocks); u16 v4l2_get_edid_phys_addr(const u8 *edid, unsigned int size, unsigned int *offset); void v4l2_set_edid_phys_addr(u8 *edid, unsigned int size, u16 phys_addr); From patchwork Tue Jan 21 10:21:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 13946083 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 36C851DEFF8 for ; Tue, 21 Jan 2025 10:25:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737455107; cv=none; b=p+c7gcZj7I96v+kOM/jI4v5UD/EHMCsC5hwMNfayos9ff4P1IRhAs+h+PASsgibSgPfsZe2Z6j2ucul6foNEQQDf3+kDToOmqHUxJnwdpr9H0kphSrlGTMTc0iMSG3lj/5kR2S/f0QQGjwd1H6TeSLnoh1AvYq42/ylaTNeeXjE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737455107; c=relaxed/simple; bh=vHyZCL553cK5IQ29n+d+bfU+cD4MB5tVKarHlF33vYA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d0XzhwNp3lNVfQDGPcR0jDOJH1bNWqy/sczN8lEBIJxQHAR7KndBOgLTGD5m5n+4hD4KvZICnE6QRZyNg4PD+qBu/iBZbRP6JjPUVvyhYvZbQ5Fd7+bCxEE/t+Qut0wbiuoZ5EWeFm5o3CnxUakdHqGJFy1sikJKJ5ZHaXW0gzU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA025C4CEE4; Tue, 21 Jan 2025 10:25:05 +0000 (UTC) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil Subject: [PATCH 2/2] media: adv7511-v4l2: add support for the EEODB Date: Tue, 21 Jan 2025 11:21:42 +0100 Message-ID: X-Mailer: git-send-email 2.45.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Support the HDMI Forum EDID Extension Override Data Block by using the new v4l2_num_edid_blocks helper function. Signed-off-by: Hans Verkuil --- drivers/media/i2c/adv7511-v4l2.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/adv7511-v4l2.c b/drivers/media/i2c/adv7511-v4l2.c index 4036972af3a6..f95a99d85360 100644 --- a/drivers/media/i2c/adv7511-v4l2.c +++ b/drivers/media/i2c/adv7511-v4l2.c @@ -1664,7 +1664,9 @@ static bool adv7511_check_edid_status(struct v4l2_subdev *sd) if (!err) { adv7511_dbg_dump_edid(2, debug, sd, segment, &state->edid.data[segment * 256]); if (segment == 0) { - state->edid.blocks = state->edid.data[0x7e] + 1; + state->edid.blocks = + v4l2_num_edid_blocks(state->edid.data, + EDID_MAX_SEGM * 2); v4l2_dbg(1, debug, sd, "%s: %d blocks in total\n", __func__, state->edid.blocks); } @@ -1682,7 +1684,7 @@ static bool adv7511_check_edid_status(struct v4l2_subdev *sd) /* one more segment read ok */ state->edid.segments = segment + 1; v4l2_ctrl_s_ctrl(state->have_edid0_ctrl, 0x1); - if (((state->edid.data[0x7e] >> 1) + 1) > state->edid.segments) { + if (state->edid.blocks > state->edid.segments * 2) { /* Request next EDID segment */ v4l2_dbg(1, debug, sd, "%s: request segment %d\n", __func__, state->edid.segments); adv7511_wr(sd, 0xc9, 0xf);