Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp831219ybi; Fri, 21 Jun 2019 08:53:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqyjCn6eGjzM5hQjB9UeDXum7sGXrmMBmf441/B3CffqDIeX/y+iy0s7nNEpBADukctiUhnC X-Received: by 2002:a17:902:a517:: with SMTP id s23mr4326883plq.306.1561132417744; Fri, 21 Jun 2019 08:53:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561132417; cv=none; d=google.com; s=arc-20160816; b=tVXVjnguS6N1r36fU67UW+nWMyEAvb5slkX3RE+VLQxw6P4E1ojdG1D/9VbUuQUX+P dR/ymV/uFRC72SHq5vkZPlHQSqGnWZ/s0ehoTBFDrE+FjsBwKK/KrwVD3dN7VIld9/Yf 3/t/tdDWb9fM1WST80ktjo/NA5u+tt5sa8XCjndi4t9SNSHn03O3y22wknMBXy+1ofKD Qj6WlABqY0ZPz6wznuO/Tto7nXKOv6k76uN/d3OQ2mGr0C9W8GrCashT8nPHsXGTJVNg 670jxN2r9XxJ3twy6XR4JpwQ/TCtsl0DcFSotmVpwc+os4d/FUoejNeyp/9Iaox59bJ7 LG2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:organization:references:in-reply-to:date:cc:to:from :subject:message-id; bh=0a8vObuPTs/SKC3r1z9khjw00FYEG9Bmv/dxdr3u6L8=; b=EedNsDQ7rA2KjAwB63lLEdlJXBremxF0Lh3DX5d1zWuWGiI51Qyb7jVKJTEdFfM3Dq pj2ND5VXCtii/E4hZ+/Cpd4cl+8qzl2/fnt+cWuFEddUo4rixiuKATiU9KSJ5ZAI34xI SM69z9rbtW6FUT/tigH90ygDkHo9XIM57yJIqZgW/qv17mP1gE2EkvfjuGcZxSmgURdr q5NHBwGTcVMLjgfBIvnfJwTD++/MG+JiS83sxk+PSshyxKpecqSQw6ZFQUsNVDPvXgdX Dvxd1Sx2ZvLBxzg/EiJ6GvdYCT5Y78gm1lPILc3l0FONIay04GKBAofam6k8NL/W/KD3 OjHQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y12si2985277pge.187.2019.06.21.08.53.21; Fri, 21 Jun 2019 08:53:37 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726445AbfFUPxD (ORCPT + 99 others); Fri, 21 Jun 2019 11:53:03 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:57358 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726385AbfFUPxD (ORCPT ); Fri, 21 Jun 2019 11:53:03 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id DBBF1270B16 Message-ID: <33068f355edfaabb1c60d5e16a219a058a489531.camel@collabora.com> Subject: Re: [PATCH 2/3] drm/rockchip: Add optional support for CRTC gamma LUT From: Ezequiel Garcia To: Doug Anderson Cc: dri-devel , "open list:ARM/Rockchip SoC..." , Heiko =?ISO-8859-1?Q?St=FCbner?= , Sandy Huang , kernel@collabora.com, Sean Paul , Boris Brezillon , Jacopo Mondi , Ilia Mirkin , Rob Herring , Mark Rutland , devicetree@vger.kernel.org, LKML Date: Fri, 21 Jun 2019 12:52:51 -0300 In-Reply-To: References: <20190618213406.7667-1-ezequiel@collabora.com> <20190618213406.7667-3-ezequiel@collabora.com> Organization: Collabora Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.30.5-1.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2019-06-20 at 10:25 -0700, Doug Anderson wrote: > Hi, > > On Tue, Jun 18, 2019 at 2:43 PM Ezequiel Garcia wrote: > > +static void vop_crtc_gamma_set(struct vop *vop, struct drm_crtc *crtc, > > + struct drm_crtc_state *old_state) > > +{ > > + int idle, ret, i; > > + > > + spin_lock(&vop->reg_lock); > > + VOP_REG_SET(vop, common, dsp_lut_en, 0); > > + vop_cfg_done(vop); > > + spin_unlock(&vop->reg_lock); > > + > > + ret = readx_poll_timeout(vop_dsp_lut_is_enable, vop, > > + idle, !idle, 5, 30 * 1000); > > + if (ret) > > Worth an error message? > Sure. > > > @@ -1205,6 +1294,7 @@ static void vop_crtc_atomic_flush(struct drm_crtc *crtc, > > > > static const struct drm_crtc_helper_funcs vop_crtc_helper_funcs = { > > .mode_fixup = vop_crtc_mode_fixup, > > + .atomic_check = vop_crtc_atomic_check, > > At first I was worried that there was a bug here since in the context > of dw_hdmi (an encoder) adding ".atomic_check" caused ".mode_fixup" to > stop getting called as per mode_fixup() in > "drivers/gpu/drm/drm_atomic_helper.c". > > ...but it seems like it's OK for CRTCs, so I think we're fine. > > > > @@ -1323,6 +1413,7 @@ static const struct drm_crtc_funcs vop_crtc_funcs = { > > .disable_vblank = vop_crtc_disable_vblank, > > .set_crc_source = vop_crtc_set_crc_source, > > .verify_crc_source = vop_crtc_verify_crc_source, > > + .gamma_set = drm_atomic_helper_legacy_gamma_set, > > Are there any issues in adding this ".gamma_set" property even though > we may or may not actually have the ability to set the gamma > (depending on whether or not the LUT register range was provided in > the device tree)? I am a DRM noob but > drm_atomic_helper_legacy_gamma_set() is not a trivial little function > and now we'll be running it in some cases where we don't actually have > gamma. > > I also notice that there's at least one bit of code that seems to > check if ".gamma_set" is NULL. ...and if it is, it'll return -ENOSYS > right away. Do we still properly return -ENOSYS on devices that don't > have the register range? > > It seems like the absolute safest would be to have two copies of this > struct: one used for VOPs that have the range and one for VOPs that > don't. > > ...but possibly I'm just paranoid and as I've said I'm a clueless > noob. If someone says it's fine to always provide the .gamma_set > property that's fine too. > Provided we do the suggestion below (setting gamma_size and enabling color management) when lut_regs is set, then I think we are fine. Before this change: * GAMMA_LUT property doesn't exist, and so can't be set. * DRM_IOCTL_MODE_SETGAMMA (legacy) return ENOSYS. After this change, on platforms that doesn't support this: * GAMMA_LUT property doesn't exist, and so can't be set. * DRM_IOCTL_MODE_SETGAMMA (legacy) return EINVAL. The only difference is the ENOSYS/EINVAL errno, which I doubt will regress anything. I don't think this difference deserves assigning (the legacy) .gamma_set hook conditionally, which would make the implementation too ugly. > > > static void vop_fb_unref_worker(struct drm_flip_work *work, void *val) > > @@ -1480,6 +1571,10 @@ static int vop_create_crtc(struct vop *vop) > > goto err_cleanup_planes; > > > > drm_crtc_helper_add(crtc, &vop_crtc_helper_funcs); > > + if (vop_data->lut_size) { > > + drm_mode_crtc_set_gamma_size(crtc, vop_data->lut_size); > > + drm_crtc_enable_color_mgmt(crtc, 0, false, vop_data->lut_size); > > Should we only do the above calls if we successfully mapped the resources? > Yes, totally. See above. > > > @@ -1776,6 +1871,17 @@ static int vop_bind(struct device *dev, struct device *master, void *data) > > if (IS_ERR(vop->regs)) > > return PTR_ERR(vop->regs); > > > > + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "lut"); > > As per comments in the bindings, shouldn't use the name "lut" but > should just pick resource #1. Yes. Thanks a lot for the review, Ezequiel