From patchwork Wed Mar 29 14:15:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 9651675 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2382C601D7 for ; Wed, 29 Mar 2017 14:16:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15E14284BC for ; Wed, 29 Mar 2017 14:16:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0AE2C284C9; Wed, 29 Mar 2017 14:16:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 99AC9284BC for ; Wed, 29 Mar 2017 14:16:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755818AbdC2OPu (ORCPT ); Wed, 29 Mar 2017 10:15:50 -0400 Received: from lb3-smtp-cloud3.xs4all.net ([194.109.24.30]:41433 "EHLO lb3-smtp-cloud3.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751734AbdC2OPs (ORCPT ); Wed, 29 Mar 2017 10:15:48 -0400 Received: from marune.fritz.box ([IPv6:2001:983:e9a7:1:ef31:4dcf:822e:7392]) by smtp-cloud3.xs4all.net with ESMTP id 1qFj1v0073YS7uB01qFmiY; Wed, 29 Mar 2017 16:15:47 +0200 From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Daniel Vetter , Russell King , dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org, Krzysztof Kozlowski , Inki Dae , Marek Szyprowski , Javier Martinez Canillas , Benjamin Gaignard , Hans Verkuil Subject: [PATCHv5 01/11] cec-edid: rename cec_get_edid_phys_addr Date: Wed, 29 Mar 2017 16:15:33 +0200 Message-Id: <20170329141543.32935-2-hverkuil@xs4all.nl> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170329141543.32935-1-hverkuil@xs4all.nl> References: <20170329141543.32935-1-hverkuil@xs4all.nl> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hans Verkuil Rename cec_get_edid_phys_addr to cec_get_raw_edid_phys_addr. Add a new cec_get_edid_phys_addr function that takes a struct edid pointer. This reflects the fact that some drivers have a struct edid pointer and others a u8 pointer to the raw edid data. Signed-off-by: Hans Verkuil --- drivers/media/cec-edid.c | 15 +++++++++++++-- drivers/media/i2c/adv7511.c | 5 ++--- drivers/media/i2c/adv7604.c | 3 ++- drivers/media/i2c/adv7842.c | 2 +- drivers/media/platform/vivid/vivid-vid-cap.c | 3 ++- include/media/cec-edid.h | 17 ++++++++++++++--- 6 files changed, 34 insertions(+), 11 deletions(-) diff --git a/drivers/media/cec-edid.c b/drivers/media/cec-edid.c index 5719b991e340..d7b369f53831 100644 --- a/drivers/media/cec-edid.c +++ b/drivers/media/cec-edid.c @@ -21,6 +21,7 @@ #include #include #include +#include /* * This EDID is expected to be a CEA-861 compliant, which means that there are @@ -82,8 +83,8 @@ static unsigned int cec_get_edid_spa_location(const u8 *edid, unsigned int size) return 0; } -u16 cec_get_edid_phys_addr(const u8 *edid, unsigned int size, - unsigned int *offset) +u16 cec_get_raw_edid_phys_addr(const u8 *edid, unsigned int size, + unsigned int *offset) { unsigned int loc = cec_get_edid_spa_location(edid, size); @@ -93,6 +94,16 @@ u16 cec_get_edid_phys_addr(const u8 *edid, unsigned int size, return CEC_PHYS_ADDR_INVALID; return (edid[loc] << 8) | edid[loc + 1]; } +EXPORT_SYMBOL_GPL(cec_get_raw_edid_phys_addr); + +u16 cec_get_edid_phys_addr(const struct edid *edid) +{ + if (!edid || edid->extensions == 0) + return CEC_PHYS_ADDR_INVALID; + + return cec_get_raw_edid_phys_addr((u8 *)edid, + EDID_LENGTH * (edid->extensions + 1), NULL); +} EXPORT_SYMBOL_GPL(cec_get_edid_phys_addr); void cec_set_edid_phys_addr(u8 *edid, unsigned int size, u16 phys_addr) diff --git a/drivers/media/i2c/adv7511.c b/drivers/media/i2c/adv7511.c index 8c9e28949ab1..4723e826804a 100644 --- a/drivers/media/i2c/adv7511.c +++ b/drivers/media/i2c/adv7511.c @@ -1712,9 +1712,8 @@ static bool adv7511_check_edid_status(struct v4l2_subdev *sd) v4l2_dbg(1, debug, sd, "%s: edid complete with %d segment(s)\n", __func__, state->edid.segments); state->edid.complete = true; - ed.phys_addr = cec_get_edid_phys_addr(state->edid.data, - state->edid.segments * 256, - NULL); + ed.phys_addr = cec_get_raw_edid_phys_addr(state->edid.data, + state->edid.segments * 256, NULL); /* report when we have all segments but report only for segment 0 */ diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c index d8bf435db86d..ac60c9116f9c 100644 --- a/drivers/media/i2c/adv7604.c +++ b/drivers/media/i2c/adv7604.c @@ -2305,7 +2305,8 @@ static int adv76xx_set_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid) edid->blocks = 2; return -E2BIG; } - pa = cec_get_edid_phys_addr(edid->edid, edid->blocks * 128, &spa_loc); + pa = cec_get_raw_edid_phys_addr(edid->edid, + edid->blocks * 128, &spa_loc); err = cec_phys_addr_validate(pa, &pa, NULL); if (err) return err; diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c index 2d61f0cc2b5b..440870d1d988 100644 --- a/drivers/media/i2c/adv7842.c +++ b/drivers/media/i2c/adv7842.c @@ -802,7 +802,7 @@ static int edid_write_hdmi_segment(struct v4l2_subdev *sd, u8 port) if (!state->hdmi_edid.present) return 0; - pa = cec_get_edid_phys_addr(edid, 256, &spa_loc); + pa = cec_get_raw_edid_phys_addr(edid, 256, &spa_loc); err = cec_phys_addr_validate(pa, &pa, NULL); if (err) return err; diff --git a/drivers/media/platform/vivid/vivid-vid-cap.c b/drivers/media/platform/vivid/vivid-vid-cap.c index 01419455e545..6a7310e212cf 100644 --- a/drivers/media/platform/vivid/vivid-vid-cap.c +++ b/drivers/media/platform/vivid/vivid-vid-cap.c @@ -1736,7 +1736,8 @@ int vidioc_s_edid(struct file *file, void *_fh, edid->blocks = dev->edid_max_blocks; return -E2BIG; } - phys_addr = cec_get_edid_phys_addr(edid->edid, edid->blocks * 128, NULL); + phys_addr = cec_get_raw_edid_phys_addr(edid->edid, + edid->blocks * 128, NULL); ret = cec_phys_addr_validate(phys_addr, &phys_addr, NULL); if (ret) return ret; diff --git a/include/media/cec-edid.h b/include/media/cec-edid.h index bdf731ecba1a..46a1d383608e 100644 --- a/include/media/cec-edid.h +++ b/include/media/cec-edid.h @@ -27,7 +27,7 @@ ((pa) >> 12), ((pa) >> 8) & 0xf, ((pa) >> 4) & 0xf, (pa) & 0xf /** - * cec_get_edid_phys_addr() - find and return the physical address + * cec_get_raw_edid_phys_addr() - find and return the physical address * * @edid: pointer to the EDID data * @size: size in bytes of the EDID data @@ -37,8 +37,19 @@ * * Return: the physical address or CEC_PHYS_ADDR_INVALID if there is none. */ -u16 cec_get_edid_phys_addr(const u8 *edid, unsigned int size, - unsigned int *offset); +u16 cec_get_raw_edid_phys_addr(const u8 *edid, unsigned int size, + unsigned int *offset); + +struct edid; + +/** + * cec_get_edid_phys_addr() - find and return the physical address + * + * @edid: pointer to struct edid + * + * Return: the physical address or CEC_PHYS_ADDR_INVALID if there is none. + */ +u16 cec_get_edid_phys_addr(const struct edid *edid); /** * cec_set_edid_phys_addr() - find and set the physical address