From patchwork Mon May 30 08:38:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9140437 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 A22E560759 for ; Mon, 30 May 2016 08:39:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9789B27D17 for ; Mon, 30 May 2016 08:39:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C54D28213; Mon, 30 May 2016 08:39:18 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36BF127D17 for ; Mon, 30 May 2016 08:39:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EE9E66E6D3; Mon, 30 May 2016 08:38:59 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1F5F56E6C3; Mon, 30 May 2016 08:38:57 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id q62so20327947wmg.3; Mon, 30 May 2016 01:38:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=jKWbKtY5Jy+H1pUMJ0+WyujNMGGWXSxAwC1JMhfx4lk=; b=IpYxehtymEp7XcSZs+impBKQqOY6vLmDyHZyzCkePsWdLWOElF46MMohVFey1QYaNJ M04jLRgpOQC0sVmLz7EkhtoGsYC+Ng1EpK2QGK8W4cKYDzv3KhBd0naudPJH4h+zusSz zPbUPW2d+Umt3Oub3EttYiI06evsOsM6ylZZ4fdb8C/w6AX5ydI9LIi62AGIhoMnQiJc Gm8fUH336FkiuFKwqZt+fRO9kANqKkP3k1M3+y9yUGmE6NtDgK7ku1UX/6F9aui00/OV QE32nWOSOGQ5WcjQmVbscPuSkiasy0Yy6E5B4TlXoNhT7alRxfQ1r9HiIYr51wgds3kl Skfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=jKWbKtY5Jy+H1pUMJ0+WyujNMGGWXSxAwC1JMhfx4lk=; b=RfwLunrWn5OjZkBSFIU5eYWUpfYgf97CXqUWpH8sGTx2bc3BGrFw0zKZlUGGnVadL8 BhWIFL+xpnO5mL0E85ErjLRp1jJvxYrBdTZVBogOd6kSPCeOR66vvqmiN2PnqwX/wkR5 XReD9p4haEa3QQEJZASgXobBhK7s9m/R7omx4CtvoDP9fVVFhTF4RccUYFset3eFDspK WDkoUA2v5kUmpM4exMne77xV06jdXzNGbObVANAjkUuopnk/9y9DHhTkxxKYDbLFzacU yxSRe/srGX2tUcOLYYoC1INvLPSXy5/hQjGjNTHxoFRfB/G7FoL9ZNxyoDWyvb1Wsj9I ehIw== X-Gm-Message-State: ALyK8tLasPDkYcjfUt+Bmb4+yga2w5zfiAG/NnzPibvAFao3URkLm+BxVoOa2m1KA2v9mw== X-Received: by 10.28.156.135 with SMTP id f129mr10396332wme.36.1464597535171; Mon, 30 May 2016 01:38:55 -0700 (PDT) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id l9sm6945376wjm.0.2016.05.30.01.38.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 May 2016 01:38:54 -0700 (PDT) From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Mon, 30 May 2016 09:38:23 +0100 Message-Id: <1464597519-16659-6-git-send-email-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1464597519-16659-1-git-send-email-chris@chris-wilson.co.uk> References: <1464597519-16659-1-git-send-email-chris@chris-wilson.co.uk> Cc: dri-devel@lists.freedesktop.org Subject: [Intel-gfx] [PATCH v2 05/21] drm: Minimally initialise drm_dp_aux X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP When trying to split up the initialisation phase and the registration phase, one immediate problem encountered is trying to use our own i2c devices before registration with userspace. drm_dp_aux in particular only offers an interface for setting up the device after we have exposed the connector via sysfs. In order to break the chicken-and-egg problem, export drm_dp_aux_init() to minimally prepare the i2c device for internal use before drm_connector_register(). Signed-off-by: Chris Wilson Cc: Rafael Antognolli Cc: dri-devel@lists.freedesktop.org --- drivers/gpu/drm/drm_dp_helper.c | 18 +++++++++++++----- include/drm/drm_dp_helper.h | 1 + 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c index eeaf5a7c3aa7..e1900d386685 100644 --- a/drivers/gpu/drm/drm_dp_helper.c +++ b/drivers/gpu/drm/drm_dp_helper.c @@ -774,6 +774,17 @@ static const struct i2c_algorithm drm_dp_i2c_algo = { .master_xfer = drm_dp_i2c_xfer, }; +void drm_dp_aux_init(struct drm_dp_aux *aux) +{ + mutex_init(&aux->hw_mutex); + rt_mutex_init(&aux->ddc.bus_lock); + + aux->ddc.algo = &drm_dp_i2c_algo; + aux->ddc.algo_data = aux; + aux->ddc.retries = 3; +} +EXPORT_SYMBOL(drm_dp_aux_init); + /** * drm_dp_aux_register() - initialise and register aux channel * @aux: DisplayPort AUX channel @@ -784,11 +795,8 @@ int drm_dp_aux_register(struct drm_dp_aux *aux) { int ret; - mutex_init(&aux->hw_mutex); - - aux->ddc.algo = &drm_dp_i2c_algo; - aux->ddc.algo_data = aux; - aux->ddc.retries = 3; + if (!aux->ddc.algo) + drm_dp_aux_init(aux); aux->ddc.class = I2C_CLASS_DDC; aux->ddc.owner = THIS_MODULE; diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h index 5a848e734422..4d85cf2874af 100644 --- a/include/drm/drm_dp_helper.h +++ b/include/drm/drm_dp_helper.h @@ -805,6 +805,7 @@ int drm_dp_link_power_up(struct drm_dp_aux *aux, struct drm_dp_link *link); int drm_dp_link_power_down(struct drm_dp_aux *aux, struct drm_dp_link *link); int drm_dp_link_configure(struct drm_dp_aux *aux, struct drm_dp_link *link); +void drm_dp_aux_init(struct drm_dp_aux *aux); int drm_dp_aux_register(struct drm_dp_aux *aux); void drm_dp_aux_unregister(struct drm_dp_aux *aux);