Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3241490imm; Sun, 13 May 2018 07:12:47 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpxYiqbH5zwoJ8HNyvbRFodbV5/1ExXsjbLtPtv9j3d2OQDsj7NcTjYCAhICHbrxJOqDUM5 X-Received: by 2002:a63:9846:: with SMTP id l6-v6mr5428753pgo.217.1526220767522; Sun, 13 May 2018 07:12:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526220767; cv=none; d=google.com; s=arc-20160816; b=U2CVFGfcCqlVpfOemJriiA2qhp/sy3Z+xy8OoH9+NiBWr6I+OxiLK56E39GghSf4Ee 704cHeSzv3A866VVy0hIuc6jEQGwXeQDnSUy6R0WZH0PSlR5ihDXPzO+LD0Kv0TsAn5W 5LUt2Al/gT3hl0QcjH8TE4/qSh1fGg2aWC75yF/d9Lklku8WPdoGkFi98zN2Q6Zl1PeQ aEk8uYluf4C3a3RahAbMHSJeqcH8h+g9Ayb7bzpj6jVsmDbpidrTQMRtDYCB3riSmkz7 J8nVXuDml3yceqb0kE7ciIhYdJhH7zMJrycPwAfsgBqxaa67Zmdr4lXrtvi8uug2RCP0 AbZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=HjzxojS7LAXuMruoK+KgQjhs5EtDODX+FI0m7Z6e3U4=; b=hP6oZs3JhQWEgpN0sr1Wg6sk8e/ZL/GMOLU/T7Cx2/xuXOLeKS71B4xlvzk9AzxQO2 BTliql2QF68XrR+Gu+BRF5hSrXK7kbxXzroDwBTAb2lSsHhtvVm235ZDg6baE9+RKWfW Evews5TftsOdobcKtl7SbnRK9FGBZpswRZps+o4kfD4ksnF8axdEGeRZohc6WLQS0P4S 2tbg7kqTlVAaKaJPjnBeZltcijDCyhFObYBeBZCW6qbhveMtIjskMcn2BkIRPcN4A4cc aenTNWXy8Z/BfZG+MuEwaNxTqWuHy9xo+XR6EmN7oaPfh1QEQwkzJ3xuYaz+N7aIJ0NU kqNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=OaMz8VYK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f19-v6si7132010plr.13.2018.05.13.07.12.32; Sun, 13 May 2018 07:12:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=OaMz8VYK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751705AbeEMOMW (ORCPT + 99 others); Sun, 13 May 2018 10:12:22 -0400 Received: from mail-io0-f172.google.com ([209.85.223.172]:42348 "EHLO mail-io0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751438AbeEMOMU (ORCPT ); Sun, 13 May 2018 10:12:20 -0400 Received: by mail-io0-f172.google.com with SMTP id a10-v6so12250032ioc.9 for ; Sun, 13 May 2018 07:12:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=HjzxojS7LAXuMruoK+KgQjhs5EtDODX+FI0m7Z6e3U4=; b=OaMz8VYK5HtJYQF/krqEMOvmOXcitWVFVt2E/MViHXTIgYOrjDX9PTHSX43RmCbAa6 0v0V/an22QJ6lwLhKOsrctIViBC1EQKu0qAp3qCGdolQVWE6uO0X0cWVnBQZja8dSG2z o0Nn2rDhlt/XjNUxKfFFO8OA5EGVxV6mjv02E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=HjzxojS7LAXuMruoK+KgQjhs5EtDODX+FI0m7Z6e3U4=; b=oIM5Xn6wK0kUQN3tDDZnpQYj2jQhfy4bLvhO0N9tzElkvHfAJchciLxLVk1NrzqnFD KQ1V7KKpWetHJc25pbi9MwR9jau53EgN4RMgwGA3xDuGNCeyVjugC6Y274N6RsuO4igu MoBSlJ1YxFPOxcigtuiCEFXgSgZ/b7I59iyW3hEDrnBZT6m5qDQQ9o2OMUSDQLF9FCX8 RAR4T97JfQVAl/p6xb9OIhiES1C2xdRUDFk5KrtGgRiouR/B2lRNGdYnW1zSIZt8TADr qj7z+qjdaM6AY/hb+vi6CS5Qw0Xtc3/rKlgi2jK6dN9j1hMwAbiZ25QjF85iHaeahUuf 96aw== X-Gm-Message-State: ALKqPwcJrGaee62x+L+WfmKyZJzSOhhOUU9HHi3Qi9VmuIA4fzOFRME+ 5jRLQZfJBinhMnyNIH8HBC6/XeSCBHufY/jhSUa9Jg== X-Received: by 2002:a6b:1745:: with SMTP id 66-v6mr6576030iox.278.1526220739190; Sun, 13 May 2018 07:12:19 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a4f:f5d6:0:0:0:0:0 with HTTP; Sun, 13 May 2018 07:12:18 -0700 (PDT) X-Originating-IP: [2a02:168:5635:0:39d2:f87e:2033:9f6] In-Reply-To: <1525866725-16685-1-git-send-email-satendra.t@samsung.com> References: <1525777110-11378-1-git-send-email-satendra.t@samsung.com> <1525866725-16685-1-git-send-email-satendra.t@samsung.com> From: Daniel Vetter Date: Sun, 13 May 2018 16:12:18 +0200 X-Google-Sender-Auth: JeJb8B8F7bLfUx-CBlAdaxw2Th4 Message-ID: Subject: Re: [PATCH 00/13] drm/kms/mode: using helper func drm_display_mode_to/from_videomode for calculating timing parameters To: Satendra Singh Thakur Cc: Linux Kernel Mailing List , dri-devel , linux-tegra@vger.kernel.org, Linux ARM , linux-samsung-soc , "moderated list:ARM/Mediatek SoC support" , linux-amlogic@lists.infradead.org, sst2005@gmail.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 9, 2018 at 1:52 PM, Satendra Singh Thakur wrote: > On Thu, May 08, 2018 at 16:28:30 +0530, Satendra Singh Thakur wrote: >> On Thu, May 07, 2018 at 15:46:02 +0200, Daniel Vetter wrote: >> > On Thu, May 03, 2018 at 01:53:55PM +0530, Satendra Singh Thakur wrote: >> > > 1.There is a function in drm-core to calculate display timing parameters: >> > > horizontal front porch, back porch, sync length, >> > > vertical front porch, back porch, sync length and >> > > clock in Hz. >> > > However, some drivers are still calculating these parameters themselves. >> > > Therefore, there is a duplication of the code. >> > > This patch series replaces this redundant code with the function >> > > drm_display_mode_to_videomode. >> > > This removes nearly 100 redundant lines from the related drivers. >> > > 2.For some drivers (sun4i) the reverse helper >> > > drm_display_mode_from_videomode is used. >> > > 3.For some drivers it replaces arithmatic operators (*, /) with shifting >> > > operators (>>, <<). >> > > 4.For some drivers DRM_MODE_FLAG_* are replaced with DISPLAY_FLAGS_* flags. >> > > 5.These changes apply to following crtc and encoder drivers: >> > > atmel-hlcdc >> > > bridge-tc358767 >> > > exynos-dsi >> > > fsl-dcu >> > > gma500-mdfld_dsi_dpi >> > > hisilicon-kirin_dsi, ade >> > > meson-encoder >> > > pl111-display >> > > sun4i-tv >> > > ti lcdc >> > > tegra dc >> > > mediatek dpi dsi >> > > bridge-adv7533 >> > >> > The drm_mode_to_videomode helper is meant for interop between drm and v4l, >> > which have different internal structures to represent modes. >> > >> > For drivers that only use drm I think the better option would be to add >> > these fields to struct drm_display_mode as another set of crtc_* values >> > (the computed values are stored in crtc_ prefixed members). And compute >> > front/back porch in drm_mode_set_crtcinfo. >> > >> > Then we can use these new drm_display_mode->crtc_h|vfront|back_porch >> > fields in all the drivers you're changing. This way you avoid having to >> > change all the drm drivers to use v4l #defines. >> > >> > Thanks, >> > Daniel >> >> Hi Daniel, >> Thanks for the comments. >> I will look into it. >> >> Thanks >> -Satendra > > Hi Daniel, > Thanks for the comments. > Please find below my understanding in this direction. > > 1. Currently struct videomode is being used in 50 drm drivers and 14 fbdev drivers. > Since, it's already being used by so many drm drivers, that is the reason > these fbdev objects (struct videmode and func drm_display_mode_to_videomode) were used in this patch series. The biggest contributor for that seems to be of_get_videomode. We should probably have a of_drm_get_display_mode helper, which automatically converts the of/dt video description into the drm display mode structure. And I found way less than 50 drm drivers using videomode, much less if we ignore of. > 2. Anyway, if fbdev related objects (struct/func) are not encouraged in drm drivers, then we may add > h/v front/back porches in struct drm_display_mode as adviced by you. > > 3. We can calculate these params in func drm_mode_set_crtcinfo at the end of it. > int drm_mode_set_crtcinfo () > { > . > . > crtc_hfront_porch = crtc_hsync_start - crtc_hdisplay; > crtc_vfront_porch = crtc_vsync_start - crtc_vdisplay; > . > . > crtc_clock_hz = crtc_clock*1000; > }; > > 4. Normally mode is programmed in HW in following callbacks of crtc and encoder drivers > -mode_set > -mode_set_nofb > -atomic_enable > > > Normally drm_mode_set_crtcinfo is used in > -mode_fixup callbacks (CBs) > of encoder and crtc drivers. > > if mode_fixup CBs are called before mode_set CBs then > drm_mode_set_crtcinfo is right place to calculate sync/porch params. > We can use crtc_hfront/back_porches directly and program them to HW > in above mentioned callbacks. > > int my_mode_set () > { > REG_WRITE(crtc_hfront_porch); > REG_WRITE(crtc_hback_porch); > . > . > } Agreed with your plan up to point 5 here. > 6. However, if these params are being modified after calling drm_set_crtcinfo as mentioned below: > > bool amdgpu_atombios_encoder_mode_fixup(struct drm_encoder *encoder, > const struct drm_display_mode *mode, > struct drm_display_mode *adjusted_mode) > { > struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder); > > /* set the active encoder to connector routing */ > amdgpu_encoder_set_active_device(encoder); > ***drm_mode_set_crtcinfo(adjusted_mode, 0);**** > > /* hw bug */ > if ((mode->flags & DRM_MODE_FLAG_INTERLACE) > && (mode->crtc_vsync_start < (mode->crtc_vdisplay + 2))) > adjusted_mode->crtc_vsync_start = adjusted_mode->crtc_vdisplay + 2; > > Then we may need to define new func like > > void drm_calc_hv_porches_sync() > { > crtc_hfront_porch = crtc_hsync_start - crtc_hdisplay; > crtc_vfront_porch = crtc_vsync_start - crtc_vdisplay; > . > . > crtc_clock_hz = crtc_clock*1000; > } and call this func in mode_set*, atomic_enable CBS before programming the HW with this mode. > > > Should I create patches around this idea ? > Please let me know your comments. I'm not sure about point 6. I think we should wait with coming up with a solution to this problem once there's a clear need for it. Most likely I think drivers who both need to adjust computed timings and who need v/hfront/back porch just need to adjust everything on their own. And we won't provide any additional helpers. Cheers, Daniel -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch