From patchwork Wed Jan 9 04:08:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 13929 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 264E923E33 for ; Wed, 9 Jan 2013 04:09:19 +0000 (UTC) Received: from mail-vb0-f43.google.com (mail-vb0-f43.google.com [209.85.212.43]) by fiordland.canonical.com (Postfix) with ESMTP id B3730A18F4F for ; Wed, 9 Jan 2013 04:09:18 +0000 (UTC) Received: by mail-vb0-f43.google.com with SMTP id fs19so1152080vbb.16 for ; Tue, 08 Jan 2013 20:09:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:dkim-signature:x-received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references:x-gm-message-state; bh=PFEp1V+fSxV55N01R2nIAscns1E5DtoEJNhWE/sax28=; b=C5hbsTUU0JrXTHDYEyylKzNdM8YOgTOImFVAdgdqOMS23JPT5XikpVd0AHDkjg0tmJ EyeXLK/4FLQRffjJ3k/ah7SvmK3mcQ2wUA7Ea25JJ1tdFAgC6b1yzNl6trkqMVvwFWm/ TfWwX4/15vNUWdGVKxcb2W6mmDML0esOhx1j36Nhd7u35eoxfmMkZ8J0ifWr2e4Wx0OV tUHgv4pyWRsB9gWSp1z+CX4eOoD4fwt9LgIOF+DEJmsVR061PViA8ZxePQV4hCQtCAT5 ijX5TjZymn8xz4gnjRr5ORcx1oCfZ/eR78xiBKl8EI1QNU3jXWbPtpeGIkVOdB8HwAiu Xo+w== X-Received: by 10.220.8.18 with SMTP id f18mr86243894vcf.14.1357704558221; Tue, 08 Jan 2013 20:09:18 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.145.101 with SMTP id st5csp144867veb; Tue, 8 Jan 2013 20:09:17 -0800 (PST) X-Received: by 10.66.87.202 with SMTP id ba10mr185481481pab.72.1357704557345; Tue, 08 Jan 2013 20:09:17 -0800 (PST) Received: from mail-pa0-f51.google.com (mail-pa0-f51.google.com [209.85.220.51]) by mx.google.com with ESMTPS id u8si65183659pav.4.2013.01.08.20.09.17 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 08 Jan 2013 20:09:17 -0800 (PST) Received-SPF: pass (google.com: domain of robdclark@gmail.com designates 209.85.220.51 as permitted sender) client-ip=209.85.220.51; Authentication-Results: mx.google.com; spf=pass (google.com: domain of robdclark@gmail.com designates 209.85.220.51 as permitted sender) smtp.mail=robdclark@gmail.com; dkim=pass header.i=@gmail.com Received: by mail-pa0-f51.google.com with SMTP id fb11so759891pad.10 for ; Tue, 08 Jan 2013 20:09:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=PFEp1V+fSxV55N01R2nIAscns1E5DtoEJNhWE/sax28=; b=eOz23MMvD4+Dalu2Fxr6Te0mX+CprSHiyxpTr/zqWFSRv03rC0T5xTp6s5tposvmBT qPs62qgygrpEctrfP55Di1wV2xj0hUU5qQZGBXvdJWDXNJtoRQ8mY4P3sY8sItQ5MUMX C/V7mVDW/x5aqhpDlEdIRikNfjM3rnW7Tu+eQNAM7gREZhujNzI5YxUCgLeUPcCqLHzv qdeuuFVA7X+ZTvDAZdtuZO0m1828zxgKgPv3jiB8zUaHB2S59+t1cjX7uvXJSmg33O0u qIi+D52T8A8Ymk/sv+ykDQeOPskP46q4gpZ6fJpqi4gvi5GoWluwxZ7tE5xuK+NQpuUc RzLw== X-Received: by 10.68.228.2 with SMTP id se2mr208035061pbc.93.1357704556971; Tue, 08 Jan 2013 20:09:16 -0800 (PST) Received: from localhost (pool-74-100-87-234.lsanca.fios.verizon.net. [74.100.87.234]) by mx.google.com with ESMTPS id im4sm8777887pbc.13.2013.01.08.20.09.15 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 08 Jan 2013 20:09:16 -0800 (PST) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: patches@linaro.org, Rob Clark Subject: [PATCH 3/4] drm: i2c encoder helper wrappers Date: Tue, 8 Jan 2013 22:08:45 -0600 Message-Id: <1357704526-3447-4-git-send-email-robdclark@gmail.com> X-Mailer: git-send-email 1.8.0.2 In-Reply-To: <1357704526-3447-1-git-send-email-robdclark@gmail.com> References: <1357704526-3447-1-git-send-email-robdclark@gmail.com> X-Gm-Message-State: ALoCoQmr7+zmewuwbdTmE9HhEogP2p5MRyh9ZZpj0RahOpEXJ7RJWegGY8VNttpqTHOKFNduNOzL Simplify life for drivers using an encoder-slave, so that they can make their drm_encoder_helper_funcs const, rather than needing to dynamically allocate and populate them. Signed-off-by: Rob Clark Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_encoder_slave.c | 63 +++++++++++++++++++++++++++++++++++++ include/drm/drm_encoder_slave.h | 20 ++++++++++++ 2 files changed, 83 insertions(+) diff --git a/drivers/gpu/drm/drm_encoder_slave.c b/drivers/gpu/drm/drm_encoder_slave.c index 63e7334..48c52f7 100644 --- a/drivers/gpu/drm/drm_encoder_slave.c +++ b/drivers/gpu/drm/drm_encoder_slave.c @@ -123,3 +123,66 @@ void drm_i2c_encoder_destroy(struct drm_encoder *drm_encoder) module_put(module); } EXPORT_SYMBOL(drm_i2c_encoder_destroy); + +/* + * Wrapper fxns which can be plugged in to drm_encoder_helper_funcs: + */ + +static inline struct drm_encoder_slave_funcs * +get_slave_funcs(struct drm_encoder *enc) +{ + return to_encoder_slave(enc)->slave_funcs; +} + +void drm_i2c_encoder_dpms(struct drm_encoder *encoder, int mode) +{ + get_slave_funcs(encoder)->dpms(encoder, mode); +} +EXPORT_SYMBOL(drm_i2c_encoder_dpms); + +bool drm_i2c_encoder_mode_fixup(struct drm_encoder *encoder, + const struct drm_display_mode *mode, + struct drm_display_mode *adjusted_mode) +{ + return get_slave_funcs(encoder)->mode_fixup(encoder, mode, adjusted_mode); +} +EXPORT_SYMBOL(drm_i2c_encoder_mode_fixup); + +void drm_i2c_encoder_prepare(struct drm_encoder *encoder) +{ + drm_i2c_encoder_dpms(encoder, DRM_MODE_DPMS_OFF); +} +EXPORT_SYMBOL(drm_i2c_encoder_prepare); + +void drm_i2c_encoder_commit(struct drm_encoder *encoder) +{ + drm_i2c_encoder_dpms(encoder, DRM_MODE_DPMS_ON); +} +EXPORT_SYMBOL(drm_i2c_encoder_commit); + +void drm_i2c_encoder_mode_set(struct drm_encoder *encoder, + struct drm_display_mode *mode, + struct drm_display_mode *adjusted_mode) +{ + get_slave_funcs(encoder)->mode_set(encoder, mode, adjusted_mode); +} +EXPORT_SYMBOL(drm_i2c_encoder_mode_set); + +enum drm_connector_status drm_i2c_encoder_detect(struct drm_encoder *encoder, + struct drm_connector *connector) +{ + return get_slave_funcs(encoder)->detect(encoder, connector); +} +EXPORT_SYMBOL(drm_i2c_encoder_detect); + +void drm_i2c_encoder_save(struct drm_encoder *encoder) +{ + get_slave_funcs(encoder)->save(encoder); +} +EXPORT_SYMBOL(drm_i2c_encoder_save); + +void drm_i2c_encoder_restore(struct drm_encoder *encoder) +{ + get_slave_funcs(encoder)->restore(encoder); +} +EXPORT_SYMBOL(drm_i2c_encoder_restore); diff --git a/include/drm/drm_encoder_slave.h b/include/drm/drm_encoder_slave.h index b0c11a7..8b9cc36 100644 --- a/include/drm/drm_encoder_slave.h +++ b/include/drm/drm_encoder_slave.h @@ -159,4 +159,24 @@ static inline void drm_i2c_encoder_unregister(struct drm_i2c_encoder_driver *dri void drm_i2c_encoder_destroy(struct drm_encoder *encoder); + +/* + * Wrapper fxns which can be plugged in to drm_encoder_helper_funcs: + */ + +void drm_i2c_encoder_dpms(struct drm_encoder *encoder, int mode); +bool drm_i2c_encoder_mode_fixup(struct drm_encoder *encoder, + const struct drm_display_mode *mode, + struct drm_display_mode *adjusted_mode); +void drm_i2c_encoder_prepare(struct drm_encoder *encoder); +void drm_i2c_encoder_commit(struct drm_encoder *encoder); +void drm_i2c_encoder_mode_set(struct drm_encoder *encoder, + struct drm_display_mode *mode, + struct drm_display_mode *adjusted_mode); +enum drm_connector_status drm_i2c_encoder_detect(struct drm_encoder *encoder, + struct drm_connector *connector); +void drm_i2c_encoder_save(struct drm_encoder *encoder); +void drm_i2c_encoder_restore(struct drm_encoder *encoder); + + #endif