Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2661595ybp; Thu, 10 Oct 2019 10:37:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqz9lx4pIamZr3g+P2B2SVOJyzQyyv40mHYPlgTArqYlWFoi/tRN1NTK9iwY8GxKDkq8lksZ X-Received: by 2002:a50:e445:: with SMTP id e5mr9139944edm.257.1570729027570; Thu, 10 Oct 2019 10:37:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570729027; cv=none; d=google.com; s=arc-20160816; b=hBFuN0fHO/1K+kwuYsgsWjCLZJYinvM4aN9rh1s3N03M8ZltlK4fmSLJ6Or6IioQrQ IyISw7uvn02yisUK2wikeEm4VLYaR2hyE9+BwdAccooGR1FtxLQznj4LbEm1z43JPBdb uCpx8RSLMbR8pAmN3LlqhHhV1i0hJdjrAWu8n06IV1M7OtFsZRD7OrCIibTVkU1Y+rmL tXOhnSU4dTGHF2TcrKNGFlTbRxQU36IZJL70CmNmpoHIgxyf0tjsGwokXYQlffK4o64C z4aEB+u1NDMIwhftVskMYgBQz9GehuEDHU/1wnq+J93tf6SXV/ER7Z1Ur0EV7AXfZqGG ZfUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=lcjVoxI0/jPjszJjMySETZQKoYIeZrlk5tqidhHPsjI=; b=kW7NgGIzqSPyXh/9isSBug+0KRJtnMr7bdNCcAuBnUmyk0JMs1tflSDXqzumbRBhZk 117ZTMqOB0PR2EhpJgpRoAcXOaNlS7jmBGJj+5qlU8mZZV+mdjSa2uSRl76AXttMIWf8 Af3mnATdX2VHvFDDLROHEQvfZGKpJ+9sd23kJP2heKCGaA8Gs7XAon5YFGxcvarfHLLz pBRV8PLWcBA5q0IegnCIxwmzWDRhXVIpGI3Ak9VHlqsuryBmmSg9RXttvyLGR7k9py/g /K2VpHRSQ4Ndq1HGdE92ZUTeuGcuwAQmwJw1Dbf6QNRFwVthmYoix0eTnuYfpYmq14Bk Bofg== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u1si3543724ejt.143.2019.10.10.10.36.43; Thu, 10 Oct 2019 10:37:07 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726761AbfJJRgN (ORCPT + 99 others); Thu, 10 Oct 2019 13:36:13 -0400 Received: from mga07.intel.com ([134.134.136.100]:11447 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726131AbfJJRgN (ORCPT ); Thu, 10 Oct 2019 13:36:13 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Oct 2019 10:36:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,281,1566889200"; d="scan'208";a="200538447" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.174]) by FMSMGA003.fm.intel.com with SMTP; 10 Oct 2019 10:36:08 -0700 Received: by stinkbox (sSMTP sendmail emulation); Thu, 10 Oct 2019 20:36:07 +0300 Date: Thu, 10 Oct 2019 20:36:07 +0300 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= To: Ilia Mirkin Cc: Sean Paul , Mark Rutland , devicetree , Jacopo Mondi , Rob Herring , Linux Kernel Mailing List , dri-devel , Douglas Anderson , "open list:ARM/Rockchip SoC..." , Boris Brezillon , Sean Paul , Ezequiel Garcia , kernel@collabora.com, Ezequiel Garcia Subject: Re: [PATCH v4 2/3] drm/rockchip: Add optional support for CRTC gamma LUT Message-ID: <20191010173607.GH1208@intel.com> References: <20191008230038.24037-1-ezequiel@collabora.com> <20191008230038.24037-3-ezequiel@collabora.com> <20191009180136.GE85762@art_vandelay> <20191010160059.GJ85762@art_vandelay> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 10, 2019 at 12:23:05PM -0400, Ilia Mirkin wrote: > On Thu, Oct 10, 2019 at 12:01 PM Sean Paul wrote: > > > > > +static int vop_crtc_atomic_check(struct drm_crtc *crtc, > > > > > + struct drm_crtc_state *crtc_state) > > > > > +{ > > > > > + struct vop *vop = to_vop(crtc); > > > > > + > > > > > + if (vop->lut_regs && crtc_state->color_mgmt_changed && > > > > > + crtc_state->gamma_lut) { > > > > > + unsigned int len; > > > > > + > > > > > + len = drm_color_lut_size(crtc_state->gamma_lut); > > > > > + if (len != crtc->gamma_size) { > > > > > + DRM_DEBUG_KMS("Invalid LUT size; got %d, expected %d\n", > > > > > + len, crtc->gamma_size); > > > > > + return -EINVAL; > > > > > + } > > > > > > > > Overflow is avoided in drm_mode_gamma_set_ioctl(), so I don't think you need > > > > this function. > > > > > > > > > > But that only applies to the legacy path. Isn't this needed to ensure > > > a gamma blob > > > has the right size? > > > > Yeah, good point, we check the element size in the atomic path, but not the max > > size. I haven't looked at enough color lut stuff to have an opinion whether this > > check would be useful in a helper function or not, something to consider, I > > suppose. > > Some implementations support multiple sizes (e.g. 256 and 1024) but > not anything in between. It would be difficult to expose this > generically, I would imagine. > The 256 size is kind of special, since > basically all legacy usage assumes that 256 is the one true quantity > of LUT entries... What we do currently in i915 is: crtc->gamma_size = 256 GAMMA_LUT_SIZE = platform specific (256, 129, 257, 2^10, or 2^18+1 (lol)) DEGAMMA_LUT_SIZE = platform specific (0, 33, 65, or 2^10) i915 will accept: - gamma lut of size 256, iff ctm==NULL and degamma==NULL (the so called "legacy gamma" mode) - (de)gamma_lut of size (DE)GAMMA_LUT_SIZE if it passes the checks done by drm_color_lut_check() Ie. just one or two gamma modes per platform is exposed. And that's about all we can do with the current uapi even though our hardware supports many more modes. The resulting precision, interpolation vs. truncation behaviour, and handling of out of gamut values are all totally unspecified and userspace just has to make a guess. We also cheat with the 2^10 sized LUTs a bit due to the hw sharing the same LUT for gamma and degamma, and so if you enable both at the same time we throw away every second entry and each stage only gets a 2^9 entry LUT in the end. Oh and for the 2^18+1 monstrosity we cheat even more and throw away ~99.8% of the entries :( This here was my idea for extending the uapi so that we could expose the full hw capabilities and let userspace decide which mode suits it best without having to guess what it'll get: https://github.com/vsyrjala/linux/commits/gamma_mode_prop Maybe in a few years I'll find time to get back to it... -- Ville Syrj?l? Intel