Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752409AbcDTCUW (ORCPT ); Tue, 19 Apr 2016 22:20:22 -0400 Received: from regular1.263xmail.com ([211.150.99.132]:50315 "EHLO regular1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750859AbcDTCUU (ORCPT ); Tue, 19 Apr 2016 22:20:20 -0400 X-263anti-spam: BIG:0;ABS:1;DNS:0;ATT:0;SPF:S;KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-ABS-CHECKED: 1 X-SKE-CHECKED: 1 X-ADDR-CHECKED: 0 X-KSVirus-check: 0 X-RL-SENDER: mark.yao@rock-chips.com X-FST-TO: linux-kernel@vger.kernel.org X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: mark.yao@rock-chips.com X-UNIQUE-TAG: <4728c67e7ee098d9cb8df37db574c7f1> X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 Message-ID: <5716E757.8070702@rock-chips.com> Date: Wed, 20 Apr 2016 10:20:07 +0800 From: Mark yao User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0 MIME-Version: 1.0 To: John Keeping CC: David Airlie , Heiko Stuebner , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] drm/rockchip: get rid of rockchip_drm_crtc_mode_config References: <1460948611-32259-1-git-send-email-mark.yao@rock-chips.com> <20160418102538.0ed730ca.john@metanate.com> <57159B37.9050806@rock-chips.com> <20160419100630.06518b63.john@metanate.com> In-Reply-To: <20160419100630.06518b63.john@metanate.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4061 Lines: 116 On 2016年04月19日 17:06, John Keeping wrote: > On Tue, 19 Apr 2016 10:43:03 +0800, Mark yao wrote: > >> On 2016年04月18日 17:25, John Keeping wrote: >>> On Mon, 18 Apr 2016 11:03:31 +0800, Mark Yao wrote: >>> >>>>> We need to take care of the vop status when use >>>>> rockchip_drm_crtc_mode_config, if vop is disabled, >>>>> the function would failed, that is terrible. >>>>> >>>>> Save connector type and output mode on drm_display_mode->private_flags >>>>> at encoder mode_fixup, then we can configure the type and mode safely >>>>> on crtc mode_set. >>> Since Rockchip is atomic, shouldn't this be using atomic_check hooks and >>> a subclassed crtc_state structure? >>> >> I try to use atomic_check with crtc_state, but it seems not easy, >> there are two value need transmit from connector to vop: connector type >> and out_mode >> >> the connector type I think we can loop the atomic state to find the >> connector type. >> but the out_mode is a custom value, I can't find a generic way to >> transmit it with atomic state. >> >> BTW, I think on atomic side, the drm_display_mode is under control by >> atomic state, >> and the mode->private_flags is not use by drm framework, I found i915 >> and gma500 also use >> mode->private_flags to transmit custom value. >> >> So I think it's no problem using mode->private_flags. > The documentation for drm_display_mode::private says: > > It shouldn't be used by atomic drivers since they can store any > additional data by subclassing state structures. > > This applies to private_flags as well. > > I think this means that we should do something like the patch below > (which isn't even compile tested and doesn't cover implementing > drm_encoder_helper_funcs::atomic_check on all of the encoders): > > -- >8 -- > diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h > index 00d17d71aa4c..9d65fa9188f4 100644 > --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h > +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h > @@ -31,6 +31,14 @@ > struct drm_device; > struct drm_connector; > > +struct rockchip_crtc_state { > + struct drm_crtc_state base; > + int output_type; > + int output_mode; > +}; > + > +#define to_rockchip_crtc_state(s) container_of(x, struct rockchip_crtc_state, base) > + > /* > * Rockchip drm private crtc funcs. > * @enable_vblank: enable crtc vblank irq. > diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c > index a619f120f801..5cdf3123e1eb 100644 > --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c > +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c > @@ -1044,13 +1044,34 @@ static void vop_crtc_destroy(struct drm_crtc *crtc) > drm_crtc_cleanup(crtc); > } > > +static struct drm_crtc_state *vop_crtc_duplicate_state(struct drm_crtc *crtc) > +{ > + struct rockchip_crtc_state *rockchip_state; > + > + rockchip_state = kzalloc(sizeof(*rockchip_state), GFP_KERNEL); > + if (!rockchip_state) > + return NULL; > + > + __drm_atomic_helper_crtc_duplicate_state(crtc, &rockchip_state->base); > + return &rockchip_state->base; > +} > + > +static void vop_crtc_destroy_state(struct drm_crtc *crtc, > + struct drm_crtc_state *state) > +{ > + struct rockchip_crtc_state *s = to_rockchip_crtc_state(state); > + > + __drm_atomic_helper_crtc_destroy_state(crtc, &s->base); > + kfree(s); > +} > + > static const struct drm_crtc_funcs vop_crtc_funcs = { > .set_config = drm_atomic_helper_set_config, > .page_flip = drm_atomic_helper_page_flip, > .destroy = vop_crtc_destroy, > .reset = drm_atomic_helper_crtc_reset, > - .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state, > - .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state, > + .atomic_duplicate_state = vop_crtc_duplicate_state, > + .atomic_destroy_state = vop_crtc_destroy_state, > }; > > static bool vop_win_pending_is_complete(struct vop_win *vop_win) > > > Hi John Good, I had implement it according to your advise. Thanks. -- Mark Yao