Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753317AbdFPJMH (ORCPT ); Fri, 16 Jun 2017 05:12:07 -0400 Received: from mail-ve1eur01on0115.outbound.protection.outlook.com ([104.47.1.115]:19760 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753289AbdFPJMC (ORCPT ); Fri, 16 Jun 2017 05:12:02 -0400 Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=axentia.se; From: Peter Rosin To: linux-kernel@vger.kernel.org Cc: Peter Rosin , Boris Brezillon , David Airlie , Daniel Vetter , Jani Nikula , Sean Paul , dri-devel@lists.freedesktop.org Subject: [RFC PATCH 1/3] atmel-hlcdc: add support for 8-bit color lookup table mode Date: Fri, 16 Jun 2017 11:12:25 +0200 Message-Id: <1497604347-17960-2-git-send-email-peda@axentia.se> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1497604347-17960-1-git-send-email-peda@axentia.se> References: <1497604347-17960-1-git-send-email-peda@axentia.se> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [81.224.171.159] X-ClientProxiedBy: DB6PR1001CA0019.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:4:b7::29) To HE1PR0202MB2554.eurprd02.prod.outlook.com (2603:10a6:3:90::7) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5d3c08ad-06b6-4076-babb-08d4b497be3f X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131423075);SRVR:HE1PR0202MB2554; X-Microsoft-Exchange-Diagnostics: 1;HE1PR0202MB2554;3:WEbjUZSHVP1iWM0xyhznm7kfnbC6DrIs9TF7v5SL87cSOCHBcsPQCGFLZA/dsOIusgibfkgO6rCcyG0+B86SXImGh9Cv/RCOCerWPKAhfVG6rtgHosJCpnD+RFx4KuOjyrS4xsjMP+Ih3Vb0bEdW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+Fyklpx6mYlmvqKKYYLi3trYFl/S5nVwGrCTUBvFV5HdC8StOm4tTGwxKy0wVOpa0KgBzuSqFctKDzIYN4/oJqWsZ8Ncsun0= X-Microsoft-Exchange-Diagnostics: 1;HE1PR0202MB2554;31:75gKRbrGDZktmOWXCjLHltxVWMiRYeGLEEt5qJy8h1hEAARTcEgngwmaSAo66s8kkAeRG4e3+nHEohYUavyBI/61aTkvQgKql+VfnYtwF0pxnKgv5AtDqv+N3cgw4clupsAdZlo7klMYRFBiKpIjvqJ4tg/Xhu28D6TtLQqU69hcG0rVCmi0KjicRA9NFetKlM+Uj1lKY2qN2AFhk2XrjyXYn99NAVrxck7J1ndH70fsJQrrdp1OowkUov9xbVXfOWXhnu0EpbJMZbVZGPbJLSU4HLmossgvDLbBVXSqECILp7rkPe6DieY41dGvB7qPHapCrpO7fy3tUFCI3eoAfqk7J2O8XmGMy+Y6GurnMu5cIiHzXAlP9t+lmYgKUyTGlkm1phkLwnefOkkSMtZGya6O2xSGP60ggbiXzzpyu4+p6i+RtCbjC/icGljb3F0SqLCsncYCZPYREm3HnJyD3pcadVfkeccY5pn+zEuItpNaGGZl4LnWQ/tuS/ydX5huWNkqliwKny4m/DWEH1DOzzibmOzyQmajRu+ABGQZBDwEdzOiLV/V7DjnEGPIOZ54mgxI+UC/A8iGbKyAEDrLIBld96DO0EDWrYppTgaR0Pk= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(100000703101)(100105400095)(10201501046)(6041248)(20161123560025)(20161123558100)(20161123564025)(20161123562025)(20161123555025)(2016111802025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(6043046)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:HE1PR0202MB2554;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:HE1PR0202MB2554; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;HE1PR0202MB2554;4:7LgrIOX6945r1qHNTy/Of9hy91vA8CRNvwIm2UXA?= =?us-ascii?Q?rHhMhLmoaHjQDDQBuV3FHqxa4kdLllniRHiOflpnuadL1+a+bqfB/5Ncrtt5?= =?us-ascii?Q?gsQECNFp4QzD4snUKoH0WmkACjEFk9JnuOCDiCiQi/BvMuVTPCg/BGy3DI3J?= =?us-ascii?Q?qSVHKzN8+jl03tksiQdD8tmcImO/9R1V8Whdz6CsSTCZRinQl3844HJQwr3x?= =?us-ascii?Q?3U74O6vuY5pI+pySshWehpC4QdJjx7ri9GSkBhCdgfuiGgIDNtrBYZtIuBcL?= =?us-ascii?Q?XWe6Q/ni2eGUipGfxf/EFdeJ4jTHU9qlU+VfJCSAwfSr0j+geMhRKWGocon6?= =?us-ascii?Q?iRvclY+BG5tsWw+3uDWv6of4jhq93t1NeMWkAmKYaL0F2QAF1RvuvOSUfh59?= =?us-ascii?Q?3pIswCPwMQ9JrkDWvZcrTu93Z+2UuX0+SUuQAbLIlWFOtaqeDILC7yF/X12O?= =?us-ascii?Q?/Yd9f3wQw5NptIXq7pdrjzA5ZVOZcxPuS7HyTbXmLYdnAz/VEgNaVY1wzS9J?= =?us-ascii?Q?G2lsyr1c1CuWIMvbj4OMzZ4FEIc3WCrAsnz8dNOlTSeJ0tuovoLzxvijEsfp?= =?us-ascii?Q?7bfsf/HjmtsIQYjKiRYujxvZ2Z7OBwEstQmBlvsCNsswY3v9hXKh/QobWHmD?= =?us-ascii?Q?CsyF90CO39+NMAb5WOOMRb94dCktxdUPS6dwLLhqhrdipOYOhrSav0eK+Ae6?= =?us-ascii?Q?pStXlhfn7qM9ZK0DgTAnoR5koRU98SDcrCGQwVIqRAZNFg7haJA8MWou/+is?= =?us-ascii?Q?hzMeuOmKYHBc8urhQ+MxmVdt2TXaNqHuKNxEEWDjmh/70xDQyB5w3hDRTLB2?= =?us-ascii?Q?u7AcvYxjyw9WCEEKfsrUdwCN7c6hk/NYwgH6oM4ut/incbagmMWE2L3mhfbQ?= =?us-ascii?Q?BFxv3gp35cuM/y1+9HPDz/KMCqVQD6slUM8qdTOhnstw5Q47Jeq9xjZb0Yg0?= =?us-ascii?Q?OIWISRuhwvp8ft8zTSIUg7wUrVWeTJ9vm6Pe7XyE0gMV5fZWG33FvAcZiCKW?= =?us-ascii?Q?j6noqRzFCJrky8eLIihNRDm1e9rn7rdAs+I/OcLhu8BpaGVLzwyIjsmvw0Wn?= =?us-ascii?Q?Pk5BdFCAxBKpR+SvG6YM8SKPKK7zJ+S2AkayVVjM1TktznLiS66Az1YiWu1E?= =?us-ascii?Q?eu+BmMNmkpVsbJG9uhuz/TikEugOI9nS5x5HhiL2z3crHsIwxZdibhfOuon8?= =?us-ascii?Q?vMCr8ALYb7RjbWN80+3o7momeV7dgBGwc17s?= X-Forefront-PRVS: 0340850FCD X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(6069001)(39830400002)(39400400002)(39410400002)(189998001)(2950100002)(8676002)(6506006)(2361001)(54906002)(42186005)(6916009)(2351001)(81166006)(5003940100001)(66066001)(7736002)(86362001)(50226002)(2906002)(36756003)(47776003)(5660300001)(478600001)(4326008)(53936002)(305945005)(33646002)(110136004)(6512007)(74482002)(76176999)(50986999)(48376002)(38730400002)(25786009)(6666003)(6116002)(3846002)(50466002)(6486002)(217873001)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:HE1PR0202MB2554;H:localhost.localdomain;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;HE1PR0202MB2554;23:CrVUKgbRDIz2DI6JIXtVhlAKu9tl9hvl2bBoNa0?= =?us-ascii?Q?i6XOQTu9jPK24xWdJsM2ZHEJBaF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zPj8n8S6uKIj9KNXj1/ZlWk2Jtc2les1qekH7kbJUaD127PErNPHJo5b?= =?us-ascii?Q?BWighudvDgEJg2ub4EzzS5YS71wL/3dxPxQxY7f/djdY74mwT3XY8EUBM7WZ?= =?us-ascii?Q?ONlLSmDnTQy8HqTpX2127x2dEmIr0Mt/Ki5rTJsp07e9MHiHedZ+i0SjGYMh?= =?us-ascii?Q?a80jx/BdIuU0=3D?= X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;HE1PR0202MB2554;6:GkNCFUOCGyqRiVzBOLa/Xp6DB2WB7S9NYkAbmKop?= =?us-ascii?Q?xnEM9Dh0GObADXlAF5aAnql1EMOAbUhNaIcPJlo7W58ma3rPCioyciTTmoQt?= =?us-ascii?Q?20bncPEVSpE1pWCs6iNnVV2GQtdzstTq8g/5kVJwESMPxyAqEQeUKZ7O+atD?= =?us-ascii?Q?QXex2ErneIaDnufFrsbPBZVRScLhU55ESQXizjGuwPR99AeoZZk+x8ZKKB+1?= =?us-ascii?Q?Js/lRWfpkou6AFCUqBcYTJjGoXFKJCTJvwErk/KRK9fNXMWTUT6htN6Q8+Sl?= =?us-ascii?Q?PyBzTaJymf3I+vGclWtSSG458jjT9B1cvlDWmnCEBoDmjeDO57TzOQjvuarq?= =?us-ascii?Q?TQhqLgnC2tNWQYKdEFjgLa6NUTSOVLSg+/DDm1hp053leCKk6Y2U1mmccrqr?= =?us-ascii?Q?t2FUrj940L9RErjqv1d6TT6F/pRm8+1t4qT8YVKNrcr80biU60LGx5+LdsGS?= =?us-ascii?Q?dTFvLUkOWEpYpIwICdlTZOYGs8+5owVZswlv44YE2fliOkRE7grxX9N7x0Q6?= =?us-ascii?Q?U/X1sWfK9kfYLVZ9E8YhBEvg9nQL0rFRakkcIfz0wHEdzXbbnGPbU4NQZkll?= =?us-ascii?Q?zM67AEiCD2Bm+eZIO5WXd6nqJcdt0r9hGBERGwf0ejhiI9/xLlUHIHb/ft8q?= =?us-ascii?Q?yrSWinKlaHDF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1xzp9gLc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;HE1PR0202MB2554;7:NyIl2PZoEhJQkv5fs9BeaODdrYD8bX44xZrkmZLXXQr0zhvFj/iWXNmsV+uZL6jZ5ECZKXatGF9BG+ZK3LtDU5obXxXbxGyifOqIVbjjeRlgnE/gGXYQ2S0iTRqhrt03SjqTXHC/XkrFf7lCjzR3EWmwDCpxObKNUthjQ8sQLZEYeWLNtTYm6Pr3SFrSxvwVNC6FNgteLRn9zCTjwMc+B7QoTPtQ1imUIsvsWDoD59WVm9MQ0DMAIsX1afi146JS2dKhvgnH1McVzwSrIZeNjmOzCWpA2ugyUz1kjDBE+k9yWxDJHVI/e6hgXXBKrQc9puIXnHQ3h6feVYv4sbIheOQEbNQninQul4BswhxYnC+xxpatUziRbBjcC/bb9Op0/PLxs50YsjLeGgB1kWChgrrqPC4QngjfncpUMCHIGhU+Kxfj0IYK2MxitCdbwuoEx1T+07RQR3NLwW+v2Jkwrk1WMjrLYUCJnr8iKARbDTfuO3lC8LTq405BxybJJd5IfeQUWj4+W2TyzhSZhex4CVvX6E8JYeX1d9L/Zj3sjS+F+jn7D1opNpAS196xfCjTXJhu1dK2Y3P/+9aXCyzOMZb9uJaddgRhrYF/Q3Y/QUIY6v/SXwB9e9rASjPUyifoXtIwayPFLhS6jlsbxSbXpt4zopnoBG+7PhqDPvqmO3NqGN7dDR3c0gzQysIJNU85s6mOdBVpfOcQos3eJmkdHntqJ2E3bTH5esGaL2J09yvoHPLN/DoAkMMvZ0kZZGcTUP4ILbGjcoWEFMVqRPbOrx1RVpHaFnMStYbQL7uoZtk= X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2017 09:11:57.7129 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0202MB2554 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 8702 Lines: 286 All layers of chips support this, the only variable is the base address of the lookup table in the register map. Signed-off-by: Peter Rosin --- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 48 +++++++++++++++++++++++++ drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 13 +++++++ drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h | 16 +++++++++ drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 5 +++ 4 files changed, 82 insertions(+) diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c index 5348985..75871b5 100644 --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c @@ -61,6 +61,7 @@ struct atmel_hlcdc_crtc { struct atmel_hlcdc_dc *dc; struct drm_pending_vblank_event *event; int id; + u32 clut[ATMEL_HLCDC_CLUT_SIZE]; }; static inline struct atmel_hlcdc_crtc * @@ -140,6 +141,46 @@ static void atmel_hlcdc_crtc_mode_set_nofb(struct drm_crtc *c) cfg); } +static void +atmel_hlcdc_crtc_load_lut(struct drm_crtc *c) +{ + struct atmel_hlcdc_crtc *crtc = drm_crtc_to_atmel_hlcdc_crtc(c); + struct atmel_hlcdc_dc *dc = crtc->dc; + int layer; + int idx; + + for (layer = 0; layer < ATMEL_HLCDC_MAX_LAYERS; layer++) { + if (!dc->layers[layer]) + continue; + for (idx = 0; idx < ATMEL_HLCDC_CLUT_SIZE; idx++) + atmel_hlcdc_layer_write_clut(dc->layers[layer], + idx, crtc->clut[idx]); + } +} + +static void +atmel_hlcdc_crtc_flush_lut(struct drm_crtc *c) +{ + struct atmel_hlcdc_crtc *crtc = drm_crtc_to_atmel_hlcdc_crtc(c); + struct drm_crtc_state *state = c->state; + struct drm_color_lut *lut; + int idx; + + if (!state->gamma_lut) + return; + + lut = (struct drm_color_lut *)state->gamma_lut->data; + + for (idx = 0; idx < ATMEL_HLCDC_CLUT_SIZE; idx++) { + crtc->clut[idx] = + ((lut[idx].red << 8) & 0xff0000) | + (lut[idx].green & 0xff00) | + (lut[idx].blue >> 8); + } + + atmel_hlcdc_crtc_load_lut(c); +} + static enum drm_mode_status atmel_hlcdc_crtc_mode_valid(struct drm_crtc *c, const struct drm_display_mode *mode) @@ -312,6 +353,9 @@ static void atmel_hlcdc_crtc_atomic_flush(struct drm_crtc *crtc, struct drm_crtc_state *old_s) { /* TODO: write common plane control register if available */ + + if (crtc->state->color_mgmt_changed) + atmel_hlcdc_crtc_flush_lut(crtc); } static const struct drm_crtc_helper_funcs lcdc_crtc_helper_funcs = { @@ -429,6 +473,7 @@ static const struct drm_crtc_funcs atmel_hlcdc_crtc_funcs = { .atomic_destroy_state = atmel_hlcdc_crtc_destroy_state, .enable_vblank = atmel_hlcdc_crtc_enable_vblank, .disable_vblank = atmel_hlcdc_crtc_disable_vblank, + .set_property = drm_atomic_helper_crtc_set_property, }; int atmel_hlcdc_crtc_create(struct drm_device *dev) @@ -484,6 +529,9 @@ int atmel_hlcdc_crtc_create(struct drm_device *dev) drm_crtc_helper_add(&crtc->base, &lcdc_crtc_helper_funcs); drm_crtc_vblank_reset(&crtc->base); + drm_mode_crtc_set_gamma_size(&crtc->base, ATMEL_HLCDC_CLUT_SIZE); + drm_crtc_enable_color_mgmt(&crtc->base, 0, false, ATMEL_HLCDC_CLUT_SIZE); + dc->crtc = &crtc->base; return 0; diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c index 30dbffd..4f6ef07 100644 --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c @@ -42,6 +42,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_at91sam9n12_layers[] = { .default_color = 3, .general_config = 4, }, + .clut_offset = 0x400, }, }; @@ -73,6 +74,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_at91sam9x5_layers[] = { .disc_pos = 5, .disc_size = 6, }, + .clut_offset = 0x400, }, { .name = "overlay1", @@ -91,6 +93,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_at91sam9x5_layers[] = { .chroma_key_mask = 8, .general_config = 9, }, + .clut_offset = 0x800, }, { .name = "high-end-overlay", @@ -112,6 +115,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_at91sam9x5_layers[] = { .scaler_config = 13, .csc = 14, }, + .clut_offset = 0x1000, }, { .name = "cursor", @@ -131,6 +135,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_at91sam9x5_layers[] = { .chroma_key_mask = 8, .general_config = 9, }, + .clut_offset = 0x1400, }, }; @@ -162,6 +167,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_sama5d3_layers[] = { .disc_pos = 5, .disc_size = 6, }, + .clut_offset = 0x600, }, { .name = "overlay1", @@ -180,6 +186,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_sama5d3_layers[] = { .chroma_key_mask = 8, .general_config = 9, }, + .clut_offset = 0xa00, }, { .name = "overlay2", @@ -198,6 +205,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_sama5d3_layers[] = { .chroma_key_mask = 8, .general_config = 9, }, + .clut_offset = 0xe00, }, { .name = "high-end-overlay", @@ -223,6 +231,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_sama5d3_layers[] = { }, .csc = 14, }, + .clut_offset = 0x1200, }, { .name = "cursor", @@ -244,6 +253,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_sama5d3_layers[] = { .general_config = 9, .scaler_config = 13, }, + .clut_offset = 0x1600, }, }; @@ -275,6 +285,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_sama5d4_layers[] = { .disc_pos = 5, .disc_size = 6, }, + .clut_offset = 0x600, }, { .name = "overlay1", @@ -293,6 +304,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_sama5d4_layers[] = { .chroma_key_mask = 8, .general_config = 9, }, + .clut_offset = 0xa00, }, { .name = "overlay2", @@ -336,6 +348,7 @@ static const struct atmel_hlcdc_layer_desc atmel_hlcdc_sama5d4_layers[] = { }, .csc = 14, }, + .clut_offset = 0x1200, }, }; diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h index b0596a8..709f7b9 100644 --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h @@ -88,6 +88,11 @@ #define ATMEL_HLCDC_YUV422SWP BIT(17) #define ATMEL_HLCDC_DSCALEOPT BIT(20) +#define ATMEL_HLCDC_C1_MODE ATMEL_HLCDC_CLUT_MODE(0) +#define ATMEL_HLCDC_C2_MODE ATMEL_HLCDC_CLUT_MODE(1) +#define ATMEL_HLCDC_C4_MODE ATMEL_HLCDC_CLUT_MODE(2) +#define ATMEL_HLCDC_C8_MODE ATMEL_HLCDC_CLUT_MODE(3) + #define ATMEL_HLCDC_XRGB4444_MODE ATMEL_HLCDC_RGB_MODE(0) #define ATMEL_HLCDC_ARGB4444_MODE ATMEL_HLCDC_RGB_MODE(1) #define ATMEL_HLCDC_RGBA4444_MODE ATMEL_HLCDC_RGB_MODE(2) @@ -142,6 +147,8 @@ #define ATMEL_HLCDC_DMA_CHANNEL_DSCR_DONE BIT(2) #define ATMEL_HLCDC_DMA_CHANNEL_DSCR_OVERRUN BIT(3) +#define ATMEL_HLCDC_CLUT_SIZE 256 + #define ATMEL_HLCDC_MAX_LAYERS 6 /** @@ -259,6 +266,7 @@ struct atmel_hlcdc_layer_desc { int id; int regs_offset; int cfgs_offset; + int clut_offset; struct atmel_hlcdc_formats *formats; struct atmel_hlcdc_layer_cfg_layout layout; int max_width; @@ -414,6 +422,14 @@ static inline u32 atmel_hlcdc_layer_read_cfg(struct atmel_hlcdc_layer *layer, (cfgid * sizeof(u32))); } +static inline void atmel_hlcdc_layer_write_clut(struct atmel_hlcdc_layer *layer, + unsigned int c, u32 val) +{ + atmel_hlcdc_layer_write_reg(layer, + layer->desc->clut_offset + c * sizeof(u32), + val); +} + static inline void atmel_hlcdc_layer_init(struct atmel_hlcdc_layer *layer, const struct atmel_hlcdc_layer_desc *desc, struct regmap *regmap) diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c index 1124200..5537843 100644 --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c @@ -83,6 +83,7 @@ drm_plane_state_to_atmel_hlcdc_plane_state(struct drm_plane_state *s) #define SUBPIXEL_MASK 0xffff static uint32_t rgb_formats[] = { + DRM_FORMAT_C8, DRM_FORMAT_XRGB4444, DRM_FORMAT_ARGB4444, DRM_FORMAT_RGBA4444, @@ -100,6 +101,7 @@ struct atmel_hlcdc_formats atmel_hlcdc_plane_rgb_formats = { }; static uint32_t rgb_and_yuv_formats[] = { + DRM_FORMAT_C8, DRM_FORMAT_XRGB4444, DRM_FORMAT_ARGB4444, DRM_FORMAT_RGBA4444, @@ -128,6 +130,9 @@ struct atmel_hlcdc_formats atmel_hlcdc_plane_rgb_and_yuv_formats = { static int atmel_hlcdc_format_to_plane_mode(u32 format, u32 *mode) { switch (format) { + case DRM_FORMAT_C8: + *mode = ATMEL_HLCDC_C8_MODE; + break; case DRM_FORMAT_XRGB4444: *mode = ATMEL_HLCDC_XRGB4444_MODE; break; -- 2.1.4