From patchwork Fri Apr 29 09:29:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kulkarni, Vandita" X-Patchwork-Id: 8979001 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E09989F372 for ; Fri, 29 Apr 2016 09:29:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0E019201FA for ; Fri, 29 Apr 2016 09:29:40 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 2CFF420256 for ; Fri, 29 Apr 2016 09:29:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F2DAC6EE87; Fri, 29 Apr 2016 09:29:34 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTP id 6F5FD6EE87; Fri, 29 Apr 2016 09:29:32 +0000 (UTC) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP; 29 Apr 2016 02:29:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,551,1455004800"; d="scan'208";a="794896318" Received: from vandita-desktop.iind.intel.com ([10.223.26.11]) by orsmga003.jf.intel.com with ESMTP; 29 Apr 2016 02:29:31 -0700 From: Vandita Kulkarni To: intel-gfx@lists.freedesktop.org Date: Fri, 29 Apr 2016 14:59:15 +0530 Message-Id: <1461922157-32553-4-git-send-email-vandita.kulkarni@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1461922157-32553-1-git-send-email-vandita.kulkarni@intel.com> References: <1461922157-32553-1-git-send-email-vandita.kulkarni@intel.com> Cc: corbet@lwn.net, airlied@linux.ie, dri-devel@lists.freedesktop.org, daniel.vetter@intel.com Subject: [Intel-gfx] [PATCHv2 3/5] drm: Introduce DRM_MODE_COLOR() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Damien Lespiau In the hope of expressing colors in the KMS API in a consitant want, let's introduce a ARGB 16161616 color and a few convinience macros around it. Signed-off-by: Damien Lespiau --- include/uapi/drm/drm_mode.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index 7a7856e..203c7ab0 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -295,6 +295,40 @@ struct drm_mode_get_connector { */ #define DRM_MODE_PROP_ATOMIC 0x80000000 +/* Color for the KMS API, ARGB (msb -> lsb) 16bits per component. */ +#define DRM_MODE_COLOR(a, r, b, g) \ + (((__u64)(a) << 48) | ((__u64)(r) << 32) | \ + ((__u64)(g) << 16) | (__u64)(b)) + +/* Extract full precision, 8 bits, 10 bits and 12 bits components. */ +#define DRM_MODE_COLOR_ALPHA(color) (((color) >> 48) & 0xffff) +#define DRM_MODE_COLOR_RED(color) (((color) >> 32) & 0xffff) +#define DRM_MODE_COLOR_BLUE(color) (((color) >> 16) & 0xffff) +#define DRM_MODE_COLOR_GREEN(color) ((color) & 0xffff) +#define DRM_MODE_COLOR_ALPHA_8(color) (((color) >> (48 + 8)) & 0xff) +#define DRM_MODE_COLOR_RED_8(color) (((color) >> (32 + 8)) & 0xff) +#define DRM_MODE_COLOR_BLUE_8(color) (((color) >> (16 + 8)) & 0xff) +#define DRM_MODE_COLOR_GREEN_8(color) (((color) >> 8) & 0xff) +#define DRM_MODE_COLOR_ALPHA_10(color) (((color) >> (48 + 6)) & 0x3ff) +#define DRM_MODE_COLOR_RED_10(color) (((color) >> (32 + 6)) & 0x3ff) +#define DRM_MODE_COLOR_BLUE_10(color) (((color) >> (16 + 6)) & 0x3ff) +#define DRM_MODE_COLOR_GREEN_10(color) (((color) >> 6) & 0x3ff) +#define DRM_MODE_COLOR_ALPHA_12(color) (((color) >> (48 + 4)) & 0xfff) +#define DRM_MODE_COLOR_RED_12(color) (((color) >> (32 + 4)) & 0xfff) +#define DRM_MODE_COLOR_BLUE_12(color) (((color) >> (16 + 4)) & 0xfff) +#define DRM_MODE_COLOR_GREEN_12(color) (((color) >> 4) & 0xfff) + +/* Handy macros to convert a DRM_MODE_COLOR() into common precisions */ +#define DRM_MODE_COLOR_TO_ARGB_8888(color) \ + ((DRM_MODE_COLOR_ALPHA_8(color) << 24) | \ + (DRM_MODE_COLOR_RED_8(color) << 16) | \ + (DRM_MODE_COLOR_GREEN_8(color) << 8) | \ + DRM_MODE_COLOR_BLUE_8(color)) +#define DRM_MODE_COLOR_TO_RGB_101010(color) \ + ((DRM_MODE_COLOR_RED_10(color) << 20) | \ + (DRM_MODE_COLOR_GREEN_10(color) << 10) | \ + DRM_MODE_COLOR_BLUE_10(color)) + struct drm_mode_property_enum { __u64 value; char name[DRM_PROP_NAME_LEN];