From patchwork Thu Aug 29 01:51:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Hackmann X-Patchwork-Id: 2851093 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9B359BF546 for ; Thu, 29 Aug 2013 03:04:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7516A2041C for ; Thu, 29 Aug 2013 03:04:32 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 535292039D for ; Thu, 29 Aug 2013 03:04:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2303CE60BC for ; Wed, 28 Aug 2013 20:04:31 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yh0-f74.google.com (mail-yh0-f74.google.com [209.85.213.74]) by gabe.freedesktop.org (Postfix) with ESMTP id 9D09FE642C for ; Wed, 28 Aug 2013 18:51:40 -0700 (PDT) Received: by mail-yh0-f74.google.com with SMTP id c41so729462yho.5 for ; Wed, 28 Aug 2013 18:51:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qHS8UR0xq/Vo6wHTCHMU7+wUi9gx6x09S4GDpAiH08E=; b=DoduWRS6H2bNWBgIX3KbMLe0q9PbNtQc/njEtxHO5FNT+69891r77i9GD85XUwWI2x xnJIVr/NV+83tM9SYKFFtG+OGo5pj4Kv6RX4nGMw7D0Tzlshyae5YqAdFgnOU65UKF4o e+70N/cu2p3+pzoI8lzPXwD6Y2g3/iFLMdRNtiQxFSYzFZTRMTxyYr4Nd5cX57vCs6e/ XS4EyBNZ1As4knzSP/DiluUH+XQKL6hZ0k3BRlkqzjo+mbhwFdZLn0v9s3q3eHZTPZiO 3DwznU7fjRtR2nqVKcHrCgn64VLuuYlykBDMC7puiIxcq5IdpEEzNIQs86oBhH7hEN4X otHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qHS8UR0xq/Vo6wHTCHMU7+wUi9gx6x09S4GDpAiH08E=; b=Ft9aHSRP7RAaOeIDq7LOehff1kHLp76ZAzePqaQEaRqnGyjngeB5gLTnzjq6S2SzQt JEbe8A1sFYM8EUPpWEFBgvTCJ593PpI6aNanBtCHiusBtgIZFYKRIICRSGXaA5KmxkL6 vb9vzne7UDRW2iQ5iWOigxv12jm16Vf6EcqPVi4FW0oGio+7vc1PpxvkVHDDVgToHGlA OJa4vfvCR0TduUGopMdBZF5YN+Nis0sJJU5OEpTcKpQ80gM8QhX+bM9Q9RXkn1jkhMHW 1U+FG+lEWXR3n9OqoE4pd7QFAK4q7gt8IWpwUZoVFBDuLzafwFCE03I8eZcg5dec2Yn+ d1/g== X-Gm-Message-State: ALoCoQncHGoVJtRtEVthQy51UlLLcSxeC595hDtkqBbbpoMI7CUqBuw8nf5dWnlKip+g6HW9L6/ipPMj6QKFFuAvL/eiaUYddqgTi8ogItZIPnB95JrmxwXYihcZga3tBNxNzyBJbBggZ4k1GjJso2JQqqFBrWUBotn+Pzz/fy+kedlGoKGWucQHd5QAF3D72q6wzij70K/1Nzus98e0cuZni+AnSdLIHg== X-Received: by 10.236.172.34 with SMTP id s22mr308672yhl.25.1377741099916; Wed, 28 Aug 2013 18:51:39 -0700 (PDT) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id z45si1786025yha.7.1969.12.31.16.00.00 (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Wed, 28 Aug 2013 18:51:39 -0700 (PDT) Received: from ghackmann.mtv.corp.google.com (ghackmann.mtv.corp.google.com [172.18.120.106]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id B0D5B5A407C; Wed, 28 Aug 2013 18:51:39 -0700 (PDT) Received: by ghackmann.mtv.corp.google.com (Postfix, from userid 163046) id 6F3B01005DB; Wed, 28 Aug 2013 18:51:39 -0700 (PDT) From: Greg Hackmann To: dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org Subject: [RFC 3/4] video: adf: add display core helper Date: Wed, 28 Aug 2013 18:51:20 -0700 Message-Id: <1377741081-30189-4-git-send-email-ghackmann@google.com> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1377741081-30189-1-git-send-email-ghackmann@google.com> References: <1377741081-30189-1-git-send-email-ghackmann@google.com> Cc: konkers@google.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Optional helper which implements some ADF interface ops for displays using the Display Core framework Signed-off-by: Greg Hackmann --- drivers/video/adf/Kconfig | 5 ++ drivers/video/adf/Makefile | 2 + drivers/video/adf/adf.c | 28 ++++++++- drivers/video/adf/adf.h | 1 + drivers/video/adf/adf_display.c | 123 ++++++++++++++++++++++++++++++++++++++++ include/video/adf_display.h | 31 ++++++++++ 6 files changed, 189 insertions(+), 1 deletion(-) create mode 100644 drivers/video/adf/adf_display.c create mode 100644 include/video/adf_display.h diff --git a/drivers/video/adf/Kconfig b/drivers/video/adf/Kconfig index 0b64408..30b0611 100644 --- a/drivers/video/adf/Kconfig +++ b/drivers/video/adf/Kconfig @@ -3,3 +3,8 @@ menuconfig ADF depends on SW_SYNC depends on DMA_SHARED_BUFFER tristate "Atomic Display Framework" + +menuconfig ADF_DISPLAY_CORE + depends on ADF + depends on DISPLAY_CORE + tristate "Helper for implementing ADF interface ops with Display Core devices" diff --git a/drivers/video/adf/Makefile b/drivers/video/adf/Makefile index 2af5f79..30164ee 100644 --- a/drivers/video/adf/Makefile +++ b/drivers/video/adf/Makefile @@ -8,3 +8,5 @@ obj-$(CONFIG_ADF) += adf.o \ adf_sysfs.o obj-$(CONFIG_COMPAT) += adf_fops32.o + +obj-$(CONFIG_ADF_DISPLAY_CORE) += adf_display.o diff --git a/drivers/video/adf/adf.c b/drivers/video/adf/adf.c index 5dc04af..b3b57dd 100644 --- a/drivers/video/adf/adf.c +++ b/drivers/video/adf/adf.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2013 Google, Inc. - * adf_modeinfo_set_name modified from drm_mode_set_name in + * adf_modeinfo_{set_name,set_vrefresh} modified from * drivers/gpu/drm/drm_modes.c * * This software is licensed under the terms of the GNU General Public @@ -966,6 +966,32 @@ void adf_modeinfo_set_name(struct drm_mode_modeinfo *mode) interlaced ? "i" : ""); } +void adf_modeinfo_set_vrefresh(struct drm_mode_modeinfo *mode) +{ + int refresh = 0; + unsigned int calc_val; + + if (mode->vrefresh > 0) + return; + else if (mode->htotal > 0 && mode->vtotal > 0) { + int vtotal; + vtotal = mode->vtotal; + /* work out vrefresh the value will be x1000 */ + calc_val = (mode->clock * 1000); + calc_val /= mode->htotal; + refresh = (calc_val + vtotal / 2) / vtotal; + + if (mode->flags & DRM_MODE_FLAG_INTERLACE) + refresh *= 2; + if (mode->flags & DRM_MODE_FLAG_DBLSCAN) + refresh /= 2; + if (mode->vscan > 1) + refresh /= mode->vscan; + + mode->vrefresh = refresh; + } +} + static void __exit adf_exit(void); static int __init adf_init(void) { diff --git a/drivers/video/adf/adf.h b/drivers/video/adf/adf.h index acad631..5f7260d 100644 --- a/drivers/video/adf/adf.h +++ b/drivers/video/adf/adf.h @@ -44,5 +44,6 @@ struct adf_event_refcount *adf_obj_find_refcount(struct adf_obj *obj, enum adf_event_type type); void adf_modeinfo_set_name(struct drm_mode_modeinfo *mode); +void adf_modeinfo_set_vrefresh(struct drm_mode_modeinfo *mode); #endif /* __ADF_H */ diff --git a/drivers/video/adf/adf_display.c b/drivers/video/adf/adf_display.c new file mode 100644 index 0000000..c87f6a5 --- /dev/null +++ b/drivers/video/adf/adf_display.c @@ -0,0 +1,123 @@ +/* + * Copyright (C) 2013 Google, Inc. + * adf_modeinfo_from_videomode modified from drm_display_mode_from_videomode in + * drivers/gpu/drm/drm_modes.c + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include +#include