From mboxrd@z Thu Jan 1 00:00:00 1970 From: Greg Hackmann 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> References: <1377741081-30189-1-git-send-email-ghackmann@google.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: 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) In-Reply-To: <1377741081-30189-1-git-send-email-ghackmann@google.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org Cc: konkers@google.com List-Id: dri-devel@lists.freedesktop.org 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