From: Chris Wilson Subject: Re: [PATCH 4/4] drm/i915: Add support for variable cursor size on 845/865 Date: Wed, 13 Aug 2014 08:05:29 +0100 Message-ID: <20140813070529.GC22250@nuc-i3427.alporthouse.com> References: <1407861595-1228-1-git-send-email-ville.syrjala@linux.intel.com> <1407861595-1228-5-git-send-email-ville.syrjala@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from fireflyinternet.com (mail.fireflyinternet.com [87.106.93.118]) by gabe.freedesktop.org (Postfix) with ESMTP id 12C5389FAC for ; Wed, 13 Aug 2014 00:05:32 -0700 (PDT) Content-Disposition: inline In-Reply-To: <1407861595-1228-5-git-send-email-ville.syrjala@linux.intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: ville.syrjala@linux.intel.com Cc: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org On Tue, Aug 12, 2014 at 07:39:55PM +0300, ville.syrjala@linux.intel.com wrote: > /* Check for which cursor types we support */ > - if (!((width == 64 && height == 64) || > - (width == 128 && height == 128 && !IS_GEN2(dev)) || > - (width == 256 && height == 256 && !IS_GEN2(dev)))) { > - DRM_DEBUG("Cursor dimension not supported\n"); > - return -EINVAL; > + if (IS_845G(dev) || IS_I865G(dev)) { > + if (width == 0 || height == 0 || (width & 63) != 0 || > + width > (IS_845G(dev) ? 64 : 512) || height > 1023) { > + DRM_DEBUG("Cursor dimension not supported\n"); > + return -EINVAL; > + } > + } else { > + if (!((width == 64 && height == 64) || > + (width == 128 && height == 128 && !IS_GEN2(dev)) || > + (width == 256 && height == 256 && !IS_GEN2(dev)))) { > + DRM_DEBUG("Cursor dimension not supported\n"); > + return -EINVAL; Whilst changing this code, could we rewrite this sanely? switch (width | height) { // fails width==0 xor height==0 case 128: case 256: if (!IS_GEN2(dev)) case 64: break; default: DRM_DEBUG("Cursor dimension not supported\n"); return -EINVAL; } Ok, maybe I was having too much fun, but there are simpler ways of writing that predicate. -Chris -- Chris Wilson, Intel Open Source Technology Centre