From patchwork Wed Jun 7 14:46:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 9771621 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 7AD366034B for ; Wed, 7 Jun 2017 14:46:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5CE2528358 for ; Wed, 7 Jun 2017 14:46:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 506AB28456; Wed, 7 Jun 2017 14:46:27 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 953A228358 for ; Wed, 7 Jun 2017 14:46:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 703AD89496; Wed, 7 Jun 2017 14:46:22 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from lb3-smtp-cloud3.xs4all.net (lb3-smtp-cloud3.xs4all.net [194.109.24.30]) by gabe.freedesktop.org (Postfix) with ESMTPS id D676F89450 for ; Wed, 7 Jun 2017 14:46:21 +0000 (UTC) Received: from marune.fritz.box ([IPv6:2001:983:e9a7:1:ef31:4dcf:822e:7392]) by smtp-cloud3.xs4all.net with ESMTP id VqmG1v00Q3YS7uB01qmKqN; Wed, 07 Jun 2017 16:46:19 +0200 From: Hans Verkuil To: linux-media@vger.kernel.org Subject: [PATCH 1/9] cec: add cec_s_phys_addr_from_edid helper function Date: Wed, 7 Jun 2017 16:46:08 +0200 Message-Id: <20170607144616.15247-2-hverkuil@xs4all.nl> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170607144616.15247-1-hverkuil@xs4all.nl> References: <20170607144616.15247-1-hverkuil@xs4all.nl> Cc: Hans Verkuil , dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Hans Verkuil This function simplifies the integration of CEC in DRM drivers. Signed-off-by: Hans Verkuil --- Documentation/media/kapi/cec-core.rst | 8 ++++++++ drivers/media/cec/cec-adap.c | 14 ++++++++++++++ include/media/cec.h | 9 +++++++++ 3 files changed, 31 insertions(+) diff --git a/Documentation/media/kapi/cec-core.rst b/Documentation/media/kapi/cec-core.rst index 7a04c5386dc8..278b358b2f2e 100644 --- a/Documentation/media/kapi/cec-core.rst +++ b/Documentation/media/kapi/cec-core.rst @@ -307,6 +307,14 @@ to another valid physical address, then this function will first set the address to CEC_PHYS_ADDR_INVALID before enabling the new physical address. .. c:function:: + void cec_s_phys_addr_from_edid(struct cec_adapter *adap, + const struct edid *edid); + +A helper function that extracts the physical address from the edid struct +and calls cec_s_phys_addr() with that address, or CEC_PHYS_ADDR_INVALID +if the EDID did not contain a physical address or edid was a NULL pointer. + +.. c:function:: int cec_s_log_addrs(struct cec_adapter *adap, struct cec_log_addrs *log_addrs, bool block); diff --git a/drivers/media/cec/cec-adap.c b/drivers/media/cec/cec-adap.c index fd6d9cccade7..61e39bbe3cf9 100644 --- a/drivers/media/cec/cec-adap.c +++ b/drivers/media/cec/cec-adap.c @@ -28,6 +28,8 @@ #include #include +#include + #include "cec-priv.h" static void cec_fill_msg_report_features(struct cec_adapter *adap, @@ -1408,6 +1410,18 @@ void cec_s_phys_addr(struct cec_adapter *adap, u16 phys_addr, bool block) } EXPORT_SYMBOL_GPL(cec_s_phys_addr); +void cec_s_phys_addr_from_edid(struct cec_adapter *adap, + const struct edid *edid) +{ + u16 pa = CEC_PHYS_ADDR_INVALID; + + if (edid && edid->extensions) + pa = cec_get_edid_phys_addr((const u8 *)edid, + EDID_LENGTH * (edid->extensions + 1), NULL); + cec_s_phys_addr(adap, pa, false); +} +EXPORT_SYMBOL_GPL(cec_s_phys_addr_from_edid); + /* * Called from either the ioctl or a driver to set the logical addresses. * diff --git a/include/media/cec.h b/include/media/cec.h index bfa88d4d67e1..a548b292eeb1 100644 --- a/include/media/cec.h +++ b/include/media/cec.h @@ -206,6 +206,8 @@ static inline bool cec_is_sink(const struct cec_adapter *adap) #define cec_phys_addr_exp(pa) \ ((pa) >> 12), ((pa) >> 8) & 0xf, ((pa) >> 4) & 0xf, (pa) & 0xf +struct edid; + #if IS_ENABLED(CONFIG_CEC_CORE) struct cec_adapter *cec_allocate_adapter(const struct cec_adap_ops *ops, void *priv, const char *name, u32 caps, u8 available_las); @@ -217,6 +219,8 @@ int cec_s_log_addrs(struct cec_adapter *adap, struct cec_log_addrs *log_addrs, bool block); void cec_s_phys_addr(struct cec_adapter *adap, u16 phys_addr, bool block); +void cec_s_phys_addr_from_edid(struct cec_adapter *adap, + const struct edid *edid); int cec_transmit_msg(struct cec_adapter *adap, struct cec_msg *msg, bool block); @@ -326,6 +330,11 @@ static inline void cec_s_phys_addr(struct cec_adapter *adap, u16 phys_addr, { } +static inline void cec_s_phys_addr_from_edid(struct cec_adapter *adap, + const struct edid *edid) +{ +} + static inline u16 cec_get_edid_phys_addr(const u8 *edid, unsigned int size, unsigned int *offset) {